aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/DMA-API.txt12
-rw-r--r--Documentation/DocBook/Makefile10
-rw-r--r--Documentation/DocBook/kernel-api.tmpl32
-rw-r--r--Documentation/IPMI.txt34
-rw-r--r--Documentation/block/as-iosched.txt6
-rw-r--r--Documentation/devices.txt102
-rw-r--r--Documentation/filesystems/Locking2
-rw-r--r--Documentation/filesystems/fuse.txt21
-rw-r--r--Documentation/filesystems/sysv-fs.txt177
-rw-r--r--Documentation/kernel-parameters.txt22
-rw-r--r--Documentation/power/s2ram.txt56
-rw-r--r--Documentation/power/swsusp-and-swap-files.txt60
-rw-r--r--Documentation/power/swsusp.txt18
-rw-r--r--Documentation/power/userland-swsusp.txt64
-rw-r--r--MAINTAINERS25
-rw-r--r--README17
-rw-r--r--REPORTING-BUGS4
-rw-r--r--arch/alpha/kernel/pci.c3
-rw-r--r--arch/alpha/kernel/sys_miata.c10
-rw-r--r--arch/alpha/kernel/sys_nautilus.c2
-rw-r--r--arch/alpha/mm/fault.c2
-rw-r--r--arch/arm/common/sharpsl_pm.c22
-rw-r--r--arch/arm/kernel/signal.c1
-rw-r--r--arch/arm/mach-omap1/board-h3.c3
-rw-r--r--arch/arm/mach-omap1/board-nokia770.c6
-rw-r--r--arch/arm/mach-omap1/devices.c2
-rw-r--r--arch/arm/mach-omap1/leds-osk.c4
-rw-r--r--arch/arm/mach-omap2/board-h4.c3
-rw-r--r--arch/arm/mach-pxa/akita-ioexp.c6
-rw-r--r--arch/arm/mach-s3c2410/dma.c4
-rw-r--r--arch/arm/mm/fault.c2
-rw-r--r--arch/arm26/kernel/ecard.c4
-rw-r--r--arch/arm26/mm/fault.c2
-rw-r--r--arch/arm26/mm/memc.c6
-rw-r--r--arch/avr32/kernel/kprobes.c1
-rw-r--r--arch/avr32/kernel/signal.c2
-rw-r--r--arch/avr32/mm/dma-coherent.c2
-rw-r--r--arch/cris/mm/fault.c2
-rw-r--r--arch/frv/kernel/futex.c6
-rw-r--r--arch/frv/kernel/setup.c2
-rw-r--r--arch/frv/kernel/signal.c2
-rw-r--r--arch/frv/mm/fault.c2
-rw-r--r--arch/frv/mm/pgalloc.c6
-rw-r--r--arch/h8300/kernel/setup.c2
-rw-r--r--arch/h8300/kernel/signal.c2
-rw-r--r--arch/i386/kernel/acpi/cstate.c6
-rw-r--r--arch/i386/kernel/cpu/mcheck/non-fatal.c6
-rw-r--r--arch/i386/kernel/cpu/mcheck/therm_throt.c2
-rw-r--r--arch/i386/kernel/cpuid.c2
-rw-r--r--arch/i386/kernel/crash.c66
-rw-r--r--arch/i386/kernel/io_apic.c1
-rw-r--r--arch/i386/kernel/kprobes.c4
-rw-r--r--arch/i386/kernel/microcode.c2
-rw-r--r--arch/i386/kernel/msr.c2
-rw-r--r--arch/i386/kernel/reboot.c1
-rw-r--r--arch/i386/kernel/setup.c3
-rw-r--r--arch/i386/kernel/smp.c4
-rw-r--r--arch/i386/kernel/smpboot.c11
-rw-r--r--arch/i386/kernel/sysenter.c2
-rw-r--r--arch/i386/kernel/traps.c2
-rw-r--r--arch/i386/kernel/tsc.c4
-rw-r--r--arch/i386/mm/highmem.c26
-rw-r--r--arch/i386/mm/hugetlbpage.c112
-rw-r--r--arch/i386/mm/init.c4
-rw-r--r--arch/i386/mm/pgtable.c6
-rw-r--r--arch/i386/power/Makefile2
-rw-r--r--arch/i386/power/suspend.c158
-rw-r--r--arch/i386/power/swsusp.S9
-rw-r--r--arch/ia64/hp/sim/simserial.c4
-rw-r--r--arch/ia64/ia32/binfmt_elf32.c8
-rw-r--r--arch/ia64/ia32/ia32_support.c2
-rw-r--r--arch/ia64/ia32/ia32priv.h2
-rw-r--r--arch/ia64/ia32/sys_ia32.c2
-rw-r--r--arch/ia64/kernel/kprobes.c2
-rw-r--r--arch/ia64/kernel/mca.c8
-rw-r--r--arch/ia64/kernel/palinfo.c2
-rw-r--r--arch/ia64/kernel/perfmon.c2
-rw-r--r--arch/ia64/kernel/salinfo.c2
-rw-r--r--arch/ia64/kernel/smpboot.c12
-rw-r--r--arch/ia64/mm/hugetlbpage.c5
-rw-r--r--arch/ia64/mm/init.c4
-rw-r--r--arch/ia64/pci/pci.c4
-rw-r--r--arch/m32r/kernel/setup.c4
-rw-r--r--arch/m32r/kernel/signal.c2
-rw-r--r--arch/m32r/mm/discontig.c4
-rw-r--r--arch/m68k/amiga/chipram.c3
-rw-r--r--arch/m68k/atari/hades-pci.c3
-rw-r--r--arch/m68k/mm/fault.c2
-rw-r--r--arch/m68knommu/platform/5307/timers.c16
-rw-r--r--arch/m68knommu/platform/68360/config.c2
-rw-r--r--arch/mips/Kconfig9
-rw-r--r--arch/mips/dec/ecc-berr.c1
-rw-r--r--arch/mips/dec/ioasic-irq.c4
-rw-r--r--arch/mips/dec/kn01-berr.c2
-rw-r--r--arch/mips/dec/kn02-irq.c7
-rw-r--r--arch/mips/emma2rh/common/irq_emma2rh.c7
-rw-r--r--arch/mips/emma2rh/markeins/irq_markeins.c7
-rw-r--r--arch/mips/jazz/irq.c7
-rw-r--r--arch/mips/kernel/binfmt_elfn32.c1
-rw-r--r--arch/mips/kernel/binfmt_elfo32.c1
-rw-r--r--arch/mips/kernel/i8259.c162
-rw-r--r--arch/mips/kernel/irixelf.c8
-rw-r--r--arch/mips/kernel/irq-mv6434x.c10
-rw-r--r--arch/mips/kernel/irq-rm7000.c7
-rw-r--r--arch/mips/kernel/irq-rm9000.c8
-rw-r--r--arch/mips/kernel/irq.c2
-rw-r--r--arch/mips/kernel/irq_cpu.c10
-rw-r--r--arch/mips/kernel/kspd.c4
-rw-r--r--arch/mips/lasat/interrupt.c7
-rw-r--r--arch/mips/mm/dma-coherent.c4
-rw-r--r--arch/mips/mm/dma-ip27.c4
-rw-r--r--arch/mips/mm/dma-ip32.c5
-rw-r--r--arch/mips/mm/dma-noncoherent.c5
-rw-r--r--arch/mips/mm/highmem.c10
-rw-r--r--arch/mips/momentum/ocelot_c/cpci-irq.c10
-rw-r--r--arch/mips/momentum/ocelot_c/uart-irq.c10
-rw-r--r--arch/mips/philips/pnx8550/common/int.c8
-rw-r--r--arch/mips/sgi-ip22/ip22-int.c28
-rw-r--r--arch/mips/sgi-ip27/ip27-irq.c8
-rw-r--r--arch/mips/sgi-ip27/ip27-timer.c5
-rw-r--r--arch/mips/tx4927/common/tx4927_irq.c26
-rw-r--r--arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c21
-rw-r--r--arch/mips/tx4938/common/irq.c20
-rw-r--r--arch/mips/tx4938/toshiba_rbtx4938/irq.c10
-rw-r--r--arch/mips/vr41xx/Kconfig5
-rw-r--r--arch/mips/vr41xx/common/icu.c14
-rw-r--r--arch/parisc/kernel/binfmt_elf32.c1
-rw-r--r--arch/parisc/mm/fault.c2
-rw-r--r--arch/powerpc/kernel/crash.c59
-rw-r--r--arch/powerpc/kernel/kprobes.c2
-rw-r--r--arch/powerpc/kernel/rtas_flash.c4
-rw-r--r--arch/powerpc/kernel/signal_32.c2
-rw-r--r--arch/powerpc/kernel/vdso.c2
-rw-r--r--arch/powerpc/mm/hugetlbpage.c7
-rw-r--r--arch/powerpc/mm/init_64.c6
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c6
-rw-r--r--arch/powerpc/platforms/embedded6xx/ls_uart.c4
-rw-r--r--arch/powerpc/platforms/powermac/backlight.c12
-rw-r--r--arch/powerpc/platforms/pseries/eeh_event.c6
-rw-r--r--arch/ppc/8260_io/fcc_enet.c21
-rw-r--r--arch/ppc/8xx_io/fec.c21
-rw-r--r--arch/s390/appldata/appldata_base.c8
-rw-r--r--arch/s390/kernel/binfmt_elf32.c1
-rw-r--r--arch/s390/kernel/kprobes.c2
-rw-r--r--arch/s390/lib/uaccess_std.c6
-rw-r--r--arch/sh/Kconfig100
-rw-r--r--arch/sh/Kconfig.debug22
-rw-r--r--arch/sh/Makefile26
-rw-r--r--arch/sh/boards/renesas/r7780rp/Makefile4
-rw-r--r--arch/sh/boards/renesas/r7780rp/irq.c1
-rw-r--r--arch/sh/boards/renesas/r7780rp/psw.c122
-rw-r--r--arch/sh/boards/renesas/r7780rp/setup.c29
-rw-r--r--arch/sh/boards/se/7206/Makefile7
-rw-r--r--arch/sh/boards/se/7206/io.c123
-rw-r--r--arch/sh/boards/se/7206/irq.c139
-rw-r--r--arch/sh/boards/se/7206/led.c57
-rw-r--r--arch/sh/boards/se/7206/setup.c79
-rw-r--r--arch/sh/boards/se/7619/Makefile5
-rw-r--r--arch/sh/boards/se/7619/io.c102
-rw-r--r--arch/sh/boards/se/7619/setup.c43
-rw-r--r--arch/sh/boards/titan/setup.c27
-rw-r--r--arch/sh/boot/compressed/misc.c3
-rw-r--r--arch/sh/configs/r7780rp_defconfig69
-rw-r--r--arch/sh/configs/se7206_defconfig826
-rw-r--r--arch/sh/drivers/Kconfig9
-rw-r--r--arch/sh/drivers/Makefile2
-rw-r--r--arch/sh/drivers/dma/Makefile4
-rw-r--r--arch/sh/drivers/dma/dma-api.c274
-rw-r--r--arch/sh/drivers/dma/dma-sh.c9
-rw-r--r--arch/sh/drivers/dma/dma-sysfs.c23
-rw-r--r--arch/sh/drivers/pci/ops-titan.c24
-rw-r--r--arch/sh/drivers/pci/pci-sh7780.c14
-rw-r--r--arch/sh/drivers/push-switch.c138
-rw-r--r--arch/sh/kernel/Makefile3
-rw-r--r--arch/sh/kernel/cpu/Makefile11
-rw-r--r--arch/sh/kernel/cpu/clock.c27
-rw-r--r--arch/sh/kernel/cpu/init.c2
-rw-r--r--arch/sh/kernel/cpu/irq/Makefile3
-rw-r--r--arch/sh/kernel/cpu/irq/imask.c5
-rw-r--r--arch/sh/kernel/cpu/irq/intc2.c25
-rw-r--r--arch/sh/kernel/cpu/irq/ipr.c93
-rw-r--r--arch/sh/kernel/cpu/sh2/Makefile3
-rw-r--r--arch/sh/kernel/cpu/sh2/clock-sh7619.c81
-rw-r--r--arch/sh/kernel/cpu/sh2/entry.S341
-rw-r--r--arch/sh/kernel/cpu/sh2/ex.S46
-rw-r--r--arch/sh/kernel/cpu/sh2/probe.c16
-rw-r--r--arch/sh/kernel/cpu/sh2/setup-sh7619.c53
-rw-r--r--arch/sh/kernel/cpu/sh2a/Makefile10
-rw-r--r--arch/sh/kernel/cpu/sh2a/clock-sh7206.c85
-rw-r--r--arch/sh/kernel/cpu/sh2a/probe.c39
-rw-r--r--arch/sh/kernel/cpu/sh2a/setup-sh7206.c58
-rw-r--r--arch/sh/kernel/cpu/sh3/Makefile2
-rw-r--r--arch/sh/kernel/cpu/sh3/clock-sh7709.c2
-rw-r--r--arch/sh/kernel/cpu/sh3/entry.S (renamed from arch/sh/kernel/entry.S)546
-rw-r--r--arch/sh/kernel/cpu/sh4/Makefile3
-rw-r--r--arch/sh/kernel/cpu/sh4/clock-sh4-202.c4
-rw-r--r--arch/sh/kernel/cpu/sh4/clock-sh7780.c2
-rw-r--r--arch/sh/kernel/cpu/sh4/fpu.c25
-rw-r--r--arch/sh/kernel/cpu/sh4/probe.c19
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh7750.c70
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh7780.c36
-rw-r--r--arch/sh/kernel/cpu/sh4/sq.c13
-rw-r--r--arch/sh/kernel/early_printk.c44
-rw-r--r--arch/sh/kernel/entry-common.S433
-rw-r--r--arch/sh/kernel/head.S17
-rw-r--r--arch/sh/kernel/irq.c55
-rw-r--r--arch/sh/kernel/process.c32
-rw-r--r--arch/sh/kernel/relocate_kernel.S14
-rw-r--r--arch/sh/kernel/setup.c5
-rw-r--r--arch/sh/kernel/sh_ksyms.c6
-rw-r--r--arch/sh/kernel/signal.c37
-rw-r--r--arch/sh/kernel/stacktrace.c43
-rw-r--r--arch/sh/kernel/sys_sh.c7
-rw-r--r--arch/sh/kernel/time.c139
-rw-r--r--arch/sh/kernel/timers/Makefile2
-rw-r--r--arch/sh/kernel/timers/timer-cmt.c196
-rw-r--r--arch/sh/kernel/timers/timer-mtu2.c200
-rw-r--r--arch/sh/kernel/timers/timer-tmu.c13
-rw-r--r--arch/sh/kernel/timers/timer.c6
-rw-r--r--arch/sh/kernel/traps.c200
-rw-r--r--arch/sh/kernel/vsyscall/vsyscall.c2
-rw-r--r--arch/sh/mm/Kconfig77
-rw-r--r--arch/sh/mm/cache-sh2.c69
-rw-r--r--arch/sh/mm/cache-sh4.c18
-rw-r--r--arch/sh/mm/clear_page.S18
-rw-r--r--arch/sh/mm/copy_page.S16
-rw-r--r--arch/sh/mm/fault.c161
-rw-r--r--arch/sh/mm/hugetlbpage.c5
-rw-r--r--arch/sh/mm/init.c45
-rw-r--r--arch/sh/mm/ioremap.c4
-rw-r--r--arch/sh/mm/pg-dma.c2
-rw-r--r--arch/sh/mm/pg-sh4.c35
-rw-r--r--arch/sh/mm/pmb.c6
-rw-r--r--arch/sh/tools/mach-types2
-rw-r--r--arch/sh64/kernel/setup.c4
-rw-r--r--arch/sh64/kernel/signal.c2
-rw-r--r--arch/sh64/mm/fault.c2
-rw-r--r--arch/sh64/mm/hugetlbpage.c5
-rw-r--r--arch/sparc/mm/highmem.c8
-rw-r--r--arch/sparc64/kernel/binfmt_elf32.c1
-rw-r--r--arch/sparc64/mm/hugetlbpage.c5
-rw-r--r--arch/sparc64/mm/init.c4
-rw-r--r--arch/sparc64/mm/tsb.c2
-rw-r--r--arch/um/drivers/chan_kern.c2
-rw-r--r--arch/um/drivers/daemon_kern.c2
-rw-r--r--arch/um/drivers/line.c6
-rw-r--r--arch/um/drivers/mcast_kern.c2
-rw-r--r--arch/um/drivers/mconsole_kern.c4
-rw-r--r--arch/um/drivers/net_kern.c1
-rw-r--r--arch/um/drivers/pcap_kern.c2
-rw-r--r--arch/um/drivers/port_kern.c4
-rw-r--r--arch/um/drivers/slip_kern.c2
-rw-r--r--arch/um/drivers/slirp_kern.c2
-rw-r--r--arch/um/include/chan_kern.h2
-rw-r--r--arch/um/include/line.h2
-rw-r--r--arch/um/include/sysdep-i386/ptrace.h2
-rw-r--r--arch/um/include/sysdep-i386/stub.h1
-rw-r--r--arch/um/include/sysdep-x86_64/ptrace.h2
-rw-r--r--arch/um/os-Linux/drivers/ethertap_kern.c2
-rw-r--r--arch/um/os-Linux/drivers/tuntap_kern.c2
-rw-r--r--arch/um/sys-i386/ldt.c1
-rw-r--r--arch/um/sys-i386/ptrace_user.c2
-rw-r--r--arch/um/sys-i386/user-offsets.c2
-rw-r--r--arch/x86_64/ia32/ia32_binfmt.c4
-rw-r--r--arch/x86_64/ia32/syscall32.c2
-rw-r--r--arch/x86_64/kernel/crash.c69
-rw-r--r--arch/x86_64/kernel/kprobes.c2
-rw-r--r--arch/x86_64/kernel/mce.c8
-rw-r--r--arch/x86_64/kernel/mce_amd.c4
-rw-r--r--arch/x86_64/kernel/setup.c3
-rw-r--r--arch/x86_64/kernel/smp.c4
-rw-r--r--arch/x86_64/kernel/smpboot.c12
-rw-r--r--arch/x86_64/kernel/time.c4
-rw-r--r--arch/x86_64/kernel/vsyscall.c3
-rw-r--r--block/as-iosched.c7
-rw-r--r--block/blktrace.c3
-rw-r--r--block/cfq-iosched.c12
-rw-r--r--block/ll_rw_blk.c18
-rw-r--r--crypto/cryptomgr.c7
-rw-r--r--drivers/acpi/osl.c25
-rw-r--r--drivers/ata/libata-core.c25
-rw-r--r--drivers/ata/libata-eh.c2
-rw-r--r--drivers/ata/libata-scsi.c14
-rw-r--r--drivers/ata/libata.h4
-rw-r--r--drivers/atm/he.c6
-rw-r--r--drivers/atm/idt77252.c9
-rw-r--r--drivers/base/core.c1
-rw-r--r--drivers/base/dmapool.c4
-rw-r--r--drivers/base/memory.c34
-rw-r--r--drivers/base/topology.c2
-rw-r--r--drivers/block/DAC960.c4
-rw-r--r--drivers/block/Kconfig3
-rw-r--r--drivers/block/aoe/aoe.h2
-rw-r--r--drivers/block/aoe/aoeblk.c2
-rw-r--r--drivers/block/aoe/aoecmd.c4
-rw-r--r--drivers/block/aoe/aoedev.c2
-rw-r--r--drivers/block/cciss.c332
-rw-r--r--drivers/block/cciss.h6
-rw-r--r--drivers/block/cciss_cmd.h3
-rw-r--r--drivers/block/floppy.c10
-rw-r--r--drivers/block/nbd.c16
-rw-r--r--drivers/block/paride/aten.c4
-rw-r--r--drivers/block/paride/bpck.c4
-rw-r--r--drivers/block/paride/bpck6.c17
-rw-r--r--drivers/block/paride/comm.c4
-rw-r--r--drivers/block/paride/dstr.c4
-rw-r--r--drivers/block/paride/epat.c4
-rw-r--r--drivers/block/paride/epia.c4
-rw-r--r--drivers/block/paride/fit2.c4
-rw-r--r--drivers/block/paride/fit3.c4
-rw-r--r--drivers/block/paride/friq.c4
-rw-r--r--drivers/block/paride/frpw.c4
-rw-r--r--drivers/block/paride/jumbo70
-rw-r--r--drivers/block/paride/kbic.c14
-rw-r--r--drivers/block/paride/ktti.c4
-rw-r--r--drivers/block/paride/on20.c4
-rw-r--r--drivers/block/paride/on26.c4
-rw-r--r--drivers/block/paride/paride.c47
-rw-r--r--drivers/block/paride/paride.h4
-rw-r--r--drivers/block/paride/pcd.c8
-rw-r--r--drivers/block/paride/pd.c8
-rw-r--r--drivers/block/paride/pf.c8
-rw-r--r--drivers/block/paride/pg.c4
-rw-r--r--drivers/block/paride/pseudo.h10
-rw-r--r--drivers/block/paride/pt.c4
-rw-r--r--drivers/block/pktcdvd.c2
-rw-r--r--drivers/block/sx8.c7
-rw-r--r--drivers/block/ub.c8
-rw-r--r--drivers/bluetooth/bcm203x.c7
-rw-r--r--drivers/bluetooth/hci_bcsp.c4
-rw-r--r--drivers/cdrom/optcd.c2
-rw-r--r--drivers/cdrom/sbpcd.c5
-rw-r--r--drivers/char/agp/amd64-agp.c2
-rw-r--r--drivers/char/cyclades.c9
-rw-r--r--drivers/char/decserial.c38
-rw-r--r--drivers/char/drm/drm_sman.c1
-rw-r--r--drivers/char/drm/drm_vm.c8
-rw-r--r--drivers/char/drm/via_dmablit.c6
-rw-r--r--drivers/char/epca.c8
-rw-r--r--drivers/char/esp.c14
-rw-r--r--drivers/char/genrtc.c4
-rw-r--r--drivers/char/hvc_console.c1
-rw-r--r--drivers/char/hvcs.c426
-rw-r--r--drivers/char/hvsi.c16
-rw-r--r--drivers/char/hw_random/Kconfig19
-rw-r--r--drivers/char/hw_random/Makefile3
-rw-r--r--drivers/char/ip2/i2cmd.h5
-rw-r--r--drivers/char/ip2/i2lib.c13
-rw-r--r--drivers/char/ip2/ip2main.c23
-rw-r--r--drivers/char/ipmi/ipmi_bt_sm.c641
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c25
-rw-r--r--drivers/char/ipmi/ipmi_kcs_sm.c18
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c724
-rw-r--r--drivers/char/ipmi/ipmi_poweroff.c114
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c376
-rw-r--r--drivers/char/ipmi/ipmi_smic_sm.c14
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c121
-rw-r--r--drivers/char/isicom.c12
-rw-r--r--drivers/char/istallion.c12
-rw-r--r--drivers/char/misc.c2
-rw-r--r--drivers/char/mmtimer.c23
-rw-r--r--drivers/char/moxa.c13
-rw-r--r--drivers/char/mxser.c9
-rw-r--r--drivers/char/pcmcia/synclink_cs.c34
-rw-r--r--drivers/char/random.c6
-rw-r--r--drivers/char/rio/rio_linux.c8
-rw-r--r--drivers/char/riscom8.c17
-rw-r--r--drivers/char/serial167.c6
-rw-r--r--drivers/char/sonypi.c4
-rw-r--r--drivers/char/specialix.c14
-rw-r--r--drivers/char/stallion.c10
-rw-r--r--drivers/char/synclink.c35
-rw-r--r--drivers/char/synclink_gt.c37
-rw-r--r--drivers/char/synclinkmp.c34
-rw-r--r--drivers/char/sysrq.c18
-rw-r--r--drivers/char/toshiba.c1
-rw-r--r--drivers/char/tpm/tpm.c7
-rw-r--r--drivers/char/tty_io.c31
-rw-r--r--drivers/char/vt.c22
-rw-r--r--drivers/char/watchdog/pcwd_usb.c2
-rw-r--r--drivers/connector/cn_queue.c8
-rw-r--r--drivers/connector/connector.c31
-rw-r--r--drivers/cpufreq/cpufreq.c12
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c7
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c28
-rw-r--r--drivers/dma/ioatdma.c4
-rw-r--r--drivers/edac/edac_mc.c1
-rw-r--r--drivers/i2c/chips/ds1374.c12
-rw-r--r--drivers/i2c/chips/m41t00.c9
-rw-r--r--drivers/ide/Kconfig16
-rw-r--r--drivers/ide/ide.c19
-rw-r--r--drivers/ide/pci/via82cxxx.c21
-rw-r--r--drivers/ieee1394/eth1394.c2
-rw-r--r--drivers/ieee1394/hosts.c11
-rw-r--r--drivers/ieee1394/hosts.h2
-rw-r--r--drivers/ieee1394/nodemgr.c1
-rw-r--r--drivers/ieee1394/ohci1394.c8
-rw-r--r--drivers/ieee1394/pcilynx.c2
-rw-r--r--drivers/ieee1394/raw1394.c40
-rw-r--r--drivers/ieee1394/sbp2.c28
-rw-r--r--drivers/ieee1394/sbp2.h2
-rw-r--r--drivers/infiniband/core/addr.c6
-rw-r--r--drivers/infiniband/core/cache.c7
-rw-r--r--drivers/infiniband/core/cm.c19
-rw-r--r--drivers/infiniband/core/cma.c10
-rw-r--r--drivers/infiniband/core/iwcm.c6
-rw-r--r--drivers/infiniband/core/mad.c25
-rw-r--r--drivers/infiniband/core/mad_priv.h2
-rw-r--r--drivers/infiniband/core/mad_rmpp.c18
-rw-r--r--drivers/infiniband/core/sa_query.c10
-rw-r--r--drivers/infiniband/core/uverbs_mem.c7
-rw-r--r--drivers/infiniband/hw/amso1100/c2_vq.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_av.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_cq.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_main.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_mrmw.c4
-rw-r--r--drivers/infiniband/hw/ehca/ehca_pd.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_qp.c2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_user_pages.c7
-rw-r--r--drivers/infiniband/hw/mthca/mthca_av.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_catas.c4
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h16
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c25
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c10
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c22
-rw-r--r--drivers/infiniband/ulp/iser/iser_verbs.c10
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c7
-rw-r--r--drivers/input/gameport/gameport.c1
-rw-r--r--drivers/input/keyboard/atkbd.c6
-rw-r--r--drivers/input/keyboard/lkkbd.c6
-rw-r--r--drivers/input/keyboard/sunkbd.c6
-rw-r--r--drivers/input/misc/hp_sdc_rtc.c4
-rw-r--r--drivers/input/mouse/psmouse-base.c7
-rw-r--r--drivers/input/serio/libps2.c6
-rw-r--r--drivers/input/serio/serio.c1
-rw-r--r--drivers/input/touchscreen/ads7846.c2
-rw-r--r--drivers/isdn/act2000/capi.c4
-rw-r--r--drivers/isdn/act2000/capi.h2
-rw-r--r--drivers/isdn/act2000/module.c18
-rw-r--r--drivers/isdn/capi/kcapi.c14
-rw-r--r--drivers/isdn/gigaset/bas-gigaset.c34
-rw-r--r--drivers/isdn/gigaset/usb-gigaset.c12
-rw-r--r--drivers/isdn/hisax/amd7930_fn.c7
-rw-r--r--drivers/isdn/hisax/config.c9
-rw-r--r--drivers/isdn/hisax/hfc4s8s_l1.c5
-rw-r--r--drivers/isdn/hisax/hfc_2bds0.c9
-rw-r--r--drivers/isdn/hisax/hfc_pci.c6
-rw-r--r--drivers/isdn/hisax/hfc_sx.c6
-rw-r--r--drivers/isdn/hisax/icc.c6
-rw-r--r--drivers/isdn/hisax/isac.c6
-rw-r--r--drivers/isdn/hisax/isar.c6
-rw-r--r--drivers/isdn/hisax/isdnhdlc.h8
-rw-r--r--drivers/isdn/hisax/isdnl1.c6
-rw-r--r--drivers/isdn/hisax/w6692.c6
-rw-r--r--drivers/isdn/hysdn/boardergo.c5
-rw-r--r--drivers/isdn/i4l/isdn_net.c6
-rw-r--r--drivers/isdn/pcbit/drv.c4
-rw-r--r--drivers/isdn/pcbit/layer2.c6
-rw-r--r--drivers/isdn/pcbit/pcbit.h2
-rw-r--r--drivers/leds/Kconfig6
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/leds-wrap.c142
-rw-r--r--drivers/macintosh/adb.c4
-rw-r--r--drivers/macintosh/apm_emu.c3
-rw-r--r--drivers/macintosh/rack-meter.c16
-rw-r--r--drivers/macintosh/smu.c4
-rw-r--r--drivers/macintosh/therm_adt746x.c1
-rw-r--r--drivers/macintosh/via-pmu.c2
-rw-r--r--drivers/macintosh/windfarm_core.c1
-rw-r--r--drivers/md/dm-crypt.c10
-rw-r--r--drivers/md/dm-mpath.c20
-rw-r--r--drivers/md/dm-raid1.c4
-rw-r--r--drivers/md/dm-snap.c15
-rw-r--r--drivers/md/dm.c4
-rw-r--r--drivers/md/kcopyd.c6
-rw-r--r--drivers/md/md.c2
-rw-r--r--drivers/md/raid5.c4
-rw-r--r--drivers/media/dvb/b2c2/flexcop-pci.c9
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c20
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c2
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c19
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-remote.c7
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb.h2
-rw-r--r--drivers/media/dvb/dvb-usb/usb-urb.c2
-rw-r--r--drivers/media/dvb/frontends/l64781.c2
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c2
-rw-r--r--drivers/media/radio/Kconfig32
-rw-r--r--drivers/media/video/cpia_pp.c20
-rw-r--r--drivers/media/video/cx88/cx88-input.c6
-rw-r--r--drivers/media/video/ir-kbd-i2c.c6
-rw-r--r--drivers/media/video/msp3400-driver.c2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-context.c13
-rw-r--r--drivers/media/video/saa6588.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c9
-rw-r--r--drivers/media/video/tvaudio.c1
-rw-r--r--drivers/media/video/video-buf-dvb.c2
-rw-r--r--drivers/media/video/vivi.c1
-rw-r--r--drivers/message/fusion/mptbase.c255
-rw-r--r--drivers/message/fusion/mptfc.c19
-rw-r--r--drivers/message/fusion/mptlan.c29
-rw-r--r--drivers/message/fusion/mptsas.c25
-rw-r--r--drivers/message/fusion/mptscsih.c24
-rw-r--r--drivers/message/fusion/mptspi.c18
-rw-r--r--drivers/message/i2o/bus-osm.c3
-rw-r--r--drivers/message/i2o/device.c27
-rw-r--r--drivers/message/i2o/driver.c22
-rw-r--r--drivers/message/i2o/exec-osm.c23
-rw-r--r--drivers/message/i2o/i2o_block.c30
-rw-r--r--drivers/message/i2o/i2o_block.h4
-rw-r--r--drivers/message/i2o/i2o_config.c8
-rw-r--r--drivers/message/i2o/i2o_proc.c2
-rw-r--r--drivers/message/i2o/i2o_scsi.c23
-rw-r--r--drivers/message/i2o/pci.c5
-rw-r--r--drivers/mfd/ucb1x00-ts.c2
-rw-r--r--drivers/misc/tifm_7xx1.c18
-rw-r--r--drivers/misc/tifm_core.c5
-rw-r--r--drivers/mmc/mmc.c14
-rw-r--r--drivers/mmc/mmc.h2
-rw-r--r--drivers/mmc/mmc_sysfs.c10
-rw-r--r--drivers/mmc/tifm_sd.c28
-rw-r--r--drivers/mtd/devices/m25p80.c2
-rw-r--r--drivers/net/8139too.c26
-rw-r--r--drivers/net/bnx2.c6
-rw-r--r--drivers/net/cassini.c6
-rw-r--r--drivers/net/chelsio/common.h2
-rw-r--r--drivers/net/chelsio/cphy.h2
-rw-r--r--drivers/net/chelsio/cxgb2.c16
-rw-r--r--drivers/net/chelsio/my3126.c8
-rw-r--r--drivers/net/e100.c8
-rw-r--r--drivers/net/e1000/e1000_main.c10
-rw-r--r--drivers/net/ehea/ehea_main.c9
-rw-r--r--drivers/net/hamradio/baycom_epp.c14
-rw-r--r--drivers/net/hamradio/dmascc.c8
-rw-r--r--drivers/net/irda/mcs7780.c6
-rw-r--r--drivers/net/irda/sir-dev.h2
-rw-r--r--drivers/net/irda/sir_dev.c8
-rw-r--r--drivers/net/irda/stir4200.c1
-rw-r--r--drivers/net/iseries_veth.c12
-rw-r--r--drivers/net/ixgb/ixgb_main.c10
-rw-r--r--drivers/net/lasi_82596.c94
-rw-r--r--drivers/net/mv643xx_eth.c9
-rw-r--r--drivers/net/myri10ge/myri10ge.c7
-rw-r--r--drivers/net/netxen/netxen_nic.h3
-rw-r--r--drivers/net/netxen/netxen_nic_init.c5
-rw-r--r--drivers/net/netxen/netxen_nic_main.c19
-rw-r--r--drivers/net/ns83820.c10
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c12
-rw-r--r--drivers/net/phy/phy.c9
-rw-r--r--drivers/net/plip.c38
-rw-r--r--drivers/net/qla3xxx.c20
-rw-r--r--drivers/net/qla3xxx.h4
-rw-r--r--drivers/net/r8169.c23
-rw-r--r--drivers/net/s2io.c16
-rw-r--r--drivers/net/s2io.h2
-rw-r--r--drivers/net/sis190.c13
-rw-r--r--drivers/net/skge.c15
-rw-r--r--drivers/net/skge.h2
-rw-r--r--drivers/net/smc91x.c15
-rw-r--r--drivers/net/spider_net.c9
-rw-r--r--drivers/net/sungem.c6
-rw-r--r--drivers/net/tg3.c6
-rw-r--r--drivers/net/tlan.c23
-rw-r--r--drivers/net/tlan.h1
-rw-r--r--drivers/net/tulip/21142.c7
-rw-r--r--drivers/net/tulip/timer.c7
-rw-r--r--drivers/net/tulip/tulip.h7
-rw-r--r--drivers/net/tulip/tulip_core.c3
-rw-r--r--drivers/net/wan/pc300_tty.c23
-rw-r--r--drivers/net/wireless/airo.c1
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx.h2
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c20
-rw-r--r--drivers/net/wireless/hostap/hostap.h2
-rw-r--r--drivers/net/wireless/hostap/hostap_ap.c19
-rw-r--r--drivers/net/wireless/hostap/hostap_hw.c21
-rw-r--r--drivers/net/wireless/hostap/hostap_info.c6
-rw-r--r--drivers/net/wireless/hostap/hostap_main.c8
-rw-r--r--drivers/net/wireless/ipw2100.c47
-rw-r--r--drivers/net/wireless/ipw2100.h10
-rw-r--r--drivers/net/wireless/ipw2200.c227
-rw-r--r--drivers/net/wireless/ipw2200.h16
-rw-r--r--drivers/net/wireless/orinoco.c28
-rw-r--r--drivers/net/wireless/prism54/isl_ioctl.c8
-rw-r--r--drivers/net/wireless/prism54/isl_ioctl.h4
-rw-r--r--drivers/net/wireless/prism54/islpci_dev.c5
-rw-r--r--drivers/net/wireless/prism54/islpci_eth.c4
-rw-r--r--drivers/net/wireless/prism54/islpci_eth.h2
-rw-r--r--drivers/net/wireless/prism54/islpci_mgt.c2
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c30
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.h6
-rw-r--r--drivers/oprofile/cpu_buffer.c9
-rw-r--r--drivers/oprofile/cpu_buffer.h2
-rw-r--r--drivers/parport/parport_pc.c12
-rw-r--r--drivers/pci/hotplug/shpchp.h4
-rw-r--r--drivers/pci/hotplug/shpchp_core.c2
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c19
-rw-r--r--drivers/pci/msi.c2
-rw-r--r--drivers/pci/pcie/aer/aerdrv.c2
-rw-r--r--drivers/pci/pcie/aer/aerdrv.h2
-rw-r--r--drivers/pci/pcie/aer/aerdrv_core.c8
-rw-r--r--drivers/pci/probe.c1
-rw-r--r--drivers/pcmcia/cs.c1
-rw-r--r--drivers/pcmcia/ds.c7
-rw-r--r--drivers/pnp/card.c30
-rw-r--r--drivers/pnp/interface.c17
-rw-r--r--drivers/pnp/pnpbios/core.c1
-rw-r--r--drivers/rtc/Kconfig12
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/rtc-dev.c7
-rw-r--r--drivers/rtc/rtc-ds1672.c9
-rw-r--r--drivers/rtc/rtc-ds1742.c67
-rw-r--r--drivers/rtc/rtc-omap.c572
-rw-r--r--drivers/rtc/rtc-rs5c372.c90
-rw-r--r--drivers/rtc/rtc-test.c9
-rw-r--r--drivers/rtc/rtc-x1205.c12
-rw-r--r--drivers/s390/block/dasd.c10
-rw-r--r--drivers/s390/block/dasd_devmap.c2
-rw-r--r--drivers/s390/block/dasd_eckd.c2
-rw-r--r--drivers/s390/block/dasd_fba.c2
-rw-r--r--drivers/s390/block/dasd_int.h2
-rw-r--r--drivers/s390/cio/css.c9
-rw-r--r--drivers/s390/crypto/ap_bus.c6
-rw-r--r--drivers/s390/net/lcs.c8
-rw-r--r--drivers/s390/net/qeth_main.c6
-rw-r--r--drivers/s390/scsi/zfcp_def.h6
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c2
-rw-r--r--drivers/scsi/53c700.c82
-rw-r--r--drivers/scsi/53c700.h16
-rw-r--r--drivers/scsi/NCR5380.c11
-rw-r--r--drivers/scsi/NCR5380.h4
-rw-r--r--drivers/scsi/aha152x.c4
-rw-r--r--drivers/scsi/aic94xx/aic94xx.h4
-rw-r--r--drivers/scsi/aic94xx/aic94xx_hwi.c2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_init.c4
-rw-r--r--drivers/scsi/aic94xx/aic94xx_scb.c9
-rw-r--r--drivers/scsi/ibmvscsi/ibmvstgt.c10
-rw-r--r--drivers/scsi/ide-scsi.c6
-rw-r--r--drivers/scsi/imm.c12
-rw-r--r--drivers/scsi/ipr.c11
-rw-r--r--drivers/scsi/libiscsi.c7
-rw-r--r--drivers/scsi/libsas/sas_discover.c22
-rw-r--r--drivers/scsi/libsas/sas_event.c14
-rw-r--r--drivers/scsi/libsas/sas_init.c8
-rw-r--r--drivers/scsi/libsas/sas_internal.h12
-rw-r--r--drivers/scsi/libsas/sas_phy.c45
-rw-r--r--drivers/scsi/libsas/sas_port.c30
-rw-r--r--drivers/scsi/libsas/sas_scsi_host.c4
-rw-r--r--drivers/scsi/oktagon_esp.c6
-rw-r--r--drivers/scsi/ppa.c12
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c2
-rw-r--r--drivers/scsi/qla4xxx/ql4_os.c9
-rw-r--r--drivers/scsi/scsi.c2
-rw-r--r--drivers/scsi/scsi_lib.c4
-rw-r--r--drivers/scsi/scsi_scan.c7
-rw-r--r--drivers/scsi/scsi_sysfs.c10
-rw-r--r--drivers/scsi/scsi_tgt_lib.c17
-rw-r--r--drivers/scsi/scsi_transport_fc.c60
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c8
-rw-r--r--drivers/scsi/scsi_transport_spi.c7
-rw-r--r--drivers/serial/8250_exar_st16c554.c52
-rw-r--r--drivers/serial/8250_pnp.c29
-rw-r--r--drivers/serial/Kconfig30
-rw-r--r--drivers/serial/Makefile2
-rw-r--r--drivers/serial/amba-pl010.c2
-rw-r--r--drivers/serial/dz.c371
-rw-r--r--drivers/serial/dz.h32
-rw-r--r--drivers/serial/mcfserial.c54
-rw-r--r--drivers/serial/mpsc.c22
-rw-r--r--drivers/serial/sh-sci.c6
-rw-r--r--drivers/serial/sh-sci.h37
-rw-r--r--drivers/serial/uartlite.c505
-rw-r--r--drivers/spi/pxa2xx_spi.c9
-rw-r--r--drivers/spi/spi.c25
-rw-r--r--drivers/spi/spi_bitbang.c9
-rw-r--r--drivers/spi/spi_butterfly.c2
-rw-r--r--drivers/usb/atm/cxacru.c12
-rw-r--r--drivers/usb/atm/speedtch.c15
-rw-r--r--drivers/usb/atm/ueagle-atm.c8
-rw-r--r--drivers/usb/class/cdc-acm.c6
-rw-r--r--drivers/usb/core/buffer.c2
-rw-r--r--drivers/usb/core/hub.c27
-rw-r--r--drivers/usb/core/message.c9
-rw-r--r--drivers/usb/core/usb.c9
-rw-r--r--drivers/usb/gadget/ether.c6
-rw-r--r--drivers/usb/gadget/file_storage.c2
-rw-r--r--drivers/usb/gadget/gmidi.c2
-rw-r--r--drivers/usb/gadget/goku_udc.c2
-rw-r--r--drivers/usb/gadget/inode.c6
-rw-r--r--drivers/usb/gadget/net2280.c2
-rw-r--r--drivers/usb/gadget/omap_udc.c2
-rw-r--r--drivers/usb/gadget/zero.c2
-rw-r--r--drivers/usb/host/ehci-dbg.c2
-rw-r--r--drivers/usb/host/hc_crisv10.c16
-rw-r--r--drivers/usb/host/ohci-dbg.c2
-rw-r--r--drivers/usb/host/ohci-pnx4008.c2
-rw-r--r--drivers/usb/host/u132-hcd.c62
-rw-r--r--drivers/usb/host/uhci-hcd.c2
-rw-r--r--drivers/usb/host/uhci-q.c2
-rw-r--r--drivers/usb/input/acecad.c2
-rw-r--r--drivers/usb/input/aiptek.c2
-rw-r--r--drivers/usb/input/ati_remote.c6
-rw-r--r--drivers/usb/input/hid-core.c17
-rw-r--r--drivers/usb/input/keyspan_remote.c2
-rw-r--r--drivers/usb/input/mtouchusb.c2
-rw-r--r--drivers/usb/input/powermate.c4
-rw-r--r--drivers/usb/input/touchkitusb.c2
-rw-r--r--drivers/usb/input/usbkbd.c8
-rw-r--r--drivers/usb/input/usbmouse.c4
-rw-r--r--drivers/usb/input/usbtouchscreen.c2
-rw-r--r--drivers/usb/input/xpad.c2
-rw-r--r--drivers/usb/input/yealink.c6
-rw-r--r--drivers/usb/misc/appledisplay.c11
-rw-r--r--drivers/usb/misc/ftdi-elan.c86
-rw-r--r--drivers/usb/misc/phidgetkit.c25
-rw-r--r--drivers/usb/misc/phidgetmotorcontrol.c15
-rw-r--r--drivers/usb/misc/usbtest.c36
-rw-r--r--drivers/usb/mon/mon_text.c10
-rw-r--r--drivers/usb/net/catc.c2
-rw-r--r--drivers/usb/net/kaweth.c9
-rw-r--r--drivers/usb/net/net1080.c2
-rw-r--r--drivers/usb/net/pegasus.c8
-rw-r--r--drivers/usb/net/pegasus.h2
-rw-r--r--drivers/usb/net/rndis_host.c2
-rw-r--r--drivers/usb/net/rtl8150.c2
-rw-r--r--drivers/usb/net/usbnet.c11
-rw-r--r--drivers/usb/serial/aircable.c13
-rw-r--r--drivers/usb/serial/digi_acceleport.c14
-rw-r--r--drivers/usb/serial/ftdi_sio.c19
-rw-r--r--drivers/usb/serial/keyspan_pda.c22
-rw-r--r--drivers/usb/serial/mos7720.c2
-rw-r--r--drivers/usb/serial/mos7840.c4
-rw-r--r--drivers/usb/serial/usb-serial.c7
-rw-r--r--drivers/usb/serial/whiteheat.c15
-rw-r--r--drivers/usb/storage/onetouch.c4
-rw-r--r--drivers/usb/storage/transport.c2
-rw-r--r--drivers/usb/storage/usb.c2
-rw-r--r--drivers/video/console/fbcon.c6
-rw-r--r--drivers/video/geode/gxfb_core.c2
-rw-r--r--drivers/video/pxafb.c7
-rw-r--r--drivers/w1/Makefile4
-rw-r--r--drivers/w1/slaves/Makefile4
-rw-r--r--drivers/w1/slaves/w1_ds2433.c30
-rw-r--r--drivers/w1/w1.c1
-rw-r--r--fs/9p/mux.c16
-rw-r--r--fs/9p/vfs_inode.c4
-rw-r--r--fs/adfs/super.c8
-rw-r--r--fs/affs/amigaffs.c4
-rw-r--r--fs/affs/bitmap.c3
-rw-r--r--fs/affs/super.c6
-rw-r--r--fs/afs/kafsasyncd.c1
-rw-r--r--fs/afs/kafstimod.c1
-rw-r--r--fs/afs/server.c3
-rw-r--r--fs/afs/super.c12
-rw-r--r--fs/aio.c36
-rw-r--r--fs/autofs/inode.c7
-rw-r--r--fs/autofs4/inode.c7
-rw-r--r--fs/befs/linuxvfs.c6
-rw-r--r--fs/bfs/inode.c6
-rw-r--r--fs/binfmt_elf.c26
-rw-r--r--fs/binfmt_elf_fdpic.c3
-rw-r--r--fs/bio.c10
-rw-r--r--fs/block_dev.c6
-rw-r--r--fs/buffer.c6
-rw-r--r--fs/cifs/cifsfs.c17
-rw-r--r--fs/cifs/connect.c1
-rw-r--r--fs/cifs/misc.c4
-rw-r--r--fs/cifs/transport.c6
-rw-r--r--fs/coda/inode.c6
-rw-r--r--fs/compat.c37
-rw-r--r--fs/compat_ioctl.c33
-rw-r--r--fs/configfs/configfs_internal.h2
-rw-r--r--fs/configfs/mount.c2
-rw-r--r--fs/cramfs/inode.c2
-rw-r--r--fs/dcache.c22
-rw-r--r--fs/dcookies.c2
-rw-r--r--fs/dlm/memory.c2
-rw-r--r--fs/dnotify.c4
-rw-r--r--fs/dquot.c4
-rw-r--r--fs/ecryptfs/crypto.c6
-rw-r--r--fs/ecryptfs/file.c2
-rw-r--r--fs/ecryptfs/inode.c6
-rw-r--r--fs/ecryptfs/keystore.c2
-rw-r--r--fs/ecryptfs/main.c8
-rw-r--r--fs/ecryptfs/super.c2
-rw-r--r--fs/efs/super.c6
-rw-r--r--fs/eventpoll.c8
-rw-r--r--fs/exec.c5
-rw-r--r--fs/ext2/ioctl.c6
-rw-r--r--fs/ext2/super.c24
-rw-r--r--fs/ext2/xattr.c5
-rw-r--r--fs/ext3/Makefile2
-rw-r--r--fs/ext3/balloc.c31
-rw-r--r--fs/ext3/dir.c3
-rw-r--r--fs/ext3/ext3_jbd.c59
-rw-r--r--fs/ext3/inode.c85
-rw-r--r--fs/ext3/namei.c9
-rw-r--r--fs/ext3/super.c17
-rw-r--r--fs/ext3/xattr.c5
-rw-r--r--fs/ext4/Makefile3
-rw-r--r--fs/ext4/balloc.c31
-rw-r--r--fs/ext4/dir.c3
-rw-r--r--fs/ext4/ext4_jbd2.c59
-rw-r--r--fs/ext4/extents.c110
-rw-r--r--fs/ext4/inode.c85
-rw-r--r--fs/ext4/namei.c9
-rw-r--r--fs/ext4/super.c17
-rw-r--r--fs/ext4/xattr.c5
-rw-r--r--fs/fat/cache.c6
-rw-r--r--fs/fat/inode.c6
-rw-r--r--fs/fcntl.c4
-rw-r--r--fs/file.c35
-rw-r--r--fs/freevxfs/vxfs_inode.c6
-rw-r--r--fs/fuse/dev.c4
-rw-r--r--fs/fuse/dir.c5
-rw-r--r--fs/fuse/file.c37
-rw-r--r--fs/fuse/fuse_i.h9
-rw-r--r--fs/fuse/inode.c123
-rw-r--r--fs/gfs2/glock.c8
-rw-r--r--fs/gfs2/main.c4
-rw-r--r--fs/gfs2/util.c6
-rw-r--r--fs/gfs2/util.h6
-rw-r--r--fs/hfs/super.c6
-rw-r--r--fs/hfsplus/super.c6
-rw-r--r--fs/hpfs/dir.c10
-rw-r--r--fs/hpfs/dnode.c13
-rw-r--r--fs/hpfs/ea.c5
-rw-r--r--fs/hpfs/hpfs_fn.h3
-rw-r--r--fs/hpfs/inode.c5
-rw-r--r--fs/hpfs/map.c20
-rw-r--r--fs/hpfs/super.c29
-rw-r--r--fs/hugetlbfs/inode.c6
-rw-r--r--fs/inode.c9
-rw-r--r--fs/inotify_user.c4
-rw-r--r--fs/isofs/inode.c6
-rw-r--r--fs/jbd/journal.c8
-rw-r--r--fs/jbd/revoke.c4
-rw-r--r--fs/jbd/transaction.c4
-rw-r--r--fs/jbd2/commit.c8
-rw-r--r--fs/jbd2/journal.c8
-rw-r--r--fs/jbd2/revoke.c4
-rw-r--r--fs/jbd2/transaction.c2
-rw-r--r--fs/jffs/inode-v23.c4
-rw-r--r--fs/jffs/intrep.c4
-rw-r--r--fs/jffs/jffs_fm.c4
-rw-r--r--fs/jffs2/background.c1
-rw-r--r--fs/jffs2/malloc.c18
-rw-r--r--fs/jffs2/super.c6
-rw-r--r--fs/jfs/jfs_logmgr.c2
-rw-r--r--fs/jfs/jfs_metapage.c4
-rw-r--r--fs/jfs/jfs_txnmgr.c2
-rw-r--r--fs/jfs/super.c6
-rw-r--r--fs/lockd/clntproc.c1
-rw-r--r--fs/lockd/host.c53
-rw-r--r--fs/locks.c6
-rw-r--r--fs/mbcache.c2
-rw-r--r--fs/minix/inode.c6
-rw-r--r--fs/namei.c9
-rw-r--r--fs/namespace.c2
-rw-r--r--fs/ncpfs/inode.c14
-rw-r--r--fs/ncpfs/sock.c20
-rw-r--r--fs/nfs/client.c2
-rw-r--r--fs/nfs/direct.c4
-rw-r--r--fs/nfs/inode.c6
-rw-r--r--fs/nfs/namespace.c8
-rw-r--r--fs/nfs/nfs4_fs.h2
-rw-r--r--fs/nfs/nfs4renewd.c5
-rw-r--r--fs/nfs/pagelist.c4
-rw-r--r--fs/nfs/read.c4
-rw-r--r--fs/nfs/write.c6
-rw-r--r--fs/nfsd/nfs3xdr.c24
-rw-r--r--fs/nfsd/nfs4state.c17
-rw-r--r--fs/nfsd/nfsxdr.c13
-rw-r--r--fs/nls/nls_cp936.c113
-rw-r--r--fs/ntfs/attrib.c2
-rw-r--r--fs/ntfs/index.c2
-rw-r--r--fs/ntfs/inode.c4
-rw-r--r--fs/ntfs/unistr.c2
-rw-r--r--fs/ocfs2/alloc.c9
-rw-r--r--fs/ocfs2/cluster/heartbeat.c10
-rw-r--r--fs/ocfs2/cluster/quorum.c4
-rw-r--r--fs/ocfs2/cluster/tcp.c78
-rw-r--r--fs/ocfs2/cluster/tcp_internal.h8
-rw-r--r--fs/ocfs2/dlm/dlmcommon.h2
-rw-r--r--fs/ocfs2/dlm/dlmdomain.c2
-rw-r--r--fs/ocfs2/dlm/dlmfs.c6
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c2
-rw-r--r--fs/ocfs2/dlm/dlmrecovery.c5
-rw-r--r--fs/ocfs2/dlm/userdlm.c10
-rw-r--r--fs/ocfs2/extent_map.c2
-rw-r--r--fs/ocfs2/inode.h2
-rw-r--r--fs/ocfs2/journal.c7
-rw-r--r--fs/ocfs2/journal.h2
-rw-r--r--fs/ocfs2/ocfs2.h2
-rw-r--r--fs/ocfs2/super.c12
-rw-r--r--fs/ocfs2/uptodate.c2
-rw-r--r--fs/openpromfs/inode.c6
-rw-r--r--fs/partitions/amiga.c2
-rw-r--r--fs/partitions/atari.c2
-rw-r--r--fs/partitions/check.c19
-rw-r--r--fs/partitions/ibm.c29
-rw-r--r--fs/pipe.c22
-rw-r--r--fs/proc/Makefile3
-rw-r--r--fs/proc/base.c11
-rw-r--r--fs/proc/inode.c6
-rw-r--r--fs/proc/kcore.c16
-rw-r--r--fs/proc/proc_misc.c2
-rw-r--r--fs/qnx4/inode.c6
-rw-r--r--fs/reiserfs/file.c61
-rw-r--r--fs/reiserfs/inode.c10
-rw-r--r--fs/reiserfs/journal.c12
-rw-r--r--fs/reiserfs/super.c9
-rw-r--r--fs/romfs/inode.c6
-rw-r--r--fs/seq_file.c4
-rw-r--r--fs/smbfs/inode.c6
-rw-r--r--fs/smbfs/request.c4
-rw-r--r--fs/stat.c7
-rw-r--r--fs/sysfs/mount.c2
-rw-r--r--fs/sysfs/sysfs.h2
-rw-r--r--fs/sysv/CHANGES60
-rw-r--r--fs/sysv/ChangeLog106
-rw-r--r--fs/sysv/INTRO182
-rw-r--r--fs/sysv/inode.c6
-rw-r--r--fs/udf/super.c10
-rw-r--r--fs/ufs/super.c12
-rw-r--r--fs/ufs/util.h2
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c21
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c14
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c1
-rw-r--r--include/acpi/platform/aclinux.h2
-rw-r--r--include/asm-alpha/dma-mapping.h4
-rw-r--r--include/asm-alpha/unistd.h182
-rw-r--r--include/asm-arm/arch-omap/irda.h2
-rw-r--r--include/asm-arm/dma-mapping.h2
-rw-r--r--include/asm-arm/setup.h104
-rw-r--r--include/asm-arm/unistd.h150
-rw-r--r--include/asm-arm26/pgalloc.h2
-rw-r--r--include/asm-arm26/setup.h4
-rw-r--r--include/asm-arm26/unistd.h133
-rw-r--r--include/asm-avr32/dma-mapping.h5
-rw-r--r--include/asm-avr32/setup.h4
-rw-r--r--include/asm-cris/arch-v10/bitops.h10
-rw-r--r--include/asm-cris/dma-mapping.h4
-rw-r--r--include/asm-cris/semaphore-helper.h8
-rw-r--r--include/asm-frv/dma-mapping.h4
-rw-r--r--include/asm-frv/highmem.h5
-rw-r--r--include/asm-frv/param.h1
-rw-r--r--include/asm-frv/setup.h6
-rw-r--r--include/asm-frv/unistd.h119
-rw-r--r--include/asm-generic/Kbuild1
-rw-r--r--include/asm-generic/Kbuild.asm1
-rw-r--r--include/asm-generic/atomic.h7
-rw-r--r--include/asm-generic/dma-mapping.h4
-rw-r--r--include/asm-generic/futex.h4
-rw-r--r--include/asm-h8300/delay.h4
-rw-r--r--include/asm-h8300/mmu_context.h4
-rw-r--r--include/asm-h8300/pci.h4
-rw-r--r--include/asm-h8300/tlbflush.h4
-rw-r--r--include/asm-h8300/unistd.h166
-rw-r--r--include/asm-i386/Kbuild1
-rw-r--r--include/asm-i386/atomic.h2
-rw-r--r--include/asm-i386/dma-mapping.h4
-rw-r--r--include/asm-i386/futex.h4
-rw-r--r--include/asm-i386/mmzone.h27
-rw-r--r--include/asm-i386/param.h1
-rw-r--r--include/asm-i386/pgtable.h10
-rw-r--r--include/asm-i386/rwsem.h4
-rw-r--r--include/asm-i386/setup.h6
-rw-r--r--include/asm-i386/spinlock_types.h4
-rw-r--r--include/asm-i386/suspend.h13
-rw-r--r--include/asm-i386/unistd.h98
-rw-r--r--include/asm-ia64/Kbuild1
-rw-r--r--include/asm-ia64/dma-mapping.h5
-rw-r--r--include/asm-ia64/futex.h4
-rw-r--r--include/asm-ia64/pgalloc.h2
-rw-r--r--include/asm-m32r/setup.h9
-rw-r--r--include/asm-m32r/unistd.h111
-rw-r--r--include/asm-m68k/dma-mapping.h4
-rw-r--r--include/asm-m68k/setup.h6
-rw-r--r--include/asm-m68k/unistd.h97
-rw-r--r--include/asm-m68knommu/irq.h1
-rw-r--r--include/asm-m68knommu/rtc.h1
-rw-r--r--include/asm-m68knommu/setup.h5
-rw-r--r--include/asm-m68knommu/ucontext.h6
-rw-r--r--include/asm-m68knommu/unistd.h150
-rw-r--r--include/asm-mips/dma-mapping.h4
-rw-r--r--include/asm-mips/futex.h4
-rw-r--r--include/asm-mips/highmem.h10
-rw-r--r--include/asm-mips/i8259.h37
-rw-r--r--include/asm-mips/pgtable-32.h6
-rw-r--r--include/asm-mips/pgtable-64.h4
-rw-r--r--include/asm-mips/setup.h2
-rw-r--r--include/asm-mips/unistd.h262
-rw-r--r--include/asm-parisc/dma-mapping.h4
-rw-r--r--include/asm-parisc/futex.h4
-rw-r--r--include/asm-powerpc/dma-mapping.h6
-rw-r--r--include/asm-powerpc/elf.h2
-rw-r--r--include/asm-powerpc/futex.h4
-rw-r--r--include/asm-powerpc/pgalloc.h2
-rw-r--r--include/asm-powerpc/setup.h3
-rw-r--r--include/asm-powerpc/unistd.h109
-rw-r--r--include/asm-ppc/highmem.h8
-rw-r--r--include/asm-s390/setup.h3
-rw-r--r--include/asm-s390/unistd.h154
-rw-r--r--include/asm-sh/atomic.h48
-rw-r--r--include/asm-sh/bugs.h8
-rw-r--r--include/asm-sh/clock.h12
-rw-r--r--include/asm-sh/cpu-sh2/cache.h22
-rw-r--r--include/asm-sh/cpu-sh2/freq.h18
-rw-r--r--include/asm-sh/cpu-sh2/mmu_context.h16
-rw-r--r--include/asm-sh/cpu-sh2/timer.h6
-rw-r--r--include/asm-sh/cpu-sh2a/addrspace.h1
-rw-r--r--include/asm-sh/cpu-sh2a/cache.h39
-rw-r--r--include/asm-sh/cpu-sh2a/cacheflush.h1
-rw-r--r--include/asm-sh/cpu-sh2a/dma.h1
-rw-r--r--include/asm-sh/cpu-sh2a/freq.h18
-rw-r--r--include/asm-sh/cpu-sh2a/mmu_context.h1
-rw-r--r--include/asm-sh/cpu-sh2a/timer.h1
-rw-r--r--include/asm-sh/cpu-sh2a/ubc.h1
-rw-r--r--include/asm-sh/cpu-sh2a/watchdog.h1
-rw-r--r--include/asm-sh/dma-mapping.h2
-rw-r--r--include/asm-sh/dma.h40
-rw-r--r--include/asm-sh/elf.h2
-rw-r--r--include/asm-sh/entry-macros.S33
-rw-r--r--include/asm-sh/irq-sh73180.h314
-rw-r--r--include/asm-sh/irq-sh7343.h317
-rw-r--r--include/asm-sh/irq-sh7780.h311
-rw-r--r--include/asm-sh/irq.h620
-rw-r--r--include/asm-sh/irqflags.h123
-rw-r--r--include/asm-sh/mmu_context.h44
-rw-r--r--include/asm-sh/page.h35
-rw-r--r--include/asm-sh/pgalloc.h20
-rw-r--r--include/asm-sh/pgtable-2level.h70
-rw-r--r--include/asm-sh/pgtable.h371
-rw-r--r--include/asm-sh/processor.h24
-rw-r--r--include/asm-sh/push-switch.h28
-rw-r--r--include/asm-sh/rwsem.h27
-rw-r--r--include/asm-sh/se7206.h13
-rw-r--r--include/asm-sh/setup.h6
-rw-r--r--include/asm-sh/system.h101
-rw-r--r--include/asm-sh/thread_info.h8
-rw-r--r--include/asm-sh/timer.h23
-rw-r--r--include/asm-sh/titan.h32
-rw-r--r--include/asm-sh/unistd.h119
-rw-r--r--include/asm-sh64/dma-mapping.h2
-rw-r--r--include/asm-sh64/setup.h6
-rw-r--r--include/asm-sh64/unistd.h142
-rw-r--r--include/asm-sparc/unistd.h130
-rw-r--r--include/asm-sparc64/dma-mapping.h4
-rw-r--r--include/asm-sparc64/futex.h4
-rw-r--r--include/asm-sparc64/pgalloc.h2
-rw-r--r--include/asm-sparc64/unistd.h118
-rw-r--r--include/asm-um/dma-mapping.h4
-rw-r--r--include/asm-v850/irq.h2
-rw-r--r--include/asm-v850/unistd.h160
-rw-r--r--include/asm-x86_64/Kbuild1
-rw-r--r--include/asm-x86_64/atomic.h2
-rw-r--r--include/asm-x86_64/dma-mapping.h5
-rw-r--r--include/asm-x86_64/futex.h4
-rw-r--r--include/asm-x86_64/smp.h7
-rw-r--r--include/asm-x86_64/spinlock_types.h4
-rw-r--r--include/asm-x86_64/unistd.h99
-rw-r--r--include/asm-xtensa/dma-mapping.h4
-rw-r--r--include/asm-xtensa/unistd.h184
-rw-r--r--include/linux/Kbuild3
-rw-r--r--include/linux/aio.h4
-rw-r--r--include/linux/bootmem.h3
-rw-r--r--include/linux/bottom_half.h10
-rw-r--r--include/linux/carta_random32.h29
-rw-r--r--include/linux/cciss_ioctl.h2
-rw-r--r--include/linux/cdev.h4
-rw-r--r--include/linux/connector.h4
-rw-r--r--include/linux/cpu.h29
-rw-r--r--include/linux/cpuset.h4
-rw-r--r--include/linux/debug_locks.h2
-rw-r--r--include/linux/delayacct.h2
-rw-r--r--include/linux/device.h22
-rw-r--r--include/linux/elf.h4
-rw-r--r--include/linux/ext3_jbd.h76
-rw-r--r--include/linux/ext4_jbd2.h76
-rw-r--r--include/linux/file.h4
-rw-r--r--include/linux/freezer.h87
-rw-r--r--include/linux/fs.h20
-rw-r--r--include/linux/fs_struct.h2
-rw-r--r--include/linux/fuse.h24
-rw-r--r--include/linux/gfp.h3
-rw-r--r--include/linux/highmem.h8
-rw-r--r--include/linux/hugetlb.h1
-rw-r--r--include/linux/i2o.h22
-rw-r--r--include/linux/init_task.h2
-rw-r--r--include/linux/interrupt.h7
-rw-r--r--include/linux/ipmi.h45
-rw-r--r--include/linux/ipmi_msgdefs.h13
-rw-r--r--include/linux/ipmi_smi.h8
-rw-r--r--include/linux/jbd.h3
-rw-r--r--include/linux/jbd2.h3
-rw-r--r--include/linux/kbd_kern.h2
-rw-r--r--include/linux/kexec.h1
-rw-r--r--include/linux/kprobes.h2
-rw-r--r--include/linux/ktime.h4
-rw-r--r--include/linux/libata.h7
-rw-r--r--include/linux/lockd/lockd.h2
-rw-r--r--include/linux/lockdep.h11
-rw-r--r--include/linux/mm.h81
-rw-r--r--include/linux/mmc/host.h2
-rw-r--r--include/linux/mmzone.h87
-rw-r--r--include/linux/moduleparam.h3
-rw-r--r--include/linux/msg.h6
-rw-r--r--include/linux/mutex.h2
-rw-r--r--include/linux/nbd.h1
-rw-r--r--include/linux/ncp_fs_sb.h8
-rw-r--r--include/linux/netpoll.h2
-rw-r--r--include/linux/nfs_fs_sb.h2
-rw-r--r--include/linux/pci_ids.h6
-rw-r--r--include/linux/profile.h24
-rw-r--r--include/linux/quotaops.h3
-rw-r--r--include/linux/radix-tree.h101
-rw-r--r--include/linux/raid/raid5.h2
-rw-r--r--include/linux/reiserfs_fs.h2
-rw-r--r--include/linux/reiserfs_fs_sb.h3
-rw-r--r--include/linux/relay.h4
-rw-r--r--include/linux/rmap.h4
-rw-r--r--include/linux/rtmutex.h2
-rw-r--r--include/linux/rwsem-spinlock.h3
-rw-r--r--include/linux/sched.h111
-rw-r--r--include/linux/seq_file.h4
-rw-r--r--include/linux/serial_8250.h1
-rw-r--r--include/linux/serial_core.h2
-rw-r--r--include/linux/signal.h2
-rw-r--r--include/linux/skbuff.h8
-rw-r--r--include/linux/slab.h92
-rw-r--r--include/linux/smp.h7
-rw-r--r--include/linux/spinlock.h1
-rw-r--r--include/linux/sunrpc/rpc_pipe_fs.h2
-rw-r--r--include/linux/sunrpc/sched.h4
-rw-r--r--include/linux/sunrpc/xprt.h2
-rw-r--r--include/linux/suspend.h9
-rw-r--r--include/linux/swap.h6
-rw-r--r--include/linux/taskstats_kern.h43
-rw-r--r--include/linux/tty.h2
-rw-r--r--include/linux/uaccess.h49
-rw-r--r--include/linux/usb.h2
-rw-r--r--include/linux/workqueue.h153
-rw-r--r--include/net/dst.h2
-rw-r--r--include/net/ieee80211softmac.h4
-rw-r--r--include/net/inet_hashtables.h6
-rw-r--r--include/net/inet_timewait_sock.h2
-rw-r--r--include/net/neighbour.h2
-rw-r--r--include/net/netfilter/nf_conntrack_expect.h2
-rw-r--r--include/net/request_sock.h4
-rw-r--r--include/net/sctp/structs.h2
-rw-r--r--include/net/sock.h21
-rw-r--r--include/net/timewait_sock.h2
-rw-r--r--include/scsi/libsas.h29
-rw-r--r--include/scsi/scsi_transport_fc.h4
-rw-r--r--include/scsi/scsi_transport_iscsi.h2
-rw-r--r--include/sound/ac97_codec.h2
-rw-r--r--include/sound/ak4114.h2
-rw-r--r--init/do_mounts_initrd.c1
-rw-r--r--init/initramfs.c4
-rw-r--r--init/main.c4
-rw-r--r--ipc/compat.c23
-rw-r--r--ipc/mqueue.c6
-rw-r--r--ipc/msg.c44
-rw-r--r--ipc/sem.c3
-rw-r--r--ipc/util.c7
-rw-r--r--kernel/Kconfig.hz20
-rw-r--r--kernel/acct.c3
-rw-r--r--kernel/audit.c1
-rw-r--r--kernel/auditfilter.c3
-rw-r--r--kernel/configs.c2
-rw-r--r--kernel/cpu.c6
-rw-r--r--kernel/cpuset.c22
-rw-r--r--kernel/delayacct.c4
-rw-r--r--kernel/dma.c2
-rw-r--r--kernel/exit.c8
-rw-r--r--kernel/fork.c42
-rw-r--r--kernel/futex.c45
-rw-r--r--kernel/irq/handle.c2
-rw-r--r--kernel/kallsyms.c17
-rw-r--r--kernel/kexec.c59
-rw-r--r--kernel/kmod.c16
-rw-r--r--kernel/kprobes.c117
-rw-r--r--kernel/kthread.c13
-rw-r--r--kernel/lockdep.c48
-rw-r--r--kernel/lockdep_internals.h2
-rw-r--r--kernel/lockdep_proc.c6
-rw-r--r--kernel/module.c2
-rw-r--r--kernel/mutex-debug.c3
-rw-r--r--kernel/pid.c2
-rw-r--r--kernel/posix-timers.c2
-rw-r--r--kernel/power/Kconfig2
-rw-r--r--kernel/power/disk.c66
-rw-r--r--kernel/power/main.c14
-rw-r--r--kernel/power/power.h32
-rw-r--r--kernel/power/poweroff.c4
-rw-r--r--kernel/power/process.c130
-rw-r--r--kernel/power/snapshot.c860
-rw-r--r--kernel/power/swap.c347
-rw-r--r--kernel/power/swsusp.c98
-rw-r--r--kernel/power/user.c102
-rw-r--r--kernel/printk.c24
-rw-r--r--kernel/profile.c47
-rw-r--r--kernel/rcupdate.c4
-rw-r--r--kernel/rcutorture.c4
-rw-r--r--kernel/relay.c12
-rw-r--r--kernel/resource.c6
-rw-r--r--kernel/rtmutex-tester.c1
-rw-r--r--kernel/sched.c39
-rw-r--r--kernel/signal.c6
-rw-r--r--kernel/softirq.c2
-rw-r--r--kernel/sys.c8
-rw-r--r--kernel/sysctl.c17
-rw-r--r--kernel/taskstats.c169
-rw-r--r--kernel/user.c4
-rw-r--r--kernel/workqueue.c144
-rw-r--r--lib/Kconfig.debug1
-rw-r--r--lib/Makefile2
-rw-r--r--lib/cmdline.c35
-rw-r--r--lib/idr.c4
-rw-r--r--lib/kobject.c3
-rw-r--r--lib/list_debug.c10
-rw-r--r--lib/locking-selftest.c2
-rw-r--r--lib/radix-tree.c333
-rw-r--r--mm/allocpercpu.c9
-rw-r--r--mm/bootmem.c6
-rw-r--r--mm/filemap.c1
-rw-r--r--mm/fremap.c2
-rw-r--r--mm/hugetlb.c22
-rw-r--r--mm/memory.c3
-rw-r--r--mm/memory_hotplug.c1
-rw-r--r--mm/mempolicy.c10
-rw-r--r--mm/migrate.c19
-rw-r--r--mm/mlock.c2
-rw-r--r--mm/mmap.c4
-rw-r--r--mm/mmzone.c5
-rw-r--r--mm/nommu.c18
-rw-r--r--mm/oom_kill.c41
-rw-r--r--mm/page_alloc.c281
-rw-r--r--mm/page_io.c45
-rw-r--r--mm/pdflush.c1
-rw-r--r--mm/readahead.c8
-rw-r--r--mm/shmem.c8
-rw-r--r--mm/slab.c298
-rw-r--r--mm/sparse.c23
-rw-r--r--mm/swap.c10
-rw-r--r--mm/swapfile.c92
-rw-r--r--mm/thrash.c116
-rw-r--r--mm/vmscan.c13
-rw-r--r--mm/vmstat.c22
-rw-r--r--net/atm/lec.c9
-rw-r--r--net/atm/lec.h2
-rw-r--r--net/bluetooth/hci_sysfs.c12
-rw-r--r--net/bridge/br_fdb.c2
-rw-r--r--net/bridge/br_if.c10
-rw-r--r--net/bridge/br_private.h2
-rw-r--r--net/core/dev.c2
-rw-r--r--net/core/dst.c2
-rw-r--r--net/core/flow.c6
-rw-r--r--net/core/link_watch.c13
-rw-r--r--net/core/neighbour.c2
-rw-r--r--net/core/netpoll.c11
-rw-r--r--net/core/skbuff.c20
-rw-r--r--net/core/sock.c25
-rw-r--r--net/dccp/ackvec.c4
-rw-r--r--net/dccp/ccid.c6
-rw-r--r--net/dccp/ccid.h4
-rw-r--r--net/dccp/ccids/ccid3.c6
-rw-r--r--net/dccp/ccids/lib/loss_interval.c2
-rw-r--r--net/dccp/ccids/lib/loss_interval.h2
-rw-r--r--net/dccp/ccids/lib/packet_history.h4
-rw-r--r--net/dccp/minisocks.c3
-rw-r--r--net/decnet/dn_table.c4
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_assoc.c18
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_auth.c23
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_event.c12
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_module.c4
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_priv.h13
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_scan.c13
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_wx.c6
-rw-r--r--net/ipv4/fib_hash.c8
-rw-r--r--net/ipv4/fib_trie.c6
-rw-r--r--net/ipv4/inet_hashtables.c6
-rw-r--r--net/ipv4/inet_timewait_sock.c7
-rw-r--r--net/ipv4/inetpeer.c2
-rw-r--r--net/ipv4/ipmr.c2
-rw-r--r--net/ipv4/ipvs/ip_vs_conn.c2
-rw-r--r--net/ipv4/ipvs/ip_vs_ctl.c6
-rw-r--r--net/ipv4/netfilter/ip_conntrack_core.c4
-rw-r--r--net/ipv4/tcp_minisocks.c3
-rw-r--r--net/ipv6/af_inet6.c6
-rw-r--r--net/ipv6/ip6_fib.c4
-rw-r--r--net/ipv6/xfrm6_tunnel.c4
-rw-r--r--net/irda/ircomm/ircomm_tty.c11
-rw-r--r--net/netfilter/nf_conntrack_core.c6
-rw-r--r--net/netfilter/nf_conntrack_expect.c2
-rw-r--r--net/netfilter/xt_hashlimit.c2
-rw-r--r--net/rxrpc/krxiod.c1
-rw-r--r--net/rxrpc/krxsecd.c1
-rw-r--r--net/rxrpc/krxtimod.c1
-rw-r--r--net/sctp/associola.c11
-rw-r--r--net/sctp/endpointola.c10
-rw-r--r--net/sctp/inqueue.c9
-rw-r--r--net/sctp/protocol.c4
-rw-r--r--net/sctp/sm_make_chunk.c4
-rw-r--r--net/sctp/socket.c4
-rw-r--r--net/socket.c25
-rw-r--r--net/sunrpc/cache.c8
-rw-r--r--net/sunrpc/rpc_pipe.c14
-rw-r--r--net/sunrpc/sched.c12
-rw-r--r--net/sunrpc/svcauth.c3
-rw-r--r--net/sunrpc/svcsock.c32
-rw-r--r--net/sunrpc/xprt.c7
-rw-r--r--net/sunrpc/xprtsock.c51
-rw-r--r--net/tipc/handler.c2
-rw-r--r--net/xfrm/xfrm_input.c4
-rw-r--r--net/xfrm/xfrm_policy.c10
-rw-r--r--net/xfrm/xfrm_state.c8
-rw-r--r--scripts/kconfig/qconf.cc8
-rwxr-xr-xscripts/kernel-doc2
-rwxr-xr-xscripts/ver_linux8
-rw-r--r--security/keys/key.c14
-rw-r--r--security/keys/keyring.c4
-rw-r--r--security/keys/process_keys.c2
-rw-r--r--security/selinux/avc.c4
-rw-r--r--security/selinux/hooks.c4
-rw-r--r--security/selinux/ss/avtab.c4
-rw-r--r--sound/aoa/aoa-gpio.h2
-rw-r--r--sound/aoa/core/snd-aoa-gpio-feature.c16
-rw-r--r--sound/aoa/core/snd-aoa-gpio-pmf.c16
-rw-r--r--sound/arm/sa11xx-uda1341.c2
-rw-r--r--sound/core/pcm_native.c10
-rw-r--r--sound/i2c/other/ak4114.c8
-rw-r--r--sound/oss/Kconfig115
-rw-r--r--sound/oss/btaudio.c2
-rw-r--r--sound/oss/emu10k1/audio.c8
-rw-r--r--sound/oss/emu10k1/cardwi.c31
-rw-r--r--sound/oss/emu10k1/cardwi.h2
-rw-r--r--sound/oss/emu10k1/passthrough.c13
-rw-r--r--sound/oss/via82cxxx_audio.c4
-rw-r--r--sound/pci/ac97/ac97_codec.c7
-rw-r--r--sound/pci/hda/hda_codec.c10
-rw-r--r--sound/pci/hda/hda_local.h1
-rw-r--r--sound/ppc/tumbler.c8
-rw-r--r--sound/usb/usx2y/usX2Yhwdep.c2
1343 files changed, 18845 insertions, 13852 deletions
diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
index 05431621c861..805db4b2cba6 100644
--- a/Documentation/DMA-API.txt
+++ b/Documentation/DMA-API.txt
@@ -77,7 +77,7 @@ To get this part of the dma_ API, you must #include <linux/dmapool.h>
77Many drivers need lots of small dma-coherent memory regions for DMA 77Many drivers need lots of small dma-coherent memory regions for DMA
78descriptors or I/O buffers. Rather than allocating in units of a page 78descriptors or I/O buffers. Rather than allocating in units of a page
79or more using dma_alloc_coherent(), you can use DMA pools. These work 79or more using dma_alloc_coherent(), you can use DMA pools. These work
80much like a kmem_cache_t, except that they use the dma-coherent allocator 80much like a struct kmem_cache, except that they use the dma-coherent allocator
81not __get_free_pages(). Also, they understand common hardware constraints 81not __get_free_pages(). Also, they understand common hardware constraints
82for alignment, like queue heads needing to be aligned on N byte boundaries. 82for alignment, like queue heads needing to be aligned on N byte boundaries.
83 83
@@ -94,7 +94,7 @@ The pool create() routines initialize a pool of dma-coherent buffers
94for use with a given device. It must be called in a context which 94for use with a given device. It must be called in a context which
95can sleep. 95can sleep.
96 96
97The "name" is for diagnostics (like a kmem_cache_t name); dev and size 97The "name" is for diagnostics (like a struct kmem_cache name); dev and size
98are like what you'd pass to dma_alloc_coherent(). The device's hardware 98are like what you'd pass to dma_alloc_coherent(). The device's hardware
99alignment requirement for this type of data is "align" (which is expressed 99alignment requirement for this type of data is "align" (which is expressed
100in bytes, and must be a power of two). If your device has no boundary 100in bytes, and must be a power of two). If your device has no boundary
@@ -431,10 +431,10 @@ be identical to those passed in (and returned by
431dma_alloc_noncoherent()). 431dma_alloc_noncoherent()).
432 432
433int 433int
434dma_is_consistent(dma_addr_t dma_handle) 434dma_is_consistent(struct device *dev, dma_addr_t dma_handle)
435 435
436returns true if the memory pointed to by the dma_handle is actually 436returns true if the device dev is performing consistent DMA on the memory
437consistent. 437area pointed to by the dma_handle.
438 438
439int 439int
440dma_get_cache_alignment(void) 440dma_get_cache_alignment(void)
@@ -459,7 +459,7 @@ anything like this. You must also be extra careful about accessing
459memory you intend to sync partially. 459memory you intend to sync partially.
460 460
461void 461void
462dma_cache_sync(void *vaddr, size_t size, 462dma_cache_sync(struct device *dev, void *vaddr, size_t size,
463 enum dma_data_direction direction) 463 enum dma_data_direction direction)
464 464
465Do a partial sync of memory that was allocated by 465Do a partial sync of memory that was allocated by
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index db9499adbed4..36526a1e76d7 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -190,9 +190,13 @@ quiet_cmd_fig2png = FIG2PNG $@
190### 190###
191# Help targets as used by the top-level makefile 191# Help targets as used by the top-level makefile
192dochelp: 192dochelp:
193 @echo ' Linux kernel internal documentation in different formats:' 193 @echo ' Linux kernel internal documentation in different formats:'
194 @echo ' xmldocs (XML DocBook), psdocs (Postscript), pdfdocs (PDF)' 194 @echo ' htmldocs - HTML'
195 @echo ' htmldocs (HTML), mandocs (man pages, use installmandocs to install)' 195 @echo ' installmandocs - install man pages generated by mandocs'
196 @echo ' mandocs - man pages'
197 @echo ' pdfdocs - PDF'
198 @echo ' psdocs - Postscript'
199 @echo ' xmldocs - XML DocBook'
196 200
197### 201###
198# Temporary files left by various tools 202# Temporary files left by various tools
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl
index a166675c4303..ca094913c555 100644
--- a/Documentation/DocBook/kernel-api.tmpl
+++ b/Documentation/DocBook/kernel-api.tmpl
@@ -418,9 +418,35 @@ X!Edrivers/pnp/system.c
418!Idrivers/parport/daisy.c 418!Idrivers/parport/daisy.c
419 </chapter> 419 </chapter>
420 420
421 <chapter id="viddev"> 421 <chapter id="message_devices">
422 <title>Video4Linux</title> 422 <title>Message-based devices</title>
423!Edrivers/media/video/videodev.c 423 <sect1><title>Fusion message devices</title>
424!Edrivers/message/fusion/mptbase.c
425!Idrivers/message/fusion/mptbase.c
426!Edrivers/message/fusion/mptscsih.c
427!Idrivers/message/fusion/mptscsih.c
428!Idrivers/message/fusion/mptctl.c
429!Idrivers/message/fusion/mptspi.c
430!Idrivers/message/fusion/mptfc.c
431!Idrivers/message/fusion/mptlan.c
432 </sect1>
433 <sect1><title>I2O message devices</title>
434!Iinclude/linux/i2o.h
435!Idrivers/message/i2o/core.h
436!Edrivers/message/i2o/iop.c
437!Idrivers/message/i2o/iop.c
438!Idrivers/message/i2o/config-osm.c
439!Edrivers/message/i2o/exec-osm.c
440!Idrivers/message/i2o/exec-osm.c
441!Idrivers/message/i2o/bus-osm.c
442!Edrivers/message/i2o/device.c
443!Idrivers/message/i2o/device.c
444!Idrivers/message/i2o/driver.c
445!Idrivers/message/i2o/pci.c
446!Idrivers/message/i2o/i2o_block.c
447!Idrivers/message/i2o/i2o_scsi.c
448!Idrivers/message/i2o/i2o_proc.c
449 </sect1>
424 </chapter> 450 </chapter>
425 451
426 <chapter id="snddev"> 452 <chapter id="snddev">
diff --git a/Documentation/IPMI.txt b/Documentation/IPMI.txt
index 0e3924ecd76b..24dc3fcf1594 100644
--- a/Documentation/IPMI.txt
+++ b/Documentation/IPMI.txt
@@ -365,6 +365,7 @@ You can change this at module load time (for a module) with:
365 regshifts=<shift1>,<shift2>,... 365 regshifts=<shift1>,<shift2>,...
366 slave_addrs=<addr1>,<addr2>,... 366 slave_addrs=<addr1>,<addr2>,...
367 force_kipmid=<enable1>,<enable2>,... 367 force_kipmid=<enable1>,<enable2>,...
368 unload_when_empty=[0|1]
368 369
369Each of these except si_trydefaults is a list, the first item for the 370Each of these except si_trydefaults is a list, the first item for the
370first interface, second item for the second interface, etc. 371first interface, second item for the second interface, etc.
@@ -416,6 +417,11 @@ by the driver, but systems with broken interrupts might need an enable,
416or users that don't want the daemon (don't need the performance, don't 417or users that don't want the daemon (don't need the performance, don't
417want the CPU hit) can disable it. 418want the CPU hit) can disable it.
418 419
420If unload_when_empty is set to 1, the driver will be unloaded if it
421doesn't find any interfaces or all the interfaces fail to work. The
422default is one. Setting to 0 is useful with the hotmod, but is
423obviously only useful for modules.
424
419When compiled into the kernel, the parameters can be specified on the 425When compiled into the kernel, the parameters can be specified on the
420kernel command line as: 426kernel command line as:
421 427
@@ -441,6 +447,25 @@ have high-res timers enabled in the kernel and you don't have
441interrupts enabled, the driver will run VERY slowly. Don't blame me, 447interrupts enabled, the driver will run VERY slowly. Don't blame me,
442these interfaces suck. 448these interfaces suck.
443 449
450The driver supports a hot add and remove of interfaces. This way,
451interfaces can be added or removed after the kernel is up and running.
452This is done using /sys/modules/ipmi_si/hotmod, which is a write-only
453parameter. You write a string to this interface. The string has the
454format:
455 <op1>[:op2[:op3...]]
456The "op"s are:
457 add|remove,kcs|bt|smic,mem|i/o,<address>[,<opt1>[,<opt2>[,...]]]
458You can specify more than one interface on the line. The "opt"s are:
459 rsp=<regspacing>
460 rsi=<regsize>
461 rsh=<regshift>
462 irq=<irq>
463 ipmb=<ipmb slave addr>
464and these have the same meanings as discussed above. Note that you
465can also use this on the kernel command line for a more compact format
466for specifying an interface. Note that when removing an interface,
467only the first three parameters (si type, address type, and address)
468are used for the comparison. Any options are ignored for removing.
444 469
445The SMBus Driver 470The SMBus Driver
446---------------- 471----------------
@@ -502,7 +527,10 @@ used to control it:
502 527
503 modprobe ipmi_watchdog timeout=<t> pretimeout=<t> action=<action type> 528 modprobe ipmi_watchdog timeout=<t> pretimeout=<t> action=<action type>
504 preaction=<preaction type> preop=<preop type> start_now=x 529 preaction=<preaction type> preop=<preop type> start_now=x
505 nowayout=x 530 nowayout=x ifnum_to_use=n
531
532ifnum_to_use specifies which interface the watchdog timer should use.
533The default is -1, which means to pick the first one registered.
506 534
507The timeout is the number of seconds to the action, and the pretimeout 535The timeout is the number of seconds to the action, and the pretimeout
508is the amount of seconds before the reset that the pre-timeout panic will 536is the amount of seconds before the reset that the pre-timeout panic will
@@ -624,5 +652,9 @@ command line. The parameter is also available via the proc filesystem
624in /proc/sys/dev/ipmi/poweroff_powercycle. Note that if the system 652in /proc/sys/dev/ipmi/poweroff_powercycle. Note that if the system
625does not support power cycling, it will always do the power off. 653does not support power cycling, it will always do the power off.
626 654
655The "ifnum_to_use" parameter specifies which interface the poweroff
656code should use. The default is -1, which means to pick the first one
657registered.
658
627Note that if you have ACPI enabled, the system will prefer using ACPI to 659Note that if you have ACPI enabled, the system will prefer using ACPI to
628power off. 660power off.
diff --git a/Documentation/block/as-iosched.txt b/Documentation/block/as-iosched.txt
index e2a66f8143c5..a598fe10a297 100644
--- a/Documentation/block/as-iosched.txt
+++ b/Documentation/block/as-iosched.txt
@@ -24,8 +24,10 @@ very similar behavior to the deadline IO scheduler.
24Selecting IO schedulers 24Selecting IO schedulers
25----------------------- 25-----------------------
26To choose IO schedulers at boot time, use the argument 'elevator=deadline'. 26To choose IO schedulers at boot time, use the argument 'elevator=deadline'.
27'noop' and 'as' (the default) are also available. IO schedulers are assigned 27'noop', 'as' and 'cfq' (the default) are also available. IO schedulers are
28globally at boot time only presently. 28assigned globally at boot time only presently. It's also possible to change
29the IO scheduler for a determined device on the fly, as described in
30Documentation/block/switching-sched.txt.
29 31
30 32
31Anticipatory IO scheduler Policies 33Anticipatory IO scheduler Policies
diff --git a/Documentation/devices.txt b/Documentation/devices.txt
index 70690f1a14af..8de132a02ba9 100644
--- a/Documentation/devices.txt
+++ b/Documentation/devices.txt
@@ -3,7 +3,7 @@
3 3
4 Maintained by Torben Mathiasen <device@lanana.org> 4 Maintained by Torben Mathiasen <device@lanana.org>
5 5
6 Last revised: 15 May 2006 6 Last revised: 29 November 2006
7 7
8This list is the Linux Device List, the official registry of allocated 8This list is the Linux Device List, the official registry of allocated
9device numbers and /dev directory nodes for the Linux operating 9device numbers and /dev directory nodes for the Linux operating
@@ -94,6 +94,7 @@ Your cooperation is appreciated.
94 9 = /dev/urandom Faster, less secure random number gen. 94 9 = /dev/urandom Faster, less secure random number gen.
95 10 = /dev/aio Asynchronous I/O notification interface 95 10 = /dev/aio Asynchronous I/O notification interface
96 11 = /dev/kmsg Writes to this come out as printk's 96 11 = /dev/kmsg Writes to this come out as printk's
97
97 1 block RAM disk 98 1 block RAM disk
98 0 = /dev/ram0 First RAM disk 99 0 = /dev/ram0 First RAM disk
99 1 = /dev/ram1 Second RAM disk 100 1 = /dev/ram1 Second RAM disk
@@ -122,7 +123,7 @@ Your cooperation is appreciated.
122 devices are on major 128 and above and use the PTY 123 devices are on major 128 and above and use the PTY
123 master multiplex (/dev/ptmx) to acquire a PTY on 124 master multiplex (/dev/ptmx) to acquire a PTY on
124 demand. 125 demand.
125 126
126 2 block Floppy disks 127 2 block Floppy disks
127 0 = /dev/fd0 Controller 0, drive 0, autodetect 128 0 = /dev/fd0 Controller 0, drive 0, autodetect
128 1 = /dev/fd1 Controller 0, drive 1, autodetect 129 1 = /dev/fd1 Controller 0, drive 1, autodetect
@@ -257,7 +258,7 @@ Your cooperation is appreciated.
257 129 = /dev/vcsa1 tty1 text/attribute contents 258 129 = /dev/vcsa1 tty1 text/attribute contents
258 ... 259 ...
259 191 = /dev/vcsa63 tty63 text/attribute contents 260 191 = /dev/vcsa63 tty63 text/attribute contents
260 261
261 NOTE: These devices permit both read and write access. 262 NOTE: These devices permit both read and write access.
262 263
263 7 block Loopback devices 264 7 block Loopback devices
@@ -411,7 +412,7 @@ Your cooperation is appreciated.
411 207 = /dev/video/em8300_sp EM8300 DVD decoder subpicture 412 207 = /dev/video/em8300_sp EM8300 DVD decoder subpicture
412 208 = /dev/compaq/cpqphpc Compaq PCI Hot Plug Controller 413 208 = /dev/compaq/cpqphpc Compaq PCI Hot Plug Controller
413 209 = /dev/compaq/cpqrid Compaq Remote Insight Driver 414 209 = /dev/compaq/cpqrid Compaq Remote Insight Driver
414 210 = /dev/impi/bt IMPI coprocessor block transfer 415 210 = /dev/impi/bt IMPI coprocessor block transfer
415 211 = /dev/impi/smic IMPI coprocessor stream interface 416 211 = /dev/impi/smic IMPI coprocessor stream interface
416 212 = /dev/watchdogs/0 First watchdog device 417 212 = /dev/watchdogs/0 First watchdog device
417 213 = /dev/watchdogs/1 Second watchdog device 418 213 = /dev/watchdogs/1 Second watchdog device
@@ -506,6 +507,7 @@ Your cooperation is appreciated.
506 33 = /dev/patmgr1 Sequencer patch manager 507 33 = /dev/patmgr1 Sequencer patch manager
507 34 = /dev/midi02 Third MIDI port 508 34 = /dev/midi02 Third MIDI port
508 50 = /dev/midi03 Fourth MIDI port 509 50 = /dev/midi03 Fourth MIDI port
510
509 14 block BIOS harddrive callback support {2.6} 511 14 block BIOS harddrive callback support {2.6}
510 0 = /dev/dos_hda First BIOS harddrive whole disk 512 0 = /dev/dos_hda First BIOS harddrive whole disk
511 64 = /dev/dos_hdb Second BIOS harddrive whole disk 513 64 = /dev/dos_hdb Second BIOS harddrive whole disk
@@ -527,6 +529,7 @@ Your cooperation is appreciated.
527 529
528 16 char Non-SCSI scanners 530 16 char Non-SCSI scanners
529 0 = /dev/gs4500 Genius 4500 handheld scanner 531 0 = /dev/gs4500 Genius 4500 handheld scanner
532
530 16 block GoldStar CD-ROM 533 16 block GoldStar CD-ROM
531 0 = /dev/gscd GoldStar CD-ROM 534 0 = /dev/gscd GoldStar CD-ROM
532 535
@@ -548,6 +551,7 @@ Your cooperation is appreciated.
548 0 = /dev/ttyC0 First Cyclades port 551 0 = /dev/ttyC0 First Cyclades port
549 ... 552 ...
550 31 = /dev/ttyC31 32nd Cyclades port 553 31 = /dev/ttyC31 32nd Cyclades port
554
551 19 block "Double" compressed disk 555 19 block "Double" compressed disk
552 0 = /dev/double0 First compressed disk 556 0 = /dev/double0 First compressed disk
553 ... 557 ...
@@ -563,6 +567,7 @@ Your cooperation is appreciated.
563 0 = /dev/cub0 Callout device for ttyC0 567 0 = /dev/cub0 Callout device for ttyC0
564 ... 568 ...
565 31 = /dev/cub31 Callout device for ttyC31 569 31 = /dev/cub31 Callout device for ttyC31
570
566 20 block Hitachi CD-ROM (under development) 571 20 block Hitachi CD-ROM (under development)
567 0 = /dev/hitcd Hitachi CD-ROM 572 0 = /dev/hitcd Hitachi CD-ROM
568 573
@@ -582,7 +587,7 @@ Your cooperation is appreciated.
582 587
583 This device is used on the ARM-based Acorn RiscPC. 588 This device is used on the ARM-based Acorn RiscPC.
584 Partitions are handled the same way as for IDE disks 589 Partitions are handled the same way as for IDE disks
585 (see major number 3). 590 (see major number 3).
586 591
587 22 char Digiboard serial card 592 22 char Digiboard serial card
588 0 = /dev/ttyD0 First Digiboard port 593 0 = /dev/ttyD0 First Digiboard port
@@ -591,7 +596,7 @@ Your cooperation is appreciated.
591 22 block Second IDE hard disk/CD-ROM interface 596 22 block Second IDE hard disk/CD-ROM interface
592 0 = /dev/hdc Master: whole disk (or CD-ROM) 597 0 = /dev/hdc Master: whole disk (or CD-ROM)
593 64 = /dev/hdd Slave: whole disk (or CD-ROM) 598 64 = /dev/hdd Slave: whole disk (or CD-ROM)
594 599
595 Partitions are handled the same way as for the first 600 Partitions are handled the same way as for the first
596 interface (see major number 3). 601 interface (see major number 3).
597 602
@@ -639,6 +644,7 @@ Your cooperation is appreciated.
639 644
640 26 char Quanta WinVision frame grabber {2.6} 645 26 char Quanta WinVision frame grabber {2.6}
641 0 = /dev/wvisfgrab Quanta WinVision frame grabber 646 0 = /dev/wvisfgrab Quanta WinVision frame grabber
647
642 26 block Second Matsushita (Panasonic/SoundBlaster) CD-ROM 648 26 block Second Matsushita (Panasonic/SoundBlaster) CD-ROM
643 0 = /dev/sbpcd4 Panasonic CD-ROM controller 1 unit 0 649 0 = /dev/sbpcd4 Panasonic CD-ROM controller 1 unit 0
644 1 = /dev/sbpcd5 Panasonic CD-ROM controller 1 unit 1 650 1 = /dev/sbpcd5 Panasonic CD-ROM controller 1 unit 1
@@ -670,6 +676,7 @@ Your cooperation is appreciated.
670 37 = /dev/nrawqft1 Unit 1, no rewind-on-close, no file marks 676 37 = /dev/nrawqft1 Unit 1, no rewind-on-close, no file marks
671 38 = /dev/nrawqft2 Unit 2, no rewind-on-close, no file marks 677 38 = /dev/nrawqft2 Unit 2, no rewind-on-close, no file marks
672 39 = /dev/nrawqft3 Unit 3, no rewind-on-close, no file marks 678 39 = /dev/nrawqft3 Unit 3, no rewind-on-close, no file marks
679
673 27 block Third Matsushita (Panasonic/SoundBlaster) CD-ROM 680 27 block Third Matsushita (Panasonic/SoundBlaster) CD-ROM
674 0 = /dev/sbpcd8 Panasonic CD-ROM controller 2 unit 0 681 0 = /dev/sbpcd8 Panasonic CD-ROM controller 2 unit 0
675 1 = /dev/sbpcd9 Panasonic CD-ROM controller 2 unit 1 682 1 = /dev/sbpcd9 Panasonic CD-ROM controller 2 unit 1
@@ -681,6 +688,7 @@ Your cooperation is appreciated.
681 1 = /dev/staliomem1 Second Stallion card I/O memory 688 1 = /dev/staliomem1 Second Stallion card I/O memory
682 2 = /dev/staliomem2 Third Stallion card I/O memory 689 2 = /dev/staliomem2 Third Stallion card I/O memory
683 3 = /dev/staliomem3 Fourth Stallion card I/O memory 690 3 = /dev/staliomem3 Fourth Stallion card I/O memory
691
684 28 char Atari SLM ACSI laser printer (68k/Atari) 692 28 char Atari SLM ACSI laser printer (68k/Atari)
685 0 = /dev/slm0 First SLM laser printer 693 0 = /dev/slm0 First SLM laser printer
686 1 = /dev/slm1 Second SLM laser printer 694 1 = /dev/slm1 Second SLM laser printer
@@ -690,6 +698,7 @@ Your cooperation is appreciated.
690 1 = /dev/sbpcd13 Panasonic CD-ROM controller 3 unit 1 698 1 = /dev/sbpcd13 Panasonic CD-ROM controller 3 unit 1
691 2 = /dev/sbpcd14 Panasonic CD-ROM controller 3 unit 2 699 2 = /dev/sbpcd14 Panasonic CD-ROM controller 3 unit 2
692 3 = /dev/sbpcd15 Panasonic CD-ROM controller 3 unit 3 700 3 = /dev/sbpcd15 Panasonic CD-ROM controller 3 unit 3
701
693 28 block ACSI disk (68k/Atari) 702 28 block ACSI disk (68k/Atari)
694 0 = /dev/ada First ACSI disk whole disk 703 0 = /dev/ada First ACSI disk whole disk
695 16 = /dev/adb Second ACSI disk whole disk 704 16 = /dev/adb Second ACSI disk whole disk
@@ -750,6 +759,7 @@ Your cooperation is appreciated.
750 31 char MPU-401 MIDI 759 31 char MPU-401 MIDI
751 0 = /dev/mpu401data MPU-401 data port 760 0 = /dev/mpu401data MPU-401 data port
752 1 = /dev/mpu401stat MPU-401 status port 761 1 = /dev/mpu401stat MPU-401 status port
762
753 31 block ROM/flash memory card 763 31 block ROM/flash memory card
754 0 = /dev/rom0 First ROM card (rw) 764 0 = /dev/rom0 First ROM card (rw)
755 ... 765 ...
@@ -801,7 +811,7 @@ Your cooperation is appreciated.
801 34 block Fourth IDE hard disk/CD-ROM interface 811 34 block Fourth IDE hard disk/CD-ROM interface
802 0 = /dev/hdg Master: whole disk (or CD-ROM) 812 0 = /dev/hdg Master: whole disk (or CD-ROM)
803 64 = /dev/hdh Slave: whole disk (or CD-ROM) 813 64 = /dev/hdh Slave: whole disk (or CD-ROM)
804 814
805 Partitions are handled the same way as for the first 815 Partitions are handled the same way as for the first
806 interface (see major number 3). 816 interface (see major number 3).
807 817
@@ -818,6 +828,7 @@ Your cooperation is appreciated.
818 129 = /dev/smpte1 Second MIDI port, SMPTE timed 828 129 = /dev/smpte1 Second MIDI port, SMPTE timed
819 130 = /dev/smpte2 Third MIDI port, SMPTE timed 829 130 = /dev/smpte2 Third MIDI port, SMPTE timed
820 131 = /dev/smpte3 Fourth MIDI port, SMPTE timed 830 131 = /dev/smpte3 Fourth MIDI port, SMPTE timed
831
821 35 block Slow memory ramdisk 832 35 block Slow memory ramdisk
822 0 = /dev/slram Slow memory ramdisk 833 0 = /dev/slram Slow memory ramdisk
823 834
@@ -828,6 +839,7 @@ Your cooperation is appreciated.
828 16 = /dev/tap0 First Ethertap device 839 16 = /dev/tap0 First Ethertap device
829 ... 840 ...
830 31 = /dev/tap15 16th Ethertap device 841 31 = /dev/tap15 16th Ethertap device
842
831 36 block MCA ESDI hard disk 843 36 block MCA ESDI hard disk
832 0 = /dev/eda First ESDI disk whole disk 844 0 = /dev/eda First ESDI disk whole disk
833 64 = /dev/edb Second ESDI disk whole disk 845 64 = /dev/edb Second ESDI disk whole disk
@@ -882,6 +894,7 @@ Your cooperation is appreciated.
882 894
883 40 char Matrox Meteor frame grabber {2.6} 895 40 char Matrox Meteor frame grabber {2.6}
884 0 = /dev/mmetfgrab Matrox Meteor frame grabber 896 0 = /dev/mmetfgrab Matrox Meteor frame grabber
897
885 40 block Syquest EZ135 parallel port removable drive 898 40 block Syquest EZ135 parallel port removable drive
886 0 = /dev/eza Parallel EZ135 drive, whole disk 899 0 = /dev/eza Parallel EZ135 drive, whole disk
887 900
@@ -893,6 +906,7 @@ Your cooperation is appreciated.
893 906
894 41 char Yet Another Micro Monitor 907 41 char Yet Another Micro Monitor
895 0 = /dev/yamm Yet Another Micro Monitor 908 0 = /dev/yamm Yet Another Micro Monitor
909
896 41 block MicroSolutions BackPack parallel port CD-ROM 910 41 block MicroSolutions BackPack parallel port CD-ROM
897 0 = /dev/bpcd BackPack CD-ROM 911 0 = /dev/bpcd BackPack CD-ROM
898 912
@@ -901,6 +915,7 @@ Your cooperation is appreciated.
901 the parallel port ATAPI CD-ROM driver at major number 46. 915 the parallel port ATAPI CD-ROM driver at major number 46.
902 916
903 42 char Demo/sample use 917 42 char Demo/sample use
918
904 42 block Demo/sample use 919 42 block Demo/sample use
905 920
906 This number is intended for use in sample code, as 921 This number is intended for use in sample code, as
@@ -918,6 +933,7 @@ Your cooperation is appreciated.
918 0 = /dev/ttyI0 First virtual modem 933 0 = /dev/ttyI0 First virtual modem
919 ... 934 ...
920 63 = /dev/ttyI63 64th virtual modem 935 63 = /dev/ttyI63 64th virtual modem
936
921 43 block Network block devices 937 43 block Network block devices
922 0 = /dev/nb0 First network block device 938 0 = /dev/nb0 First network block device
923 1 = /dev/nb1 Second network block device 939 1 = /dev/nb1 Second network block device
@@ -934,12 +950,13 @@ Your cooperation is appreciated.
934 0 = /dev/cui0 Callout device for ttyI0 950 0 = /dev/cui0 Callout device for ttyI0
935 ... 951 ...
936 63 = /dev/cui63 Callout device for ttyI63 952 63 = /dev/cui63 Callout device for ttyI63
953
937 44 block Flash Translation Layer (FTL) filesystems 954 44 block Flash Translation Layer (FTL) filesystems
938 0 = /dev/ftla FTL on first Memory Technology Device 955 0 = /dev/ftla FTL on first Memory Technology Device
939 16 = /dev/ftlb FTL on second Memory Technology Device 956 16 = /dev/ftlb FTL on second Memory Technology Device
940 32 = /dev/ftlc FTL on third Memory Technology Device 957 32 = /dev/ftlc FTL on third Memory Technology Device
941 ... 958 ...
942 240 = /dev/ftlp FTL on 16th Memory Technology Device 959 240 = /dev/ftlp FTL on 16th Memory Technology Device
943 960
944 Partitions are handled in the same way as for IDE 961 Partitions are handled in the same way as for IDE
945 disks (see major number 3) except that the partition 962 disks (see major number 3) except that the partition
@@ -958,6 +975,7 @@ Your cooperation is appreciated.
958 191 = /dev/ippp63 64th SyncPPP device 975 191 = /dev/ippp63 64th SyncPPP device
959 976
960 255 = /dev/isdninfo ISDN monitor interface 977 255 = /dev/isdninfo ISDN monitor interface
978
961 45 block Parallel port IDE disk devices 979 45 block Parallel port IDE disk devices
962 0 = /dev/pda First parallel port IDE disk 980 0 = /dev/pda First parallel port IDE disk
963 16 = /dev/pdb Second parallel port IDE disk 981 16 = /dev/pdb Second parallel port IDE disk
@@ -1044,6 +1062,7 @@ Your cooperation is appreciated.
1044 1 = /dev/dcbri1 Second DataComm card 1062 1 = /dev/dcbri1 Second DataComm card
1045 2 = /dev/dcbri2 Third DataComm card 1063 2 = /dev/dcbri2 Third DataComm card
1046 3 = /dev/dcbri3 Fourth DataComm card 1064 3 = /dev/dcbri3 Fourth DataComm card
1065
1047 52 block Mylex DAC960 PCI RAID controller; fifth controller 1066 52 block Mylex DAC960 PCI RAID controller; fifth controller
1048 0 = /dev/rd/c4d0 First disk, whole disk 1067 0 = /dev/rd/c4d0 First disk, whole disk
1049 8 = /dev/rd/c4d1 Second disk, whole disk 1068 8 = /dev/rd/c4d1 Second disk, whole disk
@@ -1093,6 +1112,7 @@ Your cooperation is appreciated.
1093 1112
1094 55 char DSP56001 digital signal processor 1113 55 char DSP56001 digital signal processor
1095 0 = /dev/dsp56k First DSP56001 1114 0 = /dev/dsp56k First DSP56001
1115
1096 55 block Mylex DAC960 PCI RAID controller; eighth controller 1116 55 block Mylex DAC960 PCI RAID controller; eighth controller
1097 0 = /dev/rd/c7d0 First disk, whole disk 1117 0 = /dev/rd/c7d0 First disk, whole disk
1098 8 = /dev/rd/c7d1 Second disk, whole disk 1118 8 = /dev/rd/c7d1 Second disk, whole disk
@@ -1130,6 +1150,7 @@ Your cooperation is appreciated.
1130 0 = /dev/cup0 Callout device for ttyP0 1150 0 = /dev/cup0 Callout device for ttyP0
1131 1 = /dev/cup1 Callout device for ttyP1 1151 1 = /dev/cup1 Callout device for ttyP1
1132 ... 1152 ...
1153
1133 58 block Reserved for logical volume manager 1154 58 block Reserved for logical volume manager
1134 1155
1135 59 char sf firewall package 1156 59 char sf firewall package
@@ -1149,6 +1170,7 @@ Your cooperation is appreciated.
1149 NAMING CONFLICT -- PROPOSED REVISED NAME /dev/rpda0 etc 1170 NAMING CONFLICT -- PROPOSED REVISED NAME /dev/rpda0 etc
1150 1171
1151 60-63 char LOCAL/EXPERIMENTAL USE 1172 60-63 char LOCAL/EXPERIMENTAL USE
1173
1152 60-63 block LOCAL/EXPERIMENTAL USE 1174 60-63 block LOCAL/EXPERIMENTAL USE
1153 Allocated for local/experimental use. For devices not 1175 Allocated for local/experimental use. For devices not
1154 assigned official numbers, these ranges should be 1176 assigned official numbers, these ranges should be
@@ -1434,7 +1456,6 @@ Your cooperation is appreciated.
1434 DAC960 (see major number 48) except that the limit on 1456 DAC960 (see major number 48) except that the limit on
1435 partitions is 15. 1457 partitions is 15.
1436 1458
1437
1438 78 char PAM Software's multimodem boards 1459 78 char PAM Software's multimodem boards
1439 0 = /dev/ttyM0 First PAM modem 1460 0 = /dev/ttyM0 First PAM modem
1440 1 = /dev/ttyM1 Second PAM modem 1461 1 = /dev/ttyM1 Second PAM modem
@@ -1450,7 +1471,6 @@ Your cooperation is appreciated.
1450 DAC960 (see major number 48) except that the limit on 1471 DAC960 (see major number 48) except that the limit on
1451 partitions is 15. 1472 partitions is 15.
1452 1473
1453
1454 79 char PAM Software's multimodem boards - alternate devices 1474 79 char PAM Software's multimodem boards - alternate devices
1455 0 = /dev/cum0 Callout device for ttyM0 1475 0 = /dev/cum0 Callout device for ttyM0
1456 1 = /dev/cum1 Callout device for ttyM1 1476 1 = /dev/cum1 Callout device for ttyM1
@@ -1466,7 +1486,6 @@ Your cooperation is appreciated.
1466 DAC960 (see major number 48) except that the limit on 1486 DAC960 (see major number 48) except that the limit on
1467 partitions is 15. 1487 partitions is 15.
1468 1488
1469
1470 80 char Photometrics AT200 CCD camera 1489 80 char Photometrics AT200 CCD camera
1471 0 = /dev/at200 Photometrics AT200 CCD camera 1490 0 = /dev/at200 Photometrics AT200 CCD camera
1472 1491
@@ -1679,7 +1698,7 @@ Your cooperation is appreciated.
1679 1 = /dev/dcxx1 Second capture card 1698 1 = /dev/dcxx1 Second capture card
1680 ... 1699 ...
1681 1700
1682 94 block IBM S/390 DASD block storage 1701 94 block IBM S/390 DASD block storage
1683 0 = /dev/dasda First DASD device, major 1702 0 = /dev/dasda First DASD device, major
1684 1 = /dev/dasda1 First DASD device, block 1 1703 1 = /dev/dasda1 First DASD device, block 1
1685 2 = /dev/dasda2 First DASD device, block 2 1704 2 = /dev/dasda2 First DASD device, block 2
@@ -1695,7 +1714,7 @@ Your cooperation is appreciated.
1695 1 = /dev/ipnat NAT control device/log file 1714 1 = /dev/ipnat NAT control device/log file
1696 2 = /dev/ipstate State information log file 1715 2 = /dev/ipstate State information log file
1697 3 = /dev/ipauth Authentication control device/log file 1716 3 = /dev/ipauth Authentication control device/log file
1698 ... 1717 ...
1699 1718
1700 96 char Parallel port ATAPI tape devices 1719 96 char Parallel port ATAPI tape devices
1701 0 = /dev/pt0 First parallel port ATAPI tape 1720 0 = /dev/pt0 First parallel port ATAPI tape
@@ -1705,7 +1724,7 @@ Your cooperation is appreciated.
1705 129 = /dev/npt1 Second p.p. ATAPI tape, no rewind 1724 129 = /dev/npt1 Second p.p. ATAPI tape, no rewind
1706 ... 1725 ...
1707 1726
1708 96 block Inverse NAND Flash Translation Layer 1727 96 block Inverse NAND Flash Translation Layer
1709 0 = /dev/inftla First INFTL layer 1728 0 = /dev/inftla First INFTL layer
1710 16 = /dev/inftlb Second INFTL layer 1729 16 = /dev/inftlb Second INFTL layer
1711 ... 1730 ...
@@ -1937,7 +1956,6 @@ Your cooperation is appreciated.
1937 ... 1956 ...
1938 1957
1939113 block IBM iSeries virtual CD-ROM 1958113 block IBM iSeries virtual CD-ROM
1940
1941 0 = /dev/iseries/vcda First virtual CD-ROM 1959 0 = /dev/iseries/vcda First virtual CD-ROM
1942 1 = /dev/iseries/vcdb Second virtual CD-ROM 1960 1 = /dev/iseries/vcdb Second virtual CD-ROM
1943 ... 1961 ...
@@ -2059,11 +2077,12 @@ Your cooperation is appreciated.
2059 ... 2077 ...
2060 2078
2061119 char VMware virtual network control 2079119 char VMware virtual network control
2062 0 = /dev/vnet0 1st virtual network 2080 0 = /dev/vmnet0 1st virtual network
2063 1 = /dev/vnet1 2nd virtual network 2081 1 = /dev/vmnet1 2nd virtual network
2064 ... 2082 ...
2065 2083
2066120-127 char LOCAL/EXPERIMENTAL USE 2084120-127 char LOCAL/EXPERIMENTAL USE
2085
2067120-127 block LOCAL/EXPERIMENTAL USE 2086120-127 block LOCAL/EXPERIMENTAL USE
2068 Allocated for local/experimental use. For devices not 2087 Allocated for local/experimental use. For devices not
2069 assigned official numbers, these ranges should be 2088 assigned official numbers, these ranges should be
@@ -2075,7 +2094,6 @@ Your cooperation is appreciated.
2075 nodes; instead they should be accessed through the 2094 nodes; instead they should be accessed through the
2076 /dev/ptmx cloning interface. 2095 /dev/ptmx cloning interface.
2077 2096
2078
2079128 block SCSI disk devices (128-143) 2097128 block SCSI disk devices (128-143)
2080 0 = /dev/sddy 129th SCSI disk whole disk 2098 0 = /dev/sddy 129th SCSI disk whole disk
2081 16 = /dev/sddz 130th SCSI disk whole disk 2099 16 = /dev/sddz 130th SCSI disk whole disk
@@ -2087,7 +2105,6 @@ Your cooperation is appreciated.
2087 disks (see major number 3) except that the limit on 2105 disks (see major number 3) except that the limit on
2088 partitions is 15. 2106 partitions is 15.
2089 2107
2090
2091129 block SCSI disk devices (144-159) 2108129 block SCSI disk devices (144-159)
2092 0 = /dev/sdeo 145th SCSI disk whole disk 2109 0 = /dev/sdeo 145th SCSI disk whole disk
2093 16 = /dev/sdep 146th SCSI disk whole disk 2110 16 = /dev/sdep 146th SCSI disk whole disk
@@ -2123,7 +2140,6 @@ Your cooperation is appreciated.
2123 disks (see major number 3) except that the limit on 2140 disks (see major number 3) except that the limit on
2124 partitions is 15. 2141 partitions is 15.
2125 2142
2126
2127132 block SCSI disk devices (192-207) 2143132 block SCSI disk devices (192-207)
2128 0 = /dev/sdgk 193rd SCSI disk whole disk 2144 0 = /dev/sdgk 193rd SCSI disk whole disk
2129 16 = /dev/sdgl 194th SCSI disk whole disk 2145 16 = /dev/sdgl 194th SCSI disk whole disk
@@ -2135,7 +2151,6 @@ Your cooperation is appreciated.
2135 disks (see major number 3) except that the limit on 2151 disks (see major number 3) except that the limit on
2136 partitions is 15. 2152 partitions is 15.
2137 2153
2138
2139133 block SCSI disk devices (208-223) 2154133 block SCSI disk devices (208-223)
2140 0 = /dev/sdha 209th SCSI disk whole disk 2155 0 = /dev/sdha 209th SCSI disk whole disk
2141 16 = /dev/sdhb 210th SCSI disk whole disk 2156 16 = /dev/sdhb 210th SCSI disk whole disk
@@ -2147,7 +2162,6 @@ Your cooperation is appreciated.
2147 disks (see major number 3) except that the limit on 2162 disks (see major number 3) except that the limit on
2148 partitions is 15. 2163 partitions is 15.
2149 2164
2150
2151134 block SCSI disk devices (224-239) 2165134 block SCSI disk devices (224-239)
2152 0 = /dev/sdhq 225th SCSI disk whole disk 2166 0 = /dev/sdhq 225th SCSI disk whole disk
2153 16 = /dev/sdhr 226th SCSI disk whole disk 2167 16 = /dev/sdhr 226th SCSI disk whole disk
@@ -2159,7 +2173,6 @@ Your cooperation is appreciated.
2159 disks (see major number 3) except that the limit on 2173 disks (see major number 3) except that the limit on
2160 partitions is 15. 2174 partitions is 15.
2161 2175
2162
2163135 block SCSI disk devices (240-255) 2176135 block SCSI disk devices (240-255)
2164 0 = /dev/sdig 241st SCSI disk whole disk 2177 0 = /dev/sdig 241st SCSI disk whole disk
2165 16 = /dev/sdih 242nd SCSI disk whole disk 2178 16 = /dev/sdih 242nd SCSI disk whole disk
@@ -2171,7 +2184,6 @@ Your cooperation is appreciated.
2171 disks (see major number 3) except that the limit on 2184 disks (see major number 3) except that the limit on
2172 partitions is 15. 2185 partitions is 15.
2173 2186
2174
2175136-143 char Unix98 PTY slaves 2187136-143 char Unix98 PTY slaves
2176 0 = /dev/pts/0 First Unix98 pseudo-TTY 2188 0 = /dev/pts/0 First Unix98 pseudo-TTY
2177 1 = /dev/pts/1 Second Unix98 pesudo-TTY 2189 1 = /dev/pts/1 Second Unix98 pesudo-TTY
@@ -2384,6 +2396,7 @@ Your cooperation is appreciated.
2384 ... 2396 ...
2385 2397
2386159 char RESERVED 2398159 char RESERVED
2399
2387159 block RESERVED 2400159 block RESERVED
2388 2401
2389160 char General Purpose Instrument Bus (GPIB) 2402160 char General Purpose Instrument Bus (GPIB)
@@ -2427,7 +2440,7 @@ Your cooperation is appreciated.
2427 2440
2428 Partitions are handled in the same way as for IDE 2441 Partitions are handled in the same way as for IDE
2429 disks (see major number 3) except that the limit on 2442 disks (see major number 3) except that the limit on
2430 partitions is 31. 2443 partitions is 31.
2431 2444
2432162 char Raw block device interface 2445162 char Raw block device interface
2433 0 = /dev/rawctl Raw I/O control device 2446 0 = /dev/rawctl Raw I/O control device
@@ -2483,7 +2496,6 @@ Your cooperation is appreciated.
2483 2496
2484171 char Reserved for IEEE 1394 (Firewire) 2497171 char Reserved for IEEE 1394 (Firewire)
2485 2498
2486
2487172 char Moxa Intellio serial card 2499172 char Moxa Intellio serial card
2488 0 = /dev/ttyMX0 First Moxa port 2500 0 = /dev/ttyMX0 First Moxa port
2489 1 = /dev/ttyMX1 Second Moxa port 2501 1 = /dev/ttyMX1 Second Moxa port
@@ -2543,9 +2555,6 @@ Your cooperation is appreciated.
2543 64 = /dev/usb/rio500 Diamond Rio 500 2555 64 = /dev/usb/rio500 Diamond Rio 500
2544 65 = /dev/usb/usblcd USBLCD Interface (info@usblcd.de) 2556 65 = /dev/usb/usblcd USBLCD Interface (info@usblcd.de)
2545 66 = /dev/usb/cpad0 Synaptics cPad (mouse/LCD) 2557 66 = /dev/usb/cpad0 Synaptics cPad (mouse/LCD)
2546 67 = /dev/usb/adutux0 1st Ontrak ADU device
2547 ...
2548 76 = /dev/usb/adutux10 10th Ontrak ADU device
2549 96 = /dev/usb/hiddev0 1st USB HID device 2558 96 = /dev/usb/hiddev0 1st USB HID device
2550 ... 2559 ...
2551 111 = /dev/usb/hiddev15 16th USB HID device 2560 111 = /dev/usb/hiddev15 16th USB HID device
@@ -2558,7 +2567,7 @@ Your cooperation is appreciated.
2558 132 = /dev/usb/idmouse ID Mouse (fingerprint scanner) device 2567 132 = /dev/usb/idmouse ID Mouse (fingerprint scanner) device
2559 133 = /dev/usb/sisusbvga1 First SiSUSB VGA device 2568 133 = /dev/usb/sisusbvga1 First SiSUSB VGA device
2560 ... 2569 ...
2561 140 = /dev/usb/sisusbvga8 Eigth SISUSB VGA device 2570 140 = /dev/usb/sisusbvga8 Eighth SISUSB VGA device
2562 144 = /dev/usb/lcd USB LCD device 2571 144 = /dev/usb/lcd USB LCD device
2563 160 = /dev/usb/legousbtower0 1st USB Legotower device 2572 160 = /dev/usb/legousbtower0 1st USB Legotower device
2564 ... 2573 ...
@@ -2571,7 +2580,7 @@ Your cooperation is appreciated.
2571 0 = /dev/uba First USB block device 2580 0 = /dev/uba First USB block device
2572 8 = /dev/ubb Second USB block device 2581 8 = /dev/ubb Second USB block device
2573 16 = /dev/ubc Third USB block device 2582 16 = /dev/ubc Third USB block device
2574 ... 2583 ...
2575 2584
2576181 char Conrad Electronic parallel port radio clocks 2585181 char Conrad Electronic parallel port radio clocks
2577 0 = /dev/pcfclock0 First Conrad radio clock 2586 0 = /dev/pcfclock0 First Conrad radio clock
@@ -2657,7 +2666,7 @@ Your cooperation is appreciated.
2657 32 = /dev/mvideo/status2 Third device 2666 32 = /dev/mvideo/status2 Third device
2658 ... 2667 ...
2659 ... 2668 ...
2660 240 = /dev/mvideo/status15 16th device 2669 240 = /dev/mvideo/status15 16th device
2661 ... 2670 ...
2662 2671
2663195 char Nvidia graphics devices 2672195 char Nvidia graphics devices
@@ -2795,6 +2804,10 @@ Your cooperation is appreciated.
2795 ... 2804 ...
2796 185 = /dev/ttyNX15 Hilscher netX serial port 15 2805 185 = /dev/ttyNX15 Hilscher netX serial port 15
2797 186 = /dev/ttyJ0 JTAG1 DCC protocol based serial port emulation 2806 186 = /dev/ttyJ0 JTAG1 DCC protocol based serial port emulation
2807 187 = /dev/ttyUL0 Xilinx uartlite - port 0
2808 ...
2809 190 = /dev/ttyUL3 Xilinx uartlite - port 3
2810 191 = /dev/xvc0 Xen virtual console - port 0
2798 2811
2799205 char Low-density serial ports (alternate device) 2812205 char Low-density serial ports (alternate device)
2800 0 = /dev/culu0 Callout device for ttyLU0 2813 0 = /dev/culu0 Callout device for ttyLU0
@@ -2832,7 +2845,6 @@ Your cooperation is appreciated.
2832 82 = /dev/cuvr0 Callout device for ttyVR0 2845 82 = /dev/cuvr0 Callout device for ttyVR0
2833 83 = /dev/cuvr1 Callout device for ttyVR1 2846 83 = /dev/cuvr1 Callout device for ttyVR1
2834 2847
2835
2836206 char OnStream SC-x0 tape devices 2848206 char OnStream SC-x0 tape devices
2837 0 = /dev/osst0 First OnStream SCSI tape, mode 0 2849 0 = /dev/osst0 First OnStream SCSI tape, mode 0
2838 1 = /dev/osst1 Second OnStream SCSI tape, mode 0 2850 1 = /dev/osst1 Second OnStream SCSI tape, mode 0
@@ -2922,7 +2934,6 @@ Your cooperation is appreciated.
2922 ... 2934 ...
2923 2935
2924212 char LinuxTV.org DVB driver subsystem 2936212 char LinuxTV.org DVB driver subsystem
2925
2926 0 = /dev/dvb/adapter0/video0 first video decoder of first card 2937 0 = /dev/dvb/adapter0/video0 first video decoder of first card
2927 1 = /dev/dvb/adapter0/audio0 first audio decoder of first card 2938 1 = /dev/dvb/adapter0/audio0 first audio decoder of first card
2928 2 = /dev/dvb/adapter0/sec0 (obsolete/unused) 2939 2 = /dev/dvb/adapter0/sec0 (obsolete/unused)
@@ -3008,9 +3019,9 @@ Your cooperation is appreciated.
3008 2 = /dev/3270/tub2 Second 3270 terminal 3019 2 = /dev/3270/tub2 Second 3270 terminal
3009 ... 3020 ...
3010 3021
3011229 char IBM iSeries virtual console 3022229 char IBM iSeries/pSeries virtual console
3012 0 = /dev/iseries/vtty0 First console port 3023 0 = /dev/hvc0 First console port
3013 1 = /dev/iseries/vtty1 Second console port 3024 1 = /dev/hvc1 Second console port
3014 ... 3025 ...
3015 3026
3016230 char IBM iSeries virtual tape 3027230 char IBM iSeries virtual tape
@@ -3083,12 +3094,14 @@ Your cooperation is appreciated.
3083234-239 UNASSIGNED 3094234-239 UNASSIGNED
3084 3095
3085240-254 char LOCAL/EXPERIMENTAL USE 3096240-254 char LOCAL/EXPERIMENTAL USE
3097
3086240-254 block LOCAL/EXPERIMENTAL USE 3098240-254 block LOCAL/EXPERIMENTAL USE
3087 Allocated for local/experimental use. For devices not 3099 Allocated for local/experimental use. For devices not
3088 assigned official numbers, these ranges should be 3100 assigned official numbers, these ranges should be
3089 used in order to avoid conflicting with future assignments. 3101 used in order to avoid conflicting with future assignments.
3090 3102
3091255 char RESERVED 3103255 char RESERVED
3104
3092255 block RESERVED 3105255 block RESERVED
3093 3106
3094 This major is reserved to assist the expansion to a 3107 This major is reserved to assist the expansion to a
@@ -3115,7 +3128,20 @@ Your cooperation is appreciated.
3115257 char Phoenix Technologies Cryptographic Services Driver 3128257 char Phoenix Technologies Cryptographic Services Driver
3116 0 = /dev/ptlsec Crypto Services Driver 3129 0 = /dev/ptlsec Crypto Services Driver
3117 3130
3118 3131257 block SSFDC Flash Translation Layer filesystem
3132 0 = /dev/ssfdca First SSFDC layer
3133 8 = /dev/ssfdcb Second SSFDC layer
3134 16 = /dev/ssfdcc Third SSFDC layer
3135 24 = /dev/ssfdcd 4th SSFDC layer
3136 32 = /dev/ssfdce 5th SSFDC layer
3137 40 = /dev/ssfdcf 6th SSFDC layer
3138 48 = /dev/ssfdcg 7th SSFDC layer
3139 56 = /dev/ssfdch 8th SSFDC layer
3140
3141258 block ROM/Flash read-only translation layer
3142 0 = /dev/blockrom0 First ROM card's translation layer interface
3143 1 = /dev/blockrom1 Second ROM card's translation layer interface
3144 ...
3119 3145
3120 **** ADDITIONAL /dev DIRECTORY ENTRIES 3146 **** ADDITIONAL /dev DIRECTORY ENTRIES
3121 3147
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index eb1a6cad21e6..790ef6fbe495 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -124,7 +124,7 @@ sync_fs: no no read
124write_super_lockfs: ? 124write_super_lockfs: ?
125unlockfs: ? 125unlockfs: ?
126statfs: no no no 126statfs: no no no
127remount_fs: no yes maybe (see below) 127remount_fs: yes yes maybe (see below)
128clear_inode: no 128clear_inode: no
129umount_begin: yes no no 129umount_begin: yes no no
130show_options: no (vfsmount->sem) 130show_options: no (vfsmount->sem)
diff --git a/Documentation/filesystems/fuse.txt b/Documentation/filesystems/fuse.txt
index 3d7447738958..345392c4caeb 100644
--- a/Documentation/filesystems/fuse.txt
+++ b/Documentation/filesystems/fuse.txt
@@ -51,6 +51,22 @@ homepage:
51 51
52 http://fuse.sourceforge.net/ 52 http://fuse.sourceforge.net/
53 53
54Filesystem type
55~~~~~~~~~~~~~~~
56
57The filesystem type given to mount(2) can be one of the following:
58
59'fuse'
60
61 This is the usual way to mount a FUSE filesystem. The first
62 argument of the mount system call may contain an arbitrary string,
63 which is not interpreted by the kernel.
64
65'fuseblk'
66
67 The filesystem is block device based. The first argument of the
68 mount system call is interpreted as the name of the device.
69
54Mount options 70Mount options
55~~~~~~~~~~~~~ 71~~~~~~~~~~~~~
56 72
@@ -94,6 +110,11 @@ Mount options
94 The default is infinite. Note that the size of read requests is 110 The default is infinite. Note that the size of read requests is
95 limited anyway to 32 pages (which is 128kbyte on i386). 111 limited anyway to 32 pages (which is 128kbyte on i386).
96 112
113'blksize=N'
114
115 Set the block size for the filesystem. The default is 512. This
116 option is only valid for 'fuseblk' type mounts.
117
97Control filesystem 118Control filesystem
98~~~~~~~~~~~~~~~~~~ 119~~~~~~~~~~~~~~~~~~
99 120
diff --git a/Documentation/filesystems/sysv-fs.txt b/Documentation/filesystems/sysv-fs.txt
index d81722418010..253b50d1328e 100644
--- a/Documentation/filesystems/sysv-fs.txt
+++ b/Documentation/filesystems/sysv-fs.txt
@@ -1,11 +1,8 @@
1This is the implementation of the SystemV/Coherent filesystem for Linux.
2It implements all of 1It implements all of
3 - Xenix FS, 2 - Xenix FS,
4 - SystemV/386 FS, 3 - SystemV/386 FS,
5 - Coherent FS. 4 - Coherent FS.
6 5
7This is version beta 4.
8
9To install: 6To install:
10* Answer the 'System V and Coherent filesystem support' question with 'y' 7* Answer the 'System V and Coherent filesystem support' question with 'y'
11 when configuring the kernel. 8 when configuring the kernel.
@@ -28,11 +25,173 @@ Bugs in the present implementation:
28 for this FS on hard disk yet. 25 for this FS on hard disk yet.
29 26
30 27
31Please report any bugs and suggestions to 28These filesystems are rather similar. Here is a comparison with Minix FS:
32 Bruno Haible <haible@ma2s2.mathematik.uni-karlsruhe.de> 29
33 Pascal Haible <haible@izfm.uni-stuttgart.de> 30* Linux fdisk reports on partitions
34 Krzysztof G. Baranowski <kgb@manjak.knm.org.pl> 31 - Minix FS 0x81 Linux/Minix
32 - Xenix FS ??
33 - SystemV FS ??
34 - Coherent FS 0x08 AIX bootable
35
36* Size of a block or zone (data allocation unit on disk)
37 - Minix FS 1024
38 - Xenix FS 1024 (also 512 ??)
39 - SystemV FS 1024 (also 512 and 2048)
40 - Coherent FS 512
41
42* General layout: all have one boot block, one super block and
43 separate areas for inodes and for directories/data.
44 On SystemV Release 2 FS (e.g. Microport) the first track is reserved and
45 all the block numbers (including the super block) are offset by one track.
46
47* Byte ordering of "short" (16 bit entities) on disk:
48 - Minix FS little endian 0 1
49 - Xenix FS little endian 0 1
50 - SystemV FS little endian 0 1
51 - Coherent FS little endian 0 1
52 Of course, this affects only the file system, not the data of files on it!
53
54* Byte ordering of "long" (32 bit entities) on disk:
55 - Minix FS little endian 0 1 2 3
56 - Xenix FS little endian 0 1 2 3
57 - SystemV FS little endian 0 1 2 3
58 - Coherent FS PDP-11 2 3 0 1
59 Of course, this affects only the file system, not the data of files on it!
60
61* Inode on disk: "short", 0 means non-existent, the root dir ino is:
62 - Minix FS 1
63 - Xenix FS, SystemV FS, Coherent FS 2
64
65* Maximum number of hard links to a file:
66 - Minix FS 250
67 - Xenix FS ??
68 - SystemV FS ??
69 - Coherent FS >=10000
70
71* Free inode management:
72 - Minix FS a bitmap
73 - Xenix FS, SystemV FS, Coherent FS
74 There is a cache of a certain number of free inodes in the super-block.
75 When it is exhausted, new free inodes are found using a linear search.
76
77* Free block management:
78 - Minix FS a bitmap
79 - Xenix FS, SystemV FS, Coherent FS
80 Free blocks are organized in a "free list". Maybe a misleading term,
81 since it is not true that every free block contains a pointer to
82 the next free block. Rather, the free blocks are organized in chunks
83 of limited size, and every now and then a free block contains pointers
84 to the free blocks pertaining to the next chunk; the first of these
85 contains pointers and so on. The list terminates with a "block number"
86 0 on Xenix FS and SystemV FS, with a block zeroed out on Coherent FS.
87
88* Super-block location:
89 - Minix FS block 1 = bytes 1024..2047
90 - Xenix FS block 1 = bytes 1024..2047
91 - SystemV FS bytes 512..1023
92 - Coherent FS block 1 = bytes 512..1023
93
94* Super-block layout:
95 - Minix FS
96 unsigned short s_ninodes;
97 unsigned short s_nzones;
98 unsigned short s_imap_blocks;
99 unsigned short s_zmap_blocks;
100 unsigned short s_firstdatazone;
101 unsigned short s_log_zone_size;
102 unsigned long s_max_size;
103 unsigned short s_magic;
104 - Xenix FS, SystemV FS, Coherent FS
105 unsigned short s_firstdatazone;
106 unsigned long s_nzones;
107 unsigned short s_fzone_count;
108 unsigned long s_fzones[NICFREE];
109 unsigned short s_finode_count;
110 unsigned short s_finodes[NICINOD];
111 char s_flock;
112 char s_ilock;
113 char s_modified;
114 char s_rdonly;
115 unsigned long s_time;
116 short s_dinfo[4]; -- SystemV FS only
117 unsigned long s_free_zones;
118 unsigned short s_free_inodes;
119 short s_dinfo[4]; -- Xenix FS only
120 unsigned short s_interleave_m,s_interleave_n; -- Coherent FS only
121 char s_fname[6];
122 char s_fpack[6];
123 then they differ considerably:
124 Xenix FS
125 char s_clean;
126 char s_fill[371];
127 long s_magic;
128 long s_type;
129 SystemV FS
130 long s_fill[12 or 14];
131 long s_state;
132 long s_magic;
133 long s_type;
134 Coherent FS
135 unsigned long s_unique;
136 Note that Coherent FS has no magic.
137
138* Inode layout:
139 - Minix FS
140 unsigned short i_mode;
141 unsigned short i_uid;
142 unsigned long i_size;
143 unsigned long i_time;
144 unsigned char i_gid;
145 unsigned char i_nlinks;
146 unsigned short i_zone[7+1+1];
147 - Xenix FS, SystemV FS, Coherent FS
148 unsigned short i_mode;
149 unsigned short i_nlink;
150 unsigned short i_uid;
151 unsigned short i_gid;
152 unsigned long i_size;
153 unsigned char i_zone[3*(10+1+1+1)];
154 unsigned long i_atime;
155 unsigned long i_mtime;
156 unsigned long i_ctime;
157
158* Regular file data blocks are organized as
159 - Minix FS
160 7 direct blocks
161 1 indirect block (pointers to blocks)
162 1 double-indirect block (pointer to pointers to blocks)
163 - Xenix FS, SystemV FS, Coherent FS
164 10 direct blocks
165 1 indirect block (pointers to blocks)
166 1 double-indirect block (pointer to pointers to blocks)
167 1 triple-indirect block (pointer to pointers to pointers to blocks)
168
169* Inode size, inodes per block
170 - Minix FS 32 32
171 - Xenix FS 64 16
172 - SystemV FS 64 16
173 - Coherent FS 64 8
174
175* Directory entry on disk
176 - Minix FS
177 unsigned short inode;
178 char name[14/30];
179 - Xenix FS, SystemV FS, Coherent FS
180 unsigned short inode;
181 char name[14];
182
183* Dir entry size, dir entries per block
184 - Minix FS 16/32 64/32
185 - Xenix FS 16 64
186 - SystemV FS 16 64
187 - Coherent FS 16 32
188
189* How to implement symbolic links such that the host fsck doesn't scream:
190 - Minix FS normal
191 - Xenix FS kludge: as regular files with chmod 1000
192 - SystemV FS ??
193 - Coherent FS kludge: as regular files with chmod 1000
35 194
36Bruno Haible
37<haible@ma2s2.mathematik.uni-karlsruhe.de>
38 195
196Notation: We often speak of a "block" but mean a zone (the allocation unit)
197and not the disk driver's notion of "block".
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index d34fd6a28faa..b79bcdf16319 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -648,6 +648,10 @@ and is between 256 and 4096 characters. It is defined in the file
648 idle= [HW] 648 idle= [HW]
649 Format: idle=poll or idle=halt 649 Format: idle=poll or idle=halt
650 650
651 ignore_loglevel [KNL]
652 Ignore loglevel setting - this will print /all/
653 kernel messages to the console. Useful for debugging.
654
651 ihash_entries= [KNL] 655 ihash_entries= [KNL]
652 Set number of hash buckets for inode cache. 656 Set number of hash buckets for inode cache.
653 657
@@ -712,7 +716,12 @@ and is between 256 and 4096 characters. It is defined in the file
712 Format: <RDP>,<reset>,<pci_scan>,<verbosity> 716 Format: <RDP>,<reset>,<pci_scan>,<verbosity>
713 717
714 isolcpus= [KNL,SMP] Isolate CPUs from the general scheduler. 718 isolcpus= [KNL,SMP] Isolate CPUs from the general scheduler.
715 Format: <cpu number>,...,<cpu number> 719 Format:
720 <cpu number>,...,<cpu number>
721 or
722 <cpu number>-<cpu number> (must be a positive range in ascending order)
723 or a mixture
724 <cpu number>,...,<cpu number>-<cpu number>
716 This option can be used to specify one or more CPUs 725 This option can be used to specify one or more CPUs
717 to isolate from the general SMP balancing and scheduling 726 to isolate from the general SMP balancing and scheduling
718 algorithms. The only way to move a process onto or off 727 algorithms. The only way to move a process onto or off
@@ -1010,6 +1019,10 @@ and is between 256 and 4096 characters. It is defined in the file
1010 emulation library even if a 387 maths coprocessor 1019 emulation library even if a 387 maths coprocessor
1011 is present. 1020 is present.
1012 1021
1022 noaliencache [MM, NUMA] Disables the allcoation of alien caches in
1023 the slab allocator. Saves per-node memory, but will
1024 impact performance on real NUMA hardware.
1025
1013 noalign [KNL,ARM] 1026 noalign [KNL,ARM]
1014 1027
1015 noapic [SMP,APIC] Tells the kernel to not make use of any 1028 noapic [SMP,APIC] Tells the kernel to not make use of any
@@ -1288,6 +1301,7 @@ and is between 256 and 4096 characters. It is defined in the file
1288 Param: "schedule" - profile schedule points. 1301 Param: "schedule" - profile schedule points.
1289 Param: <number> - step/bucket size as a power of 2 for 1302 Param: <number> - step/bucket size as a power of 2 for
1290 statistical time based profiling. 1303 statistical time based profiling.
1304 Param: "sleep" - profile D-state sleeping (millisecs)
1291 1305
1292 processor.max_cstate= [HW,ACPI] 1306 processor.max_cstate= [HW,ACPI]
1293 Limit processor to maximum C-state 1307 Limit processor to maximum C-state
@@ -1369,6 +1383,12 @@ and is between 256 and 4096 characters. It is defined in the file
1369 resume= [SWSUSP] 1383 resume= [SWSUSP]
1370 Specify the partition device for software suspend 1384 Specify the partition device for software suspend
1371 1385
1386 resume_offset= [SWSUSP]
1387 Specify the offset from the beginning of the partition
1388 given by "resume=" at which the swap header is located,
1389 in <PAGE_SIZE> units (needed only for swap files).
1390 See Documentation/power/swsusp-and-swap-files.txt
1391
1372 rhash_entries= [KNL,NET] 1392 rhash_entries= [KNL,NET]
1373 Set number of hash buckets for route cache 1393 Set number of hash buckets for route cache
1374 1394
diff --git a/Documentation/power/s2ram.txt b/Documentation/power/s2ram.txt
new file mode 100644
index 000000000000..b05f512130ea
--- /dev/null
+++ b/Documentation/power/s2ram.txt
@@ -0,0 +1,56 @@
1 How to get s2ram working
2 ~~~~~~~~~~~~~~~~~~~~~~~~
3 2006 Linus Torvalds
4 2006 Pavel Machek
5
61) Check suspend.sf.net, program s2ram there has long whitelist of
7 "known ok" machines, along with tricks to use on each one.
8
92) If that does not help, try reading tricks.txt and
10 video.txt. Perhaps problem is as simple as broken module, and
11 simple module unload can fix it.
12
133) You can use Linus' TRACE_RESUME infrastructure, described below.
14
15 Using TRACE_RESUME
16 ~~~~~~~~~~~~~~~~~~
17
18I've been working at making the machines I have able to STR, and almost
19always it's a driver that is buggy. Thank God for the suspend/resume
20debugging - the thing that Chuck tried to disable. That's often the _only_
21way to debug these things, and it's actually pretty powerful (but
22time-consuming - having to insert TRACE_RESUME() markers into the device
23driver that doesn't resume and recompile and reboot).
24
25Anyway, the way to debug this for people who are interested (have a
26machine that doesn't boot) is:
27
28 - enable PM_DEBUG, and PM_TRACE
29
30 - use a script like this:
31
32 #!/bin/sh
33 sync
34 echo 1 > /sys/power/pm_trace
35 echo mem > /sys/power/state
36
37 to suspend
38
39 - if it doesn't come back up (which is usually the problem), reboot by
40 holding the power button down, and look at the dmesg output for things
41 like
42
43 Magic number: 4:156:725
44 hash matches drivers/base/power/resume.c:28
45 hash matches device 0000:01:00.0
46
47 which means that the last trace event was just before trying to resume
48 device 0000:01:00.0. Then figure out what driver is controlling that
49 device (lspci and /sys/devices/pci* is your friend), and see if you can
50 fix it, disable it, or trace into its resume function.
51
52For example, the above happens to be the VGA device on my EVO, which I
53used to run with "radeonfb" (it's an ATI Radeon mobility). It turns out
54that "radeonfb" simply cannot resume that device - it tries to set the
55PLL's, and it just _hangs_. Using the regular VGA console and letting X
56resume it instead works fine.
diff --git a/Documentation/power/swsusp-and-swap-files.txt b/Documentation/power/swsusp-and-swap-files.txt
new file mode 100644
index 000000000000..06f911a5f885
--- /dev/null
+++ b/Documentation/power/swsusp-and-swap-files.txt
@@ -0,0 +1,60 @@
1Using swap files with software suspend (swsusp)
2 (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
3
4The Linux kernel handles swap files almost in the same way as it handles swap
5partitions and there are only two differences between these two types of swap
6areas:
7(1) swap files need not be contiguous,
8(2) the header of a swap file is not in the first block of the partition that
9holds it. From the swsusp's point of view (1) is not a problem, because it is
10already taken care of by the swap-handling code, but (2) has to be taken into
11consideration.
12
13In principle the location of a swap file's header may be determined with the
14help of appropriate filesystem driver. Unfortunately, however, it requires the
15filesystem holding the swap file to be mounted, and if this filesystem is
16journaled, it cannot be mounted during resume from disk. For this reason to
17identify a swap file swsusp uses the name of the partition that holds the file
18and the offset from the beginning of the partition at which the swap file's
19header is located. For convenience, this offset is expressed in <PAGE_SIZE>
20units.
21
22In order to use a swap file with swsusp, you need to:
23
241) Create the swap file and make it active, eg.
25
26# dd if=/dev/zero of=<swap_file_path> bs=1024 count=<swap_file_size_in_k>
27# mkswap <swap_file_path>
28# swapon <swap_file_path>
29
302) Use an application that will bmap the swap file with the help of the
31FIBMAP ioctl and determine the location of the file's swap header, as the
32offset, in <PAGE_SIZE> units, from the beginning of the partition which
33holds the swap file.
34
353) Add the following parameters to the kernel command line:
36
37resume=<swap_file_partition> resume_offset=<swap_file_offset>
38
39where <swap_file_partition> is the partition on which the swap file is located
40and <swap_file_offset> is the offset of the swap header determined by the
41application in 2) (of course, this step may be carried out automatically
42by the same application that determies the swap file's header offset using the
43FIBMAP ioctl)
44
45OR
46
47Use a userland suspend application that will set the partition and offset
48with the help of the SNAPSHOT_SET_SWAP_AREA ioctl described in
49Documentation/power/userland-swsusp.txt (this is the only method to suspend
50to a swap file allowing the resume to be initiated from an initrd or initramfs
51image).
52
53Now, swsusp will use the swap file in the same way in which it would use a swap
54partition. In particular, the swap file has to be active (ie. be present in
55/proc/swaps) so that it can be used for suspending.
56
57Note that if the swap file used for suspending is deleted and recreated,
58the location of its header need not be the same as before. Thus every time
59this happens the value of the "resume_offset=" kernel command line parameter
60has to be updated.
diff --git a/Documentation/power/swsusp.txt b/Documentation/power/swsusp.txt
index e635e6f1e316..0761ff6c57ed 100644
--- a/Documentation/power/swsusp.txt
+++ b/Documentation/power/swsusp.txt
@@ -297,20 +297,12 @@ system is shut down or suspended. Additionally use the encrypted
297suspend image to prevent sensitive data from being stolen after 297suspend image to prevent sensitive data from being stolen after
298resume. 298resume.
299 299
300Q: Why can't we suspend to a swap file? 300Q: Can I suspend to a swap file?
301 301
302A: Because accessing swap file needs the filesystem mounted, and 302A: Generally, yes, you can. However, it requires you to use the "resume=" and
303filesystem might do something wrong (like replaying the journal) 303"resume_offset=" kernel command line parameters, so the resume from a swap file
304during mount. 304cannot be initiated from an initrd or initramfs image. See
305 305swsusp-and-swap-files.txt for details.
306There are few ways to get that fixed:
307
3081) Probably could be solved by modifying every filesystem to support
309some kind of "really read-only!" option. Patches welcome.
310
3112) suspend2 gets around that by storing absolute positions in on-disk
312image (and blocksize), with resume parameter pointing directly to
313suspend header.
314 306
315Q: Is there a maximum system RAM size that is supported by swsusp? 307Q: Is there a maximum system RAM size that is supported by swsusp?
316 308
diff --git a/Documentation/power/userland-swsusp.txt b/Documentation/power/userland-swsusp.txt
index 64755e9285db..000556c932e9 100644
--- a/Documentation/power/userland-swsusp.txt
+++ b/Documentation/power/userland-swsusp.txt
@@ -9,9 +9,8 @@ done it already.
9Now, to use the userland interface for software suspend you need special 9Now, to use the userland interface for software suspend you need special
10utilities that will read/write the system memory snapshot from/to the 10utilities that will read/write the system memory snapshot from/to the
11kernel. Such utilities are available, for example, from 11kernel. Such utilities are available, for example, from
12<http://www.sisk.pl/kernel/utilities/suspend>. You may want to have 12<http://suspend.sourceforge.net>. You may want to have a look at them if you
13a look at them if you are going to develop your own suspend/resume 13are going to develop your own suspend/resume utilities.
14utilities.
15 14
16The interface consists of a character device providing the open(), 15The interface consists of a character device providing the open(),
17release(), read(), and write() operations as well as several ioctl() 16release(), read(), and write() operations as well as several ioctl()
@@ -21,9 +20,9 @@ be read from /sys/class/misc/snapshot/dev.
21 20
22The device can be open either for reading or for writing. If open for 21The device can be open either for reading or for writing. If open for
23reading, it is considered to be in the suspend mode. Otherwise it is 22reading, it is considered to be in the suspend mode. Otherwise it is
24assumed to be in the resume mode. The device cannot be open for reading 23assumed to be in the resume mode. The device cannot be open for simultaneous
25and writing. It is also impossible to have the device open more than once 24reading and writing. It is also impossible to have the device open more than
26at a time. 25once at a time.
27 26
28The ioctl() commands recognized by the device are: 27The ioctl() commands recognized by the device are:
29 28
@@ -69,9 +68,46 @@ SNAPSHOT_FREE_SWAP_PAGES - free all swap pages allocated with
69SNAPSHOT_SET_SWAP_FILE - set the resume partition (the last ioctl() argument 68SNAPSHOT_SET_SWAP_FILE - set the resume partition (the last ioctl() argument
70 should specify the device's major and minor numbers in the old 69 should specify the device's major and minor numbers in the old
71 two-byte format, as returned by the stat() function in the .st_rdev 70 two-byte format, as returned by the stat() function in the .st_rdev
72 member of the stat structure); it is recommended to always use this 71 member of the stat structure)
73 call, because the code to set the resume partition could be removed from 72
74 future kernels 73SNAPSHOT_SET_SWAP_AREA - set the resume partition and the offset (in <PAGE_SIZE>
74 units) from the beginning of the partition at which the swap header is
75 located (the last ioctl() argument should point to a struct
76 resume_swap_area, as defined in kernel/power/power.h, containing the
77 resume device specification, as for the SNAPSHOT_SET_SWAP_FILE ioctl(),
78 and the offset); for swap partitions the offset is always 0, but it is
79 different to zero for swap files (please see
80 Documentation/swsusp-and-swap-files.txt for details).
81 The SNAPSHOT_SET_SWAP_AREA ioctl() is considered as a replacement for
82 SNAPSHOT_SET_SWAP_FILE which is regarded as obsolete. It is
83 recommended to always use this call, because the code to set the resume
84 partition may be removed from future kernels
85
86SNAPSHOT_S2RAM - suspend to RAM; using this call causes the kernel to
87 immediately enter the suspend-to-RAM state, so this call must always
88 be preceded by the SNAPSHOT_FREEZE call and it is also necessary
89 to use the SNAPSHOT_UNFREEZE call after the system wakes up. This call
90 is needed to implement the suspend-to-both mechanism in which the
91 suspend image is first created, as though the system had been suspended
92 to disk, and then the system is suspended to RAM (this makes it possible
93 to resume the system from RAM if there's enough battery power or restore
94 its state on the basis of the saved suspend image otherwise)
95
96SNAPSHOT_PMOPS - enable the usage of the pmops->prepare, pmops->enter and
97 pmops->finish methods (the in-kernel swsusp knows these as the "platform
98 method") which are needed on many machines to (among others) speed up
99 the resume by letting the BIOS skip some steps or to let the system
100 recognise the correct state of the hardware after the resume (in
101 particular on many machines this ensures that unplugged AC
102 adapters get correctly detected and that kacpid does not run wild after
103 the resume). The last ioctl() argument can take one of the three
104 values, defined in kernel/power/power.h:
105 PMOPS_PREPARE - make the kernel carry out the
106 pm_ops->prepare(PM_SUSPEND_DISK) operation
107 PMOPS_ENTER - make the kernel power off the system by calling
108 pm_ops->enter(PM_SUSPEND_DISK)
109 PMOPS_FINISH - make the kernel carry out the
110 pm_ops->finish(PM_SUSPEND_DISK) operation
75 111
76The device's read() operation can be used to transfer the snapshot image from 112The device's read() operation can be used to transfer the snapshot image from
77the kernel. It has the following limitations: 113the kernel. It has the following limitations:
@@ -91,10 +127,12 @@ unfreeze user space processes frozen by SNAPSHOT_UNFREEZE if they are
91still frozen when the device is being closed). 127still frozen when the device is being closed).
92 128
93Currently it is assumed that the userland utilities reading/writing the 129Currently it is assumed that the userland utilities reading/writing the
94snapshot image from/to the kernel will use a swap partition, called the resume 130snapshot image from/to the kernel will use a swap parition, called the resume
95partition, as storage space. However, this is not really required, as they 131partition, or a swap file as storage space (if a swap file is used, the resume
96can use, for example, a special (blank) suspend partition or a file on a partition 132partition is the partition that holds this file). However, this is not really
97that is unmounted before SNAPSHOT_ATOMIC_SNAPSHOT and mounted afterwards. 133required, as they can use, for example, a special (blank) suspend partition or
134a file on a partition that is unmounted before SNAPSHOT_ATOMIC_SNAPSHOT and
135mounted afterwards.
98 136
99These utilities SHOULD NOT make any assumptions regarding the ordering of 137These utilities SHOULD NOT make any assumptions regarding the ordering of
100data within the snapshot image, except for the image header that MAY be 138data within the snapshot image, except for the image header that MAY be
diff --git a/MAINTAINERS b/MAINTAINERS
index 5dff26814a06..cf24400213f8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1091,13 +1091,19 @@ M: miku@iki.fi
1091S: Maintained 1091S: Maintained
1092 1092
1093EXT2 FILE SYSTEM 1093EXT2 FILE SYSTEM
1094L: ext2-devel@lists.sourceforge.net 1094L: linux-ext4@vger.kernel.org
1095S: Maintained 1095S: Maintained
1096 1096
1097EXT3 FILE SYSTEM 1097EXT3 FILE SYSTEM
1098P: Stephen Tweedie, Andrew Morton 1098P: Stephen Tweedie, Andrew Morton
1099M: sct@redhat.com, akpm@osdl.org, adilger@clusterfs.com 1099M: sct@redhat.com, akpm@osdl.org, adilger@clusterfs.com
1100L: ext2-devel@lists.sourceforge.net 1100L: linux-ext4@vger.kernel.org
1101S: Maintained
1102
1103EXT4 FILE SYSTEM
1104P: Stephen Tweedie, Andrew Morton
1105M: sct@redhat.com, akpm@osdl.org, adilger@clusterfs.com
1106L: linux-ext4@vger.kernel.org
1101S: Maintained 1107S: Maintained
1102 1108
1103F71805F HARDWARE MONITORING DRIVER 1109F71805F HARDWARE MONITORING DRIVER
@@ -1214,7 +1220,8 @@ HARDWARE MONITORING
1214P: Jean Delvare 1220P: Jean Delvare
1215M: khali@linux-fr.org 1221M: khali@linux-fr.org
1216L: lm-sensors@lm-sensors.org 1222L: lm-sensors@lm-sensors.org
1217W: http://www.lm-sensors.nu/ 1223W: http://www.lm-sensors.org/
1224T: quilt http://khali.linux-fr.org/devel/linux-2.6/jdelvare-hwmon/
1218S: Maintained 1225S: Maintained
1219 1226
1220HARDWARE RANDOM NUMBER GENERATOR CORE 1227HARDWARE RANDOM NUMBER GENERATOR CORE
@@ -1340,8 +1347,7 @@ I2C SUBSYSTEM
1340P: Jean Delvare 1347P: Jean Delvare
1341M: khali@linux-fr.org 1348M: khali@linux-fr.org
1342L: i2c@lm-sensors.org 1349L: i2c@lm-sensors.org
1343W: http://www.lm-sensors.nu/ 1350T: quilt http://khali.linux-fr.org/devel/linux-2.6/jdelvare-i2c/
1344T: quilt kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/
1345S: Maintained 1351S: Maintained
1346 1352
1347I2O 1353I2O
@@ -1673,7 +1679,7 @@ S: Supported
1673JOURNALLING LAYER FOR BLOCK DEVICES (JBD) 1679JOURNALLING LAYER FOR BLOCK DEVICES (JBD)
1674P: Stephen Tweedie, Andrew Morton 1680P: Stephen Tweedie, Andrew Morton
1675M: sct@redhat.com, akpm@osdl.org 1681M: sct@redhat.com, akpm@osdl.org
1676L: ext2-devel@lists.sourceforge.net 1682L: linux-ext4@vger.kernel.org
1677S: Maintained 1683S: Maintained
1678 1684
1679K8TEMP HARDWARE MONITORING DRIVER 1685K8TEMP HARDWARE MONITORING DRIVER
@@ -2913,7 +2919,6 @@ S: Maintained
2913SUN3/3X 2919SUN3/3X
2914P: Sam Creasey 2920P: Sam Creasey
2915M: sammy@sammy.net 2921M: sammy@sammy.net
2916L: sun3-list@redhat.com
2917W: http://sammy.net/sun3/ 2922W: http://sammy.net/sun3/
2918S: Maintained 2923S: Maintained
2919 2924
@@ -3454,6 +3459,12 @@ W: http://oss.sgi.com/projects/xfs
3454T: git git://oss.sgi.com:8090/xfs/xfs-2.6 3459T: git git://oss.sgi.com:8090/xfs/xfs-2.6
3455S: Supported 3460S: Supported
3456 3461
3462XILINX UARTLITE SERIAL DRIVER
3463P: Peter Korsgaard
3464M: jacmet@sunsite.dk
3465L: linux-serial@vger.kernel.org
3466S: Maintained
3467
3457X86 3-LEVEL PAGING (PAE) SUPPORT 3468X86 3-LEVEL PAGING (PAE) SUPPORT
3458P: Ingo Molnar 3469P: Ingo Molnar
3459M: mingo@redhat.com 3470M: mingo@redhat.com
diff --git a/README b/README
index 3e264723b863..c05561523029 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
1 Linux kernel release 2.6.xx <http://kernel.org> 1 Linux kernel release 2.6.xx <http://kernel.org/>
2 2
3These are the release notes for Linux version 2.6. Read them carefully, 3These are the release notes for Linux version 2.6. Read them carefully,
4as they tell you what this is all about, explain how to install the 4as they tell you what this is all about, explain how to install the
@@ -22,15 +22,17 @@ ON WHAT HARDWARE DOES IT RUN?
22 22
23 Although originally developed first for 32-bit x86-based PCs (386 or higher), 23 Although originally developed first for 32-bit x86-based PCs (386 or higher),
24 today Linux also runs on (at least) the Compaq Alpha AXP, Sun SPARC and 24 today Linux also runs on (at least) the Compaq Alpha AXP, Sun SPARC and
25 UltraSPARC, Motorola 68000, PowerPC, PowerPC64, ARM, Hitachi SuperH, 25 UltraSPARC, Motorola 68000, PowerPC, PowerPC64, ARM, Hitachi SuperH, Cell,
26 IBM S/390, MIPS, HP PA-RISC, Intel IA-64, DEC VAX, AMD x86-64, AXIS CRIS, 26 IBM S/390, MIPS, HP PA-RISC, Intel IA-64, DEC VAX, AMD x86-64, AXIS CRIS,
27 and Renesas M32R architectures. 27 Cris, Xtensa, AVR32 and Renesas M32R architectures.
28 28
29 Linux is easily portable to most general-purpose 32- or 64-bit architectures 29 Linux is easily portable to most general-purpose 32- or 64-bit architectures
30 as long as they have a paged memory management unit (PMMU) and a port of the 30 as long as they have a paged memory management unit (PMMU) and a port of the
31 GNU C compiler (gcc) (part of The GNU Compiler Collection, GCC). Linux has 31 GNU C compiler (gcc) (part of The GNU Compiler Collection, GCC). Linux has
32 also been ported to a number of architectures without a PMMU, although 32 also been ported to a number of architectures without a PMMU, although
33 functionality is then obviously somewhat limited. 33 functionality is then obviously somewhat limited.
34 Linux has also been ported to itself. You can now run the kernel as a
35 userspace application - this is called UserMode Linux (UML).
34 36
35DOCUMENTATION: 37DOCUMENTATION:
36 38
@@ -113,6 +115,7 @@ INSTALLING the kernel:
113 version 2.6.12.2 and want to jump to 2.6.12.3, you must first 115 version 2.6.12.2 and want to jump to 2.6.12.3, you must first
114 reverse the 2.6.12.2 patch (that is, patch -R) _before_ applying 116 reverse the 2.6.12.2 patch (that is, patch -R) _before_ applying
115 the 2.6.12.3 patch. 117 the 2.6.12.3 patch.
118 You can read more on this in Documentation/applying-patches.txt
116 119
117 - Make sure you have no stale .o files and dependencies lying around: 120 - Make sure you have no stale .o files and dependencies lying around:
118 121
@@ -161,6 +164,7 @@ CONFIGURING the kernel:
161 only ask you for the answers to new questions. 164 only ask you for the answers to new questions.
162 165
163 - Alternate configuration commands are: 166 - Alternate configuration commands are:
167 "make config" Plain text interface.
164 "make menuconfig" Text based color menus, radiolists & dialogs. 168 "make menuconfig" Text based color menus, radiolists & dialogs.
165 "make xconfig" X windows (Qt) based configuration tool. 169 "make xconfig" X windows (Qt) based configuration tool.
166 "make gconfig" X windows (Gtk) based configuration tool. 170 "make gconfig" X windows (Gtk) based configuration tool.
@@ -303,8 +307,9 @@ IF SOMETHING GOES WRONG:
303 307
304 - If you compiled the kernel with CONFIG_KALLSYMS you can send the dump 308 - If you compiled the kernel with CONFIG_KALLSYMS you can send the dump
305 as is, otherwise you will have to use the "ksymoops" program to make 309 as is, otherwise you will have to use the "ksymoops" program to make
306 sense of the dump. This utility can be downloaded from 310 sense of the dump (but compiling with CONFIG_KALLSYMS is usually preferred).
307 ftp://ftp.<country>.kernel.org/pub/linux/utils/kernel/ksymoops. 311 This utility can be downloaded from
312 ftp://ftp.<country>.kernel.org/pub/linux/utils/kernel/ksymoops/ .
308 Alternately you can do the dump lookup by hand: 313 Alternately you can do the dump lookup by hand:
309 314
310 - In debugging dumps like the above, it helps enormously if you can 315 - In debugging dumps like the above, it helps enormously if you can
@@ -336,7 +341,7 @@ IF SOMETHING GOES WRONG:
336 341
337 If you for some reason cannot do the above (you have a pre-compiled 342 If you for some reason cannot do the above (you have a pre-compiled
338 kernel image or similar), telling me as much about your setup as 343 kernel image or similar), telling me as much about your setup as
339 possible will help. 344 possible will help. Please read the REPORTING-BUGS document for details.
340 345
341 - Alternately, you can use gdb on a running kernel. (read-only; i.e. you 346 - Alternately, you can use gdb on a running kernel. (read-only; i.e. you
342 cannot change values or set break points.) To do this, first compile the 347 cannot change values or set break points.) To do this, first compile the
diff --git a/REPORTING-BUGS b/REPORTING-BUGS
index f9da827a0c18..ac02e42a2627 100644
--- a/REPORTING-BUGS
+++ b/REPORTING-BUGS
@@ -40,7 +40,9 @@ summary from [1.]>" for easy identification by the developers.
40[1.] One line summary of the problem: 40[1.] One line summary of the problem:
41[2.] Full description of the problem/report: 41[2.] Full description of the problem/report:
42[3.] Keywords (i.e., modules, networking, kernel): 42[3.] Keywords (i.e., modules, networking, kernel):
43[4.] Kernel version (from /proc/version): 43[4.] Kernel information
44[4.1.] Kernel version (from /proc/version):
45[4.2.] Kernel .config file:
44[5.] Most recent kernel version which did not have the bug: 46[5.] Most recent kernel version which did not have the bug:
45[6.] Output of Oops.. message (if applicable) with symbolic information 47[6.] Output of Oops.. message (if applicable) with symbolic information
46 resolved (see Documentation/oops-tracing.txt) 48 resolved (see Documentation/oops-tracing.txt)
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index ffb7d5423cc0..3c10b9a1ddf5 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -516,10 +516,11 @@ sys_pciconfig_iobase(long which, unsigned long bus, unsigned long dfn)
516 if (bus == 0 && dfn == 0) { 516 if (bus == 0 && dfn == 0) {
517 hose = pci_isa_hose; 517 hose = pci_isa_hose;
518 } else { 518 } else {
519 dev = pci_find_slot(bus, dfn); 519 dev = pci_get_bus_and_slot(bus, dfn);
520 if (!dev) 520 if (!dev)
521 return -ENODEV; 521 return -ENODEV;
522 hose = dev->sysdata; 522 hose = dev->sysdata;
523 pci_dev_put(dev);
523 } 524 }
524 } 525 }
525 526
diff --git a/arch/alpha/kernel/sys_miata.c b/arch/alpha/kernel/sys_miata.c
index b8b817feb1ee..910b43cd63e8 100644
--- a/arch/alpha/kernel/sys_miata.c
+++ b/arch/alpha/kernel/sys_miata.c
@@ -183,11 +183,15 @@ miata_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
183 183
184 if((slot == 7) && (PCI_FUNC(dev->devfn) == 3)) { 184 if((slot == 7) && (PCI_FUNC(dev->devfn) == 3)) {
185 u8 irq=0; 185 u8 irq=0;
186 186 struct pci_dev *pdev = pci_get_slot(dev->bus, dev->devfn & ~7);
187 if(pci_read_config_byte(pci_find_slot(dev->bus->number, dev->devfn & ~(7)), 0x40,&irq)!=PCIBIOS_SUCCESSFUL) 187 if(pdev == NULL || pci_read_config_byte(pdev, 0x40,&irq) != PCIBIOS_SUCCESSFUL) {
188 pci_dev_put(pdev);
188 return -1; 189 return -1;
189 else 190 }
191 else {
192 pci_dev_put(pdev);
190 return irq; 193 return irq;
194 }
191 } 195 }
192 196
193 return COMMON_TABLE_LOOKUP; 197 return COMMON_TABLE_LOOKUP;
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 93744bab73fb..e7594a7cf585 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -200,7 +200,7 @@ nautilus_init_pci(void)
200 bus = pci_scan_bus(0, alpha_mv.pci_ops, hose); 200 bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
201 hose->bus = bus; 201 hose->bus = bus;
202 202
203 irongate = pci_find_slot(0, 0); 203 irongate = pci_get_bus_and_slot(0, 0);
204 bus->self = irongate; 204 bus->self = irongate;
205 bus->resource[1] = &irongate_mem; 205 bus->resource[1] = &irongate_mem;
206 206
diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
index 8871529a34e2..8aa9db834c11 100644
--- a/arch/alpha/mm/fault.c
+++ b/arch/alpha/mm/fault.c
@@ -108,7 +108,7 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
108 108
109 /* If we're in an interrupt context, or have no user context, 109 /* If we're in an interrupt context, or have no user context,
110 we must not take the fault. */ 110 we must not take the fault. */
111 if (!mm || in_interrupt()) 111 if (!mm || in_atomic())
112 goto no_context; 112 goto no_context;
113 113
114#ifdef CONFIG_ALPHA_LARGE_VMALLOC 114#ifdef CONFIG_ALPHA_LARGE_VMALLOC
diff --git a/arch/arm/common/sharpsl_pm.c b/arch/arm/common/sharpsl_pm.c
index 605dedf96790..b3599743093b 100644
--- a/arch/arm/common/sharpsl_pm.c
+++ b/arch/arm/common/sharpsl_pm.c
@@ -60,16 +60,16 @@ static int sharpsl_ac_check(void);
60static int sharpsl_fatal_check(void); 60static int sharpsl_fatal_check(void);
61static int sharpsl_average_value(int ad); 61static int sharpsl_average_value(int ad);
62static void sharpsl_average_clear(void); 62static void sharpsl_average_clear(void);
63static void sharpsl_charge_toggle(void *private_); 63static void sharpsl_charge_toggle(struct work_struct *private_);
64static void sharpsl_battery_thread(void *private_); 64static void sharpsl_battery_thread(struct work_struct *private_);
65 65
66 66
67/* 67/*
68 * Variables 68 * Variables
69 */ 69 */
70struct sharpsl_pm_status sharpsl_pm; 70struct sharpsl_pm_status sharpsl_pm;
71DECLARE_WORK(toggle_charger, sharpsl_charge_toggle, NULL); 71DECLARE_DELAYED_WORK(toggle_charger, sharpsl_charge_toggle);
72DECLARE_WORK(sharpsl_bat, sharpsl_battery_thread, NULL); 72DECLARE_DELAYED_WORK(sharpsl_bat, sharpsl_battery_thread);
73DEFINE_LED_TRIGGER(sharpsl_charge_led_trigger); 73DEFINE_LED_TRIGGER(sharpsl_charge_led_trigger);
74 74
75 75
@@ -116,7 +116,7 @@ void sharpsl_battery_kick(void)
116EXPORT_SYMBOL(sharpsl_battery_kick); 116EXPORT_SYMBOL(sharpsl_battery_kick);
117 117
118 118
119static void sharpsl_battery_thread(void *private_) 119static void sharpsl_battery_thread(struct work_struct *private_)
120{ 120{
121 int voltage, percent, apm_status, i = 0; 121 int voltage, percent, apm_status, i = 0;
122 122
@@ -128,7 +128,7 @@ static void sharpsl_battery_thread(void *private_)
128 /* Corgi cannot confirm when battery fully charged so periodically kick! */ 128 /* Corgi cannot confirm when battery fully charged so periodically kick! */
129 if (!sharpsl_pm.machinfo->batfull_irq && (sharpsl_pm.charge_mode == CHRG_ON) 129 if (!sharpsl_pm.machinfo->batfull_irq && (sharpsl_pm.charge_mode == CHRG_ON)
130 && time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_ON_TIME_INTERVAL)) 130 && time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_ON_TIME_INTERVAL))
131 schedule_work(&toggle_charger); 131 schedule_delayed_work(&toggle_charger, 0);
132 132
133 while(1) { 133 while(1) {
134 voltage = sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT); 134 voltage = sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT);
@@ -212,7 +212,7 @@ static void sharpsl_charge_off(void)
212 sharpsl_pm_led(SHARPSL_LED_OFF); 212 sharpsl_pm_led(SHARPSL_LED_OFF);
213 sharpsl_pm.charge_mode = CHRG_OFF; 213 sharpsl_pm.charge_mode = CHRG_OFF;
214 214
215 schedule_work(&sharpsl_bat); 215 schedule_delayed_work(&sharpsl_bat, 0);
216} 216}
217 217
218static void sharpsl_charge_error(void) 218static void sharpsl_charge_error(void)
@@ -222,7 +222,7 @@ static void sharpsl_charge_error(void)
222 sharpsl_pm.charge_mode = CHRG_ERROR; 222 sharpsl_pm.charge_mode = CHRG_ERROR;
223} 223}
224 224
225static void sharpsl_charge_toggle(void *private_) 225static void sharpsl_charge_toggle(struct work_struct *private_)
226{ 226{
227 dev_dbg(sharpsl_pm.dev, "Toogling Charger at time: %lx\n", jiffies); 227 dev_dbg(sharpsl_pm.dev, "Toogling Charger at time: %lx\n", jiffies);
228 228
@@ -254,7 +254,7 @@ static void sharpsl_ac_timer(unsigned long data)
254 else if (sharpsl_pm.charge_mode == CHRG_ON) 254 else if (sharpsl_pm.charge_mode == CHRG_ON)
255 sharpsl_charge_off(); 255 sharpsl_charge_off();
256 256
257 schedule_work(&sharpsl_bat); 257 schedule_delayed_work(&sharpsl_bat, 0);
258} 258}
259 259
260 260
@@ -279,10 +279,10 @@ static void sharpsl_chrg_full_timer(unsigned long data)
279 sharpsl_charge_off(); 279 sharpsl_charge_off();
280 } else if (sharpsl_pm.full_count < 2) { 280 } else if (sharpsl_pm.full_count < 2) {
281 dev_dbg(sharpsl_pm.dev, "Charge Full: Count too low\n"); 281 dev_dbg(sharpsl_pm.dev, "Charge Full: Count too low\n");
282 schedule_work(&toggle_charger); 282 schedule_delayed_work(&toggle_charger, 0);
283 } else if (time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_FINISH_TIME)) { 283 } else if (time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_FINISH_TIME)) {
284 dev_dbg(sharpsl_pm.dev, "Charge Full: Interrupt generated too slowly - retry.\n"); 284 dev_dbg(sharpsl_pm.dev, "Charge Full: Interrupt generated too slowly - retry.\n");
285 schedule_work(&toggle_charger); 285 schedule_delayed_work(&toggle_charger, 0);
286 } else { 286 } else {
287 sharpsl_charge_off(); 287 sharpsl_charge_off();
288 sharpsl_pm.charge_mode = CHRG_DONE; 288 sharpsl_pm.charge_mode = CHRG_DONE;
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index 48cf7fffddf2..f38a60a03b8c 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -11,6 +11,7 @@
11#include <linux/signal.h> 11#include <linux/signal.h>
12#include <linux/ptrace.h> 12#include <linux/ptrace.h>
13#include <linux/personality.h> 13#include <linux/personality.h>
14#include <linux/freezer.h>
14 15
15#include <asm/cacheflush.h> 16#include <asm/cacheflush.h>
16#include <asm/ucontext.h> 17#include <asm/ucontext.h>
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index f225a083dee1..9d2346fb68f4 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -323,7 +323,8 @@ static int h3_transceiver_mode(struct device *dev, int mode)
323 323
324 cancel_delayed_work(&irda_config->gpio_expa); 324 cancel_delayed_work(&irda_config->gpio_expa);
325 PREPARE_WORK(&irda_config->gpio_expa, set_trans_mode, &mode); 325 PREPARE_WORK(&irda_config->gpio_expa, set_trans_mode, &mode);
326 schedule_work(&irda_config->gpio_expa); 326#error this is not permitted - mode is an argument variable
327 schedule_delayed_work(&irda_config->gpio_expa, 0);
327 328
328 return 0; 329 return 0;
329} 330}
diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index dbc555d209ff..cbe909bad79b 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -74,7 +74,7 @@ static struct omap_kp_platform_data nokia770_kp_data = {
74 .rows = 8, 74 .rows = 8,
75 .cols = 8, 75 .cols = 8,
76 .keymap = nokia770_keymap, 76 .keymap = nokia770_keymap,
77 .keymapsize = ARRAY_SIZE(nokia770_keymap) 77 .keymapsize = ARRAY_SIZE(nokia770_keymap),
78 .delay = 4, 78 .delay = 4,
79}; 79};
80 80
@@ -191,7 +191,7 @@ static void nokia770_audio_pwr_up(void)
191 printk("HP connected\n"); 191 printk("HP connected\n");
192} 192}
193 193
194static void codec_delayed_power_down(void *arg) 194static void codec_delayed_power_down(struct work_struct *work)
195{ 195{
196 down(&audio_pwr_sem); 196 down(&audio_pwr_sem);
197 if (audio_pwr_state == -1) 197 if (audio_pwr_state == -1)
@@ -200,7 +200,7 @@ static void codec_delayed_power_down(void *arg)
200 up(&audio_pwr_sem); 200 up(&audio_pwr_sem);
201} 201}
202 202
203static DECLARE_WORK(codec_power_down_work, codec_delayed_power_down, NULL); 203static DECLARE_DELAYED_WORK(codec_power_down_work, codec_delayed_power_down);
204 204
205static void nokia770_audio_pwr_down(void) 205static void nokia770_audio_pwr_down(void)
206{ 206{
diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c
index a611c3b63954..6dcd10ab4496 100644
--- a/arch/arm/mach-omap1/devices.c
+++ b/arch/arm/mach-omap1/devices.c
@@ -55,7 +55,7 @@ static inline void omap_init_irda(void) {}
55 55
56/*-------------------------------------------------------------------------*/ 56/*-------------------------------------------------------------------------*/
57 57
58#if defined(CONFIG_OMAP_RTC) || defined(CONFIG_OMAP_RTC) 58#if defined(CONFIG_RTC_DRV_OMAP) || defined(CONFIG_RTC_DRV_OMAP_MODULE)
59 59
60#define OMAP_RTC_BASE 0xfffb4800 60#define OMAP_RTC_BASE 0xfffb4800
61 61
diff --git a/arch/arm/mach-omap1/leds-osk.c b/arch/arm/mach-omap1/leds-osk.c
index 3b29e59b0e6f..0cbf1b0071f8 100644
--- a/arch/arm/mach-omap1/leds-osk.c
+++ b/arch/arm/mach-omap1/leds-osk.c
@@ -35,7 +35,7 @@ static u8 hw_led_state;
35 35
36static u8 tps_leds_change; 36static u8 tps_leds_change;
37 37
38static void tps_work(void *unused) 38static void tps_work(struct work_struct *unused)
39{ 39{
40 for (;;) { 40 for (;;) {
41 u8 leds; 41 u8 leds;
@@ -61,7 +61,7 @@ static void tps_work(void *unused)
61 } 61 }
62} 62}
63 63
64static DECLARE_WORK(work, tps_work, NULL); 64static DECLARE_WORK(work, tps_work);
65 65
66#ifdef CONFIG_OMAP_OSK_MISTRAL 66#ifdef CONFIG_OMAP_OSK_MISTRAL
67 67
diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c
index 26a95a642ad7..3b1ad1d981a3 100644
--- a/arch/arm/mach-omap2/board-h4.c
+++ b/arch/arm/mach-omap2/board-h4.c
@@ -206,7 +206,8 @@ static int h4_transceiver_mode(struct device *dev, int mode)
206 206
207 cancel_delayed_work(&irda_config->gpio_expa); 207 cancel_delayed_work(&irda_config->gpio_expa);
208 PREPARE_WORK(&irda_config->gpio_expa, set_trans_mode, &mode); 208 PREPARE_WORK(&irda_config->gpio_expa, set_trans_mode, &mode);
209 schedule_work(&irda_config->gpio_expa); 209#error this is not permitted - mode is an argument variable
210 schedule_delayed_work(&irda_config->gpio_expa, 0);
210 211
211 return 0; 212 return 0;
212} 213}
diff --git a/arch/arm/mach-pxa/akita-ioexp.c b/arch/arm/mach-pxa/akita-ioexp.c
index 1b398742ab56..12d2fe0ceff6 100644
--- a/arch/arm/mach-pxa/akita-ioexp.c
+++ b/arch/arm/mach-pxa/akita-ioexp.c
@@ -36,11 +36,11 @@ I2C_CLIENT_INSMOD;
36 36
37static int max7310_write(struct i2c_client *client, int address, int data); 37static int max7310_write(struct i2c_client *client, int address, int data);
38static struct i2c_client max7310_template; 38static struct i2c_client max7310_template;
39static void akita_ioexp_work(void *private_); 39static void akita_ioexp_work(struct work_struct *private_);
40 40
41static struct device *akita_ioexp_device; 41static struct device *akita_ioexp_device;
42static unsigned char ioexp_output_value = AKITA_IOEXP_IO_OUT; 42static unsigned char ioexp_output_value = AKITA_IOEXP_IO_OUT;
43DECLARE_WORK(akita_ioexp, akita_ioexp_work, NULL); 43DECLARE_WORK(akita_ioexp, akita_ioexp_work);
44 44
45 45
46/* 46/*
@@ -158,7 +158,7 @@ void akita_reset_ioexp(struct device *dev, unsigned char bit)
158EXPORT_SYMBOL(akita_set_ioexp); 158EXPORT_SYMBOL(akita_set_ioexp);
159EXPORT_SYMBOL(akita_reset_ioexp); 159EXPORT_SYMBOL(akita_reset_ioexp);
160 160
161static void akita_ioexp_work(void *private_) 161static void akita_ioexp_work(struct work_struct *private_)
162{ 162{
163 if (akita_ioexp_device) 163 if (akita_ioexp_device)
164 max7310_set_ouputs(akita_ioexp_device, ioexp_output_value); 164 max7310_set_ouputs(akita_ioexp_device, ioexp_output_value);
diff --git a/arch/arm/mach-s3c2410/dma.c b/arch/arm/mach-s3c2410/dma.c
index 3d211dc2f2f9..01abb0ace234 100644
--- a/arch/arm/mach-s3c2410/dma.c
+++ b/arch/arm/mach-s3c2410/dma.c
@@ -40,7 +40,7 @@
40 40
41/* io map for dma */ 41/* io map for dma */
42static void __iomem *dma_base; 42static void __iomem *dma_base;
43static kmem_cache_t *dma_kmem; 43static struct kmem_cache *dma_kmem;
44 44
45struct s3c24xx_dma_selection dma_sel; 45struct s3c24xx_dma_selection dma_sel;
46 46
@@ -1271,7 +1271,7 @@ struct sysdev_class dma_sysclass = {
1271 1271
1272/* kmem cache implementation */ 1272/* kmem cache implementation */
1273 1273
1274static void s3c2410_dma_cache_ctor(void *p, kmem_cache_t *c, unsigned long f) 1274static void s3c2410_dma_cache_ctor(void *p, struct kmem_cache *c, unsigned long f)
1275{ 1275{
1276 memset(p, 0, sizeof(struct s3c2410_dma_buf)); 1276 memset(p, 0, sizeof(struct s3c2410_dma_buf));
1277} 1277}
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index 5e658a874498..9fd6d2eafb40 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -230,7 +230,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
230 * If we're in an interrupt or have no user 230 * If we're in an interrupt or have no user
231 * context, we must not take the fault.. 231 * context, we must not take the fault..
232 */ 232 */
233 if (in_interrupt() || !mm) 233 if (in_atomic() || !mm)
234 goto no_context; 234 goto no_context;
235 235
236 /* 236 /*
diff --git a/arch/arm26/kernel/ecard.c b/arch/arm26/kernel/ecard.c
index 047d0a408b9d..43dd41be71fb 100644
--- a/arch/arm26/kernel/ecard.c
+++ b/arch/arm26/kernel/ecard.c
@@ -620,12 +620,10 @@ ecard_probe(int slot, card_type_t type)
620 struct ex_ecid cid; 620 struct ex_ecid cid;
621 int i, rc = -ENOMEM; 621 int i, rc = -ENOMEM;
622 622
623 ec = kmalloc(sizeof(ecard_t), GFP_KERNEL); 623 ec = kzalloc(sizeof(ecard_t), GFP_KERNEL);
624 if (!ec) 624 if (!ec)
625 goto nomem; 625 goto nomem;
626 626
627 memset(ec, 0, sizeof(ecard_t));
628
629 ec->slot_no = slot; 627 ec->slot_no = slot;
630 ec->type = type; 628 ec->type = type;
631 ec->irq = NO_IRQ; 629 ec->irq = NO_IRQ;
diff --git a/arch/arm26/mm/fault.c b/arch/arm26/mm/fault.c
index a1f6d8a9cc32..93c0cee0fb5e 100644
--- a/arch/arm26/mm/fault.c
+++ b/arch/arm26/mm/fault.c
@@ -215,7 +215,7 @@ int do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
215 * If we're in an interrupt or have no user 215 * If we're in an interrupt or have no user
216 * context, we must not take the fault.. 216 * context, we must not take the fault..
217 */ 217 */
218 if (in_interrupt() || !mm) 218 if (in_atomic() || !mm)
219 goto no_context; 219 goto no_context;
220 220
221 down_read(&mm->mmap_sem); 221 down_read(&mm->mmap_sem);
diff --git a/arch/arm26/mm/memc.c b/arch/arm26/mm/memc.c
index 34def6397c3c..f2901581d4da 100644
--- a/arch/arm26/mm/memc.c
+++ b/arch/arm26/mm/memc.c
@@ -24,7 +24,7 @@
24 24
25#define MEMC_TABLE_SIZE (256*sizeof(unsigned long)) 25#define MEMC_TABLE_SIZE (256*sizeof(unsigned long))
26 26
27kmem_cache_t *pte_cache, *pgd_cache; 27struct kmem_cache *pte_cache, *pgd_cache;
28int page_nr; 28int page_nr;
29 29
30/* 30/*
@@ -162,12 +162,12 @@ void __init create_memmap_holes(struct meminfo *mi)
162{ 162{
163} 163}
164 164
165static void pte_cache_ctor(void *pte, kmem_cache_t *cache, unsigned long flags) 165static void pte_cache_ctor(void *pte, struct kmem_cache *cache, unsigned long flags)
166{ 166{
167 memzero(pte, sizeof(pte_t) * PTRS_PER_PTE); 167 memzero(pte, sizeof(pte_t) * PTRS_PER_PTE);
168} 168}
169 169
170static void pgd_cache_ctor(void *pgd, kmem_cache_t *cache, unsigned long flags) 170static void pgd_cache_ctor(void *pgd, struct kmem_cache *cache, unsigned long flags)
171{ 171{
172 memzero(pgd + MEMC_TABLE_SIZE, USER_PTRS_PER_PGD * sizeof(pgd_t)); 172 memzero(pgd + MEMC_TABLE_SIZE, USER_PTRS_PER_PGD * sizeof(pgd_t));
173} 173}
diff --git a/arch/avr32/kernel/kprobes.c b/arch/avr32/kernel/kprobes.c
index ca41fc1edbe1..d0abbcaf1c1e 100644
--- a/arch/avr32/kernel/kprobes.c
+++ b/arch/avr32/kernel/kprobes.c
@@ -154,6 +154,7 @@ ss_probe:
154 return 1; 154 return 1;
155 155
156no_kprobe: 156no_kprobe:
157 preempt_enable_no_resched();
157 return ret; 158 return ret;
158} 159}
159 160
diff --git a/arch/avr32/kernel/signal.c b/arch/avr32/kernel/signal.c
index 33096651c24f..0ec14854a200 100644
--- a/arch/avr32/kernel/signal.c
+++ b/arch/avr32/kernel/signal.c
@@ -15,7 +15,7 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/ptrace.h> 16#include <linux/ptrace.h>
17#include <linux/unistd.h> 17#include <linux/unistd.h>
18#include <linux/suspend.h> 18#include <linux/freezer.h>
19 19
20#include <asm/uaccess.h> 20#include <asm/uaccess.h>
21#include <asm/ucontext.h> 21#include <asm/ucontext.h>
diff --git a/arch/avr32/mm/dma-coherent.c b/arch/avr32/mm/dma-coherent.c
index 44ab8a7bdae2..b68d669f823d 100644
--- a/arch/avr32/mm/dma-coherent.c
+++ b/arch/avr32/mm/dma-coherent.c
@@ -11,7 +11,7 @@
11#include <asm/addrspace.h> 11#include <asm/addrspace.h>
12#include <asm/cacheflush.h> 12#include <asm/cacheflush.h>
13 13
14void dma_cache_sync(void *vaddr, size_t size, int direction) 14void dma_cache_sync(struct device *dev, void *vaddr, size_t size, int direction)
15{ 15{
16 /* 16 /*
17 * No need to sync an uncached area 17 * No need to sync an uncached area
diff --git a/arch/cris/mm/fault.c b/arch/cris/mm/fault.c
index 934c51078cce..c73e91f1299a 100644
--- a/arch/cris/mm/fault.c
+++ b/arch/cris/mm/fault.c
@@ -232,7 +232,7 @@ do_page_fault(unsigned long address, struct pt_regs *regs,
232 * context, we must not take the fault.. 232 * context, we must not take the fault..
233 */ 233 */
234 234
235 if (in_interrupt() || !mm) 235 if (in_atomic() || !mm)
236 goto no_context; 236 goto no_context;
237 237
238 down_read(&mm->mmap_sem); 238 down_read(&mm->mmap_sem);
diff --git a/arch/frv/kernel/futex.c b/arch/frv/kernel/futex.c
index eae874a970c6..14f64b054c7e 100644
--- a/arch/frv/kernel/futex.c
+++ b/arch/frv/kernel/futex.c
@@ -10,9 +10,9 @@
10 */ 10 */
11 11
12#include <linux/futex.h> 12#include <linux/futex.h>
13#include <linux/uaccess.h>
13#include <asm/futex.h> 14#include <asm/futex.h>
14#include <asm/errno.h> 15#include <asm/errno.h>
15#include <asm/uaccess.h>
16 16
17/* 17/*
18 * the various futex operations; MMU fault checking is ignored under no-MMU 18 * the various futex operations; MMU fault checking is ignored under no-MMU
@@ -200,7 +200,7 @@ int futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
200 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) 200 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
201 return -EFAULT; 201 return -EFAULT;
202 202
203 inc_preempt_count(); 203 pagefault_disable();
204 204
205 switch (op) { 205 switch (op) {
206 case FUTEX_OP_SET: 206 case FUTEX_OP_SET:
@@ -223,7 +223,7 @@ int futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
223 break; 223 break;
224 } 224 }
225 225
226 dec_preempt_count(); 226 pagefault_enable();
227 227
228 if (!ret) { 228 if (!ret) {
229 switch (cmp) { 229 switch (cmp) {
diff --git a/arch/frv/kernel/setup.c b/arch/frv/kernel/setup.c
index a8c61dac1cee..1a5eb6c301c9 100644
--- a/arch/frv/kernel/setup.c
+++ b/arch/frv/kernel/setup.c
@@ -947,7 +947,7 @@ static void __init setup_linux_memory(void)
947 if (LOADER_TYPE && INITRD_START) { 947 if (LOADER_TYPE && INITRD_START) {
948 if (INITRD_START + INITRD_SIZE <= (low_top_pfn << PAGE_SHIFT)) { 948 if (INITRD_START + INITRD_SIZE <= (low_top_pfn << PAGE_SHIFT)) {
949 reserve_bootmem(INITRD_START, INITRD_SIZE); 949 reserve_bootmem(INITRD_START, INITRD_SIZE);
950 initrd_start = INITRD_START ? INITRD_START + PAGE_OFFSET : 0; 950 initrd_start = INITRD_START + PAGE_OFFSET;
951 initrd_end = initrd_start + INITRD_SIZE; 951 initrd_end = initrd_start + INITRD_SIZE;
952 } 952 }
953 else { 953 else {
diff --git a/arch/frv/kernel/signal.c b/arch/frv/kernel/signal.c
index b8a5882b8625..85baeae9666a 100644
--- a/arch/frv/kernel/signal.c
+++ b/arch/frv/kernel/signal.c
@@ -21,7 +21,7 @@
21#include <linux/ptrace.h> 21#include <linux/ptrace.h>
22#include <linux/unistd.h> 22#include <linux/unistd.h>
23#include <linux/personality.h> 23#include <linux/personality.h>
24#include <linux/suspend.h> 24#include <linux/freezer.h>
25#include <asm/ucontext.h> 25#include <asm/ucontext.h>
26#include <asm/uaccess.h> 26#include <asm/uaccess.h>
27#include <asm/cacheflush.h> 27#include <asm/cacheflush.h>
diff --git a/arch/frv/mm/fault.c b/arch/frv/mm/fault.c
index 8b3eb50c5105..3f12296c3688 100644
--- a/arch/frv/mm/fault.c
+++ b/arch/frv/mm/fault.c
@@ -78,7 +78,7 @@ asmlinkage void do_page_fault(int datammu, unsigned long esr0, unsigned long ear
78 * If we're in an interrupt or have no user 78 * If we're in an interrupt or have no user
79 * context, we must not take the fault.. 79 * context, we must not take the fault..
80 */ 80 */
81 if (in_interrupt() || !mm) 81 if (in_atomic() || !mm)
82 goto no_context; 82 goto no_context;
83 83
84 down_read(&mm->mmap_sem); 84 down_read(&mm->mmap_sem);
diff --git a/arch/frv/mm/pgalloc.c b/arch/frv/mm/pgalloc.c
index f76dd03ddd99..19b13be114a2 100644
--- a/arch/frv/mm/pgalloc.c
+++ b/arch/frv/mm/pgalloc.c
@@ -18,7 +18,7 @@
18#include <asm/cacheflush.h> 18#include <asm/cacheflush.h>
19 19
20pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((aligned(PAGE_SIZE))); 20pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((aligned(PAGE_SIZE)));
21kmem_cache_t *pgd_cache; 21struct kmem_cache *pgd_cache;
22 22
23pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) 23pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
24{ 24{
@@ -100,7 +100,7 @@ static inline void pgd_list_del(pgd_t *pgd)
100 set_page_private(next, (unsigned long) pprev); 100 set_page_private(next, (unsigned long) pprev);
101} 101}
102 102
103void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused) 103void pgd_ctor(void *pgd, struct kmem_cache *cache, unsigned long unused)
104{ 104{
105 unsigned long flags; 105 unsigned long flags;
106 106
@@ -120,7 +120,7 @@ void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused)
120} 120}
121 121
122/* never called when PTRS_PER_PMD > 1 */ 122/* never called when PTRS_PER_PMD > 1 */
123void pgd_dtor(void *pgd, kmem_cache_t *cache, unsigned long unused) 123void pgd_dtor(void *pgd, struct kmem_cache *cache, unsigned long unused)
124{ 124{
125 unsigned long flags; /* can be called from interrupt context */ 125 unsigned long flags; /* can be called from interrupt context */
126 126
diff --git a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c
index 1077b71d5226..6adf8f41d2a1 100644
--- a/arch/h8300/kernel/setup.c
+++ b/arch/h8300/kernel/setup.c
@@ -116,7 +116,7 @@ void __init setup_arch(char **cmdline_p)
116#endif 116#endif
117#else 117#else
118 if ((memory_end < CONFIG_BLKDEV_RESERVE_ADDRESS) && 118 if ((memory_end < CONFIG_BLKDEV_RESERVE_ADDRESS) &&
119 (memory_end > CONFIG_BLKDEV_RESERVE_ADDRESS) 119 (memory_end > CONFIG_BLKDEV_RESERVE_ADDRESS))
120 /* overlap userarea */ 120 /* overlap userarea */
121 memory_end = CONFIG_BLKDEV_RESERVE_ADDRESS; 121 memory_end = CONFIG_BLKDEV_RESERVE_ADDRESS;
122#endif 122#endif
diff --git a/arch/h8300/kernel/signal.c b/arch/h8300/kernel/signal.c
index 7787f70a05bb..02955604d760 100644
--- a/arch/h8300/kernel/signal.c
+++ b/arch/h8300/kernel/signal.c
@@ -38,7 +38,7 @@
38#include <linux/personality.h> 38#include <linux/personality.h>
39#include <linux/tty.h> 39#include <linux/tty.h>
40#include <linux/binfmts.h> 40#include <linux/binfmts.h>
41#include <linux/suspend.h> 41#include <linux/freezer.h>
42 42
43#include <asm/setup.h> 43#include <asm/setup.h>
44#include <asm/uaccess.h> 44#include <asm/uaccess.h>
diff --git a/arch/i386/kernel/acpi/cstate.c b/arch/i386/kernel/acpi/cstate.c
index 4664b55f623e..12e937c1ce4b 100644
--- a/arch/i386/kernel/acpi/cstate.c
+++ b/arch/i386/kernel/acpi/cstate.c
@@ -156,10 +156,8 @@ static int __init ffh_cstate_init(void)
156 156
157static void __exit ffh_cstate_exit(void) 157static void __exit ffh_cstate_exit(void)
158{ 158{
159 if (cpu_cstate_entry) { 159 free_percpu(cpu_cstate_entry);
160 free_percpu(cpu_cstate_entry); 160 cpu_cstate_entry = NULL;
161 cpu_cstate_entry = NULL;
162 }
163} 161}
164 162
165arch_initcall(ffh_cstate_init); 163arch_initcall(ffh_cstate_init);
diff --git a/arch/i386/kernel/cpu/mcheck/non-fatal.c b/arch/i386/kernel/cpu/mcheck/non-fatal.c
index 1f9153ae5b03..6b5d3518a1c0 100644
--- a/arch/i386/kernel/cpu/mcheck/non-fatal.c
+++ b/arch/i386/kernel/cpu/mcheck/non-fatal.c
@@ -51,10 +51,10 @@ static void mce_checkregs (void *info)
51 } 51 }
52} 52}
53 53
54static void mce_work_fn(void *data); 54static void mce_work_fn(struct work_struct *work);
55static DECLARE_WORK(mce_work, mce_work_fn, NULL); 55static DECLARE_DELAYED_WORK(mce_work, mce_work_fn);
56 56
57static void mce_work_fn(void *data) 57static void mce_work_fn(struct work_struct *work)
58{ 58{
59 on_each_cpu(mce_checkregs, NULL, 1, 1); 59 on_each_cpu(mce_checkregs, NULL, 1, 1);
60 schedule_delayed_work(&mce_work, MCE_RATE); 60 schedule_delayed_work(&mce_work, MCE_RATE);
diff --git a/arch/i386/kernel/cpu/mcheck/therm_throt.c b/arch/i386/kernel/cpu/mcheck/therm_throt.c
index bad8b4420709..065005c3f168 100644
--- a/arch/i386/kernel/cpu/mcheck/therm_throt.c
+++ b/arch/i386/kernel/cpu/mcheck/therm_throt.c
@@ -116,7 +116,6 @@ static __cpuinit int thermal_throttle_add_dev(struct sys_device *sys_dev)
116 return sysfs_create_group(&sys_dev->kobj, &thermal_throttle_attr_group); 116 return sysfs_create_group(&sys_dev->kobj, &thermal_throttle_attr_group);
117} 117}
118 118
119#ifdef CONFIG_HOTPLUG_CPU
120static __cpuinit void thermal_throttle_remove_dev(struct sys_device *sys_dev) 119static __cpuinit void thermal_throttle_remove_dev(struct sys_device *sys_dev)
121{ 120{
122 return sysfs_remove_group(&sys_dev->kobj, &thermal_throttle_attr_group); 121 return sysfs_remove_group(&sys_dev->kobj, &thermal_throttle_attr_group);
@@ -153,7 +152,6 @@ static struct notifier_block thermal_throttle_cpu_notifier =
153{ 152{
154 .notifier_call = thermal_throttle_cpu_callback, 153 .notifier_call = thermal_throttle_cpu_callback,
155}; 154};
156#endif /* CONFIG_HOTPLUG_CPU */
157 155
158static __init int thermal_throttle_init_device(void) 156static __init int thermal_throttle_init_device(void)
159{ 157{
diff --git a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c
index 5c5d4507ee7d..db6dd20c3589 100644
--- a/arch/i386/kernel/cpuid.c
+++ b/arch/i386/kernel/cpuid.c
@@ -166,7 +166,6 @@ static int cpuid_device_create(int i)
166 return err; 166 return err;
167} 167}
168 168
169#ifdef CONFIG_HOTPLUG_CPU
170static int cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) 169static int cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
171{ 170{
172 unsigned int cpu = (unsigned long)hcpu; 171 unsigned int cpu = (unsigned long)hcpu;
@@ -186,7 +185,6 @@ static struct notifier_block __cpuinitdata cpuid_class_cpu_notifier =
186{ 185{
187 .notifier_call = cpuid_class_cpu_callback, 186 .notifier_call = cpuid_class_cpu_callback,
188}; 187};
189#endif /* !CONFIG_HOTPLUG_CPU */
190 188
191static int __init cpuid_init(void) 189static int __init cpuid_init(void)
192{ 190{
diff --git a/arch/i386/kernel/crash.c b/arch/i386/kernel/crash.c
index 144b43288965..a5e0e990ea95 100644
--- a/arch/i386/kernel/crash.c
+++ b/arch/i386/kernel/crash.c
@@ -31,68 +31,6 @@
31/* This keeps a track of which one is crashing cpu. */ 31/* This keeps a track of which one is crashing cpu. */
32static int crashing_cpu; 32static int crashing_cpu;
33 33
34static u32 *append_elf_note(u32 *buf, char *name, unsigned type, void *data,
35 size_t data_len)
36{
37 struct elf_note note;
38
39 note.n_namesz = strlen(name) + 1;
40 note.n_descsz = data_len;
41 note.n_type = type;
42 memcpy(buf, &note, sizeof(note));
43 buf += (sizeof(note) +3)/4;
44 memcpy(buf, name, note.n_namesz);
45 buf += (note.n_namesz + 3)/4;
46 memcpy(buf, data, note.n_descsz);
47 buf += (note.n_descsz + 3)/4;
48
49 return buf;
50}
51
52static void final_note(u32 *buf)
53{
54 struct elf_note note;
55
56 note.n_namesz = 0;
57 note.n_descsz = 0;
58 note.n_type = 0;
59 memcpy(buf, &note, sizeof(note));
60}
61
62static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
63{
64 struct elf_prstatus prstatus;
65 u32 *buf;
66
67 if ((cpu < 0) || (cpu >= NR_CPUS))
68 return;
69
70 /* Using ELF notes here is opportunistic.
71 * I need a well defined structure format
72 * for the data I pass, and I need tags
73 * on the data to indicate what information I have
74 * squirrelled away. ELF notes happen to provide
75 * all of that, so there is no need to invent something new.
76 */
77 buf = (u32*)per_cpu_ptr(crash_notes, cpu);
78 if (!buf)
79 return;
80 memset(&prstatus, 0, sizeof(prstatus));
81 prstatus.pr_pid = current->pid;
82 elf_core_copy_regs(&prstatus.pr_reg, regs);
83 buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
84 sizeof(prstatus));
85 final_note(buf);
86}
87
88static void crash_save_self(struct pt_regs *regs)
89{
90 int cpu;
91
92 cpu = safe_smp_processor_id();
93 crash_save_this_cpu(regs, cpu);
94}
95
96#if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC) 34#if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC)
97static atomic_t waiting_for_crash_ipi; 35static atomic_t waiting_for_crash_ipi;
98 36
@@ -121,7 +59,7 @@ static int crash_nmi_callback(struct notifier_block *self,
121 crash_fixup_ss_esp(&fixed_regs, regs); 59 crash_fixup_ss_esp(&fixed_regs, regs);
122 regs = &fixed_regs; 60 regs = &fixed_regs;
123 } 61 }
124 crash_save_this_cpu(regs, cpu); 62 crash_save_cpu(regs, cpu);
125 disable_local_APIC(); 63 disable_local_APIC();
126 atomic_dec(&waiting_for_crash_ipi); 64 atomic_dec(&waiting_for_crash_ipi);
127 /* Assume hlt works */ 65 /* Assume hlt works */
@@ -195,5 +133,5 @@ void machine_crash_shutdown(struct pt_regs *regs)
195#if defined(CONFIG_X86_IO_APIC) 133#if defined(CONFIG_X86_IO_APIC)
196 disable_IO_APIC(); 134 disable_IO_APIC();
197#endif 135#endif
198 crash_save_self(regs); 136 crash_save_cpu(regs, safe_smp_processor_id());
199} 137}
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 7f015a71ab55..e21dcde0790e 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -34,6 +34,7 @@
34#include <linux/pci.h> 34#include <linux/pci.h>
35#include <linux/msi.h> 35#include <linux/msi.h>
36#include <linux/htirq.h> 36#include <linux/htirq.h>
37#include <linux/freezer.h>
37 38
38#include <asm/io.h> 39#include <asm/io.h>
39#include <asm/smp.h> 40#include <asm/smp.h>
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c
index fc79e1e859c4..af1d53344993 100644
--- a/arch/i386/kernel/kprobes.c
+++ b/arch/i386/kernel/kprobes.c
@@ -184,7 +184,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
184void __kprobes arch_remove_kprobe(struct kprobe *p) 184void __kprobes arch_remove_kprobe(struct kprobe *p)
185{ 185{
186 mutex_lock(&kprobe_mutex); 186 mutex_lock(&kprobe_mutex);
187 free_insn_slot(p->ainsn.insn); 187 free_insn_slot(p->ainsn.insn, (p->ainsn.boostable == 1));
188 mutex_unlock(&kprobe_mutex); 188 mutex_unlock(&kprobe_mutex);
189} 189}
190 190
@@ -333,7 +333,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
333 return 1; 333 return 1;
334 334
335ss_probe: 335ss_probe:
336#ifndef CONFIG_PREEMPT 336#if !defined(CONFIG_PREEMPT) || defined(CONFIG_PM)
337 if (p->ainsn.boostable == 1 && !p->post_handler){ 337 if (p->ainsn.boostable == 1 && !p->post_handler){
338 /* Boost up -- we can execute copied instructions directly */ 338 /* Boost up -- we can execute copied instructions directly */
339 reset_current_kprobe(); 339 reset_current_kprobe();
diff --git a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c
index 23f5984d0654..972346604f9d 100644
--- a/arch/i386/kernel/microcode.c
+++ b/arch/i386/kernel/microcode.c
@@ -703,7 +703,6 @@ static struct sysdev_driver mc_sysdev_driver = {
703 .resume = mc_sysdev_resume, 703 .resume = mc_sysdev_resume,
704}; 704};
705 705
706#ifdef CONFIG_HOTPLUG_CPU
707static __cpuinit int 706static __cpuinit int
708mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu) 707mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
709{ 708{
@@ -726,7 +725,6 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
726static struct notifier_block mc_cpu_notifier = { 725static struct notifier_block mc_cpu_notifier = {
727 .notifier_call = mc_cpu_callback, 726 .notifier_call = mc_cpu_callback,
728}; 727};
729#endif
730 728
731static int __init microcode_init (void) 729static int __init microcode_init (void)
732{ 730{
diff --git a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c
index fd45059c9084..1d1a56cae340 100644
--- a/arch/i386/kernel/msr.c
+++ b/arch/i386/kernel/msr.c
@@ -249,7 +249,6 @@ static int msr_device_create(int i)
249 return err; 249 return err;
250} 250}
251 251
252#ifdef CONFIG_HOTPLUG_CPU
253static int msr_class_cpu_callback(struct notifier_block *nfb, 252static int msr_class_cpu_callback(struct notifier_block *nfb,
254 unsigned long action, void *hcpu) 253 unsigned long action, void *hcpu)
255{ 254{
@@ -270,7 +269,6 @@ static struct notifier_block __cpuinitdata msr_class_cpu_notifier =
270{ 269{
271 .notifier_call = msr_class_cpu_callback, 270 .notifier_call = msr_class_cpu_callback,
272}; 271};
273#endif
274 272
275static int __init msr_init(void) 273static int __init msr_init(void)
276{ 274{
diff --git a/arch/i386/kernel/reboot.c b/arch/i386/kernel/reboot.c
index 84278e0093a2..3514b4153f7f 100644
--- a/arch/i386/kernel/reboot.c
+++ b/arch/i386/kernel/reboot.c
@@ -12,6 +12,7 @@
12#include <linux/dmi.h> 12#include <linux/dmi.h>
13#include <linux/ctype.h> 13#include <linux/ctype.h>
14#include <linux/pm.h> 14#include <linux/pm.h>
15#include <linux/reboot.h>
15#include <asm/uaccess.h> 16#include <asm/uaccess.h>
16#include <asm/apic.h> 17#include <asm/apic.h>
17#include <asm/desc.h> 18#include <asm/desc.h>
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index 695d53fd14de..79df6e612dbd 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -448,8 +448,7 @@ void __init setup_bootmem_allocator(void)
448 if (LOADER_TYPE && INITRD_START) { 448 if (LOADER_TYPE && INITRD_START) {
449 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) { 449 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
450 reserve_bootmem(INITRD_START, INITRD_SIZE); 450 reserve_bootmem(INITRD_START, INITRD_SIZE);
451 initrd_start = 451 initrd_start = INITRD_START + PAGE_OFFSET;
452 INITRD_START ? INITRD_START + PAGE_OFFSET : 0;
453 initrd_end = initrd_start+INITRD_SIZE; 452 initrd_end = initrd_start+INITRD_SIZE;
454 } 453 }
455 else { 454 else {
diff --git a/arch/i386/kernel/smp.c b/arch/i386/kernel/smp.c
index 1b080ab8a49f..5285aff8367f 100644
--- a/arch/i386/kernel/smp.c
+++ b/arch/i386/kernel/smp.c
@@ -693,6 +693,10 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
693 put_cpu(); 693 put_cpu();
694 return -EBUSY; 694 return -EBUSY;
695 } 695 }
696
697 /* Can deadlock when called with interrupts disabled */
698 WARN_ON(irqs_disabled());
699
696 spin_lock_bh(&call_lock); 700 spin_lock_bh(&call_lock);
697 __smp_call_function_single(cpu, func, info, nonatomic, wait); 701 __smp_call_function_single(cpu, func, info, nonatomic, wait);
698 spin_unlock_bh(&call_lock); 702 spin_unlock_bh(&call_lock);
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index b4e6f32de453..4bf0e3c83b8b 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -1071,13 +1071,15 @@ void cpu_exit_clear(void)
1071 1071
1072struct warm_boot_cpu_info { 1072struct warm_boot_cpu_info {
1073 struct completion *complete; 1073 struct completion *complete;
1074 struct work_struct task;
1074 int apicid; 1075 int apicid;
1075 int cpu; 1076 int cpu;
1076}; 1077};
1077 1078
1078static void __cpuinit do_warm_boot_cpu(void *p) 1079static void __cpuinit do_warm_boot_cpu(struct work_struct *work)
1079{ 1080{
1080 struct warm_boot_cpu_info *info = p; 1081 struct warm_boot_cpu_info *info =
1082 container_of(work, struct warm_boot_cpu_info, task);
1081 do_boot_cpu(info->apicid, info->cpu); 1083 do_boot_cpu(info->apicid, info->cpu);
1082 complete(info->complete); 1084 complete(info->complete);
1083} 1085}
@@ -1086,7 +1088,6 @@ static int __cpuinit __smp_prepare_cpu(int cpu)
1086{ 1088{
1087 DECLARE_COMPLETION_ONSTACK(done); 1089 DECLARE_COMPLETION_ONSTACK(done);
1088 struct warm_boot_cpu_info info; 1090 struct warm_boot_cpu_info info;
1089 struct work_struct task;
1090 int apicid, ret; 1091 int apicid, ret;
1091 struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu); 1092 struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
1092 1093
@@ -1111,7 +1112,7 @@ static int __cpuinit __smp_prepare_cpu(int cpu)
1111 info.complete = &done; 1112 info.complete = &done;
1112 info.apicid = apicid; 1113 info.apicid = apicid;
1113 info.cpu = cpu; 1114 info.cpu = cpu;
1114 INIT_WORK(&task, do_warm_boot_cpu, &info); 1115 INIT_WORK(&info.task, do_warm_boot_cpu);
1115 1116
1116 tsc_sync_disabled = 1; 1117 tsc_sync_disabled = 1;
1117 1118
@@ -1119,7 +1120,7 @@ static int __cpuinit __smp_prepare_cpu(int cpu)
1119 clone_pgd_range(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS, 1120 clone_pgd_range(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS,
1120 KERNEL_PGD_PTRS); 1121 KERNEL_PGD_PTRS);
1121 flush_tlb_all(); 1122 flush_tlb_all();
1122 schedule_work(&task); 1123 schedule_work(&info.task);
1123 wait_for_completion(&done); 1124 wait_for_completion(&done);
1124 1125
1125 tsc_sync_disabled = 0; 1126 tsc_sync_disabled = 0;
diff --git a/arch/i386/kernel/sysenter.c b/arch/i386/kernel/sysenter.c
index 92849c7def5a..7de9117b5a3a 100644
--- a/arch/i386/kernel/sysenter.c
+++ b/arch/i386/kernel/sysenter.c
@@ -136,7 +136,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int exstack)
136 goto up_fail; 136 goto up_fail;
137 } 137 }
138 138
139 vma = kmem_cache_zalloc(vm_area_cachep, SLAB_KERNEL); 139 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
140 if (!vma) { 140 if (!vma) {
141 ret = -ENOMEM; 141 ret = -ENOMEM;
142 goto up_fail; 142 goto up_fail;
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index c447807e2a45..68de48e498ca 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -464,7 +464,7 @@ void die(const char * str, struct pt_regs * regs, long err)
464 u32 lock_owner; 464 u32 lock_owner;
465 int lock_owner_depth; 465 int lock_owner_depth;
466 } die = { 466 } die = {
467 .lock = SPIN_LOCK_UNLOCKED, 467 .lock = __SPIN_LOCK_UNLOCKED(die.lock),
468 .lock_owner = -1, 468 .lock_owner = -1,
469 .lock_owner_depth = 0 469 .lock_owner_depth = 0
470 }; 470 };
diff --git a/arch/i386/kernel/tsc.c b/arch/i386/kernel/tsc.c
index 7f22e03253e2..1bbe45dca7a0 100644
--- a/arch/i386/kernel/tsc.c
+++ b/arch/i386/kernel/tsc.c
@@ -216,7 +216,7 @@ static unsigned int cpufreq_delayed_issched = 0;
216static unsigned int cpufreq_init = 0; 216static unsigned int cpufreq_init = 0;
217static struct work_struct cpufreq_delayed_get_work; 217static struct work_struct cpufreq_delayed_get_work;
218 218
219static void handle_cpufreq_delayed_get(void *v) 219static void handle_cpufreq_delayed_get(struct work_struct *work)
220{ 220{
221 unsigned int cpu; 221 unsigned int cpu;
222 222
@@ -305,7 +305,7 @@ static int __init cpufreq_tsc(void)
305{ 305{
306 int ret; 306 int ret;
307 307
308 INIT_WORK(&cpufreq_delayed_get_work, handle_cpufreq_delayed_get, NULL); 308 INIT_WORK(&cpufreq_delayed_get_work, handle_cpufreq_delayed_get);
309 ret = cpufreq_register_notifier(&time_cpufreq_notifier_block, 309 ret = cpufreq_register_notifier(&time_cpufreq_notifier_block,
310 CPUFREQ_TRANSITION_NOTIFIER); 310 CPUFREQ_TRANSITION_NOTIFIER);
311 if (!ret) 311 if (!ret)
diff --git a/arch/i386/mm/highmem.c b/arch/i386/mm/highmem.c
index f9f647cdbc7b..e0fa6cb655a8 100644
--- a/arch/i386/mm/highmem.c
+++ b/arch/i386/mm/highmem.c
@@ -32,7 +32,7 @@ void *kmap_atomic(struct page *page, enum km_type type)
32 unsigned long vaddr; 32 unsigned long vaddr;
33 33
34 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ 34 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
35 inc_preempt_count(); 35 pagefault_disable();
36 if (!PageHighMem(page)) 36 if (!PageHighMem(page))
37 return page_address(page); 37 return page_address(page);
38 38
@@ -50,26 +50,22 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
50 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; 50 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
51 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id(); 51 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
52 52
53#ifdef CONFIG_DEBUG_HIGHMEM
54 if (vaddr >= PAGE_OFFSET && vaddr < (unsigned long)high_memory) {
55 dec_preempt_count();
56 preempt_check_resched();
57 return;
58 }
59
60 if (vaddr != __fix_to_virt(FIX_KMAP_BEGIN+idx))
61 BUG();
62#endif
63 /* 53 /*
64 * Force other mappings to Oops if they'll try to access this pte 54 * Force other mappings to Oops if they'll try to access this pte
65 * without first remap it. Keeping stale mappings around is a bad idea 55 * without first remap it. Keeping stale mappings around is a bad idea
66 * also, in case the page changes cacheability attributes or becomes 56 * also, in case the page changes cacheability attributes or becomes
67 * a protected page in a hypervisor. 57 * a protected page in a hypervisor.
68 */ 58 */
69 kpte_clear_flush(kmap_pte-idx, vaddr); 59 if (vaddr == __fix_to_virt(FIX_KMAP_BEGIN+idx))
60 kpte_clear_flush(kmap_pte-idx, vaddr);
61 else {
62#ifdef CONFIG_DEBUG_HIGHMEM
63 BUG_ON(vaddr < PAGE_OFFSET);
64 BUG_ON(vaddr >= (unsigned long)high_memory);
65#endif
66 }
70 67
71 dec_preempt_count(); 68 pagefault_enable();
72 preempt_check_resched();
73} 69}
74 70
75/* This is the same as kmap_atomic() but can map memory that doesn't 71/* This is the same as kmap_atomic() but can map memory that doesn't
@@ -80,7 +76,7 @@ void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
80 enum fixed_addresses idx; 76 enum fixed_addresses idx;
81 unsigned long vaddr; 77 unsigned long vaddr;
82 78
83 inc_preempt_count(); 79 pagefault_disable();
84 80
85 idx = type + KM_TYPE_NR*smp_processor_id(); 81 idx = type + KM_TYPE_NR*smp_processor_id();
86 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 82 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
diff --git a/arch/i386/mm/hugetlbpage.c b/arch/i386/mm/hugetlbpage.c
index 1719a8141f81..34728e4afe48 100644
--- a/arch/i386/mm/hugetlbpage.c
+++ b/arch/i386/mm/hugetlbpage.c
@@ -17,6 +17,113 @@
17#include <asm/tlb.h> 17#include <asm/tlb.h>
18#include <asm/tlbflush.h> 18#include <asm/tlbflush.h>
19 19
20static unsigned long page_table_shareable(struct vm_area_struct *svma,
21 struct vm_area_struct *vma,
22 unsigned long addr, pgoff_t idx)
23{
24 unsigned long saddr = ((idx - svma->vm_pgoff) << PAGE_SHIFT) +
25 svma->vm_start;
26 unsigned long sbase = saddr & PUD_MASK;
27 unsigned long s_end = sbase + PUD_SIZE;
28
29 /*
30 * match the virtual addresses, permission and the alignment of the
31 * page table page.
32 */
33 if (pmd_index(addr) != pmd_index(saddr) ||
34 vma->vm_flags != svma->vm_flags ||
35 sbase < svma->vm_start || svma->vm_end < s_end)
36 return 0;
37
38 return saddr;
39}
40
41static int vma_shareable(struct vm_area_struct *vma, unsigned long addr)
42{
43 unsigned long base = addr & PUD_MASK;
44 unsigned long end = base + PUD_SIZE;
45
46 /*
47 * check on proper vm_flags and page table alignment
48 */
49 if (vma->vm_flags & VM_MAYSHARE &&
50 vma->vm_start <= base && end <= vma->vm_end)
51 return 1;
52 return 0;
53}
54
55/*
56 * search for a shareable pmd page for hugetlb.
57 */
58static void huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
59{
60 struct vm_area_struct *vma = find_vma(mm, addr);
61 struct address_space *mapping = vma->vm_file->f_mapping;
62 pgoff_t idx = ((addr - vma->vm_start) >> PAGE_SHIFT) +
63 vma->vm_pgoff;
64 struct prio_tree_iter iter;
65 struct vm_area_struct *svma;
66 unsigned long saddr;
67 pte_t *spte = NULL;
68
69 if (!vma_shareable(vma, addr))
70 return;
71
72 spin_lock(&mapping->i_mmap_lock);
73 vma_prio_tree_foreach(svma, &iter, &mapping->i_mmap, idx, idx) {
74 if (svma == vma)
75 continue;
76
77 saddr = page_table_shareable(svma, vma, addr, idx);
78 if (saddr) {
79 spte = huge_pte_offset(svma->vm_mm, saddr);
80 if (spte) {
81 get_page(virt_to_page(spte));
82 break;
83 }
84 }
85 }
86
87 if (!spte)
88 goto out;
89
90 spin_lock(&mm->page_table_lock);
91 if (pud_none(*pud))
92 pud_populate(mm, pud, (unsigned long) spte & PAGE_MASK);
93 else
94 put_page(virt_to_page(spte));
95 spin_unlock(&mm->page_table_lock);
96out:
97 spin_unlock(&mapping->i_mmap_lock);
98}
99
100/*
101 * unmap huge page backed by shared pte.
102 *
103 * Hugetlb pte page is ref counted at the time of mapping. If pte is shared
104 * indicated by page_count > 1, unmap is achieved by clearing pud and
105 * decrementing the ref count. If count == 1, the pte page is not shared.
106 *
107 * called with vma->vm_mm->page_table_lock held.
108 *
109 * returns: 1 successfully unmapped a shared pte page
110 * 0 the underlying pte page is not shared, or it is the last user
111 */
112int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
113{
114 pgd_t *pgd = pgd_offset(mm, *addr);
115 pud_t *pud = pud_offset(pgd, *addr);
116
117 BUG_ON(page_count(virt_to_page(ptep)) == 0);
118 if (page_count(virt_to_page(ptep)) == 1)
119 return 0;
120
121 pud_clear(pud);
122 put_page(virt_to_page(ptep));
123 *addr = ALIGN(*addr, HPAGE_SIZE * PTRS_PER_PTE) - HPAGE_SIZE;
124 return 1;
125}
126
20pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr) 127pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
21{ 128{
22 pgd_t *pgd; 129 pgd_t *pgd;
@@ -25,8 +132,11 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
25 132
26 pgd = pgd_offset(mm, addr); 133 pgd = pgd_offset(mm, addr);
27 pud = pud_alloc(mm, pgd, addr); 134 pud = pud_alloc(mm, pgd, addr);
28 if (pud) 135 if (pud) {
136 if (pud_none(*pud))
137 huge_pmd_share(mm, addr, pud);
29 pte = (pte_t *) pmd_alloc(mm, pud, addr); 138 pte = (pte_t *) pmd_alloc(mm, pud, addr);
139 }
30 BUG_ON(pte && !pte_none(*pte) && !pte_huge(*pte)); 140 BUG_ON(pte && !pte_none(*pte) && !pte_huge(*pte));
31 141
32 return pte; 142 return pte;
diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c
index f4dd048187ff..84697dfc7348 100644
--- a/arch/i386/mm/init.c
+++ b/arch/i386/mm/init.c
@@ -697,8 +697,8 @@ int remove_memory(u64 start, u64 size)
697#endif 697#endif
698#endif 698#endif
699 699
700kmem_cache_t *pgd_cache; 700struct kmem_cache *pgd_cache;
701kmem_cache_t *pmd_cache; 701struct kmem_cache *pmd_cache;
702 702
703void __init pgtable_cache_init(void) 703void __init pgtable_cache_init(void)
704{ 704{
diff --git a/arch/i386/mm/pgtable.c b/arch/i386/mm/pgtable.c
index 65b5c0959033..f349eaf450b0 100644
--- a/arch/i386/mm/pgtable.c
+++ b/arch/i386/mm/pgtable.c
@@ -196,7 +196,7 @@ struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
196 return pte; 196 return pte;
197} 197}
198 198
199void pmd_ctor(void *pmd, kmem_cache_t *cache, unsigned long flags) 199void pmd_ctor(void *pmd, struct kmem_cache *cache, unsigned long flags)
200{ 200{
201 memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t)); 201 memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
202} 202}
@@ -236,7 +236,7 @@ static inline void pgd_list_del(pgd_t *pgd)
236 set_page_private(next, (unsigned long)pprev); 236 set_page_private(next, (unsigned long)pprev);
237} 237}
238 238
239void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused) 239void pgd_ctor(void *pgd, struct kmem_cache *cache, unsigned long unused)
240{ 240{
241 unsigned long flags; 241 unsigned long flags;
242 242
@@ -256,7 +256,7 @@ void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused)
256} 256}
257 257
258/* never called when PTRS_PER_PMD > 1 */ 258/* never called when PTRS_PER_PMD > 1 */
259void pgd_dtor(void *pgd, kmem_cache_t *cache, unsigned long unused) 259void pgd_dtor(void *pgd, struct kmem_cache *cache, unsigned long unused)
260{ 260{
261 unsigned long flags; /* can be called from interrupt context */ 261 unsigned long flags; /* can be called from interrupt context */
262 262
diff --git a/arch/i386/power/Makefile b/arch/i386/power/Makefile
index 8cfa4e8a719d..2de7bbf03cd7 100644
--- a/arch/i386/power/Makefile
+++ b/arch/i386/power/Makefile
@@ -1,2 +1,2 @@
1obj-$(CONFIG_PM) += cpu.o 1obj-$(CONFIG_PM) += cpu.o
2obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o 2obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o suspend.o
diff --git a/arch/i386/power/suspend.c b/arch/i386/power/suspend.c
new file mode 100644
index 000000000000..db5e98d2eb73
--- /dev/null
+++ b/arch/i386/power/suspend.c
@@ -0,0 +1,158 @@
1/*
2 * Suspend support specific for i386 - temporary page tables
3 *
4 * Distribute under GPLv2
5 *
6 * Copyright (c) 2006 Rafael J. Wysocki <rjw@sisk.pl>
7 */
8
9#include <linux/suspend.h>
10#include <linux/bootmem.h>
11
12#include <asm/system.h>
13#include <asm/page.h>
14#include <asm/pgtable.h>
15
16/* Defined in arch/i386/power/swsusp.S */
17extern int restore_image(void);
18
19/* Pointer to the temporary resume page tables */
20pgd_t *resume_pg_dir;
21
22/* The following three functions are based on the analogous code in
23 * arch/i386/mm/init.c
24 */
25
26/*
27 * Create a middle page table on a resume-safe page and put a pointer to it in
28 * the given global directory entry. This only returns the gd entry
29 * in non-PAE compilation mode, since the middle layer is folded.
30 */
31static pmd_t *resume_one_md_table_init(pgd_t *pgd)
32{
33 pud_t *pud;
34 pmd_t *pmd_table;
35
36#ifdef CONFIG_X86_PAE
37 pmd_table = (pmd_t *)get_safe_page(GFP_ATOMIC);
38 if (!pmd_table)
39 return NULL;
40
41 set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
42 pud = pud_offset(pgd, 0);
43
44 BUG_ON(pmd_table != pmd_offset(pud, 0));
45#else
46 pud = pud_offset(pgd, 0);
47 pmd_table = pmd_offset(pud, 0);
48#endif
49
50 return pmd_table;
51}
52
53/*
54 * Create a page table on a resume-safe page and place a pointer to it in
55 * a middle page directory entry.
56 */
57static pte_t *resume_one_page_table_init(pmd_t *pmd)
58{
59 if (pmd_none(*pmd)) {
60 pte_t *page_table = (pte_t *)get_safe_page(GFP_ATOMIC);
61 if (!page_table)
62 return NULL;
63
64 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
65
66 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
67
68 return page_table;
69 }
70
71 return pte_offset_kernel(pmd, 0);
72}
73
74/*
75 * This maps the physical memory to kernel virtual address space, a total
76 * of max_low_pfn pages, by creating page tables starting from address
77 * PAGE_OFFSET. The page tables are allocated out of resume-safe pages.
78 */
79static int resume_physical_mapping_init(pgd_t *pgd_base)
80{
81 unsigned long pfn;
82 pgd_t *pgd;
83 pmd_t *pmd;
84 pte_t *pte;
85 int pgd_idx, pmd_idx;
86
87 pgd_idx = pgd_index(PAGE_OFFSET);
88 pgd = pgd_base + pgd_idx;
89 pfn = 0;
90
91 for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
92 pmd = resume_one_md_table_init(pgd);
93 if (!pmd)
94 return -ENOMEM;
95
96 if (pfn >= max_low_pfn)
97 continue;
98
99 for (pmd_idx = 0; pmd_idx < PTRS_PER_PMD; pmd++, pmd_idx++) {
100 if (pfn >= max_low_pfn)
101 break;
102
103 /* Map with big pages if possible, otherwise create
104 * normal page tables.
105 * NOTE: We can mark everything as executable here
106 */
107 if (cpu_has_pse) {
108 set_pmd(pmd, pfn_pmd(pfn, PAGE_KERNEL_LARGE_EXEC));
109 pfn += PTRS_PER_PTE;
110 } else {
111 pte_t *max_pte;
112
113 pte = resume_one_page_table_init(pmd);
114 if (!pte)
115 return -ENOMEM;
116
117 max_pte = pte + PTRS_PER_PTE;
118 for (; pte < max_pte; pte++, pfn++) {
119 if (pfn >= max_low_pfn)
120 break;
121
122 set_pte(pte, pfn_pte(pfn, PAGE_KERNEL_EXEC));
123 }
124 }
125 }
126 }
127 return 0;
128}
129
130static inline void resume_init_first_level_page_table(pgd_t *pg_dir)
131{
132#ifdef CONFIG_X86_PAE
133 int i;
134
135 /* Init entries of the first-level page table to the zero page */
136 for (i = 0; i < PTRS_PER_PGD; i++)
137 set_pgd(pg_dir + i,
138 __pgd(__pa(empty_zero_page) | _PAGE_PRESENT));
139#endif
140}
141
142int swsusp_arch_resume(void)
143{
144 int error;
145
146 resume_pg_dir = (pgd_t *)get_safe_page(GFP_ATOMIC);
147 if (!resume_pg_dir)
148 return -ENOMEM;
149
150 resume_init_first_level_page_table(resume_pg_dir);
151 error = resume_physical_mapping_init(resume_pg_dir);
152 if (error)
153 return error;
154
155 /* We have got enough memory and from now on we cannot recover */
156 restore_image();
157 return 0;
158}
diff --git a/arch/i386/power/swsusp.S b/arch/i386/power/swsusp.S
index 8a2b50a0aaad..53662e05b393 100644
--- a/arch/i386/power/swsusp.S
+++ b/arch/i386/power/swsusp.S
@@ -28,8 +28,9 @@ ENTRY(swsusp_arch_suspend)
28 call swsusp_save 28 call swsusp_save
29 ret 29 ret
30 30
31ENTRY(swsusp_arch_resume) 31ENTRY(restore_image)
32 movl $swsusp_pg_dir-__PAGE_OFFSET, %ecx 32 movl resume_pg_dir, %ecx
33 subl $__PAGE_OFFSET, %ecx
33 movl %ecx, %cr3 34 movl %ecx, %cr3
34 35
35 movl restore_pblist, %edx 36 movl restore_pblist, %edx
@@ -51,6 +52,10 @@ copy_loop:
51 .p2align 4,,7 52 .p2align 4,,7
52 53
53done: 54done:
55 /* go back to the original page tables */
56 movl $swapper_pg_dir, %ecx
57 subl $__PAGE_OFFSET, %ecx
58 movl %ecx, %cr3
54 /* Flush TLB, including "global" things (vmalloc) */ 59 /* Flush TLB, including "global" things (vmalloc) */
55 movl mmu_cr4_features, %eax 60 movl mmu_cr4_features, %eax
56 movl %eax, %edx 61 movl %eax, %edx
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index caab986af70c..b62f0c4d2c7c 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -209,7 +209,7 @@ static void do_serial_bh(void)
209} 209}
210#endif 210#endif
211 211
212static void do_softint(void *private_) 212static void do_softint(struct work_struct *private_)
213{ 213{
214 printk(KERN_ERR "simserial: do_softint called\n"); 214 printk(KERN_ERR "simserial: do_softint called\n");
215} 215}
@@ -698,7 +698,7 @@ static int get_async_struct(int line, struct async_struct **ret_info)
698 info->flags = sstate->flags; 698 info->flags = sstate->flags;
699 info->xmit_fifo_size = sstate->xmit_fifo_size; 699 info->xmit_fifo_size = sstate->xmit_fifo_size;
700 info->line = line; 700 info->line = line;
701 INIT_WORK(&info->work, do_softint, info); 701 INIT_WORK(&info->work, do_softint);
702 info->state = sstate; 702 info->state = sstate;
703 if (sstate->info) { 703 if (sstate->info) {
704 kfree(info); 704 kfree(info);
diff --git a/arch/ia64/ia32/binfmt_elf32.c b/arch/ia64/ia32/binfmt_elf32.c
index daa6b91bc921..578737ec7629 100644
--- a/arch/ia64/ia32/binfmt_elf32.c
+++ b/arch/ia64/ia32/binfmt_elf32.c
@@ -91,7 +91,7 @@ ia64_elf32_init (struct pt_regs *regs)
91 * it with privilege level 3 because the IVE uses non-privileged accesses to these 91 * it with privilege level 3 because the IVE uses non-privileged accesses to these
92 * tables. IA-32 segmentation is used to protect against IA-32 accesses to them. 92 * tables. IA-32 segmentation is used to protect against IA-32 accesses to them.
93 */ 93 */
94 vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 94 vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
95 if (vma) { 95 if (vma) {
96 memset(vma, 0, sizeof(*vma)); 96 memset(vma, 0, sizeof(*vma));
97 vma->vm_mm = current->mm; 97 vma->vm_mm = current->mm;
@@ -117,7 +117,7 @@ ia64_elf32_init (struct pt_regs *regs)
117 * code is locked in specific gate page, which is pointed by pretcode 117 * code is locked in specific gate page, which is pointed by pretcode
118 * when setup_frame_ia32 118 * when setup_frame_ia32
119 */ 119 */
120 vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 120 vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
121 if (vma) { 121 if (vma) {
122 memset(vma, 0, sizeof(*vma)); 122 memset(vma, 0, sizeof(*vma));
123 vma->vm_mm = current->mm; 123 vma->vm_mm = current->mm;
@@ -142,7 +142,7 @@ ia64_elf32_init (struct pt_regs *regs)
142 * Install LDT as anonymous memory. This gives us all-zero segment descriptors 142 * Install LDT as anonymous memory. This gives us all-zero segment descriptors
143 * until a task modifies them via modify_ldt(). 143 * until a task modifies them via modify_ldt().
144 */ 144 */
145 vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 145 vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
146 if (vma) { 146 if (vma) {
147 memset(vma, 0, sizeof(*vma)); 147 memset(vma, 0, sizeof(*vma));
148 vma->vm_mm = current->mm; 148 vma->vm_mm = current->mm;
@@ -214,7 +214,7 @@ ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack)
214 bprm->loader += stack_base; 214 bprm->loader += stack_base;
215 bprm->exec += stack_base; 215 bprm->exec += stack_base;
216 216
217 mpnt = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 217 mpnt = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
218 if (!mpnt) 218 if (!mpnt)
219 return -ENOMEM; 219 return -ENOMEM;
220 220
diff --git a/arch/ia64/ia32/ia32_support.c b/arch/ia64/ia32/ia32_support.c
index c187743965a0..6af400a12ca1 100644
--- a/arch/ia64/ia32/ia32_support.c
+++ b/arch/ia64/ia32/ia32_support.c
@@ -249,7 +249,7 @@ ia32_init (void)
249 249
250#if PAGE_SHIFT > IA32_PAGE_SHIFT 250#if PAGE_SHIFT > IA32_PAGE_SHIFT
251 { 251 {
252 extern kmem_cache_t *partial_page_cachep; 252 extern struct kmem_cache *partial_page_cachep;
253 253
254 partial_page_cachep = kmem_cache_create("partial_page_cache", 254 partial_page_cachep = kmem_cache_create("partial_page_cache",
255 sizeof(struct partial_page), 0, 0, 255 sizeof(struct partial_page), 0, 0,
diff --git a/arch/ia64/ia32/ia32priv.h b/arch/ia64/ia32/ia32priv.h
index 703a67c934f8..cfa0bc0026b5 100644
--- a/arch/ia64/ia32/ia32priv.h
+++ b/arch/ia64/ia32/ia32priv.h
@@ -330,8 +330,6 @@ struct old_linux32_dirent {
330void ia64_elf32_init(struct pt_regs *regs); 330void ia64_elf32_init(struct pt_regs *regs);
331#define ELF_PLAT_INIT(_r, load_addr) ia64_elf32_init(_r) 331#define ELF_PLAT_INIT(_r, load_addr) ia64_elf32_init(_r)
332 332
333#define elf_addr_t u32
334
335/* This macro yields a bitmask that programs can use to figure out 333/* This macro yields a bitmask that programs can use to figure out
336 what instruction set this CPU supports. */ 334 what instruction set this CPU supports. */
337#define ELF_HWCAP 0 335#define ELF_HWCAP 0
diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
index 9d6a3f210148..a4a6e1463af8 100644
--- a/arch/ia64/ia32/sys_ia32.c
+++ b/arch/ia64/ia32/sys_ia32.c
@@ -254,7 +254,7 @@ mmap_subpage (struct file *file, unsigned long start, unsigned long end, int pro
254} 254}
255 255
256/* SLAB cache for partial_page structures */ 256/* SLAB cache for partial_page structures */
257kmem_cache_t *partial_page_cachep; 257struct kmem_cache *partial_page_cachep;
258 258
259/* 259/*
260 * init partial_page_list. 260 * init partial_page_list.
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c
index 51217d63285e..4d592ee9300b 100644
--- a/arch/ia64/kernel/kprobes.c
+++ b/arch/ia64/kernel/kprobes.c
@@ -481,7 +481,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
481void __kprobes arch_remove_kprobe(struct kprobe *p) 481void __kprobes arch_remove_kprobe(struct kprobe *p)
482{ 482{
483 mutex_lock(&kprobe_mutex); 483 mutex_lock(&kprobe_mutex);
484 free_insn_slot(p->ainsn.insn); 484 free_insn_slot(p->ainsn.insn, 0);
485 mutex_unlock(&kprobe_mutex); 485 mutex_unlock(&kprobe_mutex);
486} 486}
487/* 487/*
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 7cfa63a98cb3..6bedd97570ca 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -678,7 +678,7 @@ ia64_mca_cmc_vector_enable (void *dummy)
678 * disable the cmc interrupt vector. 678 * disable the cmc interrupt vector.
679 */ 679 */
680static void 680static void
681ia64_mca_cmc_vector_disable_keventd(void *unused) 681ia64_mca_cmc_vector_disable_keventd(struct work_struct *unused)
682{ 682{
683 on_each_cpu(ia64_mca_cmc_vector_disable, NULL, 1, 0); 683 on_each_cpu(ia64_mca_cmc_vector_disable, NULL, 1, 0);
684} 684}
@@ -690,7 +690,7 @@ ia64_mca_cmc_vector_disable_keventd(void *unused)
690 * enable the cmc interrupt vector. 690 * enable the cmc interrupt vector.
691 */ 691 */
692static void 692static void
693ia64_mca_cmc_vector_enable_keventd(void *unused) 693ia64_mca_cmc_vector_enable_keventd(struct work_struct *unused)
694{ 694{
695 on_each_cpu(ia64_mca_cmc_vector_enable, NULL, 1, 0); 695 on_each_cpu(ia64_mca_cmc_vector_enable, NULL, 1, 0);
696} 696}
@@ -1247,8 +1247,8 @@ ia64_mca_handler(struct pt_regs *regs, struct switch_stack *sw,
1247 monarch_cpu = -1; 1247 monarch_cpu = -1;
1248} 1248}
1249 1249
1250static DECLARE_WORK(cmc_disable_work, ia64_mca_cmc_vector_disable_keventd, NULL); 1250static DECLARE_WORK(cmc_disable_work, ia64_mca_cmc_vector_disable_keventd);
1251static DECLARE_WORK(cmc_enable_work, ia64_mca_cmc_vector_enable_keventd, NULL); 1251static DECLARE_WORK(cmc_enable_work, ia64_mca_cmc_vector_enable_keventd);
1252 1252
1253/* 1253/*
1254 * ia64_mca_cmc_int_handler 1254 * ia64_mca_cmc_int_handler
diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
index 0b546e2b36ac..c4c10a0b99d9 100644
--- a/arch/ia64/kernel/palinfo.c
+++ b/arch/ia64/kernel/palinfo.c
@@ -952,7 +952,6 @@ remove_palinfo_proc_entries(unsigned int hcpu)
952 } 952 }
953} 953}
954 954
955#ifdef CONFIG_HOTPLUG_CPU
956static int palinfo_cpu_callback(struct notifier_block *nfb, 955static int palinfo_cpu_callback(struct notifier_block *nfb,
957 unsigned long action, void *hcpu) 956 unsigned long action, void *hcpu)
958{ 957{
@@ -974,7 +973,6 @@ static struct notifier_block palinfo_cpu_notifier =
974 .notifier_call = palinfo_cpu_callback, 973 .notifier_call = palinfo_cpu_callback,
975 .priority = 0, 974 .priority = 0,
976}; 975};
977#endif
978 976
979static int __init 977static int __init
980palinfo_init(void) 978palinfo_init(void)
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 3aaede0d6981..e2321536ee4c 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -2302,7 +2302,7 @@ pfm_smpl_buffer_alloc(struct task_struct *task, pfm_context_t *ctx, unsigned lon
2302 DPRINT(("smpl_buf @%p\n", smpl_buf)); 2302 DPRINT(("smpl_buf @%p\n", smpl_buf));
2303 2303
2304 /* allocate vma */ 2304 /* allocate vma */
2305 vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 2305 vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
2306 if (!vma) { 2306 if (!vma) {
2307 DPRINT(("Cannot allocate vma\n")); 2307 DPRINT(("Cannot allocate vma\n"));
2308 goto error_kmem; 2308 goto error_kmem;
diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
index e63b8ca5344a..fd607ca51a8d 100644
--- a/arch/ia64/kernel/salinfo.c
+++ b/arch/ia64/kernel/salinfo.c
@@ -575,7 +575,6 @@ static struct file_operations salinfo_data_fops = {
575 .write = salinfo_log_write, 575 .write = salinfo_log_write,
576}; 576};
577 577
578#ifdef CONFIG_HOTPLUG_CPU
579static int __devinit 578static int __devinit
580salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu) 579salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
581{ 580{
@@ -620,7 +619,6 @@ static struct notifier_block salinfo_cpu_notifier =
620 .notifier_call = salinfo_cpu_callback, 619 .notifier_call = salinfo_cpu_callback,
621 .priority = 0, 620 .priority = 0,
622}; 621};
623#endif /* CONFIG_HOTPLUG_CPU */
624 622
625static int __init 623static int __init
626salinfo_init(void) 624salinfo_init(void)
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
index f7d7f5668144..b21ddecea943 100644
--- a/arch/ia64/kernel/smpboot.c
+++ b/arch/ia64/kernel/smpboot.c
@@ -463,15 +463,17 @@ struct pt_regs * __devinit idle_regs(struct pt_regs *regs)
463} 463}
464 464
465struct create_idle { 465struct create_idle {
466 struct work_struct work;
466 struct task_struct *idle; 467 struct task_struct *idle;
467 struct completion done; 468 struct completion done;
468 int cpu; 469 int cpu;
469}; 470};
470 471
471void 472void
472do_fork_idle(void *_c_idle) 473do_fork_idle(struct work_struct *work)
473{ 474{
474 struct create_idle *c_idle = _c_idle; 475 struct create_idle *c_idle =
476 container_of(work, struct create_idle, work);
475 477
476 c_idle->idle = fork_idle(c_idle->cpu); 478 c_idle->idle = fork_idle(c_idle->cpu);
477 complete(&c_idle->done); 479 complete(&c_idle->done);
@@ -482,10 +484,10 @@ do_boot_cpu (int sapicid, int cpu)
482{ 484{
483 int timeout; 485 int timeout;
484 struct create_idle c_idle = { 486 struct create_idle c_idle = {
487 .work = __WORK_INITIALIZER(c_idle.work, do_fork_idle),
485 .cpu = cpu, 488 .cpu = cpu,
486 .done = COMPLETION_INITIALIZER(c_idle.done), 489 .done = COMPLETION_INITIALIZER(c_idle.done),
487 }; 490 };
488 DECLARE_WORK(work, do_fork_idle, &c_idle);
489 491
490 c_idle.idle = get_idle_for_cpu(cpu); 492 c_idle.idle = get_idle_for_cpu(cpu);
491 if (c_idle.idle) { 493 if (c_idle.idle) {
@@ -497,9 +499,9 @@ do_boot_cpu (int sapicid, int cpu)
497 * We can't use kernel_thread since we must avoid to reschedule the child. 499 * We can't use kernel_thread since we must avoid to reschedule the child.
498 */ 500 */
499 if (!keventd_up() || current_is_keventd()) 501 if (!keventd_up() || current_is_keventd())
500 work.func(work.data); 502 c_idle.work.func(&c_idle.work);
501 else { 503 else {
502 schedule_work(&work); 504 schedule_work(&c_idle.work);
503 wait_for_completion(&c_idle.done); 505 wait_for_completion(&c_idle.done);
504 } 506 }
505 507
diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
index f3a9585e98a8..0c7e94edc20e 100644
--- a/arch/ia64/mm/hugetlbpage.c
+++ b/arch/ia64/mm/hugetlbpage.c
@@ -64,6 +64,11 @@ huge_pte_offset (struct mm_struct *mm, unsigned long addr)
64 return pte; 64 return pte;
65} 65}
66 66
67int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
68{
69 return 0;
70}
71
67#define mk_pte_huge(entry) { pte_val(entry) |= _PAGE_P; } 72#define mk_pte_huge(entry) { pte_val(entry) |= _PAGE_P; }
68 73
69/* 74/*
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index ff87a5cba399..56dc2024220e 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -156,7 +156,7 @@ ia64_init_addr_space (void)
156 * the problem. When the process attempts to write to the register backing store 156 * the problem. When the process attempts to write to the register backing store
157 * for the first time, it will get a SEGFAULT in this case. 157 * for the first time, it will get a SEGFAULT in this case.
158 */ 158 */
159 vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 159 vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
160 if (vma) { 160 if (vma) {
161 memset(vma, 0, sizeof(*vma)); 161 memset(vma, 0, sizeof(*vma));
162 vma->vm_mm = current->mm; 162 vma->vm_mm = current->mm;
@@ -175,7 +175,7 @@ ia64_init_addr_space (void)
175 175
176 /* map NaT-page at address zero to speed up speculative dereferencing of NULL: */ 176 /* map NaT-page at address zero to speed up speculative dereferencing of NULL: */
177 if (!(current->personality & MMAP_PAGE_ZERO)) { 177 if (!(current->personality & MMAP_PAGE_ZERO)) {
178 vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 178 vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
179 if (vma) { 179 if (vma) {
180 memset(vma, 0, sizeof(*vma)); 180 memset(vma, 0, sizeof(*vma));
181 vma->vm_mm = current->mm; 181 vma->vm_mm = current->mm;
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index f4edfbf27134..eb92cef9cd0d 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -564,8 +564,8 @@ pcibios_enable_device (struct pci_dev *dev, int mask)
564void 564void
565pcibios_disable_device (struct pci_dev *dev) 565pcibios_disable_device (struct pci_dev *dev)
566{ 566{
567 if (dev->is_enabled) 567 BUG_ON(atomic_read(&dev->enable_cnt));
568 acpi_pci_irq_disable(dev); 568 acpi_pci_irq_disable(dev);
569} 569}
570 570
571void 571void
diff --git a/arch/m32r/kernel/setup.c b/arch/m32r/kernel/setup.c
index 0e7778be33cc..936205f7aba0 100644
--- a/arch/m32r/kernel/setup.c
+++ b/arch/m32r/kernel/setup.c
@@ -196,9 +196,7 @@ static unsigned long __init setup_memory(void)
196 if (LOADER_TYPE && INITRD_START) { 196 if (LOADER_TYPE && INITRD_START) {
197 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) { 197 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
198 reserve_bootmem(INITRD_START, INITRD_SIZE); 198 reserve_bootmem(INITRD_START, INITRD_SIZE);
199 initrd_start = INITRD_START ? 199 initrd_start = INITRD_START + PAGE_OFFSET;
200 INITRD_START + PAGE_OFFSET : 0;
201
202 initrd_end = initrd_start + INITRD_SIZE; 200 initrd_end = initrd_start + INITRD_SIZE;
203 printk("initrd:start[%08lx],size[%08lx]\n", 201 printk("initrd:start[%08lx],size[%08lx]\n",
204 initrd_start, INITRD_SIZE); 202 initrd_start, INITRD_SIZE);
diff --git a/arch/m32r/kernel/signal.c b/arch/m32r/kernel/signal.c
index b60cea4aebaa..092ea86bb079 100644
--- a/arch/m32r/kernel/signal.c
+++ b/arch/m32r/kernel/signal.c
@@ -21,7 +21,7 @@
21#include <linux/unistd.h> 21#include <linux/unistd.h>
22#include <linux/stddef.h> 22#include <linux/stddef.h>
23#include <linux/personality.h> 23#include <linux/personality.h>
24#include <linux/suspend.h> 24#include <linux/freezer.h>
25#include <asm/cacheflush.h> 25#include <asm/cacheflush.h>
26#include <asm/ucontext.h> 26#include <asm/ucontext.h>
27#include <asm/uaccess.h> 27#include <asm/uaccess.h>
diff --git a/arch/m32r/mm/discontig.c b/arch/m32r/mm/discontig.c
index abb34ccd5986..c7efdb0aefc5 100644
--- a/arch/m32r/mm/discontig.c
+++ b/arch/m32r/mm/discontig.c
@@ -105,9 +105,7 @@ unsigned long __init setup_memory(void)
105 if (INITRD_START + INITRD_SIZE <= PFN_PHYS(max_low_pfn)) { 105 if (INITRD_START + INITRD_SIZE <= PFN_PHYS(max_low_pfn)) {
106 reserve_bootmem_node(NODE_DATA(0), INITRD_START, 106 reserve_bootmem_node(NODE_DATA(0), INITRD_START,
107 INITRD_SIZE); 107 INITRD_SIZE);
108 initrd_start = INITRD_START ? 108 initrd_start = INITRD_START + PAGE_OFFSET;
109 INITRD_START + PAGE_OFFSET : 0;
110
111 initrd_end = initrd_start + INITRD_SIZE; 109 initrd_end = initrd_start + INITRD_SIZE;
112 printk("initrd:start[%08lx],size[%08lx]\n", 110 printk("initrd:start[%08lx],size[%08lx]\n",
113 initrd_start, INITRD_SIZE); 111 initrd_start, INITRD_SIZE);
diff --git a/arch/m68k/amiga/chipram.c b/arch/m68k/amiga/chipram.c
index de1304c91112..fa015d801617 100644
--- a/arch/m68k/amiga/chipram.c
+++ b/arch/m68k/amiga/chipram.c
@@ -52,10 +52,9 @@ void *amiga_chip_alloc(unsigned long size, const char *name)
52#ifdef DEBUG 52#ifdef DEBUG
53 printk("amiga_chip_alloc: allocate %ld bytes\n", size); 53 printk("amiga_chip_alloc: allocate %ld bytes\n", size);
54#endif 54#endif
55 res = kmalloc(sizeof(struct resource), GFP_KERNEL); 55 res = kzalloc(sizeof(struct resource), GFP_KERNEL);
56 if (!res) 56 if (!res)
57 return NULL; 57 return NULL;
58 memset(res, 0, sizeof(struct resource));
59 res->name = name; 58 res->name = name;
60 59
61 if (allocate_resource(&chipram_res, res, size, 0, UINT_MAX, PAGE_SIZE, NULL, NULL) < 0) { 60 if (allocate_resource(&chipram_res, res, size, 0, UINT_MAX, PAGE_SIZE, NULL, NULL) < 0) {
diff --git a/arch/m68k/atari/hades-pci.c b/arch/m68k/atari/hades-pci.c
index 6ca57b6564da..bee2b1443e36 100644
--- a/arch/m68k/atari/hades-pci.c
+++ b/arch/m68k/atari/hades-pci.c
@@ -375,10 +375,9 @@ struct pci_bus_info * __init init_hades_pci(void)
375 * Allocate memory for bus info structure. 375 * Allocate memory for bus info structure.
376 */ 376 */
377 377
378 bus = kmalloc(sizeof(struct pci_bus_info), GFP_KERNEL); 378 bus = kzalloc(sizeof(struct pci_bus_info), GFP_KERNEL);
379 if (!bus) 379 if (!bus)
380 return NULL; 380 return NULL;
381 memset(bus, 0, sizeof(struct pci_bus_info));
382 381
383 /* 382 /*
384 * Claim resources. The m68k has no separate I/O space, both 383 * Claim resources. The m68k has no separate I/O space, both
diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c
index 911f2ce3f53e..2adbeb16e1b8 100644
--- a/arch/m68k/mm/fault.c
+++ b/arch/m68k/mm/fault.c
@@ -99,7 +99,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
99 * If we're in an interrupt or have no user 99 * If we're in an interrupt or have no user
100 * context, we must not take the fault.. 100 * context, we must not take the fault..
101 */ 101 */
102 if (in_interrupt() || !mm) 102 if (in_atomic() || !mm)
103 goto no_context; 103 goto no_context;
104 104
105 down_read(&mm->mmap_sem); 105 down_read(&mm->mmap_sem);
diff --git a/arch/m68knommu/platform/5307/timers.c b/arch/m68knommu/platform/5307/timers.c
index 24781f009337..e5668af19789 100644
--- a/arch/m68knommu/platform/5307/timers.c
+++ b/arch/m68knommu/platform/5307/timers.c
@@ -3,7 +3,7 @@
3/* 3/*
4 * timers.c -- generic ColdFire hardware timer support. 4 * timers.c -- generic ColdFire hardware timer support.
5 * 5 *
6 * Copyright (C) 1999-2003, Greg Ungerer (gerg@snapgear.com) 6 * Copyright (C) 1999-2006, Greg Ungerer (gerg@snapgear.com)
7 */ 7 */
8 8
9/***************************************************************************/ 9/***************************************************************************/
@@ -44,6 +44,14 @@ unsigned int mcf_timerlevel = 5;
44extern void mcf_settimericr(int timer, int level); 44extern void mcf_settimericr(int timer, int level);
45extern int mcf_timerirqpending(int timer); 45extern int mcf_timerirqpending(int timer);
46 46
47#if defined(CONFIG_M532x)
48#define __raw_readtrr __raw_readl
49#define __raw_writetrr __raw_writel
50#else
51#define __raw_readtrr __raw_readw
52#define __raw_writetrr __raw_writew
53#endif
54
47/***************************************************************************/ 55/***************************************************************************/
48 56
49void coldfire_tick(void) 57void coldfire_tick(void)
@@ -57,7 +65,7 @@ void coldfire_tick(void)
57void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *)) 65void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *))
58{ 66{
59 __raw_writew(MCFTIMER_TMR_DISABLE, TA(MCFTIMER_TMR)); 67 __raw_writew(MCFTIMER_TMR_DISABLE, TA(MCFTIMER_TMR));
60 __raw_writew(((MCF_BUSCLK / 16) / HZ), TA(MCFTIMER_TRR)); 68 __raw_writetrr(((MCF_BUSCLK / 16) / HZ), TA(MCFTIMER_TRR));
61 __raw_writew(MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 | 69 __raw_writew(MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 |
62 MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE, TA(MCFTIMER_TMR)); 70 MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE, TA(MCFTIMER_TMR));
63 71
@@ -76,7 +84,7 @@ unsigned long coldfire_timer_offset(void)
76 unsigned long trr, tcn, offset; 84 unsigned long trr, tcn, offset;
77 85
78 tcn = __raw_readw(TA(MCFTIMER_TCN)); 86 tcn = __raw_readw(TA(MCFTIMER_TCN));
79 trr = __raw_readw(TA(MCFTIMER_TRR)); 87 trr = __raw_readtrr(TA(MCFTIMER_TRR));
80 offset = (tcn * (1000000 / HZ)) / trr; 88 offset = (tcn * (1000000 / HZ)) / trr;
81 89
82 /* Check if we just wrapped the counters and maybe missed a tick */ 90 /* Check if we just wrapped the counters and maybe missed a tick */
@@ -120,7 +128,7 @@ void coldfire_profile_init(void)
120 /* Set up TIMER 2 as high speed profile clock */ 128 /* Set up TIMER 2 as high speed profile clock */
121 __raw_writew(MCFTIMER_TMR_DISABLE, PA(MCFTIMER_TMR)); 129 __raw_writew(MCFTIMER_TMR_DISABLE, PA(MCFTIMER_TMR));
122 130
123 __raw_writew(((MCF_CLK / 16) / PROFILEHZ), PA(MCFTIMER_TRR)); 131 __raw_writetrr(((MCF_CLK / 16) / PROFILEHZ), PA(MCFTIMER_TRR));
124 __raw_writew(MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 | 132 __raw_writew(MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 |
125 MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE, PA(MCFTIMER_TMR)); 133 MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE, PA(MCFTIMER_TMR));
126 134
diff --git a/arch/m68knommu/platform/68360/config.c b/arch/m68knommu/platform/68360/config.c
index c5482e3622eb..1b36f6261764 100644
--- a/arch/m68knommu/platform/68360/config.c
+++ b/arch/m68knommu/platform/68360/config.c
@@ -114,7 +114,7 @@ void BSP_gettod (int *yearp, int *monp, int *dayp,
114{ 114{
115} 115}
116 116
117int BSP_hwclk(int op, struct hwclk_time *t) 117int BSP_hwclk(int op, struct rtc_time *t)
118{ 118{
119 if (!op) { 119 if (!op) {
120 /* read */ 120 /* read */
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 4d64960be035..d8af858fe3f5 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -242,6 +242,7 @@ config LASAT
242 select SYS_SUPPORTS_32BIT_KERNEL 242 select SYS_SUPPORTS_32BIT_KERNEL
243 select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL 243 select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
244 select SYS_SUPPORTS_LITTLE_ENDIAN 244 select SYS_SUPPORTS_LITTLE_ENDIAN
245 select GENERIC_HARDIRQS_NO__DO_IRQ
245 246
246config MIPS_ATLAS 247config MIPS_ATLAS
247 bool "MIPS Atlas board" 248 bool "MIPS Atlas board"
@@ -265,6 +266,7 @@ config MIPS_ATLAS
265 select SYS_SUPPORTS_BIG_ENDIAN 266 select SYS_SUPPORTS_BIG_ENDIAN
266 select SYS_SUPPORTS_LITTLE_ENDIAN 267 select SYS_SUPPORTS_LITTLE_ENDIAN
267 select SYS_SUPPORTS_MULTITHREADING if EXPERIMENTAL 268 select SYS_SUPPORTS_MULTITHREADING if EXPERIMENTAL
269 select GENERIC_HARDIRQS_NO__DO_IRQ
268 help 270 help
269 This enables support for the MIPS Technologies Atlas evaluation 271 This enables support for the MIPS Technologies Atlas evaluation
270 board. 272 board.
@@ -419,6 +421,7 @@ config MOMENCO_OCELOT_C
419 select SYS_SUPPORTS_32BIT_KERNEL 421 select SYS_SUPPORTS_32BIT_KERNEL
420 select SYS_SUPPORTS_64BIT_KERNEL 422 select SYS_SUPPORTS_64BIT_KERNEL
421 select SYS_SUPPORTS_BIG_ENDIAN 423 select SYS_SUPPORTS_BIG_ENDIAN
424 select GENERIC_HARDIRQS_NO__DO_IRQ
422 help 425 help
423 The Ocelot is a MIPS-based Single Board Computer (SBC) made by 426 The Ocelot is a MIPS-based Single Board Computer (SBC) made by
424 Momentum Computer <http://www.momenco.com/>. 427 Momentum Computer <http://www.momenco.com/>.
@@ -569,6 +572,7 @@ config SGI_IP27
569 select SYS_SUPPORTS_BIG_ENDIAN 572 select SYS_SUPPORTS_BIG_ENDIAN
570 select SYS_SUPPORTS_NUMA 573 select SYS_SUPPORTS_NUMA
571 select SYS_SUPPORTS_SMP 574 select SYS_SUPPORTS_SMP
575 select GENERIC_HARDIRQS_NO__DO_IRQ
572 help 576 help
573 This are the SGI Origin 200, Origin 2000 and Onyx 2 Graphics 577 This are the SGI Origin 200, Origin 2000 and Onyx 2 Graphics
574 workstations. To compile a Linux kernel that runs on these, say Y 578 workstations. To compile a Linux kernel that runs on these, say Y
@@ -835,6 +839,10 @@ config SCHED_NO_NO_OMIT_FRAME_POINTER
835 bool 839 bool
836 default y 840 default y
837 841
842config GENERIC_HARDIRQS_NO__DO_IRQ
843 bool
844 default n
845
838# 846#
839# Select some configuration options automatically based on user selections. 847# Select some configuration options automatically based on user selections.
840# 848#
@@ -996,6 +1004,7 @@ config SOC_PNX8550
996 select HW_HAS_PCI 1004 select HW_HAS_PCI
997 select SYS_HAS_CPU_MIPS32_R1 1005 select SYS_HAS_CPU_MIPS32_R1
998 select SYS_SUPPORTS_32BIT_KERNEL 1006 select SYS_SUPPORTS_32BIT_KERNEL
1007 select GENERIC_HARDIRQS_NO__DO_IRQ
999 1008
1000config SWAP_IO_SPACE 1009config SWAP_IO_SPACE
1001 bool 1010 bool
diff --git a/arch/mips/dec/ecc-berr.c b/arch/mips/dec/ecc-berr.c
index c8430c07355e..6d55e8aab668 100644
--- a/arch/mips/dec/ecc-berr.c
+++ b/arch/mips/dec/ecc-berr.c
@@ -25,6 +25,7 @@
25#include <asm/cpu.h> 25#include <asm/cpu.h>
26#include <asm/irq_regs.h> 26#include <asm/irq_regs.h>
27#include <asm/processor.h> 27#include <asm/processor.h>
28#include <asm/ptrace.h>
28#include <asm/system.h> 29#include <asm/system.h>
29#include <asm/traps.h> 30#include <asm/traps.h>
30 31
diff --git a/arch/mips/dec/ioasic-irq.c b/arch/mips/dec/ioasic-irq.c
index 269b22b34313..4c7cb4048d35 100644
--- a/arch/mips/dec/ioasic-irq.c
+++ b/arch/mips/dec/ioasic-irq.c
@@ -67,7 +67,6 @@ static struct irq_chip ioasic_irq_type = {
67 .mask = mask_ioasic_irq, 67 .mask = mask_ioasic_irq,
68 .mask_ack = ack_ioasic_irq, 68 .mask_ack = ack_ioasic_irq,
69 .unmask = unmask_ioasic_irq, 69 .unmask = unmask_ioasic_irq,
70 .end = end_ioasic_irq,
71}; 70};
72 71
73 72
@@ -106,8 +105,7 @@ void __init init_ioasic_irqs(int base)
106 set_irq_chip_and_handler(i, &ioasic_irq_type, 105 set_irq_chip_and_handler(i, &ioasic_irq_type,
107 handle_level_irq); 106 handle_level_irq);
108 for (; i < base + IO_IRQ_LINES; i++) 107 for (; i < base + IO_IRQ_LINES; i++)
109 set_irq_chip_and_handler(i, &ioasic_dma_irq_type, 108 set_irq_chip(i, &ioasic_dma_irq_type);
110 handle_level_irq);
111 109
112 ioasic_irq_base = base; 110 ioasic_irq_base = base;
113} 111}
diff --git a/arch/mips/dec/kn01-berr.c b/arch/mips/dec/kn01-berr.c
index f19b4617a0a6..d3b8002bf1e7 100644
--- a/arch/mips/dec/kn01-berr.c
+++ b/arch/mips/dec/kn01-berr.c
@@ -20,8 +20,10 @@
20#include <linux/types.h> 20#include <linux/types.h>
21 21
22#include <asm/inst.h> 22#include <asm/inst.h>
23#include <asm/irq_regs.h>
23#include <asm/mipsregs.h> 24#include <asm/mipsregs.h>
24#include <asm/page.h> 25#include <asm/page.h>
26#include <asm/ptrace.h>
25#include <asm/system.h> 27#include <asm/system.h>
26#include <asm/traps.h> 28#include <asm/traps.h>
27#include <asm/uaccess.h> 29#include <asm/uaccess.h>
diff --git a/arch/mips/dec/kn02-irq.c b/arch/mips/dec/kn02-irq.c
index 5a9be4c93584..916e46b8ccd8 100644
--- a/arch/mips/dec/kn02-irq.c
+++ b/arch/mips/dec/kn02-irq.c
@@ -57,19 +57,12 @@ static void ack_kn02_irq(unsigned int irq)
57 iob(); 57 iob();
58} 58}
59 59
60static void end_kn02_irq(unsigned int irq)
61{
62 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
63 unmask_kn02_irq(irq);
64}
65
66static struct irq_chip kn02_irq_type = { 60static struct irq_chip kn02_irq_type = {
67 .typename = "KN02-CSR", 61 .typename = "KN02-CSR",
68 .ack = ack_kn02_irq, 62 .ack = ack_kn02_irq,
69 .mask = mask_kn02_irq, 63 .mask = mask_kn02_irq,
70 .mask_ack = ack_kn02_irq, 64 .mask_ack = ack_kn02_irq,
71 .unmask = unmask_kn02_irq, 65 .unmask = unmask_kn02_irq,
72 .end = end_kn02_irq,
73}; 66};
74 67
75 68
diff --git a/arch/mips/emma2rh/common/irq_emma2rh.c b/arch/mips/emma2rh/common/irq_emma2rh.c
index 59b98299c896..8d880f0b06ec 100644
--- a/arch/mips/emma2rh/common/irq_emma2rh.c
+++ b/arch/mips/emma2rh/common/irq_emma2rh.c
@@ -56,19 +56,12 @@ static void emma2rh_irq_disable(unsigned int irq)
56 ll_emma2rh_irq_disable(irq - emma2rh_irq_base); 56 ll_emma2rh_irq_disable(irq - emma2rh_irq_base);
57} 57}
58 58
59static void emma2rh_irq_end(unsigned int irq)
60{
61 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
62 ll_emma2rh_irq_enable(irq - emma2rh_irq_base);
63}
64
65struct irq_chip emma2rh_irq_controller = { 59struct irq_chip emma2rh_irq_controller = {
66 .typename = "emma2rh_irq", 60 .typename = "emma2rh_irq",
67 .ack = emma2rh_irq_disable, 61 .ack = emma2rh_irq_disable,
68 .mask = emma2rh_irq_disable, 62 .mask = emma2rh_irq_disable,
69 .mask_ack = emma2rh_irq_disable, 63 .mask_ack = emma2rh_irq_disable,
70 .unmask = emma2rh_irq_enable, 64 .unmask = emma2rh_irq_enable,
71 .end = emma2rh_irq_end,
72}; 65};
73 66
74void emma2rh_irq_init(u32 irq_base) 67void emma2rh_irq_init(u32 irq_base)
diff --git a/arch/mips/emma2rh/markeins/irq_markeins.c b/arch/mips/emma2rh/markeins/irq_markeins.c
index 3ac4e405ecdc..2116d9be5fa9 100644
--- a/arch/mips/emma2rh/markeins/irq_markeins.c
+++ b/arch/mips/emma2rh/markeins/irq_markeins.c
@@ -48,19 +48,12 @@ static void emma2rh_sw_irq_disable(unsigned int irq)
48 ll_emma2rh_sw_irq_disable(irq - emma2rh_sw_irq_base); 48 ll_emma2rh_sw_irq_disable(irq - emma2rh_sw_irq_base);
49} 49}
50 50
51static void emma2rh_sw_irq_end(unsigned int irq)
52{
53 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
54 ll_emma2rh_sw_irq_enable(irq - emma2rh_sw_irq_base);
55}
56
57struct irq_chip emma2rh_sw_irq_controller = { 51struct irq_chip emma2rh_sw_irq_controller = {
58 .typename = "emma2rh_sw_irq", 52 .typename = "emma2rh_sw_irq",
59 .ack = emma2rh_sw_irq_disable, 53 .ack = emma2rh_sw_irq_disable,
60 .mask = emma2rh_sw_irq_disable, 54 .mask = emma2rh_sw_irq_disable,
61 .mask_ack = emma2rh_sw_irq_disable, 55 .mask_ack = emma2rh_sw_irq_disable,
62 .unmask = emma2rh_sw_irq_enable, 56 .unmask = emma2rh_sw_irq_enable,
63 .end = emma2rh_sw_irq_end,
64}; 57};
65 58
66void emma2rh_sw_irq_init(u32 irq_base) 59void emma2rh_sw_irq_init(u32 irq_base)
diff --git a/arch/mips/jazz/irq.c b/arch/mips/jazz/irq.c
index 5c4f50cdf157..f8d417b5c2bb 100644
--- a/arch/mips/jazz/irq.c
+++ b/arch/mips/jazz/irq.c
@@ -39,19 +39,12 @@ void disable_r4030_irq(unsigned int irq)
39 spin_unlock_irqrestore(&r4030_lock, flags); 39 spin_unlock_irqrestore(&r4030_lock, flags);
40} 40}
41 41
42static void end_r4030_irq(unsigned int irq)
43{
44 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
45 enable_r4030_irq(irq);
46}
47
48static struct irq_chip r4030_irq_type = { 42static struct irq_chip r4030_irq_type = {
49 .typename = "R4030", 43 .typename = "R4030",
50 .ack = disable_r4030_irq, 44 .ack = disable_r4030_irq,
51 .mask = disable_r4030_irq, 45 .mask = disable_r4030_irq,
52 .mask_ack = disable_r4030_irq, 46 .mask_ack = disable_r4030_irq,
53 .unmask = enable_r4030_irq, 47 .unmask = enable_r4030_irq,
54 .end = end_r4030_irq,
55}; 48};
56 49
57void __init init_r4030_ints(void) 50void __init init_r4030_ints(void)
diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
index 4a9f1ecefaf2..9b34238d41c0 100644
--- a/arch/mips/kernel/binfmt_elfn32.c
+++ b/arch/mips/kernel/binfmt_elfn32.c
@@ -90,7 +90,6 @@ struct elf_prpsinfo32
90 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */ 90 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
91}; 91};
92 92
93#define elf_addr_t u32
94#define elf_caddr_t u32 93#define elf_caddr_t u32
95#define init_elf_binfmt init_elfn32_binfmt 94#define init_elf_binfmt init_elfn32_binfmt
96 95
diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
index e31813779895..993f7ec70f35 100644
--- a/arch/mips/kernel/binfmt_elfo32.c
+++ b/arch/mips/kernel/binfmt_elfo32.c
@@ -92,7 +92,6 @@ struct elf_prpsinfo32
92 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */ 92 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
93}; 93};
94 94
95#define elf_addr_t u32
96#define elf_caddr_t u32 95#define elf_caddr_t u32
97#define init_elf_binfmt init_elf32_binfmt 96#define init_elf_binfmt init_elf32_binfmt
98 97
diff --git a/arch/mips/kernel/i8259.c b/arch/mips/kernel/i8259.c
index 2526c0ca4d81..b59a676c6d0e 100644
--- a/arch/mips/kernel/i8259.c
+++ b/arch/mips/kernel/i8259.c
@@ -19,9 +19,6 @@
19#include <asm/i8259.h> 19#include <asm/i8259.h>
20#include <asm/io.h> 20#include <asm/io.h>
21 21
22void enable_8259A_irq(unsigned int irq);
23void disable_8259A_irq(unsigned int irq);
24
25/* 22/*
26 * This is the 'legacy' 8259A Programmable Interrupt Controller, 23 * This is the 'legacy' 8259A Programmable Interrupt Controller,
27 * present in the majority of PC/AT boxes. 24 * present in the majority of PC/AT boxes.
@@ -31,23 +28,16 @@ void disable_8259A_irq(unsigned int irq);
31 * moves to arch independent land 28 * moves to arch independent land
32 */ 29 */
33 30
31static int i8259A_auto_eoi;
34DEFINE_SPINLOCK(i8259A_lock); 32DEFINE_SPINLOCK(i8259A_lock);
35 33/* some platforms call this... */
36static void end_8259A_irq (unsigned int irq)
37{
38 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)) &&
39 irq_desc[irq].action)
40 enable_8259A_irq(irq);
41}
42
43void mask_and_ack_8259A(unsigned int); 34void mask_and_ack_8259A(unsigned int);
44 35
45static struct irq_chip i8259A_irq_type = { 36static struct irq_chip i8259A_chip = {
46 .typename = "XT-PIC", 37 .name = "XT-PIC",
47 .enable = enable_8259A_irq, 38 .mask = disable_8259A_irq,
48 .disable = disable_8259A_irq, 39 .unmask = enable_8259A_irq,
49 .ack = mask_and_ack_8259A, 40 .mask_ack = mask_and_ack_8259A,
50 .end = end_8259A_irq,
51}; 41};
52 42
53/* 43/*
@@ -59,8 +49,8 @@ static struct irq_chip i8259A_irq_type = {
59 */ 49 */
60static unsigned int cached_irq_mask = 0xffff; 50static unsigned int cached_irq_mask = 0xffff;
61 51
62#define cached_21 (cached_irq_mask) 52#define cached_master_mask (cached_irq_mask)
63#define cached_A1 (cached_irq_mask >> 8) 53#define cached_slave_mask (cached_irq_mask >> 8)
64 54
65void disable_8259A_irq(unsigned int irq) 55void disable_8259A_irq(unsigned int irq)
66{ 56{
@@ -70,9 +60,9 @@ void disable_8259A_irq(unsigned int irq)
70 spin_lock_irqsave(&i8259A_lock, flags); 60 spin_lock_irqsave(&i8259A_lock, flags);
71 cached_irq_mask |= mask; 61 cached_irq_mask |= mask;
72 if (irq & 8) 62 if (irq & 8)
73 outb(cached_A1,0xA1); 63 outb(cached_slave_mask, PIC_SLAVE_IMR);
74 else 64 else
75 outb(cached_21,0x21); 65 outb(cached_master_mask, PIC_MASTER_IMR);
76 spin_unlock_irqrestore(&i8259A_lock, flags); 66 spin_unlock_irqrestore(&i8259A_lock, flags);
77} 67}
78 68
@@ -84,9 +74,9 @@ void enable_8259A_irq(unsigned int irq)
84 spin_lock_irqsave(&i8259A_lock, flags); 74 spin_lock_irqsave(&i8259A_lock, flags);
85 cached_irq_mask &= mask; 75 cached_irq_mask &= mask;
86 if (irq & 8) 76 if (irq & 8)
87 outb(cached_A1,0xA1); 77 outb(cached_slave_mask, PIC_SLAVE_IMR);
88 else 78 else
89 outb(cached_21,0x21); 79 outb(cached_master_mask, PIC_MASTER_IMR);
90 spin_unlock_irqrestore(&i8259A_lock, flags); 80 spin_unlock_irqrestore(&i8259A_lock, flags);
91} 81}
92 82
@@ -98,9 +88,9 @@ int i8259A_irq_pending(unsigned int irq)
98 88
99 spin_lock_irqsave(&i8259A_lock, flags); 89 spin_lock_irqsave(&i8259A_lock, flags);
100 if (irq < 8) 90 if (irq < 8)
101 ret = inb(0x20) & mask; 91 ret = inb(PIC_MASTER_CMD) & mask;
102 else 92 else
103 ret = inb(0xA0) & (mask >> 8); 93 ret = inb(PIC_SLAVE_CMD) & (mask >> 8);
104 spin_unlock_irqrestore(&i8259A_lock, flags); 94 spin_unlock_irqrestore(&i8259A_lock, flags);
105 95
106 return ret; 96 return ret;
@@ -109,7 +99,7 @@ int i8259A_irq_pending(unsigned int irq)
109void make_8259A_irq(unsigned int irq) 99void make_8259A_irq(unsigned int irq)
110{ 100{
111 disable_irq_nosync(irq); 101 disable_irq_nosync(irq);
112 set_irq_chip(irq, &i8259A_irq_type); 102 set_irq_chip_and_handler(irq, &i8259A_chip, handle_level_irq);
113 enable_irq(irq); 103 enable_irq(irq);
114} 104}
115 105
@@ -125,14 +115,14 @@ static inline int i8259A_irq_real(unsigned int irq)
125 int irqmask = 1 << irq; 115 int irqmask = 1 << irq;
126 116
127 if (irq < 8) { 117 if (irq < 8) {
128 outb(0x0B,0x20); /* ISR register */ 118 outb(0x0B,PIC_MASTER_CMD); /* ISR register */
129 value = inb(0x20) & irqmask; 119 value = inb(PIC_MASTER_CMD) & irqmask;
130 outb(0x0A,0x20); /* back to the IRR register */ 120 outb(0x0A,PIC_MASTER_CMD); /* back to the IRR register */
131 return value; 121 return value;
132 } 122 }
133 outb(0x0B,0xA0); /* ISR register */ 123 outb(0x0B,PIC_SLAVE_CMD); /* ISR register */
134 value = inb(0xA0) & (irqmask >> 8); 124 value = inb(PIC_SLAVE_CMD) & (irqmask >> 8);
135 outb(0x0A,0xA0); /* back to the IRR register */ 125 outb(0x0A,PIC_SLAVE_CMD); /* back to the IRR register */
136 return value; 126 return value;
137} 127}
138 128
@@ -149,17 +139,19 @@ void mask_and_ack_8259A(unsigned int irq)
149 139
150 spin_lock_irqsave(&i8259A_lock, flags); 140 spin_lock_irqsave(&i8259A_lock, flags);
151 /* 141 /*
152 * Lightweight spurious IRQ detection. We do not want to overdo 142 * Lightweight spurious IRQ detection. We do not want
153 * spurious IRQ handling - it's usually a sign of hardware problems, so 143 * to overdo spurious IRQ handling - it's usually a sign
154 * we only do the checks we can do without slowing down good hardware 144 * of hardware problems, so we only do the checks we can
155 * nnecesserily. 145 * do without slowing down good hardware unnecessarily.
156 * 146 *
157 * Note that IRQ7 and IRQ15 (the two spurious IRQs usually resulting 147 * Note that IRQ7 and IRQ15 (the two spurious IRQs
158 * rom the 8259A-1|2 PICs) occur even if the IRQ is masked in the 8259A. 148 * usually resulting from the 8259A-1|2 PICs) occur
159 * Thus we can check spurious 8259A IRQs without doing the quite slow 149 * even if the IRQ is masked in the 8259A. Thus we
160 * i8259A_irq_real() call for every IRQ. This does not cover 100% of 150 * can check spurious 8259A IRQs without doing the
161 * spurious interrupts, but should be enough to warn the user that 151 * quite slow i8259A_irq_real() call for every IRQ.
162 * there is something bad going on ... 152 * This does not cover 100% of spurious interrupts,
153 * but should be enough to warn the user that there
154 * is something bad going on ...
163 */ 155 */
164 if (cached_irq_mask & irqmask) 156 if (cached_irq_mask & irqmask)
165 goto spurious_8259A_irq; 157 goto spurious_8259A_irq;
@@ -167,14 +159,14 @@ void mask_and_ack_8259A(unsigned int irq)
167 159
168handle_real_irq: 160handle_real_irq:
169 if (irq & 8) { 161 if (irq & 8) {
170 inb(0xA1); /* DUMMY - (do we need this?) */ 162 inb(PIC_SLAVE_IMR); /* DUMMY - (do we need this?) */
171 outb(cached_A1,0xA1); 163 outb(cached_slave_mask, PIC_SLAVE_IMR);
172 outb(0x60+(irq&7),0xA0);/* 'Specific EOI' to slave */ 164 outb(0x60+(irq&7),PIC_SLAVE_CMD);/* 'Specific EOI' to slave */
173 outb(0x62,0x20); /* 'Specific EOI' to master-IRQ2 */ 165 outb(0x60+PIC_CASCADE_IR,PIC_MASTER_CMD); /* 'Specific EOI' to master-IRQ2 */
174 } else { 166 } else {
175 inb(0x21); /* DUMMY - (do we need this?) */ 167 inb(PIC_MASTER_IMR); /* DUMMY - (do we need this?) */
176 outb(cached_21,0x21); 168 outb(cached_master_mask, PIC_MASTER_IMR);
177 outb(0x60+irq,0x20); /* 'Specific EOI' to master */ 169 outb(0x60+irq,PIC_MASTER_CMD); /* 'Specific EOI to master */
178 } 170 }
179#ifdef CONFIG_MIPS_MT_SMTC 171#ifdef CONFIG_MIPS_MT_SMTC
180 if (irq_hwmask[irq] & ST0_IM) 172 if (irq_hwmask[irq] & ST0_IM)
@@ -195,7 +187,7 @@ spurious_8259A_irq:
195 goto handle_real_irq; 187 goto handle_real_irq;
196 188
197 { 189 {
198 static int spurious_irq_mask = 0; 190 static int spurious_irq_mask;
199 /* 191 /*
200 * At this point we can be sure the IRQ is spurious, 192 * At this point we can be sure the IRQ is spurious,
201 * lets ACK and report it. [once per IRQ] 193 * lets ACK and report it. [once per IRQ]
@@ -216,13 +208,25 @@ spurious_8259A_irq:
216 208
217static int i8259A_resume(struct sys_device *dev) 209static int i8259A_resume(struct sys_device *dev)
218{ 210{
219 init_8259A(0); 211 init_8259A(i8259A_auto_eoi);
212 return 0;
213}
214
215static int i8259A_shutdown(struct sys_device *dev)
216{
217 /* Put the i8259A into a quiescent state that
218 * the kernel initialization code can get it
219 * out of.
220 */
221 outb(0xff, PIC_MASTER_IMR); /* mask all of 8259A-1 */
222 outb(0xff, PIC_SLAVE_IMR); /* mask all of 8259A-1 */
220 return 0; 223 return 0;
221} 224}
222 225
223static struct sysdev_class i8259_sysdev_class = { 226static struct sysdev_class i8259_sysdev_class = {
224 set_kset_name("i8259"), 227 set_kset_name("i8259"),
225 .resume = i8259A_resume, 228 .resume = i8259A_resume,
229 .shutdown = i8259A_shutdown,
226}; 230};
227 231
228static struct sys_device device_i8259A = { 232static struct sys_device device_i8259A = {
@@ -244,41 +248,41 @@ void __init init_8259A(int auto_eoi)
244{ 248{
245 unsigned long flags; 249 unsigned long flags;
246 250
251 i8259A_auto_eoi = auto_eoi;
252
247 spin_lock_irqsave(&i8259A_lock, flags); 253 spin_lock_irqsave(&i8259A_lock, flags);
248 254
249 outb(0xff, 0x21); /* mask all of 8259A-1 */ 255 outb(0xff, PIC_MASTER_IMR); /* mask all of 8259A-1 */
250 outb(0xff, 0xA1); /* mask all of 8259A-2 */ 256 outb(0xff, PIC_SLAVE_IMR); /* mask all of 8259A-2 */
251 257
252 /* 258 /*
253 * outb_p - this has to work on a wide range of PC hardware. 259 * outb_p - this has to work on a wide range of PC hardware.
254 */ 260 */
255 outb_p(0x11, 0x20); /* ICW1: select 8259A-1 init */ 261 outb_p(0x11, PIC_MASTER_CMD); /* ICW1: select 8259A-1 init */
256 outb_p(0x00, 0x21); /* ICW2: 8259A-1 IR0-7 mapped to 0x00-0x07 */ 262 outb_p(I8259A_IRQ_BASE + 0, PIC_MASTER_IMR); /* ICW2: 8259A-1 IR0 mapped to I8259A_IRQ_BASE + 0x00 */
257 outb_p(0x04, 0x21); /* 8259A-1 (the master) has a slave on IR2 */ 263 outb_p(1U << PIC_CASCADE_IR, PIC_MASTER_IMR); /* 8259A-1 (the master) has a slave on IR2 */
258 if (auto_eoi) 264 if (auto_eoi) /* master does Auto EOI */
259 outb_p(0x03, 0x21); /* master does Auto EOI */ 265 outb_p(MASTER_ICW4_DEFAULT | PIC_ICW4_AEOI, PIC_MASTER_IMR);
260 else 266 else /* master expects normal EOI */
261 outb_p(0x01, 0x21); /* master expects normal EOI */ 267 outb_p(MASTER_ICW4_DEFAULT, PIC_MASTER_IMR);
262 268
263 outb_p(0x11, 0xA0); /* ICW1: select 8259A-2 init */ 269 outb_p(0x11, PIC_SLAVE_CMD); /* ICW1: select 8259A-2 init */
264 outb_p(0x08, 0xA1); /* ICW2: 8259A-2 IR0-7 mapped to 0x08-0x0f */ 270 outb_p(I8259A_IRQ_BASE + 8, PIC_SLAVE_IMR); /* ICW2: 8259A-2 IR0 mapped to I8259A_IRQ_BASE + 0x08 */
265 outb_p(0x02, 0xA1); /* 8259A-2 is a slave on master's IR2 */ 271 outb_p(PIC_CASCADE_IR, PIC_SLAVE_IMR); /* 8259A-2 is a slave on master's IR2 */
266 outb_p(0x01, 0xA1); /* (slave's support for AEOI in flat mode 272 outb_p(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR); /* (slave's support for AEOI in flat mode is to be investigated) */
267 is to be investigated) */
268
269 if (auto_eoi) 273 if (auto_eoi)
270 /* 274 /*
271 * in AEOI mode we just have to mask the interrupt 275 * In AEOI mode we just have to mask the interrupt
272 * when acking. 276 * when acking.
273 */ 277 */
274 i8259A_irq_type.ack = disable_8259A_irq; 278 i8259A_chip.mask_ack = disable_8259A_irq;
275 else 279 else
276 i8259A_irq_type.ack = mask_and_ack_8259A; 280 i8259A_chip.mask_ack = mask_and_ack_8259A;
277 281
278 udelay(100); /* wait for 8259A to initialize */ 282 udelay(100); /* wait for 8259A to initialize */
279 283
280 outb(cached_21, 0x21); /* restore master IRQ mask */ 284 outb(cached_master_mask, PIC_MASTER_IMR); /* restore master IRQ mask */
281 outb(cached_A1, 0xA1); /* restore slave IRQ mask */ 285 outb(cached_slave_mask, PIC_SLAVE_IMR); /* restore slave IRQ mask */
282 286
283 spin_unlock_irqrestore(&i8259A_lock, flags); 287 spin_unlock_irqrestore(&i8259A_lock, flags);
284} 288}
@@ -291,11 +295,17 @@ static struct irqaction irq2 = {
291}; 295};
292 296
293static struct resource pic1_io_resource = { 297static struct resource pic1_io_resource = {
294 .name = "pic1", .start = 0x20, .end = 0x21, .flags = IORESOURCE_BUSY 298 .name = "pic1",
299 .start = PIC_MASTER_CMD,
300 .end = PIC_MASTER_IMR,
301 .flags = IORESOURCE_BUSY
295}; 302};
296 303
297static struct resource pic2_io_resource = { 304static struct resource pic2_io_resource = {
298 .name = "pic2", .start = 0xa0, .end = 0xa1, .flags = IORESOURCE_BUSY 305 .name = "pic2",
306 .start = PIC_SLAVE_CMD,
307 .end = PIC_SLAVE_IMR,
308 .flags = IORESOURCE_BUSY
299}; 309};
300 310
301/* 311/*
@@ -313,7 +323,7 @@ void __init init_i8259_irqs (void)
313 init_8259A(0); 323 init_8259A(0);
314 324
315 for (i = 0; i < 16; i++) 325 for (i = 0; i < 16; i++)
316 set_irq_chip(i, &i8259A_irq_type); 326 set_irq_chip_and_handler(i, &i8259A_chip, handle_level_irq);
317 327
318 setup_irq(2, &irq2); 328 setup_irq(PIC_CASCADE_IR, &irq2);
319} 329}
diff --git a/arch/mips/kernel/irixelf.c b/arch/mips/kernel/irixelf.c
index ab12c8f01518..1bbefbf43373 100644
--- a/arch/mips/kernel/irixelf.c
+++ b/arch/mips/kernel/irixelf.c
@@ -52,10 +52,6 @@ static struct linux_binfmt irix_format = {
52 irix_core_dump, PAGE_SIZE 52 irix_core_dump, PAGE_SIZE
53}; 53};
54 54
55#ifndef elf_addr_t
56#define elf_addr_t unsigned long
57#endif
58
59#ifdef DEBUG 55#ifdef DEBUG
60/* Debugging routines. */ 56/* Debugging routines. */
61static char *get_elf_p_type(Elf32_Word p_type) 57static char *get_elf_p_type(Elf32_Word p_type)
@@ -1013,7 +1009,7 @@ static int notesize(struct memelfnote *en)
1013 int sz; 1009 int sz;
1014 1010
1015 sz = sizeof(struct elf_note); 1011 sz = sizeof(struct elf_note);
1016 sz += roundup(strlen(en->name), 4); 1012 sz += roundup(strlen(en->name) + 1, 4);
1017 sz += roundup(en->datasz, 4); 1013 sz += roundup(en->datasz, 4);
1018 1014
1019 return sz; 1015 return sz;
@@ -1032,7 +1028,7 @@ static int writenote(struct memelfnote *men, struct file *file)
1032{ 1028{
1033 struct elf_note en; 1029 struct elf_note en;
1034 1030
1035 en.n_namesz = strlen(men->name); 1031 en.n_namesz = strlen(men->name) + 1;
1036 en.n_descsz = men->datasz; 1032 en.n_descsz = men->datasz;
1037 en.n_type = men->type; 1033 en.n_type = men->type;
1038 1034
diff --git a/arch/mips/kernel/irq-mv6434x.c b/arch/mips/kernel/irq-mv6434x.c
index 6cfb31cafde2..efbd219845b5 100644
--- a/arch/mips/kernel/irq-mv6434x.c
+++ b/arch/mips/kernel/irq-mv6434x.c
@@ -67,15 +67,6 @@ static inline void unmask_mv64340_irq(unsigned int irq)
67} 67}
68 68
69/* 69/*
70 * End IRQ processing
71 */
72static void end_mv64340_irq(unsigned int irq)
73{
74 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
75 unmask_mv64340_irq(irq);
76}
77
78/*
79 * Interrupt handler for interrupts coming from the Marvell chip. 70 * Interrupt handler for interrupts coming from the Marvell chip.
80 * It could be built in ethernet ports etc... 71 * It could be built in ethernet ports etc...
81 */ 72 */
@@ -106,7 +97,6 @@ struct irq_chip mv64340_irq_type = {
106 .mask = mask_mv64340_irq, 97 .mask = mask_mv64340_irq,
107 .mask_ack = mask_mv64340_irq, 98 .mask_ack = mask_mv64340_irq,
108 .unmask = unmask_mv64340_irq, 99 .unmask = unmask_mv64340_irq,
109 .end = end_mv64340_irq,
110}; 100};
111 101
112void __init mv64340_irq_init(unsigned int base) 102void __init mv64340_irq_init(unsigned int base)
diff --git a/arch/mips/kernel/irq-rm7000.c b/arch/mips/kernel/irq-rm7000.c
index ddcc2a5f8a06..123324ba8c14 100644
--- a/arch/mips/kernel/irq-rm7000.c
+++ b/arch/mips/kernel/irq-rm7000.c
@@ -29,19 +29,12 @@ static inline void mask_rm7k_irq(unsigned int irq)
29 clear_c0_intcontrol(0x100 << (irq - irq_base)); 29 clear_c0_intcontrol(0x100 << (irq - irq_base));
30} 30}
31 31
32static void rm7k_cpu_irq_end(unsigned int irq)
33{
34 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
35 unmask_rm7k_irq(irq);
36}
37
38static struct irq_chip rm7k_irq_controller = { 32static struct irq_chip rm7k_irq_controller = {
39 .typename = "RM7000", 33 .typename = "RM7000",
40 .ack = mask_rm7k_irq, 34 .ack = mask_rm7k_irq,
41 .mask = mask_rm7k_irq, 35 .mask = mask_rm7k_irq,
42 .mask_ack = mask_rm7k_irq, 36 .mask_ack = mask_rm7k_irq,
43 .unmask = unmask_rm7k_irq, 37 .unmask = unmask_rm7k_irq,
44 .end = rm7k_cpu_irq_end,
45}; 38};
46 39
47void __init rm7k_cpu_irq_init(int base) 40void __init rm7k_cpu_irq_init(int base)
diff --git a/arch/mips/kernel/irq-rm9000.c b/arch/mips/kernel/irq-rm9000.c
index ba6440c88abd..0e6f4c5349d2 100644
--- a/arch/mips/kernel/irq-rm9000.c
+++ b/arch/mips/kernel/irq-rm9000.c
@@ -80,19 +80,12 @@ static void rm9k_perfcounter_irq_shutdown(unsigned int irq)
80 on_each_cpu(local_rm9k_perfcounter_irq_shutdown, (void *) irq, 0, 1); 80 on_each_cpu(local_rm9k_perfcounter_irq_shutdown, (void *) irq, 0, 1);
81} 81}
82 82
83static void rm9k_cpu_irq_end(unsigned int irq)
84{
85 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
86 unmask_rm9k_irq(irq);
87}
88
89static struct irq_chip rm9k_irq_controller = { 83static struct irq_chip rm9k_irq_controller = {
90 .typename = "RM9000", 84 .typename = "RM9000",
91 .ack = mask_rm9k_irq, 85 .ack = mask_rm9k_irq,
92 .mask = mask_rm9k_irq, 86 .mask = mask_rm9k_irq,
93 .mask_ack = mask_rm9k_irq, 87 .mask_ack = mask_rm9k_irq,
94 .unmask = unmask_rm9k_irq, 88 .unmask = unmask_rm9k_irq,
95 .end = rm9k_cpu_irq_end,
96}; 89};
97 90
98static struct irq_chip rm9k_perfcounter_irq = { 91static struct irq_chip rm9k_perfcounter_irq = {
@@ -103,7 +96,6 @@ static struct irq_chip rm9k_perfcounter_irq = {
103 .mask = mask_rm9k_irq, 96 .mask = mask_rm9k_irq,
104 .mask_ack = mask_rm9k_irq, 97 .mask_ack = mask_rm9k_irq,
105 .unmask = unmask_rm9k_irq, 98 .unmask = unmask_rm9k_irq,
106 .end = rm9k_cpu_irq_end,
107}; 99};
108 100
109unsigned int rm9000_perfcount_irq; 101unsigned int rm9000_perfcount_irq;
diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
index b339798b3172..2fe4c868a801 100644
--- a/arch/mips/kernel/irq.c
+++ b/arch/mips/kernel/irq.c
@@ -117,7 +117,7 @@ int show_interrupts(struct seq_file *p, void *v)
117 for_each_online_cpu(j) 117 for_each_online_cpu(j)
118 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); 118 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
119#endif 119#endif
120 seq_printf(p, " %14s", irq_desc[i].chip->typename); 120 seq_printf(p, " %14s", irq_desc[i].chip->name);
121 seq_printf(p, " %s", action->name); 121 seq_printf(p, " %s", action->name);
122 122
123 for (action=action->next; action; action = action->next) 123 for (action=action->next; action; action = action->next)
diff --git a/arch/mips/kernel/irq_cpu.c b/arch/mips/kernel/irq_cpu.c
index be5ac23d3812..fcc86b96ccf6 100644
--- a/arch/mips/kernel/irq_cpu.c
+++ b/arch/mips/kernel/irq_cpu.c
@@ -50,12 +50,6 @@ static inline void mask_mips_irq(unsigned int irq)
50 irq_disable_hazard(); 50 irq_disable_hazard();
51} 51}
52 52
53static void mips_cpu_irq_end(unsigned int irq)
54{
55 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
56 unmask_mips_irq(irq);
57}
58
59static struct irq_chip mips_cpu_irq_controller = { 53static struct irq_chip mips_cpu_irq_controller = {
60 .typename = "MIPS", 54 .typename = "MIPS",
61 .ack = mask_mips_irq, 55 .ack = mask_mips_irq,
@@ -63,7 +57,6 @@ static struct irq_chip mips_cpu_irq_controller = {
63 .mask_ack = mask_mips_irq, 57 .mask_ack = mask_mips_irq,
64 .unmask = unmask_mips_irq, 58 .unmask = unmask_mips_irq,
65 .eoi = unmask_mips_irq, 59 .eoi = unmask_mips_irq,
66 .end = mips_cpu_irq_end,
67}; 60};
68 61
69/* 62/*
@@ -96,8 +89,6 @@ static void mips_mt_cpu_irq_ack(unsigned int irq)
96 mask_mips_mt_irq(irq); 89 mask_mips_mt_irq(irq);
97} 90}
98 91
99#define mips_mt_cpu_irq_end mips_cpu_irq_end
100
101static struct irq_chip mips_mt_cpu_irq_controller = { 92static struct irq_chip mips_mt_cpu_irq_controller = {
102 .typename = "MIPS", 93 .typename = "MIPS",
103 .startup = mips_mt_cpu_irq_startup, 94 .startup = mips_mt_cpu_irq_startup,
@@ -106,7 +97,6 @@ static struct irq_chip mips_mt_cpu_irq_controller = {
106 .mask_ack = mips_mt_cpu_irq_ack, 97 .mask_ack = mips_mt_cpu_irq_ack,
107 .unmask = unmask_mips_mt_irq, 98 .unmask = unmask_mips_mt_irq,
108 .eoi = unmask_mips_mt_irq, 99 .eoi = unmask_mips_mt_irq,
109 .end = mips_mt_cpu_irq_end,
110}; 100};
111 101
112void __init mips_cpu_irq_init(int irq_base) 102void __init mips_cpu_irq_init(int irq_base)
diff --git a/arch/mips/kernel/kspd.c b/arch/mips/kernel/kspd.c
index f06a144c7881..2c82412b9efe 100644
--- a/arch/mips/kernel/kspd.c
+++ b/arch/mips/kernel/kspd.c
@@ -319,7 +319,7 @@ static void sp_cleanup(void)
319static int channel_open = 0; 319static int channel_open = 0;
320 320
321/* the work handler */ 321/* the work handler */
322static void sp_work(void *data) 322static void sp_work(struct work_struct *unused)
323{ 323{
324 if (!channel_open) { 324 if (!channel_open) {
325 if( rtlx_open(RTLX_CHANNEL_SYSIO, 1) != 0) { 325 if( rtlx_open(RTLX_CHANNEL_SYSIO, 1) != 0) {
@@ -354,7 +354,7 @@ static void startwork(int vpe)
354 return; 354 return;
355 } 355 }
356 356
357 INIT_WORK(&work, sp_work, NULL); 357 INIT_WORK(&work, sp_work);
358 queue_work(workqueue, &work); 358 queue_work(workqueue, &work);
359 } else 359 } else
360 queue_work(workqueue, &work); 360 queue_work(workqueue, &work);
diff --git a/arch/mips/lasat/interrupt.c b/arch/mips/lasat/interrupt.c
index 4a84a7beac53..2affa5ff171c 100644
--- a/arch/mips/lasat/interrupt.c
+++ b/arch/mips/lasat/interrupt.c
@@ -44,19 +44,12 @@ void enable_lasat_irq(unsigned int irq_nr)
44 *lasat_int_mask |= (1 << irq_nr) << lasat_int_mask_shift; 44 *lasat_int_mask |= (1 << irq_nr) << lasat_int_mask_shift;
45} 45}
46 46
47static void end_lasat_irq(unsigned int irq)
48{
49 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
50 enable_lasat_irq(irq);
51}
52
53static struct irq_chip lasat_irq_type = { 47static struct irq_chip lasat_irq_type = {
54 .typename = "Lasat", 48 .typename = "Lasat",
55 .ack = disable_lasat_irq, 49 .ack = disable_lasat_irq,
56 .mask = disable_lasat_irq, 50 .mask = disable_lasat_irq,
57 .mask_ack = disable_lasat_irq, 51 .mask_ack = disable_lasat_irq,
58 .unmask = enable_lasat_irq, 52 .unmask = enable_lasat_irq,
59 .end = end_lasat_irq,
60}; 53};
61 54
62static inline int ls1bit32(unsigned int x) 55static inline int ls1bit32(unsigned int x)
diff --git a/arch/mips/mm/dma-coherent.c b/arch/mips/mm/dma-coherent.c
index 7fa5fd16e46b..5697c6e250a3 100644
--- a/arch/mips/mm/dma-coherent.c
+++ b/arch/mips/mm/dma-coherent.c
@@ -190,14 +190,14 @@ int dma_supported(struct device *dev, u64 mask)
190 190
191EXPORT_SYMBOL(dma_supported); 191EXPORT_SYMBOL(dma_supported);
192 192
193int dma_is_consistent(dma_addr_t dma_addr) 193int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
194{ 194{
195 return 1; 195 return 1;
196} 196}
197 197
198EXPORT_SYMBOL(dma_is_consistent); 198EXPORT_SYMBOL(dma_is_consistent);
199 199
200void dma_cache_sync(void *vaddr, size_t size, 200void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
201 enum dma_data_direction direction) 201 enum dma_data_direction direction)
202{ 202{
203 BUG_ON(direction == DMA_NONE); 203 BUG_ON(direction == DMA_NONE);
diff --git a/arch/mips/mm/dma-ip27.c b/arch/mips/mm/dma-ip27.c
index 8da19fd22ac6..f088344db465 100644
--- a/arch/mips/mm/dma-ip27.c
+++ b/arch/mips/mm/dma-ip27.c
@@ -197,14 +197,14 @@ int dma_supported(struct device *dev, u64 mask)
197 197
198EXPORT_SYMBOL(dma_supported); 198EXPORT_SYMBOL(dma_supported);
199 199
200int dma_is_consistent(dma_addr_t dma_addr) 200int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
201{ 201{
202 return 1; 202 return 1;
203} 203}
204 204
205EXPORT_SYMBOL(dma_is_consistent); 205EXPORT_SYMBOL(dma_is_consistent);
206 206
207void dma_cache_sync(void *vaddr, size_t size, 207void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
208 enum dma_data_direction direction) 208 enum dma_data_direction direction)
209{ 209{
210 BUG_ON(direction == DMA_NONE); 210 BUG_ON(direction == DMA_NONE);
diff --git a/arch/mips/mm/dma-ip32.c b/arch/mips/mm/dma-ip32.c
index ec54ed0d26ff..b42b6f7456e6 100644
--- a/arch/mips/mm/dma-ip32.c
+++ b/arch/mips/mm/dma-ip32.c
@@ -363,14 +363,15 @@ int dma_supported(struct device *dev, u64 mask)
363 363
364EXPORT_SYMBOL(dma_supported); 364EXPORT_SYMBOL(dma_supported);
365 365
366int dma_is_consistent(dma_addr_t dma_addr) 366int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
367{ 367{
368 return 1; 368 return 1;
369} 369}
370 370
371EXPORT_SYMBOL(dma_is_consistent); 371EXPORT_SYMBOL(dma_is_consistent);
372 372
373void dma_cache_sync(void *vaddr, size_t size, enum dma_data_direction direction) 373void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
374 enum dma_data_direction direction)
374{ 375{
375 if (direction == DMA_NONE) 376 if (direction == DMA_NONE)
376 return; 377 return;
diff --git a/arch/mips/mm/dma-noncoherent.c b/arch/mips/mm/dma-noncoherent.c
index 2eeffe5c2a3a..8cecef0957c3 100644
--- a/arch/mips/mm/dma-noncoherent.c
+++ b/arch/mips/mm/dma-noncoherent.c
@@ -299,14 +299,15 @@ int dma_supported(struct device *dev, u64 mask)
299 299
300EXPORT_SYMBOL(dma_supported); 300EXPORT_SYMBOL(dma_supported);
301 301
302int dma_is_consistent(dma_addr_t dma_addr) 302int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
303{ 303{
304 return 1; 304 return 1;
305} 305}
306 306
307EXPORT_SYMBOL(dma_is_consistent); 307EXPORT_SYMBOL(dma_is_consistent);
308 308
309void dma_cache_sync(void *vaddr, size_t size, enum dma_data_direction direction) 309void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
310 enum dma_data_direction direction)
310{ 311{
311 if (direction == DMA_NONE) 312 if (direction == DMA_NONE)
312 return; 313 return;
diff --git a/arch/mips/mm/highmem.c b/arch/mips/mm/highmem.c
index 99ebf3ccc222..675502ada5a2 100644
--- a/arch/mips/mm/highmem.c
+++ b/arch/mips/mm/highmem.c
@@ -39,7 +39,7 @@ void *__kmap_atomic(struct page *page, enum km_type type)
39 unsigned long vaddr; 39 unsigned long vaddr;
40 40
41 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ 41 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
42 inc_preempt_count(); 42 pagefault_disable();
43 if (!PageHighMem(page)) 43 if (!PageHighMem(page))
44 return page_address(page); 44 return page_address(page);
45 45
@@ -62,8 +62,7 @@ void __kunmap_atomic(void *kvaddr, enum km_type type)
62 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id(); 62 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
63 63
64 if (vaddr < FIXADDR_START) { // FIXME 64 if (vaddr < FIXADDR_START) { // FIXME
65 dec_preempt_count(); 65 pagefault_enable();
66 preempt_check_resched();
67 return; 66 return;
68 } 67 }
69 68
@@ -78,8 +77,7 @@ void __kunmap_atomic(void *kvaddr, enum km_type type)
78 local_flush_tlb_one(vaddr); 77 local_flush_tlb_one(vaddr);
79#endif 78#endif
80 79
81 dec_preempt_count(); 80 pagefault_enable();
82 preempt_check_resched();
83} 81}
84 82
85#ifndef CONFIG_LIMITED_DMA 83#ifndef CONFIG_LIMITED_DMA
@@ -92,7 +90,7 @@ void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
92 enum fixed_addresses idx; 90 enum fixed_addresses idx;
93 unsigned long vaddr; 91 unsigned long vaddr;
94 92
95 inc_preempt_count(); 93 pagefault_disable();
96 94
97 idx = type + KM_TYPE_NR*smp_processor_id(); 95 idx = type + KM_TYPE_NR*smp_processor_id();
98 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 96 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
diff --git a/arch/mips/momentum/ocelot_c/cpci-irq.c b/arch/mips/momentum/ocelot_c/cpci-irq.c
index e5a4a0a8a7f0..bb11fef08472 100644
--- a/arch/mips/momentum/ocelot_c/cpci-irq.c
+++ b/arch/mips/momentum/ocelot_c/cpci-irq.c
@@ -66,15 +66,6 @@ static inline void unmask_cpci_irq(unsigned int irq)
66} 66}
67 67
68/* 68/*
69 * End IRQ processing
70 */
71static void end_cpci_irq(unsigned int irq)
72{
73 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
74 unmask_cpci_irq(irq);
75}
76
77/*
78 * Interrupt handler for interrupts coming from the FPGA chip. 69 * Interrupt handler for interrupts coming from the FPGA chip.
79 * It could be built in ethernet ports etc... 70 * It could be built in ethernet ports etc...
80 */ 71 */
@@ -98,7 +89,6 @@ struct irq_chip cpci_irq_type = {
98 .mask = mask_cpci_irq, 89 .mask = mask_cpci_irq,
99 .mask_ack = mask_cpci_irq, 90 .mask_ack = mask_cpci_irq,
100 .unmask = unmask_cpci_irq, 91 .unmask = unmask_cpci_irq,
101 .end = end_cpci_irq,
102}; 92};
103 93
104void cpci_irq_init(void) 94void cpci_irq_init(void)
diff --git a/arch/mips/momentum/ocelot_c/uart-irq.c b/arch/mips/momentum/ocelot_c/uart-irq.c
index 0029f0008dea..a7a80c0da569 100644
--- a/arch/mips/momentum/ocelot_c/uart-irq.c
+++ b/arch/mips/momentum/ocelot_c/uart-irq.c
@@ -60,15 +60,6 @@ static inline void unmask_uart_irq(unsigned int irq)
60} 60}
61 61
62/* 62/*
63 * End IRQ processing
64 */
65static void end_uart_irq(unsigned int irq)
66{
67 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
68 unmask_uart_irq(irq);
69}
70
71/*
72 * Interrupt handler for interrupts coming from the FPGA chip. 63 * Interrupt handler for interrupts coming from the FPGA chip.
73 */ 64 */
74void ll_uart_irq(void) 65void ll_uart_irq(void)
@@ -91,7 +82,6 @@ struct irq_chip uart_irq_type = {
91 .mask = mask_uart_irq, 82 .mask = mask_uart_irq,
92 .mask_ack = mask_uart_irq, 83 .mask_ack = mask_uart_irq,
93 .unmask = unmask_uart_irq, 84 .unmask = unmask_uart_irq,
94 .end = end_uart_irq,
95}; 85};
96 86
97void uart_irq_init(void) 87void uart_irq_init(void)
diff --git a/arch/mips/philips/pnx8550/common/int.c b/arch/mips/philips/pnx8550/common/int.c
index 0dc23930edbd..2c36c108c4d6 100644
--- a/arch/mips/philips/pnx8550/common/int.c
+++ b/arch/mips/philips/pnx8550/common/int.c
@@ -158,20 +158,12 @@ int pnx8550_set_gic_priority(int irq, int priority)
158 return prev_priority; 158 return prev_priority;
159} 159}
160 160
161static void end_irq(unsigned int irq)
162{
163 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) {
164 unmask_irq(irq);
165 }
166}
167
168static struct irq_chip level_irq_type = { 161static struct irq_chip level_irq_type = {
169 .typename = "PNX Level IRQ", 162 .typename = "PNX Level IRQ",
170 .ack = mask_irq, 163 .ack = mask_irq,
171 .mask = mask_irq, 164 .mask = mask_irq,
172 .mask_ack = mask_irq, 165 .mask_ack = mask_irq,
173 .unmask = unmask_irq, 166 .unmask = unmask_irq,
174 .end = end_irq,
175}; 167};
176 168
177static struct irqaction gic_action = { 169static struct irqaction gic_action = {
diff --git a/arch/mips/sgi-ip22/ip22-int.c b/arch/mips/sgi-ip22/ip22-int.c
index c7b138053159..c44f8be0644f 100644
--- a/arch/mips/sgi-ip22/ip22-int.c
+++ b/arch/mips/sgi-ip22/ip22-int.c
@@ -51,19 +51,12 @@ static void disable_local0_irq(unsigned int irq)
51 sgint->imask0 &= ~(1 << (irq - SGINT_LOCAL0)); 51 sgint->imask0 &= ~(1 << (irq - SGINT_LOCAL0));
52} 52}
53 53
54static void end_local0_irq (unsigned int irq)
55{
56 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
57 enable_local0_irq(irq);
58}
59
60static struct irq_chip ip22_local0_irq_type = { 54static struct irq_chip ip22_local0_irq_type = {
61 .typename = "IP22 local 0", 55 .typename = "IP22 local 0",
62 .ack = disable_local0_irq, 56 .ack = disable_local0_irq,
63 .mask = disable_local0_irq, 57 .mask = disable_local0_irq,
64 .mask_ack = disable_local0_irq, 58 .mask_ack = disable_local0_irq,
65 .unmask = enable_local0_irq, 59 .unmask = enable_local0_irq,
66 .end = end_local0_irq,
67}; 60};
68 61
69static void enable_local1_irq(unsigned int irq) 62static void enable_local1_irq(unsigned int irq)
@@ -79,19 +72,12 @@ void disable_local1_irq(unsigned int irq)
79 sgint->imask1 &= ~(1 << (irq - SGINT_LOCAL1)); 72 sgint->imask1 &= ~(1 << (irq - SGINT_LOCAL1));
80} 73}
81 74
82static void end_local1_irq (unsigned int irq)
83{
84 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
85 enable_local1_irq(irq);
86}
87
88static struct irq_chip ip22_local1_irq_type = { 75static struct irq_chip ip22_local1_irq_type = {
89 .typename = "IP22 local 1", 76 .typename = "IP22 local 1",
90 .ack = disable_local1_irq, 77 .ack = disable_local1_irq,
91 .mask = disable_local1_irq, 78 .mask = disable_local1_irq,
92 .mask_ack = disable_local1_irq, 79 .mask_ack = disable_local1_irq,
93 .unmask = enable_local1_irq, 80 .unmask = enable_local1_irq,
94 .end = end_local1_irq,
95}; 81};
96 82
97static void enable_local2_irq(unsigned int irq) 83static void enable_local2_irq(unsigned int irq)
@@ -107,19 +93,12 @@ void disable_local2_irq(unsigned int irq)
107 sgint->imask0 &= ~(1 << (SGI_MAP_0_IRQ - SGINT_LOCAL0)); 93 sgint->imask0 &= ~(1 << (SGI_MAP_0_IRQ - SGINT_LOCAL0));
108} 94}
109 95
110static void end_local2_irq (unsigned int irq)
111{
112 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
113 enable_local2_irq(irq);
114}
115
116static struct irq_chip ip22_local2_irq_type = { 96static struct irq_chip ip22_local2_irq_type = {
117 .typename = "IP22 local 2", 97 .typename = "IP22 local 2",
118 .ack = disable_local2_irq, 98 .ack = disable_local2_irq,
119 .mask = disable_local2_irq, 99 .mask = disable_local2_irq,
120 .mask_ack = disable_local2_irq, 100 .mask_ack = disable_local2_irq,
121 .unmask = enable_local2_irq, 101 .unmask = enable_local2_irq,
122 .end = end_local2_irq,
123}; 102};
124 103
125static void enable_local3_irq(unsigned int irq) 104static void enable_local3_irq(unsigned int irq)
@@ -135,19 +114,12 @@ void disable_local3_irq(unsigned int irq)
135 sgint->imask1 &= ~(1 << (SGI_MAP_1_IRQ - SGINT_LOCAL1)); 114 sgint->imask1 &= ~(1 << (SGI_MAP_1_IRQ - SGINT_LOCAL1));
136} 115}
137 116
138static void end_local3_irq (unsigned int irq)
139{
140 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
141 enable_local3_irq(irq);
142}
143
144static struct irq_chip ip22_local3_irq_type = { 117static struct irq_chip ip22_local3_irq_type = {
145 .typename = "IP22 local 3", 118 .typename = "IP22 local 3",
146 .ack = disable_local3_irq, 119 .ack = disable_local3_irq,
147 .mask = disable_local3_irq, 120 .mask = disable_local3_irq,
148 .mask_ack = disable_local3_irq, 121 .mask_ack = disable_local3_irq,
149 .unmask = enable_local3_irq, 122 .unmask = enable_local3_irq,
150 .end = end_local3_irq,
151}; 123};
152 124
153static void indy_local0_irqdispatch(void) 125static void indy_local0_irqdispatch(void)
diff --git a/arch/mips/sgi-ip27/ip27-irq.c b/arch/mips/sgi-ip27/ip27-irq.c
index 5f8835b4e84a..319f8803ef6f 100644
--- a/arch/mips/sgi-ip27/ip27-irq.c
+++ b/arch/mips/sgi-ip27/ip27-irq.c
@@ -332,13 +332,6 @@ static inline void disable_bridge_irq(unsigned int irq)
332 intr_disconnect_level(cpu, swlevel); 332 intr_disconnect_level(cpu, swlevel);
333} 333}
334 334
335static void end_bridge_irq(unsigned int irq)
336{
337 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)) &&
338 irq_desc[irq].action)
339 enable_bridge_irq(irq);
340}
341
342static struct irq_chip bridge_irq_type = { 335static struct irq_chip bridge_irq_type = {
343 .typename = "bridge", 336 .typename = "bridge",
344 .startup = startup_bridge_irq, 337 .startup = startup_bridge_irq,
@@ -347,7 +340,6 @@ static struct irq_chip bridge_irq_type = {
347 .mask = disable_bridge_irq, 340 .mask = disable_bridge_irq,
348 .mask_ack = disable_bridge_irq, 341 .mask_ack = disable_bridge_irq,
349 .unmask = enable_bridge_irq, 342 .unmask = enable_bridge_irq,
350 .end = end_bridge_irq,
351}; 343};
352 344
353void __devinit register_bridge_irq(unsigned int irq) 345void __devinit register_bridge_irq(unsigned int irq)
diff --git a/arch/mips/sgi-ip27/ip27-timer.c b/arch/mips/sgi-ip27/ip27-timer.c
index 7d361726bbfb..c20e9899b34b 100644
--- a/arch/mips/sgi-ip27/ip27-timer.c
+++ b/arch/mips/sgi-ip27/ip27-timer.c
@@ -180,10 +180,6 @@ static void disable_rt_irq(unsigned int irq)
180{ 180{
181} 181}
182 182
183static void end_rt_irq(unsigned int irq)
184{
185}
186
187static struct irq_chip rt_irq_type = { 183static struct irq_chip rt_irq_type = {
188 .typename = "SN HUB RT timer", 184 .typename = "SN HUB RT timer",
189 .ack = disable_rt_irq, 185 .ack = disable_rt_irq,
@@ -191,7 +187,6 @@ static struct irq_chip rt_irq_type = {
191 .mask_ack = disable_rt_irq, 187 .mask_ack = disable_rt_irq,
192 .unmask = enable_rt_irq, 188 .unmask = enable_rt_irq,
193 .eoi = enable_rt_irq, 189 .eoi = enable_rt_irq,
194 .end = end_rt_irq,
195}; 190};
196 191
197static struct irqaction rt_irqaction = { 192static struct irqaction rt_irqaction = {
diff --git a/arch/mips/tx4927/common/tx4927_irq.c b/arch/mips/tx4927/common/tx4927_irq.c
index 21873de49aa8..ed4a19adf361 100644
--- a/arch/mips/tx4927/common/tx4927_irq.c
+++ b/arch/mips/tx4927/common/tx4927_irq.c
@@ -66,12 +66,10 @@
66#define TX4927_IRQ_CP0_INIT ( 1 << 10 ) 66#define TX4927_IRQ_CP0_INIT ( 1 << 10 )
67#define TX4927_IRQ_CP0_ENABLE ( 1 << 13 ) 67#define TX4927_IRQ_CP0_ENABLE ( 1 << 13 )
68#define TX4927_IRQ_CP0_DISABLE ( 1 << 14 ) 68#define TX4927_IRQ_CP0_DISABLE ( 1 << 14 )
69#define TX4927_IRQ_CP0_ENDIRQ ( 1 << 16 )
70 69
71#define TX4927_IRQ_PIC_INIT ( 1 << 20 ) 70#define TX4927_IRQ_PIC_INIT ( 1 << 20 )
72#define TX4927_IRQ_PIC_ENABLE ( 1 << 23 ) 71#define TX4927_IRQ_PIC_ENABLE ( 1 << 23 )
73#define TX4927_IRQ_PIC_DISABLE ( 1 << 24 ) 72#define TX4927_IRQ_PIC_DISABLE ( 1 << 24 )
74#define TX4927_IRQ_PIC_ENDIRQ ( 1 << 26 )
75 73
76#define TX4927_IRQ_ALL 0xffffffff 74#define TX4927_IRQ_ALL 0xffffffff
77#endif 75#endif
@@ -82,12 +80,10 @@ static const u32 tx4927_irq_debug_flag = (TX4927_IRQ_NONE
82 | TX4927_IRQ_WARN | TX4927_IRQ_EROR 80 | TX4927_IRQ_WARN | TX4927_IRQ_EROR
83// | TX4927_IRQ_CP0_INIT 81// | TX4927_IRQ_CP0_INIT
84// | TX4927_IRQ_CP0_ENABLE 82// | TX4927_IRQ_CP0_ENABLE
85// | TX4927_IRQ_CP0_DISABLE
86// | TX4927_IRQ_CP0_ENDIRQ 83// | TX4927_IRQ_CP0_ENDIRQ
87// | TX4927_IRQ_PIC_INIT 84// | TX4927_IRQ_PIC_INIT
88// | TX4927_IRQ_PIC_ENABLE 85// | TX4927_IRQ_PIC_ENABLE
89// | TX4927_IRQ_PIC_DISABLE 86// | TX4927_IRQ_PIC_DISABLE
90// | TX4927_IRQ_PIC_ENDIRQ
91// | TX4927_IRQ_INIT 87// | TX4927_IRQ_INIT
92// | TX4927_IRQ_NEST1 88// | TX4927_IRQ_NEST1
93// | TX4927_IRQ_NEST2 89// | TX4927_IRQ_NEST2
@@ -114,11 +110,9 @@ static const u32 tx4927_irq_debug_flag = (TX4927_IRQ_NONE
114 110
115static void tx4927_irq_cp0_enable(unsigned int irq); 111static void tx4927_irq_cp0_enable(unsigned int irq);
116static void tx4927_irq_cp0_disable(unsigned int irq); 112static void tx4927_irq_cp0_disable(unsigned int irq);
117static void tx4927_irq_cp0_end(unsigned int irq);
118 113
119static void tx4927_irq_pic_enable(unsigned int irq); 114static void tx4927_irq_pic_enable(unsigned int irq);
120static void tx4927_irq_pic_disable(unsigned int irq); 115static void tx4927_irq_pic_disable(unsigned int irq);
121static void tx4927_irq_pic_end(unsigned int irq);
122 116
123/* 117/*
124 * Kernel structs for all pic's 118 * Kernel structs for all pic's
@@ -131,7 +125,6 @@ static struct irq_chip tx4927_irq_cp0_type = {
131 .mask = tx4927_irq_cp0_disable, 125 .mask = tx4927_irq_cp0_disable,
132 .mask_ack = tx4927_irq_cp0_disable, 126 .mask_ack = tx4927_irq_cp0_disable,
133 .unmask = tx4927_irq_cp0_enable, 127 .unmask = tx4927_irq_cp0_enable,
134 .end = tx4927_irq_cp0_end,
135}; 128};
136 129
137#define TX4927_PIC_NAME "TX4927-PIC" 130#define TX4927_PIC_NAME "TX4927-PIC"
@@ -141,7 +134,6 @@ static struct irq_chip tx4927_irq_pic_type = {
141 .mask = tx4927_irq_pic_disable, 134 .mask = tx4927_irq_pic_disable,
142 .mask_ack = tx4927_irq_pic_disable, 135 .mask_ack = tx4927_irq_pic_disable,
143 .unmask = tx4927_irq_pic_enable, 136 .unmask = tx4927_irq_pic_enable,
144 .end = tx4927_irq_pic_end,
145}; 137};
146 138
147#define TX4927_PIC_ACTION(s) { no_action, 0, CPU_MASK_NONE, s, NULL, NULL } 139#define TX4927_PIC_ACTION(s) { no_action, 0, CPU_MASK_NONE, s, NULL, NULL }
@@ -214,15 +206,6 @@ static void tx4927_irq_cp0_disable(unsigned int irq)
214 tx4927_irq_cp0_modify(CCP0_STATUS, tx4927_irq_cp0_mask(irq), 0); 206 tx4927_irq_cp0_modify(CCP0_STATUS, tx4927_irq_cp0_mask(irq), 0);
215} 207}
216 208
217static void tx4927_irq_cp0_end(unsigned int irq)
218{
219 TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_ENDIRQ, "irq=%d \n", irq);
220
221 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
222 tx4927_irq_cp0_enable(irq);
223 }
224}
225
226/* 209/*
227 * Functions for pic 210 * Functions for pic
228 */ 211 */
@@ -376,15 +359,6 @@ static void tx4927_irq_pic_disable(unsigned int irq)
376 tx4927_irq_pic_mask(irq), 0); 359 tx4927_irq_pic_mask(irq), 0);
377} 360}
378 361
379static void tx4927_irq_pic_end(unsigned int irq)
380{
381 TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_ENDIRQ, "irq=%d\n", irq);
382
383 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
384 tx4927_irq_pic_enable(irq);
385 }
386}
387
388/* 362/*
389 * Main init functions 363 * Main init functions
390 */ 364 */
diff --git a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
index 34cdb2a240e9..5a5ea6c0b9f6 100644
--- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
+++ b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
@@ -153,7 +153,6 @@ JP7 is not bus master -- do NOT use -- only 4 pci bus master's allowed -- SouthB
153#define TOSHIBA_RBTX4927_IRQ_IOC_INIT ( 1 << 10 ) 153#define TOSHIBA_RBTX4927_IRQ_IOC_INIT ( 1 << 10 )
154#define TOSHIBA_RBTX4927_IRQ_IOC_ENABLE ( 1 << 13 ) 154#define TOSHIBA_RBTX4927_IRQ_IOC_ENABLE ( 1 << 13 )
155#define TOSHIBA_RBTX4927_IRQ_IOC_DISABLE ( 1 << 14 ) 155#define TOSHIBA_RBTX4927_IRQ_IOC_DISABLE ( 1 << 14 )
156#define TOSHIBA_RBTX4927_IRQ_IOC_ENDIRQ ( 1 << 16 )
157 156
158#define TOSHIBA_RBTX4927_IRQ_ISA_INIT ( 1 << 20 ) 157#define TOSHIBA_RBTX4927_IRQ_ISA_INIT ( 1 << 20 )
159#define TOSHIBA_RBTX4927_IRQ_ISA_ENABLE ( 1 << 23 ) 158#define TOSHIBA_RBTX4927_IRQ_ISA_ENABLE ( 1 << 23 )
@@ -172,7 +171,6 @@ static const u32 toshiba_rbtx4927_irq_debug_flag =
172// | TOSHIBA_RBTX4927_IRQ_IOC_INIT 171// | TOSHIBA_RBTX4927_IRQ_IOC_INIT
173// | TOSHIBA_RBTX4927_IRQ_IOC_ENABLE 172// | TOSHIBA_RBTX4927_IRQ_IOC_ENABLE
174// | TOSHIBA_RBTX4927_IRQ_IOC_DISABLE 173// | TOSHIBA_RBTX4927_IRQ_IOC_DISABLE
175// | TOSHIBA_RBTX4927_IRQ_IOC_ENDIRQ
176// | TOSHIBA_RBTX4927_IRQ_ISA_INIT 174// | TOSHIBA_RBTX4927_IRQ_ISA_INIT
177// | TOSHIBA_RBTX4927_IRQ_ISA_ENABLE 175// | TOSHIBA_RBTX4927_IRQ_ISA_ENABLE
178// | TOSHIBA_RBTX4927_IRQ_ISA_DISABLE 176// | TOSHIBA_RBTX4927_IRQ_ISA_DISABLE
@@ -223,7 +221,6 @@ extern void mask_and_ack_8259A(unsigned int irq);
223 221
224static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq); 222static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq);
225static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq); 223static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq);
226static void toshiba_rbtx4927_irq_ioc_end(unsigned int irq);
227 224
228#ifdef CONFIG_TOSHIBA_FPCIB0 225#ifdef CONFIG_TOSHIBA_FPCIB0
229static void toshiba_rbtx4927_irq_isa_enable(unsigned int irq); 226static void toshiba_rbtx4927_irq_isa_enable(unsigned int irq);
@@ -239,7 +236,6 @@ static struct irq_chip toshiba_rbtx4927_irq_ioc_type = {
239 .mask = toshiba_rbtx4927_irq_ioc_disable, 236 .mask = toshiba_rbtx4927_irq_ioc_disable,
240 .mask_ack = toshiba_rbtx4927_irq_ioc_disable, 237 .mask_ack = toshiba_rbtx4927_irq_ioc_disable,
241 .unmask = toshiba_rbtx4927_irq_ioc_enable, 238 .unmask = toshiba_rbtx4927_irq_ioc_enable,
242 .end = toshiba_rbtx4927_irq_ioc_end,
243}; 239};
244#define TOSHIBA_RBTX4927_IOC_INTR_ENAB 0xbc002000 240#define TOSHIBA_RBTX4927_IOC_INTR_ENAB 0xbc002000
245#define TOSHIBA_RBTX4927_IOC_INTR_STAT 0xbc002006 241#define TOSHIBA_RBTX4927_IOC_INTR_STAT 0xbc002006
@@ -388,23 +384,6 @@ static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq)
388 TOSHIBA_RBTX4927_WR08(TOSHIBA_RBTX4927_IOC_INTR_ENAB, v); 384 TOSHIBA_RBTX4927_WR08(TOSHIBA_RBTX4927_IOC_INTR_ENAB, v);
389} 385}
390 386
391static void toshiba_rbtx4927_irq_ioc_end(unsigned int irq)
392{
393 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_IOC_ENDIRQ,
394 "irq=%d\n", irq);
395
396 if (irq < TOSHIBA_RBTX4927_IRQ_IOC_BEG
397 || irq > TOSHIBA_RBTX4927_IRQ_IOC_END) {
398 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_EROR,
399 "bad irq=%d\n", irq);
400 panic("\n");
401 }
402
403 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
404 toshiba_rbtx4927_irq_ioc_enable(irq);
405 }
406}
407
408 387
409/**********************************************************************************/ 388/**********************************************************************************/
410/* Functions for isa */ 389/* Functions for isa */
diff --git a/arch/mips/tx4938/common/irq.c b/arch/mips/tx4938/common/irq.c
index 42e127683ae9..a347b424d91c 100644
--- a/arch/mips/tx4938/common/irq.c
+++ b/arch/mips/tx4938/common/irq.c
@@ -39,11 +39,9 @@
39 39
40static void tx4938_irq_cp0_enable(unsigned int irq); 40static void tx4938_irq_cp0_enable(unsigned int irq);
41static void tx4938_irq_cp0_disable(unsigned int irq); 41static void tx4938_irq_cp0_disable(unsigned int irq);
42static void tx4938_irq_cp0_end(unsigned int irq);
43 42
44static void tx4938_irq_pic_enable(unsigned int irq); 43static void tx4938_irq_pic_enable(unsigned int irq);
45static void tx4938_irq_pic_disable(unsigned int irq); 44static void tx4938_irq_pic_disable(unsigned int irq);
46static void tx4938_irq_pic_end(unsigned int irq);
47 45
48/**********************************************************************************/ 46/**********************************************************************************/
49/* Kernel structs for all pic's */ 47/* Kernel structs for all pic's */
@@ -56,7 +54,6 @@ static struct irq_chip tx4938_irq_cp0_type = {
56 .mask = tx4938_irq_cp0_disable, 54 .mask = tx4938_irq_cp0_disable,
57 .mask_ack = tx4938_irq_cp0_disable, 55 .mask_ack = tx4938_irq_cp0_disable,
58 .unmask = tx4938_irq_cp0_enable, 56 .unmask = tx4938_irq_cp0_enable,
59 .end = tx4938_irq_cp0_end,
60}; 57};
61 58
62#define TX4938_PIC_NAME "TX4938-PIC" 59#define TX4938_PIC_NAME "TX4938-PIC"
@@ -66,7 +63,6 @@ static struct irq_chip tx4938_irq_pic_type = {
66 .mask = tx4938_irq_pic_disable, 63 .mask = tx4938_irq_pic_disable,
67 .mask_ack = tx4938_irq_pic_disable, 64 .mask_ack = tx4938_irq_pic_disable,
68 .unmask = tx4938_irq_pic_enable, 65 .unmask = tx4938_irq_pic_enable,
69 .end = tx4938_irq_pic_end,
70}; 66};
71 67
72static struct irqaction tx4938_irq_pic_action = { 68static struct irqaction tx4938_irq_pic_action = {
@@ -104,14 +100,6 @@ tx4938_irq_cp0_disable(unsigned int irq)
104 clear_c0_status(tx4938_irq_cp0_mask(irq)); 100 clear_c0_status(tx4938_irq_cp0_mask(irq));
105} 101}
106 102
107static void
108tx4938_irq_cp0_end(unsigned int irq)
109{
110 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
111 tx4938_irq_cp0_enable(irq);
112 }
113}
114
115/**********************************************************************************/ 103/**********************************************************************************/
116/* Functions for pic */ 104/* Functions for pic */
117/**********************************************************************************/ 105/**********************************************************************************/
@@ -269,14 +257,6 @@ tx4938_irq_pic_disable(unsigned int irq)
269 tx4938_irq_pic_mask(irq), 0); 257 tx4938_irq_pic_mask(irq), 0);
270} 258}
271 259
272static void
273tx4938_irq_pic_end(unsigned int irq)
274{
275 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
276 tx4938_irq_pic_enable(irq);
277 }
278}
279
280/**********************************************************************************/ 260/**********************************************************************************/
281/* Main init functions */ 261/* Main init functions */
282/**********************************************************************************/ 262/**********************************************************************************/
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/irq.c b/arch/mips/tx4938/toshiba_rbtx4938/irq.c
index 8c87a35f3068..b6f363d08011 100644
--- a/arch/mips/tx4938/toshiba_rbtx4938/irq.c
+++ b/arch/mips/tx4938/toshiba_rbtx4938/irq.c
@@ -89,7 +89,6 @@ IRQ Device
89 89
90static void toshiba_rbtx4938_irq_ioc_enable(unsigned int irq); 90static void toshiba_rbtx4938_irq_ioc_enable(unsigned int irq);
91static void toshiba_rbtx4938_irq_ioc_disable(unsigned int irq); 91static void toshiba_rbtx4938_irq_ioc_disable(unsigned int irq);
92static void toshiba_rbtx4938_irq_ioc_end(unsigned int irq);
93 92
94#define TOSHIBA_RBTX4938_IOC_NAME "RBTX4938-IOC" 93#define TOSHIBA_RBTX4938_IOC_NAME "RBTX4938-IOC"
95static struct irq_chip toshiba_rbtx4938_irq_ioc_type = { 94static struct irq_chip toshiba_rbtx4938_irq_ioc_type = {
@@ -98,7 +97,6 @@ static struct irq_chip toshiba_rbtx4938_irq_ioc_type = {
98 .mask = toshiba_rbtx4938_irq_ioc_disable, 97 .mask = toshiba_rbtx4938_irq_ioc_disable,
99 .mask_ack = toshiba_rbtx4938_irq_ioc_disable, 98 .mask_ack = toshiba_rbtx4938_irq_ioc_disable,
100 .unmask = toshiba_rbtx4938_irq_ioc_enable, 99 .unmask = toshiba_rbtx4938_irq_ioc_enable,
101 .end = toshiba_rbtx4938_irq_ioc_end,
102}; 100};
103 101
104#define TOSHIBA_RBTX4938_IOC_INTR_ENAB 0xb7f02000 102#define TOSHIBA_RBTX4938_IOC_INTR_ENAB 0xb7f02000
@@ -167,14 +165,6 @@ toshiba_rbtx4938_irq_ioc_disable(unsigned int irq)
167 TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB); 165 TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB);
168} 166}
169 167
170static void
171toshiba_rbtx4938_irq_ioc_end(unsigned int irq)
172{
173 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
174 toshiba_rbtx4938_irq_ioc_enable(irq);
175 }
176}
177
178extern void __init txx9_spi_irqinit(int irc_irq); 168extern void __init txx9_spi_irqinit(int irc_irq);
179 169
180void __init arch_init_irq(void) 170void __init arch_init_irq(void)
diff --git a/arch/mips/vr41xx/Kconfig b/arch/mips/vr41xx/Kconfig
index 92f41f6f934a..c8dfd8092cab 100644
--- a/arch/mips/vr41xx/Kconfig
+++ b/arch/mips/vr41xx/Kconfig
@@ -6,6 +6,7 @@ config CASIO_E55
6 select ISA 6 select ISA
7 select SYS_SUPPORTS_32BIT_KERNEL 7 select SYS_SUPPORTS_32BIT_KERNEL
8 select SYS_SUPPORTS_LITTLE_ENDIAN 8 select SYS_SUPPORTS_LITTLE_ENDIAN
9 select GENERIC_HARDIRQS_NO__DO_IRQ
9 10
10config IBM_WORKPAD 11config IBM_WORKPAD
11 bool "Support for IBM WorkPad z50" 12 bool "Support for IBM WorkPad z50"
@@ -15,6 +16,7 @@ config IBM_WORKPAD
15 select ISA 16 select ISA
16 select SYS_SUPPORTS_32BIT_KERNEL 17 select SYS_SUPPORTS_32BIT_KERNEL
17 select SYS_SUPPORTS_LITTLE_ENDIAN 18 select SYS_SUPPORTS_LITTLE_ENDIAN
19 select GENERIC_HARDIRQS_NO__DO_IRQ
18 20
19config NEC_CMBVR4133 21config NEC_CMBVR4133
20 bool "Support for NEC CMB-VR4133" 22 bool "Support for NEC CMB-VR4133"
@@ -39,6 +41,7 @@ config TANBAC_TB022X
39 select IRQ_CPU 41 select IRQ_CPU
40 select SYS_SUPPORTS_32BIT_KERNEL 42 select SYS_SUPPORTS_32BIT_KERNEL
41 select SYS_SUPPORTS_LITTLE_ENDIAN 43 select SYS_SUPPORTS_LITTLE_ENDIAN
44 select GENERIC_HARDIRQS_NO__DO_IRQ
42 help 45 help
43 The TANBAC VR4131 multichip module(TB0225) and 46 The TANBAC VR4131 multichip module(TB0225) and
44 the TANBAC VR4131DIMM(TB0229) are MIPS-based platforms 47 the TANBAC VR4131DIMM(TB0229) are MIPS-based platforms
@@ -71,6 +74,7 @@ config VICTOR_MPC30X
71 select IRQ_CPU 74 select IRQ_CPU
72 select SYS_SUPPORTS_32BIT_KERNEL 75 select SYS_SUPPORTS_32BIT_KERNEL
73 select SYS_SUPPORTS_LITTLE_ENDIAN 76 select SYS_SUPPORTS_LITTLE_ENDIAN
77 select GENERIC_HARDIRQS_NO__DO_IRQ
74 78
75config ZAO_CAPCELLA 79config ZAO_CAPCELLA
76 bool "Support for ZAO Networks Capcella" 80 bool "Support for ZAO Networks Capcella"
@@ -80,6 +84,7 @@ config ZAO_CAPCELLA
80 select IRQ_CPU 84 select IRQ_CPU
81 select SYS_SUPPORTS_32BIT_KERNEL 85 select SYS_SUPPORTS_32BIT_KERNEL
82 select SYS_SUPPORTS_LITTLE_ENDIAN 86 select SYS_SUPPORTS_LITTLE_ENDIAN
87 select GENERIC_HARDIRQS_NO__DO_IRQ
83 88
84config PCI_VR41XX 89config PCI_VR41XX
85 bool "Add PCI control unit support of NEC VR4100 series" 90 bool "Add PCI control unit support of NEC VR4100 series"
diff --git a/arch/mips/vr41xx/common/icu.c b/arch/mips/vr41xx/common/icu.c
index 54b92a74c7ac..c075261976c5 100644
--- a/arch/mips/vr41xx/common/icu.c
+++ b/arch/mips/vr41xx/common/icu.c
@@ -427,19 +427,12 @@ static void enable_sysint1_irq(unsigned int irq)
427 icu1_set(MSYSINT1REG, 1 << SYSINT1_IRQ_TO_PIN(irq)); 427 icu1_set(MSYSINT1REG, 1 << SYSINT1_IRQ_TO_PIN(irq));
428} 428}
429 429
430static void end_sysint1_irq(unsigned int irq)
431{
432 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
433 icu1_set(MSYSINT1REG, 1 << SYSINT1_IRQ_TO_PIN(irq));
434}
435
436static struct irq_chip sysint1_irq_type = { 430static struct irq_chip sysint1_irq_type = {
437 .typename = "SYSINT1", 431 .typename = "SYSINT1",
438 .ack = disable_sysint1_irq, 432 .ack = disable_sysint1_irq,
439 .mask = disable_sysint1_irq, 433 .mask = disable_sysint1_irq,
440 .mask_ack = disable_sysint1_irq, 434 .mask_ack = disable_sysint1_irq,
441 .unmask = enable_sysint1_irq, 435 .unmask = enable_sysint1_irq,
442 .end = end_sysint1_irq,
443}; 436};
444 437
445static void disable_sysint2_irq(unsigned int irq) 438static void disable_sysint2_irq(unsigned int irq)
@@ -452,19 +445,12 @@ static void enable_sysint2_irq(unsigned int irq)
452 icu2_set(MSYSINT2REG, 1 << SYSINT2_IRQ_TO_PIN(irq)); 445 icu2_set(MSYSINT2REG, 1 << SYSINT2_IRQ_TO_PIN(irq));
453} 446}
454 447
455static void end_sysint2_irq(unsigned int irq)
456{
457 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
458 icu2_set(MSYSINT2REG, 1 << SYSINT2_IRQ_TO_PIN(irq));
459}
460
461static struct irq_chip sysint2_irq_type = { 448static struct irq_chip sysint2_irq_type = {
462 .typename = "SYSINT2", 449 .typename = "SYSINT2",
463 .ack = disable_sysint2_irq, 450 .ack = disable_sysint2_irq,
464 .mask = disable_sysint2_irq, 451 .mask = disable_sysint2_irq,
465 .mask_ack = disable_sysint2_irq, 452 .mask_ack = disable_sysint2_irq,
466 .unmask = enable_sysint2_irq, 453 .unmask = enable_sysint2_irq,
467 .end = end_sysint2_irq,
468}; 454};
469 455
470static inline int set_sysint1_assign(unsigned int irq, unsigned char assign) 456static inline int set_sysint1_assign(unsigned int irq, unsigned char assign)
diff --git a/arch/parisc/kernel/binfmt_elf32.c b/arch/parisc/kernel/binfmt_elf32.c
index 1e64e7b88110..ecb10a4f63c6 100644
--- a/arch/parisc/kernel/binfmt_elf32.c
+++ b/arch/parisc/kernel/binfmt_elf32.c
@@ -75,7 +75,6 @@ struct elf_prpsinfo32
75 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */ 75 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
76}; 76};
77 77
78#define elf_addr_t unsigned int
79#define init_elf_binfmt init_elf32_binfmt 78#define init_elf_binfmt init_elf32_binfmt
80 79
81#define ELF_PLATFORM ("PARISC32\0") 80#define ELF_PLATFORM ("PARISC32\0")
diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
index 64785e46f93b..641f9c920eee 100644
--- a/arch/parisc/mm/fault.c
+++ b/arch/parisc/mm/fault.c
@@ -152,7 +152,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,
152 const struct exception_table_entry *fix; 152 const struct exception_table_entry *fix;
153 unsigned long acc_type; 153 unsigned long acc_type;
154 154
155 if (in_interrupt() || !mm) 155 if (in_atomic() || !mm)
156 goto no_context; 156 goto no_context;
157 157
158 down_read(&mm->mmap_sem); 158 down_read(&mm->mmap_sem);
diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c
index 89b03c8da9d2..d3f2080d2eee 100644
--- a/arch/powerpc/kernel/crash.c
+++ b/arch/powerpc/kernel/crash.c
@@ -46,61 +46,6 @@ int crashing_cpu = -1;
46static cpumask_t cpus_in_crash = CPU_MASK_NONE; 46static cpumask_t cpus_in_crash = CPU_MASK_NONE;
47cpumask_t cpus_in_sr = CPU_MASK_NONE; 47cpumask_t cpus_in_sr = CPU_MASK_NONE;
48 48
49static u32 *append_elf_note(u32 *buf, char *name, unsigned type, void *data,
50 size_t data_len)
51{
52 struct elf_note note;
53
54 note.n_namesz = strlen(name) + 1;
55 note.n_descsz = data_len;
56 note.n_type = type;
57 memcpy(buf, &note, sizeof(note));
58 buf += (sizeof(note) +3)/4;
59 memcpy(buf, name, note.n_namesz);
60 buf += (note.n_namesz + 3)/4;
61 memcpy(buf, data, note.n_descsz);
62 buf += (note.n_descsz + 3)/4;
63
64 return buf;
65}
66
67static void final_note(u32 *buf)
68{
69 struct elf_note note;
70
71 note.n_namesz = 0;
72 note.n_descsz = 0;
73 note.n_type = 0;
74 memcpy(buf, &note, sizeof(note));
75}
76
77static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
78{
79 struct elf_prstatus prstatus;
80 u32 *buf;
81
82 if ((cpu < 0) || (cpu >= NR_CPUS))
83 return;
84
85 /* Using ELF notes here is opportunistic.
86 * I need a well defined structure format
87 * for the data I pass, and I need tags
88 * on the data to indicate what information I have
89 * squirrelled away. ELF notes happen to provide
90 * all of that that no need to invent something new.
91 */
92 buf = (u32*)per_cpu_ptr(crash_notes, cpu);
93 if (!buf)
94 return;
95
96 memset(&prstatus, 0, sizeof(prstatus));
97 prstatus.pr_pid = current->pid;
98 elf_core_copy_regs(&prstatus.pr_reg, regs);
99 buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
100 sizeof(prstatus));
101 final_note(buf);
102}
103
104#ifdef CONFIG_SMP 49#ifdef CONFIG_SMP
105static atomic_t enter_on_soft_reset = ATOMIC_INIT(0); 50static atomic_t enter_on_soft_reset = ATOMIC_INIT(0);
106 51
@@ -113,7 +58,7 @@ void crash_ipi_callback(struct pt_regs *regs)
113 58
114 hard_irq_disable(); 59 hard_irq_disable();
115 if (!cpu_isset(cpu, cpus_in_crash)) 60 if (!cpu_isset(cpu, cpus_in_crash))
116 crash_save_this_cpu(regs, cpu); 61 crash_save_cpu(regs, cpu);
117 cpu_set(cpu, cpus_in_crash); 62 cpu_set(cpu, cpus_in_crash);
118 63
119 /* 64 /*
@@ -306,7 +251,7 @@ void default_machine_crash_shutdown(struct pt_regs *regs)
306 * such that another IPI will not be sent. 251 * such that another IPI will not be sent.
307 */ 252 */
308 crashing_cpu = smp_processor_id(); 253 crashing_cpu = smp_processor_id();
309 crash_save_this_cpu(regs, crashing_cpu); 254 crash_save_cpu(regs, crashing_cpu);
310 crash_kexec_prepare_cpus(crashing_cpu); 255 crash_kexec_prepare_cpus(crashing_cpu);
311 cpu_set(crashing_cpu, cpus_in_crash); 256 cpu_set(crashing_cpu, cpus_in_crash);
312 if (ppc_md.kexec_cpu_down) 257 if (ppc_md.kexec_cpu_down)
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index 7b8d12b9026c..4657563f8813 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -85,7 +85,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
85void __kprobes arch_remove_kprobe(struct kprobe *p) 85void __kprobes arch_remove_kprobe(struct kprobe *p)
86{ 86{
87 mutex_lock(&kprobe_mutex); 87 mutex_lock(&kprobe_mutex);
88 free_insn_slot(p->ainsn.insn); 88 free_insn_slot(p->ainsn.insn, 0);
89 mutex_unlock(&kprobe_mutex); 89 mutex_unlock(&kprobe_mutex);
90} 90}
91 91
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c
index b9561d300516..7d0f13fecc0e 100644
--- a/arch/powerpc/kernel/rtas_flash.c
+++ b/arch/powerpc/kernel/rtas_flash.c
@@ -101,7 +101,7 @@ struct flash_block_list_header { /* just the header of flash_block_list */
101static struct flash_block_list_header rtas_firmware_flash_list = {0, NULL}; 101static struct flash_block_list_header rtas_firmware_flash_list = {0, NULL};
102 102
103/* Use slab cache to guarantee 4k alignment */ 103/* Use slab cache to guarantee 4k alignment */
104static kmem_cache_t *flash_block_cache = NULL; 104static struct kmem_cache *flash_block_cache = NULL;
105 105
106#define FLASH_BLOCK_LIST_VERSION (1UL) 106#define FLASH_BLOCK_LIST_VERSION (1UL)
107 107
@@ -286,7 +286,7 @@ static ssize_t rtas_flash_read(struct file *file, char __user *buf,
286} 286}
287 287
288/* constructor for flash_block_cache */ 288/* constructor for flash_block_cache */
289void rtas_block_ctor(void *ptr, kmem_cache_t *cache, unsigned long flags) 289void rtas_block_ctor(void *ptr, struct kmem_cache *cache, unsigned long flags)
290{ 290{
291 memset(ptr, 0, RTAS_BLK_SIZE); 291 memset(ptr, 0, RTAS_BLK_SIZE);
292} 292}
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index 320353f0926f..e4ebe1a6228e 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -36,7 +36,7 @@
36#include <linux/stddef.h> 36#include <linux/stddef.h>
37#include <linux/tty.h> 37#include <linux/tty.h>
38#include <linux/binfmts.h> 38#include <linux/binfmts.h>
39#include <linux/suspend.h> 39#include <linux/freezer.h>
40#endif 40#endif
41 41
42#include <asm/uaccess.h> 42#include <asm/uaccess.h>
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index c913ad5cad29..a4b28c73bba0 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -264,7 +264,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
264 264
265 265
266 /* Allocate a VMA structure and fill it up */ 266 /* Allocate a VMA structure and fill it up */
267 vma = kmem_cache_zalloc(vm_area_cachep, SLAB_KERNEL); 267 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
268 if (vma == NULL) { 268 if (vma == NULL) {
269 rc = -ENOMEM; 269 rc = -ENOMEM;
270 goto fail_mmapsem; 270 goto fail_mmapsem;
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index 506d89768d45..89c836d54809 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -146,6 +146,11 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
146 return hugepte_offset(hpdp, addr); 146 return hugepte_offset(hpdp, addr);
147} 147}
148 148
149int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
150{
151 return 0;
152}
153
149static void free_hugepte_range(struct mmu_gather *tlb, hugepd_t *hpdp) 154static void free_hugepte_range(struct mmu_gather *tlb, hugepd_t *hpdp)
150{ 155{
151 pte_t *hugepte = hugepd_page(*hpdp); 156 pte_t *hugepte = hugepd_page(*hpdp);
@@ -1042,7 +1047,7 @@ repeat:
1042 return err; 1047 return err;
1043} 1048}
1044 1049
1045static void zero_ctor(void *addr, kmem_cache_t *cache, unsigned long flags) 1050static void zero_ctor(void *addr, struct kmem_cache *cache, unsigned long flags)
1046{ 1051{
1047 memset(addr, 0, kmem_cache_size(cache)); 1052 memset(addr, 0, kmem_cache_size(cache));
1048} 1053}
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index 9a178549cbcf..d12a87ec5ae9 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -141,7 +141,7 @@ static int __init setup_kcore(void)
141} 141}
142module_init(setup_kcore); 142module_init(setup_kcore);
143 143
144static void zero_ctor(void *addr, kmem_cache_t *cache, unsigned long flags) 144static void zero_ctor(void *addr, struct kmem_cache *cache, unsigned long flags)
145{ 145{
146 memset(addr, 0, kmem_cache_size(cache)); 146 memset(addr, 0, kmem_cache_size(cache));
147} 147}
@@ -166,9 +166,9 @@ static const char *pgtable_cache_name[ARRAY_SIZE(pgtable_cache_size)] = {
166/* Hugepages need one extra cache, initialized in hugetlbpage.c. We 166/* Hugepages need one extra cache, initialized in hugetlbpage.c. We
167 * can't put into the tables above, because HPAGE_SHIFT is not compile 167 * can't put into the tables above, because HPAGE_SHIFT is not compile
168 * time constant. */ 168 * time constant. */
169kmem_cache_t *pgtable_cache[ARRAY_SIZE(pgtable_cache_size)+1]; 169struct kmem_cache *pgtable_cache[ARRAY_SIZE(pgtable_cache_size)+1];
170#else 170#else
171kmem_cache_t *pgtable_cache[ARRAY_SIZE(pgtable_cache_size)]; 171struct kmem_cache *pgtable_cache[ARRAY_SIZE(pgtable_cache_size)];
172#endif 172#endif
173 173
174void pgtable_cache_init(void) 174void pgtable_cache_init(void)
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index c7d010749a18..e3af9112c026 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -40,7 +40,7 @@
40 40
41#include "spufs.h" 41#include "spufs.h"
42 42
43static kmem_cache_t *spufs_inode_cache; 43static struct kmem_cache *spufs_inode_cache;
44char *isolated_loader; 44char *isolated_loader;
45 45
46static struct inode * 46static struct inode *
@@ -48,7 +48,7 @@ spufs_alloc_inode(struct super_block *sb)
48{ 48{
49 struct spufs_inode_info *ei; 49 struct spufs_inode_info *ei;
50 50
51 ei = kmem_cache_alloc(spufs_inode_cache, SLAB_KERNEL); 51 ei = kmem_cache_alloc(spufs_inode_cache, GFP_KERNEL);
52 if (!ei) 52 if (!ei)
53 return NULL; 53 return NULL;
54 54
@@ -65,7 +65,7 @@ spufs_destroy_inode(struct inode *inode)
65} 65}
66 66
67static void 67static void
68spufs_init_once(void *p, kmem_cache_t * cachep, unsigned long flags) 68spufs_init_once(void *p, struct kmem_cache * cachep, unsigned long flags)
69{ 69{
70 struct spufs_inode_info *ei = p; 70 struct spufs_inode_info *ei = p;
71 71
diff --git a/arch/powerpc/platforms/embedded6xx/ls_uart.c b/arch/powerpc/platforms/embedded6xx/ls_uart.c
index 31bcdae84823..0e837762cc5b 100644
--- a/arch/powerpc/platforms/embedded6xx/ls_uart.c
+++ b/arch/powerpc/platforms/embedded6xx/ls_uart.c
@@ -14,7 +14,7 @@ static unsigned long avr_clock;
14 14
15static struct work_struct wd_work; 15static struct work_struct wd_work;
16 16
17static void wd_stop(void *unused) 17static void wd_stop(struct work_struct *unused)
18{ 18{
19 const char string[] = "AAAAFFFFJJJJ>>>>VVVV>>>>ZZZZVVVVKKKK"; 19 const char string[] = "AAAAFFFFJJJJ>>>>VVVV>>>>ZZZZVVVVKKKK";
20 int i = 0, rescue = 8; 20 int i = 0, rescue = 8;
@@ -122,7 +122,7 @@ static int __init ls_uarts_init(void)
122 122
123 ls_uart_init(); 123 ls_uart_init();
124 124
125 INIT_WORK(&wd_work, wd_stop, NULL); 125 INIT_WORK(&wd_work, wd_stop);
126 schedule_work(&wd_work); 126 schedule_work(&wd_work);
127 127
128 return 0; 128 return 0;
diff --git a/arch/powerpc/platforms/powermac/backlight.c b/arch/powerpc/platforms/powermac/backlight.c
index afa593a8544a..c3a89414ddc0 100644
--- a/arch/powerpc/platforms/powermac/backlight.c
+++ b/arch/powerpc/platforms/powermac/backlight.c
@@ -18,11 +18,11 @@
18 18
19#define OLD_BACKLIGHT_MAX 15 19#define OLD_BACKLIGHT_MAX 15
20 20
21static void pmac_backlight_key_worker(void *data); 21static void pmac_backlight_key_worker(struct work_struct *work);
22static void pmac_backlight_set_legacy_worker(void *data); 22static void pmac_backlight_set_legacy_worker(struct work_struct *work);
23 23
24static DECLARE_WORK(pmac_backlight_key_work, pmac_backlight_key_worker, NULL); 24static DECLARE_WORK(pmac_backlight_key_work, pmac_backlight_key_worker);
25static DECLARE_WORK(pmac_backlight_set_legacy_work, pmac_backlight_set_legacy_worker, NULL); 25static DECLARE_WORK(pmac_backlight_set_legacy_work, pmac_backlight_set_legacy_worker);
26 26
27/* Although these variables are used in interrupt context, it makes no sense to 27/* Although these variables are used in interrupt context, it makes no sense to
28 * protect them. No user is able to produce enough key events per second and 28 * protect them. No user is able to produce enough key events per second and
@@ -94,7 +94,7 @@ int pmac_backlight_curve_lookup(struct fb_info *info, int value)
94 return level; 94 return level;
95} 95}
96 96
97static void pmac_backlight_key_worker(void *data) 97static void pmac_backlight_key_worker(struct work_struct *work)
98{ 98{
99 if (atomic_read(&kernel_backlight_disabled)) 99 if (atomic_read(&kernel_backlight_disabled))
100 return; 100 return;
@@ -166,7 +166,7 @@ static int __pmac_backlight_set_legacy_brightness(int brightness)
166 return error; 166 return error;
167} 167}
168 168
169static void pmac_backlight_set_legacy_worker(void *data) 169static void pmac_backlight_set_legacy_worker(struct work_struct *work)
170{ 170{
171 if (atomic_read(&kernel_backlight_disabled)) 171 if (atomic_read(&kernel_backlight_disabled))
172 return; 172 return;
diff --git a/arch/powerpc/platforms/pseries/eeh_event.c b/arch/powerpc/platforms/pseries/eeh_event.c
index 137077451316..49037edf7d39 100644
--- a/arch/powerpc/platforms/pseries/eeh_event.c
+++ b/arch/powerpc/platforms/pseries/eeh_event.c
@@ -37,8 +37,8 @@
37/* EEH event workqueue setup. */ 37/* EEH event workqueue setup. */
38static DEFINE_SPINLOCK(eeh_eventlist_lock); 38static DEFINE_SPINLOCK(eeh_eventlist_lock);
39LIST_HEAD(eeh_eventlist); 39LIST_HEAD(eeh_eventlist);
40static void eeh_thread_launcher(void *); 40static void eeh_thread_launcher(struct work_struct *);
41DECLARE_WORK(eeh_event_wq, eeh_thread_launcher, NULL); 41DECLARE_WORK(eeh_event_wq, eeh_thread_launcher);
42 42
43/* Serialize reset sequences for a given pci device */ 43/* Serialize reset sequences for a given pci device */
44DEFINE_MUTEX(eeh_event_mutex); 44DEFINE_MUTEX(eeh_event_mutex);
@@ -103,7 +103,7 @@ static int eeh_event_handler(void * dummy)
103 * eeh_thread_launcher 103 * eeh_thread_launcher
104 * @dummy - unused 104 * @dummy - unused
105 */ 105 */
106static void eeh_thread_launcher(void *dummy) 106static void eeh_thread_launcher(struct work_struct *dummy)
107{ 107{
108 if (kernel_thread(eeh_event_handler, NULL, CLONE_KERNEL) < 0) 108 if (kernel_thread(eeh_event_handler, NULL, CLONE_KERNEL) < 0)
109 printk(KERN_ERR "Failed to start EEH daemon\n"); 109 printk(KERN_ERR "Failed to start EEH daemon\n");
diff --git a/arch/ppc/8260_io/fcc_enet.c b/arch/ppc/8260_io/fcc_enet.c
index 2e1943e27819..709952c25f29 100644
--- a/arch/ppc/8260_io/fcc_enet.c
+++ b/arch/ppc/8260_io/fcc_enet.c
@@ -385,6 +385,7 @@ struct fcc_enet_private {
385 phy_info_t *phy; 385 phy_info_t *phy;
386 struct work_struct phy_relink; 386 struct work_struct phy_relink;
387 struct work_struct phy_display_config; 387 struct work_struct phy_display_config;
388 struct net_device *dev;
388 389
389 uint sequence_done; 390 uint sequence_done;
390 391
@@ -1391,10 +1392,11 @@ static phy_info_t *phy_info[] = {
1391 NULL 1392 NULL
1392}; 1393};
1393 1394
1394static void mii_display_status(void *data) 1395static void mii_display_status(struct work_struct *work)
1395{ 1396{
1396 struct net_device *dev = data; 1397 volatile struct fcc_enet_private *fep =
1397 volatile struct fcc_enet_private *fep = dev->priv; 1398 container_of(work, struct fcc_enet_private, phy_relink);
1399 struct net_device *dev = fep->dev;
1398 uint s = fep->phy_status; 1400 uint s = fep->phy_status;
1399 1401
1400 if (!fep->link && !fep->old_link) { 1402 if (!fep->link && !fep->old_link) {
@@ -1428,10 +1430,12 @@ static void mii_display_status(void *data)
1428 printk(".\n"); 1430 printk(".\n");
1429} 1431}
1430 1432
1431static void mii_display_config(void *data) 1433static void mii_display_config(struct work_struct *work)
1432{ 1434{
1433 struct net_device *dev = data; 1435 volatile struct fcc_enet_private *fep =
1434 volatile struct fcc_enet_private *fep = dev->priv; 1436 container_of(work, struct fcc_enet_private,
1437 phy_display_config);
1438 struct net_device *dev = fep->dev;
1435 uint s = fep->phy_status; 1439 uint s = fep->phy_status;
1436 1440
1437 printk("%s: config: auto-negotiation ", dev->name); 1441 printk("%s: config: auto-negotiation ", dev->name);
@@ -1758,8 +1762,9 @@ static int __init fec_enet_init(void)
1758 cep->phy_id_done = 0; 1762 cep->phy_id_done = 0;
1759 cep->phy_addr = fip->fc_phyaddr; 1763 cep->phy_addr = fip->fc_phyaddr;
1760 mii_queue(dev, mk_mii_read(MII_PHYSID1), mii_discover_phy); 1764 mii_queue(dev, mk_mii_read(MII_PHYSID1), mii_discover_phy);
1761 INIT_WORK(&cep->phy_relink, mii_display_status, dev); 1765 INIT_WORK(&cep->phy_relink, mii_display_status);
1762 INIT_WORK(&cep->phy_display_config, mii_display_config, dev); 1766 INIT_WORK(&cep->phy_display_config, mii_display_config);
1767 cep->dev = dev;
1763#endif /* CONFIG_USE_MDIO */ 1768#endif /* CONFIG_USE_MDIO */
1764 1769
1765 fip++; 1770 fip++;
diff --git a/arch/ppc/8xx_io/fec.c b/arch/ppc/8xx_io/fec.c
index 2f9fa9e3d331..e6c28fb423b2 100644
--- a/arch/ppc/8xx_io/fec.c
+++ b/arch/ppc/8xx_io/fec.c
@@ -173,6 +173,7 @@ struct fec_enet_private {
173 uint phy_speed; 173 uint phy_speed;
174 phy_info_t *phy; 174 phy_info_t *phy;
175 struct work_struct phy_task; 175 struct work_struct phy_task;
176 struct net_device *dev;
176 177
177 uint sequence_done; 178 uint sequence_done;
178 179
@@ -1263,10 +1264,11 @@ static void mii_display_status(struct net_device *dev)
1263 printk(".\n"); 1264 printk(".\n");
1264} 1265}
1265 1266
1266static void mii_display_config(void *priv) 1267static void mii_display_config(struct work_struct *work)
1267{ 1268{
1268 struct net_device *dev = (struct net_device *)priv; 1269 struct fec_enet_private *fep =
1269 struct fec_enet_private *fep = dev->priv; 1270 container_of(work, struct fec_enet_private, phy_task);
1271 struct net_device *dev = fep->dev;
1270 volatile uint *s = &(fep->phy_status); 1272 volatile uint *s = &(fep->phy_status);
1271 1273
1272 printk("%s: config: auto-negotiation ", dev->name); 1274 printk("%s: config: auto-negotiation ", dev->name);
@@ -1295,10 +1297,11 @@ static void mii_display_config(void *priv)
1295 fep->sequence_done = 1; 1297 fep->sequence_done = 1;
1296} 1298}
1297 1299
1298static void mii_relink(void *priv) 1300static void mii_relink(struct work_struct *work)
1299{ 1301{
1300 struct net_device *dev = (struct net_device *)priv; 1302 struct fec_enet_private *fep =
1301 struct fec_enet_private *fep = dev->priv; 1303 container_of(work, struct fec_enet_private, phy_task);
1304 struct net_device *dev = fep->dev;
1302 int duplex; 1305 int duplex;
1303 1306
1304 fep->link = (fep->phy_status & PHY_STAT_LINK) ? 1 : 0; 1307 fep->link = (fep->phy_status & PHY_STAT_LINK) ? 1 : 0;
@@ -1325,7 +1328,8 @@ static void mii_queue_relink(uint mii_reg, struct net_device *dev)
1325{ 1328{
1326 struct fec_enet_private *fep = dev->priv; 1329 struct fec_enet_private *fep = dev->priv;
1327 1330
1328 INIT_WORK(&fep->phy_task, mii_relink, (void *)dev); 1331 fep->dev = dev;
1332 INIT_WORK(&fep->phy_task, mii_relink);
1329 schedule_work(&fep->phy_task); 1333 schedule_work(&fep->phy_task);
1330} 1334}
1331 1335
@@ -1333,7 +1337,8 @@ static void mii_queue_config(uint mii_reg, struct net_device *dev)
1333{ 1337{
1334 struct fec_enet_private *fep = dev->priv; 1338 struct fec_enet_private *fep = dev->priv;
1335 1339
1336 INIT_WORK(&fep->phy_task, mii_display_config, (void *)dev); 1340 fep->dev = dev;
1341 INIT_WORK(&fep->phy_task, mii_display_config);
1337 schedule_work(&fep->phy_task); 1342 schedule_work(&fep->phy_task);
1338} 1343}
1339 1344
diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c
index af1e8fc7d985..b8c237290263 100644
--- a/arch/s390/appldata/appldata_base.c
+++ b/arch/s390/appldata/appldata_base.c
@@ -92,8 +92,8 @@ static int appldata_timer_active;
92 * Work queue 92 * Work queue
93 */ 93 */
94static struct workqueue_struct *appldata_wq; 94static struct workqueue_struct *appldata_wq;
95static void appldata_work_fn(void *data); 95static void appldata_work_fn(struct work_struct *work);
96static DECLARE_WORK(appldata_work, appldata_work_fn, NULL); 96static DECLARE_WORK(appldata_work, appldata_work_fn);
97 97
98 98
99/* 99/*
@@ -125,7 +125,7 @@ static void appldata_timer_function(unsigned long data)
125 * 125 *
126 * call data gathering function for each (active) module 126 * call data gathering function for each (active) module
127 */ 127 */
128static void appldata_work_fn(void *data) 128static void appldata_work_fn(struct work_struct *work)
129{ 129{
130 struct list_head *lh; 130 struct list_head *lh;
131 struct appldata_ops *ops; 131 struct appldata_ops *ops;
@@ -561,7 +561,6 @@ appldata_offline_cpu(int cpu)
561 spin_unlock(&appldata_timer_lock); 561 spin_unlock(&appldata_timer_lock);
562} 562}
563 563
564#ifdef CONFIG_HOTPLUG_CPU
565static int __cpuinit 564static int __cpuinit
566appldata_cpu_notify(struct notifier_block *self, 565appldata_cpu_notify(struct notifier_block *self,
567 unsigned long action, void *hcpu) 566 unsigned long action, void *hcpu)
@@ -582,7 +581,6 @@ appldata_cpu_notify(struct notifier_block *self,
582static struct notifier_block appldata_nb = { 581static struct notifier_block appldata_nb = {
583 .notifier_call = appldata_cpu_notify, 582 .notifier_call = appldata_cpu_notify,
584}; 583};
585#endif
586 584
587/* 585/*
588 * appldata_init() 586 * appldata_init()
diff --git a/arch/s390/kernel/binfmt_elf32.c b/arch/s390/kernel/binfmt_elf32.c
index 9565a2dcfadc..5c46054195cb 100644
--- a/arch/s390/kernel/binfmt_elf32.c
+++ b/arch/s390/kernel/binfmt_elf32.c
@@ -176,7 +176,6 @@ struct elf_prpsinfo32
176 176
177#include <linux/highuid.h> 177#include <linux/highuid.h>
178 178
179#define elf_addr_t u32
180/* 179/*
181#define init_elf_binfmt init_elf32_binfmt 180#define init_elf_binfmt init_elf32_binfmt
182*/ 181*/
diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
index 67914fe7f317..576368c4f605 100644
--- a/arch/s390/kernel/kprobes.c
+++ b/arch/s390/kernel/kprobes.c
@@ -200,7 +200,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
200void __kprobes arch_remove_kprobe(struct kprobe *p) 200void __kprobes arch_remove_kprobe(struct kprobe *p)
201{ 201{
202 mutex_lock(&kprobe_mutex); 202 mutex_lock(&kprobe_mutex);
203 free_insn_slot(p->ainsn.insn); 203 free_insn_slot(p->ainsn.insn, 0);
204 mutex_unlock(&kprobe_mutex); 204 mutex_unlock(&kprobe_mutex);
205} 205}
206 206
diff --git a/arch/s390/lib/uaccess_std.c b/arch/s390/lib/uaccess_std.c
index 2d549ed2e113..bbaca66fa293 100644
--- a/arch/s390/lib/uaccess_std.c
+++ b/arch/s390/lib/uaccess_std.c
@@ -11,7 +11,7 @@
11 11
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <asm/uaccess.h> 14#include <linux/uaccess.h>
15#include <asm/futex.h> 15#include <asm/futex.h>
16 16
17#ifndef __s390x__ 17#ifndef __s390x__
@@ -258,7 +258,7 @@ int futex_atomic_op(int op, int __user *uaddr, int oparg, int *old)
258{ 258{
259 int oldval = 0, newval, ret; 259 int oldval = 0, newval, ret;
260 260
261 inc_preempt_count(); 261 pagefault_disable();
262 262
263 switch (op) { 263 switch (op) {
264 case FUTEX_OP_SET: 264 case FUTEX_OP_SET:
@@ -284,7 +284,7 @@ int futex_atomic_op(int op, int __user *uaddr, int oparg, int *old)
284 default: 284 default:
285 ret = -ENOSYS; 285 ret = -ENOSYS;
286 } 286 }
287 dec_preempt_count(); 287 pagefault_enable();
288 *old = oldval; 288 *old = oldval;
289 return ret; 289 return ret;
290} 290}
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index bffc7e176970..d83d64af31f2 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -51,6 +51,14 @@ config GENERIC_TIME
51config ARCH_MAY_HAVE_PC_FDC 51config ARCH_MAY_HAVE_PC_FDC
52 bool 52 bool
53 53
54config STACKTRACE_SUPPORT
55 bool
56 default y
57
58config LOCKDEP_SUPPORT
59 bool
60 default y
61
54source "init/Kconfig" 62source "init/Kconfig"
55 63
56menu "System type" 64menu "System type"
@@ -219,6 +227,20 @@ config SH_SHMIN
219 help 227 help
220 Select SHMIN if configuring for the SHMIN board. 228 Select SHMIN if configuring for the SHMIN board.
221 229
230config SH_7206_SOLUTION_ENGINE
231 bool "SolutionEngine7206"
232 select CPU_SUBTYPE_SH7206
233 help
234 Select 7206 SolutionEngine if configuring for a Hitachi SH7206
235 evaluation board.
236
237config SH_7619_SOLUTION_ENGINE
238 bool "SolutionEngine7619"
239 select CPU_SUBTYPE_SH7619
240 help
241 Select 7619 SolutionEngine if configuring for a Hitachi SH7619
242 evaluation board.
243
222config SH_UNKNOWN 244config SH_UNKNOWN
223 bool "BareCPU" 245 bool "BareCPU"
224 help 246 help
@@ -280,12 +302,20 @@ config CF_BASE_ADDR
280 302
281menu "Processor features" 303menu "Processor features"
282 304
283config CPU_LITTLE_ENDIAN 305choice
284 bool "Little Endian" 306 prompt "Endianess selection"
307 default CPU_LITTLE_ENDIAN
285 help 308 help
286 Some SuperH machines can be configured for either little or big 309 Some SuperH machines can be configured for either little or big
287 endian byte order. These modes require different kernels. Say Y if 310 endian byte order. These modes require different kernels.
288 your machine is little endian, N if it's a big endian machine. 311
312config CPU_LITTLE_ENDIAN
313 bool "Little Endian"
314
315config CPU_BIG_ENDIAN
316 bool "Big Endian"
317
318endchoice
289 319
290config SH_FPU 320config SH_FPU
291 bool "FPU support" 321 bool "FPU support"
@@ -345,6 +375,9 @@ config CPU_HAS_MASKREG_IRQ
345config CPU_HAS_INTC2_IRQ 375config CPU_HAS_INTC2_IRQ
346 bool 376 bool
347 377
378config CPU_HAS_IPR_IRQ
379 bool
380
348config CPU_HAS_SR_RB 381config CPU_HAS_SR_RB
349 bool "CPU has SR.RB" 382 bool "CPU has SR.RB"
350 depends on CPU_SH3 || CPU_SH4 383 depends on CPU_SH3 || CPU_SH4
@@ -357,6 +390,9 @@ config CPU_HAS_SR_RB
357 See <file:Documentation/sh/register-banks.txt> for further 390 See <file:Documentation/sh/register-banks.txt> for further
358 information on SR.RB and register banking in the kernel in general. 391 information on SR.RB and register banking in the kernel in general.
359 392
393config CPU_HAS_PTEA
394 bool
395
360endmenu 396endmenu
361 397
362menu "Timer support" 398menu "Timer support"
@@ -364,10 +400,25 @@ depends on !GENERIC_TIME
364 400
365config SH_TMU 401config SH_TMU
366 bool "TMU timer support" 402 bool "TMU timer support"
403 depends on CPU_SH3 || CPU_SH4
367 default y 404 default y
368 help 405 help
369 This enables the use of the TMU as the system timer. 406 This enables the use of the TMU as the system timer.
370 407
408config SH_CMT
409 bool "CMT timer support"
410 depends on CPU_SH2
411 default y
412 help
413 This enables the use of the CMT as the system timer.
414
415config SH_MTU2
416 bool "MTU2 timer support"
417 depends on CPU_SH2A
418 default n
419 help
420 This enables the use of the MTU2 as the system timer.
421
371endmenu 422endmenu
372 423
373source "arch/sh/boards/renesas/hs7751rvoip/Kconfig" 424source "arch/sh/boards/renesas/hs7751rvoip/Kconfig"
@@ -376,19 +427,52 @@ source "arch/sh/boards/renesas/rts7751r2d/Kconfig"
376 427
377source "arch/sh/boards/renesas/r7780rp/Kconfig" 428source "arch/sh/boards/renesas/r7780rp/Kconfig"
378 429
430config SH_TIMER_IRQ
431 int
432 default "28" if CPU_SUBTYPE_SH7780
433 default "86" if CPU_SUBTYPE_SH7619
434 default "140" if CPU_SUBTYPE_SH7206
435 default "16"
436
437config NO_IDLE_HZ
438 bool "Dynamic tick timer"
439 help
440 Select this option if you want to disable continuous timer ticks
441 and have them programmed to occur as required. This option saves
442 power as the system can remain in idle state for longer.
443
444 By default dynamic tick is disabled during the boot, and can be
445 manually enabled with:
446
447 echo 1 > /sys/devices/system/timer/timer0/dyn_tick
448
449 Alternatively, if you want dynamic tick automatically enabled
450 during boot, pass "dyntick=enable" via the kernel command string.
451
452 Please note that dynamic tick may affect the accuracy of
453 timekeeping on some platforms depending on the implementation.
454
379config SH_PCLK_FREQ 455config SH_PCLK_FREQ
380 int "Peripheral clock frequency (in Hz)" 456 int "Peripheral clock frequency (in Hz)"
457 default "27000000" if CPU_SUBTYPE_SH73180 || CPU_SUBTYPE_SH7343
458 default "31250000" if CPU_SUBTYPE_SH7619
459 default "33333333" if CPU_SUBTYPE_SH7300 || CPU_SUBTYPE_SH7770 || \
460 CPU_SUBTYPE_SH7760 || CPU_SUBTYPE_SH7705 || \
461 CPU_SUBTYPE_SH7206
381 default "50000000" if CPU_SUBTYPE_SH7750 || CPU_SUBTYPE_SH7780 462 default "50000000" if CPU_SUBTYPE_SH7750 || CPU_SUBTYPE_SH7780
382 default "60000000" if CPU_SUBTYPE_SH7751 463 default "60000000" if CPU_SUBTYPE_SH7751
383 default "33333333" if CPU_SUBTYPE_SH7300 || CPU_SUBTYPE_SH7770 || \
384 CPU_SUBTYPE_SH7760 || CPU_SUBTYPE_SH7705
385 default "27000000" if CPU_SUBTYPE_SH73180 || CPU_SUBTYPE_SH7343
386 default "66000000" if CPU_SUBTYPE_SH4_202 464 default "66000000" if CPU_SUBTYPE_SH4_202
387 help 465 help
388 This option is used to specify the peripheral clock frequency. 466 This option is used to specify the peripheral clock frequency.
389 This is necessary for determining the reference clock value on 467 This is necessary for determining the reference clock value on
390 platforms lacking an RTC. 468 platforms lacking an RTC.
391 469
470config SH_CLK_MD
471 int "CPU Mode Pin Setting"
472 depends on CPU_SUBTYPE_SH7619 || CPU_SUBTYPE_SH7206
473 help
474 MD2 - MD0 Setting.
475
392menu "CPU Frequency scaling" 476menu "CPU Frequency scaling"
393 477
394source "drivers/cpufreq/Kconfig" 478source "drivers/cpufreq/Kconfig"
@@ -421,6 +505,8 @@ config HEARTBEAT
421 behavior is platform-dependent, but normally the flash frequency is 505 behavior is platform-dependent, but normally the flash frequency is
422 a hyperbolic function of the 5-minute load average. 506 a hyperbolic function of the 5-minute load average.
423 507
508source "arch/sh/drivers/Kconfig"
509
424endmenu 510endmenu
425 511
426config ISA_DMA_API 512config ISA_DMA_API
diff --git a/arch/sh/Kconfig.debug b/arch/sh/Kconfig.debug
index 48479e014dac..66a25ef4ef1b 100644
--- a/arch/sh/Kconfig.debug
+++ b/arch/sh/Kconfig.debug
@@ -1,5 +1,9 @@
1menu "Kernel hacking" 1menu "Kernel hacking"
2 2
3config TRACE_IRQFLAGS_SUPPORT
4 bool
5 default y
6
3source "lib/Kconfig.debug" 7source "lib/Kconfig.debug"
4 8
5config SH_STANDARD_BIOS 9config SH_STANDARD_BIOS
@@ -17,7 +21,18 @@ config SH_STANDARD_BIOS
17 21
18config EARLY_SCIF_CONSOLE 22config EARLY_SCIF_CONSOLE
19 bool "Use early SCIF console" 23 bool "Use early SCIF console"
20 depends on CPU_SH4 || CPU_SH2A && !SH_STANDARD_BIOS 24 help
25 This enables an early console using a fixed SCIF port. This can
26 be used by platforms that are either not running the SH
27 standard BIOS, or do not wish to use the BIOS callbacks for the
28 serial I/O.
29
30config EARLY_SCIF_CONSOLE_PORT
31 hex "SCIF port for early console"
32 depends on EARLY_SCIF_CONSOLE
33 default "0xffe00000" if CPU_SUBTYPE_SH7780
34 default "0xfffe9800" if CPU_SUBTYPE_SH72060
35 default "0xffe80000" if CPU_SH4
21 36
22config EARLY_PRINTK 37config EARLY_PRINTK
23 bool "Early printk support" 38 bool "Early printk support"
@@ -30,6 +45,11 @@ config EARLY_PRINTK
30 when the kernel may crash or hang before the serial console is 45 when the kernel may crash or hang before the serial console is
31 initialised. If unsure, say N. 46 initialised. If unsure, say N.
32 47
48 On devices that are running SH-IPL and want to keep the port
49 initialization consistent while not using the BIOS callbacks,
50 select both the EARLY_SCIF_CONSOLE and SH_STANDARD_BIOS, using
51 the kernel command line option to toggle back and forth.
52
33config DEBUG_STACKOVERFLOW 53config DEBUG_STACKOVERFLOW
34 bool "Check for stack overflows" 54 bool "Check for stack overflows"
35 depends on DEBUG_KERNEL 55 depends on DEBUG_KERNEL
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 26d62ff51a64..d10bba5e1074 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -13,10 +13,6 @@
13# for "archclean" and "archdep" for cleaning up and making dependencies for 13# for "archclean" and "archdep" for cleaning up and making dependencies for
14# this architecture 14# this architecture
15# 15#
16
17cflags-y := -mb
18cflags-$(CONFIG_CPU_LITTLE_ENDIAN) := -ml
19
20isa-y := any 16isa-y := any
21isa-$(CONFIG_SH_DSP) := sh 17isa-$(CONFIG_SH_DSP) := sh
22isa-$(CONFIG_CPU_SH2) := sh2 18isa-$(CONFIG_CPU_SH2) := sh2
@@ -38,13 +34,16 @@ isa-y := $(isa-y)-nofpu
38endif 34endif
39endif 35endif
40 36
41cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),) 37cflags-$(CONFIG_CPU_SH2) := -m2
42 38cflags-$(CONFIG_CPU_SH3) := -m3
43cflags-$(CONFIG_CPU_SH2) += -m2 39cflags-$(CONFIG_CPU_SH4) := -m4 \
44cflags-$(CONFIG_CPU_SH3) += -m3
45cflags-$(CONFIG_CPU_SH4) += -m4 \
46 $(call cc-option,-mno-implicit-fp,-m4-nofpu) 40 $(call cc-option,-mno-implicit-fp,-m4-nofpu)
47cflags-$(CONFIG_CPU_SH4A) += $(call cc-option,-m4a-nofpu,) 41cflags-$(CONFIG_CPU_SH4A) := -m4a $(call cc-option,-m4a-nofpu,)
42
43cflags-$(CONFIG_CPU_BIG_ENDIAN) += -mb
44cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -ml
45
46cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),) -ffreestanding
48 47
49cflags-$(CONFIG_SH_DSP) += -Wa,-dsp 48cflags-$(CONFIG_SH_DSP) += -Wa,-dsp
50cflags-$(CONFIG_SH_KGDB) += -g 49cflags-$(CONFIG_SH_KGDB) += -g
@@ -59,7 +58,9 @@ OBJCOPYFLAGS := -O binary -R .note -R .comment -R .stab -R .stabstr -S
59# never be used by anyone. Use a board-specific defconfig that has a 58# never be used by anyone. Use a board-specific defconfig that has a
60# reasonable chance of being current instead. 59# reasonable chance of being current instead.
61# 60#
62KBUILD_DEFCONFIG := rts7751r2d_defconfig 61KBUILD_DEFCONFIG := r7780rp_defconfig
62
63KBUILD_IMAGE := arch/sh/boot/zImage
63 64
64# 65#
65# Choosing incompatible machines durings configuration will result in 66# Choosing incompatible machines durings configuration will result in
@@ -109,6 +110,8 @@ machdir-$(CONFIG_SH_SH4202_MICRODEV) := superh/microdev
109machdir-$(CONFIG_SH_LANDISK) := landisk 110machdir-$(CONFIG_SH_LANDISK) := landisk
110machdir-$(CONFIG_SH_TITAN) := titan 111machdir-$(CONFIG_SH_TITAN) := titan
111machdir-$(CONFIG_SH_SHMIN) := shmin 112machdir-$(CONFIG_SH_SHMIN) := shmin
113machdir-$(CONFIG_SH_7206_SOLUTION_ENGINE) := se/7206
114machdir-$(CONFIG_SH_7619_SOLUTION_ENGINE) := se/7619
112machdir-$(CONFIG_SH_UNKNOWN) := unknown 115machdir-$(CONFIG_SH_UNKNOWN) := unknown
113 116
114incdir-y := $(notdir $(machdir-y)) 117incdir-y := $(notdir $(machdir-y))
@@ -124,6 +127,7 @@ core-$(CONFIG_HD64465) += arch/sh/cchips/hd6446x/hd64465/
124core-$(CONFIG_VOYAGERGX) += arch/sh/cchips/voyagergx/ 127core-$(CONFIG_VOYAGERGX) += arch/sh/cchips/voyagergx/
125 128
126cpuincdir-$(CONFIG_CPU_SH2) := cpu-sh2 129cpuincdir-$(CONFIG_CPU_SH2) := cpu-sh2
130cpuincdir-$(CONFIG_CPU_SH2A) := cpu-sh2a
127cpuincdir-$(CONFIG_CPU_SH3) := cpu-sh3 131cpuincdir-$(CONFIG_CPU_SH3) := cpu-sh3
128cpuincdir-$(CONFIG_CPU_SH4) := cpu-sh4 132cpuincdir-$(CONFIG_CPU_SH4) := cpu-sh4
129 133
diff --git a/arch/sh/boards/renesas/r7780rp/Makefile b/arch/sh/boards/renesas/r7780rp/Makefile
index f1776d027978..574b0316ed56 100644
--- a/arch/sh/boards/renesas/r7780rp/Makefile
+++ b/arch/sh/boards/renesas/r7780rp/Makefile
@@ -3,4 +3,6 @@
3# 3#
4 4
5obj-y := setup.o io.o irq.o 5obj-y := setup.o io.o irq.o
6obj-$(CONFIG_HEARTBEAT) += led.o 6
7obj-$(CONFIG_HEARTBEAT) += led.o
8obj-$(CONFIG_PUSH_SWITCH) += psw.o
diff --git a/arch/sh/boards/renesas/r7780rp/irq.c b/arch/sh/boards/renesas/r7780rp/irq.c
index aa15ec5bc69e..cc381e197783 100644
--- a/arch/sh/boards/renesas/r7780rp/irq.c
+++ b/arch/sh/boards/renesas/r7780rp/irq.c
@@ -10,6 +10,7 @@
10 */ 10 */
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/irq.h> 12#include <linux/irq.h>
13#include <linux/interrupt.h>
13#include <linux/io.h> 14#include <linux/io.h>
14#include <asm/r7780rp.h> 15#include <asm/r7780rp.h>
15 16
diff --git a/arch/sh/boards/renesas/r7780rp/psw.c b/arch/sh/boards/renesas/r7780rp/psw.c
new file mode 100644
index 000000000000..c844dfa5d58d
--- /dev/null
+++ b/arch/sh/boards/renesas/r7780rp/psw.c
@@ -0,0 +1,122 @@
1/*
2 * arch/sh/boards/renesas/r7780rp/psw.c
3 *
4 * push switch support for RDBRP-1/RDBREVRP-1 debug boards.
5 *
6 * Copyright (C) 2006 Paul Mundt
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12#include <linux/io.h>
13#include <linux/init.h>
14#include <linux/interrupt.h>
15#include <linux/platform_device.h>
16#include <asm/mach/r7780rp.h>
17#include <asm/push-switch.h>
18
19static irqreturn_t psw_irq_handler(int irq, void *arg)
20{
21 struct platform_device *pdev = arg;
22 struct push_switch *psw = platform_get_drvdata(pdev);
23 struct push_switch_platform_info *psw_info = pdev->dev.platform_data;
24 unsigned int l, mask;
25 int ret = 0;
26
27 l = ctrl_inw(PA_DBSW);
28
29 /* Nothing to do if there's no state change */
30 if (psw->state) {
31 ret = 1;
32 goto out;
33 }
34
35 mask = l & 0x70;
36 /* Figure out who raised it */
37 if (mask & (1 << psw_info->bit)) {
38 psw->state = !!(mask & (1 << psw_info->bit));
39 if (psw->state) /* debounce */
40 mod_timer(&psw->debounce, jiffies + 50);
41
42 ret = 1;
43 }
44
45out:
46 /* Clear the switch IRQs */
47 l |= (0x7 << 12);
48 ctrl_outw(l, PA_DBSW);
49
50 return IRQ_RETVAL(ret);
51}
52
53static struct resource psw_resources[] = {
54 [0] = {
55 .start = IRQ_PSW,
56 .flags = IORESOURCE_IRQ,
57 },
58};
59
60static struct push_switch_platform_info s2_platform_data = {
61 .name = "s2",
62 .bit = 6,
63 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
64 IRQF_SHARED,
65 .irq_handler = psw_irq_handler,
66};
67
68static struct platform_device s2_switch_device = {
69 .name = "push-switch",
70 .id = 0,
71 .num_resources = ARRAY_SIZE(psw_resources),
72 .resource = psw_resources,
73 .dev = {
74 .platform_data = &s2_platform_data,
75 },
76};
77
78static struct push_switch_platform_info s3_platform_data = {
79 .name = "s3",
80 .bit = 5,
81 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
82 IRQF_SHARED,
83 .irq_handler = psw_irq_handler,
84};
85
86static struct platform_device s3_switch_device = {
87 .name = "push-switch",
88 .id = 1,
89 .num_resources = ARRAY_SIZE(psw_resources),
90 .resource = psw_resources,
91 .dev = {
92 .platform_data = &s3_platform_data,
93 },
94};
95
96static struct push_switch_platform_info s4_platform_data = {
97 .name = "s4",
98 .bit = 4,
99 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
100 IRQF_SHARED,
101 .irq_handler = psw_irq_handler,
102};
103
104static struct platform_device s4_switch_device = {
105 .name = "push-switch",
106 .id = 2,
107 .num_resources = ARRAY_SIZE(psw_resources),
108 .resource = psw_resources,
109 .dev = {
110 .platform_data = &s4_platform_data,
111 },
112};
113
114static struct platform_device *psw_devices[] = {
115 &s2_switch_device, &s3_switch_device, &s4_switch_device,
116};
117
118static int __init psw_init(void)
119{
120 return platform_add_devices(psw_devices, ARRAY_SIZE(psw_devices));
121}
122module_init(psw_init);
diff --git a/arch/sh/boards/renesas/r7780rp/setup.c b/arch/sh/boards/renesas/r7780rp/setup.c
index c331caeb694b..9f89c8de9db9 100644
--- a/arch/sh/boards/renesas/r7780rp/setup.c
+++ b/arch/sh/boards/renesas/r7780rp/setup.c
@@ -44,8 +44,37 @@ static struct platform_device m66596_usb_host_device = {
44 .resource = m66596_usb_host_resources, 44 .resource = m66596_usb_host_resources,
45}; 45};
46 46
47static struct resource cf_ide_resources[] = {
48 [0] = {
49 .start = 0x1f0,
50 .end = 0x1f0 + 8,
51 .flags = IORESOURCE_IO,
52 },
53 [1] = {
54 .start = 0x1f0 + 0x206,
55 .end = 0x1f0 + 8 + 0x206 + 8,
56 .flags = IORESOURCE_IO,
57 },
58 [2] = {
59#ifdef CONFIG_SH_R7780MP
60 .start = 1,
61#else
62 .start = 4,
63#endif
64 .flags = IORESOURCE_IRQ,
65 },
66};
67
68static struct platform_device cf_ide_device = {
69 .name = "pata_platform",
70 .id = -1,
71 .num_resources = ARRAY_SIZE(cf_ide_resources),
72 .resource = cf_ide_resources,
73};
74
47static struct platform_device *r7780rp_devices[] __initdata = { 75static struct platform_device *r7780rp_devices[] __initdata = {
48 &m66596_usb_host_device, 76 &m66596_usb_host_device,
77 &cf_ide_device,
49}; 78};
50 79
51static int __init r7780rp_devices_setup(void) 80static int __init r7780rp_devices_setup(void)
diff --git a/arch/sh/boards/se/7206/Makefile b/arch/sh/boards/se/7206/Makefile
new file mode 100644
index 000000000000..63950f4f2453
--- /dev/null
+++ b/arch/sh/boards/se/7206/Makefile
@@ -0,0 +1,7 @@
1#
2# Makefile for the 7206 SolutionEngine specific parts of the kernel
3#
4
5obj-y := setup.o io.o irq.o
6obj-$(CONFIG_HEARTBEAT) += led.o
7
diff --git a/arch/sh/boards/se/7206/io.c b/arch/sh/boards/se/7206/io.c
new file mode 100644
index 000000000000..b557273e0cbe
--- /dev/null
+++ b/arch/sh/boards/se/7206/io.c
@@ -0,0 +1,123 @@
1/* $Id: io.c,v 1.5 2004/02/22 23:08:43 kkojima Exp $
2 *
3 * linux/arch/sh/boards/se/7206/io.c
4 *
5 * Copyright (C) 2006 Yoshinori Sato
6 *
7 * I/O routine for Hitachi 7206 SolutionEngine.
8 *
9 */
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <asm/io.h>
14#include <asm/se7206.h>
15
16
17static inline void delay(void)
18{
19 ctrl_inw(0x20000000); /* P2 ROM Area */
20}
21
22/* MS7750 requires special versions of in*, out* routines, since
23 PC-like io ports are located at upper half byte of 16-bit word which
24 can be accessed only with 16-bit wide. */
25
26static inline volatile __u16 *
27port2adr(unsigned int port)
28{
29 if (port >= 0x2000)
30 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
31 else if (port >= 0x300 || port < 0x310)
32 return (volatile __u16 *) (PA_SMSC + (port - 0x300));
33}
34
35unsigned char se7206_inb(unsigned long port)
36{
37 return (*port2adr(port))&0xff;
38}
39
40unsigned char se7206_inb_p(unsigned long port)
41{
42 unsigned long v;
43
44 v = (*port2adr(port))&0xff;
45 delay();
46 return v;
47}
48
49unsigned short se7206_inw(unsigned long port)
50{
51 return *port2adr(port);;
52}
53
54unsigned int se7206_inl(unsigned long port)
55{
56 maybebadio(port);
57 return 0;
58}
59
60void se7206_outb(unsigned char value, unsigned long port)
61{
62 *(port2adr(port)) = value;
63}
64
65void se7206_outb_p(unsigned char value, unsigned long port)
66{
67 *(port2adr(port)) = value;
68 delay();
69}
70
71void se7206_outw(unsigned short value, unsigned long port)
72{
73 *port2adr(port) = value;
74}
75
76void se7206_outl(unsigned int value, unsigned long port)
77{
78 maybebadio(port);
79}
80
81void se7206_insb(unsigned long port, void *addr, unsigned long count)
82{
83 volatile __u16 *p = port2adr(port);
84 __u8 *ap = addr;
85
86 while (count--)
87 *ap++ = *p;
88}
89
90void se7206_insw(unsigned long port, void *addr, unsigned long count)
91{
92 volatile __u16 *p = port2adr(port);
93 __u16 *ap = addr;
94 while (count--)
95 *ap++ = *p;
96}
97
98void se7206_insl(unsigned long port, void *addr, unsigned long count)
99{
100 maybebadio(port);
101}
102
103void se7206_outsb(unsigned long port, const void *addr, unsigned long count)
104{
105 volatile __u16 *p = port2adr(port);
106 const __u8 *ap = addr;
107
108 while (count--)
109 *p = *ap++;
110}
111
112void se7206_outsw(unsigned long port, const void *addr, unsigned long count)
113{
114 volatile __u16 *p = port2adr(port);
115 const __u16 *ap = addr;
116 while (count--)
117 *p = *ap++;
118}
119
120void se7206_outsl(unsigned long port, const void *addr, unsigned long count)
121{
122 maybebadio(port);
123}
diff --git a/arch/sh/boards/se/7206/irq.c b/arch/sh/boards/se/7206/irq.c
new file mode 100644
index 000000000000..3fb0c5f5b23a
--- /dev/null
+++ b/arch/sh/boards/se/7206/irq.c
@@ -0,0 +1,139 @@
1/*
2 * linux/arch/sh/boards/se/7206/irq.c
3 *
4 * Copyright (C) 2005,2006 Yoshinori Sato
5 *
6 * Hitachi SolutionEngine Support.
7 *
8 */
9#include <linux/init.h>
10#include <linux/irq.h>
11#include <linux/io.h>
12#include <linux/irq.h>
13#include <asm/se7206.h>
14
15#define INTSTS0 0x31800000
16#define INTSTS1 0x31800002
17#define INTMSK0 0x31800004
18#define INTMSK1 0x31800006
19#define INTSEL 0x31800008
20
21static void disable_se7206_irq(unsigned int irq)
22{
23 unsigned short val;
24 unsigned short mask = 0xffff ^ (0x0f << 4 * (3 - (IRQ0_IRQ - irq)));
25 unsigned short msk0,msk1;
26
27 /* Set the priority in IPR to 0 */
28 val = ctrl_inw(INTC_IPR01);
29 val &= mask;
30 ctrl_outw(val, INTC_IPR01);
31 /* FPGA mask set */
32 msk0 = ctrl_inw(INTMSK0);
33 msk1 = ctrl_inw(INTMSK1);
34
35 switch (irq) {
36 case IRQ0_IRQ:
37 msk0 |= 0x0010;
38 break;
39 case IRQ1_IRQ:
40 msk0 |= 0x000f;
41 break;
42 case IRQ2_IRQ:
43 msk0 |= 0x0f00;
44 msk1 |= 0x00ff;
45 break;
46 }
47 ctrl_outw(msk0, INTMSK0);
48 ctrl_outw(msk1, INTMSK1);
49}
50
51static void enable_se7206_irq(unsigned int irq)
52{
53 unsigned short val;
54 unsigned short value = (0x0001 << 4 * (3 - (IRQ0_IRQ - irq)));
55 unsigned short msk0,msk1;
56
57 /* Set priority in IPR back to original value */
58 val = ctrl_inw(INTC_IPR01);
59 val |= value;
60 ctrl_outw(val, INTC_IPR01);
61
62 /* FPGA mask reset */
63 msk0 = ctrl_inw(INTMSK0);
64 msk1 = ctrl_inw(INTMSK1);
65
66 switch (irq) {
67 case IRQ0_IRQ:
68 msk0 &= ~0x0010;
69 break;
70 case IRQ1_IRQ:
71 msk0 &= ~0x000f;
72 break;
73 case IRQ2_IRQ:
74 msk0 &= ~0x0f00;
75 msk1 &= ~0x00ff;
76 break;
77 }
78 ctrl_outw(msk0, INTMSK0);
79 ctrl_outw(msk1, INTMSK1);
80}
81
82static void eoi_se7206_irq(unsigned int irq)
83{
84 unsigned short sts0,sts1;
85
86 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
87 enable_se7206_irq(irq);
88 /* FPGA isr clear */
89 sts0 = ctrl_inw(INTSTS0);
90 sts1 = ctrl_inw(INTSTS1);
91
92 switch (irq) {
93 case IRQ0_IRQ:
94 sts0 &= ~0x0010;
95 break;
96 case IRQ1_IRQ:
97 sts0 &= ~0x000f;
98 break;
99 case IRQ2_IRQ:
100 sts0 &= ~0x0f00;
101 sts1 &= ~0x00ff;
102 break;
103 }
104 ctrl_outw(sts0, INTSTS0);
105 ctrl_outw(sts1, INTSTS1);
106}
107
108static struct irq_chip se7206_irq_chip __read_mostly = {
109 .name = "SE7206-FPGA-IRQ",
110 .mask = disable_se7206_irq,
111 .unmask = enable_se7206_irq,
112 .mask_ack = disable_se7206_irq,
113 .eoi = eoi_se7206_irq,
114};
115
116static void make_se7206_irq(unsigned int irq)
117{
118 disable_irq_nosync(irq);
119 set_irq_chip_and_handler_name(irq, &se7206_irq_chip,
120 handle_level_irq, "level");
121 disable_se7206_irq(irq);
122}
123
124/*
125 * Initialize IRQ setting
126 */
127void __init init_se7206_IRQ(void)
128{
129 make_se7206_irq(IRQ0_IRQ); /* SMC91C111 */
130 make_se7206_irq(IRQ1_IRQ); /* ATA */
131 make_se7206_irq(IRQ3_IRQ); /* SLOT / PCM */
132 ctrl_outw(inw(INTC_ICR1) | 0x000b ,INTC_ICR1 ) ; /* ICR1 */
133
134 /* FPGA System register setup*/
135 ctrl_outw(0x0000,INTSTS0); /* Clear INTSTS0 */
136 ctrl_outw(0x0000,INTSTS1); /* Clear INTSTS1 */
137 /* IRQ0=LAN, IRQ1=ATA, IRQ3=SLT,PCM */
138 ctrl_outw(0x0001,INTSEL);
139}
diff --git a/arch/sh/boards/se/7206/led.c b/arch/sh/boards/se/7206/led.c
new file mode 100644
index 000000000000..ef794601ab86
--- /dev/null
+++ b/arch/sh/boards/se/7206/led.c
@@ -0,0 +1,57 @@
1/*
2 * linux/arch/sh/kernel/led_se.c
3 *
4 * Copyright (C) 2000 Stuart Menefy <stuart.menefy@st.com>
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * This file contains Solution Engine specific LED code.
10 */
11
12#include <linux/config.h>
13#include <asm/se7206.h>
14
15#ifdef CONFIG_HEARTBEAT
16
17#include <linux/sched.h>
18
19/* Cycle the LED's in the clasic Knightrider/Sun pattern */
20void heartbeat_se(void)
21{
22 static unsigned int cnt = 0, period = 0;
23 volatile unsigned short* p = (volatile unsigned short*)PA_LED;
24 static unsigned bit = 0, up = 1;
25
26 cnt += 1;
27 if (cnt < period) {
28 return;
29 }
30
31 cnt = 0;
32
33 /* Go through the points (roughly!):
34 * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
35 */
36 period = 110 - ( (300<<FSHIFT)/
37 ((avenrun[0]/5) + (3<<FSHIFT)) );
38
39 if (up) {
40 if (bit == 7) {
41 bit--;
42 up=0;
43 } else {
44 bit ++;
45 }
46 } else {
47 if (bit == 0) {
48 bit++;
49 up=1;
50 } else {
51 bit--;
52 }
53 }
54 *p = 1<<(bit+8);
55
56}
57#endif /* CONFIG_HEARTBEAT */
diff --git a/arch/sh/boards/se/7206/setup.c b/arch/sh/boards/se/7206/setup.c
new file mode 100644
index 000000000000..0f42e91a3238
--- /dev/null
+++ b/arch/sh/boards/se/7206/setup.c
@@ -0,0 +1,79 @@
1/*
2 *
3 * linux/arch/sh/boards/se/7206/setup.c
4 *
5 * Copyright (C) 2006 Yoshinori Sato
6 *
7 * Hitachi 7206 SolutionEngine Support.
8 *
9 */
10
11#include <linux/init.h>
12#include <linux/platform_device.h>
13#include <asm/se7206.h>
14#include <asm/io.h>
15#include <asm/machvec.h>
16
17static struct resource smc91x_resources[] = {
18 [0] = {
19 .start = 0x300,
20 .end = 0x300 + 0x020 - 1,
21 .flags = IORESOURCE_MEM,
22 },
23 [1] = {
24 .start = 64,
25 .end = 64,
26 .flags = IORESOURCE_IRQ,
27 },
28};
29
30static struct platform_device smc91x_device = {
31 .name = "smc91x",
32 .id = -1,
33 .num_resources = ARRAY_SIZE(smc91x_resources),
34 .resource = smc91x_resources,
35};
36
37static int __init se7206_devices_setup(void)
38{
39 return platform_device_register(&smc91x_device);
40}
41
42__initcall(se7206_devices_setup);
43
44void heartbeat_se(void);
45
46/*
47 * The Machine Vector
48 */
49
50struct sh_machine_vector mv_se __initmv = {
51 .mv_name = "SolutionEngine",
52 .mv_nr_irqs = 256,
53 .mv_inb = se7206_inb,
54 .mv_inw = se7206_inw,
55 .mv_inl = se7206_inl,
56 .mv_outb = se7206_outb,
57 .mv_outw = se7206_outw,
58 .mv_outl = se7206_outl,
59
60 .mv_inb_p = se7206_inb_p,
61 .mv_inw_p = se7206_inw,
62 .mv_inl_p = se7206_inl,
63 .mv_outb_p = se7206_outb_p,
64 .mv_outw_p = se7206_outw,
65 .mv_outl_p = se7206_outl,
66
67 .mv_insb = se7206_insb,
68 .mv_insw = se7206_insw,
69 .mv_insl = se7206_insl,
70 .mv_outsb = se7206_outsb,
71 .mv_outsw = se7206_outsw,
72 .mv_outsl = se7206_outsl,
73
74 .mv_init_irq = init_se7206_IRQ,
75#ifdef CONFIG_HEARTBEAT
76 .mv_heartbeat = heartbeat_se,
77#endif
78};
79ALIAS_MV(se)
diff --git a/arch/sh/boards/se/7619/Makefile b/arch/sh/boards/se/7619/Makefile
new file mode 100644
index 000000000000..3666eca8a658
--- /dev/null
+++ b/arch/sh/boards/se/7619/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for the 7619 SolutionEngine specific parts of the kernel
3#
4
5obj-y := setup.o io.o
diff --git a/arch/sh/boards/se/7619/io.c b/arch/sh/boards/se/7619/io.c
new file mode 100644
index 000000000000..176f1f39cd9d
--- /dev/null
+++ b/arch/sh/boards/se/7619/io.c
@@ -0,0 +1,102 @@
1/*
2 *
3 * linux/arch/sh/boards/se/7619/io.c
4 *
5 * Copyright (C) 2006 Yoshinori Sato
6 *
7 * I/O routine for Hitachi 7619 SolutionEngine.
8 *
9 */
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <asm/io.h>
14#include <asm/se7619.h>
15#include <asm/irq.h>
16
17/* FIXME: M3A-ZAB7 Compact Flash Slot support */
18
19static inline void delay(void)
20{
21 ctrl_inw(0xa0000000); /* Uncached ROM area (P2) */
22}
23
24#define badio(name,port) \
25 printk("bad I/O operation (%s) for port 0x%lx at 0x%08x\n", \
26 #name, (port), (__u32) __builtin_return_address(0))
27
28unsigned char se7619___inb(unsigned long port)
29{
30 badio(inb, port);
31 return 0;
32}
33
34unsigned char se7619___inb_p(unsigned long port)
35{
36 badio(inb_p, port);
37 delay();
38 return 0;
39}
40
41unsigned short se7619___inw(unsigned long port)
42{
43 badio(inw, port);
44 return 0;
45}
46
47unsigned int se7619___inl(unsigned long port)
48{
49 badio(inl, port);
50 return 0;
51}
52
53void se7619___outb(unsigned char value, unsigned long port)
54{
55 badio(outb, port);
56}
57
58void se7619___outb_p(unsigned char value, unsigned long port)
59{
60 badio(outb_p, port);
61 delay();
62}
63
64void se7619___outw(unsigned short value, unsigned long port)
65{
66 badio(outw, port);
67}
68
69void se7619___outl(unsigned int value, unsigned long port)
70{
71 badio(outl, port);
72}
73
74void se7619___insb(unsigned long port, void *addr, unsigned long count)
75{
76 badio(inw, port);
77}
78
79void se7619___insw(unsigned long port, void *addr, unsigned long count)
80{
81 badio(inw, port);
82}
83
84void se7619___insl(unsigned long port, void *addr, unsigned long count)
85{
86 badio(insl, port);
87}
88
89void se7619___outsb(unsigned long port, const void *addr, unsigned long count)
90{
91 badio(insl, port);
92}
93
94void se7619___outsw(unsigned long port, const void *addr, unsigned long count)
95{
96 badio(insl, port);
97}
98
99void se7619___outsl(unsigned long port, const void *addr, unsigned long count)
100{
101 badio(outsw, port);
102}
diff --git a/arch/sh/boards/se/7619/setup.c b/arch/sh/boards/se/7619/setup.c
new file mode 100644
index 000000000000..e627b26de0d0
--- /dev/null
+++ b/arch/sh/boards/se/7619/setup.c
@@ -0,0 +1,43 @@
1/*
2 * arch/sh/boards/se/7619/setup.c
3 *
4 * Copyright (C) 2006 Yoshinori Sato
5 *
6 * Hitachi SH7619 SolutionEngine Support.
7 */
8
9#include <linux/init.h>
10#include <linux/platform_device.h>
11#include <asm/io.h>
12#include <asm/se7619.h>
13#include <asm/machvec.h>
14
15/*
16 * The Machine Vector
17 */
18
19struct sh_machine_vector mv_se __initmv = {
20 .mv_name = "SolutionEngine",
21 .mv_nr_irqs = 108,
22 .mv_inb = se7619___inb,
23 .mv_inw = se7619___inw,
24 .mv_inl = se7619___inl,
25 .mv_outb = se7619___outb,
26 .mv_outw = se7619___outw,
27 .mv_outl = se7619___outl,
28
29 .mv_inb_p = se7619___inb_p,
30 .mv_inw_p = se7619___inw,
31 .mv_inl_p = se7619___inl,
32 .mv_outb_p = se7619___outb_p,
33 .mv_outw_p = se7619___outw,
34 .mv_outl_p = se7619___outl,
35
36 .mv_insb = se7619___insb,
37 .mv_insw = se7619___insw,
38 .mv_insl = se7619___insl,
39 .mv_outsb = se7619___outsb,
40 .mv_outsw = se7619___outsw,
41 .mv_outsl = se7619___outsl,
42};
43ALIAS_MV(se)
diff --git a/arch/sh/boards/titan/setup.c b/arch/sh/boards/titan/setup.c
index a6046d93758b..6bcd939bfaed 100644
--- a/arch/sh/boards/titan/setup.c
+++ b/arch/sh/boards/titan/setup.c
@@ -1,26 +1,30 @@
1/* 1/*
2 * Setup for Titan 2 * arch/sh/boards/titan/setup.c - Setup for Titan
3 *
4 * Copyright (C) 2006 Jamie Lenehan
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
3 */ 9 */
4
5#include <linux/init.h> 10#include <linux/init.h>
6#include <asm/irq.h> 11#include <linux/irq.h>
7#include <asm/titan.h> 12#include <asm/titan.h>
8#include <asm/io.h> 13#include <asm/io.h>
9 14
10extern void __init pcibios_init_platform(void);
11
12static struct ipr_data titan_ipr_map[] = { 15static struct ipr_data titan_ipr_map[] = {
13 { TITAN_IRQ_WAN, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY }, 16 /* IRQ, IPR idx, shift, prio */
14 { TITAN_IRQ_LAN, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY }, 17 { TITAN_IRQ_WAN, 3, 12, 8 }, /* eth0 (WAN) */
15 { TITAN_IRQ_MPCIA, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY }, 18 { TITAN_IRQ_LAN, 3, 8, 8 }, /* eth1 (LAN) */
16 { TITAN_IRQ_USB, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY }, 19 { TITAN_IRQ_MPCIA, 3, 4, 8 }, /* mPCI A (top) */
20 { TITAN_IRQ_USB, 3, 0, 8 }, /* mPCI B (bottom), USB */
17}; 21};
18 22
19static void __init init_titan_irq(void) 23static void __init init_titan_irq(void)
20{ 24{
21 /* enable individual interrupt mode for externals */ 25 /* enable individual interrupt mode for externals */
22 ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR); 26 ipr_irq_enable_irlm();
23 27 /* register ipr irqs */
24 make_ipr_irq(titan_ipr_map, ARRAY_SIZE(titan_ipr_map)); 28 make_ipr_irq(titan_ipr_map, ARRAY_SIZE(titan_ipr_map));
25} 29}
26 30
@@ -47,6 +51,5 @@ struct sh_machine_vector mv_titan __initmv = {
47 .mv_ioport_map = titan_ioport_map, 51 .mv_ioport_map = titan_ioport_map,
48 52
49 .mv_init_irq = init_titan_irq, 53 .mv_init_irq = init_titan_irq,
50 .mv_init_pci = pcibios_init_platform,
51}; 54};
52ALIAS_MV(titan) 55ALIAS_MV(titan)
diff --git a/arch/sh/boot/compressed/misc.c b/arch/sh/boot/compressed/misc.c
index f2fed5ce5cc3..35452d85b7f7 100644
--- a/arch/sh/boot/compressed/misc.c
+++ b/arch/sh/boot/compressed/misc.c
@@ -12,6 +12,7 @@
12 */ 12 */
13 13
14#include <asm/uaccess.h> 14#include <asm/uaccess.h>
15#include <asm/addrspace.h>
15#ifdef CONFIG_SH_STANDARD_BIOS 16#ifdef CONFIG_SH_STANDARD_BIOS
16#include <asm/sh_bios.h> 17#include <asm/sh_bios.h>
17#endif 18#endif
@@ -228,7 +229,7 @@ long* stack_start = &user_stack[STACK_SIZE];
228void decompress_kernel(void) 229void decompress_kernel(void)
229{ 230{
230 output_data = 0; 231 output_data = 0;
231 output_ptr = (unsigned long)&_text+0x20001000; 232 output_ptr = P2SEGADDR((unsigned long)&_text+0x1000);
232 free_mem_ptr = (unsigned long)&_end; 233 free_mem_ptr = (unsigned long)&_end;
233 free_mem_end_ptr = free_mem_ptr + HEAP_SIZE; 234 free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
234 235
diff --git a/arch/sh/configs/r7780rp_defconfig b/arch/sh/configs/r7780rp_defconfig
index 34e2046c3213..2b75b4896ba5 100644
--- a/arch/sh/configs/r7780rp_defconfig
+++ b/arch/sh/configs/r7780rp_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.19-rc3 3# Linux kernel version: 2.6.19
4# Tue Oct 31 12:32:06 2006 4# Wed Dec 6 11:59:38 2006
5# 5#
6CONFIG_SUPERH=y 6CONFIG_SUPERH=y
7CONFIG_RWSEM_GENERIC_SPINLOCK=y 7CONFIG_RWSEM_GENERIC_SPINLOCK=y
@@ -11,6 +11,8 @@ CONFIG_GENERIC_HARDIRQS=y
11CONFIG_GENERIC_IRQ_PROBE=y 11CONFIG_GENERIC_IRQ_PROBE=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y 12CONFIG_GENERIC_CALIBRATE_DELAY=y
13# CONFIG_GENERIC_TIME is not set 13# CONFIG_GENERIC_TIME is not set
14CONFIG_STACKTRACE_SUPPORT=y
15CONFIG_LOCKDEP_SUPPORT=y
14CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 16CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
15 17
16# 18#
@@ -37,6 +39,7 @@ CONFIG_BSD_PROCESS_ACCT=y
37# CONFIG_AUDIT is not set 39# CONFIG_AUDIT is not set
38CONFIG_IKCONFIG=y 40CONFIG_IKCONFIG=y
39CONFIG_IKCONFIG_PROC=y 41CONFIG_IKCONFIG_PROC=y
42# CONFIG_SYSFS_DEPRECATED is not set
40# CONFIG_RELAY is not set 43# CONFIG_RELAY is not set
41CONFIG_INITRAMFS_SOURCE="" 44CONFIG_INITRAMFS_SOURCE=""
42CONFIG_CC_OPTIMIZE_FOR_SIZE=y 45CONFIG_CC_OPTIMIZE_FOR_SIZE=y
@@ -118,6 +121,8 @@ CONFIG_SH_R7780RP=y
118# CONFIG_SH_LANDISK is not set 121# CONFIG_SH_LANDISK is not set
119# CONFIG_SH_TITAN is not set 122# CONFIG_SH_TITAN is not set
120# CONFIG_SH_SHMIN is not set 123# CONFIG_SH_SHMIN is not set
124# CONFIG_SH_7206_SOLUTION_ENGINE is not set
125# CONFIG_SH_7619_SOLUTION_ENGINE is not set
121# CONFIG_SH_UNKNOWN is not set 126# CONFIG_SH_UNKNOWN is not set
122 127
123# 128#
@@ -130,6 +135,12 @@ CONFIG_CPU_SH4A=y
130# SH-2 Processor Support 135# SH-2 Processor Support
131# 136#
132# CONFIG_CPU_SUBTYPE_SH7604 is not set 137# CONFIG_CPU_SUBTYPE_SH7604 is not set
138# CONFIG_CPU_SUBTYPE_SH7619 is not set
139
140#
141# SH-2A Processor Support
142#
143# CONFIG_CPU_SUBTYPE_SH7206 is not set
133 144
134# 145#
135# SH-3 Processor Support 146# SH-3 Processor Support
@@ -165,6 +176,7 @@ CONFIG_CPU_SH4A=y
165# 176#
166# CONFIG_CPU_SUBTYPE_SH7770 is not set 177# CONFIG_CPU_SUBTYPE_SH7770 is not set
167CONFIG_CPU_SUBTYPE_SH7780=y 178CONFIG_CPU_SUBTYPE_SH7780=y
179# CONFIG_CPU_SUBTYPE_SH7785 is not set
168 180
169# 181#
170# SH4AL-DSP Processor Support 182# SH4AL-DSP Processor Support
@@ -181,8 +193,14 @@ CONFIG_MEMORY_START=0x08000000
181CONFIG_MEMORY_SIZE=0x08000000 193CONFIG_MEMORY_SIZE=0x08000000
182# CONFIG_32BIT is not set 194# CONFIG_32BIT is not set
183CONFIG_VSYSCALL=y 195CONFIG_VSYSCALL=y
196CONFIG_PAGE_SIZE_4KB=y
197# CONFIG_PAGE_SIZE_8KB is not set
198# CONFIG_PAGE_SIZE_64KB is not set
184CONFIG_HUGETLB_PAGE_SIZE_64K=y 199CONFIG_HUGETLB_PAGE_SIZE_64K=y
200# CONFIG_HUGETLB_PAGE_SIZE_256K is not set
185# CONFIG_HUGETLB_PAGE_SIZE_1MB is not set 201# CONFIG_HUGETLB_PAGE_SIZE_1MB is not set
202# CONFIG_HUGETLB_PAGE_SIZE_4MB is not set
203# CONFIG_HUGETLB_PAGE_SIZE_64MB is not set
186CONFIG_SELECT_MEMORY_MODEL=y 204CONFIG_SELECT_MEMORY_MODEL=y
187CONFIG_FLATMEM_MANUAL=y 205CONFIG_FLATMEM_MANUAL=y
188# CONFIG_DISCONTIGMEM_MANUAL is not set 206# CONFIG_DISCONTIGMEM_MANUAL is not set
@@ -204,12 +222,14 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
204# Processor features 222# Processor features
205# 223#
206CONFIG_CPU_LITTLE_ENDIAN=y 224CONFIG_CPU_LITTLE_ENDIAN=y
225# CONFIG_CPU_BIG_ENDIAN is not set
207CONFIG_SH_FPU=y 226CONFIG_SH_FPU=y
208# CONFIG_SH_DSP is not set 227# CONFIG_SH_DSP is not set
209CONFIG_SH_STORE_QUEUES=y 228CONFIG_SH_STORE_QUEUES=y
210CONFIG_CPU_HAS_INTEVT=y 229CONFIG_CPU_HAS_INTEVT=y
211CONFIG_CPU_HAS_INTC2_IRQ=y 230CONFIG_CPU_HAS_INTC2_IRQ=y
212CONFIG_CPU_HAS_SR_RB=y 231CONFIG_CPU_HAS_SR_RB=y
232CONFIG_CPU_HAS_PTEA=y
213 233
214# 234#
215# Timer support 235# Timer support
@@ -220,6 +240,8 @@ CONFIG_SH_TMU=y
220# R7780RP options 240# R7780RP options
221# 241#
222CONFIG_SH_R7780MP=y 242CONFIG_SH_R7780MP=y
243CONFIG_SH_TIMER_IRQ=28
244CONFIG_NO_IDLE_HZ=y
223CONFIG_SH_PCLK_FREQ=32000000 245CONFIG_SH_PCLK_FREQ=32000000
224 246
225# 247#
@@ -238,13 +260,18 @@ CONFIG_SH_PCLK_FREQ=32000000
238# CONFIG_HD6446X_SERIES is not set 260# CONFIG_HD6446X_SERIES is not set
239 261
240# 262#
263# Additional SuperH Device Drivers
264#
265CONFIG_PUSH_SWITCH=y
266
267#
241# Kernel features 268# Kernel features
242# 269#
243# CONFIG_HZ_100 is not set 270# CONFIG_HZ_100 is not set
244CONFIG_HZ_250=y 271CONFIG_HZ_250=y
245# CONFIG_HZ_1000 is not set 272# CONFIG_HZ_1000 is not set
246CONFIG_HZ=250 273CONFIG_HZ=250
247# CONFIG_KEXEC is not set 274CONFIG_KEXEC=y
248# CONFIG_SMP is not set 275# CONFIG_SMP is not set
249# CONFIG_PREEMPT_NONE is not set 276# CONFIG_PREEMPT_NONE is not set
250# CONFIG_PREEMPT_VOLUNTARY is not set 277# CONFIG_PREEMPT_VOLUNTARY is not set
@@ -278,10 +305,7 @@ CONFIG_PCI_AUTO_UPDATE_RESOURCES=y
278# 305#
279# PCI Hotplug Support 306# PCI Hotplug Support
280# 307#
281CONFIG_HOTPLUG_PCI=y 308# CONFIG_HOTPLUG_PCI is not set
282# CONFIG_HOTPLUG_PCI_FAKE is not set
283# CONFIG_HOTPLUG_PCI_CPCI is not set
284# CONFIG_HOTPLUG_PCI_SHPC is not set
285 309
286# 310#
287# Executable file formats 311# Executable file formats
@@ -341,6 +365,7 @@ CONFIG_INET_TCP_DIAG=y
341# CONFIG_TCP_CONG_ADVANCED is not set 365# CONFIG_TCP_CONG_ADVANCED is not set
342CONFIG_TCP_CONG_CUBIC=y 366CONFIG_TCP_CONG_CUBIC=y
343CONFIG_DEFAULT_TCP_CONG="cubic" 367CONFIG_DEFAULT_TCP_CONG="cubic"
368# CONFIG_TCP_MD5SIG is not set
344# CONFIG_IPV6 is not set 369# CONFIG_IPV6 is not set
345# CONFIG_INET6_XFRM_TUNNEL is not set 370# CONFIG_INET6_XFRM_TUNNEL is not set
346# CONFIG_INET6_TUNNEL is not set 371# CONFIG_INET6_TUNNEL is not set
@@ -556,6 +581,7 @@ CONFIG_SATA_SIL=y
556# CONFIG_PATA_IT821X is not set 581# CONFIG_PATA_IT821X is not set
557# CONFIG_PATA_JMICRON is not set 582# CONFIG_PATA_JMICRON is not set
558# CONFIG_PATA_TRIFLEX is not set 583# CONFIG_PATA_TRIFLEX is not set
584# CONFIG_PATA_MARVELL is not set
559# CONFIG_PATA_MPIIX is not set 585# CONFIG_PATA_MPIIX is not set
560# CONFIG_PATA_OLDPIIX is not set 586# CONFIG_PATA_OLDPIIX is not set
561# CONFIG_PATA_NETCELL is not set 587# CONFIG_PATA_NETCELL is not set
@@ -572,6 +598,7 @@ CONFIG_SATA_SIL=y
572# CONFIG_PATA_SIS is not set 598# CONFIG_PATA_SIS is not set
573# CONFIG_PATA_VIA is not set 599# CONFIG_PATA_VIA is not set
574# CONFIG_PATA_WINBOND is not set 600# CONFIG_PATA_WINBOND is not set
601CONFIG_PATA_PLATFORM=y
575 602
576# 603#
577# Multi-device support (RAID and LVM) 604# Multi-device support (RAID and LVM)
@@ -688,6 +715,7 @@ CONFIG_R8169=y
688# CONFIG_IXGB is not set 715# CONFIG_IXGB is not set
689# CONFIG_S2IO is not set 716# CONFIG_S2IO is not set
690# CONFIG_MYRI10GE is not set 717# CONFIG_MYRI10GE is not set
718# CONFIG_NETXEN_NIC is not set
691 719
692# 720#
693# Token Ring devices 721# Token Ring devices
@@ -830,10 +858,6 @@ CONFIG_HW_RANDOM=y
830# CONFIG_DTLK is not set 858# CONFIG_DTLK is not set
831# CONFIG_R3964 is not set 859# CONFIG_R3964 is not set
832# CONFIG_APPLICOM is not set 860# CONFIG_APPLICOM is not set
833
834#
835# Ftape, the floppy tape device driver
836#
837# CONFIG_DRM is not set 861# CONFIG_DRM is not set
838# CONFIG_RAW_DRIVER is not set 862# CONFIG_RAW_DRIVER is not set
839 863
@@ -1020,7 +1044,7 @@ CONFIG_INOTIFY_USER=y
1020CONFIG_DNOTIFY=y 1044CONFIG_DNOTIFY=y
1021# CONFIG_AUTOFS_FS is not set 1045# CONFIG_AUTOFS_FS is not set
1022# CONFIG_AUTOFS4_FS is not set 1046# CONFIG_AUTOFS4_FS is not set
1023# CONFIG_FUSE_FS is not set 1047CONFIG_FUSE_FS=m
1024 1048
1025# 1049#
1026# CD-ROM/DVD Filesystems 1050# CD-ROM/DVD Filesystems
@@ -1052,7 +1076,7 @@ CONFIG_TMPFS=y
1052CONFIG_HUGETLBFS=y 1076CONFIG_HUGETLBFS=y
1053CONFIG_HUGETLB_PAGE=y 1077CONFIG_HUGETLB_PAGE=y
1054CONFIG_RAMFS=y 1078CONFIG_RAMFS=y
1055# CONFIG_CONFIGFS_FS is not set 1079CONFIG_CONFIGFS_FS=m
1056 1080
1057# 1081#
1058# Miscellaneous filesystems 1082# Miscellaneous filesystems
@@ -1153,28 +1177,33 @@ CONFIG_NLS_ISO8859_1=y
1153# 1177#
1154# Profiling support 1178# Profiling support
1155# 1179#
1156# CONFIG_PROFILING is not set 1180CONFIG_PROFILING=y
1181CONFIG_OPROFILE=m
1157 1182
1158# 1183#
1159# Kernel hacking 1184# Kernel hacking
1160# 1185#
1161# CONFIG_PRINTK_TIME is not set 1186CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1187CONFIG_PRINTK_TIME=y
1162CONFIG_ENABLE_MUST_CHECK=y 1188CONFIG_ENABLE_MUST_CHECK=y
1163# CONFIG_MAGIC_SYSRQ is not set 1189CONFIG_MAGIC_SYSRQ=y
1164# CONFIG_UNUSED_SYMBOLS is not set 1190# CONFIG_UNUSED_SYMBOLS is not set
1165CONFIG_DEBUG_KERNEL=y 1191CONFIG_DEBUG_KERNEL=y
1166CONFIG_LOG_BUF_SHIFT=14 1192CONFIG_LOG_BUF_SHIFT=14
1167CONFIG_DETECT_SOFTLOCKUP=y 1193CONFIG_DETECT_SOFTLOCKUP=y
1168# CONFIG_SCHEDSTATS is not set 1194# CONFIG_SCHEDSTATS is not set
1169# CONFIG_DEBUG_SLAB is not set 1195# CONFIG_DEBUG_SLAB is not set
1170CONFIG_DEBUG_SPINLOCK=y 1196# CONFIG_DEBUG_PREEMPT is not set
1197# CONFIG_DEBUG_SPINLOCK is not set
1171# CONFIG_DEBUG_MUTEXES is not set 1198# CONFIG_DEBUG_MUTEXES is not set
1172# CONFIG_DEBUG_RWSEMS is not set 1199# CONFIG_DEBUG_RWSEMS is not set
1200# CONFIG_DEBUG_LOCK_ALLOC is not set
1201# CONFIG_PROVE_LOCKING is not set
1173# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 1202# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1174# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set 1203# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1175# CONFIG_DEBUG_KOBJECT is not set 1204# CONFIG_DEBUG_KOBJECT is not set
1176# CONFIG_DEBUG_BUGVERBOSE is not set 1205CONFIG_DEBUG_BUGVERBOSE=y
1177# CONFIG_DEBUG_INFO is not set 1206CONFIG_DEBUG_INFO=y
1178CONFIG_DEBUG_FS=y 1207CONFIG_DEBUG_FS=y
1179# CONFIG_DEBUG_VM is not set 1208# CONFIG_DEBUG_VM is not set
1180# CONFIG_DEBUG_LIST is not set 1209# CONFIG_DEBUG_LIST is not set
@@ -1184,7 +1213,7 @@ CONFIG_FORCED_INLINING=y
1184# CONFIG_RCU_TORTURE_TEST is not set 1213# CONFIG_RCU_TORTURE_TEST is not set
1185# CONFIG_SH_STANDARD_BIOS is not set 1214# CONFIG_SH_STANDARD_BIOS is not set
1186# CONFIG_EARLY_SCIF_CONSOLE is not set 1215# CONFIG_EARLY_SCIF_CONSOLE is not set
1187# CONFIG_DEBUG_STACKOVERFLOW is not set 1216CONFIG_DEBUG_STACKOVERFLOW=y
1188# CONFIG_DEBUG_STACK_USAGE is not set 1217# CONFIG_DEBUG_STACK_USAGE is not set
1189# CONFIG_4KSTACKS is not set 1218# CONFIG_4KSTACKS is not set
1190# CONFIG_KGDB is not set 1219# CONFIG_KGDB is not set
diff --git a/arch/sh/configs/se7206_defconfig b/arch/sh/configs/se7206_defconfig
new file mode 100644
index 000000000000..36cec0b6e7c1
--- /dev/null
+++ b/arch/sh/configs/se7206_defconfig
@@ -0,0 +1,826 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.19-rc4
4# Sun Nov 5 16:20:10 2006
5#
6CONFIG_SUPERH=y
7CONFIG_RWSEM_GENERIC_SPINLOCK=y
8CONFIG_GENERIC_FIND_NEXT_BIT=y
9CONFIG_GENERIC_HWEIGHT=y
10CONFIG_GENERIC_HARDIRQS=y
11CONFIG_GENERIC_IRQ_PROBE=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y
13# CONFIG_GENERIC_TIME is not set
14CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
15
16#
17# Code maturity level options
18#
19CONFIG_EXPERIMENTAL=y
20CONFIG_BROKEN_ON_SMP=y
21CONFIG_INIT_ENV_ARG_LIMIT=32
22
23#
24# General setup
25#
26CONFIG_LOCALVERSION=""
27# CONFIG_LOCALVERSION_AUTO is not set
28# CONFIG_SYSVIPC is not set
29# CONFIG_POSIX_MQUEUE is not set
30# CONFIG_BSD_PROCESS_ACCT is not set
31# CONFIG_TASKSTATS is not set
32# CONFIG_UTS_NS is not set
33# CONFIG_AUDIT is not set
34# CONFIG_IKCONFIG is not set
35# CONFIG_RELAY is not set
36CONFIG_INITRAMFS_SOURCE=""
37# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
38CONFIG_SYSCTL=y
39CONFIG_EMBEDDED=y
40CONFIG_UID16=y
41# CONFIG_SYSCTL_SYSCALL is not set
42CONFIG_KALLSYMS=y
43# CONFIG_KALLSYMS_EXTRA_PASS is not set
44# CONFIG_HOTPLUG is not set
45CONFIG_PRINTK=y
46CONFIG_BUG=y
47CONFIG_ELF_CORE=y
48CONFIG_BASE_FULL=y
49# CONFIG_FUTEX is not set
50# CONFIG_EPOLL is not set
51CONFIG_SLAB=y
52CONFIG_VM_EVENT_COUNTERS=y
53CONFIG_TINY_SHMEM=y
54CONFIG_BASE_SMALL=0
55# CONFIG_SLOB is not set
56
57#
58# Loadable module support
59#
60# CONFIG_MODULES is not set
61
62#
63# Block layer
64#
65CONFIG_BLOCK=y
66# CONFIG_LBD is not set
67# CONFIG_LSF is not set
68
69#
70# IO Schedulers
71#
72CONFIG_IOSCHED_NOOP=y
73# CONFIG_IOSCHED_AS is not set
74# CONFIG_IOSCHED_DEADLINE is not set
75# CONFIG_IOSCHED_CFQ is not set
76# CONFIG_DEFAULT_AS is not set
77# CONFIG_DEFAULT_DEADLINE is not set
78# CONFIG_DEFAULT_CFQ is not set
79CONFIG_DEFAULT_NOOP=y
80CONFIG_DEFAULT_IOSCHED="noop"
81
82#
83# System type
84#
85# CONFIG_SH_SOLUTION_ENGINE is not set
86# CONFIG_SH_7751_SOLUTION_ENGINE is not set
87# CONFIG_SH_7300_SOLUTION_ENGINE is not set
88# CONFIG_SH_7343_SOLUTION_ENGINE is not set
89# CONFIG_SH_73180_SOLUTION_ENGINE is not set
90# CONFIG_SH_7751_SYSTEMH is not set
91# CONFIG_SH_HP6XX is not set
92# CONFIG_SH_EC3104 is not set
93# CONFIG_SH_SATURN is not set
94# CONFIG_SH_DREAMCAST is not set
95# CONFIG_SH_BIGSUR is not set
96# CONFIG_SH_MPC1211 is not set
97# CONFIG_SH_SH03 is not set
98# CONFIG_SH_SECUREEDGE5410 is not set
99# CONFIG_SH_HS7751RVOIP is not set
100# CONFIG_SH_7710VOIPGW is not set
101# CONFIG_SH_RTS7751R2D is not set
102# CONFIG_SH_R7780RP is not set
103# CONFIG_SH_EDOSK7705 is not set
104# CONFIG_SH_SH4202_MICRODEV is not set
105# CONFIG_SH_LANDISK is not set
106# CONFIG_SH_TITAN is not set
107# CONFIG_SH_SHMIN is not set
108CONFIG_SH_7206_SOLUTION_ENGINE=y
109# CONFIG_SH_7619_SOLUTION_ENGINE is not set
110# CONFIG_SH_UNKNOWN is not set
111
112#
113# Processor selection
114#
115CONFIG_CPU_SH2=y
116CONFIG_CPU_SH2A=y
117
118#
119# SH-2 Processor Support
120#
121# CONFIG_CPU_SUBTYPE_SH7604 is not set
122# CONFIG_CPU_SUBTYPE_SH7619 is not set
123
124#
125# SH-2A Processor Support
126#
127CONFIG_CPU_SUBTYPE_SH7206=y
128
129#
130# SH-3 Processor Support
131#
132# CONFIG_CPU_SUBTYPE_SH7300 is not set
133# CONFIG_CPU_SUBTYPE_SH7705 is not set
134# CONFIG_CPU_SUBTYPE_SH7706 is not set
135# CONFIG_CPU_SUBTYPE_SH7707 is not set
136# CONFIG_CPU_SUBTYPE_SH7708 is not set
137# CONFIG_CPU_SUBTYPE_SH7709 is not set
138# CONFIG_CPU_SUBTYPE_SH7710 is not set
139
140#
141# SH-4 Processor Support
142#
143# CONFIG_CPU_SUBTYPE_SH7750 is not set
144# CONFIG_CPU_SUBTYPE_SH7091 is not set
145# CONFIG_CPU_SUBTYPE_SH7750R is not set
146# CONFIG_CPU_SUBTYPE_SH7750S is not set
147# CONFIG_CPU_SUBTYPE_SH7751 is not set
148# CONFIG_CPU_SUBTYPE_SH7751R is not set
149# CONFIG_CPU_SUBTYPE_SH7760 is not set
150# CONFIG_CPU_SUBTYPE_SH4_202 is not set
151
152#
153# ST40 Processor Support
154#
155# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
156# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
157
158#
159# SH-4A Processor Support
160#
161# CONFIG_CPU_SUBTYPE_SH7770 is not set
162# CONFIG_CPU_SUBTYPE_SH7780 is not set
163
164#
165# SH4AL-DSP Processor Support
166#
167# CONFIG_CPU_SUBTYPE_SH73180 is not set
168# CONFIG_CPU_SUBTYPE_SH7343 is not set
169
170#
171# Memory management options
172#
173CONFIG_PAGE_OFFSET=0x00000000
174CONFIG_MEMORY_START=0x0c000000
175CONFIG_MEMORY_SIZE=0x02000000
176CONFIG_SELECT_MEMORY_MODEL=y
177CONFIG_FLATMEM_MANUAL=y
178# CONFIG_DISCONTIGMEM_MANUAL is not set
179# CONFIG_SPARSEMEM_MANUAL is not set
180CONFIG_FLATMEM=y
181CONFIG_FLAT_NODE_MEM_MAP=y
182# CONFIG_SPARSEMEM_STATIC is not set
183CONFIG_SPLIT_PTLOCK_CPUS=4
184# CONFIG_RESOURCES_64BIT is not set
185
186#
187# Cache configuration
188#
189# CONFIG_SH_DIRECT_MAPPED is not set
190# CONFIG_SH_WRITETHROUGH is not set
191# CONFIG_SH_OCRAM is not set
192
193#
194# Processor features
195#
196# CONFIG_CPU_LITTLE_ENDIAN is not set
197# CONFIG_SH_FPU is not set
198# CONFIG_SH_FPU_EMU is not set
199# CONFIG_SH_DSP is not set
200
201#
202# Timer support
203#
204CONFIG_SH_CMT=y
205# CONFIG_SH_MTU2 is not set
206CONFIG_SH_PCLK_FREQ=33333333
207CONFIG_SH_CLK_MD=6
208
209#
210# CPU Frequency scaling
211#
212# CONFIG_CPU_FREQ is not set
213
214#
215# DMA support
216#
217# CONFIG_SH_DMA is not set
218
219#
220# Companion Chips
221#
222# CONFIG_HD6446X_SERIES is not set
223
224#
225# Kernel features
226#
227CONFIG_HZ_100=y
228# CONFIG_HZ_250 is not set
229# CONFIG_HZ_1000 is not set
230CONFIG_HZ=100
231# CONFIG_KEXEC is not set
232# CONFIG_SMP is not set
233CONFIG_PREEMPT_NONE=y
234# CONFIG_PREEMPT_VOLUNTARY is not set
235# CONFIG_PREEMPT is not set
236
237#
238# Boot options
239#
240CONFIG_ZERO_PAGE_OFFSET=0x00001000
241CONFIG_BOOT_LINK_OFFSET=0x00800000
242# CONFIG_UBC_WAKEUP is not set
243# CONFIG_CMDLINE_BOOL is not set
244
245#
246# Bus options
247#
248# CONFIG_PCI is not set
249
250#
251# PCCARD (PCMCIA/CardBus) support
252#
253
254#
255# PCI Hotplug Support
256#
257
258#
259# Executable file formats
260#
261CONFIG_BINFMT_FLAT=y
262CONFIG_BINFMT_ZFLAT=y
263# CONFIG_BINFMT_SHARED_FLAT is not set
264# CONFIG_BINFMT_MISC is not set
265
266#
267# Power management options (EXPERIMENTAL)
268#
269# CONFIG_PM is not set
270
271#
272# Networking
273#
274CONFIG_NET=y
275
276#
277# Networking options
278#
279# CONFIG_NETDEBUG is not set
280# CONFIG_PACKET is not set
281# CONFIG_UNIX is not set
282CONFIG_XFRM=y
283# CONFIG_XFRM_USER is not set
284# CONFIG_XFRM_SUB_POLICY is not set
285# CONFIG_NET_KEY is not set
286CONFIG_INET=y
287# CONFIG_IP_MULTICAST is not set
288# CONFIG_IP_ADVANCED_ROUTER is not set
289CONFIG_IP_FIB_HASH=y
290# CONFIG_IP_PNP is not set
291# CONFIG_NET_IPIP is not set
292# CONFIG_NET_IPGRE is not set
293# CONFIG_ARPD is not set
294# CONFIG_SYN_COOKIES is not set
295# CONFIG_INET_AH is not set
296# CONFIG_INET_ESP is not set
297# CONFIG_INET_IPCOMP is not set
298# CONFIG_INET_XFRM_TUNNEL is not set
299# CONFIG_INET_TUNNEL is not set
300CONFIG_INET_XFRM_MODE_TRANSPORT=y
301CONFIG_INET_XFRM_MODE_TUNNEL=y
302CONFIG_INET_XFRM_MODE_BEET=y
303# CONFIG_INET_DIAG is not set
304# CONFIG_TCP_CONG_ADVANCED is not set
305CONFIG_TCP_CONG_CUBIC=y
306CONFIG_DEFAULT_TCP_CONG="cubic"
307# CONFIG_IPV6 is not set
308# CONFIG_INET6_XFRM_TUNNEL is not set
309# CONFIG_INET6_TUNNEL is not set
310# CONFIG_NETWORK_SECMARK is not set
311# CONFIG_NETFILTER is not set
312
313#
314# DCCP Configuration (EXPERIMENTAL)
315#
316# CONFIG_IP_DCCP is not set
317
318#
319# SCTP Configuration (EXPERIMENTAL)
320#
321# CONFIG_IP_SCTP is not set
322
323#
324# TIPC Configuration (EXPERIMENTAL)
325#
326# CONFIG_TIPC is not set
327# CONFIG_ATM is not set
328# CONFIG_BRIDGE is not set
329# CONFIG_VLAN_8021Q is not set
330# CONFIG_DECNET is not set
331# CONFIG_LLC2 is not set
332# CONFIG_IPX is not set
333# CONFIG_ATALK is not set
334# CONFIG_X25 is not set
335# CONFIG_LAPB is not set
336# CONFIG_ECONET is not set
337# CONFIG_WAN_ROUTER is not set
338
339#
340# QoS and/or fair queueing
341#
342# CONFIG_NET_SCHED is not set
343
344#
345# Network testing
346#
347# CONFIG_NET_PKTGEN is not set
348# CONFIG_HAMRADIO is not set
349# CONFIG_IRDA is not set
350# CONFIG_BT is not set
351# CONFIG_IEEE80211 is not set
352
353#
354# Device Drivers
355#
356
357#
358# Generic Driver Options
359#
360# CONFIG_STANDALONE is not set
361# CONFIG_PREVENT_FIRMWARE_BUILD is not set
362# CONFIG_SYS_HYPERVISOR is not set
363
364#
365# Connector - unified userspace <-> kernelspace linker
366#
367# CONFIG_CONNECTOR is not set
368
369#
370# Memory Technology Devices (MTD)
371#
372CONFIG_MTD=y
373# CONFIG_MTD_DEBUG is not set
374# CONFIG_MTD_CONCAT is not set
375CONFIG_MTD_PARTITIONS=y
376CONFIG_MTD_REDBOOT_PARTS=y
377CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
378# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
379# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
380# CONFIG_MTD_CMDLINE_PARTS is not set
381
382#
383# User Modules And Translation Layers
384#
385CONFIG_MTD_CHAR=y
386CONFIG_MTD_BLOCK=y
387# CONFIG_FTL is not set
388# CONFIG_NFTL is not set
389# CONFIG_INFTL is not set
390# CONFIG_RFD_FTL is not set
391# CONFIG_SSFDC is not set
392
393#
394# RAM/ROM/Flash chip drivers
395#
396CONFIG_MTD_CFI=y
397# CONFIG_MTD_JEDECPROBE is not set
398CONFIG_MTD_GEN_PROBE=y
399# CONFIG_MTD_CFI_ADV_OPTIONS is not set
400CONFIG_MTD_MAP_BANK_WIDTH_1=y
401CONFIG_MTD_MAP_BANK_WIDTH_2=y
402CONFIG_MTD_MAP_BANK_WIDTH_4=y
403# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
404# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
405# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
406CONFIG_MTD_CFI_I1=y
407CONFIG_MTD_CFI_I2=y
408# CONFIG_MTD_CFI_I4 is not set
409# CONFIG_MTD_CFI_I8 is not set
410# CONFIG_MTD_CFI_INTELEXT is not set
411CONFIG_MTD_CFI_AMDSTD=y
412# CONFIG_MTD_CFI_STAA is not set
413CONFIG_MTD_CFI_UTIL=y
414# CONFIG_MTD_RAM is not set
415# CONFIG_MTD_ROM is not set
416# CONFIG_MTD_ABSENT is not set
417# CONFIG_MTD_OBSOLETE_CHIPS is not set
418
419#
420# Mapping drivers for chip access
421#
422# CONFIG_MTD_COMPLEX_MAPPINGS is not set
423CONFIG_MTD_PHYSMAP=y
424CONFIG_MTD_PHYSMAP_START=0x20000000
425CONFIG_MTD_PHYSMAP_LEN=0x1000000
426CONFIG_MTD_PHYSMAP_BANKWIDTH=4
427# CONFIG_MTD_SOLUTIONENGINE is not set
428# CONFIG_MTD_UCLINUX is not set
429# CONFIG_MTD_PLATRAM is not set
430
431#
432# Self-contained MTD device drivers
433#
434# CONFIG_MTD_SLRAM is not set
435# CONFIG_MTD_PHRAM is not set
436# CONFIG_MTD_MTDRAM is not set
437# CONFIG_MTD_BLOCK2MTD is not set
438
439#
440# Disk-On-Chip Device Drivers
441#
442# CONFIG_MTD_DOC2000 is not set
443# CONFIG_MTD_DOC2001 is not set
444# CONFIG_MTD_DOC2001PLUS is not set
445
446#
447# NAND Flash Device Drivers
448#
449# CONFIG_MTD_NAND is not set
450
451#
452# OneNAND Flash Device Drivers
453#
454# CONFIG_MTD_ONENAND is not set
455
456#
457# Parallel port support
458#
459# CONFIG_PARPORT is not set
460
461#
462# Plug and Play support
463#
464
465#
466# Block devices
467#
468# CONFIG_BLK_DEV_COW_COMMON is not set
469# CONFIG_BLK_DEV_LOOP is not set
470# CONFIG_BLK_DEV_NBD is not set
471CONFIG_BLK_DEV_RAM=y
472CONFIG_BLK_DEV_RAM_COUNT=16
473CONFIG_BLK_DEV_RAM_SIZE=4096
474CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
475# CONFIG_BLK_DEV_INITRD is not set
476# CONFIG_CDROM_PKTCDVD is not set
477# CONFIG_ATA_OVER_ETH is not set
478
479#
480# Misc devices
481#
482# CONFIG_TIFM_CORE is not set
483
484#
485# ATA/ATAPI/MFM/RLL support
486#
487# CONFIG_IDE is not set
488
489#
490# SCSI device support
491#
492# CONFIG_RAID_ATTRS is not set
493# CONFIG_SCSI is not set
494# CONFIG_SCSI_NETLINK is not set
495
496#
497# Serial ATA (prod) and Parallel ATA (experimental) drivers
498#
499# CONFIG_ATA is not set
500
501#
502# Multi-device support (RAID and LVM)
503#
504# CONFIG_MD is not set
505
506#
507# Fusion MPT device support
508#
509# CONFIG_FUSION is not set
510
511#
512# IEEE 1394 (FireWire) support
513#
514
515#
516# I2O device support
517#
518
519#
520# Network device support
521#
522# CONFIG_NETDEVICES is not set
523# CONFIG_NETPOLL is not set
524# CONFIG_NET_POLL_CONTROLLER is not set
525
526#
527# ISDN subsystem
528#
529# CONFIG_ISDN is not set
530
531#
532# Telephony Support
533#
534# CONFIG_PHONE is not set
535
536#
537# Input device support
538#
539# CONFIG_INPUT is not set
540
541#
542# Hardware I/O ports
543#
544# CONFIG_SERIO is not set
545# CONFIG_GAMEPORT is not set
546
547#
548# Character devices
549#
550# CONFIG_VT is not set
551# CONFIG_SERIAL_NONSTANDARD is not set
552
553#
554# Serial drivers
555#
556# CONFIG_SERIAL_8250 is not set
557
558#
559# Non-8250 serial port support
560#
561CONFIG_SERIAL_SH_SCI=y
562CONFIG_SERIAL_SH_SCI_NR_UARTS=4
563CONFIG_SERIAL_SH_SCI_CONSOLE=y
564CONFIG_SERIAL_CORE=y
565CONFIG_SERIAL_CORE_CONSOLE=y
566# CONFIG_UNIX98_PTYS is not set
567CONFIG_LEGACY_PTYS=y
568CONFIG_LEGACY_PTY_COUNT=256
569
570#
571# IPMI
572#
573# CONFIG_IPMI_HANDLER is not set
574
575#
576# Watchdog Cards
577#
578# CONFIG_WATCHDOG is not set
579CONFIG_HW_RANDOM=y
580# CONFIG_GEN_RTC is not set
581# CONFIG_DTLK is not set
582# CONFIG_R3964 is not set
583
584#
585# Ftape, the floppy tape device driver
586#
587# CONFIG_RAW_DRIVER is not set
588
589#
590# TPM devices
591#
592# CONFIG_TCG_TPM is not set
593
594#
595# I2C support
596#
597# CONFIG_I2C is not set
598
599#
600# SPI support
601#
602# CONFIG_SPI is not set
603# CONFIG_SPI_MASTER is not set
604
605#
606# Dallas's 1-wire bus
607#
608# CONFIG_W1 is not set
609
610#
611# Hardware Monitoring support
612#
613CONFIG_HWMON=y
614# CONFIG_HWMON_VID is not set
615# CONFIG_SENSORS_ABITUGURU is not set
616# CONFIG_SENSORS_F71805F is not set
617# CONFIG_SENSORS_VT1211 is not set
618# CONFIG_HWMON_DEBUG_CHIP is not set
619
620#
621# Multimedia devices
622#
623# CONFIG_VIDEO_DEV is not set
624
625#
626# Digital Video Broadcasting Devices
627#
628# CONFIG_DVB is not set
629
630#
631# Graphics support
632#
633CONFIG_FIRMWARE_EDID=y
634# CONFIG_FB is not set
635
636#
637# Sound
638#
639# CONFIG_SOUND is not set
640
641#
642# USB support
643#
644# CONFIG_USB_ARCH_HAS_HCD is not set
645# CONFIG_USB_ARCH_HAS_OHCI is not set
646# CONFIG_USB_ARCH_HAS_EHCI is not set
647
648#
649# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
650#
651
652#
653# USB Gadget Support
654#
655# CONFIG_USB_GADGET is not set
656
657#
658# MMC/SD Card support
659#
660# CONFIG_MMC is not set
661
662#
663# LED devices
664#
665# CONFIG_NEW_LEDS is not set
666
667#
668# LED drivers
669#
670
671#
672# LED Triggers
673#
674
675#
676# InfiniBand support
677#
678
679#
680# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
681#
682
683#
684# Real Time Clock
685#
686# CONFIG_RTC_CLASS is not set
687
688#
689# DMA Engine support
690#
691# CONFIG_DMA_ENGINE is not set
692
693#
694# DMA Clients
695#
696
697#
698# DMA Devices
699#
700
701#
702# File systems
703#
704CONFIG_EXT2_FS=y
705# CONFIG_EXT2_FS_XATTR is not set
706# CONFIG_EXT3_FS is not set
707# CONFIG_EXT4DEV_FS is not set
708# CONFIG_REISERFS_FS is not set
709# CONFIG_JFS_FS is not set
710# CONFIG_FS_POSIX_ACL is not set
711# CONFIG_XFS_FS is not set
712# CONFIG_GFS2_FS is not set
713# CONFIG_MINIX_FS is not set
714CONFIG_ROMFS_FS=y
715# CONFIG_INOTIFY is not set
716# CONFIG_QUOTA is not set
717# CONFIG_DNOTIFY is not set
718# CONFIG_AUTOFS_FS is not set
719# CONFIG_AUTOFS4_FS is not set
720# CONFIG_FUSE_FS is not set
721
722#
723# CD-ROM/DVD Filesystems
724#
725# CONFIG_ISO9660_FS is not set
726# CONFIG_UDF_FS is not set
727
728#
729# DOS/FAT/NT Filesystems
730#
731# CONFIG_MSDOS_FS is not set
732# CONFIG_VFAT_FS is not set
733# CONFIG_NTFS_FS is not set
734
735#
736# Pseudo filesystems
737#
738CONFIG_PROC_FS=y
739CONFIG_PROC_SYSCTL=y
740# CONFIG_SYSFS is not set
741# CONFIG_TMPFS is not set
742# CONFIG_HUGETLBFS is not set
743# CONFIG_HUGETLB_PAGE is not set
744CONFIG_RAMFS=y
745
746#
747# Miscellaneous filesystems
748#
749# CONFIG_ADFS_FS is not set
750# CONFIG_AFFS_FS is not set
751# CONFIG_HFS_FS is not set
752# CONFIG_HFSPLUS_FS is not set
753# CONFIG_BEFS_FS is not set
754# CONFIG_BFS_FS is not set
755# CONFIG_EFS_FS is not set
756# CONFIG_JFFS_FS is not set
757# CONFIG_JFFS2_FS is not set
758CONFIG_CRAMFS=y
759# CONFIG_VXFS_FS is not set
760# CONFIG_HPFS_FS is not set
761# CONFIG_QNX4FS_FS is not set
762# CONFIG_SYSV_FS is not set
763# CONFIG_UFS_FS is not set
764
765#
766# Network File Systems
767#
768# CONFIG_NFS_FS is not set
769# CONFIG_NFSD is not set
770# CONFIG_SMB_FS is not set
771# CONFIG_CIFS is not set
772# CONFIG_NCP_FS is not set
773# CONFIG_CODA_FS is not set
774# CONFIG_AFS_FS is not set
775# CONFIG_9P_FS is not set
776
777#
778# Partition Types
779#
780# CONFIG_PARTITION_ADVANCED is not set
781CONFIG_MSDOS_PARTITION=y
782
783#
784# Native Language Support
785#
786# CONFIG_NLS is not set
787
788#
789# Profiling support
790#
791# CONFIG_PROFILING is not set
792
793#
794# Kernel hacking
795#
796# CONFIG_PRINTK_TIME is not set
797CONFIG_ENABLE_MUST_CHECK=y
798# CONFIG_MAGIC_SYSRQ is not set
799# CONFIG_UNUSED_SYMBOLS is not set
800# CONFIG_DEBUG_KERNEL is not set
801CONFIG_LOG_BUF_SHIFT=14
802# CONFIG_DEBUG_BUGVERBOSE is not set
803# CONFIG_UNWIND_INFO is not set
804# CONFIG_HEADERS_CHECK is not set
805# CONFIG_SH_STANDARD_BIOS is not set
806# CONFIG_EARLY_SCIF_CONSOLE is not set
807# CONFIG_KGDB is not set
808
809#
810# Security options
811#
812# CONFIG_KEYS is not set
813
814#
815# Cryptographic options
816#
817# CONFIG_CRYPTO is not set
818
819#
820# Library routines
821#
822CONFIG_CRC_CCITT=y
823# CONFIG_CRC16 is not set
824CONFIG_CRC32=y
825# CONFIG_LIBCRC32C is not set
826CONFIG_ZLIB_INFLATE=y
diff --git a/arch/sh/drivers/Kconfig b/arch/sh/drivers/Kconfig
new file mode 100644
index 000000000000..c54c758e6243
--- /dev/null
+++ b/arch/sh/drivers/Kconfig
@@ -0,0 +1,9 @@
1menu "Additional SuperH Device Drivers"
2
3config PUSH_SWITCH
4 tristate "Push switch support"
5 help
6 This enables support for the push switch framework, a simple
7 framework that allows for sysfs driven switch status reporting.
8
9endmenu
diff --git a/arch/sh/drivers/Makefile b/arch/sh/drivers/Makefile
index 338c3729d270..bf18dbfb6787 100644
--- a/arch/sh/drivers/Makefile
+++ b/arch/sh/drivers/Makefile
@@ -5,4 +5,4 @@
5obj-$(CONFIG_PCI) += pci/ 5obj-$(CONFIG_PCI) += pci/
6obj-$(CONFIG_SH_DMA) += dma/ 6obj-$(CONFIG_SH_DMA) += dma/
7obj-$(CONFIG_SUPERHYWAY) += superhyway/ 7obj-$(CONFIG_SUPERHYWAY) += superhyway/
8 8obj-$(CONFIG_PUSH_SWITCH) += push-switch.o
diff --git a/arch/sh/drivers/dma/Makefile b/arch/sh/drivers/dma/Makefile
index 065d4c90970e..db1295d32268 100644
--- a/arch/sh/drivers/dma/Makefile
+++ b/arch/sh/drivers/dma/Makefile
@@ -2,8 +2,8 @@
2# Makefile for the SuperH DMA specific kernel interface routines under Linux. 2# Makefile for the SuperH DMA specific kernel interface routines under Linux.
3# 3#
4 4
5obj-y += dma-api.o dma-isa.o 5obj-y += dma-api.o
6obj-$(CONFIG_ISA_DMA_API) += dma-isa.o
6obj-$(CONFIG_SYSFS) += dma-sysfs.o 7obj-$(CONFIG_SYSFS) += dma-sysfs.o
7obj-$(CONFIG_SH_DMA) += dma-sh.o 8obj-$(CONFIG_SH_DMA) += dma-sh.o
8obj-$(CONFIG_SH_DREAMCAST) += dma-pvr2.o dma-g2.o 9obj-$(CONFIG_SH_DREAMCAST) += dma-pvr2.o dma-g2.o
9
diff --git a/arch/sh/drivers/dma/dma-api.c b/arch/sh/drivers/dma/dma-api.c
index 47c3e837599b..e062067edd24 100644
--- a/arch/sh/drivers/dma/dma-api.c
+++ b/arch/sh/drivers/dma/dma-api.c
@@ -11,61 +11,27 @@
11 */ 11 */
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/interrupt.h>
15#include <linux/spinlock.h> 14#include <linux/spinlock.h>
16#include <linux/proc_fs.h> 15#include <linux/proc_fs.h>
17#include <linux/list.h> 16#include <linux/list.h>
18#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/mm.h>
19#include <asm/dma.h> 19#include <asm/dma.h>
20 20
21DEFINE_SPINLOCK(dma_spin_lock); 21DEFINE_SPINLOCK(dma_spin_lock);
22static LIST_HEAD(registered_dmac_list); 22static LIST_HEAD(registered_dmac_list);
23 23
24/*
25 * A brief note about the reasons for this API as it stands.
26 *
27 * For starters, the old ISA DMA API didn't work for us for a number of
28 * reasons, for one, the vast majority of channels on the SH DMAC are
29 * dual-address mode only, and both the new and the old DMA APIs are after the
30 * concept of managing a DMA buffer, which doesn't overly fit this model very
31 * well. In addition to which, the new API is largely geared at IOMMUs and
32 * GARTs, and doesn't even support the channel notion very well.
33 *
34 * The other thing that's a marginal issue, is the sheer number of random DMA
35 * engines that are present (ie, in boards like the Dreamcast), some of which
36 * cascade off of the SH DMAC, and others do not. As such, there was a real
37 * need for a scalable subsystem that could deal with both single and
38 * dual-address mode usage, in addition to interoperating with cascaded DMACs.
39 *
40 * There really isn't any reason why this needs to be SH specific, though I'm
41 * not aware of too many other processors (with the exception of some MIPS)
42 * that have the same concept of a dual address mode, or any real desire to
43 * actually make use of the DMAC even if such a subsystem were exposed
44 * elsewhere.
45 *
46 * The idea for this was derived from the ARM port, which acted as an excellent
47 * reference when trying to address these issues.
48 *
49 * It should also be noted that the decision to add Yet Another DMA API(tm) to
50 * the kernel wasn't made easily, and was only decided upon after conferring
51 * with jejb with regards to the state of the old and new APIs as they applied
52 * to these circumstances. Philip Blundell was also a great help in figuring
53 * out some single-address mode DMA semantics that were otherwise rather
54 * confusing.
55 */
56
57struct dma_info *get_dma_info(unsigned int chan) 24struct dma_info *get_dma_info(unsigned int chan)
58{ 25{
59 struct dma_info *info; 26 struct dma_info *info;
60 unsigned int total = 0;
61 27
62 /* 28 /*
63 * Look for each DMAC's range to determine who the owner of 29 * Look for each DMAC's range to determine who the owner of
64 * the channel is. 30 * the channel is.
65 */ 31 */
66 list_for_each_entry(info, &registered_dmac_list, list) { 32 list_for_each_entry(info, &registered_dmac_list, list) {
67 total += info->nr_channels; 33 if ((chan < info->first_channel_nr) ||
68 if (chan > total) 34 (chan >= info->first_channel_nr + info->nr_channels))
69 continue; 35 continue;
70 36
71 return info; 37 return info;
@@ -73,6 +39,22 @@ struct dma_info *get_dma_info(unsigned int chan)
73 39
74 return NULL; 40 return NULL;
75} 41}
42EXPORT_SYMBOL(get_dma_info);
43
44struct dma_info *get_dma_info_by_name(const char *dmac_name)
45{
46 struct dma_info *info;
47
48 list_for_each_entry(info, &registered_dmac_list, list) {
49 if (dmac_name && (strcmp(dmac_name, info->name) != 0))
50 continue;
51 else
52 return info;
53 }
54
55 return NULL;
56}
57EXPORT_SYMBOL(get_dma_info_by_name);
76 58
77static unsigned int get_nr_channels(void) 59static unsigned int get_nr_channels(void)
78{ 60{
@@ -91,63 +73,161 @@ static unsigned int get_nr_channels(void)
91struct dma_channel *get_dma_channel(unsigned int chan) 73struct dma_channel *get_dma_channel(unsigned int chan)
92{ 74{
93 struct dma_info *info = get_dma_info(chan); 75 struct dma_info *info = get_dma_info(chan);
76 struct dma_channel *channel;
77 int i;
94 78
95 if (!info) 79 if (unlikely(!info))
96 return ERR_PTR(-EINVAL); 80 return ERR_PTR(-EINVAL);
97 81
98 return info->channels + chan; 82 for (i = 0; i < info->nr_channels; i++) {
83 channel = &info->channels[i];
84 if (channel->chan == chan)
85 return channel;
86 }
87
88 return NULL;
99} 89}
90EXPORT_SYMBOL(get_dma_channel);
100 91
101int get_dma_residue(unsigned int chan) 92int get_dma_residue(unsigned int chan)
102{ 93{
103 struct dma_info *info = get_dma_info(chan); 94 struct dma_info *info = get_dma_info(chan);
104 struct dma_channel *channel = &info->channels[chan]; 95 struct dma_channel *channel = get_dma_channel(chan);
105 96
106 if (info->ops->get_residue) 97 if (info->ops->get_residue)
107 return info->ops->get_residue(channel); 98 return info->ops->get_residue(channel);
108 99
109 return 0; 100 return 0;
110} 101}
102EXPORT_SYMBOL(get_dma_residue);
111 103
112int request_dma(unsigned int chan, const char *dev_id) 104static int search_cap(const char **haystack, const char *needle)
113{ 105{
114 struct dma_info *info = get_dma_info(chan); 106 const char **p;
115 struct dma_channel *channel = &info->channels[chan]; 107
108 for (p = haystack; *p; p++)
109 if (strcmp(*p, needle) == 0)
110 return 1;
111
112 return 0;
113}
114
115/**
116 * request_dma_bycap - Allocate a DMA channel based on its capabilities
117 * @dmac: List of DMA controllers to search
118 * @caps: List of capabilites
119 *
120 * Search all channels of all DMA controllers to find a channel which
121 * matches the requested capabilities. The result is the channel
122 * number if a match is found, or %-ENODEV if no match is found.
123 *
124 * Note that not all DMA controllers export capabilities, in which
125 * case they can never be allocated using this API, and so
126 * request_dma() must be used specifying the channel number.
127 */
128int request_dma_bycap(const char **dmac, const char **caps, const char *dev_id)
129{
130 unsigned int found = 0;
131 struct dma_info *info;
132 const char **p;
133 int i;
134
135 BUG_ON(!dmac || !caps);
136
137 list_for_each_entry(info, &registered_dmac_list, list)
138 if (strcmp(*dmac, info->name) == 0) {
139 found = 1;
140 break;
141 }
142
143 if (!found)
144 return -ENODEV;
145
146 for (i = 0; i < info->nr_channels; i++) {
147 struct dma_channel *channel = &info->channels[i];
148
149 if (unlikely(!channel->caps))
150 continue;
151
152 for (p = caps; *p; p++) {
153 if (!search_cap(channel->caps, *p))
154 break;
155 if (request_dma(channel->chan, dev_id) == 0)
156 return channel->chan;
157 }
158 }
159
160 return -EINVAL;
161}
162EXPORT_SYMBOL(request_dma_bycap);
163
164int dmac_search_free_channel(const char *dev_id)
165{
166 struct dma_channel *channel = { 0 };
167 struct dma_info *info = get_dma_info(0);
168 int i;
169
170 for (i = 0; i < info->nr_channels; i++) {
171 channel = &info->channels[i];
172 if (unlikely(!channel))
173 return -ENODEV;
174
175 if (atomic_read(&channel->busy) == 0)
176 break;
177 }
116 178
117 down(&channel->sem); 179 if (info->ops->request) {
180 int result = info->ops->request(channel);
181 if (result)
182 return result;
118 183
119 if (!info->ops || chan >= MAX_DMA_CHANNELS) { 184 atomic_set(&channel->busy, 1);
120 up(&channel->sem); 185 return channel->chan;
121 return -EINVAL;
122 } 186 }
123 187
124 atomic_set(&channel->busy, 1); 188 return -ENOSYS;
189}
190
191int request_dma(unsigned int chan, const char *dev_id)
192{
193 struct dma_channel *channel = { 0 };
194 struct dma_info *info = get_dma_info(chan);
195 int result;
196
197 channel = get_dma_channel(chan);
198 if (atomic_xchg(&channel->busy, 1))
199 return -EBUSY;
125 200
126 strlcpy(channel->dev_id, dev_id, sizeof(channel->dev_id)); 201 strlcpy(channel->dev_id, dev_id, sizeof(channel->dev_id));
127 202
128 up(&channel->sem); 203 if (info->ops->request) {
204 result = info->ops->request(channel);
205 if (result)
206 atomic_set(&channel->busy, 0);
129 207
130 if (info->ops->request) 208 return result;
131 return info->ops->request(channel); 209 }
132 210
133 return 0; 211 return 0;
134} 212}
213EXPORT_SYMBOL(request_dma);
135 214
136void free_dma(unsigned int chan) 215void free_dma(unsigned int chan)
137{ 216{
138 struct dma_info *info = get_dma_info(chan); 217 struct dma_info *info = get_dma_info(chan);
139 struct dma_channel *channel = &info->channels[chan]; 218 struct dma_channel *channel = get_dma_channel(chan);
140 219
141 if (info->ops->free) 220 if (info->ops->free)
142 info->ops->free(channel); 221 info->ops->free(channel);
143 222
144 atomic_set(&channel->busy, 0); 223 atomic_set(&channel->busy, 0);
145} 224}
225EXPORT_SYMBOL(free_dma);
146 226
147void dma_wait_for_completion(unsigned int chan) 227void dma_wait_for_completion(unsigned int chan)
148{ 228{
149 struct dma_info *info = get_dma_info(chan); 229 struct dma_info *info = get_dma_info(chan);
150 struct dma_channel *channel = &info->channels[chan]; 230 struct dma_channel *channel = get_dma_channel(chan);
151 231
152 if (channel->flags & DMA_TEI_CAPABLE) { 232 if (channel->flags & DMA_TEI_CAPABLE) {
153 wait_event(channel->wait_queue, 233 wait_event(channel->wait_queue,
@@ -158,21 +238,52 @@ void dma_wait_for_completion(unsigned int chan)
158 while (info->ops->get_residue(channel)) 238 while (info->ops->get_residue(channel))
159 cpu_relax(); 239 cpu_relax();
160} 240}
241EXPORT_SYMBOL(dma_wait_for_completion);
242
243int register_chan_caps(const char *dmac, struct dma_chan_caps *caps)
244{
245 struct dma_info *info;
246 unsigned int found = 0;
247 int i;
248
249 list_for_each_entry(info, &registered_dmac_list, list)
250 if (strcmp(dmac, info->name) == 0) {
251 found = 1;
252 break;
253 }
254
255 if (unlikely(!found))
256 return -ENODEV;
257
258 for (i = 0; i < info->nr_channels; i++, caps++) {
259 struct dma_channel *channel;
260
261 if ((info->first_channel_nr + i) != caps->ch_num)
262 return -EINVAL;
263
264 channel = &info->channels[i];
265 channel->caps = caps->caplist;
266 }
267
268 return 0;
269}
270EXPORT_SYMBOL(register_chan_caps);
161 271
162void dma_configure_channel(unsigned int chan, unsigned long flags) 272void dma_configure_channel(unsigned int chan, unsigned long flags)
163{ 273{
164 struct dma_info *info = get_dma_info(chan); 274 struct dma_info *info = get_dma_info(chan);
165 struct dma_channel *channel = &info->channels[chan]; 275 struct dma_channel *channel = get_dma_channel(chan);
166 276
167 if (info->ops->configure) 277 if (info->ops->configure)
168 info->ops->configure(channel, flags); 278 info->ops->configure(channel, flags);
169} 279}
280EXPORT_SYMBOL(dma_configure_channel);
170 281
171int dma_xfer(unsigned int chan, unsigned long from, 282int dma_xfer(unsigned int chan, unsigned long from,
172 unsigned long to, size_t size, unsigned int mode) 283 unsigned long to, size_t size, unsigned int mode)
173{ 284{
174 struct dma_info *info = get_dma_info(chan); 285 struct dma_info *info = get_dma_info(chan);
175 struct dma_channel *channel = &info->channels[chan]; 286 struct dma_channel *channel = get_dma_channel(chan);
176 287
177 channel->sar = from; 288 channel->sar = from;
178 channel->dar = to; 289 channel->dar = to;
@@ -181,8 +292,20 @@ int dma_xfer(unsigned int chan, unsigned long from,
181 292
182 return info->ops->xfer(channel); 293 return info->ops->xfer(channel);
183} 294}
295EXPORT_SYMBOL(dma_xfer);
296
297int dma_extend(unsigned int chan, unsigned long op, void *param)
298{
299 struct dma_info *info = get_dma_info(chan);
300 struct dma_channel *channel = get_dma_channel(chan);
301
302 if (info->ops->extend)
303 return info->ops->extend(channel, op, param);
304
305 return -ENOSYS;
306}
307EXPORT_SYMBOL(dma_extend);
184 308
185#ifdef CONFIG_PROC_FS
186static int dma_read_proc(char *buf, char **start, off_t off, 309static int dma_read_proc(char *buf, char **start, off_t off,
187 int len, int *eof, void *data) 310 int len, int *eof, void *data)
188{ 311{
@@ -214,8 +337,6 @@ static int dma_read_proc(char *buf, char **start, off_t off,
214 337
215 return p - buf; 338 return p - buf;
216} 339}
217#endif
218
219 340
220int register_dmac(struct dma_info *info) 341int register_dmac(struct dma_info *info)
221{ 342{
@@ -224,8 +345,7 @@ int register_dmac(struct dma_info *info)
224 INIT_LIST_HEAD(&info->list); 345 INIT_LIST_HEAD(&info->list);
225 346
226 printk(KERN_INFO "DMA: Registering %s handler (%d channel%s).\n", 347 printk(KERN_INFO "DMA: Registering %s handler (%d channel%s).\n",
227 info->name, info->nr_channels, 348 info->name, info->nr_channels, info->nr_channels > 1 ? "s" : "");
228 info->nr_channels > 1 ? "s" : "");
229 349
230 BUG_ON((info->flags & DMAC_CHANNELS_CONFIGURED) && !info->channels); 350 BUG_ON((info->flags & DMAC_CHANNELS_CONFIGURED) && !info->channels);
231 351
@@ -242,28 +362,26 @@ int register_dmac(struct dma_info *info)
242 362
243 size = sizeof(struct dma_channel) * info->nr_channels; 363 size = sizeof(struct dma_channel) * info->nr_channels;
244 364
245 info->channels = kmalloc(size, GFP_KERNEL); 365 info->channels = kzalloc(size, GFP_KERNEL);
246 if (!info->channels) 366 if (!info->channels)
247 return -ENOMEM; 367 return -ENOMEM;
248
249 memset(info->channels, 0, size);
250 } 368 }
251 369
252 total_channels = get_nr_channels(); 370 total_channels = get_nr_channels();
253 for (i = 0; i < info->nr_channels; i++) { 371 for (i = 0; i < info->nr_channels; i++) {
254 struct dma_channel *chan = info->channels + i; 372 struct dma_channel *chan = &info->channels[i];
373
374 atomic_set(&chan->busy, 0);
255 375
256 chan->chan = i; 376 chan->chan = info->first_channel_nr + i;
257 chan->vchan = i + total_channels; 377 chan->vchan = info->first_channel_nr + i + total_channels;
258 378
259 memcpy(chan->dev_id, "Unused", 7); 379 memcpy(chan->dev_id, "Unused", 7);
260 380
261 if (info->flags & DMAC_CHANNELS_TEI_CAPABLE) 381 if (info->flags & DMAC_CHANNELS_TEI_CAPABLE)
262 chan->flags |= DMA_TEI_CAPABLE; 382 chan->flags |= DMA_TEI_CAPABLE;
263 383
264 init_MUTEX(&chan->sem);
265 init_waitqueue_head(&chan->wait_queue); 384 init_waitqueue_head(&chan->wait_queue);
266
267 dma_create_sysfs_files(chan, info); 385 dma_create_sysfs_files(chan, info);
268 } 386 }
269 387
@@ -271,6 +389,7 @@ int register_dmac(struct dma_info *info)
271 389
272 return 0; 390 return 0;
273} 391}
392EXPORT_SYMBOL(register_dmac);
274 393
275void unregister_dmac(struct dma_info *info) 394void unregister_dmac(struct dma_info *info)
276{ 395{
@@ -285,31 +404,16 @@ void unregister_dmac(struct dma_info *info)
285 list_del(&info->list); 404 list_del(&info->list);
286 platform_device_unregister(info->pdev); 405 platform_device_unregister(info->pdev);
287} 406}
407EXPORT_SYMBOL(unregister_dmac);
288 408
289static int __init dma_api_init(void) 409static int __init dma_api_init(void)
290{ 410{
291 printk("DMA: Registering DMA API.\n"); 411 printk(KERN_NOTICE "DMA: Registering DMA API.\n");
292
293#ifdef CONFIG_PROC_FS
294 create_proc_read_entry("dma", 0, 0, dma_read_proc, 0); 412 create_proc_read_entry("dma", 0, 0, dma_read_proc, 0);
295#endif
296
297 return 0; 413 return 0;
298} 414}
299
300subsys_initcall(dma_api_init); 415subsys_initcall(dma_api_init);
301 416
302MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>"); 417MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
303MODULE_DESCRIPTION("DMA API for SuperH"); 418MODULE_DESCRIPTION("DMA API for SuperH");
304MODULE_LICENSE("GPL"); 419MODULE_LICENSE("GPL");
305
306EXPORT_SYMBOL(request_dma);
307EXPORT_SYMBOL(free_dma);
308EXPORT_SYMBOL(register_dmac);
309EXPORT_SYMBOL(get_dma_residue);
310EXPORT_SYMBOL(get_dma_info);
311EXPORT_SYMBOL(get_dma_channel);
312EXPORT_SYMBOL(dma_xfer);
313EXPORT_SYMBOL(dma_wait_for_completion);
314EXPORT_SYMBOL(dma_configure_channel);
315
diff --git a/arch/sh/drivers/dma/dma-sh.c b/arch/sh/drivers/dma/dma-sh.c
index 660786013350..f63721ed86c2 100644
--- a/arch/sh/drivers/dma/dma-sh.c
+++ b/arch/sh/drivers/dma/dma-sh.c
@@ -94,20 +94,13 @@ static int sh_dmac_request_dma(struct dma_channel *chan)
94 if (unlikely(!chan->flags & DMA_TEI_CAPABLE)) 94 if (unlikely(!chan->flags & DMA_TEI_CAPABLE))
95 return 0; 95 return 0;
96 96
97 chan->name = kzalloc(32, GFP_KERNEL);
98 if (unlikely(chan->name == NULL))
99 return -ENOMEM;
100 snprintf(chan->name, 32, "DMAC Transfer End (Channel %d)",
101 chan->chan);
102
103 return request_irq(get_dmte_irq(chan->chan), dma_tei, 97 return request_irq(get_dmte_irq(chan->chan), dma_tei,
104 IRQF_DISABLED, chan->name, chan); 98 IRQF_DISABLED, chan->dev_id, chan);
105} 99}
106 100
107static void sh_dmac_free_dma(struct dma_channel *chan) 101static void sh_dmac_free_dma(struct dma_channel *chan)
108{ 102{
109 free_irq(get_dmte_irq(chan->chan), chan); 103 free_irq(get_dmte_irq(chan->chan), chan);
110 kfree(chan->name);
111} 104}
112 105
113static void 106static void
diff --git a/arch/sh/drivers/dma/dma-sysfs.c b/arch/sh/drivers/dma/dma-sysfs.c
index 29b8ef9873d1..eebcd4768bbf 100644
--- a/arch/sh/drivers/dma/dma-sysfs.c
+++ b/arch/sh/drivers/dma/dma-sysfs.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * sysfs interface for SH DMA API 4 * sysfs interface for SH DMA API
5 * 5 *
6 * Copyright (C) 2004, 2005 Paul Mundt 6 * Copyright (C) 2004 - 2006 Paul Mundt
7 * 7 *
8 * This file is subject to the terms and conditions of the GNU General Public 8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive 9 * License. See the file "COPYING" in the main directory of this archive
@@ -21,7 +21,6 @@
21static struct sysdev_class dma_sysclass = { 21static struct sysdev_class dma_sysclass = {
22 set_kset_name("dma"), 22 set_kset_name("dma"),
23}; 23};
24
25EXPORT_SYMBOL(dma_sysclass); 24EXPORT_SYMBOL(dma_sysclass);
26 25
27static ssize_t dma_show_devices(struct sys_device *dev, char *buf) 26static ssize_t dma_show_devices(struct sys_device *dev, char *buf)
@@ -31,7 +30,10 @@ static ssize_t dma_show_devices(struct sys_device *dev, char *buf)
31 30
32 for (i = 0; i < MAX_DMA_CHANNELS; i++) { 31 for (i = 0; i < MAX_DMA_CHANNELS; i++) {
33 struct dma_info *info = get_dma_info(i); 32 struct dma_info *info = get_dma_info(i);
34 struct dma_channel *channel = &info->channels[i]; 33 struct dma_channel *channel = get_dma_channel(i);
34
35 if (unlikely(!info) || !channel)
36 continue;
35 37
36 len += sprintf(buf + len, "%2d: %14s %s\n", 38 len += sprintf(buf + len, "%2d: %14s %s\n",
37 channel->chan, info->name, 39 channel->chan, info->name,
@@ -125,11 +127,16 @@ int dma_create_sysfs_files(struct dma_channel *chan, struct dma_info *info)
125 if (ret) 127 if (ret)
126 return ret; 128 return ret;
127 129
128 sysdev_create_file(dev, &attr_dev_id); 130 ret |= sysdev_create_file(dev, &attr_dev_id);
129 sysdev_create_file(dev, &attr_count); 131 ret |= sysdev_create_file(dev, &attr_count);
130 sysdev_create_file(dev, &attr_mode); 132 ret |= sysdev_create_file(dev, &attr_mode);
131 sysdev_create_file(dev, &attr_flags); 133 ret |= sysdev_create_file(dev, &attr_flags);
132 sysdev_create_file(dev, &attr_config); 134 ret |= sysdev_create_file(dev, &attr_config);
135
136 if (unlikely(ret)) {
137 dev_err(&info->pdev->dev, "Failed creating attrs\n");
138 return ret;
139 }
133 140
134 snprintf(name, sizeof(name), "dma%d", chan->chan); 141 snprintf(name, sizeof(name), "dma%d", chan->chan);
135 return sysfs_create_link(&info->pdev->dev.kobj, &dev->kobj, name); 142 return sysfs_create_link(&info->pdev->dev.kobj, &dev->kobj, name);
diff --git a/arch/sh/drivers/pci/ops-titan.c b/arch/sh/drivers/pci/ops-titan.c
index cd56d53375e7..ac8ee2312cd8 100644
--- a/arch/sh/drivers/pci/ops-titan.c
+++ b/arch/sh/drivers/pci/ops-titan.c
@@ -15,25 +15,21 @@
15#include <linux/types.h> 15#include <linux/types.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/pci.h> 17#include <linux/pci.h>
18#include <asm/io.h> 18#include <linux/io.h>
19#include <asm/titan.h> 19#include <asm/titan.h>
20#include "pci-sh4.h" 20#include "pci-sh4.h"
21 21
22static char titan_irq_tab[] __initdata = {
23 TITAN_IRQ_WAN,
24 TITAN_IRQ_LAN,
25 TITAN_IRQ_MPCIA,
26 TITAN_IRQ_MPCIB,
27 TITAN_IRQ_USB,
28};
29
22int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin) 30int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin)
23{ 31{
24 int irq = -1; 32 int irq = titan_irq_tab[slot];
25
26 switch (slot) {
27 case 0: irq = TITAN_IRQ_WAN; break; /* eth0 (WAN) */
28 case 1: irq = TITAN_IRQ_LAN; break; /* eth1 (LAN) */
29 case 2: irq = TITAN_IRQ_MPCIA; break; /* mPCI A */
30 case 3: irq = TITAN_IRQ_MPCIB; break; /* mPCI B */
31 case 4: irq = TITAN_IRQ_USB; break; /* USB */
32 default:
33 printk(KERN_INFO "PCI: Bad IRQ mapping "
34 "request for slot %d\n", slot);
35 return -1;
36 }
37 33
38 printk("PCI: Mapping TITAN IRQ for slot %d, pin %c to irq %d\n", 34 printk("PCI: Mapping TITAN IRQ for slot %d, pin %c to irq %d\n",
39 slot, pin - 1 + 'A', irq); 35 slot, pin - 1 + 'A', irq);
diff --git a/arch/sh/drivers/pci/pci-sh7780.c b/arch/sh/drivers/pci/pci-sh7780.c
index d6e635296534..602b644c35ad 100644
--- a/arch/sh/drivers/pci/pci-sh7780.c
+++ b/arch/sh/drivers/pci/pci-sh7780.c
@@ -22,6 +22,20 @@
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include "pci-sh4.h" 23#include "pci-sh4.h"
24 24
25#define INTC_BASE 0xffd00000
26#define INTC_ICR0 (INTC_BASE+0x0)
27#define INTC_ICR1 (INTC_BASE+0x1c)
28#define INTC_INTPRI (INTC_BASE+0x10)
29#define INTC_INTREQ (INTC_BASE+0x24)
30#define INTC_INTMSK0 (INTC_BASE+0x44)
31#define INTC_INTMSK1 (INTC_BASE+0x48)
32#define INTC_INTMSK2 (INTC_BASE+0x40080)
33#define INTC_INTMSKCLR0 (INTC_BASE+0x64)
34#define INTC_INTMSKCLR1 (INTC_BASE+0x68)
35#define INTC_INTMSKCLR2 (INTC_BASE+0x40084)
36#define INTC_INT2MSKR (INTC_BASE+0x40038)
37#define INTC_INT2MSKCR (INTC_BASE+0x4003c)
38
25/* 39/*
26 * Initialization. Try all known PCI access methods. Note that we support 40 * Initialization. Try all known PCI access methods. Note that we support
27 * using both PCI BIOS and direct access: in such cases, we use I/O ports 41 * using both PCI BIOS and direct access: in such cases, we use I/O ports
diff --git a/arch/sh/drivers/push-switch.c b/arch/sh/drivers/push-switch.c
new file mode 100644
index 000000000000..f2b9157c314f
--- /dev/null
+++ b/arch/sh/drivers/push-switch.c
@@ -0,0 +1,138 @@
1/*
2 * Generic push-switch framework
3 *
4 * Copyright (C) 2006 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/init.h>
11#include <linux/module.h>
12#include <linux/interrupt.h>
13#include <linux/platform_device.h>
14#include <asm/push-switch.h>
15
16#define DRV_NAME "push-switch"
17#define DRV_VERSION "0.1.0"
18
19static ssize_t switch_show(struct device *dev,
20 struct device_attribute *attr,
21 char *buf)
22{
23 struct push_switch_platform_info *psw_info = dev->platform_data;
24 return sprintf(buf, "%s\n", psw_info->name);
25}
26static DEVICE_ATTR(switch, S_IRUGO, switch_show, NULL);
27
28static void switch_timer(unsigned long data)
29{
30 struct push_switch *psw = (struct push_switch *)data;
31
32 schedule_work(&psw->work);
33}
34
35static void switch_work_handler(void *data)
36{
37 struct platform_device *pdev = data;
38 struct push_switch *psw = platform_get_drvdata(pdev);
39
40 psw->state = 0;
41
42 kobject_uevent(&pdev->dev.kobj, KOBJ_CHANGE);
43}
44
45static int switch_drv_probe(struct platform_device *pdev)
46{
47 struct push_switch_platform_info *psw_info;
48 struct push_switch *psw;
49 int ret, irq;
50
51 psw = kzalloc(sizeof(struct push_switch), GFP_KERNEL);
52 if (unlikely(!psw))
53 return -ENOMEM;
54
55 irq = platform_get_irq(pdev, 0);
56 if (unlikely(irq < 0)) {
57 ret = -ENODEV;
58 goto err;
59 }
60
61 psw_info = pdev->dev.platform_data;
62 BUG_ON(!psw_info);
63
64 ret = request_irq(irq, psw_info->irq_handler,
65 IRQF_DISABLED | psw_info->irq_flags,
66 psw_info->name ? psw_info->name : DRV_NAME, pdev);
67 if (unlikely(ret < 0))
68 goto err;
69
70 if (psw_info->name) {
71 ret = device_create_file(&pdev->dev, &dev_attr_switch);
72 if (unlikely(ret)) {
73 dev_err(&pdev->dev, "Failed creating device attrs\n");
74 ret = -EINVAL;
75 goto err_irq;
76 }
77 }
78
79 INIT_WORK(&psw->work, switch_work_handler, pdev);
80 init_timer(&psw->debounce);
81
82 psw->debounce.function = switch_timer;
83 psw->debounce.data = (unsigned long)psw;
84
85 platform_set_drvdata(pdev, psw);
86
87 return 0;
88
89err_irq:
90 free_irq(irq, pdev);
91err:
92 kfree(psw);
93 return ret;
94}
95
96static int switch_drv_remove(struct platform_device *pdev)
97{
98 struct push_switch *psw = platform_get_drvdata(pdev);
99 struct push_switch_platform_info *psw_info = pdev->dev.platform_data;
100 int irq = platform_get_irq(pdev, 0);
101
102 if (psw_info->name)
103 device_remove_file(&pdev->dev, &dev_attr_switch);
104
105 platform_set_drvdata(pdev, NULL);
106 flush_scheduled_work();
107 del_timer_sync(&psw->debounce);
108 free_irq(irq, pdev);
109
110 kfree(psw);
111
112 return 0;
113}
114
115static struct platform_driver switch_driver = {
116 .probe = switch_drv_probe,
117 .remove = switch_drv_remove,
118 .driver = {
119 .name = DRV_NAME,
120 },
121};
122
123static int __init switch_init(void)
124{
125 printk(KERN_NOTICE DRV_NAME ": version %s loaded\n", DRV_VERSION);
126 return platform_driver_register(&switch_driver);
127}
128
129static void __exit switch_exit(void)
130{
131 platform_driver_unregister(&switch_driver);
132}
133module_init(switch_init);
134module_exit(switch_exit);
135
136MODULE_VERSION(DRV_VERSION);
137MODULE_AUTHOR("Paul Mundt");
138MODULE_LICENSE("GPLv2");
diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
index 5da88a43d350..99c7e5249f7a 100644
--- a/arch/sh/kernel/Makefile
+++ b/arch/sh/kernel/Makefile
@@ -4,7 +4,7 @@
4 4
5extra-y := head.o init_task.o vmlinux.lds 5extra-y := head.o init_task.o vmlinux.lds
6 6
7obj-y := process.o signal.o entry.o traps.o irq.o \ 7obj-y := process.o signal.o traps.o irq.o \
8 ptrace.o setup.o time.o sys_sh.o semaphore.o \ 8 ptrace.o setup.o time.o sys_sh.o semaphore.o \
9 io.o io_generic.o sh_ksyms.o syscalls.o 9 io.o io_generic.o sh_ksyms.o syscalls.o
10 10
@@ -21,3 +21,4 @@ obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
21obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o 21obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
22obj-$(CONFIG_APM) += apm.o 22obj-$(CONFIG_APM) += apm.o
23obj-$(CONFIG_PM) += pm.o 23obj-$(CONFIG_PM) += pm.o
24obj-$(CONFIG_STACKTRACE) += stacktrace.o
diff --git a/arch/sh/kernel/cpu/Makefile b/arch/sh/kernel/cpu/Makefile
index fb5dac069382..0582e6712b79 100644
--- a/arch/sh/kernel/cpu/Makefile
+++ b/arch/sh/kernel/cpu/Makefile
@@ -2,11 +2,12 @@
2# Makefile for the Linux/SuperH CPU-specifc backends. 2# Makefile for the Linux/SuperH CPU-specifc backends.
3# 3#
4 4
5obj-y += irq/ init.o clock.o 5obj-$(CONFIG_CPU_SH2) = sh2/
6 6obj-$(CONFIG_CPU_SH2A) = sh2a/
7obj-$(CONFIG_CPU_SH2) += sh2/ 7obj-$(CONFIG_CPU_SH3) = sh3/
8obj-$(CONFIG_CPU_SH3) += sh3/ 8obj-$(CONFIG_CPU_SH4) = sh4/
9obj-$(CONFIG_CPU_SH4) += sh4/
10 9
11obj-$(CONFIG_UBC_WAKEUP) += ubc.o 10obj-$(CONFIG_UBC_WAKEUP) += ubc.o
12obj-$(CONFIG_SH_ADC) += adc.o 11obj-$(CONFIG_SH_ADC) += adc.o
12
13obj-y += irq/ init.o clock.o
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index 51ec64cdf348..abb586b12565 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -5,9 +5,11 @@
5 * 5 *
6 * This clock framework is derived from the OMAP version by: 6 * This clock framework is derived from the OMAP version by:
7 * 7 *
8 * Copyright (C) 2004 Nokia Corporation 8 * Copyright (C) 2004 - 2005 Nokia Corporation
9 * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com> 9 * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
10 * 10 *
11 * Modified for omap shared clock framework by Tony Lindgren <tony@atomide.com>
12 *
11 * This file is subject to the terms and conditions of the GNU General Public 13 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive 14 * License. See the file "COPYING" in the main directory of this archive
13 * for more details. 15 * for more details.
@@ -20,6 +22,7 @@
20#include <linux/kref.h> 22#include <linux/kref.h>
21#include <linux/seq_file.h> 23#include <linux/seq_file.h>
22#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h>
23#include <asm/clock.h> 26#include <asm/clock.h>
24#include <asm/timer.h> 27#include <asm/timer.h>
25 28
@@ -195,17 +198,37 @@ void clk_recalc_rate(struct clk *clk)
195 propagate_rate(clk); 198 propagate_rate(clk);
196} 199}
197 200
198struct clk *clk_get(const char *id) 201/*
202 * Returns a clock. Note that we first try to use device id on the bus
203 * and clock name. If this fails, we try to use clock name only.
204 */
205struct clk *clk_get(struct device *dev, const char *id)
199{ 206{
200 struct clk *p, *clk = ERR_PTR(-ENOENT); 207 struct clk *p, *clk = ERR_PTR(-ENOENT);
208 int idno;
209
210 if (dev == NULL || dev->bus != &platform_bus_type)
211 idno = -1;
212 else
213 idno = to_platform_device(dev)->id;
201 214
202 mutex_lock(&clock_list_sem); 215 mutex_lock(&clock_list_sem);
203 list_for_each_entry(p, &clock_list, node) { 216 list_for_each_entry(p, &clock_list, node) {
217 if (p->id == idno &&
218 strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
219 clk = p;
220 goto found;
221 }
222 }
223
224 list_for_each_entry(p, &clock_list, node) {
204 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { 225 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
205 clk = p; 226 clk = p;
206 break; 227 break;
207 } 228 }
208 } 229 }
230
231found:
209 mutex_unlock(&clock_list_sem); 232 mutex_unlock(&clock_list_sem);
210 233
211 return clk; 234 return clk;
diff --git a/arch/sh/kernel/cpu/init.c b/arch/sh/kernel/cpu/init.c
index bfb90eb0b7a6..48121766e8d2 100644
--- a/arch/sh/kernel/cpu/init.c
+++ b/arch/sh/kernel/cpu/init.c
@@ -68,12 +68,14 @@ static void __init cache_init(void)
68 68
69 waysize = cpu_data->dcache.sets; 69 waysize = cpu_data->dcache.sets;
70 70
71#ifdef CCR_CACHE_ORA
71 /* 72 /*
72 * If the OC is already in RAM mode, we only have 73 * If the OC is already in RAM mode, we only have
73 * half of the entries to flush.. 74 * half of the entries to flush..
74 */ 75 */
75 if (ccr & CCR_CACHE_ORA) 76 if (ccr & CCR_CACHE_ORA)
76 waysize >>= 1; 77 waysize >>= 1;
78#endif
77 79
78 waysize <<= cpu_data->dcache.entry_shift; 80 waysize <<= cpu_data->dcache.entry_shift;
79 81
diff --git a/arch/sh/kernel/cpu/irq/Makefile b/arch/sh/kernel/cpu/irq/Makefile
index 1c034c283f59..0049d217561a 100644
--- a/arch/sh/kernel/cpu/irq/Makefile
+++ b/arch/sh/kernel/cpu/irq/Makefile
@@ -1,8 +1,9 @@
1# 1#
2# Makefile for the Linux/SuperH CPU-specifc IRQ handlers. 2# Makefile for the Linux/SuperH CPU-specifc IRQ handlers.
3# 3#
4obj-y += ipr.o imask.o 4obj-y += imask.o
5 5
6obj-$(CONFIG_CPU_HAS_IPR_IRQ) += ipr.o
6obj-$(CONFIG_CPU_HAS_PINT_IRQ) += pint.o 7obj-$(CONFIG_CPU_HAS_PINT_IRQ) += pint.o
7obj-$(CONFIG_CPU_HAS_MASKREG_IRQ) += maskreg.o 8obj-$(CONFIG_CPU_HAS_MASKREG_IRQ) += maskreg.o
8obj-$(CONFIG_CPU_HAS_INTC2_IRQ) += intc2.o 9obj-$(CONFIG_CPU_HAS_INTC2_IRQ) += intc2.o
diff --git a/arch/sh/kernel/cpu/irq/imask.c b/arch/sh/kernel/cpu/irq/imask.c
index a33ae3e0a5a5..301b505c4278 100644
--- a/arch/sh/kernel/cpu/irq/imask.c
+++ b/arch/sh/kernel/cpu/irq/imask.c
@@ -53,7 +53,10 @@ void static inline set_interrupt_registers(int ip)
53{ 53{
54 unsigned long __dummy; 54 unsigned long __dummy;
55 55
56 asm volatile("ldc %2, r6_bank\n\t" 56 asm volatile(
57#ifdef CONFIG_CPU_HAS_SR_RB
58 "ldc %2, r6_bank\n\t"
59#endif
57 "stc sr, %0\n\t" 60 "stc sr, %0\n\t"
58 "and #0xf0, %0\n\t" 61 "and #0xf0, %0\n\t"
59 "shlr2 %0\n\t" 62 "shlr2 %0\n\t"
diff --git a/arch/sh/kernel/cpu/irq/intc2.c b/arch/sh/kernel/cpu/irq/intc2.c
index 74ca576a7ce5..74defe76a058 100644
--- a/arch/sh/kernel/cpu/irq/intc2.c
+++ b/arch/sh/kernel/cpu/irq/intc2.c
@@ -11,22 +11,29 @@
11 * Hitachi 7751, the STM ST40 STB1, SH7760, and SH7780. 11 * Hitachi 7751, the STM ST40 STB1, SH7760, and SH7780.
12 */ 12 */
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/irq.h> 14#include <linux/interrupt.h>
15#include <linux/io.h> 15#include <linux/io.h>
16#include <asm/system.h> 16
17#if defined(CONFIG_CPU_SUBTYPE_SH7760)
18#define INTC2_BASE 0xfe080000
19#define INTC2_INTMSK (INTC2_BASE + 0x40)
20#define INTC2_INTMSKCLR (INTC2_BASE + 0x60)
21#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
22#define INTC2_BASE 0xffd40000
23#define INTC2_INTMSK (INTC2_BASE + 0x38)
24#define INTC2_INTMSKCLR (INTC2_BASE + 0x3c)
25#endif
17 26
18static void disable_intc2_irq(unsigned int irq) 27static void disable_intc2_irq(unsigned int irq)
19{ 28{
20 struct intc2_data *p = get_irq_chip_data(irq); 29 struct intc2_data *p = get_irq_chip_data(irq);
21 ctrl_outl(1 << p->msk_shift, 30 ctrl_outl(1 << p->msk_shift, INTC2_INTMSK + p->msk_offset);
22 INTC2_BASE + INTC2_INTMSK_OFFSET + p->msk_offset);
23} 31}
24 32
25static void enable_intc2_irq(unsigned int irq) 33static void enable_intc2_irq(unsigned int irq)
26{ 34{
27 struct intc2_data *p = get_irq_chip_data(irq); 35 struct intc2_data *p = get_irq_chip_data(irq);
28 ctrl_outl(1 << p->msk_shift, 36 ctrl_outl(1 << p->msk_shift, INTC2_INTMSKCLR + p->msk_offset);
29 INTC2_BASE + INTC2_INTMSKCLR_OFFSET + p->msk_offset);
30} 37}
31 38
32static struct irq_chip intc2_irq_chip = { 39static struct irq_chip intc2_irq_chip = {
@@ -61,12 +68,10 @@ void make_intc2_irq(struct intc2_data *table, unsigned int nr_irqs)
61 /* Set the priority level */ 68 /* Set the priority level */
62 local_irq_save(flags); 69 local_irq_save(flags);
63 70
64 ipr = ctrl_inl(INTC2_BASE + INTC2_INTPRI_OFFSET + 71 ipr = ctrl_inl(INTC2_BASE + p->ipr_offset);
65 p->ipr_offset);
66 ipr &= ~(0xf << p->ipr_shift); 72 ipr &= ~(0xf << p->ipr_shift);
67 ipr |= p->priority << p->ipr_shift; 73 ipr |= p->priority << p->ipr_shift;
68 ctrl_outl(ipr, INTC2_BASE + INTC2_INTPRI_OFFSET + 74 ctrl_outl(ipr, INTC2_BASE + p->ipr_offset);
69 p->ipr_offset);
70 75
71 local_irq_restore(flags); 76 local_irq_restore(flags);
72 77
diff --git a/arch/sh/kernel/cpu/irq/ipr.c b/arch/sh/kernel/cpu/irq/ipr.c
index a0089563cbfc..35eb5751a3aa 100644
--- a/arch/sh/kernel/cpu/irq/ipr.c
+++ b/arch/sh/kernel/cpu/irq/ipr.c
@@ -19,25 +19,21 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/irq.h> 20#include <linux/irq.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <asm/system.h> 22#include <linux/io.h>
23#include <asm/io.h> 23#include <linux/interrupt.h>
24#include <asm/machvec.h>
25
26 24
27static void disable_ipr_irq(unsigned int irq) 25static void disable_ipr_irq(unsigned int irq)
28{ 26{
29 struct ipr_data *p = get_irq_chip_data(irq); 27 struct ipr_data *p = get_irq_chip_data(irq);
30 int shift = p->shift*4;
31 /* Set the priority in IPR to 0 */ 28 /* Set the priority in IPR to 0 */
32 ctrl_outw(ctrl_inw(p->addr) & (0xffff ^ (0xf << shift)), p->addr); 29 ctrl_outw(ctrl_inw(p->addr) & (0xffff ^ (0xf << p->shift)), p->addr);
33} 30}
34 31
35static void enable_ipr_irq(unsigned int irq) 32static void enable_ipr_irq(unsigned int irq)
36{ 33{
37 struct ipr_data *p = get_irq_chip_data(irq); 34 struct ipr_data *p = get_irq_chip_data(irq);
38 int shift = p->shift*4;
39 /* Set priority in IPR back to original value */ 35 /* Set priority in IPR back to original value */
40 ctrl_outw(ctrl_inw(p->addr) | (p->priority << shift), p->addr); 36 ctrl_outw(ctrl_inw(p->addr) | (p->priority << p->shift), p->addr);
41} 37}
42 38
43static struct irq_chip ipr_irq_chip = { 39static struct irq_chip ipr_irq_chip = {
@@ -53,6 +49,10 @@ void make_ipr_irq(struct ipr_data *table, unsigned int nr_irqs)
53 49
54 for (i = 0; i < nr_irqs; i++) { 50 for (i = 0; i < nr_irqs; i++) {
55 unsigned int irq = table[i].irq; 51 unsigned int irq = table[i].irq;
52 table[i].addr = map_ipridx_to_addr(table[i].ipr_idx);
53 /* could the IPR index be mapped, if not we ignore this */
54 if (table[i].addr == 0)
55 continue;
56 disable_irq_nosync(irq); 56 disable_irq_nosync(irq);
57 set_irq_chip_and_handler_name(irq, &ipr_irq_chip, 57 set_irq_chip_and_handler_name(irq, &ipr_irq_chip,
58 handle_level_irq, "level"); 58 handle_level_irq, "level");
@@ -62,83 +62,6 @@ void make_ipr_irq(struct ipr_data *table, unsigned int nr_irqs)
62} 62}
63EXPORT_SYMBOL(make_ipr_irq); 63EXPORT_SYMBOL(make_ipr_irq);
64 64
65static struct ipr_data sys_ipr_map[] = {
66#ifndef CONFIG_CPU_SUBTYPE_SH7780
67 { TIMER_IRQ, TIMER_IPR_ADDR, TIMER_IPR_POS, TIMER_PRIORITY },
68 { TIMER1_IRQ, TIMER1_IPR_ADDR, TIMER1_IPR_POS, TIMER1_PRIORITY },
69#ifdef RTC_IRQ
70 { RTC_IRQ, RTC_IPR_ADDR, RTC_IPR_POS, RTC_PRIORITY },
71#endif
72#ifdef SCI_ERI_IRQ
73 { SCI_ERI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY },
74 { SCI_RXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY },
75 { SCI_TXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY },
76#endif
77#ifdef SCIF1_ERI_IRQ
78 { SCIF1_ERI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
79 { SCIF1_RXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
80 { SCIF1_BRI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
81 { SCIF1_TXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
82#endif
83#if defined(CONFIG_CPU_SUBTYPE_SH7300)
84 { SCIF0_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY },
85 { DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
86 { DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
87 { VIO_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
88#endif
89#ifdef SCIF_ERI_IRQ
90 { SCIF_ERI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
91 { SCIF_RXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
92 { SCIF_BRI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
93 { SCIF_TXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
94#endif
95#ifdef IRDA_ERI_IRQ
96 { IRDA_ERI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
97 { IRDA_RXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
98 { IRDA_BRI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
99 { IRDA_TXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
100#endif
101#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \
102 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
103 defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705)
104 /*
105 * Initialize the Interrupt Controller (INTC)
106 * registers to their power on values
107 */
108
109 /*
110 * Enable external irq (INTC IRQ mode).
111 * You should set corresponding bits of PFC to "00"
112 * to enable these interrupts.
113 */
114 { IRQ0_IRQ, IRQ0_IPR_ADDR, IRQ0_IPR_POS, IRQ0_PRIORITY },
115 { IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, IRQ1_PRIORITY },
116 { IRQ2_IRQ, IRQ2_IPR_ADDR, IRQ2_IPR_POS, IRQ2_PRIORITY },
117 { IRQ3_IRQ, IRQ3_IPR_ADDR, IRQ3_IPR_POS, IRQ3_PRIORITY },
118 { IRQ4_IRQ, IRQ4_IPR_ADDR, IRQ4_IPR_POS, IRQ4_PRIORITY },
119 { IRQ5_IRQ, IRQ5_IPR_ADDR, IRQ5_IPR_POS, IRQ5_PRIORITY },
120#endif
121#endif
122};
123
124void __init init_IRQ(void)
125{
126 make_ipr_irq(sys_ipr_map, ARRAY_SIZE(sys_ipr_map));
127
128#ifdef CONFIG_CPU_HAS_PINT_IRQ
129 init_IRQ_pint();
130#endif
131
132#ifdef CONFIG_CPU_HAS_INTC2_IRQ
133 init_IRQ_intc2();
134#endif
135 /* Perform the machine specific initialisation */
136 if (sh_mv.mv_init_irq != NULL)
137 sh_mv.mv_init_irq();
138
139 irq_ctx_init(smp_processor_id());
140}
141
142#if !defined(CONFIG_CPU_HAS_PINT_IRQ) 65#if !defined(CONFIG_CPU_HAS_PINT_IRQ)
143int ipr_irq_demux(int irq) 66int ipr_irq_demux(int irq)
144{ 67{
diff --git a/arch/sh/kernel/cpu/sh2/Makefile b/arch/sh/kernel/cpu/sh2/Makefile
index 389353fba608..f0f059acfcfb 100644
--- a/arch/sh/kernel/cpu/sh2/Makefile
+++ b/arch/sh/kernel/cpu/sh2/Makefile
@@ -2,5 +2,6 @@
2# Makefile for the Linux/SuperH SH-2 backends. 2# Makefile for the Linux/SuperH SH-2 backends.
3# 3#
4 4
5obj-y := probe.o 5obj-y := ex.o probe.o entry.o
6 6
7obj-$(CONFIG_CPU_SUBTYPE_SH7619) += setup-sh7619.o clock-sh7619.o
diff --git a/arch/sh/kernel/cpu/sh2/clock-sh7619.c b/arch/sh/kernel/cpu/sh2/clock-sh7619.c
new file mode 100644
index 000000000000..d0440b269702
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2/clock-sh7619.c
@@ -0,0 +1,81 @@
1/*
2 * arch/sh/kernel/cpu/sh2/clock-sh7619.c
3 *
4 * SH7619 support for the clock framework
5 *
6 * Copyright (C) 2006 Yoshinori Sato
7 *
8 * Based on clock-sh4.c
9 * Copyright (C) 2005 Paul Mundt
10 *
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
13 * for more details.
14 */
15#include <linux/init.h>
16#include <linux/kernel.h>
17#include <asm/clock.h>
18#include <asm/freq.h>
19#include <asm/io.h>
20
21const static int pll1rate[]={1,2};
22const static int pfc_divisors[]={1,2,0,4};
23
24#if (CONFIG_SH_CLK_MD == 1) || (CONFIG_SH_CLK_MD == 2)
25#define PLL2 (4)
26#elif (CONFIG_SH_CLK_MD == 5) || (CONFIG_SH_CLK_MD == 6)
27#define PLL2 (2)
28#else
29#error "Illigal Clock Mode!"
30#endif
31
32static void master_clk_init(struct clk *clk)
33{
34 clk->rate *= PLL2 * pll1rate[(ctrl_inw(FREQCR) >> 8) & 7];
35}
36
37static struct clk_ops sh7619_master_clk_ops = {
38 .init = master_clk_init,
39};
40
41static void module_clk_recalc(struct clk *clk)
42{
43 int idx = (ctrl_inw(FREQCR) & 0x0007);
44 clk->rate = clk->parent->rate / pfc_divisors[idx];
45}
46
47static struct clk_ops sh7619_module_clk_ops = {
48 .recalc = module_clk_recalc,
49};
50
51static void bus_clk_recalc(struct clk *clk)
52{
53 clk->rate = clk->parent->rate / pll1rate[(ctrl_inw(FREQCR) >> 8) & 7];
54}
55
56static struct clk_ops sh7619_bus_clk_ops = {
57 .recalc = bus_clk_recalc,
58};
59
60static void cpu_clk_recalc(struct clk *clk)
61{
62 clk->rate = clk->parent->rate;
63}
64
65static struct clk_ops sh7619_cpu_clk_ops = {
66 .recalc = cpu_clk_recalc,
67};
68
69static struct clk_ops *sh7619_clk_ops[] = {
70 &sh7619_master_clk_ops,
71 &sh7619_module_clk_ops,
72 &sh7619_bus_clk_ops,
73 &sh7619_cpu_clk_ops,
74};
75
76void __init arch_init_clk_ops(struct clk_ops **ops, int idx)
77{
78 if (idx < ARRAY_SIZE(sh7619_clk_ops))
79 *ops = sh7619_clk_ops[idx];
80}
81
diff --git a/arch/sh/kernel/cpu/sh2/entry.S b/arch/sh/kernel/cpu/sh2/entry.S
new file mode 100644
index 000000000000..34d51b3745ea
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2/entry.S
@@ -0,0 +1,341 @@
1/*
2 * arch/sh/kernel/cpu/sh2/entry.S
3 *
4 * The SH-2 exception entry
5 *
6 * Copyright (C) 2005,2006 Yoshinori Sato
7 * Copyright (C) 2005 AXE,Inc.
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13
14#include <linux/linkage.h>
15#include <asm/asm-offsets.h>
16#include <asm/thread_info.h>
17#include <asm/cpu/mmu_context.h>
18#include <asm/unistd.h>
19#include <asm/errno.h>
20#include <asm/page.h>
21
22/* Offsets to the stack */
23OFF_R0 = 0 /* Return value. New ABI also arg4 */
24OFF_R1 = 4 /* New ABI: arg5 */
25OFF_R2 = 8 /* New ABI: arg6 */
26OFF_R3 = 12 /* New ABI: syscall_nr */
27OFF_R4 = 16 /* New ABI: arg0 */
28OFF_R5 = 20 /* New ABI: arg1 */
29OFF_R6 = 24 /* New ABI: arg2 */
30OFF_R7 = 28 /* New ABI: arg3 */
31OFF_SP = (15*4)
32OFF_PC = (16*4)
33OFF_SR = (16*4+2*4)
34OFF_TRA = (16*4+6*4)
35
36#include <asm/entry-macros.S>
37
38ENTRY(exception_handler)
39 ! already saved r0/r1
40 mov.l r2,@-sp
41 mov.l r3,@-sp
42 mov r0,r1
43 cli
44 mov.l $cpu_mode,r2
45 mov.l @r2,r0
46 mov.l @(5*4,r15),r3 ! previous SR
47 shll2 r3 ! set "S" flag
48 rotl r0 ! T <- "S" flag
49 rotl r0 ! "S" flag is LSB
50 rotcr r3 ! T -> r3:b30
51 shlr r3
52 shlr r0
53 bt/s 1f
54 mov.l r3,@(5*4,r15) ! copy cpu mode to SR
55 ! switch to kernel mode
56 mov #1,r0
57 rotr r0
58 rotr r0
59 mov.l r0,@r2 ! enter kernel mode
60 mov.l $current_thread_info,r2
61 mov.l @r2,r2
62 mov #0x20,r0
63 shll8 r0
64 add r2,r0
65 mov r15,r2 ! r2 = user stack top
66 mov r0,r15 ! switch kernel stack
67 add #-4,r15 ! dummy
68 mov.l r1,@-r15 ! TRA
69 sts.l macl, @-r15
70 sts.l mach, @-r15
71 stc.l gbr, @-r15
72 mov.l @(4*4,r2),r0
73 mov.l @(5*4,r2),r1
74 mov.l r1,@-r15 ! original SR
75 sts.l pr,@-r15
76 mov.l r0,@-r15 ! original PC
77 mov r2,r3
78 add #(4+2)*4,r3 ! rewind r0 - r3 + exception frame
79 mov.l r3,@-r15 ! original SP
80 mov.l r14,@-r15
81 mov.l r13,@-r15
82 mov.l r12,@-r15
83 mov.l r11,@-r15
84 mov.l r10,@-r15
85 mov.l r9,@-r15
86 mov.l r8,@-r15
87 mov.l r7,@-r15
88 mov.l r6,@-r15
89 mov.l r5,@-r15
90 mov.l r4,@-r15
91 mov r2,r8 ! copy user -> kernel stack
92 mov.l @r8+,r3
93 mov.l r3,@-r15
94 mov.l @r8+,r2
95 mov.l r2,@-r15
96 mov.l @r8+,r1
97 mov.l r1,@-r15
98 mov.l @r8+,r0
99 bra 2f
100 mov.l r0,@-r15
1011:
102 ! in kernel exception
103 mov #(22-4-4-1)*4+4,r0
104 mov r15,r2
105 sub r0,r15
106 mov.l @r2+,r0 ! old R3
107 mov.l r0,@-r15
108 mov.l @r2+,r0 ! old R2
109 mov.l r0,@-r15
110 mov.l @r2+,r0 ! old R1
111 mov.l r0,@-r15
112 mov.l @r2+,r0 ! old R0
113 mov.l r0,@-r15
114 mov.l @r2+,r3 ! old PC
115 mov.l @r2+,r0 ! old SR
116 add #-4,r2 ! exception frame stub (sr)
117 mov.l r1,@-r2 ! TRA
118 sts.l macl, @-r2
119 sts.l mach, @-r2
120 stc.l gbr, @-r2
121 mov.l r0,@-r2 ! save old SR
122 sts.l pr,@-r2
123 mov.l r3,@-r2 ! save old PC
124 mov r2,r0
125 add #8*4,r0
126 mov.l r0,@-r2 ! save old SP
127 mov.l r14,@-r2
128 mov.l r13,@-r2
129 mov.l r12,@-r2
130 mov.l r11,@-r2
131 mov.l r10,@-r2
132 mov.l r9,@-r2
133 mov.l r8,@-r2
134 mov.l r7,@-r2
135 mov.l r6,@-r2
136 mov.l r5,@-r2
137 mov.l r4,@-r2
138 mov.l @(OFF_R0,r15),r0
139 mov.l @(OFF_R1,r15),r1
140 mov.l @(OFF_R2,r15),r2
141 mov.l @(OFF_R3,r15),r3
1422:
143 mov #OFF_TRA,r8
144 add r15,r8
145 mov.l @r8,r9
146 mov #64,r8
147 cmp/hs r8,r9
148 bt interrupt_entry ! vec >= 64 is interrupt
149 mov #32,r8
150 cmp/hs r8,r9
151 bt trap_entry ! 64 > vec >= 32 is trap
152 mov.l 4f,r8
153 mov r9,r4
154 shll2 r9
155 add r9,r8
156 mov.l @r8,r8
157 mov #0,r9
158 cmp/eq r9,r8
159 bf 3f
160 mov.l 8f,r8 ! unhandled exception
1613:
162 mov.l 5f,r10
163 jmp @r8
164 lds r10,pr
165
166interrupt_entry:
167 mov r9,r4
168 mov.l 6f,r9
169 mov.l 7f,r8
170 jmp @r8
171 lds r9,pr
172
173 .align 2
1744: .long exception_handling_table
1755: .long ret_from_exception
1766: .long ret_from_irq
1777: .long do_IRQ
1788: .long do_exception_error
179
180trap_entry:
181 add #-0x10,r9
182 shll2 r9 ! TRA
183 mov #OFF_TRA,r8
184 add r15,r8
185 mov.l r9,@r8
186 mov r9,r8
187#ifdef CONFIG_TRACE_IRQFLAGS
188 mov.l 5f, r9
189 jsr @r9
190 nop
191#endif
192 sti
193 bra system_call
194 nop
195
196 .align 2
1971: .long syscall_exit
1982: .long break_point_trap_software
1993: .long NR_syscalls
2004: .long sys_call_table
201#ifdef CONFIG_TRACE_IRQFLAGS
2025: .long trace_hardirqs_on
203#endif
204
205#if defined(CONFIG_SH_STANDARD_BIOS)
206 /* Unwind the stack and jmp to the debug entry */
207debug_kernel_fw:
208 mov r15,r0
209 add #(22-4)*4-4,r0
210 ldc.l @r0+,gbr
211 lds.l @r0+,mach
212 lds.l @r0+,macl
213 mov r15,r0
214 mov.l @(OFF_SP,r0),r1
215 mov #OFF_SR,r2
216 mov.l @(r0,r2),r3
217 mov.l r3,@-r1
218 mov #OFF_SP,r2
219 mov.l @(r0,r2),r3
220 mov.l r3,@-r1
221 mov r15,r0
222 add #(22-4)*4-8,r0
223 mov.l 1f,r2
224 mov.l @r2,r2
225 stc sr,r3
226 mov.l r2,@r0
227 mov.l r3,@r0
228 mov.l r1,@(8,r0)
229 mov.l @r15+, r0
230 mov.l @r15+, r1
231 mov.l @r15+, r2
232 mov.l @r15+, r3
233 mov.l @r15+, r4
234 mov.l @r15+, r5
235 mov.l @r15+, r6
236 mov.l @r15+, r7
237 mov.l @r15+, r8
238 mov.l @r15+, r9
239 mov.l @r15+, r10
240 mov.l @r15+, r11
241 mov.l @r15+, r12
242 mov.l @r15+, r13
243 mov.l @r15+, r14
244 add #8,r15
245 lds.l @r15+, pr
246 rte
247 mov.l @r15+,r15
248 .align 2
2491: .long gdb_vbr_vector
250#endif /* CONFIG_SH_STANDARD_BIOS */
251
252ENTRY(address_error_handler)
253 mov r15,r4 ! regs
254 add #4,r4
255 mov #OFF_PC,r0
256 mov.l @(r0,r15),r6 ! pc
257 mov.l 1f,r0
258 jmp @r0
259 mov #0,r5 ! writeaccess is unknown
260 .align 2
261
2621: .long do_address_error
263
264restore_all:
265 cli
266#ifdef CONFIG_TRACE_IRQFLAGS
267 mov.l 3f, r0
268 jsr @r0
269 nop
270#endif
271 mov r15,r0
272 mov.l $cpu_mode,r2
273 mov #OFF_SR,r3
274 mov.l @(r0,r3),r1
275 mov.l r1,@r2
276 shll2 r1 ! clear MD bit
277 shlr2 r1
278 mov.l @(OFF_SP,r0),r2
279 add #-8,r2
280 mov.l r2,@(OFF_SP,r0) ! point exception frame top
281 mov.l r1,@(4,r2) ! set sr
282 mov #OFF_PC,r3
283 mov.l @(r0,r3),r1
284 mov.l r1,@r2 ! set pc
285 add #4*16+4,r0
286 lds.l @r0+,pr
287 add #4,r0 ! skip sr
288 ldc.l @r0+,gbr
289 lds.l @r0+,mach
290 lds.l @r0+,macl
291 get_current_thread_info r0, r1
292 mov.l $current_thread_info,r1
293 mov.l r0,@r1
294 mov.l @r15+,r0
295 mov.l @r15+,r1
296 mov.l @r15+,r2
297 mov.l @r15+,r3
298 mov.l @r15+,r4
299 mov.l @r15+,r5
300 mov.l @r15+,r6
301 mov.l @r15+,r7
302 mov.l @r15+,r8
303 mov.l @r15+,r9
304 mov.l @r15+,r10
305 mov.l @r15+,r11
306 mov.l @r15+,r12
307 mov.l @r15+,r13
308 mov.l @r15+,r14
309 mov.l @r15,r15
310 rte
311 nop
3122:
313 mov.l 1f,r8
314 mov.l 2f,r9
315 jmp @r9
316 lds r8,pr
317
318 .align 2
319$current_thread_info:
320 .long __current_thread_info
321$cpu_mode:
322 .long __cpu_mode
323#ifdef CONFIG_TRACE_IRQFLAGS
3243: .long trace_hardirqs_off
325#endif
326
327! common exception handler
328#include "../../entry-common.S"
329
330 .data
331! cpu operation mode
332! bit30 = MD (compatible SH3/4)
333__cpu_mode:
334 .long 0x40000000
335
336 .section .bss
337__current_thread_info:
338 .long 0
339
340ENTRY(exception_handling_table)
341 .space 4*32
diff --git a/arch/sh/kernel/cpu/sh2/ex.S b/arch/sh/kernel/cpu/sh2/ex.S
new file mode 100644
index 000000000000..6d285af7846c
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2/ex.S
@@ -0,0 +1,46 @@
1/*
2 * arch/sh/kernel/cpu/sh2/ex.S
3 *
4 * The SH-2 exception vector table
5 *
6 * Copyright (C) 2005 Yoshinori Sato
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12
13#include <linux/linkage.h>
14
15!
16! convert Exception Vector to Exception Number
17!
18exception_entry:
19no = 0
20 .rept 256
21 mov.l r0,@-sp
22 mov #no,r0
23 bra exception_trampoline
24 and #0xff,r0
25no = no + 1
26 .endr
27exception_trampoline:
28 mov.l r1,@-sp
29 mov.l $exception_handler,r1
30 jmp @r1
31
32 .align 2
33$exception_entry:
34 .long exception_entry
35$exception_handler:
36 .long exception_handler
37!
38! Exception Vector Base
39!
40 .align 2
41ENTRY(vbr_base)
42vector = 0
43 .rept 256
44 .long exception_entry + vector * 8
45vector = vector + 1
46 .endr
diff --git a/arch/sh/kernel/cpu/sh2/probe.c b/arch/sh/kernel/cpu/sh2/probe.c
index f17a2a0d588e..ba527d9b5024 100644
--- a/arch/sh/kernel/cpu/sh2/probe.c
+++ b/arch/sh/kernel/cpu/sh2/probe.c
@@ -17,17 +17,23 @@
17 17
18int __init detect_cpu_and_cache_system(void) 18int __init detect_cpu_and_cache_system(void)
19{ 19{
20 /* 20#if defined(CONFIG_CPU_SUBTYPE_SH7604)
21 * For now, assume SH7604 .. fix this later.
22 */
23 cpu_data->type = CPU_SH7604; 21 cpu_data->type = CPU_SH7604;
24 cpu_data->dcache.ways = 4; 22 cpu_data->dcache.ways = 4;
25 cpu_data->dcache.way_shift = 6; 23 cpu_data->dcache.way_incr = (1<<10);
26 cpu_data->dcache.sets = 64; 24 cpu_data->dcache.sets = 64;
27 cpu_data->dcache.entry_shift = 4; 25 cpu_data->dcache.entry_shift = 4;
28 cpu_data->dcache.linesz = L1_CACHE_BYTES; 26 cpu_data->dcache.linesz = L1_CACHE_BYTES;
29 cpu_data->dcache.flags = 0; 27 cpu_data->dcache.flags = 0;
30 28#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
29 cpu_data->type = CPU_SH7619;
30 cpu_data->dcache.ways = 4;
31 cpu_data->dcache.way_incr = (1<<12);
32 cpu_data->dcache.sets = 256;
33 cpu_data->dcache.entry_shift = 4;
34 cpu_data->dcache.linesz = L1_CACHE_BYTES;
35 cpu_data->dcache.flags = 0;
36#endif
31 /* 37 /*
32 * SH-2 doesn't have separate caches 38 * SH-2 doesn't have separate caches
33 */ 39 */
diff --git a/arch/sh/kernel/cpu/sh2/setup-sh7619.c b/arch/sh/kernel/cpu/sh2/setup-sh7619.c
new file mode 100644
index 000000000000..82c2d905152f
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2/setup-sh7619.c
@@ -0,0 +1,53 @@
1/*
2 * SH7619 Setup
3 *
4 * Copyright (C) 2006 Yoshinori Sato
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct plat_sci_port sci_platform_data[] = {
16 {
17 .mapbase = 0xf8400000,
18 .flags = UPF_BOOT_AUTOCONF,
19 .type = PORT_SCIF,
20 .irqs = { 88, 89, 91, 90},
21 }, {
22 .mapbase = 0xf8410000,
23 .flags = UPF_BOOT_AUTOCONF,
24 .type = PORT_SCIF,
25 .irqs = { 92, 93, 95, 94},
26 }, {
27 .mapbase = 0xf8420000,
28 .flags = UPF_BOOT_AUTOCONF,
29 .type = PORT_SCIF,
30 .irqs = { 96, 97, 99, 98},
31 }, {
32 .flags = 0,
33 }
34};
35
36static struct platform_device sci_device = {
37 .name = "sh-sci",
38 .id = -1,
39 .dev = {
40 .platform_data = sci_platform_data,
41 },
42};
43
44static struct platform_device *sh7619_devices[] __initdata = {
45 &sci_device,
46};
47
48static int __init sh7619_devices_setup(void)
49{
50 return platform_add_devices(sh7619_devices,
51 ARRAY_SIZE(sh7619_devices));
52}
53__initcall(sh7619_devices_setup);
diff --git a/arch/sh/kernel/cpu/sh2a/Makefile b/arch/sh/kernel/cpu/sh2a/Makefile
new file mode 100644
index 000000000000..350972ae9410
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2a/Makefile
@@ -0,0 +1,10 @@
1#
2# Makefile for the Linux/SuperH SH-2A backends.
3#
4
5obj-y := common.o probe.o
6
7common-y += $(addprefix ../sh2/, ex.o)
8common-y += $(addprefix ../sh2/, entry.o)
9
10obj-$(CONFIG_CPU_SUBTYPE_SH7206) += setup-sh7206.o clock-sh7206.o
diff --git a/arch/sh/kernel/cpu/sh2a/clock-sh7206.c b/arch/sh/kernel/cpu/sh2a/clock-sh7206.c
new file mode 100644
index 000000000000..a9ad309c6a33
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2a/clock-sh7206.c
@@ -0,0 +1,85 @@
1/*
2 * arch/sh/kernel/cpu/sh2a/clock-sh7206.c
3 *
4 * SH7206 support for the clock framework
5 *
6 * Copyright (C) 2006 Yoshinori Sato
7 *
8 * Based on clock-sh4.c
9 * Copyright (C) 2005 Paul Mundt
10 *
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
13 * for more details.
14 */
15#include <linux/init.h>
16#include <linux/kernel.h>
17#include <asm/clock.h>
18#include <asm/freq.h>
19#include <asm/io.h>
20
21const static int pll1rate[]={1,2,3,4,6,8};
22const static int pfc_divisors[]={1,2,3,4,6,8,12};
23#define ifc_divisors pfc_divisors
24
25#if (CONFIG_SH_CLK_MD == 2)
26#define PLL2 (4)
27#elif (CONFIG_SH_CLK_MD == 6)
28#define PLL2 (2)
29#elif (CONFIG_SH_CLK_MD == 7)
30#define PLL2 (1)
31#else
32#error "Illigal Clock Mode!"
33#endif
34
35static void master_clk_init(struct clk *clk)
36{
37 clk->rate *= PLL2 * pll1rate[(ctrl_inw(FREQCR) >> 8) & 0x0007];
38}
39
40static struct clk_ops sh7206_master_clk_ops = {
41 .init = master_clk_init,
42};
43
44static void module_clk_recalc(struct clk *clk)
45{
46 int idx = (ctrl_inw(FREQCR) & 0x0007);
47 clk->rate = clk->parent->rate / pfc_divisors[idx];
48}
49
50static struct clk_ops sh7206_module_clk_ops = {
51 .recalc = module_clk_recalc,
52};
53
54static void bus_clk_recalc(struct clk *clk)
55{
56 clk->rate = clk->parent->rate / pll1rate[(ctrl_inw(FREQCR) >> 8) & 0x0007];
57}
58
59static struct clk_ops sh7206_bus_clk_ops = {
60 .recalc = bus_clk_recalc,
61};
62
63static void cpu_clk_recalc(struct clk *clk)
64{
65 int idx = (ctrl_inw(FREQCR) & 0x0007);
66 clk->rate = clk->parent->rate / ifc_divisors[idx];
67}
68
69static struct clk_ops sh7206_cpu_clk_ops = {
70 .recalc = cpu_clk_recalc,
71};
72
73static struct clk_ops *sh7206_clk_ops[] = {
74 &sh7206_master_clk_ops,
75 &sh7206_module_clk_ops,
76 &sh7206_bus_clk_ops,
77 &sh7206_cpu_clk_ops,
78};
79
80void __init arch_init_clk_ops(struct clk_ops **ops, int idx)
81{
82 if (idx < ARRAY_SIZE(sh7206_clk_ops))
83 *ops = sh7206_clk_ops[idx];
84}
85
diff --git a/arch/sh/kernel/cpu/sh2a/probe.c b/arch/sh/kernel/cpu/sh2a/probe.c
new file mode 100644
index 000000000000..87c6c0542089
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2a/probe.c
@@ -0,0 +1,39 @@
1/*
2 * arch/sh/kernel/cpu/sh2a/probe.c
3 *
4 * CPU Subtype Probing for SH-2A.
5 *
6 * Copyright (C) 2004, 2005 Paul Mundt
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12
13#include <linux/init.h>
14#include <asm/processor.h>
15#include <asm/cache.h>
16
17int __init detect_cpu_and_cache_system(void)
18{
19 /* Just SH7206 for now .. */
20 cpu_data->type = CPU_SH7206;
21
22 cpu_data->dcache.ways = 4;
23 cpu_data->dcache.way_incr = (1 << 11);
24 cpu_data->dcache.sets = 128;
25 cpu_data->dcache.entry_shift = 4;
26 cpu_data->dcache.linesz = L1_CACHE_BYTES;
27 cpu_data->dcache.flags = 0;
28
29 /*
30 * The icache is the same as the dcache as far as this setup is
31 * concerned. The only real difference in hardware is that the icache
32 * lacks the U bit that the dcache has, none of this has any bearing
33 * on the cache info.
34 */
35 cpu_data->icache = cpu_data->dcache;
36
37 return 0;
38}
39
diff --git a/arch/sh/kernel/cpu/sh2a/setup-sh7206.c b/arch/sh/kernel/cpu/sh2a/setup-sh7206.c
new file mode 100644
index 000000000000..cdfeef49e62e
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2a/setup-sh7206.c
@@ -0,0 +1,58 @@
1/*
2 * SH7206 Setup
3 *
4 * Copyright (C) 2006 Yoshinori Sato
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct plat_sci_port sci_platform_data[] = {
16 {
17 .mapbase = 0xfffe8000,
18 .flags = UPF_BOOT_AUTOCONF,
19 .type = PORT_SCIF,
20 .irqs = { 240, 241, 242, 243},
21 }, {
22 .mapbase = 0xfffe8800,
23 .flags = UPF_BOOT_AUTOCONF,
24 .type = PORT_SCIF,
25 .irqs = { 244, 245, 246, 247},
26 }, {
27 .mapbase = 0xfffe9000,
28 .flags = UPF_BOOT_AUTOCONF,
29 .type = PORT_SCIF,
30 .irqs = { 248, 249, 250, 251},
31 }, {
32 .mapbase = 0xfffe9800,
33 .flags = UPF_BOOT_AUTOCONF,
34 .type = PORT_SCIF,
35 .irqs = { 252, 253, 254, 255},
36 }, {
37 .flags = 0,
38 }
39};
40
41static struct platform_device sci_device = {
42 .name = "sh-sci",
43 .id = -1,
44 .dev = {
45 .platform_data = sci_platform_data,
46 },
47};
48
49static struct platform_device *sh7206_devices[] __initdata = {
50 &sci_device,
51};
52
53static int __init sh7206_devices_setup(void)
54{
55 return platform_add_devices(sh7206_devices,
56 ARRAY_SIZE(sh7206_devices));
57}
58__initcall(sh7206_devices_setup);
diff --git a/arch/sh/kernel/cpu/sh3/Makefile b/arch/sh/kernel/cpu/sh3/Makefile
index 58d3815695ff..83905e4e4387 100644
--- a/arch/sh/kernel/cpu/sh3/Makefile
+++ b/arch/sh/kernel/cpu/sh3/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the Linux/SuperH SH-3 backends. 2# Makefile for the Linux/SuperH SH-3 backends.
3# 3#
4 4
5obj-y := ex.o probe.o 5obj-y := ex.o probe.o entry.o
6 6
7# CPU subtype setup 7# CPU subtype setup
8obj-$(CONFIG_CPU_SUBTYPE_SH7705) += setup-sh7705.o 8obj-$(CONFIG_CPU_SUBTYPE_SH7705) += setup-sh7705.o
diff --git a/arch/sh/kernel/cpu/sh3/clock-sh7709.c b/arch/sh/kernel/cpu/sh3/clock-sh7709.c
index 10461a745e5f..b791a29fdb62 100644
--- a/arch/sh/kernel/cpu/sh3/clock-sh7709.c
+++ b/arch/sh/kernel/cpu/sh3/clock-sh7709.c
@@ -24,7 +24,7 @@ static int pfc_divisors[] = { 1, 2, 4, 1, 3, 6, 1, 1 };
24 24
25static void set_bus_parent(struct clk *clk) 25static void set_bus_parent(struct clk *clk)
26{ 26{
27 struct clk *bus_clk = clk_get("bus_clk"); 27 struct clk *bus_clk = clk_get(NULL, "bus_clk");
28 clk->parent = bus_clk; 28 clk->parent = bus_clk;
29 clk_put(bus_clk); 29 clk_put(bus_clk);
30} 30}
diff --git a/arch/sh/kernel/entry.S b/arch/sh/kernel/cpu/sh3/entry.S
index 39aaefb2d83f..8c0dc2700c69 100644
--- a/arch/sh/kernel/entry.S
+++ b/arch/sh/kernel/cpu/sh3/entry.S
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/arch/sh/entry.S 2 * arch/sh/kernel/entry.S
3 * 3 *
4 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka 4 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka
5 * Copyright (C) 2003 - 2006 Paul Mundt 5 * Copyright (C) 2003 - 2006 Paul Mundt
@@ -7,15 +7,16 @@
7 * This file is subject to the terms and conditions of the GNU General Public 7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive 8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details. 9 * for more details.
10 *
11 */ 10 */
12#include <linux/sys.h> 11#include <linux/sys.h>
13#include <linux/errno.h> 12#include <linux/errno.h>
14#include <linux/linkage.h> 13#include <linux/linkage.h>
15#include <asm/asm-offsets.h> 14#include <asm/asm-offsets.h>
16#include <asm/thread_info.h> 15#include <asm/thread_info.h>
17#include <asm/cpu/mmu_context.h>
18#include <asm/unistd.h> 16#include <asm/unistd.h>
17#include <asm/cpu/mmu_context.h>
18#include <asm/pgtable.h>
19#include <asm/page.h>
19 20
20! NOTE: 21! NOTE:
21! GNU as (as of 2.9.1) changes bf/s into bt/s and bra, when the address 22! GNU as (as of 2.9.1) changes bf/s into bt/s and bra, when the address
@@ -81,6 +82,8 @@ OFF_TRA = (16*4+6*4)
81#define k_g_imask r6_bank /* r6_bank1 */ 82#define k_g_imask r6_bank /* r6_bank1 */
82#define current r7 /* r7_bank1 */ 83#define current r7 /* r7_bank1 */
83 84
85#include <asm/entry-macros.S>
86
84/* 87/*
85 * Kernel mode register usage: 88 * Kernel mode register usage:
86 * k0 scratch 89 * k0 scratch
@@ -107,26 +110,6 @@ OFF_TRA = (16*4+6*4)
107! this first version depends *much* on C implementation. 110! this first version depends *much* on C implementation.
108! 111!
109 112
110#define CLI() \
111 stc sr, r0; \
112 or #0xf0, r0; \
113 ldc r0, sr
114
115#define STI() \
116 mov.l __INV_IMASK, r11; \
117 stc sr, r10; \
118 and r11, r10; \
119 stc k_g_imask, r11; \
120 or r11, r10; \
121 ldc r10, sr
122
123#if defined(CONFIG_PREEMPT)
124# define preempt_stop() CLI()
125#else
126# define preempt_stop()
127# define resume_kernel restore_all
128#endif
129
130#if defined(CONFIG_MMU) 113#if defined(CONFIG_MMU)
131 .align 2 114 .align 2
132ENTRY(tlb_miss_load) 115ENTRY(tlb_miss_load)
@@ -155,29 +138,14 @@ ENTRY(tlb_protection_violation_store)
155 138
156call_dpf: 139call_dpf:
157 mov.l 1f, r0 140 mov.l 1f, r0
158 mov r5, r8 141 mov.l @r0, r6 ! address
159 mov.l @r0, r6
160 mov r6, r9
161 mov.l 2f, r0
162 sts pr, r10
163 jsr @r0
164 mov r15, r4
165 !
166 tst r0, r0
167 bf/s 0f
168 lds r10, pr
169 rts
170 nop
1710: STI()
172 mov.l 3f, r0 142 mov.l 3f, r0
173 mov r9, r6 143
174 mov r8, r5
175 jmp @r0 144 jmp @r0
176 mov r15, r4 145 mov r15, r4 ! regs
177 146
178 .align 2 147 .align 2
1791: .long MMU_TEA 1481: .long MMU_TEA
1802: .long __do_page_fault
1813: .long do_page_fault 1493: .long do_page_fault
182 150
183 .align 2 151 .align 2
@@ -203,32 +171,6 @@ call_dae:
2032: .long do_address_error 1712: .long do_address_error
204#endif /* CONFIG_MMU */ 172#endif /* CONFIG_MMU */
205 173
206#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
207! Handle kernel debug if either kgdb (SW) or gdb-stub (FW) is present.
208! If both are configured, handle the debug traps (breakpoints) in SW,
209! but still allow BIOS traps to FW.
210
211 .align 2
212debug_kernel:
213#if defined(CONFIG_SH_STANDARD_BIOS) && defined(CONFIG_SH_KGDB)
214 /* Force BIOS call to FW (debug_trap put TRA in r8) */
215 mov r8,r0
216 shlr2 r0
217 cmp/eq #0x3f,r0
218 bt debug_kernel_fw
219#endif /* CONFIG_SH_STANDARD_BIOS && CONFIG_SH_KGDB */
220
221debug_enter:
222#if defined(CONFIG_SH_KGDB)
223 /* Jump to kgdb, pass stacked regs as arg */
224debug_kernel_sw:
225 mov.l 3f, r0
226 jmp @r0
227 mov r15, r4
228 .align 2
2293: .long kgdb_handle_exception
230#endif /* CONFIG_SH_KGDB */
231
232#if defined(CONFIG_SH_STANDARD_BIOS) 174#if defined(CONFIG_SH_STANDARD_BIOS)
233 /* Unwind the stack and jmp to the debug entry */ 175 /* Unwind the stack and jmp to the debug entry */
234debug_kernel_fw: 176debug_kernel_fw:
@@ -269,276 +211,6 @@ debug_kernel_fw:
2692: .long gdb_vbr_vector 2112: .long gdb_vbr_vector
270#endif /* CONFIG_SH_STANDARD_BIOS */ 212#endif /* CONFIG_SH_STANDARD_BIOS */
271 213
272#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
273
274
275 .align 2
276debug_trap:
277#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
278 mov #OFF_SR, r0
279 mov.l @(r0,r15), r0 ! get status register
280 shll r0
281 shll r0 ! kernel space?
282 bt/s debug_kernel
283#endif
284 mov.l @r15, r0 ! Restore R0 value
285 mov.l 1f, r8
286 jmp @r8
287 nop
288
289 .align 2
290ENTRY(exception_error)
291 !
292 STI()
293 mov.l 2f, r0
294 jmp @r0
295 nop
296
297!
298 .align 2
2991: .long break_point_trap_software
3002: .long do_exception_error
301
302 .align 2
303ret_from_exception:
304 preempt_stop()
305ENTRY(ret_from_irq)
306 !
307 mov #OFF_SR, r0
308 mov.l @(r0,r15), r0 ! get status register
309 shll r0
310 shll r0 ! kernel space?
311 bt/s resume_kernel ! Yes, it's from kernel, go back soon
312 GET_THREAD_INFO(r8)
313
314#ifdef CONFIG_PREEMPT
315 bra resume_userspace
316 nop
317ENTRY(resume_kernel)
318 mov.l @(TI_PRE_COUNT,r8), r0 ! current_thread_info->preempt_count
319 tst r0, r0
320 bf noresched
321need_resched:
322 mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags
323 tst #_TIF_NEED_RESCHED, r0 ! need_resched set?
324 bt noresched
325
326 mov #OFF_SR, r0
327 mov.l @(r0,r15), r0 ! get status register
328 and #0xf0, r0 ! interrupts off (exception path)?
329 cmp/eq #0xf0, r0
330 bt noresched
331
332 mov.l 1f, r0
333 mov.l r0, @(TI_PRE_COUNT,r8)
334
335 STI()
336 mov.l 2f, r0
337 jsr @r0
338 nop
339 mov #0, r0
340 mov.l r0, @(TI_PRE_COUNT,r8)
341 CLI()
342
343 bra need_resched
344 nop
345noresched:
346 bra restore_all
347 nop
348
349 .align 2
3501: .long PREEMPT_ACTIVE
3512: .long schedule
352#endif
353
354ENTRY(resume_userspace)
355 ! r8: current_thread_info
356 CLI()
357 mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags
358 tst #_TIF_WORK_MASK, r0
359 bt/s restore_all
360 tst #_TIF_NEED_RESCHED, r0
361
362 .align 2
363work_pending:
364 ! r0: current_thread_info->flags
365 ! r8: current_thread_info
366 ! t: result of "tst #_TIF_NEED_RESCHED, r0"
367 bf/s work_resched
368 tst #(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK), r0
369work_notifysig:
370 bt/s restore_all
371 mov r15, r4
372 mov r12, r5 ! set arg1(save_r0)
373 mov r0, r6
374 mov.l 2f, r1
375 mova restore_all, r0
376 jmp @r1
377 lds r0, pr
378work_resched:
379#ifndef CONFIG_PREEMPT
380 ! gUSA handling
381 mov.l @(OFF_SP,r15), r0 ! get user space stack pointer
382 mov r0, r1
383 shll r0
384 bf/s 1f
385 shll r0
386 bf/s 1f
387 mov #OFF_PC, r0
388 ! SP >= 0xc0000000 : gUSA mark
389 mov.l @(r0,r15), r2 ! get user space PC (program counter)
390 mov.l @(OFF_R0,r15), r3 ! end point
391 cmp/hs r3, r2 ! r2 >= r3?
392 bt 1f
393 add r3, r1 ! rewind point #2
394 mov.l r1, @(r0,r15) ! reset PC to rewind point #2
395 !
3961:
397#endif
398 mov.l 1f, r1
399 jsr @r1 ! schedule
400 nop
401 CLI()
402 !
403 mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags
404 tst #_TIF_WORK_MASK, r0
405 bt restore_all
406 bra work_pending
407 tst #_TIF_NEED_RESCHED, r0
408
409 .align 2
4101: .long schedule
4112: .long do_notify_resume
412
413 .align 2
414syscall_exit_work:
415 ! r0: current_thread_info->flags
416 ! r8: current_thread_info
417 tst #_TIF_SYSCALL_TRACE, r0
418 bt/s work_pending
419 tst #_TIF_NEED_RESCHED, r0
420 STI()
421 ! XXX setup arguments...
422 mov.l 4f, r0 ! do_syscall_trace
423 jsr @r0
424 nop
425 bra resume_userspace
426 nop
427
428 .align 2
429syscall_trace_entry:
430 ! Yes it is traced.
431 ! XXX setup arguments...
432 mov.l 4f, r11 ! Call do_syscall_trace which notifies
433 jsr @r11 ! superior (will chomp R[0-7])
434 nop
435 ! Reload R0-R4 from kernel stack, where the
436 ! parent may have modified them using
437 ! ptrace(POKEUSR). (Note that R0-R2 are
438 ! used by the system call handler directly
439 ! from the kernel stack anyway, so don't need
440 ! to be reloaded here.) This allows the parent
441 ! to rewrite system calls and args on the fly.
442 mov.l @(OFF_R4,r15), r4 ! arg0
443 mov.l @(OFF_R5,r15), r5
444 mov.l @(OFF_R6,r15), r6
445 mov.l @(OFF_R7,r15), r7 ! arg3
446 mov.l @(OFF_R3,r15), r3 ! syscall_nr
447 ! Arrange for do_syscall_trace to be called
448 ! again as the system call returns.
449 mov.l 2f, r10 ! Number of syscalls
450 cmp/hs r10, r3
451 bf syscall_call
452 mov #-ENOSYS, r0
453 bra syscall_exit
454 mov.l r0, @(OFF_R0,r15) ! Return value
455
456/*
457 * Syscall interface:
458 *
459 * Syscall #: R3
460 * Arguments #0 to #3: R4--R7
461 * Arguments #4 to #6: R0, R1, R2
462 * TRA: (number of arguments + 0x10) x 4
463 *
464 * This code also handles delegating other traps to the BIOS/gdb stub
465 * according to:
466 *
467 * Trap number
468 * (TRA>>2) Purpose
469 * -------- -------
470 * 0x0-0xf old syscall ABI
471 * 0x10-0x1f new syscall ABI
472 * 0x20-0xff delegated through debug_trap to BIOS/gdb stub.
473 *
474 * Note: When we're first called, the TRA value must be shifted
475 * right 2 bits in order to get the value that was used as the "trapa"
476 * argument.
477 */
478
479 .align 2
480 .globl ret_from_fork
481ret_from_fork:
482 mov.l 1f, r8
483 jsr @r8
484 mov r0, r4
485 bra syscall_exit
486 nop
487 .align 2
4881: .long schedule_tail
489 !
490ENTRY(system_call)
491 mov.l 1f, r9
492 mov.l @r9, r8 ! Read from TRA (Trap Address) Register
493 !
494 ! Is the trap argument >= 0x20? (TRA will be >= 0x80)
495 mov #0x7f, r9
496 cmp/hi r9, r8
497 bt/s 0f
498 mov #OFF_TRA, r9
499 add r15, r9
500 !
501 mov.l r8, @r9 ! set TRA value to tra
502 STI()
503 ! Call the system call handler through the table.
504 ! First check for bad syscall number
505 mov r3, r9
506 mov.l 2f, r8 ! Number of syscalls
507 cmp/hs r8, r9
508 bf/s good_system_call
509 GET_THREAD_INFO(r8)
510syscall_badsys: ! Bad syscall number
511 mov #-ENOSYS, r0
512 bra resume_userspace
513 mov.l r0, @(OFF_R0,r15) ! Return value
514 !
5150:
516 bra debug_trap
517 nop
518 !
519good_system_call: ! Good syscall number
520 mov.l @(TI_FLAGS,r8), r8
521 mov #_TIF_SYSCALL_TRACE, r10
522 tst r10, r8
523 bf syscall_trace_entry
524 !
525syscall_call:
526 shll2 r9 ! x4
527 mov.l 3f, r8 ! Load the address of sys_call_table
528 add r8, r9
529 mov.l @r9, r8
530 jsr @r8 ! jump to specific syscall handler
531 nop
532 mov.l @(OFF_R0,r15), r12 ! save r0
533 mov.l r0, @(OFF_R0,r15) ! save the return value
534 !
535syscall_exit:
536 CLI()
537 !
538 GET_THREAD_INFO(r8)
539 mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags
540 tst #_TIF_ALLWORK_MASK, r0
541 bf syscall_exit_work
542restore_all: 214restore_all:
543 mov.l @r15+, r0 215 mov.l @r15+, r0
544 mov.l @r15+, r1 216 mov.l @r15+, r1
@@ -606,7 +278,9 @@ skip_restore:
606 ! 278 !
607 ! Calculate new SR value 279 ! Calculate new SR value
608 mov k3, k2 ! original SR value 280 mov k3, k2 ! original SR value
609 mov.l 9f, k1 281 mov #0xf0, k1
282 extu.b k1, k1
283 not k1, k1
610 and k1, k2 ! Mask orignal SR value 284 and k1, k2 ! Mask orignal SR value
611 ! 285 !
612 mov k3, k0 ! Calculate IMASK-bits 286 mov k3, k0 ! Calculate IMASK-bits
@@ -632,16 +306,12 @@ skip_restore:
632 nop 306 nop
633 307
634 .align 2 308 .align 2
6351: .long TRA
6362: .long NR_syscalls
6373: .long sys_call_table
6384: .long do_syscall_trace
6395: .long 0x00001000 ! DSP 3095: .long 0x00001000 ! DSP
6407: .long 0x30000000 3107: .long 0x30000000
6419:
642__INV_IMASK:
643 .long 0xffffff0f ! ~(IMASK)
644 311
312! common exception handler
313#include "../../entry-common.S"
314
645! Exception Vector Base 315! Exception Vector Base
646! 316!
647! Should be aligned page boundary. 317! Should be aligned page boundary.
@@ -661,9 +331,176 @@ general_exception:
6612: .long ret_from_exception 3312: .long ret_from_exception
662! 332!
663! 333!
334
335/* This code makes some assumptions to improve performance.
336 * Make sure they are stil true. */
337#if PTRS_PER_PGD != PTRS_PER_PTE
338#error PGD and PTE sizes don't match
339#endif
340
341/* gas doesn't flag impossible values for mov #immediate as an error */
342#if (_PAGE_PRESENT >> 2) > 0x7f
343#error cannot load PAGE_PRESENT as an immediate
344#endif
345#if _PAGE_DIRTY > 0x7f
346#error cannot load PAGE_DIRTY as an immediate
347#endif
348#if (_PAGE_PRESENT << 2) != _PAGE_ACCESSED
349#error cannot derive PAGE_ACCESSED from PAGE_PRESENT
350#endif
351
352#if defined(CONFIG_CPU_SH4)
353#define ldmmupteh(r) mov.l 8f, r
354#else
355#define ldmmupteh(r) mov #MMU_PTEH, r
356#endif
357
664 .balign 1024,0,1024 358 .balign 1024,0,1024
665tlb_miss: 359tlb_miss:
666 mov.l 1f, k2 360#ifdef COUNT_EXCEPTIONS
361 ! Increment the counts
362 mov.l 9f, k1
363 mov.l @k1, k2
364 add #1, k2
365 mov.l k2, @k1
366#endif
367
368 ! k0 scratch
369 ! k1 pgd and pte pointers
370 ! k2 faulting address
371 ! k3 pgd and pte index masks
372 ! k4 shift
373
374 ! Load up the pgd entry (k1)
375
376 ldmmupteh(k0) ! 9 LS (latency=2) MMU_PTEH
377
378 mov.w 4f, k3 ! 8 LS (latency=2) (PTRS_PER_PGD-1) << 2
379 mov #-(PGDIR_SHIFT-2), k4 ! 6 EX
380
381 mov.l @(MMU_TEA-MMU_PTEH,k0), k2 ! 18 LS (latency=2)
382
383 mov.l @(MMU_TTB-MMU_PTEH,k0), k1 ! 18 LS (latency=2)
384
385 mov k2, k0 ! 5 MT (latency=0)
386 shld k4, k0 ! 99 EX
387
388 and k3, k0 ! 78 EX
389
390 mov.l @(k0, k1), k1 ! 21 LS (latency=2)
391 mov #-(PAGE_SHIFT-2), k4 ! 6 EX
392
393 ! Load up the pte entry (k2)
394
395 mov k2, k0 ! 5 MT (latency=0)
396 shld k4, k0 ! 99 EX
397
398 tst k1, k1 ! 86 MT
399
400 bt 20f ! 110 BR
401
402 and k3, k0 ! 78 EX
403 mov.w 5f, k4 ! 8 LS (latency=2) _PAGE_PRESENT
404
405 mov.l @(k0, k1), k2 ! 21 LS (latency=2)
406 add k0, k1 ! 49 EX
407
408#ifdef CONFIG_CPU_HAS_PTEA
409 ! Test the entry for present and _PAGE_ACCESSED
410
411 mov #-28, k3 ! 6 EX
412 mov k2, k0 ! 5 MT (latency=0)
413
414 tst k4, k2 ! 68 MT
415 shld k3, k0 ! 99 EX
416
417 bt 20f ! 110 BR
418
419 ! Set PTEA register
420 ! MMU_PTEA = ((pteval >> 28) & 0xe) | (pteval & 0x1)
421 !
422 ! k0=pte>>28, k1=pte*, k2=pte, k3=<unused>, k4=_PAGE_PRESENT
423
424 and #0xe, k0 ! 79 EX
425
426 mov k0, k3 ! 5 MT (latency=0)
427 mov k2, k0 ! 5 MT (latency=0)
428
429 and #1, k0 ! 79 EX
430
431 or k0, k3 ! 82 EX
432
433 ldmmupteh(k0) ! 9 LS (latency=2)
434 shll2 k4 ! 101 EX _PAGE_ACCESSED
435
436 tst k4, k2 ! 68 MT
437
438 mov.l k3, @(MMU_PTEA-MMU_PTEH,k0) ! 27 LS
439
440 mov.l 7f, k3 ! 9 LS (latency=2) _PAGE_FLAGS_HARDWARE_MASK
441
442 ! k0=MMU_PTEH, k1=pte*, k2=pte, k3=_PAGE_FLAGS_HARDWARE, k4=_PAGE_ACCESSED
443#else
444
445 ! Test the entry for present and _PAGE_ACCESSED
446
447 mov.l 7f, k3 ! 9 LS (latency=2) _PAGE_FLAGS_HARDWARE_MASK
448 tst k4, k2 ! 68 MT
449
450 shll2 k4 ! 101 EX _PAGE_ACCESSED
451 ldmmupteh(k0) ! 9 LS (latency=2)
452
453 bt 20f ! 110 BR
454 tst k4, k2 ! 68 MT
455
456 ! k0=MMU_PTEH, k1=pte*, k2=pte, k3=_PAGE_FLAGS_HARDWARE, k4=_PAGE_ACCESSED
457
458#endif
459
460 ! Set up the entry
461
462 and k2, k3 ! 78 EX
463 bt/s 10f ! 108 BR
464
465 mov.l k3, @(MMU_PTEL-MMU_PTEH,k0) ! 27 LS
466
467 ldtlb ! 128 CO
468
469 ! At least one instruction between ldtlb and rte
470 nop ! 119 NOP
471
472 rte ! 126 CO
473
474 nop ! 119 NOP
475
476
47710: or k4, k2 ! 82 EX
478
479 ldtlb ! 128 CO
480
481 ! At least one instruction between ldtlb and rte
482 mov.l k2, @k1 ! 27 LS
483
484 rte ! 126 CO
485
486 ! Note we cannot execute mov here, because it is executed after
487 ! restoring SSR, so would be executed in user space.
488 nop ! 119 NOP
489
490
491 .align 5
492 ! Once cache line if possible...
4931: .long swapper_pg_dir
4944: .short (PTRS_PER_PGD-1) << 2
4955: .short _PAGE_PRESENT
4967: .long _PAGE_FLAGS_HARDWARE_MASK
4978: .long MMU_PTEH
498#ifdef COUNT_EXCEPTIONS
4999: .long exception_count_miss
500#endif
501
502 ! Either pgd or pte not present
50320: mov.l 1f, k2
667 mov.l 4f, k3 504 mov.l 4f, k3
668 bra handle_exception 505 bra handle_exception
669 mov.l @k2, k2 506 mov.l @k2, k2
@@ -710,8 +547,9 @@ ENTRY(handle_exception)
710 bt/s 1f ! It's a kernel to kernel transition. 547 bt/s 1f ! It's a kernel to kernel transition.
711 mov r15, k0 ! save original stack to k0 548 mov r15, k0 ! save original stack to k0
712 /* User space to kernel */ 549 /* User space to kernel */
713 mov #(THREAD_SIZE >> 8), k1 550 mov #(THREAD_SIZE >> 10), k1
714 shll8 k1 ! k1 := THREAD_SIZE 551 shll8 k1 ! k1 := THREAD_SIZE
552 shll2 k1
715 add current, k1 553 add current, k1
716 mov k1, r15 ! change to kernel stack 554 mov k1, r15 ! change to kernel stack
717 ! 555 !
@@ -761,7 +599,7 @@ skip_save:
761 ! Save the user registers on the stack. 599 ! Save the user registers on the stack.
762 mov.l k2, @-r15 ! EXPEVT 600 mov.l k2, @-r15 ! EXPEVT
763 601
764 mov #-1, k4 602 mov #-1, k4
765 mov.l k4, @-r15 ! set TRA (default: -1) 603 mov.l k4, @-r15 ! set TRA (default: -1)
766 ! 604 !
767 sts.l macl, @-r15 605 sts.l macl, @-r15
@@ -813,6 +651,15 @@ skip_save:
813 bf interrupt_exception 651 bf interrupt_exception
814 shlr2 r8 652 shlr2 r8
815 shlr r8 653 shlr r8
654
655#ifdef COUNT_EXCEPTIONS
656 mov.l 5f, r9
657 add r8, r9
658 mov.l @r9, r10
659 add #1, r10
660 mov.l r10, @r9
661#endif
662
816 mov.l 4f, r9 663 mov.l 4f, r9
817 add r8, r9 664 add r8, r9
818 mov.l @r9, r9 665 mov.l @r9, r9
@@ -826,6 +673,9 @@ skip_save:
8262: .long 0x000080f0 ! FD=1, IMASK=15 6732: .long 0x000080f0 ! FD=1, IMASK=15
8273: .long 0xcfffffff ! RB=0, BL=0 6743: .long 0xcfffffff ! RB=0, BL=0
8284: .long exception_handling_table 6754: .long exception_handling_table
676#ifdef COUNT_EXCEPTIONS
6775: .long exception_count_table
678#endif
829 679
830interrupt_exception: 680interrupt_exception:
831 mov.l 1f, r9 681 mov.l 1f, r9
diff --git a/arch/sh/kernel/cpu/sh4/Makefile b/arch/sh/kernel/cpu/sh4/Makefile
index 8dbf3895ece7..6e415baf04b4 100644
--- a/arch/sh/kernel/cpu/sh4/Makefile
+++ b/arch/sh/kernel/cpu/sh4/Makefile
@@ -2,7 +2,8 @@
2# Makefile for the Linux/SuperH SH-4 backends. 2# Makefile for the Linux/SuperH SH-4 backends.
3# 3#
4 4
5obj-y := ex.o probe.o 5obj-y := ex.o probe.o common.o
6common-y += $(addprefix ../sh3/, entry.o)
6 7
7obj-$(CONFIG_SH_FPU) += fpu.o 8obj-$(CONFIG_SH_FPU) += fpu.o
8obj-$(CONFIG_SH_STORE_QUEUES) += sq.o 9obj-$(CONFIG_SH_STORE_QUEUES) += sq.o
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
index bfdf5fe8d948..fa2019aabd74 100644
--- a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
+++ b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
@@ -97,7 +97,7 @@ static void shoc_clk_recalc(struct clk *clk)
97 97
98static int shoc_clk_verify_rate(struct clk *clk, unsigned long rate) 98static int shoc_clk_verify_rate(struct clk *clk, unsigned long rate)
99{ 99{
100 struct clk *bclk = clk_get("bus_clk"); 100 struct clk *bclk = clk_get(NULL, "bus_clk");
101 unsigned long bclk_rate = clk_get_rate(bclk); 101 unsigned long bclk_rate = clk_get_rate(bclk);
102 102
103 clk_put(bclk); 103 clk_put(bclk);
@@ -151,7 +151,7 @@ static struct clk *sh4202_onchip_clocks[] = {
151 151
152static int __init sh4202_clk_init(void) 152static int __init sh4202_clk_init(void)
153{ 153{
154 struct clk *clk = clk_get("master_clk"); 154 struct clk *clk = clk_get(NULL, "master_clk");
155 int i; 155 int i;
156 156
157 for (i = 0; i < ARRAY_SIZE(sh4202_onchip_clocks); i++) { 157 for (i = 0; i < ARRAY_SIZE(sh4202_onchip_clocks); i++) {
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh7780.c b/arch/sh/kernel/cpu/sh4/clock-sh7780.c
index 93ad367342c9..9e6a216750c8 100644
--- a/arch/sh/kernel/cpu/sh4/clock-sh7780.c
+++ b/arch/sh/kernel/cpu/sh4/clock-sh7780.c
@@ -98,7 +98,7 @@ static struct clk *sh7780_onchip_clocks[] = {
98 98
99static int __init sh7780_clk_init(void) 99static int __init sh7780_clk_init(void)
100{ 100{
101 struct clk *clk = clk_get("master_clk"); 101 struct clk *clk = clk_get(NULL, "master_clk");
102 int i; 102 int i;
103 103
104 for (i = 0; i < ARRAY_SIZE(sh7780_onchip_clocks); i++) { 104 for (i = 0; i < ARRAY_SIZE(sh7780_onchip_clocks); i++) {
diff --git a/arch/sh/kernel/cpu/sh4/fpu.c b/arch/sh/kernel/cpu/sh4/fpu.c
index f486c07e10e2..7624677f6628 100644
--- a/arch/sh/kernel/cpu/sh4/fpu.c
+++ b/arch/sh/kernel/cpu/sh4/fpu.c
@@ -282,11 +282,8 @@ ieee_fpe_handler (struct pt_regs *regs)
282 grab_fpu(regs); 282 grab_fpu(regs);
283 restore_fpu(tsk); 283 restore_fpu(tsk);
284 set_tsk_thread_flag(tsk, TIF_USEDFPU); 284 set_tsk_thread_flag(tsk, TIF_USEDFPU);
285 } else { 285 } else
286 tsk->thread.trap_no = 11;
287 tsk->thread.error_code = 0;
288 force_sig(SIGFPE, tsk); 286 force_sig(SIGFPE, tsk);
289 }
290 287
291 regs->pc = nextpc; 288 regs->pc = nextpc;
292 return 1; 289 return 1;
@@ -296,29 +293,29 @@ ieee_fpe_handler (struct pt_regs *regs)
296} 293}
297 294
298asmlinkage void 295asmlinkage void
299do_fpu_error(unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7, 296do_fpu_error(unsigned long r4, unsigned long r5, unsigned long r6,
300 struct pt_regs regs) 297 unsigned long r7, struct pt_regs __regs)
301{ 298{
299 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
302 struct task_struct *tsk = current; 300 struct task_struct *tsk = current;
303 301
304 if (ieee_fpe_handler (&regs)) 302 if (ieee_fpe_handler(regs))
305 return; 303 return;
306 304
307 regs.pc += 2; 305 regs->pc += 2;
308 save_fpu(tsk, &regs); 306 save_fpu(tsk, regs);
309 tsk->thread.trap_no = 11;
310 tsk->thread.error_code = 0;
311 force_sig(SIGFPE, tsk); 307 force_sig(SIGFPE, tsk);
312} 308}
313 309
314asmlinkage void 310asmlinkage void
315do_fpu_state_restore(unsigned long r4, unsigned long r5, unsigned long r6, 311do_fpu_state_restore(unsigned long r4, unsigned long r5, unsigned long r6,
316 unsigned long r7, struct pt_regs regs) 312 unsigned long r7, struct pt_regs __regs)
317{ 313{
314 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
318 struct task_struct *tsk = current; 315 struct task_struct *tsk = current;
319 316
320 grab_fpu(&regs); 317 grab_fpu(regs);
321 if (!user_mode(&regs)) { 318 if (!user_mode(regs)) {
322 printk(KERN_ERR "BUG: FPU is used in kernel mode.\n"); 319 printk(KERN_ERR "BUG: FPU is used in kernel mode.\n");
323 return; 320 return;
324 } 321 }
diff --git a/arch/sh/kernel/cpu/sh4/probe.c b/arch/sh/kernel/cpu/sh4/probe.c
index c294de1e14a3..afe0f1b1c030 100644
--- a/arch/sh/kernel/cpu/sh4/probe.c
+++ b/arch/sh/kernel/cpu/sh4/probe.c
@@ -79,16 +79,16 @@ int __init detect_cpu_and_cache_system(void)
79 case 0x205: 79 case 0x205:
80 cpu_data->type = CPU_SH7750; 80 cpu_data->type = CPU_SH7750;
81 cpu_data->flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_FPU | 81 cpu_data->flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_FPU |
82 CPU_HAS_PERF_COUNTER | CPU_HAS_PTEA; 82 CPU_HAS_PERF_COUNTER;
83 break; 83 break;
84 case 0x206: 84 case 0x206:
85 cpu_data->type = CPU_SH7750S; 85 cpu_data->type = CPU_SH7750S;
86 cpu_data->flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_FPU | 86 cpu_data->flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_FPU |
87 CPU_HAS_PERF_COUNTER | CPU_HAS_PTEA; 87 CPU_HAS_PERF_COUNTER;
88 break; 88 break;
89 case 0x1100: 89 case 0x1100:
90 cpu_data->type = CPU_SH7751; 90 cpu_data->type = CPU_SH7751;
91 cpu_data->flags |= CPU_HAS_FPU | CPU_HAS_PTEA; 91 cpu_data->flags |= CPU_HAS_FPU;
92 break; 92 break;
93 case 0x2000: 93 case 0x2000:
94 cpu_data->type = CPU_SH73180; 94 cpu_data->type = CPU_SH73180;
@@ -126,23 +126,22 @@ int __init detect_cpu_and_cache_system(void)
126 break; 126 break;
127 case 0x8000: 127 case 0x8000:
128 cpu_data->type = CPU_ST40RA; 128 cpu_data->type = CPU_ST40RA;
129 cpu_data->flags |= CPU_HAS_FPU | CPU_HAS_PTEA; 129 cpu_data->flags |= CPU_HAS_FPU;
130 break; 130 break;
131 case 0x8100: 131 case 0x8100:
132 cpu_data->type = CPU_ST40GX1; 132 cpu_data->type = CPU_ST40GX1;
133 cpu_data->flags |= CPU_HAS_FPU | CPU_HAS_PTEA; 133 cpu_data->flags |= CPU_HAS_FPU;
134 break; 134 break;
135 case 0x700: 135 case 0x700:
136 cpu_data->type = CPU_SH4_501; 136 cpu_data->type = CPU_SH4_501;
137 cpu_data->icache.ways = 2; 137 cpu_data->icache.ways = 2;
138 cpu_data->dcache.ways = 2; 138 cpu_data->dcache.ways = 2;
139 cpu_data->flags |= CPU_HAS_PTEA;
140 break; 139 break;
141 case 0x600: 140 case 0x600:
142 cpu_data->type = CPU_SH4_202; 141 cpu_data->type = CPU_SH4_202;
143 cpu_data->icache.ways = 2; 142 cpu_data->icache.ways = 2;
144 cpu_data->dcache.ways = 2; 143 cpu_data->dcache.ways = 2;
145 cpu_data->flags |= CPU_HAS_FPU | CPU_HAS_PTEA; 144 cpu_data->flags |= CPU_HAS_FPU;
146 break; 145 break;
147 case 0x500 ... 0x501: 146 case 0x500 ... 0x501:
148 switch (prr) { 147 switch (prr) {
@@ -160,7 +159,7 @@ int __init detect_cpu_and_cache_system(void)
160 cpu_data->icache.ways = 2; 159 cpu_data->icache.ways = 2;
161 cpu_data->dcache.ways = 2; 160 cpu_data->dcache.ways = 2;
162 161
163 cpu_data->flags |= CPU_HAS_FPU | CPU_HAS_PTEA; 162 cpu_data->flags |= CPU_HAS_FPU;
164 163
165 break; 164 break;
166 default: 165 default:
@@ -173,6 +172,10 @@ int __init detect_cpu_and_cache_system(void)
173 cpu_data->dcache.ways = 1; 172 cpu_data->dcache.ways = 1;
174#endif 173#endif
175 174
175#ifdef CONFIG_CPU_HAS_PTEA
176 cpu_data->flags |= CPU_HAS_PTEA;
177#endif
178
176 /* 179 /*
177 * On anything that's not a direct-mapped cache, look to the CVR 180 * On anything that's not a direct-mapped cache, look to the CVR
178 * for I/D-cache specifics. 181 * for I/D-cache specifics.
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7750.c b/arch/sh/kernel/cpu/sh4/setup-sh7750.c
index 50812d57c1c1..bbcb06f18b04 100644
--- a/arch/sh/kernel/cpu/sh4/setup-sh7750.c
+++ b/arch/sh/kernel/cpu/sh4/setup-sh7750.c
@@ -2,6 +2,7 @@
2 * SH7750/SH7751 Setup 2 * SH7750/SH7751 Setup
3 * 3 *
4 * Copyright (C) 2006 Paul Mundt 4 * Copyright (C) 2006 Paul Mundt
5 * Copyright (C) 2006 Jamie Lenehan
5 * 6 *
6 * This file is subject to the terms and conditions of the GNU General Public 7 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive 8 * License. See the file "COPYING" in the main directory of this archive
@@ -10,6 +11,7 @@
10#include <linux/platform_device.h> 11#include <linux/platform_device.h>
11#include <linux/init.h> 12#include <linux/init.h>
12#include <linux/serial.h> 13#include <linux/serial.h>
14#include <linux/io.h>
13#include <asm/sci.h> 15#include <asm/sci.h>
14 16
15static struct plat_sci_port sci_platform_data[] = { 17static struct plat_sci_port sci_platform_data[] = {
@@ -46,3 +48,71 @@ static int __init sh7750_devices_setup(void)
46 ARRAY_SIZE(sh7750_devices)); 48 ARRAY_SIZE(sh7750_devices));
47} 49}
48__initcall(sh7750_devices_setup); 50__initcall(sh7750_devices_setup);
51
52static struct ipr_data sh7750_ipr_map[] = {
53 /* IRQ, IPR-idx, shift, priority */
54 { 16, 0, 12, 2 }, /* TMU0 TUNI*/
55 { 17, 0, 12, 2 }, /* TMU1 TUNI */
56 { 18, 0, 4, 2 }, /* TMU2 TUNI */
57 { 19, 0, 4, 2 }, /* TMU2 TIPCI */
58 { 27, 1, 12, 2 }, /* WDT ITI */
59 { 20, 0, 0, 2 }, /* RTC ATI (alarm) */
60 { 21, 0, 0, 2 }, /* RTC PRI (period) */
61 { 22, 0, 0, 2 }, /* RTC CUI (carry) */
62 { 23, 1, 4, 3 }, /* SCI ERI */
63 { 24, 1, 4, 3 }, /* SCI RXI */
64 { 25, 1, 4, 3 }, /* SCI TXI */
65 { 40, 2, 4, 3 }, /* SCIF ERI */
66 { 41, 2, 4, 3 }, /* SCIF RXI */
67 { 42, 2, 4, 3 }, /* SCIF BRI */
68 { 43, 2, 4, 3 }, /* SCIF TXI */
69 { 34, 2, 8, 7 }, /* DMAC DMTE0 */
70 { 35, 2, 8, 7 }, /* DMAC DMTE1 */
71 { 36, 2, 8, 7 }, /* DMAC DMTE2 */
72 { 37, 2, 8, 7 }, /* DMAC DMTE3 */
73 { 28, 2, 8, 7 }, /* DMAC DMAE */
74};
75
76static struct ipr_data sh7751_ipr_map[] = {
77 { 44, 2, 8, 7 }, /* DMAC DMTE4 */
78 { 45, 2, 8, 7 }, /* DMAC DMTE5 */
79 { 46, 2, 8, 7 }, /* DMAC DMTE6 */
80 { 47, 2, 8, 7 }, /* DMAC DMTE7 */
81 /* The following use INTC_INPRI00 for masking, which is a 32-bit
82 register, not a 16-bit register like the IPRx registers, so it
83 would need special support */
84 /*{ 72, INTPRI00, 8, ? },*/ /* TMU3 TUNI */
85 /*{ 76, INTPRI00, 12, ? },*/ /* TMU4 TUNI */
86};
87
88static unsigned long ipr_offsets[] = {
89 0xffd00004UL, /* 0: IPRA */
90 0xffd00008UL, /* 1: IPRB */
91 0xffd0000cUL, /* 2: IPRC */
92 0xffd00010UL, /* 3: IPRD */
93};
94
95/* given the IPR index return the address of the IPR register */
96unsigned int map_ipridx_to_addr(int idx)
97{
98 if (idx >= ARRAY_SIZE(ipr_offsets))
99 return 0;
100 return ipr_offsets[idx];
101}
102
103#define INTC_ICR 0xffd00000UL
104#define INTC_ICR_IRLM (1<<7)
105
106/* enable individual interrupt mode for external interupts */
107void ipr_irq_enable_irlm(void)
108{
109 ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
110}
111
112void __init init_IRQ_ipr()
113{
114 make_ipr_irq(sh7750_ipr_map, ARRAY_SIZE(sh7750_ipr_map));
115#ifdef CONFIG_CPU_SUBTYPE_SH7751
116 make_ipr_irq(sh7751_ipr_map, ARRAY_SIZE(sh7751_ipr_map));
117#endif
118}
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7780.c b/arch/sh/kernel/cpu/sh4/setup-sh7780.c
index 814ddb226531..9aeaa2ddaa28 100644
--- a/arch/sh/kernel/cpu/sh4/setup-sh7780.c
+++ b/arch/sh/kernel/cpu/sh4/setup-sh7780.c
@@ -79,25 +79,27 @@ static int __init sh7780_devices_setup(void)
79__initcall(sh7780_devices_setup); 79__initcall(sh7780_devices_setup);
80 80
81static struct intc2_data intc2_irq_table[] = { 81static struct intc2_data intc2_irq_table[] = {
82 { TIMER_IRQ, 0, 24, 0, INTC_TMU0_MSK, 2 }, 82 { 28, 0, 24, 0, 0, 2 }, /* TMU0 */
83 { 21, 1, 0, 0, INTC_RTC_MSK, TIMER_PRIORITY },
84 { 22, 1, 1, 0, INTC_RTC_MSK, TIMER_PRIORITY },
85 { 23, 1, 2, 0, INTC_RTC_MSK, TIMER_PRIORITY },
86 { SCIF0_ERI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
87 { SCIF0_RXI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
88 { SCIF0_BRI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
89 { SCIF0_TXI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
90 83
91 { SCIF1_ERI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY }, 84 { 21, 1, 0, 0, 2, 2 },
92 { SCIF1_RXI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY }, 85 { 22, 1, 1, 0, 2, 2 },
93 { SCIF1_BRI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY }, 86 { 23, 1, 2, 0, 2, 2 },
94 { SCIF1_TXI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY },
95 87
96 { PCIC0_IRQ, 0x10, 8, 0, INTC_PCIC0_MSK, PCIC0_PRIORITY }, 88 { 40, 8, 24, 0, 3, 3 }, /* SCIF0 ERI */
97 { PCIC1_IRQ, 0x10, 0, 0, INTC_PCIC1_MSK, PCIC1_PRIORITY }, 89 { 41, 8, 24, 0, 3, 3 }, /* SCIF0 RXI */
98 { PCIC2_IRQ, 0x14, 24, 0, INTC_PCIC2_MSK, PCIC2_PRIORITY }, 90 { 42, 8, 24, 0, 3, 3 }, /* SCIF0 BRI */
99 { PCIC3_IRQ, 0x14, 16, 0, INTC_PCIC3_MSK, PCIC3_PRIORITY }, 91 { 43, 8, 24, 0, 3, 3 }, /* SCIF0 TXI */
100 { PCIC4_IRQ, 0x14, 8, 0, INTC_PCIC4_MSK, PCIC4_PRIORITY }, 92
93 { 76, 8, 16, 0, 4, 3 }, /* SCIF1 ERI */
94 { 77, 8, 16, 0, 4, 3 }, /* SCIF1 RXI */
95 { 78, 8, 16, 0, 4, 3 }, /* SCIF1 BRI */
96 { 79, 8, 16, 0, 4, 3 }, /* SCIF1 TXI */
97
98 { 64, 0x10, 8, 0, 14, 2 }, /* PCIC0 */
99 { 65, 0x10, 0, 0, 15, 2 }, /* PCIC1 */
100 { 66, 0x14, 24, 0, 16, 2 }, /* PCIC2 */
101 { 67, 0x14, 16, 0, 17, 2 }, /* PCIC3 */
102 { 68, 0x14, 8, 0, 18, 2 }, /* PCIC4 */
101}; 103};
102 104
103void __init init_IRQ_intc2(void) 105void __init init_IRQ_intc2(void)
diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c
index 7bcc73f9b8df..0c9ea38d2caa 100644
--- a/arch/sh/kernel/cpu/sh4/sq.c
+++ b/arch/sh/kernel/cpu/sh4/sq.c
@@ -19,7 +19,7 @@
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/vmalloc.h> 20#include <linux/vmalloc.h>
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <asm/io.h> 22#include <linux/io.h>
23#include <asm/page.h> 23#include <asm/page.h>
24#include <asm/cacheflush.h> 24#include <asm/cacheflush.h>
25#include <asm/cpu/sq.h> 25#include <asm/cpu/sq.h>
@@ -38,7 +38,7 @@ struct sq_mapping {
38 38
39static struct sq_mapping *sq_mapping_list; 39static struct sq_mapping *sq_mapping_list;
40static DEFINE_SPINLOCK(sq_mapping_lock); 40static DEFINE_SPINLOCK(sq_mapping_lock);
41static kmem_cache_t *sq_cache; 41static struct kmem_cache *sq_cache;
42static unsigned long *sq_bitmap; 42static unsigned long *sq_bitmap;
43 43
44#define store_queue_barrier() \ 44#define store_queue_barrier() \
@@ -67,6 +67,7 @@ void sq_flush_range(unsigned long start, unsigned int len)
67 /* Wait for completion */ 67 /* Wait for completion */
68 store_queue_barrier(); 68 store_queue_barrier();
69} 69}
70EXPORT_SYMBOL(sq_flush_range);
70 71
71static inline void sq_mapping_list_add(struct sq_mapping *map) 72static inline void sq_mapping_list_add(struct sq_mapping *map)
72{ 73{
@@ -166,7 +167,7 @@ unsigned long sq_remap(unsigned long phys, unsigned int size,
166 map->size = size; 167 map->size = size;
167 map->name = name; 168 map->name = name;
168 169
169 page = bitmap_find_free_region(sq_bitmap, 0x04000000, 170 page = bitmap_find_free_region(sq_bitmap, 0x04000000 >> PAGE_SHIFT,
170 get_order(map->size)); 171 get_order(map->size));
171 if (unlikely(page < 0)) { 172 if (unlikely(page < 0)) {
172 ret = -ENOSPC; 173 ret = -ENOSPC;
@@ -193,6 +194,7 @@ out:
193 kmem_cache_free(sq_cache, map); 194 kmem_cache_free(sq_cache, map);
194 return ret; 195 return ret;
195} 196}
197EXPORT_SYMBOL(sq_remap);
196 198
197/** 199/**
198 * sq_unmap - Unmap a Store Queue allocation 200 * sq_unmap - Unmap a Store Queue allocation
@@ -234,6 +236,7 @@ void sq_unmap(unsigned long vaddr)
234 236
235 kmem_cache_free(sq_cache, map); 237 kmem_cache_free(sq_cache, map);
236} 238}
239EXPORT_SYMBOL(sq_unmap);
237 240
238/* 241/*
239 * Needlessly complex sysfs interface. Unfortunately it doesn't seem like 242 * Needlessly complex sysfs interface. Unfortunately it doesn't seem like
@@ -402,7 +405,3 @@ module_exit(sq_api_exit);
402MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>, M. R. Brown <mrbrown@0xd6.org>"); 405MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>, M. R. Brown <mrbrown@0xd6.org>");
403MODULE_DESCRIPTION("Simple API for SH-4 integrated Store Queues"); 406MODULE_DESCRIPTION("Simple API for SH-4 integrated Store Queues");
404MODULE_LICENSE("GPL"); 407MODULE_LICENSE("GPL");
405
406EXPORT_SYMBOL(sq_remap);
407EXPORT_SYMBOL(sq_unmap);
408EXPORT_SYMBOL(sq_flush_range);
diff --git a/arch/sh/kernel/early_printk.c b/arch/sh/kernel/early_printk.c
index a00022722e9e..60340823798a 100644
--- a/arch/sh/kernel/early_printk.c
+++ b/arch/sh/kernel/early_printk.c
@@ -12,7 +12,7 @@
12#include <linux/console.h> 12#include <linux/console.h>
13#include <linux/tty.h> 13#include <linux/tty.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <asm/io.h> 15#include <linux/io.h>
16 16
17#ifdef CONFIG_SH_STANDARD_BIOS 17#ifdef CONFIG_SH_STANDARD_BIOS
18#include <asm/sh_bios.h> 18#include <asm/sh_bios.h>
@@ -62,17 +62,9 @@ static struct console bios_console = {
62#include <linux/serial_core.h> 62#include <linux/serial_core.h>
63#include "../../../drivers/serial/sh-sci.h" 63#include "../../../drivers/serial/sh-sci.h"
64 64
65#ifdef CONFIG_CPU_SH4
66#define SCIF_REG 0xffe80000
67#elif defined(CONFIG_CPU_SUBTYPE_SH72060)
68#define SCIF_REG 0xfffe9800
69#else
70#error "Undefined SCIF for this subtype"
71#endif
72
73static struct uart_port scif_port = { 65static struct uart_port scif_port = {
74 .mapbase = SCIF_REG, 66 .mapbase = CONFIG_EARLY_SCIF_CONSOLE_PORT,
75 .membase = (char __iomem *)SCIF_REG, 67 .membase = (char __iomem *)CONFIG_EARLY_SCIF_CONSOLE_PORT,
76}; 68};
77 69
78static void scif_sercon_putc(int c) 70static void scif_sercon_putc(int c)
@@ -113,23 +105,29 @@ static struct console scif_console = {
113 .index = -1, 105 .index = -1,
114}; 106};
115 107
108#if defined(CONFIG_CPU_SH4) && !defined(CONFIG_SH_STANDARD_BIOS)
109/*
110 * Simple SCIF init, primarily aimed at SH7750 and other similar SH-4
111 * devices that aren't using sh-ipl+g.
112 */
116static void scif_sercon_init(int baud) 113static void scif_sercon_init(int baud)
117{ 114{
118 ctrl_outw(0, SCIF_REG + 8); 115 ctrl_outw(0, scif_port.mapbase + 8);
119 ctrl_outw(0, SCIF_REG); 116 ctrl_outw(0, scif_port.mapbase);
120 117
121 /* Set baud rate */ 118 /* Set baud rate */
122 ctrl_outb((CONFIG_SH_PCLK_FREQ + 16 * baud) / 119 ctrl_outb((CONFIG_SH_PCLK_FREQ + 16 * baud) /
123 (32 * baud) - 1, SCIF_REG + 4); 120 (32 * baud) - 1, scif_port.mapbase + 4);
124 121
125 ctrl_outw(12, SCIF_REG + 24); 122 ctrl_outw(12, scif_port.mapbase + 24);
126 ctrl_outw(8, SCIF_REG + 24); 123 ctrl_outw(8, scif_port.mapbase + 24);
127 ctrl_outw(0, SCIF_REG + 32); 124 ctrl_outw(0, scif_port.mapbase + 32);
128 ctrl_outw(0x60, SCIF_REG + 16); 125 ctrl_outw(0x60, scif_port.mapbase + 16);
129 ctrl_outw(0, SCIF_REG + 36); 126 ctrl_outw(0, scif_port.mapbase + 36);
130 ctrl_outw(0x30, SCIF_REG + 8); 127 ctrl_outw(0x30, scif_port.mapbase + 8);
131} 128}
132#endif 129#endif /* CONFIG_CPU_SH4 && !CONFIG_SH_STANDARD_BIOS */
130#endif /* CONFIG_EARLY_SCIF_CONSOLE */
133 131
134/* 132/*
135 * Setup a default console, if more than one is compiled in, rely on the 133 * Setup a default console, if more than one is compiled in, rely on the
@@ -168,7 +166,7 @@ int __init setup_early_printk(char *opt)
168 if (!strncmp(buf, "serial", 6)) { 166 if (!strncmp(buf, "serial", 6)) {
169 early_console = &scif_console; 167 early_console = &scif_console;
170 168
171#ifdef CONFIG_CPU_SH4 169#if defined(CONFIG_CPU_SH4) && !defined(CONFIG_SH_STANDARD_BIOS)
172 scif_sercon_init(115200); 170 scif_sercon_init(115200);
173#endif 171#endif
174 } 172 }
diff --git a/arch/sh/kernel/entry-common.S b/arch/sh/kernel/entry-common.S
new file mode 100644
index 000000000000..29136a35d7c7
--- /dev/null
+++ b/arch/sh/kernel/entry-common.S
@@ -0,0 +1,433 @@
1/* $Id: entry.S,v 1.37 2004/06/11 13:02:46 doyu Exp $
2 *
3 * linux/arch/sh/entry.S
4 *
5 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka
6 * Copyright (C) 2003 Paul Mundt
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 *
12 */
13
14! NOTE:
15! GNU as (as of 2.9.1) changes bf/s into bt/s and bra, when the address
16! to be jumped is too far, but it causes illegal slot exception.
17
18/*
19 * entry.S contains the system-call and fault low-level handling routines.
20 * This also contains the timer-interrupt handler, as well as all interrupts
21 * and faults that can result in a task-switch.
22 *
23 * NOTE: This code handles signal-recognition, which happens every time
24 * after a timer-interrupt and after each system call.
25 *
26 * NOTE: This code uses a convention that instructions in the delay slot
27 * of a transfer-control instruction are indented by an extra space, thus:
28 *
29 * jmp @k0 ! control-transfer instruction
30 * ldc k1, ssr ! delay slot
31 *
32 * Stack layout in 'ret_from_syscall':
33 * ptrace needs to have all regs on the stack.
34 * if the order here is changed, it needs to be
35 * updated in ptrace.c and ptrace.h
36 *
37 * r0
38 * ...
39 * r15 = stack pointer
40 * spc
41 * pr
42 * ssr
43 * gbr
44 * mach
45 * macl
46 * syscall #
47 *
48 */
49
50#if defined(CONFIG_PREEMPT)
51# define preempt_stop() cli
52#else
53# define preempt_stop()
54# define resume_kernel __restore_all
55#endif
56
57#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
58! Handle kernel debug if either kgdb (SW) or gdb-stub (FW) is present.
59! If both are configured, handle the debug traps (breakpoints) in SW,
60! but still allow BIOS traps to FW.
61
62 .align 2
63debug_kernel:
64#if defined(CONFIG_SH_STANDARD_BIOS) && defined(CONFIG_SH_KGDB)
65 /* Force BIOS call to FW (debug_trap put TRA in r8) */
66 mov r8,r0
67 shlr2 r0
68 cmp/eq #0x3f,r0
69 bt debug_kernel_fw
70#endif /* CONFIG_SH_STANDARD_BIOS && CONFIG_SH_KGDB */
71
72debug_enter:
73#if defined(CONFIG_SH_KGDB)
74 /* Jump to kgdb, pass stacked regs as arg */
75debug_kernel_sw:
76 mov.l 3f, r0
77 jmp @r0
78 mov r15, r4
79 .align 2
803: .long kgdb_handle_exception
81#endif /* CONFIG_SH_KGDB */
82
83#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
84
85
86 .align 2
87debug_trap:
88#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
89 mov #OFF_SR, r0
90 mov.l @(r0,r15), r0 ! get status register
91 shll r0
92 shll r0 ! kernel space?
93 bt/s debug_kernel
94#endif
95 mov.l @r15, r0 ! Restore R0 value
96 mov.l 1f, r8
97 jmp @r8
98 nop
99
100 .align 2
101ENTRY(exception_error)
102 !
103#ifdef CONFIG_TRACE_IRQFLAGS
104 mov.l 3f, r0
105 jsr @r0
106 nop
107#endif
108 sti
109 mov.l 2f, r0
110 jmp @r0
111 nop
112
113!
114 .align 2
1151: .long break_point_trap_software
1162: .long do_exception_error
117#ifdef CONFIG_TRACE_IRQFLAGS
1183: .long trace_hardirqs_on
119#endif
120
121 .align 2
122ret_from_exception:
123 preempt_stop()
124#ifdef CONFIG_TRACE_IRQFLAGS
125 mov.l 4f, r0
126 jsr @r0
127 nop
128#endif
129ENTRY(ret_from_irq)
130 !
131 mov #OFF_SR, r0
132 mov.l @(r0,r15), r0 ! get status register
133 shll r0
134 shll r0 ! kernel space?
135 get_current_thread_info r8, r0
136 bt resume_kernel ! Yes, it's from kernel, go back soon
137
138#ifdef CONFIG_PREEMPT
139 bra resume_userspace
140 nop
141ENTRY(resume_kernel)
142 mov.l @(TI_PRE_COUNT,r8), r0 ! current_thread_info->preempt_count
143 tst r0, r0
144 bf noresched
145need_resched:
146 mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags
147 tst #_TIF_NEED_RESCHED, r0 ! need_resched set?
148 bt noresched
149
150 mov #OFF_SR, r0
151 mov.l @(r0,r15), r0 ! get status register
152 and #0xf0, r0 ! interrupts off (exception path)?
153 cmp/eq #0xf0, r0
154 bt noresched
155
156 mov.l 1f, r0
157 mov.l r0, @(TI_PRE_COUNT,r8)
158
159#ifdef CONFIG_TRACE_IRQFLAGS
160 mov.l 3f, r0
161 jsr @r0
162 nop
163#endif
164 sti
165 mov.l 2f, r0
166 jsr @r0
167 nop
168 mov #0, r0
169 mov.l r0, @(TI_PRE_COUNT,r8)
170 cli
171#ifdef CONFIG_TRACE_IRQFLAGS
172 mov.l 4f, r0
173 jsr @r0
174 nop
175#endif
176
177 bra need_resched
178 nop
179
180noresched:
181 bra __restore_all
182 nop
183
184 .align 2
1851: .long PREEMPT_ACTIVE
1862: .long schedule
187#ifdef CONFIG_TRACE_IRQFLAGS
1883: .long trace_hardirqs_on
1894: .long trace_hardirqs_off
190#endif
191#endif
192
193ENTRY(resume_userspace)
194 ! r8: current_thread_info
195 cli
196#ifdef CONFIG_TRACE_IRQFLAGS
197 mov.l 5f, r0
198 jsr @r0
199 nop
200#endif
201 mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags
202 tst #_TIF_WORK_MASK, r0
203 bt/s __restore_all
204 tst #_TIF_NEED_RESCHED, r0
205
206 .align 2
207work_pending:
208 ! r0: current_thread_info->flags
209 ! r8: current_thread_info
210 ! t: result of "tst #_TIF_NEED_RESCHED, r0"
211 bf/s work_resched
212 tst #(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK), r0
213work_notifysig:
214 bt/s __restore_all
215 mov r15, r4
216 mov r12, r5 ! set arg1(save_r0)
217 mov r0, r6
218 mov.l 2f, r1
219 mov.l 3f, r0
220 jmp @r1
221 lds r0, pr
222work_resched:
223#ifndef CONFIG_PREEMPT
224 ! gUSA handling
225 mov.l @(OFF_SP,r15), r0 ! get user space stack pointer
226 mov r0, r1
227 shll r0
228 bf/s 1f
229 shll r0
230 bf/s 1f
231 mov #OFF_PC, r0
232 ! SP >= 0xc0000000 : gUSA mark
233 mov.l @(r0,r15), r2 ! get user space PC (program counter)
234 mov.l @(OFF_R0,r15), r3 ! end point
235 cmp/hs r3, r2 ! r2 >= r3?
236 bt 1f
237 add r3, r1 ! rewind point #2
238 mov.l r1, @(r0,r15) ! reset PC to rewind point #2
239 !
2401:
241#endif
242 mov.l 1f, r1
243 jsr @r1 ! schedule
244 nop
245 cli
246#ifdef CONFIG_TRACE_IRQFLAGS
247 mov.l 5f, r0
248 jsr @r0
249 nop
250#endif
251 !
252 mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags
253 tst #_TIF_WORK_MASK, r0
254 bt __restore_all
255 bra work_pending
256 tst #_TIF_NEED_RESCHED, r0
257
258 .align 2
2591: .long schedule
2602: .long do_notify_resume
2613: .long restore_all
262#ifdef CONFIG_TRACE_IRQFLAGS
2634: .long trace_hardirqs_on
2645: .long trace_hardirqs_off
265#endif
266
267 .align 2
268syscall_exit_work:
269 ! r0: current_thread_info->flags
270 ! r8: current_thread_info
271 tst #_TIF_SYSCALL_TRACE, r0
272 bt/s work_pending
273 tst #_TIF_NEED_RESCHED, r0
274#ifdef CONFIG_TRACE_IRQFLAGS
275 mov.l 5f, r0
276 jsr @r0
277 nop
278#endif
279 sti
280 ! XXX setup arguments...
281 mov.l 4f, r0 ! do_syscall_trace
282 jsr @r0
283 nop
284 bra resume_userspace
285 nop
286
287 .align 2
288syscall_trace_entry:
289 ! Yes it is traced.
290 ! XXX setup arguments...
291 mov.l 4f, r11 ! Call do_syscall_trace which notifies
292 jsr @r11 ! superior (will chomp R[0-7])
293 nop
294 ! Reload R0-R4 from kernel stack, where the
295 ! parent may have modified them using
296 ! ptrace(POKEUSR). (Note that R0-R2 are
297 ! used by the system call handler directly
298 ! from the kernel stack anyway, so don't need
299 ! to be reloaded here.) This allows the parent
300 ! to rewrite system calls and args on the fly.
301 mov.l @(OFF_R4,r15), r4 ! arg0
302 mov.l @(OFF_R5,r15), r5
303 mov.l @(OFF_R6,r15), r6
304 mov.l @(OFF_R7,r15), r7 ! arg3
305 mov.l @(OFF_R3,r15), r3 ! syscall_nr
306 !
307 mov.l 2f, r10 ! Number of syscalls
308 cmp/hs r10, r3
309 bf syscall_call
310 mov #-ENOSYS, r0
311 bra syscall_exit
312 mov.l r0, @(OFF_R0,r15) ! Return value
313
314__restore_all:
315 mov.l 1f, r0
316 jmp @r0
317 nop
318
319 .align 2
3201: .long restore_all
321
322 .align 2
323not_syscall_tra:
324 bra debug_trap
325 nop
326
327 .align 2
328syscall_badsys: ! Bad syscall number
329 mov #-ENOSYS, r0
330 bra resume_userspace
331 mov.l r0, @(OFF_R0,r15) ! Return value
332
333
334/*
335 * Syscall interface:
336 *
337 * Syscall #: R3
338 * Arguments #0 to #3: R4--R7
339 * Arguments #4 to #6: R0, R1, R2
340 * TRA: (number of arguments + 0x10) x 4
341 *
342 * This code also handles delegating other traps to the BIOS/gdb stub
343 * according to:
344 *
345 * Trap number
346 * (TRA>>2) Purpose
347 * -------- -------
348 * 0x0-0xf old syscall ABI
349 * 0x10-0x1f new syscall ABI
350 * 0x20-0xff delegated through debug_trap to BIOS/gdb stub.
351 *
352 * Note: When we're first called, the TRA value must be shifted
353 * right 2 bits in order to get the value that was used as the "trapa"
354 * argument.
355 */
356
357 .align 2
358 .globl ret_from_fork
359ret_from_fork:
360 mov.l 1f, r8
361 jsr @r8
362 mov r0, r4
363 bra syscall_exit
364 nop
365 .align 2
3661: .long schedule_tail
367 !
368ENTRY(system_call)
369#if !defined(CONFIG_CPU_SH2)
370 mov.l 1f, r9
371 mov.l @r9, r8 ! Read from TRA (Trap Address) Register
372#endif
373 !
374 ! Is the trap argument >= 0x20? (TRA will be >= 0x80)
375 mov #0x7f, r9
376 cmp/hi r9, r8
377 bt/s not_syscall_tra
378 mov #OFF_TRA, r9
379 add r15, r9
380 mov.l r8, @r9 ! set TRA value to tra
381#ifdef CONFIG_TRACE_IRQFLAGS
382 mov.l 5f, r10
383 jsr @r10
384 nop
385#endif
386 sti
387
388 !
389 get_current_thread_info r8, r10
390 mov.l @(TI_FLAGS,r8), r8
391 mov #_TIF_SYSCALL_TRACE, r10
392 tst r10, r8
393 bf syscall_trace_entry
394 !
395 mov.l 2f, r8 ! Number of syscalls
396 cmp/hs r8, r3
397 bt syscall_badsys
398 !
399syscall_call:
400 shll2 r3 ! x4
401 mov.l 3f, r8 ! Load the address of sys_call_table
402 add r8, r3
403 mov.l @r3, r8
404 jsr @r8 ! jump to specific syscall handler
405 nop
406 mov.l @(OFF_R0,r15), r12 ! save r0
407 mov.l r0, @(OFF_R0,r15) ! save the return value
408 !
409syscall_exit:
410 cli
411#ifdef CONFIG_TRACE_IRQFLAGS
412 mov.l 6f, r0
413 jsr @r0
414 nop
415#endif
416 !
417 get_current_thread_info r8, r0
418 mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags
419 tst #_TIF_ALLWORK_MASK, r0
420 bf syscall_exit_work
421 bra __restore_all
422 nop
423 .align 2
424#if !defined(CONFIG_CPU_SH2)
4251: .long TRA
426#endif
4272: .long NR_syscalls
4283: .long sys_call_table
4294: .long do_syscall_trace
430#ifdef CONFIG_TRACE_IRQFLAGS
4315: .long trace_hardirqs_on
4326: .long trace_hardirqs_off
433#endif
diff --git a/arch/sh/kernel/head.S b/arch/sh/kernel/head.S
index f5f53d14f245..6aca4bc6ec5d 100644
--- a/arch/sh/kernel/head.S
+++ b/arch/sh/kernel/head.S
@@ -33,7 +33,7 @@ ENTRY(empty_zero_page)
33 .long 0x00360000 /* INITRD_START */ 33 .long 0x00360000 /* INITRD_START */
34 .long 0x000a0000 /* INITRD_SIZE */ 34 .long 0x000a0000 /* INITRD_SIZE */
35 .long 0 35 .long 0
36 .balign 4096,0,4096 36 .balign PAGE_SIZE,0,PAGE_SIZE
37 37
38 .text 38 .text
39/* 39/*
@@ -53,8 +53,10 @@ ENTRY(_stext)
53 ldc r0, sr 53 ldc r0, sr
54 ! Initialize global interrupt mask 54 ! Initialize global interrupt mask
55 mov #0, r0 55 mov #0, r0
56#ifdef CONFIG_CPU_HAS_SR_RB
56 ldc r0, r6_bank 57 ldc r0, r6_bank
57 58#endif
59
58 /* 60 /*
59 * Prefetch if possible to reduce cache miss penalty. 61 * Prefetch if possible to reduce cache miss penalty.
60 * 62 *
@@ -68,11 +70,14 @@ ENTRY(_stext)
68 ! 70 !
69 mov.l 2f, r0 71 mov.l 2f, r0
70 mov r0, r15 ! Set initial r15 (stack pointer) 72 mov r0, r15 ! Set initial r15 (stack pointer)
71 mov #(THREAD_SIZE >> 8), r1 73 mov #(THREAD_SIZE >> 10), r1
72 shll8 r1 ! r1 = THREAD_SIZE 74 shll8 r1 ! r1 = THREAD_SIZE
75 shll2 r1
73 sub r1, r0 ! 76 sub r1, r0 !
77#ifdef CONFIG_CPU_HAS_SR_RB
74 ldc r0, r7_bank ! ... and initial thread_info 78 ldc r0, r7_bank ! ... and initial thread_info
75 79#endif
80
76 ! Clear BSS area 81 ! Clear BSS area
77 mov.l 3f, r1 82 mov.l 3f, r1
78 add #4, r1 83 add #4, r1
@@ -95,7 +100,11 @@ ENTRY(_stext)
95 nop 100 nop
96 101
97 .balign 4 102 .balign 4
103#if defined(CONFIG_CPU_SH2)
1041: .long 0x000000F0 ! IMASK=0xF
105#else
981: .long 0x400080F0 ! MD=1, RB=0, BL=0, FD=1, IMASK=0xF 1061: .long 0x400080F0 ! MD=1, RB=0, BL=0, FD=1, IMASK=0xF
107#endif
992: .long init_thread_union+THREAD_SIZE 1082: .long init_thread_union+THREAD_SIZE
1003: .long __bss_start 1093: .long __bss_start
1014: .long _end 1104: .long _end
diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
index 944128ce9706..67be2b6e8cd1 100644
--- a/arch/sh/kernel/irq.c
+++ b/arch/sh/kernel/irq.c
@@ -12,7 +12,7 @@
12#include <linux/kernel_stat.h> 12#include <linux/kernel_stat.h>
13#include <linux/seq_file.h> 13#include <linux/seq_file.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <asm/irq.h> 15#include <linux/irq.h>
16#include <asm/processor.h> 16#include <asm/processor.h>
17#include <asm/uaccess.h> 17#include <asm/uaccess.h>
18#include <asm/thread_info.h> 18#include <asm/thread_info.h>
@@ -78,15 +78,16 @@ union irq_ctx {
78 u32 stack[THREAD_SIZE/sizeof(u32)]; 78 u32 stack[THREAD_SIZE/sizeof(u32)];
79}; 79};
80 80
81static union irq_ctx *hardirq_ctx[NR_CPUS]; 81static union irq_ctx *hardirq_ctx[NR_CPUS] __read_mostly;
82static union irq_ctx *softirq_ctx[NR_CPUS]; 82static union irq_ctx *softirq_ctx[NR_CPUS] __read_mostly;
83#endif 83#endif
84 84
85asmlinkage int do_IRQ(unsigned long r4, unsigned long r5, 85asmlinkage int do_IRQ(unsigned long r4, unsigned long r5,
86 unsigned long r6, unsigned long r7, 86 unsigned long r6, unsigned long r7,
87 struct pt_regs regs) 87 struct pt_regs __regs)
88{ 88{
89 struct pt_regs *old_regs = set_irq_regs(&regs); 89 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
90 struct pt_regs *old_regs = set_irq_regs(regs);
90 int irq; 91 int irq;
91#ifdef CONFIG_4KSTACKS 92#ifdef CONFIG_4KSTACKS
92 union irq_ctx *curctx, *irqctx; 93 union irq_ctx *curctx, *irqctx;
@@ -111,7 +112,7 @@ asmlinkage int do_IRQ(unsigned long r4, unsigned long r5,
111#endif 112#endif
112 113
113#ifdef CONFIG_CPU_HAS_INTEVT 114#ifdef CONFIG_CPU_HAS_INTEVT
114 irq = (ctrl_inl(INTEVT) >> 5) - 16; 115 irq = evt2irq(ctrl_inl(INTEVT));
115#else 116#else
116 irq = r4; 117 irq = r4;
117#endif 118#endif
@@ -135,17 +136,24 @@ asmlinkage int do_IRQ(unsigned long r4, unsigned long r5,
135 irqctx->tinfo.task = curctx->tinfo.task; 136 irqctx->tinfo.task = curctx->tinfo.task;
136 irqctx->tinfo.previous_sp = current_stack_pointer; 137 irqctx->tinfo.previous_sp = current_stack_pointer;
137 138
139 /*
140 * Copy the softirq bits in preempt_count so that the
141 * softirq checks work in the hardirq context.
142 */
143 irqctx->tinfo.preempt_count =
144 (irqctx->tinfo.preempt_count & ~SOFTIRQ_MASK) |
145 (curctx->tinfo.preempt_count & SOFTIRQ_MASK);
146
138 __asm__ __volatile__ ( 147 __asm__ __volatile__ (
139 "mov %0, r4 \n" 148 "mov %0, r4 \n"
140 "mov r15, r9 \n" 149 "mov r15, r8 \n"
141 "jsr @%1 \n" 150 "jsr @%1 \n"
142 /* swith to the irq stack */ 151 /* swith to the irq stack */
143 " mov %2, r15 \n" 152 " mov %2, r15 \n"
144 /* restore the stack (ring zero) */ 153 /* restore the stack (ring zero) */
145 "mov r9, r15 \n" 154 "mov r8, r15 \n"
146 : /* no outputs */ 155 : /* no outputs */
147 : "r" (irq), "r" (generic_handle_irq), "r" (isp) 156 : "r" (irq), "r" (generic_handle_irq), "r" (isp)
148 /* XXX: A somewhat excessive clobber list? -PFM */
149 : "memory", "r0", "r1", "r2", "r3", "r4", 157 : "memory", "r0", "r1", "r2", "r3", "r4",
150 "r5", "r6", "r7", "r8", "t", "pr" 158 "r5", "r6", "r7", "r8", "t", "pr"
151 ); 159 );
@@ -193,7 +201,7 @@ void irq_ctx_init(int cpu)
193 irqctx->tinfo.task = NULL; 201 irqctx->tinfo.task = NULL;
194 irqctx->tinfo.exec_domain = NULL; 202 irqctx->tinfo.exec_domain = NULL;
195 irqctx->tinfo.cpu = cpu; 203 irqctx->tinfo.cpu = cpu;
196 irqctx->tinfo.preempt_count = SOFTIRQ_OFFSET; 204 irqctx->tinfo.preempt_count = 0;
197 irqctx->tinfo.addr_limit = MAKE_MM_SEG(0); 205 irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
198 206
199 softirq_ctx[cpu] = irqctx; 207 softirq_ctx[cpu] = irqctx;
@@ -239,13 +247,38 @@ asmlinkage void do_softirq(void)
239 "mov r9, r15 \n" 247 "mov r9, r15 \n"
240 : /* no outputs */ 248 : /* no outputs */
241 : "r" (__do_softirq), "r" (isp) 249 : "r" (__do_softirq), "r" (isp)
242 /* XXX: A somewhat excessive clobber list? -PFM */
243 : "memory", "r0", "r1", "r2", "r3", "r4", 250 : "memory", "r0", "r1", "r2", "r3", "r4",
244 "r5", "r6", "r7", "r8", "r9", "r15", "t", "pr" 251 "r5", "r6", "r7", "r8", "r9", "r15", "t", "pr"
245 ); 252 );
253
254 /*
255 * Shouldnt happen, we returned above if in_interrupt():
256 */
257 WARN_ON_ONCE(softirq_count());
246 } 258 }
247 259
248 local_irq_restore(flags); 260 local_irq_restore(flags);
249} 261}
250EXPORT_SYMBOL(do_softirq); 262EXPORT_SYMBOL(do_softirq);
251#endif 263#endif
264
265void __init init_IRQ(void)
266{
267#ifdef CONFIG_CPU_HAS_PINT_IRQ
268 init_IRQ_pint();
269#endif
270
271#ifdef CONFIG_CPU_HAS_INTC2_IRQ
272 init_IRQ_intc2();
273#endif
274
275#ifdef CONFIG_CPU_HAS_IPR_IRQ
276 init_IRQ_ipr();
277#endif
278
279 /* Perform the machine specific initialisation */
280 if (sh_mv.mv_init_irq)
281 sh_mv.mv_init_irq();
282
283 irq_ctx_init(smp_processor_id());
284}
diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
index a52b13ac6b7f..f3e2631be144 100644
--- a/arch/sh/kernel/process.c
+++ b/arch/sh/kernel/process.c
@@ -385,10 +385,11 @@ struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *ne
385 385
386asmlinkage int sys_fork(unsigned long r4, unsigned long r5, 386asmlinkage int sys_fork(unsigned long r4, unsigned long r5,
387 unsigned long r6, unsigned long r7, 387 unsigned long r6, unsigned long r7,
388 struct pt_regs regs) 388 struct pt_regs __regs)
389{ 389{
390 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
390#ifdef CONFIG_MMU 391#ifdef CONFIG_MMU
391 return do_fork(SIGCHLD, regs.regs[15], &regs, 0, NULL, NULL); 392 return do_fork(SIGCHLD, regs->regs[15], regs, 0, NULL, NULL);
392#else 393#else
393 /* fork almost works, enough to trick you into looking elsewhere :-( */ 394 /* fork almost works, enough to trick you into looking elsewhere :-( */
394 return -EINVAL; 395 return -EINVAL;
@@ -398,11 +399,12 @@ asmlinkage int sys_fork(unsigned long r4, unsigned long r5,
398asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, 399asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
399 unsigned long parent_tidptr, 400 unsigned long parent_tidptr,
400 unsigned long child_tidptr, 401 unsigned long child_tidptr,
401 struct pt_regs regs) 402 struct pt_regs __regs)
402{ 403{
404 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
403 if (!newsp) 405 if (!newsp)
404 newsp = regs.regs[15]; 406 newsp = regs->regs[15];
405 return do_fork(clone_flags, newsp, &regs, 0, 407 return do_fork(clone_flags, newsp, regs, 0,
406 (int __user *)parent_tidptr, (int __user *)child_tidptr); 408 (int __user *)parent_tidptr, (int __user *)child_tidptr);
407} 409}
408 410
@@ -418,9 +420,10 @@ asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
418 */ 420 */
419asmlinkage int sys_vfork(unsigned long r4, unsigned long r5, 421asmlinkage int sys_vfork(unsigned long r4, unsigned long r5,
420 unsigned long r6, unsigned long r7, 422 unsigned long r6, unsigned long r7,
421 struct pt_regs regs) 423 struct pt_regs __regs)
422{ 424{
423 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs.regs[15], &regs, 425 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
426 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->regs[15], regs,
424 0, NULL, NULL); 427 0, NULL, NULL);
425} 428}
426 429
@@ -429,8 +432,9 @@ asmlinkage int sys_vfork(unsigned long r4, unsigned long r5,
429 */ 432 */
430asmlinkage int sys_execve(char *ufilename, char **uargv, 433asmlinkage int sys_execve(char *ufilename, char **uargv,
431 char **uenvp, unsigned long r7, 434 char **uenvp, unsigned long r7,
432 struct pt_regs regs) 435 struct pt_regs __regs)
433{ 436{
437 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
434 int error; 438 int error;
435 char *filename; 439 char *filename;
436 440
@@ -442,7 +446,7 @@ asmlinkage int sys_execve(char *ufilename, char **uargv,
442 error = do_execve(filename, 446 error = do_execve(filename,
443 (char __user * __user *)uargv, 447 (char __user * __user *)uargv,
444 (char __user * __user *)uenvp, 448 (char __user * __user *)uenvp,
445 &regs); 449 regs);
446 if (error == 0) { 450 if (error == 0) {
447 task_lock(current); 451 task_lock(current);
448 current->ptrace &= ~PT_DTRACE; 452 current->ptrace &= ~PT_DTRACE;
@@ -472,9 +476,7 @@ unsigned long get_wchan(struct task_struct *p)
472 return pc; 476 return pc;
473} 477}
474 478
475asmlinkage void break_point_trap(unsigned long r4, unsigned long r5, 479asmlinkage void break_point_trap(void)
476 unsigned long r6, unsigned long r7,
477 struct pt_regs regs)
478{ 480{
479 /* Clear tracing. */ 481 /* Clear tracing. */
480#if defined(CONFIG_CPU_SH4A) 482#if defined(CONFIG_CPU_SH4A)
@@ -492,8 +494,10 @@ asmlinkage void break_point_trap(unsigned long r4, unsigned long r5,
492 494
493asmlinkage void break_point_trap_software(unsigned long r4, unsigned long r5, 495asmlinkage void break_point_trap_software(unsigned long r4, unsigned long r5,
494 unsigned long r6, unsigned long r7, 496 unsigned long r6, unsigned long r7,
495 struct pt_regs regs) 497 struct pt_regs __regs)
496{ 498{
497 regs.pc -= 2; 499 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
500
501 regs->pc -= 2;
498 force_sig(SIGTRAP, current); 502 force_sig(SIGTRAP, current);
499} 503}
diff --git a/arch/sh/kernel/relocate_kernel.S b/arch/sh/kernel/relocate_kernel.S
index 8221b37c9773..c66cb3209db5 100644
--- a/arch/sh/kernel/relocate_kernel.S
+++ b/arch/sh/kernel/relocate_kernel.S
@@ -7,11 +7,9 @@
7 * This source code is licensed under the GNU General Public License, 7 * This source code is licensed under the GNU General Public License,
8 * Version 2. See the file COPYING for more details. 8 * Version 2. See the file COPYING for more details.
9 */ 9 */
10
11#include <linux/linkage.h> 10#include <linux/linkage.h>
12 11#include <asm/addrspace.h>
13#define PAGE_SIZE 4096 /* must be same value as in <asm/page.h> */ 12#include <asm/page.h>
14
15 13
16 .globl relocate_new_kernel 14 .globl relocate_new_kernel
17relocate_new_kernel: 15relocate_new_kernel:
@@ -20,8 +18,8 @@ relocate_new_kernel:
20 /* r6 = start_address */ 18 /* r6 = start_address */
21 /* r7 = vbr_reg */ 19 /* r7 = vbr_reg */
22 20
23 mov.l 10f,r8 /* 4096 */ 21 mov.l 10f,r8 /* PAGE_SIZE */
24 mov.l 11f,r9 /* 0xa0000000 */ 22 mov.l 11f,r9 /* P2SEG */
25 23
26 /* stack setting */ 24 /* stack setting */
27 add r8,r5 25 add r8,r5
@@ -32,7 +30,7 @@ relocate_new_kernel:
320: 300:
33 mov.l @r4+,r0 /* cmd = *ind++ */ 31 mov.l @r4+,r0 /* cmd = *ind++ */
34 32
351: /* addr = (cmd | 0xa0000000) & 0xfffffff0 */ 331: /* addr = (cmd | P2SEG) & 0xfffffff0 */
36 mov r0,r2 34 mov r0,r2
37 or r9,r2 35 or r9,r2
38 mov #-16,r1 36 mov #-16,r1
@@ -92,7 +90,7 @@ relocate_new_kernel:
9210: 9010:
93 .long PAGE_SIZE 91 .long PAGE_SIZE
9411: 9211:
95 .long 0xa0000000 93 .long P2SEG
96 94
97relocate_new_kernel_end: 95relocate_new_kernel_end:
98 96
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 36d86f9ac38a..f8dd6b7bfab0 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -332,8 +332,7 @@ void __init setup_arch(char **cmdline_p)
332 if (LOADER_TYPE && INITRD_START) { 332 if (LOADER_TYPE && INITRD_START) {
333 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) { 333 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
334 reserve_bootmem_node(NODE_DATA(0), INITRD_START+__MEMORY_START, INITRD_SIZE); 334 reserve_bootmem_node(NODE_DATA(0), INITRD_START+__MEMORY_START, INITRD_SIZE);
335 initrd_start = 335 initrd_start = INITRD_START + PAGE_OFFSET + __MEMORY_START;
336 INITRD_START ? INITRD_START + PAGE_OFFSET + __MEMORY_START : 0;
337 initrd_end = initrd_start + INITRD_SIZE; 336 initrd_end = initrd_start + INITRD_SIZE;
338 } else { 337 } else {
339 printk("initrd extends beyond end of memory " 338 printk("initrd extends beyond end of memory "
@@ -392,6 +391,7 @@ static int __init topology_init(void)
392subsys_initcall(topology_init); 391subsys_initcall(topology_init);
393 392
394static const char *cpu_name[] = { 393static const char *cpu_name[] = {
394 [CPU_SH7206] = "SH7206", [CPU_SH7619] = "SH7619",
395 [CPU_SH7604] = "SH7604", [CPU_SH7300] = "SH7300", 395 [CPU_SH7604] = "SH7604", [CPU_SH7300] = "SH7300",
396 [CPU_SH7705] = "SH7705", [CPU_SH7706] = "SH7706", 396 [CPU_SH7705] = "SH7705", [CPU_SH7706] = "SH7706",
397 [CPU_SH7707] = "SH7707", [CPU_SH7708] = "SH7708", 397 [CPU_SH7707] = "SH7707", [CPU_SH7708] = "SH7708",
@@ -404,6 +404,7 @@ static const char *cpu_name[] = {
404 [CPU_SH4_202] = "SH4-202", [CPU_SH4_501] = "SH4-501", 404 [CPU_SH4_202] = "SH4-202", [CPU_SH4_501] = "SH4-501",
405 [CPU_SH7770] = "SH7770", [CPU_SH7780] = "SH7780", 405 [CPU_SH7770] = "SH7770", [CPU_SH7780] = "SH7780",
406 [CPU_SH7781] = "SH7781", [CPU_SH7343] = "SH7343", 406 [CPU_SH7781] = "SH7781", [CPU_SH7343] = "SH7343",
407 [CPU_SH7785] = "SH7785",
407 [CPU_SH_NONE] = "Unknown" 408 [CPU_SH_NONE] = "Unknown"
408}; 409};
409 410
diff --git a/arch/sh/kernel/sh_ksyms.c b/arch/sh/kernel/sh_ksyms.c
index 8a2fd19dc9eb..ceee79143401 100644
--- a/arch/sh/kernel/sh_ksyms.c
+++ b/arch/sh/kernel/sh_ksyms.c
@@ -73,8 +73,6 @@ DECLARE_EXPORT(__lshrdi3);
73DECLARE_EXPORT(__movstr); 73DECLARE_EXPORT(__movstr);
74DECLARE_EXPORT(__movstrSI16); 74DECLARE_EXPORT(__movstrSI16);
75 75
76EXPORT_SYMBOL(strcpy);
77
78#ifdef CONFIG_CPU_SH4 76#ifdef CONFIG_CPU_SH4
79DECLARE_EXPORT(__movstr_i4_even); 77DECLARE_EXPORT(__movstr_i4_even);
80DECLARE_EXPORT(__movstr_i4_odd); 78DECLARE_EXPORT(__movstr_i4_odd);
@@ -101,10 +99,6 @@ EXPORT_SYMBOL(__down_trylock);
101EXPORT_SYMBOL(synchronize_irq); 99EXPORT_SYMBOL(synchronize_irq);
102#endif 100#endif
103 101
104#ifdef CONFIG_PM
105EXPORT_SYMBOL(pm_suspend);
106#endif
107
108EXPORT_SYMBOL(csum_partial); 102EXPORT_SYMBOL(csum_partial);
109#ifdef CONFIG_IPV6 103#ifdef CONFIG_IPV6
110EXPORT_SYMBOL(csum_ipv6_magic); 104EXPORT_SYMBOL(csum_ipv6_magic);
diff --git a/arch/sh/kernel/signal.c b/arch/sh/kernel/signal.c
index 5213f5bc6ce0..bb1c480a59c7 100644
--- a/arch/sh/kernel/signal.c
+++ b/arch/sh/kernel/signal.c
@@ -23,6 +23,7 @@
23#include <linux/elf.h> 23#include <linux/elf.h>
24#include <linux/personality.h> 24#include <linux/personality.h>
25#include <linux/binfmts.h> 25#include <linux/binfmts.h>
26#include <linux/freezer.h>
26 27
27#include <asm/ucontext.h> 28#include <asm/ucontext.h>
28#include <asm/uaccess.h> 29#include <asm/uaccess.h>
@@ -37,7 +38,7 @@
37asmlinkage int 38asmlinkage int
38sys_sigsuspend(old_sigset_t mask, 39sys_sigsuspend(old_sigset_t mask,
39 unsigned long r5, unsigned long r6, unsigned long r7, 40 unsigned long r5, unsigned long r6, unsigned long r7,
40 struct pt_regs regs) 41 struct pt_regs __regs)
41{ 42{
42 mask &= _BLOCKABLE; 43 mask &= _BLOCKABLE;
43 spin_lock_irq(&current->sighand->siglock); 44 spin_lock_irq(&current->sighand->siglock);
@@ -52,7 +53,7 @@ sys_sigsuspend(old_sigset_t mask,
52 return -ERESTARTNOHAND; 53 return -ERESTARTNOHAND;
53} 54}
54 55
55asmlinkage int 56asmlinkage int
56sys_sigaction(int sig, const struct old_sigaction __user *act, 57sys_sigaction(int sig, const struct old_sigaction __user *act,
57 struct old_sigaction __user *oact) 58 struct old_sigaction __user *oact)
58{ 59{
@@ -87,9 +88,11 @@ sys_sigaction(int sig, const struct old_sigaction __user *act,
87asmlinkage int 88asmlinkage int
88sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss, 89sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
89 unsigned long r6, unsigned long r7, 90 unsigned long r6, unsigned long r7,
90 struct pt_regs regs) 91 struct pt_regs __regs)
91{ 92{
92 return do_sigaltstack(uss, uoss, regs.regs[15]); 93 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
94
95 return do_sigaltstack(uss, uoss, regs->regs[15]);
93} 96}
94 97
95 98
@@ -98,7 +101,11 @@ sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
98 */ 101 */
99 102
100#define MOVW(n) (0x9300|((n)-2)) /* Move mem word at PC+n to R3 */ 103#define MOVW(n) (0x9300|((n)-2)) /* Move mem word at PC+n to R3 */
101#define TRAP16 0xc310 /* Syscall w/no args (NR in R3) */ 104#if defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH2A)
105#define TRAP_NOARG 0xc320 /* Syscall w/no args (NR in R3) */
106#else
107#define TRAP_NOARG 0xc310 /* Syscall w/no args (NR in R3) */
108#endif
102#define OR_R0_R0 0x200b /* or r0,r0 (insert to avoid hardware bug) */ 109#define OR_R0_R0 0x200b /* or r0,r0 (insert to avoid hardware bug) */
103 110
104struct sigframe 111struct sigframe
@@ -194,9 +201,10 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *r0_p
194 201
195asmlinkage int sys_sigreturn(unsigned long r4, unsigned long r5, 202asmlinkage int sys_sigreturn(unsigned long r4, unsigned long r5,
196 unsigned long r6, unsigned long r7, 203 unsigned long r6, unsigned long r7,
197 struct pt_regs regs) 204 struct pt_regs __regs)
198{ 205{
199 struct sigframe __user *frame = (struct sigframe __user *)regs.regs[15]; 206 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
207 struct sigframe __user *frame = (struct sigframe __user *)regs->regs[15];
200 sigset_t set; 208 sigset_t set;
201 int r0; 209 int r0;
202 210
@@ -216,7 +224,7 @@ asmlinkage int sys_sigreturn(unsigned long r4, unsigned long r5,
216 recalc_sigpending(); 224 recalc_sigpending();
217 spin_unlock_irq(&current->sighand->siglock); 225 spin_unlock_irq(&current->sighand->siglock);
218 226
219 if (restore_sigcontext(&regs, &frame->sc, &r0)) 227 if (restore_sigcontext(regs, &frame->sc, &r0))
220 goto badframe; 228 goto badframe;
221 return r0; 229 return r0;
222 230
@@ -227,9 +235,10 @@ badframe:
227 235
228asmlinkage int sys_rt_sigreturn(unsigned long r4, unsigned long r5, 236asmlinkage int sys_rt_sigreturn(unsigned long r4, unsigned long r5,
229 unsigned long r6, unsigned long r7, 237 unsigned long r6, unsigned long r7,
230 struct pt_regs regs) 238 struct pt_regs __regs)
231{ 239{
232 struct rt_sigframe __user *frame = (struct rt_sigframe __user *)regs.regs[15]; 240 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
241 struct rt_sigframe __user *frame = (struct rt_sigframe __user *)regs->regs[15];
233 sigset_t set; 242 sigset_t set;
234 stack_t st; 243 stack_t st;
235 int r0; 244 int r0;
@@ -246,14 +255,14 @@ asmlinkage int sys_rt_sigreturn(unsigned long r4, unsigned long r5,
246 recalc_sigpending(); 255 recalc_sigpending();
247 spin_unlock_irq(&current->sighand->siglock); 256 spin_unlock_irq(&current->sighand->siglock);
248 257
249 if (restore_sigcontext(&regs, &frame->uc.uc_mcontext, &r0)) 258 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0))
250 goto badframe; 259 goto badframe;
251 260
252 if (__copy_from_user(&st, &frame->uc.uc_stack, sizeof(st))) 261 if (__copy_from_user(&st, &frame->uc.uc_stack, sizeof(st)))
253 goto badframe; 262 goto badframe;
254 /* It is more difficult to avoid calling this function than to 263 /* It is more difficult to avoid calling this function than to
255 call it and ignore errors. */ 264 call it and ignore errors. */
256 do_sigaltstack(&st, NULL, regs.regs[15]); 265 do_sigaltstack(&st, NULL, regs->regs[15]);
257 266
258 return r0; 267 return r0;
259 268
@@ -350,7 +359,7 @@ static int setup_frame(int sig, struct k_sigaction *ka,
350 } else { 359 } else {
351 /* Generate return code (system call to sigreturn) */ 360 /* Generate return code (system call to sigreturn) */
352 err |= __put_user(MOVW(7), &frame->retcode[0]); 361 err |= __put_user(MOVW(7), &frame->retcode[0]);
353 err |= __put_user(TRAP16, &frame->retcode[1]); 362 err |= __put_user(TRAP_NOARG, &frame->retcode[1]);
354 err |= __put_user(OR_R0_R0, &frame->retcode[2]); 363 err |= __put_user(OR_R0_R0, &frame->retcode[2]);
355 err |= __put_user(OR_R0_R0, &frame->retcode[3]); 364 err |= __put_user(OR_R0_R0, &frame->retcode[3]);
356 err |= __put_user(OR_R0_R0, &frame->retcode[4]); 365 err |= __put_user(OR_R0_R0, &frame->retcode[4]);
@@ -430,7 +439,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
430 } else { 439 } else {
431 /* Generate return code (system call to rt_sigreturn) */ 440 /* Generate return code (system call to rt_sigreturn) */
432 err |= __put_user(MOVW(7), &frame->retcode[0]); 441 err |= __put_user(MOVW(7), &frame->retcode[0]);
433 err |= __put_user(TRAP16, &frame->retcode[1]); 442 err |= __put_user(TRAP_NOARG, &frame->retcode[1]);
434 err |= __put_user(OR_R0_R0, &frame->retcode[2]); 443 err |= __put_user(OR_R0_R0, &frame->retcode[2]);
435 err |= __put_user(OR_R0_R0, &frame->retcode[3]); 444 err |= __put_user(OR_R0_R0, &frame->retcode[3]);
436 err |= __put_user(OR_R0_R0, &frame->retcode[4]); 445 err |= __put_user(OR_R0_R0, &frame->retcode[4]);
diff --git a/arch/sh/kernel/stacktrace.c b/arch/sh/kernel/stacktrace.c
new file mode 100644
index 000000000000..0d5268afe80f
--- /dev/null
+++ b/arch/sh/kernel/stacktrace.c
@@ -0,0 +1,43 @@
1/*
2 * arch/sh/kernel/stacktrace.c
3 *
4 * Stack trace management functions
5 *
6 * Copyright (C) 2006 Paul Mundt
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12#include <linux/sched.h>
13#include <linux/stacktrace.h>
14#include <linux/thread_info.h>
15#include <asm/ptrace.h>
16
17/*
18 * Save stack-backtrace addresses into a stack_trace buffer.
19 */
20void save_stack_trace(struct stack_trace *trace, struct task_struct *task)
21{
22 unsigned long *sp;
23
24 if (!task)
25 task = current;
26 if (task == current)
27 sp = (unsigned long *)current_stack_pointer;
28 else
29 sp = (unsigned long *)task->thread.sp;
30
31 while (!kstack_end(sp)) {
32 unsigned long addr = *sp++;
33
34 if (__kernel_text_address(addr)) {
35 if (trace->skip > 0)
36 trace->skip--;
37 else
38 trace->entries[trace->nr_entries++] = addr;
39 if (trace->nr_entries >= trace->max_entries)
40 break;
41 }
42 }
43}
diff --git a/arch/sh/kernel/sys_sh.c b/arch/sh/kernel/sys_sh.c
index 8fde95001c34..5083b6ed4b39 100644
--- a/arch/sh/kernel/sys_sh.c
+++ b/arch/sh/kernel/sys_sh.c
@@ -33,14 +33,15 @@
33 */ 33 */
34asmlinkage int sys_pipe(unsigned long r4, unsigned long r5, 34asmlinkage int sys_pipe(unsigned long r4, unsigned long r5,
35 unsigned long r6, unsigned long r7, 35 unsigned long r6, unsigned long r7,
36 struct pt_regs regs) 36 struct pt_regs __regs)
37{ 37{
38 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
38 int fd[2]; 39 int fd[2];
39 int error; 40 int error;
40 41
41 error = do_pipe(fd); 42 error = do_pipe(fd);
42 if (!error) { 43 if (!error) {
43 regs.regs[1] = fd[1]; 44 regs->regs[1] = fd[1];
44 return fd[0]; 45 return fd[0];
45 } 46 }
46 return error; 47 return error;
@@ -50,6 +51,7 @@ unsigned long shm_align_mask = PAGE_SIZE - 1; /* Sane caches */
50 51
51EXPORT_SYMBOL(shm_align_mask); 52EXPORT_SYMBOL(shm_align_mask);
52 53
54#ifdef CONFIG_MMU
53/* 55/*
54 * To avoid cache aliases, we map the shared page with same color. 56 * To avoid cache aliases, we map the shared page with same color.
55 */ 57 */
@@ -135,6 +137,7 @@ full_search:
135 addr = COLOUR_ALIGN(addr, pgoff); 137 addr = COLOUR_ALIGN(addr, pgoff);
136 } 138 }
137} 139}
140#endif /* CONFIG_MMU */
138 141
139static inline long 142static inline long
140do_mmap2(unsigned long addr, unsigned long len, unsigned long prot, 143do_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c
index 57e708d7b52d..c206c9504c4b 100644
--- a/arch/sh/kernel/time.c
+++ b/arch/sh/kernel/time.c
@@ -13,6 +13,8 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/profile.h> 15#include <linux/profile.h>
16#include <linux/timex.h>
17#include <linux/sched.h>
16#include <asm/clock.h> 18#include <asm/clock.h>
17#include <asm/rtc.h> 19#include <asm/rtc.h>
18#include <asm/timer.h> 20#include <asm/timer.h>
@@ -50,15 +52,20 @@ unsigned long long __attribute__ ((weak)) sched_clock(void)
50#ifndef CONFIG_GENERIC_TIME 52#ifndef CONFIG_GENERIC_TIME
51void do_gettimeofday(struct timeval *tv) 53void do_gettimeofday(struct timeval *tv)
52{ 54{
55 unsigned long flags;
53 unsigned long seq; 56 unsigned long seq;
54 unsigned long usec, sec; 57 unsigned long usec, sec;
55 58
56 do { 59 do {
57 seq = read_seqbegin(&xtime_lock); 60 /*
61 * Turn off IRQs when grabbing xtime_lock, so that
62 * the sys_timer get_offset code doesn't have to handle it.
63 */
64 seq = read_seqbegin_irqsave(&xtime_lock, flags);
58 usec = get_timer_offset(); 65 usec = get_timer_offset();
59 sec = xtime.tv_sec; 66 sec = xtime.tv_sec;
60 usec += xtime.tv_nsec / 1000; 67 usec += xtime.tv_nsec / NSEC_PER_USEC;
61 } while (read_seqretry(&xtime_lock, seq)); 68 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
62 69
63 while (usec >= 1000000) { 70 while (usec >= 1000000) {
64 usec -= 1000000; 71 usec -= 1000000;
@@ -85,7 +92,7 @@ int do_settimeofday(struct timespec *tv)
85 * wall time. Discover what correction gettimeofday() would have 92 * wall time. Discover what correction gettimeofday() would have
86 * made, and then undo it! 93 * made, and then undo it!
87 */ 94 */
88 nsec -= 1000 * get_timer_offset(); 95 nsec -= get_timer_offset() * NSEC_PER_USEC;
89 96
90 wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec); 97 wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
91 wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec); 98 wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
@@ -169,6 +176,108 @@ static struct sysdev_class timer_sysclass = {
169 .resume = timer_resume, 176 .resume = timer_resume,
170}; 177};
171 178
179#ifdef CONFIG_NO_IDLE_HZ
180static int timer_dyn_tick_enable(void)
181{
182 struct dyn_tick_timer *dyn_tick = sys_timer->dyn_tick;
183 unsigned long flags;
184 int ret = -ENODEV;
185
186 if (dyn_tick) {
187 spin_lock_irqsave(&dyn_tick->lock, flags);
188 ret = 0;
189 if (!(dyn_tick->state & DYN_TICK_ENABLED)) {
190 ret = dyn_tick->enable();
191
192 if (ret == 0)
193 dyn_tick->state |= DYN_TICK_ENABLED;
194 }
195 spin_unlock_irqrestore(&dyn_tick->lock, flags);
196 }
197
198 return ret;
199}
200
201static int timer_dyn_tick_disable(void)
202{
203 struct dyn_tick_timer *dyn_tick = sys_timer->dyn_tick;
204 unsigned long flags;
205 int ret = -ENODEV;
206
207 if (dyn_tick) {
208 spin_lock_irqsave(&dyn_tick->lock, flags);
209 ret = 0;
210 if (dyn_tick->state & DYN_TICK_ENABLED) {
211 ret = dyn_tick->disable();
212
213 if (ret == 0)
214 dyn_tick->state &= ~DYN_TICK_ENABLED;
215 }
216 spin_unlock_irqrestore(&dyn_tick->lock, flags);
217 }
218
219 return ret;
220}
221
222/*
223 * Reprogram the system timer for at least the calculated time interval.
224 * This function should be called from the idle thread with IRQs disabled,
225 * immediately before sleeping.
226 */
227void timer_dyn_reprogram(void)
228{
229 struct dyn_tick_timer *dyn_tick = sys_timer->dyn_tick;
230 unsigned long next, seq, flags;
231
232 if (!dyn_tick)
233 return;
234
235 spin_lock_irqsave(&dyn_tick->lock, flags);
236 if (dyn_tick->state & DYN_TICK_ENABLED) {
237 next = next_timer_interrupt();
238 do {
239 seq = read_seqbegin(&xtime_lock);
240 dyn_tick->reprogram(next - jiffies);
241 } while (read_seqretry(&xtime_lock, seq));
242 }
243 spin_unlock_irqrestore(&dyn_tick->lock, flags);
244}
245
246static ssize_t timer_show_dyn_tick(struct sys_device *dev, char *buf)
247{
248 return sprintf(buf, "%i\n",
249 (sys_timer->dyn_tick->state & DYN_TICK_ENABLED) >> 1);
250}
251
252static ssize_t timer_set_dyn_tick(struct sys_device *dev, const char *buf,
253 size_t count)
254{
255 unsigned int enable = simple_strtoul(buf, NULL, 2);
256
257 if (enable)
258 timer_dyn_tick_enable();
259 else
260 timer_dyn_tick_disable();
261
262 return count;
263}
264static SYSDEV_ATTR(dyn_tick, 0644, timer_show_dyn_tick, timer_set_dyn_tick);
265
266/*
267 * dyntick=enable|disable
268 */
269static char dyntick_str[4] __initdata = "";
270
271static int __init dyntick_setup(char *str)
272{
273 if (str)
274 strlcpy(dyntick_str, str, sizeof(dyntick_str));
275 return 1;
276}
277
278__setup("dyntick=", dyntick_setup);
279#endif
280
172static int __init timer_init_sysfs(void) 281static int __init timer_init_sysfs(void)
173{ 282{
174 int ret = sysdev_class_register(&timer_sysclass); 283 int ret = sysdev_class_register(&timer_sysclass);
@@ -176,7 +285,22 @@ static int __init timer_init_sysfs(void)
176 return ret; 285 return ret;
177 286
178 sys_timer->dev.cls = &timer_sysclass; 287 sys_timer->dev.cls = &timer_sysclass;
179 return sysdev_register(&sys_timer->dev); 288 ret = sysdev_register(&sys_timer->dev);
289
290#ifdef CONFIG_NO_IDLE_HZ
291 if (ret == 0 && sys_timer->dyn_tick) {
292 ret = sysdev_create_file(&sys_timer->dev, &attr_dyn_tick);
293
294 /*
295 * Turn on dynamic tick after calibrate delay
296 * for correct bogomips
297 */
298 if (ret == 0 && dyntick_str[0] == 'e')
299 ret = timer_dyn_tick_enable();
300 }
301#endif
302
303 return ret;
180} 304}
181device_initcall(timer_init_sysfs); 305device_initcall(timer_init_sysfs);
182 306
@@ -200,6 +324,11 @@ void __init time_init(void)
200 sys_timer = get_sys_timer(); 324 sys_timer = get_sys_timer();
201 printk(KERN_INFO "Using %s for system timer\n", sys_timer->name); 325 printk(KERN_INFO "Using %s for system timer\n", sys_timer->name);
202 326
327#ifdef CONFIG_NO_IDLE_HZ
328 if (sys_timer->dyn_tick)
329 spin_lock_init(&sys_timer->dyn_tick->lock);
330#endif
331
203#if defined(CONFIG_SH_KGDB) 332#if defined(CONFIG_SH_KGDB)
204 /* 333 /*
205 * Set up kgdb as requested. We do it here because the serial 334 * Set up kgdb as requested. We do it here because the serial
diff --git a/arch/sh/kernel/timers/Makefile b/arch/sh/kernel/timers/Makefile
index 151a6a304cec..bcf244ff6a12 100644
--- a/arch/sh/kernel/timers/Makefile
+++ b/arch/sh/kernel/timers/Makefile
@@ -5,4 +5,6 @@
5obj-y := timer.o 5obj-y := timer.o
6 6
7obj-$(CONFIG_SH_TMU) += timer-tmu.o 7obj-$(CONFIG_SH_TMU) += timer-tmu.o
8obj-$(CONFIG_SH_MTU2) += timer-mtu2.o
9obj-$(CONFIG_SH_CMT) += timer-cmt.o
8 10
diff --git a/arch/sh/kernel/timers/timer-cmt.c b/arch/sh/kernel/timers/timer-cmt.c
new file mode 100644
index 000000000000..a574b93a4e7b
--- /dev/null
+++ b/arch/sh/kernel/timers/timer-cmt.c
@@ -0,0 +1,196 @@
1/*
2 * arch/sh/kernel/timers/timer-cmt.c - CMT Timer Support
3 *
4 * Copyright (C) 2005 Yoshinori Sato
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/init.h>
12#include <linux/kernel.h>
13#include <linux/interrupt.h>
14#include <linux/seqlock.h>
15#include <asm/timer.h>
16#include <asm/rtc.h>
17#include <asm/io.h>
18#include <asm/irq.h>
19#include <asm/clock.h>
20
21#if defined(CONFIG_CPU_SUBTYPE_SH7619)
22#define CMT_CMSTR 0xf84a0070
23#define CMT_CMCSR_0 0xf84a0072
24#define CMT_CMCNT_0 0xf84a0074
25#define CMT_CMCOR_0 0xf84a0076
26#define CMT_CMCSR_1 0xf84a0078
27#define CMT_CMCNT_1 0xf84a007a
28#define CMT_CMCOR_1 0xf84a007c
29
30#define STBCR3 0xf80a0000
31#define cmt_clock_enable() do { ctrl_outb(ctrl_inb(STBCR3) & ~0x10, STBCR3); } while(0)
32#define CMT_CMCSR_INIT 0x0040
33#define CMT_CMCSR_CALIB 0x0000
34#elif defined(CONFIG_CPU_SUBTYPE_SH7206)
35#define CMT_CMSTR 0xfffec000
36#define CMT_CMCSR_0 0xfffec002
37#define CMT_CMCNT_0 0xfffec004
38#define CMT_CMCOR_0 0xfffec006
39
40#define STBCR4 0xfffe040c
41#define cmt_clock_enable() do { ctrl_outb(ctrl_inb(STBCR4) & ~0x04, STBCR4); } while(0)
42#define CMT_CMCSR_INIT 0x0040
43#define CMT_CMCSR_CALIB 0x0000
44#else
45#error "Unknown CPU SUBTYPE"
46#endif
47
48static unsigned long cmt_timer_get_offset(void)
49{
50 int count;
51 static unsigned short count_p = 0xffff; /* for the first call after boot */
52 static unsigned long jiffies_p = 0;
53
54 /*
55 * cache volatile jiffies temporarily; we have IRQs turned off.
56 */
57 unsigned long jiffies_t;
58
59 /* timer count may underflow right here */
60 count = ctrl_inw(CMT_CMCOR_0);
61 count -= ctrl_inw(CMT_CMCNT_0);
62
63 jiffies_t = jiffies;
64
65 /*
66 * avoiding timer inconsistencies (they are rare, but they happen)...
67 * there is one kind of problem that must be avoided here:
68 * 1. the timer counter underflows
69 */
70
71 if (jiffies_t == jiffies_p) {
72 if (count > count_p) {
73 /* the nutcase */
74 if (ctrl_inw(CMT_CMCSR_0) & 0x80) { /* Check CMF bit */
75 count -= LATCH;
76 } else {
77 printk("%s (): hardware timer problem?\n",
78 __FUNCTION__);
79 }
80 }
81 } else
82 jiffies_p = jiffies_t;
83
84 count_p = count;
85
86 count = ((LATCH-1) - count) * TICK_SIZE;
87 count = (count + LATCH/2) / LATCH;
88
89 return count;
90}
91
92static irqreturn_t cmt_timer_interrupt(int irq, void *dev_id)
93{
94 unsigned long timer_status;
95
96 /* Clear CMF bit */
97 timer_status = ctrl_inw(CMT_CMCSR_0);
98 timer_status &= ~0x80;
99 ctrl_outw(timer_status, CMT_CMCSR_0);
100
101 /*
102 * Here we are in the timer irq handler. We just have irqs locally
103 * disabled but we don't know if the timer_bh is running on the other
104 * CPU. We need to avoid to SMP race with it. NOTE: we don' t need
105 * the irq version of write_lock because as just said we have irq
106 * locally disabled. -arca
107 */
108 write_seqlock(&xtime_lock);
109 handle_timer_tick();
110 write_sequnlock(&xtime_lock);
111
112 return IRQ_HANDLED;
113}
114
115static struct irqaction cmt_irq = {
116 .name = "timer",
117 .handler = cmt_timer_interrupt,
118 .flags = IRQF_DISABLED | IRQF_TIMER,
119 .mask = CPU_MASK_NONE,
120};
121
122static void cmt_clk_init(struct clk *clk)
123{
124 u8 divisor = CMT_CMCSR_INIT & 0x3;
125 ctrl_inw(CMT_CMCSR_0);
126 ctrl_outw(CMT_CMCSR_INIT, CMT_CMCSR_0);
127 clk->parent = clk_get(NULL, "module_clk");
128 clk->rate = clk->parent->rate / (8 << (divisor << 1));
129}
130
131static void cmt_clk_recalc(struct clk *clk)
132{
133 u8 divisor = ctrl_inw(CMT_CMCSR_0) & 0x3;
134 clk->rate = clk->parent->rate / (8 << (divisor << 1));
135}
136
137static struct clk_ops cmt_clk_ops = {
138 .init = cmt_clk_init,
139 .recalc = cmt_clk_recalc,
140};
141
142static struct clk cmt0_clk = {
143 .name = "cmt0_clk",
144 .ops = &cmt_clk_ops,
145};
146
147static int cmt_timer_start(void)
148{
149 ctrl_outw(ctrl_inw(CMT_CMSTR) | 0x01, CMT_CMSTR);
150 return 0;
151}
152
153static int cmt_timer_stop(void)
154{
155 ctrl_outw(ctrl_inw(CMT_CMSTR) & ~0x01, CMT_CMSTR);
156 return 0;
157}
158
159static int cmt_timer_init(void)
160{
161 unsigned long interval;
162
163 cmt_clock_enable();
164
165 setup_irq(CONFIG_SH_TIMER_IRQ, &cmt_irq);
166
167 cmt0_clk.parent = clk_get(NULL, "module_clk");
168
169 cmt_timer_stop();
170
171 interval = cmt0_clk.parent->rate / 8 / HZ;
172 printk(KERN_INFO "Interval = %ld\n", interval);
173
174 ctrl_outw(interval, CMT_CMCOR_0);
175
176 clk_register(&cmt0_clk);
177 clk_enable(&cmt0_clk);
178
179 cmt_timer_start();
180
181 return 0;
182}
183
184struct sys_timer_ops cmt_timer_ops = {
185 .init = cmt_timer_init,
186 .start = cmt_timer_start,
187 .stop = cmt_timer_stop,
188#ifndef CONFIG_GENERIC_TIME
189 .get_offset = cmt_timer_get_offset,
190#endif
191};
192
193struct sys_timer cmt_timer = {
194 .name = "cmt",
195 .ops = &cmt_timer_ops,
196};
diff --git a/arch/sh/kernel/timers/timer-mtu2.c b/arch/sh/kernel/timers/timer-mtu2.c
new file mode 100644
index 000000000000..fffcd1c09873
--- /dev/null
+++ b/arch/sh/kernel/timers/timer-mtu2.c
@@ -0,0 +1,200 @@
1/*
2 * arch/sh/kernel/timers/timer-mtu2.c - MTU2 Timer Support
3 *
4 * Copyright (C) 2005 Paul Mundt
5 *
6 * Based off of arch/sh/kernel/timers/timer-tmu.c
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12#include <linux/init.h>
13#include <linux/kernel.h>
14#include <linux/interrupt.h>
15#include <linux/seqlock.h>
16#include <asm/timer.h>
17#include <asm/io.h>
18#include <asm/irq.h>
19#include <asm/clock.h>
20
21/*
22 * We use channel 1 for our lowly system timer. Channel 2 would be the other
23 * likely candidate, but we leave it alone as it has higher divisors that
24 * would be of more use to other more interesting applications.
25 *
26 * TODO: Presently we only implement a 16-bit single-channel system timer.
27 * However, we can implement channel cascade if we go the overflow route and
28 * get away with using 2 MTU2 channels as a 32-bit timer.
29 */
30#define MTU2_TSTR 0xfffe4280
31#define MTU2_TCR_1 0xfffe4380
32#define MTU2_TMDR_1 0xfffe4381
33#define MTU2_TIOR_1 0xfffe4382
34#define MTU2_TIER_1 0xfffe4384
35#define MTU2_TSR_1 0xfffe4385
36#define MTU2_TCNT_1 0xfffe4386 /* 16-bit counter */
37#define MTU2_TGRA_1 0xfffe438a
38
39#define STBCR3 0xfffe0408
40
41#define MTU2_TSTR_CST1 (1 << 1) /* Counter Start 1 */
42
43#define MTU2_TSR_TGFA (1 << 0) /* GRA compare match */
44
45#define MTU2_TIER_TGIEA (1 << 0) /* GRA compare match interrupt enable */
46
47#define MTU2_TCR_INIT 0x22
48
49#define MTU2_TCR_CALIB 0x00
50
51static unsigned long mtu2_timer_get_offset(void)
52{
53 int count;
54 static int count_p = 0x7fff; /* for the first call after boot */
55 static unsigned long jiffies_p = 0;
56
57 /*
58 * cache volatile jiffies temporarily; we have IRQs turned off.
59 */
60 unsigned long jiffies_t;
61
62 /* timer count may underflow right here */
63 count = ctrl_inw(MTU2_TCNT_1); /* read the latched count */
64
65 jiffies_t = jiffies;
66
67 /*
68 * avoiding timer inconsistencies (they are rare, but they happen)...
69 * there is one kind of problem that must be avoided here:
70 * 1. the timer counter underflows
71 */
72
73 if (jiffies_t == jiffies_p) {
74 if (count > count_p) {
75 if (ctrl_inb(MTU2_TSR_1) & MTU2_TSR_TGFA) {
76 count -= LATCH;
77 } else {
78 printk("%s (): hardware timer problem?\n",
79 __FUNCTION__);
80 }
81 }
82 } else
83 jiffies_p = jiffies_t;
84
85 count_p = count;
86
87 count = ((LATCH-1) - count) * TICK_SIZE;
88 count = (count + LATCH/2) / LATCH;
89
90 return count;
91}
92
93static irqreturn_t mtu2_timer_interrupt(int irq, void *dev_id)
94{
95 unsigned long timer_status;
96
97 /* Clear TGFA bit */
98 timer_status = ctrl_inb(MTU2_TSR_1);
99 timer_status &= ~MTU2_TSR_TGFA;
100 ctrl_outb(timer_status, MTU2_TSR_1);
101
102 /* Do timer tick */
103 write_seqlock(&xtime_lock);
104 handle_timer_tick();
105 write_sequnlock(&xtime_lock);
106
107 return IRQ_HANDLED;
108}
109
110static struct irqaction mtu2_irq = {
111 .name = "timer",
112 .handler = mtu2_timer_interrupt,
113 .flags = IRQF_DISABLED | IRQF_TIMER,
114 .mask = CPU_MASK_NONE,
115};
116
117static unsigned int divisors[] = { 1, 4, 16, 64, 1, 1, 256 };
118
119static void mtu2_clk_init(struct clk *clk)
120{
121 u8 idx = MTU2_TCR_INIT & 0x7;
122
123 clk->rate = clk->parent->rate / divisors[idx];
124 /* Start TCNT counting */
125 ctrl_outb(ctrl_inb(MTU2_TSTR) | MTU2_TSTR_CST1, MTU2_TSTR);
126
127}
128
129static void mtu2_clk_recalc(struct clk *clk)
130{
131 u8 idx = ctrl_inb(MTU2_TCR_1) & 0x7;
132 clk->rate = clk->parent->rate / divisors[idx];
133}
134
135static struct clk_ops mtu2_clk_ops = {
136 .init = mtu2_clk_init,
137 .recalc = mtu2_clk_recalc,
138};
139
140static struct clk mtu2_clk1 = {
141 .name = "mtu2_clk1",
142 .ops = &mtu2_clk_ops,
143};
144
145static int mtu2_timer_start(void)
146{
147 ctrl_outb(ctrl_inb(MTU2_TSTR) | MTU2_TSTR_CST1, MTU2_TSTR);
148 return 0;
149}
150
151static int mtu2_timer_stop(void)
152{
153 ctrl_outb(ctrl_inb(MTU2_TSTR) & ~MTU2_TSTR_CST1, MTU2_TSTR);
154 return 0;
155}
156
157static int mtu2_timer_init(void)
158{
159 u8 tmp;
160 unsigned long interval;
161
162 setup_irq(CONFIG_SH_TIMER_IRQ, &mtu2_irq);
163
164 mtu2_clk1.parent = clk_get(NULL, "module_clk");
165
166 ctrl_outb(ctrl_inb(STBCR3) & (~0x20), STBCR3);
167
168 /* Normal operation */
169 ctrl_outb(0, MTU2_TMDR_1);
170 ctrl_outb(MTU2_TCR_INIT, MTU2_TCR_1);
171 ctrl_outb(0x01, MTU2_TIOR_1);
172
173 /* Enable underflow interrupt */
174 ctrl_outb(ctrl_inb(MTU2_TIER_1) | MTU2_TIER_TGIEA, MTU2_TIER_1);
175
176 interval = CONFIG_SH_PCLK_FREQ / 16 / HZ;
177 printk(KERN_INFO "Interval = %ld\n", interval);
178
179 ctrl_outw(interval, MTU2_TGRA_1);
180 ctrl_outw(0, MTU2_TCNT_1);
181
182 clk_register(&mtu2_clk1);
183 clk_enable(&mtu2_clk1);
184
185 return 0;
186}
187
188struct sys_timer_ops mtu2_timer_ops = {
189 .init = mtu2_timer_init,
190 .start = mtu2_timer_start,
191 .stop = mtu2_timer_stop,
192#ifndef CONFIG_GENERIC_TIME
193 .get_offset = mtu2_timer_get_offset,
194#endif
195};
196
197struct sys_timer mtu2_timer = {
198 .name = "mtu2",
199 .ops = &mtu2_timer_ops,
200};
diff --git a/arch/sh/kernel/timers/timer-tmu.c b/arch/sh/kernel/timers/timer-tmu.c
index 24927015dc31..e060e71d0785 100644
--- a/arch/sh/kernel/timers/timer-tmu.c
+++ b/arch/sh/kernel/timers/timer-tmu.c
@@ -17,7 +17,6 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/spinlock.h>
21#include <linux/seqlock.h> 20#include <linux/seqlock.h>
22#include <asm/timer.h> 21#include <asm/timer.h>
23#include <asm/rtc.h> 22#include <asm/rtc.h>
@@ -31,13 +30,9 @@
31 30
32#define TMU0_TCR_CALIB 0x0000 31#define TMU0_TCR_CALIB 0x0000
33 32
34static DEFINE_SPINLOCK(tmu0_lock);
35
36static unsigned long tmu_timer_get_offset(void) 33static unsigned long tmu_timer_get_offset(void)
37{ 34{
38 int count; 35 int count;
39 unsigned long flags;
40
41 static int count_p = 0x7fffffff; /* for the first call after boot */ 36 static int count_p = 0x7fffffff; /* for the first call after boot */
42 static unsigned long jiffies_p = 0; 37 static unsigned long jiffies_p = 0;
43 38
@@ -46,7 +41,6 @@ static unsigned long tmu_timer_get_offset(void)
46 */ 41 */
47 unsigned long jiffies_t; 42 unsigned long jiffies_t;
48 43
49 spin_lock_irqsave(&tmu0_lock, flags);
50 /* timer count may underflow right here */ 44 /* timer count may underflow right here */
51 count = ctrl_inl(TMU0_TCNT); /* read the latched count */ 45 count = ctrl_inl(TMU0_TCNT); /* read the latched count */
52 46
@@ -72,7 +66,6 @@ static unsigned long tmu_timer_get_offset(void)
72 jiffies_p = jiffies_t; 66 jiffies_p = jiffies_t;
73 67
74 count_p = count; 68 count_p = count;
75 spin_unlock_irqrestore(&tmu0_lock, flags);
76 69
77 count = ((LATCH-1) - count) * TICK_SIZE; 70 count = ((LATCH-1) - count) * TICK_SIZE;
78 count = (count + LATCH/2) / LATCH; 71 count = (count + LATCH/2) / LATCH;
@@ -106,7 +99,7 @@ static irqreturn_t tmu_timer_interrupt(int irq, void *dummy)
106static struct irqaction tmu_irq = { 99static struct irqaction tmu_irq = {
107 .name = "timer", 100 .name = "timer",
108 .handler = tmu_timer_interrupt, 101 .handler = tmu_timer_interrupt,
109 .flags = IRQF_DISABLED, 102 .flags = IRQF_DISABLED | IRQF_TIMER,
110 .mask = CPU_MASK_NONE, 103 .mask = CPU_MASK_NONE,
111}; 104};
112 105
@@ -149,9 +142,9 @@ static int tmu_timer_init(void)
149{ 142{
150 unsigned long interval; 143 unsigned long interval;
151 144
152 setup_irq(TIMER_IRQ, &tmu_irq); 145 setup_irq(CONFIG_SH_TIMER_IRQ, &tmu_irq);
153 146
154 tmu0_clk.parent = clk_get("module_clk"); 147 tmu0_clk.parent = clk_get(NULL, "module_clk");
155 148
156 /* Start TMU0 */ 149 /* Start TMU0 */
157 tmu_timer_stop(); 150 tmu_timer_stop();
diff --git a/arch/sh/kernel/timers/timer.c b/arch/sh/kernel/timers/timer.c
index dc1f631053a8..a6bcc913d25e 100644
--- a/arch/sh/kernel/timers/timer.c
+++ b/arch/sh/kernel/timers/timer.c
@@ -17,6 +17,12 @@ static struct sys_timer *sys_timers[] __initdata = {
17#ifdef CONFIG_SH_TMU 17#ifdef CONFIG_SH_TMU
18 &tmu_timer, 18 &tmu_timer,
19#endif 19#endif
20#ifdef CONFIG_SH_MTU2
21 &mtu2_timer,
22#endif
23#ifdef CONFIG_SH_CMT
24 &cmt_timer,
25#endif
20 NULL, 26 NULL,
21}; 27};
22 28
diff --git a/arch/sh/kernel/traps.c b/arch/sh/kernel/traps.c
index 53dfa55f3156..3762d9dc2046 100644
--- a/arch/sh/kernel/traps.c
+++ b/arch/sh/kernel/traps.c
@@ -18,13 +18,14 @@
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/kallsyms.h> 19#include <linux/kallsyms.h>
20#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/debug_locks.h>
21#include <asm/system.h> 22#include <asm/system.h>
22#include <asm/uaccess.h> 23#include <asm/uaccess.h>
23 24
24#ifdef CONFIG_SH_KGDB 25#ifdef CONFIG_SH_KGDB
25#include <asm/kgdb.h> 26#include <asm/kgdb.h>
26#define CHK_REMOTE_DEBUG(regs) \ 27#define CHK_REMOTE_DEBUG(regs) \
27{ \ 28{ \
28 if (kgdb_debug_hook && !user_mode(regs))\ 29 if (kgdb_debug_hook && !user_mode(regs))\
29 (*kgdb_debug_hook)(regs); \ 30 (*kgdb_debug_hook)(regs); \
30} 31}
@@ -33,8 +34,13 @@
33#endif 34#endif
34 35
35#ifdef CONFIG_CPU_SH2 36#ifdef CONFIG_CPU_SH2
36#define TRAP_RESERVED_INST 4 37# define TRAP_RESERVED_INST 4
37#define TRAP_ILLEGAL_SLOT_INST 6 38# define TRAP_ILLEGAL_SLOT_INST 6
39# define TRAP_ADDRESS_ERROR 9
40# ifdef CONFIG_CPU_SH2A
41# define TRAP_DIVZERO_ERROR 17
42# define TRAP_DIVOVF_ERROR 18
43# endif
38#else 44#else
39#define TRAP_RESERVED_INST 12 45#define TRAP_RESERVED_INST 12
40#define TRAP_ILLEGAL_SLOT_INST 13 46#define TRAP_ILLEGAL_SLOT_INST 13
@@ -88,7 +94,7 @@ void die(const char * str, struct pt_regs * regs, long err)
88 94
89 if (!user_mode(regs) || in_interrupt()) 95 if (!user_mode(regs) || in_interrupt())
90 dump_mem("Stack: ", regs->regs[15], THREAD_SIZE + 96 dump_mem("Stack: ", regs->regs[15], THREAD_SIZE +
91 (unsigned long)task_stack_page(current)); 97 (unsigned long)task_stack_page(current));
92 98
93 bust_spinlocks(0); 99 bust_spinlocks(0);
94 spin_unlock_irq(&die_lock); 100 spin_unlock_irq(&die_lock);
@@ -102,8 +108,6 @@ static inline void die_if_kernel(const char *str, struct pt_regs *regs,
102 die(str, regs, err); 108 die(str, regs, err);
103} 109}
104 110
105static int handle_unaligned_notify_count = 10;
106
107/* 111/*
108 * try and fix up kernelspace address errors 112 * try and fix up kernelspace address errors
109 * - userspace errors just cause EFAULT to be returned, resulting in SEGV 113 * - userspace errors just cause EFAULT to be returned, resulting in SEGV
@@ -198,7 +202,7 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
198 if (copy_to_user(dst,src,4)) 202 if (copy_to_user(dst,src,4))
199 goto fetch_fault; 203 goto fetch_fault;
200 ret = 0; 204 ret = 0;
201 break; 205 break;
202 206
203 case 2: /* mov.[bwl] to memory, possibly with pre-decrement */ 207 case 2: /* mov.[bwl] to memory, possibly with pre-decrement */
204 if (instruction & 4) 208 if (instruction & 4)
@@ -222,7 +226,7 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
222 if (copy_from_user(dst,src,4)) 226 if (copy_from_user(dst,src,4))
223 goto fetch_fault; 227 goto fetch_fault;
224 ret = 0; 228 ret = 0;
225 break; 229 break;
226 230
227 case 6: /* mov.[bwl] from memory, possibly with post-increment */ 231 case 6: /* mov.[bwl] from memory, possibly with post-increment */
228 src = (unsigned char*) *rm; 232 src = (unsigned char*) *rm;
@@ -230,7 +234,7 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
230 *rm += count; 234 *rm += count;
231 dst = (unsigned char*) rn; 235 dst = (unsigned char*) rn;
232 *(unsigned long*)dst = 0; 236 *(unsigned long*)dst = 0;
233 237
234#ifdef __LITTLE_ENDIAN__ 238#ifdef __LITTLE_ENDIAN__
235 if (copy_from_user(dst, src, count)) 239 if (copy_from_user(dst, src, count))
236 goto fetch_fault; 240 goto fetch_fault;
@@ -241,7 +245,7 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
241 } 245 }
242#else 246#else
243 dst += 4-count; 247 dst += 4-count;
244 248
245 if (copy_from_user(dst, src, count)) 249 if (copy_from_user(dst, src, count))
246 goto fetch_fault; 250 goto fetch_fault;
247 251
@@ -320,7 +324,8 @@ static inline int handle_unaligned_delayslot(struct pt_regs *regs)
320 return -EFAULT; 324 return -EFAULT;
321 325
322 /* kernel */ 326 /* kernel */
323 die("delay-slot-insn faulting in handle_unaligned_delayslot", regs, 0); 327 die("delay-slot-insn faulting in handle_unaligned_delayslot",
328 regs, 0);
324 } 329 }
325 330
326 return handle_unaligned_ins(instruction,regs); 331 return handle_unaligned_ins(instruction,regs);
@@ -342,6 +347,13 @@ static inline int handle_unaligned_delayslot(struct pt_regs *regs)
342#define SH_PC_8BIT_OFFSET(instr) ((((signed char)(instr))*2) + 4) 347#define SH_PC_8BIT_OFFSET(instr) ((((signed char)(instr))*2) + 4)
343#define SH_PC_12BIT_OFFSET(instr) ((((signed short)(instr<<4))>>3) + 4) 348#define SH_PC_12BIT_OFFSET(instr) ((((signed short)(instr<<4))>>3) + 4)
344 349
350/*
351 * XXX: SH-2A needs this too, but it needs an overhaul thanks to mixed 32-bit
352 * opcodes..
353 */
354#ifndef CONFIG_CPU_SH2A
355static int handle_unaligned_notify_count = 10;
356
345static int handle_unaligned_access(u16 instruction, struct pt_regs *regs) 357static int handle_unaligned_access(u16 instruction, struct pt_regs *regs)
346{ 358{
347 u_int rm; 359 u_int rm;
@@ -354,7 +366,8 @@ static int handle_unaligned_access(u16 instruction, struct pt_regs *regs)
354 if (user_mode(regs) && handle_unaligned_notify_count>0) { 366 if (user_mode(regs) && handle_unaligned_notify_count>0) {
355 handle_unaligned_notify_count--; 367 handle_unaligned_notify_count--;
356 368
357 printk("Fixing up unaligned userspace access in \"%s\" pid=%d pc=0x%p ins=0x%04hx\n", 369 printk(KERN_NOTICE "Fixing up unaligned userspace access "
370 "in \"%s\" pid=%d pc=0x%p ins=0x%04hx\n",
358 current->comm,current->pid,(u16*)regs->pc,instruction); 371 current->comm,current->pid,(u16*)regs->pc,instruction);
359 } 372 }
360 373
@@ -478,32 +491,58 @@ static int handle_unaligned_access(u16 instruction, struct pt_regs *regs)
478 regs->pc += 2; 491 regs->pc += 2;
479 return ret; 492 return ret;
480} 493}
494#endif /* CONFIG_CPU_SH2A */
495
496#ifdef CONFIG_CPU_HAS_SR_RB
497#define lookup_exception_vector(x) \
498 __asm__ __volatile__ ("stc r2_bank, %0\n\t" : "=r" ((x)))
499#else
500#define lookup_exception_vector(x) \
501 __asm__ __volatile__ ("mov r4, %0\n\t" : "=r" ((x)))
502#endif
481 503
482/* 504/*
483 * Handle various address error exceptions 505 * Handle various address error exceptions:
506 * - instruction address error:
507 * misaligned PC
508 * PC >= 0x80000000 in user mode
509 * - data address error (read and write)
510 * misaligned data access
511 * access to >= 0x80000000 is user mode
512 * Unfortuntaly we can't distinguish between instruction address error
513 * and data address errors caused by read acceses.
484 */ 514 */
485asmlinkage void do_address_error(struct pt_regs *regs, 515asmlinkage void do_address_error(struct pt_regs *regs,
486 unsigned long writeaccess, 516 unsigned long writeaccess,
487 unsigned long address) 517 unsigned long address)
488{ 518{
489 unsigned long error_code; 519 unsigned long error_code = 0;
490 mm_segment_t oldfs; 520 mm_segment_t oldfs;
521 siginfo_t info;
522#ifndef CONFIG_CPU_SH2A
491 u16 instruction; 523 u16 instruction;
492 int tmp; 524 int tmp;
525#endif
493 526
494 asm volatile("stc r2_bank,%0": "=r" (error_code)); 527 /* Intentional ifdef */
528#ifdef CONFIG_CPU_HAS_SR_RB
529 lookup_exception_vector(error_code);
530#endif
495 531
496 oldfs = get_fs(); 532 oldfs = get_fs();
497 533
498 if (user_mode(regs)) { 534 if (user_mode(regs)) {
535 int si_code = BUS_ADRERR;
536
499 local_irq_enable(); 537 local_irq_enable();
500 current->thread.error_code = error_code;
501 current->thread.trap_no = (writeaccess) ? 8 : 7;
502 538
503 /* bad PC is not something we can fix */ 539 /* bad PC is not something we can fix */
504 if (regs->pc & 1) 540 if (regs->pc & 1) {
541 si_code = BUS_ADRALN;
505 goto uspace_segv; 542 goto uspace_segv;
543 }
506 544
545#ifndef CONFIG_CPU_SH2A
507 set_fs(USER_DS); 546 set_fs(USER_DS);
508 if (copy_from_user(&instruction, (u16 *)(regs->pc), 2)) { 547 if (copy_from_user(&instruction, (u16 *)(regs->pc), 2)) {
509 /* Argh. Fault on the instruction itself. 548 /* Argh. Fault on the instruction itself.
@@ -518,14 +557,23 @@ asmlinkage void do_address_error(struct pt_regs *regs,
518 557
519 if (tmp==0) 558 if (tmp==0)
520 return; /* sorted */ 559 return; /* sorted */
560#endif
521 561
522 uspace_segv: 562uspace_segv:
523 printk(KERN_NOTICE "Killing process \"%s\" due to unaligned access\n", current->comm); 563 printk(KERN_NOTICE "Sending SIGBUS to \"%s\" due to unaligned "
524 force_sig(SIGSEGV, current); 564 "access (PC %lx PR %lx)\n", current->comm, regs->pc,
565 regs->pr);
566
567 info.si_signo = SIGBUS;
568 info.si_errno = 0;
569 info.si_code = si_code;
570 info.si_addr = (void *) address;
571 force_sig_info(SIGBUS, &info, current);
525 } else { 572 } else {
526 if (regs->pc & 1) 573 if (regs->pc & 1)
527 die("unaligned program counter", regs, error_code); 574 die("unaligned program counter", regs, error_code);
528 575
576#ifndef CONFIG_CPU_SH2A
529 set_fs(KERNEL_DS); 577 set_fs(KERNEL_DS);
530 if (copy_from_user(&instruction, (u16 *)(regs->pc), 2)) { 578 if (copy_from_user(&instruction, (u16 *)(regs->pc), 2)) {
531 /* Argh. Fault on the instruction itself. 579 /* Argh. Fault on the instruction itself.
@@ -537,6 +585,12 @@ asmlinkage void do_address_error(struct pt_regs *regs,
537 585
538 handle_unaligned_access(instruction, regs); 586 handle_unaligned_access(instruction, regs);
539 set_fs(oldfs); 587 set_fs(oldfs);
588#else
589 printk(KERN_NOTICE "Killing process \"%s\" due to unaligned "
590 "access\n", current->comm);
591
592 force_sig(SIGSEGV, current);
593#endif
540 } 594 }
541} 595}
542 596
@@ -548,7 +602,7 @@ int is_dsp_inst(struct pt_regs *regs)
548{ 602{
549 unsigned short inst; 603 unsigned short inst;
550 604
551 /* 605 /*
552 * Safe guard if DSP mode is already enabled or we're lacking 606 * Safe guard if DSP mode is already enabled or we're lacking
553 * the DSP altogether. 607 * the DSP altogether.
554 */ 608 */
@@ -569,27 +623,49 @@ int is_dsp_inst(struct pt_regs *regs)
569#define is_dsp_inst(regs) (0) 623#define is_dsp_inst(regs) (0)
570#endif /* CONFIG_SH_DSP */ 624#endif /* CONFIG_SH_DSP */
571 625
626#ifdef CONFIG_CPU_SH2A
627asmlinkage void do_divide_error(unsigned long r4, unsigned long r5,
628 unsigned long r6, unsigned long r7,
629 struct pt_regs __regs)
630{
631 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
632 siginfo_t info;
633
634 switch (r4) {
635 case TRAP_DIVZERO_ERROR:
636 info.si_code = FPE_INTDIV;
637 break;
638 case TRAP_DIVOVF_ERROR:
639 info.si_code = FPE_INTOVF;
640 break;
641 }
642
643 force_sig_info(SIGFPE, &info, current);
644}
645#endif
646
572/* arch/sh/kernel/cpu/sh4/fpu.c */ 647/* arch/sh/kernel/cpu/sh4/fpu.c */
573extern int do_fpu_inst(unsigned short, struct pt_regs *); 648extern int do_fpu_inst(unsigned short, struct pt_regs *);
574extern asmlinkage void do_fpu_state_restore(unsigned long r4, unsigned long r5, 649extern asmlinkage void do_fpu_state_restore(unsigned long r4, unsigned long r5,
575 unsigned long r6, unsigned long r7, struct pt_regs regs); 650 unsigned long r6, unsigned long r7, struct pt_regs __regs);
576 651
577asmlinkage void do_reserved_inst(unsigned long r4, unsigned long r5, 652asmlinkage void do_reserved_inst(unsigned long r4, unsigned long r5,
578 unsigned long r6, unsigned long r7, 653 unsigned long r6, unsigned long r7,
579 struct pt_regs regs) 654 struct pt_regs __regs)
580{ 655{
656 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
581 unsigned long error_code; 657 unsigned long error_code;
582 struct task_struct *tsk = current; 658 struct task_struct *tsk = current;
583 659
584#ifdef CONFIG_SH_FPU_EMU 660#ifdef CONFIG_SH_FPU_EMU
585 unsigned short inst; 661 unsigned short inst = 0;
586 int err; 662 int err;
587 663
588 get_user(inst, (unsigned short*)regs.pc); 664 get_user(inst, (unsigned short*)regs->pc);
589 665
590 err = do_fpu_inst(inst, &regs); 666 err = do_fpu_inst(inst, regs);
591 if (!err) { 667 if (!err) {
592 regs.pc += 2; 668 regs->pc += 2;
593 return; 669 return;
594 } 670 }
595 /* not a FPU inst. */ 671 /* not a FPU inst. */
@@ -597,20 +673,19 @@ asmlinkage void do_reserved_inst(unsigned long r4, unsigned long r5,
597 673
598#ifdef CONFIG_SH_DSP 674#ifdef CONFIG_SH_DSP
599 /* Check if it's a DSP instruction */ 675 /* Check if it's a DSP instruction */
600 if (is_dsp_inst(&regs)) { 676 if (is_dsp_inst(regs)) {
601 /* Enable DSP mode, and restart instruction. */ 677 /* Enable DSP mode, and restart instruction. */
602 regs.sr |= SR_DSP; 678 regs->sr |= SR_DSP;
603 return; 679 return;
604 } 680 }
605#endif 681#endif
606 682
607 asm volatile("stc r2_bank, %0": "=r" (error_code)); 683 lookup_exception_vector(error_code);
684
608 local_irq_enable(); 685 local_irq_enable();
609 tsk->thread.error_code = error_code; 686 CHK_REMOTE_DEBUG(regs);
610 tsk->thread.trap_no = TRAP_RESERVED_INST;
611 CHK_REMOTE_DEBUG(&regs);
612 force_sig(SIGILL, tsk); 687 force_sig(SIGILL, tsk);
613 die_if_no_fixup("reserved instruction", &regs, error_code); 688 die_if_no_fixup("reserved instruction", regs, error_code);
614} 689}
615 690
616#ifdef CONFIG_SH_FPU_EMU 691#ifdef CONFIG_SH_FPU_EMU
@@ -658,39 +733,41 @@ static int emulate_branch(unsigned short inst, struct pt_regs* regs)
658 733
659asmlinkage void do_illegal_slot_inst(unsigned long r4, unsigned long r5, 734asmlinkage void do_illegal_slot_inst(unsigned long r4, unsigned long r5,
660 unsigned long r6, unsigned long r7, 735 unsigned long r6, unsigned long r7,
661 struct pt_regs regs) 736 struct pt_regs __regs)
662{ 737{
738 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
663 unsigned long error_code; 739 unsigned long error_code;
664 struct task_struct *tsk = current; 740 struct task_struct *tsk = current;
665#ifdef CONFIG_SH_FPU_EMU 741#ifdef CONFIG_SH_FPU_EMU
666 unsigned short inst; 742 unsigned short inst = 0;
667 743
668 get_user(inst, (unsigned short *)regs.pc + 1); 744 get_user(inst, (unsigned short *)regs->pc + 1);
669 if (!do_fpu_inst(inst, &regs)) { 745 if (!do_fpu_inst(inst, regs)) {
670 get_user(inst, (unsigned short *)regs.pc); 746 get_user(inst, (unsigned short *)regs->pc);
671 if (!emulate_branch(inst, &regs)) 747 if (!emulate_branch(inst, regs))
672 return; 748 return;
673 /* fault in branch.*/ 749 /* fault in branch.*/
674 } 750 }
675 /* not a FPU inst. */ 751 /* not a FPU inst. */
676#endif 752#endif
677 753
678 asm volatile("stc r2_bank, %0": "=r" (error_code)); 754 lookup_exception_vector(error_code);
755
679 local_irq_enable(); 756 local_irq_enable();
680 tsk->thread.error_code = error_code; 757 CHK_REMOTE_DEBUG(regs);
681 tsk->thread.trap_no = TRAP_RESERVED_INST;
682 CHK_REMOTE_DEBUG(&regs);
683 force_sig(SIGILL, tsk); 758 force_sig(SIGILL, tsk);
684 die_if_no_fixup("illegal slot instruction", &regs, error_code); 759 die_if_no_fixup("illegal slot instruction", regs, error_code);
685} 760}
686 761
687asmlinkage void do_exception_error(unsigned long r4, unsigned long r5, 762asmlinkage void do_exception_error(unsigned long r4, unsigned long r5,
688 unsigned long r6, unsigned long r7, 763 unsigned long r6, unsigned long r7,
689 struct pt_regs regs) 764 struct pt_regs __regs)
690{ 765{
766 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
691 long ex; 767 long ex;
692 asm volatile("stc r2_bank, %0" : "=r" (ex)); 768
693 die_if_kernel("exception", &regs, ex); 769 lookup_exception_vector(ex);
770 die_if_kernel("exception", regs, ex);
694} 771}
695 772
696#if defined(CONFIG_SH_STANDARD_BIOS) 773#if defined(CONFIG_SH_STANDARD_BIOS)
@@ -735,12 +812,16 @@ void *set_exception_table_vec(unsigned int vec, void *handler)
735{ 812{
736 extern void *exception_handling_table[]; 813 extern void *exception_handling_table[];
737 void *old_handler; 814 void *old_handler;
738 815
739 old_handler = exception_handling_table[vec]; 816 old_handler = exception_handling_table[vec];
740 exception_handling_table[vec] = handler; 817 exception_handling_table[vec] = handler;
741 return old_handler; 818 return old_handler;
742} 819}
743 820
821extern asmlinkage void address_error_handler(unsigned long r4, unsigned long r5,
822 unsigned long r6, unsigned long r7,
823 struct pt_regs __regs);
824
744void __init trap_init(void) 825void __init trap_init(void)
745{ 826{
746 set_exception_table_vec(TRAP_RESERVED_INST, do_reserved_inst); 827 set_exception_table_vec(TRAP_RESERVED_INST, do_reserved_inst);
@@ -759,7 +840,15 @@ void __init trap_init(void)
759 set_exception_table_evt(0x800, do_fpu_state_restore); 840 set_exception_table_evt(0x800, do_fpu_state_restore);
760 set_exception_table_evt(0x820, do_fpu_state_restore); 841 set_exception_table_evt(0x820, do_fpu_state_restore);
761#endif 842#endif
762 843
844#ifdef CONFIG_CPU_SH2
845 set_exception_table_vec(TRAP_ADDRESS_ERROR, address_error_handler);
846#endif
847#ifdef CONFIG_CPU_SH2A
848 set_exception_table_vec(TRAP_DIVZERO_ERROR, do_divide_error);
849 set_exception_table_vec(TRAP_DIVOVF_ERROR, do_divide_error);
850#endif
851
763 /* Setup VBR for boot cpu */ 852 /* Setup VBR for boot cpu */
764 per_cpu_trap_init(); 853 per_cpu_trap_init();
765} 854}
@@ -784,6 +873,11 @@ void show_trace(struct task_struct *tsk, unsigned long *sp,
784 } 873 }
785 874
786 printk("\n"); 875 printk("\n");
876
877 if (!tsk)
878 tsk = current;
879
880 debug_show_held_locks(tsk);
787} 881}
788 882
789void show_stack(struct task_struct *tsk, unsigned long *sp) 883void show_stack(struct task_struct *tsk, unsigned long *sp)
diff --git a/arch/sh/kernel/vsyscall/vsyscall.c b/arch/sh/kernel/vsyscall/vsyscall.c
index 075d6cc1a2d7..deb46941f315 100644
--- a/arch/sh/kernel/vsyscall/vsyscall.c
+++ b/arch/sh/kernel/vsyscall/vsyscall.c
@@ -97,7 +97,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
97 goto up_fail; 97 goto up_fail;
98 } 98 }
99 99
100 vma = kmem_cache_zalloc(vm_area_cachep, SLAB_KERNEL); 100 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
101 if (!vma) { 101 if (!vma) {
102 ret = -ENOMEM; 102 ret = -ENOMEM;
103 goto up_fail; 103 goto up_fail;
diff --git a/arch/sh/mm/Kconfig b/arch/sh/mm/Kconfig
index 9dd606464d23..4e0362f50384 100644
--- a/arch/sh/mm/Kconfig
+++ b/arch/sh/mm/Kconfig
@@ -4,8 +4,12 @@ menu "Processor selection"
4# Processor families 4# Processor families
5# 5#
6config CPU_SH2 6config CPU_SH2
7 select SH_WRITETHROUGH if !CPU_SH2A
7 bool 8 bool
8 select SH_WRITETHROUGH 9
10config CPU_SH2A
11 bool
12 select CPU_SH2
9 13
10config CPU_SH3 14config CPU_SH3
11 bool 15 bool
@@ -16,6 +20,7 @@ config CPU_SH4
16 bool 20 bool
17 select CPU_HAS_INTEVT 21 select CPU_HAS_INTEVT
18 select CPU_HAS_SR_RB 22 select CPU_HAS_SR_RB
23 select CPU_HAS_PTEA if !CPU_SUBTYPE_ST40
19 24
20config CPU_SH4A 25config CPU_SH4A
21 bool 26 bool
@@ -40,6 +45,16 @@ config CPU_SUBTYPE_SH7604
40 bool "Support SH7604 processor" 45 bool "Support SH7604 processor"
41 select CPU_SH2 46 select CPU_SH2
42 47
48config CPU_SUBTYPE_SH7619
49 bool "Support SH7619 processor"
50 select CPU_SH2
51
52comment "SH-2A Processor Support"
53
54config CPU_SUBTYPE_SH7206
55 bool "Support SH7206 processor"
56 select CPU_SH2A
57
43comment "SH-3 Processor Support" 58comment "SH-3 Processor Support"
44 59
45config CPU_SUBTYPE_SH7300 60config CPU_SUBTYPE_SH7300
@@ -89,6 +104,7 @@ comment "SH-4 Processor Support"
89config CPU_SUBTYPE_SH7750 104config CPU_SUBTYPE_SH7750
90 bool "Support SH7750 processor" 105 bool "Support SH7750 processor"
91 select CPU_SH4 106 select CPU_SH4
107 select CPU_HAS_IPR_IRQ
92 help 108 help
93 Select SH7750 if you have a 200 Mhz SH-4 HD6417750 CPU. 109 Select SH7750 if you have a 200 Mhz SH-4 HD6417750 CPU.
94 110
@@ -104,15 +120,18 @@ config CPU_SUBTYPE_SH7750R
104 bool "Support SH7750R processor" 120 bool "Support SH7750R processor"
105 select CPU_SH4 121 select CPU_SH4
106 select CPU_SUBTYPE_SH7750 122 select CPU_SUBTYPE_SH7750
123 select CPU_HAS_IPR_IRQ
107 124
108config CPU_SUBTYPE_SH7750S 125config CPU_SUBTYPE_SH7750S
109 bool "Support SH7750S processor" 126 bool "Support SH7750S processor"
110 select CPU_SH4 127 select CPU_SH4
111 select CPU_SUBTYPE_SH7750 128 select CPU_SUBTYPE_SH7750
129 select CPU_HAS_IPR_IRQ
112 130
113config CPU_SUBTYPE_SH7751 131config CPU_SUBTYPE_SH7751
114 bool "Support SH7751 processor" 132 bool "Support SH7751 processor"
115 select CPU_SH4 133 select CPU_SH4
134 select CPU_HAS_IPR_IRQ
116 help 135 help
117 Select SH7751 if you have a 166 Mhz SH-4 HD6417751 CPU, 136 Select SH7751 if you have a 166 Mhz SH-4 HD6417751 CPU,
118 or if you have a HD6417751R CPU. 137 or if you have a HD6417751R CPU.
@@ -121,6 +140,7 @@ config CPU_SUBTYPE_SH7751R
121 bool "Support SH7751R processor" 140 bool "Support SH7751R processor"
122 select CPU_SH4 141 select CPU_SH4
123 select CPU_SUBTYPE_SH7751 142 select CPU_SUBTYPE_SH7751
143 select CPU_HAS_IPR_IRQ
124 144
125config CPU_SUBTYPE_SH7760 145config CPU_SUBTYPE_SH7760
126 bool "Support SH7760 processor" 146 bool "Support SH7760 processor"
@@ -157,6 +177,11 @@ config CPU_SUBTYPE_SH7780
157 select CPU_SH4A 177 select CPU_SH4A
158 select CPU_HAS_INTC2_IRQ 178 select CPU_HAS_INTC2_IRQ
159 179
180config CPU_SUBTYPE_SH7785
181 bool "Support SH7785 processor"
182 select CPU_SH4A
183 select CPU_HAS_INTC2_IRQ
184
160comment "SH4AL-DSP Processor Support" 185comment "SH4AL-DSP Processor Support"
161 186
162config CPU_SUBTYPE_SH73180 187config CPU_SUBTYPE_SH73180
@@ -216,13 +241,22 @@ config MEMORY_SIZE
216 241
217config 32BIT 242config 32BIT
218 bool "Support 32-bit physical addressing through PMB" 243 bool "Support 32-bit physical addressing through PMB"
219 depends on CPU_SH4A && MMU 244 depends on CPU_SH4A && MMU && (!X2TLB || BROKEN)
220 default y 245 default y
221 help 246 help
222 If you say Y here, physical addressing will be extended to 247 If you say Y here, physical addressing will be extended to
223 32-bits through the SH-4A PMB. If this is not set, legacy 248 32-bits through the SH-4A PMB. If this is not set, legacy
224 29-bit physical addressing will be used. 249 29-bit physical addressing will be used.
225 250
251config X2TLB
252 bool "Enable extended TLB mode"
253 depends on CPU_SUBTYPE_SH7785 && MMU && EXPERIMENTAL
254 help
255 Selecting this option will enable the extended mode of the SH-X2
256 TLB. For legacy SH-X behaviour and interoperability, say N. For
257 all of the fun new features and a willingless to submit bug reports,
258 say Y.
259
226config VSYSCALL 260config VSYSCALL
227 bool "Support vsyscall page" 261 bool "Support vsyscall page"
228 depends on MMU 262 depends on MMU
@@ -237,16 +271,52 @@ config VSYSCALL
237 (the default value) say Y. 271 (the default value) say Y.
238 272
239choice 273choice
274 prompt "Kernel page size"
275 default PAGE_SIZE_4KB
276
277config PAGE_SIZE_4KB
278 bool "4kB"
279 help
280 This is the default page size used by all SuperH CPUs.
281
282config PAGE_SIZE_8KB
283 bool "8kB"
284 depends on EXPERIMENTAL && X2TLB
285 help
286 This enables 8kB pages as supported by SH-X2 and later MMUs.
287
288config PAGE_SIZE_64KB
289 bool "64kB"
290 depends on EXPERIMENTAL && CPU_SH4
291 help
292 This enables support for 64kB pages, possible on all SH-4
293 CPUs and later. Highly experimental, not recommended.
294
295endchoice
296
297choice
240 prompt "HugeTLB page size" 298 prompt "HugeTLB page size"
241 depends on HUGETLB_PAGE && CPU_SH4 && MMU 299 depends on HUGETLB_PAGE && CPU_SH4 && MMU
242 default HUGETLB_PAGE_SIZE_64K 300 default HUGETLB_PAGE_SIZE_64K
243 301
244config HUGETLB_PAGE_SIZE_64K 302config HUGETLB_PAGE_SIZE_64K
245 bool "64K" 303 bool "64kB"
304
305config HUGETLB_PAGE_SIZE_256K
306 bool "256kB"
307 depends on X2TLB
246 308
247config HUGETLB_PAGE_SIZE_1MB 309config HUGETLB_PAGE_SIZE_1MB
248 bool "1MB" 310 bool "1MB"
249 311
312config HUGETLB_PAGE_SIZE_4MB
313 bool "4MB"
314 depends on X2TLB
315
316config HUGETLB_PAGE_SIZE_64MB
317 bool "64MB"
318 depends on X2TLB
319
250endchoice 320endchoice
251 321
252source "mm/Kconfig" 322source "mm/Kconfig"
@@ -274,7 +344,6 @@ config SH_DIRECT_MAPPED
274 344
275config SH_WRITETHROUGH 345config SH_WRITETHROUGH
276 bool "Use write-through caching" 346 bool "Use write-through caching"
277 default y if CPU_SH2
278 help 347 help
279 Selecting this option will configure the caches in write-through 348 Selecting this option will configure the caches in write-through
280 mode, as opposed to the default write-back configuration. 349 mode, as opposed to the default write-back configuration.
diff --git a/arch/sh/mm/cache-sh2.c b/arch/sh/mm/cache-sh2.c
index 2689cb24ea2b..6614033f6be9 100644
--- a/arch/sh/mm/cache-sh2.c
+++ b/arch/sh/mm/cache-sh2.c
@@ -5,6 +5,7 @@
5 * 5 *
6 * Released under the terms of the GNU GPL v2.0. 6 * Released under the terms of the GNU GPL v2.0.
7 */ 7 */
8
8#include <linux/init.h> 9#include <linux/init.h>
9#include <linux/mm.h> 10#include <linux/mm.h>
10 11
@@ -14,37 +15,43 @@
14#include <asm/cacheflush.h> 15#include <asm/cacheflush.h>
15#include <asm/io.h> 16#include <asm/io.h>
16 17
17/* 18void __flush_wback_region(void *start, int size)
18 * Calculate the OC address and set the way bit on the SH-2.
19 *
20 * We must have already jump_to_P2()'ed prior to calling this
21 * function, since we rely on CCR manipulation to do the
22 * Right Thing(tm).
23 */
24unsigned long __get_oc_addr(unsigned long set, unsigned long way)
25{ 19{
26 unsigned long ccr; 20 unsigned long v;
27 21 unsigned long begin, end;
28 /* 22
29 * On SH-2 the way bit isn't tracked in the address field 23 begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
30 * if we're doing address array access .. instead, we need 24 end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
31 * to manually switch out the way in the CCR. 25 & ~(L1_CACHE_BYTES-1);
32 */ 26 for (v = begin; v < end; v+=L1_CACHE_BYTES) {
33 ccr = ctrl_inl(CCR); 27 /* FIXME cache purge */
34 ccr &= ~0x00c0; 28 ctrl_outl((v & 0x1ffffc00), (v & 0x00000ff0) | 0x00000008);
35 ccr |= way << cpu_data->dcache.way_shift; 29 }
36 30}
37 /* 31
38 * Despite the number of sets being halved, we end up losing 32void __flush_purge_region(void *start, int size)
39 * the first 2 ways to OCRAM instead of the last 2 (if we're 33{
40 * 4-way). As a result, forcibly setting the W1 bit handily 34 unsigned long v;
41 * bumps us up 2 ways. 35 unsigned long begin, end;
42 */ 36
43 if (ccr & CCR_CACHE_ORA) 37 begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
44 ccr |= 1 << (cpu_data->dcache.way_shift + 1); 38 end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
45 39 & ~(L1_CACHE_BYTES-1);
46 ctrl_outl(ccr, CCR); 40 for (v = begin; v < end; v+=L1_CACHE_BYTES) {
47 41 ctrl_outl((v & 0x1ffffc00), (v & 0x00000ff0) | 0x00000008);
48 return CACHE_OC_ADDRESS_ARRAY | (set << cpu_data->dcache.entry_shift); 42 }
43}
44
45void __flush_invalidate_region(void *start, int size)
46{
47 unsigned long v;
48 unsigned long begin, end;
49
50 begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
51 end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
52 & ~(L1_CACHE_BYTES-1);
53 for (v = begin; v < end; v+=L1_CACHE_BYTES) {
54 ctrl_outl((v & 0x1ffffc00), (v & 0x00000ff0) | 0x00000008);
55 }
49} 56}
50 57
diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
index e48cc22724d9..ae531affccbd 100644
--- a/arch/sh/mm/cache-sh4.c
+++ b/arch/sh/mm/cache-sh4.c
@@ -11,12 +11,8 @@
11 */ 11 */
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <asm/addrspace.h> 14#include <linux/io.h>
15#include <asm/pgtable.h> 15#include <linux/mutex.h>
16#include <asm/processor.h>
17#include <asm/cache.h>
18#include <asm/io.h>
19#include <asm/pgalloc.h>
20#include <asm/mmu_context.h> 16#include <asm/mmu_context.h>
21#include <asm/cacheflush.h> 17#include <asm/cacheflush.h>
22 18
@@ -83,9 +79,9 @@ static void __init emit_cache_params(void)
83 */ 79 */
84 80
85/* Worst case assumed to be 64k cache, direct-mapped i.e. 4 synonym bits. */ 81/* Worst case assumed to be 64k cache, direct-mapped i.e. 4 synonym bits. */
86#define MAX_P3_SEMAPHORES 16 82#define MAX_P3_MUTEXES 16
87 83
88struct semaphore p3map_sem[MAX_P3_SEMAPHORES]; 84struct mutex p3map_mutex[MAX_P3_MUTEXES];
89 85
90void __init p3_cache_init(void) 86void __init p3_cache_init(void)
91{ 87{
@@ -115,7 +111,7 @@ void __init p3_cache_init(void)
115 panic("%s failed.", __FUNCTION__); 111 panic("%s failed.", __FUNCTION__);
116 112
117 for (i = 0; i < cpu_data->dcache.n_aliases; i++) 113 for (i = 0; i < cpu_data->dcache.n_aliases; i++)
118 sema_init(&p3map_sem[i], 1); 114 mutex_init(&p3map_mutex[i]);
119} 115}
120 116
121/* 117/*
@@ -229,7 +225,7 @@ static inline void flush_cache_4096(unsigned long start,
229 */ 225 */
230 if ((cpu_data->flags & CPU_HAS_P2_FLUSH_BUG) || 226 if ((cpu_data->flags & CPU_HAS_P2_FLUSH_BUG) ||
231 (start < CACHE_OC_ADDRESS_ARRAY)) 227 (start < CACHE_OC_ADDRESS_ARRAY))
232 exec_offset = 0x20000000; 228 exec_offset = 0x20000000;
233 229
234 local_irq_save(flags); 230 local_irq_save(flags);
235 __flush_cache_4096(start | SH_CACHE_ASSOC, 231 __flush_cache_4096(start | SH_CACHE_ASSOC,
@@ -250,7 +246,7 @@ void flush_dcache_page(struct page *page)
250 246
251 /* Loop all the D-cache */ 247 /* Loop all the D-cache */
252 n = cpu_data->dcache.n_aliases; 248 n = cpu_data->dcache.n_aliases;
253 for (i = 0; i < n; i++, addr += PAGE_SIZE) 249 for (i = 0; i < n; i++, addr += 4096)
254 flush_cache_4096(addr, phys); 250 flush_cache_4096(addr, phys);
255 } 251 }
256 252
diff --git a/arch/sh/mm/clear_page.S b/arch/sh/mm/clear_page.S
index 7b96425ae270..8a706131e521 100644
--- a/arch/sh/mm/clear_page.S
+++ b/arch/sh/mm/clear_page.S
@@ -1,12 +1,12 @@
1/* $Id: clear_page.S,v 1.13 2003/08/25 17:03:10 lethal Exp $ 1/*
2 *
3 * __clear_user_page, __clear_user, clear_page implementation of SuperH 2 * __clear_user_page, __clear_user, clear_page implementation of SuperH
4 * 3 *
5 * Copyright (C) 2001 Kaz Kojima 4 * Copyright (C) 2001 Kaz Kojima
6 * Copyright (C) 2001, 2002 Niibe Yutaka 5 * Copyright (C) 2001, 2002 Niibe Yutaka
7 * 6 * Copyright (C) 2006 Paul Mundt
8 */ 7 */
9#include <linux/linkage.h> 8#include <linux/linkage.h>
9#include <asm/page.h>
10 10
11/* 11/*
12 * clear_page_slow 12 * clear_page_slow
@@ -18,11 +18,11 @@
18/* 18/*
19 * r0 --- scratch 19 * r0 --- scratch
20 * r4 --- to 20 * r4 --- to
21 * r5 --- to + 4096 21 * r5 --- to + PAGE_SIZE
22 */ 22 */
23ENTRY(clear_page_slow) 23ENTRY(clear_page_slow)
24 mov r4,r5 24 mov r4,r5
25 mov.w .Llimit,r0 25 mov.l .Llimit,r0
26 add r0,r5 26 add r0,r5
27 mov #0,r0 27 mov #0,r0
28 ! 28 !
@@ -50,7 +50,7 @@ ENTRY(clear_page_slow)
50 ! 50 !
51 rts 51 rts
52 nop 52 nop
53.Llimit: .word (4096-28) 53.Llimit: .long (PAGE_SIZE-28)
54 54
55ENTRY(__clear_user) 55ENTRY(__clear_user)
56 ! 56 !
@@ -164,10 +164,10 @@ ENTRY(__clear_user)
164 * r0 --- scratch 164 * r0 --- scratch
165 * r4 --- to 165 * r4 --- to
166 * r5 --- orig_to 166 * r5 --- orig_to
167 * r6 --- to + 4096 167 * r6 --- to + PAGE_SIZE
168 */ 168 */
169ENTRY(__clear_user_page) 169ENTRY(__clear_user_page)
170 mov.w .L4096,r0 170 mov.l .Lpsz,r0
171 mov r4,r6 171 mov r4,r6
172 add r0,r6 172 add r0,r6
173 mov #0,r0 173 mov #0,r0
@@ -191,7 +191,7 @@ ENTRY(__clear_user_page)
191 ! 191 !
192 rts 192 rts
193 nop 193 nop
194.L4096: .word 4096 194.Lpsz: .long PAGE_SIZE
195 195
196#endif 196#endif
197 197
diff --git a/arch/sh/mm/copy_page.S b/arch/sh/mm/copy_page.S
index 1addffe117c3..397c94c97315 100644
--- a/arch/sh/mm/copy_page.S
+++ b/arch/sh/mm/copy_page.S
@@ -1,12 +1,12 @@
1/* $Id: copy_page.S,v 1.8 2003/08/25 17:03:10 lethal Exp $ 1/*
2 *
3 * copy_page, __copy_user_page, __copy_user implementation of SuperH 2 * copy_page, __copy_user_page, __copy_user implementation of SuperH
4 * 3 *
5 * Copyright (C) 2001 Niibe Yutaka & Kaz Kojima 4 * Copyright (C) 2001 Niibe Yutaka & Kaz Kojima
6 * Copyright (C) 2002 Toshinobu Sugioka 5 * Copyright (C) 2002 Toshinobu Sugioka
7 * 6 * Copyright (C) 2006 Paul Mundt
8 */ 7 */
9#include <linux/linkage.h> 8#include <linux/linkage.h>
9#include <asm/page.h>
10 10
11/* 11/*
12 * copy_page_slow 12 * copy_page_slow
@@ -18,7 +18,7 @@
18 18
19/* 19/*
20 * r0, r1, r2, r3, r4, r5, r6, r7 --- scratch 20 * r0, r1, r2, r3, r4, r5, r6, r7 --- scratch
21 * r8 --- from + 4096 21 * r8 --- from + PAGE_SIZE
22 * r9 --- not used 22 * r9 --- not used
23 * r10 --- to 23 * r10 --- to
24 * r11 --- from 24 * r11 --- from
@@ -30,7 +30,7 @@ ENTRY(copy_page_slow)
30 mov r4,r10 30 mov r4,r10
31 mov r5,r11 31 mov r5,r11
32 mov r5,r8 32 mov r5,r8
33 mov.w .L4096,r0 33 mov.l .Lpsz,r0
34 add r0,r8 34 add r0,r8
35 ! 35 !
361: mov.l @r11+,r0 361: mov.l @r11+,r0
@@ -80,7 +80,7 @@ ENTRY(copy_page_slow)
80 80
81/* 81/*
82 * r0, r1, r2, r3, r4, r5, r6, r7 --- scratch 82 * r0, r1, r2, r3, r4, r5, r6, r7 --- scratch
83 * r8 --- from + 4096 83 * r8 --- from + PAGE_SIZE
84 * r9 --- orig_to 84 * r9 --- orig_to
85 * r10 --- to 85 * r10 --- to
86 * r11 --- from 86 * r11 --- from
@@ -94,7 +94,7 @@ ENTRY(__copy_user_page)
94 mov r5,r11 94 mov r5,r11
95 mov r6,r9 95 mov r6,r9
96 mov r5,r8 96 mov r5,r8
97 mov.w .L4096,r0 97 mov.l .Lpsz,r0
98 add r0,r8 98 add r0,r8
99 ! 99 !
1001: ocbi @r9 1001: ocbi @r9
@@ -129,7 +129,7 @@ ENTRY(__copy_user_page)
129 rts 129 rts
130 nop 130 nop
131#endif 131#endif
132.L4096: .word 4096 132.Lpsz: .long PAGE_SIZE
133/* 133/*
134 * __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n); 134 * __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
135 * Return the number of bytes NOT copied 135 * Return the number of bytes NOT copied
diff --git a/arch/sh/mm/fault.c b/arch/sh/mm/fault.c
index 68663b8f99ae..716ebf568af2 100644
--- a/arch/sh/mm/fault.c
+++ b/arch/sh/mm/fault.c
@@ -26,13 +26,19 @@ extern void die(const char *,struct pt_regs *,long);
26 * and the problem, and then passes it off to one of the appropriate 26 * and the problem, and then passes it off to one of the appropriate
27 * routines. 27 * routines.
28 */ 28 */
29asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess, 29asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
30 unsigned long address) 30 unsigned long writeaccess,
31 unsigned long address)
31{ 32{
32 struct task_struct *tsk; 33 struct task_struct *tsk;
33 struct mm_struct *mm; 34 struct mm_struct *mm;
34 struct vm_area_struct * vma; 35 struct vm_area_struct * vma;
35 unsigned long page; 36 unsigned long page;
37 int si_code;
38 siginfo_t info;
39
40 trace_hardirqs_on();
41 local_irq_enable();
36 42
37#ifdef CONFIG_SH_KGDB 43#ifdef CONFIG_SH_KGDB
38 if (kgdb_nofault && kgdb_bus_err_hook) 44 if (kgdb_nofault && kgdb_bus_err_hook)
@@ -41,6 +47,46 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
41 47
42 tsk = current; 48 tsk = current;
43 mm = tsk->mm; 49 mm = tsk->mm;
50 si_code = SEGV_MAPERR;
51
52 if (unlikely(address >= TASK_SIZE)) {
53 /*
54 * Synchronize this task's top level page-table
55 * with the 'reference' page table.
56 *
57 * Do _not_ use "tsk" here. We might be inside
58 * an interrupt in the middle of a task switch..
59 */
60 int offset = pgd_index(address);
61 pgd_t *pgd, *pgd_k;
62 pud_t *pud, *pud_k;
63 pmd_t *pmd, *pmd_k;
64
65 pgd = get_TTB() + offset;
66 pgd_k = swapper_pg_dir + offset;
67
68 /* This will never happen with the folded page table. */
69 if (!pgd_present(*pgd)) {
70 if (!pgd_present(*pgd_k))
71 goto bad_area_nosemaphore;
72 set_pgd(pgd, *pgd_k);
73 return;
74 }
75
76 pud = pud_offset(pgd, address);
77 pud_k = pud_offset(pgd_k, address);
78 if (pud_present(*pud) || !pud_present(*pud_k))
79 goto bad_area_nosemaphore;
80 set_pud(pud, *pud_k);
81
82 pmd = pmd_offset(pud, address);
83 pmd_k = pmd_offset(pud_k, address);
84 if (pmd_present(*pmd) || !pmd_present(*pmd_k))
85 goto bad_area_nosemaphore;
86 set_pmd(pmd, *pmd_k);
87
88 return;
89 }
44 90
45 /* 91 /*
46 * If we're in an interrupt or have no user 92 * If we're in an interrupt or have no user
@@ -65,6 +111,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
65 * we can handle it.. 111 * we can handle it..
66 */ 112 */
67good_area: 113good_area:
114 si_code = SEGV_ACCERR;
68 if (writeaccess) { 115 if (writeaccess) {
69 if (!(vma->vm_flags & VM_WRITE)) 116 if (!(vma->vm_flags & VM_WRITE))
70 goto bad_area; 117 goto bad_area;
@@ -104,10 +151,13 @@ survive:
104bad_area: 151bad_area:
105 up_read(&mm->mmap_sem); 152 up_read(&mm->mmap_sem);
106 153
154bad_area_nosemaphore:
107 if (user_mode(regs)) { 155 if (user_mode(regs)) {
108 tsk->thread.address = address; 156 info.si_signo = SIGSEGV;
109 tsk->thread.error_code = writeaccess; 157 info.si_errno = 0;
110 force_sig(SIGSEGV, tsk); 158 info.si_code = si_code;
159 info.si_addr = (void *) address;
160 force_sig_info(SIGSEGV, &info, tsk);
111 return; 161 return;
112 } 162 }
113 163
@@ -127,11 +177,9 @@ no_context:
127 printk(KERN_ALERT "Unable to handle kernel paging request"); 177 printk(KERN_ALERT "Unable to handle kernel paging request");
128 printk(" at virtual address %08lx\n", address); 178 printk(" at virtual address %08lx\n", address);
129 printk(KERN_ALERT "pc = %08lx\n", regs->pc); 179 printk(KERN_ALERT "pc = %08lx\n", regs->pc);
130 asm volatile("mov.l %1, %0" 180 page = (unsigned long)get_TTB();
131 : "=r" (page)
132 : "m" (__m(MMU_TTB)));
133 if (page) { 181 if (page) {
134 page = ((unsigned long *) page)[address >> 22]; 182 page = ((unsigned long *) page)[address >> PGDIR_SHIFT];
135 printk(KERN_ALERT "*pde = %08lx\n", page); 183 printk(KERN_ALERT "*pde = %08lx\n", page);
136 if (page & _PAGE_PRESENT) { 184 if (page & _PAGE_PRESENT) {
137 page &= PAGE_MASK; 185 page &= PAGE_MASK;
@@ -166,98 +214,13 @@ do_sigbus:
166 * Send a sigbus, regardless of whether we were in kernel 214 * Send a sigbus, regardless of whether we were in kernel
167 * or user mode. 215 * or user mode.
168 */ 216 */
169 tsk->thread.address = address; 217 info.si_signo = SIGBUS;
170 tsk->thread.error_code = writeaccess; 218 info.si_errno = 0;
171 tsk->thread.trap_no = 14; 219 info.si_code = BUS_ADRERR;
172 force_sig(SIGBUS, tsk); 220 info.si_addr = (void *)address;
221 force_sig_info(SIGBUS, &info, tsk);
173 222
174 /* Kernel mode? Handle exceptions or die */ 223 /* Kernel mode? Handle exceptions or die */
175 if (!user_mode(regs)) 224 if (!user_mode(regs))
176 goto no_context; 225 goto no_context;
177} 226}
178
179#ifdef CONFIG_SH_STORE_QUEUES
180/*
181 * This is a special case for the SH-4 store queues, as pages for this
182 * space still need to be faulted in before it's possible to flush the
183 * store queue cache for writeout to the remapped region.
184 */
185#define P3_ADDR_MAX (P4SEG_STORE_QUE + 0x04000000)
186#else
187#define P3_ADDR_MAX P4SEG
188#endif
189
190/*
191 * Called with interrupts disabled.
192 */
193asmlinkage int __kprobes __do_page_fault(struct pt_regs *regs,
194 unsigned long writeaccess,
195 unsigned long address)
196{
197 pgd_t *pgd;
198 pud_t *pud;
199 pmd_t *pmd;
200 pte_t *pte;
201 pte_t entry;
202 struct mm_struct *mm = current->mm;
203 spinlock_t *ptl;
204 int ret = 1;
205
206#ifdef CONFIG_SH_KGDB
207 if (kgdb_nofault && kgdb_bus_err_hook)
208 kgdb_bus_err_hook();
209#endif
210
211 /*
212 * We don't take page faults for P1, P2, and parts of P4, these
213 * are always mapped, whether it be due to legacy behaviour in
214 * 29-bit mode, or due to PMB configuration in 32-bit mode.
215 */
216 if (address >= P3SEG && address < P3_ADDR_MAX) {
217 pgd = pgd_offset_k(address);
218 mm = NULL;
219 } else {
220 if (unlikely(address >= TASK_SIZE || !mm))
221 return 1;
222
223 pgd = pgd_offset(mm, address);
224 }
225
226 pud = pud_offset(pgd, address);
227 if (pud_none_or_clear_bad(pud))
228 return 1;
229 pmd = pmd_offset(pud, address);
230 if (pmd_none_or_clear_bad(pmd))
231 return 1;
232
233 if (mm)
234 pte = pte_offset_map_lock(mm, pmd, address, &ptl);
235 else
236 pte = pte_offset_kernel(pmd, address);
237
238 entry = *pte;
239 if (unlikely(pte_none(entry) || pte_not_present(entry)))
240 goto unlock;
241 if (unlikely(writeaccess && !pte_write(entry)))
242 goto unlock;
243
244 if (writeaccess)
245 entry = pte_mkdirty(entry);
246 entry = pte_mkyoung(entry);
247
248#ifdef CONFIG_CPU_SH4
249 /*
250 * ITLB is not affected by "ldtlb" instruction.
251 * So, we need to flush the entry by ourselves.
252 */
253 __flush_tlb_page(get_asid(), address & PAGE_MASK);
254#endif
255
256 set_pte(pte, entry);
257 update_mmu_cache(NULL, address, entry);
258 ret = 0;
259unlock:
260 if (mm)
261 pte_unmap_unlock(pte, ptl);
262 return ret;
263}
diff --git a/arch/sh/mm/hugetlbpage.c b/arch/sh/mm/hugetlbpage.c
index 329059d6b54a..cf2c2ee35a37 100644
--- a/arch/sh/mm/hugetlbpage.c
+++ b/arch/sh/mm/hugetlbpage.c
@@ -63,6 +63,11 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
63 return pte; 63 return pte;
64} 64}
65 65
66int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
67{
68 return 0;
69}
70
66struct page *follow_huge_addr(struct mm_struct *mm, 71struct page *follow_huge_addr(struct mm_struct *mm,
67 unsigned long address, int write) 72 unsigned long address, int write)
68{ 73{
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index 7154d1ce9785..59f4cc18235b 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -84,30 +84,22 @@ static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot)
84 pmd_t *pmd; 84 pmd_t *pmd;
85 pte_t *pte; 85 pte_t *pte;
86 86
87 pgd = swapper_pg_dir + pgd_index(addr); 87 pgd = pgd_offset_k(addr);
88 if (pgd_none(*pgd)) { 88 if (pgd_none(*pgd)) {
89 pgd_ERROR(*pgd); 89 pgd_ERROR(*pgd);
90 return; 90 return;
91 } 91 }
92 92
93 pud = pud_offset(pgd, addr); 93 pud = pud_alloc(NULL, pgd, addr);
94 if (pud_none(*pud)) { 94 if (unlikely(!pud)) {
95 pmd = (pmd_t *)get_zeroed_page(GFP_ATOMIC); 95 pud_ERROR(*pud);
96 set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE | _PAGE_USER)); 96 return;
97 if (pmd != pmd_offset(pud, 0)) {
98 pud_ERROR(*pud);
99 return;
100 }
101 } 97 }
102 98
103 pmd = pmd_offset(pud, addr); 99 pmd = pmd_alloc(NULL, pud, addr);
104 if (pmd_none(*pmd)) { 100 if (unlikely(!pmd)) {
105 pte = (pte_t *)get_zeroed_page(GFP_ATOMIC); 101 pmd_ERROR(*pmd);
106 set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE | _PAGE_USER)); 102 return;
107 if (pte != pte_offset_kernel(pmd, 0)) {
108 pmd_ERROR(*pmd);
109 return;
110 }
111 } 103 }
112 104
113 pte = pte_offset_kernel(pmd, addr); 105 pte = pte_offset_kernel(pmd, addr);
@@ -155,9 +147,6 @@ extern char __init_begin, __init_end;
155 147
156/* 148/*
157 * paging_init() sets up the page tables 149 * paging_init() sets up the page tables
158 *
159 * This routines also unmaps the page at virtual kernel address 0, so
160 * that we can trap those pesky NULL-reference errors in the kernel.
161 */ 150 */
162void __init paging_init(void) 151void __init paging_init(void)
163{ 152{
@@ -180,14 +169,11 @@ void __init paging_init(void)
180 */ 169 */
181 { 170 {
182 unsigned long max_dma, low, start_pfn; 171 unsigned long max_dma, low, start_pfn;
183 pgd_t *pg_dir;
184 int i;
185
186 /* We don't need kernel mapping as hardware support that. */
187 pg_dir = swapper_pg_dir;
188 172
189 for (i = 0; i < PTRS_PER_PGD; i++) 173 /* We don't need to map the kernel through the TLB, as
190 pgd_val(pg_dir[i]) = 0; 174 * it is permanatly mapped using P1. So clear the
175 * entire pgd. */
176 memset(swapper_pg_dir, 0, sizeof(swapper_pg_dir));
191 177
192 /* Turn on the MMU */ 178 /* Turn on the MMU */
193 enable_mmu(); 179 enable_mmu();
@@ -206,6 +192,10 @@ void __init paging_init(void)
206 } 192 }
207 } 193 }
208 194
195 /* Set an initial value for the MMU.TTB so we don't have to
196 * check for a null value. */
197 set_TTB(swapper_pg_dir);
198
209#elif defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4) 199#elif defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4)
210 /* 200 /*
211 * If we don't have CONFIG_MMU set and the processor in question 201 * If we don't have CONFIG_MMU set and the processor in question
@@ -227,7 +217,6 @@ static struct kcore_list kcore_mem, kcore_vmalloc;
227 217
228void __init mem_init(void) 218void __init mem_init(void)
229{ 219{
230 extern unsigned long empty_zero_page[1024];
231 int codesize, reservedpages, datasize, initsize; 220 int codesize, reservedpages, datasize, initsize;
232 int tmp; 221 int tmp;
233 extern unsigned long memory_start; 222 extern unsigned long memory_start;
diff --git a/arch/sh/mm/ioremap.c b/arch/sh/mm/ioremap.c
index a9fe80cfc233..11d54c149821 100644
--- a/arch/sh/mm/ioremap.c
+++ b/arch/sh/mm/ioremap.c
@@ -28,9 +28,7 @@ static inline void remap_area_pte(pte_t * pte, unsigned long address,
28{ 28{
29 unsigned long end; 29 unsigned long end;
30 unsigned long pfn; 30 unsigned long pfn;
31 pgprot_t pgprot = __pgprot(_PAGE_PRESENT | _PAGE_RW | 31 pgprot_t pgprot = __pgprot(pgprot_val(PAGE_KERNEL_NOCACHE) | flags);
32 _PAGE_DIRTY | _PAGE_ACCESSED |
33 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD | flags);
34 32
35 address &= ~PMD_MASK; 33 address &= ~PMD_MASK;
36 end = address + size; 34 end = address + size;
diff --git a/arch/sh/mm/pg-dma.c b/arch/sh/mm/pg-dma.c
index 1406d2e348ca..bb23679369d6 100644
--- a/arch/sh/mm/pg-dma.c
+++ b/arch/sh/mm/pg-dma.c
@@ -39,8 +39,6 @@ static void copy_page_dma(void *to, void *from)
39 39
40static void clear_page_dma(void *to) 40static void clear_page_dma(void *to)
41{ 41{
42 extern unsigned long empty_zero_page[1024];
43
44 /* 42 /*
45 * We get invoked quite early on, if the DMAC hasn't been initialized 43 * We get invoked quite early on, if the DMAC hasn't been initialized
46 * yet, fall back on the slow manual implementation. 44 * yet, fall back on the slow manual implementation.
diff --git a/arch/sh/mm/pg-sh4.c b/arch/sh/mm/pg-sh4.c
index 07371ed7a313..3f98d2a4f936 100644
--- a/arch/sh/mm/pg-sh4.c
+++ b/arch/sh/mm/pg-sh4.c
@@ -6,22 +6,12 @@
6 * 6 *
7 * Released under the terms of the GNU GPL v2.0. 7 * Released under the terms of the GNU GPL v2.0.
8 */ 8 */
9#include <linux/init.h>
10#include <linux/mman.h>
11#include <linux/mm.h> 9#include <linux/mm.h>
12#include <linux/threads.h> 10#include <linux/mutex.h>
13#include <asm/addrspace.h>
14#include <asm/page.h>
15#include <asm/pgtable.h>
16#include <asm/processor.h>
17#include <asm/cache.h>
18#include <asm/io.h>
19#include <asm/uaccess.h>
20#include <asm/pgalloc.h>
21#include <asm/mmu_context.h> 11#include <asm/mmu_context.h>
22#include <asm/cacheflush.h> 12#include <asm/cacheflush.h>
23 13
24extern struct semaphore p3map_sem[]; 14extern struct mutex p3map_mutex[];
25 15
26#define CACHE_ALIAS (cpu_data->dcache.alias_mask) 16#define CACHE_ALIAS (cpu_data->dcache.alias_mask)
27 17
@@ -37,10 +27,6 @@ void clear_user_page(void *to, unsigned long address, struct page *page)
37 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) 27 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0)
38 clear_page(to); 28 clear_page(to);
39 else { 29 else {
40 pgprot_t pgprot = __pgprot(_PAGE_PRESENT |
41 _PAGE_RW | _PAGE_CACHABLE |
42 _PAGE_DIRTY | _PAGE_ACCESSED |
43 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD);
44 unsigned long phys_addr = PHYSADDR(to); 30 unsigned long phys_addr = PHYSADDR(to);
45 unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS); 31 unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS);
46 pgd_t *pgd = pgd_offset_k(p3_addr); 32 pgd_t *pgd = pgd_offset_k(p3_addr);
@@ -50,8 +36,8 @@ void clear_user_page(void *to, unsigned long address, struct page *page)
50 pte_t entry; 36 pte_t entry;
51 unsigned long flags; 37 unsigned long flags;
52 38
53 entry = pfn_pte(phys_addr >> PAGE_SHIFT, pgprot); 39 entry = pfn_pte(phys_addr >> PAGE_SHIFT, PAGE_KERNEL);
54 down(&p3map_sem[(address & CACHE_ALIAS)>>12]); 40 mutex_lock(&p3map_mutex[(address & CACHE_ALIAS)>>12]);
55 set_pte(pte, entry); 41 set_pte(pte, entry);
56 local_irq_save(flags); 42 local_irq_save(flags);
57 __flush_tlb_page(get_asid(), p3_addr); 43 __flush_tlb_page(get_asid(), p3_addr);
@@ -59,7 +45,7 @@ void clear_user_page(void *to, unsigned long address, struct page *page)
59 update_mmu_cache(NULL, p3_addr, entry); 45 update_mmu_cache(NULL, p3_addr, entry);
60 __clear_user_page((void *)p3_addr, to); 46 __clear_user_page((void *)p3_addr, to);
61 pte_clear(&init_mm, p3_addr, pte); 47 pte_clear(&init_mm, p3_addr, pte);
62 up(&p3map_sem[(address & CACHE_ALIAS)>>12]); 48 mutex_unlock(&p3map_mutex[(address & CACHE_ALIAS)>>12]);
63 } 49 }
64} 50}
65 51
@@ -77,10 +63,6 @@ void copy_user_page(void *to, void *from, unsigned long address,
77 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) 63 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0)
78 copy_page(to, from); 64 copy_page(to, from);
79 else { 65 else {
80 pgprot_t pgprot = __pgprot(_PAGE_PRESENT |
81 _PAGE_RW | _PAGE_CACHABLE |
82 _PAGE_DIRTY | _PAGE_ACCESSED |
83 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD);
84 unsigned long phys_addr = PHYSADDR(to); 66 unsigned long phys_addr = PHYSADDR(to);
85 unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS); 67 unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS);
86 pgd_t *pgd = pgd_offset_k(p3_addr); 68 pgd_t *pgd = pgd_offset_k(p3_addr);
@@ -90,8 +72,8 @@ void copy_user_page(void *to, void *from, unsigned long address,
90 pte_t entry; 72 pte_t entry;
91 unsigned long flags; 73 unsigned long flags;
92 74
93 entry = pfn_pte(phys_addr >> PAGE_SHIFT, pgprot); 75 entry = pfn_pte(phys_addr >> PAGE_SHIFT, PAGE_KERNEL);
94 down(&p3map_sem[(address & CACHE_ALIAS)>>12]); 76 mutex_lock(&p3map_mutex[(address & CACHE_ALIAS)>>12]);
95 set_pte(pte, entry); 77 set_pte(pte, entry);
96 local_irq_save(flags); 78 local_irq_save(flags);
97 __flush_tlb_page(get_asid(), p3_addr); 79 __flush_tlb_page(get_asid(), p3_addr);
@@ -99,7 +81,7 @@ void copy_user_page(void *to, void *from, unsigned long address,
99 update_mmu_cache(NULL, p3_addr, entry); 81 update_mmu_cache(NULL, p3_addr, entry);
100 __copy_user_page((void *)p3_addr, from, to); 82 __copy_user_page((void *)p3_addr, from, to);
101 pte_clear(&init_mm, p3_addr, pte); 83 pte_clear(&init_mm, p3_addr, pte);
102 up(&p3map_sem[(address & CACHE_ALIAS)>>12]); 84 mutex_unlock(&p3map_mutex[(address & CACHE_ALIAS)>>12]);
103 } 85 }
104} 86}
105 87
@@ -122,4 +104,3 @@ inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t
122 } 104 }
123 return pte; 105 return pte;
124} 106}
125
diff --git a/arch/sh/mm/pmb.c b/arch/sh/mm/pmb.c
index 92e745341e4d..b60ad83a7635 100644
--- a/arch/sh/mm/pmb.c
+++ b/arch/sh/mm/pmb.c
@@ -30,7 +30,7 @@
30 30
31#define NR_PMB_ENTRIES 16 31#define NR_PMB_ENTRIES 16
32 32
33static kmem_cache_t *pmb_cache; 33static struct kmem_cache *pmb_cache;
34static unsigned long pmb_map; 34static unsigned long pmb_map;
35 35
36static struct pmb_entry pmb_init_map[] = { 36static struct pmb_entry pmb_init_map[] = {
@@ -283,7 +283,7 @@ void pmb_unmap(unsigned long addr)
283 } while (pmbe); 283 } while (pmbe);
284} 284}
285 285
286static void pmb_cache_ctor(void *pmb, kmem_cache_t *cachep, unsigned long flags) 286static void pmb_cache_ctor(void *pmb, struct kmem_cache *cachep, unsigned long flags)
287{ 287{
288 struct pmb_entry *pmbe = pmb; 288 struct pmb_entry *pmbe = pmb;
289 289
@@ -297,7 +297,7 @@ static void pmb_cache_ctor(void *pmb, kmem_cache_t *cachep, unsigned long flags)
297 spin_unlock_irq(&pmb_list_lock); 297 spin_unlock_irq(&pmb_list_lock);
298} 298}
299 299
300static void pmb_cache_dtor(void *pmb, kmem_cache_t *cachep, unsigned long flags) 300static void pmb_cache_dtor(void *pmb, struct kmem_cache *cachep, unsigned long flags)
301{ 301{
302 spin_lock_irq(&pmb_list_lock); 302 spin_lock_irq(&pmb_list_lock);
303 pmb_list_del(pmb); 303 pmb_list_del(pmb);
diff --git a/arch/sh/tools/mach-types b/arch/sh/tools/mach-types
index ac57638977ee..0571755e9a84 100644
--- a/arch/sh/tools/mach-types
+++ b/arch/sh/tools/mach-types
@@ -30,3 +30,5 @@ R7780MP SH_R7780MP
30TITAN SH_TITAN 30TITAN SH_TITAN
31SHMIN SH_SHMIN 31SHMIN SH_SHMIN
327710VOIPGW SH_7710VOIPGW 327710VOIPGW SH_7710VOIPGW
337206SE SH_7206_SOLUTION_ENGINE
347619SE SH_7619_SOLUTION_ENGINE
diff --git a/arch/sh64/kernel/setup.c b/arch/sh64/kernel/setup.c
index ffb310e33cef..b9e7d54d7b85 100644
--- a/arch/sh64/kernel/setup.c
+++ b/arch/sh64/kernel/setup.c
@@ -243,9 +243,7 @@ void __init setup_arch(char **cmdline_p)
243 if (INITRD_START + INITRD_SIZE <= (PFN_PHYS(last_pfn))) { 243 if (INITRD_START + INITRD_SIZE <= (PFN_PHYS(last_pfn))) {
244 reserve_bootmem_node(NODE_DATA(0), INITRD_START + __MEMORY_START, INITRD_SIZE); 244 reserve_bootmem_node(NODE_DATA(0), INITRD_START + __MEMORY_START, INITRD_SIZE);
245 245
246 initrd_start = 246 initrd_start = (long) INITRD_START + PAGE_OFFSET + __MEMORY_START;
247 (long) INITRD_START ? INITRD_START + PAGE_OFFSET + __MEMORY_START : 0;
248
249 initrd_end = initrd_start + INITRD_SIZE; 247 initrd_end = initrd_start + INITRD_SIZE;
250 } else { 248 } else {
251 printk("initrd extends beyond end of memory " 249 printk("initrd extends beyond end of memory "
diff --git a/arch/sh64/kernel/signal.c b/arch/sh64/kernel/signal.c
index 9e2ffc45c0e0..1666d3efb52e 100644
--- a/arch/sh64/kernel/signal.c
+++ b/arch/sh64/kernel/signal.c
@@ -22,7 +22,7 @@
22#include <linux/errno.h> 22#include <linux/errno.h>
23#include <linux/wait.h> 23#include <linux/wait.h>
24#include <linux/personality.h> 24#include <linux/personality.h>
25#include <linux/suspend.h> 25#include <linux/freezer.h>
26#include <linux/ptrace.h> 26#include <linux/ptrace.h>
27#include <linux/unistd.h> 27#include <linux/unistd.h>
28#include <linux/stddef.h> 28#include <linux/stddef.h>
diff --git a/arch/sh64/mm/fault.c b/arch/sh64/mm/fault.c
index 8e2f6c28b739..4f72ab33bb2b 100644
--- a/arch/sh64/mm/fault.c
+++ b/arch/sh64/mm/fault.c
@@ -154,7 +154,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
154 * If we're in an interrupt or have no user 154 * If we're in an interrupt or have no user
155 * context, we must not take the fault.. 155 * context, we must not take the fault..
156 */ 156 */
157 if (in_interrupt() || !mm) 157 if (in_atomic() || !mm)
158 goto no_context; 158 goto no_context;
159 159
160 /* TLB misses upon some cache flushes get done under cli() */ 160 /* TLB misses upon some cache flushes get done under cli() */
diff --git a/arch/sh64/mm/hugetlbpage.c b/arch/sh64/mm/hugetlbpage.c
index 187cf01750b8..4b455f611146 100644
--- a/arch/sh64/mm/hugetlbpage.c
+++ b/arch/sh64/mm/hugetlbpage.c
@@ -53,6 +53,11 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
53 return pte; 53 return pte;
54} 54}
55 55
56int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
57{
58 return 0;
59}
60
56void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, 61void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
57 pte_t *ptep, pte_t entry) 62 pte_t *ptep, pte_t entry)
58{ 63{
diff --git a/arch/sparc/mm/highmem.c b/arch/sparc/mm/highmem.c
index 4d8ed9c65182..01fc6c254292 100644
--- a/arch/sparc/mm/highmem.c
+++ b/arch/sparc/mm/highmem.c
@@ -35,7 +35,7 @@ void *kmap_atomic(struct page *page, enum km_type type)
35 unsigned long vaddr; 35 unsigned long vaddr;
36 36
37 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ 37 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
38 inc_preempt_count(); 38 pagefault_disable();
39 if (!PageHighMem(page)) 39 if (!PageHighMem(page))
40 return page_address(page); 40 return page_address(page);
41 41
@@ -70,8 +70,7 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
70 unsigned long idx = type + KM_TYPE_NR*smp_processor_id(); 70 unsigned long idx = type + KM_TYPE_NR*smp_processor_id();
71 71
72 if (vaddr < FIXADDR_START) { // FIXME 72 if (vaddr < FIXADDR_START) { // FIXME
73 dec_preempt_count(); 73 pagefault_enable();
74 preempt_check_resched();
75 return; 74 return;
76 } 75 }
77 76
@@ -97,8 +96,7 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
97#endif 96#endif
98#endif 97#endif
99 98
100 dec_preempt_count(); 99 pagefault_enable();
101 preempt_check_resched();
102} 100}
103 101
104/* We may be fed a pagetable here by ptep_to_xxx and others. */ 102/* We may be fed a pagetable here by ptep_to_xxx and others. */
diff --git a/arch/sparc64/kernel/binfmt_elf32.c b/arch/sparc64/kernel/binfmt_elf32.c
index a98f3ae175a3..9ad84ff10a17 100644
--- a/arch/sparc64/kernel/binfmt_elf32.c
+++ b/arch/sparc64/kernel/binfmt_elf32.c
@@ -141,7 +141,6 @@ cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value)
141 value->tv_sec = jiffies / HZ; 141 value->tv_sec = jiffies / HZ;
142} 142}
143 143
144#define elf_addr_t u32
145#undef start_thread 144#undef start_thread
146#define start_thread start_thread32 145#define start_thread start_thread32
147#define init_elf_binfmt init_elf32_binfmt 146#define init_elf_binfmt init_elf32_binfmt
diff --git a/arch/sparc64/mm/hugetlbpage.c b/arch/sparc64/mm/hugetlbpage.c
index 53b9b1f528e5..33fd0b265e70 100644
--- a/arch/sparc64/mm/hugetlbpage.c
+++ b/arch/sparc64/mm/hugetlbpage.c
@@ -235,6 +235,11 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
235 return pte; 235 return pte;
236} 236}
237 237
238int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
239{
240 return 0;
241}
242
238void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, 243void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
239 pte_t *ptep, pte_t entry) 244 pte_t *ptep, pte_t entry)
240{ 245{
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index 09cb7fccc03a..a8e8802eed4d 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -176,9 +176,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
176 176
177int bigkernel = 0; 177int bigkernel = 0;
178 178
179kmem_cache_t *pgtable_cache __read_mostly; 179struct kmem_cache *pgtable_cache __read_mostly;
180 180
181static void zero_ctor(void *addr, kmem_cache_t *cache, unsigned long flags) 181static void zero_ctor(void *addr, struct kmem_cache *cache, unsigned long flags)
182{ 182{
183 clear_page(addr); 183 clear_page(addr);
184} 184}
diff --git a/arch/sparc64/mm/tsb.c b/arch/sparc64/mm/tsb.c
index beaa02810f0e..236d02f41a01 100644
--- a/arch/sparc64/mm/tsb.c
+++ b/arch/sparc64/mm/tsb.c
@@ -239,7 +239,7 @@ static void setup_tsb_params(struct mm_struct *mm, unsigned long tsb_idx, unsign
239 } 239 }
240} 240}
241 241
242static kmem_cache_t *tsb_caches[8] __read_mostly; 242static struct kmem_cache *tsb_caches[8] __read_mostly;
243 243
244static const char *tsb_cache_names[8] = { 244static const char *tsb_cache_names[8] = {
245 "tsb_8KB", 245 "tsb_8KB",
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index 3576b3cc505e..7d4190e55654 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -638,7 +638,7 @@ int chan_out_fd(struct list_head *chans)
638 return -1; 638 return -1;
639} 639}
640 640
641void chan_interrupt(struct list_head *chans, struct work_struct *task, 641void chan_interrupt(struct list_head *chans, struct delayed_work *task,
642 struct tty_struct *tty, int irq) 642 struct tty_struct *tty, int irq)
643{ 643{
644 struct list_head *ele, *next; 644 struct list_head *ele, *next;
diff --git a/arch/um/drivers/daemon_kern.c b/arch/um/drivers/daemon_kern.c
index 824386974f88..9c2e7a758f21 100644
--- a/arch/um/drivers/daemon_kern.c
+++ b/arch/um/drivers/daemon_kern.c
@@ -98,4 +98,4 @@ static int register_daemon(void)
98 return 0; 98 return 0;
99} 99}
100 100
101__initcall(register_daemon); 101late_initcall(register_daemon);
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 426633e5d6e3..aa3090d05a8f 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -31,9 +31,9 @@ static irqreturn_t line_interrupt(int irq, void *data)
31 return IRQ_HANDLED; 31 return IRQ_HANDLED;
32} 32}
33 33
34static void line_timer_cb(void *arg) 34static void line_timer_cb(struct work_struct *work)
35{ 35{
36 struct line *line = arg; 36 struct line *line = container_of(work, struct line, task.work);
37 37
38 if(!line->throttled) 38 if(!line->throttled)
39 chan_interrupt(&line->chan_list, &line->task, line->tty, 39 chan_interrupt(&line->chan_list, &line->task, line->tty,
@@ -443,7 +443,7 @@ int line_open(struct line *lines, struct tty_struct *tty)
443 * is registered. 443 * is registered.
444 */ 444 */
445 enable_chan(line); 445 enable_chan(line);
446 INIT_WORK(&line->task, line_timer_cb, line); 446 INIT_DELAYED_WORK(&line->task, line_timer_cb);
447 447
448 if(!line->sigio){ 448 if(!line->sigio){
449 chan_enable_winch(&line->chan_list, tty); 449 chan_enable_winch(&line->chan_list, tty);
diff --git a/arch/um/drivers/mcast_kern.c b/arch/um/drivers/mcast_kern.c
index c090fbd464e7..52ccb7b53cd2 100644
--- a/arch/um/drivers/mcast_kern.c
+++ b/arch/um/drivers/mcast_kern.c
@@ -127,4 +127,4 @@ static int register_mcast(void)
127 return 0; 127 return 0;
128} 128}
129 129
130__initcall(register_mcast); 130late_initcall(register_mcast);
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 7b172160fe04..96f0189327af 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -56,7 +56,7 @@ static struct notifier_block reboot_notifier = {
56 56
57static LIST_HEAD(mc_requests); 57static LIST_HEAD(mc_requests);
58 58
59static void mc_work_proc(void *unused) 59static void mc_work_proc(struct work_struct *unused)
60{ 60{
61 struct mconsole_entry *req; 61 struct mconsole_entry *req;
62 unsigned long flags; 62 unsigned long flags;
@@ -72,7 +72,7 @@ static void mc_work_proc(void *unused)
72 } 72 }
73} 73}
74 74
75static DECLARE_WORK(mconsole_work, mc_work_proc, NULL); 75static DECLARE_WORK(mconsole_work, mc_work_proc);
76 76
77static irqreturn_t mconsole_interrupt(int irq, void *dev_id) 77static irqreturn_t mconsole_interrupt(int irq, void *dev_id)
78{ 78{
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index ec9eb8bd9432..286bc0b3207f 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -99,6 +99,7 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id)
99 * same device, since it tests for (dev->flags & IFF_UP). So 99 * same device, since it tests for (dev->flags & IFF_UP). So
100 * there's no harm in delaying the device shutdown. */ 100 * there's no harm in delaying the device shutdown. */
101 schedule_work(&close_work); 101 schedule_work(&close_work);
102#error this is not permitted - close_work will go out of scope
102 goto out; 103 goto out;
103 } 104 }
104 reactivate_fd(lp->fd, UM_ETH_IRQ); 105 reactivate_fd(lp->fd, UM_ETH_IRQ);
diff --git a/arch/um/drivers/pcap_kern.c b/arch/um/drivers/pcap_kern.c
index 6e1ef8558283..e67362acf0e7 100644
--- a/arch/um/drivers/pcap_kern.c
+++ b/arch/um/drivers/pcap_kern.c
@@ -109,4 +109,4 @@ static int register_pcap(void)
109 return 0; 109 return 0;
110} 110}
111 111
112__initcall(register_pcap); 112late_initcall(register_pcap);
diff --git a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c
index ce9f3733f73e..6dfe632f1c14 100644
--- a/arch/um/drivers/port_kern.c
+++ b/arch/um/drivers/port_kern.c
@@ -132,7 +132,7 @@ static int port_accept(struct port_list *port)
132DECLARE_MUTEX(ports_sem); 132DECLARE_MUTEX(ports_sem);
133struct list_head ports = LIST_HEAD_INIT(ports); 133struct list_head ports = LIST_HEAD_INIT(ports);
134 134
135void port_work_proc(void *unused) 135void port_work_proc(struct work_struct *unused)
136{ 136{
137 struct port_list *port; 137 struct port_list *port;
138 struct list_head *ele; 138 struct list_head *ele;
@@ -150,7 +150,7 @@ void port_work_proc(void *unused)
150 local_irq_restore(flags); 150 local_irq_restore(flags);
151} 151}
152 152
153DECLARE_WORK(port_work, port_work_proc, NULL); 153DECLARE_WORK(port_work, port_work_proc);
154 154
155static irqreturn_t port_interrupt(int irq, void *data) 155static irqreturn_t port_interrupt(int irq, void *data)
156{ 156{
diff --git a/arch/um/drivers/slip_kern.c b/arch/um/drivers/slip_kern.c
index 788da5439a2d..25634bd1f585 100644
--- a/arch/um/drivers/slip_kern.c
+++ b/arch/um/drivers/slip_kern.c
@@ -95,4 +95,4 @@ static int register_slip(void)
95 return 0; 95 return 0;
96} 96}
97 97
98__initcall(register_slip); 98late_initcall(register_slip);
diff --git a/arch/um/drivers/slirp_kern.c b/arch/um/drivers/slirp_kern.c
index ae322e1c8a87..b3ed8fb874ab 100644
--- a/arch/um/drivers/slirp_kern.c
+++ b/arch/um/drivers/slirp_kern.c
@@ -119,4 +119,4 @@ static int register_slirp(void)
119 return 0; 119 return 0;
120} 120}
121 121
122__initcall(register_slirp); 122late_initcall(register_slirp);
diff --git a/arch/um/include/chan_kern.h b/arch/um/include/chan_kern.h
index 572d286ed2c6..9003a343e148 100644
--- a/arch/um/include/chan_kern.h
+++ b/arch/um/include/chan_kern.h
@@ -27,7 +27,7 @@ struct chan {
27 void *data; 27 void *data;
28}; 28};
29 29
30extern void chan_interrupt(struct list_head *chans, struct work_struct *task, 30extern void chan_interrupt(struct list_head *chans, struct delayed_work *task,
31 struct tty_struct *tty, int irq); 31 struct tty_struct *tty, int irq);
32extern int parse_chan_pair(char *str, struct line *line, int device, 32extern int parse_chan_pair(char *str, struct line *line, int device,
33 const struct chan_opts *opts); 33 const struct chan_opts *opts);
diff --git a/arch/um/include/line.h b/arch/um/include/line.h
index 7be24811bb30..214ee76c40df 100644
--- a/arch/um/include/line.h
+++ b/arch/um/include/line.h
@@ -51,7 +51,7 @@ struct line {
51 char *tail; 51 char *tail;
52 52
53 int sigio; 53 int sigio;
54 struct work_struct task; 54 struct delayed_work task;
55 const struct line_driver *driver; 55 const struct line_driver *driver;
56 int have_irq; 56 int have_irq;
57}; 57};
diff --git a/arch/um/include/sysdep-i386/ptrace.h b/arch/um/include/sysdep-i386/ptrace.h
index 6670cc992ecb..52b398bcafcf 100644
--- a/arch/um/include/sysdep-i386/ptrace.h
+++ b/arch/um/include/sysdep-i386/ptrace.h
@@ -75,7 +75,7 @@ union uml_pt_regs {
75#endif 75#endif
76#ifdef UML_CONFIG_MODE_SKAS 76#ifdef UML_CONFIG_MODE_SKAS
77 struct skas_regs { 77 struct skas_regs {
78 unsigned long regs[HOST_FRAME_SIZE]; 78 unsigned long regs[MAX_REG_NR];
79 unsigned long fp[HOST_FP_SIZE]; 79 unsigned long fp[HOST_FP_SIZE];
80 unsigned long xfp[HOST_XFP_SIZE]; 80 unsigned long xfp[HOST_XFP_SIZE];
81 struct faultinfo faultinfo; 81 struct faultinfo faultinfo;
diff --git a/arch/um/include/sysdep-i386/stub.h b/arch/um/include/sysdep-i386/stub.h
index b492b12b4a10..4fffae75ba53 100644
--- a/arch/um/include/sysdep-i386/stub.h
+++ b/arch/um/include/sysdep-i386/stub.h
@@ -9,6 +9,7 @@
9#include <sys/mman.h> 9#include <sys/mman.h>
10#include <asm/ptrace.h> 10#include <asm/ptrace.h>
11#include <asm/unistd.h> 11#include <asm/unistd.h>
12#include <asm/page.h>
12#include "stub-data.h" 13#include "stub-data.h"
13#include "kern_constants.h" 14#include "kern_constants.h"
14#include "uml-config.h" 15#include "uml-config.h"
diff --git a/arch/um/include/sysdep-x86_64/ptrace.h b/arch/um/include/sysdep-x86_64/ptrace.h
index 617bb9efc934..66cb400c2c92 100644
--- a/arch/um/include/sysdep-x86_64/ptrace.h
+++ b/arch/um/include/sysdep-x86_64/ptrace.h
@@ -108,7 +108,7 @@ union uml_pt_regs {
108 * file size, while i386 uses FRAME_SIZE. Therefore, we need 108 * file size, while i386 uses FRAME_SIZE. Therefore, we need
109 * to use UM_FRAME_SIZE here instead of HOST_FRAME_SIZE. 109 * to use UM_FRAME_SIZE here instead of HOST_FRAME_SIZE.
110 */ 110 */
111 unsigned long regs[UM_FRAME_SIZE]; 111 unsigned long regs[MAX_REG_NR];
112 unsigned long fp[HOST_FP_SIZE]; 112 unsigned long fp[HOST_FP_SIZE];
113 struct faultinfo faultinfo; 113 struct faultinfo faultinfo;
114 long syscall; 114 long syscall;
diff --git a/arch/um/os-Linux/drivers/ethertap_kern.c b/arch/um/os-Linux/drivers/ethertap_kern.c
index 16385e2ada85..70541821775f 100644
--- a/arch/um/os-Linux/drivers/ethertap_kern.c
+++ b/arch/um/os-Linux/drivers/ethertap_kern.c
@@ -105,4 +105,4 @@ static int register_ethertap(void)
105 return 0; 105 return 0;
106} 106}
107 107
108__initcall(register_ethertap); 108late_initcall(register_ethertap);
diff --git a/arch/um/os-Linux/drivers/tuntap_kern.c b/arch/um/os-Linux/drivers/tuntap_kern.c
index 0edbac63c527..76570a2c25c3 100644
--- a/arch/um/os-Linux/drivers/tuntap_kern.c
+++ b/arch/um/os-Linux/drivers/tuntap_kern.c
@@ -90,4 +90,4 @@ static int register_tuntap(void)
90 return 0; 90 return 0;
91} 91}
92 92
93__initcall(register_tuntap); 93late_initcall(register_tuntap);
diff --git a/arch/um/sys-i386/ldt.c b/arch/um/sys-i386/ldt.c
index e299ee5a753d..49057d8bc668 100644
--- a/arch/um/sys-i386/ldt.c
+++ b/arch/um/sys-i386/ldt.c
@@ -3,7 +3,6 @@
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include "linux/stddef.h"
7#include "linux/sched.h" 6#include "linux/sched.h"
8#include "linux/slab.h" 7#include "linux/slab.h"
9#include "linux/types.h" 8#include "linux/types.h"
diff --git a/arch/um/sys-i386/ptrace_user.c b/arch/um/sys-i386/ptrace_user.c
index 5f3cc6685820..01212c88fcc4 100644
--- a/arch/um/sys-i386/ptrace_user.c
+++ b/arch/um/sys-i386/ptrace_user.c
@@ -4,9 +4,9 @@
4 */ 4 */
5 5
6#include <stdio.h> 6#include <stdio.h>
7#include <stddef.h>
7#include <errno.h> 8#include <errno.h>
8#include <unistd.h> 9#include <unistd.h>
9#include <linux/stddef.h>
10#include "ptrace_user.h" 10#include "ptrace_user.h"
11/* Grr, asm/user.h includes asm/ptrace.h, so has to follow ptrace_user.h */ 11/* Grr, asm/user.h includes asm/ptrace.h, so has to follow ptrace_user.h */
12#include <asm/user.h> 12#include <asm/user.h>
diff --git a/arch/um/sys-i386/user-offsets.c b/arch/um/sys-i386/user-offsets.c
index 6f4ef2b7fa4a..447306b20aea 100644
--- a/arch/um/sys-i386/user-offsets.c
+++ b/arch/um/sys-i386/user-offsets.c
@@ -2,7 +2,7 @@
2#include <signal.h> 2#include <signal.h>
3#include <asm/ptrace.h> 3#include <asm/ptrace.h>
4#include <asm/user.h> 4#include <asm/user.h>
5#include <linux/stddef.h> 5#include <stddef.h>
6#include <sys/poll.h> 6#include <sys/poll.h>
7 7
8#define DEFINE(sym, val) \ 8#define DEFINE(sym, val) \
diff --git a/arch/x86_64/ia32/ia32_binfmt.c b/arch/x86_64/ia32/ia32_binfmt.c
index 82ef182de6ae..543ef4f405e9 100644
--- a/arch/x86_64/ia32/ia32_binfmt.c
+++ b/arch/x86_64/ia32/ia32_binfmt.c
@@ -305,8 +305,6 @@ MODULE_AUTHOR("Eric Youngdale, Andi Kleen");
305#undef MODULE_DESCRIPTION 305#undef MODULE_DESCRIPTION
306#undef MODULE_AUTHOR 306#undef MODULE_AUTHOR
307 307
308#define elf_addr_t __u32
309
310static void elf32_init(struct pt_regs *); 308static void elf32_init(struct pt_regs *);
311 309
312#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 310#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
@@ -351,7 +349,7 @@ int ia32_setup_arg_pages(struct linux_binprm *bprm, unsigned long stack_top,
351 bprm->loader += stack_base; 349 bprm->loader += stack_base;
352 bprm->exec += stack_base; 350 bprm->exec += stack_base;
353 351
354 mpnt = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 352 mpnt = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
355 if (!mpnt) 353 if (!mpnt)
356 return -ENOMEM; 354 return -ENOMEM;
357 355
diff --git a/arch/x86_64/ia32/syscall32.c b/arch/x86_64/ia32/syscall32.c
index 3a01329473ab..3e5ed20cba45 100644
--- a/arch/x86_64/ia32/syscall32.c
+++ b/arch/x86_64/ia32/syscall32.c
@@ -49,7 +49,7 @@ int syscall32_setup_pages(struct linux_binprm *bprm, int exstack)
49 struct mm_struct *mm = current->mm; 49 struct mm_struct *mm = current->mm;
50 int ret; 50 int ret;
51 51
52 vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 52 vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
53 if (!vma) 53 if (!vma)
54 return -ENOMEM; 54 return -ENOMEM;
55 55
diff --git a/arch/x86_64/kernel/crash.c b/arch/x86_64/kernel/crash.c
index 3525f884af82..95a7a2c13131 100644
--- a/arch/x86_64/kernel/crash.c
+++ b/arch/x86_64/kernel/crash.c
@@ -28,71 +28,6 @@
28/* This keeps a track of which one is crashing cpu. */ 28/* This keeps a track of which one is crashing cpu. */
29static int crashing_cpu; 29static int crashing_cpu;
30 30
31static u32 *append_elf_note(u32 *buf, char *name, unsigned type,
32 void *data, size_t data_len)
33{
34 struct elf_note note;
35
36 note.n_namesz = strlen(name) + 1;
37 note.n_descsz = data_len;
38 note.n_type = type;
39 memcpy(buf, &note, sizeof(note));
40 buf += (sizeof(note) +3)/4;
41 memcpy(buf, name, note.n_namesz);
42 buf += (note.n_namesz + 3)/4;
43 memcpy(buf, data, note.n_descsz);
44 buf += (note.n_descsz + 3)/4;
45
46 return buf;
47}
48
49static void final_note(u32 *buf)
50{
51 struct elf_note note;
52
53 note.n_namesz = 0;
54 note.n_descsz = 0;
55 note.n_type = 0;
56 memcpy(buf, &note, sizeof(note));
57}
58
59static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
60{
61 struct elf_prstatus prstatus;
62 u32 *buf;
63
64 if ((cpu < 0) || (cpu >= NR_CPUS))
65 return;
66
67 /* Using ELF notes here is opportunistic.
68 * I need a well defined structure format
69 * for the data I pass, and I need tags
70 * on the data to indicate what information I have
71 * squirrelled away. ELF notes happen to provide
72 * all of that, no need to invent something new.
73 */
74
75 buf = (u32*)per_cpu_ptr(crash_notes, cpu);
76
77 if (!buf)
78 return;
79
80 memset(&prstatus, 0, sizeof(prstatus));
81 prstatus.pr_pid = current->pid;
82 elf_core_copy_regs(&prstatus.pr_reg, regs);
83 buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
84 sizeof(prstatus));
85 final_note(buf);
86}
87
88static void crash_save_self(struct pt_regs *regs)
89{
90 int cpu;
91
92 cpu = smp_processor_id();
93 crash_save_this_cpu(regs, cpu);
94}
95
96#ifdef CONFIG_SMP 31#ifdef CONFIG_SMP
97static atomic_t waiting_for_crash_ipi; 32static atomic_t waiting_for_crash_ipi;
98 33
@@ -117,7 +52,7 @@ static int crash_nmi_callback(struct notifier_block *self,
117 return NOTIFY_STOP; 52 return NOTIFY_STOP;
118 local_irq_disable(); 53 local_irq_disable();
119 54
120 crash_save_this_cpu(regs, cpu); 55 crash_save_cpu(regs, cpu);
121 disable_local_APIC(); 56 disable_local_APIC();
122 atomic_dec(&waiting_for_crash_ipi); 57 atomic_dec(&waiting_for_crash_ipi);
123 /* Assume hlt works */ 58 /* Assume hlt works */
@@ -196,5 +131,5 @@ void machine_crash_shutdown(struct pt_regs *regs)
196 131
197 disable_IO_APIC(); 132 disable_IO_APIC();
198 133
199 crash_save_self(regs); 134 crash_save_cpu(regs, smp_processor_id());
200} 135}
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c
index ac241567e682..209c8c0bec71 100644
--- a/arch/x86_64/kernel/kprobes.c
+++ b/arch/x86_64/kernel/kprobes.c
@@ -224,7 +224,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
224void __kprobes arch_remove_kprobe(struct kprobe *p) 224void __kprobes arch_remove_kprobe(struct kprobe *p)
225{ 225{
226 mutex_lock(&kprobe_mutex); 226 mutex_lock(&kprobe_mutex);
227 free_insn_slot(p->ainsn.insn); 227 free_insn_slot(p->ainsn.insn, 0);
228 mutex_unlock(&kprobe_mutex); 228 mutex_unlock(&kprobe_mutex);
229} 229}
230 230
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
index a7440cb9c14f..ac085038af29 100644
--- a/arch/x86_64/kernel/mce.c
+++ b/arch/x86_64/kernel/mce.c
@@ -306,8 +306,8 @@ void mce_log_therm_throt_event(unsigned int cpu, __u64 status)
306 */ 306 */
307 307
308static int check_interval = 5 * 60; /* 5 minutes */ 308static int check_interval = 5 * 60; /* 5 minutes */
309static void mcheck_timer(void *data); 309static void mcheck_timer(struct work_struct *work);
310static DECLARE_WORK(mcheck_work, mcheck_timer, NULL); 310static DECLARE_DELAYED_WORK(mcheck_work, mcheck_timer);
311 311
312static void mcheck_check_cpu(void *info) 312static void mcheck_check_cpu(void *info)
313{ 313{
@@ -315,7 +315,7 @@ static void mcheck_check_cpu(void *info)
315 do_machine_check(NULL, 0); 315 do_machine_check(NULL, 0);
316} 316}
317 317
318static void mcheck_timer(void *data) 318static void mcheck_timer(struct work_struct *work)
319{ 319{
320 on_each_cpu(mcheck_check_cpu, NULL, 1, 1); 320 on_each_cpu(mcheck_check_cpu, NULL, 1, 1);
321 schedule_delayed_work(&mcheck_work, check_interval * HZ); 321 schedule_delayed_work(&mcheck_work, check_interval * HZ);
@@ -641,7 +641,6 @@ static __cpuinit int mce_create_device(unsigned int cpu)
641 return err; 641 return err;
642} 642}
643 643
644#ifdef CONFIG_HOTPLUG_CPU
645static void mce_remove_device(unsigned int cpu) 644static void mce_remove_device(unsigned int cpu)
646{ 645{
647 int i; 646 int i;
@@ -675,7 +674,6 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
675static struct notifier_block mce_cpu_notifier = { 674static struct notifier_block mce_cpu_notifier = {
676 .notifier_call = mce_cpu_callback, 675 .notifier_call = mce_cpu_callback,
677}; 676};
678#endif
679 677
680static __init int mce_init_device(void) 678static __init int mce_init_device(void)
681{ 679{
diff --git a/arch/x86_64/kernel/mce_amd.c b/arch/x86_64/kernel/mce_amd.c
index 883fe747f64c..fa09debad4b7 100644
--- a/arch/x86_64/kernel/mce_amd.c
+++ b/arch/x86_64/kernel/mce_amd.c
@@ -551,7 +551,6 @@ out:
551 return err; 551 return err;
552} 552}
553 553
554#ifdef CONFIG_HOTPLUG_CPU
555/* 554/*
556 * let's be hotplug friendly. 555 * let's be hotplug friendly.
557 * in case of multiple core processors, the first core always takes ownership 556 * in case of multiple core processors, the first core always takes ownership
@@ -594,12 +593,14 @@ static void threshold_remove_bank(unsigned int cpu, int bank)
594 593
595 sprintf(name, "threshold_bank%i", bank); 594 sprintf(name, "threshold_bank%i", bank);
596 595
596#ifdef CONFIG_SMP
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, cpu)[bank] = NULL; 600 per_cpu(threshold_banks, cpu)[bank] = NULL;
601 return; 601 return;
602 } 602 }
603#endif
603 604
604 /* remove all sibling symlinks before unregistering */ 605 /* remove all sibling symlinks before unregistering */
605 for_each_cpu_mask(i, b->cpus) { 606 for_each_cpu_mask(i, b->cpus) {
@@ -656,7 +657,6 @@ static int threshold_cpu_callback(struct notifier_block *nfb,
656static struct notifier_block threshold_cpu_notifier = { 657static struct notifier_block threshold_cpu_notifier = {
657 .notifier_call = threshold_cpu_callback, 658 .notifier_call = threshold_cpu_callback,
658}; 659};
659#endif /* CONFIG_HOTPLUG_CPU */
660 660
661static __init int threshold_init_device(void) 661static __init int threshold_init_device(void)
662{ 662{
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index 6595a4ebe7f1..af425a8049fb 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -471,8 +471,7 @@ void __init setup_arch(char **cmdline_p)
471 if (LOADER_TYPE && INITRD_START) { 471 if (LOADER_TYPE && INITRD_START) {
472 if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) { 472 if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) {
473 reserve_bootmem_generic(INITRD_START, INITRD_SIZE); 473 reserve_bootmem_generic(INITRD_START, INITRD_SIZE);
474 initrd_start = 474 initrd_start = INITRD_START + PAGE_OFFSET;
475 INITRD_START ? INITRD_START + PAGE_OFFSET : 0;
476 initrd_end = initrd_start+INITRD_SIZE; 475 initrd_end = initrd_start+INITRD_SIZE;
477 } 476 }
478 else { 477 else {
diff --git a/arch/x86_64/kernel/smp.c b/arch/x86_64/kernel/smp.c
index 1bf0e094f439..af1ec4d23cf8 100644
--- a/arch/x86_64/kernel/smp.c
+++ b/arch/x86_64/kernel/smp.c
@@ -379,6 +379,10 @@ int smp_call_function_single (int cpu, void (*func) (void *info), void *info,
379 put_cpu(); 379 put_cpu();
380 return 0; 380 return 0;
381 } 381 }
382
383 /* Can deadlock when called with interrupts disabled */
384 WARN_ON(irqs_disabled());
385
382 spin_lock_bh(&call_lock); 386 spin_lock_bh(&call_lock);
383 __smp_call_function_single(cpu, func, info, nonatomic, wait); 387 __smp_call_function_single(cpu, func, info, nonatomic, wait);
384 spin_unlock_bh(&call_lock); 388 spin_unlock_bh(&call_lock);
diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
index 4c161c208d5b..daf19332f0dd 100644
--- a/arch/x86_64/kernel/smpboot.c
+++ b/arch/x86_64/kernel/smpboot.c
@@ -754,14 +754,16 @@ static int __cpuinit wakeup_secondary_via_INIT(int phys_apicid, unsigned int sta
754} 754}
755 755
756struct create_idle { 756struct create_idle {
757 struct work_struct work;
757 struct task_struct *idle; 758 struct task_struct *idle;
758 struct completion done; 759 struct completion done;
759 int cpu; 760 int cpu;
760}; 761};
761 762
762void do_fork_idle(void *_c_idle) 763void do_fork_idle(struct work_struct *work)
763{ 764{
764 struct create_idle *c_idle = _c_idle; 765 struct create_idle *c_idle =
766 container_of(work, struct create_idle, work);
765 767
766 c_idle->idle = fork_idle(c_idle->cpu); 768 c_idle->idle = fork_idle(c_idle->cpu);
767 complete(&c_idle->done); 769 complete(&c_idle->done);
@@ -776,10 +778,10 @@ static int __cpuinit do_boot_cpu(int cpu, int apicid)
776 int timeout; 778 int timeout;
777 unsigned long start_rip; 779 unsigned long start_rip;
778 struct create_idle c_idle = { 780 struct create_idle c_idle = {
781 .work = __WORK_INITIALIZER(c_idle.work, do_fork_idle),
779 .cpu = cpu, 782 .cpu = cpu,
780 .done = COMPLETION_INITIALIZER_ONSTACK(c_idle.done), 783 .done = COMPLETION_INITIALIZER_ONSTACK(c_idle.done),
781 }; 784 };
782 DECLARE_WORK(work, do_fork_idle, &c_idle);
783 785
784 /* allocate memory for gdts of secondary cpus. Hotplug is considered */ 786 /* allocate memory for gdts of secondary cpus. Hotplug is considered */
785 if (!cpu_gdt_descr[cpu].address && 787 if (!cpu_gdt_descr[cpu].address &&
@@ -826,9 +828,9 @@ static int __cpuinit do_boot_cpu(int cpu, int apicid)
826 * thread. 828 * thread.
827 */ 829 */
828 if (!keventd_up() || current_is_keventd()) 830 if (!keventd_up() || current_is_keventd())
829 work.func(work.data); 831 c_idle.work.func(&c_idle.work);
830 else { 832 else {
831 schedule_work(&work); 833 schedule_work(&c_idle.work);
832 wait_for_completion(&c_idle.done); 834 wait_for_completion(&c_idle.done);
833 } 835 }
834 836
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index e3ef544d2cfb..9f05bc9b2dad 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -563,7 +563,7 @@ static unsigned int cpufreq_delayed_issched = 0;
563static unsigned int cpufreq_init = 0; 563static unsigned int cpufreq_init = 0;
564static struct work_struct cpufreq_delayed_get_work; 564static struct work_struct cpufreq_delayed_get_work;
565 565
566static void handle_cpufreq_delayed_get(void *v) 566static void handle_cpufreq_delayed_get(struct work_struct *v)
567{ 567{
568 unsigned int cpu; 568 unsigned int cpu;
569 for_each_online_cpu(cpu) { 569 for_each_online_cpu(cpu) {
@@ -639,7 +639,7 @@ static struct notifier_block time_cpufreq_notifier_block = {
639 639
640static int __init cpufreq_tsc(void) 640static int __init cpufreq_tsc(void)
641{ 641{
642 INIT_WORK(&cpufreq_delayed_get_work, handle_cpufreq_delayed_get, NULL); 642 INIT_WORK(&cpufreq_delayed_get_work, handle_cpufreq_delayed_get);
643 if (!cpufreq_register_notifier(&time_cpufreq_notifier_block, 643 if (!cpufreq_register_notifier(&time_cpufreq_notifier_block,
644 CPUFREQ_TRANSITION_NOTIFIER)) 644 CPUFREQ_TRANSITION_NOTIFIER))
645 cpufreq_init = 1; 645 cpufreq_init = 1;
diff --git a/arch/x86_64/kernel/vsyscall.c b/arch/x86_64/kernel/vsyscall.c
index c3de9a09cd9f..4a673f5397a0 100644
--- a/arch/x86_64/kernel/vsyscall.c
+++ b/arch/x86_64/kernel/vsyscall.c
@@ -42,6 +42,7 @@
42#include <asm/topology.h> 42#include <asm/topology.h>
43 43
44#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr))) 44#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr)))
45#define __syscall_clobber "r11","rcx","memory"
45 46
46int __sysctl_vsyscall __section_sysctl_vsyscall = 1; 47int __sysctl_vsyscall __section_sysctl_vsyscall = 1;
47seqlock_t __xtime_lock __section_xtime_lock = SEQLOCK_UNLOCKED; 48seqlock_t __xtime_lock __section_xtime_lock = SEQLOCK_UNLOCKED;
@@ -274,7 +275,6 @@ static void __cpuinit cpu_vsyscall_init(void *arg)
274 vsyscall_set_cpu(raw_smp_processor_id()); 275 vsyscall_set_cpu(raw_smp_processor_id());
275} 276}
276 277
277#ifdef CONFIG_HOTPLUG_CPU
278static int __cpuinit 278static int __cpuinit
279cpu_vsyscall_notifier(struct notifier_block *n, unsigned long action, void *arg) 279cpu_vsyscall_notifier(struct notifier_block *n, unsigned long action, void *arg)
280{ 280{
@@ -283,7 +283,6 @@ cpu_vsyscall_notifier(struct notifier_block *n, unsigned long action, void *arg)
283 smp_call_function_single(cpu, cpu_vsyscall_init, NULL, 0, 1); 283 smp_call_function_single(cpu, cpu_vsyscall_init, NULL, 0, 1);
284 return NOTIFY_DONE; 284 return NOTIFY_DONE;
285} 285}
286#endif
287 286
288static void __init map_vsyscall(void) 287static void __init map_vsyscall(void)
289{ 288{
diff --git a/block/as-iosched.c b/block/as-iosched.c
index 00242111a457..5934c4bfd52a 100644
--- a/block/as-iosched.c
+++ b/block/as-iosched.c
@@ -1274,9 +1274,10 @@ static void as_merged_requests(request_queue_t *q, struct request *req,
1274 * 1274 *
1275 * FIXME! dispatch queue is not a queue at all! 1275 * FIXME! dispatch queue is not a queue at all!
1276 */ 1276 */
1277static void as_work_handler(void *data) 1277static void as_work_handler(struct work_struct *work)
1278{ 1278{
1279 struct request_queue *q = data; 1279 struct as_data *ad = container_of(work, struct as_data, antic_work);
1280 struct request_queue *q = ad->q;
1280 unsigned long flags; 1281 unsigned long flags;
1281 1282
1282 spin_lock_irqsave(q->queue_lock, flags); 1283 spin_lock_irqsave(q->queue_lock, flags);
@@ -1332,7 +1333,7 @@ static void *as_init_queue(request_queue_t *q)
1332 ad->antic_timer.function = as_antic_timeout; 1333 ad->antic_timer.function = as_antic_timeout;
1333 ad->antic_timer.data = (unsigned long)q; 1334 ad->antic_timer.data = (unsigned long)q;
1334 init_timer(&ad->antic_timer); 1335 init_timer(&ad->antic_timer);
1335 INIT_WORK(&ad->antic_work, as_work_handler, q); 1336 INIT_WORK(&ad->antic_work, as_work_handler);
1336 1337
1337 INIT_LIST_HEAD(&ad->fifo_list[REQ_SYNC]); 1338 INIT_LIST_HEAD(&ad->fifo_list[REQ_SYNC]);
1338 INIT_LIST_HEAD(&ad->fifo_list[REQ_ASYNC]); 1339 INIT_LIST_HEAD(&ad->fifo_list[REQ_ASYNC]);
diff --git a/block/blktrace.c b/block/blktrace.c
index 74e02c04b2da..d3679dd1d220 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -394,8 +394,7 @@ err:
394 if (bt) { 394 if (bt) {
395 if (bt->dropped_file) 395 if (bt->dropped_file)
396 debugfs_remove(bt->dropped_file); 396 debugfs_remove(bt->dropped_file);
397 if (bt->sequence) 397 free_percpu(bt->sequence);
398 free_percpu(bt->sequence);
399 if (bt->rchan) 398 if (bt->rchan)
400 relay_close(bt->rchan); 399 relay_close(bt->rchan);
401 kfree(bt); 400 kfree(bt);
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index e9019ed39b73..78c6b312bd30 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -43,8 +43,8 @@ static int cfq_slice_idle = HZ / 125;
43#define RQ_CIC(rq) ((struct cfq_io_context*)(rq)->elevator_private) 43#define RQ_CIC(rq) ((struct cfq_io_context*)(rq)->elevator_private)
44#define RQ_CFQQ(rq) ((rq)->elevator_private2) 44#define RQ_CFQQ(rq) ((rq)->elevator_private2)
45 45
46static kmem_cache_t *cfq_pool; 46static struct kmem_cache *cfq_pool;
47static kmem_cache_t *cfq_ioc_pool; 47static struct kmem_cache *cfq_ioc_pool;
48 48
49static DEFINE_PER_CPU(unsigned long, ioc_count); 49static DEFINE_PER_CPU(unsigned long, ioc_count);
50static struct completion *ioc_gone; 50static struct completion *ioc_gone;
@@ -1840,9 +1840,11 @@ queue_fail:
1840 return 1; 1840 return 1;
1841} 1841}
1842 1842
1843static void cfq_kick_queue(void *data) 1843static void cfq_kick_queue(struct work_struct *work)
1844{ 1844{
1845 request_queue_t *q = data; 1845 struct cfq_data *cfqd =
1846 container_of(work, struct cfq_data, unplug_work);
1847 request_queue_t *q = cfqd->queue;
1846 unsigned long flags; 1848 unsigned long flags;
1847 1849
1848 spin_lock_irqsave(q->queue_lock, flags); 1850 spin_lock_irqsave(q->queue_lock, flags);
@@ -1986,7 +1988,7 @@ static void *cfq_init_queue(request_queue_t *q)
1986 cfqd->idle_class_timer.function = cfq_idle_class_timer; 1988 cfqd->idle_class_timer.function = cfq_idle_class_timer;
1987 cfqd->idle_class_timer.data = (unsigned long) cfqd; 1989 cfqd->idle_class_timer.data = (unsigned long) cfqd;
1988 1990
1989 INIT_WORK(&cfqd->unplug_work, cfq_kick_queue, q); 1991 INIT_WORK(&cfqd->unplug_work, cfq_kick_queue);
1990 1992
1991 cfqd->cfq_quantum = cfq_quantum; 1993 cfqd->cfq_quantum = cfq_quantum;
1992 cfqd->cfq_fifo_expire[0] = cfq_fifo_expire[0]; 1994 cfqd->cfq_fifo_expire[0] = cfq_fifo_expire[0];
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 0f82e12f7b67..31512cd9f3ad 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -34,7 +34,7 @@
34 */ 34 */
35#include <scsi/scsi_cmnd.h> 35#include <scsi/scsi_cmnd.h>
36 36
37static void blk_unplug_work(void *data); 37static void blk_unplug_work(struct work_struct *work);
38static void blk_unplug_timeout(unsigned long data); 38static void blk_unplug_timeout(unsigned long data);
39static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io); 39static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io);
40static void init_request_from_bio(struct request *req, struct bio *bio); 40static void init_request_from_bio(struct request *req, struct bio *bio);
@@ -44,17 +44,17 @@ static struct io_context *current_io_context(gfp_t gfp_flags, int node);
44/* 44/*
45 * For the allocated request tables 45 * For the allocated request tables
46 */ 46 */
47static kmem_cache_t *request_cachep; 47static struct kmem_cache *request_cachep;
48 48
49/* 49/*
50 * For queue allocation 50 * For queue allocation
51 */ 51 */
52static kmem_cache_t *requestq_cachep; 52static struct kmem_cache *requestq_cachep;
53 53
54/* 54/*
55 * For io context allocations 55 * For io context allocations
56 */ 56 */
57static kmem_cache_t *iocontext_cachep; 57static struct kmem_cache *iocontext_cachep;
58 58
59/* 59/*
60 * Controlling structure to kblockd 60 * Controlling structure to kblockd
@@ -227,7 +227,7 @@ void blk_queue_make_request(request_queue_t * q, make_request_fn * mfn)
227 if (q->unplug_delay == 0) 227 if (q->unplug_delay == 0)
228 q->unplug_delay = 1; 228 q->unplug_delay = 1;
229 229
230 INIT_WORK(&q->unplug_work, blk_unplug_work, q); 230 INIT_WORK(&q->unplug_work, blk_unplug_work);
231 231
232 q->unplug_timer.function = blk_unplug_timeout; 232 q->unplug_timer.function = blk_unplug_timeout;
233 q->unplug_timer.data = (unsigned long)q; 233 q->unplug_timer.data = (unsigned long)q;
@@ -1631,9 +1631,9 @@ static void blk_backing_dev_unplug(struct backing_dev_info *bdi,
1631 } 1631 }
1632} 1632}
1633 1633
1634static void blk_unplug_work(void *data) 1634static void blk_unplug_work(struct work_struct *work)
1635{ 1635{
1636 request_queue_t *q = data; 1636 request_queue_t *q = container_of(work, request_queue_t, unplug_work);
1637 1637
1638 blk_add_trace_pdu_int(q, BLK_TA_UNPLUG_IO, NULL, 1638 blk_add_trace_pdu_int(q, BLK_TA_UNPLUG_IO, NULL,
1639 q->rq.count[READ] + q->rq.count[WRITE]); 1639 q->rq.count[READ] + q->rq.count[WRITE]);
@@ -3459,8 +3459,6 @@ static void blk_done_softirq(struct softirq_action *h)
3459 } 3459 }
3460} 3460}
3461 3461
3462#ifdef CONFIG_HOTPLUG_CPU
3463
3464static int blk_cpu_notify(struct notifier_block *self, unsigned long action, 3462static int blk_cpu_notify(struct notifier_block *self, unsigned long action,
3465 void *hcpu) 3463 void *hcpu)
3466{ 3464{
@@ -3486,8 +3484,6 @@ static struct notifier_block __devinitdata blk_cpu_notifier = {
3486 .notifier_call = blk_cpu_notify, 3484 .notifier_call = blk_cpu_notify,
3487}; 3485};
3488 3486
3489#endif /* CONFIG_HOTPLUG_CPU */
3490
3491/** 3487/**
3492 * blk_complete_request - end I/O on a request 3488 * blk_complete_request - end I/O on a request
3493 * @req: the request being processed 3489 * @req: the request being processed
diff --git a/crypto/cryptomgr.c b/crypto/cryptomgr.c
index 9b5b15601068..2ebffb84f1d9 100644
--- a/crypto/cryptomgr.c
+++ b/crypto/cryptomgr.c
@@ -40,9 +40,10 @@ struct cryptomgr_param {
40 char template[CRYPTO_MAX_ALG_NAME]; 40 char template[CRYPTO_MAX_ALG_NAME];
41}; 41};
42 42
43static void cryptomgr_probe(void *data) 43static void cryptomgr_probe(struct work_struct *work)
44{ 44{
45 struct cryptomgr_param *param = data; 45 struct cryptomgr_param *param =
46 container_of(work, struct cryptomgr_param, work);
46 struct crypto_template *tmpl; 47 struct crypto_template *tmpl;
47 struct crypto_instance *inst; 48 struct crypto_instance *inst;
48 int err; 49 int err;
@@ -112,7 +113,7 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
112 param->larval.type = larval->alg.cra_flags; 113 param->larval.type = larval->alg.cra_flags;
113 param->larval.mask = larval->mask; 114 param->larval.mask = larval->mask;
114 115
115 INIT_WORK(&param->work, cryptomgr_probe, param); 116 INIT_WORK(&param->work, cryptomgr_probe);
116 schedule_work(&param->work); 117 schedule_work(&param->work);
117 118
118 return NOTIFY_STOP; 119 return NOTIFY_STOP;
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 068fe4f100b0..02b30ae6a68e 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -50,6 +50,7 @@ ACPI_MODULE_NAME("osl")
50struct acpi_os_dpc { 50struct acpi_os_dpc {
51 acpi_osd_exec_callback function; 51 acpi_osd_exec_callback function;
52 void *context; 52 void *context;
53 struct work_struct work;
53}; 54};
54 55
55#ifdef CONFIG_ACPI_CUSTOM_DSDT 56#ifdef CONFIG_ACPI_CUSTOM_DSDT
@@ -564,12 +565,9 @@ void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */
564 acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number); 565 acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number);
565} 566}
566 567
567static void acpi_os_execute_deferred(void *context) 568static void acpi_os_execute_deferred(struct work_struct *work)
568{ 569{
569 struct acpi_os_dpc *dpc = NULL; 570 struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work);
570
571
572 dpc = (struct acpi_os_dpc *)context;
573 if (!dpc) { 571 if (!dpc) {
574 printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); 572 printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
575 return; 573 return;
@@ -602,7 +600,6 @@ acpi_status acpi_os_execute(acpi_execute_type type,
602{ 600{
603 acpi_status status = AE_OK; 601 acpi_status status = AE_OK;
604 struct acpi_os_dpc *dpc; 602 struct acpi_os_dpc *dpc;
605 struct work_struct *task;
606 603
607 ACPI_FUNCTION_TRACE("os_queue_for_execution"); 604 ACPI_FUNCTION_TRACE("os_queue_for_execution");
608 605
@@ -615,28 +612,22 @@ acpi_status acpi_os_execute(acpi_execute_type type,
615 612
616 /* 613 /*
617 * Allocate/initialize DPC structure. Note that this memory will be 614 * Allocate/initialize DPC structure. Note that this memory will be
618 * freed by the callee. The kernel handles the tq_struct list in a 615 * freed by the callee. The kernel handles the work_struct list in a
619 * way that allows us to also free its memory inside the callee. 616 * way that allows us to also free its memory inside the callee.
620 * Because we may want to schedule several tasks with different 617 * Because we may want to schedule several tasks with different
621 * parameters we can't use the approach some kernel code uses of 618 * parameters we can't use the approach some kernel code uses of
622 * having a static tq_struct. 619 * having a static work_struct.
623 * We can save time and code by allocating the DPC and tq_structs
624 * from the same memory.
625 */ 620 */
626 621
627 dpc = 622 dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC);
628 kmalloc(sizeof(struct acpi_os_dpc) + sizeof(struct work_struct),
629 GFP_ATOMIC);
630 if (!dpc) 623 if (!dpc)
631 return_ACPI_STATUS(AE_NO_MEMORY); 624 return_ACPI_STATUS(AE_NO_MEMORY);
632 625
633 dpc->function = function; 626 dpc->function = function;
634 dpc->context = context; 627 dpc->context = context;
635 628
636 task = (void *)(dpc + 1); 629 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
637 INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc); 630 if (!queue_work(kacpid_wq, &dpc->work)) {
638
639 if (!queue_work(kacpid_wq, task)) {
640 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 631 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
641 "Call to queue_work() failed.\n")); 632 "Call to queue_work() failed.\n"));
642 kfree(dpc); 633 kfree(dpc);
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index f8ec3896b793..8816e30fb7a4 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1081,7 +1081,7 @@ static unsigned int ata_id_xfermask(const u16 *id)
1081 * ata_port_queue_task - Queue port_task 1081 * ata_port_queue_task - Queue port_task
1082 * @ap: The ata_port to queue port_task for 1082 * @ap: The ata_port to queue port_task for
1083 * @fn: workqueue function to be scheduled 1083 * @fn: workqueue function to be scheduled
1084 * @data: data value to pass to workqueue function 1084 * @data: data for @fn to use
1085 * @delay: delay time for workqueue function 1085 * @delay: delay time for workqueue function
1086 * 1086 *
1087 * Schedule @fn(@data) for execution after @delay jiffies using 1087 * Schedule @fn(@data) for execution after @delay jiffies using
@@ -1096,7 +1096,7 @@ static unsigned int ata_id_xfermask(const u16 *id)
1096 * LOCKING: 1096 * LOCKING:
1097 * Inherited from caller. 1097 * Inherited from caller.
1098 */ 1098 */
1099void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), void *data, 1099void ata_port_queue_task(struct ata_port *ap, work_func_t fn, void *data,
1100 unsigned long delay) 1100 unsigned long delay)
1101{ 1101{
1102 int rc; 1102 int rc;
@@ -1104,12 +1104,10 @@ void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), void *data,
1104 if (ap->pflags & ATA_PFLAG_FLUSH_PORT_TASK) 1104 if (ap->pflags & ATA_PFLAG_FLUSH_PORT_TASK)
1105 return; 1105 return;
1106 1106
1107 PREPARE_WORK(&ap->port_task, fn, data); 1107 PREPARE_DELAYED_WORK(&ap->port_task, fn);
1108 ap->port_task_data = data;
1108 1109
1109 if (!delay) 1110 rc = queue_delayed_work(ata_wq, &ap->port_task, delay);
1110 rc = queue_work(ata_wq, &ap->port_task);
1111 else
1112 rc = queue_delayed_work(ata_wq, &ap->port_task, delay);
1113 1111
1114 /* rc == 0 means that another user is using port task */ 1112 /* rc == 0 means that another user is using port task */
1115 WARN_ON(rc == 0); 1113 WARN_ON(rc == 0);
@@ -4588,10 +4586,11 @@ fsm_start:
4588 return poll_next; 4586 return poll_next;
4589} 4587}
4590 4588
4591static void ata_pio_task(void *_data) 4589static void ata_pio_task(struct work_struct *work)
4592{ 4590{
4593 struct ata_queued_cmd *qc = _data; 4591 struct ata_port *ap =
4594 struct ata_port *ap = qc->ap; 4592 container_of(work, struct ata_port, port_task.work);
4593 struct ata_queued_cmd *qc = ap->port_task_data;
4595 u8 status; 4594 u8 status;
4596 int poll_next; 4595 int poll_next;
4597 4596
@@ -5635,9 +5634,9 @@ void ata_port_init(struct ata_port *ap, struct ata_host *host,
5635 ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR | ATA_MSG_WARN; 5634 ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR | ATA_MSG_WARN;
5636#endif 5635#endif
5637 5636
5638 INIT_WORK(&ap->port_task, NULL, NULL); 5637 INIT_DELAYED_WORK(&ap->port_task, NULL);
5639 INIT_WORK(&ap->hotplug_task, ata_scsi_hotplug, ap); 5638 INIT_DELAYED_WORK(&ap->hotplug_task, ata_scsi_hotplug);
5640 INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan, ap); 5639 INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan);
5641 INIT_LIST_HEAD(&ap->eh_done_q); 5640 INIT_LIST_HEAD(&ap->eh_done_q);
5642 init_waitqueue_head(&ap->eh_wait_q); 5641 init_waitqueue_head(&ap->eh_wait_q);
5643 5642
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 76a85dfb7307..08ad44b3e48f 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -332,7 +332,7 @@ void ata_scsi_error(struct Scsi_Host *host)
332 if (ap->pflags & ATA_PFLAG_LOADING) 332 if (ap->pflags & ATA_PFLAG_LOADING)
333 ap->pflags &= ~ATA_PFLAG_LOADING; 333 ap->pflags &= ~ATA_PFLAG_LOADING;
334 else if (ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) 334 else if (ap->pflags & ATA_PFLAG_SCSI_HOTPLUG)
335 queue_work(ata_aux_wq, &ap->hotplug_task); 335 queue_delayed_work(ata_aux_wq, &ap->hotplug_task, 0);
336 336
337 if (ap->pflags & ATA_PFLAG_RECOVERED) 337 if (ap->pflags & ATA_PFLAG_RECOVERED)
338 ata_port_printk(ap, KERN_INFO, "EH complete\n"); 338 ata_port_printk(ap, KERN_INFO, "EH complete\n");
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 8eaace94d963..664e1377b54c 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2963,7 +2963,7 @@ static void ata_scsi_remove_dev(struct ata_device *dev)
2963 2963
2964/** 2964/**
2965 * ata_scsi_hotplug - SCSI part of hotplug 2965 * ata_scsi_hotplug - SCSI part of hotplug
2966 * @data: Pointer to ATA port to perform SCSI hotplug on 2966 * @work: Pointer to ATA port to perform SCSI hotplug on
2967 * 2967 *
2968 * Perform SCSI part of hotplug. It's executed from a separate 2968 * Perform SCSI part of hotplug. It's executed from a separate
2969 * workqueue after EH completes. This is necessary because SCSI 2969 * workqueue after EH completes. This is necessary because SCSI
@@ -2973,9 +2973,10 @@ static void ata_scsi_remove_dev(struct ata_device *dev)
2973 * LOCKING: 2973 * LOCKING:
2974 * Kernel thread context (may sleep). 2974 * Kernel thread context (may sleep).
2975 */ 2975 */
2976void ata_scsi_hotplug(void *data) 2976void ata_scsi_hotplug(struct work_struct *work)
2977{ 2977{
2978 struct ata_port *ap = data; 2978 struct ata_port *ap =
2979 container_of(work, struct ata_port, hotplug_task.work);
2979 int i; 2980 int i;
2980 2981
2981 if (ap->pflags & ATA_PFLAG_UNLOADING) { 2982 if (ap->pflags & ATA_PFLAG_UNLOADING) {
@@ -3076,7 +3077,7 @@ static int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
3076 3077
3077/** 3078/**
3078 * ata_scsi_dev_rescan - initiate scsi_rescan_device() 3079 * ata_scsi_dev_rescan - initiate scsi_rescan_device()
3079 * @data: Pointer to ATA port to perform scsi_rescan_device() 3080 * @work: Pointer to ATA port to perform scsi_rescan_device()
3080 * 3081 *
3081 * After ATA pass thru (SAT) commands are executed successfully, 3082 * After ATA pass thru (SAT) commands are executed successfully,
3082 * libata need to propagate the changes to SCSI layer. This 3083 * libata need to propagate the changes to SCSI layer. This
@@ -3086,9 +3087,10 @@ static int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
3086 * LOCKING: 3087 * LOCKING:
3087 * Kernel thread context (may sleep). 3088 * Kernel thread context (may sleep).
3088 */ 3089 */
3089void ata_scsi_dev_rescan(void *data) 3090void ata_scsi_dev_rescan(struct work_struct *work)
3090{ 3091{
3091 struct ata_port *ap = data; 3092 struct ata_port *ap =
3093 container_of(work, struct ata_port, scsi_rescan_task);
3092 unsigned long flags; 3094 unsigned long flags;
3093 unsigned int i; 3095 unsigned int i;
3094 3096
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 107b2b565229..81ae41d5f23f 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -94,7 +94,7 @@ extern struct scsi_transport_template ata_scsi_transport_template;
94 94
95extern void ata_scsi_scan_host(struct ata_port *ap); 95extern void ata_scsi_scan_host(struct ata_port *ap);
96extern int ata_scsi_offline_dev(struct ata_device *dev); 96extern int ata_scsi_offline_dev(struct ata_device *dev);
97extern void ata_scsi_hotplug(void *data); 97extern void ata_scsi_hotplug(struct work_struct *work);
98extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf, 98extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
99 unsigned int buflen); 99 unsigned int buflen);
100 100
@@ -124,7 +124,7 @@ extern void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
124 unsigned int (*actor) (struct ata_scsi_args *args, 124 unsigned int (*actor) (struct ata_scsi_args *args,
125 u8 *rbuf, unsigned int buflen)); 125 u8 *rbuf, unsigned int buflen));
126extern void ata_schedule_scsi_eh(struct Scsi_Host *shost); 126extern void ata_schedule_scsi_eh(struct Scsi_Host *shost);
127extern void ata_scsi_dev_rescan(void *data); 127extern void ata_scsi_dev_rescan(struct work_struct *work);
128extern int ata_bus_probe(struct ata_port *ap); 128extern int ata_bus_probe(struct ata_port *ap);
129 129
130/* libata-eh.c */ 130/* libata-eh.c */
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index c7314a79da0f..7d9b4e52f0bf 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -820,7 +820,7 @@ he_init_group(struct he_dev *he_dev, int group)
820 void *cpuaddr; 820 void *cpuaddr;
821 821
822#ifdef USE_RBPS_POOL 822#ifdef USE_RBPS_POOL
823 cpuaddr = pci_pool_alloc(he_dev->rbps_pool, SLAB_KERNEL|SLAB_DMA, &dma_handle); 823 cpuaddr = pci_pool_alloc(he_dev->rbps_pool, GFP_KERNEL|GFP_DMA, &dma_handle);
824 if (cpuaddr == NULL) 824 if (cpuaddr == NULL)
825 return -ENOMEM; 825 return -ENOMEM;
826#else 826#else
@@ -884,7 +884,7 @@ he_init_group(struct he_dev *he_dev, int group)
884 void *cpuaddr; 884 void *cpuaddr;
885 885
886#ifdef USE_RBPL_POOL 886#ifdef USE_RBPL_POOL
887 cpuaddr = pci_pool_alloc(he_dev->rbpl_pool, SLAB_KERNEL|SLAB_DMA, &dma_handle); 887 cpuaddr = pci_pool_alloc(he_dev->rbpl_pool, GFP_KERNEL|GFP_DMA, &dma_handle);
888 if (cpuaddr == NULL) 888 if (cpuaddr == NULL)
889 return -ENOMEM; 889 return -ENOMEM;
890#else 890#else
@@ -1724,7 +1724,7 @@ __alloc_tpd(struct he_dev *he_dev)
1724 struct he_tpd *tpd; 1724 struct he_tpd *tpd;
1725 dma_addr_t dma_handle; 1725 dma_addr_t dma_handle;
1726 1726
1727 tpd = pci_pool_alloc(he_dev->tpd_pool, SLAB_ATOMIC|SLAB_DMA, &dma_handle); 1727 tpd = pci_pool_alloc(he_dev->tpd_pool, GFP_ATOMIC|GFP_DMA, &dma_handle);
1728 if (tpd == NULL) 1728 if (tpd == NULL)
1729 return NULL; 1729 return NULL;
1730 1730
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index 87b17c33b3f9..f40786121948 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -135,7 +135,7 @@ static int idt77252_change_qos(struct atm_vcc *vcc, struct atm_qos *qos,
135 int flags); 135 int flags);
136static int idt77252_proc_read(struct atm_dev *dev, loff_t * pos, 136static int idt77252_proc_read(struct atm_dev *dev, loff_t * pos,
137 char *page); 137 char *page);
138static void idt77252_softint(void *dev_id); 138static void idt77252_softint(struct work_struct *work);
139 139
140 140
141static struct atmdev_ops idt77252_ops = 141static struct atmdev_ops idt77252_ops =
@@ -2866,9 +2866,10 @@ out:
2866} 2866}
2867 2867
2868static void 2868static void
2869idt77252_softint(void *dev_id) 2869idt77252_softint(struct work_struct *work)
2870{ 2870{
2871 struct idt77252_dev *card = dev_id; 2871 struct idt77252_dev *card =
2872 container_of(work, struct idt77252_dev, tqueue);
2872 u32 stat; 2873 u32 stat;
2873 int done; 2874 int done;
2874 2875
@@ -3697,7 +3698,7 @@ idt77252_init_one(struct pci_dev *pcidev, const struct pci_device_id *id)
3697 card->pcidev = pcidev; 3698 card->pcidev = pcidev;
3698 sprintf(card->name, "idt77252-%d", card->index); 3699 sprintf(card->name, "idt77252-%d", card->index);
3699 3700
3700 INIT_WORK(&card->tqueue, idt77252_softint, (void *)card); 3701 INIT_WORK(&card->tqueue, idt77252_softint);
3701 3702
3702 membase = pci_resource_start(pcidev, 1); 3703 membase = pci_resource_start(pcidev, 1);
3703 srambase = pci_resource_start(pcidev, 2); 3704 srambase = pci_resource_start(pcidev, 2);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index e4b530ef757d..67b79a7592a9 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -386,6 +386,7 @@ void device_initialize(struct device *dev)
386 INIT_LIST_HEAD(&dev->node); 386 INIT_LIST_HEAD(&dev->node);
387 init_MUTEX(&dev->sem); 387 init_MUTEX(&dev->sem);
388 device_init_wakeup(dev, 0); 388 device_init_wakeup(dev, 0);
389 set_dev_node(dev, -1);
389} 390}
390 391
391#ifdef CONFIG_SYSFS_DEPRECATED 392#ifdef CONFIG_SYSFS_DEPRECATED
diff --git a/drivers/base/dmapool.c b/drivers/base/dmapool.c
index b2efbd4cf710..dbe0735f8c9e 100644
--- a/drivers/base/dmapool.c
+++ b/drivers/base/dmapool.c
@@ -126,7 +126,7 @@ dma_pool_create (const char *name, struct device *dev,
126 } else if (allocation < size) 126 } else if (allocation < size)
127 return NULL; 127 return NULL;
128 128
129 if (!(retval = kmalloc (sizeof *retval, SLAB_KERNEL))) 129 if (!(retval = kmalloc (sizeof *retval, GFP_KERNEL)))
130 return retval; 130 return retval;
131 131
132 strlcpy (retval->name, name, sizeof retval->name); 132 strlcpy (retval->name, name, sizeof retval->name);
@@ -297,7 +297,7 @@ restart:
297 } 297 }
298 } 298 }
299 } 299 }
300 if (!(page = pool_alloc_page (pool, SLAB_ATOMIC))) { 300 if (!(page = pool_alloc_page (pool, GFP_ATOMIC))) {
301 if (mem_flags & __GFP_WAIT) { 301 if (mem_flags & __GFP_WAIT) {
302 DECLARE_WAITQUEUE (wait, current); 302 DECLARE_WAITQUEUE (wait, current);
303 303
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index c6b7d9c4b651..74b96795d2f5 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -290,9 +290,8 @@ static CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL);
290 290
291static int block_size_init(void) 291static int block_size_init(void)
292{ 292{
293 sysfs_create_file(&memory_sysdev_class.kset.kobj, 293 return sysfs_create_file(&memory_sysdev_class.kset.kobj,
294 &class_attr_block_size_bytes.attr); 294 &class_attr_block_size_bytes.attr);
295 return 0;
296} 295}
297 296
298/* 297/*
@@ -323,12 +322,14 @@ static CLASS_ATTR(probe, 0700, NULL, memory_probe_store);
323 322
324static int memory_probe_init(void) 323static int memory_probe_init(void)
325{ 324{
326 sysfs_create_file(&memory_sysdev_class.kset.kobj, 325 return sysfs_create_file(&memory_sysdev_class.kset.kobj,
327 &class_attr_probe.attr); 326 &class_attr_probe.attr);
328 return 0;
329} 327}
330#else 328#else
331#define memory_probe_init(...) do {} while (0) 329static inline int memory_probe_init(void)
330{
331 return 0;
332}
332#endif 333#endif
333 334
334/* 335/*
@@ -431,9 +432,12 @@ int __init memory_dev_init(void)
431{ 432{
432 unsigned int i; 433 unsigned int i;
433 int ret; 434 int ret;
435 int err;
434 436
435 memory_sysdev_class.kset.uevent_ops = &memory_uevent_ops; 437 memory_sysdev_class.kset.uevent_ops = &memory_uevent_ops;
436 ret = sysdev_class_register(&memory_sysdev_class); 438 ret = sysdev_class_register(&memory_sysdev_class);
439 if (ret)
440 goto out;
437 441
438 /* 442 /*
439 * Create entries for memory sections that were found 443 * Create entries for memory sections that were found
@@ -442,11 +446,19 @@ int __init memory_dev_init(void)
442 for (i = 0; i < NR_MEM_SECTIONS; i++) { 446 for (i = 0; i < NR_MEM_SECTIONS; i++) {
443 if (!valid_section_nr(i)) 447 if (!valid_section_nr(i))
444 continue; 448 continue;
445 add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 0); 449 err = add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 0);
450 if (!ret)
451 ret = err;
446 } 452 }
447 453
448 memory_probe_init(); 454 err = memory_probe_init();
449 block_size_init(); 455 if (!ret)
450 456 ret = err;
457 err = block_size_init();
458 if (!ret)
459 ret = err;
460out:
461 if (ret)
462 printk(KERN_ERR "%s() failed: %d\n", __FUNCTION__, ret);
451 return ret; 463 return ret;
452} 464}
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index 3d12b85b0962..067a9e8bc377 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -108,7 +108,6 @@ static int __cpuinit topology_add_dev(unsigned int cpu)
108 return rc; 108 return rc;
109} 109}
110 110
111#ifdef CONFIG_HOTPLUG_CPU
112static void __cpuinit topology_remove_dev(unsigned int cpu) 111static void __cpuinit topology_remove_dev(unsigned int cpu)
113{ 112{
114 struct sys_device *sys_dev = get_cpu_sysdev(cpu); 113 struct sys_device *sys_dev = get_cpu_sysdev(cpu);
@@ -136,7 +135,6 @@ static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
136 } 135 }
137 return rc ? NOTIFY_BAD : NOTIFY_OK; 136 return rc ? NOTIFY_BAD : NOTIFY_OK;
138} 137}
139#endif
140 138
141static int __cpuinit topology_sysfs_init(void) 139static int __cpuinit topology_sysfs_init(void)
142{ 140{
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 742d07403101..8d81a3a64c07 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -324,13 +324,13 @@ static boolean DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
324 Command->Next = Controller->FreeCommands; 324 Command->Next = Controller->FreeCommands;
325 Controller->FreeCommands = Command; 325 Controller->FreeCommands = Command;
326 Controller->Commands[CommandIdentifier-1] = Command; 326 Controller->Commands[CommandIdentifier-1] = Command;
327 ScatterGatherCPU = pci_pool_alloc(ScatterGatherPool, SLAB_ATOMIC, 327 ScatterGatherCPU = pci_pool_alloc(ScatterGatherPool, GFP_ATOMIC,
328 &ScatterGatherDMA); 328 &ScatterGatherDMA);
329 if (ScatterGatherCPU == NULL) 329 if (ScatterGatherCPU == NULL)
330 return DAC960_Failure(Controller, "AUXILIARY STRUCTURE CREATION"); 330 return DAC960_Failure(Controller, "AUXILIARY STRUCTURE CREATION");
331 331
332 if (RequestSensePool != NULL) { 332 if (RequestSensePool != NULL) {
333 RequestSenseCPU = pci_pool_alloc(RequestSensePool, SLAB_ATOMIC, 333 RequestSenseCPU = pci_pool_alloc(RequestSensePool, GFP_ATOMIC,
334 &RequestSenseDMA); 334 &RequestSenseDMA);
335 if (RequestSenseCPU == NULL) { 335 if (RequestSenseCPU == NULL) {
336 pci_pool_free(ScatterGatherPool, ScatterGatherCPU, 336 pci_pool_free(ScatterGatherPool, ScatterGatherCPU,
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 17dc22282e14..432c17e1e0e6 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -168,7 +168,8 @@ config BLK_CPQ_CISS_DA
168 168
169config CISS_SCSI_TAPE 169config CISS_SCSI_TAPE
170 bool "SCSI tape drive support for Smart Array 5xxx" 170 bool "SCSI tape drive support for Smart Array 5xxx"
171 depends on BLK_CPQ_CISS_DA && SCSI && PROC_FS 171 depends on BLK_CPQ_CISS_DA && PROC_FS
172 depends on SCSI=y || SCSI=BLK_CPQ_CISS_DA
172 help 173 help
173 When enabled (Y), this option allows SCSI tape drives and SCSI medium 174 When enabled (Y), this option allows SCSI tape drives and SCSI medium
174 changers (tape robots) to be accessed via a Compaq 5xxx array 175 changers (tape robots) to be accessed via a Compaq 5xxx array
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index 6d111228cfac..2308e83e5f33 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -159,7 +159,7 @@ void aoecmd_work(struct aoedev *d);
159void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor); 159void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
160void aoecmd_ata_rsp(struct sk_buff *); 160void aoecmd_ata_rsp(struct sk_buff *);
161void aoecmd_cfg_rsp(struct sk_buff *); 161void aoecmd_cfg_rsp(struct sk_buff *);
162void aoecmd_sleepwork(void *vp); 162void aoecmd_sleepwork(struct work_struct *);
163struct sk_buff *new_skb(ulong); 163struct sk_buff *new_skb(ulong);
164 164
165int aoedev_init(void); 165int aoedev_init(void);
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index aa25f8b09fe3..478489c568a4 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -12,7 +12,7 @@
12#include <linux/netdevice.h> 12#include <linux/netdevice.h>
13#include "aoe.h" 13#include "aoe.h"
14 14
15static kmem_cache_t *buf_pool_cache; 15static struct kmem_cache *buf_pool_cache;
16 16
17static ssize_t aoedisk_show_state(struct gendisk * disk, char *page) 17static ssize_t aoedisk_show_state(struct gendisk * disk, char *page)
18{ 18{
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 8a13b1af8bab..97f7f535f412 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -408,9 +408,9 @@ rexmit_timer(ulong vp)
408/* this function performs work that has been deferred until sleeping is OK 408/* this function performs work that has been deferred until sleeping is OK
409 */ 409 */
410void 410void
411aoecmd_sleepwork(void *vp) 411aoecmd_sleepwork(struct work_struct *work)
412{ 412{
413 struct aoedev *d = (struct aoedev *) vp; 413 struct aoedev *d = container_of(work, struct aoedev, work);
414 414
415 if (d->flags & DEVFL_GDALLOC) 415 if (d->flags & DEVFL_GDALLOC)
416 aoeblk_gdalloc(d); 416 aoeblk_gdalloc(d);
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index 6125921bbec4..05a97197c918 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -88,7 +88,7 @@ aoedev_newdev(ulong nframes)
88 kfree(d); 88 kfree(d);
89 return NULL; 89 return NULL;
90 } 90 }
91 INIT_WORK(&d->work, aoecmd_sleepwork, d); 91 INIT_WORK(&d->work, aoecmd_sleepwork);
92 spin_lock_init(&d->lock); 92 spin_lock_init(&d->lock);
93 init_timer(&d->timer); 93 init_timer(&d->timer);
94 d->timer.data = (ulong) d; 94 d->timer.data = (ulong) d;
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 4105c3bf3476..892e092afe9a 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -47,14 +47,15 @@
47#include <linux/completion.h> 47#include <linux/completion.h>
48 48
49#define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin)) 49#define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin))
50#define DRIVER_NAME "HP CISS Driver (v 3.6.10)" 50#define DRIVER_NAME "HP CISS Driver (v 3.6.14)"
51#define DRIVER_VERSION CCISS_DRIVER_VERSION(3,6,10) 51#define DRIVER_VERSION CCISS_DRIVER_VERSION(3,6,14)
52 52
53/* Embedded module documentation macros - see modules.h */ 53/* Embedded module documentation macros - see modules.h */
54MODULE_AUTHOR("Hewlett-Packard Company"); 54MODULE_AUTHOR("Hewlett-Packard Company");
55MODULE_DESCRIPTION("Driver for HP Controller SA5xxx SA6xxx version 3.6.10"); 55MODULE_DESCRIPTION("Driver for HP Controller SA5xxx SA6xxx version 3.6.14");
56MODULE_SUPPORTED_DEVICE("HP SA5i SA5i+ SA532 SA5300 SA5312 SA641 SA642 SA6400" 56MODULE_SUPPORTED_DEVICE("HP SA5i SA5i+ SA532 SA5300 SA5312 SA641 SA642 SA6400"
57 " SA6i P600 P800 P400 P400i E200 E200i E500"); 57 " SA6i P600 P800 P400 P400i E200 E200i E500");
58MODULE_VERSION("3.6.14");
58MODULE_LICENSE("GPL"); 59MODULE_LICENSE("GPL");
59 60
60#include "cciss_cmd.h" 61#include "cciss_cmd.h"
@@ -81,7 +82,9 @@ static const struct pci_device_id cciss_pci_device_id[] = {
81 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3213}, 82 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3213},
82 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3214}, 83 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3214},
83 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3215}, 84 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3215},
84 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x3233}, 85 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x3237},
86 {PCI_VENDOR_ID_HP, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
87 PCI_CLASS_STORAGE_RAID << 8, 0xffff << 8, 0},
85 {0,} 88 {0,}
86}; 89};
87 90
@@ -90,27 +93,29 @@ MODULE_DEVICE_TABLE(pci, cciss_pci_device_id);
90/* board_id = Subsystem Device ID & Vendor ID 93/* board_id = Subsystem Device ID & Vendor ID
91 * product = Marketing Name for the board 94 * product = Marketing Name for the board
92 * access = Address of the struct of function pointers 95 * access = Address of the struct of function pointers
96 * nr_cmds = Number of commands supported by controller
93 */ 97 */
94static struct board_type products[] = { 98static struct board_type products[] = {
95 {0x40700E11, "Smart Array 5300", &SA5_access}, 99 {0x40700E11, "Smart Array 5300", &SA5_access, 512},
96 {0x40800E11, "Smart Array 5i", &SA5B_access}, 100 {0x40800E11, "Smart Array 5i", &SA5B_access, 512},
97 {0x40820E11, "Smart Array 532", &SA5B_access}, 101 {0x40820E11, "Smart Array 532", &SA5B_access, 512},
98 {0x40830E11, "Smart Array 5312", &SA5B_access}, 102 {0x40830E11, "Smart Array 5312", &SA5B_access, 512},
99 {0x409A0E11, "Smart Array 641", &SA5_access}, 103 {0x409A0E11, "Smart Array 641", &SA5_access, 512},
100 {0x409B0E11, "Smart Array 642", &SA5_access}, 104 {0x409B0E11, "Smart Array 642", &SA5_access, 512},
101 {0x409C0E11, "Smart Array 6400", &SA5_access}, 105 {0x409C0E11, "Smart Array 6400", &SA5_access, 512},
102 {0x409D0E11, "Smart Array 6400 EM", &SA5_access}, 106 {0x409D0E11, "Smart Array 6400 EM", &SA5_access, 512},
103 {0x40910E11, "Smart Array 6i", &SA5_access}, 107 {0x40910E11, "Smart Array 6i", &SA5_access, 512},
104 {0x3225103C, "Smart Array P600", &SA5_access}, 108 {0x3225103C, "Smart Array P600", &SA5_access, 512},
105 {0x3223103C, "Smart Array P800", &SA5_access}, 109 {0x3223103C, "Smart Array P800", &SA5_access, 512},
106 {0x3234103C, "Smart Array P400", &SA5_access}, 110 {0x3234103C, "Smart Array P400", &SA5_access, 512},
107 {0x3235103C, "Smart Array P400i", &SA5_access}, 111 {0x3235103C, "Smart Array P400i", &SA5_access, 512},
108 {0x3211103C, "Smart Array E200i", &SA5_access}, 112 {0x3211103C, "Smart Array E200i", &SA5_access, 120},
109 {0x3212103C, "Smart Array E200", &SA5_access}, 113 {0x3212103C, "Smart Array E200", &SA5_access, 120},
110 {0x3213103C, "Smart Array E200i", &SA5_access}, 114 {0x3213103C, "Smart Array E200i", &SA5_access, 120},
111 {0x3214103C, "Smart Array E200i", &SA5_access}, 115 {0x3214103C, "Smart Array E200i", &SA5_access, 120},
112 {0x3215103C, "Smart Array E200i", &SA5_access}, 116 {0x3215103C, "Smart Array E200i", &SA5_access, 120},
113 {0x3233103C, "Smart Array E500", &SA5_access}, 117 {0x3237103C, "Smart Array E500", &SA5_access, 512},
118 {0xFFFF103C, "Unknown Smart Array", &SA5_access, 120},
114}; 119};
115 120
116/* How long to wait (in milliseconds) for board to go into simple mode */ 121/* How long to wait (in milliseconds) for board to go into simple mode */
@@ -121,7 +126,6 @@ static struct board_type products[] = {
121#define MAX_CMD_RETRIES 3 126#define MAX_CMD_RETRIES 3
122 127
123#define READ_AHEAD 1024 128#define READ_AHEAD 1024
124#define NR_CMDS 384 /* #commands that can be outstanding */
125#define MAX_CTLR 32 129#define MAX_CTLR 32
126 130
127/* Originally cciss driver only supports 8 major numbers */ 131/* Originally cciss driver only supports 8 major numbers */
@@ -137,7 +141,6 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
137 unsigned int cmd, unsigned long arg); 141 unsigned int cmd, unsigned long arg);
138static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo); 142static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo);
139 143
140static int revalidate_allvol(ctlr_info_t *host);
141static int cciss_revalidate(struct gendisk *disk); 144static int cciss_revalidate(struct gendisk *disk);
142static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk); 145static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk);
143static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, 146static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
@@ -265,6 +268,7 @@ static int cciss_proc_get_info(char *buffer, char **start, off_t offset,
265 "Firmware Version: %c%c%c%c\n" 268 "Firmware Version: %c%c%c%c\n"
266 "IRQ: %d\n" 269 "IRQ: %d\n"
267 "Logical drives: %d\n" 270 "Logical drives: %d\n"
271 "Max sectors: %d\n"
268 "Current Q depth: %d\n" 272 "Current Q depth: %d\n"
269 "Current # commands on controller: %d\n" 273 "Current # commands on controller: %d\n"
270 "Max Q depth since init: %d\n" 274 "Max Q depth since init: %d\n"
@@ -275,7 +279,9 @@ static int cciss_proc_get_info(char *buffer, char **start, off_t offset,
275 (unsigned long)h->board_id, 279 (unsigned long)h->board_id,
276 h->firm_ver[0], h->firm_ver[1], h->firm_ver[2], 280 h->firm_ver[0], h->firm_ver[1], h->firm_ver[2],
277 h->firm_ver[3], (unsigned int)h->intr[SIMPLE_MODE_INT], 281 h->firm_ver[3], (unsigned int)h->intr[SIMPLE_MODE_INT],
278 h->num_luns, h->Qdepth, h->commands_outstanding, 282 h->num_luns,
283 h->cciss_max_sectors,
284 h->Qdepth, h->commands_outstanding,
279 h->maxQsinceinit, h->max_outstanding, h->maxSG); 285 h->maxQsinceinit, h->max_outstanding, h->maxSG);
280 286
281 pos += size; 287 pos += size;
@@ -400,8 +406,8 @@ static CommandList_struct *cmd_alloc(ctlr_info_t *h, int get_from_pool)
400 } else { /* get it out of the controllers pool */ 406 } else { /* get it out of the controllers pool */
401 407
402 do { 408 do {
403 i = find_first_zero_bit(h->cmd_pool_bits, NR_CMDS); 409 i = find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds);
404 if (i == NR_CMDS) 410 if (i == h->nr_cmds)
405 return NULL; 411 return NULL;
406 } while (test_and_set_bit 412 } while (test_and_set_bit
407 (i & (BITS_PER_LONG - 1), 413 (i & (BITS_PER_LONG - 1),
@@ -487,7 +493,7 @@ static int cciss_open(struct inode *inode, struct file *filep)
487 * but I'm already using way to many device nodes to claim another one 493 * but I'm already using way to many device nodes to claim another one
488 * for "raw controller". 494 * for "raw controller".
489 */ 495 */
490 if (drv->nr_blocks == 0) { 496 if (drv->heads == 0) {
491 if (iminor(inode) != 0) { /* not node 0? */ 497 if (iminor(inode) != 0) { /* not node 0? */
492 /* if not node 0 make sure it is a partition = 0 */ 498 /* if not node 0 make sure it is a partition = 0 */
493 if (iminor(inode) & 0x0f) { 499 if (iminor(inode) & 0x0f) {
@@ -850,9 +856,7 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
850 } 856 }
851 857
852 case CCISS_REVALIDVOLS: 858 case CCISS_REVALIDVOLS:
853 if (bdev != bdev->bd_contains || drv != host->drv) 859 return rebuild_lun_table(host, NULL);
854 return -ENXIO;
855 return revalidate_allvol(host);
856 860
857 case CCISS_GETLUNINFO:{ 861 case CCISS_GETLUNINFO:{
858 LogvolInfo_struct luninfo; 862 LogvolInfo_struct luninfo;
@@ -1152,75 +1156,6 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
1152 } 1156 }
1153} 1157}
1154 1158
1155/*
1156 * revalidate_allvol is for online array config utilities. After a
1157 * utility reconfigures the drives in the array, it can use this function
1158 * (through an ioctl) to make the driver zap any previous disk structs for
1159 * that controller and get new ones.
1160 *
1161 * Right now I'm using the getgeometry() function to do this, but this
1162 * function should probably be finer grained and allow you to revalidate one
1163 * particular logical volume (instead of all of them on a particular
1164 * controller).
1165 */
1166static int revalidate_allvol(ctlr_info_t *host)
1167{
1168 int ctlr = host->ctlr, i;
1169 unsigned long flags;
1170
1171 spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
1172 if (host->usage_count > 1) {
1173 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
1174 printk(KERN_WARNING "cciss: Device busy for volume"
1175 " revalidation (usage=%d)\n", host->usage_count);
1176 return -EBUSY;
1177 }
1178 host->usage_count++;
1179 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
1180
1181 for (i = 0; i < NWD; i++) {
1182 struct gendisk *disk = host->gendisk[i];
1183 if (disk) {
1184 request_queue_t *q = disk->queue;
1185
1186 if (disk->flags & GENHD_FL_UP)
1187 del_gendisk(disk);
1188 if (q)
1189 blk_cleanup_queue(q);
1190 }
1191 }
1192
1193 /*
1194 * Set the partition and block size structures for all volumes
1195 * on this controller to zero. We will reread all of this data
1196 */
1197 memset(host->drv, 0, sizeof(drive_info_struct)
1198 * CISS_MAX_LUN);
1199 /*
1200 * Tell the array controller not to give us any interrupts while
1201 * we check the new geometry. Then turn interrupts back on when
1202 * we're done.
1203 */
1204 host->access.set_intr_mask(host, CCISS_INTR_OFF);
1205 cciss_getgeometry(ctlr);
1206 host->access.set_intr_mask(host, CCISS_INTR_ON);
1207
1208 /* Loop through each real device */
1209 for (i = 0; i < NWD; i++) {
1210 struct gendisk *disk = host->gendisk[i];
1211 drive_info_struct *drv = &(host->drv[i]);
1212 /* we must register the controller even if no disks exist */
1213 /* this is for the online array utilities */
1214 if (!drv->heads && i)
1215 continue;
1216 blk_queue_hardsect_size(drv->queue, drv->block_size);
1217 set_capacity(disk, drv->nr_blocks);
1218 add_disk(disk);
1219 }
1220 host->usage_count--;
1221 return 0;
1222}
1223
1224static inline void complete_buffers(struct bio *bio, int status) 1159static inline void complete_buffers(struct bio *bio, int status)
1225{ 1160{
1226 while (bio) { 1161 while (bio) {
@@ -1243,7 +1178,7 @@ static void cciss_check_queues(ctlr_info_t *h)
1243 * in case the interrupt we serviced was from an ioctl and did not 1178 * in case the interrupt we serviced was from an ioctl and did not
1244 * free any new commands. 1179 * free any new commands.
1245 */ 1180 */
1246 if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS) 1181 if ((find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds)) == h->nr_cmds)
1247 return; 1182 return;
1248 1183
1249 /* We have room on the queue for more commands. Now we need to queue 1184 /* We have room on the queue for more commands. Now we need to queue
@@ -1262,7 +1197,7 @@ static void cciss_check_queues(ctlr_info_t *h)
1262 /* check to see if we have maxed out the number of commands 1197 /* check to see if we have maxed out the number of commands
1263 * that can be placed on the queue. 1198 * that can be placed on the queue.
1264 */ 1199 */
1265 if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS) { 1200 if ((find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds)) == h->nr_cmds) {
1266 if (curr_queue == start_queue) { 1201 if (curr_queue == start_queue) {
1267 h->next_to_run = 1202 h->next_to_run =
1268 (start_queue + 1) % (h->highest_lun + 1); 1203 (start_queue + 1) % (h->highest_lun + 1);
@@ -1380,6 +1315,11 @@ static void cciss_update_drive_info(int ctlr, int drv_index)
1380 /* if it's the controller it's already added */ 1315 /* if it's the controller it's already added */
1381 if (drv_index) { 1316 if (drv_index) {
1382 disk->queue = blk_init_queue(do_cciss_request, &h->lock); 1317 disk->queue = blk_init_queue(do_cciss_request, &h->lock);
1318 sprintf(disk->disk_name, "cciss/c%dd%d", ctlr, drv_index);
1319 disk->major = h->major;
1320 disk->first_minor = drv_index << NWD_SHIFT;
1321 disk->fops = &cciss_fops;
1322 disk->private_data = &h->drv[drv_index];
1383 1323
1384 /* Set up queue information */ 1324 /* Set up queue information */
1385 disk->queue->backing_dev_info.ra_pages = READ_AHEAD; 1325 disk->queue->backing_dev_info.ra_pages = READ_AHEAD;
@@ -1391,7 +1331,7 @@ static void cciss_update_drive_info(int ctlr, int drv_index)
1391 /* This is a limit in the driver and could be eliminated. */ 1331 /* This is a limit in the driver and could be eliminated. */
1392 blk_queue_max_phys_segments(disk->queue, MAXSGENTRIES); 1332 blk_queue_max_phys_segments(disk->queue, MAXSGENTRIES);
1393 1333
1394 blk_queue_max_sectors(disk->queue, 512); 1334 blk_queue_max_sectors(disk->queue, h->cciss_max_sectors);
1395 1335
1396 blk_queue_softirq_done(disk->queue, cciss_softirq_done); 1336 blk_queue_softirq_done(disk->queue, cciss_softirq_done);
1397 1337
@@ -1458,11 +1398,6 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
1458 1398
1459 /* Set busy_configuring flag for this operation */ 1399 /* Set busy_configuring flag for this operation */
1460 spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); 1400 spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags);
1461 if (h->num_luns >= CISS_MAX_LUN) {
1462 spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
1463 return -EINVAL;
1464 }
1465
1466 if (h->busy_configuring) { 1401 if (h->busy_configuring) {
1467 spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); 1402 spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
1468 return -EBUSY; 1403 return -EBUSY;
@@ -1495,17 +1430,8 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
1495 0, 0, TYPE_CMD); 1430 0, 0, TYPE_CMD);
1496 1431
1497 if (return_code == IO_OK) { 1432 if (return_code == IO_OK) {
1498 listlength |= 1433 listlength =
1499 (0xff & (unsigned int)(ld_buff->LUNListLength[0])) 1434 be32_to_cpu(*(__u32 *) ld_buff->LUNListLength);
1500 << 24;
1501 listlength |=
1502 (0xff & (unsigned int)(ld_buff->LUNListLength[1]))
1503 << 16;
1504 listlength |=
1505 (0xff & (unsigned int)(ld_buff->LUNListLength[2]))
1506 << 8;
1507 listlength |=
1508 0xff & (unsigned int)(ld_buff->LUNListLength[3]);
1509 } else { /* reading number of logical volumes failed */ 1435 } else { /* reading number of logical volumes failed */
1510 printk(KERN_WARNING "cciss: report logical volume" 1436 printk(KERN_WARNING "cciss: report logical volume"
1511 " command failed\n"); 1437 " command failed\n");
@@ -1556,6 +1482,14 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
1556 if (drv_index == -1) 1482 if (drv_index == -1)
1557 goto freeret; 1483 goto freeret;
1558 1484
1485 /*Check if the gendisk needs to be allocated */
1486 if (!h->gendisk[drv_index]){
1487 h->gendisk[drv_index] = alloc_disk(1 << NWD_SHIFT);
1488 if (!h->gendisk[drv_index]){
1489 printk(KERN_ERR "cciss: could not allocate new disk %d\n", drv_index);
1490 goto mem_msg;
1491 }
1492 }
1559 } 1493 }
1560 h->drv[drv_index].LunID = lunid; 1494 h->drv[drv_index].LunID = lunid;
1561 cciss_update_drive_info(ctlr, drv_index); 1495 cciss_update_drive_info(ctlr, drv_index);
@@ -1593,6 +1527,7 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
1593static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, 1527static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
1594 int clear_all) 1528 int clear_all)
1595{ 1529{
1530 int i;
1596 ctlr_info_t *h = get_host(disk); 1531 ctlr_info_t *h = get_host(disk);
1597 1532
1598 if (!capable(CAP_SYS_RAWIO)) 1533 if (!capable(CAP_SYS_RAWIO))
@@ -1616,9 +1551,35 @@ static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
1616 del_gendisk(disk); 1551 del_gendisk(disk);
1617 if (q) { 1552 if (q) {
1618 blk_cleanup_queue(q); 1553 blk_cleanup_queue(q);
1554 /* Set drv->queue to NULL so that we do not try
1555 * to call blk_start_queue on this queue in the
1556 * interrupt handler
1557 */
1619 drv->queue = NULL; 1558 drv->queue = NULL;
1620 } 1559 }
1560 /* If clear_all is set then we are deleting the logical
1561 * drive, not just refreshing its info. For drives
1562 * other than disk 0 we will call put_disk. We do not
1563 * do this for disk 0 as we need it to be able to
1564 * configure the controller.
1565 */
1566 if (clear_all){
1567 /* This isn't pretty, but we need to find the
1568 * disk in our array and NULL our the pointer.
1569 * This is so that we will call alloc_disk if
1570 * this index is used again later.
1571 */
1572 for (i=0; i < CISS_MAX_LUN; i++){
1573 if(h->gendisk[i] == disk){
1574 h->gendisk[i] = NULL;
1575 break;
1576 }
1577 }
1578 put_disk(disk);
1579 }
1621 } 1580 }
1581 } else {
1582 set_capacity(disk, 0);
1622 } 1583 }
1623 1584
1624 --h->num_luns; 1585 --h->num_luns;
@@ -2136,7 +2097,7 @@ static int add_sendcmd_reject(__u8 cmd, int ctlr, unsigned long complete)
2136 2097
2137 /* We've sent down an abort or reset, but something else 2098 /* We've sent down an abort or reset, but something else
2138 has completed */ 2099 has completed */
2139 if (srl->ncompletions >= (NR_CMDS + 2)) { 2100 if (srl->ncompletions >= (hba[ctlr]->nr_cmds + 2)) {
2140 /* Uh oh. No room to save it for later... */ 2101 /* Uh oh. No room to save it for later... */
2141 printk(KERN_WARNING "cciss%d: Sendcmd: Invalid command addr, " 2102 printk(KERN_WARNING "cciss%d: Sendcmd: Invalid command addr, "
2142 "reject list overflow, command lost!\n", ctlr); 2103 "reject list overflow, command lost!\n", ctlr);
@@ -2673,7 +2634,7 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id)
2673 a1 = a; 2634 a1 = a;
2674 if ((a & 0x04)) { 2635 if ((a & 0x04)) {
2675 a2 = (a >> 3); 2636 a2 = (a >> 3);
2676 if (a2 >= NR_CMDS) { 2637 if (a2 >= h->nr_cmds) {
2677 printk(KERN_WARNING 2638 printk(KERN_WARNING
2678 "cciss: controller cciss%d failed, stopping.\n", 2639 "cciss: controller cciss%d failed, stopping.\n",
2679 h->ctlr); 2640 h->ctlr);
@@ -2827,23 +2788,21 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *c,
2827 if (err > 0) { 2788 if (err > 0) {
2828 printk(KERN_WARNING "cciss: only %d MSI-X vectors " 2789 printk(KERN_WARNING "cciss: only %d MSI-X vectors "
2829 "available\n", err); 2790 "available\n", err);
2791 goto default_int_mode;
2830 } else { 2792 } else {
2831 printk(KERN_WARNING "cciss: MSI-X init failed %d\n", 2793 printk(KERN_WARNING "cciss: MSI-X init failed %d\n",
2832 err); 2794 err);
2795 goto default_int_mode;
2833 } 2796 }
2834 } 2797 }
2835 if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) { 2798 if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) {
2836 if (!pci_enable_msi(pdev)) { 2799 if (!pci_enable_msi(pdev)) {
2837 c->intr[SIMPLE_MODE_INT] = pdev->irq;
2838 c->msi_vector = 1; 2800 c->msi_vector = 1;
2839 return;
2840 } else { 2801 } else {
2841 printk(KERN_WARNING "cciss: MSI init failed\n"); 2802 printk(KERN_WARNING "cciss: MSI init failed\n");
2842 c->intr[SIMPLE_MODE_INT] = pdev->irq;
2843 return;
2844 } 2803 }
2845 } 2804 }
2846 default_int_mode: 2805default_int_mode:
2847#endif /* CONFIG_PCI_MSI */ 2806#endif /* CONFIG_PCI_MSI */
2848 /* if we get here we're going to use the default interrupt mode */ 2807 /* if we get here we're going to use the default interrupt mode */
2849 c->intr[SIMPLE_MODE_INT] = pdev->irq; 2808 c->intr[SIMPLE_MODE_INT] = pdev->irq;
@@ -2956,16 +2915,10 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2956 if (board_id == products[i].board_id) { 2915 if (board_id == products[i].board_id) {
2957 c->product_name = products[i].product_name; 2916 c->product_name = products[i].product_name;
2958 c->access = *(products[i].access); 2917 c->access = *(products[i].access);
2918 c->nr_cmds = products[i].nr_cmds;
2959 break; 2919 break;
2960 } 2920 }
2961 } 2921 }
2962 if (i == ARRAY_SIZE(products)) {
2963 printk(KERN_WARNING "cciss: Sorry, I don't know how"
2964 " to access the Smart Array controller %08lx\n",
2965 (unsigned long)board_id);
2966 err = -ENODEV;
2967 goto err_out_free_res;
2968 }
2969 if ((readb(&c->cfgtable->Signature[0]) != 'C') || 2922 if ((readb(&c->cfgtable->Signature[0]) != 'C') ||
2970 (readb(&c->cfgtable->Signature[1]) != 'I') || 2923 (readb(&c->cfgtable->Signature[1]) != 'I') ||
2971 (readb(&c->cfgtable->Signature[2]) != 'S') || 2924 (readb(&c->cfgtable->Signature[2]) != 'S') ||
@@ -2974,6 +2927,27 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2974 err = -ENODEV; 2927 err = -ENODEV;
2975 goto err_out_free_res; 2928 goto err_out_free_res;
2976 } 2929 }
2930 /* We didn't find the controller in our list. We know the
2931 * signature is valid. If it's an HP device let's try to
2932 * bind to the device and fire it up. Otherwise we bail.
2933 */
2934 if (i == ARRAY_SIZE(products)) {
2935 if (subsystem_vendor_id == PCI_VENDOR_ID_HP) {
2936 c->product_name = products[i-1].product_name;
2937 c->access = *(products[i-1].access);
2938 c->nr_cmds = products[i-1].nr_cmds;
2939 printk(KERN_WARNING "cciss: This is an unknown "
2940 "Smart Array controller.\n"
2941 "cciss: Please update to the latest driver "
2942 "available from www.hp.com.\n");
2943 } else {
2944 printk(KERN_WARNING "cciss: Sorry, I don't know how"
2945 " to access the Smart Array controller %08lx\n"
2946 , (unsigned long)board_id);
2947 err = -ENODEV;
2948 goto err_out_free_res;
2949 }
2950 }
2977#ifdef CONFIG_X86 2951#ifdef CONFIG_X86
2978 { 2952 {
2979 /* Need to enable prefetch in the SCSI core for 6400 in x86 */ 2953 /* Need to enable prefetch in the SCSI core for 6400 in x86 */
@@ -2984,6 +2958,17 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2984 } 2958 }
2985#endif 2959#endif
2986 2960
2961 /* Disabling DMA prefetch for the P600
2962 * An ASIC bug may result in a prefetch beyond
2963 * physical memory.
2964 */
2965 if(board_id == 0x3225103C) {
2966 __u32 dma_prefetch;
2967 dma_prefetch = readl(c->vaddr + I2O_DMA1_CFG);
2968 dma_prefetch |= 0x8000;
2969 writel(dma_prefetch, c->vaddr + I2O_DMA1_CFG);
2970 }
2971
2987#ifdef CCISS_DEBUG 2972#ifdef CCISS_DEBUG
2988 printk("Trying to put board into Simple mode\n"); 2973 printk("Trying to put board into Simple mode\n");
2989#endif /* CCISS_DEBUG */ 2974#endif /* CCISS_DEBUG */
@@ -3158,13 +3143,7 @@ geo_inq:
3158/* Returns -1 if no free entries are left. */ 3143/* Returns -1 if no free entries are left. */
3159static int alloc_cciss_hba(void) 3144static int alloc_cciss_hba(void)
3160{ 3145{
3161 struct gendisk *disk[NWD]; 3146 int i;
3162 int i, n;
3163 for (n = 0; n < NWD; n++) {
3164 disk[n] = alloc_disk(1 << NWD_SHIFT);
3165 if (!disk[n])
3166 goto out;
3167 }
3168 3147
3169 for (i = 0; i < MAX_CTLR; i++) { 3148 for (i = 0; i < MAX_CTLR; i++) {
3170 if (!hba[i]) { 3149 if (!hba[i]) {
@@ -3172,20 +3151,18 @@ static int alloc_cciss_hba(void)
3172 p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL); 3151 p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL);
3173 if (!p) 3152 if (!p)
3174 goto Enomem; 3153 goto Enomem;
3175 for (n = 0; n < NWD; n++) 3154 p->gendisk[0] = alloc_disk(1 << NWD_SHIFT);
3176 p->gendisk[n] = disk[n]; 3155 if (!p->gendisk[0])
3156 goto Enomem;
3177 hba[i] = p; 3157 hba[i] = p;
3178 return i; 3158 return i;
3179 } 3159 }
3180 } 3160 }
3181 printk(KERN_WARNING "cciss: This driver supports a maximum" 3161 printk(KERN_WARNING "cciss: This driver supports a maximum"
3182 " of %d controllers.\n", MAX_CTLR); 3162 " of %d controllers.\n", MAX_CTLR);
3183 goto out; 3163 return -1;
3184 Enomem: 3164Enomem:
3185 printk(KERN_ERR "cciss: out of memory.\n"); 3165 printk(KERN_ERR "cciss: out of memory.\n");
3186 out:
3187 while (n--)
3188 put_disk(disk[n]);
3189 return -1; 3166 return -1;
3190} 3167}
3191 3168
@@ -3195,7 +3172,7 @@ static void free_hba(int i)
3195 int n; 3172 int n;
3196 3173
3197 hba[i] = NULL; 3174 hba[i] = NULL;
3198 for (n = 0; n < NWD; n++) 3175 for (n = 0; n < CISS_MAX_LUN; n++)
3199 put_disk(p->gendisk[n]); 3176 put_disk(p->gendisk[n]);
3200 kfree(p); 3177 kfree(p);
3201} 3178}
@@ -3208,9 +3185,8 @@ static void free_hba(int i)
3208static int __devinit cciss_init_one(struct pci_dev *pdev, 3185static int __devinit cciss_init_one(struct pci_dev *pdev,
3209 const struct pci_device_id *ent) 3186 const struct pci_device_id *ent)
3210{ 3187{
3211 request_queue_t *q;
3212 int i; 3188 int i;
3213 int j; 3189 int j = 0;
3214 int rc; 3190 int rc;
3215 int dac; 3191 int dac;
3216 3192
@@ -3269,15 +3245,15 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3269 hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not"); 3245 hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not");
3270 3246
3271 hba[i]->cmd_pool_bits = 3247 hba[i]->cmd_pool_bits =
3272 kmalloc(((NR_CMDS + BITS_PER_LONG - 3248 kmalloc(((hba[i]->nr_cmds + BITS_PER_LONG -
3273 1) / BITS_PER_LONG) * sizeof(unsigned long), GFP_KERNEL); 3249 1) / BITS_PER_LONG) * sizeof(unsigned long), GFP_KERNEL);
3274 hba[i]->cmd_pool = (CommandList_struct *) 3250 hba[i]->cmd_pool = (CommandList_struct *)
3275 pci_alloc_consistent(hba[i]->pdev, 3251 pci_alloc_consistent(hba[i]->pdev,
3276 NR_CMDS * sizeof(CommandList_struct), 3252 hba[i]->nr_cmds * sizeof(CommandList_struct),
3277 &(hba[i]->cmd_pool_dhandle)); 3253 &(hba[i]->cmd_pool_dhandle));
3278 hba[i]->errinfo_pool = (ErrorInfo_struct *) 3254 hba[i]->errinfo_pool = (ErrorInfo_struct *)
3279 pci_alloc_consistent(hba[i]->pdev, 3255 pci_alloc_consistent(hba[i]->pdev,
3280 NR_CMDS * sizeof(ErrorInfo_struct), 3256 hba[i]->nr_cmds * sizeof(ErrorInfo_struct),
3281 &(hba[i]->errinfo_pool_dhandle)); 3257 &(hba[i]->errinfo_pool_dhandle));
3282 if ((hba[i]->cmd_pool_bits == NULL) 3258 if ((hba[i]->cmd_pool_bits == NULL)
3283 || (hba[i]->cmd_pool == NULL) 3259 || (hba[i]->cmd_pool == NULL)
@@ -3288,7 +3264,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3288#ifdef CONFIG_CISS_SCSI_TAPE 3264#ifdef CONFIG_CISS_SCSI_TAPE
3289 hba[i]->scsi_rejects.complete = 3265 hba[i]->scsi_rejects.complete =
3290 kmalloc(sizeof(hba[i]->scsi_rejects.complete[0]) * 3266 kmalloc(sizeof(hba[i]->scsi_rejects.complete[0]) *
3291 (NR_CMDS + 5), GFP_KERNEL); 3267 (hba[i]->nr_cmds + 5), GFP_KERNEL);
3292 if (hba[i]->scsi_rejects.complete == NULL) { 3268 if (hba[i]->scsi_rejects.complete == NULL) {
3293 printk(KERN_ERR "cciss: out of memory"); 3269 printk(KERN_ERR "cciss: out of memory");
3294 goto clean4; 3270 goto clean4;
@@ -3302,7 +3278,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3302 /* command and error info recs zeroed out before 3278 /* command and error info recs zeroed out before
3303 they are used */ 3279 they are used */
3304 memset(hba[i]->cmd_pool_bits, 0, 3280 memset(hba[i]->cmd_pool_bits, 0,
3305 ((NR_CMDS + BITS_PER_LONG - 3281 ((hba[i]->nr_cmds + BITS_PER_LONG -
3306 1) / BITS_PER_LONG) * sizeof(unsigned long)); 3282 1) / BITS_PER_LONG) * sizeof(unsigned long));
3307 3283
3308#ifdef CCISS_DEBUG 3284#ifdef CCISS_DEBUG
@@ -3317,18 +3293,34 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3317 hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_ON); 3293 hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_ON);
3318 3294
3319 cciss_procinit(i); 3295 cciss_procinit(i);
3296
3297 hba[i]->cciss_max_sectors = 2048;
3298
3320 hba[i]->busy_initializing = 0; 3299 hba[i]->busy_initializing = 0;
3321 3300
3322 for (j = 0; j < NWD; j++) { /* mfm */ 3301 do {
3323 drive_info_struct *drv = &(hba[i]->drv[j]); 3302 drive_info_struct *drv = &(hba[i]->drv[j]);
3324 struct gendisk *disk = hba[i]->gendisk[j]; 3303 struct gendisk *disk = hba[i]->gendisk[j];
3304 request_queue_t *q;
3305
3306 /* Check if the disk was allocated already */
3307 if (!disk){
3308 hba[i]->gendisk[j] = alloc_disk(1 << NWD_SHIFT);
3309 disk = hba[i]->gendisk[j];
3310 }
3311
3312 /* Check that the disk was able to be allocated */
3313 if (!disk) {
3314 printk(KERN_ERR "cciss: unable to allocate memory for disk %d\n", j);
3315 goto clean4;
3316 }
3325 3317
3326 q = blk_init_queue(do_cciss_request, &hba[i]->lock); 3318 q = blk_init_queue(do_cciss_request, &hba[i]->lock);
3327 if (!q) { 3319 if (!q) {
3328 printk(KERN_ERR 3320 printk(KERN_ERR
3329 "cciss: unable to allocate queue for disk %d\n", 3321 "cciss: unable to allocate queue for disk %d\n",
3330 j); 3322 j);
3331 break; 3323 goto clean4;
3332 } 3324 }
3333 drv->queue = q; 3325 drv->queue = q;
3334 3326
@@ -3341,7 +3333,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3341 /* This is a limit in the driver and could be eliminated. */ 3333 /* This is a limit in the driver and could be eliminated. */
3342 blk_queue_max_phys_segments(q, MAXSGENTRIES); 3334 blk_queue_max_phys_segments(q, MAXSGENTRIES);
3343 3335
3344 blk_queue_max_sectors(q, 512); 3336 blk_queue_max_sectors(q, hba[i]->cciss_max_sectors);
3345 3337
3346 blk_queue_softirq_done(q, cciss_softirq_done); 3338 blk_queue_softirq_done(q, cciss_softirq_done);
3347 3339
@@ -3360,7 +3352,8 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3360 blk_queue_hardsect_size(q, drv->block_size); 3352 blk_queue_hardsect_size(q, drv->block_size);
3361 set_capacity(disk, drv->nr_blocks); 3353 set_capacity(disk, drv->nr_blocks);
3362 add_disk(disk); 3354 add_disk(disk);
3363 } 3355 j++;
3356 } while (j <= hba[i]->highest_lun);
3364 3357
3365 return 1; 3358 return 1;
3366 3359
@@ -3371,11 +3364,11 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3371 kfree(hba[i]->cmd_pool_bits); 3364 kfree(hba[i]->cmd_pool_bits);
3372 if (hba[i]->cmd_pool) 3365 if (hba[i]->cmd_pool)
3373 pci_free_consistent(hba[i]->pdev, 3366 pci_free_consistent(hba[i]->pdev,
3374 NR_CMDS * sizeof(CommandList_struct), 3367 hba[i]->nr_cmds * sizeof(CommandList_struct),
3375 hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); 3368 hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle);
3376 if (hba[i]->errinfo_pool) 3369 if (hba[i]->errinfo_pool)
3377 pci_free_consistent(hba[i]->pdev, 3370 pci_free_consistent(hba[i]->pdev,
3378 NR_CMDS * sizeof(ErrorInfo_struct), 3371 hba[i]->nr_cmds * sizeof(ErrorInfo_struct),
3379 hba[i]->errinfo_pool, 3372 hba[i]->errinfo_pool,
3380 hba[i]->errinfo_pool_dhandle); 3373 hba[i]->errinfo_pool_dhandle);
3381 free_irq(hba[i]->intr[SIMPLE_MODE_INT], hba[i]); 3374 free_irq(hba[i]->intr[SIMPLE_MODE_INT], hba[i]);
@@ -3383,6 +3376,15 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3383 unregister_blkdev(hba[i]->major, hba[i]->devname); 3376 unregister_blkdev(hba[i]->major, hba[i]->devname);
3384 clean1: 3377 clean1:
3385 hba[i]->busy_initializing = 0; 3378 hba[i]->busy_initializing = 0;
3379 /* cleanup any queues that may have been initialized */
3380 for (j=0; j <= hba[i]->highest_lun; j++){
3381 drive_info_struct *drv = &(hba[i]->drv[j]);
3382 if (drv->queue)
3383 blk_cleanup_queue(drv->queue);
3384 }
3385 pci_release_regions(pdev);
3386 pci_disable_device(pdev);
3387 pci_set_drvdata(pdev, NULL);
3386 free_hba(i); 3388 free_hba(i);
3387 return -1; 3389 return -1;
3388} 3390}
@@ -3430,7 +3432,7 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev)
3430 remove_proc_entry(hba[i]->devname, proc_cciss); 3432 remove_proc_entry(hba[i]->devname, proc_cciss);
3431 3433
3432 /* remove it from the disk list */ 3434 /* remove it from the disk list */
3433 for (j = 0; j < NWD; j++) { 3435 for (j = 0; j < CISS_MAX_LUN; j++) {
3434 struct gendisk *disk = hba[i]->gendisk[j]; 3436 struct gendisk *disk = hba[i]->gendisk[j];
3435 if (disk) { 3437 if (disk) {
3436 request_queue_t *q = disk->queue; 3438 request_queue_t *q = disk->queue;
@@ -3442,9 +3444,9 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev)
3442 } 3444 }
3443 } 3445 }
3444 3446
3445 pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(CommandList_struct), 3447 pci_free_consistent(hba[i]->pdev, hba[i]->nr_cmds * sizeof(CommandList_struct),
3446 hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); 3448 hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle);
3447 pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(ErrorInfo_struct), 3449 pci_free_consistent(hba[i]->pdev, hba[i]->nr_cmds * sizeof(ErrorInfo_struct),
3448 hba[i]->errinfo_pool, hba[i]->errinfo_pool_dhandle); 3450 hba[i]->errinfo_pool, hba[i]->errinfo_pool_dhandle);
3449 kfree(hba[i]->cmd_pool_bits); 3451 kfree(hba[i]->cmd_pool_bits);
3450#ifdef CONFIG_CISS_SCSI_TAPE 3452#ifdef CONFIG_CISS_SCSI_TAPE
diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
index 562235c1445a..b70988dd33ec 100644
--- a/drivers/block/cciss.h
+++ b/drivers/block/cciss.h
@@ -6,7 +6,6 @@
6#include "cciss_cmd.h" 6#include "cciss_cmd.h"
7 7
8 8
9#define NWD 16
10#define NWD_SHIFT 4 9#define NWD_SHIFT 4
11#define MAX_PART (1 << NWD_SHIFT) 10#define MAX_PART (1 << NWD_SHIFT)
12 11
@@ -60,6 +59,7 @@ struct ctlr_info
60 __u32 board_id; 59 __u32 board_id;
61 void __iomem *vaddr; 60 void __iomem *vaddr;
62 unsigned long paddr; 61 unsigned long paddr;
62 int nr_cmds; /* Number of commands allowed on this controller */
63 CfgTable_struct __iomem *cfgtable; 63 CfgTable_struct __iomem *cfgtable;
64 int interrupts_enabled; 64 int interrupts_enabled;
65 int major; 65 int major;
@@ -76,6 +76,7 @@ struct ctlr_info
76 unsigned int intr[4]; 76 unsigned int intr[4];
77 unsigned int msix_vector; 77 unsigned int msix_vector;
78 unsigned int msi_vector; 78 unsigned int msi_vector;
79 int cciss_max_sectors;
79 BYTE cciss_read; 80 BYTE cciss_read;
80 BYTE cciss_write; 81 BYTE cciss_write;
81 BYTE cciss_read_capacity; 82 BYTE cciss_read_capacity;
@@ -110,7 +111,7 @@ struct ctlr_info
110 int next_to_run; 111 int next_to_run;
111 112
112 // Disk structures we need to pass back 113 // Disk structures we need to pass back
113 struct gendisk *gendisk[NWD]; 114 struct gendisk *gendisk[CISS_MAX_LUN];
114#ifdef CONFIG_CISS_SCSI_TAPE 115#ifdef CONFIG_CISS_SCSI_TAPE
115 void *scsi_ctlr; /* ptr to structure containing scsi related stuff */ 116 void *scsi_ctlr; /* ptr to structure containing scsi related stuff */
116 /* list of block side commands the scsi error handling sucked up */ 117 /* list of block side commands the scsi error handling sucked up */
@@ -282,6 +283,7 @@ struct board_type {
282 __u32 board_id; 283 __u32 board_id;
283 char *product_name; 284 char *product_name;
284 struct access_method *access; 285 struct access_method *access;
286 int nr_cmds; /* Max cmds this kind of ctlr can handle. */
285}; 287};
286 288
287#define CCISS_LOCK(i) (&hba[i]->lock) 289#define CCISS_LOCK(i) (&hba[i]->lock)
diff --git a/drivers/block/cciss_cmd.h b/drivers/block/cciss_cmd.h
index 4af7c4c0c7af..43bf5593b59b 100644
--- a/drivers/block/cciss_cmd.h
+++ b/drivers/block/cciss_cmd.h
@@ -55,6 +55,7 @@
55#define I2O_INT_MASK 0x34 55#define I2O_INT_MASK 0x34
56#define I2O_IBPOST_Q 0x40 56#define I2O_IBPOST_Q 0x40
57#define I2O_OBPOST_Q 0x44 57#define I2O_OBPOST_Q 0x44
58#define I2O_DMA1_CFG 0x214
58 59
59//Configuration Table 60//Configuration Table
60#define CFGTBL_ChangeReq 0x00000001l 61#define CFGTBL_ChangeReq 0x00000001l
@@ -88,7 +89,7 @@ typedef union _u64bit
88//########################################################################### 89//###########################################################################
89//STRUCTURES 90//STRUCTURES
90//########################################################################### 91//###########################################################################
91#define CISS_MAX_LUN 16 92#define CISS_MAX_LUN 1024
92#define CISS_MAX_PHYS_LUN 1024 93#define CISS_MAX_PHYS_LUN 1024
93// SCSI-3 Cmmands 94// SCSI-3 Cmmands
94 95
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 9e6d3a87cbe3..3f1b38276e96 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -992,11 +992,11 @@ static void empty(void)
992{ 992{
993} 993}
994 994
995static DECLARE_WORK(floppy_work, NULL, NULL); 995static DECLARE_WORK(floppy_work, NULL);
996 996
997static void schedule_bh(void (*handler) (void)) 997static void schedule_bh(void (*handler) (void))
998{ 998{
999 PREPARE_WORK(&floppy_work, (void (*)(void *))handler, NULL); 999 PREPARE_WORK(&floppy_work, (work_func_t)handler);
1000 schedule_work(&floppy_work); 1000 schedule_work(&floppy_work);
1001} 1001}
1002 1002
@@ -1008,7 +1008,7 @@ static void cancel_activity(void)
1008 1008
1009 spin_lock_irqsave(&floppy_lock, flags); 1009 spin_lock_irqsave(&floppy_lock, flags);
1010 do_floppy = NULL; 1010 do_floppy = NULL;
1011 PREPARE_WORK(&floppy_work, (void *)empty, NULL); 1011 PREPARE_WORK(&floppy_work, (work_func_t)empty);
1012 del_timer(&fd_timer); 1012 del_timer(&fd_timer);
1013 spin_unlock_irqrestore(&floppy_lock, flags); 1013 spin_unlock_irqrestore(&floppy_lock, flags);
1014} 1014}
@@ -1868,7 +1868,7 @@ static void show_floppy(void)
1868 printk("fdc_busy=%lu\n", fdc_busy); 1868 printk("fdc_busy=%lu\n", fdc_busy);
1869 if (do_floppy) 1869 if (do_floppy)
1870 printk("do_floppy=%p\n", do_floppy); 1870 printk("do_floppy=%p\n", do_floppy);
1871 if (floppy_work.pending) 1871 if (work_pending(&floppy_work))
1872 printk("floppy_work.func=%p\n", floppy_work.func); 1872 printk("floppy_work.func=%p\n", floppy_work.func);
1873 if (timer_pending(&fd_timer)) 1873 if (timer_pending(&fd_timer))
1874 printk("fd_timer.function=%p\n", fd_timer.function); 1874 printk("fd_timer.function=%p\n", fd_timer.function);
@@ -4498,7 +4498,7 @@ static void floppy_release_irq_and_dma(void)
4498 printk("floppy timer still active:%s\n", timeout_message); 4498 printk("floppy timer still active:%s\n", timeout_message);
4499 if (timer_pending(&fd_timer)) 4499 if (timer_pending(&fd_timer))
4500 printk("auxiliary floppy timer still active\n"); 4500 printk("auxiliary floppy timer still active\n");
4501 if (floppy_work.pending) 4501 if (work_pending(&floppy_work))
4502 printk("work still pending\n"); 4502 printk("work still pending\n");
4503#endif 4503#endif
4504 old_fdc = fdc; 4504 old_fdc = fdc;
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 9d1035e8d9d8..7bf2cfbd6285 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -355,14 +355,30 @@ harderror:
355 return NULL; 355 return NULL;
356} 356}
357 357
358static ssize_t pid_show(struct gendisk *disk, char *page)
359{
360 return sprintf(page, "%ld\n",
361 (long) ((struct nbd_device *)disk->private_data)->pid);
362}
363
364static struct disk_attribute pid_attr = {
365 .attr = { .name = "pid", .mode = S_IRUGO },
366 .show = pid_show,
367};
368
358static void nbd_do_it(struct nbd_device *lo) 369static void nbd_do_it(struct nbd_device *lo)
359{ 370{
360 struct request *req; 371 struct request *req;
361 372
362 BUG_ON(lo->magic != LO_MAGIC); 373 BUG_ON(lo->magic != LO_MAGIC);
363 374
375 lo->pid = current->pid;
376 sysfs_create_file(&lo->disk->kobj, &pid_attr.attr);
377
364 while ((req = nbd_read_stat(lo)) != NULL) 378 while ((req = nbd_read_stat(lo)) != NULL)
365 nbd_end_request(req); 379 nbd_end_request(req);
380
381 sysfs_remove_file(&lo->disk->kobj, &pid_attr.attr);
366 return; 382 return;
367} 383}
368 384
diff --git a/drivers/block/paride/aten.c b/drivers/block/paride/aten.c
index c4d696d43dc1..2695465568ad 100644
--- a/drivers/block/paride/aten.c
+++ b/drivers/block/paride/aten.c
@@ -149,12 +149,12 @@ static struct pi_protocol aten = {
149 149
150static int __init aten_init(void) 150static int __init aten_init(void)
151{ 151{
152 return pi_register(&aten)-1; 152 return paride_register(&aten);
153} 153}
154 154
155static void __exit aten_exit(void) 155static void __exit aten_exit(void)
156{ 156{
157 pi_unregister( &aten ); 157 paride_unregister( &aten );
158} 158}
159 159
160MODULE_LICENSE("GPL"); 160MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/bpck.c b/drivers/block/paride/bpck.c
index d462ff6b139d..4f27e7392e38 100644
--- a/drivers/block/paride/bpck.c
+++ b/drivers/block/paride/bpck.c
@@ -464,12 +464,12 @@ static struct pi_protocol bpck = {
464 464
465static int __init bpck_init(void) 465static int __init bpck_init(void)
466{ 466{
467 return pi_register(&bpck)-1; 467 return paride_register(&bpck);
468} 468}
469 469
470static void __exit bpck_exit(void) 470static void __exit bpck_exit(void)
471{ 471{
472 pi_unregister(&bpck); 472 paride_unregister(&bpck);
473} 473}
474 474
475MODULE_LICENSE("GPL"); 475MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/bpck6.c b/drivers/block/paride/bpck6.c
index 41a237c5957d..ad124525ac23 100644
--- a/drivers/block/paride/bpck6.c
+++ b/drivers/block/paride/bpck6.c
@@ -31,10 +31,7 @@ static int verbose; /* set this to 1 to see debugging messages and whatnot */
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/types.h> 32#include <linux/types.h>
33#include <asm/io.h> 33#include <asm/io.h>
34
35#if defined(CONFIG_PARPORT_MODULE)||defined(CONFIG_PARPORT)
36#include <linux/parport.h> 34#include <linux/parport.h>
37#endif
38 35
39#include "ppc6lnx.c" 36#include "ppc6lnx.c"
40#include "paride.h" 37#include "paride.h"
@@ -139,11 +136,6 @@ static int bpck6_test_port ( PIA *pi ) /* check for 8-bit port */
139 PPCSTRUCT(pi)->ppc_id=pi->unit; 136 PPCSTRUCT(pi)->ppc_id=pi->unit;
140 PPCSTRUCT(pi)->lpt_addr=pi->port; 137 PPCSTRUCT(pi)->lpt_addr=pi->port;
141 138
142#ifdef CONFIG_PARPORT_PC_MODULE
143#define CONFIG_PARPORT_PC
144#endif
145
146#ifdef CONFIG_PARPORT_PC
147 /* look at the parport device to see if what modes we can use */ 139 /* look at the parport device to see if what modes we can use */
148 if(((struct pardevice *)(pi->pardev))->port->modes & 140 if(((struct pardevice *)(pi->pardev))->port->modes &
149 (PARPORT_MODE_EPP) 141 (PARPORT_MODE_EPP)
@@ -161,11 +153,6 @@ static int bpck6_test_port ( PIA *pi ) /* check for 8-bit port */
161 { 153 {
162 return 1; 154 return 1;
163 } 155 }
164#else
165 /* there is no way of knowing what kind of port we have
166 default to the highest mode possible */
167 return 5;
168#endif
169} 156}
170 157
171static int bpck6_probe_unit ( PIA *pi ) 158static int bpck6_probe_unit ( PIA *pi )
@@ -265,12 +252,12 @@ static int __init bpck6_init(void)
265 printk(KERN_INFO "bpck6: Copyright 2001 by Micro Solutions, Inc., DeKalb IL. USA\n"); 252 printk(KERN_INFO "bpck6: Copyright 2001 by Micro Solutions, Inc., DeKalb IL. USA\n");
266 if(verbose) 253 if(verbose)
267 printk(KERN_DEBUG "bpck6: verbose debug enabled.\n"); 254 printk(KERN_DEBUG "bpck6: verbose debug enabled.\n");
268 return pi_register(&bpck6) - 1; 255 return paride_register(&bpck6);
269} 256}
270 257
271static void __exit bpck6_exit(void) 258static void __exit bpck6_exit(void)
272{ 259{
273 pi_unregister(&bpck6); 260 paride_unregister(&bpck6);
274} 261}
275 262
276MODULE_LICENSE("GPL"); 263MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/comm.c b/drivers/block/paride/comm.c
index 43d61359d8ec..9bcd35495323 100644
--- a/drivers/block/paride/comm.c
+++ b/drivers/block/paride/comm.c
@@ -205,12 +205,12 @@ static struct pi_protocol comm = {
205 205
206static int __init comm_init(void) 206static int __init comm_init(void)
207{ 207{
208 return pi_register(&comm)-1; 208 return paride_register(&comm);
209} 209}
210 210
211static void __exit comm_exit(void) 211static void __exit comm_exit(void)
212{ 212{
213 pi_unregister(&comm); 213 paride_unregister(&comm);
214} 214}
215 215
216MODULE_LICENSE("GPL"); 216MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/dstr.c b/drivers/block/paride/dstr.c
index 04d53bf58e8c..accc5c777cbb 100644
--- a/drivers/block/paride/dstr.c
+++ b/drivers/block/paride/dstr.c
@@ -220,12 +220,12 @@ static struct pi_protocol dstr = {
220 220
221static int __init dstr_init(void) 221static int __init dstr_init(void)
222{ 222{
223 return pi_register(&dstr)-1; 223 return paride_register(&dstr);
224} 224}
225 225
226static void __exit dstr_exit(void) 226static void __exit dstr_exit(void)
227{ 227{
228 pi_unregister(&dstr); 228 paride_unregister(&dstr);
229} 229}
230 230
231MODULE_LICENSE("GPL"); 231MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/epat.c b/drivers/block/paride/epat.c
index 55d1c0a1fb90..1bcdff77322e 100644
--- a/drivers/block/paride/epat.c
+++ b/drivers/block/paride/epat.c
@@ -327,12 +327,12 @@ static int __init epat_init(void)
327#ifdef CONFIG_PARIDE_EPATC8 327#ifdef CONFIG_PARIDE_EPATC8
328 epatc8 = 1; 328 epatc8 = 1;
329#endif 329#endif
330 return pi_register(&epat)-1; 330 return paride_register(&epat);
331} 331}
332 332
333static void __exit epat_exit(void) 333static void __exit epat_exit(void)
334{ 334{
335 pi_unregister(&epat); 335 paride_unregister(&epat);
336} 336}
337 337
338MODULE_LICENSE("GPL"); 338MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/epia.c b/drivers/block/paride/epia.c
index 0f2e0c292d82..fb0e782d055e 100644
--- a/drivers/block/paride/epia.c
+++ b/drivers/block/paride/epia.c
@@ -303,12 +303,12 @@ static struct pi_protocol epia = {
303 303
304static int __init epia_init(void) 304static int __init epia_init(void)
305{ 305{
306 return pi_register(&epia)-1; 306 return paride_register(&epia);
307} 307}
308 308
309static void __exit epia_exit(void) 309static void __exit epia_exit(void)
310{ 310{
311 pi_unregister(&epia); 311 paride_unregister(&epia);
312} 312}
313 313
314MODULE_LICENSE("GPL"); 314MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/fit2.c b/drivers/block/paride/fit2.c
index e0f0691d8bc2..381283753ae4 100644
--- a/drivers/block/paride/fit2.c
+++ b/drivers/block/paride/fit2.c
@@ -138,12 +138,12 @@ static struct pi_protocol fit2 = {
138 138
139static int __init fit2_init(void) 139static int __init fit2_init(void)
140{ 140{
141 return pi_register(&fit2)-1; 141 return paride_register(&fit2);
142} 142}
143 143
144static void __exit fit2_exit(void) 144static void __exit fit2_exit(void)
145{ 145{
146 pi_unregister(&fit2); 146 paride_unregister(&fit2);
147} 147}
148 148
149MODULE_LICENSE("GPL"); 149MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/fit3.c b/drivers/block/paride/fit3.c
index 15400e7bc666..275d269458eb 100644
--- a/drivers/block/paride/fit3.c
+++ b/drivers/block/paride/fit3.c
@@ -198,12 +198,12 @@ static struct pi_protocol fit3 = {
198 198
199static int __init fit3_init(void) 199static int __init fit3_init(void)
200{ 200{
201 return pi_register(&fit3)-1; 201 return paride_register(&fit3);
202} 202}
203 203
204static void __exit fit3_exit(void) 204static void __exit fit3_exit(void)
205{ 205{
206 pi_unregister(&fit3); 206 paride_unregister(&fit3);
207} 207}
208 208
209MODULE_LICENSE("GPL"); 209MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/friq.c b/drivers/block/paride/friq.c
index 5ea2904d2815..4f2ba244689b 100644
--- a/drivers/block/paride/friq.c
+++ b/drivers/block/paride/friq.c
@@ -263,12 +263,12 @@ static struct pi_protocol friq = {
263 263
264static int __init friq_init(void) 264static int __init friq_init(void)
265{ 265{
266 return pi_register(&friq)-1; 266 return paride_register(&friq);
267} 267}
268 268
269static void __exit friq_exit(void) 269static void __exit friq_exit(void)
270{ 270{
271 pi_unregister(&friq); 271 paride_unregister(&friq);
272} 272}
273 273
274MODULE_LICENSE("GPL"); 274MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/frpw.c b/drivers/block/paride/frpw.c
index 56b3824b1538..c3cde364603a 100644
--- a/drivers/block/paride/frpw.c
+++ b/drivers/block/paride/frpw.c
@@ -300,12 +300,12 @@ static struct pi_protocol frpw = {
300 300
301static int __init frpw_init(void) 301static int __init frpw_init(void)
302{ 302{
303 return pi_register(&frpw)-1; 303 return paride_register(&frpw);
304} 304}
305 305
306static void __exit frpw_exit(void) 306static void __exit frpw_exit(void)
307{ 307{
308 pi_unregister(&frpw); 308 paride_unregister(&frpw);
309} 309}
310 310
311MODULE_LICENSE("GPL"); 311MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/jumbo b/drivers/block/paride/jumbo
deleted file mode 100644
index e793b9cb7e72..000000000000
--- a/drivers/block/paride/jumbo
+++ /dev/null
@@ -1,70 +0,0 @@
1#!/bin/sh
2#
3# This script can be used to build "jumbo" modules that contain the
4# base PARIDE support, one protocol module and one high-level driver.
5#
6echo -n "High level driver [pcd] : "
7read X
8HLD=${X:-pcd}
9#
10echo -n "Protocol module [bpck] : "
11read X
12PROTO=${X:-bpck}
13#
14echo -n "Use MODVERSIONS [y] ? "
15read X
16UMODV=${X:-y}
17#
18echo -n "For SMP kernel [n] ? "
19read X
20USMP=${X:-n}
21#
22echo -n "Support PARPORT [n] ? "
23read X
24UPARP=${X:-n}
25#
26echo
27#
28case $USMP in
29 y* | Y* ) FSMP="-DCONFIG_SMP"
30 ;;
31 *) FSMP=""
32 ;;
33esac
34#
35MODI="-include ../../../include/linux/modversions.h"
36#
37case $UMODV in
38 y* | Y* ) FMODV="-DMODVERSIONS $MODI"
39 ;;
40 *) FMODV=""
41 ;;
42esac
43#
44case $UPARP in
45 y* | Y* ) FPARP="-DCONFIG_PARPORT"
46 ;;
47 *) FPARP=""
48 ;;
49esac
50#
51TARG=$HLD-$PROTO.o
52FPROTO=-DCONFIG_PARIDE_`echo "$PROTO" | tr [a-z] [A-Z]`
53FK="-D__KERNEL__ -I ../../../include"
54FLCH=-D_LINUX_CONFIG_H
55#
56echo cc $FK $FSMP $FLCH $FPARP $FPROTO $FMODV -Wall -O2 -o Jb.o -c paride.c
57cc $FK $FSMP $FLCH $FPARP $FPROTO $FMODV -Wall -O2 -o Jb.o -c paride.c
58#
59echo cc $FK $FSMP $FMODV -Wall -O2 -o Jp.o -c $PROTO.c
60cc $FK $FSMP $FMODV -Wall -O2 -o Jp.o -c $PROTO.c
61#
62echo cc $FK $FSMP $FMODV -DMODULE -DPARIDE_JUMBO -Wall -O2 -o Jd.o -c $HLD.c
63cc $FK $FSMP $FMODV -DMODULE -DPARIDE_JUMBO -Wall -O2 -o Jd.o -c $HLD.c
64#
65echo ld -r -o $TARG Jp.o Jb.o Jd.o
66ld -r -o $TARG Jp.o Jb.o Jd.o
67#
68#
69rm Jp.o Jb.o Jd.o
70#
diff --git a/drivers/block/paride/kbic.c b/drivers/block/paride/kbic.c
index d983bcea76fe..35999c415ee3 100644
--- a/drivers/block/paride/kbic.c
+++ b/drivers/block/paride/kbic.c
@@ -283,13 +283,21 @@ static struct pi_protocol k971 = {
283 283
284static int __init kbic_init(void) 284static int __init kbic_init(void)
285{ 285{
286 return (pi_register(&k951)||pi_register(&k971))-1; 286 int rv;
287
288 rv = paride_register(&k951);
289 if (rv < 0)
290 return rv;
291 rv = paride_register(&k971);
292 if (rv < 0)
293 paride_unregister(&k951);
294 return rv;
287} 295}
288 296
289static void __exit kbic_exit(void) 297static void __exit kbic_exit(void)
290{ 298{
291 pi_unregister(&k951); 299 paride_unregister(&k951);
292 pi_unregister(&k971); 300 paride_unregister(&k971);
293} 301}
294 302
295MODULE_LICENSE("GPL"); 303MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/ktti.c b/drivers/block/paride/ktti.c
index 6c7edbfba9a0..117ab0e8ccf0 100644
--- a/drivers/block/paride/ktti.c
+++ b/drivers/block/paride/ktti.c
@@ -115,12 +115,12 @@ static struct pi_protocol ktti = {
115 115
116static int __init ktti_init(void) 116static int __init ktti_init(void)
117{ 117{
118 return pi_register(&ktti)-1; 118 return paride_register(&ktti);
119} 119}
120 120
121static void __exit ktti_exit(void) 121static void __exit ktti_exit(void)
122{ 122{
123 pi_unregister(&ktti); 123 paride_unregister(&ktti);
124} 124}
125 125
126MODULE_LICENSE("GPL"); 126MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/on20.c b/drivers/block/paride/on20.c
index 9f8e01096809..0173697a1a4d 100644
--- a/drivers/block/paride/on20.c
+++ b/drivers/block/paride/on20.c
@@ -140,12 +140,12 @@ static struct pi_protocol on20 = {
140 140
141static int __init on20_init(void) 141static int __init on20_init(void)
142{ 142{
143 return pi_register(&on20)-1; 143 return paride_register(&on20);
144} 144}
145 145
146static void __exit on20_exit(void) 146static void __exit on20_exit(void)
147{ 147{
148 pi_unregister(&on20); 148 paride_unregister(&on20);
149} 149}
150 150
151MODULE_LICENSE("GPL"); 151MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/on26.c b/drivers/block/paride/on26.c
index 0f833caa2101..95ba256921f2 100644
--- a/drivers/block/paride/on26.c
+++ b/drivers/block/paride/on26.c
@@ -306,12 +306,12 @@ static struct pi_protocol on26 = {
306 306
307static int __init on26_init(void) 307static int __init on26_init(void)
308{ 308{
309 return pi_register(&on26)-1; 309 return paride_register(&on26);
310} 310}
311 311
312static void __exit on26_exit(void) 312static void __exit on26_exit(void)
313{ 313{
314 pi_unregister(&on26); 314 paride_unregister(&on26);
315} 315}
316 316
317MODULE_LICENSE("GPL"); 317MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/paride.c b/drivers/block/paride/paride.c
index 4b258f7836f3..48c50f11f63b 100644
--- a/drivers/block/paride/paride.c
+++ b/drivers/block/paride/paride.c
@@ -29,14 +29,7 @@
29#include <linux/spinlock.h> 29#include <linux/spinlock.h>
30#include <linux/wait.h> 30#include <linux/wait.h>
31#include <linux/sched.h> /* TASK_* */ 31#include <linux/sched.h> /* TASK_* */
32
33#ifdef CONFIG_PARPORT_MODULE
34#define CONFIG_PARPORT
35#endif
36
37#ifdef CONFIG_PARPORT
38#include <linux/parport.h> 32#include <linux/parport.h>
39#endif
40 33
41#include "paride.h" 34#include "paride.h"
42 35
@@ -76,8 +69,6 @@ void pi_read_block(PIA * pi, char *buf, int count)
76 69
77EXPORT_SYMBOL(pi_read_block); 70EXPORT_SYMBOL(pi_read_block);
78 71
79#ifdef CONFIG_PARPORT
80
81static void pi_wake_up(void *p) 72static void pi_wake_up(void *p)
82{ 73{
83 PIA *pi = (PIA *) p; 74 PIA *pi = (PIA *) p;
@@ -100,11 +91,8 @@ static void pi_wake_up(void *p)
100 cont(); 91 cont();
101} 92}
102 93
103#endif
104
105int pi_schedule_claimed(PIA * pi, void (*cont) (void)) 94int pi_schedule_claimed(PIA * pi, void (*cont) (void))
106{ 95{
107#ifdef CONFIG_PARPORT
108 unsigned long flags; 96 unsigned long flags;
109 97
110 spin_lock_irqsave(&pi_spinlock, flags); 98 spin_lock_irqsave(&pi_spinlock, flags);
@@ -115,7 +103,6 @@ int pi_schedule_claimed(PIA * pi, void (*cont) (void))
115 } 103 }
116 pi->claimed = 1; 104 pi->claimed = 1;
117 spin_unlock_irqrestore(&pi_spinlock, flags); 105 spin_unlock_irqrestore(&pi_spinlock, flags);
118#endif
119 return 1; 106 return 1;
120} 107}
121EXPORT_SYMBOL(pi_schedule_claimed); 108EXPORT_SYMBOL(pi_schedule_claimed);
@@ -133,20 +120,16 @@ static void pi_claim(PIA * pi)
133 if (pi->claimed) 120 if (pi->claimed)
134 return; 121 return;
135 pi->claimed = 1; 122 pi->claimed = 1;
136#ifdef CONFIG_PARPORT
137 if (pi->pardev) 123 if (pi->pardev)
138 wait_event(pi->parq, 124 wait_event(pi->parq,
139 !parport_claim((struct pardevice *) pi->pardev)); 125 !parport_claim((struct pardevice *) pi->pardev));
140#endif
141} 126}
142 127
143static void pi_unclaim(PIA * pi) 128static void pi_unclaim(PIA * pi)
144{ 129{
145 pi->claimed = 0; 130 pi->claimed = 0;
146#ifdef CONFIG_PARPORT
147 if (pi->pardev) 131 if (pi->pardev)
148 parport_release((struct pardevice *) (pi->pardev)); 132 parport_release((struct pardevice *) (pi->pardev));
149#endif
150} 133}
151 134
152void pi_connect(PIA * pi) 135void pi_connect(PIA * pi)
@@ -167,21 +150,15 @@ EXPORT_SYMBOL(pi_disconnect);
167 150
168static void pi_unregister_parport(PIA * pi) 151static void pi_unregister_parport(PIA * pi)
169{ 152{
170#ifdef CONFIG_PARPORT
171 if (pi->pardev) { 153 if (pi->pardev) {
172 parport_unregister_device((struct pardevice *) (pi->pardev)); 154 parport_unregister_device((struct pardevice *) (pi->pardev));
173 pi->pardev = NULL; 155 pi->pardev = NULL;
174 } 156 }
175#endif
176} 157}
177 158
178void pi_release(PIA * pi) 159void pi_release(PIA * pi)
179{ 160{
180 pi_unregister_parport(pi); 161 pi_unregister_parport(pi);
181#ifndef CONFIG_PARPORT
182 if (pi->reserved)
183 release_region(pi->port, pi->reserved);
184#endif /* !CONFIG_PARPORT */
185 if (pi->proto->release_proto) 162 if (pi->proto->release_proto)
186 pi->proto->release_proto(pi); 163 pi->proto->release_proto(pi);
187 module_put(pi->proto->owner); 164 module_put(pi->proto->owner);
@@ -229,7 +206,7 @@ static int pi_test_proto(PIA * pi, char *scratch, int verbose)
229 return res; 206 return res;
230} 207}
231 208
232int pi_register(PIP * pr) 209int paride_register(PIP * pr)
233{ 210{
234 int k; 211 int k;
235 212
@@ -237,24 +214,24 @@ int pi_register(PIP * pr)
237 if (protocols[k] && !strcmp(pr->name, protocols[k]->name)) { 214 if (protocols[k] && !strcmp(pr->name, protocols[k]->name)) {
238 printk("paride: %s protocol already registered\n", 215 printk("paride: %s protocol already registered\n",
239 pr->name); 216 pr->name);
240 return 0; 217 return -1;
241 } 218 }
242 k = 0; 219 k = 0;
243 while ((k < MAX_PROTOS) && (protocols[k])) 220 while ((k < MAX_PROTOS) && (protocols[k]))
244 k++; 221 k++;
245 if (k == MAX_PROTOS) { 222 if (k == MAX_PROTOS) {
246 printk("paride: protocol table full\n"); 223 printk("paride: protocol table full\n");
247 return 0; 224 return -1;
248 } 225 }
249 protocols[k] = pr; 226 protocols[k] = pr;
250 pr->index = k; 227 pr->index = k;
251 printk("paride: %s registered as protocol %d\n", pr->name, k); 228 printk("paride: %s registered as protocol %d\n", pr->name, k);
252 return 1; 229 return 0;
253} 230}
254 231
255EXPORT_SYMBOL(pi_register); 232EXPORT_SYMBOL(paride_register);
256 233
257void pi_unregister(PIP * pr) 234void paride_unregister(PIP * pr)
258{ 235{
259 if (!pr) 236 if (!pr)
260 return; 237 return;
@@ -265,12 +242,10 @@ void pi_unregister(PIP * pr)
265 protocols[pr->index] = NULL; 242 protocols[pr->index] = NULL;
266} 243}
267 244
268EXPORT_SYMBOL(pi_unregister); 245EXPORT_SYMBOL(paride_unregister);
269 246
270static int pi_register_parport(PIA * pi, int verbose) 247static int pi_register_parport(PIA * pi, int verbose)
271{ 248{
272#ifdef CONFIG_PARPORT
273
274 struct parport *port; 249 struct parport *port;
275 250
276 port = parport_find_base(pi->port); 251 port = parport_find_base(pi->port);
@@ -290,7 +265,6 @@ static int pi_register_parport(PIA * pi, int verbose)
290 printk("%s: 0x%x is %s\n", pi->device, pi->port, port->name); 265 printk("%s: 0x%x is %s\n", pi->device, pi->port, port->name);
291 266
292 pi->parname = (char *) port->name; 267 pi->parname = (char *) port->name;
293#endif
294 268
295 return 1; 269 return 1;
296} 270}
@@ -447,13 +421,6 @@ int pi_init(PIA * pi, int autoprobe, int port, int mode,
447 printk("%s: Adapter not found\n", device); 421 printk("%s: Adapter not found\n", device);
448 return 0; 422 return 0;
449 } 423 }
450#ifndef CONFIG_PARPORT
451 if (!request_region(pi->port, pi->reserved, pi->device)) {
452 printk(KERN_WARNING "paride: Unable to request region 0x%x\n",
453 pi->port);
454 return 0;
455 }
456#endif /* !CONFIG_PARPORT */
457 424
458 if (pi->parname) 425 if (pi->parname)
459 printk("%s: Sharing %s at 0x%x\n", pi->device, 426 printk("%s: Sharing %s at 0x%x\n", pi->device,
diff --git a/drivers/block/paride/paride.h b/drivers/block/paride/paride.h
index c6d98ef09e48..2bddbf45518b 100644
--- a/drivers/block/paride/paride.h
+++ b/drivers/block/paride/paride.h
@@ -163,8 +163,8 @@ struct pi_protocol {
163 163
164typedef struct pi_protocol PIP; 164typedef struct pi_protocol PIP;
165 165
166extern int pi_register( PIP * ); 166extern int paride_register( PIP * );
167extern void pi_unregister ( PIP * ); 167extern void paride_unregister ( PIP * );
168 168
169#endif /* __DRIVERS_PARIDE_H__ */ 169#endif /* __DRIVERS_PARIDE_H__ */
170/* end of paride.h */ 170/* end of paride.h */
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index ac5ba462710b..c852eed91e4b 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -912,12 +912,12 @@ static int __init pcd_init(void)
912 int unit; 912 int unit;
913 913
914 if (disable) 914 if (disable)
915 return -1; 915 return -EINVAL;
916 916
917 pcd_init_units(); 917 pcd_init_units();
918 918
919 if (pcd_detect()) 919 if (pcd_detect())
920 return -1; 920 return -ENODEV;
921 921
922 /* get the atapi capabilities page */ 922 /* get the atapi capabilities page */
923 pcd_probe_capabilities(); 923 pcd_probe_capabilities();
@@ -925,7 +925,7 @@ static int __init pcd_init(void)
925 if (register_blkdev(major, name)) { 925 if (register_blkdev(major, name)) {
926 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) 926 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++)
927 put_disk(cd->disk); 927 put_disk(cd->disk);
928 return -1; 928 return -EBUSY;
929 } 929 }
930 930
931 pcd_queue = blk_init_queue(do_pcd_request, &pcd_lock); 931 pcd_queue = blk_init_queue(do_pcd_request, &pcd_lock);
@@ -933,7 +933,7 @@ static int __init pcd_init(void)
933 unregister_blkdev(major, name); 933 unregister_blkdev(major, name);
934 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) 934 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++)
935 put_disk(cd->disk); 935 put_disk(cd->disk);
936 return -1; 936 return -ENOMEM;
937 } 937 }
938 938
939 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) { 939 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) {
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
index 40a11e567970..9d9bff23f426 100644
--- a/drivers/block/paride/pd.c
+++ b/drivers/block/paride/pd.c
@@ -352,19 +352,19 @@ static enum action (*phase)(void);
352 352
353static void run_fsm(void); 353static void run_fsm(void);
354 354
355static void ps_tq_int( void *data); 355static void ps_tq_int(struct work_struct *work);
356 356
357static DECLARE_WORK(fsm_tq, ps_tq_int, NULL); 357static DECLARE_DELAYED_WORK(fsm_tq, ps_tq_int);
358 358
359static void schedule_fsm(void) 359static void schedule_fsm(void)
360{ 360{
361 if (!nice) 361 if (!nice)
362 schedule_work(&fsm_tq); 362 schedule_delayed_work(&fsm_tq, 0);
363 else 363 else
364 schedule_delayed_work(&fsm_tq, nice-1); 364 schedule_delayed_work(&fsm_tq, nice-1);
365} 365}
366 366
367static void ps_tq_int(void *data) 367static void ps_tq_int(struct work_struct *work)
368{ 368{
369 run_fsm(); 369 run_fsm();
370} 370}
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index 1a9dee19efcf..7cdaa1951260 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -933,25 +933,25 @@ static int __init pf_init(void)
933 int unit; 933 int unit;
934 934
935 if (disable) 935 if (disable)
936 return -1; 936 return -EINVAL;
937 937
938 pf_init_units(); 938 pf_init_units();
939 939
940 if (pf_detect()) 940 if (pf_detect())
941 return -1; 941 return -ENODEV;
942 pf_busy = 0; 942 pf_busy = 0;
943 943
944 if (register_blkdev(major, name)) { 944 if (register_blkdev(major, name)) {
945 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) 945 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++)
946 put_disk(pf->disk); 946 put_disk(pf->disk);
947 return -1; 947 return -EBUSY;
948 } 948 }
949 pf_queue = blk_init_queue(do_pf_request, &pf_spin_lock); 949 pf_queue = blk_init_queue(do_pf_request, &pf_spin_lock);
950 if (!pf_queue) { 950 if (!pf_queue) {
951 unregister_blkdev(major, name); 951 unregister_blkdev(major, name);
952 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) 952 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++)
953 put_disk(pf->disk); 953 put_disk(pf->disk);
954 return -1; 954 return -ENOMEM;
955 } 955 }
956 956
957 blk_queue_max_phys_segments(pf_queue, cluster); 957 blk_queue_max_phys_segments(pf_queue, cluster);
diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
index 13f998aa1cd3..9970aedbb5d9 100644
--- a/drivers/block/paride/pg.c
+++ b/drivers/block/paride/pg.c
@@ -646,14 +646,14 @@ static int __init pg_init(void)
646 int err; 646 int err;
647 647
648 if (disable){ 648 if (disable){
649 err = -1; 649 err = -EINVAL;
650 goto out; 650 goto out;
651 } 651 }
652 652
653 pg_init_units(); 653 pg_init_units();
654 654
655 if (pg_detect()) { 655 if (pg_detect()) {
656 err = -1; 656 err = -ENODEV;
657 goto out; 657 goto out;
658 } 658 }
659 659
diff --git a/drivers/block/paride/pseudo.h b/drivers/block/paride/pseudo.h
index 932342d7a8eb..bc3703294143 100644
--- a/drivers/block/paride/pseudo.h
+++ b/drivers/block/paride/pseudo.h
@@ -35,7 +35,7 @@
35#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/workqueue.h> 36#include <linux/workqueue.h>
37 37
38static void ps_tq_int( void *data); 38static void ps_tq_int(struct work_struct *work);
39 39
40static void (* ps_continuation)(void); 40static void (* ps_continuation)(void);
41static int (* ps_ready)(void); 41static int (* ps_ready)(void);
@@ -45,7 +45,7 @@ static int ps_nice = 0;
45 45
46static DEFINE_SPINLOCK(ps_spinlock __attribute__((unused))); 46static DEFINE_SPINLOCK(ps_spinlock __attribute__((unused)));
47 47
48static DECLARE_WORK(ps_tq, ps_tq_int, NULL); 48static DECLARE_DELAYED_WORK(ps_tq, ps_tq_int);
49 49
50static void ps_set_intr(void (*continuation)(void), 50static void ps_set_intr(void (*continuation)(void),
51 int (*ready)(void), 51 int (*ready)(void),
@@ -63,14 +63,14 @@ static void ps_set_intr(void (*continuation)(void),
63 if (!ps_tq_active) { 63 if (!ps_tq_active) {
64 ps_tq_active = 1; 64 ps_tq_active = 1;
65 if (!ps_nice) 65 if (!ps_nice)
66 schedule_work(&ps_tq); 66 schedule_delayed_work(&ps_tq, 0);
67 else 67 else
68 schedule_delayed_work(&ps_tq, ps_nice-1); 68 schedule_delayed_work(&ps_tq, ps_nice-1);
69 } 69 }
70 spin_unlock_irqrestore(&ps_spinlock,flags); 70 spin_unlock_irqrestore(&ps_spinlock,flags);
71} 71}
72 72
73static void ps_tq_int(void *data) 73static void ps_tq_int(struct work_struct *work)
74{ 74{
75 void (*con)(void); 75 void (*con)(void);
76 unsigned long flags; 76 unsigned long flags;
@@ -92,7 +92,7 @@ static void ps_tq_int(void *data)
92 } 92 }
93 ps_tq_active = 1; 93 ps_tq_active = 1;
94 if (!ps_nice) 94 if (!ps_nice)
95 schedule_work(&ps_tq); 95 schedule_delayed_work(&ps_tq, 0);
96 else 96 else
97 schedule_delayed_work(&ps_tq, ps_nice-1); 97 schedule_delayed_work(&ps_tq, ps_nice-1);
98 spin_unlock_irqrestore(&ps_spinlock,flags); 98 spin_unlock_irqrestore(&ps_spinlock,flags);
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index 35fb26636721..c902b25e4869 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -946,12 +946,12 @@ static int __init pt_init(void)
946 int err; 946 int err;
947 947
948 if (disable) { 948 if (disable) {
949 err = -1; 949 err = -EINVAL;
950 goto out; 950 goto out;
951 } 951 }
952 952
953 if (pt_detect()) { 953 if (pt_detect()) {
954 err = -1; 954 err = -ENODEV;
955 goto out; 955 goto out;
956 } 956 }
957 957
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index f2904f67af47..e45eaa264119 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -54,7 +54,7 @@
54#include <linux/proc_fs.h> 54#include <linux/proc_fs.h>
55#include <linux/seq_file.h> 55#include <linux/seq_file.h>
56#include <linux/miscdevice.h> 56#include <linux/miscdevice.h>
57#include <linux/suspend.h> 57#include <linux/freezer.h>
58#include <linux/mutex.h> 58#include <linux/mutex.h>
59#include <scsi/scsi_cmnd.h> 59#include <scsi/scsi_cmnd.h>
60#include <scsi/scsi_ioctl.h> 60#include <scsi/scsi_ioctl.h>
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index 47d6975268ff..54509eb3391b 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -1244,9 +1244,10 @@ out:
1244 return IRQ_RETVAL(handled); 1244 return IRQ_RETVAL(handled);
1245} 1245}
1246 1246
1247static void carm_fsm_task (void *_data) 1247static void carm_fsm_task (struct work_struct *work)
1248{ 1248{
1249 struct carm_host *host = _data; 1249 struct carm_host *host =
1250 container_of(work, struct carm_host, fsm_task);
1250 unsigned long flags; 1251 unsigned long flags;
1251 unsigned int state; 1252 unsigned int state;
1252 int rc, i, next_dev; 1253 int rc, i, next_dev;
@@ -1619,7 +1620,7 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1619 host->pdev = pdev; 1620 host->pdev = pdev;
1620 host->flags = pci_dac ? FL_DAC : 0; 1621 host->flags = pci_dac ? FL_DAC : 0;
1621 spin_lock_init(&host->lock); 1622 spin_lock_init(&host->lock);
1622 INIT_WORK(&host->fsm_task, carm_fsm_task, host); 1623 INIT_WORK(&host->fsm_task, carm_fsm_task);
1623 init_completion(&host->probe_comp); 1624 init_completion(&host->probe_comp);
1624 1625
1625 for (i = 0; i < ARRAY_SIZE(host->req); i++) 1626 for (i = 0; i < ARRAY_SIZE(host->req); i++)
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 0d5c73f07265..2098eff91e14 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -376,7 +376,7 @@ static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd,
376 int stalled_pipe); 376 int stalled_pipe);
377static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd); 377static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd);
378static void ub_reset_enter(struct ub_dev *sc, int try); 378static void ub_reset_enter(struct ub_dev *sc, int try);
379static void ub_reset_task(void *arg); 379static void ub_reset_task(struct work_struct *work);
380static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun); 380static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun);
381static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, 381static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun,
382 struct ub_capacity *ret); 382 struct ub_capacity *ret);
@@ -1558,9 +1558,9 @@ static void ub_reset_enter(struct ub_dev *sc, int try)
1558 schedule_work(&sc->reset_work); 1558 schedule_work(&sc->reset_work);
1559} 1559}
1560 1560
1561static void ub_reset_task(void *arg) 1561static void ub_reset_task(struct work_struct *work)
1562{ 1562{
1563 struct ub_dev *sc = arg; 1563 struct ub_dev *sc = container_of(work, struct ub_dev, reset_work);
1564 unsigned long flags; 1564 unsigned long flags;
1565 struct list_head *p; 1565 struct list_head *p;
1566 struct ub_lun *lun; 1566 struct ub_lun *lun;
@@ -2179,7 +2179,7 @@ static int ub_probe(struct usb_interface *intf,
2179 usb_init_urb(&sc->work_urb); 2179 usb_init_urb(&sc->work_urb);
2180 tasklet_init(&sc->tasklet, ub_scsi_action, (unsigned long)sc); 2180 tasklet_init(&sc->tasklet, ub_scsi_action, (unsigned long)sc);
2181 atomic_set(&sc->poison, 0); 2181 atomic_set(&sc->poison, 0);
2182 INIT_WORK(&sc->reset_work, ub_reset_task, sc); 2182 INIT_WORK(&sc->reset_work, ub_reset_task);
2183 init_waitqueue_head(&sc->reset_wait); 2183 init_waitqueue_head(&sc->reset_wait);
2184 2184
2185 init_timer(&sc->work_timer); 2185 init_timer(&sc->work_timer);
diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
index 516751754aa9..9256985cbe36 100644
--- a/drivers/bluetooth/bcm203x.c
+++ b/drivers/bluetooth/bcm203x.c
@@ -157,9 +157,10 @@ static void bcm203x_complete(struct urb *urb)
157 } 157 }
158} 158}
159 159
160static void bcm203x_work(void *user_data) 160static void bcm203x_work(struct work_struct *work)
161{ 161{
162 struct bcm203x_data *data = user_data; 162 struct bcm203x_data *data =
163 container_of(work, struct bcm203x_data, work);
163 164
164 if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0) 165 if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0)
165 BT_ERR("Can't submit URB"); 166 BT_ERR("Can't submit URB");
@@ -246,7 +247,7 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
246 247
247 release_firmware(firmware); 248 release_firmware(firmware);
248 249
249 INIT_WORK(&data->work, bcm203x_work, (void *) data); 250 INIT_WORK(&data->work, bcm203x_work);
250 251
251 usb_set_intfdata(intf, data); 252 usb_set_intfdata(intf, data);
252 253
diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c
index d0cface535fb..5e2c31882003 100644
--- a/drivers/bluetooth/hci_bcsp.c
+++ b/drivers/bluetooth/hci_bcsp.c
@@ -330,7 +330,7 @@ static struct sk_buff *bcsp_dequeue(struct hci_uart *hu)
330 reliable packet if the number of packets sent but not yet ack'ed 330 reliable packet if the number of packets sent but not yet ack'ed
331 is < than the winsize */ 331 is < than the winsize */
332 332
333 spin_lock_irqsave(&bcsp->unack.lock, flags); 333 spin_lock_irqsave_nested(&bcsp->unack.lock, flags, SINGLE_DEPTH_NESTING);
334 334
335 if (bcsp->unack.qlen < BCSP_TXWINSIZE && (skb = skb_dequeue(&bcsp->rel)) != NULL) { 335 if (bcsp->unack.qlen < BCSP_TXWINSIZE && (skb = skb_dequeue(&bcsp->rel)) != NULL) {
336 struct sk_buff *nskb = bcsp_prepare_pkt(bcsp, skb->data, skb->len, bt_cb(skb)->pkt_type); 336 struct sk_buff *nskb = bcsp_prepare_pkt(bcsp, skb->data, skb->len, bt_cb(skb)->pkt_type);
@@ -696,7 +696,7 @@ static void bcsp_timed_event(unsigned long arg)
696 696
697 BT_DBG("hu %p retransmitting %u pkts", hu, bcsp->unack.qlen); 697 BT_DBG("hu %p retransmitting %u pkts", hu, bcsp->unack.qlen);
698 698
699 spin_lock_irqsave(&bcsp->unack.lock, flags); 699 spin_lock_irqsave_nested(&bcsp->unack.lock, flags, SINGLE_DEPTH_NESTING);
700 700
701 while ((skb = __skb_dequeue_tail(&bcsp->unack)) != NULL) { 701 while ((skb = __skb_dequeue_tail(&bcsp->unack)) != NULL) {
702 bcsp->msgq_txseq = (bcsp->msgq_txseq - 1) & 0x07; 702 bcsp->msgq_txseq = (bcsp->msgq_txseq - 1) & 0x07;
diff --git a/drivers/cdrom/optcd.c b/drivers/cdrom/optcd.c
index 25032d7edc55..3541690a77d4 100644
--- a/drivers/cdrom/optcd.c
+++ b/drivers/cdrom/optcd.c
@@ -101,7 +101,7 @@ static void debug(int debug_this, const char* fmt, ...)
101 return; 101 return;
102 102
103 va_start(args, fmt); 103 va_start(args, fmt);
104 vsprintf(s, fmt, args); 104 vsnprintf(s, sizeof(s), fmt, args);
105 printk(KERN_DEBUG "optcd: %s\n", s); 105 printk(KERN_DEBUG "optcd: %s\n", s);
106 va_end(args); 106 va_end(args);
107} 107}
diff --git a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c
index ba50e5a712f2..a1283b1ef989 100644
--- a/drivers/cdrom/sbpcd.c
+++ b/drivers/cdrom/sbpcd.c
@@ -770,11 +770,10 @@ static void msg(int level, const char *fmt, ...)
770 770
771 msgnum++; 771 msgnum++;
772 if (msgnum>99) msgnum=0; 772 if (msgnum>99) msgnum=0;
773 sprintf(buf, MSG_LEVEL "%s-%d [%02d]: ", major_name, current_drive - D_S, msgnum);
774 va_start(args, fmt); 773 va_start(args, fmt);
775 vsprintf(&buf[18], fmt, args); 774 vsnprintf(buf, sizeof(buf), fmt, args);
776 va_end(args); 775 va_end(args);
777 printk(buf); 776 printk(MSG_LEVEL "%s-%d [%02d]: %s", major_name, current_drive - D_S, msgnum, buf);
778#if KLOGD_PAUSE 777#if KLOGD_PAUSE
779 sbp_sleep(KLOGD_PAUSE); /* else messages get lost */ 778 sbp_sleep(KLOGD_PAUSE); /* else messages get lost */
780#endif /* KLOGD_PAUSE */ 779#endif /* KLOGD_PAUSE */
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 00b17ae39736..2f2c4efff8a3 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -459,7 +459,7 @@ static const struct aper_size_info_32 nforce3_sizes[5] =
459 459
460/* Handle shadow device of the Nvidia NForce3 */ 460/* Handle shadow device of the Nvidia NForce3 */
461/* CHECK-ME original 2.4 version set up some IORRs. Check if that is needed. */ 461/* CHECK-ME original 2.4 version set up some IORRs. Check if that is needed. */
462static int __devinit nforce3_agp_init(struct pci_dev *pdev) 462static int nforce3_agp_init(struct pci_dev *pdev)
463{ 463{
464 u32 tmp, apbase, apbar, aplimit; 464 u32 tmp, apbase, apbar, aplimit;
465 struct pci_dev *dev1; 465 struct pci_dev *dev1;
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index e608dadece2f..acb2de5e3a98 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -926,9 +926,10 @@ cy_sched_event(struct cyclades_port *info, int event)
926 * had to poll every port to see if that port needed servicing. 926 * had to poll every port to see if that port needed servicing.
927 */ 927 */
928static void 928static void
929do_softint(void *private_) 929do_softint(struct work_struct *work)
930{ 930{
931 struct cyclades_port *info = (struct cyclades_port *) private_; 931 struct cyclades_port *info =
932 container_of(work, struct cyclades_port, tqueue);
932 struct tty_struct *tty; 933 struct tty_struct *tty;
933 934
934 tty = info->tty; 935 tty = info->tty;
@@ -5328,7 +5329,7 @@ cy_init(void)
5328 info->blocked_open = 0; 5329 info->blocked_open = 0;
5329 info->default_threshold = 0; 5330 info->default_threshold = 0;
5330 info->default_timeout = 0; 5331 info->default_timeout = 0;
5331 INIT_WORK(&info->tqueue, do_softint, info); 5332 INIT_WORK(&info->tqueue, do_softint);
5332 init_waitqueue_head(&info->open_wait); 5333 init_waitqueue_head(&info->open_wait);
5333 init_waitqueue_head(&info->close_wait); 5334 init_waitqueue_head(&info->close_wait);
5334 init_waitqueue_head(&info->shutdown_wait); 5335 init_waitqueue_head(&info->shutdown_wait);
@@ -5403,7 +5404,7 @@ cy_init(void)
5403 info->blocked_open = 0; 5404 info->blocked_open = 0;
5404 info->default_threshold = 0; 5405 info->default_threshold = 0;
5405 info->default_timeout = 0; 5406 info->default_timeout = 0;
5406 INIT_WORK(&info->tqueue, do_softint, info); 5407 INIT_WORK(&info->tqueue, do_softint);
5407 init_waitqueue_head(&info->open_wait); 5408 init_waitqueue_head(&info->open_wait);
5408 init_waitqueue_head(&info->close_wait); 5409 init_waitqueue_head(&info->close_wait);
5409 init_waitqueue_head(&info->shutdown_wait); 5410 init_waitqueue_head(&info->shutdown_wait);
diff --git a/drivers/char/decserial.c b/drivers/char/decserial.c
index 85f404e25c73..8ea2bea2b183 100644
--- a/drivers/char/decserial.c
+++ b/drivers/char/decserial.c
@@ -23,20 +23,12 @@
23extern int zs_init(void); 23extern int zs_init(void);
24#endif 24#endif
25 25
26#ifdef CONFIG_DZ
27extern int dz_init(void);
28#endif
29
30#ifdef CONFIG_SERIAL_CONSOLE 26#ifdef CONFIG_SERIAL_CONSOLE
31 27
32#ifdef CONFIG_ZS 28#ifdef CONFIG_ZS
33extern void zs_serial_console_init(void); 29extern void zs_serial_console_init(void);
34#endif 30#endif
35 31
36#ifdef CONFIG_DZ
37extern void dz_serial_console_init(void);
38#endif
39
40#endif 32#endif
41 33
42/* rs_init - starts up the serial interface - 34/* rs_init - starts up the serial interface -
@@ -46,23 +38,11 @@ extern void dz_serial_console_init(void);
46 38
47int __init rs_init(void) 39int __init rs_init(void)
48{ 40{
49 41#ifdef CONFIG_ZS
50#if defined(CONFIG_ZS) && defined(CONFIG_DZ)
51 if (IOASIC) 42 if (IOASIC)
52 return zs_init(); 43 return zs_init();
53 else
54 return dz_init();
55#else
56
57#ifdef CONFIG_ZS
58 return zs_init();
59#endif
60
61#ifdef CONFIG_DZ
62 return dz_init();
63#endif
64
65#endif 44#endif
45 return -ENXIO;
66} 46}
67 47
68__initcall(rs_init); 48__initcall(rs_init);
@@ -76,21 +56,9 @@ __initcall(rs_init);
76 */ 56 */
77static int __init decserial_console_init(void) 57static int __init decserial_console_init(void)
78{ 58{
79#if defined(CONFIG_ZS) && defined(CONFIG_DZ) 59#ifdef CONFIG_ZS
80 if (IOASIC) 60 if (IOASIC)
81 zs_serial_console_init(); 61 zs_serial_console_init();
82 else
83 dz_serial_console_init();
84#else
85
86#ifdef CONFIG_ZS
87 zs_serial_console_init();
88#endif
89
90#ifdef CONFIG_DZ
91 dz_serial_console_init();
92#endif
93
94#endif 62#endif
95 return 0; 63 return 0;
96} 64}
diff --git a/drivers/char/drm/drm_sman.c b/drivers/char/drm/drm_sman.c
index 425c82336ee0..19c81d2e13d0 100644
--- a/drivers/char/drm/drm_sman.c
+++ b/drivers/char/drm/drm_sman.c
@@ -162,6 +162,7 @@ drm_sman_set_manager(drm_sman_t * sman, unsigned int manager,
162 162
163 return 0; 163 return 0;
164} 164}
165EXPORT_SYMBOL(drm_sman_set_manager);
165 166
166static drm_owner_item_t *drm_sman_get_owner_item(drm_sman_t * sman, 167static drm_owner_item_t *drm_sman_get_owner_item(drm_sman_t * sman,
167 unsigned long owner) 168 unsigned long owner)
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index b40ae438f531..ae2691942ddb 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -147,14 +147,14 @@ static __inline__ struct page *drm_do_vm_shm_nopage(struct vm_area_struct *vma,
147 if (address > vma->vm_end) 147 if (address > vma->vm_end)
148 return NOPAGE_SIGBUS; /* Disallow mremap */ 148 return NOPAGE_SIGBUS; /* Disallow mremap */
149 if (!map) 149 if (!map)
150 return NOPAGE_OOM; /* Nothing allocated */ 150 return NOPAGE_SIGBUS; /* Nothing allocated */
151 151
152 offset = address - vma->vm_start; 152 offset = address - vma->vm_start;
153 i = (unsigned long)map->handle + offset; 153 i = (unsigned long)map->handle + offset;
154 page = (map->type == _DRM_CONSISTENT) ? 154 page = (map->type == _DRM_CONSISTENT) ?
155 virt_to_page((void *)i) : vmalloc_to_page((void *)i); 155 virt_to_page((void *)i) : vmalloc_to_page((void *)i);
156 if (!page) 156 if (!page)
157 return NOPAGE_OOM; 157 return NOPAGE_SIGBUS;
158 get_page(page); 158 get_page(page);
159 159
160 DRM_DEBUG("shm_nopage 0x%lx\n", address); 160 DRM_DEBUG("shm_nopage 0x%lx\n", address);
@@ -272,7 +272,7 @@ static __inline__ struct page *drm_do_vm_dma_nopage(struct vm_area_struct *vma,
272 if (address > vma->vm_end) 272 if (address > vma->vm_end)
273 return NOPAGE_SIGBUS; /* Disallow mremap */ 273 return NOPAGE_SIGBUS; /* Disallow mremap */
274 if (!dma->pagelist) 274 if (!dma->pagelist)
275 return NOPAGE_OOM; /* Nothing allocated */ 275 return NOPAGE_SIGBUS; /* Nothing allocated */
276 276
277 offset = address - vma->vm_start; /* vm_[pg]off[set] should be 0 */ 277 offset = address - vma->vm_start; /* vm_[pg]off[set] should be 0 */
278 page_nr = offset >> PAGE_SHIFT; 278 page_nr = offset >> PAGE_SHIFT;
@@ -310,7 +310,7 @@ static __inline__ struct page *drm_do_vm_sg_nopage(struct vm_area_struct *vma,
310 if (address > vma->vm_end) 310 if (address > vma->vm_end)
311 return NOPAGE_SIGBUS; /* Disallow mremap */ 311 return NOPAGE_SIGBUS; /* Disallow mremap */
312 if (!entry->pagelist) 312 if (!entry->pagelist)
313 return NOPAGE_OOM; /* Nothing allocated */ 313 return NOPAGE_SIGBUS; /* Nothing allocated */
314 314
315 offset = address - vma->vm_start; 315 offset = address - vma->vm_start;
316 map_offset = map->offset - (unsigned long)dev->sg->virtual; 316 map_offset = map->offset - (unsigned long)dev->sg->virtual;
diff --git a/drivers/char/drm/via_dmablit.c b/drivers/char/drm/via_dmablit.c
index 60c1695db300..806f9ce5f47b 100644
--- a/drivers/char/drm/via_dmablit.c
+++ b/drivers/char/drm/via_dmablit.c
@@ -500,9 +500,9 @@ via_dmablit_timer(unsigned long data)
500 500
501 501
502static void 502static void
503via_dmablit_workqueue(void *data) 503via_dmablit_workqueue(struct work_struct *work)
504{ 504{
505 drm_via_blitq_t *blitq = (drm_via_blitq_t *) data; 505 drm_via_blitq_t *blitq = container_of(work, drm_via_blitq_t, wq);
506 drm_device_t *dev = blitq->dev; 506 drm_device_t *dev = blitq->dev;
507 unsigned long irqsave; 507 unsigned long irqsave;
508 drm_via_sg_info_t *cur_sg; 508 drm_via_sg_info_t *cur_sg;
@@ -571,7 +571,7 @@ via_init_dmablit(drm_device_t *dev)
571 DRM_INIT_WAITQUEUE(blitq->blit_queue + j); 571 DRM_INIT_WAITQUEUE(blitq->blit_queue + j);
572 } 572 }
573 DRM_INIT_WAITQUEUE(&blitq->busy_queue); 573 DRM_INIT_WAITQUEUE(&blitq->busy_queue);
574 INIT_WORK(&blitq->wq, via_dmablit_workqueue, blitq); 574 INIT_WORK(&blitq->wq, via_dmablit_workqueue);
575 init_timer(&blitq->poll_timer); 575 init_timer(&blitq->poll_timer);
576 blitq->poll_timer.function = &via_dmablit_timer; 576 blitq->poll_timer.function = &via_dmablit_timer;
577 blitq->poll_timer.data = (unsigned long) blitq; 577 blitq->poll_timer.data = (unsigned long) blitq;
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index 706733c0b36a..7c71eb779802 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -200,7 +200,7 @@ static int pc_ioctl(struct tty_struct *, struct file *,
200static int info_ioctl(struct tty_struct *, struct file *, 200static int info_ioctl(struct tty_struct *, struct file *,
201 unsigned int, unsigned long); 201 unsigned int, unsigned long);
202static void pc_set_termios(struct tty_struct *, struct termios *); 202static void pc_set_termios(struct tty_struct *, struct termios *);
203static void do_softint(void *); 203static void do_softint(struct work_struct *work);
204static void pc_stop(struct tty_struct *); 204static void pc_stop(struct tty_struct *);
205static void pc_start(struct tty_struct *); 205static void pc_start(struct tty_struct *);
206static void pc_throttle(struct tty_struct * tty); 206static void pc_throttle(struct tty_struct * tty);
@@ -1505,7 +1505,7 @@ static void post_fep_init(unsigned int crd)
1505 1505
1506 ch->brdchan = bc; 1506 ch->brdchan = bc;
1507 ch->mailbox = gd; 1507 ch->mailbox = gd;
1508 INIT_WORK(&ch->tqueue, do_softint, ch); 1508 INIT_WORK(&ch->tqueue, do_softint);
1509 ch->board = &boards[crd]; 1509 ch->board = &boards[crd];
1510 1510
1511 spin_lock_irqsave(&epca_lock, flags); 1511 spin_lock_irqsave(&epca_lock, flags);
@@ -2566,9 +2566,9 @@ static void pc_set_termios(struct tty_struct *tty, struct termios *old_termios)
2566 2566
2567/* --------------------- Begin do_softint ----------------------- */ 2567/* --------------------- Begin do_softint ----------------------- */
2568 2568
2569static void do_softint(void *private_) 2569static void do_softint(struct work_struct *work)
2570{ /* Begin do_softint */ 2570{ /* Begin do_softint */
2571 struct channel *ch = (struct channel *) private_; 2571 struct channel *ch = container_of(work, struct channel, tqueue);
2572 /* Called in response to a modem change event */ 2572 /* Called in response to a modem change event */
2573 if (ch && ch->magic == EPCA_MAGIC) { /* Begin EPCA_MAGIC */ 2573 if (ch && ch->magic == EPCA_MAGIC) { /* Begin EPCA_MAGIC */
2574 struct tty_struct *tty = ch->tty; 2574 struct tty_struct *tty = ch->tty;
diff --git a/drivers/char/esp.c b/drivers/char/esp.c
index 15a4ea896328..93b551962513 100644
--- a/drivers/char/esp.c
+++ b/drivers/char/esp.c
@@ -723,9 +723,10 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
723 * ------------------------------------------------------------------- 723 * -------------------------------------------------------------------
724 */ 724 */
725 725
726static void do_softint(void *private_) 726static void do_softint(struct work_struct *work)
727{ 727{
728 struct esp_struct *info = (struct esp_struct *) private_; 728 struct esp_struct *info =
729 container_of(work, struct esp_struct, tqueue);
729 struct tty_struct *tty; 730 struct tty_struct *tty;
730 731
731 tty = info->tty; 732 tty = info->tty;
@@ -746,9 +747,10 @@ static void do_softint(void *private_)
746 * do_serial_hangup() -> tty->hangup() -> esp_hangup() 747 * do_serial_hangup() -> tty->hangup() -> esp_hangup()
747 * 748 *
748 */ 749 */
749static void do_serial_hangup(void *private_) 750static void do_serial_hangup(struct work_struct *work)
750{ 751{
751 struct esp_struct *info = (struct esp_struct *) private_; 752 struct esp_struct *info =
753 container_of(work, struct esp_struct, tqueue_hangup);
752 struct tty_struct *tty; 754 struct tty_struct *tty;
753 755
754 tty = info->tty; 756 tty = info->tty;
@@ -2501,8 +2503,8 @@ static int __init espserial_init(void)
2501 info->magic = ESP_MAGIC; 2503 info->magic = ESP_MAGIC;
2502 info->close_delay = 5*HZ/10; 2504 info->close_delay = 5*HZ/10;
2503 info->closing_wait = 30*HZ; 2505 info->closing_wait = 30*HZ;
2504 INIT_WORK(&info->tqueue, do_softint, info); 2506 INIT_WORK(&info->tqueue, do_softint);
2505 INIT_WORK(&info->tqueue_hangup, do_serial_hangup, info); 2507 INIT_WORK(&info->tqueue_hangup, do_serial_hangup);
2506 info->config.rx_timeout = rx_timeout; 2508 info->config.rx_timeout = rx_timeout;
2507 info->config.flow_on = flow_on; 2509 info->config.flow_on = flow_on;
2508 info->config.flow_off = flow_off; 2510 info->config.flow_off = flow_off;
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
index 817dc409ac20..23b25ada65ea 100644
--- a/drivers/char/genrtc.c
+++ b/drivers/char/genrtc.c
@@ -102,7 +102,7 @@ static void gen_rtc_interrupt(unsigned long arg);
102 * Routine to poll RTC seconds field for change as often as possible, 102 * Routine to poll RTC seconds field for change as often as possible,
103 * after first RTC_UIE use timer to reduce polling 103 * after first RTC_UIE use timer to reduce polling
104 */ 104 */
105static void genrtc_troutine(void *data) 105static void genrtc_troutine(struct work_struct *work)
106{ 106{
107 unsigned int tmp = get_rtc_ss(); 107 unsigned int tmp = get_rtc_ss();
108 108
@@ -255,7 +255,7 @@ static inline int gen_set_rtc_irq_bit(unsigned char bit)
255 irq_active = 1; 255 irq_active = 1;
256 stop_rtc_timers = 0; 256 stop_rtc_timers = 0;
257 lostint = 0; 257 lostint = 0;
258 INIT_WORK(&genrtc_task, genrtc_troutine, NULL); 258 INIT_WORK(&genrtc_task, genrtc_troutine);
259 oldsecs = get_rtc_ss(); 259 oldsecs = get_rtc_ss();
260 init_timer(&timer_task); 260 init_timer(&timer_task);
261 261
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index 9902ffad3b12..cc2cd46bedc6 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -38,6 +38,7 @@
38#include <linux/sched.h> 38#include <linux/sched.h>
39#include <linux/spinlock.h> 39#include <linux/spinlock.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/freezer.h>
41 42
42#include <asm/uaccess.h> 43#include <asm/uaccess.h>
43 44
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index 8728255c9463..d090622f1dea 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -337,11 +337,6 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp);
337static void hvcs_close(struct tty_struct *tty, struct file *filp); 337static void hvcs_close(struct tty_struct *tty, struct file *filp);
338static void hvcs_hangup(struct tty_struct * tty); 338static void hvcs_hangup(struct tty_struct * tty);
339 339
340static void hvcs_create_device_attrs(struct hvcs_struct *hvcsd);
341static void hvcs_remove_device_attrs(struct vio_dev *vdev);
342static void hvcs_create_driver_attrs(void);
343static void hvcs_remove_driver_attrs(void);
344
345static int __devinit hvcs_probe(struct vio_dev *dev, 340static int __devinit hvcs_probe(struct vio_dev *dev,
346 const struct vio_device_id *id); 341 const struct vio_device_id *id);
347static int __devexit hvcs_remove(struct vio_dev *dev); 342static int __devexit hvcs_remove(struct vio_dev *dev);
@@ -353,6 +348,172 @@ static void __exit hvcs_module_exit(void);
353#define HVCS_TRY_WRITE 0x00000004 348#define HVCS_TRY_WRITE 0x00000004
354#define HVCS_READ_MASK (HVCS_SCHED_READ | HVCS_QUICK_READ) 349#define HVCS_READ_MASK (HVCS_SCHED_READ | HVCS_QUICK_READ)
355 350
351static inline struct hvcs_struct *from_vio_dev(struct vio_dev *viod)
352{
353 return viod->dev.driver_data;
354}
355/* The sysfs interface for the driver and devices */
356
357static ssize_t hvcs_partner_vtys_show(struct device *dev, struct device_attribute *attr, char *buf)
358{
359 struct vio_dev *viod = to_vio_dev(dev);
360 struct hvcs_struct *hvcsd = from_vio_dev(viod);
361 unsigned long flags;
362 int retval;
363
364 spin_lock_irqsave(&hvcsd->lock, flags);
365 retval = sprintf(buf, "%X\n", hvcsd->p_unit_address);
366 spin_unlock_irqrestore(&hvcsd->lock, flags);
367 return retval;
368}
369static DEVICE_ATTR(partner_vtys, S_IRUGO, hvcs_partner_vtys_show, NULL);
370
371static ssize_t hvcs_partner_clcs_show(struct device *dev, struct device_attribute *attr, char *buf)
372{
373 struct vio_dev *viod = to_vio_dev(dev);
374 struct hvcs_struct *hvcsd = from_vio_dev(viod);
375 unsigned long flags;
376 int retval;
377
378 spin_lock_irqsave(&hvcsd->lock, flags);
379 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
380 spin_unlock_irqrestore(&hvcsd->lock, flags);
381 return retval;
382}
383static DEVICE_ATTR(partner_clcs, S_IRUGO, hvcs_partner_clcs_show, NULL);
384
385static ssize_t hvcs_current_vty_store(struct device *dev, struct device_attribute *attr, const char * buf,
386 size_t count)
387{
388 /*
389 * Don't need this feature at the present time because firmware doesn't
390 * yet support multiple partners.
391 */
392 printk(KERN_INFO "HVCS: Denied current_vty change: -EPERM.\n");
393 return -EPERM;
394}
395
396static ssize_t hvcs_current_vty_show(struct device *dev, struct device_attribute *attr, char *buf)
397{
398 struct vio_dev *viod = to_vio_dev(dev);
399 struct hvcs_struct *hvcsd = from_vio_dev(viod);
400 unsigned long flags;
401 int retval;
402
403 spin_lock_irqsave(&hvcsd->lock, flags);
404 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
405 spin_unlock_irqrestore(&hvcsd->lock, flags);
406 return retval;
407}
408
409static DEVICE_ATTR(current_vty,
410 S_IRUGO | S_IWUSR, hvcs_current_vty_show, hvcs_current_vty_store);
411
412static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribute *attr, const char *buf,
413 size_t count)
414{
415 struct vio_dev *viod = to_vio_dev(dev);
416 struct hvcs_struct *hvcsd = from_vio_dev(viod);
417 unsigned long flags;
418
419 /* writing a '0' to this sysfs entry will result in the disconnect. */
420 if (simple_strtol(buf, NULL, 0) != 0)
421 return -EINVAL;
422
423 spin_lock_irqsave(&hvcsd->lock, flags);
424
425 if (hvcsd->open_count > 0) {
426 spin_unlock_irqrestore(&hvcsd->lock, flags);
427 printk(KERN_INFO "HVCS: vterm state unchanged. "
428 "The hvcs device node is still in use.\n");
429 return -EPERM;
430 }
431
432 if (hvcsd->connected == 0) {
433 spin_unlock_irqrestore(&hvcsd->lock, flags);
434 printk(KERN_INFO "HVCS: vterm state unchanged. The"
435 " vty-server is not connected to a vty.\n");
436 return -EPERM;
437 }
438
439 hvcs_partner_free(hvcsd);
440 printk(KERN_INFO "HVCS: Closed vty-server@%X and"
441 " partner vty@%X:%d connection.\n",
442 hvcsd->vdev->unit_address,
443 hvcsd->p_unit_address,
444 (uint32_t)hvcsd->p_partition_ID);
445
446 spin_unlock_irqrestore(&hvcsd->lock, flags);
447 return count;
448}
449
450static ssize_t hvcs_vterm_state_show(struct device *dev, struct device_attribute *attr, char *buf)
451{
452 struct vio_dev *viod = to_vio_dev(dev);
453 struct hvcs_struct *hvcsd = from_vio_dev(viod);
454 unsigned long flags;
455 int retval;
456
457 spin_lock_irqsave(&hvcsd->lock, flags);
458 retval = sprintf(buf, "%d\n", hvcsd->connected);
459 spin_unlock_irqrestore(&hvcsd->lock, flags);
460 return retval;
461}
462static DEVICE_ATTR(vterm_state, S_IRUGO | S_IWUSR,
463 hvcs_vterm_state_show, hvcs_vterm_state_store);
464
465static ssize_t hvcs_index_show(struct device *dev, struct device_attribute *attr, char *buf)
466{
467 struct vio_dev *viod = to_vio_dev(dev);
468 struct hvcs_struct *hvcsd = from_vio_dev(viod);
469 unsigned long flags;
470 int retval;
471
472 spin_lock_irqsave(&hvcsd->lock, flags);
473 retval = sprintf(buf, "%d\n", hvcsd->index);
474 spin_unlock_irqrestore(&hvcsd->lock, flags);
475 return retval;
476}
477
478static DEVICE_ATTR(index, S_IRUGO, hvcs_index_show, NULL);
479
480static struct attribute *hvcs_attrs[] = {
481 &dev_attr_partner_vtys.attr,
482 &dev_attr_partner_clcs.attr,
483 &dev_attr_current_vty.attr,
484 &dev_attr_vterm_state.attr,
485 &dev_attr_index.attr,
486 NULL,
487};
488
489static struct attribute_group hvcs_attr_group = {
490 .attrs = hvcs_attrs,
491};
492
493static ssize_t hvcs_rescan_show(struct device_driver *ddp, char *buf)
494{
495 /* A 1 means it is updating, a 0 means it is done updating */
496 return snprintf(buf, PAGE_SIZE, "%d\n", hvcs_rescan_status);
497}
498
499static ssize_t hvcs_rescan_store(struct device_driver *ddp, const char * buf,
500 size_t count)
501{
502 if ((simple_strtol(buf, NULL, 0) != 1)
503 && (hvcs_rescan_status != 0))
504 return -EINVAL;
505
506 hvcs_rescan_status = 1;
507 printk(KERN_INFO "HVCS: rescanning partner info for all"
508 " vty-servers.\n");
509 hvcs_rescan_devices_list();
510 hvcs_rescan_status = 0;
511 return count;
512}
513
514static DRIVER_ATTR(rescan,
515 S_IRUGO | S_IWUSR, hvcs_rescan_show, hvcs_rescan_store);
516
356static void hvcs_kick(void) 517static void hvcs_kick(void)
357{ 518{
358 hvcs_kicked = 1; 519 hvcs_kicked = 1;
@@ -575,7 +736,7 @@ static void destroy_hvcs_struct(struct kobject *kobj)
575 spin_unlock_irqrestore(&hvcsd->lock, flags); 736 spin_unlock_irqrestore(&hvcsd->lock, flags);
576 spin_unlock(&hvcs_structs_lock); 737 spin_unlock(&hvcs_structs_lock);
577 738
578 hvcs_remove_device_attrs(vdev); 739 sysfs_remove_group(&vdev->dev.kobj, &hvcs_attr_group);
579 740
580 kfree(hvcsd); 741 kfree(hvcsd);
581} 742}
@@ -608,6 +769,7 @@ static int __devinit hvcs_probe(
608{ 769{
609 struct hvcs_struct *hvcsd; 770 struct hvcs_struct *hvcsd;
610 int index; 771 int index;
772 int retval;
611 773
612 if (!dev || !id) { 774 if (!dev || !id) {
613 printk(KERN_ERR "HVCS: probed with invalid parameter.\n"); 775 printk(KERN_ERR "HVCS: probed with invalid parameter.\n");
@@ -658,14 +820,16 @@ static int __devinit hvcs_probe(
658 * the hvcs_struct has been added to the devices list then the user app 820 * the hvcs_struct has been added to the devices list then the user app
659 * will get -ENODEV. 821 * will get -ENODEV.
660 */ 822 */
661
662 spin_lock(&hvcs_structs_lock); 823 spin_lock(&hvcs_structs_lock);
663
664 list_add_tail(&(hvcsd->next), &hvcs_structs); 824 list_add_tail(&(hvcsd->next), &hvcs_structs);
665
666 spin_unlock(&hvcs_structs_lock); 825 spin_unlock(&hvcs_structs_lock);
667 826
668 hvcs_create_device_attrs(hvcsd); 827 retval = sysfs_create_group(&dev->dev.kobj, &hvcs_attr_group);
828 if (retval) {
829 printk(KERN_ERR "HVCS: Can't create sysfs attrs for vty-server@%X\n",
830 hvcsd->vdev->unit_address);
831 return retval;
832 }
669 833
670 printk(KERN_INFO "HVCS: vty-server@%X added to the vio bus.\n", dev->unit_address); 834 printk(KERN_INFO "HVCS: vty-server@%X added to the vio bus.\n", dev->unit_address);
671 835
@@ -1354,8 +1518,10 @@ static int __init hvcs_module_init(void)
1354 if (!hvcs_tty_driver) 1518 if (!hvcs_tty_driver)
1355 return -ENOMEM; 1519 return -ENOMEM;
1356 1520
1357 if (hvcs_alloc_index_list(num_ttys_to_alloc)) 1521 if (hvcs_alloc_index_list(num_ttys_to_alloc)) {
1358 return -ENOMEM; 1522 rc = -ENOMEM;
1523 goto index_fail;
1524 }
1359 1525
1360 hvcs_tty_driver->owner = THIS_MODULE; 1526 hvcs_tty_driver->owner = THIS_MODULE;
1361 1527
@@ -1385,41 +1551,57 @@ static int __init hvcs_module_init(void)
1385 * dynamically assigned major and minor numbers for our devices. 1551 * dynamically assigned major and minor numbers for our devices.
1386 */ 1552 */
1387 if (tty_register_driver(hvcs_tty_driver)) { 1553 if (tty_register_driver(hvcs_tty_driver)) {
1388 printk(KERN_ERR "HVCS: registration " 1554 printk(KERN_ERR "HVCS: registration as a tty driver failed.\n");
1389 " as a tty driver failed.\n"); 1555 rc = -EIO;
1390 hvcs_free_index_list(); 1556 goto register_fail;
1391 put_tty_driver(hvcs_tty_driver);
1392 return -EIO;
1393 } 1557 }
1394 1558
1395 hvcs_pi_buff = kmalloc(PAGE_SIZE, GFP_KERNEL); 1559 hvcs_pi_buff = kmalloc(PAGE_SIZE, GFP_KERNEL);
1396 if (!hvcs_pi_buff) { 1560 if (!hvcs_pi_buff) {
1397 tty_unregister_driver(hvcs_tty_driver); 1561 rc = -ENOMEM;
1398 hvcs_free_index_list(); 1562 goto buff_alloc_fail;
1399 put_tty_driver(hvcs_tty_driver);
1400 return -ENOMEM;
1401 } 1563 }
1402 1564
1403 hvcs_task = kthread_run(khvcsd, NULL, "khvcsd"); 1565 hvcs_task = kthread_run(khvcsd, NULL, "khvcsd");
1404 if (IS_ERR(hvcs_task)) { 1566 if (IS_ERR(hvcs_task)) {
1405 printk(KERN_ERR "HVCS: khvcsd creation failed. Driver not loaded.\n"); 1567 printk(KERN_ERR "HVCS: khvcsd creation failed. Driver not loaded.\n");
1406 kfree(hvcs_pi_buff); 1568 rc = -EIO;
1407 tty_unregister_driver(hvcs_tty_driver); 1569 goto kthread_fail;
1408 hvcs_free_index_list();
1409 put_tty_driver(hvcs_tty_driver);
1410 return -EIO;
1411 } 1570 }
1412 1571
1413 rc = vio_register_driver(&hvcs_vio_driver); 1572 rc = vio_register_driver(&hvcs_vio_driver);
1573 if (rc) {
1574 printk(KERN_ERR "HVCS: can't register vio driver\n");
1575 goto vio_fail;
1576 }
1414 1577
1415 /* 1578 /*
1416 * This needs to be done AFTER the vio_register_driver() call or else 1579 * This needs to be done AFTER the vio_register_driver() call or else
1417 * the kobjects won't be initialized properly. 1580 * the kobjects won't be initialized properly.
1418 */ 1581 */
1419 hvcs_create_driver_attrs(); 1582 rc = driver_create_file(&(hvcs_vio_driver.driver), &driver_attr_rescan);
1583 if (rc) {
1584 printk(KERN_ERR "HVCS: sysfs attr create failed\n");
1585 goto attr_fail;
1586 }
1420 1587
1421 printk(KERN_INFO "HVCS: driver module inserted.\n"); 1588 printk(KERN_INFO "HVCS: driver module inserted.\n");
1422 1589
1590 return 0;
1591
1592attr_fail:
1593 vio_unregister_driver(&hvcs_vio_driver);
1594vio_fail:
1595 kthread_stop(hvcs_task);
1596kthread_fail:
1597 kfree(hvcs_pi_buff);
1598buff_alloc_fail:
1599 tty_unregister_driver(hvcs_tty_driver);
1600register_fail:
1601 hvcs_free_index_list();
1602index_fail:
1603 put_tty_driver(hvcs_tty_driver);
1604 hvcs_tty_driver = NULL;
1423 return rc; 1605 return rc;
1424} 1606}
1425 1607
@@ -1441,7 +1623,7 @@ static void __exit hvcs_module_exit(void)
1441 hvcs_pi_buff = NULL; 1623 hvcs_pi_buff = NULL;
1442 spin_unlock(&hvcs_pi_lock); 1624 spin_unlock(&hvcs_pi_lock);
1443 1625
1444 hvcs_remove_driver_attrs(); 1626 driver_remove_file(&hvcs_vio_driver.driver, &driver_attr_rescan);
1445 1627
1446 vio_unregister_driver(&hvcs_vio_driver); 1628 vio_unregister_driver(&hvcs_vio_driver);
1447 1629
@@ -1456,191 +1638,3 @@ static void __exit hvcs_module_exit(void)
1456 1638
1457module_init(hvcs_module_init); 1639module_init(hvcs_module_init);
1458module_exit(hvcs_module_exit); 1640module_exit(hvcs_module_exit);
1459
1460static inline struct hvcs_struct *from_vio_dev(struct vio_dev *viod)
1461{
1462 return viod->dev.driver_data;
1463}
1464/* The sysfs interface for the driver and devices */
1465
1466static ssize_t hvcs_partner_vtys_show(struct device *dev, struct device_attribute *attr, char *buf)
1467{
1468 struct vio_dev *viod = to_vio_dev(dev);
1469 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1470 unsigned long flags;
1471 int retval;
1472
1473 spin_lock_irqsave(&hvcsd->lock, flags);
1474 retval = sprintf(buf, "%X\n", hvcsd->p_unit_address);
1475 spin_unlock_irqrestore(&hvcsd->lock, flags);
1476 return retval;
1477}
1478static DEVICE_ATTR(partner_vtys, S_IRUGO, hvcs_partner_vtys_show, NULL);
1479
1480static ssize_t hvcs_partner_clcs_show(struct device *dev, struct device_attribute *attr, char *buf)
1481{
1482 struct vio_dev *viod = to_vio_dev(dev);
1483 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1484 unsigned long flags;
1485 int retval;
1486
1487 spin_lock_irqsave(&hvcsd->lock, flags);
1488 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
1489 spin_unlock_irqrestore(&hvcsd->lock, flags);
1490 return retval;
1491}
1492static DEVICE_ATTR(partner_clcs, S_IRUGO, hvcs_partner_clcs_show, NULL);
1493
1494static ssize_t hvcs_current_vty_store(struct device *dev, struct device_attribute *attr, const char * buf,
1495 size_t count)
1496{
1497 /*
1498 * Don't need this feature at the present time because firmware doesn't
1499 * yet support multiple partners.
1500 */
1501 printk(KERN_INFO "HVCS: Denied current_vty change: -EPERM.\n");
1502 return -EPERM;
1503}
1504
1505static ssize_t hvcs_current_vty_show(struct device *dev, struct device_attribute *attr, char *buf)
1506{
1507 struct vio_dev *viod = to_vio_dev(dev);
1508 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1509 unsigned long flags;
1510 int retval;
1511
1512 spin_lock_irqsave(&hvcsd->lock, flags);
1513 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
1514 spin_unlock_irqrestore(&hvcsd->lock, flags);
1515 return retval;
1516}
1517
1518static DEVICE_ATTR(current_vty,
1519 S_IRUGO | S_IWUSR, hvcs_current_vty_show, hvcs_current_vty_store);
1520
1521static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribute *attr, const char *buf,
1522 size_t count)
1523{
1524 struct vio_dev *viod = to_vio_dev(dev);
1525 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1526 unsigned long flags;
1527
1528 /* writing a '0' to this sysfs entry will result in the disconnect. */
1529 if (simple_strtol(buf, NULL, 0) != 0)
1530 return -EINVAL;
1531
1532 spin_lock_irqsave(&hvcsd->lock, flags);
1533
1534 if (hvcsd->open_count > 0) {
1535 spin_unlock_irqrestore(&hvcsd->lock, flags);
1536 printk(KERN_INFO "HVCS: vterm state unchanged. "
1537 "The hvcs device node is still in use.\n");
1538 return -EPERM;
1539 }
1540
1541 if (hvcsd->connected == 0) {
1542 spin_unlock_irqrestore(&hvcsd->lock, flags);
1543 printk(KERN_INFO "HVCS: vterm state unchanged. The"
1544 " vty-server is not connected to a vty.\n");
1545 return -EPERM;
1546 }
1547
1548 hvcs_partner_free(hvcsd);
1549 printk(KERN_INFO "HVCS: Closed vty-server@%X and"
1550 " partner vty@%X:%d connection.\n",
1551 hvcsd->vdev->unit_address,
1552 hvcsd->p_unit_address,
1553 (uint32_t)hvcsd->p_partition_ID);
1554
1555 spin_unlock_irqrestore(&hvcsd->lock, flags);
1556 return count;
1557}
1558
1559static ssize_t hvcs_vterm_state_show(struct device *dev, struct device_attribute *attr, char *buf)
1560{
1561 struct vio_dev *viod = to_vio_dev(dev);
1562 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1563 unsigned long flags;
1564 int retval;
1565
1566 spin_lock_irqsave(&hvcsd->lock, flags);
1567 retval = sprintf(buf, "%d\n", hvcsd->connected);
1568 spin_unlock_irqrestore(&hvcsd->lock, flags);
1569 return retval;
1570}
1571static DEVICE_ATTR(vterm_state, S_IRUGO | S_IWUSR,
1572 hvcs_vterm_state_show, hvcs_vterm_state_store);
1573
1574static ssize_t hvcs_index_show(struct device *dev, struct device_attribute *attr, char *buf)
1575{
1576 struct vio_dev *viod = to_vio_dev(dev);
1577 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1578 unsigned long flags;
1579 int retval;
1580
1581 spin_lock_irqsave(&hvcsd->lock, flags);
1582 retval = sprintf(buf, "%d\n", hvcsd->index);
1583 spin_unlock_irqrestore(&hvcsd->lock, flags);
1584 return retval;
1585}
1586
1587static DEVICE_ATTR(index, S_IRUGO, hvcs_index_show, NULL);
1588
1589static struct attribute *hvcs_attrs[] = {
1590 &dev_attr_partner_vtys.attr,
1591 &dev_attr_partner_clcs.attr,
1592 &dev_attr_current_vty.attr,
1593 &dev_attr_vterm_state.attr,
1594 &dev_attr_index.attr,
1595 NULL,
1596};
1597
1598static struct attribute_group hvcs_attr_group = {
1599 .attrs = hvcs_attrs,
1600};
1601
1602static void hvcs_create_device_attrs(struct hvcs_struct *hvcsd)
1603{
1604 struct vio_dev *vdev = hvcsd->vdev;
1605 sysfs_create_group(&vdev->dev.kobj, &hvcs_attr_group);
1606}
1607
1608static void hvcs_remove_device_attrs(struct vio_dev *vdev)
1609{
1610 sysfs_remove_group(&vdev->dev.kobj, &hvcs_attr_group);
1611}
1612
1613static ssize_t hvcs_rescan_show(struct device_driver *ddp, char *buf)
1614{
1615 /* A 1 means it is updating, a 0 means it is done updating */
1616 return snprintf(buf, PAGE_SIZE, "%d\n", hvcs_rescan_status);
1617}
1618
1619static ssize_t hvcs_rescan_store(struct device_driver *ddp, const char * buf,
1620 size_t count)
1621{
1622 if ((simple_strtol(buf, NULL, 0) != 1)
1623 && (hvcs_rescan_status != 0))
1624 return -EINVAL;
1625
1626 hvcs_rescan_status = 1;
1627 printk(KERN_INFO "HVCS: rescanning partner info for all"
1628 " vty-servers.\n");
1629 hvcs_rescan_devices_list();
1630 hvcs_rescan_status = 0;
1631 return count;
1632}
1633static DRIVER_ATTR(rescan,
1634 S_IRUGO | S_IWUSR, hvcs_rescan_show, hvcs_rescan_store);
1635
1636static void hvcs_create_driver_attrs(void)
1637{
1638 struct device_driver *driverfs = &(hvcs_vio_driver.driver);
1639 driver_create_file(driverfs, &driver_attr_rescan);
1640}
1641
1642static void hvcs_remove_driver_attrs(void)
1643{
1644 struct device_driver *driverfs = &(hvcs_vio_driver.driver);
1645 driver_remove_file(driverfs, &driver_attr_rescan);
1646}
diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c
index 2cf63e7305a3..82a41d5b4ed0 100644
--- a/drivers/char/hvsi.c
+++ b/drivers/char/hvsi.c
@@ -69,7 +69,7 @@
69#define __ALIGNED__ __attribute__((__aligned__(sizeof(long)))) 69#define __ALIGNED__ __attribute__((__aligned__(sizeof(long))))
70 70
71struct hvsi_struct { 71struct hvsi_struct {
72 struct work_struct writer; 72 struct delayed_work writer;
73 struct work_struct handshaker; 73 struct work_struct handshaker;
74 wait_queue_head_t emptyq; /* woken when outbuf is emptied */ 74 wait_queue_head_t emptyq; /* woken when outbuf is emptied */
75 wait_queue_head_t stateq; /* woken when HVSI state changes */ 75 wait_queue_head_t stateq; /* woken when HVSI state changes */
@@ -744,9 +744,10 @@ static int hvsi_handshake(struct hvsi_struct *hp)
744 return 0; 744 return 0;
745} 745}
746 746
747static void hvsi_handshaker(void *arg) 747static void hvsi_handshaker(struct work_struct *work)
748{ 748{
749 struct hvsi_struct *hp = (struct hvsi_struct *)arg; 749 struct hvsi_struct *hp =
750 container_of(work, struct hvsi_struct, handshaker);
750 751
751 if (hvsi_handshake(hp) >= 0) 752 if (hvsi_handshake(hp) >= 0)
752 return; 753 return;
@@ -951,9 +952,10 @@ static void hvsi_push(struct hvsi_struct *hp)
951} 952}
952 953
953/* hvsi_write_worker will keep rescheduling itself until outbuf is empty */ 954/* hvsi_write_worker will keep rescheduling itself until outbuf is empty */
954static void hvsi_write_worker(void *arg) 955static void hvsi_write_worker(struct work_struct *work)
955{ 956{
956 struct hvsi_struct *hp = (struct hvsi_struct *)arg; 957 struct hvsi_struct *hp =
958 container_of(work, struct hvsi_struct, writer.work);
957 unsigned long flags; 959 unsigned long flags;
958#ifdef DEBUG 960#ifdef DEBUG
959 static long start_j = 0; 961 static long start_j = 0;
@@ -1287,8 +1289,8 @@ static int __init hvsi_console_init(void)
1287 } 1289 }
1288 1290
1289 hp = &hvsi_ports[hvsi_count]; 1291 hp = &hvsi_ports[hvsi_count];
1290 INIT_WORK(&hp->writer, hvsi_write_worker, hp); 1292 INIT_DELAYED_WORK(&hp->writer, hvsi_write_worker);
1291 INIT_WORK(&hp->handshaker, hvsi_handshaker, hp); 1293 INIT_WORK(&hp->handshaker, hvsi_handshaker);
1292 init_waitqueue_head(&hp->emptyq); 1294 init_waitqueue_head(&hp->emptyq);
1293 init_waitqueue_head(&hp->stateq); 1295 init_waitqueue_head(&hp->stateq);
1294 spin_lock_init(&hp->lock); 1296 spin_lock_init(&hp->lock);
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index 9f7635f75178..5f3acd8e64b8 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -3,17 +3,20 @@
3# 3#
4 4
5config HW_RANDOM 5config HW_RANDOM
6 bool "Hardware Random Number Generator Core support" 6 tristate "Hardware Random Number Generator Core support"
7 default y 7 default m
8 ---help--- 8 ---help---
9 Hardware Random Number Generator Core infrastructure. 9 Hardware Random Number Generator Core infrastructure.
10 10
11 To compile this driver as a module, choose M here: the
12 module will be called rng-core.
13
11 If unsure, say Y. 14 If unsure, say Y.
12 15
13config HW_RANDOM_INTEL 16config HW_RANDOM_INTEL
14 tristate "Intel HW Random Number Generator support" 17 tristate "Intel HW Random Number Generator support"
15 depends on HW_RANDOM && (X86 || IA64) && PCI 18 depends on HW_RANDOM && (X86 || IA64) && PCI
16 default y 19 default HW_RANDOM
17 ---help--- 20 ---help---
18 This driver provides kernel-side support for the Random Number 21 This driver provides kernel-side support for the Random Number
19 Generator hardware found on Intel i8xx-based motherboards. 22 Generator hardware found on Intel i8xx-based motherboards.
@@ -26,7 +29,7 @@ config HW_RANDOM_INTEL
26config HW_RANDOM_AMD 29config HW_RANDOM_AMD
27 tristate "AMD HW Random Number Generator support" 30 tristate "AMD HW Random Number Generator support"
28 depends on HW_RANDOM && X86 && PCI 31 depends on HW_RANDOM && X86 && PCI
29 default y 32 default HW_RANDOM
30 ---help--- 33 ---help---
31 This driver provides kernel-side support for the Random Number 34 This driver provides kernel-side support for the Random Number
32 Generator hardware found on AMD 76x-based motherboards. 35 Generator hardware found on AMD 76x-based motherboards.
@@ -39,7 +42,7 @@ config HW_RANDOM_AMD
39config HW_RANDOM_GEODE 42config HW_RANDOM_GEODE
40 tristate "AMD Geode HW Random Number Generator support" 43 tristate "AMD Geode HW Random Number Generator support"
41 depends on HW_RANDOM && X86 && PCI 44 depends on HW_RANDOM && X86 && PCI
42 default y 45 default HW_RANDOM
43 ---help--- 46 ---help---
44 This driver provides kernel-side support for the Random Number 47 This driver provides kernel-side support for the Random Number
45 Generator hardware found on the AMD Geode LX. 48 Generator hardware found on the AMD Geode LX.
@@ -52,7 +55,7 @@ config HW_RANDOM_GEODE
52config HW_RANDOM_VIA 55config HW_RANDOM_VIA
53 tristate "VIA HW Random Number Generator support" 56 tristate "VIA HW Random Number Generator support"
54 depends on HW_RANDOM && X86_32 57 depends on HW_RANDOM && X86_32
55 default y 58 default HW_RANDOM
56 ---help--- 59 ---help---
57 This driver provides kernel-side support for the Random Number 60 This driver provides kernel-side support for the Random Number
58 Generator hardware found on VIA based motherboards. 61 Generator hardware found on VIA based motherboards.
@@ -65,7 +68,7 @@ config HW_RANDOM_VIA
65config HW_RANDOM_IXP4XX 68config HW_RANDOM_IXP4XX
66 tristate "Intel IXP4xx NPU HW Random Number Generator support" 69 tristate "Intel IXP4xx NPU HW Random Number Generator support"
67 depends on HW_RANDOM && ARCH_IXP4XX 70 depends on HW_RANDOM && ARCH_IXP4XX
68 default y 71 default HW_RANDOM
69 ---help--- 72 ---help---
70 This driver provides kernel-side support for the Random 73 This driver provides kernel-side support for the Random
71 Number Generator hardware found on the Intel IXP4xx NPU. 74 Number Generator hardware found on the Intel IXP4xx NPU.
@@ -78,7 +81,7 @@ config HW_RANDOM_IXP4XX
78config HW_RANDOM_OMAP 81config HW_RANDOM_OMAP
79 tristate "OMAP Random Number Generator support" 82 tristate "OMAP Random Number Generator support"
80 depends on HW_RANDOM && (ARCH_OMAP16XX || ARCH_OMAP24XX) 83 depends on HW_RANDOM && (ARCH_OMAP16XX || ARCH_OMAP24XX)
81 default y 84 default HW_RANDOM
82 ---help--- 85 ---help---
83 This driver provides kernel-side support for the Random Number 86 This driver provides kernel-side support for the Random Number
84 Generator hardware found on OMAP16xx and OMAP24xx multimedia 87 Generator hardware found on OMAP16xx and OMAP24xx multimedia
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile
index e263ae96f940..c41fa19454e3 100644
--- a/drivers/char/hw_random/Makefile
+++ b/drivers/char/hw_random/Makefile
@@ -2,7 +2,8 @@
2# Makefile for HW Random Number Generator (RNG) device drivers. 2# Makefile for HW Random Number Generator (RNG) device drivers.
3# 3#
4 4
5obj-$(CONFIG_HW_RANDOM) += core.o 5obj-$(CONFIG_HW_RANDOM) += rng-core.o
6rng-core-y := core.o
6obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o 7obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o
7obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o 8obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o
8obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o 9obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o
diff --git a/drivers/char/ip2/i2cmd.h b/drivers/char/ip2/i2cmd.h
index baa4e721b758..29277ec6b8ed 100644
--- a/drivers/char/ip2/i2cmd.h
+++ b/drivers/char/ip2/i2cmd.h
@@ -367,11 +367,6 @@ static UCHAR cc02[];
367#define CSE_NULL 3 // Replace with a null 367#define CSE_NULL 3 // Replace with a null
368#define CSE_MARK 4 // Replace with a 3-character sequence (as Unix) 368#define CSE_MARK 4 // Replace with a 3-character sequence (as Unix)
369 369
370#define CMD_SET_REPLACEMENT(arg,ch) \
371 (((cmdSyntaxPtr)(ct36a))->cmd[1] = (arg), \
372 (((cmdSyntaxPtr)(ct36a))->cmd[2] = (ch), \
373 (cmdSyntaxPtr)(ct36a))
374
375#define CSE_REPLACE 0x8 // Replace the errored character with the 370#define CSE_REPLACE 0x8 // Replace the errored character with the
376 // replacement character defined here 371 // replacement character defined here
377 372
diff --git a/drivers/char/ip2/i2lib.c b/drivers/char/ip2/i2lib.c
index 54d93f0345e8..78045767ec33 100644
--- a/drivers/char/ip2/i2lib.c
+++ b/drivers/char/ip2/i2lib.c
@@ -84,8 +84,8 @@ static void iiSendPendingMail(i2eBordStrPtr);
84static void serviceOutgoingFifo(i2eBordStrPtr); 84static void serviceOutgoingFifo(i2eBordStrPtr);
85 85
86// Functions defined in ip2.c as part of interrupt handling 86// Functions defined in ip2.c as part of interrupt handling
87static void do_input(void *); 87static void do_input(struct work_struct *);
88static void do_status(void *); 88static void do_status(struct work_struct *);
89 89
90//*************** 90//***************
91//* Debug Data * 91//* Debug Data *
@@ -331,8 +331,8 @@ i2InitChannels ( i2eBordStrPtr pB, int nChannels, i2ChanStrPtr pCh)
331 pCh->ClosingWaitTime = 30*HZ; 331 pCh->ClosingWaitTime = 30*HZ;
332 332
333 // Initialize task queue objects 333 // Initialize task queue objects
334 INIT_WORK(&pCh->tqueue_input, do_input, pCh); 334 INIT_WORK(&pCh->tqueue_input, do_input);
335 INIT_WORK(&pCh->tqueue_status, do_status, pCh); 335 INIT_WORK(&pCh->tqueue_status, do_status);
336 336
337#ifdef IP2DEBUG_TRACE 337#ifdef IP2DEBUG_TRACE
338 pCh->trace = ip2trace; 338 pCh->trace = ip2trace;
@@ -1016,7 +1016,6 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count)
1016 unsigned short channel; 1016 unsigned short channel;
1017 unsigned short stuffIndex; 1017 unsigned short stuffIndex;
1018 unsigned long flags; 1018 unsigned long flags;
1019 int rc = 0;
1020 1019
1021 int bailout = 10; 1020 int bailout = 10;
1022 1021
@@ -1573,7 +1572,7 @@ i2StripFifo(i2eBordStrPtr pB)
1573#ifdef USE_IQ 1572#ifdef USE_IQ
1574 schedule_work(&pCh->tqueue_input); 1573 schedule_work(&pCh->tqueue_input);
1575#else 1574#else
1576 do_input(pCh); 1575 do_input(&pCh->tqueue_input);
1577#endif 1576#endif
1578 1577
1579 // Note we do not need to maintain any flow-control credits at this 1578 // Note we do not need to maintain any flow-control credits at this
@@ -1810,7 +1809,7 @@ i2StripFifo(i2eBordStrPtr pB)
1810#ifdef USE_IQ 1809#ifdef USE_IQ
1811 schedule_work(&pCh->tqueue_status); 1810 schedule_work(&pCh->tqueue_status);
1812#else 1811#else
1813 do_status(pCh); 1812 do_status(&pCh->tqueue_status);
1814#endif 1813#endif
1815 } 1814 }
1816 } 1815 }
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index a3f32d46d2f8..cda2459c1d60 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -189,12 +189,12 @@ static int ip2_tiocmset(struct tty_struct *tty, struct file *file,
189 unsigned int set, unsigned int clear); 189 unsigned int set, unsigned int clear);
190 190
191static void set_irq(int, int); 191static void set_irq(int, int);
192static void ip2_interrupt_bh(i2eBordStrPtr pB); 192static void ip2_interrupt_bh(struct work_struct *work);
193static irqreturn_t ip2_interrupt(int irq, void *dev_id); 193static irqreturn_t ip2_interrupt(int irq, void *dev_id);
194static void ip2_poll(unsigned long arg); 194static void ip2_poll(unsigned long arg);
195static inline void service_all_boards(void); 195static inline void service_all_boards(void);
196static void do_input(void *p); 196static void do_input(struct work_struct *);
197static void do_status(void *p); 197static void do_status(struct work_struct *);
198 198
199static void ip2_wait_until_sent(PTTY,int); 199static void ip2_wait_until_sent(PTTY,int);
200 200
@@ -918,7 +918,7 @@ ip2_init_board( int boardnum )
918 pCh++; 918 pCh++;
919 } 919 }
920ex_exit: 920ex_exit:
921 INIT_WORK(&pB->tqueue_interrupt, (void(*)(void*)) ip2_interrupt_bh, pB); 921 INIT_WORK(&pB->tqueue_interrupt, ip2_interrupt_bh);
922 return; 922 return;
923 923
924err_release_region: 924err_release_region:
@@ -1125,8 +1125,8 @@ service_all_boards(void)
1125 1125
1126 1126
1127/******************************************************************************/ 1127/******************************************************************************/
1128/* Function: ip2_interrupt_bh(pB) */ 1128/* Function: ip2_interrupt_bh(work) */
1129/* Parameters: pB - pointer to the board structure */ 1129/* Parameters: work - pointer to the board structure */
1130/* Returns: Nothing */ 1130/* Returns: Nothing */
1131/* */ 1131/* */
1132/* Description: */ 1132/* Description: */
@@ -1135,8 +1135,9 @@ service_all_boards(void)
1135/* */ 1135/* */
1136/******************************************************************************/ 1136/******************************************************************************/
1137static void 1137static void
1138ip2_interrupt_bh(i2eBordStrPtr pB) 1138ip2_interrupt_bh(struct work_struct *work)
1139{ 1139{
1140 i2eBordStrPtr pB = container_of(work, i2eBordStr, tqueue_interrupt);
1140// pB better well be set or we have a problem! We can only get 1141// pB better well be set or we have a problem! We can only get
1141// here from the IMMEDIATE queue. Here, we process the boards. 1142// here from the IMMEDIATE queue. Here, we process the boards.
1142// Checking pB doesn't cost much and it saves us from the sanity checkers. 1143// Checking pB doesn't cost much and it saves us from the sanity checkers.
@@ -1245,9 +1246,9 @@ ip2_poll(unsigned long arg)
1245 ip2trace (ITRC_NO_PORT, ITRC_INTR, ITRC_RETURN, 0 ); 1246 ip2trace (ITRC_NO_PORT, ITRC_INTR, ITRC_RETURN, 0 );
1246} 1247}
1247 1248
1248static void do_input(void *p) 1249static void do_input(struct work_struct *work)
1249{ 1250{
1250 i2ChanStrPtr pCh = p; 1251 i2ChanStrPtr pCh = container_of(work, i2ChanStr, tqueue_input);
1251 unsigned long flags; 1252 unsigned long flags;
1252 1253
1253 ip2trace(CHANN, ITRC_INPUT, 21, 0 ); 1254 ip2trace(CHANN, ITRC_INPUT, 21, 0 );
@@ -1279,9 +1280,9 @@ static inline void isig(int sig, struct tty_struct *tty, int flush)
1279 } 1280 }
1280} 1281}
1281 1282
1282static void do_status(void *p) 1283static void do_status(struct work_struct *work)
1283{ 1284{
1284 i2ChanStrPtr pCh = p; 1285 i2ChanStrPtr pCh = container_of(work, i2ChanStr, tqueue_status);
1285 int status; 1286 int status;
1286 1287
1287 status = i2GetStatus( pCh, (I2_BRK|I2_PAR|I2_FRA|I2_OVR) ); 1288 status = i2GetStatus( pCh, (I2_BRK|I2_PAR|I2_FRA|I2_OVR) );
diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c
index 0030cd8e2e95..6c59baa887a8 100644
--- a/drivers/char/ipmi/ipmi_bt_sm.c
+++ b/drivers/char/ipmi/ipmi_bt_sm.c
@@ -33,11 +33,13 @@
33#include <linux/ipmi_msgdefs.h> /* for completion codes */ 33#include <linux/ipmi_msgdefs.h> /* for completion codes */
34#include "ipmi_si_sm.h" 34#include "ipmi_si_sm.h"
35 35
36static int bt_debug = 0x00; /* Production value 0, see following flags */ 36#define BT_DEBUG_OFF 0 /* Used in production */
37#define BT_DEBUG_ENABLE 1 /* Generic messages */
38#define BT_DEBUG_MSG 2 /* Prints all request/response buffers */
39#define BT_DEBUG_STATES 4 /* Verbose look at state changes */
40
41static int bt_debug = BT_DEBUG_OFF;
37 42
38#define BT_DEBUG_ENABLE 1
39#define BT_DEBUG_MSG 2
40#define BT_DEBUG_STATES 4
41module_param(bt_debug, int, 0644); 43module_param(bt_debug, int, 0644);
42MODULE_PARM_DESC(bt_debug, "debug bitmask, 1=enable, 2=messages, 4=states"); 44MODULE_PARM_DESC(bt_debug, "debug bitmask, 1=enable, 2=messages, 4=states");
43 45
@@ -47,38 +49,54 @@ MODULE_PARM_DESC(bt_debug, "debug bitmask, 1=enable, 2=messages, 4=states");
47 Since the Open IPMI architecture is single-message oriented at this 49 Since the Open IPMI architecture is single-message oriented at this
48 stage, the queue depth of BT is of no concern. */ 50 stage, the queue depth of BT is of no concern. */
49 51
50#define BT_NORMAL_TIMEOUT 5000000 /* seconds in microseconds */ 52#define BT_NORMAL_TIMEOUT 5 /* seconds */
51#define BT_RETRY_LIMIT 2 53#define BT_NORMAL_RETRY_LIMIT 2
52#define BT_RESET_DELAY 6000000 /* 6 seconds after warm reset */ 54#define BT_RESET_DELAY 6 /* seconds after warm reset */
55
56/* States are written in chronological order and usually cover
57 multiple rows of the state table discussion in the IPMI spec. */
53 58
54enum bt_states { 59enum bt_states {
55 BT_STATE_IDLE, 60 BT_STATE_IDLE = 0, /* Order is critical in this list */
56 BT_STATE_XACTION_START, 61 BT_STATE_XACTION_START,
57 BT_STATE_WRITE_BYTES, 62 BT_STATE_WRITE_BYTES,
58 BT_STATE_WRITE_END,
59 BT_STATE_WRITE_CONSUME, 63 BT_STATE_WRITE_CONSUME,
60 BT_STATE_B2H_WAIT, 64 BT_STATE_READ_WAIT,
61 BT_STATE_READ_END, 65 BT_STATE_CLEAR_B2H,
62 BT_STATE_RESET1, /* These must come last */ 66 BT_STATE_READ_BYTES,
67 BT_STATE_RESET1, /* These must come last */
63 BT_STATE_RESET2, 68 BT_STATE_RESET2,
64 BT_STATE_RESET3, 69 BT_STATE_RESET3,
65 BT_STATE_RESTART, 70 BT_STATE_RESTART,
66 BT_STATE_HOSED 71 BT_STATE_PRINTME,
72 BT_STATE_CAPABILITIES_BEGIN,
73 BT_STATE_CAPABILITIES_END,
74 BT_STATE_LONG_BUSY /* BT doesn't get hosed :-) */
67}; 75};
68 76
77/* Macros seen at the end of state "case" blocks. They help with legibility
78 and debugging. */
79
80#define BT_STATE_CHANGE(X,Y) { bt->state = X; return Y; }
81
82#define BT_SI_SM_RETURN(Y) { last_printed = BT_STATE_PRINTME; return Y; }
83
69struct si_sm_data { 84struct si_sm_data {
70 enum bt_states state; 85 enum bt_states state;
71 enum bt_states last_state; /* assist printing and resets */
72 unsigned char seq; /* BT sequence number */ 86 unsigned char seq; /* BT sequence number */
73 struct si_sm_io *io; 87 struct si_sm_io *io;
74 unsigned char write_data[IPMI_MAX_MSG_LENGTH]; 88 unsigned char write_data[IPMI_MAX_MSG_LENGTH];
75 int write_count; 89 int write_count;
76 unsigned char read_data[IPMI_MAX_MSG_LENGTH]; 90 unsigned char read_data[IPMI_MAX_MSG_LENGTH];
77 int read_count; 91 int read_count;
78 int truncated; 92 int truncated;
79 long timeout; 93 long timeout; /* microseconds countdown */
80 unsigned int error_retries; /* end of "common" fields */ 94 int error_retries; /* end of "common" fields */
81 int nonzero_status; /* hung BMCs stay all 0 */ 95 int nonzero_status; /* hung BMCs stay all 0 */
96 enum bt_states complete; /* to divert the state machine */
97 int BT_CAP_outreqs;
98 long BT_CAP_req2rsp;
99 int BT_CAP_retries; /* Recommended retries */
82}; 100};
83 101
84#define BT_CLR_WR_PTR 0x01 /* See IPMI 1.5 table 11.6.4 */ 102#define BT_CLR_WR_PTR 0x01 /* See IPMI 1.5 table 11.6.4 */
@@ -111,86 +129,118 @@ struct si_sm_data {
111static char *state2txt(unsigned char state) 129static char *state2txt(unsigned char state)
112{ 130{
113 switch (state) { 131 switch (state) {
114 case BT_STATE_IDLE: return("IDLE"); 132 case BT_STATE_IDLE: return("IDLE");
115 case BT_STATE_XACTION_START: return("XACTION"); 133 case BT_STATE_XACTION_START: return("XACTION");
116 case BT_STATE_WRITE_BYTES: return("WR_BYTES"); 134 case BT_STATE_WRITE_BYTES: return("WR_BYTES");
117 case BT_STATE_WRITE_END: return("WR_END"); 135 case BT_STATE_WRITE_CONSUME: return("WR_CONSUME");
118 case BT_STATE_WRITE_CONSUME: return("WR_CONSUME"); 136 case BT_STATE_READ_WAIT: return("RD_WAIT");
119 case BT_STATE_B2H_WAIT: return("B2H_WAIT"); 137 case BT_STATE_CLEAR_B2H: return("CLEAR_B2H");
120 case BT_STATE_READ_END: return("RD_END"); 138 case BT_STATE_READ_BYTES: return("RD_BYTES");
121 case BT_STATE_RESET1: return("RESET1"); 139 case BT_STATE_RESET1: return("RESET1");
122 case BT_STATE_RESET2: return("RESET2"); 140 case BT_STATE_RESET2: return("RESET2");
123 case BT_STATE_RESET3: return("RESET3"); 141 case BT_STATE_RESET3: return("RESET3");
124 case BT_STATE_RESTART: return("RESTART"); 142 case BT_STATE_RESTART: return("RESTART");
125 case BT_STATE_HOSED: return("HOSED"); 143 case BT_STATE_LONG_BUSY: return("LONG_BUSY");
144 case BT_STATE_CAPABILITIES_BEGIN: return("CAP_BEGIN");
145 case BT_STATE_CAPABILITIES_END: return("CAP_END");
126 } 146 }
127 return("BAD STATE"); 147 return("BAD STATE");
128} 148}
129#define STATE2TXT state2txt(bt->state) 149#define STATE2TXT state2txt(bt->state)
130 150
131static char *status2txt(unsigned char status, char *buf) 151static char *status2txt(unsigned char status)
132{ 152{
153 /*
154 * This cannot be called by two threads at the same time and
155 * the buffer is always consumed immediately, so the static is
156 * safe to use.
157 */
158 static char buf[40];
159
133 strcpy(buf, "[ "); 160 strcpy(buf, "[ ");
134 if (status & BT_B_BUSY) strcat(buf, "B_BUSY "); 161 if (status & BT_B_BUSY)
135 if (status & BT_H_BUSY) strcat(buf, "H_BUSY "); 162 strcat(buf, "B_BUSY ");
136 if (status & BT_OEM0) strcat(buf, "OEM0 "); 163 if (status & BT_H_BUSY)
137 if (status & BT_SMS_ATN) strcat(buf, "SMS "); 164 strcat(buf, "H_BUSY ");
138 if (status & BT_B2H_ATN) strcat(buf, "B2H "); 165 if (status & BT_OEM0)
139 if (status & BT_H2B_ATN) strcat(buf, "H2B "); 166 strcat(buf, "OEM0 ");
167 if (status & BT_SMS_ATN)
168 strcat(buf, "SMS ");
169 if (status & BT_B2H_ATN)
170 strcat(buf, "B2H ");
171 if (status & BT_H2B_ATN)
172 strcat(buf, "H2B ");
140 strcat(buf, "]"); 173 strcat(buf, "]");
141 return buf; 174 return buf;
142} 175}
143#define STATUS2TXT(buf) status2txt(status, buf) 176#define STATUS2TXT status2txt(status)
177
178/* called externally at insmod time, and internally on cleanup */
144 179
145/* This will be called from within this module on a hosed condition */
146#define FIRST_SEQ 0
147static unsigned int bt_init_data(struct si_sm_data *bt, struct si_sm_io *io) 180static unsigned int bt_init_data(struct si_sm_data *bt, struct si_sm_io *io)
148{ 181{
149 bt->state = BT_STATE_IDLE; 182 memset(bt, 0, sizeof(struct si_sm_data));
150 bt->last_state = BT_STATE_IDLE; 183 if (bt->io != io) { /* external: one-time only things */
151 bt->seq = FIRST_SEQ; 184 bt->io = io;
152 bt->io = io; 185 bt->seq = 0;
153 bt->write_count = 0; 186 }
154 bt->read_count = 0; 187 bt->state = BT_STATE_IDLE; /* start here */
155 bt->error_retries = 0; 188 bt->complete = BT_STATE_IDLE; /* end here */
156 bt->nonzero_status = 0; 189 bt->BT_CAP_req2rsp = BT_NORMAL_TIMEOUT * 1000000;
157 bt->truncated = 0; 190 bt->BT_CAP_retries = BT_NORMAL_RETRY_LIMIT;
158 bt->timeout = BT_NORMAL_TIMEOUT; 191 /* BT_CAP_outreqs == zero is a flag to read BT Capabilities */
159 return 3; /* We claim 3 bytes of space; ought to check SPMI table */ 192 return 3; /* We claim 3 bytes of space; ought to check SPMI table */
160} 193}
161 194
195/* Jam a completion code (probably an error) into a response */
196
197static void force_result(struct si_sm_data *bt, unsigned char completion_code)
198{
199 bt->read_data[0] = 4; /* # following bytes */
200 bt->read_data[1] = bt->write_data[1] | 4; /* Odd NetFn/LUN */
201 bt->read_data[2] = bt->write_data[2]; /* seq (ignored) */
202 bt->read_data[3] = bt->write_data[3]; /* Command */
203 bt->read_data[4] = completion_code;
204 bt->read_count = 5;
205}
206
207/* The upper state machine starts here */
208
162static int bt_start_transaction(struct si_sm_data *bt, 209static int bt_start_transaction(struct si_sm_data *bt,
163 unsigned char *data, 210 unsigned char *data,
164 unsigned int size) 211 unsigned int size)
165{ 212{
166 unsigned int i; 213 unsigned int i;
167 214
168 if ((size < 2) || (size > (IPMI_MAX_MSG_LENGTH - 2))) 215 if (size < 2)
169 return -1; 216 return IPMI_REQ_LEN_INVALID_ERR;
217 if (size > IPMI_MAX_MSG_LENGTH)
218 return IPMI_REQ_LEN_EXCEEDED_ERR;
170 219
171 if ((bt->state != BT_STATE_IDLE) && (bt->state != BT_STATE_HOSED)) 220 if (bt->state == BT_STATE_LONG_BUSY)
172 return -2; 221 return IPMI_NODE_BUSY_ERR;
222
223 if (bt->state != BT_STATE_IDLE)
224 return IPMI_NOT_IN_MY_STATE_ERR;
173 225
174 if (bt_debug & BT_DEBUG_MSG) { 226 if (bt_debug & BT_DEBUG_MSG) {
175 printk(KERN_WARNING "+++++++++++++++++++++++++++++++++++++\n"); 227 printk(KERN_WARNING "BT: +++++++++++++++++ New command\n");
176 printk(KERN_WARNING "BT: write seq=0x%02X:", bt->seq); 228 printk(KERN_WARNING "BT: NetFn/LUN CMD [%d data]:", size - 2);
177 for (i = 0; i < size; i ++) 229 for (i = 0; i < size; i ++)
178 printk (" %02x", data[i]); 230 printk (" %02x", data[i]);
179 printk("\n"); 231 printk("\n");
180 } 232 }
181 bt->write_data[0] = size + 1; /* all data plus seq byte */ 233 bt->write_data[0] = size + 1; /* all data plus seq byte */
182 bt->write_data[1] = *data; /* NetFn/LUN */ 234 bt->write_data[1] = *data; /* NetFn/LUN */
183 bt->write_data[2] = bt->seq; 235 bt->write_data[2] = bt->seq++;
184 memcpy(bt->write_data + 3, data + 1, size - 1); 236 memcpy(bt->write_data + 3, data + 1, size - 1);
185 bt->write_count = size + 2; 237 bt->write_count = size + 2;
186
187 bt->error_retries = 0; 238 bt->error_retries = 0;
188 bt->nonzero_status = 0; 239 bt->nonzero_status = 0;
189 bt->read_count = 0;
190 bt->truncated = 0; 240 bt->truncated = 0;
191 bt->state = BT_STATE_XACTION_START; 241 bt->state = BT_STATE_XACTION_START;
192 bt->last_state = BT_STATE_IDLE; 242 bt->timeout = bt->BT_CAP_req2rsp;
193 bt->timeout = BT_NORMAL_TIMEOUT; 243 force_result(bt, IPMI_ERR_UNSPECIFIED);
194 return 0; 244 return 0;
195} 245}
196 246
@@ -198,38 +248,30 @@ static int bt_start_transaction(struct si_sm_data *bt,
198 it calls this. Strip out the length and seq bytes. */ 248 it calls this. Strip out the length and seq bytes. */
199 249
200static int bt_get_result(struct si_sm_data *bt, 250static int bt_get_result(struct si_sm_data *bt,
201 unsigned char *data, 251 unsigned char *data,
202 unsigned int length) 252 unsigned int length)
203{ 253{
204 int i, msg_len; 254 int i, msg_len;
205 255
206 msg_len = bt->read_count - 2; /* account for length & seq */ 256 msg_len = bt->read_count - 2; /* account for length & seq */
207 /* Always NetFn, Cmd, cCode */
208 if (msg_len < 3 || msg_len > IPMI_MAX_MSG_LENGTH) { 257 if (msg_len < 3 || msg_len > IPMI_MAX_MSG_LENGTH) {
209 printk(KERN_DEBUG "BT results: bad msg_len = %d\n", msg_len); 258 force_result(bt, IPMI_ERR_UNSPECIFIED);
210 data[0] = bt->write_data[1] | 0x4; /* Kludge a response */
211 data[1] = bt->write_data[3];
212 data[2] = IPMI_ERR_UNSPECIFIED;
213 msg_len = 3; 259 msg_len = 3;
214 } else { 260 }
215 data[0] = bt->read_data[1]; 261 data[0] = bt->read_data[1];
216 data[1] = bt->read_data[3]; 262 data[1] = bt->read_data[3];
217 if (length < msg_len) 263 if (length < msg_len || bt->truncated) {
218 bt->truncated = 1; 264 data[2] = IPMI_ERR_MSG_TRUNCATED;
219 if (bt->truncated) { /* can be set in read_all_bytes() */ 265 msg_len = 3;
220 data[2] = IPMI_ERR_MSG_TRUNCATED; 266 } else
221 msg_len = 3; 267 memcpy(data + 2, bt->read_data + 4, msg_len - 2);
222 } else
223 memcpy(data + 2, bt->read_data + 4, msg_len - 2);
224 268
225 if (bt_debug & BT_DEBUG_MSG) { 269 if (bt_debug & BT_DEBUG_MSG) {
226 printk (KERN_WARNING "BT: res (raw)"); 270 printk (KERN_WARNING "BT: result %d bytes:", msg_len);
227 for (i = 0; i < msg_len; i++) 271 for (i = 0; i < msg_len; i++)
228 printk(" %02x", data[i]); 272 printk(" %02x", data[i]);
229 printk ("\n"); 273 printk ("\n");
230 }
231 } 274 }
232 bt->read_count = 0; /* paranoia */
233 return msg_len; 275 return msg_len;
234} 276}
235 277
@@ -238,22 +280,40 @@ static int bt_get_result(struct si_sm_data *bt,
238 280
239static void reset_flags(struct si_sm_data *bt) 281static void reset_flags(struct si_sm_data *bt)
240{ 282{
283 if (bt_debug)
284 printk(KERN_WARNING "IPMI BT: flag reset %s\n",
285 status2txt(BT_STATUS));
241 if (BT_STATUS & BT_H_BUSY) 286 if (BT_STATUS & BT_H_BUSY)
242 BT_CONTROL(BT_H_BUSY); 287 BT_CONTROL(BT_H_BUSY); /* force clear */
243 if (BT_STATUS & BT_B_BUSY) 288 BT_CONTROL(BT_CLR_WR_PTR); /* always reset */
244 BT_CONTROL(BT_B_BUSY); 289 BT_CONTROL(BT_SMS_ATN); /* always clear */
245 BT_CONTROL(BT_CLR_WR_PTR); 290 BT_INTMASK_W(BT_BMC_HWRST);
246 BT_CONTROL(BT_SMS_ATN); 291}
247 292
248 if (BT_STATUS & BT_B2H_ATN) { 293/* Get rid of an unwanted/stale response. This should only be needed for
249 int i; 294 BMCs that support multiple outstanding requests. */
250 BT_CONTROL(BT_H_BUSY); 295
251 BT_CONTROL(BT_B2H_ATN); 296static void drain_BMC2HOST(struct si_sm_data *bt)
252 BT_CONTROL(BT_CLR_RD_PTR); 297{
253 for (i = 0; i < IPMI_MAX_MSG_LENGTH + 2; i++) 298 int i, size;
254 BMC2HOST; 299
255 BT_CONTROL(BT_H_BUSY); 300 if (!(BT_STATUS & BT_B2H_ATN)) /* Not signalling a response */
256 } 301 return;
302
303 BT_CONTROL(BT_H_BUSY); /* now set */
304 BT_CONTROL(BT_B2H_ATN); /* always clear */
305 BT_STATUS; /* pause */
306 BT_CONTROL(BT_B2H_ATN); /* some BMCs are stubborn */
307 BT_CONTROL(BT_CLR_RD_PTR); /* always reset */
308 if (bt_debug)
309 printk(KERN_WARNING "IPMI BT: stale response %s; ",
310 status2txt(BT_STATUS));
311 size = BMC2HOST;
312 for (i = 0; i < size ; i++)
313 BMC2HOST;
314 BT_CONTROL(BT_H_BUSY); /* now clear */
315 if (bt_debug)
316 printk("drained %d bytes\n", size + 1);
257} 317}
258 318
259static inline void write_all_bytes(struct si_sm_data *bt) 319static inline void write_all_bytes(struct si_sm_data *bt)
@@ -261,201 +321,256 @@ static inline void write_all_bytes(struct si_sm_data *bt)
261 int i; 321 int i;
262 322
263 if (bt_debug & BT_DEBUG_MSG) { 323 if (bt_debug & BT_DEBUG_MSG) {
264 printk(KERN_WARNING "BT: write %d bytes seq=0x%02X", 324 printk(KERN_WARNING "BT: write %d bytes seq=0x%02X",
265 bt->write_count, bt->seq); 325 bt->write_count, bt->seq);
266 for (i = 0; i < bt->write_count; i++) 326 for (i = 0; i < bt->write_count; i++)
267 printk (" %02x", bt->write_data[i]); 327 printk (" %02x", bt->write_data[i]);
268 printk ("\n"); 328 printk ("\n");
269 } 329 }
270 for (i = 0; i < bt->write_count; i++) 330 for (i = 0; i < bt->write_count; i++)
271 HOST2BMC(bt->write_data[i]); 331 HOST2BMC(bt->write_data[i]);
272} 332}
273 333
274static inline int read_all_bytes(struct si_sm_data *bt) 334static inline int read_all_bytes(struct si_sm_data *bt)
275{ 335{
276 unsigned char i; 336 unsigned char i;
277 337
338 /* length is "framing info", minimum = 4: NetFn, Seq, Cmd, cCode.
339 Keep layout of first four bytes aligned with write_data[] */
340
278 bt->read_data[0] = BMC2HOST; 341 bt->read_data[0] = BMC2HOST;
279 bt->read_count = bt->read_data[0]; 342 bt->read_count = bt->read_data[0];
280 if (bt_debug & BT_DEBUG_MSG)
281 printk(KERN_WARNING "BT: read %d bytes:", bt->read_count);
282 343
283 /* minimum: length, NetFn, Seq, Cmd, cCode == 5 total, or 4 more
284 following the length byte. */
285 if (bt->read_count < 4 || bt->read_count >= IPMI_MAX_MSG_LENGTH) { 344 if (bt->read_count < 4 || bt->read_count >= IPMI_MAX_MSG_LENGTH) {
286 if (bt_debug & BT_DEBUG_MSG) 345 if (bt_debug & BT_DEBUG_MSG)
287 printk("bad length %d\n", bt->read_count); 346 printk(KERN_WARNING "BT: bad raw rsp len=%d\n",
347 bt->read_count);
288 bt->truncated = 1; 348 bt->truncated = 1;
289 return 1; /* let next XACTION START clean it up */ 349 return 1; /* let next XACTION START clean it up */
290 } 350 }
291 for (i = 1; i <= bt->read_count; i++) 351 for (i = 1; i <= bt->read_count; i++)
292 bt->read_data[i] = BMC2HOST; 352 bt->read_data[i] = BMC2HOST;
293 bt->read_count++; /* account for the length byte */ 353 bt->read_count++; /* Account internally for length byte */
294 354
295 if (bt_debug & BT_DEBUG_MSG) { 355 if (bt_debug & BT_DEBUG_MSG) {
296 for (i = 0; i < bt->read_count; i++) 356 int max = bt->read_count;
357
358 printk(KERN_WARNING "BT: got %d bytes seq=0x%02X",
359 max, bt->read_data[2]);
360 if (max > 16)
361 max = 16;
362 for (i = 0; i < max; i++)
297 printk (" %02x", bt->read_data[i]); 363 printk (" %02x", bt->read_data[i]);
298 printk ("\n"); 364 printk ("%s\n", bt->read_count == max ? "" : " ...");
299 } 365 }
300 if (bt->seq != bt->write_data[2]) /* idiot check */
301 printk(KERN_DEBUG "BT: internal error: sequence mismatch\n");
302 366
303 /* per the spec, the (NetFn, Seq, Cmd) tuples should match */ 367 /* per the spec, the (NetFn[1], Seq[2], Cmd[3]) tuples must match */
304 if ((bt->read_data[3] == bt->write_data[3]) && /* Cmd */ 368 if ((bt->read_data[3] == bt->write_data[3]) &&
305 (bt->read_data[2] == bt->write_data[2]) && /* Sequence */ 369 (bt->read_data[2] == bt->write_data[2]) &&
306 ((bt->read_data[1] & 0xF8) == (bt->write_data[1] & 0xF8))) 370 ((bt->read_data[1] & 0xF8) == (bt->write_data[1] & 0xF8)))
307 return 1; 371 return 1;
308 372
309 if (bt_debug & BT_DEBUG_MSG) 373 if (bt_debug & BT_DEBUG_MSG)
310 printk(KERN_WARNING "BT: bad packet: " 374 printk(KERN_WARNING "IPMI BT: bad packet: "
311 "want 0x(%02X, %02X, %02X) got (%02X, %02X, %02X)\n", 375 "want 0x(%02X, %02X, %02X) got (%02X, %02X, %02X)\n",
312 bt->write_data[1], bt->write_data[2], bt->write_data[3], 376 bt->write_data[1] | 0x04, bt->write_data[2], bt->write_data[3],
313 bt->read_data[1], bt->read_data[2], bt->read_data[3]); 377 bt->read_data[1], bt->read_data[2], bt->read_data[3]);
314 return 0; 378 return 0;
315} 379}
316 380
317/* Modifies bt->state appropriately, need to get into the bt_event() switch */ 381/* Restart if retries are left, or return an error completion code */
318 382
319static void error_recovery(struct si_sm_data *bt, char *reason) 383static enum si_sm_result error_recovery(struct si_sm_data *bt,
384 unsigned char status,
385 unsigned char cCode)
320{ 386{
321 unsigned char status; 387 char *reason;
322 char buf[40]; /* For getting status */
323 388
324 bt->timeout = BT_NORMAL_TIMEOUT; /* various places want to retry */ 389 bt->timeout = bt->BT_CAP_req2rsp;
325 390
326 status = BT_STATUS; 391 switch (cCode) {
327 printk(KERN_DEBUG "BT: %s in %s %s\n", reason, STATE2TXT, 392 case IPMI_TIMEOUT_ERR:
328 STATUS2TXT(buf)); 393 reason = "timeout";
394 break;
395 default:
396 reason = "internal error";
397 break;
398 }
399
400 printk(KERN_WARNING "IPMI BT: %s in %s %s ", /* open-ended line */
401 reason, STATE2TXT, STATUS2TXT);
329 402
403 /* Per the IPMI spec, retries are based on the sequence number
404 known only to this module, so manage a restart here. */
330 (bt->error_retries)++; 405 (bt->error_retries)++;
331 if (bt->error_retries > BT_RETRY_LIMIT) { 406 if (bt->error_retries < bt->BT_CAP_retries) {
332 printk(KERN_DEBUG "retry limit (%d) exceeded\n", BT_RETRY_LIMIT); 407 printk("%d retries left\n",
333 bt->state = BT_STATE_HOSED; 408 bt->BT_CAP_retries - bt->error_retries);
334 if (!bt->nonzero_status) 409 bt->state = BT_STATE_RESTART;
335 printk(KERN_ERR "IPMI: BT stuck, try power cycle\n"); 410 return SI_SM_CALL_WITHOUT_DELAY;
336 else if (bt->error_retries <= BT_RETRY_LIMIT + 1) {
337 printk(KERN_DEBUG "IPMI: BT reset (takes 5 secs)\n");
338 bt->state = BT_STATE_RESET1;
339 }
340 return;
341 } 411 }
342 412
343 /* Sometimes the BMC queues get in an "off-by-one" state...*/ 413 printk("failed %d retries, sending error response\n",
344 if ((bt->state == BT_STATE_B2H_WAIT) && (status & BT_B2H_ATN)) { 414 bt->BT_CAP_retries);
345 printk(KERN_DEBUG "retry B2H_WAIT\n"); 415 if (!bt->nonzero_status)
346 return; 416 printk(KERN_ERR "IPMI BT: stuck, try power cycle\n");
417
418 /* this is most likely during insmod */
419 else if (bt->seq <= (unsigned char)(bt->BT_CAP_retries & 0xFF)) {
420 printk(KERN_WARNING "IPMI: BT reset (takes 5 secs)\n");
421 bt->state = BT_STATE_RESET1;
422 return SI_SM_CALL_WITHOUT_DELAY;
347 } 423 }
348 424
349 printk(KERN_DEBUG "restart command\n"); 425 /* Concoct a useful error message, set up the next state, and
350 bt->state = BT_STATE_RESTART; 426 be done with this sequence. */
427
428 bt->state = BT_STATE_IDLE;
429 switch (cCode) {
430 case IPMI_TIMEOUT_ERR:
431 if (status & BT_B_BUSY) {
432 cCode = IPMI_NODE_BUSY_ERR;
433 bt->state = BT_STATE_LONG_BUSY;
434 }
435 break;
436 default:
437 break;
438 }
439 force_result(bt, cCode);
440 return SI_SM_TRANSACTION_COMPLETE;
351} 441}
352 442
353/* Check the status and (possibly) advance the BT state machine. The 443/* Check status and (usually) take action and change this state machine. */
354 default return is SI_SM_CALL_WITH_DELAY. */
355 444
356static enum si_sm_result bt_event(struct si_sm_data *bt, long time) 445static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
357{ 446{
358 unsigned char status; 447 unsigned char status, BT_CAP[8];
359 char buf[40]; /* For getting status */ 448 static enum bt_states last_printed = BT_STATE_PRINTME;
360 int i; 449 int i;
361 450
362 status = BT_STATUS; 451 status = BT_STATUS;
363 bt->nonzero_status |= status; 452 bt->nonzero_status |= status;
364 453 if ((bt_debug & BT_DEBUG_STATES) && (bt->state != last_printed)) {
365 if ((bt_debug & BT_DEBUG_STATES) && (bt->state != bt->last_state))
366 printk(KERN_WARNING "BT: %s %s TO=%ld - %ld \n", 454 printk(KERN_WARNING "BT: %s %s TO=%ld - %ld \n",
367 STATE2TXT, 455 STATE2TXT,
368 STATUS2TXT(buf), 456 STATUS2TXT,
369 bt->timeout, 457 bt->timeout,
370 time); 458 time);
371 bt->last_state = bt->state; 459 last_printed = bt->state;
460 }
372 461
373 if (bt->state == BT_STATE_HOSED) 462 /* Commands that time out may still (eventually) provide a response.
374 return SI_SM_HOSED; 463 This stale response will get in the way of a new response so remove
464 it if possible (hopefully during IDLE). Even if it comes up later
465 it will be rejected by its (now-forgotten) seq number. */
466
467 if ((bt->state < BT_STATE_WRITE_BYTES) && (status & BT_B2H_ATN)) {
468 drain_BMC2HOST(bt);
469 BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
470 }
375 471
376 if (bt->state != BT_STATE_IDLE) { /* do timeout test */ 472 if ((bt->state != BT_STATE_IDLE) &&
473 (bt->state < BT_STATE_PRINTME)) { /* check timeout */
377 bt->timeout -= time; 474 bt->timeout -= time;
378 if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1)) { 475 if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1))
379 error_recovery(bt, "timed out"); 476 return error_recovery(bt,
380 return SI_SM_CALL_WITHOUT_DELAY; 477 status,
381 } 478 IPMI_TIMEOUT_ERR);
382 } 479 }
383 480
384 switch (bt->state) { 481 switch (bt->state) {
385 482
386 case BT_STATE_IDLE: /* check for asynchronous messages */ 483 /* Idle state first checks for asynchronous messages from another
484 channel, then does some opportunistic housekeeping. */
485
486 case BT_STATE_IDLE:
387 if (status & BT_SMS_ATN) { 487 if (status & BT_SMS_ATN) {
388 BT_CONTROL(BT_SMS_ATN); /* clear it */ 488 BT_CONTROL(BT_SMS_ATN); /* clear it */
389 return SI_SM_ATTN; 489 return SI_SM_ATTN;
390 } 490 }
391 return SI_SM_IDLE;
392 491
393 case BT_STATE_XACTION_START: 492 if (status & BT_H_BUSY) /* clear a leftover H_BUSY */
394 if (status & BT_H_BUSY) {
395 BT_CONTROL(BT_H_BUSY); 493 BT_CONTROL(BT_H_BUSY);
396 break;
397 }
398 if (status & BT_B2H_ATN)
399 break;
400 bt->state = BT_STATE_WRITE_BYTES;
401 return SI_SM_CALL_WITHOUT_DELAY; /* for logging */
402 494
403 case BT_STATE_WRITE_BYTES: 495 /* Read BT capabilities if it hasn't been done yet */
496 if (!bt->BT_CAP_outreqs)
497 BT_STATE_CHANGE(BT_STATE_CAPABILITIES_BEGIN,
498 SI_SM_CALL_WITHOUT_DELAY);
499 bt->timeout = bt->BT_CAP_req2rsp;
500 BT_SI_SM_RETURN(SI_SM_IDLE);
501
502 case BT_STATE_XACTION_START:
404 if (status & (BT_B_BUSY | BT_H2B_ATN)) 503 if (status & (BT_B_BUSY | BT_H2B_ATN))
405 break; 504 BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
505 if (BT_STATUS & BT_H_BUSY)
506 BT_CONTROL(BT_H_BUSY); /* force clear */
507 BT_STATE_CHANGE(BT_STATE_WRITE_BYTES,
508 SI_SM_CALL_WITHOUT_DELAY);
509
510 case BT_STATE_WRITE_BYTES:
511 if (status & BT_H_BUSY)
512 BT_CONTROL(BT_H_BUSY); /* clear */
406 BT_CONTROL(BT_CLR_WR_PTR); 513 BT_CONTROL(BT_CLR_WR_PTR);
407 write_all_bytes(bt); 514 write_all_bytes(bt);
408 BT_CONTROL(BT_H2B_ATN); /* clears too fast to catch? */ 515 BT_CONTROL(BT_H2B_ATN); /* can clear too fast to catch */
409 bt->state = BT_STATE_WRITE_CONSUME; 516 BT_STATE_CHANGE(BT_STATE_WRITE_CONSUME,
410 return SI_SM_CALL_WITHOUT_DELAY; /* it MIGHT sail through */ 517 SI_SM_CALL_WITHOUT_DELAY);
411
412 case BT_STATE_WRITE_CONSUME: /* BMCs usually blow right thru here */
413 if (status & (BT_H2B_ATN | BT_B_BUSY))
414 break;
415 bt->state = BT_STATE_B2H_WAIT;
416 /* fall through with status */
417
418 /* Stay in BT_STATE_B2H_WAIT until a packet matches. However, spinning
419 hard here, constantly reading status, seems to hold off the
420 generation of B2H_ATN so ALWAYS return CALL_WITH_DELAY. */
421
422 case BT_STATE_B2H_WAIT:
423 if (!(status & BT_B2H_ATN))
424 break;
425
426 /* Assume ordered, uncached writes: no need to wait */
427 if (!(status & BT_H_BUSY))
428 BT_CONTROL(BT_H_BUSY); /* set */
429 BT_CONTROL(BT_B2H_ATN); /* clear it, ACK to the BMC */
430 BT_CONTROL(BT_CLR_RD_PTR); /* reset the queue */
431 i = read_all_bytes(bt);
432 BT_CONTROL(BT_H_BUSY); /* clear */
433 if (!i) /* Try this state again */
434 break;
435 bt->state = BT_STATE_READ_END;
436 return SI_SM_CALL_WITHOUT_DELAY; /* for logging */
437
438 case BT_STATE_READ_END:
439
440 /* I could wait on BT_H_BUSY to go clear for a truly clean
441 exit. However, this is already done in XACTION_START
442 and the (possible) extra loop/status/possible wait affects
443 performance. So, as long as it works, just ignore H_BUSY */
444
445#ifdef MAKE_THIS_TRUE_IF_NECESSARY
446 518
447 if (status & BT_H_BUSY) 519 case BT_STATE_WRITE_CONSUME:
448 break; 520 if (status & (BT_B_BUSY | BT_H2B_ATN))
449#endif 521 BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
450 bt->seq++; 522 BT_STATE_CHANGE(BT_STATE_READ_WAIT,
451 bt->state = BT_STATE_IDLE; 523 SI_SM_CALL_WITHOUT_DELAY);
452 return SI_SM_TRANSACTION_COMPLETE; 524
525 /* Spinning hard can suppress B2H_ATN and force a timeout */
526
527 case BT_STATE_READ_WAIT:
528 if (!(status & BT_B2H_ATN))
529 BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
530 BT_CONTROL(BT_H_BUSY); /* set */
531
532 /* Uncached, ordered writes should just proceeed serially but
533 some BMCs don't clear B2H_ATN with one hit. Fast-path a
534 workaround without too much penalty to the general case. */
535
536 BT_CONTROL(BT_B2H_ATN); /* clear it to ACK the BMC */
537 BT_STATE_CHANGE(BT_STATE_CLEAR_B2H,
538 SI_SM_CALL_WITHOUT_DELAY);
539
540 case BT_STATE_CLEAR_B2H:
541 if (status & BT_B2H_ATN) { /* keep hitting it */
542 BT_CONTROL(BT_B2H_ATN);
543 BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
544 }
545 BT_STATE_CHANGE(BT_STATE_READ_BYTES,
546 SI_SM_CALL_WITHOUT_DELAY);
547
548 case BT_STATE_READ_BYTES:
549 if (!(status & BT_H_BUSY)) /* check in case of retry */
550 BT_CONTROL(BT_H_BUSY);
551 BT_CONTROL(BT_CLR_RD_PTR); /* start of BMC2HOST buffer */
552 i = read_all_bytes(bt); /* true == packet seq match */
553 BT_CONTROL(BT_H_BUSY); /* NOW clear */
554 if (!i) /* Not my message */
555 BT_STATE_CHANGE(BT_STATE_READ_WAIT,
556 SI_SM_CALL_WITHOUT_DELAY);
557 bt->state = bt->complete;
558 return bt->state == BT_STATE_IDLE ? /* where to next? */
559 SI_SM_TRANSACTION_COMPLETE : /* normal */
560 SI_SM_CALL_WITHOUT_DELAY; /* Startup magic */
561
562 case BT_STATE_LONG_BUSY: /* For example: after FW update */
563 if (!(status & BT_B_BUSY)) {
564 reset_flags(bt); /* next state is now IDLE */
565 bt_init_data(bt, bt->io);
566 }
567 return SI_SM_CALL_WITH_DELAY; /* No repeat printing */
453 568
454 case BT_STATE_RESET1: 569 case BT_STATE_RESET1:
455 reset_flags(bt); 570 reset_flags(bt);
456 bt->timeout = BT_RESET_DELAY; 571 drain_BMC2HOST(bt);
457 bt->state = BT_STATE_RESET2; 572 BT_STATE_CHANGE(BT_STATE_RESET2,
458 break; 573 SI_SM_CALL_WITH_DELAY);
459 574
460 case BT_STATE_RESET2: /* Send a soft reset */ 575 case BT_STATE_RESET2: /* Send a soft reset */
461 BT_CONTROL(BT_CLR_WR_PTR); 576 BT_CONTROL(BT_CLR_WR_PTR);
@@ -464,29 +579,59 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
464 HOST2BMC(42); /* Sequence number */ 579 HOST2BMC(42); /* Sequence number */
465 HOST2BMC(3); /* Cmd == Soft reset */ 580 HOST2BMC(3); /* Cmd == Soft reset */
466 BT_CONTROL(BT_H2B_ATN); 581 BT_CONTROL(BT_H2B_ATN);
467 bt->state = BT_STATE_RESET3; 582 bt->timeout = BT_RESET_DELAY * 1000000;
468 break; 583 BT_STATE_CHANGE(BT_STATE_RESET3,
584 SI_SM_CALL_WITH_DELAY);
469 585
470 case BT_STATE_RESET3: 586 case BT_STATE_RESET3: /* Hold off everything for a bit */
471 if (bt->timeout > 0) 587 if (bt->timeout > 0)
472 return SI_SM_CALL_WITH_DELAY; 588 return SI_SM_CALL_WITH_DELAY;
473 bt->state = BT_STATE_RESTART; /* printk in debug modes */ 589 drain_BMC2HOST(bt);
474 break; 590 BT_STATE_CHANGE(BT_STATE_RESTART,
591 SI_SM_CALL_WITH_DELAY);
475 592
476 case BT_STATE_RESTART: /* don't reset retries! */ 593 case BT_STATE_RESTART: /* don't reset retries or seq! */
477 reset_flags(bt);
478 bt->write_data[2] = ++bt->seq;
479 bt->read_count = 0; 594 bt->read_count = 0;
480 bt->nonzero_status = 0; 595 bt->nonzero_status = 0;
481 bt->timeout = BT_NORMAL_TIMEOUT; 596 bt->timeout = bt->BT_CAP_req2rsp;
482 bt->state = BT_STATE_XACTION_START; 597 BT_STATE_CHANGE(BT_STATE_XACTION_START,
483 break; 598 SI_SM_CALL_WITH_DELAY);
484 599
485 default: /* HOSED is supposed to be caught much earlier */ 600 /* Get BT Capabilities, using timing of upper level state machine.
486 error_recovery(bt, "internal logic error"); 601 Set outreqs to prevent infinite loop on timeout. */
487 break; 602 case BT_STATE_CAPABILITIES_BEGIN:
488 } 603 bt->BT_CAP_outreqs = 1;
489 return SI_SM_CALL_WITH_DELAY; 604 {
605 unsigned char GetBT_CAP[] = { 0x18, 0x36 };
606 bt->state = BT_STATE_IDLE;
607 bt_start_transaction(bt, GetBT_CAP, sizeof(GetBT_CAP));
608 }
609 bt->complete = BT_STATE_CAPABILITIES_END;
610 BT_STATE_CHANGE(BT_STATE_XACTION_START,
611 SI_SM_CALL_WITH_DELAY);
612
613 case BT_STATE_CAPABILITIES_END:
614 i = bt_get_result(bt, BT_CAP, sizeof(BT_CAP));
615 bt_init_data(bt, bt->io);
616 if ((i == 8) && !BT_CAP[2]) {
617 bt->BT_CAP_outreqs = BT_CAP[3];
618 bt->BT_CAP_req2rsp = BT_CAP[6] * 1000000;
619 bt->BT_CAP_retries = BT_CAP[7];
620 } else
621 printk(KERN_WARNING "IPMI BT: using default values\n");
622 if (!bt->BT_CAP_outreqs)
623 bt->BT_CAP_outreqs = 1;
624 printk(KERN_WARNING "IPMI BT: req2rsp=%ld secs retries=%d\n",
625 bt->BT_CAP_req2rsp / 1000000L, bt->BT_CAP_retries);
626 bt->timeout = bt->BT_CAP_req2rsp;
627 return SI_SM_CALL_WITHOUT_DELAY;
628
629 default: /* should never occur */
630 return error_recovery(bt,
631 status,
632 IPMI_ERR_UNSPECIFIED);
633 }
634 return SI_SM_CALL_WITH_DELAY;
490} 635}
491 636
492static int bt_detect(struct si_sm_data *bt) 637static int bt_detect(struct si_sm_data *bt)
@@ -497,7 +642,7 @@ static int bt_detect(struct si_sm_data *bt)
497 test that first. The calling routine uses negative logic. */ 642 test that first. The calling routine uses negative logic. */
498 643
499 if ((BT_STATUS == 0xFF) && (BT_INTMASK_R == 0xFF)) 644 if ((BT_STATUS == 0xFF) && (BT_INTMASK_R == 0xFF))
500 return 1; 645 return 1;
501 reset_flags(bt); 646 reset_flags(bt);
502 return 0; 647 return 0;
503} 648}
@@ -513,11 +658,11 @@ static int bt_size(void)
513 658
514struct si_sm_handlers bt_smi_handlers = 659struct si_sm_handlers bt_smi_handlers =
515{ 660{
516 .init_data = bt_init_data, 661 .init_data = bt_init_data,
517 .start_transaction = bt_start_transaction, 662 .start_transaction = bt_start_transaction,
518 .get_result = bt_get_result, 663 .get_result = bt_get_result,
519 .event = bt_event, 664 .event = bt_event,
520 .detect = bt_detect, 665 .detect = bt_detect,
521 .cleanup = bt_cleanup, 666 .cleanup = bt_cleanup,
522 .size = bt_size, 667 .size = bt_size,
523}; 668};
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index 81fcf0ce21d1..375d3378eecd 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -596,6 +596,31 @@ static int ipmi_ioctl(struct inode *inode,
596 rv = 0; 596 rv = 0;
597 break; 597 break;
598 } 598 }
599
600 case IPMICTL_GET_MAINTENANCE_MODE_CMD:
601 {
602 int mode;
603
604 mode = ipmi_get_maintenance_mode(priv->user);
605 if (copy_to_user(arg, &mode, sizeof(mode))) {
606 rv = -EFAULT;
607 break;
608 }
609 rv = 0;
610 break;
611 }
612
613 case IPMICTL_SET_MAINTENANCE_MODE_CMD:
614 {
615 int mode;
616
617 if (copy_from_user(&mode, arg, sizeof(mode))) {
618 rv = -EFAULT;
619 break;
620 }
621 rv = ipmi_set_maintenance_mode(priv->user, mode);
622 break;
623 }
599 } 624 }
600 625
601 return rv; 626 return rv;
diff --git a/drivers/char/ipmi/ipmi_kcs_sm.c b/drivers/char/ipmi/ipmi_kcs_sm.c
index 2062675f9e99..c1b8228cb7b6 100644
--- a/drivers/char/ipmi/ipmi_kcs_sm.c
+++ b/drivers/char/ipmi/ipmi_kcs_sm.c
@@ -93,8 +93,8 @@ enum kcs_states {
93 state machine. */ 93 state machine. */
94}; 94};
95 95
96#define MAX_KCS_READ_SIZE 80 96#define MAX_KCS_READ_SIZE IPMI_MAX_MSG_LENGTH
97#define MAX_KCS_WRITE_SIZE 80 97#define MAX_KCS_WRITE_SIZE IPMI_MAX_MSG_LENGTH
98 98
99/* Timeouts in microseconds. */ 99/* Timeouts in microseconds. */
100#define IBF_RETRY_TIMEOUT 1000000 100#define IBF_RETRY_TIMEOUT 1000000
@@ -261,12 +261,14 @@ static int start_kcs_transaction(struct si_sm_data *kcs, unsigned char *data,
261{ 261{
262 unsigned int i; 262 unsigned int i;
263 263
264 if ((size < 2) || (size > MAX_KCS_WRITE_SIZE)) { 264 if (size < 2)
265 return -1; 265 return IPMI_REQ_LEN_INVALID_ERR;
266 } 266 if (size > MAX_KCS_WRITE_SIZE)
267 if ((kcs->state != KCS_IDLE) && (kcs->state != KCS_HOSED)) { 267 return IPMI_REQ_LEN_EXCEEDED_ERR;
268 return -2; 268
269 } 269 if ((kcs->state != KCS_IDLE) && (kcs->state != KCS_HOSED))
270 return IPMI_NOT_IN_MY_STATE_ERR;
271
270 if (kcs_debug & KCS_DEBUG_MSG) { 272 if (kcs_debug & KCS_DEBUG_MSG) {
271 printk(KERN_DEBUG "start_kcs_transaction -"); 273 printk(KERN_DEBUG "start_kcs_transaction -");
272 for (i = 0; i < size; i ++) { 274 for (i = 0; i < size; i ++) {
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index c47add8e47df..5703ee28e1cc 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -48,7 +48,7 @@
48 48
49#define PFX "IPMI message handler: " 49#define PFX "IPMI message handler: "
50 50
51#define IPMI_DRIVER_VERSION "39.0" 51#define IPMI_DRIVER_VERSION "39.1"
52 52
53static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void); 53static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void);
54static int ipmi_init_msghandler(void); 54static int ipmi_init_msghandler(void);
@@ -59,6 +59,9 @@ static int initialized = 0;
59static struct proc_dir_entry *proc_ipmi_root = NULL; 59static struct proc_dir_entry *proc_ipmi_root = NULL;
60#endif /* CONFIG_PROC_FS */ 60#endif /* CONFIG_PROC_FS */
61 61
62/* Remain in auto-maintenance mode for this amount of time (in ms). */
63#define IPMI_MAINTENANCE_MODE_TIMEOUT 30000
64
62#define MAX_EVENTS_IN_QUEUE 25 65#define MAX_EVENTS_IN_QUEUE 25
63 66
64/* Don't let a message sit in a queue forever, always time it with at lest 67/* Don't let a message sit in a queue forever, always time it with at lest
@@ -193,17 +196,28 @@ struct ipmi_smi
193 196
194 struct kref refcount; 197 struct kref refcount;
195 198
199 /* Used for a list of interfaces. */
200 struct list_head link;
201
196 /* The list of upper layers that are using me. seq_lock 202 /* The list of upper layers that are using me. seq_lock
197 * protects this. */ 203 * protects this. */
198 struct list_head users; 204 struct list_head users;
199 205
206 /* Information to supply to users. */
207 unsigned char ipmi_version_major;
208 unsigned char ipmi_version_minor;
209
200 /* Used for wake ups at startup. */ 210 /* Used for wake ups at startup. */
201 wait_queue_head_t waitq; 211 wait_queue_head_t waitq;
202 212
203 struct bmc_device *bmc; 213 struct bmc_device *bmc;
204 char *my_dev_name; 214 char *my_dev_name;
215 char *sysfs_name;
205 216
206 /* This is the lower-layer's sender routine. */ 217 /* This is the lower-layer's sender routine. Note that you
218 * must either be holding the ipmi_interfaces_mutex or be in
219 * an umpreemptible region to use this. You must fetch the
220 * value into a local variable and make sure it is not NULL. */
207 struct ipmi_smi_handlers *handlers; 221 struct ipmi_smi_handlers *handlers;
208 void *send_info; 222 void *send_info;
209 223
@@ -242,6 +256,7 @@ struct ipmi_smi
242 spinlock_t events_lock; /* For dealing with event stuff. */ 256 spinlock_t events_lock; /* For dealing with event stuff. */
243 struct list_head waiting_events; 257 struct list_head waiting_events;
244 unsigned int waiting_events_count; /* How many events in queue? */ 258 unsigned int waiting_events_count; /* How many events in queue? */
259 int delivering_events;
245 260
246 /* The event receiver for my BMC, only really used at panic 261 /* The event receiver for my BMC, only really used at panic
247 shutdown as a place to store this. */ 262 shutdown as a place to store this. */
@@ -250,6 +265,12 @@ struct ipmi_smi
250 unsigned char local_sel_device; 265 unsigned char local_sel_device;
251 unsigned char local_event_generator; 266 unsigned char local_event_generator;
252 267
268 /* For handling of maintenance mode. */
269 int maintenance_mode;
270 int maintenance_mode_enable;
271 int auto_maintenance_timeout;
272 spinlock_t maintenance_mode_lock; /* Used in a timer... */
273
253 /* A cheap hack, if this is non-null and a message to an 274 /* A cheap hack, if this is non-null and a message to an
254 interface comes in with a NULL user, call this routine with 275 interface comes in with a NULL user, call this routine with
255 it. Note that the message will still be freed by the 276 it. Note that the message will still be freed by the
@@ -338,13 +359,6 @@ struct ipmi_smi
338}; 359};
339#define to_si_intf_from_dev(device) container_of(device, struct ipmi_smi, dev) 360#define to_si_intf_from_dev(device) container_of(device, struct ipmi_smi, dev)
340 361
341/* Used to mark an interface entry that cannot be used but is not a
342 * free entry, either, primarily used at creation and deletion time so
343 * a slot doesn't get reused too quickly. */
344#define IPMI_INVALID_INTERFACE_ENTRY ((ipmi_smi_t) ((long) 1))
345#define IPMI_INVALID_INTERFACE(i) (((i) == NULL) \
346 || (i == IPMI_INVALID_INTERFACE_ENTRY))
347
348/** 362/**
349 * The driver model view of the IPMI messaging driver. 363 * The driver model view of the IPMI messaging driver.
350 */ 364 */
@@ -354,16 +368,13 @@ static struct device_driver ipmidriver = {
354}; 368};
355static DEFINE_MUTEX(ipmidriver_mutex); 369static DEFINE_MUTEX(ipmidriver_mutex);
356 370
357#define MAX_IPMI_INTERFACES 4 371static struct list_head ipmi_interfaces = LIST_HEAD_INIT(ipmi_interfaces);
358static ipmi_smi_t ipmi_interfaces[MAX_IPMI_INTERFACES]; 372static DEFINE_MUTEX(ipmi_interfaces_mutex);
359
360/* Directly protects the ipmi_interfaces data structure. */
361static DEFINE_SPINLOCK(interfaces_lock);
362 373
363/* List of watchers that want to know when smi's are added and 374/* List of watchers that want to know when smi's are added and
364 deleted. */ 375 deleted. */
365static struct list_head smi_watchers = LIST_HEAD_INIT(smi_watchers); 376static struct list_head smi_watchers = LIST_HEAD_INIT(smi_watchers);
366static DECLARE_RWSEM(smi_watchers_sem); 377static DEFINE_MUTEX(smi_watchers_mutex);
367 378
368 379
369static void free_recv_msg_list(struct list_head *q) 380static void free_recv_msg_list(struct list_head *q)
@@ -423,48 +434,84 @@ static void intf_free(struct kref *ref)
423 kfree(intf); 434 kfree(intf);
424} 435}
425 436
437struct watcher_entry {
438 int intf_num;
439 ipmi_smi_t intf;
440 struct list_head link;
441};
442
426int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher) 443int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher)
427{ 444{
428 int i; 445 ipmi_smi_t intf;
429 unsigned long flags; 446 struct list_head to_deliver = LIST_HEAD_INIT(to_deliver);
447 struct watcher_entry *e, *e2;
448
449 mutex_lock(&smi_watchers_mutex);
450
451 mutex_lock(&ipmi_interfaces_mutex);
430 452
431 down_write(&smi_watchers_sem); 453 /* Build a list of things to deliver. */
432 list_add(&(watcher->link), &smi_watchers); 454 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
433 up_write(&smi_watchers_sem); 455 if (intf->intf_num == -1)
434 spin_lock_irqsave(&interfaces_lock, flags);
435 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
436 ipmi_smi_t intf = ipmi_interfaces[i];
437 if (IPMI_INVALID_INTERFACE(intf))
438 continue; 456 continue;
439 spin_unlock_irqrestore(&interfaces_lock, flags); 457 e = kmalloc(sizeof(*e), GFP_KERNEL);
440 watcher->new_smi(i, intf->si_dev); 458 if (!e)
441 spin_lock_irqsave(&interfaces_lock, flags); 459 goto out_err;
460 kref_get(&intf->refcount);
461 e->intf = intf;
462 e->intf_num = intf->intf_num;
463 list_add_tail(&e->link, &to_deliver);
442 } 464 }
443 spin_unlock_irqrestore(&interfaces_lock, flags); 465
466 /* We will succeed, so add it to the list. */
467 list_add(&watcher->link, &smi_watchers);
468
469 mutex_unlock(&ipmi_interfaces_mutex);
470
471 list_for_each_entry_safe(e, e2, &to_deliver, link) {
472 list_del(&e->link);
473 watcher->new_smi(e->intf_num, e->intf->si_dev);
474 kref_put(&e->intf->refcount, intf_free);
475 kfree(e);
476 }
477
478 mutex_unlock(&smi_watchers_mutex);
479
444 return 0; 480 return 0;
481
482 out_err:
483 mutex_unlock(&ipmi_interfaces_mutex);
484 mutex_unlock(&smi_watchers_mutex);
485 list_for_each_entry_safe(e, e2, &to_deliver, link) {
486 list_del(&e->link);
487 kref_put(&e->intf->refcount, intf_free);
488 kfree(e);
489 }
490 return -ENOMEM;
445} 491}
446 492
447int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher) 493int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher)
448{ 494{
449 down_write(&smi_watchers_sem); 495 mutex_lock(&smi_watchers_mutex);
450 list_del(&(watcher->link)); 496 list_del(&(watcher->link));
451 up_write(&smi_watchers_sem); 497 mutex_unlock(&smi_watchers_mutex);
452 return 0; 498 return 0;
453} 499}
454 500
501/*
502 * Must be called with smi_watchers_mutex held.
503 */
455static void 504static void
456call_smi_watchers(int i, struct device *dev) 505call_smi_watchers(int i, struct device *dev)
457{ 506{
458 struct ipmi_smi_watcher *w; 507 struct ipmi_smi_watcher *w;
459 508
460 down_read(&smi_watchers_sem);
461 list_for_each_entry(w, &smi_watchers, link) { 509 list_for_each_entry(w, &smi_watchers, link) {
462 if (try_module_get(w->owner)) { 510 if (try_module_get(w->owner)) {
463 w->new_smi(i, dev); 511 w->new_smi(i, dev);
464 module_put(w->owner); 512 module_put(w->owner);
465 } 513 }
466 } 514 }
467 up_read(&smi_watchers_sem);
468} 515}
469 516
470static int 517static int
@@ -590,6 +637,17 @@ static void deliver_response(struct ipmi_recv_msg *msg)
590 } 637 }
591} 638}
592 639
640static void
641deliver_err_response(struct ipmi_recv_msg *msg, int err)
642{
643 msg->recv_type = IPMI_RESPONSE_RECV_TYPE;
644 msg->msg_data[0] = err;
645 msg->msg.netfn |= 1; /* Convert to a response. */
646 msg->msg.data_len = 1;
647 msg->msg.data = msg->msg_data;
648 deliver_response(msg);
649}
650
593/* Find the next sequence number not being used and add the given 651/* Find the next sequence number not being used and add the given
594 message with the given timeout to the sequence table. This must be 652 message with the given timeout to the sequence table. This must be
595 called with the interface's seq_lock held. */ 653 called with the interface's seq_lock held. */
@@ -727,14 +785,8 @@ static int intf_err_seq(ipmi_smi_t intf,
727 } 785 }
728 spin_unlock_irqrestore(&(intf->seq_lock), flags); 786 spin_unlock_irqrestore(&(intf->seq_lock), flags);
729 787
730 if (msg) { 788 if (msg)
731 msg->recv_type = IPMI_RESPONSE_RECV_TYPE; 789 deliver_err_response(msg, err);
732 msg->msg_data[0] = err;
733 msg->msg.netfn |= 1; /* Convert to a response. */
734 msg->msg.data_len = 1;
735 msg->msg.data = msg->msg_data;
736 deliver_response(msg);
737 }
738 790
739 return rv; 791 return rv;
740} 792}
@@ -776,17 +828,18 @@ int ipmi_create_user(unsigned int if_num,
776 if (!new_user) 828 if (!new_user)
777 return -ENOMEM; 829 return -ENOMEM;
778 830
779 spin_lock_irqsave(&interfaces_lock, flags); 831 mutex_lock(&ipmi_interfaces_mutex);
780 intf = ipmi_interfaces[if_num]; 832 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
781 if ((if_num >= MAX_IPMI_INTERFACES) || IPMI_INVALID_INTERFACE(intf)) { 833 if (intf->intf_num == if_num)
782 spin_unlock_irqrestore(&interfaces_lock, flags); 834 goto found;
783 rv = -EINVAL;
784 goto out_kfree;
785 } 835 }
836 /* Not found, return an error */
837 rv = -EINVAL;
838 goto out_kfree;
786 839
840 found:
787 /* Note that each existing user holds a refcount to the interface. */ 841 /* Note that each existing user holds a refcount to the interface. */
788 kref_get(&intf->refcount); 842 kref_get(&intf->refcount);
789 spin_unlock_irqrestore(&interfaces_lock, flags);
790 843
791 kref_init(&new_user->refcount); 844 kref_init(&new_user->refcount);
792 new_user->handler = handler; 845 new_user->handler = handler;
@@ -807,6 +860,10 @@ int ipmi_create_user(unsigned int if_num,
807 } 860 }
808 } 861 }
809 862
863 /* Hold the lock so intf->handlers is guaranteed to be good
864 * until now */
865 mutex_unlock(&ipmi_interfaces_mutex);
866
810 new_user->valid = 1; 867 new_user->valid = 1;
811 spin_lock_irqsave(&intf->seq_lock, flags); 868 spin_lock_irqsave(&intf->seq_lock, flags);
812 list_add_rcu(&new_user->link, &intf->users); 869 list_add_rcu(&new_user->link, &intf->users);
@@ -817,6 +874,7 @@ int ipmi_create_user(unsigned int if_num,
817out_kref: 874out_kref:
818 kref_put(&intf->refcount, intf_free); 875 kref_put(&intf->refcount, intf_free);
819out_kfree: 876out_kfree:
877 mutex_unlock(&ipmi_interfaces_mutex);
820 kfree(new_user); 878 kfree(new_user);
821 return rv; 879 return rv;
822} 880}
@@ -846,6 +904,7 @@ int ipmi_destroy_user(ipmi_user_t user)
846 && (intf->seq_table[i].recv_msg->user == user)) 904 && (intf->seq_table[i].recv_msg->user == user))
847 { 905 {
848 intf->seq_table[i].inuse = 0; 906 intf->seq_table[i].inuse = 0;
907 ipmi_free_recv_msg(intf->seq_table[i].recv_msg);
849 } 908 }
850 } 909 }
851 spin_unlock_irqrestore(&intf->seq_lock, flags); 910 spin_unlock_irqrestore(&intf->seq_lock, flags);
@@ -872,9 +931,13 @@ int ipmi_destroy_user(ipmi_user_t user)
872 kfree(rcvr); 931 kfree(rcvr);
873 } 932 }
874 933
875 module_put(intf->handlers->owner); 934 mutex_lock(&ipmi_interfaces_mutex);
876 if (intf->handlers->dec_usecount) 935 if (intf->handlers) {
877 intf->handlers->dec_usecount(intf->send_info); 936 module_put(intf->handlers->owner);
937 if (intf->handlers->dec_usecount)
938 intf->handlers->dec_usecount(intf->send_info);
939 }
940 mutex_unlock(&ipmi_interfaces_mutex);
878 941
879 kref_put(&intf->refcount, intf_free); 942 kref_put(&intf->refcount, intf_free);
880 943
@@ -887,8 +950,8 @@ void ipmi_get_version(ipmi_user_t user,
887 unsigned char *major, 950 unsigned char *major,
888 unsigned char *minor) 951 unsigned char *minor)
889{ 952{
890 *major = ipmi_version_major(&user->intf->bmc->id); 953 *major = user->intf->ipmi_version_major;
891 *minor = ipmi_version_minor(&user->intf->bmc->id); 954 *minor = user->intf->ipmi_version_minor;
892} 955}
893 956
894int ipmi_set_my_address(ipmi_user_t user, 957int ipmi_set_my_address(ipmi_user_t user,
@@ -931,6 +994,65 @@ int ipmi_get_my_LUN(ipmi_user_t user,
931 return 0; 994 return 0;
932} 995}
933 996
997int ipmi_get_maintenance_mode(ipmi_user_t user)
998{
999 int mode;
1000 unsigned long flags;
1001
1002 spin_lock_irqsave(&user->intf->maintenance_mode_lock, flags);
1003 mode = user->intf->maintenance_mode;
1004 spin_unlock_irqrestore(&user->intf->maintenance_mode_lock, flags);
1005
1006 return mode;
1007}
1008EXPORT_SYMBOL(ipmi_get_maintenance_mode);
1009
1010static void maintenance_mode_update(ipmi_smi_t intf)
1011{
1012 if (intf->handlers->set_maintenance_mode)
1013 intf->handlers->set_maintenance_mode(
1014 intf->send_info, intf->maintenance_mode_enable);
1015}
1016
1017int ipmi_set_maintenance_mode(ipmi_user_t user, int mode)
1018{
1019 int rv = 0;
1020 unsigned long flags;
1021 ipmi_smi_t intf = user->intf;
1022
1023 spin_lock_irqsave(&intf->maintenance_mode_lock, flags);
1024 if (intf->maintenance_mode != mode) {
1025 switch (mode) {
1026 case IPMI_MAINTENANCE_MODE_AUTO:
1027 intf->maintenance_mode = mode;
1028 intf->maintenance_mode_enable
1029 = (intf->auto_maintenance_timeout > 0);
1030 break;
1031
1032 case IPMI_MAINTENANCE_MODE_OFF:
1033 intf->maintenance_mode = mode;
1034 intf->maintenance_mode_enable = 0;
1035 break;
1036
1037 case IPMI_MAINTENANCE_MODE_ON:
1038 intf->maintenance_mode = mode;
1039 intf->maintenance_mode_enable = 1;
1040 break;
1041
1042 default:
1043 rv = -EINVAL;
1044 goto out_unlock;
1045 }
1046
1047 maintenance_mode_update(intf);
1048 }
1049 out_unlock:
1050 spin_unlock_irqrestore(&intf->maintenance_mode_lock, flags);
1051
1052 return rv;
1053}
1054EXPORT_SYMBOL(ipmi_set_maintenance_mode);
1055
934int ipmi_set_gets_events(ipmi_user_t user, int val) 1056int ipmi_set_gets_events(ipmi_user_t user, int val)
935{ 1057{
936 unsigned long flags; 1058 unsigned long flags;
@@ -943,20 +1065,33 @@ int ipmi_set_gets_events(ipmi_user_t user, int val)
943 spin_lock_irqsave(&intf->events_lock, flags); 1065 spin_lock_irqsave(&intf->events_lock, flags);
944 user->gets_events = val; 1066 user->gets_events = val;
945 1067
946 if (val) { 1068 if (intf->delivering_events)
947 /* Deliver any queued events. */ 1069 /*
1070 * Another thread is delivering events for this, so
1071 * let it handle any new events.
1072 */
1073 goto out;
1074
1075 /* Deliver any queued events. */
1076 while (user->gets_events && !list_empty(&intf->waiting_events)) {
948 list_for_each_entry_safe(msg, msg2, &intf->waiting_events, link) 1077 list_for_each_entry_safe(msg, msg2, &intf->waiting_events, link)
949 list_move_tail(&msg->link, &msgs); 1078 list_move_tail(&msg->link, &msgs);
950 intf->waiting_events_count = 0; 1079 intf->waiting_events_count = 0;
951 }
952 1080
953 /* Hold the events lock while doing this to preserve order. */ 1081 intf->delivering_events = 1;
954 list_for_each_entry_safe(msg, msg2, &msgs, link) { 1082 spin_unlock_irqrestore(&intf->events_lock, flags);
955 msg->user = user; 1083
956 kref_get(&user->refcount); 1084 list_for_each_entry_safe(msg, msg2, &msgs, link) {
957 deliver_response(msg); 1085 msg->user = user;
1086 kref_get(&user->refcount);
1087 deliver_response(msg);
1088 }
1089
1090 spin_lock_irqsave(&intf->events_lock, flags);
1091 intf->delivering_events = 0;
958 } 1092 }
959 1093
1094 out:
960 spin_unlock_irqrestore(&intf->events_lock, flags); 1095 spin_unlock_irqrestore(&intf->events_lock, flags);
961 1096
962 return 0; 1097 return 0;
@@ -1067,7 +1202,8 @@ int ipmi_unregister_for_cmd(ipmi_user_t user,
1067void ipmi_user_set_run_to_completion(ipmi_user_t user, int val) 1202void ipmi_user_set_run_to_completion(ipmi_user_t user, int val)
1068{ 1203{
1069 ipmi_smi_t intf = user->intf; 1204 ipmi_smi_t intf = user->intf;
1070 intf->handlers->set_run_to_completion(intf->send_info, val); 1205 if (intf->handlers)
1206 intf->handlers->set_run_to_completion(intf->send_info, val);
1071} 1207}
1072 1208
1073static unsigned char 1209static unsigned char
@@ -1178,10 +1314,11 @@ static int i_ipmi_request(ipmi_user_t user,
1178 int retries, 1314 int retries,
1179 unsigned int retry_time_ms) 1315 unsigned int retry_time_ms)
1180{ 1316{
1181 int rv = 0; 1317 int rv = 0;
1182 struct ipmi_smi_msg *smi_msg; 1318 struct ipmi_smi_msg *smi_msg;
1183 struct ipmi_recv_msg *recv_msg; 1319 struct ipmi_recv_msg *recv_msg;
1184 unsigned long flags; 1320 unsigned long flags;
1321 struct ipmi_smi_handlers *handlers;
1185 1322
1186 1323
1187 if (supplied_recv) { 1324 if (supplied_recv) {
@@ -1204,6 +1341,13 @@ static int i_ipmi_request(ipmi_user_t user,
1204 } 1341 }
1205 } 1342 }
1206 1343
1344 rcu_read_lock();
1345 handlers = intf->handlers;
1346 if (!handlers) {
1347 rv = -ENODEV;
1348 goto out_err;
1349 }
1350
1207 recv_msg->user = user; 1351 recv_msg->user = user;
1208 if (user) 1352 if (user)
1209 kref_get(&user->refcount); 1353 kref_get(&user->refcount);
@@ -1246,6 +1390,24 @@ static int i_ipmi_request(ipmi_user_t user,
1246 goto out_err; 1390 goto out_err;
1247 } 1391 }
1248 1392
1393 if (((msg->netfn == IPMI_NETFN_APP_REQUEST)
1394 && ((msg->cmd == IPMI_COLD_RESET_CMD)
1395 || (msg->cmd == IPMI_WARM_RESET_CMD)))
1396 || (msg->netfn == IPMI_NETFN_FIRMWARE_REQUEST))
1397 {
1398 spin_lock_irqsave(&intf->maintenance_mode_lock, flags);
1399 intf->auto_maintenance_timeout
1400 = IPMI_MAINTENANCE_MODE_TIMEOUT;
1401 if (!intf->maintenance_mode
1402 && !intf->maintenance_mode_enable)
1403 {
1404 intf->maintenance_mode_enable = 1;
1405 maintenance_mode_update(intf);
1406 }
1407 spin_unlock_irqrestore(&intf->maintenance_mode_lock,
1408 flags);
1409 }
1410
1249 if ((msg->data_len + 2) > IPMI_MAX_MSG_LENGTH) { 1411 if ((msg->data_len + 2) > IPMI_MAX_MSG_LENGTH) {
1250 spin_lock_irqsave(&intf->counter_lock, flags); 1412 spin_lock_irqsave(&intf->counter_lock, flags);
1251 intf->sent_invalid_commands++; 1413 intf->sent_invalid_commands++;
@@ -1520,11 +1682,14 @@ static int i_ipmi_request(ipmi_user_t user,
1520 printk("\n"); 1682 printk("\n");
1521 } 1683 }
1522#endif 1684#endif
1523 intf->handlers->sender(intf->send_info, smi_msg, priority); 1685
1686 handlers->sender(intf->send_info, smi_msg, priority);
1687 rcu_read_unlock();
1524 1688
1525 return 0; 1689 return 0;
1526 1690
1527 out_err: 1691 out_err:
1692 rcu_read_unlock();
1528 ipmi_free_smi_msg(smi_msg); 1693 ipmi_free_smi_msg(smi_msg);
1529 ipmi_free_recv_msg(recv_msg); 1694 ipmi_free_recv_msg(recv_msg);
1530 return rv; 1695 return rv;
@@ -1604,6 +1769,7 @@ int ipmi_request_supply_msgs(ipmi_user_t user,
1604 -1, 0); 1769 -1, 0);
1605} 1770}
1606 1771
1772#ifdef CONFIG_PROC_FS
1607static int ipmb_file_read_proc(char *page, char **start, off_t off, 1773static int ipmb_file_read_proc(char *page, char **start, off_t off,
1608 int count, int *eof, void *data) 1774 int count, int *eof, void *data)
1609{ 1775{
@@ -1692,6 +1858,7 @@ static int stat_file_read_proc(char *page, char **start, off_t off,
1692 1858
1693 return (out - ((char *) page)); 1859 return (out - ((char *) page));
1694} 1860}
1861#endif /* CONFIG_PROC_FS */
1695 1862
1696int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, 1863int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
1697 read_proc_t *read_proc, write_proc_t *write_proc, 1864 read_proc_t *read_proc, write_proc_t *write_proc,
@@ -1817,13 +1984,12 @@ static int __find_bmc_prod_dev_id(struct device *dev, void *data)
1817 struct bmc_device *bmc = dev_get_drvdata(dev); 1984 struct bmc_device *bmc = dev_get_drvdata(dev);
1818 1985
1819 return (bmc->id.product_id == id->product_id 1986 return (bmc->id.product_id == id->product_id
1820 && bmc->id.product_id == id->product_id
1821 && bmc->id.device_id == id->device_id); 1987 && bmc->id.device_id == id->device_id);
1822} 1988}
1823 1989
1824static struct bmc_device *ipmi_find_bmc_prod_dev_id( 1990static struct bmc_device *ipmi_find_bmc_prod_dev_id(
1825 struct device_driver *drv, 1991 struct device_driver *drv,
1826 unsigned char product_id, unsigned char device_id) 1992 unsigned int product_id, unsigned char device_id)
1827{ 1993{
1828 struct prod_dev_id id = { 1994 struct prod_dev_id id = {
1829 .product_id = product_id, 1995 .product_id = product_id,
@@ -1940,6 +2106,9 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr,
1940 2106
1941static void remove_files(struct bmc_device *bmc) 2107static void remove_files(struct bmc_device *bmc)
1942{ 2108{
2109 if (!bmc->dev)
2110 return;
2111
1943 device_remove_file(&bmc->dev->dev, 2112 device_remove_file(&bmc->dev->dev,
1944 &bmc->device_id_attr); 2113 &bmc->device_id_attr);
1945 device_remove_file(&bmc->dev->dev, 2114 device_remove_file(&bmc->dev->dev,
@@ -1973,7 +2142,8 @@ cleanup_bmc_device(struct kref *ref)
1973 bmc = container_of(ref, struct bmc_device, refcount); 2142 bmc = container_of(ref, struct bmc_device, refcount);
1974 2143
1975 remove_files(bmc); 2144 remove_files(bmc);
1976 platform_device_unregister(bmc->dev); 2145 if (bmc->dev)
2146 platform_device_unregister(bmc->dev);
1977 kfree(bmc); 2147 kfree(bmc);
1978} 2148}
1979 2149
@@ -1981,7 +2151,11 @@ static void ipmi_bmc_unregister(ipmi_smi_t intf)
1981{ 2151{
1982 struct bmc_device *bmc = intf->bmc; 2152 struct bmc_device *bmc = intf->bmc;
1983 2153
1984 sysfs_remove_link(&intf->si_dev->kobj, "bmc"); 2154 if (intf->sysfs_name) {
2155 sysfs_remove_link(&intf->si_dev->kobj, intf->sysfs_name);
2156 kfree(intf->sysfs_name);
2157 intf->sysfs_name = NULL;
2158 }
1985 if (intf->my_dev_name) { 2159 if (intf->my_dev_name) {
1986 sysfs_remove_link(&bmc->dev->dev.kobj, intf->my_dev_name); 2160 sysfs_remove_link(&bmc->dev->dev.kobj, intf->my_dev_name);
1987 kfree(intf->my_dev_name); 2161 kfree(intf->my_dev_name);
@@ -1990,6 +2164,7 @@ static void ipmi_bmc_unregister(ipmi_smi_t intf)
1990 2164
1991 mutex_lock(&ipmidriver_mutex); 2165 mutex_lock(&ipmidriver_mutex);
1992 kref_put(&bmc->refcount, cleanup_bmc_device); 2166 kref_put(&bmc->refcount, cleanup_bmc_device);
2167 intf->bmc = NULL;
1993 mutex_unlock(&ipmidriver_mutex); 2168 mutex_unlock(&ipmidriver_mutex);
1994} 2169}
1995 2170
@@ -1997,6 +2172,56 @@ static int create_files(struct bmc_device *bmc)
1997{ 2172{
1998 int err; 2173 int err;
1999 2174
2175 bmc->device_id_attr.attr.name = "device_id";
2176 bmc->device_id_attr.attr.owner = THIS_MODULE;
2177 bmc->device_id_attr.attr.mode = S_IRUGO;
2178 bmc->device_id_attr.show = device_id_show;
2179
2180 bmc->provides_dev_sdrs_attr.attr.name = "provides_device_sdrs";
2181 bmc->provides_dev_sdrs_attr.attr.owner = THIS_MODULE;
2182 bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO;
2183 bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show;
2184
2185 bmc->revision_attr.attr.name = "revision";
2186 bmc->revision_attr.attr.owner = THIS_MODULE;
2187 bmc->revision_attr.attr.mode = S_IRUGO;
2188 bmc->revision_attr.show = revision_show;
2189
2190 bmc->firmware_rev_attr.attr.name = "firmware_revision";
2191 bmc->firmware_rev_attr.attr.owner = THIS_MODULE;
2192 bmc->firmware_rev_attr.attr.mode = S_IRUGO;
2193 bmc->firmware_rev_attr.show = firmware_rev_show;
2194
2195 bmc->version_attr.attr.name = "ipmi_version";
2196 bmc->version_attr.attr.owner = THIS_MODULE;
2197 bmc->version_attr.attr.mode = S_IRUGO;
2198 bmc->version_attr.show = ipmi_version_show;
2199
2200 bmc->add_dev_support_attr.attr.name = "additional_device_support";
2201 bmc->add_dev_support_attr.attr.owner = THIS_MODULE;
2202 bmc->add_dev_support_attr.attr.mode = S_IRUGO;
2203 bmc->add_dev_support_attr.show = add_dev_support_show;
2204
2205 bmc->manufacturer_id_attr.attr.name = "manufacturer_id";
2206 bmc->manufacturer_id_attr.attr.owner = THIS_MODULE;
2207 bmc->manufacturer_id_attr.attr.mode = S_IRUGO;
2208 bmc->manufacturer_id_attr.show = manufacturer_id_show;
2209
2210 bmc->product_id_attr.attr.name = "product_id";
2211 bmc->product_id_attr.attr.owner = THIS_MODULE;
2212 bmc->product_id_attr.attr.mode = S_IRUGO;
2213 bmc->product_id_attr.show = product_id_show;
2214
2215 bmc->guid_attr.attr.name = "guid";
2216 bmc->guid_attr.attr.owner = THIS_MODULE;
2217 bmc->guid_attr.attr.mode = S_IRUGO;
2218 bmc->guid_attr.show = guid_show;
2219
2220 bmc->aux_firmware_rev_attr.attr.name = "aux_firmware_revision";
2221 bmc->aux_firmware_rev_attr.attr.owner = THIS_MODULE;
2222 bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO;
2223 bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show;
2224
2000 err = device_create_file(&bmc->dev->dev, 2225 err = device_create_file(&bmc->dev->dev,
2001 &bmc->device_id_attr); 2226 &bmc->device_id_attr);
2002 if (err) goto out; 2227 if (err) goto out;
@@ -2066,7 +2291,8 @@ out:
2066 return err; 2291 return err;
2067} 2292}
2068 2293
2069static int ipmi_bmc_register(ipmi_smi_t intf) 2294static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum,
2295 const char *sysfs_name)
2070{ 2296{
2071 int rv; 2297 int rv;
2072 struct bmc_device *bmc = intf->bmc; 2298 struct bmc_device *bmc = intf->bmc;
@@ -2106,9 +2332,39 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2106 bmc->id.product_id, 2332 bmc->id.product_id,
2107 bmc->id.device_id); 2333 bmc->id.device_id);
2108 } else { 2334 } else {
2109 bmc->dev = platform_device_alloc("ipmi_bmc", 2335 char name[14];
2110 bmc->id.device_id); 2336 unsigned char orig_dev_id = bmc->id.device_id;
2337 int warn_printed = 0;
2338
2339 snprintf(name, sizeof(name),
2340 "ipmi_bmc.%4.4x", bmc->id.product_id);
2341
2342 while (ipmi_find_bmc_prod_dev_id(&ipmidriver,
2343 bmc->id.product_id,
2344 bmc->id.device_id))
2345 {
2346 if (!warn_printed) {
2347 printk(KERN_WARNING PFX
2348 "This machine has two different BMCs"
2349 " with the same product id and device"
2350 " id. This is an error in the"
2351 " firmware, but incrementing the"
2352 " device id to work around the problem."
2353 " Prod ID = 0x%x, Dev ID = 0x%x\n",
2354 bmc->id.product_id, bmc->id.device_id);
2355 warn_printed = 1;
2356 }
2357 bmc->id.device_id++; /* Wraps at 255 */
2358 if (bmc->id.device_id == orig_dev_id) {
2359 printk(KERN_ERR PFX
2360 "Out of device ids!\n");
2361 break;
2362 }
2363 }
2364
2365 bmc->dev = platform_device_alloc(name, bmc->id.device_id);
2111 if (!bmc->dev) { 2366 if (!bmc->dev) {
2367 mutex_unlock(&ipmidriver_mutex);
2112 printk(KERN_ERR 2368 printk(KERN_ERR
2113 "ipmi_msghandler:" 2369 "ipmi_msghandler:"
2114 " Unable to allocate platform device\n"); 2370 " Unable to allocate platform device\n");
@@ -2121,6 +2377,8 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2121 rv = platform_device_add(bmc->dev); 2377 rv = platform_device_add(bmc->dev);
2122 mutex_unlock(&ipmidriver_mutex); 2378 mutex_unlock(&ipmidriver_mutex);
2123 if (rv) { 2379 if (rv) {
2380 platform_device_put(bmc->dev);
2381 bmc->dev = NULL;
2124 printk(KERN_ERR 2382 printk(KERN_ERR
2125 "ipmi_msghandler:" 2383 "ipmi_msghandler:"
2126 " Unable to register bmc device: %d\n", 2384 " Unable to register bmc device: %d\n",
@@ -2130,57 +2388,6 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2130 return rv; 2388 return rv;
2131 } 2389 }
2132 2390
2133 bmc->device_id_attr.attr.name = "device_id";
2134 bmc->device_id_attr.attr.owner = THIS_MODULE;
2135 bmc->device_id_attr.attr.mode = S_IRUGO;
2136 bmc->device_id_attr.show = device_id_show;
2137
2138 bmc->provides_dev_sdrs_attr.attr.name = "provides_device_sdrs";
2139 bmc->provides_dev_sdrs_attr.attr.owner = THIS_MODULE;
2140 bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO;
2141 bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show;
2142
2143 bmc->revision_attr.attr.name = "revision";
2144 bmc->revision_attr.attr.owner = THIS_MODULE;
2145 bmc->revision_attr.attr.mode = S_IRUGO;
2146 bmc->revision_attr.show = revision_show;
2147
2148 bmc->firmware_rev_attr.attr.name = "firmware_revision";
2149 bmc->firmware_rev_attr.attr.owner = THIS_MODULE;
2150 bmc->firmware_rev_attr.attr.mode = S_IRUGO;
2151 bmc->firmware_rev_attr.show = firmware_rev_show;
2152
2153 bmc->version_attr.attr.name = "ipmi_version";
2154 bmc->version_attr.attr.owner = THIS_MODULE;
2155 bmc->version_attr.attr.mode = S_IRUGO;
2156 bmc->version_attr.show = ipmi_version_show;
2157
2158 bmc->add_dev_support_attr.attr.name
2159 = "additional_device_support";
2160 bmc->add_dev_support_attr.attr.owner = THIS_MODULE;
2161 bmc->add_dev_support_attr.attr.mode = S_IRUGO;
2162 bmc->add_dev_support_attr.show = add_dev_support_show;
2163
2164 bmc->manufacturer_id_attr.attr.name = "manufacturer_id";
2165 bmc->manufacturer_id_attr.attr.owner = THIS_MODULE;
2166 bmc->manufacturer_id_attr.attr.mode = S_IRUGO;
2167 bmc->manufacturer_id_attr.show = manufacturer_id_show;
2168
2169 bmc->product_id_attr.attr.name = "product_id";
2170 bmc->product_id_attr.attr.owner = THIS_MODULE;
2171 bmc->product_id_attr.attr.mode = S_IRUGO;
2172 bmc->product_id_attr.show = product_id_show;
2173
2174 bmc->guid_attr.attr.name = "guid";
2175 bmc->guid_attr.attr.owner = THIS_MODULE;
2176 bmc->guid_attr.attr.mode = S_IRUGO;
2177 bmc->guid_attr.show = guid_show;
2178
2179 bmc->aux_firmware_rev_attr.attr.name = "aux_firmware_revision";
2180 bmc->aux_firmware_rev_attr.attr.owner = THIS_MODULE;
2181 bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO;
2182 bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show;
2183
2184 rv = create_files(bmc); 2391 rv = create_files(bmc);
2185 if (rv) { 2392 if (rv) {
2186 mutex_lock(&ipmidriver_mutex); 2393 mutex_lock(&ipmidriver_mutex);
@@ -2202,29 +2409,44 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2202 * create symlink from system interface device to bmc device 2409 * create symlink from system interface device to bmc device
2203 * and back. 2410 * and back.
2204 */ 2411 */
2412 intf->sysfs_name = kstrdup(sysfs_name, GFP_KERNEL);
2413 if (!intf->sysfs_name) {
2414 rv = -ENOMEM;
2415 printk(KERN_ERR
2416 "ipmi_msghandler: allocate link to BMC: %d\n",
2417 rv);
2418 goto out_err;
2419 }
2420
2205 rv = sysfs_create_link(&intf->si_dev->kobj, 2421 rv = sysfs_create_link(&intf->si_dev->kobj,
2206 &bmc->dev->dev.kobj, "bmc"); 2422 &bmc->dev->dev.kobj, intf->sysfs_name);
2207 if (rv) { 2423 if (rv) {
2424 kfree(intf->sysfs_name);
2425 intf->sysfs_name = NULL;
2208 printk(KERN_ERR 2426 printk(KERN_ERR
2209 "ipmi_msghandler: Unable to create bmc symlink: %d\n", 2427 "ipmi_msghandler: Unable to create bmc symlink: %d\n",
2210 rv); 2428 rv);
2211 goto out_err; 2429 goto out_err;
2212 } 2430 }
2213 2431
2214 size = snprintf(dummy, 0, "ipmi%d", intf->intf_num); 2432 size = snprintf(dummy, 0, "ipmi%d", ifnum);
2215 intf->my_dev_name = kmalloc(size+1, GFP_KERNEL); 2433 intf->my_dev_name = kmalloc(size+1, GFP_KERNEL);
2216 if (!intf->my_dev_name) { 2434 if (!intf->my_dev_name) {
2435 kfree(intf->sysfs_name);
2436 intf->sysfs_name = NULL;
2217 rv = -ENOMEM; 2437 rv = -ENOMEM;
2218 printk(KERN_ERR 2438 printk(KERN_ERR
2219 "ipmi_msghandler: allocate link from BMC: %d\n", 2439 "ipmi_msghandler: allocate link from BMC: %d\n",
2220 rv); 2440 rv);
2221 goto out_err; 2441 goto out_err;
2222 } 2442 }
2223 snprintf(intf->my_dev_name, size+1, "ipmi%d", intf->intf_num); 2443 snprintf(intf->my_dev_name, size+1, "ipmi%d", ifnum);
2224 2444
2225 rv = sysfs_create_link(&bmc->dev->dev.kobj, &intf->si_dev->kobj, 2445 rv = sysfs_create_link(&bmc->dev->dev.kobj, &intf->si_dev->kobj,
2226 intf->my_dev_name); 2446 intf->my_dev_name);
2227 if (rv) { 2447 if (rv) {
2448 kfree(intf->sysfs_name);
2449 intf->sysfs_name = NULL;
2228 kfree(intf->my_dev_name); 2450 kfree(intf->my_dev_name);
2229 intf->my_dev_name = NULL; 2451 intf->my_dev_name = NULL;
2230 printk(KERN_ERR 2452 printk(KERN_ERR
@@ -2409,17 +2631,14 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2409 void *send_info, 2631 void *send_info,
2410 struct ipmi_device_id *device_id, 2632 struct ipmi_device_id *device_id,
2411 struct device *si_dev, 2633 struct device *si_dev,
2634 const char *sysfs_name,
2412 unsigned char slave_addr) 2635 unsigned char slave_addr)
2413{ 2636{
2414 int i, j; 2637 int i, j;
2415 int rv; 2638 int rv;
2416 ipmi_smi_t intf; 2639 ipmi_smi_t intf;
2417 unsigned long flags; 2640 ipmi_smi_t tintf;
2418 int version_major; 2641 struct list_head *link;
2419 int version_minor;
2420
2421 version_major = ipmi_version_major(device_id);
2422 version_minor = ipmi_version_minor(device_id);
2423 2642
2424 /* Make sure the driver is actually initialized, this handles 2643 /* Make sure the driver is actually initialized, this handles
2425 problems with initialization order. */ 2644 problems with initialization order. */
@@ -2437,12 +2656,16 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2437 if (!intf) 2656 if (!intf)
2438 return -ENOMEM; 2657 return -ENOMEM;
2439 memset(intf, 0, sizeof(*intf)); 2658 memset(intf, 0, sizeof(*intf));
2659
2660 intf->ipmi_version_major = ipmi_version_major(device_id);
2661 intf->ipmi_version_minor = ipmi_version_minor(device_id);
2662
2440 intf->bmc = kzalloc(sizeof(*intf->bmc), GFP_KERNEL); 2663 intf->bmc = kzalloc(sizeof(*intf->bmc), GFP_KERNEL);
2441 if (!intf->bmc) { 2664 if (!intf->bmc) {
2442 kfree(intf); 2665 kfree(intf);
2443 return -ENOMEM; 2666 return -ENOMEM;
2444 } 2667 }
2445 intf->intf_num = -1; 2668 intf->intf_num = -1; /* Mark it invalid for now. */
2446 kref_init(&intf->refcount); 2669 kref_init(&intf->refcount);
2447 intf->bmc->id = *device_id; 2670 intf->bmc->id = *device_id;
2448 intf->si_dev = si_dev; 2671 intf->si_dev = si_dev;
@@ -2470,26 +2693,30 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2470 INIT_LIST_HEAD(&intf->waiting_events); 2693 INIT_LIST_HEAD(&intf->waiting_events);
2471 intf->waiting_events_count = 0; 2694 intf->waiting_events_count = 0;
2472 mutex_init(&intf->cmd_rcvrs_mutex); 2695 mutex_init(&intf->cmd_rcvrs_mutex);
2696 spin_lock_init(&intf->maintenance_mode_lock);
2473 INIT_LIST_HEAD(&intf->cmd_rcvrs); 2697 INIT_LIST_HEAD(&intf->cmd_rcvrs);
2474 init_waitqueue_head(&intf->waitq); 2698 init_waitqueue_head(&intf->waitq);
2475 2699
2476 spin_lock_init(&intf->counter_lock); 2700 spin_lock_init(&intf->counter_lock);
2477 intf->proc_dir = NULL; 2701 intf->proc_dir = NULL;
2478 2702
2479 rv = -ENOMEM; 2703 mutex_lock(&smi_watchers_mutex);
2480 spin_lock_irqsave(&interfaces_lock, flags); 2704 mutex_lock(&ipmi_interfaces_mutex);
2481 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 2705 /* Look for a hole in the numbers. */
2482 if (ipmi_interfaces[i] == NULL) { 2706 i = 0;
2483 intf->intf_num = i; 2707 link = &ipmi_interfaces;
2484 /* Reserve the entry till we are done. */ 2708 list_for_each_entry_rcu(tintf, &ipmi_interfaces, link) {
2485 ipmi_interfaces[i] = IPMI_INVALID_INTERFACE_ENTRY; 2709 if (tintf->intf_num != i) {
2486 rv = 0; 2710 link = &tintf->link;
2487 break; 2711 break;
2488 } 2712 }
2713 i++;
2489 } 2714 }
2490 spin_unlock_irqrestore(&interfaces_lock, flags); 2715 /* Add the new interface in numeric order. */
2491 if (rv) 2716 if (i == 0)
2492 goto out; 2717 list_add_rcu(&intf->link, &ipmi_interfaces);
2718 else
2719 list_add_tail_rcu(&intf->link, link);
2493 2720
2494 rv = handlers->start_processing(send_info, intf); 2721 rv = handlers->start_processing(send_info, intf);
2495 if (rv) 2722 if (rv)
@@ -2497,8 +2724,9 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2497 2724
2498 get_guid(intf); 2725 get_guid(intf);
2499 2726
2500 if ((version_major > 1) 2727 if ((intf->ipmi_version_major > 1)
2501 || ((version_major == 1) && (version_minor >= 5))) 2728 || ((intf->ipmi_version_major == 1)
2729 && (intf->ipmi_version_minor >= 5)))
2502 { 2730 {
2503 /* Start scanning the channels to see what is 2731 /* Start scanning the channels to see what is
2504 available. */ 2732 available. */
@@ -2521,64 +2749,67 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2521 if (rv == 0) 2749 if (rv == 0)
2522 rv = add_proc_entries(intf, i); 2750 rv = add_proc_entries(intf, i);
2523 2751
2524 rv = ipmi_bmc_register(intf); 2752 rv = ipmi_bmc_register(intf, i, sysfs_name);
2525 2753
2526 out: 2754 out:
2527 if (rv) { 2755 if (rv) {
2528 if (intf->proc_dir) 2756 if (intf->proc_dir)
2529 remove_proc_entries(intf); 2757 remove_proc_entries(intf);
2758 intf->handlers = NULL;
2759 list_del_rcu(&intf->link);
2760 mutex_unlock(&ipmi_interfaces_mutex);
2761 mutex_unlock(&smi_watchers_mutex);
2762 synchronize_rcu();
2530 kref_put(&intf->refcount, intf_free); 2763 kref_put(&intf->refcount, intf_free);
2531 if (i < MAX_IPMI_INTERFACES) {
2532 spin_lock_irqsave(&interfaces_lock, flags);
2533 ipmi_interfaces[i] = NULL;
2534 spin_unlock_irqrestore(&interfaces_lock, flags);
2535 }
2536 } else { 2764 } else {
2537 spin_lock_irqsave(&interfaces_lock, flags); 2765 /* After this point the interface is legal to use. */
2538 ipmi_interfaces[i] = intf; 2766 intf->intf_num = i;
2539 spin_unlock_irqrestore(&interfaces_lock, flags); 2767 mutex_unlock(&ipmi_interfaces_mutex);
2540 call_smi_watchers(i, intf->si_dev); 2768 call_smi_watchers(i, intf->si_dev);
2769 mutex_unlock(&smi_watchers_mutex);
2541 } 2770 }
2542 2771
2543 return rv; 2772 return rv;
2544} 2773}
2545 2774
2775static void cleanup_smi_msgs(ipmi_smi_t intf)
2776{
2777 int i;
2778 struct seq_table *ent;
2779
2780 /* No need for locks, the interface is down. */
2781 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) {
2782 ent = &(intf->seq_table[i]);
2783 if (!ent->inuse)
2784 continue;
2785 deliver_err_response(ent->recv_msg, IPMI_ERR_UNSPECIFIED);
2786 }
2787}
2788
2546int ipmi_unregister_smi(ipmi_smi_t intf) 2789int ipmi_unregister_smi(ipmi_smi_t intf)
2547{ 2790{
2548 int i;
2549 struct ipmi_smi_watcher *w; 2791 struct ipmi_smi_watcher *w;
2550 unsigned long flags; 2792 int intf_num = intf->intf_num;
2551 2793
2552 ipmi_bmc_unregister(intf); 2794 ipmi_bmc_unregister(intf);
2553 2795
2554 spin_lock_irqsave(&interfaces_lock, flags); 2796 mutex_lock(&smi_watchers_mutex);
2555 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 2797 mutex_lock(&ipmi_interfaces_mutex);
2556 if (ipmi_interfaces[i] == intf) { 2798 intf->intf_num = -1;
2557 /* Set the interface number reserved until we 2799 intf->handlers = NULL;
2558 * are done. */ 2800 list_del_rcu(&intf->link);
2559 ipmi_interfaces[i] = IPMI_INVALID_INTERFACE_ENTRY; 2801 mutex_unlock(&ipmi_interfaces_mutex);
2560 intf->intf_num = -1; 2802 synchronize_rcu();
2561 break;
2562 }
2563 }
2564 spin_unlock_irqrestore(&interfaces_lock,flags);
2565 2803
2566 if (i == MAX_IPMI_INTERFACES) 2804 cleanup_smi_msgs(intf);
2567 return -ENODEV;
2568 2805
2569 remove_proc_entries(intf); 2806 remove_proc_entries(intf);
2570 2807
2571 /* Call all the watcher interfaces to tell them that 2808 /* Call all the watcher interfaces to tell them that
2572 an interface is gone. */ 2809 an interface is gone. */
2573 down_read(&smi_watchers_sem);
2574 list_for_each_entry(w, &smi_watchers, link) 2810 list_for_each_entry(w, &smi_watchers, link)
2575 w->smi_gone(i); 2811 w->smi_gone(intf_num);
2576 up_read(&smi_watchers_sem); 2812 mutex_unlock(&smi_watchers_mutex);
2577
2578 /* Allow the entry to be reused now. */
2579 spin_lock_irqsave(&interfaces_lock, flags);
2580 ipmi_interfaces[i] = NULL;
2581 spin_unlock_irqrestore(&interfaces_lock,flags);
2582 2813
2583 kref_put(&intf->refcount, intf_free); 2814 kref_put(&intf->refcount, intf_free);
2584 return 0; 2815 return 0;
@@ -2660,6 +2891,7 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf,
2660 struct ipmi_ipmb_addr *ipmb_addr; 2891 struct ipmi_ipmb_addr *ipmb_addr;
2661 struct ipmi_recv_msg *recv_msg; 2892 struct ipmi_recv_msg *recv_msg;
2662 unsigned long flags; 2893 unsigned long flags;
2894 struct ipmi_smi_handlers *handlers;
2663 2895
2664 if (msg->rsp_size < 10) { 2896 if (msg->rsp_size < 10) {
2665 /* Message not big enough, just ignore it. */ 2897 /* Message not big enough, just ignore it. */
@@ -2716,10 +2948,16 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf,
2716 printk("\n"); 2948 printk("\n");
2717 } 2949 }
2718#endif 2950#endif
2719 intf->handlers->sender(intf->send_info, msg, 0); 2951 rcu_read_lock();
2720 2952 handlers = intf->handlers;
2721 rv = -1; /* We used the message, so return the value that 2953 if (handlers) {
2722 causes it to not be freed or queued. */ 2954 handlers->sender(intf->send_info, msg, 0);
2955 /* We used the message, so return the value
2956 that causes it to not be freed or
2957 queued. */
2958 rv = -1;
2959 }
2960 rcu_read_unlock();
2723 } else { 2961 } else {
2724 /* Deliver the message to the user. */ 2962 /* Deliver the message to the user. */
2725 spin_lock_irqsave(&intf->counter_lock, flags); 2963 spin_lock_irqsave(&intf->counter_lock, flags);
@@ -3309,16 +3547,6 @@ void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf)
3309 rcu_read_unlock(); 3547 rcu_read_unlock();
3310} 3548}
3311 3549
3312static void
3313handle_msg_timeout(struct ipmi_recv_msg *msg)
3314{
3315 msg->recv_type = IPMI_RESPONSE_RECV_TYPE;
3316 msg->msg_data[0] = IPMI_TIMEOUT_COMPLETION_CODE;
3317 msg->msg.netfn |= 1; /* Convert to a response. */
3318 msg->msg.data_len = 1;
3319 msg->msg.data = msg->msg_data;
3320 deliver_response(msg);
3321}
3322 3550
3323static struct ipmi_smi_msg * 3551static struct ipmi_smi_msg *
3324smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg, 3552smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg,
@@ -3350,7 +3578,11 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent,
3350 struct list_head *timeouts, long timeout_period, 3578 struct list_head *timeouts, long timeout_period,
3351 int slot, unsigned long *flags) 3579 int slot, unsigned long *flags)
3352{ 3580{
3353 struct ipmi_recv_msg *msg; 3581 struct ipmi_recv_msg *msg;
3582 struct ipmi_smi_handlers *handlers;
3583
3584 if (intf->intf_num == -1)
3585 return;
3354 3586
3355 if (!ent->inuse) 3587 if (!ent->inuse)
3356 return; 3588 return;
@@ -3393,13 +3625,19 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent,
3393 return; 3625 return;
3394 3626
3395 spin_unlock_irqrestore(&intf->seq_lock, *flags); 3627 spin_unlock_irqrestore(&intf->seq_lock, *flags);
3628
3396 /* Send the new message. We send with a zero 3629 /* Send the new message. We send with a zero
3397 * priority. It timed out, I doubt time is 3630 * priority. It timed out, I doubt time is
3398 * that critical now, and high priority 3631 * that critical now, and high priority
3399 * messages are really only for messages to the 3632 * messages are really only for messages to the
3400 * local MC, which don't get resent. */ 3633 * local MC, which don't get resent. */
3401 intf->handlers->sender(intf->send_info, 3634 handlers = intf->handlers;
3402 smi_msg, 0); 3635 if (handlers)
3636 intf->handlers->sender(intf->send_info,
3637 smi_msg, 0);
3638 else
3639 ipmi_free_smi_msg(smi_msg);
3640
3403 spin_lock_irqsave(&intf->seq_lock, *flags); 3641 spin_lock_irqsave(&intf->seq_lock, *flags);
3404 } 3642 }
3405} 3643}
@@ -3411,18 +3649,12 @@ static void ipmi_timeout_handler(long timeout_period)
3411 struct ipmi_recv_msg *msg, *msg2; 3649 struct ipmi_recv_msg *msg, *msg2;
3412 struct ipmi_smi_msg *smi_msg, *smi_msg2; 3650 struct ipmi_smi_msg *smi_msg, *smi_msg2;
3413 unsigned long flags; 3651 unsigned long flags;
3414 int i, j; 3652 int i;
3415 3653
3416 INIT_LIST_HEAD(&timeouts); 3654 INIT_LIST_HEAD(&timeouts);
3417 3655
3418 spin_lock(&interfaces_lock); 3656 rcu_read_lock();
3419 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 3657 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
3420 intf = ipmi_interfaces[i];
3421 if (IPMI_INVALID_INTERFACE(intf))
3422 continue;
3423 kref_get(&intf->refcount);
3424 spin_unlock(&interfaces_lock);
3425
3426 /* See if any waiting messages need to be processed. */ 3658 /* See if any waiting messages need to be processed. */
3427 spin_lock_irqsave(&intf->waiting_msgs_lock, flags); 3659 spin_lock_irqsave(&intf->waiting_msgs_lock, flags);
3428 list_for_each_entry_safe(smi_msg, smi_msg2, 3660 list_for_each_entry_safe(smi_msg, smi_msg2,
@@ -3442,35 +3674,60 @@ static void ipmi_timeout_handler(long timeout_period)
3442 have timed out, putting them in the timeouts 3674 have timed out, putting them in the timeouts
3443 list. */ 3675 list. */
3444 spin_lock_irqsave(&intf->seq_lock, flags); 3676 spin_lock_irqsave(&intf->seq_lock, flags);
3445 for (j = 0; j < IPMI_IPMB_NUM_SEQ; j++) 3677 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++)
3446 check_msg_timeout(intf, &(intf->seq_table[j]), 3678 check_msg_timeout(intf, &(intf->seq_table[i]),
3447 &timeouts, timeout_period, j, 3679 &timeouts, timeout_period, i,
3448 &flags); 3680 &flags);
3449 spin_unlock_irqrestore(&intf->seq_lock, flags); 3681 spin_unlock_irqrestore(&intf->seq_lock, flags);
3450 3682
3451 list_for_each_entry_safe(msg, msg2, &timeouts, link) 3683 list_for_each_entry_safe(msg, msg2, &timeouts, link)
3452 handle_msg_timeout(msg); 3684 deliver_err_response(msg, IPMI_TIMEOUT_COMPLETION_CODE);
3453 3685
3454 kref_put(&intf->refcount, intf_free); 3686 /*
3455 spin_lock(&interfaces_lock); 3687 * Maintenance mode handling. Check the timeout
3688 * optimistically before we claim the lock. It may
3689 * mean a timeout gets missed occasionally, but that
3690 * only means the timeout gets extended by one period
3691 * in that case. No big deal, and it avoids the lock
3692 * most of the time.
3693 */
3694 if (intf->auto_maintenance_timeout > 0) {
3695 spin_lock_irqsave(&intf->maintenance_mode_lock, flags);
3696 if (intf->auto_maintenance_timeout > 0) {
3697 intf->auto_maintenance_timeout
3698 -= timeout_period;
3699 if (!intf->maintenance_mode
3700 && (intf->auto_maintenance_timeout <= 0))
3701 {
3702 intf->maintenance_mode_enable = 0;
3703 maintenance_mode_update(intf);
3704 }
3705 }
3706 spin_unlock_irqrestore(&intf->maintenance_mode_lock,
3707 flags);
3708 }
3456 } 3709 }
3457 spin_unlock(&interfaces_lock); 3710 rcu_read_unlock();
3458} 3711}
3459 3712
3460static void ipmi_request_event(void) 3713static void ipmi_request_event(void)
3461{ 3714{
3462 ipmi_smi_t intf; 3715 ipmi_smi_t intf;
3463 int i; 3716 struct ipmi_smi_handlers *handlers;
3464 3717
3465 spin_lock(&interfaces_lock); 3718 rcu_read_lock();
3466 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 3719 /* Called from the timer, no need to check if handlers is
3467 intf = ipmi_interfaces[i]; 3720 * valid. */
3468 if (IPMI_INVALID_INTERFACE(intf)) 3721 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
3722 /* No event requests when in maintenance mode. */
3723 if (intf->maintenance_mode_enable)
3469 continue; 3724 continue;
3470 3725
3471 intf->handlers->request_events(intf->send_info); 3726 handlers = intf->handlers;
3727 if (handlers)
3728 handlers->request_events(intf->send_info);
3472 } 3729 }
3473 spin_unlock(&interfaces_lock); 3730 rcu_read_unlock();
3474} 3731}
3475 3732
3476static struct timer_list ipmi_timer; 3733static struct timer_list ipmi_timer;
@@ -3599,7 +3856,6 @@ static void send_panic_events(char *str)
3599 struct kernel_ipmi_msg msg; 3856 struct kernel_ipmi_msg msg;
3600 ipmi_smi_t intf; 3857 ipmi_smi_t intf;
3601 unsigned char data[16]; 3858 unsigned char data[16];
3602 int i;
3603 struct ipmi_system_interface_addr *si; 3859 struct ipmi_system_interface_addr *si;
3604 struct ipmi_addr addr; 3860 struct ipmi_addr addr;
3605 struct ipmi_smi_msg smi_msg; 3861 struct ipmi_smi_msg smi_msg;
@@ -3633,9 +3889,9 @@ static void send_panic_events(char *str)
3633 recv_msg.done = dummy_recv_done_handler; 3889 recv_msg.done = dummy_recv_done_handler;
3634 3890
3635 /* For every registered interface, send the event. */ 3891 /* For every registered interface, send the event. */
3636 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 3892 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
3637 intf = ipmi_interfaces[i]; 3893 if (!intf->handlers)
3638 if (IPMI_INVALID_INTERFACE(intf)) 3894 /* Interface is not ready. */
3639 continue; 3895 continue;
3640 3896
3641 /* Send the event announcing the panic. */ 3897 /* Send the event announcing the panic. */
@@ -3660,13 +3916,14 @@ static void send_panic_events(char *str)
3660 if (!str) 3916 if (!str)
3661 return; 3917 return;
3662 3918
3663 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 3919 /* For every registered interface, send the event. */
3920 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
3664 char *p = str; 3921 char *p = str;
3665 struct ipmi_ipmb_addr *ipmb; 3922 struct ipmi_ipmb_addr *ipmb;
3666 int j; 3923 int j;
3667 3924
3668 intf = ipmi_interfaces[i]; 3925 if (intf->intf_num == -1)
3669 if (IPMI_INVALID_INTERFACE(intf)) 3926 /* Interface was not ready yet. */
3670 continue; 3927 continue;
3671 3928
3672 /* First job here is to figure out where to send the 3929 /* First job here is to figure out where to send the
@@ -3792,7 +4049,6 @@ static int panic_event(struct notifier_block *this,
3792 unsigned long event, 4049 unsigned long event,
3793 void *ptr) 4050 void *ptr)
3794{ 4051{
3795 int i;
3796 ipmi_smi_t intf; 4052 ipmi_smi_t intf;
3797 4053
3798 if (has_panicked) 4054 if (has_panicked)
@@ -3800,9 +4056,9 @@ static int panic_event(struct notifier_block *this,
3800 has_panicked = 1; 4056 has_panicked = 1;
3801 4057
3802 /* For every registered interface, set it to run to completion. */ 4058 /* For every registered interface, set it to run to completion. */
3803 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 4059 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
3804 intf = ipmi_interfaces[i]; 4060 if (!intf->handlers)
3805 if (IPMI_INVALID_INTERFACE(intf)) 4061 /* Interface is not ready. */
3806 continue; 4062 continue;
3807 4063
3808 intf->handlers->set_run_to_completion(intf->send_info, 1); 4064 intf->handlers->set_run_to_completion(intf->send_info, 1);
@@ -3823,7 +4079,6 @@ static struct notifier_block panic_block = {
3823 4079
3824static int ipmi_init_msghandler(void) 4080static int ipmi_init_msghandler(void)
3825{ 4081{
3826 int i;
3827 int rv; 4082 int rv;
3828 4083
3829 if (initialized) 4084 if (initialized)
@@ -3838,9 +4093,6 @@ static int ipmi_init_msghandler(void)
3838 printk(KERN_INFO "ipmi message handler version " 4093 printk(KERN_INFO "ipmi message handler version "
3839 IPMI_DRIVER_VERSION "\n"); 4094 IPMI_DRIVER_VERSION "\n");
3840 4095
3841 for (i = 0; i < MAX_IPMI_INTERFACES; i++)
3842 ipmi_interfaces[i] = NULL;
3843
3844#ifdef CONFIG_PROC_FS 4096#ifdef CONFIG_PROC_FS
3845 proc_ipmi_root = proc_mkdir("ipmi", NULL); 4097 proc_ipmi_root = proc_mkdir("ipmi", NULL);
3846 if (!proc_ipmi_root) { 4098 if (!proc_ipmi_root) {
diff --git a/drivers/char/ipmi/ipmi_poweroff.c b/drivers/char/ipmi/ipmi_poweroff.c
index 8d941db83457..597eb4f88b84 100644
--- a/drivers/char/ipmi/ipmi_poweroff.c
+++ b/drivers/char/ipmi/ipmi_poweroff.c
@@ -43,6 +43,9 @@
43 43
44#define PFX "IPMI poweroff: " 44#define PFX "IPMI poweroff: "
45 45
46static void ipmi_po_smi_gone(int if_num);
47static void ipmi_po_new_smi(int if_num, struct device *device);
48
46/* Definitions for controlling power off (if the system supports it). It 49/* Definitions for controlling power off (if the system supports it). It
47 * conveniently matches the IPMI chassis control values. */ 50 * conveniently matches the IPMI chassis control values. */
48#define IPMI_CHASSIS_POWER_DOWN 0 /* power down, the default. */ 51#define IPMI_CHASSIS_POWER_DOWN 0 /* power down, the default. */
@@ -51,6 +54,37 @@
51/* the IPMI data command */ 54/* the IPMI data command */
52static int poweroff_powercycle; 55static int poweroff_powercycle;
53 56
57/* Which interface to use, -1 means the first we see. */
58static int ifnum_to_use = -1;
59
60/* Our local state. */
61static int ready = 0;
62static ipmi_user_t ipmi_user;
63static int ipmi_ifnum;
64static void (*specific_poweroff_func)(ipmi_user_t user) = NULL;
65
66/* Holds the old poweroff function so we can restore it on removal. */
67static void (*old_poweroff_func)(void);
68
69static int set_param_ifnum(const char *val, struct kernel_param *kp)
70{
71 int rv = param_set_int(val, kp);
72 if (rv)
73 return rv;
74 if ((ifnum_to_use < 0) || (ifnum_to_use == ipmi_ifnum))
75 return 0;
76
77 ipmi_po_smi_gone(ipmi_ifnum);
78 ipmi_po_new_smi(ifnum_to_use, NULL);
79 return 0;
80}
81
82module_param_call(ifnum_to_use, set_param_ifnum, param_get_int,
83 &ifnum_to_use, 0644);
84MODULE_PARM_DESC(ifnum_to_use, "The interface number to use for the watchdog "
85 "timer. Setting to -1 defaults to the first registered "
86 "interface");
87
54/* parameter definition to allow user to flag power cycle */ 88/* parameter definition to allow user to flag power cycle */
55module_param(poweroff_powercycle, int, 0644); 89module_param(poweroff_powercycle, int, 0644);
56MODULE_PARM_DESC(poweroff_powercycle, " Set to non-zero to enable power cycle instead of power down. Power cycle is contingent on hardware support, otherwise it defaults back to power down."); 90MODULE_PARM_DESC(poweroff_powercycle, " Set to non-zero to enable power cycle instead of power down. Power cycle is contingent on hardware support, otherwise it defaults back to power down.");
@@ -142,6 +176,42 @@ static int ipmi_request_in_rc_mode(ipmi_user_t user,
142#define IPMI_ATCA_GET_ADDR_INFO_CMD 0x01 176#define IPMI_ATCA_GET_ADDR_INFO_CMD 0x01
143#define IPMI_PICMG_ID 0 177#define IPMI_PICMG_ID 0
144 178
179#define IPMI_NETFN_OEM 0x2e
180#define IPMI_ATCA_PPS_GRACEFUL_RESTART 0x11
181#define IPMI_ATCA_PPS_IANA "\x00\x40\x0A"
182#define IPMI_MOTOROLA_MANUFACTURER_ID 0x0000A1
183#define IPMI_MOTOROLA_PPS_IPMC_PRODUCT_ID 0x0051
184
185static void (*atca_oem_poweroff_hook)(ipmi_user_t user) = NULL;
186
187static void pps_poweroff_atca (ipmi_user_t user)
188{
189 struct ipmi_system_interface_addr smi_addr;
190 struct kernel_ipmi_msg send_msg;
191 int rv;
192 /*
193 * Configure IPMI address for local access
194 */
195 smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
196 smi_addr.channel = IPMI_BMC_CHANNEL;
197 smi_addr.lun = 0;
198
199 printk(KERN_INFO PFX "PPS powerdown hook used");
200
201 send_msg.netfn = IPMI_NETFN_OEM;
202 send_msg.cmd = IPMI_ATCA_PPS_GRACEFUL_RESTART;
203 send_msg.data = IPMI_ATCA_PPS_IANA;
204 send_msg.data_len = 3;
205 rv = ipmi_request_in_rc_mode(user,
206 (struct ipmi_addr *) &smi_addr,
207 &send_msg);
208 if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) {
209 printk(KERN_ERR PFX "Unable to send ATCA ,"
210 " IPMI error 0x%x\n", rv);
211 }
212 return;
213}
214
145static int ipmi_atca_detect (ipmi_user_t user) 215static int ipmi_atca_detect (ipmi_user_t user)
146{ 216{
147 struct ipmi_system_interface_addr smi_addr; 217 struct ipmi_system_interface_addr smi_addr;
@@ -167,6 +237,13 @@ static int ipmi_atca_detect (ipmi_user_t user)
167 rv = ipmi_request_wait_for_response(user, 237 rv = ipmi_request_wait_for_response(user,
168 (struct ipmi_addr *) &smi_addr, 238 (struct ipmi_addr *) &smi_addr,
169 &send_msg); 239 &send_msg);
240
241 printk(KERN_INFO PFX "ATCA Detect mfg 0x%X prod 0x%X\n", mfg_id, prod_id);
242 if((mfg_id == IPMI_MOTOROLA_MANUFACTURER_ID)
243 && (prod_id == IPMI_MOTOROLA_PPS_IPMC_PRODUCT_ID)) {
244 printk(KERN_INFO PFX "Installing Pigeon Point Systems Poweroff Hook\n");
245 atca_oem_poweroff_hook = pps_poweroff_atca;
246 }
170 return !rv; 247 return !rv;
171} 248}
172 249
@@ -200,12 +277,19 @@ static void ipmi_poweroff_atca (ipmi_user_t user)
200 rv = ipmi_request_in_rc_mode(user, 277 rv = ipmi_request_in_rc_mode(user,
201 (struct ipmi_addr *) &smi_addr, 278 (struct ipmi_addr *) &smi_addr,
202 &send_msg); 279 &send_msg);
203 if (rv) { 280 /** At this point, the system may be shutting down, and most
281 ** serial drivers (if used) will have interrupts turned off
282 ** it may be better to ignore IPMI_UNKNOWN_ERR_COMPLETION_CODE
283 ** return code
284 **/
285 if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) {
204 printk(KERN_ERR PFX "Unable to send ATCA powerdown message," 286 printk(KERN_ERR PFX "Unable to send ATCA powerdown message,"
205 " IPMI error 0x%x\n", rv); 287 " IPMI error 0x%x\n", rv);
206 goto out; 288 goto out;
207 } 289 }
208 290
291 if(atca_oem_poweroff_hook)
292 return atca_oem_poweroff_hook(user);
209 out: 293 out:
210 return; 294 return;
211} 295}
@@ -440,15 +524,6 @@ static struct poweroff_function poweroff_functions[] = {
440 / sizeof(struct poweroff_function)) 524 / sizeof(struct poweroff_function))
441 525
442 526
443/* Our local state. */
444static int ready = 0;
445static ipmi_user_t ipmi_user;
446static void (*specific_poweroff_func)(ipmi_user_t user) = NULL;
447
448/* Holds the old poweroff function so we can restore it on removal. */
449static void (*old_poweroff_func)(void);
450
451
452/* Called on a powerdown request. */ 527/* Called on a powerdown request. */
453static void ipmi_poweroff_function (void) 528static void ipmi_poweroff_function (void)
454{ 529{
@@ -473,6 +548,9 @@ static void ipmi_po_new_smi(int if_num, struct device *device)
473 if (ready) 548 if (ready)
474 return; 549 return;
475 550
551 if ((ifnum_to_use >= 0) && (ifnum_to_use != if_num))
552 return;
553
476 rv = ipmi_create_user(if_num, &ipmi_poweroff_handler, NULL, 554 rv = ipmi_create_user(if_num, &ipmi_poweroff_handler, NULL,
477 &ipmi_user); 555 &ipmi_user);
478 if (rv) { 556 if (rv) {
@@ -481,6 +559,8 @@ static void ipmi_po_new_smi(int if_num, struct device *device)
481 return; 559 return;
482 } 560 }
483 561
562 ipmi_ifnum = if_num;
563
484 /* 564 /*
485 * Do a get device ide and store some results, since this is 565 * Do a get device ide and store some results, since this is
486 * used by several functions. 566 * used by several functions.
@@ -541,9 +621,15 @@ static void ipmi_po_new_smi(int if_num, struct device *device)
541 621
542static void ipmi_po_smi_gone(int if_num) 622static void ipmi_po_smi_gone(int if_num)
543{ 623{
544 /* This can never be called, because once poweroff driver is 624 if (!ready)
545 registered, the interface can't go away until the power 625 return;
546 driver is unregistered. */ 626
627 if (ipmi_ifnum != if_num)
628 return;
629
630 ready = 0;
631 ipmi_destroy_user(ipmi_user);
632 pm_power_off = old_poweroff_func;
547} 633}
548 634
549static struct ipmi_smi_watcher smi_watcher = 635static struct ipmi_smi_watcher smi_watcher =
@@ -616,9 +702,9 @@ static int ipmi_poweroff_init (void)
616 printk(KERN_ERR PFX "Unable to register SMI watcher: %d\n", rv); 702 printk(KERN_ERR PFX "Unable to register SMI watcher: %d\n", rv);
617 goto out_err; 703 goto out_err;
618 } 704 }
619#endif
620 705
621 out_err: 706 out_err:
707#endif
622 return rv; 708 return rv;
623} 709}
624 710
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index bb1fac104fda..81a0c89598e7 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -61,6 +61,10 @@
61#include "ipmi_si_sm.h" 61#include "ipmi_si_sm.h"
62#include <linux/init.h> 62#include <linux/init.h>
63#include <linux/dmi.h> 63#include <linux/dmi.h>
64#include <linux/string.h>
65#include <linux/ctype.h>
66
67#define PFX "ipmi_si: "
64 68
65/* Measure times between events in the driver. */ 69/* Measure times between events in the driver. */
66#undef DEBUG_TIMING 70#undef DEBUG_TIMING
@@ -92,7 +96,7 @@ enum si_intf_state {
92enum si_type { 96enum si_type {
93 SI_KCS, SI_SMIC, SI_BT 97 SI_KCS, SI_SMIC, SI_BT
94}; 98};
95static char *si_to_str[] = { "KCS", "SMIC", "BT" }; 99static char *si_to_str[] = { "kcs", "smic", "bt" };
96 100
97#define DEVICE_NAME "ipmi_si" 101#define DEVICE_NAME "ipmi_si"
98 102
@@ -222,7 +226,10 @@ struct smi_info
222static int force_kipmid[SI_MAX_PARMS]; 226static int force_kipmid[SI_MAX_PARMS];
223static int num_force_kipmid; 227static int num_force_kipmid;
224 228
229static int unload_when_empty = 1;
230
225static int try_smi_init(struct smi_info *smi); 231static int try_smi_init(struct smi_info *smi);
232static void cleanup_one_si(struct smi_info *to_clean);
226 233
227static ATOMIC_NOTIFIER_HEAD(xaction_notifier_list); 234static ATOMIC_NOTIFIER_HEAD(xaction_notifier_list);
228static int register_xaction_notifier(struct notifier_block * nb) 235static int register_xaction_notifier(struct notifier_block * nb)
@@ -240,14 +247,18 @@ static void deliver_recv_msg(struct smi_info *smi_info,
240 spin_lock(&(smi_info->si_lock)); 247 spin_lock(&(smi_info->si_lock));
241} 248}
242 249
243static void return_hosed_msg(struct smi_info *smi_info) 250static void return_hosed_msg(struct smi_info *smi_info, int cCode)
244{ 251{
245 struct ipmi_smi_msg *msg = smi_info->curr_msg; 252 struct ipmi_smi_msg *msg = smi_info->curr_msg;
246 253
254 if (cCode < 0 || cCode > IPMI_ERR_UNSPECIFIED)
255 cCode = IPMI_ERR_UNSPECIFIED;
256 /* else use it as is */
257
247 /* Make it a reponse */ 258 /* Make it a reponse */
248 msg->rsp[0] = msg->data[0] | 4; 259 msg->rsp[0] = msg->data[0] | 4;
249 msg->rsp[1] = msg->data[1]; 260 msg->rsp[1] = msg->data[1];
250 msg->rsp[2] = 0xFF; /* Unknown error. */ 261 msg->rsp[2] = cCode;
251 msg->rsp_size = 3; 262 msg->rsp_size = 3;
252 263
253 smi_info->curr_msg = NULL; 264 smi_info->curr_msg = NULL;
@@ -298,7 +309,7 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info)
298 smi_info->curr_msg->data, 309 smi_info->curr_msg->data,
299 smi_info->curr_msg->data_size); 310 smi_info->curr_msg->data_size);
300 if (err) { 311 if (err) {
301 return_hosed_msg(smi_info); 312 return_hosed_msg(smi_info, err);
302 } 313 }
303 314
304 rv = SI_SM_CALL_WITHOUT_DELAY; 315 rv = SI_SM_CALL_WITHOUT_DELAY;
@@ -640,7 +651,7 @@ static enum si_sm_result smi_event_handler(struct smi_info *smi_info,
640 /* If we were handling a user message, format 651 /* If we were handling a user message, format
641 a response to send to the upper layer to 652 a response to send to the upper layer to
642 tell it about the error. */ 653 tell it about the error. */
643 return_hosed_msg(smi_info); 654 return_hosed_msg(smi_info, IPMI_ERR_UNSPECIFIED);
644 } 655 }
645 si_sm_result = smi_info->handlers->event(smi_info->si_sm, 0); 656 si_sm_result = smi_info->handlers->event(smi_info->si_sm, 0);
646 } 657 }
@@ -684,22 +695,24 @@ static enum si_sm_result smi_event_handler(struct smi_info *smi_info,
684 { 695 {
685 /* We are idle and the upper layer requested that I fetch 696 /* We are idle and the upper layer requested that I fetch
686 events, so do so. */ 697 events, so do so. */
687 unsigned char msg[2]; 698 atomic_set(&smi_info->req_events, 0);
688 699
689 spin_lock(&smi_info->count_lock); 700 smi_info->curr_msg = ipmi_alloc_smi_msg();
690 smi_info->flag_fetches++; 701 if (!smi_info->curr_msg)
691 spin_unlock(&smi_info->count_lock); 702 goto out;
692 703
693 atomic_set(&smi_info->req_events, 0); 704 smi_info->curr_msg->data[0] = (IPMI_NETFN_APP_REQUEST << 2);
694 msg[0] = (IPMI_NETFN_APP_REQUEST << 2); 705 smi_info->curr_msg->data[1] = IPMI_READ_EVENT_MSG_BUFFER_CMD;
695 msg[1] = IPMI_GET_MSG_FLAGS_CMD; 706 smi_info->curr_msg->data_size = 2;
696 707
697 smi_info->handlers->start_transaction( 708 smi_info->handlers->start_transaction(
698 smi_info->si_sm, msg, 2); 709 smi_info->si_sm,
699 smi_info->si_state = SI_GETTING_FLAGS; 710 smi_info->curr_msg->data,
711 smi_info->curr_msg->data_size);
712 smi_info->si_state = SI_GETTING_EVENTS;
700 goto restart; 713 goto restart;
701 } 714 }
702 715 out:
703 return si_sm_result; 716 return si_sm_result;
704} 717}
705 718
@@ -714,6 +727,15 @@ static void sender(void *send_info,
714 struct timeval t; 727 struct timeval t;
715#endif 728#endif
716 729
730 if (atomic_read(&smi_info->stop_operation)) {
731 msg->rsp[0] = msg->data[0] | 4;
732 msg->rsp[1] = msg->data[1];
733 msg->rsp[2] = IPMI_ERR_UNSPECIFIED;
734 msg->rsp_size = 3;
735 deliver_recv_msg(smi_info, msg);
736 return;
737 }
738
717 spin_lock_irqsave(&(smi_info->msg_lock), flags); 739 spin_lock_irqsave(&(smi_info->msg_lock), flags);
718#ifdef DEBUG_TIMING 740#ifdef DEBUG_TIMING
719 do_gettimeofday(&t); 741 do_gettimeofday(&t);
@@ -805,13 +827,21 @@ static void poll(void *send_info)
805{ 827{
806 struct smi_info *smi_info = send_info; 828 struct smi_info *smi_info = send_info;
807 829
808 smi_event_handler(smi_info, 0); 830 /*
831 * Make sure there is some delay in the poll loop so we can
832 * drive time forward and timeout things.
833 */
834 udelay(10);
835 smi_event_handler(smi_info, 10);
809} 836}
810 837
811static void request_events(void *send_info) 838static void request_events(void *send_info)
812{ 839{
813 struct smi_info *smi_info = send_info; 840 struct smi_info *smi_info = send_info;
814 841
842 if (atomic_read(&smi_info->stop_operation))
843 return;
844
815 atomic_set(&smi_info->req_events, 1); 845 atomic_set(&smi_info->req_events, 1);
816} 846}
817 847
@@ -949,12 +979,21 @@ static int smi_start_processing(void *send_info,
949 return 0; 979 return 0;
950} 980}
951 981
982static void set_maintenance_mode(void *send_info, int enable)
983{
984 struct smi_info *smi_info = send_info;
985
986 if (!enable)
987 atomic_set(&smi_info->req_events, 0);
988}
989
952static struct ipmi_smi_handlers handlers = 990static struct ipmi_smi_handlers handlers =
953{ 991{
954 .owner = THIS_MODULE, 992 .owner = THIS_MODULE,
955 .start_processing = smi_start_processing, 993 .start_processing = smi_start_processing,
956 .sender = sender, 994 .sender = sender,
957 .request_events = request_events, 995 .request_events = request_events,
996 .set_maintenance_mode = set_maintenance_mode,
958 .set_run_to_completion = set_run_to_completion, 997 .set_run_to_completion = set_run_to_completion,
959 .poll = poll, 998 .poll = poll,
960}; 999};
@@ -987,6 +1026,16 @@ static int num_regshifts = 0;
987static int slave_addrs[SI_MAX_PARMS]; 1026static int slave_addrs[SI_MAX_PARMS];
988static int num_slave_addrs = 0; 1027static int num_slave_addrs = 0;
989 1028
1029#define IPMI_IO_ADDR_SPACE 0
1030#define IPMI_MEM_ADDR_SPACE 1
1031static char *addr_space_to_str[] = { "I/O", "mem" };
1032
1033static int hotmod_handler(const char *val, struct kernel_param *kp);
1034
1035module_param_call(hotmod, hotmod_handler, NULL, NULL, 0200);
1036MODULE_PARM_DESC(hotmod, "Add and remove interfaces. See"
1037 " Documentation/IPMI.txt in the kernel sources for the"
1038 " gory details.");
990 1039
991module_param_named(trydefaults, si_trydefaults, bool, 0); 1040module_param_named(trydefaults, si_trydefaults, bool, 0);
992MODULE_PARM_DESC(trydefaults, "Setting this to 'false' will disable the" 1041MODULE_PARM_DESC(trydefaults, "Setting this to 'false' will disable the"
@@ -1038,12 +1087,12 @@ module_param_array(force_kipmid, int, &num_force_kipmid, 0);
1038MODULE_PARM_DESC(force_kipmid, "Force the kipmi daemon to be enabled (1) or" 1087MODULE_PARM_DESC(force_kipmid, "Force the kipmi daemon to be enabled (1) or"
1039 " disabled(0). Normally the IPMI driver auto-detects" 1088 " disabled(0). Normally the IPMI driver auto-detects"
1040 " this, but the value may be overridden by this parm."); 1089 " this, but the value may be overridden by this parm.");
1090module_param(unload_when_empty, int, 0);
1091MODULE_PARM_DESC(unload_when_empty, "Unload the module if no interfaces are"
1092 " specified or found, default is 1. Setting to 0"
1093 " is useful for hot add of devices using hotmod.");
1041 1094
1042 1095
1043#define IPMI_IO_ADDR_SPACE 0
1044#define IPMI_MEM_ADDR_SPACE 1
1045static char *addr_space_to_str[] = { "I/O", "memory" };
1046
1047static void std_irq_cleanup(struct smi_info *info) 1096static void std_irq_cleanup(struct smi_info *info)
1048{ 1097{
1049 if (info->si_type == SI_BT) 1098 if (info->si_type == SI_BT)
@@ -1317,6 +1366,234 @@ static int mem_setup(struct smi_info *info)
1317 return 0; 1366 return 0;
1318} 1367}
1319 1368
1369/*
1370 * Parms come in as <op1>[:op2[:op3...]]. ops are:
1371 * add|remove,kcs|bt|smic,mem|i/o,<address>[,<opt1>[,<opt2>[,...]]]
1372 * Options are:
1373 * rsp=<regspacing>
1374 * rsi=<regsize>
1375 * rsh=<regshift>
1376 * irq=<irq>
1377 * ipmb=<ipmb addr>
1378 */
1379enum hotmod_op { HM_ADD, HM_REMOVE };
1380struct hotmod_vals {
1381 char *name;
1382 int val;
1383};
1384static struct hotmod_vals hotmod_ops[] = {
1385 { "add", HM_ADD },
1386 { "remove", HM_REMOVE },
1387 { NULL }
1388};
1389static struct hotmod_vals hotmod_si[] = {
1390 { "kcs", SI_KCS },
1391 { "smic", SI_SMIC },
1392 { "bt", SI_BT },
1393 { NULL }
1394};
1395static struct hotmod_vals hotmod_as[] = {
1396 { "mem", IPMI_MEM_ADDR_SPACE },
1397 { "i/o", IPMI_IO_ADDR_SPACE },
1398 { NULL }
1399};
1400static int ipmi_strcasecmp(const char *s1, const char *s2)
1401{
1402 while (*s1 || *s2) {
1403 if (!*s1)
1404 return -1;
1405 if (!*s2)
1406 return 1;
1407 if (*s1 != *s2)
1408 return *s1 - *s2;
1409 s1++;
1410 s2++;
1411 }
1412 return 0;
1413}
1414static int parse_str(struct hotmod_vals *v, int *val, char *name, char **curr)
1415{
1416 char *s;
1417 int i;
1418
1419 s = strchr(*curr, ',');
1420 if (!s) {
1421 printk(KERN_WARNING PFX "No hotmod %s given.\n", name);
1422 return -EINVAL;
1423 }
1424 *s = '\0';
1425 s++;
1426 for (i = 0; hotmod_ops[i].name; i++) {
1427 if (ipmi_strcasecmp(*curr, v[i].name) == 0) {
1428 *val = v[i].val;
1429 *curr = s;
1430 return 0;
1431 }
1432 }
1433
1434 printk(KERN_WARNING PFX "Invalid hotmod %s '%s'\n", name, *curr);
1435 return -EINVAL;
1436}
1437
1438static int hotmod_handler(const char *val, struct kernel_param *kp)
1439{
1440 char *str = kstrdup(val, GFP_KERNEL);
1441 int rv = -EINVAL;
1442 char *next, *curr, *s, *n, *o;
1443 enum hotmod_op op;
1444 enum si_type si_type;
1445 int addr_space;
1446 unsigned long addr;
1447 int regspacing;
1448 int regsize;
1449 int regshift;
1450 int irq;
1451 int ipmb;
1452 int ival;
1453 struct smi_info *info;
1454
1455 if (!str)
1456 return -ENOMEM;
1457
1458 /* Kill any trailing spaces, as we can get a "\n" from echo. */
1459 ival = strlen(str) - 1;
1460 while ((ival >= 0) && isspace(str[ival])) {
1461 str[ival] = '\0';
1462 ival--;
1463 }
1464
1465 for (curr = str; curr; curr = next) {
1466 regspacing = 1;
1467 regsize = 1;
1468 regshift = 0;
1469 irq = 0;
1470 ipmb = 0x20;
1471
1472 next = strchr(curr, ':');
1473 if (next) {
1474 *next = '\0';
1475 next++;
1476 }
1477
1478 rv = parse_str(hotmod_ops, &ival, "operation", &curr);
1479 if (rv)
1480 break;
1481 op = ival;
1482
1483 rv = parse_str(hotmod_si, &ival, "interface type", &curr);
1484 if (rv)
1485 break;
1486 si_type = ival;
1487
1488 rv = parse_str(hotmod_as, &addr_space, "address space", &curr);
1489 if (rv)
1490 break;
1491
1492 s = strchr(curr, ',');
1493 if (s) {
1494 *s = '\0';
1495 s++;
1496 }
1497 addr = simple_strtoul(curr, &n, 0);
1498 if ((*n != '\0') || (*curr == '\0')) {
1499 printk(KERN_WARNING PFX "Invalid hotmod address"
1500 " '%s'\n", curr);
1501 break;
1502 }
1503
1504 while (s) {
1505 curr = s;
1506 s = strchr(curr, ',');
1507 if (s) {
1508 *s = '\0';
1509 s++;
1510 }
1511 o = strchr(curr, '=');
1512 if (o) {
1513 *o = '\0';
1514 o++;
1515 }
1516#define HOTMOD_INT_OPT(name, val) \
1517 if (ipmi_strcasecmp(curr, name) == 0) { \
1518 if (!o) { \
1519 printk(KERN_WARNING PFX \
1520 "No option given for '%s'\n", \
1521 curr); \
1522 goto out; \
1523 } \
1524 val = simple_strtoul(o, &n, 0); \
1525 if ((*n != '\0') || (*o == '\0')) { \
1526 printk(KERN_WARNING PFX \
1527 "Bad option given for '%s'\n", \
1528 curr); \
1529 goto out; \
1530 } \
1531 }
1532
1533 HOTMOD_INT_OPT("rsp", regspacing)
1534 else HOTMOD_INT_OPT("rsi", regsize)
1535 else HOTMOD_INT_OPT("rsh", regshift)
1536 else HOTMOD_INT_OPT("irq", irq)
1537 else HOTMOD_INT_OPT("ipmb", ipmb)
1538 else {
1539 printk(KERN_WARNING PFX
1540 "Invalid hotmod option '%s'\n",
1541 curr);
1542 goto out;
1543 }
1544#undef HOTMOD_INT_OPT
1545 }
1546
1547 if (op == HM_ADD) {
1548 info = kzalloc(sizeof(*info), GFP_KERNEL);
1549 if (!info) {
1550 rv = -ENOMEM;
1551 goto out;
1552 }
1553
1554 info->addr_source = "hotmod";
1555 info->si_type = si_type;
1556 info->io.addr_data = addr;
1557 info->io.addr_type = addr_space;
1558 if (addr_space == IPMI_MEM_ADDR_SPACE)
1559 info->io_setup = mem_setup;
1560 else
1561 info->io_setup = port_setup;
1562
1563 info->io.addr = NULL;
1564 info->io.regspacing = regspacing;
1565 if (!info->io.regspacing)
1566 info->io.regspacing = DEFAULT_REGSPACING;
1567 info->io.regsize = regsize;
1568 if (!info->io.regsize)
1569 info->io.regsize = DEFAULT_REGSPACING;
1570 info->io.regshift = regshift;
1571 info->irq = irq;
1572 if (info->irq)
1573 info->irq_setup = std_irq_setup;
1574 info->slave_addr = ipmb;
1575
1576 try_smi_init(info);
1577 } else {
1578 /* remove */
1579 struct smi_info *e, *tmp_e;
1580
1581 mutex_lock(&smi_infos_lock);
1582 list_for_each_entry_safe(e, tmp_e, &smi_infos, link) {
1583 if (e->io.addr_type != addr_space)
1584 continue;
1585 if (e->si_type != si_type)
1586 continue;
1587 if (e->io.addr_data == addr)
1588 cleanup_one_si(e);
1589 }
1590 mutex_unlock(&smi_infos_lock);
1591 }
1592 }
1593 out:
1594 kfree(str);
1595 return rv;
1596}
1320 1597
1321static __devinit void hardcode_find_bmc(void) 1598static __devinit void hardcode_find_bmc(void)
1322{ 1599{
@@ -1333,11 +1610,11 @@ static __devinit void hardcode_find_bmc(void)
1333 1610
1334 info->addr_source = "hardcoded"; 1611 info->addr_source = "hardcoded";
1335 1612
1336 if (!si_type[i] || strcmp(si_type[i], "kcs") == 0) { 1613 if (!si_type[i] || ipmi_strcasecmp(si_type[i], "kcs") == 0) {
1337 info->si_type = SI_KCS; 1614 info->si_type = SI_KCS;
1338 } else if (strcmp(si_type[i], "smic") == 0) { 1615 } else if (ipmi_strcasecmp(si_type[i], "smic") == 0) {
1339 info->si_type = SI_SMIC; 1616 info->si_type = SI_SMIC;
1340 } else if (strcmp(si_type[i], "bt") == 0) { 1617 } else if (ipmi_strcasecmp(si_type[i], "bt") == 0) {
1341 info->si_type = SI_BT; 1618 info->si_type = SI_BT;
1342 } else { 1619 } else {
1343 printk(KERN_WARNING 1620 printk(KERN_WARNING
@@ -1952,19 +2229,9 @@ static int try_get_dev_id(struct smi_info *smi_info)
1952static int type_file_read_proc(char *page, char **start, off_t off, 2229static int type_file_read_proc(char *page, char **start, off_t off,
1953 int count, int *eof, void *data) 2230 int count, int *eof, void *data)
1954{ 2231{
1955 char *out = (char *) page;
1956 struct smi_info *smi = data; 2232 struct smi_info *smi = data;
1957 2233
1958 switch (smi->si_type) { 2234 return sprintf(page, "%s\n", si_to_str[smi->si_type]);
1959 case SI_KCS:
1960 return sprintf(out, "kcs\n");
1961 case SI_SMIC:
1962 return sprintf(out, "smic\n");
1963 case SI_BT:
1964 return sprintf(out, "bt\n");
1965 default:
1966 return 0;
1967 }
1968} 2235}
1969 2236
1970static int stat_file_read_proc(char *page, char **start, off_t off, 2237static int stat_file_read_proc(char *page, char **start, off_t off,
@@ -2000,7 +2267,24 @@ static int stat_file_read_proc(char *page, char **start, off_t off,
2000 out += sprintf(out, "incoming_messages: %ld\n", 2267 out += sprintf(out, "incoming_messages: %ld\n",
2001 smi->incoming_messages); 2268 smi->incoming_messages);
2002 2269
2003 return (out - ((char *) page)); 2270 return out - page;
2271}
2272
2273static int param_read_proc(char *page, char **start, off_t off,
2274 int count, int *eof, void *data)
2275{
2276 struct smi_info *smi = data;
2277
2278 return sprintf(page,
2279 "%s,%s,0x%lx,rsp=%d,rsi=%d,rsh=%d,irq=%d,ipmb=%d\n",
2280 si_to_str[smi->si_type],
2281 addr_space_to_str[smi->io.addr_type],
2282 smi->io.addr_data,
2283 smi->io.regspacing,
2284 smi->io.regsize,
2285 smi->io.regshift,
2286 smi->irq,
2287 smi->slave_addr);
2004} 2288}
2005 2289
2006/* 2290/*
@@ -2362,6 +2646,7 @@ static int try_smi_init(struct smi_info *new_smi)
2362 new_smi, 2646 new_smi,
2363 &new_smi->device_id, 2647 &new_smi->device_id,
2364 new_smi->dev, 2648 new_smi->dev,
2649 "bmc",
2365 new_smi->slave_addr); 2650 new_smi->slave_addr);
2366 if (rv) { 2651 if (rv) {
2367 printk(KERN_ERR 2652 printk(KERN_ERR
@@ -2390,6 +2675,16 @@ static int try_smi_init(struct smi_info *new_smi)
2390 goto out_err_stop_timer; 2675 goto out_err_stop_timer;
2391 } 2676 }
2392 2677
2678 rv = ipmi_smi_add_proc_entry(new_smi->intf, "params",
2679 param_read_proc, NULL,
2680 new_smi, THIS_MODULE);
2681 if (rv) {
2682 printk(KERN_ERR
2683 "ipmi_si: Unable to create proc entry: %d\n",
2684 rv);
2685 goto out_err_stop_timer;
2686 }
2687
2393 list_add_tail(&new_smi->link, &smi_infos); 2688 list_add_tail(&new_smi->link, &smi_infos);
2394 2689
2395 mutex_unlock(&smi_infos_lock); 2690 mutex_unlock(&smi_infos_lock);
@@ -2483,7 +2778,12 @@ static __devinit int init_ipmi_si(void)
2483#endif 2778#endif
2484 2779
2485#ifdef CONFIG_PCI 2780#ifdef CONFIG_PCI
2486 pci_module_init(&ipmi_pci_driver); 2781 rv = pci_register_driver(&ipmi_pci_driver);
2782 if (rv){
2783 printk(KERN_ERR
2784 "init_ipmi_si: Unable to register PCI driver: %d\n",
2785 rv);
2786 }
2487#endif 2787#endif
2488 2788
2489 if (si_trydefaults) { 2789 if (si_trydefaults) {
@@ -2498,7 +2798,7 @@ static __devinit int init_ipmi_si(void)
2498 } 2798 }
2499 2799
2500 mutex_lock(&smi_infos_lock); 2800 mutex_lock(&smi_infos_lock);
2501 if (list_empty(&smi_infos)) { 2801 if (unload_when_empty && list_empty(&smi_infos)) {
2502 mutex_unlock(&smi_infos_lock); 2802 mutex_unlock(&smi_infos_lock);
2503#ifdef CONFIG_PCI 2803#ifdef CONFIG_PCI
2504 pci_unregister_driver(&ipmi_pci_driver); 2804 pci_unregister_driver(&ipmi_pci_driver);
@@ -2513,7 +2813,7 @@ static __devinit int init_ipmi_si(void)
2513} 2813}
2514module_init(init_ipmi_si); 2814module_init(init_ipmi_si);
2515 2815
2516static void __devexit cleanup_one_si(struct smi_info *to_clean) 2816static void cleanup_one_si(struct smi_info *to_clean)
2517{ 2817{
2518 int rv; 2818 int rv;
2519 unsigned long flags; 2819 unsigned long flags;
diff --git a/drivers/char/ipmi/ipmi_smic_sm.c b/drivers/char/ipmi/ipmi_smic_sm.c
index 39d7e5ef1a2b..e64ea7d25d24 100644
--- a/drivers/char/ipmi/ipmi_smic_sm.c
+++ b/drivers/char/ipmi/ipmi_smic_sm.c
@@ -141,12 +141,14 @@ static int start_smic_transaction(struct si_sm_data *smic,
141{ 141{
142 unsigned int i; 142 unsigned int i;
143 143
144 if ((size < 2) || (size > MAX_SMIC_WRITE_SIZE)) { 144 if (size < 2)
145 return -1; 145 return IPMI_REQ_LEN_INVALID_ERR;
146 } 146 if (size > MAX_SMIC_WRITE_SIZE)
147 if ((smic->state != SMIC_IDLE) && (smic->state != SMIC_HOSED)) { 147 return IPMI_REQ_LEN_EXCEEDED_ERR;
148 return -2; 148
149 } 149 if ((smic->state != SMIC_IDLE) && (smic->state != SMIC_HOSED))
150 return IPMI_NOT_IN_MY_STATE_ERR;
151
150 if (smic_debug & SMIC_DEBUG_MSG) { 152 if (smic_debug & SMIC_DEBUG_MSG) {
151 printk(KERN_INFO "start_smic_transaction -"); 153 printk(KERN_INFO "start_smic_transaction -");
152 for (i = 0; i < size; i ++) { 154 for (i = 0; i < size; i ++) {
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 73f759eaa5a6..90fb2a541916 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -135,6 +135,7 @@
135static int nowayout = WATCHDOG_NOWAYOUT; 135static int nowayout = WATCHDOG_NOWAYOUT;
136 136
137static ipmi_user_t watchdog_user = NULL; 137static ipmi_user_t watchdog_user = NULL;
138static int watchdog_ifnum;
138 139
139/* Default the timeout to 10 seconds. */ 140/* Default the timeout to 10 seconds. */
140static int timeout = 10; 141static int timeout = 10;
@@ -161,6 +162,8 @@ static struct fasync_struct *fasync_q = NULL;
161static char pretimeout_since_last_heartbeat = 0; 162static char pretimeout_since_last_heartbeat = 0;
162static char expect_close; 163static char expect_close;
163 164
165static int ifnum_to_use = -1;
166
164static DECLARE_RWSEM(register_sem); 167static DECLARE_RWSEM(register_sem);
165 168
166/* Parameters to ipmi_set_timeout */ 169/* Parameters to ipmi_set_timeout */
@@ -169,6 +172,8 @@ static DECLARE_RWSEM(register_sem);
169#define IPMI_SET_TIMEOUT_FORCE_HB 2 172#define IPMI_SET_TIMEOUT_FORCE_HB 2
170 173
171static int ipmi_set_timeout(int do_heartbeat); 174static int ipmi_set_timeout(int do_heartbeat);
175static void ipmi_register_watchdog(int ipmi_intf);
176static void ipmi_unregister_watchdog(int ipmi_intf);
172 177
173/* If true, the driver will start running as soon as it is configured 178/* If true, the driver will start running as soon as it is configured
174 and ready. */ 179 and ready. */
@@ -245,6 +250,26 @@ static int get_param_str(char *buffer, struct kernel_param *kp)
245 return strlen(buffer); 250 return strlen(buffer);
246} 251}
247 252
253
254static int set_param_wdog_ifnum(const char *val, struct kernel_param *kp)
255{
256 int rv = param_set_int(val, kp);
257 if (rv)
258 return rv;
259 if ((ifnum_to_use < 0) || (ifnum_to_use == watchdog_ifnum))
260 return 0;
261
262 ipmi_unregister_watchdog(watchdog_ifnum);
263 ipmi_register_watchdog(ifnum_to_use);
264 return 0;
265}
266
267module_param_call(ifnum_to_use, set_param_wdog_ifnum, get_param_int,
268 &ifnum_to_use, 0644);
269MODULE_PARM_DESC(ifnum_to_use, "The interface number to use for the watchdog "
270 "timer. Setting to -1 defaults to the first registered "
271 "interface");
272
248module_param_call(timeout, set_param_int, get_param_int, &timeout, 0644); 273module_param_call(timeout, set_param_int, get_param_int, &timeout, 0644);
249MODULE_PARM_DESC(timeout, "Timeout value in seconds."); 274MODULE_PARM_DESC(timeout, "Timeout value in seconds.");
250 275
@@ -263,12 +288,13 @@ module_param_call(preop, set_param_str, get_param_str, preop_op, 0644);
263MODULE_PARM_DESC(preop, "Pretimeout driver operation. One of: " 288MODULE_PARM_DESC(preop, "Pretimeout driver operation. One of: "
264 "preop_none, preop_panic, preop_give_data."); 289 "preop_none, preop_panic, preop_give_data.");
265 290
266module_param(start_now, int, 0); 291module_param(start_now, int, 0444);
267MODULE_PARM_DESC(start_now, "Set to 1 to start the watchdog as" 292MODULE_PARM_DESC(start_now, "Set to 1 to start the watchdog as"
268 "soon as the driver is loaded."); 293 "soon as the driver is loaded.");
269 294
270module_param(nowayout, int, 0644); 295module_param(nowayout, int, 0644);
271MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); 296MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
297 "(default=CONFIG_WATCHDOG_NOWAYOUT)");
272 298
273/* Default state of the timer. */ 299/* Default state of the timer. */
274static unsigned char ipmi_watchdog_state = WDOG_TIMEOUT_NONE; 300static unsigned char ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
@@ -872,6 +898,11 @@ static void ipmi_register_watchdog(int ipmi_intf)
872 if (watchdog_user) 898 if (watchdog_user)
873 goto out; 899 goto out;
874 900
901 if ((ifnum_to_use >= 0) && (ifnum_to_use != ipmi_intf))
902 goto out;
903
904 watchdog_ifnum = ipmi_intf;
905
875 rv = ipmi_create_user(ipmi_intf, &ipmi_hndlrs, NULL, &watchdog_user); 906 rv = ipmi_create_user(ipmi_intf, &ipmi_hndlrs, NULL, &watchdog_user);
876 if (rv < 0) { 907 if (rv < 0) {
877 printk(KERN_CRIT PFX "Unable to register with ipmi\n"); 908 printk(KERN_CRIT PFX "Unable to register with ipmi\n");
@@ -901,6 +932,39 @@ static void ipmi_register_watchdog(int ipmi_intf)
901 } 932 }
902} 933}
903 934
935static void ipmi_unregister_watchdog(int ipmi_intf)
936{
937 int rv;
938
939 down_write(&register_sem);
940
941 if (!watchdog_user)
942 goto out;
943
944 if (watchdog_ifnum != ipmi_intf)
945 goto out;
946
947 /* Make sure no one can call us any more. */
948 misc_deregister(&ipmi_wdog_miscdev);
949
950 /* Wait to make sure the message makes it out. The lower layer has
951 pointers to our buffers, we want to make sure they are done before
952 we release our memory. */
953 while (atomic_read(&set_timeout_tofree))
954 schedule_timeout_uninterruptible(1);
955
956 /* Disconnect from IPMI. */
957 rv = ipmi_destroy_user(watchdog_user);
958 if (rv) {
959 printk(KERN_WARNING PFX "error unlinking from IPMI: %d\n",
960 rv);
961 }
962 watchdog_user = NULL;
963
964 out:
965 up_write(&register_sem);
966}
967
904#ifdef HAVE_NMI_HANDLER 968#ifdef HAVE_NMI_HANDLER
905static int 969static int
906ipmi_nmi(void *dev_id, int cpu, int handled) 970ipmi_nmi(void *dev_id, int cpu, int handled)
@@ -1004,9 +1068,7 @@ static void ipmi_new_smi(int if_num, struct device *device)
1004 1068
1005static void ipmi_smi_gone(int if_num) 1069static void ipmi_smi_gone(int if_num)
1006{ 1070{
1007 /* This can never be called, because once the watchdog is 1071 ipmi_unregister_watchdog(if_num);
1008 registered, the interface can't go away until the watchdog
1009 is unregistered. */
1010} 1072}
1011 1073
1012static struct ipmi_smi_watcher smi_watcher = 1074static struct ipmi_smi_watcher smi_watcher =
@@ -1148,30 +1210,32 @@ static int __init ipmi_wdog_init(void)
1148 1210
1149 check_parms(); 1211 check_parms();
1150 1212
1213 register_reboot_notifier(&wdog_reboot_notifier);
1214 atomic_notifier_chain_register(&panic_notifier_list,
1215 &wdog_panic_notifier);
1216
1151 rv = ipmi_smi_watcher_register(&smi_watcher); 1217 rv = ipmi_smi_watcher_register(&smi_watcher);
1152 if (rv) { 1218 if (rv) {
1153#ifdef HAVE_NMI_HANDLER 1219#ifdef HAVE_NMI_HANDLER
1154 if (preaction_val == WDOG_PRETIMEOUT_NMI) 1220 if (preaction_val == WDOG_PRETIMEOUT_NMI)
1155 release_nmi(&ipmi_nmi_handler); 1221 release_nmi(&ipmi_nmi_handler);
1156#endif 1222#endif
1223 atomic_notifier_chain_unregister(&panic_notifier_list,
1224 &wdog_panic_notifier);
1225 unregister_reboot_notifier(&wdog_reboot_notifier);
1157 printk(KERN_WARNING PFX "can't register smi watcher\n"); 1226 printk(KERN_WARNING PFX "can't register smi watcher\n");
1158 return rv; 1227 return rv;
1159 } 1228 }
1160 1229
1161 register_reboot_notifier(&wdog_reboot_notifier);
1162 atomic_notifier_chain_register(&panic_notifier_list,
1163 &wdog_panic_notifier);
1164
1165 printk(KERN_INFO PFX "driver initialized\n"); 1230 printk(KERN_INFO PFX "driver initialized\n");
1166 1231
1167 return 0; 1232 return 0;
1168} 1233}
1169 1234
1170static __exit void ipmi_unregister_watchdog(void) 1235static void __exit ipmi_wdog_exit(void)
1171{ 1236{
1172 int rv; 1237 ipmi_smi_watcher_unregister(&smi_watcher);
1173 1238 ipmi_unregister_watchdog(watchdog_ifnum);
1174 down_write(&register_sem);
1175 1239
1176#ifdef HAVE_NMI_HANDLER 1240#ifdef HAVE_NMI_HANDLER
1177 if (nmi_handler_registered) 1241 if (nmi_handler_registered)
@@ -1179,37 +1243,8 @@ static __exit void ipmi_unregister_watchdog(void)
1179#endif 1243#endif
1180 1244
1181 atomic_notifier_chain_unregister(&panic_notifier_list, 1245 atomic_notifier_chain_unregister(&panic_notifier_list,
1182 &wdog_panic_notifier); 1246 &wdog_panic_notifier);
1183 unregister_reboot_notifier(&wdog_reboot_notifier); 1247 unregister_reboot_notifier(&wdog_reboot_notifier);
1184
1185 if (! watchdog_user)
1186 goto out;
1187
1188 /* Make sure no one can call us any more. */
1189 misc_deregister(&ipmi_wdog_miscdev);
1190
1191 /* Wait to make sure the message makes it out. The lower layer has
1192 pointers to our buffers, we want to make sure they are done before
1193 we release our memory. */
1194 while (atomic_read(&set_timeout_tofree))
1195 schedule_timeout_uninterruptible(1);
1196
1197 /* Disconnect from IPMI. */
1198 rv = ipmi_destroy_user(watchdog_user);
1199 if (rv) {
1200 printk(KERN_WARNING PFX "error unlinking from IPMI: %d\n",
1201 rv);
1202 }
1203 watchdog_user = NULL;
1204
1205 out:
1206 up_write(&register_sem);
1207}
1208
1209static void __exit ipmi_wdog_exit(void)
1210{
1211 ipmi_smi_watcher_unregister(&smi_watcher);
1212 ipmi_unregister_watchdog();
1213} 1248}
1214module_exit(ipmi_wdog_exit); 1249module_exit(ipmi_wdog_exit);
1215module_init(ipmi_wdog_init); 1250module_init(ipmi_wdog_init);
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index 58c955e390b3..1637c1d9a4ba 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -530,9 +530,9 @@ sched_again:
530/* Interrupt handlers */ 530/* Interrupt handlers */
531 531
532 532
533static void isicom_bottomhalf(void *data) 533static void isicom_bottomhalf(struct work_struct *work)
534{ 534{
535 struct isi_port *port = (struct isi_port *) data; 535 struct isi_port *port = container_of(work, struct isi_port, bh_tqueue);
536 struct tty_struct *tty = port->tty; 536 struct tty_struct *tty = port->tty;
537 537
538 if (!tty) 538 if (!tty)
@@ -1474,9 +1474,9 @@ static void isicom_start(struct tty_struct *tty)
1474} 1474}
1475 1475
1476/* hangup et all */ 1476/* hangup et all */
1477static void do_isicom_hangup(void *data) 1477static void do_isicom_hangup(struct work_struct *work)
1478{ 1478{
1479 struct isi_port *port = data; 1479 struct isi_port *port = container_of(work, struct isi_port, hangup_tq);
1480 struct tty_struct *tty; 1480 struct tty_struct *tty;
1481 1481
1482 tty = port->tty; 1482 tty = port->tty;
@@ -1966,8 +1966,8 @@ static int __devinit isicom_setup(void)
1966 port->channel = channel; 1966 port->channel = channel;
1967 port->close_delay = 50 * HZ/100; 1967 port->close_delay = 50 * HZ/100;
1968 port->closing_wait = 3000 * HZ/100; 1968 port->closing_wait = 3000 * HZ/100;
1969 INIT_WORK(&port->hangup_tq, do_isicom_hangup, port); 1969 INIT_WORK(&port->hangup_tq, do_isicom_hangup);
1970 INIT_WORK(&port->bh_tqueue, isicom_bottomhalf, port); 1970 INIT_WORK(&port->bh_tqueue, isicom_bottomhalf);
1971 port->status = 0; 1971 port->status = 0;
1972 init_waitqueue_head(&port->open_wait); 1972 init_waitqueue_head(&port->open_wait);
1973 init_waitqueue_head(&port->close_wait); 1973 init_waitqueue_head(&port->close_wait);
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index ffdf9df1a67a..8f591945ebd9 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -663,7 +663,7 @@ static int stli_initopen(stlibrd_t *brdp, stliport_t *portp);
663static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait); 663static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait);
664static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait); 664static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait);
665static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp); 665static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp);
666static void stli_dohangup(void *arg); 666static void stli_dohangup(struct work_struct *);
667static int stli_setport(stliport_t *portp); 667static int stli_setport(stliport_t *portp);
668static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); 668static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
669static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); 669static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
@@ -1990,9 +1990,9 @@ static void stli_start(struct tty_struct *tty)
1990 * aren't that time critical). 1990 * aren't that time critical).
1991 */ 1991 */
1992 1992
1993static void stli_dohangup(void *arg) 1993static void stli_dohangup(struct work_struct *ugly_api)
1994{ 1994{
1995 stliport_t *portp = (stliport_t *) arg; 1995 stliport_t *portp = container_of(ugly_api, stliport_t, tqhangup);
1996 if (portp->tty != NULL) { 1996 if (portp->tty != NULL) {
1997 tty_hangup(portp->tty); 1997 tty_hangup(portp->tty);
1998 } 1998 }
@@ -2898,7 +2898,7 @@ static int stli_initports(stlibrd_t *brdp)
2898 portp->baud_base = STL_BAUDBASE; 2898 portp->baud_base = STL_BAUDBASE;
2899 portp->close_delay = STL_CLOSEDELAY; 2899 portp->close_delay = STL_CLOSEDELAY;
2900 portp->closing_wait = 30 * HZ; 2900 portp->closing_wait = 30 * HZ;
2901 INIT_WORK(&portp->tqhangup, stli_dohangup, portp); 2901 INIT_WORK(&portp->tqhangup, stli_dohangup);
2902 init_waitqueue_head(&portp->open_wait); 2902 init_waitqueue_head(&portp->open_wait);
2903 init_waitqueue_head(&portp->close_wait); 2903 init_waitqueue_head(&portp->close_wait);
2904 init_waitqueue_head(&portp->raw_wait); 2904 init_waitqueue_head(&portp->raw_wait);
@@ -3476,6 +3476,8 @@ static int stli_initecp(stlibrd_t *brdp)
3476 if (sig.magic != cpu_to_le32(ECP_MAGIC)) 3476 if (sig.magic != cpu_to_le32(ECP_MAGIC))
3477 { 3477 {
3478 release_region(brdp->iobase, brdp->iosize); 3478 release_region(brdp->iobase, brdp->iosize);
3479 iounmap(brdp->membase);
3480 brdp->membase = NULL;
3479 return -ENODEV; 3481 return -ENODEV;
3480 } 3482 }
3481 3483
@@ -3632,6 +3634,8 @@ static int stli_initonb(stlibrd_t *brdp)
3632 sig.magic3 != cpu_to_le16(ONB_MAGIC3)) 3634 sig.magic3 != cpu_to_le16(ONB_MAGIC3))
3633 { 3635 {
3634 release_region(brdp->iobase, brdp->iosize); 3636 release_region(brdp->iobase, brdp->iosize);
3637 iounmap(brdp->membase);
3638 brdp->membase = NULL;
3635 return -ENODEV; 3639 return -ENODEV;
3636 } 3640 }
3637 3641
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 7a484fc7cb9e..7e975f606924 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -199,6 +199,8 @@ int misc_register(struct miscdevice * misc)
199 dev_t dev; 199 dev_t dev;
200 int err = 0; 200 int err = 0;
201 201
202 INIT_LIST_HEAD(&misc->list);
203
202 down(&misc_sem); 204 down(&misc_sem);
203 list_for_each_entry(c, &misc_list, list) { 205 list_for_each_entry(c, &misc_list, list) {
204 if (c->minor == misc->minor) { 206 if (c->minor == misc->minor) {
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 22b9905c1e52..c09160383a53 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -680,7 +680,7 @@ static int __init mmtimer_init(void)
680 if (sn_rtc_cycles_per_second < 100000) { 680 if (sn_rtc_cycles_per_second < 100000) {
681 printk(KERN_ERR "%s: unable to determine clock frequency\n", 681 printk(KERN_ERR "%s: unable to determine clock frequency\n",
682 MMTIMER_NAME); 682 MMTIMER_NAME);
683 return -1; 683 goto out1;
684 } 684 }
685 685
686 mmtimer_femtoperiod = ((unsigned long)1E15 + sn_rtc_cycles_per_second / 686 mmtimer_femtoperiod = ((unsigned long)1E15 + sn_rtc_cycles_per_second /
@@ -689,13 +689,13 @@ static int __init mmtimer_init(void)
689 if (request_irq(SGI_MMTIMER_VECTOR, mmtimer_interrupt, IRQF_PERCPU, MMTIMER_NAME, NULL)) { 689 if (request_irq(SGI_MMTIMER_VECTOR, mmtimer_interrupt, IRQF_PERCPU, MMTIMER_NAME, NULL)) {
690 printk(KERN_WARNING "%s: unable to allocate interrupt.", 690 printk(KERN_WARNING "%s: unable to allocate interrupt.",
691 MMTIMER_NAME); 691 MMTIMER_NAME);
692 return -1; 692 goto out1;
693 } 693 }
694 694
695 if (misc_register(&mmtimer_miscdev)) { 695 if (misc_register(&mmtimer_miscdev)) {
696 printk(KERN_ERR "%s: failed to register device\n", 696 printk(KERN_ERR "%s: failed to register device\n",
697 MMTIMER_NAME); 697 MMTIMER_NAME);
698 return -1; 698 goto out2;
699 } 699 }
700 700
701 /* Get max numbered node, calculate slots needed */ 701 /* Get max numbered node, calculate slots needed */
@@ -709,16 +709,18 @@ static int __init mmtimer_init(void)
709 if (timers == NULL) { 709 if (timers == NULL) {
710 printk(KERN_ERR "%s: failed to allocate memory for device\n", 710 printk(KERN_ERR "%s: failed to allocate memory for device\n",
711 MMTIMER_NAME); 711 MMTIMER_NAME);
712 return -1; 712 goto out3;
713 } 713 }
714 714
715 memset(timers,0,(sizeof(mmtimer_t *)*maxn));
716
715 /* Allocate mmtimer_t's for each online node */ 717 /* Allocate mmtimer_t's for each online node */
716 for_each_online_node(node) { 718 for_each_online_node(node) {
717 timers[node] = kmalloc_node(sizeof(mmtimer_t)*NUM_COMPARATORS, GFP_KERNEL, node); 719 timers[node] = kmalloc_node(sizeof(mmtimer_t)*NUM_COMPARATORS, GFP_KERNEL, node);
718 if (timers[node] == NULL) { 720 if (timers[node] == NULL) {
719 printk(KERN_ERR "%s: failed to allocate memory for device\n", 721 printk(KERN_ERR "%s: failed to allocate memory for device\n",
720 MMTIMER_NAME); 722 MMTIMER_NAME);
721 return -1; 723 goto out4;
722 } 724 }
723 for (i=0; i< NUM_COMPARATORS; i++) { 725 for (i=0; i< NUM_COMPARATORS; i++) {
724 mmtimer_t * base = timers[node] + i; 726 mmtimer_t * base = timers[node] + i;
@@ -739,6 +741,17 @@ static int __init mmtimer_init(void)
739 sn_rtc_cycles_per_second/(unsigned long)1E6); 741 sn_rtc_cycles_per_second/(unsigned long)1E6);
740 742
741 return 0; 743 return 0;
744
745out4:
746 for_each_online_node(node) {
747 kfree(timers[node]);
748 }
749out3:
750 misc_deregister(&mmtimer_miscdev);
751out2:
752 free_irq(SGI_MMTIMER_VECTOR, NULL);
753out1:
754 return -1;
742} 755}
743 756
744module_init(mmtimer_init); 757module_init(mmtimer_init);
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index 96cb1f07332b..8b316953173d 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -222,7 +222,7 @@ static struct semaphore moxaBuffSem;
222/* 222/*
223 * static functions: 223 * static functions:
224 */ 224 */
225static void do_moxa_softint(void *); 225static void do_moxa_softint(struct work_struct *);
226static int moxa_open(struct tty_struct *, struct file *); 226static int moxa_open(struct tty_struct *, struct file *);
227static void moxa_close(struct tty_struct *, struct file *); 227static void moxa_close(struct tty_struct *, struct file *);
228static int moxa_write(struct tty_struct *, const unsigned char *, int); 228static int moxa_write(struct tty_struct *, const unsigned char *, int);
@@ -363,7 +363,7 @@ static int __init moxa_init(void)
363 for (i = 0, ch = moxaChannels; i < MAX_PORTS; i++, ch++) { 363 for (i = 0, ch = moxaChannels; i < MAX_PORTS; i++, ch++) {
364 ch->type = PORT_16550A; 364 ch->type = PORT_16550A;
365 ch->port = i; 365 ch->port = i;
366 INIT_WORK(&ch->tqueue, do_moxa_softint, ch); 366 INIT_WORK(&ch->tqueue, do_moxa_softint);
367 ch->tty = NULL; 367 ch->tty = NULL;
368 ch->close_delay = 5 * HZ / 10; 368 ch->close_delay = 5 * HZ / 10;
369 ch->closing_wait = 30 * HZ; 369 ch->closing_wait = 30 * HZ;
@@ -498,9 +498,12 @@ static void __exit moxa_exit(void)
498 printk("Couldn't unregister MOXA Intellio family serial driver\n"); 498 printk("Couldn't unregister MOXA Intellio family serial driver\n");
499 put_tty_driver(moxaDriver); 499 put_tty_driver(moxaDriver);
500 500
501 for (i = 0; i < MAX_BOARDS; i++) 501 for (i = 0; i < MAX_BOARDS; i++) {
502 if (moxaBaseAddr[i])
503 iounmap(moxaBaseAddr[i]);
502 if (moxa_boards[i].busType == MOXA_BUS_TYPE_PCI) 504 if (moxa_boards[i].busType == MOXA_BUS_TYPE_PCI)
503 pci_dev_put(moxa_boards[i].pciInfo.pdev); 505 pci_dev_put(moxa_boards[i].pciInfo.pdev);
506 }
504 507
505 if (verbose) 508 if (verbose)
506 printk("Done\n"); 509 printk("Done\n");
@@ -509,9 +512,9 @@ static void __exit moxa_exit(void)
509module_init(moxa_init); 512module_init(moxa_init);
510module_exit(moxa_exit); 513module_exit(moxa_exit);
511 514
512static void do_moxa_softint(void *private_) 515static void do_moxa_softint(struct work_struct *work)
513{ 516{
514 struct moxa_str *ch = (struct moxa_str *) private_; 517 struct moxa_str *ch = container_of(work, struct moxa_str, tqueue);
515 struct tty_struct *tty; 518 struct tty_struct *tty;
516 519
517 if (ch && (tty = ch->tty)) { 520 if (ch && (tty = ch->tty)) {
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index 048d91142c17..5ed2486b7581 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -389,7 +389,7 @@ static int mxser_init(void);
389/* static void mxser_poll(unsigned long); */ 389/* static void mxser_poll(unsigned long); */
390static int mxser_get_ISA_conf(int, struct mxser_hwconf *); 390static int mxser_get_ISA_conf(int, struct mxser_hwconf *);
391static int mxser_get_PCI_conf(int, int, int, struct mxser_hwconf *); 391static int mxser_get_PCI_conf(int, int, int, struct mxser_hwconf *);
392static void mxser_do_softint(void *); 392static void mxser_do_softint(struct work_struct *);
393static int mxser_open(struct tty_struct *, struct file *); 393static int mxser_open(struct tty_struct *, struct file *);
394static void mxser_close(struct tty_struct *, struct file *); 394static void mxser_close(struct tty_struct *, struct file *);
395static int mxser_write(struct tty_struct *, const unsigned char *, int); 395static int mxser_write(struct tty_struct *, const unsigned char *, int);
@@ -590,7 +590,7 @@ static int mxser_initbrd(int board, struct mxser_hwconf *hwconf)
590 info->custom_divisor = hwconf->baud_base[i] * 16; 590 info->custom_divisor = hwconf->baud_base[i] * 16;
591 info->close_delay = 5 * HZ / 10; 591 info->close_delay = 5 * HZ / 10;
592 info->closing_wait = 30 * HZ; 592 info->closing_wait = 30 * HZ;
593 INIT_WORK(&info->tqueue, mxser_do_softint, info); 593 INIT_WORK(&info->tqueue, mxser_do_softint);
594 info->normal_termios = mxvar_sdriver->init_termios; 594 info->normal_termios = mxvar_sdriver->init_termios;
595 init_waitqueue_head(&info->open_wait); 595 init_waitqueue_head(&info->open_wait);
596 init_waitqueue_head(&info->close_wait); 596 init_waitqueue_head(&info->close_wait);
@@ -917,9 +917,10 @@ static int mxser_init(void)
917 return 0; 917 return 0;
918} 918}
919 919
920static void mxser_do_softint(void *private_) 920static void mxser_do_softint(struct work_struct *work)
921{ 921{
922 struct mxser_struct *info = private_; 922 struct mxser_struct *info =
923 container_of(work, struct mxser_struct, tqueue);
923 struct tty_struct *tty; 924 struct tty_struct *tty;
924 925
925 tty = info->tty; 926 tty = info->tty;
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index f9f72500ea5d..74d21c1c104f 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -75,8 +75,10 @@
75#include <pcmcia/cisreg.h> 75#include <pcmcia/cisreg.h>
76#include <pcmcia/ds.h> 76#include <pcmcia/ds.h>
77 77
78#ifdef CONFIG_HDLC_MODULE 78#if defined(CONFIG_HDLC) || (defined(CONFIG_HDLC_MODULE) && defined(CONFIG_SYNCLINK_CS_MODULE))
79#define CONFIG_HDLC 1 79#define SYNCLINK_GENERIC_HDLC 1
80#else
81#define SYNCLINK_GENERIC_HDLC 0
80#endif 82#endif
81 83
82#define GET_USER(error,value,addr) error = get_user(value,addr) 84#define GET_USER(error,value,addr) error = get_user(value,addr)
@@ -235,7 +237,7 @@ typedef struct _mgslpc_info {
235 int dosyncppp; 237 int dosyncppp;
236 spinlock_t netlock; 238 spinlock_t netlock;
237 239
238#ifdef CONFIG_HDLC 240#if SYNCLINK_GENERIC_HDLC
239 struct net_device *netdev; 241 struct net_device *netdev;
240#endif 242#endif
241 243
@@ -392,7 +394,7 @@ static void tx_timeout(unsigned long context);
392 394
393static int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg); 395static int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg);
394 396
395#ifdef CONFIG_HDLC 397#if SYNCLINK_GENERIC_HDLC
396#define dev_to_port(D) (dev_to_hdlc(D)->priv) 398#define dev_to_port(D) (dev_to_hdlc(D)->priv)
397static void hdlcdev_tx_done(MGSLPC_INFO *info); 399static void hdlcdev_tx_done(MGSLPC_INFO *info);
398static void hdlcdev_rx(MGSLPC_INFO *info, char *buf, int size); 400static void hdlcdev_rx(MGSLPC_INFO *info, char *buf, int size);
@@ -421,7 +423,7 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id);
421/* 423/*
422 * Bottom half interrupt handlers 424 * Bottom half interrupt handlers
423 */ 425 */
424static void bh_handler(void* Context); 426static void bh_handler(struct work_struct *work);
425static void bh_transmit(MGSLPC_INFO *info); 427static void bh_transmit(MGSLPC_INFO *info);
426static void bh_status(MGSLPC_INFO *info); 428static void bh_status(MGSLPC_INFO *info);
427 429
@@ -547,7 +549,7 @@ static int mgslpc_probe(struct pcmcia_device *link)
547 549
548 memset(info, 0, sizeof(MGSLPC_INFO)); 550 memset(info, 0, sizeof(MGSLPC_INFO));
549 info->magic = MGSLPC_MAGIC; 551 info->magic = MGSLPC_MAGIC;
550 INIT_WORK(&info->task, bh_handler, info); 552 INIT_WORK(&info->task, bh_handler);
551 info->max_frame_size = 4096; 553 info->max_frame_size = 4096;
552 info->close_delay = 5*HZ/10; 554 info->close_delay = 5*HZ/10;
553 info->closing_wait = 30*HZ; 555 info->closing_wait = 30*HZ;
@@ -835,9 +837,9 @@ static int bh_action(MGSLPC_INFO *info)
835 return rc; 837 return rc;
836} 838}
837 839
838static void bh_handler(void* Context) 840static void bh_handler(struct work_struct *work)
839{ 841{
840 MGSLPC_INFO *info = (MGSLPC_INFO*)Context; 842 MGSLPC_INFO *info = container_of(work, MGSLPC_INFO, task);
841 int action; 843 int action;
842 844
843 if (!info) 845 if (!info)
@@ -1053,7 +1055,7 @@ static void tx_done(MGSLPC_INFO *info)
1053 info->drop_rts_on_tx_done = 0; 1055 info->drop_rts_on_tx_done = 0;
1054 } 1056 }
1055 1057
1056#ifdef CONFIG_HDLC 1058#if SYNCLINK_GENERIC_HDLC
1057 if (info->netcount) 1059 if (info->netcount)
1058 hdlcdev_tx_done(info); 1060 hdlcdev_tx_done(info);
1059 else 1061 else
@@ -1164,7 +1166,7 @@ static void dcd_change(MGSLPC_INFO *info)
1164 } 1166 }
1165 else 1167 else
1166 info->input_signal_events.dcd_down++; 1168 info->input_signal_events.dcd_down++;
1167#ifdef CONFIG_HDLC 1169#if SYNCLINK_GENERIC_HDLC
1168 if (info->netcount) { 1170 if (info->netcount) {
1169 if (info->serial_signals & SerialSignal_DCD) 1171 if (info->serial_signals & SerialSignal_DCD)
1170 netif_carrier_on(info->netdev); 1172 netif_carrier_on(info->netdev);
@@ -2953,7 +2955,7 @@ static void mgslpc_add_device(MGSLPC_INFO *info)
2953 printk( "SyncLink PC Card %s:IO=%04X IRQ=%d\n", 2955 printk( "SyncLink PC Card %s:IO=%04X IRQ=%d\n",
2954 info->device_name, info->io_base, info->irq_level); 2956 info->device_name, info->io_base, info->irq_level);
2955 2957
2956#ifdef CONFIG_HDLC 2958#if SYNCLINK_GENERIC_HDLC
2957 hdlcdev_init(info); 2959 hdlcdev_init(info);
2958#endif 2960#endif
2959} 2961}
@@ -2969,7 +2971,7 @@ static void mgslpc_remove_device(MGSLPC_INFO *remove_info)
2969 last->next_device = info->next_device; 2971 last->next_device = info->next_device;
2970 else 2972 else
2971 mgslpc_device_list = info->next_device; 2973 mgslpc_device_list = info->next_device;
2972#ifdef CONFIG_HDLC 2974#if SYNCLINK_GENERIC_HDLC
2973 hdlcdev_exit(info); 2975 hdlcdev_exit(info);
2974#endif 2976#endif
2975 release_resources(info); 2977 release_resources(info);
@@ -3901,7 +3903,7 @@ static int rx_get_frame(MGSLPC_INFO *info)
3901 return_frame = 1; 3903 return_frame = 1;
3902 } 3904 }
3903 framesize = 0; 3905 framesize = 0;
3904#ifdef CONFIG_HDLC 3906#if SYNCLINK_GENERIC_HDLC
3905 { 3907 {
3906 struct net_device_stats *stats = hdlc_stats(info->netdev); 3908 struct net_device_stats *stats = hdlc_stats(info->netdev);
3907 stats->rx_errors++; 3909 stats->rx_errors++;
@@ -3935,7 +3937,7 @@ static int rx_get_frame(MGSLPC_INFO *info)
3935 ++framesize; 3937 ++framesize;
3936 } 3938 }
3937 3939
3938#ifdef CONFIG_HDLC 3940#if SYNCLINK_GENERIC_HDLC
3939 if (info->netcount) 3941 if (info->netcount)
3940 hdlcdev_rx(info, buf->data, framesize); 3942 hdlcdev_rx(info, buf->data, framesize);
3941 else 3943 else
@@ -4091,7 +4093,7 @@ static void tx_timeout(unsigned long context)
4091 4093
4092 spin_unlock_irqrestore(&info->lock,flags); 4094 spin_unlock_irqrestore(&info->lock,flags);
4093 4095
4094#ifdef CONFIG_HDLC 4096#if SYNCLINK_GENERIC_HDLC
4095 if (info->netcount) 4097 if (info->netcount)
4096 hdlcdev_tx_done(info); 4098 hdlcdev_tx_done(info);
4097 else 4099 else
@@ -4099,7 +4101,7 @@ static void tx_timeout(unsigned long context)
4099 bh_transmit(info); 4101 bh_transmit(info);
4100} 4102}
4101 4103
4102#ifdef CONFIG_HDLC 4104#if SYNCLINK_GENERIC_HDLC
4103 4105
4104/** 4106/**
4105 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.) 4107 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
diff --git a/drivers/char/random.c b/drivers/char/random.c
index d40df30c2b10..4c6782a1ecdb 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1422,9 +1422,9 @@ static struct keydata {
1422 1422
1423static unsigned int ip_cnt; 1423static unsigned int ip_cnt;
1424 1424
1425static void rekey_seq_generator(void *private_); 1425static void rekey_seq_generator(struct work_struct *work);
1426 1426
1427static DECLARE_WORK(rekey_work, rekey_seq_generator, NULL); 1427static DECLARE_DELAYED_WORK(rekey_work, rekey_seq_generator);
1428 1428
1429/* 1429/*
1430 * Lock avoidance: 1430 * Lock avoidance:
@@ -1438,7 +1438,7 @@ static DECLARE_WORK(rekey_work, rekey_seq_generator, NULL);
1438 * happen, and even if that happens only a not perfectly compliant 1438 * happen, and even if that happens only a not perfectly compliant
1439 * ISN is generated, nothing fatal. 1439 * ISN is generated, nothing fatal.
1440 */ 1440 */
1441static void rekey_seq_generator(void *private_) 1441static void rekey_seq_generator(struct work_struct *work)
1442{ 1442{
1443 struct keydata *keyptr = &ip_keydata[1 ^ (ip_cnt & 1)]; 1443 struct keydata *keyptr = &ip_keydata[1 ^ (ip_cnt & 1)];
1444 1444
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index 7ac68cb3bedd..e79b2ede8510 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -1026,6 +1026,7 @@ static int __init rio_init(void)
1026 found++; 1026 found++;
1027 } else { 1027 } else {
1028 iounmap(p->RIOHosts[p->RIONumHosts].Caddr); 1028 iounmap(p->RIOHosts[p->RIONumHosts].Caddr);
1029 p->RIOHosts[p->RIONumHosts].Caddr = NULL;
1029 } 1030 }
1030 } 1031 }
1031 1032
@@ -1078,6 +1079,7 @@ static int __init rio_init(void)
1078 found++; 1079 found++;
1079 } else { 1080 } else {
1080 iounmap(p->RIOHosts[p->RIONumHosts].Caddr); 1081 iounmap(p->RIOHosts[p->RIONumHosts].Caddr);
1082 p->RIOHosts[p->RIONumHosts].Caddr = NULL;
1081 } 1083 }
1082#else 1084#else
1083 printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n"); 1085 printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n");
@@ -1117,8 +1119,10 @@ static int __init rio_init(void)
1117 } 1119 }
1118 } 1120 }
1119 1121
1120 if (!okboard) 1122 if (!okboard) {
1121 iounmap(hp->Caddr); 1123 iounmap(hp->Caddr);
1124 hp->Caddr = NULL;
1125 }
1122 } 1126 }
1123 } 1127 }
1124 1128
@@ -1188,6 +1192,8 @@ static void __exit rio_exit(void)
1188 } 1192 }
1189 /* It is safe/allowed to del_timer a non-active timer */ 1193 /* It is safe/allowed to del_timer a non-active timer */
1190 del_timer(&hp->timer); 1194 del_timer(&hp->timer);
1195 if (hp->Caddr)
1196 iounmap(hp->Caddr);
1191 if (hp->Type == RIO_PCI) 1197 if (hp->Type == RIO_PCI)
1192 pci_dev_put(hp->pdev); 1198 pci_dev_put(hp->pdev);
1193 } 1199 }
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index 5ab32b38f45a..0a77bfcd5b5e 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -82,11 +82,6 @@
82static struct riscom_board * IRQ_to_board[16]; 82static struct riscom_board * IRQ_to_board[16];
83static struct tty_driver *riscom_driver; 83static struct tty_driver *riscom_driver;
84 84
85static unsigned long baud_table[] = {
86 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
87 9600, 19200, 38400, 57600, 76800, 0,
88};
89
90static struct riscom_board rc_board[RC_NBOARD] = { 85static struct riscom_board rc_board[RC_NBOARD] = {
91 { 86 {
92 .base = RC_IOBASE1, 87 .base = RC_IOBASE1,
@@ -1516,9 +1511,9 @@ static void rc_start(struct tty_struct * tty)
1516 * do_rc_hangup() -> tty->hangup() -> rc_hangup() 1511 * do_rc_hangup() -> tty->hangup() -> rc_hangup()
1517 * 1512 *
1518 */ 1513 */
1519static void do_rc_hangup(void *private_) 1514static void do_rc_hangup(struct work_struct *ugly_api)
1520{ 1515{
1521 struct riscom_port *port = (struct riscom_port *) private_; 1516 struct riscom_port *port = container_of(ugly_api, struct riscom_port, tqueue_hangup);
1522 struct tty_struct *tty; 1517 struct tty_struct *tty;
1523 1518
1524 tty = port->tty; 1519 tty = port->tty;
@@ -1567,9 +1562,9 @@ static void rc_set_termios(struct tty_struct * tty, struct termios * old_termios
1567 } 1562 }
1568} 1563}
1569 1564
1570static void do_softint(void *private_) 1565static void do_softint(struct work_struct *ugly_api)
1571{ 1566{
1572 struct riscom_port *port = (struct riscom_port *) private_; 1567 struct riscom_port *port = container_of(ugly_api, struct riscom_port, tqueue);
1573 struct tty_struct *tty; 1568 struct tty_struct *tty;
1574 1569
1575 if(!(tty = port->tty)) 1570 if(!(tty = port->tty))
@@ -1632,8 +1627,8 @@ static inline int rc_init_drivers(void)
1632 memset(rc_port, 0, sizeof(rc_port)); 1627 memset(rc_port, 0, sizeof(rc_port));
1633 for (i = 0; i < RC_NPORT * RC_NBOARD; i++) { 1628 for (i = 0; i < RC_NPORT * RC_NBOARD; i++) {
1634 rc_port[i].magic = RISCOM8_MAGIC; 1629 rc_port[i].magic = RISCOM8_MAGIC;
1635 INIT_WORK(&rc_port[i].tqueue, do_softint, &rc_port[i]); 1630 INIT_WORK(&rc_port[i].tqueue, do_softint);
1636 INIT_WORK(&rc_port[i].tqueue_hangup, do_rc_hangup, &rc_port[i]); 1631 INIT_WORK(&rc_port[i].tqueue_hangup, do_rc_hangup);
1637 rc_port[i].close_delay = 50 * HZ/100; 1632 rc_port[i].close_delay = 50 * HZ/100;
1638 rc_port[i].closing_wait = 3000 * HZ/100; 1633 rc_port[i].closing_wait = 3000 * HZ/100;
1639 init_waitqueue_head(&rc_port[i].open_wait); 1634 init_waitqueue_head(&rc_port[i].open_wait);
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c
index 3af7f0958c5d..9ba13af234be 100644
--- a/drivers/char/serial167.c
+++ b/drivers/char/serial167.c
@@ -706,9 +706,9 @@ cd2401_rx_interrupt(int irq, void *dev_id)
706 * had to poll every port to see if that port needed servicing. 706 * had to poll every port to see if that port needed servicing.
707 */ 707 */
708static void 708static void
709do_softint(void *private_) 709do_softint(struct work_struct *ugly_api)
710{ 710{
711 struct cyclades_port *info = (struct cyclades_port *) private_; 711 struct cyclades_port *info = container_of(ugly_api, struct cyclades_port, tqueue);
712 struct tty_struct *tty; 712 struct tty_struct *tty;
713 713
714 tty = info->tty; 714 tty = info->tty;
@@ -2273,7 +2273,7 @@ scrn[1] = '\0';
2273 info->blocked_open = 0; 2273 info->blocked_open = 0;
2274 info->default_threshold = 0; 2274 info->default_threshold = 0;
2275 info->default_timeout = 0; 2275 info->default_timeout = 0;
2276 INIT_WORK(&info->tqueue, do_softint, info); 2276 INIT_WORK(&info->tqueue, do_softint);
2277 init_waitqueue_head(&info->open_wait); 2277 init_waitqueue_head(&info->open_wait);
2278 init_waitqueue_head(&info->close_wait); 2278 init_waitqueue_head(&info->close_wait);
2279 /* info->session */ 2279 /* info->session */
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index c084149153de..fc87070f1866 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -765,7 +765,7 @@ static void sonypi_setbluetoothpower(u8 state)
765 sonypi_device.bluetooth_power = state; 765 sonypi_device.bluetooth_power = state;
766} 766}
767 767
768static void input_keyrelease(void *data) 768static void input_keyrelease(struct work_struct *work)
769{ 769{
770 struct sonypi_keypress kp; 770 struct sonypi_keypress kp;
771 771
@@ -1412,7 +1412,7 @@ static int __devinit sonypi_probe(struct platform_device *dev)
1412 goto err_inpdev_unregister; 1412 goto err_inpdev_unregister;
1413 } 1413 }
1414 1414
1415 INIT_WORK(&sonypi_device.input_work, input_keyrelease, NULL); 1415 INIT_WORK(&sonypi_device.input_work, input_keyrelease);
1416 } 1416 }
1417 1417
1418 sonypi_enable(0); 1418 sonypi_enable(0);
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index 7e1bd9562c2a..99137ab66b62 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -2261,9 +2261,10 @@ static void sx_start(struct tty_struct * tty)
2261 * do_sx_hangup() -> tty->hangup() -> sx_hangup() 2261 * do_sx_hangup() -> tty->hangup() -> sx_hangup()
2262 * 2262 *
2263 */ 2263 */
2264static void do_sx_hangup(void *private_) 2264static void do_sx_hangup(struct work_struct *work)
2265{ 2265{
2266 struct specialix_port *port = (struct specialix_port *) private_; 2266 struct specialix_port *port =
2267 container_of(work, struct specialix_port, tqueue_hangup);
2267 struct tty_struct *tty; 2268 struct tty_struct *tty;
2268 2269
2269 func_enter(); 2270 func_enter();
@@ -2336,9 +2337,10 @@ static void sx_set_termios(struct tty_struct * tty, struct termios * old_termios
2336} 2337}
2337 2338
2338 2339
2339static void do_softint(void *private_) 2340static void do_softint(struct work_struct *work)
2340{ 2341{
2341 struct specialix_port *port = (struct specialix_port *) private_; 2342 struct specialix_port *port =
2343 container_of(work, struct specialix_port, tqueue);
2342 struct tty_struct *tty; 2344 struct tty_struct *tty;
2343 2345
2344 func_enter(); 2346 func_enter();
@@ -2411,8 +2413,8 @@ static int sx_init_drivers(void)
2411 memset(sx_port, 0, sizeof(sx_port)); 2413 memset(sx_port, 0, sizeof(sx_port));
2412 for (i = 0; i < SX_NPORT * SX_NBOARD; i++) { 2414 for (i = 0; i < SX_NPORT * SX_NBOARD; i++) {
2413 sx_port[i].magic = SPECIALIX_MAGIC; 2415 sx_port[i].magic = SPECIALIX_MAGIC;
2414 INIT_WORK(&sx_port[i].tqueue, do_softint, &sx_port[i]); 2416 INIT_WORK(&sx_port[i].tqueue, do_softint);
2415 INIT_WORK(&sx_port[i].tqueue_hangup, do_sx_hangup, &sx_port[i]); 2417 INIT_WORK(&sx_port[i].tqueue_hangup, do_sx_hangup);
2416 sx_port[i].close_delay = 50 * HZ/100; 2418 sx_port[i].close_delay = 50 * HZ/100;
2417 sx_port[i].closing_wait = 3000 * HZ/100; 2419 sx_port[i].closing_wait = 3000 * HZ/100;
2418 init_waitqueue_head(&sx_port[i].open_wait); 2420 init_waitqueue_head(&sx_port[i].open_wait);
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 522e88e395cc..5e2de62bce70 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -500,7 +500,7 @@ static int stl_echatintr(stlbrd_t *brdp);
500static int stl_echmcaintr(stlbrd_t *brdp); 500static int stl_echmcaintr(stlbrd_t *brdp);
501static int stl_echpciintr(stlbrd_t *brdp); 501static int stl_echpciintr(stlbrd_t *brdp);
502static int stl_echpci64intr(stlbrd_t *brdp); 502static int stl_echpci64intr(stlbrd_t *brdp);
503static void stl_offintr(void *private); 503static void stl_offintr(struct work_struct *);
504static stlbrd_t *stl_allocbrd(void); 504static stlbrd_t *stl_allocbrd(void);
505static stlport_t *stl_getport(int brdnr, int panelnr, int portnr); 505static stlport_t *stl_getport(int brdnr, int panelnr, int portnr);
506 506
@@ -2081,14 +2081,12 @@ static int stl_echpci64intr(stlbrd_t *brdp)
2081/* 2081/*
2082 * Service an off-level request for some channel. 2082 * Service an off-level request for some channel.
2083 */ 2083 */
2084static void stl_offintr(void *private) 2084static void stl_offintr(struct work_struct *work)
2085{ 2085{
2086 stlport_t *portp; 2086 stlport_t *portp = container_of(work, stlport_t, tqueue);
2087 struct tty_struct *tty; 2087 struct tty_struct *tty;
2088 unsigned int oldsigs; 2088 unsigned int oldsigs;
2089 2089
2090 portp = private;
2091
2092#ifdef DEBUG 2090#ifdef DEBUG
2093 printk("stl_offintr(portp=%x)\n", (int) portp); 2091 printk("stl_offintr(portp=%x)\n", (int) portp);
2094#endif 2092#endif
@@ -2156,7 +2154,7 @@ static int __init stl_initports(stlbrd_t *brdp, stlpanel_t *panelp)
2156 portp->baud_base = STL_BAUDBASE; 2154 portp->baud_base = STL_BAUDBASE;
2157 portp->close_delay = STL_CLOSEDELAY; 2155 portp->close_delay = STL_CLOSEDELAY;
2158 portp->closing_wait = 30 * HZ; 2156 portp->closing_wait = 30 * HZ;
2159 INIT_WORK(&portp->tqueue, stl_offintr, portp); 2157 INIT_WORK(&portp->tqueue, stl_offintr);
2160 init_waitqueue_head(&portp->open_wait); 2158 init_waitqueue_head(&portp->open_wait);
2161 init_waitqueue_head(&portp->close_wait); 2159 init_waitqueue_head(&portp->close_wait);
2162 portp->stats.brd = portp->brdnr; 2160 portp->stats.brd = portp->brdnr;
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index 06784adcc35c..645187b9141e 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -101,8 +101,10 @@
101#include <linux/hdlc.h> 101#include <linux/hdlc.h>
102#include <linux/dma-mapping.h> 102#include <linux/dma-mapping.h>
103 103
104#ifdef CONFIG_HDLC_MODULE 104#if defined(CONFIG_HDLC) || (defined(CONFIG_HDLC_MODULE) && defined(CONFIG_SYNCLINK_MODULE))
105#define CONFIG_HDLC 1 105#define SYNCLINK_GENERIC_HDLC 1
106#else
107#define SYNCLINK_GENERIC_HDLC 0
106#endif 108#endif
107 109
108#define GET_USER(error,value,addr) error = get_user(value,addr) 110#define GET_USER(error,value,addr) error = get_user(value,addr)
@@ -320,7 +322,7 @@ struct mgsl_struct {
320 int dosyncppp; 322 int dosyncppp;
321 spinlock_t netlock; 323 spinlock_t netlock;
322 324
323#ifdef CONFIG_HDLC 325#if SYNCLINK_GENERIC_HDLC
324 struct net_device *netdev; 326 struct net_device *netdev;
325#endif 327#endif
326}; 328};
@@ -728,7 +730,7 @@ static void usc_loopmode_send_done( struct mgsl_struct * info );
728 730
729static int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigned long arg); 731static int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigned long arg);
730 732
731#ifdef CONFIG_HDLC 733#if SYNCLINK_GENERIC_HDLC
732#define dev_to_port(D) (dev_to_hdlc(D)->priv) 734#define dev_to_port(D) (dev_to_hdlc(D)->priv)
733static void hdlcdev_tx_done(struct mgsl_struct *info); 735static void hdlcdev_tx_done(struct mgsl_struct *info);
734static void hdlcdev_rx(struct mgsl_struct *info, char *buf, int size); 736static void hdlcdev_rx(struct mgsl_struct *info, char *buf, int size);
@@ -802,7 +804,7 @@ static int save_tx_buffer_request(struct mgsl_struct *info,const char *Buffer, u
802/* 804/*
803 * Bottom half interrupt handlers 805 * Bottom half interrupt handlers
804 */ 806 */
805static void mgsl_bh_handler(void* Context); 807static void mgsl_bh_handler(struct work_struct *work);
806static void mgsl_bh_receive(struct mgsl_struct *info); 808static void mgsl_bh_receive(struct mgsl_struct *info);
807static void mgsl_bh_transmit(struct mgsl_struct *info); 809static void mgsl_bh_transmit(struct mgsl_struct *info);
808static void mgsl_bh_status(struct mgsl_struct *info); 810static void mgsl_bh_status(struct mgsl_struct *info);
@@ -1071,9 +1073,10 @@ static int mgsl_bh_action(struct mgsl_struct *info)
1071/* 1073/*
1072 * Perform bottom half processing of work items queued by ISR. 1074 * Perform bottom half processing of work items queued by ISR.
1073 */ 1075 */
1074static void mgsl_bh_handler(void* Context) 1076static void mgsl_bh_handler(struct work_struct *work)
1075{ 1077{
1076 struct mgsl_struct *info = (struct mgsl_struct*)Context; 1078 struct mgsl_struct *info =
1079 container_of(work, struct mgsl_struct, task);
1077 int action; 1080 int action;
1078 1081
1079 if (!info) 1082 if (!info)
@@ -1276,7 +1279,7 @@ static void mgsl_isr_transmit_status( struct mgsl_struct *info )
1276 info->drop_rts_on_tx_done = 0; 1279 info->drop_rts_on_tx_done = 0;
1277 } 1280 }
1278 1281
1279#ifdef CONFIG_HDLC 1282#if SYNCLINK_GENERIC_HDLC
1280 if (info->netcount) 1283 if (info->netcount)
1281 hdlcdev_tx_done(info); 1284 hdlcdev_tx_done(info);
1282 else 1285 else
@@ -1341,7 +1344,7 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )
1341 info->input_signal_events.dcd_up++; 1344 info->input_signal_events.dcd_up++;
1342 } else 1345 } else
1343 info->input_signal_events.dcd_down++; 1346 info->input_signal_events.dcd_down++;
1344#ifdef CONFIG_HDLC 1347#if SYNCLINK_GENERIC_HDLC
1345 if (info->netcount) { 1348 if (info->netcount) {
1346 if (status & MISCSTATUS_DCD) 1349 if (status & MISCSTATUS_DCD)
1347 netif_carrier_on(info->netdev); 1350 netif_carrier_on(info->netdev);
@@ -4312,7 +4315,7 @@ static void mgsl_add_device( struct mgsl_struct *info )
4312 info->max_frame_size ); 4315 info->max_frame_size );
4313 } 4316 }
4314 4317
4315#ifdef CONFIG_HDLC 4318#if SYNCLINK_GENERIC_HDLC
4316 hdlcdev_init(info); 4319 hdlcdev_init(info);
4317#endif 4320#endif
4318 4321
@@ -4337,7 +4340,7 @@ static struct mgsl_struct* mgsl_allocate_device(void)
4337 } else { 4340 } else {
4338 memset(info, 0, sizeof(struct mgsl_struct)); 4341 memset(info, 0, sizeof(struct mgsl_struct));
4339 info->magic = MGSL_MAGIC; 4342 info->magic = MGSL_MAGIC;
4340 INIT_WORK(&info->task, mgsl_bh_handler, info); 4343 INIT_WORK(&info->task, mgsl_bh_handler);
4341 info->max_frame_size = 4096; 4344 info->max_frame_size = 4096;
4342 info->close_delay = 5*HZ/10; 4345 info->close_delay = 5*HZ/10;
4343 info->closing_wait = 30*HZ; 4346 info->closing_wait = 30*HZ;
@@ -4470,7 +4473,7 @@ static void synclink_cleanup(void)
4470 4473
4471 info = mgsl_device_list; 4474 info = mgsl_device_list;
4472 while(info) { 4475 while(info) {
4473#ifdef CONFIG_HDLC 4476#if SYNCLINK_GENERIC_HDLC
4474 hdlcdev_exit(info); 4477 hdlcdev_exit(info);
4475#endif 4478#endif
4476 mgsl_release_resources(info); 4479 mgsl_release_resources(info);
@@ -6644,7 +6647,7 @@ static int mgsl_get_rx_frame(struct mgsl_struct *info)
6644 return_frame = 1; 6647 return_frame = 1;
6645 } 6648 }
6646 framesize = 0; 6649 framesize = 0;
6647#ifdef CONFIG_HDLC 6650#if SYNCLINK_GENERIC_HDLC
6648 { 6651 {
6649 struct net_device_stats *stats = hdlc_stats(info->netdev); 6652 struct net_device_stats *stats = hdlc_stats(info->netdev);
6650 stats->rx_errors++; 6653 stats->rx_errors++;
@@ -6720,7 +6723,7 @@ static int mgsl_get_rx_frame(struct mgsl_struct *info)
6720 *ptmp); 6723 *ptmp);
6721 } 6724 }
6722 6725
6723#ifdef CONFIG_HDLC 6726#if SYNCLINK_GENERIC_HDLC
6724 if (info->netcount) 6727 if (info->netcount)
6725 hdlcdev_rx(info,info->intermediate_rxbuffer,framesize); 6728 hdlcdev_rx(info,info->intermediate_rxbuffer,framesize);
6726 else 6729 else
@@ -7624,7 +7627,7 @@ static void mgsl_tx_timeout(unsigned long context)
7624 7627
7625 spin_unlock_irqrestore(&info->irq_spinlock,flags); 7628 spin_unlock_irqrestore(&info->irq_spinlock,flags);
7626 7629
7627#ifdef CONFIG_HDLC 7630#if SYNCLINK_GENERIC_HDLC
7628 if (info->netcount) 7631 if (info->netcount)
7629 hdlcdev_tx_done(info); 7632 hdlcdev_tx_done(info);
7630 else 7633 else
@@ -7700,7 +7703,7 @@ static int usc_loopmode_active( struct mgsl_struct * info)
7700 return usc_InReg( info, CCSR ) & BIT7 ? 1 : 0 ; 7703 return usc_InReg( info, CCSR ) & BIT7 ? 1 : 0 ;
7701} 7704}
7702 7705
7703#ifdef CONFIG_HDLC 7706#if SYNCLINK_GENERIC_HDLC
7704 7707
7705/** 7708/**
7706 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.) 7709 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index d4334c79f8d4..e4730a7312b5 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -83,8 +83,10 @@
83 83
84#include "linux/synclink.h" 84#include "linux/synclink.h"
85 85
86#ifdef CONFIG_HDLC_MODULE 86#if defined(CONFIG_HDLC) || (defined(CONFIG_HDLC_MODULE) && defined(CONFIG_SYNCLINK_GT_MODULE))
87#define CONFIG_HDLC 1 87#define SYNCLINK_GENERIC_HDLC 1
88#else
89#define SYNCLINK_GENERIC_HDLC 0
88#endif 90#endif
89 91
90/* 92/*
@@ -171,7 +173,7 @@ static void set_break(struct tty_struct *tty, int break_state);
171/* 173/*
172 * generic HDLC support and callbacks 174 * generic HDLC support and callbacks
173 */ 175 */
174#ifdef CONFIG_HDLC 176#if SYNCLINK_GENERIC_HDLC
175#define dev_to_port(D) (dev_to_hdlc(D)->priv) 177#define dev_to_port(D) (dev_to_hdlc(D)->priv)
176static void hdlcdev_tx_done(struct slgt_info *info); 178static void hdlcdev_tx_done(struct slgt_info *info);
177static void hdlcdev_rx(struct slgt_info *info, char *buf, int size); 179static void hdlcdev_rx(struct slgt_info *info, char *buf, int size);
@@ -359,7 +361,7 @@ struct slgt_info {
359 int netcount; 361 int netcount;
360 int dosyncppp; 362 int dosyncppp;
361 spinlock_t netlock; 363 spinlock_t netlock;
362#ifdef CONFIG_HDLC 364#if SYNCLINK_GENERIC_HDLC
363 struct net_device *netdev; 365 struct net_device *netdev;
364#endif 366#endif
365 367
@@ -485,7 +487,7 @@ static void enable_loopback(struct slgt_info *info);
485static void set_rate(struct slgt_info *info, u32 data_rate); 487static void set_rate(struct slgt_info *info, u32 data_rate);
486 488
487static int bh_action(struct slgt_info *info); 489static int bh_action(struct slgt_info *info);
488static void bh_handler(void* context); 490static void bh_handler(struct work_struct *work);
489static void bh_transmit(struct slgt_info *info); 491static void bh_transmit(struct slgt_info *info);
490static void isr_serial(struct slgt_info *info); 492static void isr_serial(struct slgt_info *info);
491static void isr_rdma(struct slgt_info *info); 493static void isr_rdma(struct slgt_info *info);
@@ -1354,7 +1356,7 @@ static void set_break(struct tty_struct *tty, int break_state)
1354 spin_unlock_irqrestore(&info->lock,flags); 1356 spin_unlock_irqrestore(&info->lock,flags);
1355} 1357}
1356 1358
1357#ifdef CONFIG_HDLC 1359#if SYNCLINK_GENERIC_HDLC
1358 1360
1359/** 1361/**
1360 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.) 1362 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
@@ -1878,9 +1880,9 @@ static int bh_action(struct slgt_info *info)
1878/* 1880/*
1879 * perform bottom half processing 1881 * perform bottom half processing
1880 */ 1882 */
1881static void bh_handler(void* context) 1883static void bh_handler(struct work_struct *work)
1882{ 1884{
1883 struct slgt_info *info = context; 1885 struct slgt_info *info = container_of(work, struct slgt_info, task);
1884 int action; 1886 int action;
1885 1887
1886 if (!info) 1888 if (!info)
@@ -2002,7 +2004,7 @@ static void dcd_change(struct slgt_info *info)
2002 } else { 2004 } else {
2003 info->input_signal_events.dcd_down++; 2005 info->input_signal_events.dcd_down++;
2004 } 2006 }
2005#ifdef CONFIG_HDLC 2007#if SYNCLINK_GENERIC_HDLC
2006 if (info->netcount) { 2008 if (info->netcount) {
2007 if (info->signals & SerialSignal_DCD) 2009 if (info->signals & SerialSignal_DCD)
2008 netif_carrier_on(info->netdev); 2010 netif_carrier_on(info->netdev);
@@ -2180,7 +2182,7 @@ static void isr_txeom(struct slgt_info *info, unsigned short status)
2180 set_signals(info); 2182 set_signals(info);
2181 } 2183 }
2182 2184
2183#ifdef CONFIG_HDLC 2185#if SYNCLINK_GENERIC_HDLC
2184 if (info->netcount) 2186 if (info->netcount)
2185 hdlcdev_tx_done(info); 2187 hdlcdev_tx_done(info);
2186 else 2188 else
@@ -3306,7 +3308,7 @@ static void add_device(struct slgt_info *info)
3306 devstr, info->device_name, info->phys_reg_addr, 3308 devstr, info->device_name, info->phys_reg_addr,
3307 info->irq_level, info->max_frame_size); 3309 info->irq_level, info->max_frame_size);
3308 3310
3309#ifdef CONFIG_HDLC 3311#if SYNCLINK_GENERIC_HDLC
3310 hdlcdev_init(info); 3312 hdlcdev_init(info);
3311#endif 3313#endif
3312} 3314}
@@ -3326,7 +3328,7 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev
3326 } else { 3328 } else {
3327 memset(info, 0, sizeof(struct slgt_info)); 3329 memset(info, 0, sizeof(struct slgt_info));
3328 info->magic = MGSL_MAGIC; 3330 info->magic = MGSL_MAGIC;
3329 INIT_WORK(&info->task, bh_handler, info); 3331 INIT_WORK(&info->task, bh_handler);
3330 info->max_frame_size = 4096; 3332 info->max_frame_size = 4096;
3331 info->raw_rx_size = DMABUFSIZE; 3333 info->raw_rx_size = DMABUFSIZE;
3332 info->close_delay = 5*HZ/10; 3334 info->close_delay = 5*HZ/10;
@@ -3488,7 +3490,7 @@ static void slgt_cleanup(void)
3488 /* release devices */ 3490 /* release devices */
3489 info = slgt_device_list; 3491 info = slgt_device_list;
3490 while(info) { 3492 while(info) {
3491#ifdef CONFIG_HDLC 3493#if SYNCLINK_GENERIC_HDLC
3492 hdlcdev_exit(info); 3494 hdlcdev_exit(info);
3493#endif 3495#endif
3494 free_dma_bufs(info); 3496 free_dma_bufs(info);
@@ -3522,6 +3524,7 @@ static int __init slgt_init(void)
3522 3524
3523 if (!slgt_device_list) { 3525 if (!slgt_device_list) {
3524 printk("%s no devices found\n",driver_name); 3526 printk("%s no devices found\n",driver_name);
3527 pci_unregister_driver(&pci_driver);
3525 return -ENODEV; 3528 return -ENODEV;
3526 } 3529 }
3527 3530
@@ -4433,7 +4436,7 @@ check_again:
4433 framesize = 0; 4436 framesize = 0;
4434 } 4437 }
4435 4438
4436#ifdef CONFIG_HDLC 4439#if SYNCLINK_GENERIC_HDLC
4437 if (framesize == 0) { 4440 if (framesize == 0) {
4438 struct net_device_stats *stats = hdlc_stats(info->netdev); 4441 struct net_device_stats *stats = hdlc_stats(info->netdev);
4439 stats->rx_errors++; 4442 stats->rx_errors++;
@@ -4476,7 +4479,7 @@ check_again:
4476 framesize++; 4479 framesize++;
4477 } 4480 }
4478 4481
4479#ifdef CONFIG_HDLC 4482#if SYNCLINK_GENERIC_HDLC
4480 if (info->netcount) 4483 if (info->netcount)
4481 hdlcdev_rx(info,info->tmp_rbuf, framesize); 4484 hdlcdev_rx(info,info->tmp_rbuf, framesize);
4482 else 4485 else
@@ -4779,7 +4782,7 @@ static void tx_timeout(unsigned long context)
4779 info->tx_count = 0; 4782 info->tx_count = 0;
4780 spin_unlock_irqrestore(&info->lock,flags); 4783 spin_unlock_irqrestore(&info->lock,flags);
4781 4784
4782#ifdef CONFIG_HDLC 4785#if SYNCLINK_GENERIC_HDLC
4783 if (info->netcount) 4786 if (info->netcount)
4784 hdlcdev_tx_done(info); 4787 hdlcdev_tx_done(info);
4785 else 4788 else
@@ -4799,6 +4802,6 @@ static void rx_timeout(unsigned long context)
4799 spin_lock_irqsave(&info->lock, flags); 4802 spin_lock_irqsave(&info->lock, flags);
4800 info->pending_bh |= BH_RECEIVE; 4803 info->pending_bh |= BH_RECEIVE;
4801 spin_unlock_irqrestore(&info->lock, flags); 4804 spin_unlock_irqrestore(&info->lock, flags);
4802 bh_handler(info); 4805 bh_handler(&info->task);
4803} 4806}
4804 4807
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index 3e932b681371..20a96ef250be 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -67,8 +67,10 @@
67#include <linux/workqueue.h> 67#include <linux/workqueue.h>
68#include <linux/hdlc.h> 68#include <linux/hdlc.h>
69 69
70#ifdef CONFIG_HDLC_MODULE 70#if defined(CONFIG_HDLC) || (defined(CONFIG_HDLC_MODULE) && defined(CONFIG_SYNCLINKMP_MODULE))
71#define CONFIG_HDLC 1 71#define SYNCLINK_GENERIC_HDLC 1
72#else
73#define SYNCLINK_GENERIC_HDLC 0
72#endif 74#endif
73 75
74#define GET_USER(error,value,addr) error = get_user(value,addr) 76#define GET_USER(error,value,addr) error = get_user(value,addr)
@@ -280,7 +282,7 @@ typedef struct _synclinkmp_info {
280 int dosyncppp; 282 int dosyncppp;
281 spinlock_t netlock; 283 spinlock_t netlock;
282 284
283#ifdef CONFIG_HDLC 285#if SYNCLINK_GENERIC_HDLC
284 struct net_device *netdev; 286 struct net_device *netdev;
285#endif 287#endif
286 288
@@ -536,7 +538,7 @@ static void throttle(struct tty_struct * tty);
536static void unthrottle(struct tty_struct * tty); 538static void unthrottle(struct tty_struct * tty);
537static void set_break(struct tty_struct *tty, int break_state); 539static void set_break(struct tty_struct *tty, int break_state);
538 540
539#ifdef CONFIG_HDLC 541#if SYNCLINK_GENERIC_HDLC
540#define dev_to_port(D) (dev_to_hdlc(D)->priv) 542#define dev_to_port(D) (dev_to_hdlc(D)->priv)
541static void hdlcdev_tx_done(SLMP_INFO *info); 543static void hdlcdev_tx_done(SLMP_INFO *info);
542static void hdlcdev_rx(SLMP_INFO *info, char *buf, int size); 544static void hdlcdev_rx(SLMP_INFO *info, char *buf, int size);
@@ -602,7 +604,7 @@ static void enable_loopback(SLMP_INFO *info, int enable);
602static void set_rate(SLMP_INFO *info, u32 data_rate); 604static void set_rate(SLMP_INFO *info, u32 data_rate);
603 605
604static int bh_action(SLMP_INFO *info); 606static int bh_action(SLMP_INFO *info);
605static void bh_handler(void* Context); 607static void bh_handler(struct work_struct *work);
606static void bh_receive(SLMP_INFO *info); 608static void bh_receive(SLMP_INFO *info);
607static void bh_transmit(SLMP_INFO *info); 609static void bh_transmit(SLMP_INFO *info);
608static void bh_status(SLMP_INFO *info); 610static void bh_status(SLMP_INFO *info);
@@ -1607,7 +1609,7 @@ static void set_break(struct tty_struct *tty, int break_state)
1607 spin_unlock_irqrestore(&info->lock,flags); 1609 spin_unlock_irqrestore(&info->lock,flags);
1608} 1610}
1609 1611
1610#ifdef CONFIG_HDLC 1612#if SYNCLINK_GENERIC_HDLC
1611 1613
1612/** 1614/**
1613 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.) 1615 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
@@ -2063,9 +2065,9 @@ int bh_action(SLMP_INFO *info)
2063 2065
2064/* Perform bottom half processing of work items queued by ISR. 2066/* Perform bottom half processing of work items queued by ISR.
2065 */ 2067 */
2066void bh_handler(void* Context) 2068void bh_handler(struct work_struct *work)
2067{ 2069{
2068 SLMP_INFO *info = (SLMP_INFO*)Context; 2070 SLMP_INFO *info = container_of(work, SLMP_INFO, task);
2069 int action; 2071 int action;
2070 2072
2071 if (!info) 2073 if (!info)
@@ -2339,7 +2341,7 @@ static void isr_txeom(SLMP_INFO * info, unsigned char status)
2339 set_signals(info); 2341 set_signals(info);
2340 } 2342 }
2341 2343
2342#ifdef CONFIG_HDLC 2344#if SYNCLINK_GENERIC_HDLC
2343 if (info->netcount) 2345 if (info->netcount)
2344 hdlcdev_tx_done(info); 2346 hdlcdev_tx_done(info);
2345 else 2347 else
@@ -2523,7 +2525,7 @@ void isr_io_pin( SLMP_INFO *info, u16 status )
2523 info->input_signal_events.dcd_up++; 2525 info->input_signal_events.dcd_up++;
2524 } else 2526 } else
2525 info->input_signal_events.dcd_down++; 2527 info->input_signal_events.dcd_down++;
2526#ifdef CONFIG_HDLC 2528#if SYNCLINK_GENERIC_HDLC
2527 if (info->netcount) { 2529 if (info->netcount) {
2528 if (status & SerialSignal_DCD) 2530 if (status & SerialSignal_DCD)
2529 netif_carrier_on(info->netdev); 2531 netif_carrier_on(info->netdev);
@@ -3783,7 +3785,7 @@ void add_device(SLMP_INFO *info)
3783 info->irq_level, 3785 info->irq_level,
3784 info->max_frame_size ); 3786 info->max_frame_size );
3785 3787
3786#ifdef CONFIG_HDLC 3788#if SYNCLINK_GENERIC_HDLC
3787 hdlcdev_init(info); 3789 hdlcdev_init(info);
3788#endif 3790#endif
3789} 3791}
@@ -3805,7 +3807,7 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev)
3805 } else { 3807 } else {
3806 memset(info, 0, sizeof(SLMP_INFO)); 3808 memset(info, 0, sizeof(SLMP_INFO));
3807 info->magic = MGSL_MAGIC; 3809 info->magic = MGSL_MAGIC;
3808 INIT_WORK(&info->task, bh_handler, info); 3810 INIT_WORK(&info->task, bh_handler);
3809 info->max_frame_size = 4096; 3811 info->max_frame_size = 4096;
3810 info->close_delay = 5*HZ/10; 3812 info->close_delay = 5*HZ/10;
3811 info->closing_wait = 30*HZ; 3813 info->closing_wait = 30*HZ;
@@ -3977,7 +3979,7 @@ static void synclinkmp_cleanup(void)
3977 /* release devices */ 3979 /* release devices */
3978 info = synclinkmp_device_list; 3980 info = synclinkmp_device_list;
3979 while(info) { 3981 while(info) {
3980#ifdef CONFIG_HDLC 3982#if SYNCLINK_GENERIC_HDLC
3981 hdlcdev_exit(info); 3983 hdlcdev_exit(info);
3982#endif 3984#endif
3983 free_dma_bufs(info); 3985 free_dma_bufs(info);
@@ -4979,7 +4981,7 @@ CheckAgain:
4979 info->icount.rxcrc++; 4981 info->icount.rxcrc++;
4980 4982
4981 framesize = 0; 4983 framesize = 0;
4982#ifdef CONFIG_HDLC 4984#if SYNCLINK_GENERIC_HDLC
4983 { 4985 {
4984 struct net_device_stats *stats = hdlc_stats(info->netdev); 4986 struct net_device_stats *stats = hdlc_stats(info->netdev);
4985 stats->rx_errors++; 4987 stats->rx_errors++;
@@ -5020,7 +5022,7 @@ CheckAgain:
5020 index = 0; 5022 index = 0;
5021 } 5023 }
5022 5024
5023#ifdef CONFIG_HDLC 5025#if SYNCLINK_GENERIC_HDLC
5024 if (info->netcount) 5026 if (info->netcount)
5025 hdlcdev_rx(info,info->tmp_rx_buf,framesize); 5027 hdlcdev_rx(info,info->tmp_rx_buf,framesize);
5026 else 5028 else
@@ -5531,7 +5533,7 @@ void tx_timeout(unsigned long context)
5531 5533
5532 spin_unlock_irqrestore(&info->lock,flags); 5534 spin_unlock_irqrestore(&info->lock,flags);
5533 5535
5534#ifdef CONFIG_HDLC 5536#if SYNCLINK_GENERIC_HDLC
5535 if (info->netcount) 5537 if (info->netcount)
5536 hdlcdev_tx_done(info); 5538 hdlcdev_tx_done(info);
5537 else 5539 else
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index 5f49280779fb..05810c8d20bc 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -182,6 +182,18 @@ static struct sysrq_key_op sysrq_showstate_op = {
182 .enable_mask = SYSRQ_ENABLE_DUMP, 182 .enable_mask = SYSRQ_ENABLE_DUMP,
183}; 183};
184 184
185static void sysrq_handle_showstate_blocked(int key, struct tty_struct *tty)
186{
187 show_state_filter(TASK_UNINTERRUPTIBLE);
188}
189static struct sysrq_key_op sysrq_showstate_blocked_op = {
190 .handler = sysrq_handle_showstate_blocked,
191 .help_msg = "showBlockedTasks",
192 .action_msg = "Show Blocked State",
193 .enable_mask = SYSRQ_ENABLE_DUMP,
194};
195
196
185static void sysrq_handle_showmem(int key, struct tty_struct *tty) 197static void sysrq_handle_showmem(int key, struct tty_struct *tty)
186{ 198{
187 show_mem(); 199 show_mem();
@@ -219,13 +231,13 @@ static struct sysrq_key_op sysrq_term_op = {
219 .enable_mask = SYSRQ_ENABLE_SIGNAL, 231 .enable_mask = SYSRQ_ENABLE_SIGNAL,
220}; 232};
221 233
222static void moom_callback(void *ignored) 234static void moom_callback(struct work_struct *ignored)
223{ 235{
224 out_of_memory(&NODE_DATA(0)->node_zonelists[ZONE_NORMAL], 236 out_of_memory(&NODE_DATA(0)->node_zonelists[ZONE_NORMAL],
225 GFP_KERNEL, 0); 237 GFP_KERNEL, 0);
226} 238}
227 239
228static DECLARE_WORK(moom_work, moom_callback, NULL); 240static DECLARE_WORK(moom_work, moom_callback);
229 241
230static void sysrq_handle_moom(int key, struct tty_struct *tty) 242static void sysrq_handle_moom(int key, struct tty_struct *tty)
231{ 243{
@@ -304,7 +316,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = {
304 /* May be assigned at init time by SMP VOYAGER */ 316 /* May be assigned at init time by SMP VOYAGER */
305 NULL, /* v */ 317 NULL, /* v */
306 NULL, /* w */ 318 NULL, /* w */
307 NULL, /* x */ 319 &sysrq_showstate_blocked_op, /* x */
308 NULL, /* y */ 320 NULL, /* y */
309 NULL /* z */ 321 NULL /* z */
310}; 322};
diff --git a/drivers/char/toshiba.c b/drivers/char/toshiba.c
index dd36fd04a842..07067c31c4ec 100644
--- a/drivers/char/toshiba.c
+++ b/drivers/char/toshiba.c
@@ -249,6 +249,7 @@ int tosh_smm(SMMRegisters *regs)
249 249
250 return eax; 250 return eax;
251} 251}
252EXPORT_SYMBOL(tosh_smm);
252 253
253 254
254static int tosh_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, 255static int tosh_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 6e1329d404d2..33e1f66e39cb 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -325,9 +325,9 @@ static void user_reader_timeout(unsigned long ptr)
325 schedule_work(&chip->work); 325 schedule_work(&chip->work);
326} 326}
327 327
328static void timeout_work(void *ptr) 328static void timeout_work(struct work_struct *work)
329{ 329{
330 struct tpm_chip *chip = ptr; 330 struct tpm_chip *chip = container_of(work, struct tpm_chip, work);
331 331
332 down(&chip->buffer_mutex); 332 down(&chip->buffer_mutex);
333 atomic_set(&chip->data_pending, 0); 333 atomic_set(&chip->data_pending, 0);
@@ -1105,7 +1105,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vend
1105 init_MUTEX(&chip->tpm_mutex); 1105 init_MUTEX(&chip->tpm_mutex);
1106 INIT_LIST_HEAD(&chip->list); 1106 INIT_LIST_HEAD(&chip->list);
1107 1107
1108 INIT_WORK(&chip->work, timeout_work, chip); 1108 INIT_WORK(&chip->work, timeout_work);
1109 1109
1110 init_timer(&chip->user_read_timer); 1110 init_timer(&chip->user_read_timer);
1111 chip->user_read_timer.function = user_reader_timeout; 1111 chip->user_read_timer.function = user_reader_timeout;
@@ -1155,6 +1155,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vend
1155 1155
1156 if (sysfs_create_group(&dev->kobj, chip->vendor.attr_group)) { 1156 if (sysfs_create_group(&dev->kobj, chip->vendor.attr_group)) {
1157 list_del(&chip->list); 1157 list_del(&chip->list);
1158 misc_deregister(&chip->vendor.miscdev);
1158 put_device(dev); 1159 put_device(dev);
1159 clear_bit(chip->dev_num, dev_mask); 1160 clear_bit(chip->dev_num, dev_mask);
1160 kfree(chip); 1161 kfree(chip);
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 50dc49205a23..b3cfc8bc613c 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1254,7 +1254,7 @@ EXPORT_SYMBOL_GPL(tty_ldisc_flush);
1254 1254
1255/** 1255/**
1256 * do_tty_hangup - actual handler for hangup events 1256 * do_tty_hangup - actual handler for hangup events
1257 * @data: tty device 1257 * @work: tty device
1258 * 1258 *
1259 * This can be called by the "eventd" kernel thread. That is process 1259 * This can be called by the "eventd" kernel thread. That is process
1260 * synchronous but doesn't hold any locks, so we need to make sure we 1260 * synchronous but doesn't hold any locks, so we need to make sure we
@@ -1274,9 +1274,10 @@ EXPORT_SYMBOL_GPL(tty_ldisc_flush);
1274 * tasklist_lock to walk task list for hangup event 1274 * tasklist_lock to walk task list for hangup event
1275 * 1275 *
1276 */ 1276 */
1277static void do_tty_hangup(void *data) 1277static void do_tty_hangup(struct work_struct *work)
1278{ 1278{
1279 struct tty_struct *tty = (struct tty_struct *) data; 1279 struct tty_struct *tty =
1280 container_of(work, struct tty_struct, hangup_work);
1280 struct file * cons_filp = NULL; 1281 struct file * cons_filp = NULL;
1281 struct file *filp, *f = NULL; 1282 struct file *filp, *f = NULL;
1282 struct task_struct *p; 1283 struct task_struct *p;
@@ -1433,7 +1434,7 @@ void tty_vhangup(struct tty_struct * tty)
1433 1434
1434 printk(KERN_DEBUG "%s vhangup...\n", tty_name(tty, buf)); 1435 printk(KERN_DEBUG "%s vhangup...\n", tty_name(tty, buf));
1435#endif 1436#endif
1436 do_tty_hangup((void *) tty); 1437 do_tty_hangup(&tty->hangup_work);
1437} 1438}
1438EXPORT_SYMBOL(tty_vhangup); 1439EXPORT_SYMBOL(tty_vhangup);
1439 1440
@@ -3304,12 +3305,13 @@ int tty_ioctl(struct inode * inode, struct file * file,
3304 * Nasty bug: do_SAK is being called in interrupt context. This can 3305 * Nasty bug: do_SAK is being called in interrupt context. This can
3305 * deadlock. We punt it up to process context. AKPM - 16Mar2001 3306 * deadlock. We punt it up to process context. AKPM - 16Mar2001
3306 */ 3307 */
3307static void __do_SAK(void *arg) 3308static void __do_SAK(struct work_struct *work)
3308{ 3309{
3310 struct tty_struct *tty =
3311 container_of(work, struct tty_struct, SAK_work);
3309#ifdef TTY_SOFT_SAK 3312#ifdef TTY_SOFT_SAK
3310 tty_hangup(tty); 3313 tty_hangup(tty);
3311#else 3314#else
3312 struct tty_struct *tty = arg;
3313 struct task_struct *g, *p; 3315 struct task_struct *g, *p;
3314 int session; 3316 int session;
3315 int i; 3317 int i;
@@ -3388,7 +3390,7 @@ void do_SAK(struct tty_struct *tty)
3388{ 3390{
3389 if (!tty) 3391 if (!tty)
3390 return; 3392 return;
3391 PREPARE_WORK(&tty->SAK_work, __do_SAK, tty); 3393 PREPARE_WORK(&tty->SAK_work, __do_SAK);
3392 schedule_work(&tty->SAK_work); 3394 schedule_work(&tty->SAK_work);
3393} 3395}
3394 3396
@@ -3396,7 +3398,7 @@ EXPORT_SYMBOL(do_SAK);
3396 3398
3397/** 3399/**
3398 * flush_to_ldisc 3400 * flush_to_ldisc
3399 * @private_: tty structure passed from work queue. 3401 * @work: tty structure passed from work queue.
3400 * 3402 *
3401 * This routine is called out of the software interrupt to flush data 3403 * This routine is called out of the software interrupt to flush data
3402 * from the buffer chain to the line discipline. 3404 * from the buffer chain to the line discipline.
@@ -3406,9 +3408,10 @@ EXPORT_SYMBOL(do_SAK);
3406 * receive_buf method is single threaded for each tty instance. 3408 * receive_buf method is single threaded for each tty instance.
3407 */ 3409 */
3408 3410
3409static void flush_to_ldisc(void *private_) 3411static void flush_to_ldisc(struct work_struct *work)
3410{ 3412{
3411 struct tty_struct *tty = (struct tty_struct *) private_; 3413 struct tty_struct *tty =
3414 container_of(work, struct tty_struct, buf.work.work);
3412 unsigned long flags; 3415 unsigned long flags;
3413 struct tty_ldisc *disc; 3416 struct tty_ldisc *disc;
3414 struct tty_buffer *tbuf, *head; 3417 struct tty_buffer *tbuf, *head;
@@ -3553,7 +3556,7 @@ void tty_flip_buffer_push(struct tty_struct *tty)
3553 spin_unlock_irqrestore(&tty->buf.lock, flags); 3556 spin_unlock_irqrestore(&tty->buf.lock, flags);
3554 3557
3555 if (tty->low_latency) 3558 if (tty->low_latency)
3556 flush_to_ldisc((void *) tty); 3559 flush_to_ldisc(&tty->buf.work.work);
3557 else 3560 else
3558 schedule_delayed_work(&tty->buf.work, 1); 3561 schedule_delayed_work(&tty->buf.work, 1);
3559} 3562}
@@ -3580,17 +3583,17 @@ static void initialize_tty_struct(struct tty_struct *tty)
3580 tty->overrun_time = jiffies; 3583 tty->overrun_time = jiffies;
3581 tty->buf.head = tty->buf.tail = NULL; 3584 tty->buf.head = tty->buf.tail = NULL;
3582 tty_buffer_init(tty); 3585 tty_buffer_init(tty);
3583 INIT_WORK(&tty->buf.work, flush_to_ldisc, tty); 3586 INIT_DELAYED_WORK(&tty->buf.work, flush_to_ldisc);
3584 init_MUTEX(&tty->buf.pty_sem); 3587 init_MUTEX(&tty->buf.pty_sem);
3585 mutex_init(&tty->termios_mutex); 3588 mutex_init(&tty->termios_mutex);
3586 init_waitqueue_head(&tty->write_wait); 3589 init_waitqueue_head(&tty->write_wait);
3587 init_waitqueue_head(&tty->read_wait); 3590 init_waitqueue_head(&tty->read_wait);
3588 INIT_WORK(&tty->hangup_work, do_tty_hangup, tty); 3591 INIT_WORK(&tty->hangup_work, do_tty_hangup);
3589 mutex_init(&tty->atomic_read_lock); 3592 mutex_init(&tty->atomic_read_lock);
3590 mutex_init(&tty->atomic_write_lock); 3593 mutex_init(&tty->atomic_write_lock);
3591 spin_lock_init(&tty->read_lock); 3594 spin_lock_init(&tty->read_lock);
3592 INIT_LIST_HEAD(&tty->tty_files); 3595 INIT_LIST_HEAD(&tty->tty_files);
3593 INIT_WORK(&tty->SAK_work, NULL, NULL); 3596 INIT_WORK(&tty->SAK_work, NULL);
3594} 3597}
3595 3598
3596/* 3599/*
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 87587b4385ab..a8239dac994f 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -152,10 +152,10 @@ static void gotoxy(struct vc_data *vc, int new_x, int new_y);
152static void save_cur(struct vc_data *vc); 152static void save_cur(struct vc_data *vc);
153static void reset_terminal(struct vc_data *vc, int do_clear); 153static void reset_terminal(struct vc_data *vc, int do_clear);
154static void con_flush_chars(struct tty_struct *tty); 154static void con_flush_chars(struct tty_struct *tty);
155static void set_vesa_blanking(char __user *p); 155static int set_vesa_blanking(char __user *p);
156static void set_cursor(struct vc_data *vc); 156static void set_cursor(struct vc_data *vc);
157static void hide_cursor(struct vc_data *vc); 157static void hide_cursor(struct vc_data *vc);
158static void console_callback(void *ignored); 158static void console_callback(struct work_struct *ignored);
159static void blank_screen_t(unsigned long dummy); 159static void blank_screen_t(unsigned long dummy);
160static void set_palette(struct vc_data *vc); 160static void set_palette(struct vc_data *vc);
161 161
@@ -174,7 +174,7 @@ static int vesa_blank_mode; /* 0:none 1:suspendV 2:suspendH 3:powerdown */
174static int blankinterval = 10*60*HZ; 174static int blankinterval = 10*60*HZ;
175static int vesa_off_interval; 175static int vesa_off_interval;
176 176
177static DECLARE_WORK(console_work, console_callback, NULL); 177static DECLARE_WORK(console_work, console_callback);
178 178
179/* 179/*
180 * fg_console is the current virtual console, 180 * fg_console is the current virtual console,
@@ -2154,7 +2154,7 @@ out:
2154 * with other console code and prevention of re-entrancy is 2154 * with other console code and prevention of re-entrancy is
2155 * ensured with console_sem. 2155 * ensured with console_sem.
2156 */ 2156 */
2157static void console_callback(void *ignored) 2157static void console_callback(struct work_struct *ignored)
2158{ 2158{
2159 acquire_console_sem(); 2159 acquire_console_sem();
2160 2160
@@ -2369,7 +2369,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
2369 ret = __put_user(data, p); 2369 ret = __put_user(data, p);
2370 break; 2370 break;
2371 case TIOCL_SETVESABLANK: 2371 case TIOCL_SETVESABLANK:
2372 set_vesa_blanking(p); 2372 ret = set_vesa_blanking(p);
2373 break; 2373 break;
2374 case TIOCL_GETKMSGREDIRECT: 2374 case TIOCL_GETKMSGREDIRECT:
2375 data = kmsg_redirect; 2375 data = kmsg_redirect;
@@ -3313,11 +3313,15 @@ postcore_initcall(vtconsole_class_init);
3313 * Screen blanking 3313 * Screen blanking
3314 */ 3314 */
3315 3315
3316static void set_vesa_blanking(char __user *p) 3316static int set_vesa_blanking(char __user *p)
3317{ 3317{
3318 unsigned int mode; 3318 unsigned int mode;
3319 get_user(mode, p + 1); 3319
3320 vesa_blank_mode = (mode < 4) ? mode : 0; 3320 if (get_user(mode, p + 1))
3321 return -EFAULT;
3322
3323 vesa_blank_mode = (mode < 4) ? mode : 0;
3324 return 0;
3321} 3325}
3322 3326
3323void do_blank_screen(int entering_gfx) 3327void do_blank_screen(int entering_gfx)
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c
index e275dd4a705d..61138726b501 100644
--- a/drivers/char/watchdog/pcwd_usb.c
+++ b/drivers/char/watchdog/pcwd_usb.c
@@ -634,7 +634,7 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
634 usb_pcwd->intr_size = (le16_to_cpu(endpoint->wMaxPacketSize) > 8 ? le16_to_cpu(endpoint->wMaxPacketSize) : 8); 634 usb_pcwd->intr_size = (le16_to_cpu(endpoint->wMaxPacketSize) > 8 ? le16_to_cpu(endpoint->wMaxPacketSize) : 8);
635 635
636 /* set up the memory buffer's */ 636 /* set up the memory buffer's */
637 if (!(usb_pcwd->intr_buffer = usb_buffer_alloc(udev, usb_pcwd->intr_size, SLAB_ATOMIC, &usb_pcwd->intr_dma))) { 637 if (!(usb_pcwd->intr_buffer = usb_buffer_alloc(udev, usb_pcwd->intr_size, GFP_ATOMIC, &usb_pcwd->intr_dma))) {
638 printk(KERN_ERR PFX "Out of memory\n"); 638 printk(KERN_ERR PFX "Out of memory\n");
639 goto error; 639 goto error;
640 } 640 }
diff --git a/drivers/connector/cn_queue.c b/drivers/connector/cn_queue.c
index 05f8ce2cfb4a..b418b16e910e 100644
--- a/drivers/connector/cn_queue.c
+++ b/drivers/connector/cn_queue.c
@@ -31,9 +31,11 @@
31#include <linux/connector.h> 31#include <linux/connector.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33 33
34void cn_queue_wrapper(void *data) 34void cn_queue_wrapper(struct work_struct *work)
35{ 35{
36 struct cn_callback_data *d = data; 36 struct cn_callback_entry *cbq =
37 container_of(work, struct cn_callback_entry, work.work);
38 struct cn_callback_data *d = &cbq->data;
37 39
38 d->callback(d->callback_priv); 40 d->callback(d->callback_priv);
39 41
@@ -57,7 +59,7 @@ static struct cn_callback_entry *cn_queue_alloc_callback_entry(char *name, struc
57 memcpy(&cbq->id.id, id, sizeof(struct cb_id)); 59 memcpy(&cbq->id.id, id, sizeof(struct cb_id));
58 cbq->data.callback = callback; 60 cbq->data.callback = callback;
59 61
60 INIT_WORK(&cbq->work, &cn_queue_wrapper, &cbq->data); 62 INIT_DELAYED_WORK(&cbq->work, &cn_queue_wrapper);
61 return cbq; 63 return cbq;
62} 64}
63 65
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index b49bacfd8de8..5e7cd45d10ee 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -135,40 +135,39 @@ static int cn_call_callback(struct cn_msg *msg, void (*destruct_data)(void *), v
135 spin_lock_bh(&dev->cbdev->queue_lock); 135 spin_lock_bh(&dev->cbdev->queue_lock);
136 list_for_each_entry(__cbq, &dev->cbdev->queue_list, callback_entry) { 136 list_for_each_entry(__cbq, &dev->cbdev->queue_list, callback_entry) {
137 if (cn_cb_equal(&__cbq->id.id, &msg->id)) { 137 if (cn_cb_equal(&__cbq->id.id, &msg->id)) {
138 if (likely(!test_bit(0, &__cbq->work.pending) && 138 if (likely(!test_bit(WORK_STRUCT_PENDING,
139 &__cbq->work.work.management) &&
139 __cbq->data.ddata == NULL)) { 140 __cbq->data.ddata == NULL)) {
140 __cbq->data.callback_priv = msg; 141 __cbq->data.callback_priv = msg;
141 142
142 __cbq->data.ddata = data; 143 __cbq->data.ddata = data;
143 __cbq->data.destruct_data = destruct_data; 144 __cbq->data.destruct_data = destruct_data;
144 145
145 if (queue_work(dev->cbdev->cn_queue, 146 if (queue_delayed_work(
146 &__cbq->work)) 147 dev->cbdev->cn_queue,
148 &__cbq->work, 0))
147 err = 0; 149 err = 0;
148 } else { 150 } else {
149 struct work_struct *w;
150 struct cn_callback_data *d; 151 struct cn_callback_data *d;
151 152
152 w = kzalloc(sizeof(*w) + sizeof(*d), GFP_ATOMIC); 153 __cbq = kzalloc(sizeof(*__cbq), GFP_ATOMIC);
153 if (w) { 154 if (__cbq) {
154 d = (struct cn_callback_data *)(w+1); 155 d = &__cbq->data;
155
156 d->callback_priv = msg; 156 d->callback_priv = msg;
157 d->callback = __cbq->data.callback; 157 d->callback = __cbq->data.callback;
158 d->ddata = data; 158 d->ddata = data;
159 d->destruct_data = destruct_data; 159 d->destruct_data = destruct_data;
160 d->free = w; 160 d->free = __cbq;
161 161
162 INIT_LIST_HEAD(&w->entry); 162 INIT_DELAYED_WORK(&__cbq->work,
163 w->pending = 0; 163 &cn_queue_wrapper);
164 w->func = &cn_queue_wrapper;
165 w->data = d;
166 init_timer(&w->timer);
167 164
168 if (queue_work(dev->cbdev->cn_queue, w)) 165 if (queue_delayed_work(
166 dev->cbdev->cn_queue,
167 &__cbq->work, 0))
169 err = 0; 168 err = 0;
170 else { 169 else {
171 kfree(w); 170 kfree(__cbq);
172 err = -EINVAL; 171 err = -EINVAL;
173 } 172 }
174 } else 173 } else
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index dd0c2623e27b..47ab42db122a 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -42,7 +42,7 @@ static DEFINE_SPINLOCK(cpufreq_driver_lock);
42 42
43/* internal prototypes */ 43/* internal prototypes */
44static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event); 44static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event);
45static void handle_update(void *data); 45static void handle_update(struct work_struct *work);
46 46
47/** 47/**
48 * Two notifier lists: the "policy" list is involved in the 48 * Two notifier lists: the "policy" list is involved in the
@@ -665,7 +665,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
665 mutex_init(&policy->lock); 665 mutex_init(&policy->lock);
666 mutex_lock(&policy->lock); 666 mutex_lock(&policy->lock);
667 init_completion(&policy->kobj_unregister); 667 init_completion(&policy->kobj_unregister);
668 INIT_WORK(&policy->update, handle_update, (void *)(long)cpu); 668 INIT_WORK(&policy->update, handle_update);
669 669
670 /* call driver. From then on the cpufreq must be able 670 /* call driver. From then on the cpufreq must be able
671 * to accept all calls to ->verify and ->setpolicy for this CPU 671 * to accept all calls to ->verify and ->setpolicy for this CPU
@@ -895,9 +895,11 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev)
895} 895}
896 896
897 897
898static void handle_update(void *data) 898static void handle_update(struct work_struct *work)
899{ 899{
900 unsigned int cpu = (unsigned int)(long)data; 900 struct cpufreq_policy *policy =
901 container_of(work, struct cpufreq_policy, update);
902 unsigned int cpu = policy->cpu;
901 dprintk("handle_update for cpu %u called\n", cpu); 903 dprintk("handle_update for cpu %u called\n", cpu);
902 cpufreq_update_policy(cpu); 904 cpufreq_update_policy(cpu);
903} 905}
@@ -1535,7 +1537,6 @@ int cpufreq_update_policy(unsigned int cpu)
1535} 1537}
1536EXPORT_SYMBOL(cpufreq_update_policy); 1538EXPORT_SYMBOL(cpufreq_update_policy);
1537 1539
1538#ifdef CONFIG_HOTPLUG_CPU
1539static int cpufreq_cpu_callback(struct notifier_block *nfb, 1540static int cpufreq_cpu_callback(struct notifier_block *nfb,
1540 unsigned long action, void *hcpu) 1541 unsigned long action, void *hcpu)
1541{ 1542{
@@ -1575,7 +1576,6 @@ static struct notifier_block __cpuinitdata cpufreq_cpu_notifier =
1575{ 1576{
1576 .notifier_call = cpufreq_cpu_callback, 1577 .notifier_call = cpufreq_cpu_callback,
1577}; 1578};
1578#endif /* CONFIG_HOTPLUG_CPU */
1579 1579
1580/********************************************************************* 1580/*********************************************************************
1581 * REGISTER / UNREGISTER CPUFREQ DRIVER * 1581 * REGISTER / UNREGISTER CPUFREQ DRIVER *
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index c4c578defabf..5ef5ede5b884 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -59,7 +59,7 @@ static unsigned int def_sampling_rate;
59#define MAX_SAMPLING_DOWN_FACTOR (10) 59#define MAX_SAMPLING_DOWN_FACTOR (10)
60#define TRANSITION_LATENCY_LIMIT (10 * 1000) 60#define TRANSITION_LATENCY_LIMIT (10 * 1000)
61 61
62static void do_dbs_timer(void *data); 62static void do_dbs_timer(struct work_struct *work);
63 63
64struct cpu_dbs_info_s { 64struct cpu_dbs_info_s {
65 struct cpufreq_policy *cur_policy; 65 struct cpufreq_policy *cur_policy;
@@ -82,7 +82,7 @@ static unsigned int dbs_enable; /* number of CPUs using this policy */
82 * is recursive for the same process. -Venki 82 * is recursive for the same process. -Venki
83 */ 83 */
84static DEFINE_MUTEX (dbs_mutex); 84static DEFINE_MUTEX (dbs_mutex);
85static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); 85static DECLARE_DELAYED_WORK(dbs_work, do_dbs_timer);
86 86
87struct dbs_tuners { 87struct dbs_tuners {
88 unsigned int sampling_rate; 88 unsigned int sampling_rate;
@@ -420,7 +420,7 @@ static void dbs_check_cpu(int cpu)
420 } 420 }
421} 421}
422 422
423static void do_dbs_timer(void *data) 423static void do_dbs_timer(struct work_struct *work)
424{ 424{
425 int i; 425 int i;
426 lock_cpu_hotplug(); 426 lock_cpu_hotplug();
@@ -435,7 +435,6 @@ static void do_dbs_timer(void *data)
435 435
436static inline void dbs_timer_init(void) 436static inline void dbs_timer_init(void)
437{ 437{
438 INIT_WORK(&dbs_work, do_dbs_timer, NULL);
439 schedule_delayed_work(&dbs_work, 438 schedule_delayed_work(&dbs_work,
440 usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); 439 usecs_to_jiffies(dbs_tuners_ins.sampling_rate));
441 return; 440 return;
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index bf8aa45d4f01..e1cc5113c2ae 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -47,13 +47,17 @@ static unsigned int def_sampling_rate;
47#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) 47#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000)
48#define TRANSITION_LATENCY_LIMIT (10 * 1000) 48#define TRANSITION_LATENCY_LIMIT (10 * 1000)
49 49
50static void do_dbs_timer(void *data); 50static void do_dbs_timer(struct work_struct *work);
51
52/* Sampling types */
53enum dbs_sample {DBS_NORMAL_SAMPLE, DBS_SUB_SAMPLE};
51 54
52struct cpu_dbs_info_s { 55struct cpu_dbs_info_s {
53 cputime64_t prev_cpu_idle; 56 cputime64_t prev_cpu_idle;
54 cputime64_t prev_cpu_wall; 57 cputime64_t prev_cpu_wall;
55 struct cpufreq_policy *cur_policy; 58 struct cpufreq_policy *cur_policy;
56 struct work_struct work; 59 struct delayed_work work;
60 enum dbs_sample sample_type;
57 unsigned int enable; 61 unsigned int enable;
58 struct cpufreq_frequency_table *freq_table; 62 struct cpufreq_frequency_table *freq_table;
59 unsigned int freq_lo; 63 unsigned int freq_lo;
@@ -407,30 +411,31 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
407 } 411 }
408} 412}
409 413
410/* Sampling types */ 414static void do_dbs_timer(struct work_struct *work)
411enum {DBS_NORMAL_SAMPLE, DBS_SUB_SAMPLE};
412
413static void do_dbs_timer(void *data)
414{ 415{
415 unsigned int cpu = smp_processor_id(); 416 unsigned int cpu = smp_processor_id();
416 struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu); 417 struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu);
418 enum dbs_sample sample_type = dbs_info->sample_type;
417 /* We want all CPUs to do sampling nearly on same jiffy */ 419 /* We want all CPUs to do sampling nearly on same jiffy */
418 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate); 420 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate);
421
422 /* Permit rescheduling of this work item */
423 work_release(work);
424
419 delay -= jiffies % delay; 425 delay -= jiffies % delay;
420 426
421 if (!dbs_info->enable) 427 if (!dbs_info->enable)
422 return; 428 return;
423 /* Common NORMAL_SAMPLE setup */ 429 /* Common NORMAL_SAMPLE setup */
424 INIT_WORK(&dbs_info->work, do_dbs_timer, (void *)DBS_NORMAL_SAMPLE); 430 dbs_info->sample_type = DBS_NORMAL_SAMPLE;
425 if (!dbs_tuners_ins.powersave_bias || 431 if (!dbs_tuners_ins.powersave_bias ||
426 (unsigned long) data == DBS_NORMAL_SAMPLE) { 432 sample_type == DBS_NORMAL_SAMPLE) {
427 lock_cpu_hotplug(); 433 lock_cpu_hotplug();
428 dbs_check_cpu(dbs_info); 434 dbs_check_cpu(dbs_info);
429 unlock_cpu_hotplug(); 435 unlock_cpu_hotplug();
430 if (dbs_info->freq_lo) { 436 if (dbs_info->freq_lo) {
431 /* Setup timer for SUB_SAMPLE */ 437 /* Setup timer for SUB_SAMPLE */
432 INIT_WORK(&dbs_info->work, do_dbs_timer, 438 dbs_info->sample_type = DBS_SUB_SAMPLE;
433 (void *)DBS_SUB_SAMPLE);
434 delay = dbs_info->freq_hi_jiffies; 439 delay = dbs_info->freq_hi_jiffies;
435 } 440 }
436 } else { 441 } else {
@@ -449,7 +454,8 @@ static inline void dbs_timer_init(unsigned int cpu)
449 delay -= jiffies % delay; 454 delay -= jiffies % delay;
450 455
451 ondemand_powersave_bias_init(); 456 ondemand_powersave_bias_init();
452 INIT_WORK(&dbs_info->work, do_dbs_timer, NULL); 457 INIT_DELAYED_WORK_NAR(&dbs_info->work, do_dbs_timer);
458 dbs_info->sample_type = DBS_NORMAL_SAMPLE;
453 queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay); 459 queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay);
454} 460}
455 461
diff --git a/drivers/dma/ioatdma.c b/drivers/dma/ioatdma.c
index 0358419a0e48..8e8726104619 100644
--- a/drivers/dma/ioatdma.c
+++ b/drivers/dma/ioatdma.c
@@ -636,10 +636,10 @@ static int ioat_self_test(struct ioat_device *device)
636 dma_cookie_t cookie; 636 dma_cookie_t cookie;
637 int err = 0; 637 int err = 0;
638 638
639 src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, SLAB_KERNEL); 639 src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
640 if (!src) 640 if (!src)
641 return -ENOMEM; 641 return -ENOMEM;
642 dest = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, SLAB_KERNEL); 642 dest = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
643 if (!dest) { 643 if (!dest) {
644 kfree(src); 644 kfree(src);
645 return -ENOMEM; 645 return -ENOMEM;
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 75e9e38330ff..1b4fc9221803 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -28,6 +28,7 @@
28#include <linux/sysdev.h> 28#include <linux/sysdev.h>
29#include <linux/ctype.h> 29#include <linux/ctype.h>
30#include <linux/kthread.h> 30#include <linux/kthread.h>
31#include <linux/freezer.h>
31#include <asm/uaccess.h> 32#include <asm/uaccess.h>
32#include <asm/page.h> 33#include <asm/page.h>
33#include <asm/edac.h> 34#include <asm/edac.h>
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c
index 4630f1969a09..15edf40828b4 100644
--- a/drivers/i2c/chips/ds1374.c
+++ b/drivers/i2c/chips/ds1374.c
@@ -140,12 +140,14 @@ ulong ds1374_get_rtc_time(void)
140 return t1; 140 return t1;
141} 141}
142 142
143static void ds1374_set_work(void *arg) 143static ulong new_time;
144
145static void ds1374_set_work(struct work_struct *work)
144{ 146{
145 ulong t1, t2; 147 ulong t1, t2;
146 int limit = 10; /* arbitrary retry limit */ 148 int limit = 10; /* arbitrary retry limit */
147 149
148 t1 = *(ulong *) arg; 150 t1 = new_time;
149 151
150 mutex_lock(&ds1374_mutex); 152 mutex_lock(&ds1374_mutex);
151 153
@@ -167,11 +169,9 @@ static void ds1374_set_work(void *arg)
167 "can't confirm time set from rtc chip\n"); 169 "can't confirm time set from rtc chip\n");
168} 170}
169 171
170static ulong new_time;
171
172static struct workqueue_struct *ds1374_workqueue; 172static struct workqueue_struct *ds1374_workqueue;
173 173
174static DECLARE_WORK(ds1374_work, ds1374_set_work, &new_time); 174static DECLARE_WORK(ds1374_work, ds1374_set_work);
175 175
176int ds1374_set_rtc_time(ulong nowtime) 176int ds1374_set_rtc_time(ulong nowtime)
177{ 177{
@@ -180,7 +180,7 @@ int ds1374_set_rtc_time(ulong nowtime)
180 if (in_interrupt()) 180 if (in_interrupt())
181 queue_work(ds1374_workqueue, &ds1374_work); 181 queue_work(ds1374_workqueue, &ds1374_work);
182 else 182 else
183 ds1374_set_work(&new_time); 183 ds1374_set_work(NULL);
184 184
185 return 0; 185 return 0;
186} 186}
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c
index 2dd0a34d9472..420377c86422 100644
--- a/drivers/i2c/chips/m41t00.c
+++ b/drivers/i2c/chips/m41t00.c
@@ -215,8 +215,15 @@ m41t00_set(void *arg)
215} 215}
216 216
217static ulong new_time; 217static ulong new_time;
218/* well, isn't this API just _lovely_? */
219static void
220m41t00_barf(struct work_struct *unusable)
221{
222 m41t00_set(&new_time);
223}
224
218static struct workqueue_struct *m41t00_wq; 225static struct workqueue_struct *m41t00_wq;
219static DECLARE_WORK(m41t00_work, m41t00_set, &new_time); 226static DECLARE_WORK(m41t00_work, m41t00_barf);
220 227
221int 228int
222m41t00_set_rtc_time(ulong nowtime) 229m41t00_set_rtc_time(ulong nowtime)
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 0c68d0f0d8e5..e23bc0d62159 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -389,14 +389,6 @@ config BLK_DEV_RZ1000
389 Linux. This may slow disk throughput by a few percent, but at least 389 Linux. This may slow disk throughput by a few percent, but at least
390 things will operate 100% reliably. 390 things will operate 100% reliably.
391 391
392config BLK_DEV_SL82C105
393 tristate "Winbond SL82c105 support"
394 depends on PCI && (PPC || ARM) && BLK_DEV_IDEPCI
395 help
396 If you have a Winbond SL82c105 IDE controller, say Y here to enable
397 special configuration for this chip. This is common on various CHRP
398 motherboards, but could be used elsewhere. If in doubt, say Y.
399
400config BLK_DEV_IDEDMA_PCI 392config BLK_DEV_IDEDMA_PCI
401 bool "Generic PCI bus-master DMA support" 393 bool "Generic PCI bus-master DMA support"
402 depends on PCI && BLK_DEV_IDEPCI 394 depends on PCI && BLK_DEV_IDEPCI
@@ -712,6 +704,14 @@ config BLK_DEV_SIS5513
712 704
713 Please read the comments at the top of <file:drivers/ide/pci/sis5513.c>. 705 Please read the comments at the top of <file:drivers/ide/pci/sis5513.c>.
714 706
707config BLK_DEV_SL82C105
708 tristate "Winbond SL82c105 support"
709 depends on (PPC || ARM)
710 help
711 If you have a Winbond SL82c105 IDE controller, say Y here to enable
712 special configuration for this chip. This is common on various CHRP
713 motherboards, but could be used elsewhere. If in doubt, say Y.
714
715config BLK_DEV_SLC90E66 715config BLK_DEV_SLC90E66
716 tristate "SLC90E66 chipset support" 716 tristate "SLC90E66 chipset support"
717 help 717 help
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 287a66201150..16890769dca6 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -973,8 +973,8 @@ ide_settings_t *ide_find_setting_by_name (ide_drive_t *drive, char *name)
973 * @drive: drive 973 * @drive: drive
974 * 974 *
975 * Automatically remove all the driver specific settings for this 975 * Automatically remove all the driver specific settings for this
976 * drive. This function may sleep and must not be called from IRQ 976 * drive. This function may not be called from IRQ context. The
977 * context. The caller must hold ide_setting_sem. 977 * caller must hold ide_setting_sem.
978 */ 978 */
979 979
980static void auto_remove_settings (ide_drive_t *drive) 980static void auto_remove_settings (ide_drive_t *drive)
@@ -1874,11 +1874,22 @@ void ide_unregister_subdriver(ide_drive_t *drive, ide_driver_t *driver)
1874{ 1874{
1875 unsigned long flags; 1875 unsigned long flags;
1876 1876
1877 down(&ide_setting_sem);
1878 spin_lock_irqsave(&ide_lock, flags);
1879#ifdef CONFIG_PROC_FS 1877#ifdef CONFIG_PROC_FS
1880 ide_remove_proc_entries(drive->proc, driver->proc); 1878 ide_remove_proc_entries(drive->proc, driver->proc);
1881#endif 1879#endif
1880 down(&ide_setting_sem);
1881 spin_lock_irqsave(&ide_lock, flags);
1882 /*
1883 * ide_setting_sem protects the settings list
1884 * ide_lock protects the use of settings
1885 *
1886 * so we need to hold both, ide_settings_sem because we want to
1887 * modify the settings list, and ide_lock because we cannot take
1888 * a setting out that is being used.
1889 *
1890 * OTOH both ide_{read,write}_setting are only ever used under
1891 * ide_setting_sem.
1892 */
1882 auto_remove_settings(drive); 1893 auto_remove_settings(drive);
1883 spin_unlock_irqrestore(&ide_lock, flags); 1894 spin_unlock_irqrestore(&ide_lock, flags);
1884 up(&ide_setting_sem); 1895 up(&ide_setting_sem);
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
index eb7ab112c050..61f1a9665a7f 100644
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/pci/via82cxxx.c
@@ -282,11 +282,11 @@ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const
282 * Find the ISA bridge to see how good the IDE is. 282 * Find the ISA bridge to see how good the IDE is.
283 */ 283 */
284 via_config = via_config_find(&isa); 284 via_config = via_config_find(&isa);
285 if (!via_config->id) { 285
286 printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n"); 286 /* We checked this earlier so if it fails here deeep badness
287 pci_dev_put(isa); 287 is involved */
288 return -ENODEV; 288
289 } 289 BUG_ON(!via_config->id);
290 290
291 /* 291 /*
292 * Setup or disable Clk66 if appropriate 292 * Setup or disable Clk66 if appropriate
@@ -494,6 +494,17 @@ static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = {
494 494
495static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id) 495static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id)
496{ 496{
497 struct pci_dev *isa = NULL;
498 struct via_isa_bridge *via_config;
499 /*
500 * Find the ISA bridge and check we know what it is.
501 */
502 via_config = via_config_find(&isa);
503 pci_dev_put(isa);
504 if (!via_config->id) {
505 printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n");
506 return -ENODEV;
507 }
497 return ide_setup_pci_device(dev, &via82cxxx_chipsets[id->driver_data]); 508 return ide_setup_pci_device(dev, &via82cxxx_chipsets[id->driver_data]);
498} 509}
499 510
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
index 31e5cc49d61a..27d6c642415d 100644
--- a/drivers/ieee1394/eth1394.c
+++ b/drivers/ieee1394/eth1394.c
@@ -133,7 +133,7 @@ struct eth1394_node_info {
133#define ETH1394_DRIVER_NAME "eth1394" 133#define ETH1394_DRIVER_NAME "eth1394"
134static const char driver_name[] = ETH1394_DRIVER_NAME; 134static const char driver_name[] = ETH1394_DRIVER_NAME;
135 135
136static kmem_cache_t *packet_task_cache; 136static struct kmem_cache *packet_task_cache;
137 137
138static struct hpsb_highlevel eth1394_highlevel; 138static struct hpsb_highlevel eth1394_highlevel;
139 139
diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c
index d90a3a1898c0..b935e08695a9 100644
--- a/drivers/ieee1394/hosts.c
+++ b/drivers/ieee1394/hosts.c
@@ -31,9 +31,10 @@
31#include "config_roms.h" 31#include "config_roms.h"
32 32
33 33
34static void delayed_reset_bus(void * __reset_info) 34static void delayed_reset_bus(struct work_struct *work)
35{ 35{
36 struct hpsb_host *host = (struct hpsb_host*)__reset_info; 36 struct hpsb_host *host =
37 container_of(work, struct hpsb_host, delayed_reset.work);
37 int generation = host->csr.generation + 1; 38 int generation = host->csr.generation + 1;
38 39
39 /* The generation field rolls over to 2 rather than 0 per IEEE 40 /* The generation field rolls over to 2 rather than 0 per IEEE
@@ -122,7 +123,7 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
122 int i; 123 int i;
123 int hostnum = 0; 124 int hostnum = 0;
124 125
125 h = kzalloc(sizeof(*h) + extra, SLAB_KERNEL); 126 h = kzalloc(sizeof(*h) + extra, GFP_KERNEL);
126 if (!h) 127 if (!h)
127 return NULL; 128 return NULL;
128 129
@@ -145,7 +146,7 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
145 146
146 atomic_set(&h->generation, 0); 147 atomic_set(&h->generation, 0);
147 148
148 INIT_WORK(&h->delayed_reset, delayed_reset_bus, h); 149 INIT_DELAYED_WORK(&h->delayed_reset, delayed_reset_bus);
149 150
150 init_timer(&h->timeout); 151 init_timer(&h->timeout);
151 h->timeout.data = (unsigned long) h; 152 h->timeout.data = (unsigned long) h;
@@ -234,7 +235,7 @@ int hpsb_update_config_rom_image(struct hpsb_host *host)
234 * Config ROM in the near future. */ 235 * Config ROM in the near future. */
235 reset_delay = HZ; 236 reset_delay = HZ;
236 237
237 PREPARE_WORK(&host->delayed_reset, delayed_reset_bus, host); 238 PREPARE_DELAYED_WORK(&host->delayed_reset, delayed_reset_bus);
238 schedule_delayed_work(&host->delayed_reset, reset_delay); 239 schedule_delayed_work(&host->delayed_reset, reset_delay);
239 240
240 return 0; 241 return 0;
diff --git a/drivers/ieee1394/hosts.h b/drivers/ieee1394/hosts.h
index bc6dbfadb891..d553e38c9543 100644
--- a/drivers/ieee1394/hosts.h
+++ b/drivers/ieee1394/hosts.h
@@ -62,7 +62,7 @@ struct hpsb_host {
62 struct class_device class_dev; 62 struct class_device class_dev;
63 63
64 int update_config_rom; 64 int update_config_rom;
65 struct work_struct delayed_reset; 65 struct delayed_work delayed_reset;
66 unsigned int config_roms; 66 unsigned int config_roms;
67 67
68 struct list_head addr_space; 68 struct list_head addr_space;
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 8e7b83f84485..e829c9336b3c 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -15,6 +15,7 @@
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/kthread.h> 16#include <linux/kthread.h>
17#include <linux/moduleparam.h> 17#include <linux/moduleparam.h>
18#include <linux/freezer.h>
18#include <asm/atomic.h> 19#include <asm/atomic.h>
19 20
20#include "csr.h" 21#include "csr.h"
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
index 6e8ea9110c46..eae97d8dcf03 100644
--- a/drivers/ieee1394/ohci1394.c
+++ b/drivers/ieee1394/ohci1394.c
@@ -1225,7 +1225,7 @@ static int ohci_iso_recv_init(struct hpsb_iso *iso)
1225 int ctx; 1225 int ctx;
1226 int ret = -ENOMEM; 1226 int ret = -ENOMEM;
1227 1227
1228 recv = kmalloc(sizeof(*recv), SLAB_KERNEL); 1228 recv = kmalloc(sizeof(*recv), GFP_KERNEL);
1229 if (!recv) 1229 if (!recv)
1230 return -ENOMEM; 1230 return -ENOMEM;
1231 1231
@@ -1918,7 +1918,7 @@ static int ohci_iso_xmit_init(struct hpsb_iso *iso)
1918 int ctx; 1918 int ctx;
1919 int ret = -ENOMEM; 1919 int ret = -ENOMEM;
1920 1920
1921 xmit = kmalloc(sizeof(*xmit), SLAB_KERNEL); 1921 xmit = kmalloc(sizeof(*xmit), GFP_KERNEL);
1922 if (!xmit) 1922 if (!xmit)
1923 return -ENOMEM; 1923 return -ENOMEM;
1924 1924
@@ -3021,7 +3021,7 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
3021 return -ENOMEM; 3021 return -ENOMEM;
3022 } 3022 }
3023 3023
3024 d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, SLAB_KERNEL, d->prg_bus+i); 3024 d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, GFP_KERNEL, d->prg_bus+i);
3025 OHCI_DMA_ALLOC("pool dma_rcv prg[%d]", i); 3025 OHCI_DMA_ALLOC("pool dma_rcv prg[%d]", i);
3026 3026
3027 if (d->prg_cpu[i] != NULL) { 3027 if (d->prg_cpu[i] != NULL) {
@@ -3117,7 +3117,7 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d,
3117 OHCI_DMA_ALLOC("dma_rcv prg pool"); 3117 OHCI_DMA_ALLOC("dma_rcv prg pool");
3118 3118
3119 for (i = 0; i < d->num_desc; i++) { 3119 for (i = 0; i < d->num_desc; i++) {
3120 d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, SLAB_KERNEL, d->prg_bus+i); 3120 d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, GFP_KERNEL, d->prg_bus+i);
3121 OHCI_DMA_ALLOC("pool dma_trm prg[%d]", i); 3121 OHCI_DMA_ALLOC("pool dma_trm prg[%d]", i);
3122 3122
3123 if (d->prg_cpu[i] != NULL) { 3123 if (d->prg_cpu[i] != NULL) {
diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c
index 0a7412e27eb4..9cab1d661472 100644
--- a/drivers/ieee1394/pcilynx.c
+++ b/drivers/ieee1394/pcilynx.c
@@ -1428,7 +1428,7 @@ static int __devinit add_card(struct pci_dev *dev,
1428 struct i2c_algo_bit_data i2c_adapter_data; 1428 struct i2c_algo_bit_data i2c_adapter_data;
1429 1429
1430 error = -ENOMEM; 1430 error = -ENOMEM;
1431 i2c_ad = kmalloc(sizeof(*i2c_ad), SLAB_KERNEL); 1431 i2c_ad = kmalloc(sizeof(*i2c_ad), GFP_KERNEL);
1432 if (!i2c_ad) FAIL("failed to allocate I2C adapter memory"); 1432 if (!i2c_ad) FAIL("failed to allocate I2C adapter memory");
1433 1433
1434 memcpy(i2c_ad, &bit_ops, sizeof(struct i2c_adapter)); 1434 memcpy(i2c_ad, &bit_ops, sizeof(struct i2c_adapter));
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index 5ec4f5eb6b19..bf71e069eaf5 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -112,7 +112,7 @@ static struct pending_request *__alloc_pending_request(gfp_t flags)
112 112
113static inline struct pending_request *alloc_pending_request(void) 113static inline struct pending_request *alloc_pending_request(void)
114{ 114{
115 return __alloc_pending_request(SLAB_KERNEL); 115 return __alloc_pending_request(GFP_KERNEL);
116} 116}
117 117
118static void free_pending_request(struct pending_request *req) 118static void free_pending_request(struct pending_request *req)
@@ -259,7 +259,7 @@ static void host_reset(struct hpsb_host *host)
259 if (hi != NULL) { 259 if (hi != NULL) {
260 list_for_each_entry(fi, &hi->file_info_list, list) { 260 list_for_each_entry(fi, &hi->file_info_list, list) {
261 if (fi->notification == RAW1394_NOTIFY_ON) { 261 if (fi->notification == RAW1394_NOTIFY_ON) {
262 req = __alloc_pending_request(SLAB_ATOMIC); 262 req = __alloc_pending_request(GFP_ATOMIC);
263 263
264 if (req != NULL) { 264 if (req != NULL) {
265 req->file_info = fi; 265 req->file_info = fi;
@@ -306,13 +306,13 @@ static void iso_receive(struct hpsb_host *host, int channel, quadlet_t * data,
306 if (!(fi->listen_channels & (1ULL << channel))) 306 if (!(fi->listen_channels & (1ULL << channel)))
307 continue; 307 continue;
308 308
309 req = __alloc_pending_request(SLAB_ATOMIC); 309 req = __alloc_pending_request(GFP_ATOMIC);
310 if (!req) 310 if (!req)
311 break; 311 break;
312 312
313 if (!ibs) { 313 if (!ibs) {
314 ibs = kmalloc(sizeof(*ibs) + length, 314 ibs = kmalloc(sizeof(*ibs) + length,
315 SLAB_ATOMIC); 315 GFP_ATOMIC);
316 if (!ibs) { 316 if (!ibs) {
317 kfree(req); 317 kfree(req);
318 break; 318 break;
@@ -367,13 +367,13 @@ static void fcp_request(struct hpsb_host *host, int nodeid, int direction,
367 if (!fi->fcp_buffer) 367 if (!fi->fcp_buffer)
368 continue; 368 continue;
369 369
370 req = __alloc_pending_request(SLAB_ATOMIC); 370 req = __alloc_pending_request(GFP_ATOMIC);
371 if (!req) 371 if (!req)
372 break; 372 break;
373 373
374 if (!ibs) { 374 if (!ibs) {
375 ibs = kmalloc(sizeof(*ibs) + length, 375 ibs = kmalloc(sizeof(*ibs) + length,
376 SLAB_ATOMIC); 376 GFP_ATOMIC);
377 if (!ibs) { 377 if (!ibs) {
378 kfree(req); 378 kfree(req);
379 break; 379 break;
@@ -593,7 +593,7 @@ static int state_initialized(struct file_info *fi, struct pending_request *req)
593 switch (req->req.type) { 593 switch (req->req.type) {
594 case RAW1394_REQ_LIST_CARDS: 594 case RAW1394_REQ_LIST_CARDS:
595 spin_lock_irqsave(&host_info_lock, flags); 595 spin_lock_irqsave(&host_info_lock, flags);
596 khl = kmalloc(sizeof(*khl) * host_count, SLAB_ATOMIC); 596 khl = kmalloc(sizeof(*khl) * host_count, GFP_ATOMIC);
597 597
598 if (khl) { 598 if (khl) {
599 req->req.misc = host_count; 599 req->req.misc = host_count;
@@ -1045,7 +1045,7 @@ static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
1045 } 1045 }
1046 if (arm_addr->notification_options & ARM_READ) { 1046 if (arm_addr->notification_options & ARM_READ) {
1047 DBGMSG("arm_read -> entering notification-section"); 1047 DBGMSG("arm_read -> entering notification-section");
1048 req = __alloc_pending_request(SLAB_ATOMIC); 1048 req = __alloc_pending_request(GFP_ATOMIC);
1049 if (!req) { 1049 if (!req) {
1050 DBGMSG("arm_read -> rcode_conflict_error"); 1050 DBGMSG("arm_read -> rcode_conflict_error");
1051 spin_unlock_irqrestore(&host_info_lock, irqflags); 1051 spin_unlock_irqrestore(&host_info_lock, irqflags);
@@ -1064,7 +1064,7 @@ static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
1064 sizeof(struct arm_response) + 1064 sizeof(struct arm_response) +
1065 sizeof(struct arm_request_response); 1065 sizeof(struct arm_request_response);
1066 } 1066 }
1067 req->data = kmalloc(size, SLAB_ATOMIC); 1067 req->data = kmalloc(size, GFP_ATOMIC);
1068 if (!(req->data)) { 1068 if (!(req->data)) {
1069 free_pending_request(req); 1069 free_pending_request(req);
1070 DBGMSG("arm_read -> rcode_conflict_error"); 1070 DBGMSG("arm_read -> rcode_conflict_error");
@@ -1198,7 +1198,7 @@ static int arm_write(struct hpsb_host *host, int nodeid, int destid,
1198 } 1198 }
1199 if (arm_addr->notification_options & ARM_WRITE) { 1199 if (arm_addr->notification_options & ARM_WRITE) {
1200 DBGMSG("arm_write -> entering notification-section"); 1200 DBGMSG("arm_write -> entering notification-section");
1201 req = __alloc_pending_request(SLAB_ATOMIC); 1201 req = __alloc_pending_request(GFP_ATOMIC);
1202 if (!req) { 1202 if (!req) {
1203 DBGMSG("arm_write -> rcode_conflict_error"); 1203 DBGMSG("arm_write -> rcode_conflict_error");
1204 spin_unlock_irqrestore(&host_info_lock, irqflags); 1204 spin_unlock_irqrestore(&host_info_lock, irqflags);
@@ -1209,7 +1209,7 @@ static int arm_write(struct hpsb_host *host, int nodeid, int destid,
1209 sizeof(struct arm_request) + sizeof(struct arm_response) + 1209 sizeof(struct arm_request) + sizeof(struct arm_response) +
1210 (length) * sizeof(byte_t) + 1210 (length) * sizeof(byte_t) +
1211 sizeof(struct arm_request_response); 1211 sizeof(struct arm_request_response);
1212 req->data = kmalloc(size, SLAB_ATOMIC); 1212 req->data = kmalloc(size, GFP_ATOMIC);
1213 if (!(req->data)) { 1213 if (!(req->data)) {
1214 free_pending_request(req); 1214 free_pending_request(req);
1215 DBGMSG("arm_write -> rcode_conflict_error"); 1215 DBGMSG("arm_write -> rcode_conflict_error");
@@ -1400,7 +1400,7 @@ static int arm_lock(struct hpsb_host *host, int nodeid, quadlet_t * store,
1400 if (arm_addr->notification_options & ARM_LOCK) { 1400 if (arm_addr->notification_options & ARM_LOCK) {
1401 byte_t *buf1, *buf2; 1401 byte_t *buf1, *buf2;
1402 DBGMSG("arm_lock -> entering notification-section"); 1402 DBGMSG("arm_lock -> entering notification-section");
1403 req = __alloc_pending_request(SLAB_ATOMIC); 1403 req = __alloc_pending_request(GFP_ATOMIC);
1404 if (!req) { 1404 if (!req) {
1405 DBGMSG("arm_lock -> rcode_conflict_error"); 1405 DBGMSG("arm_lock -> rcode_conflict_error");
1406 spin_unlock_irqrestore(&host_info_lock, irqflags); 1406 spin_unlock_irqrestore(&host_info_lock, irqflags);
@@ -1408,7 +1408,7 @@ static int arm_lock(struct hpsb_host *host, int nodeid, quadlet_t * store,
1408 The request may be retried */ 1408 The request may be retried */
1409 } 1409 }
1410 size = sizeof(struct arm_request) + sizeof(struct arm_response) + 3 * sizeof(*store) + sizeof(struct arm_request_response); /* maximum */ 1410 size = sizeof(struct arm_request) + sizeof(struct arm_response) + 3 * sizeof(*store) + sizeof(struct arm_request_response); /* maximum */
1411 req->data = kmalloc(size, SLAB_ATOMIC); 1411 req->data = kmalloc(size, GFP_ATOMIC);
1412 if (!(req->data)) { 1412 if (!(req->data)) {
1413 free_pending_request(req); 1413 free_pending_request(req);
1414 DBGMSG("arm_lock -> rcode_conflict_error"); 1414 DBGMSG("arm_lock -> rcode_conflict_error");
@@ -1628,7 +1628,7 @@ static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store,
1628 if (arm_addr->notification_options & ARM_LOCK) { 1628 if (arm_addr->notification_options & ARM_LOCK) {
1629 byte_t *buf1, *buf2; 1629 byte_t *buf1, *buf2;
1630 DBGMSG("arm_lock64 -> entering notification-section"); 1630 DBGMSG("arm_lock64 -> entering notification-section");
1631 req = __alloc_pending_request(SLAB_ATOMIC); 1631 req = __alloc_pending_request(GFP_ATOMIC);
1632 if (!req) { 1632 if (!req) {
1633 spin_unlock_irqrestore(&host_info_lock, irqflags); 1633 spin_unlock_irqrestore(&host_info_lock, irqflags);
1634 DBGMSG("arm_lock64 -> rcode_conflict_error"); 1634 DBGMSG("arm_lock64 -> rcode_conflict_error");
@@ -1636,7 +1636,7 @@ static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store,
1636 The request may be retried */ 1636 The request may be retried */
1637 } 1637 }
1638 size = sizeof(struct arm_request) + sizeof(struct arm_response) + 3 * sizeof(*store) + sizeof(struct arm_request_response); /* maximum */ 1638 size = sizeof(struct arm_request) + sizeof(struct arm_response) + 3 * sizeof(*store) + sizeof(struct arm_request_response); /* maximum */
1639 req->data = kmalloc(size, SLAB_ATOMIC); 1639 req->data = kmalloc(size, GFP_ATOMIC);
1640 if (!(req->data)) { 1640 if (!(req->data)) {
1641 free_pending_request(req); 1641 free_pending_request(req);
1642 spin_unlock_irqrestore(&host_info_lock, irqflags); 1642 spin_unlock_irqrestore(&host_info_lock, irqflags);
@@ -1737,7 +1737,7 @@ static int arm_register(struct file_info *fi, struct pending_request *req)
1737 return (-EINVAL); 1737 return (-EINVAL);
1738 } 1738 }
1739 /* addr-list-entry for fileinfo */ 1739 /* addr-list-entry for fileinfo */
1740 addr = kmalloc(sizeof(*addr), SLAB_KERNEL); 1740 addr = kmalloc(sizeof(*addr), GFP_KERNEL);
1741 if (!addr) { 1741 if (!addr) {
1742 req->req.length = 0; 1742 req->req.length = 0;
1743 return (-ENOMEM); 1743 return (-ENOMEM);
@@ -2103,7 +2103,7 @@ static int write_phypacket(struct file_info *fi, struct pending_request *req)
2103static int get_config_rom(struct file_info *fi, struct pending_request *req) 2103static int get_config_rom(struct file_info *fi, struct pending_request *req)
2104{ 2104{
2105 int ret = sizeof(struct raw1394_request); 2105 int ret = sizeof(struct raw1394_request);
2106 quadlet_t *data = kmalloc(req->req.length, SLAB_KERNEL); 2106 quadlet_t *data = kmalloc(req->req.length, GFP_KERNEL);
2107 int status; 2107 int status;
2108 2108
2109 if (!data) 2109 if (!data)
@@ -2133,7 +2133,7 @@ static int get_config_rom(struct file_info *fi, struct pending_request *req)
2133static int update_config_rom(struct file_info *fi, struct pending_request *req) 2133static int update_config_rom(struct file_info *fi, struct pending_request *req)
2134{ 2134{
2135 int ret = sizeof(struct raw1394_request); 2135 int ret = sizeof(struct raw1394_request);
2136 quadlet_t *data = kmalloc(req->req.length, SLAB_KERNEL); 2136 quadlet_t *data = kmalloc(req->req.length, GFP_KERNEL);
2137 if (!data) 2137 if (!data)
2138 return -ENOMEM; 2138 return -ENOMEM;
2139 if (copy_from_user(data, int2ptr(req->req.sendb), req->req.length)) { 2139 if (copy_from_user(data, int2ptr(req->req.sendb), req->req.length)) {
@@ -2443,7 +2443,7 @@ static void queue_rawiso_event(struct file_info *fi)
2443 /* only one ISO activity event may be in the queue */ 2443 /* only one ISO activity event may be in the queue */
2444 if (!__rawiso_event_in_queue(fi)) { 2444 if (!__rawiso_event_in_queue(fi)) {
2445 struct pending_request *req = 2445 struct pending_request *req =
2446 __alloc_pending_request(SLAB_ATOMIC); 2446 __alloc_pending_request(GFP_ATOMIC);
2447 2447
2448 if (req) { 2448 if (req) {
2449 req->file_info = fi; 2449 req->file_info = fi;
@@ -2779,7 +2779,7 @@ static int raw1394_open(struct inode *inode, struct file *file)
2779{ 2779{
2780 struct file_info *fi; 2780 struct file_info *fi;
2781 2781
2782 fi = kzalloc(sizeof(*fi), SLAB_KERNEL); 2782 fi = kzalloc(sizeof(*fi), GFP_KERNEL);
2783 if (!fi) 2783 if (!fi)
2784 return -ENOMEM; 2784 return -ENOMEM;
2785 2785
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index 6986ac188281..cd156d4e779e 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -493,20 +493,25 @@ static void sbp2util_notify_fetch_agent(struct scsi_id_instance_data *scsi_id,
493 scsi_unblock_requests(scsi_id->scsi_host); 493 scsi_unblock_requests(scsi_id->scsi_host);
494} 494}
495 495
496static void sbp2util_write_orb_pointer(void *p) 496static void sbp2util_write_orb_pointer(struct work_struct *work)
497{ 497{
498 struct scsi_id_instance_data *scsi_id =
499 container_of(work, struct scsi_id_instance_data,
500 protocol_work.work);
498 quadlet_t data[2]; 501 quadlet_t data[2];
499 502
500 data[0] = ORB_SET_NODE_ID( 503 data[0] = ORB_SET_NODE_ID(scsi_id->hi->host->node_id);
501 ((struct scsi_id_instance_data *)p)->hi->host->node_id); 504 data[1] = scsi_id->last_orb_dma;
502 data[1] = ((struct scsi_id_instance_data *)p)->last_orb_dma;
503 sbp2util_cpu_to_be32_buffer(data, 8); 505 sbp2util_cpu_to_be32_buffer(data, 8);
504 sbp2util_notify_fetch_agent(p, SBP2_ORB_POINTER_OFFSET, data, 8); 506 sbp2util_notify_fetch_agent(scsi_id, SBP2_ORB_POINTER_OFFSET, data, 8);
505} 507}
506 508
507static void sbp2util_write_doorbell(void *p) 509static void sbp2util_write_doorbell(struct work_struct *work)
508{ 510{
509 sbp2util_notify_fetch_agent(p, SBP2_DOORBELL_OFFSET, NULL, 4); 511 struct scsi_id_instance_data *scsi_id =
512 container_of(work, struct scsi_id_instance_data,
513 protocol_work.work);
514 sbp2util_notify_fetch_agent(scsi_id, SBP2_DOORBELL_OFFSET, NULL, 4);
510} 515}
511 516
512/* 517/*
@@ -843,7 +848,7 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
843 INIT_LIST_HEAD(&scsi_id->scsi_list); 848 INIT_LIST_HEAD(&scsi_id->scsi_list);
844 spin_lock_init(&scsi_id->sbp2_command_orb_lock); 849 spin_lock_init(&scsi_id->sbp2_command_orb_lock);
845 atomic_set(&scsi_id->state, SBP2LU_STATE_RUNNING); 850 atomic_set(&scsi_id->state, SBP2LU_STATE_RUNNING);
846 INIT_WORK(&scsi_id->protocol_work, NULL, NULL); 851 INIT_DELAYED_WORK(&scsi_id->protocol_work, NULL);
847 852
848 ud->device.driver_data = scsi_id; 853 ud->device.driver_data = scsi_id;
849 854
@@ -2047,11 +2052,10 @@ static void sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
2047 * We do not accept new commands until the job is over. 2052 * We do not accept new commands until the job is over.
2048 */ 2053 */
2049 scsi_block_requests(scsi_id->scsi_host); 2054 scsi_block_requests(scsi_id->scsi_host);
2050 PREPARE_WORK(&scsi_id->protocol_work, 2055 PREPARE_DELAYED_WORK(&scsi_id->protocol_work,
2051 last_orb ? sbp2util_write_doorbell: 2056 last_orb ? sbp2util_write_doorbell:
2052 sbp2util_write_orb_pointer, 2057 sbp2util_write_orb_pointer);
2053 scsi_id); 2058 schedule_delayed_work(&scsi_id->protocol_work, 0);
2054 schedule_work(&scsi_id->protocol_work);
2055 } 2059 }
2056} 2060}
2057 2061
diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h
index abbe48e646c3..1b16d6b9cf11 100644
--- a/drivers/ieee1394/sbp2.h
+++ b/drivers/ieee1394/sbp2.h
@@ -348,7 +348,7 @@ struct scsi_id_instance_data {
348 unsigned workarounds; 348 unsigned workarounds;
349 349
350 atomic_t state; 350 atomic_t state;
351 struct work_struct protocol_work; 351 struct delayed_work protocol_work;
352}; 352};
353 353
354/* For use in scsi_id_instance_data.state */ 354/* For use in scsi_id_instance_data.state */
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 7767a11b6890..af939796750d 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -55,11 +55,11 @@ struct addr_req {
55 int status; 55 int status;
56}; 56};
57 57
58static void process_req(void *data); 58static void process_req(struct work_struct *work);
59 59
60static DEFINE_MUTEX(lock); 60static DEFINE_MUTEX(lock);
61static LIST_HEAD(req_list); 61static LIST_HEAD(req_list);
62static DECLARE_WORK(work, process_req, NULL); 62static DECLARE_DELAYED_WORK(work, process_req);
63static struct workqueue_struct *addr_wq; 63static struct workqueue_struct *addr_wq;
64 64
65void rdma_addr_register_client(struct rdma_addr_client *client) 65void rdma_addr_register_client(struct rdma_addr_client *client)
@@ -215,7 +215,7 @@ out:
215 return ret; 215 return ret;
216} 216}
217 217
218static void process_req(void *data) 218static void process_req(struct work_struct *work)
219{ 219{
220 struct addr_req *req, *temp_req; 220 struct addr_req *req, *temp_req;
221 struct sockaddr_in *src_in, *dst_in; 221 struct sockaddr_in *src_in, *dst_in;
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index 20e9f64e67a6..98272fbbfb31 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -285,9 +285,10 @@ err:
285 kfree(tprops); 285 kfree(tprops);
286} 286}
287 287
288static void ib_cache_task(void *work_ptr) 288static void ib_cache_task(struct work_struct *_work)
289{ 289{
290 struct ib_update_work *work = work_ptr; 290 struct ib_update_work *work =
291 container_of(_work, struct ib_update_work, work);
291 292
292 ib_cache_update(work->device, work->port_num); 293 ib_cache_update(work->device, work->port_num);
293 kfree(work); 294 kfree(work);
@@ -306,7 +307,7 @@ static void ib_cache_event(struct ib_event_handler *handler,
306 event->event == IB_EVENT_CLIENT_REREGISTER) { 307 event->event == IB_EVENT_CLIENT_REREGISTER) {
307 work = kmalloc(sizeof *work, GFP_ATOMIC); 308 work = kmalloc(sizeof *work, GFP_ATOMIC);
308 if (work) { 309 if (work) {
309 INIT_WORK(&work->work, ib_cache_task, work); 310 INIT_WORK(&work->work, ib_cache_task);
310 work->device = event->device; 311 work->device = event->device;
311 work->port_num = event->element.port_num; 312 work->port_num = event->element.port_num;
312 schedule_work(&work->work); 313 schedule_work(&work->work);
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index e5dc4530808a..79c937bf6962 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -101,7 +101,7 @@ struct cm_av {
101}; 101};
102 102
103struct cm_work { 103struct cm_work {
104 struct work_struct work; 104 struct delayed_work work;
105 struct list_head list; 105 struct list_head list;
106 struct cm_port *port; 106 struct cm_port *port;
107 struct ib_mad_recv_wc *mad_recv_wc; /* Received MADs */ 107 struct ib_mad_recv_wc *mad_recv_wc; /* Received MADs */
@@ -161,7 +161,7 @@ struct cm_id_private {
161 atomic_t work_count; 161 atomic_t work_count;
162}; 162};
163 163
164static void cm_work_handler(void *data); 164static void cm_work_handler(struct work_struct *work);
165 165
166static inline void cm_deref_id(struct cm_id_private *cm_id_priv) 166static inline void cm_deref_id(struct cm_id_private *cm_id_priv)
167{ 167{
@@ -668,8 +668,7 @@ static struct cm_timewait_info * cm_create_timewait_info(__be32 local_id)
668 return ERR_PTR(-ENOMEM); 668 return ERR_PTR(-ENOMEM);
669 669
670 timewait_info->work.local_id = local_id; 670 timewait_info->work.local_id = local_id;
671 INIT_WORK(&timewait_info->work.work, cm_work_handler, 671 INIT_DELAYED_WORK(&timewait_info->work.work, cm_work_handler);
672 &timewait_info->work);
673 timewait_info->work.cm_event.event = IB_CM_TIMEWAIT_EXIT; 672 timewait_info->work.cm_event.event = IB_CM_TIMEWAIT_EXIT;
674 return timewait_info; 673 return timewait_info;
675} 674}
@@ -2995,9 +2994,9 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
2995 } 2994 }
2996} 2995}
2997 2996
2998static void cm_work_handler(void *data) 2997static void cm_work_handler(struct work_struct *_work)
2999{ 2998{
3000 struct cm_work *work = data; 2999 struct cm_work *work = container_of(_work, struct cm_work, work.work);
3001 int ret; 3000 int ret;
3002 3001
3003 switch (work->cm_event.event) { 3002 switch (work->cm_event.event) {
@@ -3087,12 +3086,12 @@ static int cm_establish(struct ib_cm_id *cm_id)
3087 * we need to find the cm_id once we're in the context of the 3086 * we need to find the cm_id once we're in the context of the
3088 * worker thread, rather than holding a reference on it. 3087 * worker thread, rather than holding a reference on it.
3089 */ 3088 */
3090 INIT_WORK(&work->work, cm_work_handler, work); 3089 INIT_DELAYED_WORK(&work->work, cm_work_handler);
3091 work->local_id = cm_id->local_id; 3090 work->local_id = cm_id->local_id;
3092 work->remote_id = cm_id->remote_id; 3091 work->remote_id = cm_id->remote_id;
3093 work->mad_recv_wc = NULL; 3092 work->mad_recv_wc = NULL;
3094 work->cm_event.event = IB_CM_USER_ESTABLISHED; 3093 work->cm_event.event = IB_CM_USER_ESTABLISHED;
3095 queue_work(cm.wq, &work->work); 3094 queue_delayed_work(cm.wq, &work->work, 0);
3096out: 3095out:
3097 return ret; 3096 return ret;
3098} 3097}
@@ -3191,11 +3190,11 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
3191 return; 3190 return;
3192 } 3191 }
3193 3192
3194 INIT_WORK(&work->work, cm_work_handler, work); 3193 INIT_DELAYED_WORK(&work->work, cm_work_handler);
3195 work->cm_event.event = event; 3194 work->cm_event.event = event;
3196 work->mad_recv_wc = mad_recv_wc; 3195 work->mad_recv_wc = mad_recv_wc;
3197 work->port = (struct cm_port *)mad_agent->context; 3196 work->port = (struct cm_port *)mad_agent->context;
3198 queue_work(cm.wq, &work->work); 3197 queue_delayed_work(cm.wq, &work->work, 0);
3199} 3198}
3200 3199
3201static int cm_init_qp_init_attr(struct cm_id_private *cm_id_priv, 3200static int cm_init_qp_init_attr(struct cm_id_private *cm_id_priv,
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index cf48f2697434..985a6b564d8f 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1340,9 +1340,9 @@ static int cma_query_ib_route(struct rdma_id_private *id_priv, int timeout_ms,
1340 return (id_priv->query_id < 0) ? id_priv->query_id : 0; 1340 return (id_priv->query_id < 0) ? id_priv->query_id : 0;
1341} 1341}
1342 1342
1343static void cma_work_handler(void *data) 1343static void cma_work_handler(struct work_struct *_work)
1344{ 1344{
1345 struct cma_work *work = data; 1345 struct cma_work *work = container_of(_work, struct cma_work, work);
1346 struct rdma_id_private *id_priv = work->id; 1346 struct rdma_id_private *id_priv = work->id;
1347 int destroy = 0; 1347 int destroy = 0;
1348 1348
@@ -1373,7 +1373,7 @@ static int cma_resolve_ib_route(struct rdma_id_private *id_priv, int timeout_ms)
1373 return -ENOMEM; 1373 return -ENOMEM;
1374 1374
1375 work->id = id_priv; 1375 work->id = id_priv;
1376 INIT_WORK(&work->work, cma_work_handler, work); 1376 INIT_WORK(&work->work, cma_work_handler);
1377 work->old_state = CMA_ROUTE_QUERY; 1377 work->old_state = CMA_ROUTE_QUERY;
1378 work->new_state = CMA_ROUTE_RESOLVED; 1378 work->new_state = CMA_ROUTE_RESOLVED;
1379 work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED; 1379 work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
@@ -1430,7 +1430,7 @@ static int cma_resolve_iw_route(struct rdma_id_private *id_priv, int timeout_ms)
1430 return -ENOMEM; 1430 return -ENOMEM;
1431 1431
1432 work->id = id_priv; 1432 work->id = id_priv;
1433 INIT_WORK(&work->work, cma_work_handler, work); 1433 INIT_WORK(&work->work, cma_work_handler);
1434 work->old_state = CMA_ROUTE_QUERY; 1434 work->old_state = CMA_ROUTE_QUERY;
1435 work->new_state = CMA_ROUTE_RESOLVED; 1435 work->new_state = CMA_ROUTE_RESOLVED;
1436 work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED; 1436 work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
@@ -1583,7 +1583,7 @@ static int cma_resolve_loopback(struct rdma_id_private *id_priv)
1583 } 1583 }
1584 1584
1585 work->id = id_priv; 1585 work->id = id_priv;
1586 INIT_WORK(&work->work, cma_work_handler, work); 1586 INIT_WORK(&work->work, cma_work_handler);
1587 work->old_state = CMA_ADDR_QUERY; 1587 work->old_state = CMA_ADDR_QUERY;
1588 work->new_state = CMA_ADDR_RESOLVED; 1588 work->new_state = CMA_ADDR_RESOLVED;
1589 work->event.event = RDMA_CM_EVENT_ADDR_RESOLVED; 1589 work->event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
index cf797d7aea09..1039ad57d53b 100644
--- a/drivers/infiniband/core/iwcm.c
+++ b/drivers/infiniband/core/iwcm.c
@@ -828,9 +828,9 @@ static int process_event(struct iwcm_id_private *cm_id_priv,
828 * thread asleep on the destroy_comp list vs. an object destroyed 828 * thread asleep on the destroy_comp list vs. an object destroyed
829 * here synchronously when the last reference is removed. 829 * here synchronously when the last reference is removed.
830 */ 830 */
831static void cm_work_handler(void *arg) 831static void cm_work_handler(struct work_struct *_work)
832{ 832{
833 struct iwcm_work *work = arg; 833 struct iwcm_work *work = container_of(_work, struct iwcm_work, work);
834 struct iw_cm_event levent; 834 struct iw_cm_event levent;
835 struct iwcm_id_private *cm_id_priv = work->cm_id; 835 struct iwcm_id_private *cm_id_priv = work->cm_id;
836 unsigned long flags; 836 unsigned long flags;
@@ -900,7 +900,7 @@ static int cm_event_handler(struct iw_cm_id *cm_id,
900 goto out; 900 goto out;
901 } 901 }
902 902
903 INIT_WORK(&work->work, cm_work_handler, work); 903 INIT_WORK(&work->work, cm_work_handler);
904 work->cm_id = cm_id_priv; 904 work->cm_id = cm_id_priv;
905 work->event = *iw_event; 905 work->event = *iw_event;
906 906
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 3f9c16232c4d..15f38d94b3a8 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -65,8 +65,8 @@ static struct ib_mad_agent_private *find_mad_agent(
65static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info, 65static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
66 struct ib_mad_private *mad); 66 struct ib_mad_private *mad);
67static void cancel_mads(struct ib_mad_agent_private *mad_agent_priv); 67static void cancel_mads(struct ib_mad_agent_private *mad_agent_priv);
68static void timeout_sends(void *data); 68static void timeout_sends(struct work_struct *work);
69static void local_completions(void *data); 69static void local_completions(struct work_struct *work);
70static int add_nonoui_reg_req(struct ib_mad_reg_req *mad_reg_req, 70static int add_nonoui_reg_req(struct ib_mad_reg_req *mad_reg_req,
71 struct ib_mad_agent_private *agent_priv, 71 struct ib_mad_agent_private *agent_priv,
72 u8 mgmt_class); 72 u8 mgmt_class);
@@ -356,10 +356,9 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,
356 INIT_LIST_HEAD(&mad_agent_priv->wait_list); 356 INIT_LIST_HEAD(&mad_agent_priv->wait_list);
357 INIT_LIST_HEAD(&mad_agent_priv->done_list); 357 INIT_LIST_HEAD(&mad_agent_priv->done_list);
358 INIT_LIST_HEAD(&mad_agent_priv->rmpp_list); 358 INIT_LIST_HEAD(&mad_agent_priv->rmpp_list);
359 INIT_WORK(&mad_agent_priv->timed_work, timeout_sends, mad_agent_priv); 359 INIT_DELAYED_WORK(&mad_agent_priv->timed_work, timeout_sends);
360 INIT_LIST_HEAD(&mad_agent_priv->local_list); 360 INIT_LIST_HEAD(&mad_agent_priv->local_list);
361 INIT_WORK(&mad_agent_priv->local_work, local_completions, 361 INIT_WORK(&mad_agent_priv->local_work, local_completions);
362 mad_agent_priv);
363 atomic_set(&mad_agent_priv->refcount, 1); 362 atomic_set(&mad_agent_priv->refcount, 1);
364 init_completion(&mad_agent_priv->comp); 363 init_completion(&mad_agent_priv->comp);
365 364
@@ -2198,12 +2197,12 @@ static void mad_error_handler(struct ib_mad_port_private *port_priv,
2198/* 2197/*
2199 * IB MAD completion callback 2198 * IB MAD completion callback
2200 */ 2199 */
2201static void ib_mad_completion_handler(void *data) 2200static void ib_mad_completion_handler(struct work_struct *work)
2202{ 2201{
2203 struct ib_mad_port_private *port_priv; 2202 struct ib_mad_port_private *port_priv;
2204 struct ib_wc wc; 2203 struct ib_wc wc;
2205 2204
2206 port_priv = (struct ib_mad_port_private *)data; 2205 port_priv = container_of(work, struct ib_mad_port_private, work);
2207 ib_req_notify_cq(port_priv->cq, IB_CQ_NEXT_COMP); 2206 ib_req_notify_cq(port_priv->cq, IB_CQ_NEXT_COMP);
2208 2207
2209 while (ib_poll_cq(port_priv->cq, 1, &wc) == 1) { 2208 while (ib_poll_cq(port_priv->cq, 1, &wc) == 1) {
@@ -2324,7 +2323,7 @@ void ib_cancel_mad(struct ib_mad_agent *mad_agent,
2324} 2323}
2325EXPORT_SYMBOL(ib_cancel_mad); 2324EXPORT_SYMBOL(ib_cancel_mad);
2326 2325
2327static void local_completions(void *data) 2326static void local_completions(struct work_struct *work)
2328{ 2327{
2329 struct ib_mad_agent_private *mad_agent_priv; 2328 struct ib_mad_agent_private *mad_agent_priv;
2330 struct ib_mad_local_private *local; 2329 struct ib_mad_local_private *local;
@@ -2334,7 +2333,8 @@ static void local_completions(void *data)
2334 struct ib_wc wc; 2333 struct ib_wc wc;
2335 struct ib_mad_send_wc mad_send_wc; 2334 struct ib_mad_send_wc mad_send_wc;
2336 2335
2337 mad_agent_priv = (struct ib_mad_agent_private *)data; 2336 mad_agent_priv =
2337 container_of(work, struct ib_mad_agent_private, local_work);
2338 2338
2339 spin_lock_irqsave(&mad_agent_priv->lock, flags); 2339 spin_lock_irqsave(&mad_agent_priv->lock, flags);
2340 while (!list_empty(&mad_agent_priv->local_list)) { 2340 while (!list_empty(&mad_agent_priv->local_list)) {
@@ -2434,14 +2434,15 @@ static int retry_send(struct ib_mad_send_wr_private *mad_send_wr)
2434 return ret; 2434 return ret;
2435} 2435}
2436 2436
2437static void timeout_sends(void *data) 2437static void timeout_sends(struct work_struct *work)
2438{ 2438{
2439 struct ib_mad_agent_private *mad_agent_priv; 2439 struct ib_mad_agent_private *mad_agent_priv;
2440 struct ib_mad_send_wr_private *mad_send_wr; 2440 struct ib_mad_send_wr_private *mad_send_wr;
2441 struct ib_mad_send_wc mad_send_wc; 2441 struct ib_mad_send_wc mad_send_wc;
2442 unsigned long flags, delay; 2442 unsigned long flags, delay;
2443 2443
2444 mad_agent_priv = (struct ib_mad_agent_private *)data; 2444 mad_agent_priv = container_of(work, struct ib_mad_agent_private,
2445 timed_work.work);
2445 mad_send_wc.vendor_err = 0; 2446 mad_send_wc.vendor_err = 0;
2446 2447
2447 spin_lock_irqsave(&mad_agent_priv->lock, flags); 2448 spin_lock_irqsave(&mad_agent_priv->lock, flags);
@@ -2799,7 +2800,7 @@ static int ib_mad_port_open(struct ib_device *device,
2799 ret = -ENOMEM; 2800 ret = -ENOMEM;
2800 goto error8; 2801 goto error8;
2801 } 2802 }
2802 INIT_WORK(&port_priv->work, ib_mad_completion_handler, port_priv); 2803 INIT_WORK(&port_priv->work, ib_mad_completion_handler);
2803 2804
2804 spin_lock_irqsave(&ib_mad_port_list_lock, flags); 2805 spin_lock_irqsave(&ib_mad_port_list_lock, flags);
2805 list_add_tail(&port_priv->port_list, &ib_mad_port_list); 2806 list_add_tail(&port_priv->port_list, &ib_mad_port_list);
diff --git a/drivers/infiniband/core/mad_priv.h b/drivers/infiniband/core/mad_priv.h
index d06b59083f6e..d5548e73e068 100644
--- a/drivers/infiniband/core/mad_priv.h
+++ b/drivers/infiniband/core/mad_priv.h
@@ -102,7 +102,7 @@ struct ib_mad_agent_private {
102 struct list_head send_list; 102 struct list_head send_list;
103 struct list_head wait_list; 103 struct list_head wait_list;
104 struct list_head done_list; 104 struct list_head done_list;
105 struct work_struct timed_work; 105 struct delayed_work timed_work;
106 unsigned long timeout; 106 unsigned long timeout;
107 struct list_head local_list; 107 struct list_head local_list;
108 struct work_struct local_work; 108 struct work_struct local_work;
diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c
index 1ef79d015a1e..3663fd7022be 100644
--- a/drivers/infiniband/core/mad_rmpp.c
+++ b/drivers/infiniband/core/mad_rmpp.c
@@ -45,8 +45,8 @@ enum rmpp_state {
45struct mad_rmpp_recv { 45struct mad_rmpp_recv {
46 struct ib_mad_agent_private *agent; 46 struct ib_mad_agent_private *agent;
47 struct list_head list; 47 struct list_head list;
48 struct work_struct timeout_work; 48 struct delayed_work timeout_work;
49 struct work_struct cleanup_work; 49 struct delayed_work cleanup_work;
50 struct completion comp; 50 struct completion comp;
51 enum rmpp_state state; 51 enum rmpp_state state;
52 spinlock_t lock; 52 spinlock_t lock;
@@ -233,9 +233,10 @@ static void nack_recv(struct ib_mad_agent_private *agent,
233 } 233 }
234} 234}
235 235
236static void recv_timeout_handler(void *data) 236static void recv_timeout_handler(struct work_struct *work)
237{ 237{
238 struct mad_rmpp_recv *rmpp_recv = data; 238 struct mad_rmpp_recv *rmpp_recv =
239 container_of(work, struct mad_rmpp_recv, timeout_work.work);
239 struct ib_mad_recv_wc *rmpp_wc; 240 struct ib_mad_recv_wc *rmpp_wc;
240 unsigned long flags; 241 unsigned long flags;
241 242
@@ -254,9 +255,10 @@ static void recv_timeout_handler(void *data)
254 ib_free_recv_mad(rmpp_wc); 255 ib_free_recv_mad(rmpp_wc);
255} 256}
256 257
257static void recv_cleanup_handler(void *data) 258static void recv_cleanup_handler(struct work_struct *work)
258{ 259{
259 struct mad_rmpp_recv *rmpp_recv = data; 260 struct mad_rmpp_recv *rmpp_recv =
261 container_of(work, struct mad_rmpp_recv, cleanup_work.work);
260 unsigned long flags; 262 unsigned long flags;
261 263
262 spin_lock_irqsave(&rmpp_recv->agent->lock, flags); 264 spin_lock_irqsave(&rmpp_recv->agent->lock, flags);
@@ -285,8 +287,8 @@ create_rmpp_recv(struct ib_mad_agent_private *agent,
285 287
286 rmpp_recv->agent = agent; 288 rmpp_recv->agent = agent;
287 init_completion(&rmpp_recv->comp); 289 init_completion(&rmpp_recv->comp);
288 INIT_WORK(&rmpp_recv->timeout_work, recv_timeout_handler, rmpp_recv); 290 INIT_DELAYED_WORK(&rmpp_recv->timeout_work, recv_timeout_handler);
289 INIT_WORK(&rmpp_recv->cleanup_work, recv_cleanup_handler, rmpp_recv); 291 INIT_DELAYED_WORK(&rmpp_recv->cleanup_work, recv_cleanup_handler);
290 spin_lock_init(&rmpp_recv->lock); 292 spin_lock_init(&rmpp_recv->lock);
291 rmpp_recv->state = RMPP_STATE_ACTIVE; 293 rmpp_recv->state = RMPP_STATE_ACTIVE;
292 atomic_set(&rmpp_recv->refcount, 1); 294 atomic_set(&rmpp_recv->refcount, 1);
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 1706d3c7e95e..e45afba75341 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -360,9 +360,10 @@ static void free_sm_ah(struct kref *kref)
360 kfree(sm_ah); 360 kfree(sm_ah);
361} 361}
362 362
363static void update_sm_ah(void *port_ptr) 363static void update_sm_ah(struct work_struct *work)
364{ 364{
365 struct ib_sa_port *port = port_ptr; 365 struct ib_sa_port *port =
366 container_of(work, struct ib_sa_port, update_task);
366 struct ib_sa_sm_ah *new_ah, *old_ah; 367 struct ib_sa_sm_ah *new_ah, *old_ah;
367 struct ib_port_attr port_attr; 368 struct ib_port_attr port_attr;
368 struct ib_ah_attr ah_attr; 369 struct ib_ah_attr ah_attr;
@@ -992,8 +993,7 @@ static void ib_sa_add_one(struct ib_device *device)
992 if (IS_ERR(sa_dev->port[i].agent)) 993 if (IS_ERR(sa_dev->port[i].agent))
993 goto err; 994 goto err;
994 995
995 INIT_WORK(&sa_dev->port[i].update_task, 996 INIT_WORK(&sa_dev->port[i].update_task, update_sm_ah);
996 update_sm_ah, &sa_dev->port[i]);
997 } 997 }
998 998
999 ib_set_client_data(device, &sa_client, sa_dev); 999 ib_set_client_data(device, &sa_client, sa_dev);
@@ -1010,7 +1010,7 @@ static void ib_sa_add_one(struct ib_device *device)
1010 goto err; 1010 goto err;
1011 1011
1012 for (i = 0; i <= e - s; ++i) 1012 for (i = 0; i <= e - s; ++i)
1013 update_sm_ah(&sa_dev->port[i]); 1013 update_sm_ah(&sa_dev->port[i].update_task);
1014 1014
1015 return; 1015 return;
1016 1016
diff --git a/drivers/infiniband/core/uverbs_mem.c b/drivers/infiniband/core/uverbs_mem.c
index efe147dbeb42..db12cc0841df 100644
--- a/drivers/infiniband/core/uverbs_mem.c
+++ b/drivers/infiniband/core/uverbs_mem.c
@@ -179,9 +179,10 @@ void ib_umem_release(struct ib_device *dev, struct ib_umem *umem)
179 up_write(&current->mm->mmap_sem); 179 up_write(&current->mm->mmap_sem);
180} 180}
181 181
182static void ib_umem_account(void *work_ptr) 182static void ib_umem_account(struct work_struct *_work)
183{ 183{
184 struct ib_umem_account_work *work = work_ptr; 184 struct ib_umem_account_work *work =
185 container_of(_work, struct ib_umem_account_work, work);
185 186
186 down_write(&work->mm->mmap_sem); 187 down_write(&work->mm->mmap_sem);
187 work->mm->locked_vm -= work->diff; 188 work->mm->locked_vm -= work->diff;
@@ -216,7 +217,7 @@ void ib_umem_release_on_close(struct ib_device *dev, struct ib_umem *umem)
216 return; 217 return;
217 } 218 }
218 219
219 INIT_WORK(&work->work, ib_umem_account, work); 220 INIT_WORK(&work->work, ib_umem_account);
220 work->mm = mm; 221 work->mm = mm;
221 work->diff = PAGE_ALIGN(umem->length + umem->offset) >> PAGE_SHIFT; 222 work->diff = PAGE_ALIGN(umem->length + umem->offset) >> PAGE_SHIFT;
222 223
diff --git a/drivers/infiniband/hw/amso1100/c2_vq.c b/drivers/infiniband/hw/amso1100/c2_vq.c
index 40caeb5f41b4..36620a22413c 100644
--- a/drivers/infiniband/hw/amso1100/c2_vq.c
+++ b/drivers/infiniband/hw/amso1100/c2_vq.c
@@ -164,7 +164,7 @@ void vq_req_put(struct c2_dev *c2dev, struct c2_vq_req *r)
164 */ 164 */
165void *vq_repbuf_alloc(struct c2_dev *c2dev) 165void *vq_repbuf_alloc(struct c2_dev *c2dev)
166{ 166{
167 return kmem_cache_alloc(c2dev->host_msg_cache, SLAB_ATOMIC); 167 return kmem_cache_alloc(c2dev->host_msg_cache, GFP_ATOMIC);
168} 168}
169 169
170/* 170/*
diff --git a/drivers/infiniband/hw/ehca/ehca_av.c b/drivers/infiniband/hw/ehca/ehca_av.c
index 214e2fdddeef..0d6e2c4bb245 100644
--- a/drivers/infiniband/hw/ehca/ehca_av.c
+++ b/drivers/infiniband/hw/ehca/ehca_av.c
@@ -57,7 +57,7 @@ struct ib_ah *ehca_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
57 struct ehca_shca *shca = container_of(pd->device, struct ehca_shca, 57 struct ehca_shca *shca = container_of(pd->device, struct ehca_shca,
58 ib_device); 58 ib_device);
59 59
60 av = kmem_cache_alloc(av_cache, SLAB_KERNEL); 60 av = kmem_cache_alloc(av_cache, GFP_KERNEL);
61 if (!av) { 61 if (!av) {
62 ehca_err(pd->device, "Out of memory pd=%p ah_attr=%p", 62 ehca_err(pd->device, "Out of memory pd=%p ah_attr=%p",
63 pd, ah_attr); 63 pd, ah_attr);
diff --git a/drivers/infiniband/hw/ehca/ehca_cq.c b/drivers/infiniband/hw/ehca/ehca_cq.c
index 458fe19648a1..93995b658d94 100644
--- a/drivers/infiniband/hw/ehca/ehca_cq.c
+++ b/drivers/infiniband/hw/ehca/ehca_cq.c
@@ -134,7 +134,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe,
134 if (cqe >= 0xFFFFFFFF - 64 - additional_cqe) 134 if (cqe >= 0xFFFFFFFF - 64 - additional_cqe)
135 return ERR_PTR(-EINVAL); 135 return ERR_PTR(-EINVAL);
136 136
137 my_cq = kmem_cache_alloc(cq_cache, SLAB_KERNEL); 137 my_cq = kmem_cache_alloc(cq_cache, GFP_KERNEL);
138 if (!my_cq) { 138 if (!my_cq) {
139 ehca_err(device, "Out of memory for ehca_cq struct device=%p", 139 ehca_err(device, "Out of memory for ehca_cq struct device=%p",
140 device); 140 device);
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index 3d1c1c535038..cc47e4c13a18 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -108,7 +108,7 @@ static struct kmem_cache *ctblk_cache = NULL;
108 108
109void *ehca_alloc_fw_ctrlblock(void) 109void *ehca_alloc_fw_ctrlblock(void)
110{ 110{
111 void *ret = kmem_cache_zalloc(ctblk_cache, SLAB_KERNEL); 111 void *ret = kmem_cache_zalloc(ctblk_cache, GFP_KERNEL);
112 if (!ret) 112 if (!ret)
113 ehca_gen_err("Out of memory for ctblk"); 113 ehca_gen_err("Out of memory for ctblk");
114 return ret; 114 return ret;
diff --git a/drivers/infiniband/hw/ehca/ehca_mrmw.c b/drivers/infiniband/hw/ehca/ehca_mrmw.c
index abce676c0ae0..0a5e2214cc5f 100644
--- a/drivers/infiniband/hw/ehca/ehca_mrmw.c
+++ b/drivers/infiniband/hw/ehca/ehca_mrmw.c
@@ -53,7 +53,7 @@ static struct ehca_mr *ehca_mr_new(void)
53{ 53{
54 struct ehca_mr *me; 54 struct ehca_mr *me;
55 55
56 me = kmem_cache_alloc(mr_cache, SLAB_KERNEL); 56 me = kmem_cache_alloc(mr_cache, GFP_KERNEL);
57 if (me) { 57 if (me) {
58 memset(me, 0, sizeof(struct ehca_mr)); 58 memset(me, 0, sizeof(struct ehca_mr));
59 spin_lock_init(&me->mrlock); 59 spin_lock_init(&me->mrlock);
@@ -72,7 +72,7 @@ static struct ehca_mw *ehca_mw_new(void)
72{ 72{
73 struct ehca_mw *me; 73 struct ehca_mw *me;
74 74
75 me = kmem_cache_alloc(mw_cache, SLAB_KERNEL); 75 me = kmem_cache_alloc(mw_cache, GFP_KERNEL);
76 if (me) { 76 if (me) {
77 memset(me, 0, sizeof(struct ehca_mw)); 77 memset(me, 0, sizeof(struct ehca_mw));
78 spin_lock_init(&me->mwlock); 78 spin_lock_init(&me->mwlock);
diff --git a/drivers/infiniband/hw/ehca/ehca_pd.c b/drivers/infiniband/hw/ehca/ehca_pd.c
index 2c3cdc6f7b39..d5345e5b3cd6 100644
--- a/drivers/infiniband/hw/ehca/ehca_pd.c
+++ b/drivers/infiniband/hw/ehca/ehca_pd.c
@@ -50,7 +50,7 @@ struct ib_pd *ehca_alloc_pd(struct ib_device *device,
50{ 50{
51 struct ehca_pd *pd; 51 struct ehca_pd *pd;
52 52
53 pd = kmem_cache_alloc(pd_cache, SLAB_KERNEL); 53 pd = kmem_cache_alloc(pd_cache, GFP_KERNEL);
54 if (!pd) { 54 if (!pd) {
55 ehca_err(device, "device=%p context=%p out of memory", 55 ehca_err(device, "device=%p context=%p out of memory",
56 device, context); 56 device, context);
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c
index 8682aa50c707..c6c9cef203e3 100644
--- a/drivers/infiniband/hw/ehca/ehca_qp.c
+++ b/drivers/infiniband/hw/ehca/ehca_qp.c
@@ -450,7 +450,7 @@ struct ib_qp *ehca_create_qp(struct ib_pd *pd,
450 if (pd->uobject && udata) 450 if (pd->uobject && udata)
451 context = pd->uobject->context; 451 context = pd->uobject->context;
452 452
453 my_qp = kmem_cache_alloc(qp_cache, SLAB_KERNEL); 453 my_qp = kmem_cache_alloc(qp_cache, GFP_KERNEL);
454 if (!my_qp) { 454 if (!my_qp) {
455 ehca_err(pd->device, "pd=%p not enough memory to alloc qp", pd); 455 ehca_err(pd->device, "pd=%p not enough memory to alloc qp", pd);
456 return ERR_PTR(-ENOMEM); 456 return ERR_PTR(-ENOMEM);
diff --git a/drivers/infiniband/hw/ipath/ipath_user_pages.c b/drivers/infiniband/hw/ipath/ipath_user_pages.c
index 413754b1d8a2..8536aeb96af8 100644
--- a/drivers/infiniband/hw/ipath/ipath_user_pages.c
+++ b/drivers/infiniband/hw/ipath/ipath_user_pages.c
@@ -214,9 +214,10 @@ struct ipath_user_pages_work {
214 unsigned long num_pages; 214 unsigned long num_pages;
215}; 215};
216 216
217static void user_pages_account(void *ptr) 217static void user_pages_account(struct work_struct *_work)
218{ 218{
219 struct ipath_user_pages_work *work = ptr; 219 struct ipath_user_pages_work *work =
220 container_of(_work, struct ipath_user_pages_work, work);
220 221
221 down_write(&work->mm->mmap_sem); 222 down_write(&work->mm->mmap_sem);
222 work->mm->locked_vm -= work->num_pages; 223 work->mm->locked_vm -= work->num_pages;
@@ -242,7 +243,7 @@ void ipath_release_user_pages_on_close(struct page **p, size_t num_pages)
242 243
243 goto bail; 244 goto bail;
244 245
245 INIT_WORK(&work->work, user_pages_account, work); 246 INIT_WORK(&work->work, user_pages_account);
246 work->mm = mm; 247 work->mm = mm;
247 work->num_pages = num_pages; 248 work->num_pages = num_pages;
248 249
diff --git a/drivers/infiniband/hw/mthca/mthca_av.c b/drivers/infiniband/hw/mthca/mthca_av.c
index 57cdc1bc5f50..27caf3b0648a 100644
--- a/drivers/infiniband/hw/mthca/mthca_av.c
+++ b/drivers/infiniband/hw/mthca/mthca_av.c
@@ -189,7 +189,7 @@ int mthca_create_ah(struct mthca_dev *dev,
189on_hca_fail: 189on_hca_fail:
190 if (ah->type == MTHCA_AH_PCI_POOL) { 190 if (ah->type == MTHCA_AH_PCI_POOL) {
191 ah->av = pci_pool_alloc(dev->av_table.pool, 191 ah->av = pci_pool_alloc(dev->av_table.pool,
192 SLAB_ATOMIC, &ah->avdma); 192 GFP_ATOMIC, &ah->avdma);
193 if (!ah->av) 193 if (!ah->av)
194 return -ENOMEM; 194 return -ENOMEM;
195 195
diff --git a/drivers/infiniband/hw/mthca/mthca_catas.c b/drivers/infiniband/hw/mthca/mthca_catas.c
index cd044ea2dfa4..e948158a28d9 100644
--- a/drivers/infiniband/hw/mthca/mthca_catas.c
+++ b/drivers/infiniband/hw/mthca/mthca_catas.c
@@ -57,7 +57,7 @@ static int catas_reset_disable;
57module_param_named(catas_reset_disable, catas_reset_disable, int, 0644); 57module_param_named(catas_reset_disable, catas_reset_disable, int, 0644);
58MODULE_PARM_DESC(catas_reset_disable, "disable reset on catastrophic event if nonzero"); 58MODULE_PARM_DESC(catas_reset_disable, "disable reset on catastrophic event if nonzero");
59 59
60static void catas_reset(void *work_ptr) 60static void catas_reset(struct work_struct *work)
61{ 61{
62 struct mthca_dev *dev, *tmpdev; 62 struct mthca_dev *dev, *tmpdev;
63 LIST_HEAD(tlist); 63 LIST_HEAD(tlist);
@@ -203,7 +203,7 @@ void mthca_stop_catas_poll(struct mthca_dev *dev)
203 203
204int __init mthca_catas_init(void) 204int __init mthca_catas_init(void)
205{ 205{
206 INIT_WORK(&catas_work, catas_reset, NULL); 206 INIT_WORK(&catas_work, catas_reset);
207 207
208 catas_wq = create_singlethread_workqueue("mthca_catas"); 208 catas_wq = create_singlethread_workqueue("mthca_catas");
209 if (!catas_wq) 209 if (!catas_wq)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index f2b61851a49c..99547996aba2 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -136,11 +136,11 @@ struct ipoib_dev_priv {
136 struct list_head multicast_list; 136 struct list_head multicast_list;
137 struct rb_root multicast_tree; 137 struct rb_root multicast_tree;
138 138
139 struct work_struct pkey_task; 139 struct delayed_work pkey_task;
140 struct work_struct mcast_task; 140 struct delayed_work mcast_task;
141 struct work_struct flush_task; 141 struct work_struct flush_task;
142 struct work_struct restart_task; 142 struct work_struct restart_task;
143 struct work_struct ah_reap_task; 143 struct delayed_work ah_reap_task;
144 144
145 struct ib_device *ca; 145 struct ib_device *ca;
146 u8 port; 146 u8 port;
@@ -254,13 +254,13 @@ int ipoib_add_pkey_attr(struct net_device *dev);
254 254
255void ipoib_send(struct net_device *dev, struct sk_buff *skb, 255void ipoib_send(struct net_device *dev, struct sk_buff *skb,
256 struct ipoib_ah *address, u32 qpn); 256 struct ipoib_ah *address, u32 qpn);
257void ipoib_reap_ah(void *dev_ptr); 257void ipoib_reap_ah(struct work_struct *work);
258 258
259void ipoib_flush_paths(struct net_device *dev); 259void ipoib_flush_paths(struct net_device *dev);
260struct ipoib_dev_priv *ipoib_intf_alloc(const char *format); 260struct ipoib_dev_priv *ipoib_intf_alloc(const char *format);
261 261
262int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port); 262int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
263void ipoib_ib_dev_flush(void *dev); 263void ipoib_ib_dev_flush(struct work_struct *work);
264void ipoib_ib_dev_cleanup(struct net_device *dev); 264void ipoib_ib_dev_cleanup(struct net_device *dev);
265 265
266int ipoib_ib_dev_open(struct net_device *dev); 266int ipoib_ib_dev_open(struct net_device *dev);
@@ -271,10 +271,10 @@ int ipoib_ib_dev_stop(struct net_device *dev);
271int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port); 271int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
272void ipoib_dev_cleanup(struct net_device *dev); 272void ipoib_dev_cleanup(struct net_device *dev);
273 273
274void ipoib_mcast_join_task(void *dev_ptr); 274void ipoib_mcast_join_task(struct work_struct *work);
275void ipoib_mcast_send(struct net_device *dev, void *mgid, struct sk_buff *skb); 275void ipoib_mcast_send(struct net_device *dev, void *mgid, struct sk_buff *skb);
276 276
277void ipoib_mcast_restart_task(void *dev_ptr); 277void ipoib_mcast_restart_task(struct work_struct *work);
278int ipoib_mcast_start_thread(struct net_device *dev); 278int ipoib_mcast_start_thread(struct net_device *dev);
279int ipoib_mcast_stop_thread(struct net_device *dev, int flush); 279int ipoib_mcast_stop_thread(struct net_device *dev, int flush);
280 280
@@ -312,7 +312,7 @@ void ipoib_event(struct ib_event_handler *handler,
312int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey); 312int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey);
313int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey); 313int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey);
314 314
315void ipoib_pkey_poll(void *dev); 315void ipoib_pkey_poll(struct work_struct *work);
316int ipoib_pkey_dev_delay_open(struct net_device *dev); 316int ipoib_pkey_dev_delay_open(struct net_device *dev);
317 317
318#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 318#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 8bf5e9ec7c95..f10fba5d3265 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -400,10 +400,11 @@ static void __ipoib_reap_ah(struct net_device *dev)
400 spin_unlock_irq(&priv->tx_lock); 400 spin_unlock_irq(&priv->tx_lock);
401} 401}
402 402
403void ipoib_reap_ah(void *dev_ptr) 403void ipoib_reap_ah(struct work_struct *work)
404{ 404{
405 struct net_device *dev = dev_ptr; 405 struct ipoib_dev_priv *priv =
406 struct ipoib_dev_priv *priv = netdev_priv(dev); 406 container_of(work, struct ipoib_dev_priv, ah_reap_task.work);
407 struct net_device *dev = priv->dev;
407 408
408 __ipoib_reap_ah(dev); 409 __ipoib_reap_ah(dev);
409 410
@@ -613,10 +614,11 @@ int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port)
613 return 0; 614 return 0;
614} 615}
615 616
616void ipoib_ib_dev_flush(void *_dev) 617void ipoib_ib_dev_flush(struct work_struct *work)
617{ 618{
618 struct net_device *dev = (struct net_device *)_dev; 619 struct ipoib_dev_priv *cpriv, *priv =
619 struct ipoib_dev_priv *priv = netdev_priv(dev), *cpriv; 620 container_of(work, struct ipoib_dev_priv, flush_task);
621 struct net_device *dev = priv->dev;
620 622
621 if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags) ) { 623 if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags) ) {
622 ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_INITIALIZED not set.\n"); 624 ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_INITIALIZED not set.\n");
@@ -638,14 +640,14 @@ void ipoib_ib_dev_flush(void *_dev)
638 */ 640 */
639 if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) { 641 if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) {
640 ipoib_ib_dev_up(dev); 642 ipoib_ib_dev_up(dev);
641 ipoib_mcast_restart_task(dev); 643 ipoib_mcast_restart_task(&priv->restart_task);
642 } 644 }
643 645
644 mutex_lock(&priv->vlan_mutex); 646 mutex_lock(&priv->vlan_mutex);
645 647
646 /* Flush any child interfaces too */ 648 /* Flush any child interfaces too */
647 list_for_each_entry(cpriv, &priv->child_intfs, list) 649 list_for_each_entry(cpriv, &priv->child_intfs, list)
648 ipoib_ib_dev_flush(cpriv->dev); 650 ipoib_ib_dev_flush(&cpriv->flush_task);
649 651
650 mutex_unlock(&priv->vlan_mutex); 652 mutex_unlock(&priv->vlan_mutex);
651} 653}
@@ -672,10 +674,11 @@ void ipoib_ib_dev_cleanup(struct net_device *dev)
672 * change async notification is available. 674 * change async notification is available.
673 */ 675 */
674 676
675void ipoib_pkey_poll(void *dev_ptr) 677void ipoib_pkey_poll(struct work_struct *work)
676{ 678{
677 struct net_device *dev = dev_ptr; 679 struct ipoib_dev_priv *priv =
678 struct ipoib_dev_priv *priv = netdev_priv(dev); 680 container_of(work, struct ipoib_dev_priv, pkey_task.work);
681 struct net_device *dev = priv->dev;
679 682
680 ipoib_pkey_dev_check_presence(dev); 683 ipoib_pkey_dev_check_presence(dev);
681 684
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 5ba3154320b4..c09280243726 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -940,11 +940,11 @@ static void ipoib_setup(struct net_device *dev)
940 INIT_LIST_HEAD(&priv->dead_ahs); 940 INIT_LIST_HEAD(&priv->dead_ahs);
941 INIT_LIST_HEAD(&priv->multicast_list); 941 INIT_LIST_HEAD(&priv->multicast_list);
942 942
943 INIT_WORK(&priv->pkey_task, ipoib_pkey_poll, priv->dev); 943 INIT_DELAYED_WORK(&priv->pkey_task, ipoib_pkey_poll);
944 INIT_WORK(&priv->mcast_task, ipoib_mcast_join_task, priv->dev); 944 INIT_DELAYED_WORK(&priv->mcast_task, ipoib_mcast_join_task);
945 INIT_WORK(&priv->flush_task, ipoib_ib_dev_flush, priv->dev); 945 INIT_WORK(&priv->flush_task, ipoib_ib_dev_flush);
946 INIT_WORK(&priv->restart_task, ipoib_mcast_restart_task, priv->dev); 946 INIT_WORK(&priv->restart_task, ipoib_mcast_restart_task);
947 INIT_WORK(&priv->ah_reap_task, ipoib_reap_ah, priv->dev); 947 INIT_DELAYED_WORK(&priv->ah_reap_task, ipoib_reap_ah);
948} 948}
949 949
950struct ipoib_dev_priv *ipoib_intf_alloc(const char *name) 950struct ipoib_dev_priv *ipoib_intf_alloc(const char *name)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index d282d65e3ee0..b04b72ca32ed 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -399,7 +399,8 @@ static void ipoib_mcast_join_complete(int status,
399 mcast->backoff = 1; 399 mcast->backoff = 1;
400 mutex_lock(&mcast_mutex); 400 mutex_lock(&mcast_mutex);
401 if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) 401 if (test_bit(IPOIB_MCAST_RUN, &priv->flags))
402 queue_work(ipoib_workqueue, &priv->mcast_task); 402 queue_delayed_work(ipoib_workqueue,
403 &priv->mcast_task, 0);
403 mutex_unlock(&mcast_mutex); 404 mutex_unlock(&mcast_mutex);
404 complete(&mcast->done); 405 complete(&mcast->done);
405 return; 406 return;
@@ -435,7 +436,8 @@ static void ipoib_mcast_join_complete(int status,
435 436
436 if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) { 437 if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) {
437 if (status == -ETIMEDOUT) 438 if (status == -ETIMEDOUT)
438 queue_work(ipoib_workqueue, &priv->mcast_task); 439 queue_delayed_work(ipoib_workqueue, &priv->mcast_task,
440 0);
439 else 441 else
440 queue_delayed_work(ipoib_workqueue, &priv->mcast_task, 442 queue_delayed_work(ipoib_workqueue, &priv->mcast_task,
441 mcast->backoff * HZ); 443 mcast->backoff * HZ);
@@ -517,10 +519,11 @@ static void ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast,
517 mcast->query_id = ret; 519 mcast->query_id = ret;
518} 520}
519 521
520void ipoib_mcast_join_task(void *dev_ptr) 522void ipoib_mcast_join_task(struct work_struct *work)
521{ 523{
522 struct net_device *dev = dev_ptr; 524 struct ipoib_dev_priv *priv =
523 struct ipoib_dev_priv *priv = netdev_priv(dev); 525 container_of(work, struct ipoib_dev_priv, mcast_task.work);
526 struct net_device *dev = priv->dev;
524 527
525 if (!test_bit(IPOIB_MCAST_RUN, &priv->flags)) 528 if (!test_bit(IPOIB_MCAST_RUN, &priv->flags))
526 return; 529 return;
@@ -610,7 +613,7 @@ int ipoib_mcast_start_thread(struct net_device *dev)
610 613
611 mutex_lock(&mcast_mutex); 614 mutex_lock(&mcast_mutex);
612 if (!test_and_set_bit(IPOIB_MCAST_RUN, &priv->flags)) 615 if (!test_and_set_bit(IPOIB_MCAST_RUN, &priv->flags))
613 queue_work(ipoib_workqueue, &priv->mcast_task); 616 queue_delayed_work(ipoib_workqueue, &priv->mcast_task, 0);
614 mutex_unlock(&mcast_mutex); 617 mutex_unlock(&mcast_mutex);
615 618
616 spin_lock_irq(&priv->lock); 619 spin_lock_irq(&priv->lock);
@@ -818,10 +821,11 @@ void ipoib_mcast_dev_flush(struct net_device *dev)
818 } 821 }
819} 822}
820 823
821void ipoib_mcast_restart_task(void *dev_ptr) 824void ipoib_mcast_restart_task(struct work_struct *work)
822{ 825{
823 struct net_device *dev = dev_ptr; 826 struct ipoib_dev_priv *priv =
824 struct ipoib_dev_priv *priv = netdev_priv(dev); 827 container_of(work, struct ipoib_dev_priv, restart_task);
828 struct net_device *dev = priv->dev;
825 struct dev_mc_list *mclist; 829 struct dev_mc_list *mclist;
826 struct ipoib_mcast *mcast, *tmcast; 830 struct ipoib_mcast *mcast, *tmcast;
827 LIST_HEAD(remove_list); 831 LIST_HEAD(remove_list);
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
index 18a000034996..693b77002897 100644
--- a/drivers/infiniband/ulp/iser/iser_verbs.c
+++ b/drivers/infiniband/ulp/iser/iser_verbs.c
@@ -48,7 +48,7 @@
48 48
49static void iser_cq_tasklet_fn(unsigned long data); 49static void iser_cq_tasklet_fn(unsigned long data);
50static void iser_cq_callback(struct ib_cq *cq, void *cq_context); 50static void iser_cq_callback(struct ib_cq *cq, void *cq_context);
51static void iser_comp_error_worker(void *data); 51static void iser_comp_error_worker(struct work_struct *work);
52 52
53static void iser_cq_event_callback(struct ib_event *cause, void *context) 53static void iser_cq_event_callback(struct ib_event *cause, void *context)
54{ 54{
@@ -480,8 +480,7 @@ int iser_conn_init(struct iser_conn **ibconn)
480 init_waitqueue_head(&ib_conn->wait); 480 init_waitqueue_head(&ib_conn->wait);
481 atomic_set(&ib_conn->post_recv_buf_count, 0); 481 atomic_set(&ib_conn->post_recv_buf_count, 0);
482 atomic_set(&ib_conn->post_send_buf_count, 0); 482 atomic_set(&ib_conn->post_send_buf_count, 0);
483 INIT_WORK(&ib_conn->comperror_work, iser_comp_error_worker, 483 INIT_WORK(&ib_conn->comperror_work, iser_comp_error_worker);
484 ib_conn);
485 INIT_LIST_HEAD(&ib_conn->conn_list); 484 INIT_LIST_HEAD(&ib_conn->conn_list);
486 spin_lock_init(&ib_conn->lock); 485 spin_lock_init(&ib_conn->lock);
487 486
@@ -754,9 +753,10 @@ int iser_post_send(struct iser_desc *tx_desc)
754 return ret_val; 753 return ret_val;
755} 754}
756 755
757static void iser_comp_error_worker(void *data) 756static void iser_comp_error_worker(struct work_struct *work)
758{ 757{
759 struct iser_conn *ib_conn = data; 758 struct iser_conn *ib_conn =
759 container_of(work, struct iser_conn, comperror_work);
760 760
761 /* getting here when the state is UP means that the conn is being * 761 /* getting here when the state is UP means that the conn is being *
762 * terminated asynchronously from the iSCSI layer's perspective. */ 762 * terminated asynchronously from the iSCSI layer's perspective. */
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 64ab5fc7cca3..a6289595557b 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -390,9 +390,10 @@ static void srp_disconnect_target(struct srp_target_port *target)
390 wait_for_completion(&target->done); 390 wait_for_completion(&target->done);
391} 391}
392 392
393static void srp_remove_work(void *target_ptr) 393static void srp_remove_work(struct work_struct *work)
394{ 394{
395 struct srp_target_port *target = target_ptr; 395 struct srp_target_port *target =
396 container_of(work, struct srp_target_port, work);
396 397
397 spin_lock_irq(target->scsi_host->host_lock); 398 spin_lock_irq(target->scsi_host->host_lock);
398 if (target->state != SRP_TARGET_DEAD) { 399 if (target->state != SRP_TARGET_DEAD) {
@@ -575,7 +576,7 @@ err:
575 spin_lock_irq(target->scsi_host->host_lock); 576 spin_lock_irq(target->scsi_host->host_lock);
576 if (target->state == SRP_TARGET_CONNECTING) { 577 if (target->state == SRP_TARGET_CONNECTING) {
577 target->state = SRP_TARGET_DEAD; 578 target->state = SRP_TARGET_DEAD;
578 INIT_WORK(&target->work, srp_remove_work, target); 579 INIT_WORK(&target->work, srp_remove_work);
579 schedule_work(&target->work); 580 schedule_work(&target->work);
580 } 581 }
581 spin_unlock_irq(target->scsi_host->host_lock); 582 spin_unlock_irq(target->scsi_host->host_lock);
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index a0af97efe6ac..79dfb4b25c97 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -23,6 +23,7 @@
23#include <linux/kthread.h> 23#include <linux/kthread.h>
24#include <linux/sched.h> /* HZ */ 24#include <linux/sched.h> /* HZ */
25#include <linux/mutex.h> 25#include <linux/mutex.h>
26#include <linux/freezer.h>
26 27
27/*#include <asm/io.h>*/ 28/*#include <asm/io.h>*/
28 29
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index cbb93669d1ce..8451b29a3db5 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -567,9 +567,9 @@ static int atkbd_set_leds(struct atkbd *atkbd)
567 * interrupt context. 567 * interrupt context.
568 */ 568 */
569 569
570static void atkbd_event_work(void *data) 570static void atkbd_event_work(struct work_struct *work)
571{ 571{
572 struct atkbd *atkbd = data; 572 struct atkbd *atkbd = container_of(work, struct atkbd, event_work);
573 573
574 mutex_lock(&atkbd->event_mutex); 574 mutex_lock(&atkbd->event_mutex);
575 575
@@ -943,7 +943,7 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
943 943
944 atkbd->dev = dev; 944 atkbd->dev = dev;
945 ps2_init(&atkbd->ps2dev, serio); 945 ps2_init(&atkbd->ps2dev, serio);
946 INIT_WORK(&atkbd->event_work, atkbd_event_work, atkbd); 946 INIT_WORK(&atkbd->event_work, atkbd_event_work);
947 mutex_init(&atkbd->event_mutex); 947 mutex_init(&atkbd->event_mutex);
948 948
949 switch (serio->id.type) { 949 switch (serio->id.type) {
diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
index 979b93e33da7..b7f049b45b6b 100644
--- a/drivers/input/keyboard/lkkbd.c
+++ b/drivers/input/keyboard/lkkbd.c
@@ -572,9 +572,9 @@ lkkbd_event (struct input_dev *dev, unsigned int type, unsigned int code,
572 * were in. 572 * were in.
573 */ 573 */
574static void 574static void
575lkkbd_reinit (void *data) 575lkkbd_reinit (struct work_struct *work)
576{ 576{
577 struct lkkbd *lk = data; 577 struct lkkbd *lk = container_of(work, struct lkkbd, tq);
578 int division; 578 int division;
579 unsigned char leds_on = 0; 579 unsigned char leds_on = 0;
580 unsigned char leds_off = 0; 580 unsigned char leds_off = 0;
@@ -651,7 +651,7 @@ lkkbd_connect (struct serio *serio, struct serio_driver *drv)
651 651
652 lk->serio = serio; 652 lk->serio = serio;
653 lk->dev = input_dev; 653 lk->dev = input_dev;
654 INIT_WORK (&lk->tq, lkkbd_reinit, lk); 654 INIT_WORK (&lk->tq, lkkbd_reinit);
655 lk->bell_volume = bell_volume; 655 lk->bell_volume = bell_volume;
656 lk->keyclick_volume = keyclick_volume; 656 lk->keyclick_volume = keyclick_volume;
657 lk->ctrlclick_volume = ctrlclick_volume; 657 lk->ctrlclick_volume = ctrlclick_volume;
diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c
index cac4781103c3..6cd887c5eb0a 100644
--- a/drivers/input/keyboard/sunkbd.c
+++ b/drivers/input/keyboard/sunkbd.c
@@ -208,9 +208,9 @@ static int sunkbd_initialize(struct sunkbd *sunkbd)
208 * were in. 208 * were in.
209 */ 209 */
210 210
211static void sunkbd_reinit(void *data) 211static void sunkbd_reinit(struct work_struct *work)
212{ 212{
213 struct sunkbd *sunkbd = data; 213 struct sunkbd *sunkbd = container_of(work, struct sunkbd, tq);
214 214
215 wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ); 215 wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ);
216 216
@@ -248,7 +248,7 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv)
248 sunkbd->serio = serio; 248 sunkbd->serio = serio;
249 sunkbd->dev = input_dev; 249 sunkbd->dev = input_dev;
250 init_waitqueue_head(&sunkbd->wait); 250 init_waitqueue_head(&sunkbd->wait);
251 INIT_WORK(&sunkbd->tq, sunkbd_reinit, sunkbd); 251 INIT_WORK(&sunkbd->tq, sunkbd_reinit);
252 snprintf(sunkbd->phys, sizeof(sunkbd->phys), "%s/input0", serio->phys); 252 snprintf(sunkbd->phys, sizeof(sunkbd->phys), "%s/input0", serio->phys);
253 253
254 serio_set_drvdata(serio, sunkbd); 254 serio_set_drvdata(serio, sunkbd);
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
index ab4da79ee560..31d5a13bfd6b 100644
--- a/drivers/input/misc/hp_sdc_rtc.c
+++ b/drivers/input/misc/hp_sdc_rtc.c
@@ -695,7 +695,9 @@ static int __init hp_sdc_rtc_init(void)
695 695
696 if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr))) 696 if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr)))
697 return ret; 697 return ret;
698 misc_register(&hp_sdc_rtc_dev); 698 if (misc_register(&hp_sdc_rtc_dev) != 0)
699 printk(KERN_INFO "Could not register misc. dev for i8042 rtc\n");
700
699 create_proc_read_entry ("driver/rtc", 0, NULL, 701 create_proc_read_entry ("driver/rtc", 0, NULL,
700 hp_sdc_rtc_read_proc, NULL); 702 hp_sdc_rtc_read_proc, NULL);
701 703
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 6f9b2c7cc9c2..52bb2226ce2f 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -888,9 +888,10 @@ static int psmouse_poll(struct psmouse *psmouse)
888 * psmouse_resync() attempts to re-validate current protocol. 888 * psmouse_resync() attempts to re-validate current protocol.
889 */ 889 */
890 890
891static void psmouse_resync(void *p) 891static void psmouse_resync(struct work_struct *work)
892{ 892{
893 struct psmouse *psmouse = p, *parent = NULL; 893 struct psmouse *parent = NULL, *psmouse =
894 container_of(work, struct psmouse, resync_work);
894 struct serio *serio = psmouse->ps2dev.serio; 895 struct serio *serio = psmouse->ps2dev.serio;
895 psmouse_ret_t rc = PSMOUSE_GOOD_DATA; 896 psmouse_ret_t rc = PSMOUSE_GOOD_DATA;
896 int failed = 0, enabled = 0; 897 int failed = 0, enabled = 0;
@@ -1121,7 +1122,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
1121 goto out; 1122 goto out;
1122 1123
1123 ps2_init(&psmouse->ps2dev, serio); 1124 ps2_init(&psmouse->ps2dev, serio);
1124 INIT_WORK(&psmouse->resync_work, psmouse_resync, psmouse); 1125 INIT_WORK(&psmouse->resync_work, psmouse_resync);
1125 psmouse->dev = input_dev; 1126 psmouse->dev = input_dev;
1126 snprintf(psmouse->phys, sizeof(psmouse->phys), "%s/input0", serio->phys); 1127 snprintf(psmouse->phys, sizeof(psmouse->phys), "%s/input0", serio->phys);
1127 1128
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index e5b1b60757bb..b3e84d3bb7f7 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -251,9 +251,9 @@ EXPORT_SYMBOL(ps2_command);
251 * ps2_schedule_command(), to a PS/2 device (keyboard, mouse, etc.) 251 * ps2_schedule_command(), to a PS/2 device (keyboard, mouse, etc.)
252 */ 252 */
253 253
254static void ps2_execute_scheduled_command(void *data) 254static void ps2_execute_scheduled_command(struct work_struct *work)
255{ 255{
256 struct ps2work *ps2work = data; 256 struct ps2work *ps2work = container_of(work, struct ps2work, work);
257 257
258 ps2_command(ps2work->ps2dev, ps2work->param, ps2work->command); 258 ps2_command(ps2work->ps2dev, ps2work->param, ps2work->command);
259 kfree(ps2work); 259 kfree(ps2work);
@@ -278,7 +278,7 @@ int ps2_schedule_command(struct ps2dev *ps2dev, unsigned char *param, int comman
278 ps2work->ps2dev = ps2dev; 278 ps2work->ps2dev = ps2dev;
279 ps2work->command = command; 279 ps2work->command = command;
280 memcpy(ps2work->param, param, send); 280 memcpy(ps2work->param, param, send);
281 INIT_WORK(&ps2work->work, ps2_execute_scheduled_command, ps2work); 281 INIT_WORK(&ps2work->work, ps2_execute_scheduled_command);
282 282
283 if (!schedule_work(&ps2work->work)) { 283 if (!schedule_work(&ps2work->work)) {
284 kfree(ps2work); 284 kfree(ps2work);
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 211943f85cb6..5f1d4032fd57 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -35,6 +35,7 @@
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/kthread.h> 36#include <linux/kthread.h>
37#include <linux/mutex.h> 37#include <linux/mutex.h>
38#include <linux/freezer.h>
38 39
39MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 40MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
40MODULE_DESCRIPTION("Serio abstraction core"); 41MODULE_DESCRIPTION("Serio abstraction core");
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index f56d6a0f0624..0517c7387d67 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -189,7 +189,7 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
189{ 189{
190 struct spi_device *spi = to_spi_device(dev); 190 struct spi_device *spi = to_spi_device(dev);
191 struct ads7846 *ts = dev_get_drvdata(dev); 191 struct ads7846 *ts = dev_get_drvdata(dev);
192 struct ser_req *req = kzalloc(sizeof *req, SLAB_KERNEL); 192 struct ser_req *req = kzalloc(sizeof *req, GFP_KERNEL);
193 int status; 193 int status;
194 int sample; 194 int sample;
195 int i; 195 int i;
diff --git a/drivers/isdn/act2000/capi.c b/drivers/isdn/act2000/capi.c
index 6ae6eb322111..946c38cf6f8a 100644
--- a/drivers/isdn/act2000/capi.c
+++ b/drivers/isdn/act2000/capi.c
@@ -627,8 +627,10 @@ handle_ack(act2000_card *card, act2000_chan *chan, __u8 blocknr) {
627} 627}
628 628
629void 629void
630actcapi_dispatch(act2000_card *card) 630actcapi_dispatch(struct work_struct *work)
631{ 631{
632 struct act2000_card *card =
633 container_of(work, struct act2000_card, rcv_tq);
632 struct sk_buff *skb; 634 struct sk_buff *skb;
633 actcapi_msg *msg; 635 actcapi_msg *msg;
634 __u16 ccmd; 636 __u16 ccmd;
diff --git a/drivers/isdn/act2000/capi.h b/drivers/isdn/act2000/capi.h
index 49f453c53c64..e55f6a931f66 100644
--- a/drivers/isdn/act2000/capi.h
+++ b/drivers/isdn/act2000/capi.h
@@ -356,7 +356,7 @@ extern int actcapi_connect_req(act2000_card *, act2000_chan *, char *, char, int
356extern void actcapi_select_b2_protocol_req(act2000_card *, act2000_chan *); 356extern void actcapi_select_b2_protocol_req(act2000_card *, act2000_chan *);
357extern void actcapi_disconnect_b3_req(act2000_card *, act2000_chan *); 357extern void actcapi_disconnect_b3_req(act2000_card *, act2000_chan *);
358extern void actcapi_connect_resp(act2000_card *, act2000_chan *, __u8); 358extern void actcapi_connect_resp(act2000_card *, act2000_chan *, __u8);
359extern void actcapi_dispatch(act2000_card *); 359extern void actcapi_dispatch(struct work_struct *);
360#ifdef DEBUG_MSG 360#ifdef DEBUG_MSG
361extern void actcapi_debug_msg(struct sk_buff *skb, int); 361extern void actcapi_debug_msg(struct sk_buff *skb, int);
362#else 362#else
diff --git a/drivers/isdn/act2000/module.c b/drivers/isdn/act2000/module.c
index d89dcde4eade..90593e2ef872 100644
--- a/drivers/isdn/act2000/module.c
+++ b/drivers/isdn/act2000/module.c
@@ -192,8 +192,11 @@ act2000_set_msn(act2000_card *card, char *eazmsn)
192} 192}
193 193
194static void 194static void
195act2000_transmit(struct act2000_card *card) 195act2000_transmit(struct work_struct *work)
196{ 196{
197 struct act2000_card *card =
198 container_of(work, struct act2000_card, snd_tq);
199
197 switch (card->bus) { 200 switch (card->bus) {
198 case ACT2000_BUS_ISA: 201 case ACT2000_BUS_ISA:
199 act2000_isa_send(card); 202 act2000_isa_send(card);
@@ -207,8 +210,11 @@ act2000_transmit(struct act2000_card *card)
207} 210}
208 211
209static void 212static void
210act2000_receive(struct act2000_card *card) 213act2000_receive(struct work_struct *work)
211{ 214{
215 struct act2000_card *card =
216 container_of(work, struct act2000_card, poll_tq);
217
212 switch (card->bus) { 218 switch (card->bus) {
213 case ACT2000_BUS_ISA: 219 case ACT2000_BUS_ISA:
214 act2000_isa_receive(card); 220 act2000_isa_receive(card);
@@ -227,7 +233,7 @@ act2000_poll(unsigned long data)
227 act2000_card * card = (act2000_card *)data; 233 act2000_card * card = (act2000_card *)data;
228 unsigned long flags; 234 unsigned long flags;
229 235
230 act2000_receive(card); 236 act2000_receive(&card->poll_tq);
231 spin_lock_irqsave(&card->lock, flags); 237 spin_lock_irqsave(&card->lock, flags);
232 mod_timer(&card->ptimer, jiffies+3); 238 mod_timer(&card->ptimer, jiffies+3);
233 spin_unlock_irqrestore(&card->lock, flags); 239 spin_unlock_irqrestore(&card->lock, flags);
@@ -578,9 +584,9 @@ act2000_alloccard(int bus, int port, int irq, char *id)
578 skb_queue_head_init(&card->sndq); 584 skb_queue_head_init(&card->sndq);
579 skb_queue_head_init(&card->rcvq); 585 skb_queue_head_init(&card->rcvq);
580 skb_queue_head_init(&card->ackq); 586 skb_queue_head_init(&card->ackq);
581 INIT_WORK(&card->snd_tq, (void *) (void *) act2000_transmit, card); 587 INIT_WORK(&card->snd_tq, act2000_transmit);
582 INIT_WORK(&card->rcv_tq, (void *) (void *) actcapi_dispatch, card); 588 INIT_WORK(&card->rcv_tq, actcapi_dispatch);
583 INIT_WORK(&card->poll_tq, (void *) (void *) act2000_receive, card); 589 INIT_WORK(&card->poll_tq, act2000_receive);
584 init_timer(&card->ptimer); 590 init_timer(&card->ptimer);
585 card->interface.owner = THIS_MODULE; 591 card->interface.owner = THIS_MODULE;
586 card->interface.channels = ACT2000_BCH; 592 card->interface.channels = ACT2000_BCH;
diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
index 8c4fcb9027b3..783a25526315 100644
--- a/drivers/isdn/capi/kcapi.c
+++ b/drivers/isdn/capi/kcapi.c
@@ -208,9 +208,10 @@ static void notify_down(u32 contr)
208 } 208 }
209} 209}
210 210
211static void notify_handler(void *data) 211static void notify_handler(struct work_struct *work)
212{ 212{
213 struct capi_notifier *np = data; 213 struct capi_notifier *np =
214 container_of(work, struct capi_notifier, work);
214 215
215 switch (np->cmd) { 216 switch (np->cmd) {
216 case KCI_CONTRUP: 217 case KCI_CONTRUP:
@@ -235,7 +236,7 @@ static int notify_push(unsigned int cmd, u32 controller, u16 applid, u32 ncci)
235 if (!np) 236 if (!np)
236 return -ENOMEM; 237 return -ENOMEM;
237 238
238 INIT_WORK(&np->work, notify_handler, np); 239 INIT_WORK(&np->work, notify_handler);
239 np->cmd = cmd; 240 np->cmd = cmd;
240 np->controller = controller; 241 np->controller = controller;
241 np->applid = applid; 242 np->applid = applid;
@@ -248,10 +249,11 @@ static int notify_push(unsigned int cmd, u32 controller, u16 applid, u32 ncci)
248 249
249/* -------- Receiver ------------------------------------------ */ 250/* -------- Receiver ------------------------------------------ */
250 251
251static void recv_handler(void *_ap) 252static void recv_handler(struct work_struct *work)
252{ 253{
253 struct sk_buff *skb; 254 struct sk_buff *skb;
254 struct capi20_appl *ap = (struct capi20_appl *) _ap; 255 struct capi20_appl *ap =
256 container_of(work, struct capi20_appl, recv_work);
255 257
256 if ((!ap) || (ap->release_in_progress)) 258 if ((!ap) || (ap->release_in_progress))
257 return; 259 return;
@@ -527,7 +529,7 @@ u16 capi20_register(struct capi20_appl *ap)
527 ap->callback = NULL; 529 ap->callback = NULL;
528 init_MUTEX(&ap->recv_sem); 530 init_MUTEX(&ap->recv_sem);
529 skb_queue_head_init(&ap->recv_queue); 531 skb_queue_head_init(&ap->recv_queue);
530 INIT_WORK(&ap->recv_work, recv_handler, (void *)ap); 532 INIT_WORK(&ap->recv_work, recv_handler);
531 ap->release_in_progress = 0; 533 ap->release_in_progress = 0;
532 534
533 write_unlock_irqrestore(&application_lock, flags); 535 write_unlock_irqrestore(&application_lock, flags);
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index 0c937325a1b3..63b629b1cdb2 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -572,7 +572,7 @@ static int atread_submit(struct cardstate *cs, int timeout)
572 ucs->rcvbuf, ucs->rcvbuf_size, 572 ucs->rcvbuf, ucs->rcvbuf_size,
573 read_ctrl_callback, cs->inbuf); 573 read_ctrl_callback, cs->inbuf);
574 574
575 if ((ret = usb_submit_urb(ucs->urb_cmd_in, SLAB_ATOMIC)) != 0) { 575 if ((ret = usb_submit_urb(ucs->urb_cmd_in, GFP_ATOMIC)) != 0) {
576 update_basstate(ucs, 0, BS_ATRDPEND); 576 update_basstate(ucs, 0, BS_ATRDPEND);
577 dev_err(cs->dev, "could not submit HD_READ_ATMESSAGE: %s\n", 577 dev_err(cs->dev, "could not submit HD_READ_ATMESSAGE: %s\n",
578 get_usb_rcmsg(ret)); 578 get_usb_rcmsg(ret));
@@ -747,7 +747,7 @@ static void read_int_callback(struct urb *urb)
747 check_pending(ucs); 747 check_pending(ucs);
748 748
749resubmit: 749resubmit:
750 rc = usb_submit_urb(urb, SLAB_ATOMIC); 750 rc = usb_submit_urb(urb, GFP_ATOMIC);
751 if (unlikely(rc != 0 && rc != -ENODEV)) { 751 if (unlikely(rc != 0 && rc != -ENODEV)) {
752 dev_err(cs->dev, "could not resubmit interrupt URB: %s\n", 752 dev_err(cs->dev, "could not resubmit interrupt URB: %s\n",
753 get_usb_rcmsg(rc)); 753 get_usb_rcmsg(rc));
@@ -807,7 +807,7 @@ static void read_iso_callback(struct urb *urb)
807 urb->number_of_packets = BAS_NUMFRAMES; 807 urb->number_of_packets = BAS_NUMFRAMES;
808 gig_dbg(DEBUG_ISO, "%s: isoc read overrun/resubmit", 808 gig_dbg(DEBUG_ISO, "%s: isoc read overrun/resubmit",
809 __func__); 809 __func__);
810 rc = usb_submit_urb(urb, SLAB_ATOMIC); 810 rc = usb_submit_urb(urb, GFP_ATOMIC);
811 if (unlikely(rc != 0 && rc != -ENODEV)) { 811 if (unlikely(rc != 0 && rc != -ENODEV)) {
812 dev_err(bcs->cs->dev, 812 dev_err(bcs->cs->dev,
813 "could not resubmit isochronous read " 813 "could not resubmit isochronous read "
@@ -900,7 +900,7 @@ static int starturbs(struct bc_state *bcs)
900 } 900 }
901 901
902 dump_urb(DEBUG_ISO, "Initial isoc read", urb); 902 dump_urb(DEBUG_ISO, "Initial isoc read", urb);
903 if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) 903 if ((rc = usb_submit_urb(urb, GFP_ATOMIC)) != 0)
904 goto error; 904 goto error;
905 } 905 }
906 906
@@ -935,7 +935,7 @@ static int starturbs(struct bc_state *bcs)
935 /* submit two URBs, keep third one */ 935 /* submit two URBs, keep third one */
936 for (k = 0; k < 2; ++k) { 936 for (k = 0; k < 2; ++k) {
937 dump_urb(DEBUG_ISO, "Initial isoc write", urb); 937 dump_urb(DEBUG_ISO, "Initial isoc write", urb);
938 rc = usb_submit_urb(ubc->isoouturbs[k].urb, SLAB_ATOMIC); 938 rc = usb_submit_urb(ubc->isoouturbs[k].urb, GFP_ATOMIC);
939 if (rc != 0) 939 if (rc != 0)
940 goto error; 940 goto error;
941 } 941 }
@@ -1042,7 +1042,7 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
1042 return 0; /* no data to send */ 1042 return 0; /* no data to send */
1043 urb->number_of_packets = nframe; 1043 urb->number_of_packets = nframe;
1044 1044
1045 rc = usb_submit_urb(urb, SLAB_ATOMIC); 1045 rc = usb_submit_urb(urb, GFP_ATOMIC);
1046 if (unlikely(rc)) { 1046 if (unlikely(rc)) {
1047 if (rc == -ENODEV) 1047 if (rc == -ENODEV)
1048 /* device removed - give up silently */ 1048 /* device removed - give up silently */
@@ -1341,7 +1341,7 @@ static void read_iso_tasklet(unsigned long data)
1341 urb->dev = bcs->cs->hw.bas->udev; 1341 urb->dev = bcs->cs->hw.bas->udev;
1342 urb->transfer_flags = URB_ISO_ASAP; 1342 urb->transfer_flags = URB_ISO_ASAP;
1343 urb->number_of_packets = BAS_NUMFRAMES; 1343 urb->number_of_packets = BAS_NUMFRAMES;
1344 rc = usb_submit_urb(urb, SLAB_ATOMIC); 1344 rc = usb_submit_urb(urb, GFP_ATOMIC);
1345 if (unlikely(rc != 0 && rc != -ENODEV)) { 1345 if (unlikely(rc != 0 && rc != -ENODEV)) {
1346 dev_err(cs->dev, 1346 dev_err(cs->dev,
1347 "could not resubmit isochronous read URB: %s\n", 1347 "could not resubmit isochronous read URB: %s\n",
@@ -1458,7 +1458,7 @@ static void write_ctrl_callback(struct urb *urb)
1458 ucs->retry_ctrl); 1458 ucs->retry_ctrl);
1459 /* urb->dev is clobbered by USB subsystem */ 1459 /* urb->dev is clobbered by USB subsystem */
1460 urb->dev = ucs->udev; 1460 urb->dev = ucs->udev;
1461 rc = usb_submit_urb(urb, SLAB_ATOMIC); 1461 rc = usb_submit_urb(urb, GFP_ATOMIC);
1462 if (unlikely(rc)) { 1462 if (unlikely(rc)) {
1463 dev_err(&ucs->interface->dev, 1463 dev_err(&ucs->interface->dev,
1464 "could not resubmit request 0x%02x: %s\n", 1464 "could not resubmit request 0x%02x: %s\n",
@@ -1517,7 +1517,7 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout)
1517 (unsigned char*) &ucs->dr_ctrl, NULL, 0, 1517 (unsigned char*) &ucs->dr_ctrl, NULL, 0,
1518 write_ctrl_callback, ucs); 1518 write_ctrl_callback, ucs);
1519 ucs->retry_ctrl = 0; 1519 ucs->retry_ctrl = 0;
1520 ret = usb_submit_urb(ucs->urb_ctrl, SLAB_ATOMIC); 1520 ret = usb_submit_urb(ucs->urb_ctrl, GFP_ATOMIC);
1521 if (unlikely(ret)) { 1521 if (unlikely(ret)) {
1522 dev_err(bcs->cs->dev, "could not submit request 0x%02x: %s\n", 1522 dev_err(bcs->cs->dev, "could not submit request 0x%02x: %s\n",
1523 req, get_usb_rcmsg(ret)); 1523 req, get_usb_rcmsg(ret));
@@ -1763,7 +1763,7 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len)
1763 usb_sndctrlpipe(ucs->udev, 0), 1763 usb_sndctrlpipe(ucs->udev, 0),
1764 (unsigned char*) &ucs->dr_cmd_out, buf, len, 1764 (unsigned char*) &ucs->dr_cmd_out, buf, len,
1765 write_command_callback, cs); 1765 write_command_callback, cs);
1766 rc = usb_submit_urb(ucs->urb_cmd_out, SLAB_ATOMIC); 1766 rc = usb_submit_urb(ucs->urb_cmd_out, GFP_ATOMIC);
1767 if (unlikely(rc)) { 1767 if (unlikely(rc)) {
1768 update_basstate(ucs, 0, BS_ATWRPEND); 1768 update_basstate(ucs, 0, BS_ATWRPEND);
1769 dev_err(cs->dev, "could not submit HD_WRITE_ATMESSAGE: %s\n", 1769 dev_err(cs->dev, "could not submit HD_WRITE_ATMESSAGE: %s\n",
@@ -2218,21 +2218,21 @@ static int gigaset_probe(struct usb_interface *interface,
2218 * - three for the different uses of the default control pipe 2218 * - three for the different uses of the default control pipe
2219 * - three for each isochronous pipe 2219 * - three for each isochronous pipe
2220 */ 2220 */
2221 if (!(ucs->urb_int_in = usb_alloc_urb(0, SLAB_KERNEL)) || 2221 if (!(ucs->urb_int_in = usb_alloc_urb(0, GFP_KERNEL)) ||
2222 !(ucs->urb_cmd_in = usb_alloc_urb(0, SLAB_KERNEL)) || 2222 !(ucs->urb_cmd_in = usb_alloc_urb(0, GFP_KERNEL)) ||
2223 !(ucs->urb_cmd_out = usb_alloc_urb(0, SLAB_KERNEL)) || 2223 !(ucs->urb_cmd_out = usb_alloc_urb(0, GFP_KERNEL)) ||
2224 !(ucs->urb_ctrl = usb_alloc_urb(0, SLAB_KERNEL))) 2224 !(ucs->urb_ctrl = usb_alloc_urb(0, GFP_KERNEL)))
2225 goto allocerr; 2225 goto allocerr;
2226 2226
2227 for (j = 0; j < 2; ++j) { 2227 for (j = 0; j < 2; ++j) {
2228 ubc = cs->bcs[j].hw.bas; 2228 ubc = cs->bcs[j].hw.bas;
2229 for (i = 0; i < BAS_OUTURBS; ++i) 2229 for (i = 0; i < BAS_OUTURBS; ++i)
2230 if (!(ubc->isoouturbs[i].urb = 2230 if (!(ubc->isoouturbs[i].urb =
2231 usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL))) 2231 usb_alloc_urb(BAS_NUMFRAMES, GFP_KERNEL)))
2232 goto allocerr; 2232 goto allocerr;
2233 for (i = 0; i < BAS_INURBS; ++i) 2233 for (i = 0; i < BAS_INURBS; ++i)
2234 if (!(ubc->isoinurbs[i] = 2234 if (!(ubc->isoinurbs[i] =
2235 usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL))) 2235 usb_alloc_urb(BAS_NUMFRAMES, GFP_KERNEL)))
2236 goto allocerr; 2236 goto allocerr;
2237 } 2237 }
2238 2238
@@ -2246,7 +2246,7 @@ static int gigaset_probe(struct usb_interface *interface,
2246 (endpoint->bEndpointAddress) & 0x0f), 2246 (endpoint->bEndpointAddress) & 0x0f),
2247 ucs->int_in_buf, 3, read_int_callback, cs, 2247 ucs->int_in_buf, 3, read_int_callback, cs,
2248 endpoint->bInterval); 2248 endpoint->bInterval);
2249 if ((rc = usb_submit_urb(ucs->urb_int_in, SLAB_KERNEL)) != 0) { 2249 if ((rc = usb_submit_urb(ucs->urb_int_in, GFP_KERNEL)) != 0) {
2250 dev_err(cs->dev, "could not submit interrupt URB: %s\n", 2250 dev_err(cs->dev, "could not submit interrupt URB: %s\n",
2251 get_usb_rcmsg(rc)); 2251 get_usb_rcmsg(rc));
2252 goto error; 2252 goto error;
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
index 5ebf49ac9b23..04f2ad7ba8b0 100644
--- a/drivers/isdn/gigaset/usb-gigaset.c
+++ b/drivers/isdn/gigaset/usb-gigaset.c
@@ -410,7 +410,7 @@ static void gigaset_read_int_callback(struct urb *urb)
410 410
411 if (resubmit) { 411 if (resubmit) {
412 spin_lock_irqsave(&cs->lock, flags); 412 spin_lock_irqsave(&cs->lock, flags);
413 r = cs->connected ? usb_submit_urb(urb, SLAB_ATOMIC) : -ENODEV; 413 r = cs->connected ? usb_submit_urb(urb, GFP_ATOMIC) : -ENODEV;
414 spin_unlock_irqrestore(&cs->lock, flags); 414 spin_unlock_irqrestore(&cs->lock, flags);
415 if (r) 415 if (r)
416 dev_err(cs->dev, "error %d when resubmitting urb.\n", 416 dev_err(cs->dev, "error %d when resubmitting urb.\n",
@@ -486,7 +486,7 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
486 atomic_set(&ucs->busy, 1); 486 atomic_set(&ucs->busy, 1);
487 487
488 spin_lock_irqsave(&cs->lock, flags); 488 spin_lock_irqsave(&cs->lock, flags);
489 status = cs->connected ? usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC) : -ENODEV; 489 status = cs->connected ? usb_submit_urb(ucs->bulk_out_urb, GFP_ATOMIC) : -ENODEV;
490 spin_unlock_irqrestore(&cs->lock, flags); 490 spin_unlock_irqrestore(&cs->lock, flags);
491 491
492 if (status) { 492 if (status) {
@@ -664,7 +664,7 @@ static int write_modem(struct cardstate *cs)
664 ucs->bulk_out_endpointAddr & 0x0f), 664 ucs->bulk_out_endpointAddr & 0x0f),
665 ucs->bulk_out_buffer, count, 665 ucs->bulk_out_buffer, count,
666 gigaset_write_bulk_callback, cs); 666 gigaset_write_bulk_callback, cs);
667 ret = usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC); 667 ret = usb_submit_urb(ucs->bulk_out_urb, GFP_ATOMIC);
668 } else { 668 } else {
669 ret = -ENODEV; 669 ret = -ENODEV;
670 } 670 }
@@ -763,7 +763,7 @@ static int gigaset_probe(struct usb_interface *interface,
763 goto error; 763 goto error;
764 } 764 }
765 765
766 ucs->bulk_out_urb = usb_alloc_urb(0, SLAB_KERNEL); 766 ucs->bulk_out_urb = usb_alloc_urb(0, GFP_KERNEL);
767 if (!ucs->bulk_out_urb) { 767 if (!ucs->bulk_out_urb) {
768 dev_err(cs->dev, "Couldn't allocate bulk_out_urb\n"); 768 dev_err(cs->dev, "Couldn't allocate bulk_out_urb\n");
769 retval = -ENOMEM; 769 retval = -ENOMEM;
@@ -774,7 +774,7 @@ static int gigaset_probe(struct usb_interface *interface,
774 774
775 atomic_set(&ucs->busy, 0); 775 atomic_set(&ucs->busy, 0);
776 776
777 ucs->read_urb = usb_alloc_urb(0, SLAB_KERNEL); 777 ucs->read_urb = usb_alloc_urb(0, GFP_KERNEL);
778 if (!ucs->read_urb) { 778 if (!ucs->read_urb) {
779 dev_err(cs->dev, "No free urbs available\n"); 779 dev_err(cs->dev, "No free urbs available\n");
780 retval = -ENOMEM; 780 retval = -ENOMEM;
@@ -797,7 +797,7 @@ static int gigaset_probe(struct usb_interface *interface,
797 gigaset_read_int_callback, 797 gigaset_read_int_callback,
798 cs->inbuf + 0, endpoint->bInterval); 798 cs->inbuf + 0, endpoint->bInterval);
799 799
800 retval = usb_submit_urb(ucs->read_urb, SLAB_KERNEL); 800 retval = usb_submit_urb(ucs->read_urb, GFP_KERNEL);
801 if (retval) { 801 if (retval) {
802 dev_err(cs->dev, "Could not submit URB (error %d)\n", -retval); 802 dev_err(cs->dev, "Could not submit URB (error %d)\n", -retval);
803 goto error; 803 goto error;
diff --git a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c
index bec59010bc66..3b19caeba258 100644
--- a/drivers/isdn/hisax/amd7930_fn.c
+++ b/drivers/isdn/hisax/amd7930_fn.c
@@ -232,9 +232,10 @@ Amd7930_new_ph(struct IsdnCardState *cs)
232 232
233 233
234static void 234static void
235Amd7930_bh(struct IsdnCardState *cs) 235Amd7930_bh(struct work_struct *work)
236{ 236{
237 237 struct IsdnCardState *cs =
238 container_of(work, struct IsdnCardState, tqueue);
238 struct PStack *stptr; 239 struct PStack *stptr;
239 240
240 if (!cs) 241 if (!cs)
@@ -789,7 +790,7 @@ Amd7930_init(struct IsdnCardState *cs)
789void __devinit 790void __devinit
790setup_Amd7930(struct IsdnCardState *cs) 791setup_Amd7930(struct IsdnCardState *cs)
791{ 792{
792 INIT_WORK(&cs->tqueue, (void *)(void *) Amd7930_bh, cs); 793 INIT_WORK(&cs->tqueue, Amd7930_bh);
793 cs->dbusytimer.function = (void *) dbusy_timer_handler; 794 cs->dbusytimer.function = (void *) dbusy_timer_handler;
794 cs->dbusytimer.data = (long) cs; 795 cs->dbusytimer.data = (long) cs;
795 init_timer(&cs->dbusytimer); 796 init_timer(&cs->dbusytimer);
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index 785b08554fca..cede72cdbb31 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -1137,7 +1137,6 @@ static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockow
1137 cs->tx_skb = NULL; 1137 cs->tx_skb = NULL;
1138 cs->tx_cnt = 0; 1138 cs->tx_cnt = 0;
1139 cs->event = 0; 1139 cs->event = 0;
1140 cs->tqueue.data = cs;
1141 1140
1142 skb_queue_head_init(&cs->rq); 1141 skb_queue_head_init(&cs->rq);
1143 skb_queue_head_init(&cs->sq); 1142 skb_queue_head_init(&cs->sq);
@@ -1554,7 +1553,7 @@ static void hisax_b_l2l1(struct PStack *st, int pr, void *arg);
1554static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg); 1553static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg);
1555static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs); 1554static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs);
1556static void hisax_bc_close(struct BCState *bcs); 1555static void hisax_bc_close(struct BCState *bcs);
1557static void hisax_bh(struct IsdnCardState *cs); 1556static void hisax_bh(struct work_struct *work);
1558static void EChannel_proc_rcv(struct hisax_d_if *d_if); 1557static void EChannel_proc_rcv(struct hisax_d_if *d_if);
1559 1558
1560int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[], 1559int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
@@ -1586,7 +1585,7 @@ int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
1586 hisax_d_if->cs = cs; 1585 hisax_d_if->cs = cs;
1587 cs->hw.hisax_d_if = hisax_d_if; 1586 cs->hw.hisax_d_if = hisax_d_if;
1588 cs->cardmsg = hisax_cardmsg; 1587 cs->cardmsg = hisax_cardmsg;
1589 INIT_WORK(&cs->tqueue, (void *)(void *)hisax_bh, cs); 1588 INIT_WORK(&cs->tqueue, hisax_bh);
1590 cs->channel[0].d_st->l2.l2l1 = hisax_d_l2l1; 1589 cs->channel[0].d_st->l2.l2l1 = hisax_d_l2l1;
1591 for (i = 0; i < 2; i++) { 1590 for (i = 0; i < 2; i++) {
1592 cs->bcs[i].BC_SetStack = hisax_bc_setstack; 1591 cs->bcs[i].BC_SetStack = hisax_bc_setstack;
@@ -1618,8 +1617,10 @@ static void hisax_sched_event(struct IsdnCardState *cs, int event)
1618 schedule_work(&cs->tqueue); 1617 schedule_work(&cs->tqueue);
1619} 1618}
1620 1619
1621static void hisax_bh(struct IsdnCardState *cs) 1620static void hisax_bh(struct work_struct *work)
1622{ 1621{
1622 struct IsdnCardState *cs =
1623 container_of(work, struct IsdnCardState, tqueue);
1623 struct PStack *st; 1624 struct PStack *st;
1624 int pr; 1625 int pr;
1625 1626
diff --git a/drivers/isdn/hisax/hfc4s8s_l1.c b/drivers/isdn/hisax/hfc4s8s_l1.c
index d852c9d998b2..de9b1a4d6bac 100644
--- a/drivers/isdn/hisax/hfc4s8s_l1.c
+++ b/drivers/isdn/hisax/hfc4s8s_l1.c
@@ -1083,8 +1083,9 @@ tx_b_frame(struct hfc4s8s_btype *bch)
1083/* bottom half handler for interrupt */ 1083/* bottom half handler for interrupt */
1084/*************************************/ 1084/*************************************/
1085static void 1085static void
1086hfc4s8s_bh(hfc4s8s_hw * hw) 1086hfc4s8s_bh(struct work_struct *work)
1087{ 1087{
1088 hfc4s8s_hw *hw = container_of(work, hfc4s8s_hw, tqueue);
1088 u_char b; 1089 u_char b;
1089 struct hfc4s8s_l1 *l1p; 1090 struct hfc4s8s_l1 *l1p;
1090 volatile u_char *fifo_stat; 1091 volatile u_char *fifo_stat;
@@ -1550,7 +1551,7 @@ setup_instance(hfc4s8s_hw * hw)
1550 goto out; 1551 goto out;
1551 } 1552 }
1552 1553
1553 INIT_WORK(&hw->tqueue, (void *) (void *) hfc4s8s_bh, hw); 1554 INIT_WORK(&hw->tqueue, hfc4s8s_bh);
1554 1555
1555 if (request_irq 1556 if (request_irq
1556 (hw->irq, hfc4s8s_interrupt, IRQF_SHARED, hw->card_name, hw)) { 1557 (hw->irq, hfc4s8s_interrupt, IRQF_SHARED, hw->card_name, hw)) {
diff --git a/drivers/isdn/hisax/hfc_2bds0.c b/drivers/isdn/hisax/hfc_2bds0.c
index 6360e8214720..8d9864453a23 100644
--- a/drivers/isdn/hisax/hfc_2bds0.c
+++ b/drivers/isdn/hisax/hfc_2bds0.c
@@ -549,10 +549,11 @@ setstack_2b(struct PStack *st, struct BCState *bcs)
549} 549}
550 550
551static void 551static void
552hfcd_bh(struct IsdnCardState *cs) 552hfcd_bh(struct work_struct *work)
553{ 553{
554 if (!cs) 554 struct IsdnCardState *cs =
555 return; 555 container_of(work, struct IsdnCardState, tqueue);
556
556 if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) { 557 if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) {
557 switch (cs->dc.hfcd.ph_state) { 558 switch (cs->dc.hfcd.ph_state) {
558 case (0): 559 case (0):
@@ -1072,5 +1073,5 @@ set_cs_func(struct IsdnCardState *cs)
1072 cs->dbusytimer.function = (void *) hfc_dbusy_timer; 1073 cs->dbusytimer.function = (void *) hfc_dbusy_timer;
1073 cs->dbusytimer.data = (long) cs; 1074 cs->dbusytimer.data = (long) cs;
1074 init_timer(&cs->dbusytimer); 1075 init_timer(&cs->dbusytimer);
1075 INIT_WORK(&cs->tqueue, (void *)(void *) hfcd_bh, cs); 1076 INIT_WORK(&cs->tqueue, hfcd_bh);
1076} 1077}
diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
index 93f60b563515..5db0a85b827f 100644
--- a/drivers/isdn/hisax/hfc_pci.c
+++ b/drivers/isdn/hisax/hfc_pci.c
@@ -1506,8 +1506,10 @@ setstack_2b(struct PStack *st, struct BCState *bcs)
1506/* handle L1 state changes */ 1506/* handle L1 state changes */
1507/***************************/ 1507/***************************/
1508static void 1508static void
1509hfcpci_bh(struct IsdnCardState *cs) 1509hfcpci_bh(struct work_struct *work)
1510{ 1510{
1511 struct IsdnCardState *cs =
1512 container_of(work, struct IsdnCardState, tqueue);
1511 u_long flags; 1513 u_long flags;
1512// struct PStack *stptr; 1514// struct PStack *stptr;
1513 1515
@@ -1722,7 +1724,7 @@ setup_hfcpci(struct IsdnCard *card)
1722 Write_hfc(cs, HFCPCI_INT_M2, cs->hw.hfcpci.int_m2); 1724 Write_hfc(cs, HFCPCI_INT_M2, cs->hw.hfcpci.int_m2);
1723 /* At this point the needed PCI config is done */ 1725 /* At this point the needed PCI config is done */
1724 /* fifos are still not enabled */ 1726 /* fifos are still not enabled */
1725 INIT_WORK(&cs->tqueue, (void *)(void *) hfcpci_bh, cs); 1727 INIT_WORK(&cs->tqueue, hfcpci_bh);
1726 cs->setstack_d = setstack_hfcpci; 1728 cs->setstack_d = setstack_hfcpci;
1727 cs->BC_Send_Data = &hfcpci_send_data; 1729 cs->BC_Send_Data = &hfcpci_send_data;
1728 cs->readisac = NULL; 1730 cs->readisac = NULL;
diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
index 954d1536db1f..4fd09d21a27f 100644
--- a/drivers/isdn/hisax/hfc_sx.c
+++ b/drivers/isdn/hisax/hfc_sx.c
@@ -1251,8 +1251,10 @@ setstack_2b(struct PStack *st, struct BCState *bcs)
1251/* handle L1 state changes */ 1251/* handle L1 state changes */
1252/***************************/ 1252/***************************/
1253static void 1253static void
1254hfcsx_bh(struct IsdnCardState *cs) 1254hfcsx_bh(struct work_struct *work)
1255{ 1255{
1256 struct IsdnCardState *cs =
1257 container_of(work, struct IsdnCardState, tqueue);
1256 u_long flags; 1258 u_long flags;
1257 1259
1258 if (!cs) 1260 if (!cs)
@@ -1499,7 +1501,7 @@ setup_hfcsx(struct IsdnCard *card)
1499 cs->dbusytimer.function = (void *) hfcsx_dbusy_timer; 1501 cs->dbusytimer.function = (void *) hfcsx_dbusy_timer;
1500 cs->dbusytimer.data = (long) cs; 1502 cs->dbusytimer.data = (long) cs;
1501 init_timer(&cs->dbusytimer); 1503 init_timer(&cs->dbusytimer);
1502 INIT_WORK(&cs->tqueue, (void *)(void *) hfcsx_bh, cs); 1504 INIT_WORK(&cs->tqueue, hfcsx_bh);
1503 cs->readisac = NULL; 1505 cs->readisac = NULL;
1504 cs->writeisac = NULL; 1506 cs->writeisac = NULL;
1505 cs->readisacfifo = NULL; 1507 cs->readisacfifo = NULL;
diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
index da706925d54d..682cac32f259 100644
--- a/drivers/isdn/hisax/icc.c
+++ b/drivers/isdn/hisax/icc.c
@@ -77,8 +77,10 @@ icc_new_ph(struct IsdnCardState *cs)
77} 77}
78 78
79static void 79static void
80icc_bh(struct IsdnCardState *cs) 80icc_bh(struct work_struct *work)
81{ 81{
82 struct IsdnCardState *cs =
83 container_of(work, struct IsdnCardState, tqueue);
82 struct PStack *stptr; 84 struct PStack *stptr;
83 85
84 if (!cs) 86 if (!cs)
@@ -674,7 +676,7 @@ clear_pending_icc_ints(struct IsdnCardState *cs)
674void __devinit 676void __devinit
675setup_icc(struct IsdnCardState *cs) 677setup_icc(struct IsdnCardState *cs)
676{ 678{
677 INIT_WORK(&cs->tqueue, (void *)(void *) icc_bh, cs); 679 INIT_WORK(&cs->tqueue, icc_bh);
678 cs->dbusytimer.function = (void *) dbusy_timer_handler; 680 cs->dbusytimer.function = (void *) dbusy_timer_handler;
679 cs->dbusytimer.data = (long) cs; 681 cs->dbusytimer.data = (long) cs;
680 init_timer(&cs->dbusytimer); 682 init_timer(&cs->dbusytimer);
diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
index 282f349408bc..4e9f23803dae 100644
--- a/drivers/isdn/hisax/isac.c
+++ b/drivers/isdn/hisax/isac.c
@@ -81,8 +81,10 @@ isac_new_ph(struct IsdnCardState *cs)
81} 81}
82 82
83static void 83static void
84isac_bh(struct IsdnCardState *cs) 84isac_bh(struct work_struct *work)
85{ 85{
86 struct IsdnCardState *cs =
87 container_of(work, struct IsdnCardState, tqueue);
86 struct PStack *stptr; 88 struct PStack *stptr;
87 89
88 if (!cs) 90 if (!cs)
@@ -674,7 +676,7 @@ clear_pending_isac_ints(struct IsdnCardState *cs)
674void __devinit 676void __devinit
675setup_isac(struct IsdnCardState *cs) 677setup_isac(struct IsdnCardState *cs)
676{ 678{
677 INIT_WORK(&cs->tqueue, (void *)(void *) isac_bh, cs); 679 INIT_WORK(&cs->tqueue, isac_bh);
678 cs->dbusytimer.function = (void *) dbusy_timer_handler; 680 cs->dbusytimer.function = (void *) dbusy_timer_handler;
679 cs->dbusytimer.data = (long) cs; 681 cs->dbusytimer.data = (long) cs;
680 init_timer(&cs->dbusytimer); 682 init_timer(&cs->dbusytimer);
diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
index 674af673ff96..6f1a6583b17d 100644
--- a/drivers/isdn/hisax/isar.c
+++ b/drivers/isdn/hisax/isar.c
@@ -437,8 +437,10 @@ extern void BChannel_bh(struct BCState *);
437#define B_LL_OK 10 437#define B_LL_OK 10
438 438
439static void 439static void
440isar_bh(struct BCState *bcs) 440isar_bh(struct work_struct *work)
441{ 441{
442 struct BCState *bcs = container_of(work, struct BCState, tqueue);
443
442 BChannel_bh(bcs); 444 BChannel_bh(bcs);
443 if (test_and_clear_bit(B_LL_NOCARRIER, &bcs->event)) 445 if (test_and_clear_bit(B_LL_NOCARRIER, &bcs->event))
444 ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_NOCARR); 446 ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_NOCARR);
@@ -1580,7 +1582,7 @@ isar_setup(struct IsdnCardState *cs)
1580 cs->bcs[i].mode = 0; 1582 cs->bcs[i].mode = 0;
1581 cs->bcs[i].hw.isar.dpath = i + 1; 1583 cs->bcs[i].hw.isar.dpath = i + 1;
1582 modeisar(&cs->bcs[i], 0, 0); 1584 modeisar(&cs->bcs[i], 0, 0);
1583 INIT_WORK(&cs->bcs[i].tqueue, (void *)(void *) isar_bh, &cs->bcs[i]); 1585 INIT_WORK(&cs->bcs[i].tqueue, isar_bh);
1584 } 1586 }
1585} 1587}
1586 1588
diff --git a/drivers/isdn/hisax/isdnhdlc.h b/drivers/isdn/hisax/isdnhdlc.h
index 269315988dc8..5655b5f9c48e 100644
--- a/drivers/isdn/hisax/isdnhdlc.h
+++ b/drivers/isdn/hisax/isdnhdlc.h
@@ -41,10 +41,10 @@ struct isdnhdlc_vars {
41 unsigned char shift_reg; 41 unsigned char shift_reg;
42 unsigned char ffvalue; 42 unsigned char ffvalue;
43 43
44 int data_received:1; // set if transferring data 44 unsigned int data_received:1; // set if transferring data
45 int dchannel:1; // set if D channel (send idle instead of flags) 45 unsigned int dchannel:1; // set if D channel (send idle instead of flags)
46 int do_adapt56:1; // set if 56K adaptation 46 unsigned int do_adapt56:1; // set if 56K adaptation
47 int do_closing:1; // set if in closing phase (need to send CRC + flag 47 unsigned int do_closing:1; // set if in closing phase (need to send CRC + flag
48}; 48};
49 49
50 50
diff --git a/drivers/isdn/hisax/isdnl1.c b/drivers/isdn/hisax/isdnl1.c
index bab356886483..a14204ec88ee 100644
--- a/drivers/isdn/hisax/isdnl1.c
+++ b/drivers/isdn/hisax/isdnl1.c
@@ -315,8 +315,10 @@ BChannel_proc_ack(struct BCState *bcs)
315} 315}
316 316
317void 317void
318BChannel_bh(struct BCState *bcs) 318BChannel_bh(struct work_struct *work)
319{ 319{
320 struct BCState *bcs = container_of(work, struct BCState, tqueue);
321
320 if (!bcs) 322 if (!bcs)
321 return; 323 return;
322 if (test_and_clear_bit(B_RCVBUFREADY, &bcs->event)) 324 if (test_and_clear_bit(B_RCVBUFREADY, &bcs->event))
@@ -362,7 +364,7 @@ init_bcstate(struct IsdnCardState *cs, int bc)
362 364
363 bcs->cs = cs; 365 bcs->cs = cs;
364 bcs->channel = bc; 366 bcs->channel = bc;
365 INIT_WORK(&bcs->tqueue, (void *)(void *) BChannel_bh, bcs); 367 INIT_WORK(&bcs->tqueue, BChannel_bh);
366 spin_lock_init(&bcs->aclock); 368 spin_lock_init(&bcs->aclock);
367 bcs->BC_SetStack = NULL; 369 bcs->BC_SetStack = NULL;
368 bcs->BC_Close = NULL; 370 bcs->BC_Close = NULL;
diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
index 1655341797a9..3aeceaf9769e 100644
--- a/drivers/isdn/hisax/w6692.c
+++ b/drivers/isdn/hisax/w6692.c
@@ -101,8 +101,10 @@ W6692_new_ph(struct IsdnCardState *cs)
101} 101}
102 102
103static void 103static void
104W6692_bh(struct IsdnCardState *cs) 104W6692_bh(struct work_struct *work)
105{ 105{
106 struct IsdnCardState *cs =
107 container_of(work, struct IsdnCardState, tqueue);
106 struct PStack *stptr; 108 struct PStack *stptr;
107 109
108 if (!cs) 110 if (!cs)
@@ -1070,7 +1072,7 @@ setup_w6692(struct IsdnCard *card)
1070 id_list[cs->subtyp].card_name, cs->irq, 1072 id_list[cs->subtyp].card_name, cs->irq,
1071 cs->hw.w6692.iobase); 1073 cs->hw.w6692.iobase);
1072 1074
1073 INIT_WORK(&cs->tqueue, (void *)(void *) W6692_bh, cs); 1075 INIT_WORK(&cs->tqueue, W6692_bh);
1074 cs->readW6692 = &ReadW6692; 1076 cs->readW6692 = &ReadW6692;
1075 cs->writeW6692 = &WriteW6692; 1077 cs->writeW6692 = &WriteW6692;
1076 cs->readisacfifo = &ReadISACfifo; 1078 cs->readisacfifo = &ReadISACfifo;
diff --git a/drivers/isdn/hysdn/boardergo.c b/drivers/isdn/hysdn/boardergo.c
index 82e42a80dc4b..a1206498a1cf 100644
--- a/drivers/isdn/hysdn/boardergo.c
+++ b/drivers/isdn/hysdn/boardergo.c
@@ -71,8 +71,9 @@ ergo_interrupt(int intno, void *dev_id)
71/* may be queued from everywhere (interrupts included). */ 71/* may be queued from everywhere (interrupts included). */
72/******************************************************************************/ 72/******************************************************************************/
73static void 73static void
74ergo_irq_bh(hysdn_card * card) 74ergo_irq_bh(struct work_struct *ugli_api)
75{ 75{
76 hysdn_card * card = container_of(ugli_api, hysdn_card, irq_queue);
76 tErgDpram *dpr; 77 tErgDpram *dpr;
77 int again; 78 int again;
78 unsigned long flags; 79 unsigned long flags;
@@ -442,7 +443,7 @@ ergo_inithardware(hysdn_card * card)
442 card->writebootseq = ergo_writebootseq; 443 card->writebootseq = ergo_writebootseq;
443 card->waitpofready = ergo_waitpofready; 444 card->waitpofready = ergo_waitpofready;
444 card->set_errlog_state = ergo_set_errlog_state; 445 card->set_errlog_state = ergo_set_errlog_state;
445 INIT_WORK(&card->irq_queue, (void *) (void *) ergo_irq_bh, card); 446 INIT_WORK(&card->irq_queue, ergo_irq_bh);
446 card->hysdn_lock = SPIN_LOCK_UNLOCKED; 447 card->hysdn_lock = SPIN_LOCK_UNLOCKED;
447 448
448 return (0); 449 return (0);
diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
index 1f8d6ae66b41..2e4daebfb7e0 100644
--- a/drivers/isdn/i4l/isdn_net.c
+++ b/drivers/isdn/i4l/isdn_net.c
@@ -984,9 +984,9 @@ void isdn_net_write_super(isdn_net_local *lp, struct sk_buff *skb)
984/* 984/*
985 * called from tq_immediate 985 * called from tq_immediate
986 */ 986 */
987static void isdn_net_softint(void *private) 987static void isdn_net_softint(struct work_struct *work)
988{ 988{
989 isdn_net_local *lp = private; 989 isdn_net_local *lp = container_of(work, isdn_net_local, tqueue);
990 struct sk_buff *skb; 990 struct sk_buff *skb;
991 991
992 spin_lock_bh(&lp->xmit_lock); 992 spin_lock_bh(&lp->xmit_lock);
@@ -2596,7 +2596,7 @@ isdn_net_new(char *name, struct net_device *master)
2596 netdev->local->netdev = netdev; 2596 netdev->local->netdev = netdev;
2597 netdev->local->next = netdev->local; 2597 netdev->local->next = netdev->local;
2598 2598
2599 INIT_WORK(&netdev->local->tqueue, (void *)(void *) isdn_net_softint, netdev->local); 2599 INIT_WORK(&netdev->local->tqueue, isdn_net_softint);
2600 spin_lock_init(&netdev->local->xmit_lock); 2600 spin_lock_init(&netdev->local->xmit_lock);
2601 2601
2602 netdev->local->isdn_device = -1; 2602 netdev->local->isdn_device = -1;
diff --git a/drivers/isdn/pcbit/drv.c b/drivers/isdn/pcbit/drv.c
index 6ead5e1508b7..1966f3410a13 100644
--- a/drivers/isdn/pcbit/drv.c
+++ b/drivers/isdn/pcbit/drv.c
@@ -68,8 +68,6 @@ static void pcbit_set_msn(struct pcbit_dev *dev, char *list);
68static int pcbit_check_msn(struct pcbit_dev *dev, char *msn); 68static int pcbit_check_msn(struct pcbit_dev *dev, char *msn);
69 69
70 70
71extern void pcbit_deliver(void * data);
72
73int pcbit_init_dev(int board, int mem_base, int irq) 71int pcbit_init_dev(int board, int mem_base, int irq)
74{ 72{
75 struct pcbit_dev *dev; 73 struct pcbit_dev *dev;
@@ -129,7 +127,7 @@ int pcbit_init_dev(int board, int mem_base, int irq)
129 memset(dev->b2, 0, sizeof(struct pcbit_chan)); 127 memset(dev->b2, 0, sizeof(struct pcbit_chan));
130 dev->b2->id = 1; 128 dev->b2->id = 1;
131 129
132 INIT_WORK(&dev->qdelivery, pcbit_deliver, dev); 130 INIT_WORK(&dev->qdelivery, pcbit_deliver);
133 131
134 /* 132 /*
135 * interrupts 133 * interrupts
diff --git a/drivers/isdn/pcbit/layer2.c b/drivers/isdn/pcbit/layer2.c
index 937fd2120381..0c9f6df873fc 100644
--- a/drivers/isdn/pcbit/layer2.c
+++ b/drivers/isdn/pcbit/layer2.c
@@ -67,7 +67,6 @@ extern void pcbit_l3_receive(struct pcbit_dev *dev, ulong msg,
67 * Prototypes 67 * Prototypes
68 */ 68 */
69 69
70void pcbit_deliver(void *data);
71static void pcbit_transmit(struct pcbit_dev *dev); 70static void pcbit_transmit(struct pcbit_dev *dev);
72 71
73static void pcbit_recv_ack(struct pcbit_dev *dev, unsigned char ack); 72static void pcbit_recv_ack(struct pcbit_dev *dev, unsigned char ack);
@@ -299,11 +298,12 @@ pcbit_transmit(struct pcbit_dev *dev)
299 */ 298 */
300 299
301void 300void
302pcbit_deliver(void *data) 301pcbit_deliver(struct work_struct *work)
303{ 302{
304 struct frame_buf *frame; 303 struct frame_buf *frame;
305 unsigned long flags, msg; 304 unsigned long flags, msg;
306 struct pcbit_dev *dev = (struct pcbit_dev *) data; 305 struct pcbit_dev *dev =
306 container_of(work, struct pcbit_dev, qdelivery);
307 307
308 spin_lock_irqsave(&dev->lock, flags); 308 spin_lock_irqsave(&dev->lock, flags);
309 309
diff --git a/drivers/isdn/pcbit/pcbit.h b/drivers/isdn/pcbit/pcbit.h
index 388bacefd23a..19c18e88ff16 100644
--- a/drivers/isdn/pcbit/pcbit.h
+++ b/drivers/isdn/pcbit/pcbit.h
@@ -166,4 +166,6 @@ struct pcbit_ioctl {
166#define L2_RUNNING 5 166#define L2_RUNNING 5
167#define L2_ERROR 6 167#define L2_ERROR 6
168 168
169extern void pcbit_deliver(struct work_struct *work);
170
169#endif 171#endif
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 9c39b98d5a5b..176142c61492 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -76,6 +76,12 @@ config LEDS_NET48XX
76 This option enables support for the Soekris net4801 and net4826 error 76 This option enables support for the Soekris net4801 and net4826 error
77 LED. 77 LED.
78 78
79config LEDS_WRAP
80 tristate "LED Support for the WRAP series LEDs"
81 depends on LEDS_CLASS && SCx200_GPIO
82 help
83 This option enables support for the PCEngines WRAP programmable LEDs.
84
79comment "LED Triggers" 85comment "LED Triggers"
80 86
81config LEDS_TRIGGERS 87config LEDS_TRIGGERS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 6aa2aed7539d..500de3dc962a 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -13,6 +13,7 @@ obj-$(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 15obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o
16obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o
16 17
17# LED Triggers 18# LED Triggers
18obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o 19obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
diff --git a/drivers/leds/leds-wrap.c b/drivers/leds/leds-wrap.c
new file mode 100644
index 000000000000..27fb2d8e991f
--- /dev/null
+++ b/drivers/leds/leds-wrap.c
@@ -0,0 +1,142 @@
1/*
2 * LEDs driver for PCEngines WRAP
3 *
4 * Copyright (C) 2006 Kristian Kielhofner <kris@krisk.org>
5 *
6 * Based on leds-net48xx.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 DRVNAME "wrap-led"
22#define WRAP_ERROR_LED_GPIO 3
23#define WRAP_EXTRA_LED_GPIO 18
24
25static struct platform_device *pdev;
26
27static void wrap_error_led_set(struct led_classdev *led_cdev,
28 enum led_brightness value)
29{
30 if (value)
31 scx200_gpio_set_low(WRAP_ERROR_LED_GPIO);
32 else
33 scx200_gpio_set_high(WRAP_ERROR_LED_GPIO);
34}
35
36static void wrap_extra_led_set(struct led_classdev *led_cdev,
37 enum led_brightness value)
38{
39 if (value)
40 scx200_gpio_set_low(WRAP_EXTRA_LED_GPIO);
41 else
42 scx200_gpio_set_high(WRAP_EXTRA_LED_GPIO);
43}
44
45static struct led_classdev wrap_error_led = {
46 .name = "wrap:error",
47 .brightness_set = wrap_error_led_set,
48};
49
50static struct led_classdev wrap_extra_led = {
51 .name = "wrap:extra",
52 .brightness_set = wrap_extra_led_set,
53};
54
55#ifdef CONFIG_PM
56static int wrap_led_suspend(struct platform_device *dev,
57 pm_message_t state)
58{
59 led_classdev_suspend(&wrap_error_led);
60 led_classdev_suspend(&wrap_extra_led);
61 return 0;
62}
63
64static int wrap_led_resume(struct platform_device *dev)
65{
66 led_classdev_resume(&wrap_error_led);
67 led_classdev_resume(&wrap_extra_led);
68 return 0;
69}
70#else
71#define wrap_led_suspend NULL
72#define wrap_led_resume NULL
73#endif
74
75static int wrap_led_probe(struct platform_device *pdev)
76{
77 int ret;
78
79 ret = led_classdev_register(&pdev->dev, &wrap_error_led);
80 if (ret == 0) {
81 ret = led_classdev_register(&pdev->dev, &wrap_extra_led);
82 if (ret < 0)
83 led_classdev_unregister(&wrap_error_led);
84 }
85 return ret;
86}
87
88static int wrap_led_remove(struct platform_device *pdev)
89{
90 led_classdev_unregister(&wrap_error_led);
91 led_classdev_unregister(&wrap_extra_led);
92 return 0;
93}
94
95static struct platform_driver wrap_led_driver = {
96 .probe = wrap_led_probe,
97 .remove = wrap_led_remove,
98 .suspend = wrap_led_suspend,
99 .resume = wrap_led_resume,
100 .driver = {
101 .name = DRVNAME,
102 .owner = THIS_MODULE,
103 },
104};
105
106static int __init wrap_led_init(void)
107{
108 int ret;
109
110 if (!scx200_gpio_present()) {
111 ret = -ENODEV;
112 goto out;
113 }
114
115 ret = platform_driver_register(&wrap_led_driver);
116 if (ret < 0)
117 goto out;
118
119 pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
120 if (IS_ERR(pdev)) {
121 ret = PTR_ERR(pdev);
122 platform_driver_unregister(&wrap_led_driver);
123 goto out;
124 }
125
126out:
127 return ret;
128}
129
130static void __exit wrap_led_exit(void)
131{
132 platform_device_unregister(pdev);
133 platform_driver_unregister(&wrap_led_driver);
134}
135
136module_init(wrap_led_init);
137module_exit(wrap_led_exit);
138
139MODULE_AUTHOR("Kristian Kielhofner <kris@krisk.org>");
140MODULE_DESCRIPTION("PCEngines WRAP LED driver");
141MODULE_LICENSE("GPL");
142
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index be0bd34ff6f9..d43ea81d6df9 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -267,12 +267,12 @@ adb_probe_task(void *x)
267} 267}
268 268
269static void 269static void
270__adb_probe_task(void *data) 270__adb_probe_task(struct work_struct *bullshit)
271{ 271{
272 adb_probe_task_pid = kernel_thread(adb_probe_task, NULL, SIGCHLD | CLONE_KERNEL); 272 adb_probe_task_pid = kernel_thread(adb_probe_task, NULL, SIGCHLD | CLONE_KERNEL);
273} 273}
274 274
275static DECLARE_WORK(adb_reset_work, __adb_probe_task, NULL); 275static DECLARE_WORK(adb_reset_work, __adb_probe_task);
276 276
277int 277int
278adb_reset_bus(void) 278adb_reset_bus(void)
diff --git a/drivers/macintosh/apm_emu.c b/drivers/macintosh/apm_emu.c
index 1293876a2ebd..8862a83b8d84 100644
--- a/drivers/macintosh/apm_emu.c
+++ b/drivers/macintosh/apm_emu.c
@@ -529,7 +529,8 @@ static int __init apm_emu_init(void)
529 if (apm_proc) 529 if (apm_proc)
530 apm_proc->owner = THIS_MODULE; 530 apm_proc->owner = THIS_MODULE;
531 531
532 misc_register(&apm_device); 532 if (misc_register(&apm_device) != 0)
533 printk(KERN_INFO "Could not create misc. device for apm\n");
533 534
534 pmu_register_sleep_notifier(&apm_sleep_notifier); 535 pmu_register_sleep_notifier(&apm_sleep_notifier);
535 536
diff --git a/drivers/macintosh/rack-meter.c b/drivers/macintosh/rack-meter.c
index f1b6f563673a..5ed41fe84e57 100644
--- a/drivers/macintosh/rack-meter.c
+++ b/drivers/macintosh/rack-meter.c
@@ -48,7 +48,8 @@ struct rackmeter_dma {
48} ____cacheline_aligned; 48} ____cacheline_aligned;
49 49
50struct rackmeter_cpu { 50struct rackmeter_cpu {
51 struct work_struct sniffer; 51 struct delayed_work sniffer;
52 struct rackmeter *rm;
52 cputime64_t prev_wall; 53 cputime64_t prev_wall;
53 cputime64_t prev_idle; 54 cputime64_t prev_idle;
54 int zero; 55 int zero;
@@ -208,11 +209,12 @@ static void rackmeter_setup_dbdma(struct rackmeter *rm)
208 rackmeter_do_pause(rm, 0); 209 rackmeter_do_pause(rm, 0);
209} 210}
210 211
211static void rackmeter_do_timer(void *data) 212static void rackmeter_do_timer(struct work_struct *work)
212{ 213{
213 struct rackmeter *rm = data; 214 struct rackmeter_cpu *rcpu =
215 container_of(work, struct rackmeter_cpu, sniffer.work);
216 struct rackmeter *rm = rcpu->rm;
214 unsigned int cpu = smp_processor_id(); 217 unsigned int cpu = smp_processor_id();
215 struct rackmeter_cpu *rcpu = &rm->cpu[cpu];
216 cputime64_t cur_jiffies, total_idle_ticks; 218 cputime64_t cur_jiffies, total_idle_ticks;
217 unsigned int total_ticks, idle_ticks; 219 unsigned int total_ticks, idle_ticks;
218 int i, offset, load, cumm, pause; 220 int i, offset, load, cumm, pause;
@@ -263,8 +265,10 @@ static void __devinit rackmeter_init_cpu_sniffer(struct rackmeter *rm)
263 * on those machines yet 265 * on those machines yet
264 */ 266 */
265 267
266 INIT_WORK(&rm->cpu[0].sniffer, rackmeter_do_timer, rm); 268 rm->cpu[0].rm = rm;
267 INIT_WORK(&rm->cpu[1].sniffer, rackmeter_do_timer, rm); 269 INIT_DELAYED_WORK(&rm->cpu[0].sniffer, rackmeter_do_timer);
270 rm->cpu[1].rm = rm;
271 INIT_DELAYED_WORK(&rm->cpu[1].sniffer, rackmeter_do_timer);
268 272
269 for_each_online_cpu(cpu) { 273 for_each_online_cpu(cpu) {
270 struct rackmeter_cpu *rcpu; 274 struct rackmeter_cpu *rcpu;
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index 4f724cdd2efa..6dde27ab79a8 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -601,7 +601,7 @@ core_initcall(smu_late_init);
601 * sysfs visibility 601 * sysfs visibility
602 */ 602 */
603 603
604static void smu_expose_childs(void *unused) 604static void smu_expose_childs(struct work_struct *unused)
605{ 605{
606 struct device_node *np; 606 struct device_node *np;
607 607
@@ -611,7 +611,7 @@ static void smu_expose_childs(void *unused)
611 &smu->of_dev->dev); 611 &smu->of_dev->dev);
612} 612}
613 613
614static DECLARE_WORK(smu_expose_childs_work, smu_expose_childs, NULL); 614static DECLARE_WORK(smu_expose_childs_work, smu_expose_childs);
615 615
616static int smu_platform_probe(struct of_device* dev, 616static int smu_platform_probe(struct of_device* dev,
617 const struct of_device_id *match) 617 const struct of_device_id *match)
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
index 13b953ae8ebc..3d3bf1643e73 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -24,6 +24,7 @@
24#include <linux/suspend.h> 24#include <linux/suspend.h>
25#include <linux/kthread.h> 25#include <linux/kthread.h>
26#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
27#include <linux/freezer.h>
27 28
28#include <asm/prom.h> 29#include <asm/prom.h>
29#include <asm/machdep.h> 30#include <asm/machdep.h>
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index e63ea1c1f3c1..c8558d4ed506 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -42,7 +42,7 @@
42#include <linux/interrupt.h> 42#include <linux/interrupt.h>
43#include <linux/device.h> 43#include <linux/device.h>
44#include <linux/sysdev.h> 44#include <linux/sysdev.h>
45#include <linux/suspend.h> 45#include <linux/freezer.h>
46#include <linux/syscalls.h> 46#include <linux/syscalls.h>
47#include <linux/cpu.h> 47#include <linux/cpu.h>
48#include <asm/prom.h> 48#include <asm/prom.h>
diff --git a/drivers/macintosh/windfarm_core.c b/drivers/macintosh/windfarm_core.c
index ab3faa702d58..e947af982f93 100644
--- a/drivers/macintosh/windfarm_core.c
+++ b/drivers/macintosh/windfarm_core.c
@@ -34,6 +34,7 @@
34#include <linux/device.h> 34#include <linux/device.h>
35#include <linux/platform_device.h> 35#include <linux/platform_device.h>
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <linux/freezer.h>
37 38
38#include <asm/prom.h> 39#include <asm/prom.h>
39 40
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 08a40f4e4f60..c7bee4f2eedb 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -101,7 +101,7 @@ struct crypt_config {
101#define MIN_POOL_PAGES 32 101#define MIN_POOL_PAGES 32
102#define MIN_BIO_PAGES 8 102#define MIN_BIO_PAGES 8
103 103
104static kmem_cache_t *_crypt_io_pool; 104static struct kmem_cache *_crypt_io_pool;
105 105
106/* 106/*
107 * Different IV generation algorithms: 107 * Different IV generation algorithms:
@@ -458,11 +458,11 @@ static void dec_pending(struct crypt_io *io, int error)
458 * interrupt context. 458 * interrupt context.
459 */ 459 */
460static struct workqueue_struct *_kcryptd_workqueue; 460static struct workqueue_struct *_kcryptd_workqueue;
461static void kcryptd_do_work(void *data); 461static void kcryptd_do_work(struct work_struct *work);
462 462
463static void kcryptd_queue_io(struct crypt_io *io) 463static void kcryptd_queue_io(struct crypt_io *io)
464{ 464{
465 INIT_WORK(&io->work, kcryptd_do_work, io); 465 INIT_WORK(&io->work, kcryptd_do_work);
466 queue_work(_kcryptd_workqueue, &io->work); 466 queue_work(_kcryptd_workqueue, &io->work);
467} 467}
468 468
@@ -618,9 +618,9 @@ static void process_read_endio(struct crypt_io *io)
618 dec_pending(io, crypt_convert(cc, &ctx)); 618 dec_pending(io, crypt_convert(cc, &ctx));
619} 619}
620 620
621static void kcryptd_do_work(void *data) 621static void kcryptd_do_work(struct work_struct *work)
622{ 622{
623 struct crypt_io *io = data; 623 struct crypt_io *io = container_of(work, struct crypt_io, work);
624 624
625 if (io->post_process) 625 if (io->post_process)
626 process_read_endio(io); 626 process_read_endio(io);
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index d754e0bc6e90..cf8bf052138e 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -101,11 +101,11 @@ typedef int (*action_fn) (struct pgpath *pgpath);
101 101
102#define MIN_IOS 256 /* Mempool size */ 102#define MIN_IOS 256 /* Mempool size */
103 103
104static kmem_cache_t *_mpio_cache; 104static struct kmem_cache *_mpio_cache;
105 105
106struct workqueue_struct *kmultipathd; 106struct workqueue_struct *kmultipathd;
107static void process_queued_ios(void *data); 107static void process_queued_ios(struct work_struct *work);
108static void trigger_event(void *data); 108static void trigger_event(struct work_struct *work);
109 109
110 110
111/*----------------------------------------------- 111/*-----------------------------------------------
@@ -173,8 +173,8 @@ static struct multipath *alloc_multipath(struct dm_target *ti)
173 INIT_LIST_HEAD(&m->priority_groups); 173 INIT_LIST_HEAD(&m->priority_groups);
174 spin_lock_init(&m->lock); 174 spin_lock_init(&m->lock);
175 m->queue_io = 1; 175 m->queue_io = 1;
176 INIT_WORK(&m->process_queued_ios, process_queued_ios, m); 176 INIT_WORK(&m->process_queued_ios, process_queued_ios);
177 INIT_WORK(&m->trigger_event, trigger_event, m); 177 INIT_WORK(&m->trigger_event, trigger_event);
178 m->mpio_pool = mempool_create_slab_pool(MIN_IOS, _mpio_cache); 178 m->mpio_pool = mempool_create_slab_pool(MIN_IOS, _mpio_cache);
179 if (!m->mpio_pool) { 179 if (!m->mpio_pool) {
180 kfree(m); 180 kfree(m);
@@ -379,9 +379,10 @@ static void dispatch_queued_ios(struct multipath *m)
379 } 379 }
380} 380}
381 381
382static void process_queued_ios(void *data) 382static void process_queued_ios(struct work_struct *work)
383{ 383{
384 struct multipath *m = (struct multipath *) data; 384 struct multipath *m =
385 container_of(work, struct multipath, process_queued_ios);
385 struct hw_handler *hwh = &m->hw_handler; 386 struct hw_handler *hwh = &m->hw_handler;
386 struct pgpath *pgpath = NULL; 387 struct pgpath *pgpath = NULL;
387 unsigned init_required = 0, must_queue = 1; 388 unsigned init_required = 0, must_queue = 1;
@@ -421,9 +422,10 @@ out:
421 * An event is triggered whenever a path is taken out of use. 422 * An event is triggered whenever a path is taken out of use.
422 * Includes path failure and PG bypass. 423 * Includes path failure and PG bypass.
423 */ 424 */
424static void trigger_event(void *data) 425static void trigger_event(struct work_struct *work)
425{ 426{
426 struct multipath *m = (struct multipath *) data; 427 struct multipath *m =
428 container_of(work, struct multipath, trigger_event);
427 429
428 dm_table_event(m->ti->table); 430 dm_table_event(m->ti->table);
429} 431}
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 48a653b3f518..fc8cbb168e3e 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -883,7 +883,7 @@ static void do_mirror(struct mirror_set *ms)
883 do_writes(ms, &writes); 883 do_writes(ms, &writes);
884} 884}
885 885
886static void do_work(void *ignored) 886static void do_work(struct work_struct *ignored)
887{ 887{
888 struct mirror_set *ms; 888 struct mirror_set *ms;
889 889
@@ -1269,7 +1269,7 @@ static int __init dm_mirror_init(void)
1269 dm_dirty_log_exit(); 1269 dm_dirty_log_exit();
1270 return r; 1270 return r;
1271 } 1271 }
1272 INIT_WORK(&_kmirrord_work, do_work, NULL); 1272 INIT_WORK(&_kmirrord_work, do_work);
1273 1273
1274 r = dm_register_target(&mirror_target); 1274 r = dm_register_target(&mirror_target);
1275 if (r < 0) { 1275 if (r < 0) {
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 5281e0094072..b0ce2ce82278 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -40,7 +40,7 @@
40#define SNAPSHOT_PAGES 256 40#define SNAPSHOT_PAGES 256
41 41
42struct workqueue_struct *ksnapd; 42struct workqueue_struct *ksnapd;
43static void flush_queued_bios(void *data); 43static void flush_queued_bios(struct work_struct *work);
44 44
45struct pending_exception { 45struct pending_exception {
46 struct exception e; 46 struct exception e;
@@ -88,8 +88,8 @@ struct pending_exception {
88 * Hash table mapping origin volumes to lists of snapshots and 88 * Hash table mapping origin volumes to lists of snapshots and
89 * a lock to protect it 89 * a lock to protect it
90 */ 90 */
91static kmem_cache_t *exception_cache; 91static struct kmem_cache *exception_cache;
92static kmem_cache_t *pending_cache; 92static struct kmem_cache *pending_cache;
93static mempool_t *pending_pool; 93static mempool_t *pending_pool;
94 94
95/* 95/*
@@ -228,7 +228,7 @@ static int init_exception_table(struct exception_table *et, uint32_t size)
228 return 0; 228 return 0;
229} 229}
230 230
231static void exit_exception_table(struct exception_table *et, kmem_cache_t *mem) 231static void exit_exception_table(struct exception_table *et, struct kmem_cache *mem)
232{ 232{
233 struct list_head *slot; 233 struct list_head *slot;
234 struct exception *ex, *next; 234 struct exception *ex, *next;
@@ -528,7 +528,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
528 } 528 }
529 529
530 bio_list_init(&s->queued_bios); 530 bio_list_init(&s->queued_bios);
531 INIT_WORK(&s->queued_bios_work, flush_queued_bios, s); 531 INIT_WORK(&s->queued_bios_work, flush_queued_bios);
532 532
533 /* Add snapshot to the list of snapshots for this origin */ 533 /* Add snapshot to the list of snapshots for this origin */
534 /* Exceptions aren't triggered till snapshot_resume() is called */ 534 /* Exceptions aren't triggered till snapshot_resume() is called */
@@ -603,9 +603,10 @@ static void flush_bios(struct bio *bio)
603 } 603 }
604} 604}
605 605
606static void flush_queued_bios(void *data) 606static void flush_queued_bios(struct work_struct *work)
607{ 607{
608 struct dm_snapshot *s = (struct dm_snapshot *) data; 608 struct dm_snapshot *s =
609 container_of(work, struct dm_snapshot, queued_bios_work);
609 struct bio *queued_bios; 610 struct bio *queued_bios;
610 unsigned long flags; 611 unsigned long flags;
611 612
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index fc4f743f3b53..7ec1b112a6d5 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -121,8 +121,8 @@ struct mapped_device {
121}; 121};
122 122
123#define MIN_IOS 256 123#define MIN_IOS 256
124static kmem_cache_t *_io_cache; 124static struct kmem_cache *_io_cache;
125static kmem_cache_t *_tio_cache; 125static struct kmem_cache *_tio_cache;
126 126
127static int __init local_init(void) 127static int __init local_init(void)
128{ 128{
diff --git a/drivers/md/kcopyd.c b/drivers/md/kcopyd.c
index f1db6eff4857..b46f6c575f7e 100644
--- a/drivers/md/kcopyd.c
+++ b/drivers/md/kcopyd.c
@@ -203,7 +203,7 @@ struct kcopyd_job {
203/* FIXME: this should scale with the number of pages */ 203/* FIXME: this should scale with the number of pages */
204#define MIN_JOBS 512 204#define MIN_JOBS 512
205 205
206static kmem_cache_t *_job_cache; 206static struct kmem_cache *_job_cache;
207static mempool_t *_job_pool; 207static mempool_t *_job_pool;
208 208
209/* 209/*
@@ -417,7 +417,7 @@ static int process_jobs(struct list_head *jobs, int (*fn) (struct kcopyd_job *))
417/* 417/*
418 * kcopyd does this every time it's woken up. 418 * kcopyd does this every time it's woken up.
419 */ 419 */
420static void do_work(void *ignored) 420static void do_work(struct work_struct *ignored)
421{ 421{
422 /* 422 /*
423 * The order that these are called is *very* important. 423 * The order that these are called is *very* important.
@@ -628,7 +628,7 @@ static int kcopyd_init(void)
628 } 628 }
629 629
630 kcopyd_clients++; 630 kcopyd_clients++;
631 INIT_WORK(&_kcopyd_work, do_work, NULL); 631 INIT_WORK(&_kcopyd_work, do_work);
632 mutex_unlock(&kcopyd_init_lock); 632 mutex_unlock(&kcopyd_init_lock);
633 return 0; 633 return 0;
634} 634}
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 8cbf9c9df1c3..6c4345bde07e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -39,10 +39,10 @@
39#include <linux/raid/bitmap.h> 39#include <linux/raid/bitmap.h>
40#include <linux/sysctl.h> 40#include <linux/sysctl.h>
41#include <linux/buffer_head.h> /* for invalidate_bdev */ 41#include <linux/buffer_head.h> /* for invalidate_bdev */
42#include <linux/suspend.h>
43#include <linux/poll.h> 42#include <linux/poll.h>
44#include <linux/mutex.h> 43#include <linux/mutex.h>
45#include <linux/ctype.h> 44#include <linux/ctype.h>
45#include <linux/freezer.h>
46 46
47#include <linux/init.h> 47#include <linux/init.h>
48 48
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 69c3e201fa3b..52914d5cec76 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -348,7 +348,7 @@ static int grow_one_stripe(raid5_conf_t *conf)
348 348
349static int grow_stripes(raid5_conf_t *conf, int num) 349static int grow_stripes(raid5_conf_t *conf, int num)
350{ 350{
351 kmem_cache_t *sc; 351 struct kmem_cache *sc;
352 int devs = conf->raid_disks; 352 int devs = conf->raid_disks;
353 353
354 sprintf(conf->cache_name[0], "raid5/%s", mdname(conf->mddev)); 354 sprintf(conf->cache_name[0], "raid5/%s", mdname(conf->mddev));
@@ -397,7 +397,7 @@ static int resize_stripes(raid5_conf_t *conf, int newsize)
397 LIST_HEAD(newstripes); 397 LIST_HEAD(newstripes);
398 struct disk_info *ndisks; 398 struct disk_info *ndisks;
399 int err = 0; 399 int err = 0;
400 kmem_cache_t *sc; 400 struct kmem_cache *sc;
401 int i; 401 int i;
402 402
403 if (newsize <= conf->pool_size) 403 if (newsize <= conf->pool_size)
diff --git a/drivers/media/dvb/b2c2/flexcop-pci.c b/drivers/media/dvb/b2c2/flexcop-pci.c
index 06893243f3d4..6e166801505d 100644
--- a/drivers/media/dvb/b2c2/flexcop-pci.c
+++ b/drivers/media/dvb/b2c2/flexcop-pci.c
@@ -63,7 +63,7 @@ struct flexcop_pci {
63 63
64 unsigned long last_irq; 64 unsigned long last_irq;
65 65
66 struct work_struct irq_check_work; 66 struct delayed_work irq_check_work;
67 67
68 struct flexcop_device *fc_dev; 68 struct flexcop_device *fc_dev;
69}; 69};
@@ -97,9 +97,10 @@ static int flexcop_pci_write_ibi_reg(struct flexcop_device *fc, flexcop_ibi_regi
97 return 0; 97 return 0;
98} 98}
99 99
100static void flexcop_pci_irq_check_work(void *data) 100static void flexcop_pci_irq_check_work(struct work_struct *work)
101{ 101{
102 struct flexcop_pci *fc_pci = data; 102 struct flexcop_pci *fc_pci =
103 container_of(work, struct flexcop_pci, irq_check_work.work);
103 struct flexcop_device *fc = fc_pci->fc_dev; 104 struct flexcop_device *fc = fc_pci->fc_dev;
104 105
105 flexcop_ibi_value v = fc->read_ibi_reg(fc,sram_dest_reg_714); 106 flexcop_ibi_value v = fc->read_ibi_reg(fc,sram_dest_reg_714);
@@ -371,7 +372,7 @@ static int flexcop_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
371 if ((ret = flexcop_pci_dma_init(fc_pci)) != 0) 372 if ((ret = flexcop_pci_dma_init(fc_pci)) != 0)
372 goto err_fc_exit; 373 goto err_fc_exit;
373 374
374 INIT_WORK(&fc_pci->irq_check_work, flexcop_pci_irq_check_work, fc_pci); 375 INIT_DELAYED_WORK(&fc_pci->irq_check_work, flexcop_pci_irq_check_work);
375 376
376 return ret; 377 return ret;
377 378
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index 8a7dd507cf6e..9123147e376f 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -128,7 +128,7 @@ struct cinergyt2 {
128 128
129 struct dvbt_set_parameters_msg param; 129 struct dvbt_set_parameters_msg param;
130 struct dvbt_get_status_msg status; 130 struct dvbt_get_status_msg status;
131 struct work_struct query_work; 131 struct delayed_work query_work;
132 132
133 wait_queue_head_t poll_wq; 133 wait_queue_head_t poll_wq;
134 int pending_fe_events; 134 int pending_fe_events;
@@ -142,7 +142,7 @@ struct cinergyt2 {
142#ifdef ENABLE_RC 142#ifdef ENABLE_RC
143 struct input_dev *rc_input_dev; 143 struct input_dev *rc_input_dev;
144 char phys[64]; 144 char phys[64];
145 struct work_struct rc_query_work; 145 struct delayed_work rc_query_work;
146 int rc_input_event; 146 int rc_input_event;
147 u32 rc_last_code; 147 u32 rc_last_code;
148 unsigned long last_event_jiffies; 148 unsigned long last_event_jiffies;
@@ -287,7 +287,7 @@ static int cinergyt2_alloc_stream_urbs (struct cinergyt2 *cinergyt2)
287 int i; 287 int i;
288 288
289 cinergyt2->streambuf = usb_buffer_alloc(cinergyt2->udev, STREAM_URB_COUNT*STREAM_BUF_SIZE, 289 cinergyt2->streambuf = usb_buffer_alloc(cinergyt2->udev, STREAM_URB_COUNT*STREAM_BUF_SIZE,
290 SLAB_KERNEL, &cinergyt2->streambuf_dmahandle); 290 GFP_KERNEL, &cinergyt2->streambuf_dmahandle);
291 if (!cinergyt2->streambuf) { 291 if (!cinergyt2->streambuf) {
292 dprintk(1, "failed to alloc consistent stream memory area, bailing out!\n"); 292 dprintk(1, "failed to alloc consistent stream memory area, bailing out!\n");
293 return -ENOMEM; 293 return -ENOMEM;
@@ -723,9 +723,10 @@ static struct dvb_device cinergyt2_fe_template = {
723 723
724#ifdef ENABLE_RC 724#ifdef ENABLE_RC
725 725
726static void cinergyt2_query_rc (void *data) 726static void cinergyt2_query_rc (struct work_struct *work)
727{ 727{
728 struct cinergyt2 *cinergyt2 = data; 728 struct cinergyt2 *cinergyt2 =
729 container_of(work, struct cinergyt2, rc_query_work.work);
729 char buf[1] = { CINERGYT2_EP1_GET_RC_EVENTS }; 730 char buf[1] = { CINERGYT2_EP1_GET_RC_EVENTS };
730 struct cinergyt2_rc_event rc_events[12]; 731 struct cinergyt2_rc_event rc_events[12];
731 int n, len, i; 732 int n, len, i;
@@ -806,7 +807,7 @@ static int cinergyt2_register_rc(struct cinergyt2 *cinergyt2)
806 strlcat(cinergyt2->phys, "/input0", sizeof(cinergyt2->phys)); 807 strlcat(cinergyt2->phys, "/input0", sizeof(cinergyt2->phys));
807 cinergyt2->rc_input_event = KEY_MAX; 808 cinergyt2->rc_input_event = KEY_MAX;
808 cinergyt2->rc_last_code = ~0; 809 cinergyt2->rc_last_code = ~0;
809 INIT_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc, cinergyt2); 810 INIT_DELAYED_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc);
810 811
811 input_dev->name = DRIVER_NAME " remote control"; 812 input_dev->name = DRIVER_NAME " remote control";
812 input_dev->phys = cinergyt2->phys; 813 input_dev->phys = cinergyt2->phys;
@@ -847,9 +848,10 @@ static inline void cinergyt2_resume_rc(struct cinergyt2 *cinergyt2) { }
847 848
848#endif /* ENABLE_RC */ 849#endif /* ENABLE_RC */
849 850
850static void cinergyt2_query (void *data) 851static void cinergyt2_query (struct work_struct *work)
851{ 852{
852 struct cinergyt2 *cinergyt2 = (struct cinergyt2 *) data; 853 struct cinergyt2 *cinergyt2 =
854 container_of(work, struct cinergyt2, query_work.work);
853 char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS }; 855 char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
854 struct dvbt_get_status_msg *s = &cinergyt2->status; 856 struct dvbt_get_status_msg *s = &cinergyt2->status;
855 uint8_t lock_bits; 857 uint8_t lock_bits;
@@ -893,7 +895,7 @@ static int cinergyt2_probe (struct usb_interface *intf,
893 895
894 mutex_init(&cinergyt2->sem); 896 mutex_init(&cinergyt2->sem);
895 init_waitqueue_head (&cinergyt2->poll_wq); 897 init_waitqueue_head (&cinergyt2->poll_wq);
896 INIT_WORK(&cinergyt2->query_work, cinergyt2_query, cinergyt2); 898 INIT_DELAYED_WORK(&cinergyt2->query_work, cinergyt2_query);
897 899
898 cinergyt2->udev = interface_to_usbdev(intf); 900 cinergyt2->udev = interface_to_usbdev(intf);
899 cinergyt2->param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS; 901 cinergyt2->param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index a2ab2eebfc68..e85972222ab4 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -34,7 +34,7 @@
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/moduleparam.h> 35#include <linux/moduleparam.h>
36#include <linux/list.h> 36#include <linux/list.h>
37#include <linux/suspend.h> 37#include <linux/freezer.h>
38#include <linux/jiffies.h> 38#include <linux/jiffies.h>
39#include <asm/processor.h> 39#include <asm/processor.h>
40 40
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 8859ab74f0fe..ebf4dc5190f6 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -127,6 +127,7 @@ struct dvb_net_priv {
127 int in_use; 127 int in_use;
128 struct net_device_stats stats; 128 struct net_device_stats stats;
129 u16 pid; 129 u16 pid;
130 struct net_device *net;
130 struct dvb_net *host; 131 struct dvb_net *host;
131 struct dmx_demux *demux; 132 struct dmx_demux *demux;
132 struct dmx_section_feed *secfeed; 133 struct dmx_section_feed *secfeed;
@@ -1123,10 +1124,11 @@ static int dvb_set_mc_filter (struct net_device *dev, struct dev_mc_list *mc)
1123} 1124}
1124 1125
1125 1126
1126static void wq_set_multicast_list (void *data) 1127static void wq_set_multicast_list (struct work_struct *work)
1127{ 1128{
1128 struct net_device *dev = data; 1129 struct dvb_net_priv *priv =
1129 struct dvb_net_priv *priv = dev->priv; 1130 container_of(work, struct dvb_net_priv, set_multicast_list_wq);
1131 struct net_device *dev = priv->net;
1130 1132
1131 dvb_net_feed_stop(dev); 1133 dvb_net_feed_stop(dev);
1132 priv->rx_mode = RX_MODE_UNI; 1134 priv->rx_mode = RX_MODE_UNI;
@@ -1167,9 +1169,11 @@ static void dvb_net_set_multicast_list (struct net_device *dev)
1167} 1169}
1168 1170
1169 1171
1170static void wq_restart_net_feed (void *data) 1172static void wq_restart_net_feed (struct work_struct *work)
1171{ 1173{
1172 struct net_device *dev = data; 1174 struct dvb_net_priv *priv =
1175 container_of(work, struct dvb_net_priv, restart_net_feed_wq);
1176 struct net_device *dev = priv->net;
1173 1177
1174 if (netif_running(dev)) { 1178 if (netif_running(dev)) {
1175 dvb_net_feed_stop(dev); 1179 dvb_net_feed_stop(dev);
@@ -1276,6 +1280,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
1276 dvbnet->device[if_num] = net; 1280 dvbnet->device[if_num] = net;
1277 1281
1278 priv = net->priv; 1282 priv = net->priv;
1283 priv->net = net;
1279 priv->demux = dvbnet->demux; 1284 priv->demux = dvbnet->demux;
1280 priv->pid = pid; 1285 priv->pid = pid;
1281 priv->rx_mode = RX_MODE_UNI; 1286 priv->rx_mode = RX_MODE_UNI;
@@ -1284,8 +1289,8 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
1284 priv->feedtype = feedtype; 1289 priv->feedtype = feedtype;
1285 reset_ule(priv); 1290 reset_ule(priv);
1286 1291
1287 INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net); 1292 INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list);
1288 INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net); 1293 INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed);
1289 mutex_init(&priv->mutex); 1294 mutex_init(&priv->mutex);
1290 1295
1291 net->base_addr = pid; 1296 net->base_addr = pid;
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
index 0a3a0b6c2350..794e4471561c 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
@@ -13,9 +13,10 @@
13 * 13 *
14 * TODO: Fix the repeat rate of the input device. 14 * TODO: Fix the repeat rate of the input device.
15 */ 15 */
16static void dvb_usb_read_remote_control(void *data) 16static void dvb_usb_read_remote_control(struct work_struct *work)
17{ 17{
18 struct dvb_usb_device *d = data; 18 struct dvb_usb_device *d =
19 container_of(work, struct dvb_usb_device, rc_query_work.work);
19 u32 event; 20 u32 event;
20 int state; 21 int state;
21 22
@@ -128,7 +129,7 @@ int dvb_usb_remote_init(struct dvb_usb_device *d)
128 129
129 input_register_device(d->rc_input_dev); 130 input_register_device(d->rc_input_dev);
130 131
131 INIT_WORK(&d->rc_query_work, dvb_usb_read_remote_control, d); 132 INIT_DELAYED_WORK(&d->rc_query_work, dvb_usb_read_remote_control);
132 133
133 info("schedule remote query interval to %d msecs.", d->props.rc_interval); 134 info("schedule remote query interval to %d msecs.", d->props.rc_interval);
134 schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc_interval)); 135 schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc_interval));
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h
index 376c45a8e779..0d721731a524 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -369,7 +369,7 @@ struct dvb_usb_device {
369 /* remote control */ 369 /* remote control */
370 struct input_dev *rc_input_dev; 370 struct input_dev *rc_input_dev;
371 char rc_phys[64]; 371 char rc_phys[64];
372 struct work_struct rc_query_work; 372 struct delayed_work rc_query_work;
373 u32 last_event; 373 u32 last_event;
374 int last_state; 374 int last_state;
375 375
diff --git a/drivers/media/dvb/dvb-usb/usb-urb.c b/drivers/media/dvb/dvb-usb/usb-urb.c
index 78035ee824ca..397f51a7b2ad 100644
--- a/drivers/media/dvb/dvb-usb/usb-urb.c
+++ b/drivers/media/dvb/dvb-usb/usb-urb.c
@@ -116,7 +116,7 @@ static int usb_allocate_stream_buffers(struct usb_data_stream *stream, int num,
116 for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) { 116 for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) {
117 deb_mem("allocating buffer %d\n",stream->buf_num); 117 deb_mem("allocating buffer %d\n",stream->buf_num);
118 if (( stream->buf_list[stream->buf_num] = 118 if (( stream->buf_list[stream->buf_num] =
119 usb_buffer_alloc(stream->udev, size, SLAB_ATOMIC, 119 usb_buffer_alloc(stream->udev, size, GFP_ATOMIC,
120 &stream->dma_addr[stream->buf_num]) ) == NULL) { 120 &stream->dma_addr[stream->buf_num]) ) == NULL) {
121 deb_mem("not enough memory for urb-buffer allocation.\n"); 121 deb_mem("not enough memory for urb-buffer allocation.\n");
122 usb_free_stream_buffers(stream); 122 usb_free_stream_buffers(stream);
diff --git a/drivers/media/dvb/frontends/l64781.c b/drivers/media/dvb/frontends/l64781.c
index f3bc82e44a28..1aeacb1c4af7 100644
--- a/drivers/media/dvb/frontends/l64781.c
+++ b/drivers/media/dvb/frontends/l64781.c
@@ -36,7 +36,7 @@ struct l64781_state {
36 struct dvb_frontend frontend; 36 struct dvb_frontend frontend;
37 37
38 /* private demodulator data */ 38 /* private demodulator data */
39 int first:1; 39 unsigned int first:1;
40}; 40};
41 41
42#define dprintk(args...) \ 42#define dprintk(args...) \
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
index 8135f3e76aeb..10b121ada833 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -1244,7 +1244,7 @@ static int ttusb_dec_init_usb(struct ttusb_dec *dec)
1244 return -ENOMEM; 1244 return -ENOMEM;
1245 } 1245 }
1246 dec->irq_buffer = usb_buffer_alloc(dec->udev,IRQ_PACKET_SIZE, 1246 dec->irq_buffer = usb_buffer_alloc(dec->udev,IRQ_PACKET_SIZE,
1247 SLAB_ATOMIC, &dec->irq_dma_handle); 1247 GFP_ATOMIC, &dec->irq_dma_handle);
1248 if(!dec->irq_buffer) { 1248 if(!dec->irq_buffer) {
1249 return -ENOMEM; 1249 return -ENOMEM;
1250 } 1250 }
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 6d96b17a7f81..920b63f8cf05 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -173,38 +173,6 @@ config RADIO_MAESTRO
173 To compile this driver as a module, choose M here: the 173 To compile this driver as a module, choose M here: the
174 module will be called radio-maestro. 174 module will be called radio-maestro.
175 175
176config RADIO_MIROPCM20
177 tristate "miroSOUND PCM20 radio"
178 depends on ISA && VIDEO_V4L1 && SOUND_ACI_MIXER
179 ---help---
180 Choose Y here if you have this FM radio card. You also need to say Y
181 to "ACI mixer (miroSOUND PCM1-pro/PCM12/PCM20 radio)" (in "Sound")
182 for this to work.
183
184 In order to control your radio card, you will need to use programs
185 that are compatible with the Video For Linux API. Information on
186 this API and pointers to "v4l" programs may be found at
187 <file:Documentation/video4linux/API.html>.
188
189 To compile this driver as a module, choose M here: the
190 module will be called miropcm20.
191
192config RADIO_MIROPCM20_RDS
193 tristate "miroSOUND PCM20 radio RDS user interface (EXPERIMENTAL)"
194 depends on RADIO_MIROPCM20 && EXPERIMENTAL
195 ---help---
196 Choose Y here if you want to see RDS/RBDS information like
197 RadioText, Programme Service name, Clock Time and date, Programme
198 Type and Traffic Announcement/Programme identification.
199
200 It's not possible to read the raw RDS packets from the device, so
201 the driver cant provide an V4L interface for this. But the
202 availability of RDS is reported over V4L by the basic driver
203 already. Here RDS can be read from files in /dev/v4l/rds.
204
205 To compile this driver as a module, choose M here: the
206 module will be called miropcm20-rds.
207
208config RADIO_SF16FMI 176config RADIO_SF16FMI
209 tristate "SF16FMI Radio" 177 tristate "SF16FMI Radio"
210 depends on ISA && VIDEO_V4L2 178 depends on ISA && VIDEO_V4L2
diff --git a/drivers/media/video/cpia_pp.c b/drivers/media/video/cpia_pp.c
index 41f4b8d17559..b12cec94f4cc 100644
--- a/drivers/media/video/cpia_pp.c
+++ b/drivers/media/video/cpia_pp.c
@@ -82,6 +82,8 @@ struct pp_cam_entry {
82 struct pardevice *pdev; 82 struct pardevice *pdev;
83 struct parport *port; 83 struct parport *port;
84 struct work_struct cb_task; 84 struct work_struct cb_task;
85 void (*cb_func)(void *cbdata);
86 void *cb_data;
85 int open_count; 87 int open_count;
86 wait_queue_head_t wq_stream; 88 wait_queue_head_t wq_stream;
87 /* image state flags */ 89 /* image state flags */
@@ -130,6 +132,20 @@ static void cpia_parport_disable_irq( struct parport *port ) {
130#define PARPORT_CHUNK_SIZE PAGE_SIZE 132#define PARPORT_CHUNK_SIZE PAGE_SIZE
131 133
132 134
135static void cpia_pp_run_callback(struct work_struct *work)
136{
137 void (*cb_func)(void *cbdata);
138 void *cb_data;
139 struct pp_cam_entry *cam;
140
141 cam = container_of(work, struct pp_cam_entry, cb_task);
142 cb_func = cam->cb_func;
143 cb_data = cam->cb_data;
144 work_release(work);
145
146 cb_func(cb_data);
147}
148
133/**************************************************************************** 149/****************************************************************************
134 * 150 *
135 * CPiA-specific low-level parport functions for nibble uploads 151 * CPiA-specific low-level parport functions for nibble uploads
@@ -664,7 +680,9 @@ static int cpia_pp_registerCallback(void *privdata, void (*cb)(void *cbdata), vo
664 int retval = 0; 680 int retval = 0;
665 681
666 if(cam->port->irq != PARPORT_IRQ_NONE) { 682 if(cam->port->irq != PARPORT_IRQ_NONE) {
667 INIT_WORK(&cam->cb_task, cb, cbdata); 683 cam->cb_func = cb;
684 cam->cb_data = cbdata;
685 INIT_WORK_NAR(&cam->cb_task, cpia_pp_run_callback);
668 } else { 686 } else {
669 retval = -1; 687 retval = -1;
670 } 688 }
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index 57e1c024a547..e60a0a52e4b2 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -145,9 +145,9 @@ static void ir_timer(unsigned long data)
145 schedule_work(&ir->work); 145 schedule_work(&ir->work);
146} 146}
147 147
148static void cx88_ir_work(void *data) 148static void cx88_ir_work(struct work_struct *work)
149{ 149{
150 struct cx88_IR *ir = data; 150 struct cx88_IR *ir = container_of(work, struct cx88_IR, work);
151 unsigned long timeout; 151 unsigned long timeout;
152 152
153 cx88_ir_handle_key(ir); 153 cx88_ir_handle_key(ir);
@@ -308,7 +308,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
308 core->ir = ir; 308 core->ir = ir;
309 309
310 if (ir->polling) { 310 if (ir->polling) {
311 INIT_WORK(&ir->work, cx88_ir_work, ir); 311 INIT_WORK(&ir->work, cx88_ir_work);
312 init_timer(&ir->timer); 312 init_timer(&ir->timer);
313 ir->timer.function = ir_timer; 313 ir->timer.function = ir_timer;
314 ir->timer.data = (unsigned long)ir; 314 ir->timer.data = (unsigned long)ir;
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 1457b1602221..ab87e7bfe84f 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -268,9 +268,9 @@ static void ir_timer(unsigned long data)
268 schedule_work(&ir->work); 268 schedule_work(&ir->work);
269} 269}
270 270
271static void ir_work(void *data) 271static void ir_work(struct work_struct *work)
272{ 272{
273 struct IR_i2c *ir = data; 273 struct IR_i2c *ir = container_of(work, struct IR_i2c, work);
274 ir_key_poll(ir); 274 ir_key_poll(ir);
275 mod_timer(&ir->timer, jiffies+HZ/10); 275 mod_timer(&ir->timer, jiffies+HZ/10);
276} 276}
@@ -400,7 +400,7 @@ static int ir_attach(struct i2c_adapter *adap, int addr,
400 ir->input->name,ir->input->phys,adap->name); 400 ir->input->name,ir->input->phys,adap->name);
401 401
402 /* start polling via eventd */ 402 /* start polling via eventd */
403 INIT_WORK(&ir->work, ir_work, ir); 403 INIT_WORK(&ir->work, ir_work);
404 init_timer(&ir->timer); 404 init_timer(&ir->timer);
405 ir->timer.function = ir_timer; 405 ir->timer.function = ir_timer;
406 ir->timer.data = (unsigned long)ir; 406 ir->timer.data = (unsigned long)ir;
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index cf43df3fe708..e1b56dc13c3f 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -56,7 +56,7 @@
56#include <media/tvaudio.h> 56#include <media/tvaudio.h>
57#include <media/msp3400.h> 57#include <media/msp3400.h>
58#include <linux/kthread.h> 58#include <linux/kthread.h>
59#include <linux/suspend.h> 59#include <linux/freezer.h>
60#include "msp3400-driver.h" 60#include "msp3400-driver.h"
61 61
62/* ---------------------------------------------------------------------- */ 62/* ---------------------------------------------------------------------- */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-context.c b/drivers/media/video/pvrusb2/pvrusb2-context.c
index f129f316d20e..cf129746205d 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-context.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-context.c
@@ -45,16 +45,21 @@ static void pvr2_context_trigger_poll(struct pvr2_context *mp)
45} 45}
46 46
47 47
48static void pvr2_context_poll(struct pvr2_context *mp) 48static void pvr2_context_poll(struct work_struct *work)
49{ 49{
50 struct pvr2_context *mp =
51 container_of(work, struct pvr2_context, workpoll);
50 pvr2_context_enter(mp); do { 52 pvr2_context_enter(mp); do {
51 pvr2_hdw_poll(mp->hdw); 53 pvr2_hdw_poll(mp->hdw);
52 } while (0); pvr2_context_exit(mp); 54 } while (0); pvr2_context_exit(mp);
53} 55}
54 56
55 57
56static void pvr2_context_setup(struct pvr2_context *mp) 58static void pvr2_context_setup(struct work_struct *work)
57{ 59{
60 struct pvr2_context *mp =
61 container_of(work, struct pvr2_context, workinit);
62
58 pvr2_context_enter(mp); do { 63 pvr2_context_enter(mp); do {
59 if (!pvr2_hdw_dev_ok(mp->hdw)) break; 64 if (!pvr2_hdw_dev_ok(mp->hdw)) break;
60 pvr2_hdw_setup(mp->hdw); 65 pvr2_hdw_setup(mp->hdw);
@@ -92,8 +97,8 @@ struct pvr2_context *pvr2_context_create(
92 } 97 }
93 98
94 mp->workqueue = create_singlethread_workqueue("pvrusb2"); 99 mp->workqueue = create_singlethread_workqueue("pvrusb2");
95 INIT_WORK(&mp->workinit,(void (*)(void*))pvr2_context_setup,mp); 100 INIT_WORK(&mp->workinit, pvr2_context_setup);
96 INIT_WORK(&mp->workpoll,(void (*)(void*))pvr2_context_poll,mp); 101 INIT_WORK(&mp->workpoll, pvr2_context_poll);
97 queue_work(mp->workqueue,&mp->workinit); 102 queue_work(mp->workqueue,&mp->workinit);
98 done: 103 done:
99 return mp; 104 return mp;
diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c
index 7b9859c33018..92eabf88a09b 100644
--- a/drivers/media/video/saa6588.c
+++ b/drivers/media/video/saa6588.c
@@ -324,9 +324,9 @@ static void saa6588_timer(unsigned long data)
324 schedule_work(&s->work); 324 schedule_work(&s->work);
325} 325}
326 326
327static void saa6588_work(void *data) 327static void saa6588_work(struct work_struct *work)
328{ 328{
329 struct saa6588 *s = (struct saa6588 *)data; 329 struct saa6588 *s = container_of(work, struct saa6588, work);
330 330
331 saa6588_i2c_poll(s); 331 saa6588_i2c_poll(s);
332 mod_timer(&s->timer, jiffies + msecs_to_jiffies(20)); 332 mod_timer(&s->timer, jiffies + msecs_to_jiffies(20));
@@ -419,7 +419,7 @@ static int saa6588_attach(struct i2c_adapter *adap, int addr, int kind)
419 saa6588_configure(s); 419 saa6588_configure(s);
420 420
421 /* start polling via eventd */ 421 /* start polling via eventd */
422 INIT_WORK(&s->work, saa6588_work, s); 422 INIT_WORK(&s->work, saa6588_work);
423 init_timer(&s->timer); 423 init_timer(&s->timer);
424 s->timer.function = saa6588_timer; 424 s->timer.function = saa6588_timer;
425 s->timer.data = (unsigned long)s; 425 s->timer.data = (unsigned long)s;
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index 65d044086ce9..daaae870a2c4 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -343,9 +343,10 @@ static struct video_device saa7134_empress_template =
343 .minor = -1, 343 .minor = -1,
344}; 344};
345 345
346static void empress_signal_update(void* data) 346static void empress_signal_update(struct work_struct *work)
347{ 347{
348 struct saa7134_dev* dev = (struct saa7134_dev*) data; 348 struct saa7134_dev* dev =
349 container_of(work, struct saa7134_dev, empress_workqueue);
349 350
350 if (dev->nosignal) { 351 if (dev->nosignal) {
351 dprintk("no video signal\n"); 352 dprintk("no video signal\n");
@@ -378,7 +379,7 @@ static int empress_init(struct saa7134_dev *dev)
378 "%s empress (%s)", dev->name, 379 "%s empress (%s)", dev->name,
379 saa7134_boards[dev->board].name); 380 saa7134_boards[dev->board].name);
380 381
381 INIT_WORK(&dev->empress_workqueue, empress_signal_update, (void*) dev); 382 INIT_WORK(&dev->empress_workqueue, empress_signal_update);
382 383
383 err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER, 384 err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER,
384 empress_nr[dev->nr]); 385 empress_nr[dev->nr]);
@@ -399,7 +400,7 @@ static int empress_init(struct saa7134_dev *dev)
399 sizeof(struct saa7134_buf), 400 sizeof(struct saa7134_buf),
400 dev); 401 dev);
401 402
402 empress_signal_update(dev); 403 empress_signal_update(&dev->empress_workqueue);
403 return 0; 404 return 0;
404} 405}
405 406
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index fcaef4bf8289..d506dfaa45a9 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -29,6 +29,7 @@
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/smp_lock.h> 30#include <linux/smp_lock.h>
31#include <linux/kthread.h> 31#include <linux/kthread.h>
32#include <linux/freezer.h>
32 33
33#include <media/tvaudio.h> 34#include <media/tvaudio.h>
34#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
diff --git a/drivers/media/video/video-buf-dvb.c b/drivers/media/video/video-buf-dvb.c
index f53edf1923b7..fcc5467e7636 100644
--- a/drivers/media/video/video-buf-dvb.c
+++ b/drivers/media/video/video-buf-dvb.c
@@ -20,7 +20,7 @@
20#include <linux/fs.h> 20#include <linux/fs.h>
21#include <linux/kthread.h> 21#include <linux/kthread.h>
22#include <linux/file.h> 22#include <linux/file.h>
23#include <linux/suspend.h> 23#include <linux/freezer.h>
24 24
25#include <media/video-buf.h> 25#include <media/video-buf.h>
26#include <media/video-buf-dvb.h> 26#include <media/video-buf-dvb.h>
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 3c8dc72dc8e9..9986de5cb3d6 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -36,6 +36,7 @@
36#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
37#include <linux/kthread.h> 37#include <linux/kthread.h>
38#include <linux/highmem.h> 38#include <linux/highmem.h>
39#include <linux/freezer.h>
39 40
40/* Wake up at about 30 fps */ 41/* Wake up at about 30 fps */
41#define WAKE_NUMERATOR 30 42#define WAKE_NUMERATOR 30
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 051b7c5b8f03..6e068cf1049b 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -347,7 +347,7 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
347} 347}
348 348
349/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 349/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
350/* 350/**
351 * mpt_interrupt - MPT adapter (IOC) specific interrupt handler. 351 * mpt_interrupt - MPT adapter (IOC) specific interrupt handler.
352 * @irq: irq number (not used) 352 * @irq: irq number (not used)
353 * @bus_id: bus identifier cookie == pointer to MPT_ADAPTER structure 353 * @bus_id: bus identifier cookie == pointer to MPT_ADAPTER structure
@@ -387,14 +387,16 @@ mpt_interrupt(int irq, void *bus_id)
387} 387}
388 388
389/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 389/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
390/* 390/**
391 * mpt_base_reply - MPT base driver's callback routine; all base driver 391 * mpt_base_reply - MPT base driver's callback routine
392 * "internal" request/reply processing is routed here.
393 * Currently used for EventNotification and EventAck handling.
394 * @ioc: Pointer to MPT_ADAPTER structure 392 * @ioc: Pointer to MPT_ADAPTER structure
395 * @mf: Pointer to original MPT request frame 393 * @mf: Pointer to original MPT request frame
396 * @reply: Pointer to MPT reply frame (NULL if TurboReply) 394 * @reply: Pointer to MPT reply frame (NULL if TurboReply)
397 * 395 *
396 * MPT base driver's callback routine; all base driver
397 * "internal" request/reply processing is routed here.
398 * Currently used for EventNotification and EventAck handling.
399 *
398 * Returns 1 indicating original alloc'd request frame ptr 400 * Returns 1 indicating original alloc'd request frame ptr
399 * should be freed, or 0 if it shouldn't. 401 * should be freed, or 0 if it shouldn't.
400 */ 402 */
@@ -530,7 +532,7 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
530 * @dclass: Protocol driver's class (%MPT_DRIVER_CLASS enum value) 532 * @dclass: Protocol driver's class (%MPT_DRIVER_CLASS enum value)
531 * 533 *
532 * This routine is called by a protocol-specific driver (SCSI host, 534 * This routine is called by a protocol-specific driver (SCSI host,
533 * LAN, SCSI target) to register it's reply callback routine. Each 535 * LAN, SCSI target) to register its reply callback routine. Each
534 * protocol-specific driver must do this before it will be able to 536 * protocol-specific driver must do this before it will be able to
535 * use any IOC resources, such as obtaining request frames. 537 * use any IOC resources, such as obtaining request frames.
536 * 538 *
@@ -572,7 +574,7 @@ mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass)
572 * mpt_deregister - Deregister a protocol drivers resources. 574 * mpt_deregister - Deregister a protocol drivers resources.
573 * @cb_idx: previously registered callback handle 575 * @cb_idx: previously registered callback handle
574 * 576 *
575 * Each protocol-specific driver should call this routine when it's 577 * Each protocol-specific driver should call this routine when its
576 * module is unloaded. 578 * module is unloaded.
577 */ 579 */
578void 580void
@@ -617,7 +619,7 @@ mpt_event_register(int cb_idx, MPT_EVHANDLER ev_cbfunc)
617 * 619 *
618 * Each protocol-specific driver should call this routine 620 * Each protocol-specific driver should call this routine
619 * when it does not (or can no longer) handle events, 621 * when it does not (or can no longer) handle events,
620 * or when it's module is unloaded. 622 * or when its module is unloaded.
621 */ 623 */
622void 624void
623mpt_event_deregister(int cb_idx) 625mpt_event_deregister(int cb_idx)
@@ -656,7 +658,7 @@ mpt_reset_register(int cb_idx, MPT_RESETHANDLER reset_func)
656 * 658 *
657 * Each protocol-specific driver should call this routine 659 * Each protocol-specific driver should call this routine
658 * when it does not (or can no longer) handle IOC reset handling, 660 * when it does not (or can no longer) handle IOC reset handling,
659 * or when it's module is unloaded. 661 * or when its module is unloaded.
660 */ 662 */
661void 663void
662mpt_reset_deregister(int cb_idx) 664mpt_reset_deregister(int cb_idx)
@@ -670,6 +672,8 @@ mpt_reset_deregister(int cb_idx)
670/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 672/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
671/** 673/**
672 * mpt_device_driver_register - Register device driver hooks 674 * mpt_device_driver_register - Register device driver hooks
675 * @dd_cbfunc: driver callbacks struct
676 * @cb_idx: MPT protocol driver index
673 */ 677 */
674int 678int
675mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx) 679mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx)
@@ -696,6 +700,7 @@ mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx)
696/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 700/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
697/** 701/**
698 * mpt_device_driver_deregister - DeRegister device driver hooks 702 * mpt_device_driver_deregister - DeRegister device driver hooks
703 * @cb_idx: MPT protocol driver index
699 */ 704 */
700void 705void
701mpt_device_driver_deregister(int cb_idx) 706mpt_device_driver_deregister(int cb_idx)
@@ -887,8 +892,7 @@ mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr)
887 892
888/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 893/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
889/** 894/**
890 * mpt_send_handshake_request - Send MPT request via doorbell 895 * mpt_send_handshake_request - Send MPT request via doorbell handshake method.
891 * handshake method.
892 * @handle: Handle of registered MPT protocol driver 896 * @handle: Handle of registered MPT protocol driver
893 * @ioc: Pointer to MPT adapter structure 897 * @ioc: Pointer to MPT adapter structure
894 * @reqBytes: Size of the request in bytes 898 * @reqBytes: Size of the request in bytes
@@ -981,10 +985,13 @@ mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req,
981 985
982/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 986/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
983/** 987/**
984 * mpt_host_page_access_control - provides mechanism for the host 988 * mpt_host_page_access_control - control the IOC's Host Page Buffer access
985 * driver to control the IOC's Host Page Buffer access.
986 * @ioc: Pointer to MPT adapter structure 989 * @ioc: Pointer to MPT adapter structure
987 * @access_control_value: define bits below 990 * @access_control_value: define bits below
991 * @sleepFlag: Specifies whether the process can sleep
992 *
993 * Provides mechanism for the host driver to control the IOC's
994 * Host Page Buffer access.
988 * 995 *
989 * Access Control Value - bits[15:12] 996 * Access Control Value - bits[15:12]
990 * 0h Reserved 997 * 0h Reserved
@@ -1022,10 +1029,10 @@ mpt_host_page_access_control(MPT_ADAPTER *ioc, u8 access_control_value, int slee
1022/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1029/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1023/** 1030/**
1024 * mpt_host_page_alloc - allocate system memory for the fw 1031 * mpt_host_page_alloc - allocate system memory for the fw
1025 * If we already allocated memory in past, then resend the same pointer. 1032 * @ioc: Pointer to pointer to IOC adapter
1026 * ioc@: Pointer to pointer to IOC adapter 1033 * @ioc_init: Pointer to ioc init config page
1027 * ioc_init@: Pointer to ioc init config page
1028 * 1034 *
1035 * If we already allocated memory in past, then resend the same pointer.
1029 * Returns 0 for success, non-zero for failure. 1036 * Returns 0 for success, non-zero for failure.
1030 */ 1037 */
1031static int 1038static int
@@ -1091,12 +1098,15 @@ return 0;
1091 1098
1092/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1099/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1093/** 1100/**
1094 * mpt_verify_adapter - Given a unique IOC identifier, set pointer to 1101 * mpt_verify_adapter - Given IOC identifier, set pointer to its adapter structure.
1095 * the associated MPT adapter structure.
1096 * @iocid: IOC unique identifier (integer) 1102 * @iocid: IOC unique identifier (integer)
1097 * @iocpp: Pointer to pointer to IOC adapter 1103 * @iocpp: Pointer to pointer to IOC adapter
1098 * 1104 *
1099 * Returns iocid and sets iocpp. 1105 * Given a unique IOC identifier, set pointer to the associated MPT
1106 * adapter structure.
1107 *
1108 * Returns iocid and sets iocpp if iocid is found.
1109 * Returns -1 if iocid is not found.
1100 */ 1110 */
1101int 1111int
1102mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp) 1112mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp)
@@ -1115,9 +1125,10 @@ mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp)
1115} 1125}
1116 1126
1117/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1127/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1118/* 1128/**
1119 * mpt_attach - Install a PCI intelligent MPT adapter. 1129 * mpt_attach - Install a PCI intelligent MPT adapter.
1120 * @pdev: Pointer to pci_dev structure 1130 * @pdev: Pointer to pci_dev structure
1131 * @id: PCI device ID information
1121 * 1132 *
1122 * This routine performs all the steps necessary to bring the IOC of 1133 * This routine performs all the steps necessary to bring the IOC of
1123 * a MPT adapter to a OPERATIONAL state. This includes registering 1134 * a MPT adapter to a OPERATIONAL state. This includes registering
@@ -1417,10 +1428,9 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1417} 1428}
1418 1429
1419/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1430/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1420/* 1431/**
1421 * mpt_detach - Remove a PCI intelligent MPT adapter. 1432 * mpt_detach - Remove a PCI intelligent MPT adapter.
1422 * @pdev: Pointer to pci_dev structure 1433 * @pdev: Pointer to pci_dev structure
1423 *
1424 */ 1434 */
1425 1435
1426void 1436void
@@ -1466,10 +1476,10 @@ mpt_detach(struct pci_dev *pdev)
1466 */ 1476 */
1467#ifdef CONFIG_PM 1477#ifdef CONFIG_PM
1468/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1478/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1469/* 1479/**
1470 * mpt_suspend - Fusion MPT base driver suspend routine. 1480 * mpt_suspend - Fusion MPT base driver suspend routine.
1471 * 1481 * @pdev: Pointer to pci_dev structure
1472 * 1482 * @state: new state to enter
1473 */ 1483 */
1474int 1484int
1475mpt_suspend(struct pci_dev *pdev, pm_message_t state) 1485mpt_suspend(struct pci_dev *pdev, pm_message_t state)
@@ -1505,10 +1515,9 @@ mpt_suspend(struct pci_dev *pdev, pm_message_t state)
1505} 1515}
1506 1516
1507/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1517/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1508/* 1518/**
1509 * mpt_resume - Fusion MPT base driver resume routine. 1519 * mpt_resume - Fusion MPT base driver resume routine.
1510 * 1520 * @pdev: Pointer to pci_dev structure
1511 *
1512 */ 1521 */
1513int 1522int
1514mpt_resume(struct pci_dev *pdev) 1523mpt_resume(struct pci_dev *pdev)
@@ -1566,7 +1575,7 @@ mpt_signal_reset(int index, MPT_ADAPTER *ioc, int reset_phase)
1566} 1575}
1567 1576
1568/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1577/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1569/* 1578/**
1570 * mpt_do_ioc_recovery - Initialize or recover MPT adapter. 1579 * mpt_do_ioc_recovery - Initialize or recover MPT adapter.
1571 * @ioc: Pointer to MPT adapter structure 1580 * @ioc: Pointer to MPT adapter structure
1572 * @reason: Event word / reason 1581 * @reason: Event word / reason
@@ -1892,13 +1901,15 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1892} 1901}
1893 1902
1894/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1903/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1895/* 1904/**
1896 * mpt_detect_bound_ports - Search for PCI bus/dev_function 1905 * mpt_detect_bound_ports - Search for matching PCI bus/dev_function
1897 * which matches PCI bus/dev_function (+/-1) for newly discovered 929,
1898 * 929X, 1030 or 1035.
1899 * @ioc: Pointer to MPT adapter structure 1906 * @ioc: Pointer to MPT adapter structure
1900 * @pdev: Pointer to (struct pci_dev) structure 1907 * @pdev: Pointer to (struct pci_dev) structure
1901 * 1908 *
1909 * Search for PCI bus/dev_function which matches
1910 * PCI bus/dev_function (+/-1) for newly discovered 929,
1911 * 929X, 1030 or 1035.
1912 *
1902 * If match on PCI dev_function +/-1 is found, bind the two MPT adapters 1913 * If match on PCI dev_function +/-1 is found, bind the two MPT adapters
1903 * using alt_ioc pointer fields in their %MPT_ADAPTER structures. 1914 * using alt_ioc pointer fields in their %MPT_ADAPTER structures.
1904 */ 1915 */
@@ -1945,9 +1956,9 @@ mpt_detect_bound_ports(MPT_ADAPTER *ioc, struct pci_dev *pdev)
1945} 1956}
1946 1957
1947/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1958/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1948/* 1959/**
1949 * mpt_adapter_disable - Disable misbehaving MPT adapter. 1960 * mpt_adapter_disable - Disable misbehaving MPT adapter.
1950 * @this: Pointer to MPT adapter structure 1961 * @ioc: Pointer to MPT adapter structure
1951 */ 1962 */
1952static void 1963static void
1953mpt_adapter_disable(MPT_ADAPTER *ioc) 1964mpt_adapter_disable(MPT_ADAPTER *ioc)
@@ -2046,9 +2057,8 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
2046} 2057}
2047 2058
2048/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2059/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2049/* 2060/**
2050 * mpt_adapter_dispose - Free all resources associated with a MPT 2061 * mpt_adapter_dispose - Free all resources associated with an MPT adapter
2051 * adapter.
2052 * @ioc: Pointer to MPT adapter structure 2062 * @ioc: Pointer to MPT adapter structure
2053 * 2063 *
2054 * This routine unregisters h/w resources and frees all alloc'd memory 2064 * This routine unregisters h/w resources and frees all alloc'd memory
@@ -2099,8 +2109,8 @@ mpt_adapter_dispose(MPT_ADAPTER *ioc)
2099} 2109}
2100 2110
2101/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2111/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2102/* 2112/**
2103 * MptDisplayIocCapabilities - Disply IOC's capacilities. 2113 * MptDisplayIocCapabilities - Disply IOC's capabilities.
2104 * @ioc: Pointer to MPT adapter structure 2114 * @ioc: Pointer to MPT adapter structure
2105 */ 2115 */
2106static void 2116static void
@@ -2142,7 +2152,7 @@ MptDisplayIocCapabilities(MPT_ADAPTER *ioc)
2142} 2152}
2143 2153
2144/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2154/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2145/* 2155/**
2146 * MakeIocReady - Get IOC to a READY state, using KickStart if needed. 2156 * MakeIocReady - Get IOC to a READY state, using KickStart if needed.
2147 * @ioc: Pointer to MPT_ADAPTER structure 2157 * @ioc: Pointer to MPT_ADAPTER structure
2148 * @force: Force hard KickStart of IOC 2158 * @force: Force hard KickStart of IOC
@@ -2279,7 +2289,7 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag)
2279} 2289}
2280 2290
2281/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2291/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2282/* 2292/**
2283 * mpt_GetIocState - Get the current state of a MPT adapter. 2293 * mpt_GetIocState - Get the current state of a MPT adapter.
2284 * @ioc: Pointer to MPT_ADAPTER structure 2294 * @ioc: Pointer to MPT_ADAPTER structure
2285 * @cooked: Request raw or cooked IOC state 2295 * @cooked: Request raw or cooked IOC state
@@ -2304,7 +2314,7 @@ mpt_GetIocState(MPT_ADAPTER *ioc, int cooked)
2304} 2314}
2305 2315
2306/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2316/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2307/* 2317/**
2308 * GetIocFacts - Send IOCFacts request to MPT adapter. 2318 * GetIocFacts - Send IOCFacts request to MPT adapter.
2309 * @ioc: Pointer to MPT_ADAPTER structure 2319 * @ioc: Pointer to MPT_ADAPTER structure
2310 * @sleepFlag: Specifies whether the process can sleep 2320 * @sleepFlag: Specifies whether the process can sleep
@@ -2478,7 +2488,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
2478} 2488}
2479 2489
2480/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2490/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2481/* 2491/**
2482 * GetPortFacts - Send PortFacts request to MPT adapter. 2492 * GetPortFacts - Send PortFacts request to MPT adapter.
2483 * @ioc: Pointer to MPT_ADAPTER structure 2493 * @ioc: Pointer to MPT_ADAPTER structure
2484 * @portnum: Port number 2494 * @portnum: Port number
@@ -2545,7 +2555,7 @@ GetPortFacts(MPT_ADAPTER *ioc, int portnum, int sleepFlag)
2545} 2555}
2546 2556
2547/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2557/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2548/* 2558/**
2549 * SendIocInit - Send IOCInit request to MPT adapter. 2559 * SendIocInit - Send IOCInit request to MPT adapter.
2550 * @ioc: Pointer to MPT_ADAPTER structure 2560 * @ioc: Pointer to MPT_ADAPTER structure
2551 * @sleepFlag: Specifies whether the process can sleep 2561 * @sleepFlag: Specifies whether the process can sleep
@@ -2630,7 +2640,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
2630 } 2640 }
2631 2641
2632 /* No need to byte swap the multibyte fields in the reply 2642 /* No need to byte swap the multibyte fields in the reply
2633 * since we don't even look at it's contents. 2643 * since we don't even look at its contents.
2634 */ 2644 */
2635 2645
2636 dhsprintk((MYIOC_s_INFO_FMT "Sending PortEnable (req @ %p)\n", 2646 dhsprintk((MYIOC_s_INFO_FMT "Sending PortEnable (req @ %p)\n",
@@ -2672,7 +2682,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
2672} 2682}
2673 2683
2674/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2684/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2675/* 2685/**
2676 * SendPortEnable - Send PortEnable request to MPT adapter port. 2686 * SendPortEnable - Send PortEnable request to MPT adapter port.
2677 * @ioc: Pointer to MPT_ADAPTER structure 2687 * @ioc: Pointer to MPT_ADAPTER structure
2678 * @portnum: Port number to enable 2688 * @portnum: Port number to enable
@@ -2723,9 +2733,13 @@ SendPortEnable(MPT_ADAPTER *ioc, int portnum, int sleepFlag)
2723 return rc; 2733 return rc;
2724} 2734}
2725 2735
2726/* 2736/**
2727 * ioc: Pointer to MPT_ADAPTER structure 2737 * mpt_alloc_fw_memory - allocate firmware memory
2728 * size - total FW bytes 2738 * @ioc: Pointer to MPT_ADAPTER structure
2739 * @size: total FW bytes
2740 *
2741 * If memory has already been allocated, the same (cached) value
2742 * is returned.
2729 */ 2743 */
2730void 2744void
2731mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size) 2745mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size)
@@ -2742,9 +2756,12 @@ mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size)
2742 ioc->alloc_total += size; 2756 ioc->alloc_total += size;
2743 } 2757 }
2744} 2758}
2745/* 2759/**
2746 * If alt_img is NULL, delete from ioc structure. 2760 * mpt_free_fw_memory - free firmware memory
2747 * Else, delete a secondary image in same format. 2761 * @ioc: Pointer to MPT_ADAPTER structure
2762 *
2763 * If alt_img is NULL, delete from ioc structure.
2764 * Else, delete a secondary image in same format.
2748 */ 2765 */
2749void 2766void
2750mpt_free_fw_memory(MPT_ADAPTER *ioc) 2767mpt_free_fw_memory(MPT_ADAPTER *ioc)
@@ -2763,7 +2780,7 @@ mpt_free_fw_memory(MPT_ADAPTER *ioc)
2763 2780
2764 2781
2765/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2782/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2766/* 2783/**
2767 * mpt_do_upload - Construct and Send FWUpload request to MPT adapter port. 2784 * mpt_do_upload - Construct and Send FWUpload request to MPT adapter port.
2768 * @ioc: Pointer to MPT_ADAPTER structure 2785 * @ioc: Pointer to MPT_ADAPTER structure
2769 * @sleepFlag: Specifies whether the process can sleep 2786 * @sleepFlag: Specifies whether the process can sleep
@@ -2865,10 +2882,10 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag)
2865} 2882}
2866 2883
2867/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2884/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2868/* 2885/**
2869 * mpt_downloadboot - DownloadBoot code 2886 * mpt_downloadboot - DownloadBoot code
2870 * @ioc: Pointer to MPT_ADAPTER structure 2887 * @ioc: Pointer to MPT_ADAPTER structure
2871 * @flag: Specify which part of IOC memory is to be uploaded. 2888 * @pFwHeader: Pointer to firmware header info
2872 * @sleepFlag: Specifies whether the process can sleep 2889 * @sleepFlag: Specifies whether the process can sleep
2873 * 2890 *
2874 * FwDownloadBoot requires Programmed IO access. 2891 * FwDownloadBoot requires Programmed IO access.
@@ -3071,7 +3088,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
3071} 3088}
3072 3089
3073/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3090/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3074/* 3091/**
3075 * KickStart - Perform hard reset of MPT adapter. 3092 * KickStart - Perform hard reset of MPT adapter.
3076 * @ioc: Pointer to MPT_ADAPTER structure 3093 * @ioc: Pointer to MPT_ADAPTER structure
3077 * @force: Force hard reset 3094 * @force: Force hard reset
@@ -3145,12 +3162,12 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag)
3145} 3162}
3146 3163
3147/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3164/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3148/* 3165/**
3149 * mpt_diag_reset - Perform hard reset of the adapter. 3166 * mpt_diag_reset - Perform hard reset of the adapter.
3150 * @ioc: Pointer to MPT_ADAPTER structure 3167 * @ioc: Pointer to MPT_ADAPTER structure
3151 * @ignore: Set if to honor and clear to ignore 3168 * @ignore: Set if to honor and clear to ignore
3152 * the reset history bit 3169 * the reset history bit
3153 * @sleepflag: CAN_SLEEP if called in a non-interrupt thread, 3170 * @sleepFlag: CAN_SLEEP if called in a non-interrupt thread,
3154 * else set to NO_SLEEP (use mdelay instead) 3171 * else set to NO_SLEEP (use mdelay instead)
3155 * 3172 *
3156 * This routine places the adapter in diagnostic mode via the 3173 * This routine places the adapter in diagnostic mode via the
@@ -3436,11 +3453,12 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3436} 3453}
3437 3454
3438/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3455/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3439/* 3456/**
3440 * SendIocReset - Send IOCReset request to MPT adapter. 3457 * SendIocReset - Send IOCReset request to MPT adapter.
3441 * @ioc: Pointer to MPT_ADAPTER structure 3458 * @ioc: Pointer to MPT_ADAPTER structure
3442 * @reset_type: reset type, expected values are 3459 * @reset_type: reset type, expected values are
3443 * %MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET or %MPI_FUNCTION_IO_UNIT_RESET 3460 * %MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET or %MPI_FUNCTION_IO_UNIT_RESET
3461 * @sleepFlag: Specifies whether the process can sleep
3444 * 3462 *
3445 * Send IOCReset request to the MPT adapter. 3463 * Send IOCReset request to the MPT adapter.
3446 * 3464 *
@@ -3494,11 +3512,12 @@ SendIocReset(MPT_ADAPTER *ioc, u8 reset_type, int sleepFlag)
3494} 3512}
3495 3513
3496/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3514/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3497/* 3515/**
3498 * initChainBuffers - Allocate memory for and initialize 3516 * initChainBuffers - Allocate memory for and initialize chain buffers
3499 * chain buffers, chain buffer control arrays and spinlock. 3517 * @ioc: Pointer to MPT_ADAPTER structure
3500 * @hd: Pointer to MPT_SCSI_HOST structure 3518 *
3501 * @init: If set, initialize the spin lock. 3519 * Allocates memory for and initializes chain buffers,
3520 * chain buffer control arrays and spinlock.
3502 */ 3521 */
3503static int 3522static int
3504initChainBuffers(MPT_ADAPTER *ioc) 3523initChainBuffers(MPT_ADAPTER *ioc)
@@ -3594,7 +3613,7 @@ initChainBuffers(MPT_ADAPTER *ioc)
3594} 3613}
3595 3614
3596/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3615/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3597/* 3616/**
3598 * PrimeIocFifos - Initialize IOC request and reply FIFOs. 3617 * PrimeIocFifos - Initialize IOC request and reply FIFOs.
3599 * @ioc: Pointer to MPT_ADAPTER structure 3618 * @ioc: Pointer to MPT_ADAPTER structure
3600 * 3619 *
@@ -3891,15 +3910,15 @@ mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req,
3891} 3910}
3892 3911
3893/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3912/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3894/* 3913/**
3895 * WaitForDoorbellAck - Wait for IOC to clear the IOP_DOORBELL_STATUS bit 3914 * WaitForDoorbellAck - Wait for IOC doorbell handshake acknowledge
3896 * in it's IntStatus register.
3897 * @ioc: Pointer to MPT_ADAPTER structure 3915 * @ioc: Pointer to MPT_ADAPTER structure
3898 * @howlong: How long to wait (in seconds) 3916 * @howlong: How long to wait (in seconds)
3899 * @sleepFlag: Specifies whether the process can sleep 3917 * @sleepFlag: Specifies whether the process can sleep
3900 * 3918 *
3901 * This routine waits (up to ~2 seconds max) for IOC doorbell 3919 * This routine waits (up to ~2 seconds max) for IOC doorbell
3902 * handshake ACKnowledge. 3920 * handshake ACKnowledge, indicated by the IOP_DOORBELL_STATUS
3921 * bit in its IntStatus register being clear.
3903 * 3922 *
3904 * Returns a negative value on failure, else wait loop count. 3923 * Returns a negative value on failure, else wait loop count.
3905 */ 3924 */
@@ -3942,14 +3961,14 @@ WaitForDoorbellAck(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
3942} 3961}
3943 3962
3944/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3963/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3945/* 3964/**
3946 * WaitForDoorbellInt - Wait for IOC to set the HIS_DOORBELL_INTERRUPT bit 3965 * WaitForDoorbellInt - Wait for IOC to set its doorbell interrupt bit
3947 * in it's IntStatus register.
3948 * @ioc: Pointer to MPT_ADAPTER structure 3966 * @ioc: Pointer to MPT_ADAPTER structure
3949 * @howlong: How long to wait (in seconds) 3967 * @howlong: How long to wait (in seconds)
3950 * @sleepFlag: Specifies whether the process can sleep 3968 * @sleepFlag: Specifies whether the process can sleep
3951 * 3969 *
3952 * This routine waits (up to ~2 seconds max) for IOC doorbell interrupt. 3970 * This routine waits (up to ~2 seconds max) for IOC doorbell interrupt
3971 * (MPI_HIS_DOORBELL_INTERRUPT) to be set in the IntStatus register.
3953 * 3972 *
3954 * Returns a negative value on failure, else wait loop count. 3973 * Returns a negative value on failure, else wait loop count.
3955 */ 3974 */
@@ -3991,8 +4010,8 @@ WaitForDoorbellInt(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
3991} 4010}
3992 4011
3993/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4012/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3994/* 4013/**
3995 * WaitForDoorbellReply - Wait for and capture a IOC handshake reply. 4014 * WaitForDoorbellReply - Wait for and capture an IOC handshake reply.
3996 * @ioc: Pointer to MPT_ADAPTER structure 4015 * @ioc: Pointer to MPT_ADAPTER structure
3997 * @howlong: How long to wait (in seconds) 4016 * @howlong: How long to wait (in seconds)
3998 * @sleepFlag: Specifies whether the process can sleep 4017 * @sleepFlag: Specifies whether the process can sleep
@@ -4077,7 +4096,7 @@ WaitForDoorbellReply(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
4077} 4096}
4078 4097
4079/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4098/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4080/* 4099/**
4081 * GetLanConfigPages - Fetch LANConfig pages. 4100 * GetLanConfigPages - Fetch LANConfig pages.
4082 * @ioc: Pointer to MPT_ADAPTER structure 4101 * @ioc: Pointer to MPT_ADAPTER structure
4083 * 4102 *
@@ -4188,12 +4207,9 @@ GetLanConfigPages(MPT_ADAPTER *ioc)
4188} 4207}
4189 4208
4190/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4209/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4191/* 4210/**
4192 * mptbase_sas_persist_operation - Perform operation on SAS Persitent Table 4211 * mptbase_sas_persist_operation - Perform operation on SAS Persistent Table
4193 * @ioc: Pointer to MPT_ADAPTER structure 4212 * @ioc: Pointer to MPT_ADAPTER structure
4194 * @sas_address: 64bit SAS Address for operation.
4195 * @target_id: specified target for operation
4196 * @bus: specified bus for operation
4197 * @persist_opcode: see below 4213 * @persist_opcode: see below
4198 * 4214 *
4199 * MPI_SAS_OP_CLEAR_NOT_PRESENT - Free all persist TargetID mappings for 4215 * MPI_SAS_OP_CLEAR_NOT_PRESENT - Free all persist TargetID mappings for
@@ -4202,7 +4218,7 @@ GetLanConfigPages(MPT_ADAPTER *ioc)
4202 * 4218 *
4203 * NOTE: Don't use not this function during interrupt time. 4219 * NOTE: Don't use not this function during interrupt time.
4204 * 4220 *
4205 * Returns: 0 for success, non-zero error 4221 * Returns 0 for success, non-zero error
4206 */ 4222 */
4207 4223
4208/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4224/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -4399,7 +4415,7 @@ mptbase_raid_process_event_data(MPT_ADAPTER *ioc,
4399} 4415}
4400 4416
4401/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4417/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4402/* 4418/**
4403 * GetIoUnitPage2 - Retrieve BIOS version and boot order information. 4419 * GetIoUnitPage2 - Retrieve BIOS version and boot order information.
4404 * @ioc: Pointer to MPT_ADAPTER structure 4420 * @ioc: Pointer to MPT_ADAPTER structure
4405 * 4421 *
@@ -4457,7 +4473,8 @@ GetIoUnitPage2(MPT_ADAPTER *ioc)
4457} 4473}
4458 4474
4459/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4475/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4460/* mpt_GetScsiPortSettings - read SCSI Port Page 0 and 2 4476/**
4477 * mpt_GetScsiPortSettings - read SCSI Port Page 0 and 2
4461 * @ioc: Pointer to a Adapter Strucutre 4478 * @ioc: Pointer to a Adapter Strucutre
4462 * @portnum: IOC port number 4479 * @portnum: IOC port number
4463 * 4480 *
@@ -4644,7 +4661,8 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum)
4644} 4661}
4645 4662
4646/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4663/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4647/* mpt_readScsiDevicePageHeaders - save version and length of SDP1 4664/**
4665 * mpt_readScsiDevicePageHeaders - save version and length of SDP1
4648 * @ioc: Pointer to a Adapter Strucutre 4666 * @ioc: Pointer to a Adapter Strucutre
4649 * @portnum: IOC port number 4667 * @portnum: IOC port number
4650 * 4668 *
@@ -4996,9 +5014,8 @@ mpt_read_ioc_pg_1(MPT_ADAPTER *ioc)
4996} 5014}
4997 5015
4998/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5016/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4999/* 5017/**
5000 * SendEventNotification - Send EventNotification (on or off) request 5018 * SendEventNotification - Send EventNotification (on or off) request to adapter
5001 * to MPT adapter.
5002 * @ioc: Pointer to MPT_ADAPTER structure 5019 * @ioc: Pointer to MPT_ADAPTER structure
5003 * @EvSwitch: Event switch flags 5020 * @EvSwitch: Event switch flags
5004 */ 5021 */
@@ -5062,8 +5079,8 @@ SendEventAck(MPT_ADAPTER *ioc, EventNotificationReply_t *evnp)
5062/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5079/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5063/** 5080/**
5064 * mpt_config - Generic function to issue config message 5081 * mpt_config - Generic function to issue config message
5065 * @ioc - Pointer to an adapter structure 5082 * @ioc: Pointer to an adapter structure
5066 * @cfg - Pointer to a configuration structure. Struct contains 5083 * @pCfg: Pointer to a configuration structure. Struct contains
5067 * action, page address, direction, physical address 5084 * action, page address, direction, physical address
5068 * and pointer to a configuration page header 5085 * and pointer to a configuration page header
5069 * Page header is updated. 5086 * Page header is updated.
@@ -5188,8 +5205,8 @@ mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *pCfg)
5188} 5205}
5189 5206
5190/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5207/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5191/* 5208/**
5192 * mpt_timer_expired - Call back for timer process. 5209 * mpt_timer_expired - Callback for timer process.
5193 * Used only internal config functionality. 5210 * Used only internal config functionality.
5194 * @data: Pointer to MPT_SCSI_HOST recast as an unsigned long 5211 * @data: Pointer to MPT_SCSI_HOST recast as an unsigned long
5195 */ 5212 */
@@ -5214,12 +5231,12 @@ mpt_timer_expired(unsigned long data)
5214} 5231}
5215 5232
5216/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5233/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5217/* 5234/**
5218 * mpt_ioc_reset - Base cleanup for hard reset 5235 * mpt_ioc_reset - Base cleanup for hard reset
5219 * @ioc: Pointer to the adapter structure 5236 * @ioc: Pointer to the adapter structure
5220 * @reset_phase: Indicates pre- or post-reset functionality 5237 * @reset_phase: Indicates pre- or post-reset functionality
5221 * 5238 *
5222 * Remark: Free's resources with internally generated commands. 5239 * Remark: Frees resources with internally generated commands.
5223 */ 5240 */
5224static int 5241static int
5225mpt_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) 5242mpt_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
@@ -5271,7 +5288,7 @@ mpt_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
5271 * procfs (%MPT_PROCFS_MPTBASEDIR/...) support stuff... 5288 * procfs (%MPT_PROCFS_MPTBASEDIR/...) support stuff...
5272 */ 5289 */
5273/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5290/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5274/* 5291/**
5275 * procmpt_create - Create %MPT_PROCFS_MPTBASEDIR entries. 5292 * procmpt_create - Create %MPT_PROCFS_MPTBASEDIR entries.
5276 * 5293 *
5277 * Returns 0 for success, non-zero for failure. 5294 * Returns 0 for success, non-zero for failure.
@@ -5297,7 +5314,7 @@ procmpt_create(void)
5297} 5314}
5298 5315
5299/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5316/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5300/* 5317/**
5301 * procmpt_destroy - Tear down %MPT_PROCFS_MPTBASEDIR entries. 5318 * procmpt_destroy - Tear down %MPT_PROCFS_MPTBASEDIR entries.
5302 * 5319 *
5303 * Returns 0 for success, non-zero for failure. 5320 * Returns 0 for success, non-zero for failure.
@@ -5311,16 +5328,16 @@ procmpt_destroy(void)
5311} 5328}
5312 5329
5313/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5330/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5314/* 5331/**
5315 * procmpt_summary_read - Handle read request from /proc/mpt/summary 5332 * procmpt_summary_read - Handle read request of a summary file
5316 * or from /proc/mpt/iocN/summary.
5317 * @buf: Pointer to area to write information 5333 * @buf: Pointer to area to write information
5318 * @start: Pointer to start pointer 5334 * @start: Pointer to start pointer
5319 * @offset: Offset to start writing 5335 * @offset: Offset to start writing
5320 * @request: 5336 * @request: Amount of read data requested
5321 * @eof: Pointer to EOF integer 5337 * @eof: Pointer to EOF integer
5322 * @data: Pointer 5338 * @data: Pointer
5323 * 5339 *
5340 * Handles read request from /proc/mpt/summary or /proc/mpt/iocN/summary.
5324 * Returns number of characters written to process performing the read. 5341 * Returns number of characters written to process performing the read.
5325 */ 5342 */
5326static int 5343static int
@@ -5355,12 +5372,12 @@ procmpt_summary_read(char *buf, char **start, off_t offset, int request, int *eo
5355} 5372}
5356 5373
5357/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5374/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5358/* 5375/**
5359 * procmpt_version_read - Handle read request from /proc/mpt/version. 5376 * procmpt_version_read - Handle read request from /proc/mpt/version.
5360 * @buf: Pointer to area to write information 5377 * @buf: Pointer to area to write information
5361 * @start: Pointer to start pointer 5378 * @start: Pointer to start pointer
5362 * @offset: Offset to start writing 5379 * @offset: Offset to start writing
5363 * @request: 5380 * @request: Amount of read data requested
5364 * @eof: Pointer to EOF integer 5381 * @eof: Pointer to EOF integer
5365 * @data: Pointer 5382 * @data: Pointer
5366 * 5383 *
@@ -5411,12 +5428,12 @@ procmpt_version_read(char *buf, char **start, off_t offset, int request, int *eo
5411} 5428}
5412 5429
5413/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5430/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5414/* 5431/**
5415 * procmpt_iocinfo_read - Handle read request from /proc/mpt/iocN/info. 5432 * procmpt_iocinfo_read - Handle read request from /proc/mpt/iocN/info.
5416 * @buf: Pointer to area to write information 5433 * @buf: Pointer to area to write information
5417 * @start: Pointer to start pointer 5434 * @start: Pointer to start pointer
5418 * @offset: Offset to start writing 5435 * @offset: Offset to start writing
5419 * @request: 5436 * @request: Amount of read data requested
5420 * @eof: Pointer to EOF integer 5437 * @eof: Pointer to EOF integer
5421 * @data: Pointer 5438 * @data: Pointer
5422 * 5439 *
@@ -5577,16 +5594,17 @@ mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buffer, int *size, int len, int sh
5577 */ 5594 */
5578/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5595/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5579/** 5596/**
5580 * mpt_HardResetHandler - Generic reset handler, issue SCSI Task 5597 * mpt_HardResetHandler - Generic reset handler
5581 * Management call based on input arg values. If TaskMgmt fails,
5582 * return associated SCSI request.
5583 * @ioc: Pointer to MPT_ADAPTER structure 5598 * @ioc: Pointer to MPT_ADAPTER structure
5584 * @sleepFlag: Indicates if sleep or schedule must be called. 5599 * @sleepFlag: Indicates if sleep or schedule must be called.
5585 * 5600 *
5601 * Issues SCSI Task Management call based on input arg values.
5602 * If TaskMgmt fails, returns associated SCSI request.
5603 *
5586 * Remark: _HardResetHandler can be invoked from an interrupt thread (timer) 5604 * Remark: _HardResetHandler can be invoked from an interrupt thread (timer)
5587 * or a non-interrupt thread. In the former, must not call schedule(). 5605 * or a non-interrupt thread. In the former, must not call schedule().
5588 * 5606 *
5589 * Remark: A return of -1 is a FATAL error case, as it means a 5607 * Note: A return of -1 is a FATAL error case, as it means a
5590 * FW reload/initialization failed. 5608 * FW reload/initialization failed.
5591 * 5609 *
5592 * Returns 0 for SUCCESS or -1 if FAILED. 5610 * Returns 0 for SUCCESS or -1 if FAILED.
@@ -5935,13 +5953,14 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr)
5935} 5953}
5936 5954
5937/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5955/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5938/* 5956/**
5939 * ProcessEventNotification - Route a received EventNotificationReply to 5957 * ProcessEventNotification - Route EventNotificationReply to all event handlers
5940 * all currently regeistered event handlers.
5941 * @ioc: Pointer to MPT_ADAPTER structure 5958 * @ioc: Pointer to MPT_ADAPTER structure
5942 * @pEventReply: Pointer to EventNotification reply frame 5959 * @pEventReply: Pointer to EventNotification reply frame
5943 * @evHandlers: Pointer to integer, number of event handlers 5960 * @evHandlers: Pointer to integer, number of event handlers
5944 * 5961 *
5962 * Routes a received EventNotificationReply to all currently registered
5963 * event handlers.
5945 * Returns sum of event handlers return values. 5964 * Returns sum of event handlers return values.
5946 */ 5965 */
5947static int 5966static int
@@ -6056,7 +6075,7 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
6056} 6075}
6057 6076
6058/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6077/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6059/* 6078/**
6060 * mpt_fc_log_info - Log information returned from Fibre Channel IOC. 6079 * mpt_fc_log_info - Log information returned from Fibre Channel IOC.
6061 * @ioc: Pointer to MPT_ADAPTER structure 6080 * @ioc: Pointer to MPT_ADAPTER structure
6062 * @log_info: U32 LogInfo reply word from the IOC 6081 * @log_info: U32 LogInfo reply word from the IOC
@@ -6077,7 +6096,7 @@ mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info)
6077} 6096}
6078 6097
6079/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6098/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6080/* 6099/**
6081 * mpt_spi_log_info - Log information returned from SCSI Parallel IOC. 6100 * mpt_spi_log_info - Log information returned from SCSI Parallel IOC.
6082 * @ioc: Pointer to MPT_ADAPTER structure 6101 * @ioc: Pointer to MPT_ADAPTER structure
6083 * @mr: Pointer to MPT reply frame 6102 * @mr: Pointer to MPT reply frame
@@ -6200,7 +6219,7 @@ mpt_spi_log_info(MPT_ADAPTER *ioc, u32 log_info)
6200 }; 6219 };
6201 6220
6202/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6221/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6203/* 6222/**
6204 * mpt_sas_log_info - Log information returned from SAS IOC. 6223 * mpt_sas_log_info - Log information returned from SAS IOC.
6205 * @ioc: Pointer to MPT_ADAPTER structure 6224 * @ioc: Pointer to MPT_ADAPTER structure
6206 * @log_info: U32 LogInfo reply word from the IOC 6225 * @log_info: U32 LogInfo reply word from the IOC
@@ -6255,7 +6274,7 @@ union loginfo_type {
6255} 6274}
6256 6275
6257/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6276/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6258/* 6277/**
6259 * mpt_sp_ioc_info - IOC information returned from SCSI Parallel IOC. 6278 * mpt_sp_ioc_info - IOC information returned from SCSI Parallel IOC.
6260 * @ioc: Pointer to MPT_ADAPTER structure 6279 * @ioc: Pointer to MPT_ADAPTER structure
6261 * @ioc_status: U32 IOCStatus word from IOC 6280 * @ioc_status: U32 IOCStatus word from IOC
@@ -6416,7 +6435,7 @@ EXPORT_SYMBOL(mpt_free_fw_memory);
6416EXPORT_SYMBOL(mptbase_sas_persist_operation); 6435EXPORT_SYMBOL(mptbase_sas_persist_operation);
6417 6436
6418/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6437/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6419/* 6438/**
6420 * fusion_init - Fusion MPT base driver initialization routine. 6439 * fusion_init - Fusion MPT base driver initialization routine.
6421 * 6440 *
6422 * Returns 0 for success, non-zero for failure. 6441 * Returns 0 for success, non-zero for failure.
@@ -6456,7 +6475,7 @@ fusion_init(void)
6456} 6475}
6457 6476
6458/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6477/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6459/* 6478/**
6460 * fusion_exit - Perform driver unload cleanup. 6479 * fusion_exit - Perform driver unload cleanup.
6461 * 6480 *
6462 * This routine frees all resources associated with each MPT adapter 6481 * This routine frees all resources associated with each MPT adapter
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index 1dd491773150..ca2f9107f145 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -1018,9 +1018,10 @@ mptfc_init_host_attr(MPT_ADAPTER *ioc,int portnum)
1018} 1018}
1019 1019
1020static void 1020static void
1021mptfc_setup_reset(void *arg) 1021mptfc_setup_reset(struct work_struct *work)
1022{ 1022{
1023 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; 1023 MPT_ADAPTER *ioc =
1024 container_of(work, MPT_ADAPTER, fc_setup_reset_work);
1024 u64 pn; 1025 u64 pn;
1025 struct mptfc_rport_info *ri; 1026 struct mptfc_rport_info *ri;
1026 1027
@@ -1043,9 +1044,10 @@ mptfc_setup_reset(void *arg)
1043} 1044}
1044 1045
1045static void 1046static void
1046mptfc_rescan_devices(void *arg) 1047mptfc_rescan_devices(struct work_struct *work)
1047{ 1048{
1048 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; 1049 MPT_ADAPTER *ioc =
1050 container_of(work, MPT_ADAPTER, fc_rescan_work);
1049 int ii; 1051 int ii;
1050 u64 pn; 1052 u64 pn;
1051 struct mptfc_rport_info *ri; 1053 struct mptfc_rport_info *ri;
@@ -1154,8 +1156,8 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1154 } 1156 }
1155 1157
1156 spin_lock_init(&ioc->fc_rescan_work_lock); 1158 spin_lock_init(&ioc->fc_rescan_work_lock);
1157 INIT_WORK(&ioc->fc_rescan_work, mptfc_rescan_devices,(void *)ioc); 1159 INIT_WORK(&ioc->fc_rescan_work, mptfc_rescan_devices);
1158 INIT_WORK(&ioc->fc_setup_reset_work, mptfc_setup_reset, (void *)ioc); 1160 INIT_WORK(&ioc->fc_setup_reset_work, mptfc_setup_reset);
1159 1161
1160 spin_lock_irqsave(&ioc->FreeQlock, flags); 1162 spin_lock_irqsave(&ioc->FreeQlock, flags);
1161 1163
@@ -1393,8 +1395,7 @@ mptfc_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
1393 1395
1394/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1396/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1395/** 1397/**
1396 * mptfc_init - Register MPT adapter(s) as SCSI host(s) with 1398 * mptfc_init - Register MPT adapter(s) as SCSI host(s) with SCSI mid-layer.
1397 * linux scsi mid-layer.
1398 * 1399 *
1399 * Returns 0 for success, non-zero for failure. 1400 * Returns 0 for success, non-zero for failure.
1400 */ 1401 */
@@ -1438,7 +1439,7 @@ mptfc_init(void)
1438 1439
1439/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1440/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1440/** 1441/**
1441 * mptfc_remove - Removed fc infrastructure for devices 1442 * mptfc_remove - Remove fc infrastructure for devices
1442 * @pdev: Pointer to pci_dev structure 1443 * @pdev: Pointer to pci_dev structure
1443 * 1444 *
1444 */ 1445 */
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c
index 314c3a27585d..b7c4407c5e3f 100644
--- a/drivers/message/fusion/mptlan.c
+++ b/drivers/message/fusion/mptlan.c
@@ -111,7 +111,8 @@ struct mpt_lan_priv {
111 u32 total_received; 111 u32 total_received;
112 struct net_device_stats stats; /* Per device statistics */ 112 struct net_device_stats stats; /* Per device statistics */
113 113
114 struct work_struct post_buckets_task; 114 struct delayed_work post_buckets_task;
115 struct net_device *dev;
115 unsigned long post_buckets_active; 116 unsigned long post_buckets_active;
116}; 117};
117 118
@@ -132,7 +133,7 @@ static int lan_reply (MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf,
132static int mpt_lan_open(struct net_device *dev); 133static int mpt_lan_open(struct net_device *dev);
133static int mpt_lan_reset(struct net_device *dev); 134static int mpt_lan_reset(struct net_device *dev);
134static int mpt_lan_close(struct net_device *dev); 135static int mpt_lan_close(struct net_device *dev);
135static void mpt_lan_post_receive_buckets(void *dev_id); 136static void mpt_lan_post_receive_buckets(struct mpt_lan_priv *priv);
136static void mpt_lan_wake_post_buckets_task(struct net_device *dev, 137static void mpt_lan_wake_post_buckets_task(struct net_device *dev,
137 int priority); 138 int priority);
138static int mpt_lan_receive_post_turbo(struct net_device *dev, u32 tmsg); 139static int mpt_lan_receive_post_turbo(struct net_device *dev, u32 tmsg);
@@ -345,7 +346,7 @@ mpt_lan_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
345 priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = i; 346 priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = i;
346 spin_unlock_irqrestore(&priv->rxfidx_lock, flags); 347 spin_unlock_irqrestore(&priv->rxfidx_lock, flags);
347 } else { 348 } else {
348 mpt_lan_post_receive_buckets(dev); 349 mpt_lan_post_receive_buckets(priv);
349 netif_wake_queue(dev); 350 netif_wake_queue(dev);
350 } 351 }
351 352
@@ -441,7 +442,7 @@ mpt_lan_open(struct net_device *dev)
441 442
442 dlprintk((KERN_INFO MYNAM "/lo: Finished initializing RcvCtl\n")); 443 dlprintk((KERN_INFO MYNAM "/lo: Finished initializing RcvCtl\n"));
443 444
444 mpt_lan_post_receive_buckets(dev); 445 mpt_lan_post_receive_buckets(priv);
445 printk(KERN_INFO MYNAM ": %s/%s: interface up & active\n", 446 printk(KERN_INFO MYNAM ": %s/%s: interface up & active\n",
446 IOC_AND_NETDEV_NAMES_s_s(dev)); 447 IOC_AND_NETDEV_NAMES_s_s(dev));
447 448
@@ -854,7 +855,7 @@ mpt_lan_wake_post_buckets_task(struct net_device *dev, int priority)
854 855
855 if (test_and_set_bit(0, &priv->post_buckets_active) == 0) { 856 if (test_and_set_bit(0, &priv->post_buckets_active) == 0) {
856 if (priority) { 857 if (priority) {
857 schedule_work(&priv->post_buckets_task); 858 schedule_delayed_work(&priv->post_buckets_task, 0);
858 } else { 859 } else {
859 schedule_delayed_work(&priv->post_buckets_task, 1); 860 schedule_delayed_work(&priv->post_buckets_task, 1);
860 dioprintk((KERN_INFO MYNAM ": post_buckets queued on " 861 dioprintk((KERN_INFO MYNAM ": post_buckets queued on "
@@ -1188,10 +1189,9 @@ mpt_lan_receive_post_reply(struct net_device *dev,
1188/* Simple SGE's only at the moment */ 1189/* Simple SGE's only at the moment */
1189 1190
1190static void 1191static void
1191mpt_lan_post_receive_buckets(void *dev_id) 1192mpt_lan_post_receive_buckets(struct mpt_lan_priv *priv)
1192{ 1193{
1193 struct net_device *dev = dev_id; 1194 struct net_device *dev = priv->dev;
1194 struct mpt_lan_priv *priv = dev->priv;
1195 MPT_ADAPTER *mpt_dev = priv->mpt_dev; 1195 MPT_ADAPTER *mpt_dev = priv->mpt_dev;
1196 MPT_FRAME_HDR *mf; 1196 MPT_FRAME_HDR *mf;
1197 LANReceivePostRequest_t *pRecvReq; 1197 LANReceivePostRequest_t *pRecvReq;
@@ -1335,6 +1335,13 @@ out:
1335 clear_bit(0, &priv->post_buckets_active); 1335 clear_bit(0, &priv->post_buckets_active);
1336} 1336}
1337 1337
1338static void
1339mpt_lan_post_receive_buckets_work(struct work_struct *work)
1340{
1341 mpt_lan_post_receive_buckets(container_of(work, struct mpt_lan_priv,
1342 post_buckets_task.work));
1343}
1344
1338/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1345/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1339static struct net_device * 1346static struct net_device *
1340mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum) 1347mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
@@ -1350,11 +1357,13 @@ mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
1350 1357
1351 priv = netdev_priv(dev); 1358 priv = netdev_priv(dev);
1352 1359
1360 priv->dev = dev;
1353 priv->mpt_dev = mpt_dev; 1361 priv->mpt_dev = mpt_dev;
1354 priv->pnum = pnum; 1362 priv->pnum = pnum;
1355 1363
1356 memset(&priv->post_buckets_task, 0, sizeof(struct work_struct)); 1364 memset(&priv->post_buckets_task, 0, sizeof(priv->post_buckets_task));
1357 INIT_WORK(&priv->post_buckets_task, mpt_lan_post_receive_buckets, dev); 1365 INIT_DELAYED_WORK(&priv->post_buckets_task,
1366 mpt_lan_post_receive_buckets_work);
1358 priv->post_buckets_active = 0; 1367 priv->post_buckets_active = 0;
1359 1368
1360 dlprintk((KERN_INFO MYNAM "@%d: bucketlen = %d\n", 1369 dlprintk((KERN_INFO MYNAM "@%d: bucketlen = %d\n",
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index b752a479f6db..4f0c530e47b0 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -2006,9 +2006,10 @@ __mptsas_discovery_work(MPT_ADAPTER *ioc)
2006 *(Mutex LOCKED) 2006 *(Mutex LOCKED)
2007 */ 2007 */
2008static void 2008static void
2009mptsas_discovery_work(void * arg) 2009mptsas_discovery_work(struct work_struct *work)
2010{ 2010{
2011 struct mptsas_discovery_event *ev = arg; 2011 struct mptsas_discovery_event *ev =
2012 container_of(work, struct mptsas_discovery_event, work);
2012 MPT_ADAPTER *ioc = ev->ioc; 2013 MPT_ADAPTER *ioc = ev->ioc;
2013 2014
2014 mutex_lock(&ioc->sas_discovery_mutex); 2015 mutex_lock(&ioc->sas_discovery_mutex);
@@ -2068,9 +2069,9 @@ mptsas_find_phyinfo_by_target(MPT_ADAPTER *ioc, u32 id)
2068 * Work queue thread to clear the persitency table 2069 * Work queue thread to clear the persitency table
2069 */ 2070 */
2070static void 2071static void
2071mptsas_persist_clear_table(void * arg) 2072mptsas_persist_clear_table(struct work_struct *work)
2072{ 2073{
2073 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; 2074 MPT_ADAPTER *ioc = container_of(work, MPT_ADAPTER, sas_persist_task);
2074 2075
2075 mptbase_sas_persist_operation(ioc, MPI_SAS_OP_CLEAR_NOT_PRESENT); 2076 mptbase_sas_persist_operation(ioc, MPI_SAS_OP_CLEAR_NOT_PRESENT);
2076} 2077}
@@ -2093,9 +2094,10 @@ mptsas_reprobe_target(struct scsi_target *starget, int uld_attach)
2093 * Work queue thread to handle SAS hotplug events 2094 * Work queue thread to handle SAS hotplug events
2094 */ 2095 */
2095static void 2096static void
2096mptsas_hotplug_work(void *arg) 2097mptsas_hotplug_work(struct work_struct *work)
2097{ 2098{
2098 struct mptsas_hotplug_event *ev = arg; 2099 struct mptsas_hotplug_event *ev =
2100 container_of(work, struct mptsas_hotplug_event, work);
2099 MPT_ADAPTER *ioc = ev->ioc; 2101 MPT_ADAPTER *ioc = ev->ioc;
2100 struct mptsas_phyinfo *phy_info; 2102 struct mptsas_phyinfo *phy_info;
2101 struct sas_rphy *rphy; 2103 struct sas_rphy *rphy;
@@ -2341,7 +2343,7 @@ mptsas_send_sas_event(MPT_ADAPTER *ioc,
2341 break; 2343 break;
2342 } 2344 }
2343 2345
2344 INIT_WORK(&ev->work, mptsas_hotplug_work, ev); 2346 INIT_WORK(&ev->work, mptsas_hotplug_work);
2345 ev->ioc = ioc; 2347 ev->ioc = ioc;
2346 ev->handle = le16_to_cpu(sas_event_data->DevHandle); 2348 ev->handle = le16_to_cpu(sas_event_data->DevHandle);
2347 ev->parent_handle = 2349 ev->parent_handle =
@@ -2366,7 +2368,7 @@ mptsas_send_sas_event(MPT_ADAPTER *ioc,
2366 * Persistent table is full. 2368 * Persistent table is full.
2367 */ 2369 */
2368 INIT_WORK(&ioc->sas_persist_task, 2370 INIT_WORK(&ioc->sas_persist_task,
2369 mptsas_persist_clear_table, (void *)ioc); 2371 mptsas_persist_clear_table);
2370 schedule_work(&ioc->sas_persist_task); 2372 schedule_work(&ioc->sas_persist_task);
2371 break; 2373 break;
2372 case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA: 2374 case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA:
@@ -2395,7 +2397,7 @@ mptsas_send_raid_event(MPT_ADAPTER *ioc,
2395 return; 2397 return;
2396 } 2398 }
2397 2399
2398 INIT_WORK(&ev->work, mptsas_hotplug_work, ev); 2400 INIT_WORK(&ev->work, mptsas_hotplug_work);
2399 ev->ioc = ioc; 2401 ev->ioc = ioc;
2400 ev->id = raid_event_data->VolumeID; 2402 ev->id = raid_event_data->VolumeID;
2401 ev->event_type = MPTSAS_IGNORE_EVENT; 2403 ev->event_type = MPTSAS_IGNORE_EVENT;
@@ -2474,7 +2476,7 @@ mptsas_send_discovery_event(MPT_ADAPTER *ioc,
2474 ev = kzalloc(sizeof(*ev), GFP_ATOMIC); 2476 ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
2475 if (!ev) 2477 if (!ev)
2476 return; 2478 return;
2477 INIT_WORK(&ev->work, mptsas_discovery_work, ev); 2479 INIT_WORK(&ev->work, mptsas_discovery_work);
2478 ev->ioc = ioc; 2480 ev->ioc = ioc;
2479 schedule_work(&ev->work); 2481 schedule_work(&ev->work);
2480}; 2482};
@@ -2511,8 +2513,7 @@ mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply)
2511 break; 2513 break;
2512 case MPI_EVENT_PERSISTENT_TABLE_FULL: 2514 case MPI_EVENT_PERSISTENT_TABLE_FULL:
2513 INIT_WORK(&ioc->sas_persist_task, 2515 INIT_WORK(&ioc->sas_persist_task,
2514 mptsas_persist_clear_table, 2516 mptsas_persist_clear_table);
2515 (void *)ioc);
2516 schedule_work(&ioc->sas_persist_task); 2517 schedule_work(&ioc->sas_persist_task);
2517 break; 2518 break;
2518 case MPI_EVENT_SAS_DISCOVERY: 2519 case MPI_EVENT_SAS_DISCOVERY:
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 30524dc54b16..2c72c36b8171 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1230,15 +1230,15 @@ mptscsih_host_info(MPT_ADAPTER *ioc, char *pbuf, off_t offset, int len)
1230/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1230/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1231/** 1231/**
1232 * mptscsih_proc_info - Return information about MPT adapter 1232 * mptscsih_proc_info - Return information about MPT adapter
1233 * @host: scsi host struct
1234 * @buffer: if write, user data; if read, buffer for user
1235 * @start: returns the buffer address
1236 * @offset: if write, 0; if read, the current offset into the buffer from
1237 * the previous read.
1238 * @length: if write, return length;
1239 * @func: write = 1; read = 0
1233 * 1240 *
1234 * (linux scsi_host_template.info routine) 1241 * (linux scsi_host_template.info routine)
1235 *
1236 * buffer: if write, user data; if read, buffer for user
1237 * length: if write, return length;
1238 * offset: if write, 0; if read, the current offset into the buffer from
1239 * the previous read.
1240 * hostno: scsi host number
1241 * func: if write = 1; if read = 0
1242 */ 1242 */
1243int 1243int
1244mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, 1244mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
@@ -1902,8 +1902,7 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
1902 1902
1903/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1903/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1904/** 1904/**
1905 * mptscsih_host_reset - Perform a SCSI host adapter RESET! 1905 * mptscsih_host_reset - Perform a SCSI host adapter RESET (new_eh variant)
1906 * new_eh variant
1907 * @SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to 1906 * @SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to
1908 * 1907 *
1909 * (linux scsi_host_template.eh_host_reset_handler routine) 1908 * (linux scsi_host_template.eh_host_reset_handler routine)
@@ -1949,8 +1948,7 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
1949 1948
1950/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1949/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1951/** 1950/**
1952 * mptscsih_tm_pending_wait - wait for pending task management request to 1951 * mptscsih_tm_pending_wait - wait for pending task management request to complete
1953 * complete.
1954 * @hd: Pointer to MPT host structure. 1952 * @hd: Pointer to MPT host structure.
1955 * 1953 *
1956 * Returns {SUCCESS,FAILED}. 1954 * Returns {SUCCESS,FAILED}.
@@ -1982,6 +1980,7 @@ mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd)
1982/** 1980/**
1983 * mptscsih_tm_wait_for_completion - wait for completion of TM task 1981 * mptscsih_tm_wait_for_completion - wait for completion of TM task
1984 * @hd: Pointer to MPT host structure. 1982 * @hd: Pointer to MPT host structure.
1983 * @timeout: timeout in seconds
1985 * 1984 *
1986 * Returns {SUCCESS,FAILED}. 1985 * Returns {SUCCESS,FAILED}.
1987 */ 1986 */
@@ -3429,8 +3428,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3429/** 3428/**
3430 * mptscsih_synchronize_cache - Send SYNCHRONIZE_CACHE to all disks. 3429 * mptscsih_synchronize_cache - Send SYNCHRONIZE_CACHE to all disks.
3431 * @hd: Pointer to a SCSI HOST structure 3430 * @hd: Pointer to a SCSI HOST structure
3432 * @vtarget: per device private data 3431 * @vdevice: virtual target device
3433 * @lun: lun
3434 * 3432 *
3435 * Uses the ISR, but with special processing. 3433 * Uses the ISR, but with special processing.
3436 * MUST be single-threaded. 3434 * MUST be single-threaded.
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index e4cc3dd5fc9f..36641da59289 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -646,9 +646,10 @@ struct work_queue_wrapper {
646 int disk; 646 int disk;
647}; 647};
648 648
649static void mpt_work_wrapper(void *data) 649static void mpt_work_wrapper(struct work_struct *work)
650{ 650{
651 struct work_queue_wrapper *wqw = (struct work_queue_wrapper *)data; 651 struct work_queue_wrapper *wqw =
652 container_of(work, struct work_queue_wrapper, work);
652 struct _MPT_SCSI_HOST *hd = wqw->hd; 653 struct _MPT_SCSI_HOST *hd = wqw->hd;
653 struct Scsi_Host *shost = hd->ioc->sh; 654 struct Scsi_Host *shost = hd->ioc->sh;
654 struct scsi_device *sdev; 655 struct scsi_device *sdev;
@@ -695,7 +696,7 @@ static void mpt_dv_raid(struct _MPT_SCSI_HOST *hd, int disk)
695 disk); 696 disk);
696 return; 697 return;
697 } 698 }
698 INIT_WORK(&wqw->work, mpt_work_wrapper, wqw); 699 INIT_WORK(&wqw->work, mpt_work_wrapper);
699 wqw->hd = hd; 700 wqw->hd = hd;
700 wqw->disk = disk; 701 wqw->disk = disk;
701 702
@@ -784,9 +785,10 @@ MODULE_DEVICE_TABLE(pci, mptspi_pci_table);
784 * renegotiate for a given target 785 * renegotiate for a given target
785 */ 786 */
786static void 787static void
787mptspi_dv_renegotiate_work(void *data) 788mptspi_dv_renegotiate_work(struct work_struct *work)
788{ 789{
789 struct work_queue_wrapper *wqw = (struct work_queue_wrapper *)data; 790 struct work_queue_wrapper *wqw =
791 container_of(work, struct work_queue_wrapper, work);
790 struct _MPT_SCSI_HOST *hd = wqw->hd; 792 struct _MPT_SCSI_HOST *hd = wqw->hd;
791 struct scsi_device *sdev; 793 struct scsi_device *sdev;
792 794
@@ -804,7 +806,7 @@ mptspi_dv_renegotiate(struct _MPT_SCSI_HOST *hd)
804 if (!wqw) 806 if (!wqw)
805 return; 807 return;
806 808
807 INIT_WORK(&wqw->work, mptspi_dv_renegotiate_work, wqw); 809 INIT_WORK(&wqw->work, mptspi_dv_renegotiate_work);
808 wqw->hd = hd; 810 wqw->hd = hd;
809 811
810 schedule_work(&wqw->work); 812 schedule_work(&wqw->work);
@@ -1098,8 +1100,7 @@ static struct pci_driver mptspi_driver = {
1098 1100
1099/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1101/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1100/** 1102/**
1101 * mptspi_init - Register MPT adapter(s) as SCSI host(s) with 1103 * mptspi_init - Register MPT adapter(s) as SCSI host(s) with SCSI mid-layer.
1102 * linux scsi mid-layer.
1103 * 1104 *
1104 * Returns 0 for success, non-zero for failure. 1105 * Returns 0 for success, non-zero for failure.
1105 */ 1106 */
@@ -1133,7 +1134,6 @@ mptspi_init(void)
1133/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1134/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1134/** 1135/**
1135 * mptspi_exit - Unregisters MPT adapter(s) 1136 * mptspi_exit - Unregisters MPT adapter(s)
1136 *
1137 */ 1137 */
1138static void __exit 1138static void __exit
1139mptspi_exit(void) 1139mptspi_exit(void)
diff --git a/drivers/message/i2o/bus-osm.c b/drivers/message/i2o/bus-osm.c
index d96c687aee93..c463dc2efc09 100644
--- a/drivers/message/i2o/bus-osm.c
+++ b/drivers/message/i2o/bus-osm.c
@@ -56,6 +56,9 @@ static int i2o_bus_scan(struct i2o_device *dev)
56/** 56/**
57 * i2o_bus_store_scan - Scan the I2O Bus Adapter 57 * i2o_bus_store_scan - Scan the I2O Bus Adapter
58 * @d: device which should be scanned 58 * @d: device which should be scanned
59 * @attr: device_attribute
60 * @buf: output buffer
61 * @count: buffer size
59 * 62 *
60 * Returns count. 63 * Returns count.
61 */ 64 */
diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c
index ee183053fa23..b9df143e4ff1 100644
--- a/drivers/message/i2o/device.c
+++ b/drivers/message/i2o/device.c
@@ -54,8 +54,8 @@ static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd,
54 * @dev: I2O device to claim 54 * @dev: I2O device to claim
55 * @drv: I2O driver which wants to claim the device 55 * @drv: I2O driver which wants to claim the device
56 * 56 *
57 * Do the leg work to assign a device to a given OSM. If the claim succeed 57 * Do the leg work to assign a device to a given OSM. If the claim succeeds,
58 * the owner of the rimary. If the attempt fails a negative errno code 58 * the owner is the primary. If the attempt fails a negative errno code
59 * is returned. On success zero is returned. 59 * is returned. On success zero is returned.
60 */ 60 */
61int i2o_device_claim(struct i2o_device *dev) 61int i2o_device_claim(struct i2o_device *dev)
@@ -208,24 +208,23 @@ static struct i2o_device *i2o_device_alloc(void)
208 208
209/** 209/**
210 * i2o_device_add - allocate a new I2O device and add it to the IOP 210 * i2o_device_add - allocate a new I2O device and add it to the IOP
211 * @iop: I2O controller where the device is on 211 * @c: I2O controller that the device is on
212 * @entry: LCT entry of the I2O device 212 * @entry: LCT entry of the I2O device
213 * 213 *
214 * Allocate a new I2O device and initialize it with the LCT entry. The 214 * Allocate a new I2O device and initialize it with the LCT entry. The
215 * device is appended to the device list of the controller. 215 * device is appended to the device list of the controller.
216 * 216 *
217 * Returns a pointer to the I2O device on success or negative error code 217 * Returns zero on success, or a -ve errno.
218 * on failure.
219 */ 218 */
220static struct i2o_device *i2o_device_add(struct i2o_controller *c, 219static int i2o_device_add(struct i2o_controller *c, i2o_lct_entry *entry)
221 i2o_lct_entry * entry)
222{ 220{
223 struct i2o_device *i2o_dev, *tmp; 221 struct i2o_device *i2o_dev, *tmp;
222 int rc;
224 223
225 i2o_dev = i2o_device_alloc(); 224 i2o_dev = i2o_device_alloc();
226 if (IS_ERR(i2o_dev)) { 225 if (IS_ERR(i2o_dev)) {
227 printk(KERN_ERR "i2o: unable to allocate i2o device\n"); 226 printk(KERN_ERR "i2o: unable to allocate i2o device\n");
228 return i2o_dev; 227 return PTR_ERR(i2o_dev);
229 } 228 }
230 229
231 i2o_dev->lct_data = *entry; 230 i2o_dev->lct_data = *entry;
@@ -236,7 +235,9 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c,
236 i2o_dev->iop = c; 235 i2o_dev->iop = c;
237 i2o_dev->device.parent = &c->device; 236 i2o_dev->device.parent = &c->device;
238 237
239 device_register(&i2o_dev->device); 238 rc = device_register(&i2o_dev->device);
239 if (rc)
240 goto err;
240 241
241 list_add_tail(&i2o_dev->list, &c->devices); 242 list_add_tail(&i2o_dev->list, &c->devices);
242 243
@@ -270,12 +271,16 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c,
270 271
271 pr_debug("i2o: device %s added\n", i2o_dev->device.bus_id); 272 pr_debug("i2o: device %s added\n", i2o_dev->device.bus_id);
272 273
273 return i2o_dev; 274 return 0;
275
276err:
277 kfree(i2o_dev);
278 return rc;
274} 279}
275 280
276/** 281/**
277 * i2o_device_remove - remove an I2O device from the I2O core 282 * i2o_device_remove - remove an I2O device from the I2O core
278 * @dev: I2O device which should be released 283 * @i2o_dev: I2O device which should be released
279 * 284 *
280 * Is used on I2O controller removal or LCT modification, when the device 285 * Is used on I2O controller removal or LCT modification, when the device
281 * is removed from the system. Note that the device could still hang 286 * is removed from the system. Note that the device could still hang
diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c
index 64130227574f..9104b65ff70f 100644
--- a/drivers/message/i2o/driver.c
+++ b/drivers/message/i2o/driver.c
@@ -34,9 +34,7 @@ static spinlock_t i2o_drivers_lock;
34static struct i2o_driver **i2o_drivers; 34static struct i2o_driver **i2o_drivers;
35 35
36/** 36/**
37 * i2o_bus_match - Tell if a I2O device class id match the class ids of 37 * i2o_bus_match - Tell if I2O device class id matches the class ids of the I2O driver (OSM)
38 * the I2O driver (OSM)
39 *
40 * @dev: device which should be verified 38 * @dev: device which should be verified
41 * @drv: the driver to match against 39 * @drv: the driver to match against
42 * 40 *
@@ -232,7 +230,7 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
232 break; 230 break;
233 } 231 }
234 232
235 INIT_WORK(&evt->work, (void (*)(void *))drv->event, evt); 233 INIT_WORK(&evt->work, drv->event);
236 queue_work(drv->event_queue, &evt->work); 234 queue_work(drv->event_queue, &evt->work);
237 return 1; 235 return 1;
238 } 236 }
@@ -248,7 +246,7 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
248 246
249/** 247/**
250 * i2o_driver_notify_controller_add_all - Send notify of added controller 248 * i2o_driver_notify_controller_add_all - Send notify of added controller
251 * to all I2O drivers 249 * @c: newly added controller
252 * 250 *
253 * Send notifications to all registered drivers that a new controller was 251 * Send notifications to all registered drivers that a new controller was
254 * added. 252 * added.
@@ -267,8 +265,8 @@ void i2o_driver_notify_controller_add_all(struct i2o_controller *c)
267} 265}
268 266
269/** 267/**
270 * i2o_driver_notify_controller_remove_all - Send notify of removed 268 * i2o_driver_notify_controller_remove_all - Send notify of removed controller
271 * controller to all I2O drivers 269 * @c: controller that is being removed
272 * 270 *
273 * Send notifications to all registered drivers that a controller was 271 * Send notifications to all registered drivers that a controller was
274 * removed. 272 * removed.
@@ -287,8 +285,8 @@ void i2o_driver_notify_controller_remove_all(struct i2o_controller *c)
287} 285}
288 286
289/** 287/**
290 * i2o_driver_notify_device_add_all - Send notify of added device to all 288 * i2o_driver_notify_device_add_all - Send notify of added device
291 * I2O drivers 289 * @i2o_dev: newly added I2O device
292 * 290 *
293 * Send notifications to all registered drivers that a device was added. 291 * Send notifications to all registered drivers that a device was added.
294 */ 292 */
@@ -306,8 +304,8 @@ void i2o_driver_notify_device_add_all(struct i2o_device *i2o_dev)
306} 304}
307 305
308/** 306/**
309 * i2o_driver_notify_device_remove_all - Send notify of removed device to 307 * i2o_driver_notify_device_remove_all - Send notify of removed device
310 * all I2O drivers 308 * @i2o_dev: device that is being removed
311 * 309 *
312 * Send notifications to all registered drivers that a device was removed. 310 * Send notifications to all registered drivers that a device was removed.
313 */ 311 */
@@ -362,7 +360,7 @@ int __init i2o_driver_init(void)
362/** 360/**
363 * i2o_driver_exit - clean up I2O drivers (OSMs) 361 * i2o_driver_exit - clean up I2O drivers (OSMs)
364 * 362 *
365 * Unregisters the I2O bus and free driver array. 363 * Unregisters the I2O bus and frees driver array.
366 */ 364 */
367void __exit i2o_driver_exit(void) 365void __exit i2o_driver_exit(void)
368{ 366{
diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c
index a2350640384b..902753b2c661 100644
--- a/drivers/message/i2o/exec-osm.c
+++ b/drivers/message/i2o/exec-osm.c
@@ -94,8 +94,8 @@ static struct i2o_exec_wait *i2o_exec_wait_alloc(void)
94}; 94};
95 95
96/** 96/**
97 * i2o_exec_wait_free - Free a i2o_exec_wait struct 97 * i2o_exec_wait_free - Free an i2o_exec_wait struct
98 * @i2o_exec_wait: I2O wait data which should be cleaned up 98 * @wait: I2O wait data which should be cleaned up
99 */ 99 */
100static void i2o_exec_wait_free(struct i2o_exec_wait *wait) 100static void i2o_exec_wait_free(struct i2o_exec_wait *wait)
101{ 101{
@@ -105,7 +105,7 @@ static void i2o_exec_wait_free(struct i2o_exec_wait *wait)
105/** 105/**
106 * i2o_msg_post_wait_mem - Post and wait a message with DMA buffers 106 * i2o_msg_post_wait_mem - Post and wait a message with DMA buffers
107 * @c: controller 107 * @c: controller
108 * @m: message to post 108 * @msg: message to post
109 * @timeout: time in seconds to wait 109 * @timeout: time in seconds to wait
110 * @dma: i2o_dma struct of the DMA buffer to free on failure 110 * @dma: i2o_dma struct of the DMA buffer to free on failure
111 * 111 *
@@ -269,6 +269,7 @@ static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m,
269/** 269/**
270 * i2o_exec_show_vendor_id - Displays Vendor ID of controller 270 * i2o_exec_show_vendor_id - Displays Vendor ID of controller
271 * @d: device of which the Vendor ID should be displayed 271 * @d: device of which the Vendor ID should be displayed
272 * @attr: device_attribute to display
272 * @buf: buffer into which the Vendor ID should be printed 273 * @buf: buffer into which the Vendor ID should be printed
273 * 274 *
274 * Returns number of bytes printed into buffer. 275 * Returns number of bytes printed into buffer.
@@ -290,6 +291,7 @@ static ssize_t i2o_exec_show_vendor_id(struct device *d,
290/** 291/**
291 * i2o_exec_show_product_id - Displays Product ID of controller 292 * i2o_exec_show_product_id - Displays Product ID of controller
292 * @d: device of which the Product ID should be displayed 293 * @d: device of which the Product ID should be displayed
294 * @attr: device_attribute to display
293 * @buf: buffer into which the Product ID should be printed 295 * @buf: buffer into which the Product ID should be printed
294 * 296 *
295 * Returns number of bytes printed into buffer. 297 * Returns number of bytes printed into buffer.
@@ -365,14 +367,16 @@ static int i2o_exec_remove(struct device *dev)
365 367
366/** 368/**
367 * i2o_exec_lct_modified - Called on LCT NOTIFY reply 369 * i2o_exec_lct_modified - Called on LCT NOTIFY reply
368 * @c: I2O controller on which the LCT has modified 370 * @work: work struct for a specific controller
369 * 371 *
370 * This function handles asynchronus LCT NOTIFY replies. It parses the 372 * This function handles asynchronus LCT NOTIFY replies. It parses the
371 * new LCT and if the buffer for the LCT was to small sends a LCT NOTIFY 373 * new LCT and if the buffer for the LCT was to small sends a LCT NOTIFY
372 * again, otherwise send LCT NOTIFY to get informed on next LCT change. 374 * again, otherwise send LCT NOTIFY to get informed on next LCT change.
373 */ 375 */
374static void i2o_exec_lct_modified(struct i2o_exec_lct_notify_work *work) 376static void i2o_exec_lct_modified(struct work_struct *_work)
375{ 377{
378 struct i2o_exec_lct_notify_work *work =
379 container_of(_work, struct i2o_exec_lct_notify_work, work);
376 u32 change_ind = 0; 380 u32 change_ind = 0;
377 struct i2o_controller *c = work->c; 381 struct i2o_controller *c = work->c;
378 382
@@ -439,8 +443,7 @@ static int i2o_exec_reply(struct i2o_controller *c, u32 m,
439 443
440 work->c = c; 444 work->c = c;
441 445
442 INIT_WORK(&work->work, (void (*)(void *))i2o_exec_lct_modified, 446 INIT_WORK(&work->work, i2o_exec_lct_modified);
443 work);
444 queue_work(i2o_exec_driver.event_queue, &work->work); 447 queue_work(i2o_exec_driver.event_queue, &work->work);
445 return 1; 448 return 1;
446 } 449 }
@@ -460,13 +463,15 @@ static int i2o_exec_reply(struct i2o_controller *c, u32 m,
460 463
461/** 464/**
462 * i2o_exec_event - Event handling function 465 * i2o_exec_event - Event handling function
463 * @evt: Event which occurs 466 * @work: Work item in occurring event
464 * 467 *
465 * Handles events send by the Executive device. At the moment does not do 468 * Handles events send by the Executive device. At the moment does not do
466 * anything useful. 469 * anything useful.
467 */ 470 */
468static void i2o_exec_event(struct i2o_event *evt) 471static void i2o_exec_event(struct work_struct *work)
469{ 472{
473 struct i2o_event *evt = container_of(work, struct i2o_event, work);
474
470 if (likely(evt->i2o_dev)) 475 if (likely(evt->i2o_dev))
471 osm_debug("Event received from device: %d\n", 476 osm_debug("Event received from device: %d\n",
472 evt->i2o_dev->lct_data.tid); 477 evt->i2o_dev->lct_data.tid);
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index eaba81bf2eca..da9859f2caf2 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -259,7 +259,7 @@ static int i2o_block_device_unlock(struct i2o_device *dev, u32 media_id)
259/** 259/**
260 * i2o_block_device_power - Power management for device dev 260 * i2o_block_device_power - Power management for device dev
261 * @dev: I2O device which should receive the power management request 261 * @dev: I2O device which should receive the power management request
262 * @operation: Operation which should be send 262 * @op: Operation to send
263 * 263 *
264 * Send a power management request to the device dev. 264 * Send a power management request to the device dev.
265 * 265 *
@@ -315,7 +315,7 @@ static inline struct i2o_block_request *i2o_block_request_alloc(void)
315 * i2o_block_request_free - Frees a I2O block request 315 * i2o_block_request_free - Frees a I2O block request
316 * @ireq: I2O block request which should be freed 316 * @ireq: I2O block request which should be freed
317 * 317 *
318 * Fres the allocated memory (give it back to the request mempool). 318 * Frees the allocated memory (give it back to the request mempool).
319 */ 319 */
320static inline void i2o_block_request_free(struct i2o_block_request *ireq) 320static inline void i2o_block_request_free(struct i2o_block_request *ireq)
321{ 321{
@@ -326,6 +326,7 @@ static inline void i2o_block_request_free(struct i2o_block_request *ireq)
326 * i2o_block_sglist_alloc - Allocate the SG list and map it 326 * i2o_block_sglist_alloc - Allocate the SG list and map it
327 * @c: I2O controller to which the request belongs 327 * @c: I2O controller to which the request belongs
328 * @ireq: I2O block request 328 * @ireq: I2O block request
329 * @mptr: message body pointer
329 * 330 *
330 * Builds the SG list and map it to be accessable by the controller. 331 * Builds the SG list and map it to be accessable by the controller.
331 * 332 *
@@ -419,16 +420,18 @@ static int i2o_block_prep_req_fn(struct request_queue *q, struct request *req)
419 420
420/** 421/**
421 * i2o_block_delayed_request_fn - delayed request queue function 422 * i2o_block_delayed_request_fn - delayed request queue function
422 * delayed_request: the delayed request with the queue to start 423 * @work: the delayed request with the queue to start
423 * 424 *
424 * If the request queue is stopped for a disk, and there is no open 425 * If the request queue is stopped for a disk, and there is no open
425 * request, a new event is created, which calls this function to start 426 * request, a new event is created, which calls this function to start
426 * the queue after I2O_BLOCK_REQUEST_TIME. Otherwise the queue will never 427 * the queue after I2O_BLOCK_REQUEST_TIME. Otherwise the queue will never
427 * be started again. 428 * be started again.
428 */ 429 */
429static void i2o_block_delayed_request_fn(void *delayed_request) 430static void i2o_block_delayed_request_fn(struct work_struct *work)
430{ 431{
431 struct i2o_block_delayed_request *dreq = delayed_request; 432 struct i2o_block_delayed_request *dreq =
433 container_of(work, struct i2o_block_delayed_request,
434 work.work);
432 struct request_queue *q = dreq->queue; 435 struct request_queue *q = dreq->queue;
433 unsigned long flags; 436 unsigned long flags;
434 437
@@ -488,7 +491,7 @@ static void i2o_block_end_request(struct request *req, int uptodate,
488 * i2o_block_reply - Block OSM reply handler. 491 * i2o_block_reply - Block OSM reply handler.
489 * @c: I2O controller from which the message arrives 492 * @c: I2O controller from which the message arrives
490 * @m: message id of reply 493 * @m: message id of reply
491 * qmsg: the actuall I2O message reply 494 * @msg: the actual I2O message reply
492 * 495 *
493 * This function gets all the message replies. 496 * This function gets all the message replies.
494 * 497 *
@@ -538,8 +541,9 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m,
538 return 1; 541 return 1;
539}; 542};
540 543
541static void i2o_block_event(struct i2o_event *evt) 544static void i2o_block_event(struct work_struct *work)
542{ 545{
546 struct i2o_event *evt = container_of(work, struct i2o_event, work);
543 osm_debug("event received\n"); 547 osm_debug("event received\n");
544 kfree(evt); 548 kfree(evt);
545}; 549};
@@ -599,6 +603,8 @@ static void i2o_block_biosparam(unsigned long capacity, unsigned short *cyls,
599 603
600/** 604/**
601 * i2o_block_open - Open the block device 605 * i2o_block_open - Open the block device
606 * @inode: inode for block device being opened
607 * @file: file to open
602 * 608 *
603 * Power up the device, mount and lock the media. This function is called, 609 * Power up the device, mount and lock the media. This function is called,
604 * if the block device is opened for access. 610 * if the block device is opened for access.
@@ -626,6 +632,8 @@ static int i2o_block_open(struct inode *inode, struct file *file)
626 632
627/** 633/**
628 * i2o_block_release - Release the I2O block device 634 * i2o_block_release - Release the I2O block device
635 * @inode: inode for block device being released
636 * @file: file to close
629 * 637 *
630 * Unlock and unmount the media, and power down the device. Gets called if 638 * Unlock and unmount the media, and power down the device. Gets called if
631 * the block device is closed. 639 * the block device is closed.
@@ -672,6 +680,8 @@ static int i2o_block_getgeo(struct block_device *bdev, struct hd_geometry *geo)
672 680
673/** 681/**
674 * i2o_block_ioctl - Issue device specific ioctl calls. 682 * i2o_block_ioctl - Issue device specific ioctl calls.
683 * @inode: inode for block device ioctl
684 * @file: file for ioctl
675 * @cmd: ioctl command 685 * @cmd: ioctl command
676 * @arg: arg 686 * @arg: arg
677 * 687 *
@@ -899,7 +909,7 @@ static int i2o_block_transfer(struct request *req)
899 909
900/** 910/**
901 * i2o_block_request_fn - request queue handling function 911 * i2o_block_request_fn - request queue handling function
902 * q: request queue from which the request could be fetched 912 * @q: request queue from which the request could be fetched
903 * 913 *
904 * Takes the next request from the queue, transfers it and if no error 914 * Takes the next request from the queue, transfers it and if no error
905 * occurs dequeue it from the queue. On arrival of the reply the message 915 * occurs dequeue it from the queue. On arrival of the reply the message
@@ -938,8 +948,8 @@ static void i2o_block_request_fn(struct request_queue *q)
938 continue; 948 continue;
939 949
940 dreq->queue = q; 950 dreq->queue = q;
941 INIT_WORK(&dreq->work, i2o_block_delayed_request_fn, 951 INIT_DELAYED_WORK(&dreq->work,
942 dreq); 952 i2o_block_delayed_request_fn);
943 953
944 if (!queue_delayed_work(i2o_block_driver.event_queue, 954 if (!queue_delayed_work(i2o_block_driver.event_queue,
945 &dreq->work, 955 &dreq->work,
diff --git a/drivers/message/i2o/i2o_block.h b/drivers/message/i2o/i2o_block.h
index 4fdaa5bda412..67f921b4419b 100644
--- a/drivers/message/i2o/i2o_block.h
+++ b/drivers/message/i2o/i2o_block.h
@@ -64,7 +64,7 @@
64 64
65/* I2O Block OSM mempool struct */ 65/* I2O Block OSM mempool struct */
66struct i2o_block_mempool { 66struct i2o_block_mempool {
67 kmem_cache_t *slab; 67 struct kmem_cache *slab;
68 mempool_t *pool; 68 mempool_t *pool;
69}; 69};
70 70
@@ -96,7 +96,7 @@ struct i2o_block_request {
96 96
97/* I2O Block device delayed request */ 97/* I2O Block device delayed request */
98struct i2o_block_delayed_request { 98struct i2o_block_delayed_request {
99 struct work_struct work; 99 struct delayed_work work;
100 struct request_queue *queue; 100 struct request_queue *queue;
101}; 101};
102 102
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index 7d23e082bf26..1de30d711671 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -265,7 +265,11 @@ static int i2o_cfg_swdl(unsigned long arg)
265 return -ENOMEM; 265 return -ENOMEM;
266 } 266 }
267 267
268 __copy_from_user(buffer.virt, kxfer.buf, fragsize); 268 if (__copy_from_user(buffer.virt, kxfer.buf, fragsize)) {
269 i2o_msg_nop(c, msg);
270 i2o_dma_free(&c->pdev->dev, &buffer);
271 return -EFAULT;
272 }
269 273
270 msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_7); 274 msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_7);
271 msg->u.head[1] = 275 msg->u.head[1] =
@@ -516,7 +520,6 @@ static int i2o_cfg_evt_get(unsigned long arg, struct file *fp)
516 return 0; 520 return 0;
517} 521}
518 522
519#ifdef CONFIG_I2O_EXT_ADAPTEC
520#ifdef CONFIG_COMPAT 523#ifdef CONFIG_COMPAT
521static int i2o_cfg_passthru32(struct file *file, unsigned cmnd, 524static int i2o_cfg_passthru32(struct file *file, unsigned cmnd,
522 unsigned long arg) 525 unsigned long arg)
@@ -759,6 +762,7 @@ static long i2o_cfg_compat_ioctl(struct file *file, unsigned cmd,
759 762
760#endif 763#endif
761 764
765#ifdef CONFIG_I2O_EXT_ADAPTEC
762static int i2o_cfg_passthru(unsigned long arg) 766static int i2o_cfg_passthru(unsigned long arg)
763{ 767{
764 struct i2o_cmd_passthru __user *cmd = 768 struct i2o_cmd_passthru __user *cmd =
diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
index 3d2e76eea93e..a61cb17c5c12 100644
--- a/drivers/message/i2o/i2o_proc.c
+++ b/drivers/message/i2o/i2o_proc.c
@@ -163,7 +163,7 @@ static int print_serial_number(struct seq_file *seq, u8 * serialno, int max_len)
163 * i2o_get_class_name - do i2o class name lookup 163 * i2o_get_class_name - do i2o class name lookup
164 * @class: class number 164 * @class: class number
165 * 165 *
166 * Return a descriptive string for an i2o class 166 * Return a descriptive string for an i2o class.
167 */ 167 */
168static const char *i2o_get_class_name(int class) 168static const char *i2o_get_class_name(int class)
169{ 169{
diff --git a/drivers/message/i2o/i2o_scsi.c b/drivers/message/i2o/i2o_scsi.c
index 6ebf38213f9f..1045c8a518bb 100644
--- a/drivers/message/i2o/i2o_scsi.c
+++ b/drivers/message/i2o/i2o_scsi.c
@@ -220,7 +220,7 @@ static int i2o_scsi_probe(struct device *dev)
220 u32 id = -1; 220 u32 id = -1;
221 u64 lun = -1; 221 u64 lun = -1;
222 int channel = -1; 222 int channel = -1;
223 int i; 223 int i, rc;
224 224
225 i2o_shost = i2o_scsi_get_host(c); 225 i2o_shost = i2o_scsi_get_host(c);
226 if (!i2o_shost) 226 if (!i2o_shost)
@@ -304,14 +304,20 @@ static int i2o_scsi_probe(struct device *dev)
304 return PTR_ERR(scsi_dev); 304 return PTR_ERR(scsi_dev);
305 } 305 }
306 306
307 sysfs_create_link(&i2o_dev->device.kobj, &scsi_dev->sdev_gendev.kobj, 307 rc = sysfs_create_link(&i2o_dev->device.kobj,
308 "scsi"); 308 &scsi_dev->sdev_gendev.kobj, "scsi");
309 if (rc)
310 goto err;
309 311
310 osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %ld\n", 312 osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %ld\n",
311 i2o_dev->lct_data.tid, channel, le32_to_cpu(id), 313 i2o_dev->lct_data.tid, channel, le32_to_cpu(id),
312 (long unsigned int)le64_to_cpu(lun)); 314 (long unsigned int)le64_to_cpu(lun));
313 315
314 return 0; 316 return 0;
317
318err:
319 scsi_remove_device(scsi_dev);
320 return rc;
315}; 321};
316 322
317static const char *i2o_scsi_info(struct Scsi_Host *SChost) 323static const char *i2o_scsi_info(struct Scsi_Host *SChost)
@@ -405,8 +411,7 @@ static void i2o_scsi_notify_device_add(struct i2o_device *i2o_dev)
405}; 411};
406 412
407/** 413/**
408 * i2o_scsi_notify_device_remove - Retrieve notifications of removed 414 * i2o_scsi_notify_device_remove - Retrieve notifications of removed devices
409 * devices
410 * @i2o_dev: the I2O device which was removed 415 * @i2o_dev: the I2O device which was removed
411 * 416 *
412 * If a I2O device is removed, we catch the notification to remove the 417 * If a I2O device is removed, we catch the notification to remove the
@@ -426,8 +431,7 @@ static void i2o_scsi_notify_device_remove(struct i2o_device *i2o_dev)
426}; 431};
427 432
428/** 433/**
429 * i2o_scsi_notify_controller_add - Retrieve notifications of added 434 * i2o_scsi_notify_controller_add - Retrieve notifications of added controllers
430 * controllers
431 * @c: the controller which was added 435 * @c: the controller which was added
432 * 436 *
433 * If a I2O controller is added, we catch the notification to add a 437 * If a I2O controller is added, we catch the notification to add a
@@ -457,8 +461,7 @@ static void i2o_scsi_notify_controller_add(struct i2o_controller *c)
457}; 461};
458 462
459/** 463/**
460 * i2o_scsi_notify_controller_remove - Retrieve notifications of removed 464 * i2o_scsi_notify_controller_remove - Retrieve notifications of removed controllers
461 * controllers
462 * @c: the controller which was removed 465 * @c: the controller which was removed
463 * 466 *
464 * If a I2O controller is removed, we catch the notification to remove the 467 * If a I2O controller is removed, we catch the notification to remove the
@@ -745,7 +748,7 @@ static int i2o_scsi_abort(struct scsi_cmnd *SCpnt)
745 * @capacity: size in sectors 748 * @capacity: size in sectors
746 * @ip: geometry array 749 * @ip: geometry array
747 * 750 *
748 * This is anyones guess quite frankly. We use the same rules everyone 751 * This is anyone's guess quite frankly. We use the same rules everyone
749 * else appears to and hope. It seems to work. 752 * else appears to and hope. It seems to work.
750 */ 753 */
751 754
diff --git a/drivers/message/i2o/pci.c b/drivers/message/i2o/pci.c
index 8287f95c8c42..3661e6e065d2 100644
--- a/drivers/message/i2o/pci.c
+++ b/drivers/message/i2o/pci.c
@@ -259,6 +259,7 @@ static irqreturn_t i2o_pci_interrupt(int irq, void *dev_id)
259 259
260/** 260/**
261 * i2o_pci_irq_enable - Allocate interrupt for I2O controller 261 * i2o_pci_irq_enable - Allocate interrupt for I2O controller
262 * @c: i2o_controller that the request is for
262 * 263 *
263 * Allocate an interrupt for the I2O controller, and activate interrupts 264 * Allocate an interrupt for the I2O controller, and activate interrupts
264 * on the I2O controller. 265 * on the I2O controller.
@@ -305,7 +306,7 @@ static void i2o_pci_irq_disable(struct i2o_controller *c)
305 306
306/** 307/**
307 * i2o_pci_probe - Probe the PCI device for an I2O controller 308 * i2o_pci_probe - Probe the PCI device for an I2O controller
308 * @dev: PCI device to test 309 * @pdev: PCI device to test
309 * @id: id which matched with the PCI device id table 310 * @id: id which matched with the PCI device id table
310 * 311 *
311 * Probe the PCI device for any device which is a memory of the 312 * Probe the PCI device for any device which is a memory of the
@@ -447,7 +448,7 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
447 448
448/** 449/**
449 * i2o_pci_remove - Removes a I2O controller from the system 450 * i2o_pci_remove - Removes a I2O controller from the system
450 * pdev: I2O controller which should be removed 451 * @pdev: I2O controller which should be removed
451 * 452 *
452 * Reset the I2O controller, disable interrupts and remove all allocated 453 * Reset the I2O controller, disable interrupts and remove all allocated
453 * resources. 454 * resources.
diff --git a/drivers/mfd/ucb1x00-ts.c b/drivers/mfd/ucb1x00-ts.c
index 82938ad6ddbd..ce1a48108210 100644
--- a/drivers/mfd/ucb1x00-ts.c
+++ b/drivers/mfd/ucb1x00-ts.c
@@ -28,7 +28,7 @@
28#include <linux/string.h> 28#include <linux/string.h>
29#include <linux/input.h> 29#include <linux/input.h>
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/suspend.h> 31#include <linux/freezer.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/kthread.h> 33#include <linux/kthread.h>
34 34
diff --git a/drivers/misc/tifm_7xx1.c b/drivers/misc/tifm_7xx1.c
index 1ba8754e9383..2ab7add78f94 100644
--- a/drivers/misc/tifm_7xx1.c
+++ b/drivers/misc/tifm_7xx1.c
@@ -33,9 +33,10 @@ static void tifm_7xx1_eject(struct tifm_adapter *fm, struct tifm_dev *sock)
33 spin_unlock_irqrestore(&fm->lock, flags); 33 spin_unlock_irqrestore(&fm->lock, flags);
34} 34}
35 35
36static void tifm_7xx1_remove_media(void *adapter) 36static void tifm_7xx1_remove_media(struct work_struct *work)
37{ 37{
38 struct tifm_adapter *fm = adapter; 38 struct tifm_adapter *fm =
39 container_of(work, struct tifm_adapter, media_remover);
39 unsigned long flags; 40 unsigned long flags;
40 int cnt; 41 int cnt;
41 struct tifm_dev *sock; 42 struct tifm_dev *sock;
@@ -169,9 +170,10 @@ tifm_7xx1_sock_addr(char __iomem *base_addr, unsigned int sock_num)
169 return base_addr + ((sock_num + 1) << 10); 170 return base_addr + ((sock_num + 1) << 10);
170} 171}
171 172
172static void tifm_7xx1_insert_media(void *adapter) 173static void tifm_7xx1_insert_media(struct work_struct *work)
173{ 174{
174 struct tifm_adapter *fm = adapter; 175 struct tifm_adapter *fm =
176 container_of(work, struct tifm_adapter, media_inserter);
175 unsigned long flags; 177 unsigned long flags;
176 tifm_media_id media_id; 178 tifm_media_id media_id;
177 char *card_name = "xx"; 179 char *card_name = "xx";
@@ -261,7 +263,7 @@ static int tifm_7xx1_suspend(struct pci_dev *dev, pm_message_t state)
261 spin_unlock_irqrestore(&fm->lock, flags); 263 spin_unlock_irqrestore(&fm->lock, flags);
262 flush_workqueue(fm->wq); 264 flush_workqueue(fm->wq);
263 265
264 tifm_7xx1_remove_media(fm); 266 tifm_7xx1_remove_media(&fm->media_remover);
265 267
266 pci_set_power_state(dev, PCI_D3hot); 268 pci_set_power_state(dev, PCI_D3hot);
267 pci_disable_device(dev); 269 pci_disable_device(dev);
@@ -328,8 +330,8 @@ static int tifm_7xx1_probe(struct pci_dev *dev,
328 if (!fm->sockets) 330 if (!fm->sockets)
329 goto err_out_free; 331 goto err_out_free;
330 332
331 INIT_WORK(&fm->media_inserter, tifm_7xx1_insert_media, fm); 333 INIT_WORK(&fm->media_inserter, tifm_7xx1_insert_media);
332 INIT_WORK(&fm->media_remover, tifm_7xx1_remove_media, fm); 334 INIT_WORK(&fm->media_remover, tifm_7xx1_remove_media);
333 fm->eject = tifm_7xx1_eject; 335 fm->eject = tifm_7xx1_eject;
334 pci_set_drvdata(dev, fm); 336 pci_set_drvdata(dev, fm);
335 337
@@ -384,7 +386,7 @@ static void tifm_7xx1_remove(struct pci_dev *dev)
384 386
385 flush_workqueue(fm->wq); 387 flush_workqueue(fm->wq);
386 388
387 tifm_7xx1_remove_media(fm); 389 tifm_7xx1_remove_media(&fm->media_remover);
388 390
389 writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE); 391 writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
390 free_irq(dev->irq, fm); 392 free_irq(dev->irq, fm);
diff --git a/drivers/misc/tifm_core.c b/drivers/misc/tifm_core.c
index ee326136d03b..d61df5c3ac36 100644
--- a/drivers/misc/tifm_core.c
+++ b/drivers/misc/tifm_core.c
@@ -219,8 +219,9 @@ static int tifm_device_remove(struct device *dev)
219 struct tifm_driver *drv = fm_dev->drv; 219 struct tifm_driver *drv = fm_dev->drv;
220 220
221 if (drv) { 221 if (drv) {
222 if (drv->remove) drv->remove(fm_dev); 222 if (drv->remove)
223 fm_dev->drv = 0; 223 drv->remove(fm_dev);
224 fm_dev->drv = NULL;
224 } 225 }
225 226
226 put_device(dev); 227 put_device(dev);
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 9d190022a490..6f2a282e2b97 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1419,18 +1419,16 @@ static void mmc_setup(struct mmc_host *host)
1419 */ 1419 */
1420void mmc_detect_change(struct mmc_host *host, unsigned long delay) 1420void mmc_detect_change(struct mmc_host *host, unsigned long delay)
1421{ 1421{
1422 if (delay) 1422 mmc_schedule_delayed_work(&host->detect, delay);
1423 mmc_schedule_delayed_work(&host->detect, delay);
1424 else
1425 mmc_schedule_work(&host->detect);
1426} 1423}
1427 1424
1428EXPORT_SYMBOL(mmc_detect_change); 1425EXPORT_SYMBOL(mmc_detect_change);
1429 1426
1430 1427
1431static void mmc_rescan(void *data) 1428static void mmc_rescan(struct work_struct *work)
1432{ 1429{
1433 struct mmc_host *host = data; 1430 struct mmc_host *host =
1431 container_of(work, struct mmc_host, detect.work);
1434 struct list_head *l, *n; 1432 struct list_head *l, *n;
1435 unsigned char power_mode; 1433 unsigned char power_mode;
1436 1434
@@ -1513,7 +1511,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
1513 spin_lock_init(&host->lock); 1511 spin_lock_init(&host->lock);
1514 init_waitqueue_head(&host->wq); 1512 init_waitqueue_head(&host->wq);
1515 INIT_LIST_HEAD(&host->cards); 1513 INIT_LIST_HEAD(&host->cards);
1516 INIT_WORK(&host->detect, mmc_rescan, host); 1514 INIT_DELAYED_WORK(&host->detect, mmc_rescan);
1517 1515
1518 /* 1516 /*
1519 * By default, hosts do not support SGIO or large requests. 1517 * By default, hosts do not support SGIO or large requests.
@@ -1611,7 +1609,7 @@ EXPORT_SYMBOL(mmc_suspend_host);
1611 */ 1609 */
1612int mmc_resume_host(struct mmc_host *host) 1610int mmc_resume_host(struct mmc_host *host)
1613{ 1611{
1614 mmc_rescan(host); 1612 mmc_rescan(&host->detect.work);
1615 1613
1616 return 0; 1614 return 0;
1617} 1615}
diff --git a/drivers/mmc/mmc.h b/drivers/mmc/mmc.h
index cd5e0ab3d84b..149affe0b686 100644
--- a/drivers/mmc/mmc.h
+++ b/drivers/mmc/mmc.h
@@ -20,6 +20,6 @@ void mmc_remove_host_sysfs(struct mmc_host *host);
20void mmc_free_host_sysfs(struct mmc_host *host); 20void mmc_free_host_sysfs(struct mmc_host *host);
21 21
22int mmc_schedule_work(struct work_struct *work); 22int mmc_schedule_work(struct work_struct *work);
23int mmc_schedule_delayed_work(struct work_struct *work, unsigned long delay); 23int mmc_schedule_delayed_work(struct delayed_work *work, unsigned long delay);
24void mmc_flush_scheduled_work(void); 24void mmc_flush_scheduled_work(void);
25#endif 25#endif
diff --git a/drivers/mmc/mmc_sysfs.c b/drivers/mmc/mmc_sysfs.c
index ac5329636045..e334acd045bc 100644
--- a/drivers/mmc/mmc_sysfs.c
+++ b/drivers/mmc/mmc_sysfs.c
@@ -321,17 +321,9 @@ void mmc_free_host_sysfs(struct mmc_host *host)
321static struct workqueue_struct *workqueue; 321static struct workqueue_struct *workqueue;
322 322
323/* 323/*
324 * Internal function. Schedule work in the MMC work queue.
325 */
326int mmc_schedule_work(struct work_struct *work)
327{
328 return queue_work(workqueue, work);
329}
330
331/*
332 * Internal function. Schedule delayed work in the MMC work queue. 324 * Internal function. Schedule delayed work in the MMC work queue.
333 */ 325 */
334int mmc_schedule_delayed_work(struct work_struct *work, unsigned long delay) 326int mmc_schedule_delayed_work(struct delayed_work *work, unsigned long delay)
335{ 327{
336 return queue_delayed_work(workqueue, work, delay); 328 return queue_delayed_work(workqueue, work, delay);
337} 329}
diff --git a/drivers/mmc/tifm_sd.c b/drivers/mmc/tifm_sd.c
index 0fdc55b08a6d..e846499a004c 100644
--- a/drivers/mmc/tifm_sd.c
+++ b/drivers/mmc/tifm_sd.c
@@ -99,7 +99,7 @@ struct tifm_sd {
99 99
100 struct mmc_request *req; 100 struct mmc_request *req;
101 struct work_struct cmd_handler; 101 struct work_struct cmd_handler;
102 struct work_struct abort_handler; 102 struct delayed_work abort_handler;
103 wait_queue_head_t can_eject; 103 wait_queue_head_t can_eject;
104 104
105 size_t written_blocks; 105 size_t written_blocks;
@@ -496,9 +496,9 @@ err_out:
496 mmc_request_done(mmc, mrq); 496 mmc_request_done(mmc, mrq);
497} 497}
498 498
499static void tifm_sd_end_cmd(void *data) 499static void tifm_sd_end_cmd(struct work_struct *work)
500{ 500{
501 struct tifm_sd *host = data; 501 struct tifm_sd *host = container_of(work, struct tifm_sd, cmd_handler);
502 struct tifm_dev *sock = host->dev; 502 struct tifm_dev *sock = host->dev;
503 struct mmc_host *mmc = tifm_get_drvdata(sock); 503 struct mmc_host *mmc = tifm_get_drvdata(sock);
504 struct mmc_request *mrq; 504 struct mmc_request *mrq;
@@ -608,9 +608,9 @@ err_out:
608 mmc_request_done(mmc, mrq); 608 mmc_request_done(mmc, mrq);
609} 609}
610 610
611static void tifm_sd_end_cmd_nodma(void *data) 611static void tifm_sd_end_cmd_nodma(struct work_struct *work)
612{ 612{
613 struct tifm_sd *host = (struct tifm_sd*)data; 613 struct tifm_sd *host = container_of(work, struct tifm_sd, cmd_handler);
614 struct tifm_dev *sock = host->dev; 614 struct tifm_dev *sock = host->dev;
615 struct mmc_host *mmc = tifm_get_drvdata(sock); 615 struct mmc_host *mmc = tifm_get_drvdata(sock);
616 struct mmc_request *mrq; 616 struct mmc_request *mrq;
@@ -661,11 +661,14 @@ static void tifm_sd_end_cmd_nodma(void *data)
661 mmc_request_done(mmc, mrq); 661 mmc_request_done(mmc, mrq);
662} 662}
663 663
664static void tifm_sd_abort(void *data) 664static void tifm_sd_abort(struct work_struct *work)
665{ 665{
666 struct tifm_sd *host =
667 container_of(work, struct tifm_sd, abort_handler.work);
668
666 printk(KERN_ERR DRIVER_NAME 669 printk(KERN_ERR DRIVER_NAME
667 ": card failed to respond for a long period of time"); 670 ": card failed to respond for a long period of time");
668 tifm_eject(((struct tifm_sd*)data)->dev); 671 tifm_eject(host->dev);
669} 672}
670 673
671static void tifm_sd_ios(struct mmc_host *mmc, struct mmc_ios *ios) 674static void tifm_sd_ios(struct mmc_host *mmc, struct mmc_ios *ios)
@@ -762,9 +765,9 @@ static struct mmc_host_ops tifm_sd_ops = {
762 .get_ro = tifm_sd_ro 765 .get_ro = tifm_sd_ro
763}; 766};
764 767
765static void tifm_sd_register_host(void *data) 768static void tifm_sd_register_host(struct work_struct *work)
766{ 769{
767 struct tifm_sd *host = (struct tifm_sd*)data; 770 struct tifm_sd *host = container_of(work, struct tifm_sd, cmd_handler);
768 struct tifm_dev *sock = host->dev; 771 struct tifm_dev *sock = host->dev;
769 struct mmc_host *mmc = tifm_get_drvdata(sock); 772 struct mmc_host *mmc = tifm_get_drvdata(sock);
770 unsigned long flags; 773 unsigned long flags;
@@ -772,8 +775,7 @@ static void tifm_sd_register_host(void *data)
772 spin_lock_irqsave(&sock->lock, flags); 775 spin_lock_irqsave(&sock->lock, flags);
773 host->flags |= HOST_REG; 776 host->flags |= HOST_REG;
774 PREPARE_WORK(&host->cmd_handler, 777 PREPARE_WORK(&host->cmd_handler,
775 no_dma ? tifm_sd_end_cmd_nodma : tifm_sd_end_cmd, 778 no_dma ? tifm_sd_end_cmd_nodma : tifm_sd_end_cmd);
776 data);
777 spin_unlock_irqrestore(&sock->lock, flags); 779 spin_unlock_irqrestore(&sock->lock, flags);
778 dev_dbg(&sock->dev, "adding host\n"); 780 dev_dbg(&sock->dev, "adding host\n");
779 mmc_add_host(mmc); 781 mmc_add_host(mmc);
@@ -799,8 +801,8 @@ static int tifm_sd_probe(struct tifm_dev *sock)
799 host->dev = sock; 801 host->dev = sock;
800 host->clk_div = 61; 802 host->clk_div = 61;
801 init_waitqueue_head(&host->can_eject); 803 init_waitqueue_head(&host->can_eject);
802 INIT_WORK(&host->cmd_handler, tifm_sd_register_host, host); 804 INIT_WORK(&host->cmd_handler, tifm_sd_register_host);
803 INIT_WORK(&host->abort_handler, tifm_sd_abort, host); 805 INIT_DELAYED_WORK(&host->abort_handler, tifm_sd_abort);
804 806
805 tifm_set_drvdata(sock, mmc); 807 tifm_set_drvdata(sock, mmc);
806 sock->signal_irq = tifm_sd_signal_irq; 808 sock->signal_irq = tifm_sd_signal_irq;
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index ef4a731ca5c2..334e078ffaff 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -451,7 +451,7 @@ static int __devinit m25p_probe(struct spi_device *spi)
451 return -ENODEV; 451 return -ENODEV;
452 } 452 }
453 453
454 flash = kzalloc(sizeof *flash, SLAB_KERNEL); 454 flash = kzalloc(sizeof *flash, GFP_KERNEL);
455 if (!flash) 455 if (!flash)
456 return -ENOMEM; 456 return -ENOMEM;
457 457
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index d02ed51abfcc..931028f672de 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -594,7 +594,7 @@ struct rtl8139_private {
594 u32 rx_config; 594 u32 rx_config;
595 struct rtl_extra_stats xstats; 595 struct rtl_extra_stats xstats;
596 596
597 struct work_struct thread; 597 struct delayed_work thread;
598 598
599 struct mii_if_info mii; 599 struct mii_if_info mii;
600 unsigned int regs_len; 600 unsigned int regs_len;
@@ -636,8 +636,8 @@ static struct net_device_stats *rtl8139_get_stats (struct net_device *dev);
636static void rtl8139_set_rx_mode (struct net_device *dev); 636static void rtl8139_set_rx_mode (struct net_device *dev);
637static void __set_rx_mode (struct net_device *dev); 637static void __set_rx_mode (struct net_device *dev);
638static void rtl8139_hw_start (struct net_device *dev); 638static void rtl8139_hw_start (struct net_device *dev);
639static void rtl8139_thread (void *_data); 639static void rtl8139_thread (struct work_struct *work);
640static void rtl8139_tx_timeout_task(void *_data); 640static void rtl8139_tx_timeout_task(struct work_struct *work);
641static const struct ethtool_ops rtl8139_ethtool_ops; 641static const struct ethtool_ops rtl8139_ethtool_ops;
642 642
643/* write MMIO register, with flush */ 643/* write MMIO register, with flush */
@@ -1010,7 +1010,7 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
1010 (debug < 0 ? RTL8139_DEF_MSG_ENABLE : ((1 << debug) - 1)); 1010 (debug < 0 ? RTL8139_DEF_MSG_ENABLE : ((1 << debug) - 1));
1011 spin_lock_init (&tp->lock); 1011 spin_lock_init (&tp->lock);
1012 spin_lock_init (&tp->rx_lock); 1012 spin_lock_init (&tp->rx_lock);
1013 INIT_WORK(&tp->thread, rtl8139_thread, dev); 1013 INIT_DELAYED_WORK(&tp->thread, rtl8139_thread);
1014 tp->mii.dev = dev; 1014 tp->mii.dev = dev;
1015 tp->mii.mdio_read = mdio_read; 1015 tp->mii.mdio_read = mdio_read;
1016 tp->mii.mdio_write = mdio_write; 1016 tp->mii.mdio_write = mdio_write;
@@ -1596,15 +1596,16 @@ static inline void rtl8139_thread_iter (struct net_device *dev,
1596 RTL_R8 (Config1)); 1596 RTL_R8 (Config1));
1597} 1597}
1598 1598
1599static void rtl8139_thread (void *_data) 1599static void rtl8139_thread (struct work_struct *work)
1600{ 1600{
1601 struct net_device *dev = _data; 1601 struct rtl8139_private *tp =
1602 struct rtl8139_private *tp = netdev_priv(dev); 1602 container_of(work, struct rtl8139_private, thread.work);
1603 struct net_device *dev = tp->mii.dev;
1603 unsigned long thr_delay = next_tick; 1604 unsigned long thr_delay = next_tick;
1604 1605
1605 if (tp->watchdog_fired) { 1606 if (tp->watchdog_fired) {
1606 tp->watchdog_fired = 0; 1607 tp->watchdog_fired = 0;
1607 rtl8139_tx_timeout_task(_data); 1608 rtl8139_tx_timeout_task(work);
1608 } else if (rtnl_trylock()) { 1609 } else if (rtnl_trylock()) {
1609 rtl8139_thread_iter (dev, tp, tp->mmio_addr); 1610 rtl8139_thread_iter (dev, tp, tp->mmio_addr);
1610 rtnl_unlock (); 1611 rtnl_unlock ();
@@ -1646,10 +1647,11 @@ static inline void rtl8139_tx_clear (struct rtl8139_private *tp)
1646 /* XXX account for unsent Tx packets in tp->stats.tx_dropped */ 1647 /* XXX account for unsent Tx packets in tp->stats.tx_dropped */
1647} 1648}
1648 1649
1649static void rtl8139_tx_timeout_task (void *_data) 1650static void rtl8139_tx_timeout_task (struct work_struct *work)
1650{ 1651{
1651 struct net_device *dev = _data; 1652 struct rtl8139_private *tp =
1652 struct rtl8139_private *tp = netdev_priv(dev); 1653 container_of(work, struct rtl8139_private, thread.work);
1654 struct net_device *dev = tp->mii.dev;
1653 void __iomem *ioaddr = tp->mmio_addr; 1655 void __iomem *ioaddr = tp->mmio_addr;
1654 int i; 1656 int i;
1655 u8 tmp8; 1657 u8 tmp8;
@@ -1695,7 +1697,7 @@ static void rtl8139_tx_timeout (struct net_device *dev)
1695 struct rtl8139_private *tp = netdev_priv(dev); 1697 struct rtl8139_private *tp = netdev_priv(dev);
1696 1698
1697 if (!tp->have_thread) { 1699 if (!tp->have_thread) {
1698 INIT_WORK(&tp->thread, rtl8139_tx_timeout_task, dev); 1700 INIT_DELAYED_WORK(&tp->thread, rtl8139_tx_timeout_task);
1699 schedule_delayed_work(&tp->thread, next_tick); 1701 schedule_delayed_work(&tp->thread, next_tick);
1700 } else 1702 } else
1701 tp->watchdog_fired = 1; 1703 tp->watchdog_fired = 1;
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index fc2f1d1c7ead..5bacb7587df4 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -4411,9 +4411,9 @@ bnx2_open(struct net_device *dev)
4411} 4411}
4412 4412
4413static void 4413static void
4414bnx2_reset_task(void *data) 4414bnx2_reset_task(struct work_struct *work)
4415{ 4415{
4416 struct bnx2 *bp = data; 4416 struct bnx2 *bp = container_of(work, struct bnx2, reset_task);
4417 4417
4418 if (!netif_running(bp->dev)) 4418 if (!netif_running(bp->dev))
4419 return; 4419 return;
@@ -5702,7 +5702,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5702 bp->pdev = pdev; 5702 bp->pdev = pdev;
5703 5703
5704 spin_lock_init(&bp->phy_lock); 5704 spin_lock_init(&bp->phy_lock);
5705 INIT_WORK(&bp->reset_task, bnx2_reset_task, bp); 5705 INIT_WORK(&bp->reset_task, bnx2_reset_task);
5706 5706
5707 dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0); 5707 dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0);
5708 mem_len = MB_GET_CID_ADDR(TX_TSS_CID + 1); 5708 mem_len = MB_GET_CID_ADDR(TX_TSS_CID + 1);
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index fd2cc13f7d97..c8126484c2be 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -4066,9 +4066,9 @@ static int cas_alloc_rxds(struct cas *cp)
4066 return 0; 4066 return 0;
4067} 4067}
4068 4068
4069static void cas_reset_task(void *data) 4069static void cas_reset_task(struct work_struct *work)
4070{ 4070{
4071 struct cas *cp = (struct cas *) data; 4071 struct cas *cp = container_of(work, struct cas, reset_task);
4072#if 0 4072#if 0
4073 int pending = atomic_read(&cp->reset_task_pending); 4073 int pending = atomic_read(&cp->reset_task_pending);
4074#else 4074#else
@@ -5006,7 +5006,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
5006 atomic_set(&cp->reset_task_pending_spare, 0); 5006 atomic_set(&cp->reset_task_pending_spare, 0);
5007 atomic_set(&cp->reset_task_pending_mtu, 0); 5007 atomic_set(&cp->reset_task_pending_mtu, 0);
5008#endif 5008#endif
5009 INIT_WORK(&cp->reset_task, cas_reset_task, cp); 5009 INIT_WORK(&cp->reset_task, cas_reset_task);
5010 5010
5011 /* Default link parameters */ 5011 /* Default link parameters */
5012 if (link_mode >= 0 && link_mode <= 6) 5012 if (link_mode >= 0 && link_mode <= 6)
diff --git a/drivers/net/chelsio/common.h b/drivers/net/chelsio/common.h
index b265941e1372..74758d2c7af8 100644
--- a/drivers/net/chelsio/common.h
+++ b/drivers/net/chelsio/common.h
@@ -279,7 +279,7 @@ struct adapter {
279 struct petp *tp; 279 struct petp *tp;
280 280
281 struct port_info port[MAX_NPORTS]; 281 struct port_info port[MAX_NPORTS];
282 struct work_struct stats_update_task; 282 struct delayed_work stats_update_task;
283 struct timer_list stats_update_timer; 283 struct timer_list stats_update_timer;
284 284
285 spinlock_t tpi_lock; 285 spinlock_t tpi_lock;
diff --git a/drivers/net/chelsio/cphy.h b/drivers/net/chelsio/cphy.h
index 60901f25014e..cf9143499882 100644
--- a/drivers/net/chelsio/cphy.h
+++ b/drivers/net/chelsio/cphy.h
@@ -91,7 +91,7 @@ struct cphy {
91 int state; /* Link status state machine */ 91 int state; /* Link status state machine */
92 adapter_t *adapter; /* associated adapter */ 92 adapter_t *adapter; /* associated adapter */
93 93
94 struct work_struct phy_update; 94 struct delayed_work phy_update;
95 95
96 u16 bmsr; 96 u16 bmsr;
97 int count; 97 int count;
diff --git a/drivers/net/chelsio/cxgb2.c b/drivers/net/chelsio/cxgb2.c
index 53bec6739812..de48eadddbc4 100644
--- a/drivers/net/chelsio/cxgb2.c
+++ b/drivers/net/chelsio/cxgb2.c
@@ -953,10 +953,11 @@ static void t1_netpoll(struct net_device *dev)
953 * Periodic accumulation of MAC statistics. This is used only if the MAC 953 * Periodic accumulation of MAC statistics. This is used only if the MAC
954 * does not have any other way to prevent stats counter overflow. 954 * does not have any other way to prevent stats counter overflow.
955 */ 955 */
956static void mac_stats_task(void *data) 956static void mac_stats_task(struct work_struct *work)
957{ 957{
958 int i; 958 int i;
959 struct adapter *adapter = data; 959 struct adapter *adapter =
960 container_of(work, struct adapter, stats_update_task.work);
960 961
961 for_each_port(adapter, i) { 962 for_each_port(adapter, i) {
962 struct port_info *p = &adapter->port[i]; 963 struct port_info *p = &adapter->port[i];
@@ -977,9 +978,10 @@ static void mac_stats_task(void *data)
977/* 978/*
978 * Processes elmer0 external interrupts in process context. 979 * Processes elmer0 external interrupts in process context.
979 */ 980 */
980static void ext_intr_task(void *data) 981static void ext_intr_task(struct work_struct *work)
981{ 982{
982 struct adapter *adapter = data; 983 struct adapter *adapter =
984 container_of(work, struct adapter, ext_intr_handler_task);
983 985
984 t1_elmer0_ext_intr_handler(adapter); 986 t1_elmer0_ext_intr_handler(adapter);
985 987
@@ -1113,9 +1115,9 @@ static int __devinit init_one(struct pci_dev *pdev,
1113 spin_lock_init(&adapter->mac_lock); 1115 spin_lock_init(&adapter->mac_lock);
1114 1116
1115 INIT_WORK(&adapter->ext_intr_handler_task, 1117 INIT_WORK(&adapter->ext_intr_handler_task,
1116 ext_intr_task, adapter); 1118 ext_intr_task);
1117 INIT_WORK(&adapter->stats_update_task, mac_stats_task, 1119 INIT_DELAYED_WORK(&adapter->stats_update_task,
1118 adapter); 1120 mac_stats_task);
1119 1121
1120 pci_set_drvdata(pdev, netdev); 1122 pci_set_drvdata(pdev, netdev);
1121 } 1123 }
diff --git a/drivers/net/chelsio/my3126.c b/drivers/net/chelsio/my3126.c
index 0b90014d5b3e..c7731b6f9de3 100644
--- a/drivers/net/chelsio/my3126.c
+++ b/drivers/net/chelsio/my3126.c
@@ -93,9 +93,11 @@ static int my3126_interrupt_handler(struct cphy *cphy)
93 return cphy_cause_link_change; 93 return cphy_cause_link_change;
94} 94}
95 95
96static void my3216_poll(void *arg) 96static void my3216_poll(struct work_struct *work)
97{ 97{
98 my3126_interrupt_handler(arg); 98 struct cphy *cphy = container_of(work, struct cphy, phy_update.work);
99
100 my3126_interrupt_handler(cphy);
99} 101}
100 102
101static int my3126_set_loopback(struct cphy *cphy, int on) 103static int my3126_set_loopback(struct cphy *cphy, int on)
@@ -171,7 +173,7 @@ static struct cphy *my3126_phy_create(adapter_t *adapter,
171 if (cphy) 173 if (cphy)
172 cphy_init(cphy, adapter, phy_addr, &my3126_ops, mdio_ops); 174 cphy_init(cphy, adapter, phy_addr, &my3126_ops, mdio_ops);
173 175
174 INIT_WORK(&cphy->phy_update, my3216_poll, cphy); 176 INIT_DELAYED_WORK(&cphy->phy_update, my3216_poll);
175 cphy->bmsr = 0; 177 cphy->bmsr = 0;
176 178
177 return (cphy); 179 return (cphy);
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 3a8df479cbda..03bf164f9e8d 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2102,9 +2102,10 @@ static void e100_tx_timeout(struct net_device *netdev)
2102 schedule_work(&nic->tx_timeout_task); 2102 schedule_work(&nic->tx_timeout_task);
2103} 2103}
2104 2104
2105static void e100_tx_timeout_task(struct net_device *netdev) 2105static void e100_tx_timeout_task(struct work_struct *work)
2106{ 2106{
2107 struct nic *nic = netdev_priv(netdev); 2107 struct nic *nic = container_of(work, struct nic, tx_timeout_task);
2108 struct net_device *netdev = nic->netdev;
2108 2109
2109 DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n", 2110 DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n",
2110 readb(&nic->csr->scb.status)); 2111 readb(&nic->csr->scb.status));
@@ -2637,8 +2638,7 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2637 nic->blink_timer.function = e100_blink_led; 2638 nic->blink_timer.function = e100_blink_led;
2638 nic->blink_timer.data = (unsigned long)nic; 2639 nic->blink_timer.data = (unsigned long)nic;
2639 2640
2640 INIT_WORK(&nic->tx_timeout_task, 2641 INIT_WORK(&nic->tx_timeout_task, e100_tx_timeout_task);
2641 (void (*)(void *))e100_tx_timeout_task, netdev);
2642 2642
2643 if((err = e100_alloc(nic))) { 2643 if((err = e100_alloc(nic))) {
2644 DPRINTK(PROBE, ERR, "Cannot alloc driver memory, aborting.\n"); 2644 DPRINTK(PROBE, ERR, "Cannot alloc driver memory, aborting.\n");
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 32dde0adb683..73f3a85fd238 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -190,7 +190,7 @@ void e1000_set_ethtool_ops(struct net_device *netdev);
190static void e1000_enter_82542_rst(struct e1000_adapter *adapter); 190static void e1000_enter_82542_rst(struct e1000_adapter *adapter);
191static void e1000_leave_82542_rst(struct e1000_adapter *adapter); 191static void e1000_leave_82542_rst(struct e1000_adapter *adapter);
192static void e1000_tx_timeout(struct net_device *dev); 192static void e1000_tx_timeout(struct net_device *dev);
193static void e1000_reset_task(struct net_device *dev); 193static void e1000_reset_task(struct work_struct *work);
194static void e1000_smartspeed(struct e1000_adapter *adapter); 194static void e1000_smartspeed(struct e1000_adapter *adapter);
195static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter, 195static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter,
196 struct sk_buff *skb); 196 struct sk_buff *skb);
@@ -914,8 +914,7 @@ e1000_probe(struct pci_dev *pdev,
914 adapter->phy_info_timer.function = &e1000_update_phy_info; 914 adapter->phy_info_timer.function = &e1000_update_phy_info;
915 adapter->phy_info_timer.data = (unsigned long) adapter; 915 adapter->phy_info_timer.data = (unsigned long) adapter;
916 916
917 INIT_WORK(&adapter->reset_task, 917 INIT_WORK(&adapter->reset_task, e1000_reset_task);
918 (void (*)(void *))e1000_reset_task, netdev);
919 918
920 e1000_check_options(adapter); 919 e1000_check_options(adapter);
921 920
@@ -3306,9 +3305,10 @@ e1000_tx_timeout(struct net_device *netdev)
3306} 3305}
3307 3306
3308static void 3307static void
3309e1000_reset_task(struct net_device *netdev) 3308e1000_reset_task(struct work_struct *work)
3310{ 3309{
3311 struct e1000_adapter *adapter = netdev_priv(netdev); 3310 struct e1000_adapter *adapter =
3311 container_of(work, struct e1000_adapter, reset_task);
3312 3312
3313 e1000_reinit_locked(adapter); 3313 e1000_reinit_locked(adapter);
3314} 3314}
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index 6ad696101418..83fa32f72398 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -2224,11 +2224,12 @@ static int ehea_stop(struct net_device *dev)
2224 return ret; 2224 return ret;
2225} 2225}
2226 2226
2227static void ehea_reset_port(void *data) 2227static void ehea_reset_port(struct work_struct *work)
2228{ 2228{
2229 int ret; 2229 int ret;
2230 struct net_device *dev = data; 2230 struct ehea_port *port =
2231 struct ehea_port *port = netdev_priv(dev); 2231 container_of(work, struct ehea_port, reset_task);
2232 struct net_device *dev = port->netdev;
2232 2233
2233 port->resets++; 2234 port->resets++;
2234 down(&port->port_lock); 2235 down(&port->port_lock);
@@ -2379,7 +2380,7 @@ static int ehea_setup_single_port(struct ehea_port *port,
2379 dev->tx_timeout = &ehea_tx_watchdog; 2380 dev->tx_timeout = &ehea_tx_watchdog;
2380 dev->watchdog_timeo = EHEA_WATCH_DOG_TIMEOUT; 2381 dev->watchdog_timeo = EHEA_WATCH_DOG_TIMEOUT;
2381 2382
2382 INIT_WORK(&port->reset_task, ehea_reset_port, dev); 2383 INIT_WORK(&port->reset_task, ehea_reset_port);
2383 2384
2384 ehea_set_ethtool_ops(dev); 2385 ehea_set_ethtool_ops(dev);
2385 2386
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index 1ed9cccd3c11..3c33d6f6a6a6 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -168,8 +168,9 @@ struct baycom_state {
168 int magic; 168 int magic;
169 169
170 struct pardevice *pdev; 170 struct pardevice *pdev;
171 struct net_device *dev;
171 unsigned int work_running; 172 unsigned int work_running;
172 struct work_struct run_work; 173 struct delayed_work run_work;
173 unsigned int modem; 174 unsigned int modem;
174 unsigned int bitrate; 175 unsigned int bitrate;
175 unsigned char stat; 176 unsigned char stat;
@@ -659,16 +660,18 @@ static int receive(struct net_device *dev, int cnt)
659#define GETTICK(x) 660#define GETTICK(x)
660#endif /* __i386__ */ 661#endif /* __i386__ */
661 662
662static void epp_bh(struct net_device *dev) 663static void epp_bh(struct work_struct *work)
663{ 664{
665 struct net_device *dev;
664 struct baycom_state *bc; 666 struct baycom_state *bc;
665 struct parport *pp; 667 struct parport *pp;
666 unsigned char stat; 668 unsigned char stat;
667 unsigned char tmp[2]; 669 unsigned char tmp[2];
668 unsigned int time1 = 0, time2 = 0, time3 = 0; 670 unsigned int time1 = 0, time2 = 0, time3 = 0;
669 int cnt, cnt2; 671 int cnt, cnt2;
670 672
671 bc = netdev_priv(dev); 673 bc = container_of(work, struct baycom_state, run_work.work);
674 dev = bc->dev;
672 if (!bc->work_running) 675 if (!bc->work_running)
673 return; 676 return;
674 baycom_int_freq(bc); 677 baycom_int_freq(bc);
@@ -889,7 +892,7 @@ static int epp_open(struct net_device *dev)
889 return -EBUSY; 892 return -EBUSY;
890 } 893 }
891 dev->irq = /*pp->irq*/ 0; 894 dev->irq = /*pp->irq*/ 0;
892 INIT_WORK(&bc->run_work, (void *)(void *)epp_bh, dev); 895 INIT_DELAYED_WORK(&bc->run_work, epp_bh);
893 bc->work_running = 1; 896 bc->work_running = 1;
894 bc->modem = EPP_CONVENTIONAL; 897 bc->modem = EPP_CONVENTIONAL;
895 if (eppconfig(bc)) 898 if (eppconfig(bc))
@@ -1213,6 +1216,7 @@ static void __init baycom_epp_dev_setup(struct net_device *dev)
1213 /* 1216 /*
1214 * initialize part of the baycom_state struct 1217 * initialize part of the baycom_state struct
1215 */ 1218 */
1219 bc->dev = dev;
1216 bc->magic = BAYCOM_MAGIC; 1220 bc->magic = BAYCOM_MAGIC;
1217 bc->cfg.fclk = 19666600; 1221 bc->cfg.fclk = 19666600;
1218 bc->cfg.bps = 9600; 1222 bc->cfg.bps = 9600;
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index 0f8b9afd55b4..e6e721aff6f6 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -252,7 +252,7 @@ static inline void z8530_isr(struct scc_info *info);
252static irqreturn_t scc_isr(int irq, void *dev_id); 252static irqreturn_t scc_isr(int irq, void *dev_id);
253static void rx_isr(struct scc_priv *priv); 253static void rx_isr(struct scc_priv *priv);
254static void special_condition(struct scc_priv *priv, int rc); 254static void special_condition(struct scc_priv *priv, int rc);
255static void rx_bh(void *arg); 255static void rx_bh(struct work_struct *);
256static void tx_isr(struct scc_priv *priv); 256static void tx_isr(struct scc_priv *priv);
257static void es_isr(struct scc_priv *priv); 257static void es_isr(struct scc_priv *priv);
258static void tm_isr(struct scc_priv *priv); 258static void tm_isr(struct scc_priv *priv);
@@ -579,7 +579,7 @@ static int __init setup_adapter(int card_base, int type, int n)
579 priv->param.clocks = TCTRxCP | RCRTxCP; 579 priv->param.clocks = TCTRxCP | RCRTxCP;
580 priv->param.persist = 256; 580 priv->param.persist = 256;
581 priv->param.dma = -1; 581 priv->param.dma = -1;
582 INIT_WORK(&priv->rx_work, rx_bh, priv); 582 INIT_WORK(&priv->rx_work, rx_bh);
583 dev->priv = priv; 583 dev->priv = priv;
584 sprintf(dev->name, "dmascc%i", 2 * n + i); 584 sprintf(dev->name, "dmascc%i", 2 * n + i);
585 dev->base_addr = card_base; 585 dev->base_addr = card_base;
@@ -1272,9 +1272,9 @@ static void special_condition(struct scc_priv *priv, int rc)
1272} 1272}
1273 1273
1274 1274
1275static void rx_bh(void *arg) 1275static void rx_bh(struct work_struct *ugli_api)
1276{ 1276{
1277 struct scc_priv *priv = arg; 1277 struct scc_priv *priv = container_of(ugli_api, struct scc_priv, rx_work);
1278 int i = priv->rx_tail; 1278 int i = priv->rx_tail;
1279 int cb; 1279 int cb;
1280 unsigned long flags; 1280 unsigned long flags;
diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
index b32c52ed19d7..f0c61f3b2a82 100644
--- a/drivers/net/irda/mcs7780.c
+++ b/drivers/net/irda/mcs7780.c
@@ -560,9 +560,9 @@ static inline int mcs_find_endpoints(struct mcs_cb *mcs,
560 return ret; 560 return ret;
561} 561}
562 562
563static void mcs_speed_work(void *arg) 563static void mcs_speed_work(struct work_struct *work)
564{ 564{
565 struct mcs_cb *mcs = arg; 565 struct mcs_cb *mcs = container_of(work, struct mcs_cb, work);
566 struct net_device *netdev = mcs->netdev; 566 struct net_device *netdev = mcs->netdev;
567 567
568 mcs_speed_change(mcs); 568 mcs_speed_change(mcs);
@@ -927,7 +927,7 @@ static int mcs_probe(struct usb_interface *intf,
927 irda_qos_bits_to_value(&mcs->qos); 927 irda_qos_bits_to_value(&mcs->qos);
928 928
929 /* Speed change work initialisation*/ 929 /* Speed change work initialisation*/
930 INIT_WORK(&mcs->work, mcs_speed_work, mcs); 930 INIT_WORK(&mcs->work, mcs_speed_work);
931 931
932 /* Override the network functions we need to use */ 932 /* Override the network functions we need to use */
933 ndev->hard_start_xmit = mcs_hard_xmit; 933 ndev->hard_start_xmit = mcs_hard_xmit;
diff --git a/drivers/net/irda/sir-dev.h b/drivers/net/irda/sir-dev.h
index 9fa294a546d6..2a57bc67ce35 100644
--- a/drivers/net/irda/sir-dev.h
+++ b/drivers/net/irda/sir-dev.h
@@ -22,7 +22,7 @@
22 22
23struct sir_fsm { 23struct sir_fsm {
24 struct semaphore sem; 24 struct semaphore sem;
25 struct work_struct work; 25 struct delayed_work work;
26 unsigned state, substate; 26 unsigned state, substate;
27 int param; 27 int param;
28 int result; 28 int result;
diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c
index 3b5854d10c17..17b0c3ab6201 100644
--- a/drivers/net/irda/sir_dev.c
+++ b/drivers/net/irda/sir_dev.c
@@ -100,9 +100,9 @@ static int sirdev_tx_complete_fsm(struct sir_dev *dev)
100 * Both must be unlocked/restarted on completion - but only on final exit. 100 * Both must be unlocked/restarted on completion - but only on final exit.
101 */ 101 */
102 102
103static void sirdev_config_fsm(void *data) 103static void sirdev_config_fsm(struct work_struct *work)
104{ 104{
105 struct sir_dev *dev = data; 105 struct sir_dev *dev = container_of(work, struct sir_dev, fsm.work.work);
106 struct sir_fsm *fsm = &dev->fsm; 106 struct sir_fsm *fsm = &dev->fsm;
107 int next_state; 107 int next_state;
108 int ret = -1; 108 int ret = -1;
@@ -309,8 +309,8 @@ int sirdev_schedule_request(struct sir_dev *dev, int initial_state, unsigned par
309 fsm->param = param; 309 fsm->param = param;
310 fsm->result = 0; 310 fsm->result = 0;
311 311
312 INIT_WORK(&fsm->work, sirdev_config_fsm, dev); 312 INIT_DELAYED_WORK(&fsm->work, sirdev_config_fsm);
313 queue_work(irda_sir_wq, &fsm->work); 313 queue_delayed_work(irda_sir_wq, &fsm->work, 0);
314 return 0; 314 return 0;
315} 315}
316 316
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c
index 3b4c47875935..c14a74634fd5 100644
--- a/drivers/net/irda/stir4200.c
+++ b/drivers/net/irda/stir4200.c
@@ -50,6 +50,7 @@
50#include <linux/usb.h> 50#include <linux/usb.h>
51#include <linux/crc32.h> 51#include <linux/crc32.h>
52#include <linux/kthread.h> 52#include <linux/kthread.h>
53#include <linux/freezer.h>
53#include <net/irda/irda.h> 54#include <net/irda/irda.h>
54#include <net/irda/irlap.h> 55#include <net/irda/irlap.h>
55#include <net/irda/irda_device.h> 56#include <net/irda/irda_device.h>
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
index 2284e2ce1692..d6f4f185bf37 100644
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
@@ -166,7 +166,7 @@ struct veth_msg {
166 166
167struct veth_lpar_connection { 167struct veth_lpar_connection {
168 HvLpIndex remote_lp; 168 HvLpIndex remote_lp;
169 struct work_struct statemachine_wq; 169 struct delayed_work statemachine_wq;
170 struct veth_msg *msgs; 170 struct veth_msg *msgs;
171 int num_events; 171 int num_events;
172 struct veth_cap_data local_caps; 172 struct veth_cap_data local_caps;
@@ -456,7 +456,7 @@ static struct kobj_type veth_port_ktype = {
456 456
457static inline void veth_kick_statemachine(struct veth_lpar_connection *cnx) 457static inline void veth_kick_statemachine(struct veth_lpar_connection *cnx)
458{ 458{
459 schedule_work(&cnx->statemachine_wq); 459 schedule_delayed_work(&cnx->statemachine_wq, 0);
460} 460}
461 461
462static void veth_take_cap(struct veth_lpar_connection *cnx, 462static void veth_take_cap(struct veth_lpar_connection *cnx,
@@ -638,9 +638,11 @@ static int veth_process_caps(struct veth_lpar_connection *cnx)
638} 638}
639 639
640/* FIXME: The gotos here are a bit dubious */ 640/* FIXME: The gotos here are a bit dubious */
641static void veth_statemachine(void *p) 641static void veth_statemachine(struct work_struct *work)
642{ 642{
643 struct veth_lpar_connection *cnx = (struct veth_lpar_connection *)p; 643 struct veth_lpar_connection *cnx =
644 container_of(work, struct veth_lpar_connection,
645 statemachine_wq.work);
644 int rlp = cnx->remote_lp; 646 int rlp = cnx->remote_lp;
645 int rc; 647 int rc;
646 648
@@ -827,7 +829,7 @@ static int veth_init_connection(u8 rlp)
827 829
828 cnx->remote_lp = rlp; 830 cnx->remote_lp = rlp;
829 spin_lock_init(&cnx->lock); 831 spin_lock_init(&cnx->lock);
830 INIT_WORK(&cnx->statemachine_wq, veth_statemachine, cnx); 832 INIT_DELAYED_WORK(&cnx->statemachine_wq, veth_statemachine);
831 833
832 init_timer(&cnx->ack_timer); 834 init_timer(&cnx->ack_timer);
833 cnx->ack_timer.function = veth_timed_ack; 835 cnx->ack_timer.function = veth_timed_ack;
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index 7b127212e62b..e628126c9c49 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -106,7 +106,7 @@ static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter);
106static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter); 106static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter);
107void ixgb_set_ethtool_ops(struct net_device *netdev); 107void ixgb_set_ethtool_ops(struct net_device *netdev);
108static void ixgb_tx_timeout(struct net_device *dev); 108static void ixgb_tx_timeout(struct net_device *dev);
109static void ixgb_tx_timeout_task(struct net_device *dev); 109static void ixgb_tx_timeout_task(struct work_struct *work);
110static void ixgb_vlan_rx_register(struct net_device *netdev, 110static void ixgb_vlan_rx_register(struct net_device *netdev,
111 struct vlan_group *grp); 111 struct vlan_group *grp);
112static void ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid); 112static void ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
@@ -489,8 +489,7 @@ ixgb_probe(struct pci_dev *pdev,
489 adapter->watchdog_timer.function = &ixgb_watchdog; 489 adapter->watchdog_timer.function = &ixgb_watchdog;
490 adapter->watchdog_timer.data = (unsigned long)adapter; 490 adapter->watchdog_timer.data = (unsigned long)adapter;
491 491
492 INIT_WORK(&adapter->tx_timeout_task, 492 INIT_WORK(&adapter->tx_timeout_task, ixgb_tx_timeout_task);
493 (void (*)(void *))ixgb_tx_timeout_task, netdev);
494 493
495 strcpy(netdev->name, "eth%d"); 494 strcpy(netdev->name, "eth%d");
496 if((err = register_netdev(netdev))) 495 if((err = register_netdev(netdev)))
@@ -1493,9 +1492,10 @@ ixgb_tx_timeout(struct net_device *netdev)
1493} 1492}
1494 1493
1495static void 1494static void
1496ixgb_tx_timeout_task(struct net_device *netdev) 1495ixgb_tx_timeout_task(struct work_struct *work)
1497{ 1496{
1498 struct ixgb_adapter *adapter = netdev_priv(netdev); 1497 struct ixgb_adapter *adapter =
1498 container_of(work, struct ixgb_adapter, tx_timeout_task);
1499 1499
1500 adapter->tx_timeout_count++; 1500 adapter->tx_timeout_count++;
1501 ixgb_down(adapter, TRUE); 1501 ixgb_down(adapter, TRUE);
diff --git a/drivers/net/lasi_82596.c b/drivers/net/lasi_82596.c
index f4d815bca643..ea392f2a5aa2 100644
--- a/drivers/net/lasi_82596.c
+++ b/drivers/net/lasi_82596.c
@@ -119,14 +119,14 @@
119#define DEB(x,y) if (i596_debug & (x)) { y; } 119#define DEB(x,y) if (i596_debug & (x)) { y; }
120 120
121 121
122#define CHECK_WBACK(addr,len) \ 122#define CHECK_WBACK(priv, addr,len) \
123 do { dma_cache_sync((void *)addr, len, DMA_TO_DEVICE); } while (0) 123 do { dma_cache_sync((priv)->dev, (void *)addr, len, DMA_TO_DEVICE); } while (0)
124 124
125#define CHECK_INV(addr,len) \ 125#define CHECK_INV(priv, addr,len) \
126 do { dma_cache_sync((void *)addr, len, DMA_FROM_DEVICE); } while(0) 126 do { dma_cache_sync((priv)->dev, (void *)addr, len, DMA_FROM_DEVICE); } while(0)
127 127
128#define CHECK_WBACK_INV(addr,len) \ 128#define CHECK_WBACK_INV(priv, addr,len) \
129 do { dma_cache_sync((void *)addr, len, DMA_BIDIRECTIONAL); } while (0) 129 do { dma_cache_sync((priv)->dev, (void *)addr, len, DMA_BIDIRECTIONAL); } while (0)
130 130
131 131
132#define PA_I82596_RESET 0 /* Offsets relative to LASI-LAN-Addr.*/ 132#define PA_I82596_RESET 0 /* Offsets relative to LASI-LAN-Addr.*/
@@ -449,10 +449,10 @@ static inline void MPU_PORT(struct net_device *dev, int c, dma_addr_t x)
449 449
450static inline int wait_istat(struct net_device *dev, struct i596_private *lp, int delcnt, char *str) 450static inline int wait_istat(struct net_device *dev, struct i596_private *lp, int delcnt, char *str)
451{ 451{
452 CHECK_INV(&(lp->iscp), sizeof(struct i596_iscp)); 452 CHECK_INV(lp, &(lp->iscp), sizeof(struct i596_iscp));
453 while (--delcnt && lp->iscp.stat) { 453 while (--delcnt && lp->iscp.stat) {
454 udelay(10); 454 udelay(10);
455 CHECK_INV(&(lp->iscp), sizeof(struct i596_iscp)); 455 CHECK_INV(lp, &(lp->iscp), sizeof(struct i596_iscp));
456 } 456 }
457 if (!delcnt) { 457 if (!delcnt) {
458 printk("%s: %s, iscp.stat %04x, didn't clear\n", 458 printk("%s: %s, iscp.stat %04x, didn't clear\n",
@@ -466,10 +466,10 @@ static inline int wait_istat(struct net_device *dev, struct i596_private *lp, in
466 466
467static inline int wait_cmd(struct net_device *dev, struct i596_private *lp, int delcnt, char *str) 467static inline int wait_cmd(struct net_device *dev, struct i596_private *lp, int delcnt, char *str)
468{ 468{
469 CHECK_INV(&(lp->scb), sizeof(struct i596_scb)); 469 CHECK_INV(lp, &(lp->scb), sizeof(struct i596_scb));
470 while (--delcnt && lp->scb.command) { 470 while (--delcnt && lp->scb.command) {
471 udelay(10); 471 udelay(10);
472 CHECK_INV(&(lp->scb), sizeof(struct i596_scb)); 472 CHECK_INV(lp, &(lp->scb), sizeof(struct i596_scb));
473 } 473 }
474 if (!delcnt) { 474 if (!delcnt) {
475 printk("%s: %s, status %4.4x, cmd %4.4x.\n", 475 printk("%s: %s, status %4.4x, cmd %4.4x.\n",
@@ -522,7 +522,7 @@ static void i596_display_data(struct net_device *dev)
522 rbd, rbd->count, rbd->b_next, rbd->b_data, rbd->size); 522 rbd, rbd->count, rbd->b_next, rbd->b_data, rbd->size);
523 rbd = rbd->v_next; 523 rbd = rbd->v_next;
524 } while (rbd != lp->rbd_head); 524 } while (rbd != lp->rbd_head);
525 CHECK_INV(lp, sizeof(struct i596_private)); 525 CHECK_INV(lp, lp, sizeof(struct i596_private));
526} 526}
527 527
528 528
@@ -592,7 +592,7 @@ static inline void init_rx_bufs(struct net_device *dev)
592 rfd->b_next = WSWAPrfd(virt_to_dma(lp,lp->rfds)); 592 rfd->b_next = WSWAPrfd(virt_to_dma(lp,lp->rfds));
593 rfd->cmd = CMD_EOL|CMD_FLEX; 593 rfd->cmd = CMD_EOL|CMD_FLEX;
594 594
595 CHECK_WBACK_INV(lp, sizeof(struct i596_private)); 595 CHECK_WBACK_INV(lp, lp, sizeof(struct i596_private));
596} 596}
597 597
598static inline void remove_rx_bufs(struct net_device *dev) 598static inline void remove_rx_bufs(struct net_device *dev)
@@ -629,7 +629,7 @@ static void rebuild_rx_bufs(struct net_device *dev)
629 lp->rbd_head = lp->rbds; 629 lp->rbd_head = lp->rbds;
630 lp->rfds[0].rbd = WSWAPrbd(virt_to_dma(lp,lp->rbds)); 630 lp->rfds[0].rbd = WSWAPrbd(virt_to_dma(lp,lp->rbds));
631 631
632 CHECK_WBACK_INV(lp, sizeof(struct i596_private)); 632 CHECK_WBACK_INV(lp, lp, sizeof(struct i596_private));
633} 633}
634 634
635 635
@@ -663,8 +663,8 @@ static int init_i596_mem(struct net_device *dev)
663 663
664 DEB(DEB_INIT, printk("%s: starting i82596.\n", dev->name)); 664 DEB(DEB_INIT, printk("%s: starting i82596.\n", dev->name));
665 665
666 CHECK_WBACK(&(lp->scp), sizeof(struct i596_scp)); 666 CHECK_WBACK(lp, &(lp->scp), sizeof(struct i596_scp));
667 CHECK_WBACK(&(lp->iscp), sizeof(struct i596_iscp)); 667 CHECK_WBACK(lp, &(lp->iscp), sizeof(struct i596_iscp));
668 668
669 MPU_PORT(dev, PORT_ALTSCP, virt_to_dma(lp,&lp->scp)); 669 MPU_PORT(dev, PORT_ALTSCP, virt_to_dma(lp,&lp->scp));
670 670
@@ -678,25 +678,25 @@ static int init_i596_mem(struct net_device *dev)
678 rebuild_rx_bufs(dev); 678 rebuild_rx_bufs(dev);
679 679
680 lp->scb.command = 0; 680 lp->scb.command = 0;
681 CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb)); 681 CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
682 682
683 enable_irq(dev->irq); /* enable IRQs from LAN */ 683 enable_irq(dev->irq); /* enable IRQs from LAN */
684 684
685 DEB(DEB_INIT, printk("%s: queuing CmdConfigure\n", dev->name)); 685 DEB(DEB_INIT, printk("%s: queuing CmdConfigure\n", dev->name));
686 memcpy(lp->cf_cmd.i596_config, init_setup, 14); 686 memcpy(lp->cf_cmd.i596_config, init_setup, 14);
687 lp->cf_cmd.cmd.command = CmdConfigure; 687 lp->cf_cmd.cmd.command = CmdConfigure;
688 CHECK_WBACK(&(lp->cf_cmd), sizeof(struct cf_cmd)); 688 CHECK_WBACK(lp, &(lp->cf_cmd), sizeof(struct cf_cmd));
689 i596_add_cmd(dev, &lp->cf_cmd.cmd); 689 i596_add_cmd(dev, &lp->cf_cmd.cmd);
690 690
691 DEB(DEB_INIT, printk("%s: queuing CmdSASetup\n", dev->name)); 691 DEB(DEB_INIT, printk("%s: queuing CmdSASetup\n", dev->name));
692 memcpy(lp->sa_cmd.eth_addr, dev->dev_addr, 6); 692 memcpy(lp->sa_cmd.eth_addr, dev->dev_addr, 6);
693 lp->sa_cmd.cmd.command = CmdSASetup; 693 lp->sa_cmd.cmd.command = CmdSASetup;
694 CHECK_WBACK(&(lp->sa_cmd), sizeof(struct sa_cmd)); 694 CHECK_WBACK(lp, &(lp->sa_cmd), sizeof(struct sa_cmd));
695 i596_add_cmd(dev, &lp->sa_cmd.cmd); 695 i596_add_cmd(dev, &lp->sa_cmd.cmd);
696 696
697 DEB(DEB_INIT, printk("%s: queuing CmdTDR\n", dev->name)); 697 DEB(DEB_INIT, printk("%s: queuing CmdTDR\n", dev->name));
698 lp->tdr_cmd.cmd.command = CmdTDR; 698 lp->tdr_cmd.cmd.command = CmdTDR;
699 CHECK_WBACK(&(lp->tdr_cmd), sizeof(struct tdr_cmd)); 699 CHECK_WBACK(lp, &(lp->tdr_cmd), sizeof(struct tdr_cmd));
700 i596_add_cmd(dev, &lp->tdr_cmd.cmd); 700 i596_add_cmd(dev, &lp->tdr_cmd.cmd);
701 701
702 spin_lock_irqsave (&lp->lock, flags); 702 spin_lock_irqsave (&lp->lock, flags);
@@ -708,7 +708,7 @@ static int init_i596_mem(struct net_device *dev)
708 DEB(DEB_INIT, printk("%s: Issuing RX_START\n", dev->name)); 708 DEB(DEB_INIT, printk("%s: Issuing RX_START\n", dev->name));
709 lp->scb.command = RX_START; 709 lp->scb.command = RX_START;
710 lp->scb.rfd = WSWAPrfd(virt_to_dma(lp,lp->rfds)); 710 lp->scb.rfd = WSWAPrfd(virt_to_dma(lp,lp->rfds));
711 CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb)); 711 CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
712 712
713 CA(dev); 713 CA(dev);
714 714
@@ -740,13 +740,13 @@ static inline int i596_rx(struct net_device *dev)
740 740
741 rfd = lp->rfd_head; /* Ref next frame to check */ 741 rfd = lp->rfd_head; /* Ref next frame to check */
742 742
743 CHECK_INV(rfd, sizeof(struct i596_rfd)); 743 CHECK_INV(lp, rfd, sizeof(struct i596_rfd));
744 while ((rfd->stat) & STAT_C) { /* Loop while complete frames */ 744 while ((rfd->stat) & STAT_C) { /* Loop while complete frames */
745 if (rfd->rbd == I596_NULL) 745 if (rfd->rbd == I596_NULL)
746 rbd = NULL; 746 rbd = NULL;
747 else if (rfd->rbd == lp->rbd_head->b_addr) { 747 else if (rfd->rbd == lp->rbd_head->b_addr) {
748 rbd = lp->rbd_head; 748 rbd = lp->rbd_head;
749 CHECK_INV(rbd, sizeof(struct i596_rbd)); 749 CHECK_INV(lp, rbd, sizeof(struct i596_rbd));
750 } 750 }
751 else { 751 else {
752 printk("%s: rbd chain broken!\n", dev->name); 752 printk("%s: rbd chain broken!\n", dev->name);
@@ -790,7 +790,7 @@ static inline int i596_rx(struct net_device *dev)
790 dma_addr = dma_map_single(lp->dev, newskb->data, PKT_BUF_SZ, DMA_FROM_DEVICE); 790 dma_addr = dma_map_single(lp->dev, newskb->data, PKT_BUF_SZ, DMA_FROM_DEVICE);
791 rbd->v_data = newskb->data; 791 rbd->v_data = newskb->data;
792 rbd->b_data = WSWAPchar(dma_addr); 792 rbd->b_data = WSWAPchar(dma_addr);
793 CHECK_WBACK_INV(rbd, sizeof(struct i596_rbd)); 793 CHECK_WBACK_INV(lp, rbd, sizeof(struct i596_rbd));
794 } 794 }
795 else 795 else
796 skb = dev_alloc_skb(pkt_len + 2); 796 skb = dev_alloc_skb(pkt_len + 2);
@@ -842,7 +842,7 @@ memory_squeeze:
842 if (rbd != NULL && (rbd->count & 0x4000)) { 842 if (rbd != NULL && (rbd->count & 0x4000)) {
843 rbd->count = 0; 843 rbd->count = 0;
844 lp->rbd_head = rbd->v_next; 844 lp->rbd_head = rbd->v_next;
845 CHECK_WBACK_INV(rbd, sizeof(struct i596_rbd)); 845 CHECK_WBACK_INV(lp, rbd, sizeof(struct i596_rbd));
846 } 846 }
847 847
848 /* Tidy the frame descriptor, marking it as end of list */ 848 /* Tidy the frame descriptor, marking it as end of list */
@@ -860,10 +860,10 @@ memory_squeeze:
860 860
861 lp->scb.rfd = rfd->b_next; 861 lp->scb.rfd = rfd->b_next;
862 lp->rfd_head = rfd->v_next; 862 lp->rfd_head = rfd->v_next;
863 CHECK_WBACK_INV(rfd->v_prev, sizeof(struct i596_rfd)); 863 CHECK_WBACK_INV(lp, rfd->v_prev, sizeof(struct i596_rfd));
864 CHECK_WBACK_INV(rfd, sizeof(struct i596_rfd)); 864 CHECK_WBACK_INV(lp, rfd, sizeof(struct i596_rfd));
865 rfd = lp->rfd_head; 865 rfd = lp->rfd_head;
866 CHECK_INV(rfd, sizeof(struct i596_rfd)); 866 CHECK_INV(lp, rfd, sizeof(struct i596_rfd));
867 } 867 }
868 868
869 DEB(DEB_RXFRAME, printk("frames %d\n", frames)); 869 DEB(DEB_RXFRAME, printk("frames %d\n", frames));
@@ -902,12 +902,12 @@ static inline void i596_cleanup_cmd(struct net_device *dev, struct i596_private
902 ptr->v_next = NULL; 902 ptr->v_next = NULL;
903 ptr->b_next = I596_NULL; 903 ptr->b_next = I596_NULL;
904 } 904 }
905 CHECK_WBACK_INV(ptr, sizeof(struct i596_cmd)); 905 CHECK_WBACK_INV(lp, ptr, sizeof(struct i596_cmd));
906 } 906 }
907 907
908 wait_cmd(dev, lp, 100, "i596_cleanup_cmd timed out"); 908 wait_cmd(dev, lp, 100, "i596_cleanup_cmd timed out");
909 lp->scb.cmd = I596_NULL; 909 lp->scb.cmd = I596_NULL;
910 CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb)); 910 CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
911} 911}
912 912
913 913
@@ -925,7 +925,7 @@ static inline void i596_reset(struct net_device *dev, struct i596_private *lp)
925 925
926 /* FIXME: this command might cause an lpmc */ 926 /* FIXME: this command might cause an lpmc */
927 lp->scb.command = CUC_ABORT | RX_ABORT; 927 lp->scb.command = CUC_ABORT | RX_ABORT;
928 CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb)); 928 CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
929 CA(dev); 929 CA(dev);
930 930
931 /* wait for shutdown */ 931 /* wait for shutdown */
@@ -951,20 +951,20 @@ static void i596_add_cmd(struct net_device *dev, struct i596_cmd *cmd)
951 cmd->command |= (CMD_EOL | CMD_INTR); 951 cmd->command |= (CMD_EOL | CMD_INTR);
952 cmd->v_next = NULL; 952 cmd->v_next = NULL;
953 cmd->b_next = I596_NULL; 953 cmd->b_next = I596_NULL;
954 CHECK_WBACK(cmd, sizeof(struct i596_cmd)); 954 CHECK_WBACK(lp, cmd, sizeof(struct i596_cmd));
955 955
956 spin_lock_irqsave (&lp->lock, flags); 956 spin_lock_irqsave (&lp->lock, flags);
957 957
958 if (lp->cmd_head != NULL) { 958 if (lp->cmd_head != NULL) {
959 lp->cmd_tail->v_next = cmd; 959 lp->cmd_tail->v_next = cmd;
960 lp->cmd_tail->b_next = WSWAPcmd(virt_to_dma(lp,&cmd->status)); 960 lp->cmd_tail->b_next = WSWAPcmd(virt_to_dma(lp,&cmd->status));
961 CHECK_WBACK(lp->cmd_tail, sizeof(struct i596_cmd)); 961 CHECK_WBACK(lp, lp->cmd_tail, sizeof(struct i596_cmd));
962 } else { 962 } else {
963 lp->cmd_head = cmd; 963 lp->cmd_head = cmd;
964 wait_cmd(dev, lp, 100, "i596_add_cmd timed out"); 964 wait_cmd(dev, lp, 100, "i596_add_cmd timed out");
965 lp->scb.cmd = WSWAPcmd(virt_to_dma(lp,&cmd->status)); 965 lp->scb.cmd = WSWAPcmd(virt_to_dma(lp,&cmd->status));
966 lp->scb.command = CUC_START; 966 lp->scb.command = CUC_START;
967 CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb)); 967 CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
968 CA(dev); 968 CA(dev);
969 } 969 }
970 lp->cmd_tail = cmd; 970 lp->cmd_tail = cmd;
@@ -998,12 +998,12 @@ static int i596_test(struct net_device *dev)
998 data = virt_to_dma(lp,tint); 998 data = virt_to_dma(lp,tint);
999 999
1000 tint[1] = -1; 1000 tint[1] = -1;
1001 CHECK_WBACK(tint,PAGE_SIZE); 1001 CHECK_WBACK(lp, tint, PAGE_SIZE);
1002 1002
1003 MPU_PORT(dev, 1, data); 1003 MPU_PORT(dev, 1, data);
1004 1004
1005 for(data = 1000000; data; data--) { 1005 for(data = 1000000; data; data--) {
1006 CHECK_INV(tint,PAGE_SIZE); 1006 CHECK_INV(lp, tint, PAGE_SIZE);
1007 if(tint[1] != -1) 1007 if(tint[1] != -1)
1008 break; 1008 break;
1009 1009
@@ -1061,7 +1061,7 @@ static void i596_tx_timeout (struct net_device *dev)
1061 /* Issue a channel attention signal */ 1061 /* Issue a channel attention signal */
1062 DEB(DEB_ERRORS, printk("Kicking board.\n")); 1062 DEB(DEB_ERRORS, printk("Kicking board.\n"));
1063 lp->scb.command = CUC_START | RX_START; 1063 lp->scb.command = CUC_START | RX_START;
1064 CHECK_WBACK_INV(&(lp->scb), sizeof(struct i596_scb)); 1064 CHECK_WBACK_INV(lp, &(lp->scb), sizeof(struct i596_scb));
1065 CA (dev); 1065 CA (dev);
1066 lp->last_restart = lp->stats.tx_packets; 1066 lp->last_restart = lp->stats.tx_packets;
1067 } 1067 }
@@ -1118,8 +1118,8 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev)
1118 tbd->data = WSWAPchar(tx_cmd->dma_addr); 1118 tbd->data = WSWAPchar(tx_cmd->dma_addr);
1119 1119
1120 DEB(DEB_TXADDR,print_eth(skb->data, "tx-queued")); 1120 DEB(DEB_TXADDR,print_eth(skb->data, "tx-queued"));
1121 CHECK_WBACK_INV(tx_cmd, sizeof(struct tx_cmd)); 1121 CHECK_WBACK_INV(lp, tx_cmd, sizeof(struct tx_cmd));
1122 CHECK_WBACK_INV(tbd, sizeof(struct i596_tbd)); 1122 CHECK_WBACK_INV(lp, tbd, sizeof(struct i596_tbd));
1123 i596_add_cmd(dev, &tx_cmd->cmd); 1123 i596_add_cmd(dev, &tx_cmd->cmd);
1124 1124
1125 lp->stats.tx_packets++; 1125 lp->stats.tx_packets++;
@@ -1228,7 +1228,7 @@ static int __devinit i82596_probe(struct net_device *dev,
1228 lp->dma_addr = dma_addr; 1228 lp->dma_addr = dma_addr;
1229 lp->dev = gen_dev; 1229 lp->dev = gen_dev;
1230 1230
1231 CHECK_WBACK_INV(dev->mem_start, sizeof(struct i596_private)); 1231 CHECK_WBACK_INV(lp, dev->mem_start, sizeof(struct i596_private));
1232 1232
1233 i = register_netdev(dev); 1233 i = register_netdev(dev);
1234 if (i) { 1234 if (i) {
@@ -1295,7 +1295,7 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
1295 DEB(DEB_INTS, printk("%s: i596 interrupt command unit inactive %x.\n", dev->name, status & 0x0700)); 1295 DEB(DEB_INTS, printk("%s: i596 interrupt command unit inactive %x.\n", dev->name, status & 0x0700));
1296 1296
1297 while (lp->cmd_head != NULL) { 1297 while (lp->cmd_head != NULL) {
1298 CHECK_INV(lp->cmd_head, sizeof(struct i596_cmd)); 1298 CHECK_INV(lp, lp->cmd_head, sizeof(struct i596_cmd));
1299 if (!(lp->cmd_head->status & STAT_C)) 1299 if (!(lp->cmd_head->status & STAT_C))
1300 break; 1300 break;
1301 1301
@@ -1358,7 +1358,7 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
1358 } 1358 }
1359 ptr->v_next = NULL; 1359 ptr->v_next = NULL;
1360 ptr->b_next = I596_NULL; 1360 ptr->b_next = I596_NULL;
1361 CHECK_WBACK(ptr, sizeof(struct i596_cmd)); 1361 CHECK_WBACK(lp, ptr, sizeof(struct i596_cmd));
1362 lp->last_cmd = jiffies; 1362 lp->last_cmd = jiffies;
1363 } 1363 }
1364 1364
@@ -1372,13 +1372,13 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
1372 1372
1373 ptr->command &= 0x1fff; 1373 ptr->command &= 0x1fff;
1374 ptr = ptr->v_next; 1374 ptr = ptr->v_next;
1375 CHECK_WBACK_INV(prev, sizeof(struct i596_cmd)); 1375 CHECK_WBACK_INV(lp, prev, sizeof(struct i596_cmd));
1376 } 1376 }
1377 1377
1378 if ((lp->cmd_head != NULL)) 1378 if ((lp->cmd_head != NULL))
1379 ack_cmd |= CUC_START; 1379 ack_cmd |= CUC_START;
1380 lp->scb.cmd = WSWAPcmd(virt_to_dma(lp,&lp->cmd_head->status)); 1380 lp->scb.cmd = WSWAPcmd(virt_to_dma(lp,&lp->cmd_head->status));
1381 CHECK_WBACK_INV(&lp->scb, sizeof(struct i596_scb)); 1381 CHECK_WBACK_INV(lp, &lp->scb, sizeof(struct i596_scb));
1382 } 1382 }
1383 if ((status & 0x1000) || (status & 0x4000)) { 1383 if ((status & 0x1000) || (status & 0x4000)) {
1384 if ((status & 0x4000)) 1384 if ((status & 0x4000))
@@ -1397,7 +1397,7 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
1397 } 1397 }
1398 wait_cmd(dev, lp, 100, "i596 interrupt, timeout"); 1398 wait_cmd(dev, lp, 100, "i596 interrupt, timeout");
1399 lp->scb.command = ack_cmd; 1399 lp->scb.command = ack_cmd;
1400 CHECK_WBACK(&lp->scb, sizeof(struct i596_scb)); 1400 CHECK_WBACK(lp, &lp->scb, sizeof(struct i596_scb));
1401 1401
1402 /* DANGER: I suspect that some kind of interrupt 1402 /* DANGER: I suspect that some kind of interrupt
1403 acknowledgement aside from acking the 82596 might be needed 1403 acknowledgement aside from acking the 82596 might be needed
@@ -1426,7 +1426,7 @@ static int i596_close(struct net_device *dev)
1426 1426
1427 wait_cmd(dev, lp, 100, "close1 timed out"); 1427 wait_cmd(dev, lp, 100, "close1 timed out");
1428 lp->scb.command = CUC_ABORT | RX_ABORT; 1428 lp->scb.command = CUC_ABORT | RX_ABORT;
1429 CHECK_WBACK(&lp->scb, sizeof(struct i596_scb)); 1429 CHECK_WBACK(lp, &lp->scb, sizeof(struct i596_scb));
1430 1430
1431 CA(dev); 1431 CA(dev);
1432 1432
@@ -1486,7 +1486,7 @@ static void set_multicast_list(struct net_device *dev)
1486 dev->name); 1486 dev->name);
1487 else { 1487 else {
1488 lp->cf_cmd.cmd.command = CmdConfigure; 1488 lp->cf_cmd.cmd.command = CmdConfigure;
1489 CHECK_WBACK_INV(&lp->cf_cmd, sizeof(struct cf_cmd)); 1489 CHECK_WBACK_INV(lp, &lp->cf_cmd, sizeof(struct cf_cmd));
1490 i596_add_cmd(dev, &lp->cf_cmd.cmd); 1490 i596_add_cmd(dev, &lp->cf_cmd.cmd);
1491 } 1491 }
1492 } 1492 }
@@ -1514,7 +1514,7 @@ static void set_multicast_list(struct net_device *dev)
1514 DEB(DEB_MULTI, printk("%s: Adding address %02x:%02x:%02x:%02x:%02x:%02x\n", 1514 DEB(DEB_MULTI, printk("%s: Adding address %02x:%02x:%02x:%02x:%02x:%02x\n",
1515 dev->name, cp[0],cp[1],cp[2],cp[3],cp[4],cp[5])); 1515 dev->name, cp[0],cp[1],cp[2],cp[3],cp[4],cp[5]));
1516 } 1516 }
1517 CHECK_WBACK_INV(&lp->mc_cmd, sizeof(struct mc_cmd)); 1517 CHECK_WBACK_INV(lp, &lp->mc_cmd, sizeof(struct mc_cmd));
1518 i596_add_cmd(dev, &cmd->cmd); 1518 i596_add_cmd(dev, &cmd->cmd);
1519 } 1519 }
1520} 1520}
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 9997081c6dae..d9f48bb04b05 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -277,9 +277,11 @@ static void mv643xx_eth_tx_timeout(struct net_device *dev)
277 * 277 *
278 * Actual routine to reset the adapter when a timeout on Tx has occurred 278 * Actual routine to reset the adapter when a timeout on Tx has occurred
279 */ 279 */
280static void mv643xx_eth_tx_timeout_task(struct net_device *dev) 280static void mv643xx_eth_tx_timeout_task(struct work_struct *ugly)
281{ 281{
282 struct mv643xx_private *mp = netdev_priv(dev); 282 struct mv643xx_private *mp = container_of(ugly, struct mv643xx_private,
283 tx_timeout_task);
284 struct net_device *dev = mp->mii.dev; /* yuck */
283 285
284 if (!netif_running(dev)) 286 if (!netif_running(dev))
285 return; 287 return;
@@ -1360,8 +1362,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1360#endif 1362#endif
1361 1363
1362 /* Configure the timeout task */ 1364 /* Configure the timeout task */
1363 INIT_WORK(&mp->tx_timeout_task, 1365 INIT_WORK(&mp->tx_timeout_task, mv643xx_eth_tx_timeout_task);
1364 (void (*)(void *))mv643xx_eth_tx_timeout_task, dev);
1365 1366
1366 spin_lock_init(&mp->lock); 1367 spin_lock_init(&mp->lock);
1367 1368
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index 36350e6db1c1..38df42802386 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -2615,9 +2615,10 @@ static u32 myri10ge_read_reboot(struct myri10ge_priv *mgp)
2615 * This watchdog is used to check whether the board has suffered 2615 * This watchdog is used to check whether the board has suffered
2616 * from a parity error and needs to be recovered. 2616 * from a parity error and needs to be recovered.
2617 */ 2617 */
2618static void myri10ge_watchdog(void *arg) 2618static void myri10ge_watchdog(struct work_struct *work)
2619{ 2619{
2620 struct myri10ge_priv *mgp = arg; 2620 struct myri10ge_priv *mgp =
2621 container_of(work, struct myri10ge_priv, watchdog_work);
2621 u32 reboot; 2622 u32 reboot;
2622 int status; 2623 int status;
2623 u16 cmd, vendor; 2624 u16 cmd, vendor;
@@ -2887,7 +2888,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2887 (unsigned long)mgp); 2888 (unsigned long)mgp);
2888 2889
2889 SET_ETHTOOL_OPS(netdev, &myri10ge_ethtool_ops); 2890 SET_ETHTOOL_OPS(netdev, &myri10ge_ethtool_ops);
2890 INIT_WORK(&mgp->watchdog_work, myri10ge_watchdog, mgp); 2891 INIT_WORK(&mgp->watchdog_work, myri10ge_watchdog);
2891 status = register_netdev(netdev); 2892 status = register_netdev(netdev);
2892 if (status != 0) { 2893 if (status != 0) {
2893 dev_err(&pdev->dev, "register_netdev failed: %d\n", status); 2894 dev_err(&pdev->dev, "register_netdev failed: %d\n", status);
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index d925053fe597..9c588af8ab74 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -714,6 +714,7 @@ struct netxen_adapter {
714 spinlock_t lock; 714 spinlock_t lock;
715 struct work_struct watchdog_task; 715 struct work_struct watchdog_task;
716 struct work_struct tx_timeout_task; 716 struct work_struct tx_timeout_task;
717 struct net_device *netdev;
717 struct timer_list watchdog_timer; 718 struct timer_list watchdog_timer;
718 719
719 u32 curr_window; 720 u32 curr_window;
@@ -921,7 +922,7 @@ netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data,
921 struct netxen_port *port); 922 struct netxen_port *port);
922int netxen_nic_rx_has_work(struct netxen_adapter *adapter); 923int netxen_nic_rx_has_work(struct netxen_adapter *adapter);
923int netxen_nic_tx_has_work(struct netxen_adapter *adapter); 924int netxen_nic_tx_has_work(struct netxen_adapter *adapter);
924void netxen_watchdog_task(unsigned long v); 925void netxen_watchdog_task(struct work_struct *work);
925void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, 926void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx,
926 u32 ringid); 927 u32 ringid);
927void netxen_process_cmd_ring(unsigned long data); 928void netxen_process_cmd_ring(unsigned long data);
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 0dca029bc3e5..eae18236aefa 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -710,12 +710,13 @@ static inline int netxen_nic_check_temp(struct netxen_adapter *adapter)
710 return rv; 710 return rv;
711} 711}
712 712
713void netxen_watchdog_task(unsigned long v) 713void netxen_watchdog_task(struct work_struct *work)
714{ 714{
715 int port_num; 715 int port_num;
716 struct netxen_port *port; 716 struct netxen_port *port;
717 struct net_device *netdev; 717 struct net_device *netdev;
718 struct netxen_adapter *adapter = (struct netxen_adapter *)v; 718 struct netxen_adapter *adapter =
719 container_of(work, struct netxen_adapter, watchdog_task);
719 720
720 if (netxen_nic_check_temp(adapter)) 721 if (netxen_nic_check_temp(adapter))
721 return; 722 return;
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 1cb662d5bd76..df0bb36a1cfb 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -64,7 +64,7 @@ static int netxen_nic_open(struct net_device *netdev);
64static int netxen_nic_close(struct net_device *netdev); 64static int netxen_nic_close(struct net_device *netdev);
65static int netxen_nic_xmit_frame(struct sk_buff *, struct net_device *); 65static int netxen_nic_xmit_frame(struct sk_buff *, struct net_device *);
66static void netxen_tx_timeout(struct net_device *netdev); 66static void netxen_tx_timeout(struct net_device *netdev);
67static void netxen_tx_timeout_task(struct net_device *netdev); 67static void netxen_tx_timeout_task(struct work_struct *work);
68static void netxen_watchdog(unsigned long); 68static void netxen_watchdog(unsigned long);
69static int netxen_handle_int(struct netxen_adapter *, struct net_device *); 69static int netxen_handle_int(struct netxen_adapter *, struct net_device *);
70static int netxen_nic_ioctl(struct net_device *netdev, 70static int netxen_nic_ioctl(struct net_device *netdev,
@@ -274,8 +274,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
274 adapter->ahw.xg_linkup = 0; 274 adapter->ahw.xg_linkup = 0;
275 adapter->watchdog_timer.function = &netxen_watchdog; 275 adapter->watchdog_timer.function = &netxen_watchdog;
276 adapter->watchdog_timer.data = (unsigned long)adapter; 276 adapter->watchdog_timer.data = (unsigned long)adapter;
277 INIT_WORK(&adapter->watchdog_task, 277 INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task);
278 (void (*)(void *))netxen_watchdog_task, adapter);
279 adapter->ahw.pdev = pdev; 278 adapter->ahw.pdev = pdev;
280 adapter->proc_cmd_buf_counter = 0; 279 adapter->proc_cmd_buf_counter = 0;
281 pci_read_config_byte(pdev, PCI_REVISION_ID, &adapter->ahw.revision_id); 280 pci_read_config_byte(pdev, PCI_REVISION_ID, &adapter->ahw.revision_id);
@@ -379,8 +378,8 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
379 dev_addr); 378 dev_addr);
380 } 379 }
381 } 380 }
382 INIT_WORK(&adapter->tx_timeout_task, 381 adapter->netdev = netdev;
383 (void (*)(void *))netxen_tx_timeout_task, netdev); 382 INIT_WORK(&adapter->tx_timeout_task, netxen_tx_timeout_task);
384 netif_carrier_off(netdev); 383 netif_carrier_off(netdev);
385 netif_stop_queue(netdev); 384 netif_stop_queue(netdev);
386 385
@@ -938,18 +937,20 @@ static void netxen_tx_timeout(struct net_device *netdev)
938 schedule_work(&adapter->tx_timeout_task); 937 schedule_work(&adapter->tx_timeout_task);
939} 938}
940 939
941static void netxen_tx_timeout_task(struct net_device *netdev) 940static void netxen_tx_timeout_task(struct work_struct *work)
942{ 941{
943 struct netxen_port *port = (struct netxen_port *)netdev_priv(netdev); 942 struct netxen_adapter *adapter =
943 container_of(work, struct netxen_adapter, tx_timeout_task);
944 struct net_device *netdev = adapter->netdev;
944 unsigned long flags; 945 unsigned long flags;
945 946
946 printk(KERN_ERR "%s %s: transmit timeout, resetting.\n", 947 printk(KERN_ERR "%s %s: transmit timeout, resetting.\n",
947 netxen_nic_driver_name, netdev->name); 948 netxen_nic_driver_name, netdev->name);
948 949
949 spin_lock_irqsave(&port->adapter->lock, flags); 950 spin_lock_irqsave(&adapter->lock, flags);
950 netxen_nic_close(netdev); 951 netxen_nic_close(netdev);
951 netxen_nic_open(netdev); 952 netxen_nic_open(netdev);
952 spin_unlock_irqrestore(&port->adapter->lock, flags); 953 spin_unlock_irqrestore(&adapter->lock, flags);
953 netdev->trans_start = jiffies; 954 netdev->trans_start = jiffies;
954 netif_wake_queue(netdev); 955 netif_wake_queue(netdev);
955} 956}
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c
index b0127c71a5b6..312e0e331712 100644
--- a/drivers/net/ns83820.c
+++ b/drivers/net/ns83820.c
@@ -427,6 +427,7 @@ struct ns83820 {
427 u8 __iomem *base; 427 u8 __iomem *base;
428 428
429 struct pci_dev *pci_dev; 429 struct pci_dev *pci_dev;
430 struct net_device *ndev;
430 431
431#ifdef NS83820_VLAN_ACCEL_SUPPORT 432#ifdef NS83820_VLAN_ACCEL_SUPPORT
432 struct vlan_group *vlgrp; 433 struct vlan_group *vlgrp;
@@ -631,10 +632,10 @@ static void fastcall rx_refill_atomic(struct net_device *ndev)
631} 632}
632 633
633/* REFILL */ 634/* REFILL */
634static inline void queue_refill(void *_dev) 635static inline void queue_refill(struct work_struct *work)
635{ 636{
636 struct net_device *ndev = _dev; 637 struct ns83820 *dev = container_of(work, struct ns83820, tq_refill);
637 struct ns83820 *dev = PRIV(ndev); 638 struct net_device *ndev = dev->ndev;
638 639
639 rx_refill(ndev, GFP_KERNEL); 640 rx_refill(ndev, GFP_KERNEL);
640 if (dev->rx_info.up) 641 if (dev->rx_info.up)
@@ -1841,6 +1842,7 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
1841 1842
1842 ndev = alloc_etherdev(sizeof(struct ns83820)); 1843 ndev = alloc_etherdev(sizeof(struct ns83820));
1843 dev = PRIV(ndev); 1844 dev = PRIV(ndev);
1845 dev->ndev = ndev;
1844 err = -ENOMEM; 1846 err = -ENOMEM;
1845 if (!dev) 1847 if (!dev)
1846 goto out; 1848 goto out;
@@ -1853,7 +1855,7 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
1853 SET_MODULE_OWNER(ndev); 1855 SET_MODULE_OWNER(ndev);
1854 SET_NETDEV_DEV(ndev, &pci_dev->dev); 1856 SET_NETDEV_DEV(ndev, &pci_dev->dev);
1855 1857
1856 INIT_WORK(&dev->tq_refill, queue_refill, ndev); 1858 INIT_WORK(&dev->tq_refill, queue_refill);
1857 tasklet_init(&dev->rx_tasklet, rx_action, (unsigned long)ndev); 1859 tasklet_init(&dev->rx_tasklet, rx_action, (unsigned long)ndev);
1858 1860
1859 err = pci_enable_device(pci_dev); 1861 err = pci_enable_device(pci_dev);
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index 69813406782d..8478dca3d8d1 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -332,6 +332,7 @@ static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id);
332 */ 332 */
333 333
334typedef struct local_info_t { 334typedef struct local_info_t {
335 struct net_device *dev;
335 struct pcmcia_device *p_dev; 336 struct pcmcia_device *p_dev;
336 dev_node_t node; 337 dev_node_t node;
337 struct net_device_stats stats; 338 struct net_device_stats stats;
@@ -353,7 +354,7 @@ typedef struct local_info_t {
353 */ 354 */
354static int do_start_xmit(struct sk_buff *skb, struct net_device *dev); 355static int do_start_xmit(struct sk_buff *skb, struct net_device *dev);
355static void do_tx_timeout(struct net_device *dev); 356static void do_tx_timeout(struct net_device *dev);
356static void xirc2ps_tx_timeout_task(void *data); 357static void xirc2ps_tx_timeout_task(struct work_struct *work);
357static struct net_device_stats *do_get_stats(struct net_device *dev); 358static struct net_device_stats *do_get_stats(struct net_device *dev);
358static void set_addresses(struct net_device *dev); 359static void set_addresses(struct net_device *dev);
359static void set_multicast_list(struct net_device *dev); 360static void set_multicast_list(struct net_device *dev);
@@ -567,6 +568,7 @@ xirc2ps_probe(struct pcmcia_device *link)
567 if (!dev) 568 if (!dev)
568 return -ENOMEM; 569 return -ENOMEM;
569 local = netdev_priv(dev); 570 local = netdev_priv(dev);
571 local->dev = dev;
570 local->p_dev = link; 572 local->p_dev = link;
571 link->priv = dev; 573 link->priv = dev;
572 574
@@ -591,7 +593,7 @@ xirc2ps_probe(struct pcmcia_device *link)
591#ifdef HAVE_TX_TIMEOUT 593#ifdef HAVE_TX_TIMEOUT
592 dev->tx_timeout = do_tx_timeout; 594 dev->tx_timeout = do_tx_timeout;
593 dev->watchdog_timeo = TX_TIMEOUT; 595 dev->watchdog_timeo = TX_TIMEOUT;
594 INIT_WORK(&local->tx_timeout_task, xirc2ps_tx_timeout_task, dev); 596 INIT_WORK(&local->tx_timeout_task, xirc2ps_tx_timeout_task);
595#endif 597#endif
596 598
597 return xirc2ps_config(link); 599 return xirc2ps_config(link);
@@ -1324,9 +1326,11 @@ xirc2ps_interrupt(int irq, void *dev_id)
1324/*====================================================================*/ 1326/*====================================================================*/
1325 1327
1326static void 1328static void
1327xirc2ps_tx_timeout_task(void *data) 1329xirc2ps_tx_timeout_task(struct work_struct *work)
1328{ 1330{
1329 struct net_device *dev = data; 1331 local_info_t *local =
1332 container_of(work, local_info_t, tx_timeout_task);
1333 struct net_device *dev = local->dev;
1330 /* reset the card */ 1334 /* reset the card */
1331 do_reset(dev,1); 1335 do_reset(dev,1);
1332 dev->trans_start = jiffies; 1336 dev->trans_start = jiffies;
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 88237bdb5255..4044bb1ada86 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -397,7 +397,7 @@ out_unlock:
397EXPORT_SYMBOL(phy_start_aneg); 397EXPORT_SYMBOL(phy_start_aneg);
398 398
399 399
400static void phy_change(void *data); 400static void phy_change(struct work_struct *work);
401static void phy_timer(unsigned long data); 401static void phy_timer(unsigned long data);
402 402
403/* phy_start_machine: 403/* phy_start_machine:
@@ -555,7 +555,7 @@ int phy_start_interrupts(struct phy_device *phydev)
555{ 555{
556 int err = 0; 556 int err = 0;
557 557
558 INIT_WORK(&phydev->phy_queue, phy_change, phydev); 558 INIT_WORK(&phydev->phy_queue, phy_change);
559 559
560 if (request_irq(phydev->irq, phy_interrupt, 560 if (request_irq(phydev->irq, phy_interrupt,
561 IRQF_SHARED, 561 IRQF_SHARED,
@@ -598,10 +598,11 @@ EXPORT_SYMBOL(phy_stop_interrupts);
598 598
599 599
600/* Scheduled by the phy_interrupt/timer to handle PHY changes */ 600/* Scheduled by the phy_interrupt/timer to handle PHY changes */
601static void phy_change(void *data) 601static void phy_change(struct work_struct *work)
602{ 602{
603 int err; 603 int err;
604 struct phy_device *phydev = data; 604 struct phy_device *phydev =
605 container_of(work, struct phy_device, phy_queue);
605 606
606 err = phy_disable_interrupts(phydev); 607 err = phy_disable_interrupts(phydev);
607 608
diff --git a/drivers/net/plip.c b/drivers/net/plip.c
index 71afb274498f..6bb085f54437 100644
--- a/drivers/net/plip.c
+++ b/drivers/net/plip.c
@@ -138,9 +138,9 @@ static const unsigned int net_debug = NET_DEBUG;
138#define PLIP_NIBBLE_WAIT 3000 138#define PLIP_NIBBLE_WAIT 3000
139 139
140/* Bottom halves */ 140/* Bottom halves */
141static void plip_kick_bh(struct net_device *dev); 141static void plip_kick_bh(struct work_struct *work);
142static void plip_bh(struct net_device *dev); 142static void plip_bh(struct work_struct *work);
143static void plip_timer_bh(struct net_device *dev); 143static void plip_timer_bh(struct work_struct *work);
144 144
145/* Interrupt handler */ 145/* Interrupt handler */
146static void plip_interrupt(int irq, void *dev_id); 146static void plip_interrupt(int irq, void *dev_id);
@@ -207,9 +207,10 @@ struct plip_local {
207 207
208struct net_local { 208struct net_local {
209 struct net_device_stats enet_stats; 209 struct net_device_stats enet_stats;
210 struct net_device *dev;
210 struct work_struct immediate; 211 struct work_struct immediate;
211 struct work_struct deferred; 212 struct delayed_work deferred;
212 struct work_struct timer; 213 struct delayed_work timer;
213 struct plip_local snd_data; 214 struct plip_local snd_data;
214 struct plip_local rcv_data; 215 struct plip_local rcv_data;
215 struct pardevice *pardev; 216 struct pardevice *pardev;
@@ -306,11 +307,11 @@ plip_init_netdev(struct net_device *dev)
306 nl->nibble = PLIP_NIBBLE_WAIT; 307 nl->nibble = PLIP_NIBBLE_WAIT;
307 308
308 /* Initialize task queue structures */ 309 /* Initialize task queue structures */
309 INIT_WORK(&nl->immediate, (void (*)(void *))plip_bh, dev); 310 INIT_WORK(&nl->immediate, plip_bh);
310 INIT_WORK(&nl->deferred, (void (*)(void *))plip_kick_bh, dev); 311 INIT_DELAYED_WORK(&nl->deferred, plip_kick_bh);
311 312
312 if (dev->irq == -1) 313 if (dev->irq == -1)
313 INIT_WORK(&nl->timer, (void (*)(void *))plip_timer_bh, dev); 314 INIT_DELAYED_WORK(&nl->timer, plip_timer_bh);
314 315
315 spin_lock_init(&nl->lock); 316 spin_lock_init(&nl->lock);
316} 317}
@@ -319,9 +320,10 @@ plip_init_netdev(struct net_device *dev)
319 This routine is kicked by do_timer(). 320 This routine is kicked by do_timer().
320 Request `plip_bh' to be invoked. */ 321 Request `plip_bh' to be invoked. */
321static void 322static void
322plip_kick_bh(struct net_device *dev) 323plip_kick_bh(struct work_struct *work)
323{ 324{
324 struct net_local *nl = netdev_priv(dev); 325 struct net_local *nl =
326 container_of(work, struct net_local, deferred.work);
325 327
326 if (nl->is_deferred) 328 if (nl->is_deferred)
327 schedule_work(&nl->immediate); 329 schedule_work(&nl->immediate);
@@ -362,9 +364,9 @@ static const plip_func connection_state_table[] =
362 364
363/* Bottom half handler of PLIP. */ 365/* Bottom half handler of PLIP. */
364static void 366static void
365plip_bh(struct net_device *dev) 367plip_bh(struct work_struct *work)
366{ 368{
367 struct net_local *nl = netdev_priv(dev); 369 struct net_local *nl = container_of(work, struct net_local, immediate);
368 struct plip_local *snd = &nl->snd_data; 370 struct plip_local *snd = &nl->snd_data;
369 struct plip_local *rcv = &nl->rcv_data; 371 struct plip_local *rcv = &nl->rcv_data;
370 plip_func f; 372 plip_func f;
@@ -372,20 +374,21 @@ plip_bh(struct net_device *dev)
372 374
373 nl->is_deferred = 0; 375 nl->is_deferred = 0;
374 f = connection_state_table[nl->connection]; 376 f = connection_state_table[nl->connection];
375 if ((r = (*f)(dev, nl, snd, rcv)) != OK 377 if ((r = (*f)(nl->dev, nl, snd, rcv)) != OK
376 && (r = plip_bh_timeout_error(dev, nl, snd, rcv, r)) != OK) { 378 && (r = plip_bh_timeout_error(nl->dev, nl, snd, rcv, r)) != OK) {
377 nl->is_deferred = 1; 379 nl->is_deferred = 1;
378 schedule_delayed_work(&nl->deferred, 1); 380 schedule_delayed_work(&nl->deferred, 1);
379 } 381 }
380} 382}
381 383
382static void 384static void
383plip_timer_bh(struct net_device *dev) 385plip_timer_bh(struct work_struct *work)
384{ 386{
385 struct net_local *nl = netdev_priv(dev); 387 struct net_local *nl =
388 container_of(work, struct net_local, timer.work);
386 389
387 if (!(atomic_read (&nl->kill_timer))) { 390 if (!(atomic_read (&nl->kill_timer))) {
388 plip_interrupt (-1, dev); 391 plip_interrupt (-1, nl->dev);
389 392
390 schedule_delayed_work(&nl->timer, 1); 393 schedule_delayed_work(&nl->timer, 1);
391 } 394 }
@@ -1284,6 +1287,7 @@ static void plip_attach (struct parport *port)
1284 } 1287 }
1285 1288
1286 nl = netdev_priv(dev); 1289 nl = netdev_priv(dev);
1290 nl->dev = dev;
1287 nl->pardev = parport_register_device(port, name, plip_preempt, 1291 nl->pardev = parport_register_device(port, name, plip_preempt,
1288 plip_wakeup, plip_interrupt, 1292 plip_wakeup, plip_interrupt,
1289 0, dev); 1293 0, dev);
diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c
index ec640f6229ae..d79d141a601d 100644
--- a/drivers/net/qla3xxx.c
+++ b/drivers/net/qla3xxx.c
@@ -2008,7 +2008,7 @@ static irqreturn_t ql3xxx_isr(int irq, void *dev_id)
2008 "%s: Another function issued a reset to the " 2008 "%s: Another function issued a reset to the "
2009 "chip. ISR value = %x.\n", ndev->name, value); 2009 "chip. ISR value = %x.\n", ndev->name, value);
2010 } 2010 }
2011 queue_work(qdev->workqueue, &qdev->reset_work); 2011 queue_delayed_work(qdev->workqueue, &qdev->reset_work, 0);
2012 spin_unlock(&qdev->adapter_lock); 2012 spin_unlock(&qdev->adapter_lock);
2013 } else if (value & ISP_IMR_DISABLE_CMPL_INT) { 2013 } else if (value & ISP_IMR_DISABLE_CMPL_INT) {
2014 ql_disable_interrupts(qdev); 2014 ql_disable_interrupts(qdev);
@@ -3182,11 +3182,13 @@ static void ql3xxx_tx_timeout(struct net_device *ndev)
3182 /* 3182 /*
3183 * Wake up the worker to process this event. 3183 * Wake up the worker to process this event.
3184 */ 3184 */
3185 queue_work(qdev->workqueue, &qdev->tx_timeout_work); 3185 queue_delayed_work(qdev->workqueue, &qdev->tx_timeout_work, 0);
3186} 3186}
3187 3187
3188static void ql_reset_work(struct ql3_adapter *qdev) 3188static void ql_reset_work(struct work_struct *work)
3189{ 3189{
3190 struct ql3_adapter *qdev =
3191 container_of(work, struct ql3_adapter, reset_work.work);
3190 struct net_device *ndev = qdev->ndev; 3192 struct net_device *ndev = qdev->ndev;
3191 u32 value; 3193 u32 value;
3192 struct ql_tx_buf_cb *tx_cb; 3194 struct ql_tx_buf_cb *tx_cb;
@@ -3278,9 +3280,12 @@ static void ql_reset_work(struct ql3_adapter *qdev)
3278 } 3280 }
3279} 3281}
3280 3282
3281static void ql_tx_timeout_work(struct ql3_adapter *qdev) 3283static void ql_tx_timeout_work(struct work_struct *work)
3282{ 3284{
3283 ql_cycle_adapter(qdev,QL_DO_RESET); 3285 struct ql3_adapter *qdev =
3286 container_of(work, struct ql3_adapter, tx_timeout_work.work);
3287
3288 ql_cycle_adapter(qdev, QL_DO_RESET);
3284} 3289}
3285 3290
3286static void ql_get_board_info(struct ql3_adapter *qdev) 3291static void ql_get_board_info(struct ql3_adapter *qdev)
@@ -3459,9 +3464,8 @@ static int __devinit ql3xxx_probe(struct pci_dev *pdev,
3459 netif_stop_queue(ndev); 3464 netif_stop_queue(ndev);
3460 3465
3461 qdev->workqueue = create_singlethread_workqueue(ndev->name); 3466 qdev->workqueue = create_singlethread_workqueue(ndev->name);
3462 INIT_WORK(&qdev->reset_work, (void (*)(void *))ql_reset_work, qdev); 3467 INIT_DELAYED_WORK(&qdev->reset_work, ql_reset_work);
3463 INIT_WORK(&qdev->tx_timeout_work, 3468 INIT_DELAYED_WORK(&qdev->tx_timeout_work, ql_tx_timeout_work);
3464 (void (*)(void *))ql_tx_timeout_work, qdev);
3465 3469
3466 init_timer(&qdev->adapter_timer); 3470 init_timer(&qdev->adapter_timer);
3467 qdev->adapter_timer.function = ql3xxx_timer; 3471 qdev->adapter_timer.function = ql3xxx_timer;
diff --git a/drivers/net/qla3xxx.h b/drivers/net/qla3xxx.h
index 65da2c0bfda6..ea94de7fd071 100644
--- a/drivers/net/qla3xxx.h
+++ b/drivers/net/qla3xxx.h
@@ -1186,8 +1186,8 @@ struct ql3_adapter {
1186 u32 numPorts; 1186 u32 numPorts;
1187 struct net_device_stats stats; 1187 struct net_device_stats stats;
1188 struct workqueue_struct *workqueue; 1188 struct workqueue_struct *workqueue;
1189 struct work_struct reset_work; 1189 struct delayed_work reset_work;
1190 struct work_struct tx_timeout_work; 1190 struct delayed_work tx_timeout_work;
1191 u32 max_frame_size; 1191 u32 max_frame_size;
1192}; 1192};
1193 1193
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 45d3ca431957..85a392fab5cc 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -424,6 +424,7 @@ struct ring_info {
424struct rtl8169_private { 424struct rtl8169_private {
425 void __iomem *mmio_addr; /* memory map physical address */ 425 void __iomem *mmio_addr; /* memory map physical address */
426 struct pci_dev *pci_dev; /* Index of PCI device */ 426 struct pci_dev *pci_dev; /* Index of PCI device */
427 struct net_device *dev;
427 struct net_device_stats stats; /* statistics of net device */ 428 struct net_device_stats stats; /* statistics of net device */
428 spinlock_t lock; /* spin lock flag */ 429 spinlock_t lock; /* spin lock flag */
429 u32 msg_enable; 430 u32 msg_enable;
@@ -455,7 +456,7 @@ struct rtl8169_private {
455 void (*phy_reset_enable)(void __iomem *); 456 void (*phy_reset_enable)(void __iomem *);
456 unsigned int (*phy_reset_pending)(void __iomem *); 457 unsigned int (*phy_reset_pending)(void __iomem *);
457 unsigned int (*link_ok)(void __iomem *); 458 unsigned int (*link_ok)(void __iomem *);
458 struct work_struct task; 459 struct delayed_work task;
459 unsigned wol_enabled : 1; 460 unsigned wol_enabled : 1;
460}; 461};
461 462
@@ -1510,6 +1511,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1510 SET_MODULE_OWNER(dev); 1511 SET_MODULE_OWNER(dev);
1511 SET_NETDEV_DEV(dev, &pdev->dev); 1512 SET_NETDEV_DEV(dev, &pdev->dev);
1512 tp = netdev_priv(dev); 1513 tp = netdev_priv(dev);
1514 tp->dev = dev;
1513 tp->msg_enable = netif_msg_init(debug.msg_enable, R8169_MSG_DEFAULT); 1515 tp->msg_enable = netif_msg_init(debug.msg_enable, R8169_MSG_DEFAULT);
1514 1516
1515 /* enable device (incl. PCI PM wakeup and hotplug setup) */ 1517 /* enable device (incl. PCI PM wakeup and hotplug setup) */
@@ -1782,7 +1784,7 @@ static int rtl8169_open(struct net_device *dev)
1782 if (retval < 0) 1784 if (retval < 0)
1783 goto err_free_rx; 1785 goto err_free_rx;
1784 1786
1785 INIT_WORK(&tp->task, NULL, dev); 1787 INIT_DELAYED_WORK(&tp->task, NULL);
1786 1788
1787 rtl8169_hw_start(dev); 1789 rtl8169_hw_start(dev);
1788 1790
@@ -2105,11 +2107,11 @@ static void rtl8169_tx_clear(struct rtl8169_private *tp)
2105 tp->cur_tx = tp->dirty_tx = 0; 2107 tp->cur_tx = tp->dirty_tx = 0;
2106} 2108}
2107 2109
2108static void rtl8169_schedule_work(struct net_device *dev, void (*task)(void *)) 2110static void rtl8169_schedule_work(struct net_device *dev, work_func_t task)
2109{ 2111{
2110 struct rtl8169_private *tp = netdev_priv(dev); 2112 struct rtl8169_private *tp = netdev_priv(dev);
2111 2113
2112 PREPARE_WORK(&tp->task, task, dev); 2114 PREPARE_DELAYED_WORK(&tp->task, task);
2113 schedule_delayed_work(&tp->task, 4); 2115 schedule_delayed_work(&tp->task, 4);
2114} 2116}
2115 2117
@@ -2128,9 +2130,11 @@ static void rtl8169_wait_for_quiescence(struct net_device *dev)
2128 netif_poll_enable(dev); 2130 netif_poll_enable(dev);
2129} 2131}
2130 2132
2131static void rtl8169_reinit_task(void *_data) 2133static void rtl8169_reinit_task(struct work_struct *work)
2132{ 2134{
2133 struct net_device *dev = _data; 2135 struct rtl8169_private *tp =
2136 container_of(work, struct rtl8169_private, task.work);
2137 struct net_device *dev = tp->dev;
2134 int ret; 2138 int ret;
2135 2139
2136 if (netif_running(dev)) { 2140 if (netif_running(dev)) {
@@ -2153,10 +2157,11 @@ static void rtl8169_reinit_task(void *_data)
2153 } 2157 }
2154} 2158}
2155 2159
2156static void rtl8169_reset_task(void *_data) 2160static void rtl8169_reset_task(struct work_struct *work)
2157{ 2161{
2158 struct net_device *dev = _data; 2162 struct rtl8169_private *tp =
2159 struct rtl8169_private *tp = netdev_priv(dev); 2163 container_of(work, struct rtl8169_private, task.work);
2164 struct net_device *dev = tp->dev;
2160 2165
2161 if (!netif_running(dev)) 2166 if (!netif_running(dev))
2162 return; 2167 return;
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 33569ec9dbfc..250cdbeefdfd 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -5872,9 +5872,9 @@ static void s2io_tasklet(unsigned long dev_addr)
5872 * Description: Sets the link status for the adapter 5872 * Description: Sets the link status for the adapter
5873 */ 5873 */
5874 5874
5875static void s2io_set_link(unsigned long data) 5875static void s2io_set_link(struct work_struct *work)
5876{ 5876{
5877 nic_t *nic = (nic_t *) data; 5877 nic_t *nic = container_of(work, nic_t, set_link_task);
5878 struct net_device *dev = nic->dev; 5878 struct net_device *dev = nic->dev;
5879 XENA_dev_config_t __iomem *bar0 = nic->bar0; 5879 XENA_dev_config_t __iomem *bar0 = nic->bar0;
5880 register u64 val64; 5880 register u64 val64;
@@ -6379,10 +6379,10 @@ static int s2io_card_up(nic_t * sp)
6379 * spin lock. 6379 * spin lock.
6380 */ 6380 */
6381 6381
6382static void s2io_restart_nic(unsigned long data) 6382static void s2io_restart_nic(struct work_struct *work)
6383{ 6383{
6384 struct net_device *dev = (struct net_device *) data; 6384 nic_t *sp = container_of(work, nic_t, rst_timer_task);
6385 nic_t *sp = dev->priv; 6385 struct net_device *dev = sp->dev;
6386 6386
6387 s2io_card_down(sp); 6387 s2io_card_down(sp);
6388 if (s2io_card_up(sp)) { 6388 if (s2io_card_up(sp)) {
@@ -6992,10 +6992,8 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
6992 6992
6993 dev->tx_timeout = &s2io_tx_watchdog; 6993 dev->tx_timeout = &s2io_tx_watchdog;
6994 dev->watchdog_timeo = WATCH_DOG_TIMEOUT; 6994 dev->watchdog_timeo = WATCH_DOG_TIMEOUT;
6995 INIT_WORK(&sp->rst_timer_task, 6995 INIT_WORK(&sp->rst_timer_task, s2io_restart_nic);
6996 (void (*)(void *)) s2io_restart_nic, dev); 6996 INIT_WORK(&sp->set_link_task, s2io_set_link);
6997 INIT_WORK(&sp->set_link_task,
6998 (void (*)(void *)) s2io_set_link, sp);
6999 6997
7000 pci_save_state(sp->pdev); 6998 pci_save_state(sp->pdev);
7001 6999
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h
index 12b719f4d00f..3b0bafd273c8 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -1000,7 +1000,7 @@ s2io_msix_fifo_handle(int irq, void *dev_id);
1000static irqreturn_t s2io_isr(int irq, void *dev_id); 1000static irqreturn_t s2io_isr(int irq, void *dev_id);
1001static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag); 1001static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag);
1002static const struct ethtool_ops netdev_ethtool_ops; 1002static const struct ethtool_ops netdev_ethtool_ops;
1003static void s2io_set_link(unsigned long data); 1003static void s2io_set_link(struct work_struct *work);
1004static int s2io_set_swapper(nic_t * sp); 1004static int s2io_set_swapper(nic_t * sp);
1005static void s2io_card_down(nic_t *nic); 1005static void s2io_card_down(nic_t *nic);
1006static int s2io_card_up(nic_t *nic); 1006static int s2io_card_up(nic_t *nic);
diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
index aaba458584fb..b70ed79d4121 100644
--- a/drivers/net/sis190.c
+++ b/drivers/net/sis190.c
@@ -280,6 +280,7 @@ enum sis190_feature {
280struct sis190_private { 280struct sis190_private {
281 void __iomem *mmio_addr; 281 void __iomem *mmio_addr;
282 struct pci_dev *pci_dev; 282 struct pci_dev *pci_dev;
283 struct net_device *dev;
283 struct net_device_stats stats; 284 struct net_device_stats stats;
284 spinlock_t lock; 285 spinlock_t lock;
285 u32 rx_buf_sz; 286 u32 rx_buf_sz;
@@ -897,10 +898,11 @@ static void sis190_hw_start(struct net_device *dev)
897 netif_start_queue(dev); 898 netif_start_queue(dev);
898} 899}
899 900
900static void sis190_phy_task(void * data) 901static void sis190_phy_task(struct work_struct *work)
901{ 902{
902 struct net_device *dev = data; 903 struct sis190_private *tp =
903 struct sis190_private *tp = netdev_priv(dev); 904 container_of(work, struct sis190_private, phy_task);
905 struct net_device *dev = tp->dev;
904 void __iomem *ioaddr = tp->mmio_addr; 906 void __iomem *ioaddr = tp->mmio_addr;
905 int phy_id = tp->mii_if.phy_id; 907 int phy_id = tp->mii_if.phy_id;
906 u16 val; 908 u16 val;
@@ -1047,7 +1049,7 @@ static int sis190_open(struct net_device *dev)
1047 if (rc < 0) 1049 if (rc < 0)
1048 goto err_free_rx_1; 1050 goto err_free_rx_1;
1049 1051
1050 INIT_WORK(&tp->phy_task, sis190_phy_task, dev); 1052 INIT_WORK(&tp->phy_task, sis190_phy_task);
1051 1053
1052 sis190_request_timer(dev); 1054 sis190_request_timer(dev);
1053 1055
@@ -1436,6 +1438,7 @@ static struct net_device * __devinit sis190_init_board(struct pci_dev *pdev)
1436 SET_NETDEV_DEV(dev, &pdev->dev); 1438 SET_NETDEV_DEV(dev, &pdev->dev);
1437 1439
1438 tp = netdev_priv(dev); 1440 tp = netdev_priv(dev);
1441 tp->dev = dev;
1439 tp->msg_enable = netif_msg_init(debug.msg_enable, SIS190_MSG_DEFAULT); 1442 tp->msg_enable = netif_msg_init(debug.msg_enable, SIS190_MSG_DEFAULT);
1440 1443
1441 rc = pci_enable_device(pdev); 1444 rc = pci_enable_device(pdev);
@@ -1798,7 +1801,7 @@ static int __devinit sis190_init_one(struct pci_dev *pdev,
1798 1801
1799 sis190_init_rxfilter(dev); 1802 sis190_init_rxfilter(dev);
1800 1803
1801 INIT_WORK(&tp->phy_task, sis190_phy_task, dev); 1804 INIT_WORK(&tp->phy_task, sis190_phy_task);
1802 1805
1803 dev->open = sis190_open; 1806 dev->open = sis190_open;
1804 dev->stop = sis190_close; 1807 dev->stop = sis190_close;
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 5513907e8393..b60f0451f6cd 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -1327,10 +1327,11 @@ static void xm_check_link(struct net_device *dev)
1327 * Since internal PHY is wired to a level triggered pin, can't 1327 * Since internal PHY is wired to a level triggered pin, can't
1328 * get an interrupt when carrier is detected. 1328 * get an interrupt when carrier is detected.
1329 */ 1329 */
1330static void xm_link_timer(void *arg) 1330static void xm_link_timer(struct work_struct *work)
1331{ 1331{
1332 struct net_device *dev = arg; 1332 struct skge_port *skge =
1333 struct skge_port *skge = netdev_priv(arg); 1333 container_of(work, struct skge_port, link_thread.work);
1334 struct net_device *dev = skge->netdev;
1334 struct skge_hw *hw = skge->hw; 1335 struct skge_hw *hw = skge->hw;
1335 int port = skge->port; 1336 int port = skge->port;
1336 1337
@@ -3072,9 +3073,9 @@ static void skge_error_irq(struct skge_hw *hw)
3072 * because accessing phy registers requires spin wait which might 3073 * because accessing phy registers requires spin wait which might
3073 * cause excess interrupt latency. 3074 * cause excess interrupt latency.
3074 */ 3075 */
3075static void skge_extirq(void *arg) 3076static void skge_extirq(struct work_struct *work)
3076{ 3077{
3077 struct skge_hw *hw = arg; 3078 struct skge_hw *hw = container_of(work, struct skge_hw, phy_work);
3078 int port; 3079 int port;
3079 3080
3080 mutex_lock(&hw->phy_mutex); 3081 mutex_lock(&hw->phy_mutex);
@@ -3456,7 +3457,7 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
3456 skge->port = port; 3457 skge->port = port;
3457 3458
3458 /* Only used for Genesis XMAC */ 3459 /* Only used for Genesis XMAC */
3459 INIT_WORK(&skge->link_thread, xm_link_timer, dev); 3460 INIT_DELAYED_WORK(&skge->link_thread, xm_link_timer);
3460 3461
3461 if (hw->chip_id != CHIP_ID_GENESIS) { 3462 if (hw->chip_id != CHIP_ID_GENESIS) {
3462 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; 3463 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
@@ -3543,7 +3544,7 @@ static int __devinit skge_probe(struct pci_dev *pdev,
3543 3544
3544 hw->pdev = pdev; 3545 hw->pdev = pdev;
3545 mutex_init(&hw->phy_mutex); 3546 mutex_init(&hw->phy_mutex);
3546 INIT_WORK(&hw->phy_work, skge_extirq, hw); 3547 INIT_WORK(&hw->phy_work, skge_extirq);
3547 spin_lock_init(&hw->hw_lock); 3548 spin_lock_init(&hw->hw_lock);
3548 3549
3549 hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000); 3550 hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000);
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index 537c0aaa1db8..23e5275d920c 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -2456,7 +2456,7 @@ struct skge_port {
2456 2456
2457 struct net_device_stats net_stats; 2457 struct net_device_stats net_stats;
2458 2458
2459 struct work_struct link_thread; 2459 struct delayed_work link_thread;
2460 enum pause_control flow_control; 2460 enum pause_control flow_control;
2461 enum pause_status flow_status; 2461 enum pause_status flow_status;
2462 u8 rx_csum; 2462 u8 rx_csum;
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index 95b6478f55c6..e62a9586fb95 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -210,6 +210,7 @@ struct smc_local {
210 210
211 /* work queue */ 211 /* work queue */
212 struct work_struct phy_configure; 212 struct work_struct phy_configure;
213 struct net_device *dev;
213 int work_pending; 214 int work_pending;
214 215
215 spinlock_t lock; 216 spinlock_t lock;
@@ -1114,10 +1115,11 @@ static void smc_phy_check_media(struct net_device *dev, int init)
1114 * of autonegotiation.) If the RPC ANEG bit is cleared, the selection 1115 * of autonegotiation.) If the RPC ANEG bit is cleared, the selection
1115 * is controlled by the RPC SPEED and RPC DPLX bits. 1116 * is controlled by the RPC SPEED and RPC DPLX bits.
1116 */ 1117 */
1117static void smc_phy_configure(void *data) 1118static void smc_phy_configure(struct work_struct *work)
1118{ 1119{
1119 struct net_device *dev = data; 1120 struct smc_local *lp =
1120 struct smc_local *lp = netdev_priv(dev); 1121 container_of(work, struct smc_local, phy_configure);
1122 struct net_device *dev = lp->dev;
1121 void __iomem *ioaddr = lp->base; 1123 void __iomem *ioaddr = lp->base;
1122 int phyaddr = lp->mii.phy_id; 1124 int phyaddr = lp->mii.phy_id;
1123 int my_phy_caps; /* My PHY capabilities */ 1125 int my_phy_caps; /* My PHY capabilities */
@@ -1592,7 +1594,7 @@ smc_open(struct net_device *dev)
1592 1594
1593 /* Configure the PHY, initialize the link state */ 1595 /* Configure the PHY, initialize the link state */
1594 if (lp->phy_type != 0) 1596 if (lp->phy_type != 0)
1595 smc_phy_configure(dev); 1597 smc_phy_configure(&lp->phy_configure);
1596 else { 1598 else {
1597 spin_lock_irq(&lp->lock); 1599 spin_lock_irq(&lp->lock);
1598 smc_10bt_check_media(dev, 1); 1600 smc_10bt_check_media(dev, 1);
@@ -1972,7 +1974,8 @@ static int __init smc_probe(struct net_device *dev, void __iomem *ioaddr)
1972#endif 1974#endif
1973 1975
1974 tasklet_init(&lp->tx_task, smc_hardware_send_pkt, (unsigned long)dev); 1976 tasklet_init(&lp->tx_task, smc_hardware_send_pkt, (unsigned long)dev);
1975 INIT_WORK(&lp->phy_configure, smc_phy_configure, dev); 1977 INIT_WORK(&lp->phy_configure, smc_phy_configure);
1978 lp->dev = dev;
1976 lp->mii.phy_id_mask = 0x1f; 1979 lp->mii.phy_id_mask = 0x1f;
1977 lp->mii.reg_num_mask = 0x1f; 1980 lp->mii.reg_num_mask = 0x1f;
1978 lp->mii.force_media = 0; 1981 lp->mii.force_media = 0;
@@ -2322,7 +2325,7 @@ static int smc_drv_resume(struct platform_device *dev)
2322 smc_reset(ndev); 2325 smc_reset(ndev);
2323 smc_enable(ndev); 2326 smc_enable(ndev);
2324 if (lp->phy_type != 0) 2327 if (lp->phy_type != 0)
2325 smc_phy_configure(ndev); 2328 smc_phy_configure(&lp->phy_configure);
2326 netif_device_attach(ndev); 2329 netif_device_attach(ndev);
2327 } 2330 }
2328 } 2331 }
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index 13e0a43e423b..ebb6aa39f9c7 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -1939,10 +1939,11 @@ spider_net_stop(struct net_device *netdev)
1939 * called as task when tx hangs, resets interface (if interface is up) 1939 * called as task when tx hangs, resets interface (if interface is up)
1940 */ 1940 */
1941static void 1941static void
1942spider_net_tx_timeout_task(void *data) 1942spider_net_tx_timeout_task(struct work_struct *work)
1943{ 1943{
1944 struct net_device *netdev = data; 1944 struct spider_net_card *card =
1945 struct spider_net_card *card = netdev_priv(netdev); 1945 container_of(work, struct spider_net_card, tx_timeout_task);
1946 struct net_device *netdev = card->netdev;
1946 1947
1947 if (!(netdev->flags & IFF_UP)) 1948 if (!(netdev->flags & IFF_UP))
1948 goto out; 1949 goto out;
@@ -2116,7 +2117,7 @@ spider_net_alloc_card(void)
2116 card = netdev_priv(netdev); 2117 card = netdev_priv(netdev);
2117 card->netdev = netdev; 2118 card->netdev = netdev;
2118 card->msg_enable = SPIDER_NET_DEFAULT_MSG; 2119 card->msg_enable = SPIDER_NET_DEFAULT_MSG;
2119 INIT_WORK(&card->tx_timeout_task, spider_net_tx_timeout_task, netdev); 2120 INIT_WORK(&card->tx_timeout_task, spider_net_tx_timeout_task);
2120 init_waitqueue_head(&card->waitq); 2121 init_waitqueue_head(&card->waitq);
2121 atomic_set(&card->tx_timeout_task_counter, 0); 2122 atomic_set(&card->tx_timeout_task_counter, 0);
2122 2123
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index cf44e72399b9..785e4a535f9e 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -2282,9 +2282,9 @@ static void gem_do_stop(struct net_device *dev, int wol)
2282 } 2282 }
2283} 2283}
2284 2284
2285static void gem_reset_task(void *data) 2285static void gem_reset_task(struct work_struct *work)
2286{ 2286{
2287 struct gem *gp = (struct gem *) data; 2287 struct gem *gp = container_of(work, struct gem, reset_task);
2288 2288
2289 mutex_lock(&gp->pm_mutex); 2289 mutex_lock(&gp->pm_mutex);
2290 2290
@@ -3044,7 +3044,7 @@ static int __devinit gem_init_one(struct pci_dev *pdev,
3044 gp->link_timer.function = gem_link_timer; 3044 gp->link_timer.function = gem_link_timer;
3045 gp->link_timer.data = (unsigned long) gp; 3045 gp->link_timer.data = (unsigned long) gp;
3046 3046
3047 INIT_WORK(&gp->reset_task, gem_reset_task, gp); 3047 INIT_WORK(&gp->reset_task, gem_reset_task);
3048 3048
3049 gp->lstate = link_down; 3049 gp->lstate = link_down;
3050 gp->timer_ticks = 0; 3050 gp->timer_ticks = 0;
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index c20bb998e0e5..d9123c9adc1e 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -3654,9 +3654,9 @@ static void tg3_poll_controller(struct net_device *dev)
3654} 3654}
3655#endif 3655#endif
3656 3656
3657static void tg3_reset_task(void *_data) 3657static void tg3_reset_task(struct work_struct *work)
3658{ 3658{
3659 struct tg3 *tp = _data; 3659 struct tg3 *tp = container_of(work, struct tg3, reset_task);
3660 unsigned int restart_timer; 3660 unsigned int restart_timer;
3661 3661
3662 tg3_full_lock(tp, 0); 3662 tg3_full_lock(tp, 0);
@@ -11734,7 +11734,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
11734#endif 11734#endif
11735 spin_lock_init(&tp->lock); 11735 spin_lock_init(&tp->lock);
11736 spin_lock_init(&tp->indirect_lock); 11736 spin_lock_init(&tp->indirect_lock);
11737 INIT_WORK(&tp->reset_task, tg3_reset_task, tp); 11737 INIT_WORK(&tp->reset_task, tg3_reset_task);
11738 11738
11739 tp->regs = ioremap_nocache(tg3reg_base, tg3reg_len); 11739 tp->regs = ioremap_nocache(tg3reg_base, tg3reg_len);
11740 if (tp->regs == 0UL) { 11740 if (tp->regs == 0UL) {
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c
index e14f5a00f65a..f85f00251123 100644
--- a/drivers/net/tlan.c
+++ b/drivers/net/tlan.c
@@ -296,6 +296,7 @@ static void TLan_SetMulticastList( struct net_device *);
296static int TLan_ioctl( struct net_device *dev, struct ifreq *rq, int cmd); 296static int TLan_ioctl( struct net_device *dev, struct ifreq *rq, int cmd);
297static int TLan_probe1( struct pci_dev *pdev, long ioaddr, int irq, int rev, const struct pci_device_id *ent); 297static int TLan_probe1( struct pci_dev *pdev, long ioaddr, int irq, int rev, const struct pci_device_id *ent);
298static void TLan_tx_timeout( struct net_device *dev); 298static void TLan_tx_timeout( struct net_device *dev);
299static void TLan_tx_timeout_work(struct work_struct *work);
299static int tlan_init_one( struct pci_dev *pdev, const struct pci_device_id *ent); 300static int tlan_init_one( struct pci_dev *pdev, const struct pci_device_id *ent);
300 301
301static u32 TLan_HandleInvalid( struct net_device *, u16 ); 302static u32 TLan_HandleInvalid( struct net_device *, u16 );
@@ -562,6 +563,7 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
562 priv = netdev_priv(dev); 563 priv = netdev_priv(dev);
563 564
564 priv->pciDev = pdev; 565 priv->pciDev = pdev;
566 priv->dev = dev;
565 567
566 /* Is this a PCI device? */ 568 /* Is this a PCI device? */
567 if (pdev) { 569 if (pdev) {
@@ -634,7 +636,7 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
634 636
635 /* This will be used when we get an adapter error from 637 /* This will be used when we get an adapter error from
636 * within our irq handler */ 638 * within our irq handler */
637 INIT_WORK(&priv->tlan_tqueue, (void *)(void*)TLan_tx_timeout, dev); 639 INIT_WORK(&priv->tlan_tqueue, TLan_tx_timeout_work);
638 640
639 spin_lock_init(&priv->lock); 641 spin_lock_init(&priv->lock);
640 642
@@ -1040,6 +1042,25 @@ static void TLan_tx_timeout(struct net_device *dev)
1040} 1042}
1041 1043
1042 1044
1045 /***************************************************************
1046 * TLan_tx_timeout_work
1047 *
1048 * Returns: nothing
1049 *
1050 * Params:
1051 * work work item of device which timed out
1052 *
1053 **************************************************************/
1054
1055static void TLan_tx_timeout_work(struct work_struct *work)
1056{
1057 TLanPrivateInfo *priv =
1058 container_of(work, TLanPrivateInfo, tlan_tqueue);
1059
1060 TLan_tx_timeout(priv->dev);
1061}
1062
1063
1043 1064
1044 /*************************************************************** 1065 /***************************************************************
1045 * TLan_StartTx 1066 * TLan_StartTx
diff --git a/drivers/net/tlan.h b/drivers/net/tlan.h
index a44e2f2ef62a..41ce0b665937 100644
--- a/drivers/net/tlan.h
+++ b/drivers/net/tlan.h
@@ -170,6 +170,7 @@ typedef u8 TLanBuffer[TLAN_MAX_FRAME_SIZE];
170typedef struct tlan_private_tag { 170typedef struct tlan_private_tag {
171 struct net_device *nextDevice; 171 struct net_device *nextDevice;
172 struct pci_dev *pciDev; 172 struct pci_dev *pciDev;
173 struct net_device *dev;
173 void *dmaStorage; 174 void *dmaStorage;
174 dma_addr_t dmaStorageDMA; 175 dma_addr_t dmaStorageDMA;
175 unsigned int dmaSize; 176 unsigned int dmaSize;
diff --git a/drivers/net/tulip/21142.c b/drivers/net/tulip/21142.c
index fa3a2bb105ad..942b839ccc5b 100644
--- a/drivers/net/tulip/21142.c
+++ b/drivers/net/tulip/21142.c
@@ -26,10 +26,11 @@ static u16 t21142_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, };
26 26
27/* Handle the 21143 uniquely: do autoselect with NWay, not the EEPROM list 27/* Handle the 21143 uniquely: do autoselect with NWay, not the EEPROM list
28 of available transceivers. */ 28 of available transceivers. */
29void t21142_media_task(void *data) 29void t21142_media_task(struct work_struct *work)
30{ 30{
31 struct net_device *dev = data; 31 struct tulip_private *tp =
32 struct tulip_private *tp = netdev_priv(dev); 32 container_of(work, struct tulip_private, media_work);
33 struct net_device *dev = tp->dev;
33 void __iomem *ioaddr = tp->base_addr; 34 void __iomem *ioaddr = tp->base_addr;
34 int csr12 = ioread32(ioaddr + CSR12); 35 int csr12 = ioread32(ioaddr + CSR12);
35 int next_tick = 60*HZ; 36 int next_tick = 60*HZ;
diff --git a/drivers/net/tulip/timer.c b/drivers/net/tulip/timer.c
index 066e5d6bcbd8..df326fe1cc8f 100644
--- a/drivers/net/tulip/timer.c
+++ b/drivers/net/tulip/timer.c
@@ -18,10 +18,11 @@
18#include "tulip.h" 18#include "tulip.h"
19 19
20 20
21void tulip_media_task(void *data) 21void tulip_media_task(struct work_struct *work)
22{ 22{
23 struct net_device *dev = data; 23 struct tulip_private *tp =
24 struct tulip_private *tp = netdev_priv(dev); 24 container_of(work, struct tulip_private, media_work);
25 struct net_device *dev = tp->dev;
25 void __iomem *ioaddr = tp->base_addr; 26 void __iomem *ioaddr = tp->base_addr;
26 u32 csr12 = ioread32(ioaddr + CSR12); 27 u32 csr12 = ioread32(ioaddr + CSR12);
27 int next_tick = 2*HZ; 28 int next_tick = 2*HZ;
diff --git a/drivers/net/tulip/tulip.h b/drivers/net/tulip/tulip.h
index ad107f45c7b1..25f25da76917 100644
--- a/drivers/net/tulip/tulip.h
+++ b/drivers/net/tulip/tulip.h
@@ -44,7 +44,7 @@ struct tulip_chip_table {
44 int valid_intrs; /* CSR7 interrupt enable settings */ 44 int valid_intrs; /* CSR7 interrupt enable settings */
45 int flags; 45 int flags;
46 void (*media_timer) (unsigned long); 46 void (*media_timer) (unsigned long);
47 void (*media_task) (void *); 47 work_func_t media_task;
48}; 48};
49 49
50 50
@@ -392,6 +392,7 @@ struct tulip_private {
392 int csr12_shadow; 392 int csr12_shadow;
393 int pad0; /* Used for 8-byte alignment */ 393 int pad0; /* Used for 8-byte alignment */
394 struct work_struct media_work; 394 struct work_struct media_work;
395 struct net_device *dev;
395}; 396};
396 397
397 398
@@ -406,7 +407,7 @@ struct eeprom_fixup {
406 407
407/* 21142.c */ 408/* 21142.c */
408extern u16 t21142_csr14[]; 409extern u16 t21142_csr14[];
409void t21142_media_task(void *data); 410void t21142_media_task(struct work_struct *work);
410void t21142_start_nway(struct net_device *dev); 411void t21142_start_nway(struct net_device *dev);
411void t21142_lnk_change(struct net_device *dev, int csr5); 412void t21142_lnk_change(struct net_device *dev, int csr5);
412 413
@@ -444,7 +445,7 @@ void pnic_lnk_change(struct net_device *dev, int csr5);
444void pnic_timer(unsigned long data); 445void pnic_timer(unsigned long data);
445 446
446/* timer.c */ 447/* timer.c */
447void tulip_media_task(void *data); 448void tulip_media_task(struct work_struct *work);
448void mxic_timer(unsigned long data); 449void mxic_timer(unsigned long data);
449void comet_timer(unsigned long data); 450void comet_timer(unsigned long data);
450 451
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index 0aee618f883c..5a35354aa523 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -1367,6 +1367,7 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1367 * it is zeroed and aligned in alloc_etherdev 1367 * it is zeroed and aligned in alloc_etherdev
1368 */ 1368 */
1369 tp = netdev_priv(dev); 1369 tp = netdev_priv(dev);
1370 tp->dev = dev;
1370 1371
1371 tp->rx_ring = pci_alloc_consistent(pdev, 1372 tp->rx_ring = pci_alloc_consistent(pdev,
1372 sizeof(struct tulip_rx_desc) * RX_RING_SIZE + 1373 sizeof(struct tulip_rx_desc) * RX_RING_SIZE +
@@ -1389,7 +1390,7 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1389 tp->timer.data = (unsigned long)dev; 1390 tp->timer.data = (unsigned long)dev;
1390 tp->timer.function = tulip_tbl[tp->chip_id].media_timer; 1391 tp->timer.function = tulip_tbl[tp->chip_id].media_timer;
1391 1392
1392 INIT_WORK(&tp->media_work, tulip_tbl[tp->chip_id].media_task, dev); 1393 INIT_WORK(&tp->media_work, tulip_tbl[tp->chip_id].media_task);
1393 1394
1394 dev->base_addr = (unsigned long)ioaddr; 1395 dev->base_addr = (unsigned long)ioaddr;
1395 1396
diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c
index 931cbdf6d791..b2a23aed4428 100644
--- a/drivers/net/wan/pc300_tty.c
+++ b/drivers/net/wan/pc300_tty.c
@@ -125,8 +125,8 @@ static int cpc_tty_write_room(struct tty_struct *tty);
125static int cpc_tty_chars_in_buffer(struct tty_struct *tty); 125static int cpc_tty_chars_in_buffer(struct tty_struct *tty);
126static void cpc_tty_flush_buffer(struct tty_struct *tty); 126static void cpc_tty_flush_buffer(struct tty_struct *tty);
127static void cpc_tty_hangup(struct tty_struct *tty); 127static void cpc_tty_hangup(struct tty_struct *tty);
128static void cpc_tty_rx_work(void *data); 128static void cpc_tty_rx_work(struct work_struct *work);
129static void cpc_tty_tx_work(void *data); 129static void cpc_tty_tx_work(struct work_struct *work);
130static int cpc_tty_send_to_card(pc300dev_t *dev,void *buf, int len); 130static int cpc_tty_send_to_card(pc300dev_t *dev,void *buf, int len);
131static void cpc_tty_trace(pc300dev_t *dev, char* buf, int len, char rxtx); 131static void cpc_tty_trace(pc300dev_t *dev, char* buf, int len, char rxtx);
132static void cpc_tty_signal_off(pc300dev_t *pc300dev, unsigned char); 132static void cpc_tty_signal_off(pc300dev_t *pc300dev, unsigned char);
@@ -261,8 +261,8 @@ void cpc_tty_init(pc300dev_t *pc300dev)
261 cpc_tty->tty_minor = port + CPC_TTY_MINOR_START; 261 cpc_tty->tty_minor = port + CPC_TTY_MINOR_START;
262 cpc_tty->pc300dev = pc300dev; 262 cpc_tty->pc300dev = pc300dev;
263 263
264 INIT_WORK(&cpc_tty->tty_tx_work, cpc_tty_tx_work, (void *)cpc_tty); 264 INIT_WORK(&cpc_tty->tty_tx_work, cpc_tty_tx_work);
265 INIT_WORK(&cpc_tty->tty_rx_work, cpc_tty_rx_work, (void *)port); 265 INIT_WORK(&cpc_tty->tty_rx_work, cpc_tty_rx_work);
266 266
267 cpc_tty->buf_rx.first = cpc_tty->buf_rx.last = NULL; 267 cpc_tty->buf_rx.first = cpc_tty->buf_rx.last = NULL;
268 268
@@ -659,21 +659,23 @@ static void cpc_tty_hangup(struct tty_struct *tty)
659 * o call the line disc. read 659 * o call the line disc. read
660 * o free memory 660 * o free memory
661 */ 661 */
662static void cpc_tty_rx_work(void * data) 662static void cpc_tty_rx_work(struct work_struct *work)
663{ 663{
664 st_cpc_tty_area *cpc_tty;
664 unsigned long port; 665 unsigned long port;
665 int i, j; 666 int i, j;
666 st_cpc_tty_area *cpc_tty;
667 volatile st_cpc_rx_buf *buf; 667 volatile st_cpc_rx_buf *buf;
668 char flags=0,flg_rx=1; 668 char flags=0,flg_rx=1;
669 struct tty_ldisc *ld; 669 struct tty_ldisc *ld;
670 670
671 if (cpc_tty_cnt == 0) return; 671 if (cpc_tty_cnt == 0) return;
672
673 672
674 for (i=0; (i < 4) && flg_rx ; i++) { 673 for (i=0; (i < 4) && flg_rx ; i++) {
675 flg_rx = 0; 674 flg_rx = 0;
676 port = (unsigned long)data; 675
676 cpc_tty = container_of(work, st_cpc_tty_area, tty_rx_work);
677 port = cpc_tty - cpc_tty_area;
678
677 for (j=0; j < CPC_TTY_NPORTS; j++) { 679 for (j=0; j < CPC_TTY_NPORTS; j++) {
678 cpc_tty = &cpc_tty_area[port]; 680 cpc_tty = &cpc_tty_area[port];
679 681
@@ -882,9 +884,10 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
882 * o if need call line discipline wakeup 884 * o if need call line discipline wakeup
883 * o call wake_up_interruptible 885 * o call wake_up_interruptible
884 */ 886 */
885static void cpc_tty_tx_work(void *data) 887static void cpc_tty_tx_work(struct work_struct *work)
886{ 888{
887 st_cpc_tty_area *cpc_tty = (st_cpc_tty_area *) data; 889 st_cpc_tty_area *cpc_tty =
890 container_of(work, st_cpc_tty_area, tty_tx_work);
888 struct tty_struct *tty; 891 struct tty_struct *tty;
889 892
890 CPC_TTY_DBG("%s: cpc_tty_tx_work init\n",cpc_tty->name); 893 CPC_TTY_DBG("%s: cpc_tty_tx_work init\n",cpc_tty->name);
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index efcdaf1c5f73..44a22701da97 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -49,6 +49,7 @@
49#include <asm/uaccess.h> 49#include <asm/uaccess.h>
50#include <net/ieee80211.h> 50#include <net/ieee80211.h>
51#include <linux/kthread.h> 51#include <linux/kthread.h>
52#include <linux/freezer.h>
52 53
53#include "airo.h" 54#include "airo.h"
54 55
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx.h b/drivers/net/wireless/bcm43xx/bcm43xx.h
index 94dfb92fab5c..8286678513b9 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx.h
@@ -819,7 +819,7 @@ struct bcm43xx_private {
819 struct tasklet_struct isr_tasklet; 819 struct tasklet_struct isr_tasklet;
820 820
821 /* Periodic tasks */ 821 /* Periodic tasks */
822 struct work_struct periodic_work; 822 struct delayed_work periodic_work;
823 unsigned int periodic_state; 823 unsigned int periodic_state;
824 824
825 struct work_struct restart_work; 825 struct work_struct restart_work;
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index 5b3c27359a18..2ec2e5afce67 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -3215,9 +3215,10 @@ static void do_periodic_work(struct bcm43xx_private *bcm)
3215 schedule_delayed_work(&bcm->periodic_work, HZ * 15); 3215 schedule_delayed_work(&bcm->periodic_work, HZ * 15);
3216} 3216}
3217 3217
3218static void bcm43xx_periodic_work_handler(void *d) 3218static void bcm43xx_periodic_work_handler(struct work_struct *work)
3219{ 3219{
3220 struct bcm43xx_private *bcm = d; 3220 struct bcm43xx_private *bcm =
3221 container_of(work, struct bcm43xx_private, periodic_work.work);
3221 struct net_device *net_dev = bcm->net_dev; 3222 struct net_device *net_dev = bcm->net_dev;
3222 unsigned long flags; 3223 unsigned long flags;
3223 u32 savedirqs = 0; 3224 u32 savedirqs = 0;
@@ -3279,11 +3280,11 @@ void bcm43xx_periodic_tasks_delete(struct bcm43xx_private *bcm)
3279 3280
3280void bcm43xx_periodic_tasks_setup(struct bcm43xx_private *bcm) 3281void bcm43xx_periodic_tasks_setup(struct bcm43xx_private *bcm)
3281{ 3282{
3282 struct work_struct *work = &(bcm->periodic_work); 3283 struct delayed_work *work = &bcm->periodic_work;
3283 3284
3284 assert(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED); 3285 assert(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED);
3285 INIT_WORK(work, bcm43xx_periodic_work_handler, bcm); 3286 INIT_DELAYED_WORK(work, bcm43xx_periodic_work_handler);
3286 schedule_work(work); 3287 schedule_delayed_work(work, 0);
3287} 3288}
3288 3289
3289static void bcm43xx_security_init(struct bcm43xx_private *bcm) 3290static void bcm43xx_security_init(struct bcm43xx_private *bcm)
@@ -3635,7 +3636,7 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm)
3635 bcm43xx_periodic_tasks_setup(bcm); 3636 bcm43xx_periodic_tasks_setup(bcm);
3636 3637
3637 /*FIXME: This should be handled by softmac instead. */ 3638 /*FIXME: This should be handled by softmac instead. */
3638 schedule_work(&bcm->softmac->associnfo.work); 3639 schedule_delayed_work(&bcm->softmac->associnfo.work, 0);
3639 3640
3640out: 3641out:
3641 mutex_unlock(&(bcm)->mutex); 3642 mutex_unlock(&(bcm)->mutex);
@@ -4182,9 +4183,10 @@ static void __devexit bcm43xx_remove_one(struct pci_dev *pdev)
4182/* Hard-reset the chip. Do not call this directly. 4183/* Hard-reset the chip. Do not call this directly.
4183 * Use bcm43xx_controller_restart() 4184 * Use bcm43xx_controller_restart()
4184 */ 4185 */
4185static void bcm43xx_chip_reset(void *_bcm) 4186static void bcm43xx_chip_reset(struct work_struct *work)
4186{ 4187{
4187 struct bcm43xx_private *bcm = _bcm; 4188 struct bcm43xx_private *bcm =
4189 container_of(work, struct bcm43xx_private, restart_work);
4188 struct bcm43xx_phyinfo *phy; 4190 struct bcm43xx_phyinfo *phy;
4189 int err = -ENODEV; 4191 int err = -ENODEV;
4190 4192
@@ -4211,7 +4213,7 @@ void bcm43xx_controller_restart(struct bcm43xx_private *bcm, const char *reason)
4211 if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) 4213 if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED)
4212 return; 4214 return;
4213 printk(KERN_ERR PFX "Controller RESET (%s) ...\n", reason); 4215 printk(KERN_ERR PFX "Controller RESET (%s) ...\n", reason);
4214 INIT_WORK(&bcm->restart_work, bcm43xx_chip_reset, bcm); 4216 INIT_WORK(&bcm->restart_work, bcm43xx_chip_reset);
4215 schedule_work(&bcm->restart_work); 4217 schedule_work(&bcm->restart_work);
4216} 4218}
4217 4219
diff --git a/drivers/net/wireless/hostap/hostap.h b/drivers/net/wireless/hostap/hostap.h
index e663518bd570..e89c890d16fd 100644
--- a/drivers/net/wireless/hostap/hostap.h
+++ b/drivers/net/wireless/hostap/hostap.h
@@ -35,7 +35,7 @@ int hostap_80211_get_hdrlen(u16 fc);
35struct net_device_stats *hostap_get_stats(struct net_device *dev); 35struct net_device_stats *hostap_get_stats(struct net_device *dev);
36void hostap_setup_dev(struct net_device *dev, local_info_t *local, 36void hostap_setup_dev(struct net_device *dev, local_info_t *local,
37 int main_dev); 37 int main_dev);
38void hostap_set_multicast_list_queue(void *data); 38void hostap_set_multicast_list_queue(struct work_struct *work);
39int hostap_set_hostapd(local_info_t *local, int val, int rtnl_locked); 39int hostap_set_hostapd(local_info_t *local, int val, int rtnl_locked);
40int hostap_set_hostapd_sta(local_info_t *local, int val, int rtnl_locked); 40int hostap_set_hostapd_sta(local_info_t *local, int val, int rtnl_locked);
41void hostap_cleanup(local_info_t *local); 41void hostap_cleanup(local_info_t *local);
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
index ba13125024cb..08bc57a4b895 100644
--- a/drivers/net/wireless/hostap/hostap_ap.c
+++ b/drivers/net/wireless/hostap/hostap_ap.c
@@ -49,10 +49,10 @@ MODULE_PARM_DESC(autom_ap_wds, "Add WDS connections to other APs "
49static struct sta_info* ap_get_sta(struct ap_data *ap, u8 *sta); 49static struct sta_info* ap_get_sta(struct ap_data *ap, u8 *sta);
50static void hostap_event_expired_sta(struct net_device *dev, 50static void hostap_event_expired_sta(struct net_device *dev,
51 struct sta_info *sta); 51 struct sta_info *sta);
52static void handle_add_proc_queue(void *data); 52static void handle_add_proc_queue(struct work_struct *work);
53 53
54#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT 54#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
55static void handle_wds_oper_queue(void *data); 55static void handle_wds_oper_queue(struct work_struct *work);
56static void prism2_send_mgmt(struct net_device *dev, 56static void prism2_send_mgmt(struct net_device *dev,
57 u16 type_subtype, char *body, 57 u16 type_subtype, char *body,
58 int body_len, u8 *addr, u16 tx_cb_idx); 58 int body_len, u8 *addr, u16 tx_cb_idx);
@@ -807,7 +807,7 @@ void hostap_init_data(local_info_t *local)
807 INIT_LIST_HEAD(&ap->sta_list); 807 INIT_LIST_HEAD(&ap->sta_list);
808 808
809 /* Initialize task queue structure for AP management */ 809 /* Initialize task queue structure for AP management */
810 INIT_WORK(&local->ap->add_sta_proc_queue, handle_add_proc_queue, ap); 810 INIT_WORK(&local->ap->add_sta_proc_queue, handle_add_proc_queue);
811 811
812 ap->tx_callback_idx = 812 ap->tx_callback_idx =
813 hostap_tx_callback_register(local, hostap_ap_tx_cb, ap); 813 hostap_tx_callback_register(local, hostap_ap_tx_cb, ap);
@@ -815,7 +815,7 @@ void hostap_init_data(local_info_t *local)
815 printk(KERN_WARNING "%s: failed to register TX callback for " 815 printk(KERN_WARNING "%s: failed to register TX callback for "
816 "AP\n", local->dev->name); 816 "AP\n", local->dev->name);
817#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT 817#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
818 INIT_WORK(&local->ap->wds_oper_queue, handle_wds_oper_queue, local); 818 INIT_WORK(&local->ap->wds_oper_queue, handle_wds_oper_queue);
819 819
820 ap->tx_callback_auth = 820 ap->tx_callback_auth =
821 hostap_tx_callback_register(local, hostap_ap_tx_cb_auth, ap); 821 hostap_tx_callback_register(local, hostap_ap_tx_cb_auth, ap);
@@ -1062,9 +1062,10 @@ static int prism2_sta_proc_read(char *page, char **start, off_t off,
1062} 1062}
1063 1063
1064 1064
1065static void handle_add_proc_queue(void *data) 1065static void handle_add_proc_queue(struct work_struct *work)
1066{ 1066{
1067 struct ap_data *ap = (struct ap_data *) data; 1067 struct ap_data *ap = container_of(work, struct ap_data,
1068 add_sta_proc_queue);
1068 struct sta_info *sta; 1069 struct sta_info *sta;
1069 char name[20]; 1070 char name[20];
1070 struct add_sta_proc_data *entry, *prev; 1071 struct add_sta_proc_data *entry, *prev;
@@ -1952,9 +1953,11 @@ static void handle_pspoll(local_info_t *local,
1952 1953
1953#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT 1954#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
1954 1955
1955static void handle_wds_oper_queue(void *data) 1956static void handle_wds_oper_queue(struct work_struct *work)
1956{ 1957{
1957 local_info_t *local = data; 1958 struct ap_data *ap = container_of(work, struct ap_data,
1959 wds_oper_queue);
1960 local_info_t *local = ap->local;
1958 struct wds_oper_data *entry, *prev; 1961 struct wds_oper_data *entry, *prev;
1959 1962
1960 spin_lock_bh(&local->lock); 1963 spin_lock_bh(&local->lock);
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index ed00ebb6e7f4..c19e68636a1c 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -1645,9 +1645,9 @@ static void prism2_schedule_reset(local_info_t *local)
1645 1645
1646/* Called only as scheduled task after noticing card timeout in interrupt 1646/* Called only as scheduled task after noticing card timeout in interrupt
1647 * context */ 1647 * context */
1648static void handle_reset_queue(void *data) 1648static void handle_reset_queue(struct work_struct *work)
1649{ 1649{
1650 local_info_t *local = (local_info_t *) data; 1650 local_info_t *local = container_of(work, local_info_t, reset_queue);
1651 1651
1652 printk(KERN_DEBUG "%s: scheduled card reset\n", local->dev->name); 1652 printk(KERN_DEBUG "%s: scheduled card reset\n", local->dev->name);
1653 prism2_hw_reset(local->dev); 1653 prism2_hw_reset(local->dev);
@@ -2896,9 +2896,10 @@ static void hostap_passive_scan(unsigned long data)
2896 2896
2897/* Called only as a scheduled task when communications quality values should 2897/* Called only as a scheduled task when communications quality values should
2898 * be updated. */ 2898 * be updated. */
2899static void handle_comms_qual_update(void *data) 2899static void handle_comms_qual_update(struct work_struct *work)
2900{ 2900{
2901 local_info_t *local = data; 2901 local_info_t *local =
2902 container_of(work, local_info_t, comms_qual_update);
2902 prism2_update_comms_qual(local->dev); 2903 prism2_update_comms_qual(local->dev);
2903} 2904}
2904 2905
@@ -3050,9 +3051,9 @@ static int prism2_set_tim(struct net_device *dev, int aid, int set)
3050} 3051}
3051 3052
3052 3053
3053static void handle_set_tim_queue(void *data) 3054static void handle_set_tim_queue(struct work_struct *work)
3054{ 3055{
3055 local_info_t *local = (local_info_t *) data; 3056 local_info_t *local = container_of(work, local_info_t, set_tim_queue);
3056 struct set_tim_data *entry; 3057 struct set_tim_data *entry;
3057 u16 val; 3058 u16 val;
3058 3059
@@ -3209,15 +3210,15 @@ prism2_init_local_data(struct prism2_helper_functions *funcs, int card_idx,
3209 local->scan_channel_mask = 0xffff; 3210 local->scan_channel_mask = 0xffff;
3210 3211
3211 /* Initialize task queue structures */ 3212 /* Initialize task queue structures */
3212 INIT_WORK(&local->reset_queue, handle_reset_queue, local); 3213 INIT_WORK(&local->reset_queue, handle_reset_queue);
3213 INIT_WORK(&local->set_multicast_list_queue, 3214 INIT_WORK(&local->set_multicast_list_queue,
3214 hostap_set_multicast_list_queue, local->dev); 3215 hostap_set_multicast_list_queue);
3215 3216
3216 INIT_WORK(&local->set_tim_queue, handle_set_tim_queue, local); 3217 INIT_WORK(&local->set_tim_queue, handle_set_tim_queue);
3217 INIT_LIST_HEAD(&local->set_tim_list); 3218 INIT_LIST_HEAD(&local->set_tim_list);
3218 spin_lock_init(&local->set_tim_lock); 3219 spin_lock_init(&local->set_tim_lock);
3219 3220
3220 INIT_WORK(&local->comms_qual_update, handle_comms_qual_update, local); 3221 INIT_WORK(&local->comms_qual_update, handle_comms_qual_update);
3221 3222
3222 /* Initialize tasklets for handling hardware IRQ related operations 3223 /* Initialize tasklets for handling hardware IRQ related operations
3223 * outside hw IRQ handler */ 3224 * outside hw IRQ handler */
diff --git a/drivers/net/wireless/hostap/hostap_info.c b/drivers/net/wireless/hostap/hostap_info.c
index 50f72d831cf4..5fd2b1ad7f5e 100644
--- a/drivers/net/wireless/hostap/hostap_info.c
+++ b/drivers/net/wireless/hostap/hostap_info.c
@@ -474,9 +474,9 @@ static void handle_info_queue_scanresults(local_info_t *local)
474 474
475/* Called only as scheduled task after receiving info frames (used to avoid 475/* Called only as scheduled task after receiving info frames (used to avoid
476 * pending too much time in HW IRQ handler). */ 476 * pending too much time in HW IRQ handler). */
477static void handle_info_queue(void *data) 477static void handle_info_queue(struct work_struct *work)
478{ 478{
479 local_info_t *local = (local_info_t *) data; 479 local_info_t *local = container_of(work, local_info_t, info_queue);
480 480
481 if (test_and_clear_bit(PRISM2_INFO_PENDING_LINKSTATUS, 481 if (test_and_clear_bit(PRISM2_INFO_PENDING_LINKSTATUS,
482 &local->pending_info)) 482 &local->pending_info))
@@ -493,7 +493,7 @@ void hostap_info_init(local_info_t *local)
493{ 493{
494 skb_queue_head_init(&local->info_list); 494 skb_queue_head_init(&local->info_list);
495#ifndef PRISM2_NO_STATION_MODES 495#ifndef PRISM2_NO_STATION_MODES
496 INIT_WORK(&local->info_queue, handle_info_queue, local); 496 INIT_WORK(&local->info_queue, handle_info_queue);
497#endif /* PRISM2_NO_STATION_MODES */ 497#endif /* PRISM2_NO_STATION_MODES */
498} 498}
499 499
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
index 53374fcba77e..0796be9d9e77 100644
--- a/drivers/net/wireless/hostap/hostap_main.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
@@ -767,14 +767,14 @@ static int prism2_set_mac_address(struct net_device *dev, void *p)
767 767
768/* TODO: to be further implemented as soon as Prism2 fully supports 768/* TODO: to be further implemented as soon as Prism2 fully supports
769 * GroupAddresses and correct documentation is available */ 769 * GroupAddresses and correct documentation is available */
770void hostap_set_multicast_list_queue(void *data) 770void hostap_set_multicast_list_queue(struct work_struct *work)
771{ 771{
772 struct net_device *dev = (struct net_device *) data; 772 local_info_t *local =
773 container_of(work, local_info_t, set_multicast_list_queue);
774 struct net_device *dev = local->dev;
773 struct hostap_interface *iface; 775 struct hostap_interface *iface;
774 local_info_t *local;
775 776
776 iface = netdev_priv(dev); 777 iface = netdev_priv(dev);
777 local = iface->local;
778 if (hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE, 778 if (hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE,
779 local->is_promisc)) { 779 local->is_promisc)) {
780 printk(KERN_INFO "%s: %sabling promiscuous mode failed\n", 780 printk(KERN_INFO "%s: %sabling promiscuous mode failed\n",
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index 79607b8b877c..1bcd352a813b 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -316,7 +316,7 @@ static void ipw2100_release_firmware(struct ipw2100_priv *priv,
316 struct ipw2100_fw *fw); 316 struct ipw2100_fw *fw);
317static int ipw2100_ucode_download(struct ipw2100_priv *priv, 317static int ipw2100_ucode_download(struct ipw2100_priv *priv,
318 struct ipw2100_fw *fw); 318 struct ipw2100_fw *fw);
319static void ipw2100_wx_event_work(struct ipw2100_priv *priv); 319static void ipw2100_wx_event_work(struct work_struct *work);
320static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device *dev); 320static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device *dev);
321static struct iw_handler_def ipw2100_wx_handler_def; 321static struct iw_handler_def ipw2100_wx_handler_def;
322 322
@@ -679,7 +679,8 @@ static void schedule_reset(struct ipw2100_priv *priv)
679 queue_delayed_work(priv->workqueue, &priv->reset_work, 679 queue_delayed_work(priv->workqueue, &priv->reset_work,
680 priv->reset_backoff * HZ); 680 priv->reset_backoff * HZ);
681 else 681 else
682 queue_work(priv->workqueue, &priv->reset_work); 682 queue_delayed_work(priv->workqueue, &priv->reset_work,
683 0);
683 684
684 if (priv->reset_backoff < MAX_RESET_BACKOFF) 685 if (priv->reset_backoff < MAX_RESET_BACKOFF)
685 priv->reset_backoff++; 686 priv->reset_backoff++;
@@ -1873,8 +1874,10 @@ static void ipw2100_down(struct ipw2100_priv *priv)
1873 netif_stop_queue(priv->net_dev); 1874 netif_stop_queue(priv->net_dev);
1874} 1875}
1875 1876
1876static void ipw2100_reset_adapter(struct ipw2100_priv *priv) 1877static void ipw2100_reset_adapter(struct work_struct *work)
1877{ 1878{
1879 struct ipw2100_priv *priv =
1880 container_of(work, struct ipw2100_priv, reset_work.work);
1878 unsigned long flags; 1881 unsigned long flags;
1879 union iwreq_data wrqu = { 1882 union iwreq_data wrqu = {
1880 .ap_addr = { 1883 .ap_addr = {
@@ -2071,9 +2074,9 @@ static void isr_indicate_association_lost(struct ipw2100_priv *priv, u32 status)
2071 return; 2074 return;
2072 2075
2073 if (priv->status & STATUS_SECURITY_UPDATED) 2076 if (priv->status & STATUS_SECURITY_UPDATED)
2074 queue_work(priv->workqueue, &priv->security_work); 2077 queue_delayed_work(priv->workqueue, &priv->security_work, 0);
2075 2078
2076 queue_work(priv->workqueue, &priv->wx_event_work); 2079 queue_delayed_work(priv->workqueue, &priv->wx_event_work, 0);
2077} 2080}
2078 2081
2079static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status) 2082static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status)
@@ -5524,8 +5527,11 @@ static int ipw2100_configure_security(struct ipw2100_priv *priv, int batch_mode)
5524 return err; 5527 return err;
5525} 5528}
5526 5529
5527static void ipw2100_security_work(struct ipw2100_priv *priv) 5530static void ipw2100_security_work(struct work_struct *work)
5528{ 5531{
5532 struct ipw2100_priv *priv =
5533 container_of(work, struct ipw2100_priv, security_work.work);
5534
5529 /* If we happen to have reconnected before we get a chance to 5535 /* If we happen to have reconnected before we get a chance to
5530 * process this, then update the security settings--which causes 5536 * process this, then update the security settings--which causes
5531 * a disassociation to occur */ 5537 * a disassociation to occur */
@@ -5748,7 +5754,7 @@ static int ipw2100_set_address(struct net_device *dev, void *p)
5748 5754
5749 priv->reset_backoff = 0; 5755 priv->reset_backoff = 0;
5750 mutex_unlock(&priv->action_mutex); 5756 mutex_unlock(&priv->action_mutex);
5751 ipw2100_reset_adapter(priv); 5757 ipw2100_reset_adapter(&priv->reset_work.work);
5752 return 0; 5758 return 0;
5753 5759
5754 done: 5760 done:
@@ -5910,9 +5916,10 @@ static const struct ethtool_ops ipw2100_ethtool_ops = {
5910 .get_drvinfo = ipw_ethtool_get_drvinfo, 5916 .get_drvinfo = ipw_ethtool_get_drvinfo,
5911}; 5917};
5912 5918
5913static void ipw2100_hang_check(void *adapter) 5919static void ipw2100_hang_check(struct work_struct *work)
5914{ 5920{
5915 struct ipw2100_priv *priv = adapter; 5921 struct ipw2100_priv *priv =
5922 container_of(work, struct ipw2100_priv, hang_check.work);
5916 unsigned long flags; 5923 unsigned long flags;
5917 u32 rtc = 0xa5a5a5a5; 5924 u32 rtc = 0xa5a5a5a5;
5918 u32 len = sizeof(rtc); 5925 u32 len = sizeof(rtc);
@@ -5952,9 +5959,10 @@ static void ipw2100_hang_check(void *adapter)
5952 spin_unlock_irqrestore(&priv->low_lock, flags); 5959 spin_unlock_irqrestore(&priv->low_lock, flags);
5953} 5960}
5954 5961
5955static void ipw2100_rf_kill(void *adapter) 5962static void ipw2100_rf_kill(struct work_struct *work)
5956{ 5963{
5957 struct ipw2100_priv *priv = adapter; 5964 struct ipw2100_priv *priv =
5965 container_of(work, struct ipw2100_priv, rf_kill.work);
5958 unsigned long flags; 5966 unsigned long flags;
5959 5967
5960 spin_lock_irqsave(&priv->low_lock, flags); 5968 spin_lock_irqsave(&priv->low_lock, flags);
@@ -6103,14 +6111,11 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
6103 6111
6104 priv->workqueue = create_workqueue(DRV_NAME); 6112 priv->workqueue = create_workqueue(DRV_NAME);
6105 6113
6106 INIT_WORK(&priv->reset_work, 6114 INIT_DELAYED_WORK(&priv->reset_work, ipw2100_reset_adapter);
6107 (void (*)(void *))ipw2100_reset_adapter, priv); 6115 INIT_DELAYED_WORK(&priv->security_work, ipw2100_security_work);
6108 INIT_WORK(&priv->security_work, 6116 INIT_DELAYED_WORK(&priv->wx_event_work, ipw2100_wx_event_work);
6109 (void (*)(void *))ipw2100_security_work, priv); 6117 INIT_DELAYED_WORK(&priv->hang_check, ipw2100_hang_check);
6110 INIT_WORK(&priv->wx_event_work, 6118 INIT_DELAYED_WORK(&priv->rf_kill, ipw2100_rf_kill);
6111 (void (*)(void *))ipw2100_wx_event_work, priv);
6112 INIT_WORK(&priv->hang_check, ipw2100_hang_check, priv);
6113 INIT_WORK(&priv->rf_kill, ipw2100_rf_kill, priv);
6114 6119
6115 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) 6120 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
6116 ipw2100_irq_tasklet, (unsigned long)priv); 6121 ipw2100_irq_tasklet, (unsigned long)priv);
@@ -8281,8 +8286,10 @@ static struct iw_handler_def ipw2100_wx_handler_def = {
8281 .get_wireless_stats = ipw2100_wx_wireless_stats, 8286 .get_wireless_stats = ipw2100_wx_wireless_stats,
8282}; 8287};
8283 8288
8284static void ipw2100_wx_event_work(struct ipw2100_priv *priv) 8289static void ipw2100_wx_event_work(struct work_struct *work)
8285{ 8290{
8291 struct ipw2100_priv *priv =
8292 container_of(work, struct ipw2100_priv, wx_event_work.work);
8286 union iwreq_data wrqu; 8293 union iwreq_data wrqu;
8287 int len = ETH_ALEN; 8294 int len = ETH_ALEN;
8288 8295
diff --git a/drivers/net/wireless/ipw2100.h b/drivers/net/wireless/ipw2100.h
index 55b7227198df..de7d384d38af 100644
--- a/drivers/net/wireless/ipw2100.h
+++ b/drivers/net/wireless/ipw2100.h
@@ -583,11 +583,11 @@ struct ipw2100_priv {
583 struct tasklet_struct irq_tasklet; 583 struct tasklet_struct irq_tasklet;
584 584
585 struct workqueue_struct *workqueue; 585 struct workqueue_struct *workqueue;
586 struct work_struct reset_work; 586 struct delayed_work reset_work;
587 struct work_struct security_work; 587 struct delayed_work security_work;
588 struct work_struct wx_event_work; 588 struct delayed_work wx_event_work;
589 struct work_struct hang_check; 589 struct delayed_work hang_check;
590 struct work_struct rf_kill; 590 struct delayed_work rf_kill;
591 591
592 u32 interrupts; 592 u32 interrupts;
593 int tx_interrupts; 593 int tx_interrupts;
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index c692d01a76ca..e82e56bb85e1 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -187,9 +187,9 @@ static struct ipw_rx_queue *ipw_rx_queue_alloc(struct ipw_priv *);
187static void ipw_rx_queue_free(struct ipw_priv *, struct ipw_rx_queue *); 187static void ipw_rx_queue_free(struct ipw_priv *, struct ipw_rx_queue *);
188static void ipw_rx_queue_replenish(void *); 188static void ipw_rx_queue_replenish(void *);
189static int ipw_up(struct ipw_priv *); 189static int ipw_up(struct ipw_priv *);
190static void ipw_bg_up(void *); 190static void ipw_bg_up(struct work_struct *work);
191static void ipw_down(struct ipw_priv *); 191static void ipw_down(struct ipw_priv *);
192static void ipw_bg_down(void *); 192static void ipw_bg_down(struct work_struct *work);
193static int ipw_config(struct ipw_priv *); 193static int ipw_config(struct ipw_priv *);
194static int init_supported_rates(struct ipw_priv *priv, 194static int init_supported_rates(struct ipw_priv *priv,
195 struct ipw_supported_rates *prates); 195 struct ipw_supported_rates *prates);
@@ -862,11 +862,12 @@ static void ipw_led_link_on(struct ipw_priv *priv)
862 spin_unlock_irqrestore(&priv->lock, flags); 862 spin_unlock_irqrestore(&priv->lock, flags);
863} 863}
864 864
865static void ipw_bg_led_link_on(void *data) 865static void ipw_bg_led_link_on(struct work_struct *work)
866{ 866{
867 struct ipw_priv *priv = data; 867 struct ipw_priv *priv =
868 container_of(work, struct ipw_priv, led_link_on.work);
868 mutex_lock(&priv->mutex); 869 mutex_lock(&priv->mutex);
869 ipw_led_link_on(data); 870 ipw_led_link_on(priv);
870 mutex_unlock(&priv->mutex); 871 mutex_unlock(&priv->mutex);
871} 872}
872 873
@@ -906,11 +907,12 @@ static void ipw_led_link_off(struct ipw_priv *priv)
906 spin_unlock_irqrestore(&priv->lock, flags); 907 spin_unlock_irqrestore(&priv->lock, flags);
907} 908}
908 909
909static void ipw_bg_led_link_off(void *data) 910static void ipw_bg_led_link_off(struct work_struct *work)
910{ 911{
911 struct ipw_priv *priv = data; 912 struct ipw_priv *priv =
913 container_of(work, struct ipw_priv, led_link_off.work);
912 mutex_lock(&priv->mutex); 914 mutex_lock(&priv->mutex);
913 ipw_led_link_off(data); 915 ipw_led_link_off(priv);
914 mutex_unlock(&priv->mutex); 916 mutex_unlock(&priv->mutex);
915} 917}
916 918
@@ -985,11 +987,12 @@ static void ipw_led_activity_off(struct ipw_priv *priv)
985 spin_unlock_irqrestore(&priv->lock, flags); 987 spin_unlock_irqrestore(&priv->lock, flags);
986} 988}
987 989
988static void ipw_bg_led_activity_off(void *data) 990static void ipw_bg_led_activity_off(struct work_struct *work)
989{ 991{
990 struct ipw_priv *priv = data; 992 struct ipw_priv *priv =
993 container_of(work, struct ipw_priv, led_act_off.work);
991 mutex_lock(&priv->mutex); 994 mutex_lock(&priv->mutex);
992 ipw_led_activity_off(data); 995 ipw_led_activity_off(priv);
993 mutex_unlock(&priv->mutex); 996 mutex_unlock(&priv->mutex);
994} 997}
995 998
@@ -2228,11 +2231,12 @@ static void ipw_adapter_restart(void *adapter)
2228 } 2231 }
2229} 2232}
2230 2233
2231static void ipw_bg_adapter_restart(void *data) 2234static void ipw_bg_adapter_restart(struct work_struct *work)
2232{ 2235{
2233 struct ipw_priv *priv = data; 2236 struct ipw_priv *priv =
2237 container_of(work, struct ipw_priv, adapter_restart);
2234 mutex_lock(&priv->mutex); 2238 mutex_lock(&priv->mutex);
2235 ipw_adapter_restart(data); 2239 ipw_adapter_restart(priv);
2236 mutex_unlock(&priv->mutex); 2240 mutex_unlock(&priv->mutex);
2237} 2241}
2238 2242
@@ -2249,11 +2253,12 @@ static void ipw_scan_check(void *data)
2249 } 2253 }
2250} 2254}
2251 2255
2252static void ipw_bg_scan_check(void *data) 2256static void ipw_bg_scan_check(struct work_struct *work)
2253{ 2257{
2254 struct ipw_priv *priv = data; 2258 struct ipw_priv *priv =
2259 container_of(work, struct ipw_priv, scan_check.work);
2255 mutex_lock(&priv->mutex); 2260 mutex_lock(&priv->mutex);
2256 ipw_scan_check(data); 2261 ipw_scan_check(priv);
2257 mutex_unlock(&priv->mutex); 2262 mutex_unlock(&priv->mutex);
2258} 2263}
2259 2264
@@ -3831,17 +3836,19 @@ static int ipw_disassociate(void *data)
3831 return 1; 3836 return 1;
3832} 3837}
3833 3838
3834static void ipw_bg_disassociate(void *data) 3839static void ipw_bg_disassociate(struct work_struct *work)
3835{ 3840{
3836 struct ipw_priv *priv = data; 3841 struct ipw_priv *priv =
3842 container_of(work, struct ipw_priv, disassociate);
3837 mutex_lock(&priv->mutex); 3843 mutex_lock(&priv->mutex);
3838 ipw_disassociate(data); 3844 ipw_disassociate(priv);
3839 mutex_unlock(&priv->mutex); 3845 mutex_unlock(&priv->mutex);
3840} 3846}
3841 3847
3842static void ipw_system_config(void *data) 3848static void ipw_system_config(struct work_struct *work)
3843{ 3849{
3844 struct ipw_priv *priv = data; 3850 struct ipw_priv *priv =
3851 container_of(work, struct ipw_priv, system_config);
3845 3852
3846#ifdef CONFIG_IPW2200_PROMISCUOUS 3853#ifdef CONFIG_IPW2200_PROMISCUOUS
3847 if (priv->prom_net_dev && netif_running(priv->prom_net_dev)) { 3854 if (priv->prom_net_dev && netif_running(priv->prom_net_dev)) {
@@ -4208,11 +4215,12 @@ static void ipw_gather_stats(struct ipw_priv *priv)
4208 IPW_STATS_INTERVAL); 4215 IPW_STATS_INTERVAL);
4209} 4216}
4210 4217
4211static void ipw_bg_gather_stats(void *data) 4218static void ipw_bg_gather_stats(struct work_struct *work)
4212{ 4219{
4213 struct ipw_priv *priv = data; 4220 struct ipw_priv *priv =
4221 container_of(work, struct ipw_priv, gather_stats.work);
4214 mutex_lock(&priv->mutex); 4222 mutex_lock(&priv->mutex);
4215 ipw_gather_stats(data); 4223 ipw_gather_stats(priv);
4216 mutex_unlock(&priv->mutex); 4224 mutex_unlock(&priv->mutex);
4217} 4225}
4218 4226
@@ -4268,8 +4276,8 @@ static void ipw_handle_missed_beacon(struct ipw_priv *priv,
4268 if (!(priv->status & STATUS_ROAMING)) { 4276 if (!(priv->status & STATUS_ROAMING)) {
4269 priv->status |= STATUS_ROAMING; 4277 priv->status |= STATUS_ROAMING;
4270 if (!(priv->status & STATUS_SCANNING)) 4278 if (!(priv->status & STATUS_SCANNING))
4271 queue_work(priv->workqueue, 4279 queue_delayed_work(priv->workqueue,
4272 &priv->request_scan); 4280 &priv->request_scan, 0);
4273 } 4281 }
4274 return; 4282 return;
4275 } 4283 }
@@ -4607,8 +4615,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4607#ifdef CONFIG_IPW2200_MONITOR 4615#ifdef CONFIG_IPW2200_MONITOR
4608 if (priv->ieee->iw_mode == IW_MODE_MONITOR) { 4616 if (priv->ieee->iw_mode == IW_MODE_MONITOR) {
4609 priv->status |= STATUS_SCAN_FORCED; 4617 priv->status |= STATUS_SCAN_FORCED;
4610 queue_work(priv->workqueue, 4618 queue_delayed_work(priv->workqueue,
4611 &priv->request_scan); 4619 &priv->request_scan, 0);
4612 break; 4620 break;
4613 } 4621 }
4614 priv->status &= ~STATUS_SCAN_FORCED; 4622 priv->status &= ~STATUS_SCAN_FORCED;
@@ -4631,8 +4639,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4631 /* Don't schedule if we aborted the scan */ 4639 /* Don't schedule if we aborted the scan */
4632 priv->status &= ~STATUS_ROAMING; 4640 priv->status &= ~STATUS_ROAMING;
4633 } else if (priv->status & STATUS_SCAN_PENDING) 4641 } else if (priv->status & STATUS_SCAN_PENDING)
4634 queue_work(priv->workqueue, 4642 queue_delayed_work(priv->workqueue,
4635 &priv->request_scan); 4643 &priv->request_scan, 0);
4636 else if (priv->config & CFG_BACKGROUND_SCAN 4644 else if (priv->config & CFG_BACKGROUND_SCAN
4637 && priv->status & STATUS_ASSOCIATED) 4645 && priv->status & STATUS_ASSOCIATED)
4638 queue_delayed_work(priv->workqueue, 4646 queue_delayed_work(priv->workqueue,
@@ -5055,11 +5063,12 @@ static void ipw_rx_queue_replenish(void *data)
5055 ipw_rx_queue_restock(priv); 5063 ipw_rx_queue_restock(priv);
5056} 5064}
5057 5065
5058static void ipw_bg_rx_queue_replenish(void *data) 5066static void ipw_bg_rx_queue_replenish(struct work_struct *work)
5059{ 5067{
5060 struct ipw_priv *priv = data; 5068 struct ipw_priv *priv =
5069 container_of(work, struct ipw_priv, rx_replenish);
5061 mutex_lock(&priv->mutex); 5070 mutex_lock(&priv->mutex);
5062 ipw_rx_queue_replenish(data); 5071 ipw_rx_queue_replenish(priv);
5063 mutex_unlock(&priv->mutex); 5072 mutex_unlock(&priv->mutex);
5064} 5073}
5065 5074
@@ -5489,9 +5498,10 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
5489 return 1; 5498 return 1;
5490} 5499}
5491 5500
5492static void ipw_merge_adhoc_network(void *data) 5501static void ipw_merge_adhoc_network(struct work_struct *work)
5493{ 5502{
5494 struct ipw_priv *priv = data; 5503 struct ipw_priv *priv =
5504 container_of(work, struct ipw_priv, merge_networks);
5495 struct ieee80211_network *network = NULL; 5505 struct ieee80211_network *network = NULL;
5496 struct ipw_network_match match = { 5506 struct ipw_network_match match = {
5497 .network = priv->assoc_network 5507 .network = priv->assoc_network
@@ -5948,11 +5958,12 @@ static void ipw_adhoc_check(void *data)
5948 priv->assoc_request.beacon_interval); 5958 priv->assoc_request.beacon_interval);
5949} 5959}
5950 5960
5951static void ipw_bg_adhoc_check(void *data) 5961static void ipw_bg_adhoc_check(struct work_struct *work)
5952{ 5962{
5953 struct ipw_priv *priv = data; 5963 struct ipw_priv *priv =
5964 container_of(work, struct ipw_priv, adhoc_check.work);
5954 mutex_lock(&priv->mutex); 5965 mutex_lock(&priv->mutex);
5955 ipw_adhoc_check(data); 5966 ipw_adhoc_check(priv);
5956 mutex_unlock(&priv->mutex); 5967 mutex_unlock(&priv->mutex);
5957} 5968}
5958 5969
@@ -6299,19 +6310,26 @@ done:
6299 return err; 6310 return err;
6300} 6311}
6301 6312
6302static int ipw_request_passive_scan(struct ipw_priv *priv) { 6313static void ipw_request_passive_scan(struct work_struct *work)
6303 return ipw_request_scan_helper(priv, IW_SCAN_TYPE_PASSIVE); 6314{
6315 struct ipw_priv *priv =
6316 container_of(work, struct ipw_priv, request_passive_scan);
6317 ipw_request_scan_helper(priv, IW_SCAN_TYPE_PASSIVE);
6304} 6318}
6305 6319
6306static int ipw_request_scan(struct ipw_priv *priv) { 6320static void ipw_request_scan(struct work_struct *work)
6307 return ipw_request_scan_helper(priv, IW_SCAN_TYPE_ACTIVE); 6321{
6322 struct ipw_priv *priv =
6323 container_of(work, struct ipw_priv, request_scan.work);
6324 ipw_request_scan_helper(priv, IW_SCAN_TYPE_ACTIVE);
6308} 6325}
6309 6326
6310static void ipw_bg_abort_scan(void *data) 6327static void ipw_bg_abort_scan(struct work_struct *work)
6311{ 6328{
6312 struct ipw_priv *priv = data; 6329 struct ipw_priv *priv =
6330 container_of(work, struct ipw_priv, abort_scan);
6313 mutex_lock(&priv->mutex); 6331 mutex_lock(&priv->mutex);
6314 ipw_abort_scan(data); 6332 ipw_abort_scan(priv);
6315 mutex_unlock(&priv->mutex); 6333 mutex_unlock(&priv->mutex);
6316} 6334}
6317 6335
@@ -7084,9 +7102,10 @@ static int ipw_qos_set_tx_queue_command(struct ipw_priv *priv,
7084/* 7102/*
7085* background support to run QoS activate functionality 7103* background support to run QoS activate functionality
7086*/ 7104*/
7087static void ipw_bg_qos_activate(void *data) 7105static void ipw_bg_qos_activate(struct work_struct *work)
7088{ 7106{
7089 struct ipw_priv *priv = data; 7107 struct ipw_priv *priv =
7108 container_of(work, struct ipw_priv, qos_activate);
7090 7109
7091 if (priv == NULL) 7110 if (priv == NULL)
7092 return; 7111 return;
@@ -7394,11 +7413,12 @@ static void ipw_roam(void *data)
7394 priv->status &= ~STATUS_ROAMING; 7413 priv->status &= ~STATUS_ROAMING;
7395} 7414}
7396 7415
7397static void ipw_bg_roam(void *data) 7416static void ipw_bg_roam(struct work_struct *work)
7398{ 7417{
7399 struct ipw_priv *priv = data; 7418 struct ipw_priv *priv =
7419 container_of(work, struct ipw_priv, roam);
7400 mutex_lock(&priv->mutex); 7420 mutex_lock(&priv->mutex);
7401 ipw_roam(data); 7421 ipw_roam(priv);
7402 mutex_unlock(&priv->mutex); 7422 mutex_unlock(&priv->mutex);
7403} 7423}
7404 7424
@@ -7479,8 +7499,8 @@ static int ipw_associate(void *data)
7479 &priv->request_scan, 7499 &priv->request_scan,
7480 SCAN_INTERVAL); 7500 SCAN_INTERVAL);
7481 else 7501 else
7482 queue_work(priv->workqueue, 7502 queue_delayed_work(priv->workqueue,
7483 &priv->request_scan); 7503 &priv->request_scan, 0);
7484 } 7504 }
7485 7505
7486 return 0; 7506 return 0;
@@ -7491,11 +7511,12 @@ static int ipw_associate(void *data)
7491 return 1; 7511 return 1;
7492} 7512}
7493 7513
7494static void ipw_bg_associate(void *data) 7514static void ipw_bg_associate(struct work_struct *work)
7495{ 7515{
7496 struct ipw_priv *priv = data; 7516 struct ipw_priv *priv =
7517 container_of(work, struct ipw_priv, associate);
7497 mutex_lock(&priv->mutex); 7518 mutex_lock(&priv->mutex);
7498 ipw_associate(data); 7519 ipw_associate(priv);
7499 mutex_unlock(&priv->mutex); 7520 mutex_unlock(&priv->mutex);
7500} 7521}
7501 7522
@@ -9410,7 +9431,7 @@ static int ipw_wx_set_scan(struct net_device *dev,
9410 9431
9411 IPW_DEBUG_WX("Start scan\n"); 9432 IPW_DEBUG_WX("Start scan\n");
9412 9433
9413 queue_work(priv->workqueue, &priv->request_scan); 9434 queue_delayed_work(priv->workqueue, &priv->request_scan, 0);
9414 9435
9415 return 0; 9436 return 0;
9416} 9437}
@@ -10547,11 +10568,12 @@ static void ipw_rf_kill(void *adapter)
10547 spin_unlock_irqrestore(&priv->lock, flags); 10568 spin_unlock_irqrestore(&priv->lock, flags);
10548} 10569}
10549 10570
10550static void ipw_bg_rf_kill(void *data) 10571static void ipw_bg_rf_kill(struct work_struct *work)
10551{ 10572{
10552 struct ipw_priv *priv = data; 10573 struct ipw_priv *priv =
10574 container_of(work, struct ipw_priv, rf_kill.work);
10553 mutex_lock(&priv->mutex); 10575 mutex_lock(&priv->mutex);
10554 ipw_rf_kill(data); 10576 ipw_rf_kill(priv);
10555 mutex_unlock(&priv->mutex); 10577 mutex_unlock(&priv->mutex);
10556} 10578}
10557 10579
@@ -10582,11 +10604,12 @@ static void ipw_link_up(struct ipw_priv *priv)
10582 queue_delayed_work(priv->workqueue, &priv->request_scan, HZ); 10604 queue_delayed_work(priv->workqueue, &priv->request_scan, HZ);
10583} 10605}
10584 10606
10585static void ipw_bg_link_up(void *data) 10607static void ipw_bg_link_up(struct work_struct *work)
10586{ 10608{
10587 struct ipw_priv *priv = data; 10609 struct ipw_priv *priv =
10610 container_of(work, struct ipw_priv, link_up);
10588 mutex_lock(&priv->mutex); 10611 mutex_lock(&priv->mutex);
10589 ipw_link_up(data); 10612 ipw_link_up(priv);
10590 mutex_unlock(&priv->mutex); 10613 mutex_unlock(&priv->mutex);
10591} 10614}
10592 10615
@@ -10606,15 +10629,16 @@ static void ipw_link_down(struct ipw_priv *priv)
10606 10629
10607 if (!(priv->status & STATUS_EXIT_PENDING)) { 10630 if (!(priv->status & STATUS_EXIT_PENDING)) {
10608 /* Queue up another scan... */ 10631 /* Queue up another scan... */
10609 queue_work(priv->workqueue, &priv->request_scan); 10632 queue_delayed_work(priv->workqueue, &priv->request_scan, 0);
10610 } 10633 }
10611} 10634}
10612 10635
10613static void ipw_bg_link_down(void *data) 10636static void ipw_bg_link_down(struct work_struct *work)
10614{ 10637{
10615 struct ipw_priv *priv = data; 10638 struct ipw_priv *priv =
10639 container_of(work, struct ipw_priv, link_down);
10616 mutex_lock(&priv->mutex); 10640 mutex_lock(&priv->mutex);
10617 ipw_link_down(data); 10641 ipw_link_down(priv);
10618 mutex_unlock(&priv->mutex); 10642 mutex_unlock(&priv->mutex);
10619} 10643}
10620 10644
@@ -10626,38 +10650,30 @@ static int ipw_setup_deferred_work(struct ipw_priv *priv)
10626 init_waitqueue_head(&priv->wait_command_queue); 10650 init_waitqueue_head(&priv->wait_command_queue);
10627 init_waitqueue_head(&priv->wait_state); 10651 init_waitqueue_head(&priv->wait_state);
10628 10652
10629 INIT_WORK(&priv->adhoc_check, ipw_bg_adhoc_check, priv); 10653 INIT_DELAYED_WORK(&priv->adhoc_check, ipw_bg_adhoc_check);
10630 INIT_WORK(&priv->associate, ipw_bg_associate, priv); 10654 INIT_WORK(&priv->associate, ipw_bg_associate);
10631 INIT_WORK(&priv->disassociate, ipw_bg_disassociate, priv); 10655 INIT_WORK(&priv->disassociate, ipw_bg_disassociate);
10632 INIT_WORK(&priv->system_config, ipw_system_config, priv); 10656 INIT_WORK(&priv->system_config, ipw_system_config);
10633 INIT_WORK(&priv->rx_replenish, ipw_bg_rx_queue_replenish, priv); 10657 INIT_WORK(&priv->rx_replenish, ipw_bg_rx_queue_replenish);
10634 INIT_WORK(&priv->adapter_restart, ipw_bg_adapter_restart, priv); 10658 INIT_WORK(&priv->adapter_restart, ipw_bg_adapter_restart);
10635 INIT_WORK(&priv->rf_kill, ipw_bg_rf_kill, priv); 10659 INIT_DELAYED_WORK(&priv->rf_kill, ipw_bg_rf_kill);
10636 INIT_WORK(&priv->up, (void (*)(void *))ipw_bg_up, priv); 10660 INIT_WORK(&priv->up, ipw_bg_up);
10637 INIT_WORK(&priv->down, (void (*)(void *))ipw_bg_down, priv); 10661 INIT_WORK(&priv->down, ipw_bg_down);
10638 INIT_WORK(&priv->request_scan, 10662 INIT_DELAYED_WORK(&priv->request_scan, ipw_request_scan);
10639 (void (*)(void *))ipw_request_scan, priv); 10663 INIT_WORK(&priv->request_passive_scan, ipw_request_passive_scan);
10640 INIT_WORK(&priv->request_passive_scan, 10664 INIT_DELAYED_WORK(&priv->gather_stats, ipw_bg_gather_stats);
10641 (void (*)(void *))ipw_request_passive_scan, priv); 10665 INIT_WORK(&priv->abort_scan, ipw_bg_abort_scan);
10642 INIT_WORK(&priv->gather_stats, 10666 INIT_WORK(&priv->roam, ipw_bg_roam);
10643 (void (*)(void *))ipw_bg_gather_stats, priv); 10667 INIT_DELAYED_WORK(&priv->scan_check, ipw_bg_scan_check);
10644 INIT_WORK(&priv->abort_scan, (void (*)(void *))ipw_bg_abort_scan, priv); 10668 INIT_WORK(&priv->link_up, ipw_bg_link_up);
10645 INIT_WORK(&priv->roam, ipw_bg_roam, priv); 10669 INIT_WORK(&priv->link_down, ipw_bg_link_down);
10646 INIT_WORK(&priv->scan_check, ipw_bg_scan_check, priv); 10670 INIT_DELAYED_WORK(&priv->led_link_on, ipw_bg_led_link_on);
10647 INIT_WORK(&priv->link_up, (void (*)(void *))ipw_bg_link_up, priv); 10671 INIT_DELAYED_WORK(&priv->led_link_off, ipw_bg_led_link_off);
10648 INIT_WORK(&priv->link_down, (void (*)(void *))ipw_bg_link_down, priv); 10672 INIT_DELAYED_WORK(&priv->led_act_off, ipw_bg_led_activity_off);
10649 INIT_WORK(&priv->led_link_on, (void (*)(void *))ipw_bg_led_link_on, 10673 INIT_WORK(&priv->merge_networks, ipw_merge_adhoc_network);
10650 priv);
10651 INIT_WORK(&priv->led_link_off, (void (*)(void *))ipw_bg_led_link_off,
10652 priv);
10653 INIT_WORK(&priv->led_act_off, (void (*)(void *))ipw_bg_led_activity_off,
10654 priv);
10655 INIT_WORK(&priv->merge_networks,
10656 (void (*)(void *))ipw_merge_adhoc_network, priv);
10657 10674
10658#ifdef CONFIG_IPW2200_QOS 10675#ifdef CONFIG_IPW2200_QOS
10659 INIT_WORK(&priv->qos_activate, (void (*)(void *))ipw_bg_qos_activate, 10676 INIT_WORK(&priv->qos_activate, ipw_bg_qos_activate);
10660 priv);
10661#endif /* CONFIG_IPW2200_QOS */ 10677#endif /* CONFIG_IPW2200_QOS */
10662 10678
10663 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) 10679 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
@@ -11190,7 +11206,8 @@ static int ipw_up(struct ipw_priv *priv)
11190 11206
11191 /* If configure to try and auto-associate, kick 11207 /* If configure to try and auto-associate, kick
11192 * off a scan. */ 11208 * off a scan. */
11193 queue_work(priv->workqueue, &priv->request_scan); 11209 queue_delayed_work(priv->workqueue,
11210 &priv->request_scan, 0);
11194 11211
11195 return 0; 11212 return 0;
11196 } 11213 }
@@ -11211,11 +11228,12 @@ static int ipw_up(struct ipw_priv *priv)
11211 return -EIO; 11228 return -EIO;
11212} 11229}
11213 11230
11214static void ipw_bg_up(void *data) 11231static void ipw_bg_up(struct work_struct *work)
11215{ 11232{
11216 struct ipw_priv *priv = data; 11233 struct ipw_priv *priv =
11234 container_of(work, struct ipw_priv, up);
11217 mutex_lock(&priv->mutex); 11235 mutex_lock(&priv->mutex);
11218 ipw_up(data); 11236 ipw_up(priv);
11219 mutex_unlock(&priv->mutex); 11237 mutex_unlock(&priv->mutex);
11220} 11238}
11221 11239
@@ -11282,11 +11300,12 @@ static void ipw_down(struct ipw_priv *priv)
11282 ipw_led_radio_off(priv); 11300 ipw_led_radio_off(priv);
11283} 11301}
11284 11302
11285static void ipw_bg_down(void *data) 11303static void ipw_bg_down(struct work_struct *work)
11286{ 11304{
11287 struct ipw_priv *priv = data; 11305 struct ipw_priv *priv =
11306 container_of(work, struct ipw_priv, down);
11288 mutex_lock(&priv->mutex); 11307 mutex_lock(&priv->mutex);
11289 ipw_down(data); 11308 ipw_down(priv);
11290 mutex_unlock(&priv->mutex); 11309 mutex_unlock(&priv->mutex);
11291} 11310}
11292 11311
diff --git a/drivers/net/wireless/ipw2200.h b/drivers/net/wireless/ipw2200.h
index dad5eedefbf1..626a240a87d8 100644
--- a/drivers/net/wireless/ipw2200.h
+++ b/drivers/net/wireless/ipw2200.h
@@ -1290,21 +1290,21 @@ struct ipw_priv {
1290 1290
1291 struct workqueue_struct *workqueue; 1291 struct workqueue_struct *workqueue;
1292 1292
1293 struct work_struct adhoc_check; 1293 struct delayed_work adhoc_check;
1294 struct work_struct associate; 1294 struct work_struct associate;
1295 struct work_struct disassociate; 1295 struct work_struct disassociate;
1296 struct work_struct system_config; 1296 struct work_struct system_config;
1297 struct work_struct rx_replenish; 1297 struct work_struct rx_replenish;
1298 struct work_struct request_scan; 1298 struct delayed_work request_scan;
1299 struct work_struct request_passive_scan; 1299 struct work_struct request_passive_scan;
1300 struct work_struct adapter_restart; 1300 struct work_struct adapter_restart;
1301 struct work_struct rf_kill; 1301 struct delayed_work rf_kill;
1302 struct work_struct up; 1302 struct work_struct up;
1303 struct work_struct down; 1303 struct work_struct down;
1304 struct work_struct gather_stats; 1304 struct delayed_work gather_stats;
1305 struct work_struct abort_scan; 1305 struct work_struct abort_scan;
1306 struct work_struct roam; 1306 struct work_struct roam;
1307 struct work_struct scan_check; 1307 struct delayed_work scan_check;
1308 struct work_struct link_up; 1308 struct work_struct link_up;
1309 struct work_struct link_down; 1309 struct work_struct link_down;
1310 1310
@@ -1319,9 +1319,9 @@ struct ipw_priv {
1319 u32 led_ofdm_on; 1319 u32 led_ofdm_on;
1320 u32 led_ofdm_off; 1320 u32 led_ofdm_off;
1321 1321
1322 struct work_struct led_link_on; 1322 struct delayed_work led_link_on;
1323 struct work_struct led_link_off; 1323 struct delayed_work led_link_off;
1324 struct work_struct led_act_off; 1324 struct delayed_work led_act_off;
1325 struct work_struct merge_networks; 1325 struct work_struct merge_networks;
1326 1326
1327 struct ipw_cmd_log *cmdlog; 1327 struct ipw_cmd_log *cmdlog;
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index 336cabac13b3..936c888e03e1 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -980,9 +980,11 @@ static void print_linkstatus(struct net_device *dev, u16 status)
980} 980}
981 981
982/* Search scan results for requested BSSID, join it if found */ 982/* Search scan results for requested BSSID, join it if found */
983static void orinoco_join_ap(struct net_device *dev) 983static void orinoco_join_ap(struct work_struct *work)
984{ 984{
985 struct orinoco_private *priv = netdev_priv(dev); 985 struct orinoco_private *priv =
986 container_of(work, struct orinoco_private, join_work);
987 struct net_device *dev = priv->ndev;
986 struct hermes *hw = &priv->hw; 988 struct hermes *hw = &priv->hw;
987 int err; 989 int err;
988 unsigned long flags; 990 unsigned long flags;
@@ -1055,9 +1057,11 @@ static void orinoco_join_ap(struct net_device *dev)
1055} 1057}
1056 1058
1057/* Send new BSSID to userspace */ 1059/* Send new BSSID to userspace */
1058static void orinoco_send_wevents(struct net_device *dev) 1060static void orinoco_send_wevents(struct work_struct *work)
1059{ 1061{
1060 struct orinoco_private *priv = netdev_priv(dev); 1062 struct orinoco_private *priv =
1063 container_of(work, struct orinoco_private, wevent_work);
1064 struct net_device *dev = priv->ndev;
1061 struct hermes *hw = &priv->hw; 1065 struct hermes *hw = &priv->hw;
1062 union iwreq_data wrqu; 1066 union iwreq_data wrqu;
1063 int err; 1067 int err;
@@ -1864,9 +1868,11 @@ __orinoco_set_multicast_list(struct net_device *dev)
1864 1868
1865/* This must be called from user context, without locks held - use 1869/* This must be called from user context, without locks held - use
1866 * schedule_work() */ 1870 * schedule_work() */
1867static void orinoco_reset(struct net_device *dev) 1871static void orinoco_reset(struct work_struct *work)
1868{ 1872{
1869 struct orinoco_private *priv = netdev_priv(dev); 1873 struct orinoco_private *priv =
1874 container_of(work, struct orinoco_private, reset_work);
1875 struct net_device *dev = priv->ndev;
1870 struct hermes *hw = &priv->hw; 1876 struct hermes *hw = &priv->hw;
1871 int err; 1877 int err;
1872 unsigned long flags; 1878 unsigned long flags;
@@ -2434,9 +2440,9 @@ struct net_device *alloc_orinocodev(int sizeof_card,
2434 priv->hw_unavailable = 1; /* orinoco_init() must clear this 2440 priv->hw_unavailable = 1; /* orinoco_init() must clear this
2435 * before anything else touches the 2441 * before anything else touches the
2436 * hardware */ 2442 * hardware */
2437 INIT_WORK(&priv->reset_work, (void (*)(void *))orinoco_reset, dev); 2443 INIT_WORK(&priv->reset_work, orinoco_reset);
2438 INIT_WORK(&priv->join_work, (void (*)(void *))orinoco_join_ap, dev); 2444 INIT_WORK(&priv->join_work, orinoco_join_ap);
2439 INIT_WORK(&priv->wevent_work, (void (*)(void *))orinoco_send_wevents, dev); 2445 INIT_WORK(&priv->wevent_work, orinoco_send_wevents);
2440 2446
2441 netif_carrier_off(dev); 2447 netif_carrier_off(dev);
2442 priv->last_linkstatus = 0xffff; 2448 priv->last_linkstatus = 0xffff;
@@ -3608,7 +3614,7 @@ static int orinoco_ioctl_reset(struct net_device *dev,
3608 printk(KERN_DEBUG "%s: Forcing reset!\n", dev->name); 3614 printk(KERN_DEBUG "%s: Forcing reset!\n", dev->name);
3609 3615
3610 /* Firmware reset */ 3616 /* Firmware reset */
3611 orinoco_reset(dev); 3617 orinoco_reset(&priv->reset_work);
3612 } else { 3618 } else {
3613 printk(KERN_DEBUG "%s: Force scheduling reset!\n", dev->name); 3619 printk(KERN_DEBUG "%s: Force scheduling reset!\n", dev->name);
3614 3620
@@ -4154,7 +4160,7 @@ static int orinoco_ioctl_commit(struct net_device *dev,
4154 return 0; 4160 return 0;
4155 4161
4156 if (priv->broken_disableport) { 4162 if (priv->broken_disableport) {
4157 orinoco_reset(dev); 4163 orinoco_reset(&priv->reset_work);
4158 return 0; 4164 return 0;
4159 } 4165 }
4160 4166
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c
index 4a20e45de3ca..a87eb51886c8 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.c
+++ b/drivers/net/wireless/prism54/isl_ioctl.c
@@ -157,8 +157,9 @@ prism54_mib_init(islpci_private *priv)
157 * schedule_work(), thus we can as well use sleeping semaphore 157 * schedule_work(), thus we can as well use sleeping semaphore
158 * locking */ 158 * locking */
159void 159void
160prism54_update_stats(islpci_private *priv) 160prism54_update_stats(struct work_struct *work)
161{ 161{
162 islpci_private *priv = container_of(work, islpci_private, stats_work);
162 char *data; 163 char *data;
163 int j; 164 int j;
164 struct obj_bss bss, *bss2; 165 struct obj_bss bss, *bss2;
@@ -2493,9 +2494,10 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2493 * interrupt context, no locks held. 2494 * interrupt context, no locks held.
2494 */ 2495 */
2495void 2496void
2496prism54_process_trap(void *data) 2497prism54_process_trap(struct work_struct *work)
2497{ 2498{
2498 struct islpci_mgmtframe *frame = data; 2499 struct islpci_mgmtframe *frame =
2500 container_of(work, struct islpci_mgmtframe, ws);
2499 struct net_device *ndev = frame->ndev; 2501 struct net_device *ndev = frame->ndev;
2500 enum oid_num_t n = mgt_oidtonum(frame->header->oid); 2502 enum oid_num_t n = mgt_oidtonum(frame->header->oid);
2501 2503
diff --git a/drivers/net/wireless/prism54/isl_ioctl.h b/drivers/net/wireless/prism54/isl_ioctl.h
index e8183d30c52e..bcfbfb9281d2 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.h
+++ b/drivers/net/wireless/prism54/isl_ioctl.h
@@ -31,12 +31,12 @@
31void prism54_mib_init(islpci_private *); 31void prism54_mib_init(islpci_private *);
32 32
33struct iw_statistics *prism54_get_wireless_stats(struct net_device *); 33struct iw_statistics *prism54_get_wireless_stats(struct net_device *);
34void prism54_update_stats(islpci_private *); 34void prism54_update_stats(struct work_struct *);
35 35
36void prism54_acl_init(struct islpci_acl *); 36void prism54_acl_init(struct islpci_acl *);
37void prism54_acl_clean(struct islpci_acl *); 37void prism54_acl_clean(struct islpci_acl *);
38 38
39void prism54_process_trap(void *); 39void prism54_process_trap(struct work_struct *);
40 40
41void prism54_wpa_bss_ie_init(islpci_private *priv); 41void prism54_wpa_bss_ie_init(islpci_private *priv);
42void prism54_wpa_bss_ie_clean(islpci_private *priv); 42void prism54_wpa_bss_ie_clean(islpci_private *priv);
diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c
index 1e0603ca436c..f057fd9fcd79 100644
--- a/drivers/net/wireless/prism54/islpci_dev.c
+++ b/drivers/net/wireless/prism54/islpci_dev.c
@@ -860,11 +860,10 @@ islpci_setup(struct pci_dev *pdev)
860 priv->state_off = 1; 860 priv->state_off = 1;
861 861
862 /* initialize workqueue's */ 862 /* initialize workqueue's */
863 INIT_WORK(&priv->stats_work, 863 INIT_WORK(&priv->stats_work, prism54_update_stats);
864 (void (*)(void *)) prism54_update_stats, priv);
865 priv->stats_timestamp = 0; 864 priv->stats_timestamp = 0;
866 865
867 INIT_WORK(&priv->reset_task, islpci_do_reset_and_wake, priv); 866 INIT_WORK(&priv->reset_task, islpci_do_reset_and_wake);
868 priv->reset_task_pending = 0; 867 priv->reset_task_pending = 0;
869 868
870 /* allocate various memory areas */ 869 /* allocate various memory areas */
diff --git a/drivers/net/wireless/prism54/islpci_eth.c b/drivers/net/wireless/prism54/islpci_eth.c
index 676d83813dc8..b1122912ee2d 100644
--- a/drivers/net/wireless/prism54/islpci_eth.c
+++ b/drivers/net/wireless/prism54/islpci_eth.c
@@ -480,9 +480,9 @@ islpci_eth_receive(islpci_private *priv)
480} 480}
481 481
482void 482void
483islpci_do_reset_and_wake(void *data) 483islpci_do_reset_and_wake(struct work_struct *work)
484{ 484{
485 islpci_private *priv = data; 485 islpci_private *priv = container_of(work, islpci_private, reset_task);
486 486
487 islpci_reset(priv, 1); 487 islpci_reset(priv, 1);
488 priv->reset_task_pending = 0; 488 priv->reset_task_pending = 0;
diff --git a/drivers/net/wireless/prism54/islpci_eth.h b/drivers/net/wireless/prism54/islpci_eth.h
index 26789454067c..5bf820defbd0 100644
--- a/drivers/net/wireless/prism54/islpci_eth.h
+++ b/drivers/net/wireless/prism54/islpci_eth.h
@@ -67,6 +67,6 @@ void islpci_eth_cleanup_transmit(islpci_private *, isl38xx_control_block *);
67int islpci_eth_transmit(struct sk_buff *, struct net_device *); 67int islpci_eth_transmit(struct sk_buff *, struct net_device *);
68int islpci_eth_receive(islpci_private *); 68int islpci_eth_receive(islpci_private *);
69void islpci_eth_tx_timeout(struct net_device *); 69void islpci_eth_tx_timeout(struct net_device *);
70void islpci_do_reset_and_wake(void *data); 70void islpci_do_reset_and_wake(struct work_struct *);
71 71
72#endif /* _ISL_GEN_H */ 72#endif /* _ISL_GEN_H */
diff --git a/drivers/net/wireless/prism54/islpci_mgt.c b/drivers/net/wireless/prism54/islpci_mgt.c
index 036a875054c9..2246f7930b4e 100644
--- a/drivers/net/wireless/prism54/islpci_mgt.c
+++ b/drivers/net/wireless/prism54/islpci_mgt.c
@@ -386,7 +386,7 @@ islpci_mgt_receive(struct net_device *ndev)
386 386
387 /* Create work to handle trap out of interrupt 387 /* Create work to handle trap out of interrupt
388 * context. */ 388 * context. */
389 INIT_WORK(&frame->ws, prism54_process_trap, frame); 389 INIT_WORK(&frame->ws, prism54_process_trap);
390 schedule_work(&frame->ws); 390 schedule_work(&frame->ws);
391 391
392 } else { 392 } else {
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 2696f95b9278..f1573a9c2336 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -32,8 +32,8 @@
32 32
33static void ieee_init(struct ieee80211_device *ieee); 33static void ieee_init(struct ieee80211_device *ieee);
34static void softmac_init(struct ieee80211softmac_device *sm); 34static void softmac_init(struct ieee80211softmac_device *sm);
35static void set_rts_cts_work(void *d); 35static void set_rts_cts_work(struct work_struct *work);
36static void set_basic_rates_work(void *d); 36static void set_basic_rates_work(struct work_struct *work);
37 37
38static void housekeeping_init(struct zd_mac *mac); 38static void housekeeping_init(struct zd_mac *mac);
39static void housekeeping_enable(struct zd_mac *mac); 39static void housekeeping_enable(struct zd_mac *mac);
@@ -48,8 +48,8 @@ int zd_mac_init(struct zd_mac *mac,
48 memset(mac, 0, sizeof(*mac)); 48 memset(mac, 0, sizeof(*mac));
49 spin_lock_init(&mac->lock); 49 spin_lock_init(&mac->lock);
50 mac->netdev = netdev; 50 mac->netdev = netdev;
51 INIT_WORK(&mac->set_rts_cts_work, set_rts_cts_work, mac); 51 INIT_DELAYED_WORK(&mac->set_rts_cts_work, set_rts_cts_work);
52 INIT_WORK(&mac->set_basic_rates_work, set_basic_rates_work, mac); 52 INIT_DELAYED_WORK(&mac->set_basic_rates_work, set_basic_rates_work);
53 53
54 ieee_init(ieee); 54 ieee_init(ieee);
55 softmac_init(ieee80211_priv(netdev)); 55 softmac_init(ieee80211_priv(netdev));
@@ -366,9 +366,10 @@ static void try_enable_tx(struct zd_mac *mac)
366 spin_unlock_irqrestore(&mac->lock, flags); 366 spin_unlock_irqrestore(&mac->lock, flags);
367} 367}
368 368
369static void set_rts_cts_work(void *d) 369static void set_rts_cts_work(struct work_struct *work)
370{ 370{
371 struct zd_mac *mac = d; 371 struct zd_mac *mac =
372 container_of(work, struct zd_mac, set_rts_cts_work.work);
372 unsigned long flags; 373 unsigned long flags;
373 u8 rts_rate; 374 u8 rts_rate;
374 unsigned int short_preamble; 375 unsigned int short_preamble;
@@ -387,9 +388,10 @@ static void set_rts_cts_work(void *d)
387 try_enable_tx(mac); 388 try_enable_tx(mac);
388} 389}
389 390
390static void set_basic_rates_work(void *d) 391static void set_basic_rates_work(struct work_struct *work)
391{ 392{
392 struct zd_mac *mac = d; 393 struct zd_mac *mac =
394 container_of(work, struct zd_mac, set_basic_rates_work.work);
393 unsigned long flags; 395 unsigned long flags;
394 u16 basic_rates; 396 u16 basic_rates;
395 397
@@ -467,12 +469,13 @@ static void bssinfo_change(struct net_device *netdev, u32 changes)
467 if (need_set_rts_cts && !mac->updating_rts_rate) { 469 if (need_set_rts_cts && !mac->updating_rts_rate) {
468 mac->updating_rts_rate = 1; 470 mac->updating_rts_rate = 1;
469 netif_stop_queue(mac->netdev); 471 netif_stop_queue(mac->netdev);
470 queue_work(zd_workqueue, &mac->set_rts_cts_work); 472 queue_delayed_work(zd_workqueue, &mac->set_rts_cts_work, 0);
471 } 473 }
472 if (need_set_rates && !mac->updating_basic_rates) { 474 if (need_set_rates && !mac->updating_basic_rates) {
473 mac->updating_basic_rates = 1; 475 mac->updating_basic_rates = 1;
474 netif_stop_queue(mac->netdev); 476 netif_stop_queue(mac->netdev);
475 queue_work(zd_workqueue, &mac->set_basic_rates_work); 477 queue_delayed_work(zd_workqueue, &mac->set_basic_rates_work,
478 0);
476 } 479 }
477 spin_unlock_irqrestore(&mac->lock, flags); 480 spin_unlock_irqrestore(&mac->lock, flags);
478} 481}
@@ -1182,9 +1185,10 @@ struct iw_statistics *zd_mac_get_wireless_stats(struct net_device *ndev)
1182 1185
1183#define LINK_LED_WORK_DELAY HZ 1186#define LINK_LED_WORK_DELAY HZ
1184 1187
1185static void link_led_handler(void *p) 1188static void link_led_handler(struct work_struct *work)
1186{ 1189{
1187 struct zd_mac *mac = p; 1190 struct zd_mac *mac =
1191 container_of(work, struct zd_mac, housekeeping.link_led_work.work);
1188 struct zd_chip *chip = &mac->chip; 1192 struct zd_chip *chip = &mac->chip;
1189 struct ieee80211softmac_device *sm = ieee80211_priv(mac->netdev); 1193 struct ieee80211softmac_device *sm = ieee80211_priv(mac->netdev);
1190 int is_associated; 1194 int is_associated;
@@ -1205,7 +1209,7 @@ static void link_led_handler(void *p)
1205 1209
1206static void housekeeping_init(struct zd_mac *mac) 1210static void housekeeping_init(struct zd_mac *mac)
1207{ 1211{
1208 INIT_WORK(&mac->housekeeping.link_led_work, link_led_handler, mac); 1212 INIT_DELAYED_WORK(&mac->housekeeping.link_led_work, link_led_handler);
1209} 1213}
1210 1214
1211static void housekeeping_enable(struct zd_mac *mac) 1215static void housekeeping_enable(struct zd_mac *mac)
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h
index 5dcfb251f02e..d4e8b870409d 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.h
+++ b/drivers/net/wireless/zd1211rw/zd_mac.h
@@ -119,7 +119,7 @@ struct rx_status {
119#define ZD_RX_ERROR 0x80 119#define ZD_RX_ERROR 0x80
120 120
121struct housekeeping { 121struct housekeeping {
122 struct work_struct link_led_work; 122 struct delayed_work link_led_work;
123}; 123};
124 124
125#define ZD_MAC_STATS_BUFFER_SIZE 16 125#define ZD_MAC_STATS_BUFFER_SIZE 16
@@ -133,8 +133,8 @@ struct zd_mac {
133 struct iw_statistics iw_stats; 133 struct iw_statistics iw_stats;
134 134
135 struct housekeeping housekeeping; 135 struct housekeeping housekeeping;
136 struct work_struct set_rts_cts_work; 136 struct delayed_work set_rts_cts_work;
137 struct work_struct set_basic_rates_work; 137 struct delayed_work set_basic_rates_work;
138 138
139 unsigned int stats_count; 139 unsigned int stats_count;
140 u8 qual_buffer[ZD_MAC_STATS_BUFFER_SIZE]; 140 u8 qual_buffer[ZD_MAC_STATS_BUFFER_SIZE];
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index fc4bc9b94c74..a83c3db7d18f 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -29,7 +29,7 @@
29 29
30struct oprofile_cpu_buffer cpu_buffer[NR_CPUS] __cacheline_aligned; 30struct oprofile_cpu_buffer cpu_buffer[NR_CPUS] __cacheline_aligned;
31 31
32static void wq_sync_buffer(void *); 32static void wq_sync_buffer(struct work_struct *work);
33 33
34#define DEFAULT_TIMER_EXPIRE (HZ / 10) 34#define DEFAULT_TIMER_EXPIRE (HZ / 10)
35static int work_enabled; 35static int work_enabled;
@@ -65,7 +65,7 @@ int alloc_cpu_buffers(void)
65 b->sample_received = 0; 65 b->sample_received = 0;
66 b->sample_lost_overflow = 0; 66 b->sample_lost_overflow = 0;
67 b->cpu = i; 67 b->cpu = i;
68 INIT_WORK(&b->work, wq_sync_buffer, b); 68 INIT_DELAYED_WORK(&b->work, wq_sync_buffer);
69 } 69 }
70 return 0; 70 return 0;
71 71
@@ -282,9 +282,10 @@ void oprofile_add_trace(unsigned long pc)
282 * By using schedule_delayed_work_on and then schedule_delayed_work 282 * By using schedule_delayed_work_on and then schedule_delayed_work
283 * we guarantee this will stay on the correct cpu 283 * we guarantee this will stay on the correct cpu
284 */ 284 */
285static void wq_sync_buffer(void * data) 285static void wq_sync_buffer(struct work_struct *work)
286{ 286{
287 struct oprofile_cpu_buffer * b = data; 287 struct oprofile_cpu_buffer * b =
288 container_of(work, struct oprofile_cpu_buffer, work.work);
288 if (b->cpu != smp_processor_id()) { 289 if (b->cpu != smp_processor_id()) {
289 printk("WQ on CPU%d, prefer CPU%d\n", 290 printk("WQ on CPU%d, prefer CPU%d\n",
290 smp_processor_id(), b->cpu); 291 smp_processor_id(), b->cpu);
diff --git a/drivers/oprofile/cpu_buffer.h b/drivers/oprofile/cpu_buffer.h
index 09abb80e0570..49900d9e3235 100644
--- a/drivers/oprofile/cpu_buffer.h
+++ b/drivers/oprofile/cpu_buffer.h
@@ -43,7 +43,7 @@ struct oprofile_cpu_buffer {
43 unsigned long sample_lost_overflow; 43 unsigned long sample_lost_overflow;
44 unsigned long backtrace_aborted; 44 unsigned long backtrace_aborted;
45 int cpu; 45 int cpu;
46 struct work_struct work; 46 struct delayed_work work;
47} ____cacheline_aligned; 47} ____cacheline_aligned;
48 48
49extern struct oprofile_cpu_buffer cpu_buffer[]; 49extern struct oprofile_cpu_buffer cpu_buffer[];
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index 39c96641bc72..b61c17b3e298 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -1975,7 +1975,7 @@ static int __devinit parport_ECPPS2_supported(struct parport *pb){return 0;}
1975/* --- IRQ detection -------------------------------------- */ 1975/* --- IRQ detection -------------------------------------- */
1976 1976
1977/* Only if supports ECP mode */ 1977/* Only if supports ECP mode */
1978static int __devinit programmable_irq_support(struct parport *pb) 1978static int programmable_irq_support(struct parport *pb)
1979{ 1979{
1980 int irq, intrLine; 1980 int irq, intrLine;
1981 unsigned char oecr = inb (ECONTROL (pb)); 1981 unsigned char oecr = inb (ECONTROL (pb));
@@ -1992,7 +1992,7 @@ static int __devinit programmable_irq_support(struct parport *pb)
1992 return irq; 1992 return irq;
1993} 1993}
1994 1994
1995static int __devinit irq_probe_ECP(struct parport *pb) 1995static int irq_probe_ECP(struct parport *pb)
1996{ 1996{
1997 int i; 1997 int i;
1998 unsigned long irqs; 1998 unsigned long irqs;
@@ -2020,7 +2020,7 @@ static int __devinit irq_probe_ECP(struct parport *pb)
2020 * This detection seems that only works in National Semiconductors 2020 * This detection seems that only works in National Semiconductors
2021 * This doesn't work in SMC, LGS, and Winbond 2021 * This doesn't work in SMC, LGS, and Winbond
2022 */ 2022 */
2023static int __devinit irq_probe_EPP(struct parport *pb) 2023static int irq_probe_EPP(struct parport *pb)
2024{ 2024{
2025#ifndef ADVANCED_DETECT 2025#ifndef ADVANCED_DETECT
2026 return PARPORT_IRQ_NONE; 2026 return PARPORT_IRQ_NONE;
@@ -2059,7 +2059,7 @@ static int __devinit irq_probe_EPP(struct parport *pb)
2059#endif /* Advanced detection */ 2059#endif /* Advanced detection */
2060} 2060}
2061 2061
2062static int __devinit irq_probe_SPP(struct parport *pb) 2062static int irq_probe_SPP(struct parport *pb)
2063{ 2063{
2064 /* Don't even try to do this. */ 2064 /* Don't even try to do this. */
2065 return PARPORT_IRQ_NONE; 2065 return PARPORT_IRQ_NONE;
@@ -2747,6 +2747,7 @@ enum parport_pc_pci_cards {
2747 titan_1284p2, 2747 titan_1284p2,
2748 avlab_1p, 2748 avlab_1p,
2749 avlab_2p, 2749 avlab_2p,
2750 oxsemi_952,
2750 oxsemi_954, 2751 oxsemi_954,
2751 oxsemi_840, 2752 oxsemi_840,
2752 aks_0100, 2753 aks_0100,
@@ -2822,6 +2823,7 @@ static struct parport_pc_pci {
2822 /* avlab_2p */ { 2, { { 0, 1}, { 2, 3 },} }, 2823 /* avlab_2p */ { 2, { { 0, 1}, { 2, 3 },} },
2823 /* The Oxford Semi cards are unusual: 954 doesn't support ECP, 2824 /* The Oxford Semi cards are unusual: 954 doesn't support ECP,
2824 * and 840 locks up if you write 1 to bit 2! */ 2825 * and 840 locks up if you write 1 to bit 2! */
2826 /* oxsemi_952 */ { 1, { { 0, 1 }, } },
2825 /* oxsemi_954 */ { 1, { { 0, -1 }, } }, 2827 /* oxsemi_954 */ { 1, { { 0, -1 }, } },
2826 /* oxsemi_840 */ { 1, { { 0, -1 }, } }, 2828 /* oxsemi_840 */ { 1, { { 0, -1 }, } },
2827 /* aks_0100 */ { 1, { { 0, -1 }, } }, 2829 /* aks_0100 */ { 1, { { 0, -1 }, } },
@@ -2895,6 +2897,8 @@ static const struct pci_device_id parport_pc_pci_tbl[] = {
2895 /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/ 2897 /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/
2896 { 0x14db, 0x2120, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1p}, /* AFAVLAB_TK9902 */ 2898 { 0x14db, 0x2120, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1p}, /* AFAVLAB_TK9902 */
2897 { 0x14db, 0x2121, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2p}, 2899 { 0x14db, 0x2121, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2p},
2900 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI952PP,
2901 PCI_ANY_ID, PCI_ANY_ID, 0, 0, oxsemi_952 },
2898 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI954PP, 2902 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI954PP,
2899 PCI_ANY_ID, PCI_ANY_ID, 0, 0, oxsemi_954 }, 2903 PCI_ANY_ID, PCI_ANY_ID, 0, 0, oxsemi_954 },
2900 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_12PCI840, 2904 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_12PCI840,
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index ea2087c34149..50757695844f 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -70,7 +70,7 @@ struct slot {
70 struct hotplug_slot *hotplug_slot; 70 struct hotplug_slot *hotplug_slot;
71 struct list_head slot_list; 71 struct list_head slot_list;
72 char name[SLOT_NAME_SIZE]; 72 char name[SLOT_NAME_SIZE];
73 struct work_struct work; /* work for button event */ 73 struct delayed_work work; /* work for button event */
74 struct mutex lock; 74 struct mutex lock;
75}; 75};
76 76
@@ -187,7 +187,7 @@ extern int shpchp_configure_device(struct slot *p_slot);
187extern int shpchp_unconfigure_device(struct slot *p_slot); 187extern int shpchp_unconfigure_device(struct slot *p_slot);
188extern void shpchp_remove_ctrl_files(struct controller *ctrl); 188extern void shpchp_remove_ctrl_files(struct controller *ctrl);
189extern void cleanup_slots(struct controller *ctrl); 189extern void cleanup_slots(struct controller *ctrl);
190extern void queue_pushbutton_work(void *data); 190extern void queue_pushbutton_work(struct work_struct *work);
191 191
192 192
193#ifdef CONFIG_ACPI 193#ifdef CONFIG_ACPI
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index 235c18a22393..4eac85b3d90e 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -159,7 +159,7 @@ static int init_slots(struct controller *ctrl)
159 goto error_info; 159 goto error_info;
160 160
161 slot->number = sun; 161 slot->number = sun;
162 INIT_WORK(&slot->work, queue_pushbutton_work, slot); 162 INIT_DELAYED_WORK(&slot->work, queue_pushbutton_work);
163 163
164 /* register this slot with the hotplug pci core */ 164 /* register this slot with the hotplug pci core */
165 hotplug_slot->private = slot; 165 hotplug_slot->private = slot;
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index c39901dbff20..158ac7836096 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -36,7 +36,7 @@
36#include "../pci.h" 36#include "../pci.h"
37#include "shpchp.h" 37#include "shpchp.h"
38 38
39static void interrupt_event_handler(void *data); 39static void interrupt_event_handler(struct work_struct *work);
40static int shpchp_enable_slot(struct slot *p_slot); 40static int shpchp_enable_slot(struct slot *p_slot);
41static int shpchp_disable_slot(struct slot *p_slot); 41static int shpchp_disable_slot(struct slot *p_slot);
42 42
@@ -50,7 +50,7 @@ static int queue_interrupt_event(struct slot *p_slot, u32 event_type)
50 50
51 info->event_type = event_type; 51 info->event_type = event_type;
52 info->p_slot = p_slot; 52 info->p_slot = p_slot;
53 INIT_WORK(&info->work, interrupt_event_handler, info); 53 INIT_WORK(&info->work, interrupt_event_handler);
54 54
55 schedule_work(&info->work); 55 schedule_work(&info->work);
56 56
@@ -408,9 +408,10 @@ struct pushbutton_work_info {
408 * Handles all pending events and exits. 408 * Handles all pending events and exits.
409 * 409 *
410 */ 410 */
411static void shpchp_pushbutton_thread(void *data) 411static void shpchp_pushbutton_thread(struct work_struct *work)
412{ 412{
413 struct pushbutton_work_info *info = data; 413 struct pushbutton_work_info *info =
414 container_of(work, struct pushbutton_work_info, work);
414 struct slot *p_slot = info->p_slot; 415 struct slot *p_slot = info->p_slot;
415 416
416 mutex_lock(&p_slot->lock); 417 mutex_lock(&p_slot->lock);
@@ -436,9 +437,9 @@ static void shpchp_pushbutton_thread(void *data)
436 kfree(info); 437 kfree(info);
437} 438}
438 439
439void queue_pushbutton_work(void *data) 440void queue_pushbutton_work(struct work_struct *work)
440{ 441{
441 struct slot *p_slot = data; 442 struct slot *p_slot = container_of(work, struct slot, work.work);
442 struct pushbutton_work_info *info; 443 struct pushbutton_work_info *info;
443 444
444 info = kmalloc(sizeof(*info), GFP_KERNEL); 445 info = kmalloc(sizeof(*info), GFP_KERNEL);
@@ -447,7 +448,7 @@ void queue_pushbutton_work(void *data)
447 return; 448 return;
448 } 449 }
449 info->p_slot = p_slot; 450 info->p_slot = p_slot;
450 INIT_WORK(&info->work, shpchp_pushbutton_thread, info); 451 INIT_WORK(&info->work, shpchp_pushbutton_thread);
451 452
452 mutex_lock(&p_slot->lock); 453 mutex_lock(&p_slot->lock);
453 switch (p_slot->state) { 454 switch (p_slot->state) {
@@ -541,9 +542,9 @@ static void handle_button_press_event(struct slot *p_slot)
541 } 542 }
542} 543}
543 544
544static void interrupt_event_handler(void *data) 545static void interrupt_event_handler(struct work_struct *work)
545{ 546{
546 struct event_info *info = data; 547 struct event_info *info = container_of(work, struct event_info, work);
547 struct slot *p_slot = info->p_slot; 548 struct slot *p_slot = info->p_slot;
548 549
549 mutex_lock(&p_slot->lock); 550 mutex_lock(&p_slot->lock);
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 9fc9a34ef24a..9168401401bc 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -26,7 +26,7 @@
26 26
27static DEFINE_SPINLOCK(msi_lock); 27static DEFINE_SPINLOCK(msi_lock);
28static struct msi_desc* msi_desc[NR_IRQS] = { [0 ... NR_IRQS-1] = NULL }; 28static struct msi_desc* msi_desc[NR_IRQS] = { [0 ... NR_IRQS-1] = NULL };
29static kmem_cache_t* msi_cachep; 29static struct kmem_cache* msi_cachep;
30 30
31static int pci_msi_enable = 1; 31static int pci_msi_enable = 1;
32 32
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c
index 04c43ef529ac..55866b6b26fa 100644
--- a/drivers/pci/pcie/aer/aerdrv.c
+++ b/drivers/pci/pcie/aer/aerdrv.c
@@ -160,7 +160,7 @@ static struct aer_rpc* aer_alloc_rpc(struct pcie_device *dev)
160 rpc->e_lock = SPIN_LOCK_UNLOCKED; 160 rpc->e_lock = SPIN_LOCK_UNLOCKED;
161 161
162 rpc->rpd = dev; 162 rpc->rpd = dev;
163 INIT_WORK(&rpc->dpc_handler, aer_isr, (void *)dev); 163 INIT_WORK(&rpc->dpc_handler, aer_isr);
164 rpc->prod_idx = rpc->cons_idx = 0; 164 rpc->prod_idx = rpc->cons_idx = 0;
165 mutex_init(&rpc->rpc_mutex); 165 mutex_init(&rpc->rpc_mutex);
166 init_waitqueue_head(&rpc->wait_release); 166 init_waitqueue_head(&rpc->wait_release);
diff --git a/drivers/pci/pcie/aer/aerdrv.h b/drivers/pci/pcie/aer/aerdrv.h
index daf0cad88fc8..3c0a58f64dd8 100644
--- a/drivers/pci/pcie/aer/aerdrv.h
+++ b/drivers/pci/pcie/aer/aerdrv.h
@@ -118,7 +118,7 @@ extern struct bus_type pcie_port_bus_type;
118extern void aer_enable_rootport(struct aer_rpc *rpc); 118extern void aer_enable_rootport(struct aer_rpc *rpc);
119extern void aer_delete_rootport(struct aer_rpc *rpc); 119extern void aer_delete_rootport(struct aer_rpc *rpc);
120extern int aer_init(struct pcie_device *dev); 120extern int aer_init(struct pcie_device *dev);
121extern void aer_isr(void *context); 121extern void aer_isr(struct work_struct *work);
122extern void aer_print_error(struct pci_dev *dev, struct aer_err_info *info); 122extern void aer_print_error(struct pci_dev *dev, struct aer_err_info *info);
123extern int aer_osc_setup(struct pci_dev *dev); 123extern int aer_osc_setup(struct pci_dev *dev);
124 124
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
index 1c7e660d6535..08e13033ced8 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -690,14 +690,14 @@ static void aer_isr_one_error(struct pcie_device *p_device,
690 690
691/** 691/**
692 * aer_isr - consume errors detected by root port 692 * aer_isr - consume errors detected by root port
693 * @context: pointer to a private data of pcie device 693 * @work: definition of this work item
694 * 694 *
695 * Invoked, as DPC, when root port records new detected error 695 * Invoked, as DPC, when root port records new detected error
696 **/ 696 **/
697void aer_isr(void *context) 697void aer_isr(struct work_struct *work)
698{ 698{
699 struct pcie_device *p_device = (struct pcie_device *) context; 699 struct aer_rpc *rpc = container_of(work, struct aer_rpc, dpc_handler);
700 struct aer_rpc *rpc = get_service_data(p_device); 700 struct pcie_device *p_device = rpc->rpd;
701 struct aer_err_source *e_src; 701 struct aer_err_source *e_src;
702 702
703 mutex_lock(&rpc->rpc_mutex); 703 mutex_lock(&rpc->rpc_mutex);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 0eeac60042b3..6a3c1e728900 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -873,6 +873,7 @@ void __devinit pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
873 dev->dev.release = pci_release_dev; 873 dev->dev.release = pci_release_dev;
874 pci_dev_get(dev); 874 pci_dev_get(dev);
875 875
876 set_dev_node(&dev->dev, pcibus_to_node(bus));
876 dev->dev.dma_mask = &dev->dma_mask; 877 dev->dev.dma_mask = &dev->dma_mask;
877 dev->dev.coherent_dma_mask = 0xffffffffull; 878 dev->dev.coherent_dma_mask = 0xffffffffull;
878 879
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index f9cd831a3f31..606a46740338 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -29,6 +29,7 @@
29#include <linux/pci.h> 29#include <linux/pci.h>
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/kthread.h> 31#include <linux/kthread.h>
32#include <linux/freezer.h>
32#include <asm/system.h> 33#include <asm/system.h>
33#include <asm/irq.h> 34#include <asm/irq.h>
34 35
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 45df12eda3c5..7355eb455a88 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -675,9 +675,10 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
675} 675}
676 676
677 677
678static void pcmcia_delayed_add_device(void *data) 678static void pcmcia_delayed_add_device(struct work_struct *work)
679{ 679{
680 struct pcmcia_socket *s = data; 680 struct pcmcia_socket *s =
681 container_of(work, struct pcmcia_socket, device_add);
681 ds_dbg(1, "adding additional device to %d\n", s->sock); 682 ds_dbg(1, "adding additional device to %d\n", s->sock);
682 pcmcia_device_add(s, s->pcmcia_state.mfc_pfc); 683 pcmcia_device_add(s, s->pcmcia_state.mfc_pfc);
683 s->pcmcia_state.device_add_pending = 0; 684 s->pcmcia_state.device_add_pending = 0;
@@ -1349,7 +1350,7 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev,
1349 init_waitqueue_head(&socket->queue); 1350 init_waitqueue_head(&socket->queue);
1350#endif 1351#endif
1351 INIT_LIST_HEAD(&socket->devices_list); 1352 INIT_LIST_HEAD(&socket->devices_list);
1352 INIT_WORK(&socket->device_add, pcmcia_delayed_add_device, socket); 1353 INIT_WORK(&socket->device_add, pcmcia_delayed_add_device);
1353 memset(&socket->pcmcia_state, 0, sizeof(u8)); 1354 memset(&socket->pcmcia_state, 0, sizeof(u8));
1354 socket->device_count = 0; 1355 socket->device_count = 0;
1355 1356
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index 227600cd6360..91c047a7e635 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -164,9 +164,17 @@ static DEVICE_ATTR(card_id,S_IRUGO,pnp_show_card_ids,NULL);
164 164
165static int pnp_interface_attach_card(struct pnp_card *card) 165static int pnp_interface_attach_card(struct pnp_card *card)
166{ 166{
167 device_create_file(&card->dev,&dev_attr_name); 167 int rc = device_create_file(&card->dev,&dev_attr_name);
168 device_create_file(&card->dev,&dev_attr_card_id); 168 if (rc) return rc;
169
170 rc = device_create_file(&card->dev,&dev_attr_card_id);
171 if (rc) goto err_name;
172
169 return 0; 173 return 0;
174
175err_name:
176 device_remove_file(&card->dev,&dev_attr_name);
177 return rc;
170} 178}
171 179
172/** 180/**
@@ -306,16 +314,20 @@ found:
306 down_write(&dev->dev.bus->subsys.rwsem); 314 down_write(&dev->dev.bus->subsys.rwsem);
307 dev->card_link = clink; 315 dev->card_link = clink;
308 dev->dev.driver = &drv->link.driver; 316 dev->dev.driver = &drv->link.driver;
309 if (pnp_bus_type.probe(&dev->dev)) { 317 if (pnp_bus_type.probe(&dev->dev))
310 dev->dev.driver = NULL; 318 goto err_out;
311 dev->card_link = NULL; 319 if (device_bind_driver(&dev->dev))
312 up_write(&dev->dev.bus->subsys.rwsem); 320 goto err_out;
313 return NULL; 321
314 }
315 device_bind_driver(&dev->dev);
316 up_write(&dev->dev.bus->subsys.rwsem); 322 up_write(&dev->dev.bus->subsys.rwsem);
317 323
318 return dev; 324 return dev;
325
326err_out:
327 dev->dev.driver = NULL;
328 dev->card_link = NULL;
329 up_write(&dev->dev.bus->subsys.rwsem);
330 return NULL;
319} 331}
320 332
321/** 333/**
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index 9d8b415eca79..ac9fcd499f3f 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -461,8 +461,19 @@ static DEVICE_ATTR(id,S_IRUGO,pnp_show_current_ids,NULL);
461 461
462int pnp_interface_attach_device(struct pnp_dev *dev) 462int pnp_interface_attach_device(struct pnp_dev *dev)
463{ 463{
464 device_create_file(&dev->dev,&dev_attr_options); 464 int rc = device_create_file(&dev->dev,&dev_attr_options);
465 device_create_file(&dev->dev,&dev_attr_resources); 465 if (rc) goto err;
466 device_create_file(&dev->dev,&dev_attr_id); 466 rc = device_create_file(&dev->dev,&dev_attr_resources);
467 if (rc) goto err_opt;
468 rc = device_create_file(&dev->dev,&dev_attr_id);
469 if (rc) goto err_res;
470
467 return 0; 471 return 0;
472
473err_res:
474 device_remove_file(&dev->dev,&dev_attr_resources);
475err_opt:
476 device_remove_file(&dev->dev,&dev_attr_options);
477err:
478 return rc;
468} 479}
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
index 80066ad792f7..33adeba1a31f 100644
--- a/drivers/pnp/pnpbios/core.c
+++ b/drivers/pnp/pnpbios/core.c
@@ -61,6 +61,7 @@
61#include <linux/dmi.h> 61#include <linux/dmi.h>
62#include <linux/delay.h> 62#include <linux/delay.h>
63#include <linux/acpi.h> 63#include <linux/acpi.h>
64#include <linux/freezer.h>
64 65
65#include <asm/page.h> 66#include <asm/page.h>
66#include <asm/desc.h> 67#include <asm/desc.h>
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index fc766a7a611e..2a63ab2b47f4 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -154,15 +154,23 @@ config RTC_DRV_DS1672
154 will be called rtc-ds1672. 154 will be called rtc-ds1672.
155 155
156config RTC_DRV_DS1742 156config RTC_DRV_DS1742
157 tristate "Dallas DS1742" 157 tristate "Dallas DS1742/1743"
158 depends on RTC_CLASS 158 depends on RTC_CLASS
159 help 159 help
160 If you say yes here you get support for the 160 If you say yes here you get support for the
161 Dallas DS1742 timekeeping chip. 161 Dallas DS1742/1743 timekeeping chip.
162 162
163 This driver can also be built as a module. If so, the module 163 This driver can also be built as a module. If so, the module
164 will be called rtc-ds1742. 164 will be called rtc-ds1742.
165 165
166config RTC_DRV_OMAP
167 tristate "TI OMAP1"
168 depends on RTC_CLASS && ( \
169 ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 )
170 help
171 Say "yes" here to support the real time clock on TI OMAP1 chips.
172 This driver can also be built as a module called rtc-omap.
173
166config RTC_DRV_PCF8563 174config RTC_DRV_PCF8563
167 tristate "Philips PCF8563/Epson RTC8564" 175 tristate "Philips PCF8563/Epson RTC8564"
168 depends on RTC_CLASS && I2C 176 depends on RTC_CLASS && I2C
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 3ba5ff6e6800..bd4c45d333f0 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o
21obj-$(CONFIG_RTC_DRV_DS1307) += rtc-ds1307.o 21obj-$(CONFIG_RTC_DRV_DS1307) += rtc-ds1307.o
22obj-$(CONFIG_RTC_DRV_DS1672) += rtc-ds1672.o 22obj-$(CONFIG_RTC_DRV_DS1672) += rtc-ds1672.o
23obj-$(CONFIG_RTC_DRV_DS1742) += rtc-ds1742.o 23obj-$(CONFIG_RTC_DRV_DS1742) += rtc-ds1742.o
24obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o
24obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o 25obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o
25obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o 26obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o
26obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o 27obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index 814b9e1873f5..828b329e08e0 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -53,9 +53,10 @@ static int rtc_dev_open(struct inode *inode, struct file *file)
53 * Routine to poll RTC seconds field for change as often as possible, 53 * Routine to poll RTC seconds field for change as often as possible,
54 * after first RTC_UIE use timer to reduce polling 54 * after first RTC_UIE use timer to reduce polling
55 */ 55 */
56static void rtc_uie_task(void *data) 56static void rtc_uie_task(struct work_struct *work)
57{ 57{
58 struct rtc_device *rtc = data; 58 struct rtc_device *rtc =
59 container_of(work, struct rtc_device, uie_task);
59 struct rtc_time tm; 60 struct rtc_time tm;
60 int num = 0; 61 int num = 0;
61 int err; 62 int err;
@@ -411,7 +412,7 @@ static int rtc_dev_add_device(struct class_device *class_dev,
411 spin_lock_init(&rtc->irq_lock); 412 spin_lock_init(&rtc->irq_lock);
412 init_waitqueue_head(&rtc->irq_queue); 413 init_waitqueue_head(&rtc->irq_queue);
413#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL 414#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
414 INIT_WORK(&rtc->uie_task, rtc_uie_task, rtc); 415 INIT_WORK(&rtc->uie_task, rtc_uie_task);
415 setup_timer(&rtc->uie_timer, rtc_uie_timer, (unsigned long)rtc); 416 setup_timer(&rtc->uie_timer, rtc_uie_timer, (unsigned long)rtc);
416#endif 417#endif
417 418
diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c
index 67e816a9a39f..dfef1637bfb8 100644
--- a/drivers/rtc/rtc-ds1672.c
+++ b/drivers/rtc/rtc-ds1672.c
@@ -237,17 +237,22 @@ static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind)
237 /* read control register */ 237 /* read control register */
238 err = ds1672_get_control(client, &control); 238 err = ds1672_get_control(client, &control);
239 if (err) 239 if (err)
240 goto exit_detach; 240 goto exit_devreg;
241 241
242 if (control & DS1672_REG_CONTROL_EOSC) 242 if (control & DS1672_REG_CONTROL_EOSC)
243 dev_warn(&client->dev, "Oscillator not enabled. " 243 dev_warn(&client->dev, "Oscillator not enabled. "
244 "Set time to enable.\n"); 244 "Set time to enable.\n");
245 245
246 /* Register sysfs hooks */ 246 /* Register sysfs hooks */
247 device_create_file(&client->dev, &dev_attr_control); 247 err = device_create_file(&client->dev, &dev_attr_control);
248 if (err)
249 goto exit_devreg;
248 250
249 return 0; 251 return 0;
250 252
253exit_devreg:
254 rtc_device_unregister(rtc);
255
251exit_detach: 256exit_detach:
252 i2c_detach_client(client); 257 i2c_detach_client(client);
253 258
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c
index 6273a3d240a2..17633bfa8480 100644
--- a/drivers/rtc/rtc-ds1742.c
+++ b/drivers/rtc/rtc-ds1742.c
@@ -6,6 +6,10 @@
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 *
10 * Copyright (C) 2006 Torsten Ertbjerg Rasmussen <tr@newtec.dk>
11 * - nvram size determined from resource
12 * - this ds1742 driver now supports ds1743.
9 */ 13 */
10 14
11#include <linux/bcd.h> 15#include <linux/bcd.h>
@@ -17,20 +21,19 @@
17#include <linux/platform_device.h> 21#include <linux/platform_device.h>
18#include <linux/io.h> 22#include <linux/io.h>
19 23
20#define DRV_VERSION "0.2" 24#define DRV_VERSION "0.3"
21 25
22#define RTC_REG_SIZE 0x800 26#define RTC_SIZE 8
23#define RTC_OFFSET 0x7f8
24 27
25#define RTC_CONTROL (RTC_OFFSET + 0) 28#define RTC_CONTROL 0
26#define RTC_CENTURY (RTC_OFFSET + 0) 29#define RTC_CENTURY 0
27#define RTC_SECONDS (RTC_OFFSET + 1) 30#define RTC_SECONDS 1
28#define RTC_MINUTES (RTC_OFFSET + 2) 31#define RTC_MINUTES 2
29#define RTC_HOURS (RTC_OFFSET + 3) 32#define RTC_HOURS 3
30#define RTC_DAY (RTC_OFFSET + 4) 33#define RTC_DAY 4
31#define RTC_DATE (RTC_OFFSET + 5) 34#define RTC_DATE 5
32#define RTC_MONTH (RTC_OFFSET + 6) 35#define RTC_MONTH 6
33#define RTC_YEAR (RTC_OFFSET + 7) 36#define RTC_YEAR 7
34 37
35#define RTC_CENTURY_MASK 0x3f 38#define RTC_CENTURY_MASK 0x3f
36#define RTC_SECONDS_MASK 0x7f 39#define RTC_SECONDS_MASK 0x7f
@@ -48,7 +51,10 @@
48 51
49struct rtc_plat_data { 52struct rtc_plat_data {
50 struct rtc_device *rtc; 53 struct rtc_device *rtc;
51 void __iomem *ioaddr; 54 void __iomem *ioaddr_nvram;
55 void __iomem *ioaddr_rtc;
56 size_t size_nvram;
57 size_t size;
52 unsigned long baseaddr; 58 unsigned long baseaddr;
53 unsigned long last_jiffies; 59 unsigned long last_jiffies;
54}; 60};
@@ -57,7 +63,7 @@ static int ds1742_rtc_set_time(struct device *dev, struct rtc_time *tm)
57{ 63{
58 struct platform_device *pdev = to_platform_device(dev); 64 struct platform_device *pdev = to_platform_device(dev);
59 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 65 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
60 void __iomem *ioaddr = pdata->ioaddr; 66 void __iomem *ioaddr = pdata->ioaddr_rtc;
61 u8 century; 67 u8 century;
62 68
63 century = BIN2BCD((tm->tm_year + 1900) / 100); 69 century = BIN2BCD((tm->tm_year + 1900) / 100);
@@ -82,7 +88,7 @@ static int ds1742_rtc_read_time(struct device *dev, struct rtc_time *tm)
82{ 88{
83 struct platform_device *pdev = to_platform_device(dev); 89 struct platform_device *pdev = to_platform_device(dev);
84 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 90 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
85 void __iomem *ioaddr = pdata->ioaddr; 91 void __iomem *ioaddr = pdata->ioaddr_rtc;
86 unsigned int year, month, day, hour, minute, second, week; 92 unsigned int year, month, day, hour, minute, second, week;
87 unsigned int century; 93 unsigned int century;
88 94
@@ -127,10 +133,10 @@ static ssize_t ds1742_nvram_read(struct kobject *kobj, char *buf,
127 struct platform_device *pdev = 133 struct platform_device *pdev =
128 to_platform_device(container_of(kobj, struct device, kobj)); 134 to_platform_device(container_of(kobj, struct device, kobj));
129 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 135 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
130 void __iomem *ioaddr = pdata->ioaddr; 136 void __iomem *ioaddr = pdata->ioaddr_nvram;
131 ssize_t count; 137 ssize_t count;
132 138
133 for (count = 0; size > 0 && pos < RTC_OFFSET; count++, size--) 139 for (count = 0; size > 0 && pos < pdata->size_nvram; count++, size--)
134 *buf++ = readb(ioaddr + pos++); 140 *buf++ = readb(ioaddr + pos++);
135 return count; 141 return count;
136} 142}
@@ -141,10 +147,10 @@ static ssize_t ds1742_nvram_write(struct kobject *kobj, char *buf,
141 struct platform_device *pdev = 147 struct platform_device *pdev =
142 to_platform_device(container_of(kobj, struct device, kobj)); 148 to_platform_device(container_of(kobj, struct device, kobj));
143 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 149 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
144 void __iomem *ioaddr = pdata->ioaddr; 150 void __iomem *ioaddr = pdata->ioaddr_nvram;
145 ssize_t count; 151 ssize_t count;
146 152
147 for (count = 0; size > 0 && pos < RTC_OFFSET; count++, size--) 153 for (count = 0; size > 0 && pos < pdata->size_nvram; count++, size--)
148 writeb(*buf++, ioaddr + pos++); 154 writeb(*buf++, ioaddr + pos++);
149 return count; 155 return count;
150} 156}
@@ -155,7 +161,6 @@ static struct bin_attribute ds1742_nvram_attr = {
155 .mode = S_IRUGO | S_IWUGO, 161 .mode = S_IRUGO | S_IWUGO,
156 .owner = THIS_MODULE, 162 .owner = THIS_MODULE,
157 }, 163 },
158 .size = RTC_OFFSET,
159 .read = ds1742_nvram_read, 164 .read = ds1742_nvram_read,
160 .write = ds1742_nvram_write, 165 .write = ds1742_nvram_write,
161}; 166};
@@ -175,19 +180,23 @@ static int __init ds1742_rtc_probe(struct platform_device *pdev)
175 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); 180 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
176 if (!pdata) 181 if (!pdata)
177 return -ENOMEM; 182 return -ENOMEM;
178 if (!request_mem_region(res->start, RTC_REG_SIZE, pdev->name)) { 183 pdata->size = res->end - res->start + 1;
184 if (!request_mem_region(res->start, pdata->size, pdev->name)) {
179 ret = -EBUSY; 185 ret = -EBUSY;
180 goto out; 186 goto out;
181 } 187 }
182 pdata->baseaddr = res->start; 188 pdata->baseaddr = res->start;
183 ioaddr = ioremap(pdata->baseaddr, RTC_REG_SIZE); 189 ioaddr = ioremap(pdata->baseaddr, pdata->size);
184 if (!ioaddr) { 190 if (!ioaddr) {
185 ret = -ENOMEM; 191 ret = -ENOMEM;
186 goto out; 192 goto out;
187 } 193 }
188 pdata->ioaddr = ioaddr; 194 pdata->ioaddr_nvram = ioaddr;
195 pdata->size_nvram = pdata->size - RTC_SIZE;
196 pdata->ioaddr_rtc = ioaddr + pdata->size_nvram;
189 197
190 /* turn RTC on if it was not on */ 198 /* turn RTC on if it was not on */
199 ioaddr = pdata->ioaddr_rtc;
191 sec = readb(ioaddr + RTC_SECONDS); 200 sec = readb(ioaddr + RTC_SECONDS);
192 if (sec & RTC_STOP) { 201 if (sec & RTC_STOP) {
193 sec &= RTC_SECONDS_MASK; 202 sec &= RTC_SECONDS_MASK;
@@ -208,6 +217,8 @@ static int __init ds1742_rtc_probe(struct platform_device *pdev)
208 pdata->rtc = rtc; 217 pdata->rtc = rtc;
209 pdata->last_jiffies = jiffies; 218 pdata->last_jiffies = jiffies;
210 platform_set_drvdata(pdev, pdata); 219 platform_set_drvdata(pdev, pdata);
220 ds1742_nvram_attr.size = max(ds1742_nvram_attr.size,
221 pdata->size_nvram);
211 ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1742_nvram_attr); 222 ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1742_nvram_attr);
212 if (ret) 223 if (ret)
213 goto out; 224 goto out;
@@ -215,10 +226,10 @@ static int __init ds1742_rtc_probe(struct platform_device *pdev)
215 out: 226 out:
216 if (pdata->rtc) 227 if (pdata->rtc)
217 rtc_device_unregister(pdata->rtc); 228 rtc_device_unregister(pdata->rtc);
218 if (ioaddr) 229 if (pdata->ioaddr_nvram)
219 iounmap(ioaddr); 230 iounmap(pdata->ioaddr_nvram);
220 if (pdata->baseaddr) 231 if (pdata->baseaddr)
221 release_mem_region(pdata->baseaddr, RTC_REG_SIZE); 232 release_mem_region(pdata->baseaddr, pdata->size);
222 kfree(pdata); 233 kfree(pdata);
223 return ret; 234 return ret;
224} 235}
@@ -229,8 +240,8 @@ static int __devexit ds1742_rtc_remove(struct platform_device *pdev)
229 240
230 sysfs_remove_bin_file(&pdev->dev.kobj, &ds1742_nvram_attr); 241 sysfs_remove_bin_file(&pdev->dev.kobj, &ds1742_nvram_attr);
231 rtc_device_unregister(pdata->rtc); 242 rtc_device_unregister(pdata->rtc);
232 iounmap(pdata->ioaddr); 243 iounmap(pdata->ioaddr_nvram);
233 release_mem_region(pdata->baseaddr, RTC_REG_SIZE); 244 release_mem_region(pdata->baseaddr, pdata->size);
234 kfree(pdata); 245 kfree(pdata);
235 return 0; 246 return 0;
236} 247}
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
new file mode 100644
index 000000000000..eac5fb1fc02f
--- /dev/null
+++ b/drivers/rtc/rtc-omap.c
@@ -0,0 +1,572 @@
1/*
2 * TI OMAP1 Real Time Clock interface for Linux
3 *
4 * Copyright (C) 2003 MontaVista Software, Inc.
5 * Author: George G. Davis <gdavis@mvista.com> or <source@mvista.com>
6 *
7 * Copyright (C) 2006 David Brownell (new RTC framework)
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/module.h>
18#include <linux/ioport.h>
19#include <linux/delay.h>
20#include <linux/rtc.h>
21#include <linux/bcd.h>
22#include <linux/platform_device.h>
23
24#include <asm/io.h>
25#include <asm/mach/time.h>
26
27
28/* The OMAP1 RTC is a year/month/day/hours/minutes/seconds BCD clock
29 * with century-range alarm matching, driven by the 32kHz clock.
30 *
31 * The main user-visible ways it differs from PC RTCs are by omitting
32 * "don't care" alarm fields and sub-second periodic IRQs, and having
33 * an autoadjust mechanism to calibrate to the true oscillator rate.
34 *
35 * Board-specific wiring options include using split power mode with
36 * RTC_OFF_NOFF used as the reset signal (so the RTC won't be reset),
37 * and wiring RTC_WAKE_INT (so the RTC alarm can wake the system from
38 * low power modes). See the BOARD-SPECIFIC CUSTOMIZATION comment.
39 */
40
41#define OMAP_RTC_BASE 0xfffb4800
42
43/* RTC registers */
44#define OMAP_RTC_SECONDS_REG 0x00
45#define OMAP_RTC_MINUTES_REG 0x04
46#define OMAP_RTC_HOURS_REG 0x08
47#define OMAP_RTC_DAYS_REG 0x0C
48#define OMAP_RTC_MONTHS_REG 0x10
49#define OMAP_RTC_YEARS_REG 0x14
50#define OMAP_RTC_WEEKS_REG 0x18
51
52#define OMAP_RTC_ALARM_SECONDS_REG 0x20
53#define OMAP_RTC_ALARM_MINUTES_REG 0x24
54#define OMAP_RTC_ALARM_HOURS_REG 0x28
55#define OMAP_RTC_ALARM_DAYS_REG 0x2c
56#define OMAP_RTC_ALARM_MONTHS_REG 0x30
57#define OMAP_RTC_ALARM_YEARS_REG 0x34
58
59#define OMAP_RTC_CTRL_REG 0x40
60#define OMAP_RTC_STATUS_REG 0x44
61#define OMAP_RTC_INTERRUPTS_REG 0x48
62
63#define OMAP_RTC_COMP_LSB_REG 0x4c
64#define OMAP_RTC_COMP_MSB_REG 0x50
65#define OMAP_RTC_OSC_REG 0x54
66
67/* OMAP_RTC_CTRL_REG bit fields: */
68#define OMAP_RTC_CTRL_SPLIT (1<<7)
69#define OMAP_RTC_CTRL_DISABLE (1<<6)
70#define OMAP_RTC_CTRL_SET_32_COUNTER (1<<5)
71#define OMAP_RTC_CTRL_TEST (1<<4)
72#define OMAP_RTC_CTRL_MODE_12_24 (1<<3)
73#define OMAP_RTC_CTRL_AUTO_COMP (1<<2)
74#define OMAP_RTC_CTRL_ROUND_30S (1<<1)
75#define OMAP_RTC_CTRL_STOP (1<<0)
76
77/* OMAP_RTC_STATUS_REG bit fields: */
78#define OMAP_RTC_STATUS_POWER_UP (1<<7)
79#define OMAP_RTC_STATUS_ALARM (1<<6)
80#define OMAP_RTC_STATUS_1D_EVENT (1<<5)
81#define OMAP_RTC_STATUS_1H_EVENT (1<<4)
82#define OMAP_RTC_STATUS_1M_EVENT (1<<3)
83#define OMAP_RTC_STATUS_1S_EVENT (1<<2)
84#define OMAP_RTC_STATUS_RUN (1<<1)
85#define OMAP_RTC_STATUS_BUSY (1<<0)
86
87/* OMAP_RTC_INTERRUPTS_REG bit fields: */
88#define OMAP_RTC_INTERRUPTS_IT_ALARM (1<<3)
89#define OMAP_RTC_INTERRUPTS_IT_TIMER (1<<2)
90
91
92#define rtc_read(addr) omap_readb(OMAP_RTC_BASE + (addr))
93#define rtc_write(val, addr) omap_writeb(val, OMAP_RTC_BASE + (addr))
94
95
96/* platform_bus isn't hotpluggable, so for static linkage it'd be safe
97 * to get rid of probe() and remove() code ... too bad the driver struct
98 * remembers probe(), that's about 25% of the runtime footprint!!
99 */
100#ifndef MODULE
101#undef __devexit
102#undef __devexit_p
103#define __devexit __exit
104#define __devexit_p __exit_p
105#endif
106
107
108/* we rely on the rtc framework to handle locking (rtc->ops_lock),
109 * so the only other requirement is that register accesses which
110 * require BUSY to be clear are made with IRQs locally disabled
111 */
112static void rtc_wait_not_busy(void)
113{
114 int count = 0;
115 u8 status;
116
117 /* BUSY may stay active for 1/32768 second (~30 usec) */
118 for (count = 0; count < 50; count++) {
119 status = rtc_read(OMAP_RTC_STATUS_REG);
120 if ((status & (u8)OMAP_RTC_STATUS_BUSY) == 0)
121 break;
122 udelay(1);
123 }
124 /* now we have ~15 usec to read/write various registers */
125}
126
127static irqreturn_t rtc_irq(int irq, void *class_dev)
128{
129 unsigned long events = 0;
130 u8 irq_data;
131
132 irq_data = rtc_read(OMAP_RTC_STATUS_REG);
133
134 /* alarm irq? */
135 if (irq_data & OMAP_RTC_STATUS_ALARM) {
136 rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG);
137 events |= RTC_IRQF | RTC_AF;
138 }
139
140 /* 1/sec periodic/update irq? */
141 if (irq_data & OMAP_RTC_STATUS_1S_EVENT)
142 events |= RTC_IRQF | RTC_UF;
143
144 rtc_update_irq(class_dev, 1, events);
145
146 return IRQ_HANDLED;
147}
148
149#ifdef CONFIG_RTC_INTF_DEV
150
151static int
152omap_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
153{
154 u8 reg;
155
156 switch (cmd) {
157 case RTC_AIE_OFF:
158 case RTC_AIE_ON:
159 case RTC_UIE_OFF:
160 case RTC_UIE_ON:
161 break;
162 default:
163 return -ENOIOCTLCMD;
164 }
165
166 local_irq_disable();
167 rtc_wait_not_busy();
168 reg = rtc_read(OMAP_RTC_INTERRUPTS_REG);
169 switch (cmd) {
170 /* AIE = Alarm Interrupt Enable */
171 case RTC_AIE_OFF:
172 reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM;
173 break;
174 case RTC_AIE_ON:
175 reg |= OMAP_RTC_INTERRUPTS_IT_ALARM;
176 break;
177 /* UIE = Update Interrupt Enable (1/second) */
178 case RTC_UIE_OFF:
179 reg &= ~OMAP_RTC_INTERRUPTS_IT_TIMER;
180 break;
181 case RTC_UIE_ON:
182 reg |= OMAP_RTC_INTERRUPTS_IT_TIMER;
183 break;
184 }
185 rtc_wait_not_busy();
186 rtc_write(reg, OMAP_RTC_INTERRUPTS_REG);
187 local_irq_enable();
188
189 return 0;
190}
191
192#else
193#define omap_rtc_ioctl NULL
194#endif
195
196/* this hardware doesn't support "don't care" alarm fields */
197static int tm2bcd(struct rtc_time *tm)
198{
199 if (rtc_valid_tm(tm) != 0)
200 return -EINVAL;
201
202 tm->tm_sec = BIN2BCD(tm->tm_sec);
203 tm->tm_min = BIN2BCD(tm->tm_min);
204 tm->tm_hour = BIN2BCD(tm->tm_hour);
205 tm->tm_mday = BIN2BCD(tm->tm_mday);
206
207 tm->tm_mon = BIN2BCD(tm->tm_mon + 1);
208
209 /* epoch == 1900 */
210 if (tm->tm_year < 100 || tm->tm_year > 199)
211 return -EINVAL;
212 tm->tm_year = BIN2BCD(tm->tm_year - 100);
213
214 return 0;
215}
216
217static void bcd2tm(struct rtc_time *tm)
218{
219 tm->tm_sec = BCD2BIN(tm->tm_sec);
220 tm->tm_min = BCD2BIN(tm->tm_min);
221 tm->tm_hour = BCD2BIN(tm->tm_hour);
222 tm->tm_mday = BCD2BIN(tm->tm_mday);
223 tm->tm_mon = BCD2BIN(tm->tm_mon) - 1;
224 /* epoch == 1900 */
225 tm->tm_year = BCD2BIN(tm->tm_year) + 100;
226}
227
228
229static int omap_rtc_read_time(struct device *dev, struct rtc_time *tm)
230{
231 /* we don't report wday/yday/isdst ... */
232 local_irq_disable();
233 rtc_wait_not_busy();
234
235 tm->tm_sec = rtc_read(OMAP_RTC_SECONDS_REG);
236 tm->tm_min = rtc_read(OMAP_RTC_MINUTES_REG);
237 tm->tm_hour = rtc_read(OMAP_RTC_HOURS_REG);
238 tm->tm_mday = rtc_read(OMAP_RTC_DAYS_REG);
239 tm->tm_mon = rtc_read(OMAP_RTC_MONTHS_REG);
240 tm->tm_year = rtc_read(OMAP_RTC_YEARS_REG);
241
242 local_irq_enable();
243
244 bcd2tm(tm);
245 return 0;
246}
247
248static int omap_rtc_set_time(struct device *dev, struct rtc_time *tm)
249{
250 if (tm2bcd(tm) < 0)
251 return -EINVAL;
252 local_irq_disable();
253 rtc_wait_not_busy();
254
255 rtc_write(tm->tm_year, OMAP_RTC_YEARS_REG);
256 rtc_write(tm->tm_mon, OMAP_RTC_MONTHS_REG);
257 rtc_write(tm->tm_mday, OMAP_RTC_DAYS_REG);
258 rtc_write(tm->tm_hour, OMAP_RTC_HOURS_REG);
259 rtc_write(tm->tm_min, OMAP_RTC_MINUTES_REG);
260 rtc_write(tm->tm_sec, OMAP_RTC_SECONDS_REG);
261
262 local_irq_enable();
263
264 return 0;
265}
266
267static int omap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
268{
269 local_irq_disable();
270 rtc_wait_not_busy();
271
272 alm->time.tm_sec = rtc_read(OMAP_RTC_ALARM_SECONDS_REG);
273 alm->time.tm_min = rtc_read(OMAP_RTC_ALARM_MINUTES_REG);
274 alm->time.tm_hour = rtc_read(OMAP_RTC_ALARM_HOURS_REG);
275 alm->time.tm_mday = rtc_read(OMAP_RTC_ALARM_DAYS_REG);
276 alm->time.tm_mon = rtc_read(OMAP_RTC_ALARM_MONTHS_REG);
277 alm->time.tm_year = rtc_read(OMAP_RTC_ALARM_YEARS_REG);
278
279 local_irq_enable();
280
281 bcd2tm(&alm->time);
282 alm->pending = !!(rtc_read(OMAP_RTC_INTERRUPTS_REG)
283 & OMAP_RTC_INTERRUPTS_IT_ALARM);
284 alm->enabled = alm->pending && device_may_wakeup(dev);
285
286 return 0;
287}
288
289static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
290{
291 u8 reg;
292
293 /* Much userspace code uses RTC_ALM_SET, thus "don't care" for
294 * day/month/year specifies alarms up to 24 hours in the future.
295 * So we need to handle that ... but let's ignore the "don't care"
296 * values for hours/minutes/seconds.
297 */
298 if (alm->time.tm_mday <= 0
299 && alm->time.tm_mon < 0
300 && alm->time.tm_year < 0) {
301 struct rtc_time tm;
302 unsigned long now, then;
303
304 omap_rtc_read_time(dev, &tm);
305 rtc_tm_to_time(&tm, &now);
306
307 alm->time.tm_mday = tm.tm_mday;
308 alm->time.tm_mon = tm.tm_mon;
309 alm->time.tm_year = tm.tm_year;
310 rtc_tm_to_time(&alm->time, &then);
311
312 /* sometimes the alarm wraps into tomorrow */
313 if (then < now) {
314 rtc_time_to_tm(now + 24 * 60 * 60, &tm);
315 alm->time.tm_mday = tm.tm_mday;
316 alm->time.tm_mon = tm.tm_mon;
317 alm->time.tm_year = tm.tm_year;
318 }
319 }
320
321 if (tm2bcd(&alm->time) < 0)
322 return -EINVAL;
323
324 local_irq_disable();
325 rtc_wait_not_busy();
326
327 rtc_write(alm->time.tm_year, OMAP_RTC_ALARM_YEARS_REG);
328 rtc_write(alm->time.tm_mon, OMAP_RTC_ALARM_MONTHS_REG);
329 rtc_write(alm->time.tm_mday, OMAP_RTC_ALARM_DAYS_REG);
330 rtc_write(alm->time.tm_hour, OMAP_RTC_ALARM_HOURS_REG);
331 rtc_write(alm->time.tm_min, OMAP_RTC_ALARM_MINUTES_REG);
332 rtc_write(alm->time.tm_sec, OMAP_RTC_ALARM_SECONDS_REG);
333
334 reg = rtc_read(OMAP_RTC_INTERRUPTS_REG);
335 if (alm->enabled)
336 reg |= OMAP_RTC_INTERRUPTS_IT_ALARM;
337 else
338 reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM;
339 rtc_write(reg, OMAP_RTC_INTERRUPTS_REG);
340
341 local_irq_enable();
342
343 return 0;
344}
345
346static struct rtc_class_ops omap_rtc_ops = {
347 .ioctl = omap_rtc_ioctl,
348 .read_time = omap_rtc_read_time,
349 .set_time = omap_rtc_set_time,
350 .read_alarm = omap_rtc_read_alarm,
351 .set_alarm = omap_rtc_set_alarm,
352};
353
354static int omap_rtc_alarm;
355static int omap_rtc_timer;
356
357static int __devinit omap_rtc_probe(struct platform_device *pdev)
358{
359 struct resource *res, *mem;
360 struct rtc_device *rtc;
361 u8 reg, new_ctrl;
362
363 omap_rtc_timer = platform_get_irq(pdev, 0);
364 if (omap_rtc_timer <= 0) {
365 pr_debug("%s: no update irq?\n", pdev->name);
366 return -ENOENT;
367 }
368
369 omap_rtc_alarm = platform_get_irq(pdev, 1);
370 if (omap_rtc_alarm <= 0) {
371 pr_debug("%s: no alarm irq?\n", pdev->name);
372 return -ENOENT;
373 }
374
375 /* NOTE: using static mapping for RTC registers */
376 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
377 if (res && res->start != OMAP_RTC_BASE) {
378 pr_debug("%s: RTC registers at %08x, expected %08x\n",
379 pdev->name, (unsigned) res->start, OMAP_RTC_BASE);
380 return -ENOENT;
381 }
382
383 if (res)
384 mem = request_mem_region(res->start,
385 res->end - res->start + 1,
386 pdev->name);
387 else
388 mem = NULL;
389 if (!mem) {
390 pr_debug("%s: RTC registers at %08x are not free\n",
391 pdev->name, OMAP_RTC_BASE);
392 return -EBUSY;
393 }
394
395 rtc = rtc_device_register(pdev->name, &pdev->dev,
396 &omap_rtc_ops, THIS_MODULE);
397 if (IS_ERR(rtc)) {
398 pr_debug("%s: can't register RTC device, err %ld\n",
399 pdev->name, PTR_ERR(rtc));
400 goto fail;
401 }
402 platform_set_drvdata(pdev, rtc);
403 class_set_devdata(&rtc->class_dev, mem);
404
405 /* clear pending irqs, and set 1/second periodic,
406 * which we'll use instead of update irqs
407 */
408 rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
409
410 /* clear old status */
411 reg = rtc_read(OMAP_RTC_STATUS_REG);
412 if (reg & (u8) OMAP_RTC_STATUS_POWER_UP) {
413 pr_info("%s: RTC power up reset detected\n",
414 pdev->name);
415 rtc_write(OMAP_RTC_STATUS_POWER_UP, OMAP_RTC_STATUS_REG);
416 }
417 if (reg & (u8) OMAP_RTC_STATUS_ALARM)
418 rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG);
419
420 /* handle periodic and alarm irqs */
421 if (request_irq(omap_rtc_timer, rtc_irq, SA_INTERRUPT,
422 rtc->class_dev.class_id, &rtc->class_dev)) {
423 pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n",
424 pdev->name, omap_rtc_timer);
425 goto fail0;
426 }
427 if (request_irq(omap_rtc_alarm, rtc_irq, SA_INTERRUPT,
428 rtc->class_dev.class_id, &rtc->class_dev)) {
429 pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n",
430 pdev->name, omap_rtc_alarm);
431 goto fail1;
432 }
433
434 /* On boards with split power, RTC_ON_NOFF won't reset the RTC */
435 reg = rtc_read(OMAP_RTC_CTRL_REG);
436 if (reg & (u8) OMAP_RTC_CTRL_STOP)
437 pr_info("%s: already running\n", pdev->name);
438
439 /* force to 24 hour mode */
440 new_ctrl = reg & ~(OMAP_RTC_CTRL_SPLIT|OMAP_RTC_CTRL_AUTO_COMP);
441 new_ctrl |= OMAP_RTC_CTRL_STOP;
442
443 /* BOARD-SPECIFIC CUSTOMIZATION CAN GO HERE:
444 *
445 * - Boards wired so that RTC_WAKE_INT does something, and muxed
446 * right (W13_1610_RTC_WAKE_INT is the default after chip reset),
447 * should initialize the device wakeup flag appropriately.
448 *
449 * - Boards wired so RTC_ON_nOFF is used as the reset signal,
450 * rather than nPWRON_RESET, should forcibly enable split
451 * power mode. (Some chip errata report that RTC_CTRL_SPLIT
452 * is write-only, and always reads as zero...)
453 */
454 device_init_wakeup(&pdev->dev, 0);
455
456 if (new_ctrl & (u8) OMAP_RTC_CTRL_SPLIT)
457 pr_info("%s: split power mode\n", pdev->name);
458
459 if (reg != new_ctrl)
460 rtc_write(new_ctrl, OMAP_RTC_CTRL_REG);
461
462 return 0;
463
464fail1:
465 free_irq(omap_rtc_timer, NULL);
466fail0:
467 rtc_device_unregister(rtc);
468fail:
469 release_resource(mem);
470 return -EIO;
471}
472
473static int __devexit omap_rtc_remove(struct platform_device *pdev)
474{
475 struct rtc_device *rtc = platform_get_drvdata(pdev);;
476
477 device_init_wakeup(&pdev->dev, 0);
478
479 /* leave rtc running, but disable irqs */
480 rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
481
482 free_irq(omap_rtc_timer, rtc);
483 free_irq(omap_rtc_alarm, rtc);
484
485 release_resource(class_get_devdata(&rtc->class_dev));
486 rtc_device_unregister(rtc);
487 return 0;
488}
489
490#ifdef CONFIG_PM
491
492static struct timespec rtc_delta;
493static u8 irqstat;
494
495static int omap_rtc_suspend(struct platform_device *pdev, pm_message_t state)
496{
497 struct rtc_time rtc_tm;
498 struct timespec time;
499
500 time.tv_nsec = 0;
501 omap_rtc_read_time(NULL, &rtc_tm);
502 rtc_tm_to_time(&rtc_tm, &time.tv_sec);
503
504 save_time_delta(&rtc_delta, &time);
505 irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG);
506
507 /* FIXME the RTC alarm is not currently acting as a wakeup event
508 * source, and in fact this enable() call is just saving a flag
509 * that's never used...
510 */
511 if (device_may_wakeup(&pdev->dev))
512 enable_irq_wake(omap_rtc_alarm);
513 else
514 rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
515
516 return 0;
517}
518
519static int omap_rtc_resume(struct platform_device *pdev)
520{
521 struct rtc_time rtc_tm;
522 struct timespec time;
523
524 time.tv_nsec = 0;
525 omap_rtc_read_time(NULL, &rtc_tm);
526 rtc_tm_to_time(&rtc_tm, &time.tv_sec);
527
528 restore_time_delta(&rtc_delta, &time);
529 if (device_may_wakeup(&pdev->dev))
530 disable_irq_wake(omap_rtc_alarm);
531 else
532 rtc_write(irqstat, OMAP_RTC_INTERRUPTS_REG);
533 return 0;
534}
535
536#else
537#define omap_rtc_suspend NULL
538#define omap_rtc_resume NULL
539#endif
540
541static void omap_rtc_shutdown(struct platform_device *pdev)
542{
543 rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
544}
545
546MODULE_ALIAS("omap_rtc");
547static struct platform_driver omap_rtc_driver = {
548 .probe = omap_rtc_probe,
549 .remove = __devexit_p(omap_rtc_remove),
550 .suspend = omap_rtc_suspend,
551 .resume = omap_rtc_resume,
552 .shutdown = omap_rtc_shutdown,
553 .driver = {
554 .name = "omap_rtc",
555 .owner = THIS_MODULE,
556 },
557};
558
559static int __init rtc_init(void)
560{
561 return platform_driver_register(&omap_rtc_driver);
562}
563module_init(rtc_init);
564
565static void __exit rtc_exit(void)
566{
567 platform_driver_unregister(&omap_rtc_driver);
568}
569module_exit(rtc_exit);
570
571MODULE_AUTHOR("George G. Davis (and others)");
572MODULE_LICENSE("GPL");
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
index a44fe4efa216..e2c7698fdba3 100644
--- a/drivers/rtc/rtc-rs5c372.c
+++ b/drivers/rtc/rtc-rs5c372.c
@@ -13,7 +13,7 @@
13#include <linux/rtc.h> 13#include <linux/rtc.h>
14#include <linux/bcd.h> 14#include <linux/bcd.h>
15 15
16#define DRV_VERSION "0.2" 16#define DRV_VERSION "0.3"
17 17
18/* Addresses to scan */ 18/* Addresses to scan */
19static unsigned short normal_i2c[] = { /* 0x32,*/ I2C_CLIENT_END }; 19static unsigned short normal_i2c[] = { /* 0x32,*/ I2C_CLIENT_END };
@@ -39,6 +39,14 @@ static int rs5c372_attach(struct i2c_adapter *adapter);
39static int rs5c372_detach(struct i2c_client *client); 39static int rs5c372_detach(struct i2c_client *client);
40static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind); 40static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind);
41 41
42struct rs5c372 {
43 u8 reg_addr;
44 u8 regs[17];
45 struct i2c_msg msg[1];
46 struct i2c_client client;
47 struct rtc_device *rtc;
48};
49
42static struct i2c_driver rs5c372_driver = { 50static struct i2c_driver rs5c372_driver = {
43 .driver = { 51 .driver = {
44 .name = "rs5c372", 52 .name = "rs5c372",
@@ -49,18 +57,16 @@ static struct i2c_driver rs5c372_driver = {
49 57
50static int rs5c372_get_datetime(struct i2c_client *client, struct rtc_time *tm) 58static int rs5c372_get_datetime(struct i2c_client *client, struct rtc_time *tm)
51{ 59{
52 unsigned char buf[7] = { RS5C372_REG_BASE };
53 60
54 /* this implements the 1st reading method, according 61 struct rs5c372 *rs5c372 = i2c_get_clientdata(client);
55 * to the datasheet. buf[0] is initialized with 62 u8 *buf = &(rs5c372->regs[1]);
56 * address ptr and transmission format register. 63
64 /* this implements the 3rd reading method, according
65 * to the datasheet. rs5c372 defaults to internal
66 * address 0xF, so 0x0 is in regs[1]
57 */ 67 */
58 struct i2c_msg msgs[] = {
59 { client->addr, 0, 1, buf },
60 { client->addr, I2C_M_RD, 7, buf },
61 };
62 68
63 if ((i2c_transfer(client->adapter, msgs, 2)) != 2) { 69 if ((i2c_transfer(client->adapter, rs5c372->msg, 1)) != 1) {
64 dev_err(&client->dev, "%s: read error\n", __FUNCTION__); 70 dev_err(&client->dev, "%s: read error\n", __FUNCTION__);
65 return -EIO; 71 return -EIO;
66 } 72 }
@@ -114,23 +120,14 @@ static int rs5c372_set_datetime(struct i2c_client *client, struct rtc_time *tm)
114 120
115static int rs5c372_get_trim(struct i2c_client *client, int *osc, int *trim) 121static int rs5c372_get_trim(struct i2c_client *client, int *osc, int *trim)
116{ 122{
117 unsigned char buf = RS5C372_REG_TRIM; 123 struct rs5c372 *rs5c372 = i2c_get_clientdata(client);
118 124 u8 tmp = rs5c372->regs[RS5C372_REG_TRIM + 1];
119 struct i2c_msg msgs[] = {
120 { client->addr, 0, 1, &buf },
121 { client->addr, I2C_M_RD, 1, &buf },
122 };
123
124 if ((i2c_transfer(client->adapter, msgs, 2)) != 2) {
125 dev_err(&client->dev, "%s: read error\n", __FUNCTION__);
126 return -EIO;
127 }
128 125
129 if (osc) 126 if (osc)
130 *osc = (buf & RS5C372_TRIM_XSL) ? 32000 : 32768; 127 *osc = (tmp & RS5C372_TRIM_XSL) ? 32000 : 32768;
131 128
132 if (trim) { 129 if (trim) {
133 *trim = buf & RS5C372_TRIM_MASK; 130 *trim = tmp & RS5C372_TRIM_MASK;
134 dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, *trim); 131 dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, *trim);
135 } 132 }
136 133
@@ -201,7 +198,7 @@ static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind)
201{ 198{
202 int err = 0; 199 int err = 0;
203 struct i2c_client *client; 200 struct i2c_client *client;
204 struct rtc_device *rtc; 201 struct rs5c372 *rs5c372;
205 202
206 dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); 203 dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
207 204
@@ -210,10 +207,11 @@ static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind)
210 goto exit; 207 goto exit;
211 } 208 }
212 209
213 if (!(client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) { 210 if (!(rs5c372 = kzalloc(sizeof(struct rs5c372), GFP_KERNEL))) {
214 err = -ENOMEM; 211 err = -ENOMEM;
215 goto exit; 212 goto exit;
216 } 213 }
214 client = &rs5c372->client;
217 215
218 /* I2C client */ 216 /* I2C client */
219 client->addr = address; 217 client->addr = address;
@@ -222,32 +220,47 @@ static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind)
222 220
223 strlcpy(client->name, rs5c372_driver.driver.name, I2C_NAME_SIZE); 221 strlcpy(client->name, rs5c372_driver.driver.name, I2C_NAME_SIZE);
224 222
223 i2c_set_clientdata(client, rs5c372);
224
225 rs5c372->msg[0].addr = address;
226 rs5c372->msg[0].flags = I2C_M_RD;
227 rs5c372->msg[0].len = sizeof(rs5c372->regs);
228 rs5c372->msg[0].buf = rs5c372->regs;
229
225 /* Inform the i2c layer */ 230 /* Inform the i2c layer */
226 if ((err = i2c_attach_client(client))) 231 if ((err = i2c_attach_client(client)))
227 goto exit_kfree; 232 goto exit_kfree;
228 233
229 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); 234 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
230 235
231 rtc = rtc_device_register(rs5c372_driver.driver.name, &client->dev, 236 rs5c372->rtc = rtc_device_register(rs5c372_driver.driver.name,
232 &rs5c372_rtc_ops, THIS_MODULE); 237 &client->dev, &rs5c372_rtc_ops, THIS_MODULE);
233 238
234 if (IS_ERR(rtc)) { 239 if (IS_ERR(rs5c372->rtc)) {
235 err = PTR_ERR(rtc); 240 err = PTR_ERR(rs5c372->rtc);
236 goto exit_detach; 241 goto exit_detach;
237 } 242 }
238 243
239 i2c_set_clientdata(client, rtc); 244 err = device_create_file(&client->dev, &dev_attr_trim);
240 245 if (err)
241 device_create_file(&client->dev, &dev_attr_trim); 246 goto exit_devreg;
242 device_create_file(&client->dev, &dev_attr_osc); 247 err = device_create_file(&client->dev, &dev_attr_osc);
248 if (err)
249 goto exit_trim;
243 250
244 return 0; 251 return 0;
245 252
253exit_trim:
254 device_remove_file(&client->dev, &dev_attr_trim);
255
256exit_devreg:
257 rtc_device_unregister(rs5c372->rtc);
258
246exit_detach: 259exit_detach:
247 i2c_detach_client(client); 260 i2c_detach_client(client);
248 261
249exit_kfree: 262exit_kfree:
250 kfree(client); 263 kfree(rs5c372);
251 264
252exit: 265exit:
253 return err; 266 return err;
@@ -256,16 +269,15 @@ exit:
256static int rs5c372_detach(struct i2c_client *client) 269static int rs5c372_detach(struct i2c_client *client)
257{ 270{
258 int err; 271 int err;
259 struct rtc_device *rtc = i2c_get_clientdata(client); 272 struct rs5c372 *rs5c372 = i2c_get_clientdata(client);
260 273
261 if (rtc) 274 if (rs5c372->rtc)
262 rtc_device_unregister(rtc); 275 rtc_device_unregister(rs5c372->rtc);
263 276
264 if ((err = i2c_detach_client(client))) 277 if ((err = i2c_detach_client(client)))
265 return err; 278 return err;
266 279
267 kfree(client); 280 kfree(rs5c372);
268
269 return 0; 281 return 0;
270} 282}
271 283
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
index 6ef9c62d5032..f50a1b8e1607 100644
--- a/drivers/rtc/rtc-test.c
+++ b/drivers/rtc/rtc-test.c
@@ -123,11 +123,18 @@ static int test_probe(struct platform_device *plat_dev)
123 err = PTR_ERR(rtc); 123 err = PTR_ERR(rtc);
124 return err; 124 return err;
125 } 125 }
126 device_create_file(&plat_dev->dev, &dev_attr_irq); 126
127 err = device_create_file(&plat_dev->dev, &dev_attr_irq);
128 if (err)
129 goto err;
127 130
128 platform_set_drvdata(plat_dev, rtc); 131 platform_set_drvdata(plat_dev, rtc);
129 132
130 return 0; 133 return 0;
134
135err:
136 rtc_device_unregister(rtc);
137 return err;
131} 138}
132 139
133static int __devexit test_remove(struct platform_device *plat_dev) 140static int __devexit test_remove(struct platform_device *plat_dev)
diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c
index 522c69753bbf..9a67487d086b 100644
--- a/drivers/rtc/rtc-x1205.c
+++ b/drivers/rtc/rtc-x1205.c
@@ -562,11 +562,19 @@ static int x1205_probe(struct i2c_adapter *adapter, int address, int kind)
562 else 562 else
563 dev_err(&client->dev, "couldn't read status\n"); 563 dev_err(&client->dev, "couldn't read status\n");
564 564
565 device_create_file(&client->dev, &dev_attr_atrim); 565 err = device_create_file(&client->dev, &dev_attr_atrim);
566 device_create_file(&client->dev, &dev_attr_dtrim); 566 if (err) goto exit_devreg;
567 err = device_create_file(&client->dev, &dev_attr_dtrim);
568 if (err) goto exit_atrim;
567 569
568 return 0; 570 return 0;
569 571
572exit_atrim:
573 device_remove_file(&client->dev, &dev_attr_atrim);
574
575exit_devreg:
576 rtc_device_unregister(rtc);
577
570exit_detach: 578exit_detach:
571 i2c_detach_client(client); 579 i2c_detach_client(client);
572 580
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index a2cef57d7bcb..2af2d9b53d18 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -54,7 +54,7 @@ static void dasd_flush_request_queue(struct dasd_device *);
54static void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *); 54static void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *);
55static int dasd_flush_ccw_queue(struct dasd_device *, int); 55static int dasd_flush_ccw_queue(struct dasd_device *, int);
56static void dasd_tasklet(struct dasd_device *); 56static void dasd_tasklet(struct dasd_device *);
57static void do_kick_device(void *data); 57static void do_kick_device(struct work_struct *);
58 58
59/* 59/*
60 * SECTION: Operations on the device structure. 60 * SECTION: Operations on the device structure.
@@ -100,7 +100,7 @@ dasd_alloc_device(void)
100 (unsigned long) device); 100 (unsigned long) device);
101 INIT_LIST_HEAD(&device->ccw_queue); 101 INIT_LIST_HEAD(&device->ccw_queue);
102 init_timer(&device->timer); 102 init_timer(&device->timer);
103 INIT_WORK(&device->kick_work, do_kick_device, device); 103 INIT_WORK(&device->kick_work, do_kick_device);
104 device->state = DASD_STATE_NEW; 104 device->state = DASD_STATE_NEW;
105 device->target = DASD_STATE_NEW; 105 device->target = DASD_STATE_NEW;
106 106
@@ -407,11 +407,9 @@ dasd_change_state(struct dasd_device *device)
407 * event daemon. 407 * event daemon.
408 */ 408 */
409static void 409static void
410do_kick_device(void *data) 410do_kick_device(struct work_struct *work)
411{ 411{
412 struct dasd_device *device; 412 struct dasd_device *device = container_of(work, struct dasd_device, kick_work);
413
414 device = (struct dasd_device *) data;
415 dasd_change_state(device); 413 dasd_change_state(device);
416 dasd_schedule_bh(device); 414 dasd_schedule_bh(device);
417 dasd_put_device(device); 415 dasd_put_device(device);
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index 17fdd8c9f740..cf28ccc57948 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -25,7 +25,7 @@
25 25
26#include "dasd_int.h" 26#include "dasd_int.h"
27 27
28kmem_cache_t *dasd_page_cache; 28struct kmem_cache *dasd_page_cache;
29EXPORT_SYMBOL_GPL(dasd_page_cache); 29EXPORT_SYMBOL_GPL(dasd_page_cache);
30 30
31/* 31/*
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 5ecea3e4fdef..fdaa471e845f 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -1215,7 +1215,7 @@ dasd_eckd_build_cp(struct dasd_device * device, struct request *req)
1215 dst = page_address(bv->bv_page) + bv->bv_offset; 1215 dst = page_address(bv->bv_page) + bv->bv_offset;
1216 if (dasd_page_cache) { 1216 if (dasd_page_cache) {
1217 char *copy = kmem_cache_alloc(dasd_page_cache, 1217 char *copy = kmem_cache_alloc(dasd_page_cache,
1218 SLAB_DMA | __GFP_NOWARN); 1218 GFP_DMA | __GFP_NOWARN);
1219 if (copy && rq_data_dir(req) == WRITE) 1219 if (copy && rq_data_dir(req) == WRITE)
1220 memcpy(copy + bv->bv_offset, dst, bv->bv_len); 1220 memcpy(copy + bv->bv_offset, dst, bv->bv_len);
1221 if (copy) 1221 if (copy)
diff --git a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c
index 80926c548228..b857fd5893fd 100644
--- a/drivers/s390/block/dasd_fba.c
+++ b/drivers/s390/block/dasd_fba.c
@@ -308,7 +308,7 @@ dasd_fba_build_cp(struct dasd_device * device, struct request *req)
308 dst = page_address(bv->bv_page) + bv->bv_offset; 308 dst = page_address(bv->bv_page) + bv->bv_offset;
309 if (dasd_page_cache) { 309 if (dasd_page_cache) {
310 char *copy = kmem_cache_alloc(dasd_page_cache, 310 char *copy = kmem_cache_alloc(dasd_page_cache,
311 SLAB_DMA | __GFP_NOWARN); 311 GFP_DMA | __GFP_NOWARN);
312 if (copy && rq_data_dir(req) == WRITE) 312 if (copy && rq_data_dir(req) == WRITE)
313 memcpy(copy + bv->bv_offset, dst, bv->bv_len); 313 memcpy(copy + bv->bv_offset, dst, bv->bv_len);
314 if (copy) 314 if (copy)
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 9f52004f6fc2..dc5dd509434d 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -474,7 +474,7 @@ extern struct dasd_profile_info_t dasd_global_profile;
474extern unsigned int dasd_profile_level; 474extern unsigned int dasd_profile_level;
475extern struct block_device_operations dasd_device_operations; 475extern struct block_device_operations dasd_device_operations;
476 476
477extern kmem_cache_t *dasd_page_cache; 477extern struct kmem_cache *dasd_page_cache;
478 478
479struct dasd_ccw_req * 479struct dasd_ccw_req *
480dasd_kmalloc_request(char *, int, int, struct dasd_device *); 480dasd_kmalloc_request(char *, int, int, struct dasd_device *);
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index ad7f7e1c0163..26cf2f5ae2e7 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -334,7 +334,7 @@ static LIST_HEAD(slow_subchannels_head);
334static DEFINE_SPINLOCK(slow_subchannel_lock); 334static DEFINE_SPINLOCK(slow_subchannel_lock);
335 335
336static void 336static void
337css_trigger_slow_path(void) 337css_trigger_slow_path(struct work_struct *unused)
338{ 338{
339 CIO_TRACE_EVENT(4, "slowpath"); 339 CIO_TRACE_EVENT(4, "slowpath");
340 340
@@ -359,8 +359,7 @@ css_trigger_slow_path(void)
359 spin_unlock_irq(&slow_subchannel_lock); 359 spin_unlock_irq(&slow_subchannel_lock);
360} 360}
361 361
362typedef void (*workfunc)(void *); 362DECLARE_WORK(slow_path_work, css_trigger_slow_path);
363DECLARE_WORK(slow_path_work, (workfunc)css_trigger_slow_path, NULL);
364struct workqueue_struct *slow_path_wq; 363struct workqueue_struct *slow_path_wq;
365 364
366/* Reprobe subchannel if unregistered. */ 365/* Reprobe subchannel if unregistered. */
@@ -397,7 +396,7 @@ static int reprobe_subchannel(struct subchannel_id schid, void *data)
397} 396}
398 397
399/* Work function used to reprobe all unregistered subchannels. */ 398/* Work function used to reprobe all unregistered subchannels. */
400static void reprobe_all(void *data) 399static void reprobe_all(struct work_struct *unused)
401{ 400{
402 int ret; 401 int ret;
403 402
@@ -413,7 +412,7 @@ static void reprobe_all(void *data)
413 need_reprobe); 412 need_reprobe);
414} 413}
415 414
416DECLARE_WORK(css_reprobe_work, reprobe_all, NULL); 415DECLARE_WORK(css_reprobe_work, reprobe_all);
417 416
418/* Schedule reprobing of all unregistered subchannels. */ 417/* Schedule reprobing of all unregistered subchannels. */
419void css_schedule_reprobe(void) 418void css_schedule_reprobe(void)
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index 6a54334ffe09..e4dc947e74e9 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -37,7 +37,7 @@
37#include "ap_bus.h" 37#include "ap_bus.h"
38 38
39/* Some prototypes. */ 39/* Some prototypes. */
40static void ap_scan_bus(void *); 40static void ap_scan_bus(struct work_struct *);
41static void ap_poll_all(unsigned long); 41static void ap_poll_all(unsigned long);
42static void ap_poll_timeout(unsigned long); 42static void ap_poll_timeout(unsigned long);
43static int ap_poll_thread_start(void); 43static int ap_poll_thread_start(void);
@@ -71,7 +71,7 @@ static struct device *ap_root_device = NULL;
71static struct workqueue_struct *ap_work_queue; 71static struct workqueue_struct *ap_work_queue;
72static struct timer_list ap_config_timer; 72static struct timer_list ap_config_timer;
73static int ap_config_time = AP_CONFIG_TIME; 73static int ap_config_time = AP_CONFIG_TIME;
74static DECLARE_WORK(ap_config_work, ap_scan_bus, NULL); 74static DECLARE_WORK(ap_config_work, ap_scan_bus);
75 75
76/** 76/**
77 * Tasklet & timer for AP request polling. 77 * Tasklet & timer for AP request polling.
@@ -732,7 +732,7 @@ static void ap_device_release(struct device *dev)
732 kfree(ap_dev); 732 kfree(ap_dev);
733} 733}
734 734
735static void ap_scan_bus(void *data) 735static void ap_scan_bus(struct work_struct *unused)
736{ 736{
737 struct ap_device *ap_dev; 737 struct ap_device *ap_dev;
738 struct device *dev; 738 struct device *dev;
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index 08d4e47070bd..e5665b6743a1 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -67,7 +67,7 @@ static char debug_buffer[255];
67 * Some prototypes. 67 * Some prototypes.
68 */ 68 */
69static void lcs_tasklet(unsigned long); 69static void lcs_tasklet(unsigned long);
70static void lcs_start_kernel_thread(struct lcs_card *card); 70static void lcs_start_kernel_thread(struct work_struct *);
71static void lcs_get_frames_cb(struct lcs_channel *, struct lcs_buffer *); 71static void lcs_get_frames_cb(struct lcs_channel *, struct lcs_buffer *);
72static int lcs_send_delipm(struct lcs_card *, struct lcs_ipm_list *); 72static int lcs_send_delipm(struct lcs_card *, struct lcs_ipm_list *);
73static int lcs_recovery(void *ptr); 73static int lcs_recovery(void *ptr);
@@ -1724,8 +1724,9 @@ lcs_stopcard(struct lcs_card *card)
1724 * Kernel Thread helper functions for LGW initiated commands 1724 * Kernel Thread helper functions for LGW initiated commands
1725 */ 1725 */
1726static void 1726static void
1727lcs_start_kernel_thread(struct lcs_card *card) 1727lcs_start_kernel_thread(struct work_struct *work)
1728{ 1728{
1729 struct lcs_card *card = container_of(work, struct lcs_card, kernel_thread_starter);
1729 LCS_DBF_TEXT(5, trace, "krnthrd"); 1730 LCS_DBF_TEXT(5, trace, "krnthrd");
1730 if (lcs_do_start_thread(card, LCS_RECOVERY_THREAD)) 1731 if (lcs_do_start_thread(card, LCS_RECOVERY_THREAD))
1731 kernel_thread(lcs_recovery, (void *) card, SIGCHLD); 1732 kernel_thread(lcs_recovery, (void *) card, SIGCHLD);
@@ -2053,8 +2054,7 @@ lcs_probe_device(struct ccwgroup_device *ccwgdev)
2053 ccwgdev->cdev[0]->handler = lcs_irq; 2054 ccwgdev->cdev[0]->handler = lcs_irq;
2054 ccwgdev->cdev[1]->handler = lcs_irq; 2055 ccwgdev->cdev[1]->handler = lcs_irq;
2055 card->gdev = ccwgdev; 2056 card->gdev = ccwgdev;
2056 INIT_WORK(&card->kernel_thread_starter, 2057 INIT_WORK(&card->kernel_thread_starter, lcs_start_kernel_thread);
2057 (void *) lcs_start_kernel_thread, card);
2058 card->thread_start_mask = 0; 2058 card->thread_start_mask = 0;
2059 card->thread_allowed_mask = 0; 2059 card->thread_allowed_mask = 0;
2060 card->thread_running_mask = 0; 2060 card->thread_running_mask = 0;
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index 7fdc5272c446..2bde4f1fb9c2 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -1039,8 +1039,9 @@ qeth_do_start_thread(struct qeth_card *card, unsigned long thread)
1039} 1039}
1040 1040
1041static void 1041static void
1042qeth_start_kernel_thread(struct qeth_card *card) 1042qeth_start_kernel_thread(struct work_struct *work)
1043{ 1043{
1044 struct qeth_card *card = container_of(work, struct qeth_card, kernel_thread_starter);
1044 QETH_DBF_TEXT(trace , 2, "strthrd"); 1045 QETH_DBF_TEXT(trace , 2, "strthrd");
1045 1046
1046 if (card->read.state != CH_STATE_UP && 1047 if (card->read.state != CH_STATE_UP &&
@@ -1103,8 +1104,7 @@ qeth_setup_card(struct qeth_card *card)
1103 card->thread_start_mask = 0; 1104 card->thread_start_mask = 0;
1104 card->thread_allowed_mask = 0; 1105 card->thread_allowed_mask = 0;
1105 card->thread_running_mask = 0; 1106 card->thread_running_mask = 0;
1106 INIT_WORK(&card->kernel_thread_starter, 1107 INIT_WORK(&card->kernel_thread_starter, qeth_start_kernel_thread);
1107 (void *)qeth_start_kernel_thread,card);
1108 INIT_LIST_HEAD(&card->ip_list); 1108 INIT_LIST_HEAD(&card->ip_list);
1109 card->ip_tbd_list = kmalloc(sizeof(struct list_head), GFP_KERNEL); 1109 card->ip_tbd_list = kmalloc(sizeof(struct list_head), GFP_KERNEL);
1110 if (!card->ip_tbd_list) { 1110 if (!card->ip_tbd_list) {
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 74c0eac083e4..32933ed54b8a 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -1032,9 +1032,9 @@ struct zfcp_data {
1032 wwn_t init_wwpn; 1032 wwn_t init_wwpn;
1033 fcp_lun_t init_fcp_lun; 1033 fcp_lun_t init_fcp_lun;
1034 char *driver_version; 1034 char *driver_version;
1035 kmem_cache_t *fsf_req_qtcb_cache; 1035 struct kmem_cache *fsf_req_qtcb_cache;
1036 kmem_cache_t *sr_buffer_cache; 1036 struct kmem_cache *sr_buffer_cache;
1037 kmem_cache_t *gid_pn_cache; 1037 struct kmem_cache *gid_pn_cache;
1038}; 1038};
1039 1039
1040/** 1040/**
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index 277826cdd0c8..067f1519eb04 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -109,7 +109,7 @@ zfcp_fsf_req_alloc(mempool_t *pool, int req_flags)
109 ptr = kmalloc(size, GFP_ATOMIC); 109 ptr = kmalloc(size, GFP_ATOMIC);
110 else 110 else
111 ptr = kmem_cache_alloc(zfcp_data.fsf_req_qtcb_cache, 111 ptr = kmem_cache_alloc(zfcp_data.fsf_req_qtcb_cache,
112 SLAB_ATOMIC); 112 GFP_ATOMIC);
113 } 113 }
114 114
115 if (unlikely(!ptr)) 115 if (unlikely(!ptr))
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index 335a25540c08..68103e508db7 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -313,7 +313,7 @@ NCR_700_detect(struct scsi_host_template *tpnt,
313 hostdata->status = memory + STATUS_OFFSET; 313 hostdata->status = memory + STATUS_OFFSET;
314 /* all of these offsets are L1_CACHE_BYTES separated. It is fatal 314 /* all of these offsets are L1_CACHE_BYTES separated. It is fatal
315 * if this isn't sufficient separation to avoid dma flushing issues */ 315 * if this isn't sufficient separation to avoid dma flushing issues */
316 BUG_ON(!dma_is_consistent(pScript) && L1_CACHE_BYTES < dma_get_cache_alignment()); 316 BUG_ON(!dma_is_consistent(hostdata->dev, pScript) && L1_CACHE_BYTES < dma_get_cache_alignment());
317 hostdata->slots = (struct NCR_700_command_slot *)(memory + SLOTS_OFFSET); 317 hostdata->slots = (struct NCR_700_command_slot *)(memory + SLOTS_OFFSET);
318 hostdata->dev = dev; 318 hostdata->dev = dev;
319 319
@@ -362,11 +362,11 @@ NCR_700_detect(struct scsi_host_template *tpnt,
362 for (j = 0; j < PATCHES; j++) 362 for (j = 0; j < PATCHES; j++)
363 script[LABELPATCHES[j]] = bS_to_host(pScript + SCRIPT[LABELPATCHES[j]]); 363 script[LABELPATCHES[j]] = bS_to_host(pScript + SCRIPT[LABELPATCHES[j]]);
364 /* now patch up fixed addresses. */ 364 /* now patch up fixed addresses. */
365 script_patch_32(script, MessageLocation, 365 script_patch_32(hostdata->dev, script, MessageLocation,
366 pScript + MSGOUT_OFFSET); 366 pScript + MSGOUT_OFFSET);
367 script_patch_32(script, StatusAddress, 367 script_patch_32(hostdata->dev, script, StatusAddress,
368 pScript + STATUS_OFFSET); 368 pScript + STATUS_OFFSET);
369 script_patch_32(script, ReceiveMsgAddress, 369 script_patch_32(hostdata->dev, script, ReceiveMsgAddress,
370 pScript + MSGIN_OFFSET); 370 pScript + MSGIN_OFFSET);
371 371
372 hostdata->script = script; 372 hostdata->script = script;
@@ -821,8 +821,9 @@ process_extended_message(struct Scsi_Host *host,
821 shost_printk(KERN_WARNING, host, 821 shost_printk(KERN_WARNING, host,
822 "Unexpected SDTR msg\n"); 822 "Unexpected SDTR msg\n");
823 hostdata->msgout[0] = A_REJECT_MSG; 823 hostdata->msgout[0] = A_REJECT_MSG;
824 dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE); 824 dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE);
825 script_patch_16(hostdata->script, MessageCount, 1); 825 script_patch_16(hostdata->dev, hostdata->script,
826 MessageCount, 1);
826 /* SendMsgOut returns, so set up the return 827 /* SendMsgOut returns, so set up the return
827 * address */ 828 * address */
828 resume_offset = hostdata->pScript + Ent_SendMessageWithATN; 829 resume_offset = hostdata->pScript + Ent_SendMessageWithATN;
@@ -833,8 +834,9 @@ process_extended_message(struct Scsi_Host *host,
833 printk(KERN_INFO "scsi%d: (%d:%d), Unsolicited WDTR after CMD, Rejecting\n", 834 printk(KERN_INFO "scsi%d: (%d:%d), Unsolicited WDTR after CMD, Rejecting\n",
834 host->host_no, pun, lun); 835 host->host_no, pun, lun);
835 hostdata->msgout[0] = A_REJECT_MSG; 836 hostdata->msgout[0] = A_REJECT_MSG;
836 dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE); 837 dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE);
837 script_patch_16(hostdata->script, MessageCount, 1); 838 script_patch_16(hostdata->dev, hostdata->script, MessageCount,
839 1);
838 resume_offset = hostdata->pScript + Ent_SendMessageWithATN; 840 resume_offset = hostdata->pScript + Ent_SendMessageWithATN;
839 841
840 break; 842 break;
@@ -847,8 +849,9 @@ process_extended_message(struct Scsi_Host *host,
847 printk("\n"); 849 printk("\n");
848 /* just reject it */ 850 /* just reject it */
849 hostdata->msgout[0] = A_REJECT_MSG; 851 hostdata->msgout[0] = A_REJECT_MSG;
850 dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE); 852 dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE);
851 script_patch_16(hostdata->script, MessageCount, 1); 853 script_patch_16(hostdata->dev, hostdata->script, MessageCount,
854 1);
852 /* SendMsgOut returns, so set up the return 855 /* SendMsgOut returns, so set up the return
853 * address */ 856 * address */
854 resume_offset = hostdata->pScript + Ent_SendMessageWithATN; 857 resume_offset = hostdata->pScript + Ent_SendMessageWithATN;
@@ -929,8 +932,9 @@ process_message(struct Scsi_Host *host, struct NCR_700_Host_Parameters *hostdata
929 printk("\n"); 932 printk("\n");
930 /* just reject it */ 933 /* just reject it */
931 hostdata->msgout[0] = A_REJECT_MSG; 934 hostdata->msgout[0] = A_REJECT_MSG;
932 dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE); 935 dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE);
933 script_patch_16(hostdata->script, MessageCount, 1); 936 script_patch_16(hostdata->dev, hostdata->script, MessageCount,
937 1);
934 /* SendMsgOut returns, so set up the return 938 /* SendMsgOut returns, so set up the return
935 * address */ 939 * address */
936 resume_offset = hostdata->pScript + Ent_SendMessageWithATN; 940 resume_offset = hostdata->pScript + Ent_SendMessageWithATN;
@@ -939,7 +943,7 @@ process_message(struct Scsi_Host *host, struct NCR_700_Host_Parameters *hostdata
939 } 943 }
940 NCR_700_writel(temp, host, TEMP_REG); 944 NCR_700_writel(temp, host, TEMP_REG);
941 /* set us up to receive another message */ 945 /* set us up to receive another message */
942 dma_cache_sync(hostdata->msgin, MSG_ARRAY_SIZE, DMA_FROM_DEVICE); 946 dma_cache_sync(hostdata->dev, hostdata->msgin, MSG_ARRAY_SIZE, DMA_FROM_DEVICE);
943 return resume_offset; 947 return resume_offset;
944} 948}
945 949
@@ -1019,9 +1023,9 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
1019 slot->SG[1].ins = bS_to_host(SCRIPT_RETURN); 1023 slot->SG[1].ins = bS_to_host(SCRIPT_RETURN);
1020 slot->SG[1].pAddr = 0; 1024 slot->SG[1].pAddr = 0;
1021 slot->resume_offset = hostdata->pScript; 1025 slot->resume_offset = hostdata->pScript;
1022 dma_cache_sync(slot->SG, sizeof(slot->SG[0])*2, DMA_TO_DEVICE); 1026 dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG[0])*2, DMA_TO_DEVICE);
1023 dma_cache_sync(SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); 1027 dma_cache_sync(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);
1024 1028
1025 /* queue the command for reissue */ 1029 /* queue the command for reissue */
1026 slot->state = NCR_700_SLOT_QUEUED; 1030 slot->state = NCR_700_SLOT_QUEUED;
1027 slot->flags = NCR_700_FLAG_AUTOSENSE; 1031 slot->flags = NCR_700_FLAG_AUTOSENSE;
@@ -1136,11 +1140,12 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
1136 hostdata->cmd = slot->cmnd; 1140 hostdata->cmd = slot->cmnd;
1137 1141
1138 /* re-patch for this command */ 1142 /* re-patch for this command */
1139 script_patch_32_abs(hostdata->script, CommandAddress, 1143 script_patch_32_abs(hostdata->dev, hostdata->script,
1140 slot->pCmd); 1144 CommandAddress, slot->pCmd);
1141 script_patch_16(hostdata->script, 1145 script_patch_16(hostdata->dev, hostdata->script,
1142 CommandCount, slot->cmnd->cmd_len); 1146 CommandCount, slot->cmnd->cmd_len);
1143 script_patch_32_abs(hostdata->script, SGScriptStartAddress, 1147 script_patch_32_abs(hostdata->dev, hostdata->script,
1148 SGScriptStartAddress,
1144 to32bit(&slot->pSG[0].ins)); 1149 to32bit(&slot->pSG[0].ins));
1145 1150
1146 /* Note: setting SXFER only works if we're 1151 /* Note: setting SXFER only works if we're
@@ -1150,13 +1155,13 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
1150 * should therefore always clear ACK */ 1155 * should therefore always clear ACK */
1151 NCR_700_writeb(NCR_700_get_SXFER(hostdata->cmd->device), 1156 NCR_700_writeb(NCR_700_get_SXFER(hostdata->cmd->device),
1152 host, SXFER_REG); 1157 host, SXFER_REG);
1153 dma_cache_sync(hostdata->msgin, 1158 dma_cache_sync(hostdata->dev, hostdata->msgin,
1154 MSG_ARRAY_SIZE, DMA_FROM_DEVICE); 1159 MSG_ARRAY_SIZE, DMA_FROM_DEVICE);
1155 dma_cache_sync(hostdata->msgout, 1160 dma_cache_sync(hostdata->dev, hostdata->msgout,
1156 MSG_ARRAY_SIZE, DMA_TO_DEVICE); 1161 MSG_ARRAY_SIZE, DMA_TO_DEVICE);
1157 /* I'm just being paranoid here, the command should 1162 /* I'm just being paranoid here, the command should
1158 * already have been flushed from the cache */ 1163 * already have been flushed from the cache */
1159 dma_cache_sync(slot->cmnd->cmnd, 1164 dma_cache_sync(hostdata->dev, slot->cmnd->cmnd,
1160 slot->cmnd->cmd_len, DMA_TO_DEVICE); 1165 slot->cmnd->cmd_len, DMA_TO_DEVICE);
1161 1166
1162 1167
@@ -1220,7 +1225,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
1220 hostdata->reselection_id = reselection_id; 1225 hostdata->reselection_id = reselection_id;
1221 /* just in case we have a stale simple tag message, clear it */ 1226 /* just in case we have a stale simple tag message, clear it */
1222 hostdata->msgin[1] = 0; 1227 hostdata->msgin[1] = 0;
1223 dma_cache_sync(hostdata->msgin, 1228 dma_cache_sync(hostdata->dev, hostdata->msgin,
1224 MSG_ARRAY_SIZE, DMA_BIDIRECTIONAL); 1229 MSG_ARRAY_SIZE, DMA_BIDIRECTIONAL);
1225 if(hostdata->tag_negotiated & (1<<reselection_id)) { 1230 if(hostdata->tag_negotiated & (1<<reselection_id)) {
1226 resume_offset = hostdata->pScript + Ent_GetReselectionWithTag; 1231 resume_offset = hostdata->pScript + Ent_GetReselectionWithTag;
@@ -1336,7 +1341,7 @@ process_selection(struct Scsi_Host *host, __u32 dsp)
1336 hostdata->cmd = NULL; 1341 hostdata->cmd = NULL;
1337 /* clear any stale simple tag message */ 1342 /* clear any stale simple tag message */
1338 hostdata->msgin[1] = 0; 1343 hostdata->msgin[1] = 0;
1339 dma_cache_sync(hostdata->msgin, MSG_ARRAY_SIZE, 1344 dma_cache_sync(hostdata->dev, hostdata->msgin, MSG_ARRAY_SIZE,
1340 DMA_BIDIRECTIONAL); 1345 DMA_BIDIRECTIONAL);
1341 1346
1342 if(id == 0xff) { 1347 if(id == 0xff) {
@@ -1433,29 +1438,30 @@ NCR_700_start_command(struct scsi_cmnd *SCp)
1433 NCR_700_set_flag(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION); 1438 NCR_700_set_flag(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION);
1434 } 1439 }
1435 1440
1436 script_patch_16(hostdata->script, MessageCount, count); 1441 script_patch_16(hostdata->dev, hostdata->script, MessageCount, count);
1437 1442
1438 1443
1439 script_patch_ID(hostdata->script, 1444 script_patch_ID(hostdata->dev, hostdata->script,
1440 Device_ID, 1<<scmd_id(SCp)); 1445 Device_ID, 1<<scmd_id(SCp));
1441 1446
1442 script_patch_32_abs(hostdata->script, CommandAddress, 1447 script_patch_32_abs(hostdata->dev, hostdata->script, CommandAddress,
1443 slot->pCmd); 1448 slot->pCmd);
1444 script_patch_16(hostdata->script, CommandCount, SCp->cmd_len); 1449 script_patch_16(hostdata->dev, hostdata->script, CommandCount,
1450 SCp->cmd_len);
1445 /* finally plumb the beginning of the SG list into the script 1451 /* finally plumb the beginning of the SG list into the script
1446 * */ 1452 * */
1447 script_patch_32_abs(hostdata->script, SGScriptStartAddress, 1453 script_patch_32_abs(hostdata->dev, hostdata->script,
1448 to32bit(&slot->pSG[0].ins)); 1454 SGScriptStartAddress, to32bit(&slot->pSG[0].ins));
1449 NCR_700_clear_fifo(SCp->device->host); 1455 NCR_700_clear_fifo(SCp->device->host);
1450 1456
1451 if(slot->resume_offset == 0) 1457 if(slot->resume_offset == 0)
1452 slot->resume_offset = hostdata->pScript; 1458 slot->resume_offset = hostdata->pScript;
1453 /* now perform all the writebacks and invalidates */ 1459 /* now perform all the writebacks and invalidates */
1454 dma_cache_sync(hostdata->msgout, count, DMA_TO_DEVICE); 1460 dma_cache_sync(hostdata->dev, hostdata->msgout, count, DMA_TO_DEVICE);
1455 dma_cache_sync(hostdata->msgin, MSG_ARRAY_SIZE, 1461 dma_cache_sync(hostdata->dev, hostdata->msgin, MSG_ARRAY_SIZE,
1456 DMA_FROM_DEVICE); 1462 DMA_FROM_DEVICE);
1457 dma_cache_sync(SCp->cmnd, SCp->cmd_len, DMA_TO_DEVICE); 1463 dma_cache_sync(hostdata->dev, SCp->cmnd, SCp->cmd_len, DMA_TO_DEVICE);
1458 dma_cache_sync(hostdata->status, 1, DMA_FROM_DEVICE); 1464 dma_cache_sync(hostdata->dev, hostdata->status, 1, DMA_FROM_DEVICE);
1459 1465
1460 /* set the synchronous period/offset */ 1466 /* set the synchronous period/offset */
1461 NCR_700_writeb(NCR_700_get_SXFER(SCp->device), 1467 NCR_700_writeb(NCR_700_get_SXFER(SCp->device),
@@ -1631,7 +1637,7 @@ NCR_700_intr(int irq, void *dev_id)
1631 slot->SG[i].ins = bS_to_host(SCRIPT_NOP); 1637 slot->SG[i].ins = bS_to_host(SCRIPT_NOP);
1632 slot->SG[i].pAddr = 0; 1638 slot->SG[i].pAddr = 0;
1633 } 1639 }
1634 dma_cache_sync(slot->SG, sizeof(slot->SG), DMA_TO_DEVICE); 1640 dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG), DMA_TO_DEVICE);
1635 /* and pretend we disconnected after 1641 /* and pretend we disconnected after
1636 * the command phase */ 1642 * the command phase */
1637 resume_offset = hostdata->pScript + Ent_MsgInDuringData; 1643 resume_offset = hostdata->pScript + Ent_MsgInDuringData;
@@ -1897,9 +1903,9 @@ NCR_700_queuecommand(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *))
1897 } 1903 }
1898 slot->SG[i].ins = bS_to_host(SCRIPT_RETURN); 1904 slot->SG[i].ins = bS_to_host(SCRIPT_RETURN);
1899 slot->SG[i].pAddr = 0; 1905 slot->SG[i].pAddr = 0;
1900 dma_cache_sync(slot->SG, sizeof(slot->SG), DMA_TO_DEVICE); 1906 dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG), DMA_TO_DEVICE);
1901 DEBUG((" SETTING %08lx to %x\n", 1907 DEBUG((" SETTING %08lx to %x\n",
1902 (&slot->pSG[i].ins), 1908 (&slot->pSG[i].ins),
1903 slot->SG[i].ins)); 1909 slot->SG[i].ins));
1904 } 1910 }
1905 slot->resume_offset = 0; 1911 slot->resume_offset = 0;
diff --git a/drivers/scsi/53c700.h b/drivers/scsi/53c700.h
index f5c3caf344a7..f38822db4210 100644
--- a/drivers/scsi/53c700.h
+++ b/drivers/scsi/53c700.h
@@ -415,31 +415,31 @@ struct NCR_700_Host_Parameters {
415#define NCR_710_MIN_XFERP 0 415#define NCR_710_MIN_XFERP 0
416#define NCR_700_MIN_PERIOD 25 /* for SDTR message, 100ns */ 416#define NCR_700_MIN_PERIOD 25 /* for SDTR message, 100ns */
417 417
418#define script_patch_32(script, symbol, value) \ 418#define script_patch_32(dev, script, symbol, value) \
419{ \ 419{ \
420 int i; \ 420 int i; \
421 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \ 421 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
422 __u32 val = bS_to_cpu((script)[A_##symbol##_used[i]]) + value; \ 422 __u32 val = bS_to_cpu((script)[A_##symbol##_used[i]]) + value; \
423 (script)[A_##symbol##_used[i]] = bS_to_host(val); \ 423 (script)[A_##symbol##_used[i]] = bS_to_host(val); \
424 dma_cache_sync(&(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \ 424 dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
425 DEBUG((" script, patching %s at %d to 0x%lx\n", \ 425 DEBUG((" script, patching %s at %d to 0x%lx\n", \
426 #symbol, A_##symbol##_used[i], (value))); \ 426 #symbol, A_##symbol##_used[i], (value))); \
427 } \ 427 } \
428} 428}
429 429
430#define script_patch_32_abs(script, symbol, value) \ 430#define script_patch_32_abs(dev, script, symbol, value) \
431{ \ 431{ \
432 int i; \ 432 int i; \
433 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \ 433 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
434 (script)[A_##symbol##_used[i]] = bS_to_host(value); \ 434 (script)[A_##symbol##_used[i]] = bS_to_host(value); \
435 dma_cache_sync(&(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \ 435 dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
436 DEBUG((" script, patching %s at %d to 0x%lx\n", \ 436 DEBUG((" script, patching %s at %d to 0x%lx\n", \
437 #symbol, A_##symbol##_used[i], (value))); \ 437 #symbol, A_##symbol##_used[i], (value))); \
438 } \ 438 } \
439} 439}
440 440
441/* Used for patching the SCSI ID in the SELECT instruction */ 441/* Used for patching the SCSI ID in the SELECT instruction */
442#define script_patch_ID(script, symbol, value) \ 442#define script_patch_ID(dev, script, symbol, value) \
443{ \ 443{ \
444 int i; \ 444 int i; \
445 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \ 445 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
@@ -447,13 +447,13 @@ struct NCR_700_Host_Parameters {
447 val &= 0xff00ffff; \ 447 val &= 0xff00ffff; \
448 val |= ((value) & 0xff) << 16; \ 448 val |= ((value) & 0xff) << 16; \
449 (script)[A_##symbol##_used[i]] = bS_to_host(val); \ 449 (script)[A_##symbol##_used[i]] = bS_to_host(val); \
450 dma_cache_sync(&(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \ 450 dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
451 DEBUG((" script, patching ID field %s at %d to 0x%x\n", \ 451 DEBUG((" script, patching ID field %s at %d to 0x%x\n", \
452 #symbol, A_##symbol##_used[i], val)); \ 452 #symbol, A_##symbol##_used[i], val)); \
453 } \ 453 } \
454} 454}
455 455
456#define script_patch_16(script, symbol, value) \ 456#define script_patch_16(dev, script, symbol, value) \
457{ \ 457{ \
458 int i; \ 458 int i; \
459 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \ 459 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
@@ -461,7 +461,7 @@ struct NCR_700_Host_Parameters {
461 val &= 0xffff0000; \ 461 val &= 0xffff0000; \
462 val |= ((value) & 0xffff); \ 462 val |= ((value) & 0xffff); \
463 (script)[A_##symbol##_used[i]] = bS_to_host(val); \ 463 (script)[A_##symbol##_used[i]] = bS_to_host(val); \
464 dma_cache_sync(&(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \ 464 dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
465 DEBUG((" script, patching short field %s at %d to 0x%x\n", \ 465 DEBUG((" script, patching short field %s at %d to 0x%x\n", \
466 #symbol, A_##symbol##_used[i], val)); \ 466 #symbol, A_##symbol##_used[i], val)); \
467 } \ 467 } \
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index a6aa91072880..bb3cb3360541 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -849,7 +849,7 @@ static int __devinit NCR5380_init(struct Scsi_Host *instance, int flags)
849 hostdata->issue_queue = NULL; 849 hostdata->issue_queue = NULL;
850 hostdata->disconnected_queue = NULL; 850 hostdata->disconnected_queue = NULL;
851 851
852 INIT_WORK(&hostdata->coroutine, NCR5380_main, hostdata); 852 INIT_DELAYED_WORK(&hostdata->coroutine, NCR5380_main);
853 853
854#ifdef NCR5380_STATS 854#ifdef NCR5380_STATS
855 for (i = 0; i < 8; ++i) { 855 for (i = 0; i < 8; ++i) {
@@ -1016,7 +1016,7 @@ static int NCR5380_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
1016 1016
1017 /* Run the coroutine if it isn't already running. */ 1017 /* Run the coroutine if it isn't already running. */
1018 /* Kick off command processing */ 1018 /* Kick off command processing */
1019 schedule_work(&hostdata->coroutine); 1019 schedule_delayed_work(&hostdata->coroutine, 0);
1020 return 0; 1020 return 0;
1021} 1021}
1022 1022
@@ -1033,9 +1033,10 @@ static int NCR5380_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
1033 * host lock and called routines may take the isa dma lock. 1033 * host lock and called routines may take the isa dma lock.
1034 */ 1034 */
1035 1035
1036static void NCR5380_main(void *p) 1036static void NCR5380_main(struct work_struct *work)
1037{ 1037{
1038 struct NCR5380_hostdata *hostdata = p; 1038 struct NCR5380_hostdata *hostdata =
1039 container_of(work, struct NCR5380_hostdata, coroutine.work);
1039 struct Scsi_Host *instance = hostdata->host; 1040 struct Scsi_Host *instance = hostdata->host;
1040 Scsi_Cmnd *tmp, *prev; 1041 Scsi_Cmnd *tmp, *prev;
1041 int done; 1042 int done;
@@ -1221,7 +1222,7 @@ static irqreturn_t NCR5380_intr(int irq, void *dev_id)
1221 } /* if BASR_IRQ */ 1222 } /* if BASR_IRQ */
1222 spin_unlock_irqrestore(instance->host_lock, flags); 1223 spin_unlock_irqrestore(instance->host_lock, flags);
1223 if(!done) 1224 if(!done)
1224 schedule_work(&hostdata->coroutine); 1225 schedule_delayed_work(&hostdata->coroutine, 0);
1225 } while (!done); 1226 } while (!done);
1226 return IRQ_HANDLED; 1227 return IRQ_HANDLED;
1227} 1228}
diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h
index 1bc73de496b0..713a108c02ef 100644
--- a/drivers/scsi/NCR5380.h
+++ b/drivers/scsi/NCR5380.h
@@ -271,7 +271,7 @@ struct NCR5380_hostdata {
271 unsigned long time_expires; /* in jiffies, set prior to sleeping */ 271 unsigned long time_expires; /* in jiffies, set prior to sleeping */
272 int select_time; /* timer in select for target response */ 272 int select_time; /* timer in select for target response */
273 volatile Scsi_Cmnd *selecting; 273 volatile Scsi_Cmnd *selecting;
274 struct work_struct coroutine; /* our co-routine */ 274 struct delayed_work coroutine; /* our co-routine */
275#ifdef NCR5380_STATS 275#ifdef NCR5380_STATS
276 unsigned timebase; /* Base for time calcs */ 276 unsigned timebase; /* Base for time calcs */
277 long time_read[8]; /* time to do reads */ 277 long time_read[8]; /* time to do reads */
@@ -298,7 +298,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance);
298#ifndef DONT_USE_INTR 298#ifndef DONT_USE_INTR
299static irqreturn_t NCR5380_intr(int irq, void *dev_id); 299static irqreturn_t NCR5380_intr(int irq, void *dev_id);
300#endif 300#endif
301static void NCR5380_main(void *ptr); 301static void NCR5380_main(struct work_struct *work);
302static void NCR5380_print_options(struct Scsi_Host *instance); 302static void NCR5380_print_options(struct Scsi_Host *instance);
303#ifdef NDEBUG 303#ifdef NDEBUG
304static void NCR5380_print_phase(struct Scsi_Host *instance); 304static void NCR5380_print_phase(struct Scsi_Host *instance);
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index 306f46b85a55..0cec742d12e9 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -1443,7 +1443,7 @@ static struct work_struct aha152x_tq;
1443 * Run service completions on the card with interrupts enabled. 1443 * Run service completions on the card with interrupts enabled.
1444 * 1444 *
1445 */ 1445 */
1446static void run(void) 1446static void run(struct work_struct *work)
1447{ 1447{
1448 struct aha152x_hostdata *hd; 1448 struct aha152x_hostdata *hd;
1449 1449
@@ -1499,7 +1499,7 @@ static irqreturn_t intr(int irqno, void *dev_id)
1499 HOSTDATA(shpnt)->service=1; 1499 HOSTDATA(shpnt)->service=1;
1500 1500
1501 /* Poke the BH handler */ 1501 /* Poke the BH handler */
1502 INIT_WORK(&aha152x_tq, (void *) run, NULL); 1502 INIT_WORK(&aha152x_tq, run);
1503 schedule_work(&aha152x_tq); 1503 schedule_work(&aha152x_tq);
1504 } 1504 }
1505 DO_UNLOCK(flags); 1505 DO_UNLOCK(flags);
diff --git a/drivers/scsi/aic94xx/aic94xx.h b/drivers/scsi/aic94xx/aic94xx.h
index 71a031df7a34..32f513b1b78a 100644
--- a/drivers/scsi/aic94xx/aic94xx.h
+++ b/drivers/scsi/aic94xx/aic94xx.h
@@ -56,8 +56,8 @@
56/* 2*ITNL timeout + 1 second */ 56/* 2*ITNL timeout + 1 second */
57#define AIC94XX_SCB_TIMEOUT (5*HZ) 57#define AIC94XX_SCB_TIMEOUT (5*HZ)
58 58
59extern kmem_cache_t *asd_dma_token_cache; 59extern struct kmem_cache *asd_dma_token_cache;
60extern kmem_cache_t *asd_ascb_cache; 60extern struct kmem_cache *asd_ascb_cache;
61extern char sas_addr_str[2*SAS_ADDR_SIZE + 1]; 61extern char sas_addr_str[2*SAS_ADDR_SIZE + 1];
62 62
63static inline void asd_stringify_sas_addr(char *p, const u8 *sas_addr) 63static inline void asd_stringify_sas_addr(char *p, const u8 *sas_addr)
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.c b/drivers/scsi/aic94xx/aic94xx_hwi.c
index af7e01134364..da94e126ca83 100644
--- a/drivers/scsi/aic94xx/aic94xx_hwi.c
+++ b/drivers/scsi/aic94xx/aic94xx_hwi.c
@@ -1047,7 +1047,7 @@ irqreturn_t asd_hw_isr(int irq, void *dev_id)
1047static inline struct asd_ascb *asd_ascb_alloc(struct asd_ha_struct *asd_ha, 1047static inline struct asd_ascb *asd_ascb_alloc(struct asd_ha_struct *asd_ha,
1048 gfp_t gfp_flags) 1048 gfp_t gfp_flags)
1049{ 1049{
1050 extern kmem_cache_t *asd_ascb_cache; 1050 extern struct kmem_cache *asd_ascb_cache;
1051 struct asd_seq_data *seq = &asd_ha->seq; 1051 struct asd_seq_data *seq = &asd_ha->seq;
1052 struct asd_ascb *ascb; 1052 struct asd_ascb *ascb;
1053 unsigned long flags; 1053 unsigned long flags;
diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index 42302ef05ee5..fbc82b00a418 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -450,8 +450,8 @@ static inline void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha)
450 asd_ha->scb_pool = NULL; 450 asd_ha->scb_pool = NULL;
451} 451}
452 452
453kmem_cache_t *asd_dma_token_cache; 453struct kmem_cache *asd_dma_token_cache;
454kmem_cache_t *asd_ascb_cache; 454struct kmem_cache *asd_ascb_cache;
455 455
456static int asd_create_global_caches(void) 456static int asd_create_global_caches(void)
457{ 457{
diff --git a/drivers/scsi/aic94xx/aic94xx_scb.c b/drivers/scsi/aic94xx/aic94xx_scb.c
index 14d5d8c2ee13..75ed6b0569d1 100644
--- a/drivers/scsi/aic94xx/aic94xx_scb.c
+++ b/drivers/scsi/aic94xx/aic94xx_scb.c
@@ -414,9 +414,10 @@ void asd_invalidate_edb(struct asd_ascb *ascb, int edb_id)
414} 414}
415 415
416/* hard reset a phy later */ 416/* hard reset a phy later */
417static void do_phy_reset_later(void *data) 417static void do_phy_reset_later(struct work_struct *work)
418{ 418{
419 struct sas_phy *sas_phy = data; 419 struct sas_phy *sas_phy =
420 container_of(work, struct sas_phy, reset_work);
420 int error; 421 int error;
421 422
422 ASD_DPRINTK("%s: About to hard reset phy %d\n", __FUNCTION__, 423 ASD_DPRINTK("%s: About to hard reset phy %d\n", __FUNCTION__,
@@ -430,7 +431,7 @@ static void do_phy_reset_later(void *data)
430 431
431static void phy_reset_later(struct sas_phy *sas_phy, struct Scsi_Host *shost) 432static void phy_reset_later(struct sas_phy *sas_phy, struct Scsi_Host *shost)
432{ 433{
433 INIT_WORK(&sas_phy->reset_work, do_phy_reset_later, sas_phy); 434 INIT_WORK(&sas_phy->reset_work, do_phy_reset_later);
434 queue_work(shost->work_q, &sas_phy->reset_work); 435 queue_work(shost->work_q, &sas_phy->reset_work);
435} 436}
436 437
@@ -442,7 +443,7 @@ static void task_kill_later(struct asd_ascb *ascb)
442 struct Scsi_Host *shost = sas_ha->core.shost; 443 struct Scsi_Host *shost = sas_ha->core.shost;
443 struct sas_task *task = ascb->uldd_task; 444 struct sas_task *task = ascb->uldd_task;
444 445
445 INIT_WORK(&task->abort_work, (void (*)(void *))sas_task_abort, task); 446 INIT_WORK(&task->abort_work, sas_task_abort);
446 queue_work(shost->work_q, &task->abort_work); 447 queue_work(shost->work_q, &task->abort_work);
447} 448}
448 449
diff --git a/drivers/scsi/ibmvscsi/ibmvstgt.c b/drivers/scsi/ibmvscsi/ibmvstgt.c
index 0e74174a1b37..e28260f05d6b 100644
--- a/drivers/scsi/ibmvscsi/ibmvstgt.c
+++ b/drivers/scsi/ibmvscsi/ibmvstgt.c
@@ -67,6 +67,7 @@ struct vio_port {
67 67
68 unsigned long liobn; 68 unsigned long liobn;
69 unsigned long riobn; 69 unsigned long riobn;
70 struct srp_target *target;
70}; 71};
71 72
72static struct workqueue_struct *vtgtd; 73static struct workqueue_struct *vtgtd;
@@ -685,10 +686,10 @@ static inline struct viosrp_crq *next_crq(struct crq_queue *queue)
685 return crq; 686 return crq;
686} 687}
687 688
688static void handle_crq(void *data) 689static void handle_crq(struct work_struct *work)
689{ 690{
690 struct srp_target *target = (struct srp_target *) data; 691 struct vio_port *vport = container_of(work, struct vio_port, crq_work);
691 struct vio_port *vport = target_to_port(target); 692 struct srp_target *target = vport->target;
692 struct viosrp_crq *crq; 693 struct viosrp_crq *crq;
693 int done = 0; 694 int done = 0;
694 695
@@ -822,6 +823,7 @@ static int ibmvstgt_probe(struct vio_dev *dev, const struct vio_device_id *id)
822 target->shost = shost; 823 target->shost = shost;
823 vport->dma_dev = dev; 824 vport->dma_dev = dev;
824 target->ldata = vport; 825 target->ldata = vport;
826 vport->target = target;
825 err = srp_target_alloc(target, &dev->dev, INITIAL_SRP_LIMIT, 827 err = srp_target_alloc(target, &dev->dev, INITIAL_SRP_LIMIT,
826 SRP_MAX_IU_LEN); 828 SRP_MAX_IU_LEN);
827 if (err) 829 if (err)
@@ -837,7 +839,7 @@ static int ibmvstgt_probe(struct vio_dev *dev, const struct vio_device_id *id)
837 vport->liobn = dma[0]; 839 vport->liobn = dma[0];
838 vport->riobn = dma[5]; 840 vport->riobn = dma[5];
839 841
840 INIT_WORK(&vport->crq_work, handle_crq, target); 842 INIT_WORK(&vport->crq_work, handle_crq);
841 843
842 err = crq_queue_create(&vport->crq_queue, target); 844 err = crq_queue_create(&vport->crq_queue, target);
843 if (err) 845 if (err)
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 1427a41e8441..8f6b5bf580f6 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -110,6 +110,7 @@ typedef struct ide_scsi_obj {
110} idescsi_scsi_t; 110} idescsi_scsi_t;
111 111
112static DEFINE_MUTEX(idescsi_ref_mutex); 112static DEFINE_MUTEX(idescsi_ref_mutex);
113static int idescsi_nocd; /* Set by module param to skip cd */
113 114
114#define ide_scsi_g(disk) \ 115#define ide_scsi_g(disk) \
115 container_of((disk)->private_data, struct ide_scsi_obj, driver) 116 container_of((disk)->private_data, struct ide_scsi_obj, driver)
@@ -1127,6 +1128,9 @@ static int ide_scsi_probe(ide_drive_t *drive)
1127 warned = 1; 1128 warned = 1;
1128 } 1129 }
1129 1130
1131 if (idescsi_nocd && drive->media == ide_cdrom)
1132 return -ENODEV;
1133
1130 if (!strstr("ide-scsi", drive->driver_req) || 1134 if (!strstr("ide-scsi", drive->driver_req) ||
1131 !drive->present || 1135 !drive->present ||
1132 drive->media == ide_disk || 1136 drive->media == ide_disk ||
@@ -1187,6 +1191,8 @@ static void __exit exit_idescsi_module(void)
1187 driver_unregister(&idescsi_driver.gen_driver); 1191 driver_unregister(&idescsi_driver.gen_driver);
1188} 1192}
1189 1193
1194module_param(idescsi_nocd, int, 0600);
1195MODULE_PARM_DESC(idescsi_nocd, "Disable handling of CD-ROMs so they may be driven by ide-cd");
1190module_init(init_idescsi_module); 1196module_init(init_idescsi_module);
1191module_exit(exit_idescsi_module); 1197module_exit(exit_idescsi_module);
1192MODULE_LICENSE("GPL"); 1198MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index e31f6122106f..0464c182c577 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -36,7 +36,7 @@ typedef struct {
36 int base_hi; /* Hi Base address for ECP-ISA chipset */ 36 int base_hi; /* Hi Base address for ECP-ISA chipset */
37 int mode; /* Transfer mode */ 37 int mode; /* Transfer mode */
38 struct scsi_cmnd *cur_cmd; /* Current queued command */ 38 struct scsi_cmnd *cur_cmd; /* Current queued command */
39 struct work_struct imm_tq; /* Polling interrupt stuff */ 39 struct delayed_work imm_tq; /* Polling interrupt stuff */
40 unsigned long jstart; /* Jiffies at start */ 40 unsigned long jstart; /* Jiffies at start */
41 unsigned failed:1; /* Failure flag */ 41 unsigned failed:1; /* Failure flag */
42 unsigned dp:1; /* Data phase present */ 42 unsigned dp:1; /* Data phase present */
@@ -733,9 +733,9 @@ static int imm_completion(struct scsi_cmnd *cmd)
733 * the scheduler's task queue to generate a stream of call-backs and 733 * the scheduler's task queue to generate a stream of call-backs and
734 * complete the request when the drive is ready. 734 * complete the request when the drive is ready.
735 */ 735 */
736static void imm_interrupt(void *data) 736static void imm_interrupt(struct work_struct *work)
737{ 737{
738 imm_struct *dev = (imm_struct *) data; 738 imm_struct *dev = container_of(work, imm_struct, imm_tq.work);
739 struct scsi_cmnd *cmd = dev->cur_cmd; 739 struct scsi_cmnd *cmd = dev->cur_cmd;
740 struct Scsi_Host *host = cmd->device->host; 740 struct Scsi_Host *host = cmd->device->host;
741 unsigned long flags; 741 unsigned long flags;
@@ -745,7 +745,6 @@ static void imm_interrupt(void *data)
745 return; 745 return;
746 } 746 }
747 if (imm_engine(dev, cmd)) { 747 if (imm_engine(dev, cmd)) {
748 INIT_WORK(&dev->imm_tq, imm_interrupt, (void *) dev);
749 schedule_delayed_work(&dev->imm_tq, 1); 748 schedule_delayed_work(&dev->imm_tq, 1);
750 return; 749 return;
751 } 750 }
@@ -953,8 +952,7 @@ static int imm_queuecommand(struct scsi_cmnd *cmd,
953 cmd->result = DID_ERROR << 16; /* default return code */ 952 cmd->result = DID_ERROR << 16; /* default return code */
954 cmd->SCp.phase = 0; /* bus free */ 953 cmd->SCp.phase = 0; /* bus free */
955 954
956 INIT_WORK(&dev->imm_tq, imm_interrupt, dev); 955 schedule_delayed_work(&dev->imm_tq, 0);
957 schedule_work(&dev->imm_tq);
958 956
959 imm_pb_claim(dev); 957 imm_pb_claim(dev);
960 958
@@ -1225,7 +1223,7 @@ static int __imm_attach(struct parport *pb)
1225 else 1223 else
1226 ports = 8; 1224 ports = 8;
1227 1225
1228 INIT_WORK(&dev->imm_tq, imm_interrupt, dev); 1226 INIT_DELAYED_WORK(&dev->imm_tq, imm_interrupt);
1229 1227
1230 err = -ENOMEM; 1228 err = -ENOMEM;
1231 host = scsi_host_alloc(&imm_template, sizeof(imm_struct *)); 1229 host = scsi_host_alloc(&imm_template, sizeof(imm_struct *));
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 2d83fbb806a5..b318500785e5 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -2307,7 +2307,7 @@ static void ipr_release_dump(struct kref *kref)
2307 2307
2308/** 2308/**
2309 * ipr_worker_thread - Worker thread 2309 * ipr_worker_thread - Worker thread
2310 * @data: ioa config struct 2310 * @work: ioa config struct
2311 * 2311 *
2312 * Called at task level from a work thread. This function takes care 2312 * Called at task level from a work thread. This function takes care
2313 * of adding and removing device from the mid-layer as configuration 2313 * of adding and removing device from the mid-layer as configuration
@@ -2316,13 +2316,14 @@ static void ipr_release_dump(struct kref *kref)
2316 * Return value: 2316 * Return value:
2317 * nothing 2317 * nothing
2318 **/ 2318 **/
2319static void ipr_worker_thread(void *data) 2319static void ipr_worker_thread(struct work_struct *work)
2320{ 2320{
2321 unsigned long lock_flags; 2321 unsigned long lock_flags;
2322 struct ipr_resource_entry *res; 2322 struct ipr_resource_entry *res;
2323 struct scsi_device *sdev; 2323 struct scsi_device *sdev;
2324 struct ipr_dump *dump; 2324 struct ipr_dump *dump;
2325 struct ipr_ioa_cfg *ioa_cfg = data; 2325 struct ipr_ioa_cfg *ioa_cfg =
2326 container_of(work, struct ipr_ioa_cfg, work_q);
2326 u8 bus, target, lun; 2327 u8 bus, target, lun;
2327 int did_work; 2328 int did_work;
2328 2329
@@ -6939,7 +6940,7 @@ static int __devinit ipr_alloc_cmd_blks(struct ipr_ioa_cfg *ioa_cfg)
6939 return -ENOMEM; 6940 return -ENOMEM;
6940 6941
6941 for (i = 0; i < IPR_NUM_CMD_BLKS; i++) { 6942 for (i = 0; i < IPR_NUM_CMD_BLKS; i++) {
6942 ipr_cmd = pci_pool_alloc (ioa_cfg->ipr_cmd_pool, SLAB_KERNEL, &dma_addr); 6943 ipr_cmd = pci_pool_alloc (ioa_cfg->ipr_cmd_pool, GFP_KERNEL, &dma_addr);
6943 6944
6944 if (!ipr_cmd) { 6945 if (!ipr_cmd) {
6945 ipr_free_cmd_blks(ioa_cfg); 6946 ipr_free_cmd_blks(ioa_cfg);
@@ -7121,7 +7122,7 @@ static void __devinit ipr_init_ioa_cfg(struct ipr_ioa_cfg *ioa_cfg,
7121 INIT_LIST_HEAD(&ioa_cfg->hostrcb_pending_q); 7122 INIT_LIST_HEAD(&ioa_cfg->hostrcb_pending_q);
7122 INIT_LIST_HEAD(&ioa_cfg->free_res_q); 7123 INIT_LIST_HEAD(&ioa_cfg->free_res_q);
7123 INIT_LIST_HEAD(&ioa_cfg->used_res_q); 7124 INIT_LIST_HEAD(&ioa_cfg->used_res_q);
7124 INIT_WORK(&ioa_cfg->work_q, ipr_worker_thread, ioa_cfg); 7125 INIT_WORK(&ioa_cfg->work_q, ipr_worker_thread);
7125 init_waitqueue_head(&ioa_cfg->reset_wait_q); 7126 init_waitqueue_head(&ioa_cfg->reset_wait_q);
7126 ioa_cfg->sdt_state = INACTIVE; 7127 ioa_cfg->sdt_state = INACTIVE;
7127 if (ipr_enable_cache) 7128 if (ipr_enable_cache)
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 5d8862189485..e11b23c641e2 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -719,9 +719,10 @@ again:
719 return rc; 719 return rc;
720} 720}
721 721
722static void iscsi_xmitworker(void *data) 722static void iscsi_xmitworker(struct work_struct *work)
723{ 723{
724 struct iscsi_conn *conn = data; 724 struct iscsi_conn *conn =
725 container_of(work, struct iscsi_conn, xmitwork);
725 int rc; 726 int rc;
726 /* 727 /*
727 * serialize Xmit worker on a per-connection basis. 728 * serialize Xmit worker on a per-connection basis.
@@ -1512,7 +1513,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
1512 if (conn->mgmtqueue == ERR_PTR(-ENOMEM)) 1513 if (conn->mgmtqueue == ERR_PTR(-ENOMEM))
1513 goto mgmtqueue_alloc_fail; 1514 goto mgmtqueue_alloc_fail;
1514 1515
1515 INIT_WORK(&conn->xmitwork, iscsi_xmitworker, conn); 1516 INIT_WORK(&conn->xmitwork, iscsi_xmitworker);
1516 1517
1517 /* allocate login_mtask used for the login/text sequences */ 1518 /* allocate login_mtask used for the login/text sequences */
1518 spin_lock_bh(&session->lock); 1519 spin_lock_bh(&session->lock);
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
index d977bd492d8d..fb7df7b75811 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -647,10 +647,12 @@ void sas_unregister_domain_devices(struct asd_sas_port *port)
647 * Discover process only interrogates devices in order to discover the 647 * Discover process only interrogates devices in order to discover the
648 * domain. 648 * domain.
649 */ 649 */
650static void sas_discover_domain(void *data) 650static void sas_discover_domain(struct work_struct *work)
651{ 651{
652 int error = 0; 652 int error = 0;
653 struct asd_sas_port *port = data; 653 struct sas_discovery_event *ev =
654 container_of(work, struct sas_discovery_event, work);
655 struct asd_sas_port *port = ev->port;
654 656
655 sas_begin_event(DISCE_DISCOVER_DOMAIN, &port->disc.disc_event_lock, 657 sas_begin_event(DISCE_DISCOVER_DOMAIN, &port->disc.disc_event_lock,
656 &port->disc.pending); 658 &port->disc.pending);
@@ -692,10 +694,12 @@ static void sas_discover_domain(void *data)
692 current->pid, error); 694 current->pid, error);
693} 695}
694 696
695static void sas_revalidate_domain(void *data) 697static void sas_revalidate_domain(struct work_struct *work)
696{ 698{
697 int res = 0; 699 int res = 0;
698 struct asd_sas_port *port = data; 700 struct sas_discovery_event *ev =
701 container_of(work, struct sas_discovery_event, work);
702 struct asd_sas_port *port = ev->port;
699 703
700 sas_begin_event(DISCE_REVALIDATE_DOMAIN, &port->disc.disc_event_lock, 704 sas_begin_event(DISCE_REVALIDATE_DOMAIN, &port->disc.disc_event_lock,
701 &port->disc.pending); 705 &port->disc.pending);
@@ -722,7 +726,7 @@ int sas_discover_event(struct asd_sas_port *port, enum discover_event ev)
722 BUG_ON(ev >= DISC_NUM_EVENTS); 726 BUG_ON(ev >= DISC_NUM_EVENTS);
723 727
724 sas_queue_event(ev, &disc->disc_event_lock, &disc->pending, 728 sas_queue_event(ev, &disc->disc_event_lock, &disc->pending,
725 &disc->disc_work[ev], port->ha->core.shost); 729 &disc->disc_work[ev].work, port->ha->core.shost);
726 730
727 return 0; 731 return 0;
728} 732}
@@ -737,13 +741,15 @@ void sas_init_disc(struct sas_discovery *disc, struct asd_sas_port *port)
737{ 741{
738 int i; 742 int i;
739 743
740 static void (*sas_event_fns[DISC_NUM_EVENTS])(void *) = { 744 static const work_func_t sas_event_fns[DISC_NUM_EVENTS] = {
741 [DISCE_DISCOVER_DOMAIN] = sas_discover_domain, 745 [DISCE_DISCOVER_DOMAIN] = sas_discover_domain,
742 [DISCE_REVALIDATE_DOMAIN] = sas_revalidate_domain, 746 [DISCE_REVALIDATE_DOMAIN] = sas_revalidate_domain,
743 }; 747 };
744 748
745 spin_lock_init(&disc->disc_event_lock); 749 spin_lock_init(&disc->disc_event_lock);
746 disc->pending = 0; 750 disc->pending = 0;
747 for (i = 0; i < DISC_NUM_EVENTS; i++) 751 for (i = 0; i < DISC_NUM_EVENTS; i++) {
748 INIT_WORK(&disc->disc_work[i], sas_event_fns[i], port); 752 INIT_WORK(&disc->disc_work[i].work, sas_event_fns[i]);
753 disc->disc_work[i].port = port;
754 }
749} 755}
diff --git a/drivers/scsi/libsas/sas_event.c b/drivers/scsi/libsas/sas_event.c
index 19110ed1c89c..d83392ee6823 100644
--- a/drivers/scsi/libsas/sas_event.c
+++ b/drivers/scsi/libsas/sas_event.c
@@ -31,7 +31,7 @@ static void notify_ha_event(struct sas_ha_struct *sas_ha, enum ha_event event)
31 BUG_ON(event >= HA_NUM_EVENTS); 31 BUG_ON(event >= HA_NUM_EVENTS);
32 32
33 sas_queue_event(event, &sas_ha->event_lock, &sas_ha->pending, 33 sas_queue_event(event, &sas_ha->event_lock, &sas_ha->pending,
34 &sas_ha->ha_events[event], sas_ha->core.shost); 34 &sas_ha->ha_events[event].work, sas_ha->core.shost);
35} 35}
36 36
37static void notify_port_event(struct asd_sas_phy *phy, enum port_event event) 37static void notify_port_event(struct asd_sas_phy *phy, enum port_event event)
@@ -41,7 +41,7 @@ static void notify_port_event(struct asd_sas_phy *phy, enum port_event event)
41 BUG_ON(event >= PORT_NUM_EVENTS); 41 BUG_ON(event >= PORT_NUM_EVENTS);
42 42
43 sas_queue_event(event, &ha->event_lock, &phy->port_events_pending, 43 sas_queue_event(event, &ha->event_lock, &phy->port_events_pending,
44 &phy->port_events[event], ha->core.shost); 44 &phy->port_events[event].work, ha->core.shost);
45} 45}
46 46
47static void notify_phy_event(struct asd_sas_phy *phy, enum phy_event event) 47static void notify_phy_event(struct asd_sas_phy *phy, enum phy_event event)
@@ -51,12 +51,12 @@ static void notify_phy_event(struct asd_sas_phy *phy, enum phy_event event)
51 BUG_ON(event >= PHY_NUM_EVENTS); 51 BUG_ON(event >= PHY_NUM_EVENTS);
52 52
53 sas_queue_event(event, &ha->event_lock, &phy->phy_events_pending, 53 sas_queue_event(event, &ha->event_lock, &phy->phy_events_pending,
54 &phy->phy_events[event], ha->core.shost); 54 &phy->phy_events[event].work, ha->core.shost);
55} 55}
56 56
57int sas_init_events(struct sas_ha_struct *sas_ha) 57int sas_init_events(struct sas_ha_struct *sas_ha)
58{ 58{
59 static void (*sas_ha_event_fns[HA_NUM_EVENTS])(void *) = { 59 static const work_func_t sas_ha_event_fns[HA_NUM_EVENTS] = {
60 [HAE_RESET] = sas_hae_reset, 60 [HAE_RESET] = sas_hae_reset,
61 }; 61 };
62 62
@@ -64,8 +64,10 @@ int sas_init_events(struct sas_ha_struct *sas_ha)
64 64
65 spin_lock_init(&sas_ha->event_lock); 65 spin_lock_init(&sas_ha->event_lock);
66 66
67 for (i = 0; i < HA_NUM_EVENTS; i++) 67 for (i = 0; i < HA_NUM_EVENTS; i++) {
68 INIT_WORK(&sas_ha->ha_events[i], sas_ha_event_fns[i], sas_ha); 68 INIT_WORK(&sas_ha->ha_events[i].work, sas_ha_event_fns[i]);
69 sas_ha->ha_events[i].ha = sas_ha;
70 }
69 71
70 sas_ha->notify_ha_event = notify_ha_event; 72 sas_ha->notify_ha_event = notify_ha_event;
71 sas_ha->notify_port_event = notify_port_event; 73 sas_ha->notify_port_event = notify_port_event;
diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c
index 0fb347b4b1a2..2f0c07fc3f48 100644
--- a/drivers/scsi/libsas/sas_init.c
+++ b/drivers/scsi/libsas/sas_init.c
@@ -36,7 +36,7 @@
36 36
37#include "../scsi_sas_internal.h" 37#include "../scsi_sas_internal.h"
38 38
39kmem_cache_t *sas_task_cache; 39struct kmem_cache *sas_task_cache;
40 40
41/*------------ SAS addr hash -----------*/ 41/*------------ SAS addr hash -----------*/
42void sas_hash_addr(u8 *hashed, const u8 *sas_addr) 42void sas_hash_addr(u8 *hashed, const u8 *sas_addr)
@@ -65,9 +65,11 @@ void sas_hash_addr(u8 *hashed, const u8 *sas_addr)
65 65
66/* ---------- HA events ---------- */ 66/* ---------- HA events ---------- */
67 67
68void sas_hae_reset(void *data) 68void sas_hae_reset(struct work_struct *work)
69{ 69{
70 struct sas_ha_struct *ha = data; 70 struct sas_ha_event *ev =
71 container_of(work, struct sas_ha_event, work);
72 struct sas_ha_struct *ha = ev->ha;
71 73
72 sas_begin_event(HAE_RESET, &ha->event_lock, 74 sas_begin_event(HAE_RESET, &ha->event_lock,
73 &ha->pending); 75 &ha->pending);
diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h
index bffcee474921..137d7e496b6d 100644
--- a/drivers/scsi/libsas/sas_internal.h
+++ b/drivers/scsi/libsas/sas_internal.h
@@ -60,11 +60,11 @@ void sas_shutdown_queue(struct sas_ha_struct *sas_ha);
60 60
61void sas_deform_port(struct asd_sas_phy *phy); 61void sas_deform_port(struct asd_sas_phy *phy);
62 62
63void sas_porte_bytes_dmaed(void *); 63void sas_porte_bytes_dmaed(struct work_struct *work);
64void sas_porte_broadcast_rcvd(void *); 64void sas_porte_broadcast_rcvd(struct work_struct *work);
65void sas_porte_link_reset_err(void *); 65void sas_porte_link_reset_err(struct work_struct *work);
66void sas_porte_timer_event(void *); 66void sas_porte_timer_event(struct work_struct *work);
67void sas_porte_hard_reset(void *); 67void sas_porte_hard_reset(struct work_struct *work);
68 68
69int sas_notify_lldd_dev_found(struct domain_device *); 69int sas_notify_lldd_dev_found(struct domain_device *);
70void sas_notify_lldd_dev_gone(struct domain_device *); 70void sas_notify_lldd_dev_gone(struct domain_device *);
@@ -75,7 +75,7 @@ int sas_smp_get_phy_events(struct sas_phy *phy);
75 75
76struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy); 76struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy);
77 77
78void sas_hae_reset(void *); 78void sas_hae_reset(struct work_struct *work);
79 79
80static inline void sas_queue_event(int event, spinlock_t *lock, 80static inline void sas_queue_event(int event, spinlock_t *lock,
81 unsigned long *pending, 81 unsigned long *pending,
diff --git a/drivers/scsi/libsas/sas_phy.c b/drivers/scsi/libsas/sas_phy.c
index 9340cdbae4a3..b459c4b635b1 100644
--- a/drivers/scsi/libsas/sas_phy.c
+++ b/drivers/scsi/libsas/sas_phy.c
@@ -30,9 +30,11 @@
30 30
31/* ---------- Phy events ---------- */ 31/* ---------- Phy events ---------- */
32 32
33static void sas_phye_loss_of_signal(void *data) 33static void sas_phye_loss_of_signal(struct work_struct *work)
34{ 34{
35 struct asd_sas_phy *phy = data; 35 struct asd_sas_event *ev =
36 container_of(work, struct asd_sas_event, work);
37 struct asd_sas_phy *phy = ev->phy;
36 38
37 sas_begin_event(PHYE_LOSS_OF_SIGNAL, &phy->ha->event_lock, 39 sas_begin_event(PHYE_LOSS_OF_SIGNAL, &phy->ha->event_lock,
38 &phy->phy_events_pending); 40 &phy->phy_events_pending);
@@ -40,18 +42,22 @@ static void sas_phye_loss_of_signal(void *data)
40 sas_deform_port(phy); 42 sas_deform_port(phy);
41} 43}
42 44
43static void sas_phye_oob_done(void *data) 45static void sas_phye_oob_done(struct work_struct *work)
44{ 46{
45 struct asd_sas_phy *phy = data; 47 struct asd_sas_event *ev =
48 container_of(work, struct asd_sas_event, work);
49 struct asd_sas_phy *phy = ev->phy;
46 50
47 sas_begin_event(PHYE_OOB_DONE, &phy->ha->event_lock, 51 sas_begin_event(PHYE_OOB_DONE, &phy->ha->event_lock,
48 &phy->phy_events_pending); 52 &phy->phy_events_pending);
49 phy->error = 0; 53 phy->error = 0;
50} 54}
51 55
52static void sas_phye_oob_error(void *data) 56static void sas_phye_oob_error(struct work_struct *work)
53{ 57{
54 struct asd_sas_phy *phy = data; 58 struct asd_sas_event *ev =
59 container_of(work, struct asd_sas_event, work);
60 struct asd_sas_phy *phy = ev->phy;
55 struct sas_ha_struct *sas_ha = phy->ha; 61 struct sas_ha_struct *sas_ha = phy->ha;
56 struct asd_sas_port *port = phy->port; 62 struct asd_sas_port *port = phy->port;
57 struct sas_internal *i = 63 struct sas_internal *i =
@@ -80,9 +86,11 @@ static void sas_phye_oob_error(void *data)
80 } 86 }
81} 87}
82 88
83static void sas_phye_spinup_hold(void *data) 89static void sas_phye_spinup_hold(struct work_struct *work)
84{ 90{
85 struct asd_sas_phy *phy = data; 91 struct asd_sas_event *ev =
92 container_of(work, struct asd_sas_event, work);
93 struct asd_sas_phy *phy = ev->phy;
86 struct sas_ha_struct *sas_ha = phy->ha; 94 struct sas_ha_struct *sas_ha = phy->ha;
87 struct sas_internal *i = 95 struct sas_internal *i =
88 to_sas_internal(sas_ha->core.shost->transportt); 96 to_sas_internal(sas_ha->core.shost->transportt);
@@ -100,14 +108,14 @@ int sas_register_phys(struct sas_ha_struct *sas_ha)
100{ 108{
101 int i; 109 int i;
102 110
103 static void (*sas_phy_event_fns[PHY_NUM_EVENTS])(void *) = { 111 static const work_func_t sas_phy_event_fns[PHY_NUM_EVENTS] = {
104 [PHYE_LOSS_OF_SIGNAL] = sas_phye_loss_of_signal, 112 [PHYE_LOSS_OF_SIGNAL] = sas_phye_loss_of_signal,
105 [PHYE_OOB_DONE] = sas_phye_oob_done, 113 [PHYE_OOB_DONE] = sas_phye_oob_done,
106 [PHYE_OOB_ERROR] = sas_phye_oob_error, 114 [PHYE_OOB_ERROR] = sas_phye_oob_error,
107 [PHYE_SPINUP_HOLD] = sas_phye_spinup_hold, 115 [PHYE_SPINUP_HOLD] = sas_phye_spinup_hold,
108 }; 116 };
109 117
110 static void (*sas_port_event_fns[PORT_NUM_EVENTS])(void *) = { 118 static const work_func_t sas_port_event_fns[PORT_NUM_EVENTS] = {
111 [PORTE_BYTES_DMAED] = sas_porte_bytes_dmaed, 119 [PORTE_BYTES_DMAED] = sas_porte_bytes_dmaed,
112 [PORTE_BROADCAST_RCVD] = sas_porte_broadcast_rcvd, 120 [PORTE_BROADCAST_RCVD] = sas_porte_broadcast_rcvd,
113 [PORTE_LINK_RESET_ERR] = sas_porte_link_reset_err, 121 [PORTE_LINK_RESET_ERR] = sas_porte_link_reset_err,
@@ -122,13 +130,18 @@ int sas_register_phys(struct sas_ha_struct *sas_ha)
122 130
123 phy->error = 0; 131 phy->error = 0;
124 INIT_LIST_HEAD(&phy->port_phy_el); 132 INIT_LIST_HEAD(&phy->port_phy_el);
125 for (k = 0; k < PORT_NUM_EVENTS; k++) 133 for (k = 0; k < PORT_NUM_EVENTS; k++) {
126 INIT_WORK(&phy->port_events[k], sas_port_event_fns[k], 134 INIT_WORK(&phy->port_events[k].work,
127 phy); 135 sas_port_event_fns[k]);
136 phy->port_events[k].phy = phy;
137 }
138
139 for (k = 0; k < PHY_NUM_EVENTS; k++) {
140 INIT_WORK(&phy->phy_events[k].work,
141 sas_phy_event_fns[k]);
142 phy->phy_events[k].phy = phy;
143 }
128 144
129 for (k = 0; k < PHY_NUM_EVENTS; k++)
130 INIT_WORK(&phy->phy_events[k], sas_phy_event_fns[k],
131 phy);
132 phy->port = NULL; 145 phy->port = NULL;
133 phy->ha = sas_ha; 146 phy->ha = sas_ha;
134 spin_lock_init(&phy->frame_rcvd_lock); 147 spin_lock_init(&phy->frame_rcvd_lock);
diff --git a/drivers/scsi/libsas/sas_port.c b/drivers/scsi/libsas/sas_port.c
index 253cdcf306a2..971c37ceecb4 100644
--- a/drivers/scsi/libsas/sas_port.c
+++ b/drivers/scsi/libsas/sas_port.c
@@ -181,9 +181,11 @@ void sas_deform_port(struct asd_sas_phy *phy)
181 181
182/* ---------- SAS port events ---------- */ 182/* ---------- SAS port events ---------- */
183 183
184void sas_porte_bytes_dmaed(void *data) 184void sas_porte_bytes_dmaed(struct work_struct *work)
185{ 185{
186 struct asd_sas_phy *phy = data; 186 struct asd_sas_event *ev =
187 container_of(work, struct asd_sas_event, work);
188 struct asd_sas_phy *phy = ev->phy;
187 189
188 sas_begin_event(PORTE_BYTES_DMAED, &phy->ha->event_lock, 190 sas_begin_event(PORTE_BYTES_DMAED, &phy->ha->event_lock,
189 &phy->port_events_pending); 191 &phy->port_events_pending);
@@ -191,11 +193,13 @@ void sas_porte_bytes_dmaed(void *data)
191 sas_form_port(phy); 193 sas_form_port(phy);
192} 194}
193 195
194void sas_porte_broadcast_rcvd(void *data) 196void sas_porte_broadcast_rcvd(struct work_struct *work)
195{ 197{
198 struct asd_sas_event *ev =
199 container_of(work, struct asd_sas_event, work);
200 struct asd_sas_phy *phy = ev->phy;
196 unsigned long flags; 201 unsigned long flags;
197 u32 prim; 202 u32 prim;
198 struct asd_sas_phy *phy = data;
199 203
200 sas_begin_event(PORTE_BROADCAST_RCVD, &phy->ha->event_lock, 204 sas_begin_event(PORTE_BROADCAST_RCVD, &phy->ha->event_lock,
201 &phy->port_events_pending); 205 &phy->port_events_pending);
@@ -208,9 +212,11 @@ void sas_porte_broadcast_rcvd(void *data)
208 sas_discover_event(phy->port, DISCE_REVALIDATE_DOMAIN); 212 sas_discover_event(phy->port, DISCE_REVALIDATE_DOMAIN);
209} 213}
210 214
211void sas_porte_link_reset_err(void *data) 215void sas_porte_link_reset_err(struct work_struct *work)
212{ 216{
213 struct asd_sas_phy *phy = data; 217 struct asd_sas_event *ev =
218 container_of(work, struct asd_sas_event, work);
219 struct asd_sas_phy *phy = ev->phy;
214 220
215 sas_begin_event(PORTE_LINK_RESET_ERR, &phy->ha->event_lock, 221 sas_begin_event(PORTE_LINK_RESET_ERR, &phy->ha->event_lock,
216 &phy->port_events_pending); 222 &phy->port_events_pending);
@@ -218,9 +224,11 @@ void sas_porte_link_reset_err(void *data)
218 sas_deform_port(phy); 224 sas_deform_port(phy);
219} 225}
220 226
221void sas_porte_timer_event(void *data) 227void sas_porte_timer_event(struct work_struct *work)
222{ 228{
223 struct asd_sas_phy *phy = data; 229 struct asd_sas_event *ev =
230 container_of(work, struct asd_sas_event, work);
231 struct asd_sas_phy *phy = ev->phy;
224 232
225 sas_begin_event(PORTE_TIMER_EVENT, &phy->ha->event_lock, 233 sas_begin_event(PORTE_TIMER_EVENT, &phy->ha->event_lock,
226 &phy->port_events_pending); 234 &phy->port_events_pending);
@@ -228,9 +236,11 @@ void sas_porte_timer_event(void *data)
228 sas_deform_port(phy); 236 sas_deform_port(phy);
229} 237}
230 238
231void sas_porte_hard_reset(void *data) 239void sas_porte_hard_reset(struct work_struct *work)
232{ 240{
233 struct asd_sas_phy *phy = data; 241 struct asd_sas_event *ev =
242 container_of(work, struct asd_sas_event, work);
243 struct asd_sas_phy *phy = ev->phy;
234 244
235 sas_begin_event(PORTE_HARD_RESET, &phy->ha->event_lock, 245 sas_begin_event(PORTE_HARD_RESET, &phy->ha->event_lock,
236 &phy->port_events_pending); 246 &phy->port_events_pending);
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index e064aac06b90..22672d54aa27 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -846,8 +846,10 @@ static int do_sas_task_abort(struct sas_task *task)
846 return -EAGAIN; 846 return -EAGAIN;
847} 847}
848 848
849void sas_task_abort(struct sas_task *task) 849void sas_task_abort(struct work_struct *work)
850{ 850{
851 struct sas_task *task =
852 container_of(work, struct sas_task, abort_work);
851 int i; 853 int i;
852 854
853 for (i = 0; i < 5; i++) 855 for (i = 0; i < 5; i++)
diff --git a/drivers/scsi/oktagon_esp.c b/drivers/scsi/oktagon_esp.c
index dd67a68c5c23..c116a6ae3c54 100644
--- a/drivers/scsi/oktagon_esp.c
+++ b/drivers/scsi/oktagon_esp.c
@@ -72,12 +72,12 @@ static void dma_advance_sg(Scsi_Cmnd *);
72static int oktagon_notify_reboot(struct notifier_block *this, unsigned long code, void *x); 72static int oktagon_notify_reboot(struct notifier_block *this, unsigned long code, void *x);
73 73
74#ifdef USE_BOTTOM_HALF 74#ifdef USE_BOTTOM_HALF
75static void dma_commit(void *opaque); 75static void dma_commit(struct work_struct *unused);
76 76
77long oktag_to_io(long *paddr, long *addr, long len); 77long oktag_to_io(long *paddr, long *addr, long len);
78long oktag_from_io(long *addr, long *paddr, long len); 78long oktag_from_io(long *addr, long *paddr, long len);
79 79
80static DECLARE_WORK(tq_fake_dma, dma_commit, NULL); 80static DECLARE_WORK(tq_fake_dma, dma_commit);
81 81
82#define DMA_MAXTRANSFER 0x8000 82#define DMA_MAXTRANSFER 0x8000
83 83
@@ -266,7 +266,7 @@ oktagon_notify_reboot(struct notifier_block *this, unsigned long code, void *x)
266 */ 266 */
267 267
268 268
269static void dma_commit(void *opaque) 269static void dma_commit(struct work_struct *unused)
270{ 270{
271 long wait,len2,pos; 271 long wait,len2,pos;
272 struct NCR_ESP *esp; 272 struct NCR_ESP *esp;
diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index 89a2a9f11e41..584ba4d6e038 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -31,7 +31,7 @@ typedef struct {
31 int base; /* Actual port address */ 31 int base; /* Actual port address */
32 int mode; /* Transfer mode */ 32 int mode; /* Transfer mode */
33 struct scsi_cmnd *cur_cmd; /* Current queued command */ 33 struct scsi_cmnd *cur_cmd; /* Current queued command */
34 struct work_struct ppa_tq; /* Polling interrupt stuff */ 34 struct delayed_work ppa_tq; /* Polling interrupt stuff */
35 unsigned long jstart; /* Jiffies at start */ 35 unsigned long jstart; /* Jiffies at start */
36 unsigned long recon_tmo; /* How many usecs to wait for reconnection (6th bit) */ 36 unsigned long recon_tmo; /* How many usecs to wait for reconnection (6th bit) */
37 unsigned int failed:1; /* Failure flag */ 37 unsigned int failed:1; /* Failure flag */
@@ -627,9 +627,9 @@ static int ppa_completion(struct scsi_cmnd *cmd)
627 * the scheduler's task queue to generate a stream of call-backs and 627 * the scheduler's task queue to generate a stream of call-backs and
628 * complete the request when the drive is ready. 628 * complete the request when the drive is ready.
629 */ 629 */
630static void ppa_interrupt(void *data) 630static void ppa_interrupt(struct work_struct *work)
631{ 631{
632 ppa_struct *dev = (ppa_struct *) data; 632 ppa_struct *dev = container_of(work, ppa_struct, ppa_tq.work);
633 struct scsi_cmnd *cmd = dev->cur_cmd; 633 struct scsi_cmnd *cmd = dev->cur_cmd;
634 634
635 if (!cmd) { 635 if (!cmd) {
@@ -637,7 +637,6 @@ static void ppa_interrupt(void *data)
637 return; 637 return;
638 } 638 }
639 if (ppa_engine(dev, cmd)) { 639 if (ppa_engine(dev, cmd)) {
640 dev->ppa_tq.data = (void *) dev;
641 schedule_delayed_work(&dev->ppa_tq, 1); 640 schedule_delayed_work(&dev->ppa_tq, 1);
642 return; 641 return;
643 } 642 }
@@ -822,8 +821,7 @@ static int ppa_queuecommand(struct scsi_cmnd *cmd,
822 cmd->result = DID_ERROR << 16; /* default return code */ 821 cmd->result = DID_ERROR << 16; /* default return code */
823 cmd->SCp.phase = 0; /* bus free */ 822 cmd->SCp.phase = 0; /* bus free */
824 823
825 dev->ppa_tq.data = dev; 824 schedule_delayed_work(&dev->ppa_tq, 0);
826 schedule_work(&dev->ppa_tq);
827 825
828 ppa_pb_claim(dev); 826 ppa_pb_claim(dev);
829 827
@@ -1086,7 +1084,7 @@ static int __ppa_attach(struct parport *pb)
1086 else 1084 else
1087 ports = 8; 1085 ports = 8;
1088 1086
1089 INIT_WORK(&dev->ppa_tq, ppa_interrupt, dev); 1087 INIT_DELAYED_WORK(&dev->ppa_tq, ppa_interrupt);
1090 1088
1091 err = -ENOMEM; 1089 err = -ENOMEM;
1092 host = scsi_host_alloc(&ppa_template, sizeof(ppa_struct *)); 1090 host = scsi_host_alloc(&ppa_template, sizeof(ppa_struct *));
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index cbe0cad83b68..d03523d3bf38 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -24,7 +24,7 @@ char qla2x00_version_str[40];
24/* 24/*
25 * SRB allocation cache 25 * SRB allocation cache
26 */ 26 */
27static kmem_cache_t *srb_cachep; 27static struct kmem_cache *srb_cachep;
28 28
29/* 29/*
30 * Ioctl related information. 30 * Ioctl related information.
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index db9d88e7bee7..9ef693c8809a 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -19,7 +19,7 @@ char qla4xxx_version_str[40];
19/* 19/*
20 * SRB allocation cache 20 * SRB allocation cache
21 */ 21 */
22static kmem_cache_t *srb_cachep; 22static struct kmem_cache *srb_cachep;
23 23
24/* 24/*
25 * Module parameter information and variables 25 * Module parameter information and variables
@@ -961,9 +961,10 @@ static int qla4xxx_recover_adapter(struct scsi_qla_host *ha,
961 * the mid-level tries to sleep when it reaches the driver threshold 961 * the mid-level tries to sleep when it reaches the driver threshold
962 * "host->can_queue". This can cause a panic if we were in our interrupt code. 962 * "host->can_queue". This can cause a panic if we were in our interrupt code.
963 **/ 963 **/
964static void qla4xxx_do_dpc(void *data) 964static void qla4xxx_do_dpc(struct work_struct *work)
965{ 965{
966 struct scsi_qla_host *ha = (struct scsi_qla_host *) data; 966 struct scsi_qla_host *ha =
967 container_of(work, struct scsi_qla_host, dpc_work);
967 struct ddb_entry *ddb_entry, *dtemp; 968 struct ddb_entry *ddb_entry, *dtemp;
968 969
969 DEBUG2(printk("scsi%ld: %s: DPC handler waking up." 970 DEBUG2(printk("scsi%ld: %s: DPC handler waking up."
@@ -1253,7 +1254,7 @@ static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev,
1253 ret = -ENODEV; 1254 ret = -ENODEV;
1254 goto probe_failed; 1255 goto probe_failed;
1255 } 1256 }
1256 INIT_WORK(&ha->dpc_work, qla4xxx_do_dpc, ha); 1257 INIT_WORK(&ha->dpc_work, qla4xxx_do_dpc);
1257 1258
1258 ret = request_irq(pdev->irq, qla4xxx_intr_handler, 1259 ret = request_irq(pdev->irq, qla4xxx_intr_handler,
1259 SA_INTERRUPT|SA_SHIRQ, "qla4xxx", ha); 1260 SA_INTERRUPT|SA_SHIRQ, "qla4xxx", ha);
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index fafc00deaade..24cffd98ee63 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -136,7 +136,7 @@ const char * scsi_device_type(unsigned type)
136EXPORT_SYMBOL(scsi_device_type); 136EXPORT_SYMBOL(scsi_device_type);
137 137
138struct scsi_host_cmd_pool { 138struct scsi_host_cmd_pool {
139 kmem_cache_t *slab; 139 struct kmem_cache *slab;
140 unsigned int users; 140 unsigned int users;
141 char *name; 141 char *name;
142 unsigned int slab_flags; 142 unsigned int slab_flags;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index fb616c69151f..1748e27501cd 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -36,7 +36,7 @@
36struct scsi_host_sg_pool { 36struct scsi_host_sg_pool {
37 size_t size; 37 size_t size;
38 char *name; 38 char *name;
39 kmem_cache_t *slab; 39 struct kmem_cache *slab;
40 mempool_t *pool; 40 mempool_t *pool;
41}; 41};
42 42
@@ -241,7 +241,7 @@ struct scsi_io_context {
241 char sense[SCSI_SENSE_BUFFERSIZE]; 241 char sense[SCSI_SENSE_BUFFERSIZE];
242}; 242};
243 243
244static kmem_cache_t *scsi_io_context_cache; 244static struct kmem_cache *scsi_io_context_cache;
245 245
246static void scsi_end_async(struct request *req, int uptodate) 246static void scsi_end_async(struct request *req, int uptodate)
247{ 247{
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 4d656148bd67..14e635aa44ce 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -437,9 +437,10 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
437 goto retry; 437 goto retry;
438} 438}
439 439
440static void scsi_target_reap_usercontext(void *data) 440static void scsi_target_reap_usercontext(struct work_struct *work)
441{ 441{
442 struct scsi_target *starget = data; 442 struct scsi_target *starget =
443 container_of(work, struct scsi_target, ew.work);
443 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 444 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
444 unsigned long flags; 445 unsigned long flags;
445 446
@@ -475,7 +476,7 @@ void scsi_target_reap(struct scsi_target *starget)
475 starget->state = STARGET_DEL; 476 starget->state = STARGET_DEL;
476 spin_unlock_irqrestore(shost->host_lock, flags); 477 spin_unlock_irqrestore(shost->host_lock, flags);
477 execute_in_process_context(scsi_target_reap_usercontext, 478 execute_in_process_context(scsi_target_reap_usercontext,
478 starget, &starget->ew); 479 &starget->ew);
479 return; 480 return;
480 481
481 } 482 }
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index e1a91665d1c2..259c90cfa367 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -218,16 +218,16 @@ static void scsi_device_cls_release(struct class_device *class_dev)
218 put_device(&sdev->sdev_gendev); 218 put_device(&sdev->sdev_gendev);
219} 219}
220 220
221static void scsi_device_dev_release_usercontext(void *data) 221static void scsi_device_dev_release_usercontext(struct work_struct *work)
222{ 222{
223 struct device *dev = data;
224 struct scsi_device *sdev; 223 struct scsi_device *sdev;
225 struct device *parent; 224 struct device *parent;
226 struct scsi_target *starget; 225 struct scsi_target *starget;
227 unsigned long flags; 226 unsigned long flags;
228 227
229 parent = dev->parent; 228 sdev = container_of(work, struct scsi_device, ew.work);
230 sdev = to_scsi_device(dev); 229
230 parent = sdev->sdev_gendev.parent;
231 starget = to_scsi_target(parent); 231 starget = to_scsi_target(parent);
232 232
233 spin_lock_irqsave(sdev->host->host_lock, flags); 233 spin_lock_irqsave(sdev->host->host_lock, flags);
@@ -258,7 +258,7 @@ static void scsi_device_dev_release_usercontext(void *data)
258static void scsi_device_dev_release(struct device *dev) 258static void scsi_device_dev_release(struct device *dev)
259{ 259{
260 struct scsi_device *sdp = to_scsi_device(dev); 260 struct scsi_device *sdp = to_scsi_device(dev);
261 execute_in_process_context(scsi_device_dev_release_usercontext, dev, 261 execute_in_process_context(scsi_device_dev_release_usercontext,
262 &sdp->ew); 262 &sdp->ew);
263} 263}
264 264
diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
index 39da5cd6fb6f..d402aff5f314 100644
--- a/drivers/scsi/scsi_tgt_lib.c
+++ b/drivers/scsi/scsi_tgt_lib.c
@@ -33,7 +33,7 @@
33#include "scsi_tgt_priv.h" 33#include "scsi_tgt_priv.h"
34 34
35static struct workqueue_struct *scsi_tgtd; 35static struct workqueue_struct *scsi_tgtd;
36static kmem_cache_t *scsi_tgt_cmd_cache; 36static struct kmem_cache *scsi_tgt_cmd_cache;
37 37
38/* 38/*
39 * TODO: this struct will be killed when the block layer supports large bios 39 * TODO: this struct will be killed when the block layer supports large bios
@@ -185,10 +185,11 @@ static void cmd_hashlist_del(struct scsi_cmnd *cmd)
185 spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags); 185 spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags);
186} 186}
187 187
188static void scsi_tgt_cmd_destroy(void *data) 188static void scsi_tgt_cmd_destroy(struct work_struct *work)
189{ 189{
190 struct scsi_cmnd *cmd = data; 190 struct scsi_tgt_cmd *tcmd =
191 struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data; 191 container_of(work, struct scsi_tgt_cmd, work);
192 struct scsi_cmnd *cmd = tcmd->rq->special;
192 193
193 dprintk("cmd %p %d %lu\n", cmd, cmd->sc_data_direction, 194 dprintk("cmd %p %d %lu\n", cmd, cmd->sc_data_direction,
194 rq_data_dir(cmd->request)); 195 rq_data_dir(cmd->request));
@@ -214,6 +215,7 @@ static void init_scsi_tgt_cmd(struct request *rq, struct scsi_tgt_cmd *tcmd,
214 struct list_head *head; 215 struct list_head *head;
215 216
216 tcmd->tag = tag; 217 tcmd->tag = tag;
218 INIT_WORK(&tcmd->work, scsi_tgt_cmd_destroy);
217 spin_lock_irqsave(&qdata->cmd_hash_lock, flags); 219 spin_lock_irqsave(&qdata->cmd_hash_lock, flags);
218 head = &qdata->cmd_hash[cmd_hashfn(tag)]; 220 head = &qdata->cmd_hash[cmd_hashfn(tag)];
219 list_add(&tcmd->hash_list, head); 221 list_add(&tcmd->hash_list, head);
@@ -303,7 +305,7 @@ void scsi_tgt_free_queue(struct Scsi_Host *shost)
303 cmd = tcmd->rq->special; 305 cmd = tcmd->rq->special;
304 306
305 shost->hostt->eh_abort_handler(cmd); 307 shost->hostt->eh_abort_handler(cmd);
306 scsi_tgt_cmd_destroy(cmd); 308 scsi_tgt_cmd_destroy(&tcmd->work);
307 } 309 }
308} 310}
309EXPORT_SYMBOL_GPL(scsi_tgt_free_queue); 311EXPORT_SYMBOL_GPL(scsi_tgt_free_queue);
@@ -347,7 +349,6 @@ static void scsi_tgt_cmd_done(struct scsi_cmnd *cmd)
347 dprintk("cmd %p %lu\n", cmd, rq_data_dir(cmd->request)); 349 dprintk("cmd %p %lu\n", cmd, rq_data_dir(cmd->request));
348 350
349 scsi_tgt_uspace_send_status(cmd, tcmd->tag); 351 scsi_tgt_uspace_send_status(cmd, tcmd->tag);
350 INIT_WORK(&tcmd->work, scsi_tgt_cmd_destroy, cmd);
351 queue_work(scsi_tgtd, &tcmd->work); 352 queue_work(scsi_tgtd, &tcmd->work);
352} 353}
353 354
@@ -549,13 +550,15 @@ static int scsi_tgt_copy_sense(struct scsi_cmnd *cmd, unsigned long uaddr,
549 550
550static int scsi_tgt_abort_cmd(struct Scsi_Host *shost, struct scsi_cmnd *cmd) 551static int scsi_tgt_abort_cmd(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
551{ 552{
553 struct scsi_tgt_cmd *tcmd;
552 int err; 554 int err;
553 555
554 err = shost->hostt->eh_abort_handler(cmd); 556 err = shost->hostt->eh_abort_handler(cmd);
555 if (err) 557 if (err)
556 eprintk("fail to abort %p\n", cmd); 558 eprintk("fail to abort %p\n", cmd);
557 559
558 scsi_tgt_cmd_destroy(cmd); 560 tcmd = cmd->request->end_io_data;
561 scsi_tgt_cmd_destroy(&tcmd->work);
559 return err; 562 return err;
560} 563}
561 564
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 38c215a78f69..3571ce8934e7 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -241,9 +241,9 @@ fc_bitfield_name_search(remote_port_roles, fc_remote_port_role_names)
241#define FC_MGMTSRVR_PORTID 0x00000a 241#define FC_MGMTSRVR_PORTID 0x00000a
242 242
243 243
244static void fc_timeout_deleted_rport(void *data); 244static void fc_timeout_deleted_rport(struct work_struct *work);
245static void fc_timeout_fail_rport_io(void *data); 245static void fc_timeout_fail_rport_io(struct work_struct *work);
246static void fc_scsi_scan_rport(void *data); 246static void fc_scsi_scan_rport(struct work_struct *work);
247 247
248/* 248/*
249 * Attribute counts pre object type... 249 * Attribute counts pre object type...
@@ -1613,7 +1613,7 @@ fc_flush_work(struct Scsi_Host *shost)
1613 * 1 on success / 0 already queued / < 0 for error 1613 * 1 on success / 0 already queued / < 0 for error
1614 **/ 1614 **/
1615static int 1615static int
1616fc_queue_devloss_work(struct Scsi_Host *shost, struct work_struct *work, 1616fc_queue_devloss_work(struct Scsi_Host *shost, struct delayed_work *work,
1617 unsigned long delay) 1617 unsigned long delay)
1618{ 1618{
1619 if (unlikely(!fc_host_devloss_work_q(shost))) { 1619 if (unlikely(!fc_host_devloss_work_q(shost))) {
@@ -1625,9 +1625,6 @@ fc_queue_devloss_work(struct Scsi_Host *shost, struct work_struct *work,
1625 return -EINVAL; 1625 return -EINVAL;
1626 } 1626 }
1627 1627
1628 if (delay == 0)
1629 return queue_work(fc_host_devloss_work_q(shost), work);
1630
1631 return queue_delayed_work(fc_host_devloss_work_q(shost), work, delay); 1628 return queue_delayed_work(fc_host_devloss_work_q(shost), work, delay);
1632} 1629}
1633 1630
@@ -1712,12 +1709,13 @@ EXPORT_SYMBOL(fc_remove_host);
1712 * fc_starget_delete - called to delete the scsi decendents of an rport 1709 * fc_starget_delete - called to delete the scsi decendents of an rport
1713 * (target and all sdevs) 1710 * (target and all sdevs)
1714 * 1711 *
1715 * @data: remote port to be operated on. 1712 * @work: remote port to be operated on.
1716 **/ 1713 **/
1717static void 1714static void
1718fc_starget_delete(void *data) 1715fc_starget_delete(struct work_struct *work)
1719{ 1716{
1720 struct fc_rport *rport = (struct fc_rport *)data; 1717 struct fc_rport *rport =
1718 container_of(work, struct fc_rport, stgt_delete_work);
1721 struct Scsi_Host *shost = rport_to_shost(rport); 1719 struct Scsi_Host *shost = rport_to_shost(rport);
1722 unsigned long flags; 1720 unsigned long flags;
1723 struct fc_internal *i = to_fc_internal(shost->transportt); 1721 struct fc_internal *i = to_fc_internal(shost->transportt);
@@ -1751,12 +1749,13 @@ fc_starget_delete(void *data)
1751/** 1749/**
1752 * fc_rport_final_delete - finish rport termination and delete it. 1750 * fc_rport_final_delete - finish rport termination and delete it.
1753 * 1751 *
1754 * @data: remote port to be deleted. 1752 * @work: remote port to be deleted.
1755 **/ 1753 **/
1756static void 1754static void
1757fc_rport_final_delete(void *data) 1755fc_rport_final_delete(struct work_struct *work)
1758{ 1756{
1759 struct fc_rport *rport = (struct fc_rport *)data; 1757 struct fc_rport *rport =
1758 container_of(work, struct fc_rport, rport_delete_work);
1760 struct device *dev = &rport->dev; 1759 struct device *dev = &rport->dev;
1761 struct Scsi_Host *shost = rport_to_shost(rport); 1760 struct Scsi_Host *shost = rport_to_shost(rport);
1762 struct fc_internal *i = to_fc_internal(shost->transportt); 1761 struct fc_internal *i = to_fc_internal(shost->transportt);
@@ -1770,7 +1769,7 @@ fc_rport_final_delete(void *data)
1770 1769
1771 /* Delete SCSI target and sdevs */ 1770 /* Delete SCSI target and sdevs */
1772 if (rport->scsi_target_id != -1) 1771 if (rport->scsi_target_id != -1)
1773 fc_starget_delete(data); 1772 fc_starget_delete(&rport->stgt_delete_work);
1774 else if (i->f->dev_loss_tmo_callbk) 1773 else if (i->f->dev_loss_tmo_callbk)
1775 i->f->dev_loss_tmo_callbk(rport); 1774 i->f->dev_loss_tmo_callbk(rport);
1776 else if (i->f->terminate_rport_io) 1775 else if (i->f->terminate_rport_io)
@@ -1829,11 +1828,11 @@ fc_rport_create(struct Scsi_Host *shost, int channel,
1829 rport->channel = channel; 1828 rport->channel = channel;
1830 rport->fast_io_fail_tmo = -1; 1829 rport->fast_io_fail_tmo = -1;
1831 1830
1832 INIT_WORK(&rport->dev_loss_work, fc_timeout_deleted_rport, rport); 1831 INIT_DELAYED_WORK(&rport->dev_loss_work, fc_timeout_deleted_rport);
1833 INIT_WORK(&rport->fail_io_work, fc_timeout_fail_rport_io, rport); 1832 INIT_DELAYED_WORK(&rport->fail_io_work, fc_timeout_fail_rport_io);
1834 INIT_WORK(&rport->scan_work, fc_scsi_scan_rport, rport); 1833 INIT_WORK(&rport->scan_work, fc_scsi_scan_rport);
1835 INIT_WORK(&rport->stgt_delete_work, fc_starget_delete, rport); 1834 INIT_WORK(&rport->stgt_delete_work, fc_starget_delete);
1836 INIT_WORK(&rport->rport_delete_work, fc_rport_final_delete, rport); 1835 INIT_WORK(&rport->rport_delete_work, fc_rport_final_delete);
1837 1836
1838 spin_lock_irqsave(shost->host_lock, flags); 1837 spin_lock_irqsave(shost->host_lock, flags);
1839 1838
@@ -1963,7 +1962,7 @@ fc_remote_port_add(struct Scsi_Host *shost, int channel,
1963 } 1962 }
1964 1963
1965 if (match) { 1964 if (match) {
1966 struct work_struct *work = 1965 struct delayed_work *work =
1967 &rport->dev_loss_work; 1966 &rport->dev_loss_work;
1968 1967
1969 memcpy(&rport->node_name, &ids->node_name, 1968 memcpy(&rport->node_name, &ids->node_name,
@@ -2267,12 +2266,13 @@ EXPORT_SYMBOL(fc_remote_port_rolechg);
2267 * was a SCSI target (thus was blocked), and failed 2266 * was a SCSI target (thus was blocked), and failed
2268 * to return in the alloted time. 2267 * to return in the alloted time.
2269 * 2268 *
2270 * @data: rport target that failed to reappear in the alloted time. 2269 * @work: rport target that failed to reappear in the alloted time.
2271 **/ 2270 **/
2272static void 2271static void
2273fc_timeout_deleted_rport(void *data) 2272fc_timeout_deleted_rport(struct work_struct *work)
2274{ 2273{
2275 struct fc_rport *rport = (struct fc_rport *)data; 2274 struct fc_rport *rport =
2275 container_of(work, struct fc_rport, dev_loss_work.work);
2276 struct Scsi_Host *shost = rport_to_shost(rport); 2276 struct Scsi_Host *shost = rport_to_shost(rport);
2277 struct fc_host_attrs *fc_host = shost_to_fc_host(shost); 2277 struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
2278 unsigned long flags; 2278 unsigned long flags;
@@ -2366,15 +2366,16 @@ fc_timeout_deleted_rport(void *data)
2366 * fc_timeout_fail_rport_io - Timeout handler for a fast io failing on a 2366 * fc_timeout_fail_rport_io - Timeout handler for a fast io failing on a
2367 * disconnected SCSI target. 2367 * disconnected SCSI target.
2368 * 2368 *
2369 * @data: rport to terminate io on. 2369 * @work: rport to terminate io on.
2370 * 2370 *
2371 * Notes: Only requests the failure of the io, not that all are flushed 2371 * Notes: Only requests the failure of the io, not that all are flushed
2372 * prior to returning. 2372 * prior to returning.
2373 **/ 2373 **/
2374static void 2374static void
2375fc_timeout_fail_rport_io(void *data) 2375fc_timeout_fail_rport_io(struct work_struct *work)
2376{ 2376{
2377 struct fc_rport *rport = (struct fc_rport *)data; 2377 struct fc_rport *rport =
2378 container_of(work, struct fc_rport, fail_io_work.work);
2378 struct Scsi_Host *shost = rport_to_shost(rport); 2379 struct Scsi_Host *shost = rport_to_shost(rport);
2379 struct fc_internal *i = to_fc_internal(shost->transportt); 2380 struct fc_internal *i = to_fc_internal(shost->transportt);
2380 2381
@@ -2387,12 +2388,13 @@ fc_timeout_fail_rport_io(void *data)
2387/** 2388/**
2388 * fc_scsi_scan_rport - called to perform a scsi scan on a remote port. 2389 * fc_scsi_scan_rport - called to perform a scsi scan on a remote port.
2389 * 2390 *
2390 * @data: remote port to be scanned. 2391 * @work: remote port to be scanned.
2391 **/ 2392 **/
2392static void 2393static void
2393fc_scsi_scan_rport(void *data) 2394fc_scsi_scan_rport(struct work_struct *work)
2394{ 2395{
2395 struct fc_rport *rport = (struct fc_rport *)data; 2396 struct fc_rport *rport =
2397 container_of(work, struct fc_rport, scan_work);
2396 struct Scsi_Host *shost = rport_to_shost(rport); 2398 struct Scsi_Host *shost = rport_to_shost(rport);
2397 unsigned long flags; 2399 unsigned long flags;
2398 2400
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 9b25124a989e..9c22f1342715 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -234,9 +234,11 @@ static int iscsi_user_scan(struct Scsi_Host *shost, uint channel,
234 return 0; 234 return 0;
235} 235}
236 236
237static void session_recovery_timedout(void *data) 237static void session_recovery_timedout(struct work_struct *work)
238{ 238{
239 struct iscsi_cls_session *session = data; 239 struct iscsi_cls_session *session =
240 container_of(work, struct iscsi_cls_session,
241 recovery_work.work);
240 242
241 dev_printk(KERN_INFO, &session->dev, "iscsi: session recovery timed " 243 dev_printk(KERN_INFO, &session->dev, "iscsi: session recovery timed "
242 "out after %d secs\n", session->recovery_tmo); 244 "out after %d secs\n", session->recovery_tmo);
@@ -276,7 +278,7 @@ iscsi_alloc_session(struct Scsi_Host *shost,
276 278
277 session->transport = transport; 279 session->transport = transport;
278 session->recovery_tmo = 120; 280 session->recovery_tmo = 120;
279 INIT_WORK(&session->recovery_work, session_recovery_timedout, session); 281 INIT_DELAYED_WORK(&session->recovery_work, session_recovery_timedout);
280 INIT_LIST_HEAD(&session->host_list); 282 INIT_LIST_HEAD(&session->host_list);
281 INIT_LIST_HEAD(&session->sess_list); 283 INIT_LIST_HEAD(&session->sess_list);
282 284
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index 9f070f0d0f2b..3fded4831460 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -964,9 +964,10 @@ struct work_queue_wrapper {
964}; 964};
965 965
966static void 966static void
967spi_dv_device_work_wrapper(void *data) 967spi_dv_device_work_wrapper(struct work_struct *work)
968{ 968{
969 struct work_queue_wrapper *wqw = (struct work_queue_wrapper *)data; 969 struct work_queue_wrapper *wqw =
970 container_of(work, struct work_queue_wrapper, work);
970 struct scsi_device *sdev = wqw->sdev; 971 struct scsi_device *sdev = wqw->sdev;
971 972
972 kfree(wqw); 973 kfree(wqw);
@@ -1006,7 +1007,7 @@ spi_schedule_dv_device(struct scsi_device *sdev)
1006 return; 1007 return;
1007 } 1008 }
1008 1009
1009 INIT_WORK(&wqw->work, spi_dv_device_work_wrapper, wqw); 1010 INIT_WORK(&wqw->work, spi_dv_device_work_wrapper);
1010 wqw->sdev = sdev; 1011 wqw->sdev = sdev;
1011 1012
1012 schedule_work(&wqw->work); 1013 schedule_work(&wqw->work);
diff --git a/drivers/serial/8250_exar_st16c554.c b/drivers/serial/8250_exar_st16c554.c
new file mode 100644
index 000000000000..567143ace159
--- /dev/null
+++ b/drivers/serial/8250_exar_st16c554.c
@@ -0,0 +1,52 @@
1/*
2 * linux/drivers/serial/8250_exar.c
3 *
4 * Written by Paul B Schroeder < pschroeder "at" uplogix "dot" com >
5 * Based on 8250_boca.
6 *
7 * Copyright (C) 2005 Russell King.
8 * Data taken from include/asm-i386/serial.h
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/serial_8250.h>
17
18#define PORT(_base,_irq) \
19 { \
20 .iobase = _base, \
21 .irq = _irq, \
22 .uartclk = 1843200, \
23 .iotype = UPIO_PORT, \
24 .flags = UPF_BOOT_AUTOCONF, \
25 }
26
27static struct plat_serial8250_port exar_data[] = {
28 PORT(0x100, 5),
29 PORT(0x108, 5),
30 PORT(0x110, 5),
31 PORT(0x118, 5),
32 { },
33};
34
35static struct platform_device exar_device = {
36 .name = "serial8250",
37 .id = PLAT8250_DEV_EXAR_ST16C554,
38 .dev = {
39 .platform_data = exar_data,
40 },
41};
42
43static int __init exar_init(void)
44{
45 return platform_device_register(&exar_device);
46}
47
48module_init(exar_init);
49
50MODULE_AUTHOR("Paul B Schroeder");
51MODULE_DESCRIPTION("8250 serial probe module for Exar cards");
52MODULE_LICENSE("GPL");
diff --git a/drivers/serial/8250_pnp.c b/drivers/serial/8250_pnp.c
index 71d907c8288b..d3d6b82706b5 100644
--- a/drivers/serial/8250_pnp.c
+++ b/drivers/serial/8250_pnp.c
@@ -464,11 +464,38 @@ static void __devexit serial_pnp_remove(struct pnp_dev *dev)
464 serial8250_unregister_port(line - 1); 464 serial8250_unregister_port(line - 1);
465} 465}
466 466
467#ifdef CONFIG_PM
468static int serial_pnp_suspend(struct pnp_dev *dev, pm_message_t state)
469{
470 long line = (long)pnp_get_drvdata(dev);
471
472 if (!line)
473 return -ENODEV;
474 serial8250_suspend_port(line - 1);
475 return 0;
476}
477
478static int serial_pnp_resume(struct pnp_dev *dev)
479{
480 long line = (long)pnp_get_drvdata(dev);
481
482 if (!line)
483 return -ENODEV;
484 serial8250_resume_port(line - 1);
485 return 0;
486}
487#else
488#define serial_pnp_suspend NULL
489#define serial_pnp_resume NULL
490#endif /* CONFIG_PM */
491
467static struct pnp_driver serial_pnp_driver = { 492static struct pnp_driver serial_pnp_driver = {
468 .name = "serial", 493 .name = "serial",
469 .id_table = pnp_dev_table,
470 .probe = serial_pnp_probe, 494 .probe = serial_pnp_probe,
471 .remove = __devexit_p(serial_pnp_remove), 495 .remove = __devexit_p(serial_pnp_remove),
496 .suspend = serial_pnp_suspend,
497 .resume = serial_pnp_resume,
498 .id_table = pnp_dev_table,
472}; 499};
473 500
474static int __init serial8250_pnp_init(void) 501static int __init serial8250_pnp_init(void)
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 0b71e7d18903..fc12d5df10e2 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -210,6 +210,17 @@ config SERIAL_8250_BOCA
210 To compile this driver as a module, choose M here: the module 210 To compile this driver as a module, choose M here: the module
211 will be called 8250_boca. 211 will be called 8250_boca.
212 212
213config SERIAL_8250_EXAR_ST16C554
214 tristate "Support Exar ST16C554/554D Quad UART"
215 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
216 help
217 The Uplogix Envoy TU301 uses this Exar Quad UART. If you are
218 tinkering with your Envoy TU301, or have a machine with this UART,
219 say Y here.
220
221 To compile this driver as a module, choose M here: the module
222 will be called 8250_exar_st16c554.
223
213config SERIAL_8250_HUB6 224config SERIAL_8250_HUB6
214 tristate "Support Hub6 cards" 225 tristate "Support Hub6 cards"
215 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS 226 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
@@ -511,6 +522,25 @@ config SERIAL_IMX_CONSOLE
511 your boot loader (lilo or loadlin) about how to pass options to the 522 your boot loader (lilo or loadlin) about how to pass options to the
512 kernel at boot time.) 523 kernel at boot time.)
513 524
525config SERIAL_UARTLITE
526 tristate "Xilinx uartlite serial port support"
527 depends on PPC32
528 select SERIAL_CORE
529 help
530 Say Y here if you want to use the Xilinx uartlite serial controller.
531
532 To compile this driver as a module, choose M here: the
533 module will be called uartlite.ko.
534
535config SERIAL_UARTLITE_CONSOLE
536 bool "Support for console on Xilinx uartlite serial port"
537 depends on SERIAL_UARTLITE=y
538 select SERIAL_CORE_CONSOLE
539 help
540 Say Y here if you wish to use a Xilinx uartlite as the system
541 console (the system console is the device which receives all kernel
542 messages and warnings and which allows logins in single user mode).
543
514config SERIAL_SUNCORE 544config SERIAL_SUNCORE
515 bool 545 bool
516 depends on SPARC 546 depends on SPARC
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index b4d8a7c182e3..df3632cd7df9 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_SERIAL_8250_CONSOLE) += 8250_early.o
17obj-$(CONFIG_SERIAL_8250_FOURPORT) += 8250_fourport.o 17obj-$(CONFIG_SERIAL_8250_FOURPORT) += 8250_fourport.o
18obj-$(CONFIG_SERIAL_8250_ACCENT) += 8250_accent.o 18obj-$(CONFIG_SERIAL_8250_ACCENT) += 8250_accent.o
19obj-$(CONFIG_SERIAL_8250_BOCA) += 8250_boca.o 19obj-$(CONFIG_SERIAL_8250_BOCA) += 8250_boca.o
20obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554) += 8250_exar_st16c554.o
20obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o 21obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o
21obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o 22obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o
22obj-$(CONFIG_SERIAL_8250_AU1X00) += 8250_au1x00.o 23obj-$(CONFIG_SERIAL_8250_AU1X00) += 8250_au1x00.o
@@ -55,4 +56,5 @@ obj-$(CONFIG_SERIAL_VR41XX) += vr41xx_siu.o
55obj-$(CONFIG_SERIAL_SGI_IOC4) += ioc4_serial.o 56obj-$(CONFIG_SERIAL_SGI_IOC4) += ioc4_serial.o
56obj-$(CONFIG_SERIAL_SGI_IOC3) += ioc3_serial.o 57obj-$(CONFIG_SERIAL_SGI_IOC3) += ioc3_serial.o
57obj-$(CONFIG_SERIAL_ATMEL) += atmel_serial.o 58obj-$(CONFIG_SERIAL_ATMEL) += atmel_serial.o
59obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o
58obj-$(CONFIG_SERIAL_NETX) += netx-serial.o 60obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index 4213fabc62bf..4d3626ef4643 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -129,6 +129,8 @@ static void pl010_rx_chars(struct uart_port *port)
129 */ 129 */
130 rsr = readb(port->membase + UART01x_RSR) | UART_DUMMY_RSR_RX; 130 rsr = readb(port->membase + UART01x_RSR) | UART_DUMMY_RSR_RX;
131 if (unlikely(rsr & UART01x_RSR_ANY)) { 131 if (unlikely(rsr & UART01x_RSR_ANY)) {
132 writel(0, port->membase + UART01x_ECR);
133
132 if (rsr & UART01x_RSR_BE) { 134 if (rsr & UART01x_RSR_BE) {
133 rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE); 135 rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE);
134 port->icount.brk++; 136 port->icount.brk++;
diff --git a/drivers/serial/dz.c b/drivers/serial/dz.c
index 53662b33b841..af1544f3356f 100644
--- a/drivers/serial/dz.c
+++ b/drivers/serial/dz.c
@@ -1,11 +1,13 @@
1/* 1/*
2 * dz.c: Serial port driver for DECStations equiped 2 * dz.c: Serial port driver for DECstations equipped
3 * with the DZ chipset. 3 * with the DZ chipset.
4 * 4 *
5 * Copyright (C) 1998 Olivier A. D. Lebaillif 5 * Copyright (C) 1998 Olivier A. D. Lebaillif
6 * 6 *
7 * Email: olivier.lebaillif@ifrsys.com 7 * Email: olivier.lebaillif@ifrsys.com
8 * 8 *
9 * Copyright (C) 2004, 2006 Maciej W. Rozycki
10 *
9 * [31-AUG-98] triemer 11 * [31-AUG-98] triemer
10 * Changed IRQ to use Harald's dec internals interrupts.h 12 * Changed IRQ to use Harald's dec internals interrupts.h
11 * removed base_addr code - moving address assignment to setup.c 13 * removed base_addr code - moving address assignment to setup.c
@@ -26,10 +28,16 @@
26 28
27#undef DEBUG_DZ 29#undef DEBUG_DZ
28 30
31#if defined(CONFIG_SERIAL_DZ_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
32#define SUPPORT_SYSRQ
33#endif
34
35#include <linux/delay.h>
29#include <linux/module.h> 36#include <linux/module.h>
30#include <linux/interrupt.h> 37#include <linux/interrupt.h>
31#include <linux/init.h> 38#include <linux/init.h>
32#include <linux/console.h> 39#include <linux/console.h>
40#include <linux/sysrq.h>
33#include <linux/tty.h> 41#include <linux/tty.h>
34#include <linux/tty_flip.h> 42#include <linux/tty_flip.h>
35#include <linux/serial_core.h> 43#include <linux/serial_core.h>
@@ -45,14 +53,10 @@
45#include <asm/system.h> 53#include <asm/system.h>
46#include <asm/uaccess.h> 54#include <asm/uaccess.h>
47 55
48#define CONSOLE_LINE (3) /* for definition of struct console */
49
50#include "dz.h" 56#include "dz.h"
51 57
52#define DZ_INTR_DEBUG 1
53
54static char *dz_name = "DECstation DZ serial driver version "; 58static char *dz_name = "DECstation DZ serial driver version ";
55static char *dz_version = "1.02"; 59static char *dz_version = "1.03";
56 60
57struct dz_port { 61struct dz_port {
58 struct uart_port port; 62 struct uart_port port;
@@ -61,22 +65,6 @@ struct dz_port {
61 65
62static struct dz_port dz_ports[DZ_NB_PORT]; 66static struct dz_port dz_ports[DZ_NB_PORT];
63 67
64#ifdef DEBUG_DZ
65/*
66 * debugging code to send out chars via prom
67 */
68static void debug_console(const char *s, int count)
69{
70 unsigned i;
71
72 for (i = 0; i < count; i++) {
73 if (*s == 10)
74 prom_printf("%c", 13);
75 prom_printf("%c", *s++);
76 }
77}
78#endif
79
80/* 68/*
81 * ------------------------------------------------------------ 69 * ------------------------------------------------------------
82 * dz_in () and dz_out () 70 * dz_in () and dz_out ()
@@ -90,6 +78,7 @@ static inline unsigned short dz_in(struct dz_port *dport, unsigned offset)
90{ 78{
91 volatile unsigned short *addr = 79 volatile unsigned short *addr =
92 (volatile unsigned short *) (dport->port.membase + offset); 80 (volatile unsigned short *) (dport->port.membase + offset);
81
93 return *addr; 82 return *addr;
94} 83}
95 84
@@ -98,6 +87,7 @@ static inline void dz_out(struct dz_port *dport, unsigned offset,
98{ 87{
99 volatile unsigned short *addr = 88 volatile unsigned short *addr =
100 (volatile unsigned short *) (dport->port.membase + offset); 89 (volatile unsigned short *) (dport->port.membase + offset);
90
101 *addr = value; 91 *addr = value;
102} 92}
103 93
@@ -144,7 +134,7 @@ static void dz_stop_rx(struct uart_port *uport)
144 134
145 spin_lock_irqsave(&dport->port.lock, flags); 135 spin_lock_irqsave(&dport->port.lock, flags);
146 dport->cflag &= ~DZ_CREAD; 136 dport->cflag &= ~DZ_CREAD;
147 dz_out(dport, DZ_LPR, dport->cflag); 137 dz_out(dport, DZ_LPR, dport->cflag | dport->port.line);
148 spin_unlock_irqrestore(&dport->port.lock, flags); 138 spin_unlock_irqrestore(&dport->port.lock, flags);
149} 139}
150 140
@@ -155,14 +145,14 @@ static void dz_enable_ms(struct uart_port *port)
155 145
156/* 146/*
157 * ------------------------------------------------------------ 147 * ------------------------------------------------------------
158 * Here starts the interrupt handling routines. All of the
159 * following subroutines are declared as inline and are folded
160 * into dz_interrupt. They were separated out for readability's
161 * sake.
162 * 148 *
163 * Note: rs_interrupt() is a "fast" interrupt, which means that it 149 * Here start the interrupt handling routines. All of the following
150 * subroutines are declared as inline and are folded into
151 * dz_interrupt. They were separated out for readability's sake.
152 *
153 * Note: dz_interrupt() is a "fast" interrupt, which means that it
164 * runs with interrupts turned off. People who may want to modify 154 * runs with interrupts turned off. People who may want to modify
165 * rs_interrupt() should try to keep the interrupt handler as fast as 155 * dz_interrupt() should try to keep the interrupt handler as fast as
166 * possible. After you are done making modifications, it is not a bad 156 * possible. After you are done making modifications, it is not a bad
167 * idea to do: 157 * idea to do:
168 * 158 *
@@ -180,92 +170,74 @@ static void dz_enable_ms(struct uart_port *port)
180 * This routine deals with inputs from any lines. 170 * This routine deals with inputs from any lines.
181 * ------------------------------------------------------------ 171 * ------------------------------------------------------------
182 */ 172 */
183static inline void dz_receive_chars(struct dz_port *dport) 173static inline void dz_receive_chars(struct dz_port *dport_in,
174 struct pt_regs *regs)
184{ 175{
176 struct dz_port *dport;
185 struct tty_struct *tty = NULL; 177 struct tty_struct *tty = NULL;
186 struct uart_icount *icount; 178 struct uart_icount *icount;
187 int ignore = 0; 179 int lines_rx[DZ_NB_PORT] = { [0 ... DZ_NB_PORT - 1] = 0 };
188 unsigned short status, tmp; 180 unsigned short status;
189 unsigned char ch, flag; 181 unsigned char ch, flag;
182 int i;
190 183
191 /* this code is going to be a problem... 184 while ((status = dz_in(dport_in, DZ_RBUF)) & DZ_DVAL) {
192 the call to tty_flip_buffer is going to need 185 dport = &dz_ports[LINE(status)];
193 to be rethought... 186 tty = dport->port.info->tty; /* point to the proper dev */
194 */
195 do {
196 status = dz_in(dport, DZ_RBUF);
197
198 /* punt so we don't get duplicate characters */
199 if (!(status & DZ_DVAL))
200 goto ignore_char;
201
202
203 ch = UCHAR(status); /* grab the char */
204 flag = TTY_NORMAL;
205 187
206#if 0 188 ch = UCHAR(status); /* grab the char */
207 if (info->is_console) {
208 if (ch == 0)
209 return; /* it's a break ... */
210 }
211#endif
212 189
213 tty = dport->port.info->tty;/* now tty points to the proper dev */
214 icount = &dport->port.icount; 190 icount = &dport->port.icount;
215
216 if (!tty)
217 break;
218
219 icount->rx++; 191 icount->rx++;
220 192
221 /* keep track of the statistics */ 193 flag = TTY_NORMAL;
222 if (status & (DZ_OERR | DZ_FERR | DZ_PERR)) { 194 if (status & DZ_FERR) { /* frame error */
223 if (status & DZ_PERR) /* parity error */ 195 /*
224 icount->parity++; 196 * There is no separate BREAK status bit, so
225 else if (status & DZ_FERR) /* frame error */ 197 * treat framing errors as BREAKs for Magic SysRq
226 icount->frame++; 198 * and SAK; normally, otherwise.
227 if (status & DZ_OERR) /* overrun error */
228 icount->overrun++;
229
230 /* check to see if we should ignore the character
231 and mask off conditions that should be ignored
232 */ 199 */
233 200 if (uart_handle_break(&dport->port))
234 if (status & dport->port.ignore_status_mask) { 201 continue;
235 if (++ignore > 100) 202 if (dport->port.flags & UPF_SAK)
236 break; 203 flag = TTY_BREAK;
237 goto ignore_char; 204 else
238 }
239 /* mask off the error conditions we want to ignore */
240 tmp = status & dport->port.read_status_mask;
241
242 if (tmp & DZ_PERR) {
243 flag = TTY_PARITY;
244#ifdef DEBUG_DZ
245 debug_console("PERR\n", 5);
246#endif
247 } else if (tmp & DZ_FERR) {
248 flag = TTY_FRAME; 205 flag = TTY_FRAME;
249#ifdef DEBUG_DZ 206 } else if (status & DZ_OERR) /* overrun error */
250 debug_console("FERR\n", 5); 207 flag = TTY_OVERRUN;
251#endif 208 else if (status & DZ_PERR) /* parity error */
252 } 209 flag = TTY_PARITY;
253 if (tmp & DZ_OERR) { 210
254#ifdef DEBUG_DZ 211 /* keep track of the statistics */
255 debug_console("OERR\n", 5); 212 switch (flag) {
256#endif 213 case TTY_FRAME:
257 tty_insert_flip_char(tty, ch, flag); 214 icount->frame++;
258 ch = 0; 215 break;
259 flag = TTY_OVERRUN; 216 case TTY_PARITY:
260 } 217 icount->parity++;
218 break;
219 case TTY_OVERRUN:
220 icount->overrun++;
221 break;
222 case TTY_BREAK:
223 icount->brk++;
224 break;
225 default:
226 break;
261 } 227 }
262 tty_insert_flip_char(tty, ch, flag);
263 ignore_char:
264 ;
265 } while (status & DZ_DVAL);
266 228
267 if (tty) 229 if (uart_handle_sysrq_char(&dport->port, ch, regs))
268 tty_flip_buffer_push(tty); 230 continue;
231
232 if ((status & dport->port.ignore_status_mask) == 0) {
233 uart_insert_char(&dport->port,
234 status, DZ_OERR, ch, flag);
235 lines_rx[LINE(status)] = 1;
236 }
237 }
238 for (i = 0; i < DZ_NB_PORT; i++)
239 if (lines_rx[i])
240 tty_flip_buffer_push(dz_ports[i].port.info->tty);
269} 241}
270 242
271/* 243/*
@@ -275,26 +247,32 @@ static inline void dz_receive_chars(struct dz_port *dport)
275 * This routine deals with outputs to any lines. 247 * This routine deals with outputs to any lines.
276 * ------------------------------------------------------------ 248 * ------------------------------------------------------------
277 */ 249 */
278static inline void dz_transmit_chars(struct dz_port *dport) 250static inline void dz_transmit_chars(struct dz_port *dport_in)
279{ 251{
280 struct circ_buf *xmit = &dport->port.info->xmit; 252 struct dz_port *dport;
253 struct circ_buf *xmit;
254 unsigned short status;
281 unsigned char tmp; 255 unsigned char tmp;
282 256
283 if (dport->port.x_char) { /* XON/XOFF chars */ 257 status = dz_in(dport_in, DZ_CSR);
258 dport = &dz_ports[LINE(status)];
259 xmit = &dport->port.info->xmit;
260
261 if (dport->port.x_char) { /* XON/XOFF chars */
284 dz_out(dport, DZ_TDR, dport->port.x_char); 262 dz_out(dport, DZ_TDR, dport->port.x_char);
285 dport->port.icount.tx++; 263 dport->port.icount.tx++;
286 dport->port.x_char = 0; 264 dport->port.x_char = 0;
287 return; 265 return;
288 } 266 }
289 /* if nothing to do or stopped or hardware stopped */ 267 /* If nothing to do or stopped or hardware stopped. */
290 if (uart_circ_empty(xmit) || uart_tx_stopped(&dport->port)) { 268 if (uart_circ_empty(xmit) || uart_tx_stopped(&dport->port)) {
291 dz_stop_tx(&dport->port); 269 dz_stop_tx(&dport->port);
292 return; 270 return;
293 } 271 }
294 272
295 /* 273 /*
296 * if something to do ... (rember the dz has no output fifo so we go 274 * If something to do... (remember the dz has no output fifo,
297 * one char at a time :-< 275 * so we go one char at a time) :-<
298 */ 276 */
299 tmp = xmit->buf[xmit->tail]; 277 tmp = xmit->buf[xmit->tail];
300 xmit->tail = (xmit->tail + 1) & (DZ_XMIT_SIZE - 1); 278 xmit->tail = (xmit->tail + 1) & (DZ_XMIT_SIZE - 1);
@@ -304,23 +282,29 @@ static inline void dz_transmit_chars(struct dz_port *dport)
304 if (uart_circ_chars_pending(xmit) < DZ_WAKEUP_CHARS) 282 if (uart_circ_chars_pending(xmit) < DZ_WAKEUP_CHARS)
305 uart_write_wakeup(&dport->port); 283 uart_write_wakeup(&dport->port);
306 284
307 /* Are we done */ 285 /* Are we are done. */
308 if (uart_circ_empty(xmit)) 286 if (uart_circ_empty(xmit))
309 dz_stop_tx(&dport->port); 287 dz_stop_tx(&dport->port);
310} 288}
311 289
312/* 290/*
313 * ------------------------------------------------------------ 291 * ------------------------------------------------------------
314 * check_modem_status () 292 * check_modem_status()
315 * 293 *
316 * Only valid for the MODEM line duh ! 294 * DS 3100 & 5100: Only valid for the MODEM line, duh!
295 * DS 5000/200: Valid for the MODEM and PRINTER line.
317 * ------------------------------------------------------------ 296 * ------------------------------------------------------------
318 */ 297 */
319static inline void check_modem_status(struct dz_port *dport) 298static inline void check_modem_status(struct dz_port *dport)
320{ 299{
300 /*
301 * FIXME:
302 * 1. No status change interrupt; use a timer.
303 * 2. Handle the 3100/5000 as appropriate. --macro
304 */
321 unsigned short status; 305 unsigned short status;
322 306
323 /* if not ne modem line just return */ 307 /* If not the modem line just return. */
324 if (dport->port.line != DZ_MODEM) 308 if (dport->port.line != DZ_MODEM)
325 return; 309 return;
326 310
@@ -341,21 +325,18 @@ static inline void check_modem_status(struct dz_port *dport)
341 */ 325 */
342static irqreturn_t dz_interrupt(int irq, void *dev) 326static irqreturn_t dz_interrupt(int irq, void *dev)
343{ 327{
344 struct dz_port *dport; 328 struct dz_port *dport = (struct dz_port *)dev;
345 unsigned short status; 329 unsigned short status;
346 330
347 /* get the reason why we just got an irq */ 331 /* get the reason why we just got an irq */
348 status = dz_in((struct dz_port *)dev, DZ_CSR); 332 status = dz_in(dport, DZ_CSR);
349 dport = &dz_ports[LINE(status)];
350 333
351 if (status & DZ_RDONE) 334 if ((status & (DZ_RDONE | DZ_RIE)) == (DZ_RDONE | DZ_RIE))
352 dz_receive_chars(dport); 335 dz_receive_chars(dport, regs);
353 336
354 if (status & DZ_TRDY) 337 if ((status & (DZ_TRDY | DZ_TIE)) == (DZ_TRDY | DZ_TIE))
355 dz_transmit_chars(dport); 338 dz_transmit_chars(dport);
356 339
357 /* FIXME: what about check modem status??? --rmk */
358
359 return IRQ_HANDLED; 340 return IRQ_HANDLED;
360} 341}
361 342
@@ -367,13 +348,13 @@ static irqreturn_t dz_interrupt(int irq, void *dev)
367 348
368static unsigned int dz_get_mctrl(struct uart_port *uport) 349static unsigned int dz_get_mctrl(struct uart_port *uport)
369{ 350{
351 /*
352 * FIXME: Handle the 3100/5000 as appropriate. --macro
353 */
370 struct dz_port *dport = (struct dz_port *)uport; 354 struct dz_port *dport = (struct dz_port *)uport;
371 unsigned int mctrl = TIOCM_CAR | TIOCM_DSR | TIOCM_CTS; 355 unsigned int mctrl = TIOCM_CAR | TIOCM_DSR | TIOCM_CTS;
372 356
373 if (dport->port.line == DZ_MODEM) { 357 if (dport->port.line == DZ_MODEM) {
374 /*
375 * CHECKME: This is a guess from the other code... --rmk
376 */
377 if (dz_in(dport, DZ_MSR) & DZ_MODEM_DSR) 358 if (dz_in(dport, DZ_MSR) & DZ_MODEM_DSR)
378 mctrl &= ~TIOCM_DSR; 359 mctrl &= ~TIOCM_DSR;
379 } 360 }
@@ -383,6 +364,9 @@ static unsigned int dz_get_mctrl(struct uart_port *uport)
383 364
384static void dz_set_mctrl(struct uart_port *uport, unsigned int mctrl) 365static void dz_set_mctrl(struct uart_port *uport, unsigned int mctrl)
385{ 366{
367 /*
368 * FIXME: Handle the 3100/5000 as appropriate. --macro
369 */
386 struct dz_port *dport = (struct dz_port *)uport; 370 struct dz_port *dport = (struct dz_port *)uport;
387 unsigned short tmp; 371 unsigned short tmp;
388 372
@@ -409,13 +393,6 @@ static int dz_startup(struct uart_port *uport)
409 unsigned long flags; 393 unsigned long flags;
410 unsigned short tmp; 394 unsigned short tmp;
411 395
412 /* The dz lines for the mouse/keyboard must be
413 * opened using their respective drivers.
414 */
415 if ((dport->port.line == DZ_KEYBOARD) ||
416 (dport->port.line == DZ_MOUSE))
417 return -ENODEV;
418
419 spin_lock_irqsave(&dport->port.lock, flags); 396 spin_lock_irqsave(&dport->port.lock, flags);
420 397
421 /* enable the interrupt and the scanning */ 398 /* enable the interrupt and the scanning */
@@ -442,7 +419,8 @@ static void dz_shutdown(struct uart_port *uport)
442} 419}
443 420
444/* 421/*
445 * get_lsr_info - get line status register info 422 * -------------------------------------------------------------------
423 * dz_tx_empty() -- get the transmitter empty status
446 * 424 *
447 * Purpose: Let user call ioctl() to get info when the UART physically 425 * Purpose: Let user call ioctl() to get info when the UART physically
448 * is emptied. On bus types like RS485, the transmitter must 426 * is emptied. On bus types like RS485, the transmitter must
@@ -450,21 +428,28 @@ static void dz_shutdown(struct uart_port *uport)
450 * the transmit shift register is empty, not be done when the 428 * the transmit shift register is empty, not be done when the
451 * transmit holding register is empty. This functionality 429 * transmit holding register is empty. This functionality
452 * allows an RS485 driver to be written in user space. 430 * allows an RS485 driver to be written in user space.
431 * -------------------------------------------------------------------
453 */ 432 */
454static unsigned int dz_tx_empty(struct uart_port *uport) 433static unsigned int dz_tx_empty(struct uart_port *uport)
455{ 434{
456 struct dz_port *dport = (struct dz_port *)uport; 435 struct dz_port *dport = (struct dz_port *)uport;
457 unsigned short status = dz_in(dport, DZ_LPR); 436 unsigned short tmp, mask = 1 << dport->port.line;
458 437
459 /* FIXME: this appears to be obviously broken --rmk. */ 438 tmp = dz_in(dport, DZ_TCR);
460 return status ? TIOCSER_TEMT : 0; 439 tmp &= mask;
440
441 return tmp ? 0 : TIOCSER_TEMT;
461} 442}
462 443
463static void dz_break_ctl(struct uart_port *uport, int break_state) 444static void dz_break_ctl(struct uart_port *uport, int break_state)
464{ 445{
446 /*
447 * FIXME: Can't access BREAK bits in TDR easily;
448 * reuse the code for polled TX. --macro
449 */
465 struct dz_port *dport = (struct dz_port *)uport; 450 struct dz_port *dport = (struct dz_port *)uport;
466 unsigned long flags; 451 unsigned long flags;
467 unsigned short tmp, mask = 1 << uport->line; 452 unsigned short tmp, mask = 1 << dport->port.line;
468 453
469 spin_lock_irqsave(&uport->lock, flags); 454 spin_lock_irqsave(&uport->lock, flags);
470 tmp = dz_in(dport, DZ_TCR); 455 tmp = dz_in(dport, DZ_TCR);
@@ -561,7 +546,7 @@ static void dz_set_termios(struct uart_port *uport, struct termios *termios,
561 546
562 spin_lock_irqsave(&dport->port.lock, flags); 547 spin_lock_irqsave(&dport->port.lock, flags);
563 548
564 dz_out(dport, DZ_LPR, cflag); 549 dz_out(dport, DZ_LPR, cflag | dport->port.line);
565 dport->cflag = cflag; 550 dport->cflag = cflag;
566 551
567 /* setup accept flag */ 552 /* setup accept flag */
@@ -650,7 +635,7 @@ static void __init dz_init_ports(void)
650 for (i = 0, dport = dz_ports; i < DZ_NB_PORT; i++, dport++) { 635 for (i = 0, dport = dz_ports; i < DZ_NB_PORT; i++, dport++) {
651 spin_lock_init(&dport->port.lock); 636 spin_lock_init(&dport->port.lock);
652 dport->port.membase = (char *) base; 637 dport->port.membase = (char *) base;
653 dport->port.iotype = UPIO_PORT; 638 dport->port.iotype = UPIO_MEM;
654 dport->port.irq = dec_interrupt[DEC_IRQ_DZ11]; 639 dport->port.irq = dec_interrupt[DEC_IRQ_DZ11];
655 dport->port.line = i; 640 dport->port.line = i;
656 dport->port.fifosize = 1; 641 dport->port.fifosize = 1;
@@ -662,10 +647,7 @@ static void __init dz_init_ports(void)
662static void dz_reset(struct dz_port *dport) 647static void dz_reset(struct dz_port *dport)
663{ 648{
664 dz_out(dport, DZ_CSR, DZ_CLR); 649 dz_out(dport, DZ_CSR, DZ_CLR);
665
666 while (dz_in(dport, DZ_CSR) & DZ_CLR); 650 while (dz_in(dport, DZ_CSR) & DZ_CLR);
667 /* FIXME: cpu_relax? */
668
669 iob(); 651 iob();
670 652
671 /* enable scanning */ 653 /* enable scanning */
@@ -673,26 +655,55 @@ static void dz_reset(struct dz_port *dport)
673} 655}
674 656
675#ifdef CONFIG_SERIAL_DZ_CONSOLE 657#ifdef CONFIG_SERIAL_DZ_CONSOLE
658/*
659 * -------------------------------------------------------------------
660 * dz_console_putchar() -- transmit a character
661 *
662 * Polled transmission. This is tricky. We need to mask transmit
663 * interrupts so that they do not interfere, enable the transmitter
664 * for the line requested and then wait till the transmit scanner
665 * requests data for this line. But it may request data for another
666 * line first, in which case we have to disable its transmitter and
667 * repeat waiting till our line pops up. Only then the character may
668 * be transmitted. Finally, the state of the transmitter mask is
669 * restored. Welcome to the world of PDP-11!
670 * -------------------------------------------------------------------
671 */
676static void dz_console_putchar(struct uart_port *uport, int ch) 672static void dz_console_putchar(struct uart_port *uport, int ch)
677{ 673{
678 struct dz_port *dport = (struct dz_port *)uport; 674 struct dz_port *dport = (struct dz_port *)uport;
679 unsigned long flags; 675 unsigned long flags;
680 int loops = 2500; 676 unsigned short csr, tcr, trdy, mask;
681 unsigned short tmp = (unsigned char)ch; 677 int loops = 10000;
682 /* this code sends stuff out to serial device - spinning its
683 wheels and waiting. */
684 678
685 spin_lock_irqsave(&dport->port.lock, flags); 679 spin_lock_irqsave(&dport->port.lock, flags);
680 csr = dz_in(dport, DZ_CSR);
681 dz_out(dport, DZ_CSR, csr & ~DZ_TIE);
682 tcr = dz_in(dport, DZ_TCR);
683 tcr |= 1 << dport->port.line;
684 mask = tcr;
685 dz_out(dport, DZ_TCR, mask);
686 iob();
687 spin_unlock_irqrestore(&dport->port.lock, flags);
686 688
687 /* spin our wheels */ 689 while (loops--) {
688 while (((dz_in(dport, DZ_CSR) & DZ_TRDY) != DZ_TRDY) && loops--) 690 trdy = dz_in(dport, DZ_CSR);
689 /* FIXME: cpu_relax, udelay? --rmk */ 691 if (!(trdy & DZ_TRDY))
690 ; 692 continue;
693 trdy = (trdy & DZ_TLINE) >> 8;
694 if (trdy == dport->port.line)
695 break;
696 mask &= ~(1 << trdy);
697 dz_out(dport, DZ_TCR, mask);
698 iob();
699 udelay(2);
700 }
691 701
692 /* Actually transmit the character. */ 702 if (loops) /* Cannot send otherwise. */
693 dz_out(dport, DZ_TDR, tmp); 703 dz_out(dport, DZ_TDR, ch);
694 704
695 spin_unlock_irqrestore(&dport->port.lock, flags); 705 dz_out(dport, DZ_TCR, tcr);
706 dz_out(dport, DZ_CSR, csr);
696} 707}
697 708
698/* 709/*
@@ -703,11 +714,11 @@ static void dz_console_putchar(struct uart_port *uport, int ch)
703 * The console must be locked when we get here. 714 * The console must be locked when we get here.
704 * ------------------------------------------------------------------- 715 * -------------------------------------------------------------------
705 */ 716 */
706static void dz_console_print(struct console *cons, 717static void dz_console_print(struct console *co,
707 const char *str, 718 const char *str,
708 unsigned int count) 719 unsigned int count)
709{ 720{
710 struct dz_port *dport = &dz_ports[CONSOLE_LINE]; 721 struct dz_port *dport = &dz_ports[co->index];
711#ifdef DEBUG_DZ 722#ifdef DEBUG_DZ
712 prom_printf((char *) str); 723 prom_printf((char *) str);
713#endif 724#endif
@@ -716,49 +727,43 @@ static void dz_console_print(struct console *cons,
716 727
717static int __init dz_console_setup(struct console *co, char *options) 728static int __init dz_console_setup(struct console *co, char *options)
718{ 729{
719 struct dz_port *dport = &dz_ports[CONSOLE_LINE]; 730 struct dz_port *dport = &dz_ports[co->index];
720 int baud = 9600; 731 int baud = 9600;
721 int bits = 8; 732 int bits = 8;
722 int parity = 'n'; 733 int parity = 'n';
723 int flow = 'n'; 734 int flow = 'n';
724 int ret;
725 unsigned short mask, tmp;
726 735
727 if (options) 736 if (options)
728 uart_parse_options(options, &baud, &parity, &bits, &flow); 737 uart_parse_options(options, &baud, &parity, &bits, &flow);
729 738
730 dz_reset(dport); 739 dz_reset(dport);
731 740
732 ret = uart_set_options(&dport->port, co, baud, parity, bits, flow); 741 return uart_set_options(&dport->port, co, baud, parity, bits, flow);
733 if (ret == 0) {
734 mask = 1 << dport->port.line;
735 tmp = dz_in(dport, DZ_TCR); /* read the TX flag */
736 if (!(tmp & mask)) {
737 tmp |= mask; /* set the TX flag */
738 dz_out(dport, DZ_TCR, tmp);
739 }
740 }
741
742 return ret;
743} 742}
744 743
745static struct console dz_sercons = 744static struct uart_driver dz_reg;
746{ 745static struct console dz_sercons = {
747 .name = "ttyS", 746 .name = "ttyS",
748 .write = dz_console_print, 747 .write = dz_console_print,
749 .device = uart_console_device, 748 .device = uart_console_device,
750 .setup = dz_console_setup, 749 .setup = dz_console_setup,
751 .flags = CON_CONSDEV | CON_PRINTBUFFER, 750 .flags = CON_PRINTBUFFER,
752 .index = CONSOLE_LINE, 751 .index = -1,
752 .data = &dz_reg,
753}; 753};
754 754
755void __init dz_serial_console_init(void) 755static int __init dz_serial_console_init(void)
756{ 756{
757 dz_init_ports(); 757 if (!IOASIC) {
758 758 dz_init_ports();
759 register_console(&dz_sercons); 759 register_console(&dz_sercons);
760 return 0;
761 } else
762 return -ENXIO;
760} 763}
761 764
765console_initcall(dz_serial_console_init);
766
762#define SERIAL_DZ_CONSOLE &dz_sercons 767#define SERIAL_DZ_CONSOLE &dz_sercons
763#else 768#else
764#define SERIAL_DZ_CONSOLE NULL 769#define SERIAL_DZ_CONSOLE NULL
@@ -767,35 +772,29 @@ void __init dz_serial_console_init(void)
767static struct uart_driver dz_reg = { 772static struct uart_driver dz_reg = {
768 .owner = THIS_MODULE, 773 .owner = THIS_MODULE,
769 .driver_name = "serial", 774 .driver_name = "serial",
770 .dev_name = "ttyS%d", 775 .dev_name = "ttyS",
771 .major = TTY_MAJOR, 776 .major = TTY_MAJOR,
772 .minor = 64, 777 .minor = 64,
773 .nr = DZ_NB_PORT, 778 .nr = DZ_NB_PORT,
774 .cons = SERIAL_DZ_CONSOLE, 779 .cons = SERIAL_DZ_CONSOLE,
775}; 780};
776 781
777int __init dz_init(void) 782static int __init dz_init(void)
778{ 783{
779 unsigned long flags;
780 int ret, i; 784 int ret, i;
781 785
786 if (IOASIC)
787 return -ENXIO;
788
782 printk("%s%s\n", dz_name, dz_version); 789 printk("%s%s\n", dz_name, dz_version);
783 790
784 dz_init_ports(); 791 dz_init_ports();
785 792
786 save_flags(flags);
787 cli();
788
789#ifndef CONFIG_SERIAL_DZ_CONSOLE 793#ifndef CONFIG_SERIAL_DZ_CONSOLE
790 /* reset the chip */ 794 /* reset the chip */
791 dz_reset(&dz_ports[0]); 795 dz_reset(&dz_ports[0]);
792#endif 796#endif
793 797
794 /* order matters here... the trick is that flags
795 is updated... in request_irq - to immediatedly obliterate
796 it is unwise. */
797 restore_flags(flags);
798
799 if (request_irq(dz_ports[0].port.irq, dz_interrupt, 798 if (request_irq(dz_ports[0].port.irq, dz_interrupt,
800 IRQF_DISABLED, "DZ", &dz_ports[0])) 799 IRQF_DISABLED, "DZ", &dz_ports[0]))
801 panic("Unable to register DZ interrupt"); 800 panic("Unable to register DZ interrupt");
@@ -810,5 +809,7 @@ int __init dz_init(void)
810 return ret; 809 return ret;
811} 810}
812 811
812module_init(dz_init);
813
813MODULE_DESCRIPTION("DECstation DZ serial driver"); 814MODULE_DESCRIPTION("DECstation DZ serial driver");
814MODULE_LICENSE("GPL"); 815MODULE_LICENSE("GPL");
diff --git a/drivers/serial/dz.h b/drivers/serial/dz.h
index 86ef417382bb..9674d4e49872 100644
--- a/drivers/serial/dz.h
+++ b/drivers/serial/dz.h
@@ -1,20 +1,22 @@
1/* 1/*
2 * dz.h: Serial port driver for DECStations equiped 2 * dz.h: Serial port driver for DECstations equipped
3 * with the DZ chipset. 3 * with the DZ chipset.
4 * 4 *
5 * Copyright (C) 1998 Olivier A. D. Lebaillif 5 * Copyright (C) 1998 Olivier A. D. Lebaillif
6 * 6 *
7 * Email: olivier.lebaillif@ifrsys.com 7 * Email: olivier.lebaillif@ifrsys.com
8 * 8 *
9 * Copyright (C) 2004, 2006 Maciej W. Rozycki
9 */ 10 */
10#ifndef DZ_SERIAL_H 11#ifndef DZ_SERIAL_H
11#define DZ_SERIAL_H 12#define DZ_SERIAL_H
12 13
13/* 14/*
14 * Definitions for the Control and Status Received. 15 * Definitions for the Control and Status Register.
15 */ 16 */
16#define DZ_TRDY 0x8000 /* Transmitter empty */ 17#define DZ_TRDY 0x8000 /* Transmitter empty */
17#define DZ_TIE 0x4000 /* Transmitter Interrupt Enable */ 18#define DZ_TIE 0x4000 /* Transmitter Interrupt Enbl */
19#define DZ_TLINE 0x0300 /* Transmitter Line Number */
18#define DZ_RDONE 0x0080 /* Receiver data ready */ 20#define DZ_RDONE 0x0080 /* Receiver data ready */
19#define DZ_RIE 0x0040 /* Receive Interrupt Enable */ 21#define DZ_RIE 0x0040 /* Receive Interrupt Enable */
20#define DZ_MSE 0x0020 /* Master Scan Enable */ 22#define DZ_MSE 0x0020 /* Master Scan Enable */
@@ -22,32 +24,44 @@
22#define DZ_MAINT 0x0008 /* Loop Back Mode */ 24#define DZ_MAINT 0x0008 /* Loop Back Mode */
23 25
24/* 26/*
25 * Definitions for the Received buffer. 27 * Definitions for the Receiver Buffer Register.
26 */ 28 */
27#define DZ_RBUF_MASK 0x00FF /* Data Mask in the Receive Buffer */ 29#define DZ_RBUF_MASK 0x00FF /* Data Mask */
28#define DZ_LINE_MASK 0x0300 /* Line Mask in the Receive Buffer */ 30#define DZ_LINE_MASK 0x0300 /* Line Mask */
29#define DZ_DVAL 0x8000 /* Valid Data indicator */ 31#define DZ_DVAL 0x8000 /* Valid Data indicator */
30#define DZ_OERR 0x4000 /* Overrun error indicator */ 32#define DZ_OERR 0x4000 /* Overrun error indicator */
31#define DZ_FERR 0x2000 /* Frame error indicator */ 33#define DZ_FERR 0x2000 /* Frame error indicator */
32#define DZ_PERR 0x1000 /* Parity error indicator */ 34#define DZ_PERR 0x1000 /* Parity error indicator */
33 35
34#define LINE(x) (x & DZ_LINE_MASK) >> 8 /* Get the line number from the input buffer */ 36#define LINE(x) ((x & DZ_LINE_MASK) >> 8) /* Get the line number
35#define UCHAR(x) (unsigned char)(x & DZ_RBUF_MASK) 37 from the input buffer */
38#define UCHAR(x) ((unsigned char)(x & DZ_RBUF_MASK))
36 39
37/* 40/*
38 * Definitions for the Transmit Register. 41 * Definitions for the Transmit Control Register.
39 */ 42 */
40#define DZ_LINE_KEYBOARD 0x0001 43#define DZ_LINE_KEYBOARD 0x0001
41#define DZ_LINE_MOUSE 0x0002 44#define DZ_LINE_MOUSE 0x0002
42#define DZ_LINE_MODEM 0x0004 45#define DZ_LINE_MODEM 0x0004
43#define DZ_LINE_PRINTER 0x0008 46#define DZ_LINE_PRINTER 0x0008
44 47
48#define DZ_MODEM_RTS 0x0800 /* RTS for the modem line (2) */
45#define DZ_MODEM_DTR 0x0400 /* DTR for the modem line (2) */ 49#define DZ_MODEM_DTR 0x0400 /* DTR for the modem line (2) */
50#define DZ_PRINT_RTS 0x0200 /* RTS for the prntr line (3) */
51#define DZ_PRINT_DTR 0x0100 /* DTR for the prntr line (3) */
52#define DZ_LNENB 0x000f /* Transmitter Line Enable */
46 53
47/* 54/*
48 * Definitions for the Modem Status Register. 55 * Definitions for the Modem Status Register.
49 */ 56 */
57#define DZ_MODEM_RI 0x0800 /* RI for the modem line (2) */
58#define DZ_MODEM_CD 0x0400 /* CD for the modem line (2) */
50#define DZ_MODEM_DSR 0x0200 /* DSR for the modem line (2) */ 59#define DZ_MODEM_DSR 0x0200 /* DSR for the modem line (2) */
60#define DZ_MODEM_CTS 0x0100 /* CTS for the modem line (2) */
61#define DZ_PRINT_RI 0x0008 /* RI for the printer line (3) */
62#define DZ_PRINT_CD 0x0004 /* CD for the printer line (3) */
63#define DZ_PRINT_DSR 0x0002 /* DSR for the prntr line (3) */
64#define DZ_PRINT_CTS 0x0001 /* CTS for the prntr line (3) */
51 65
52/* 66/*
53 * Definitions for the Transmit Data Register. 67 * Definitions for the Transmit Data Register.
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c
index aee1b31f1a1c..3db206d29b33 100644
--- a/drivers/serial/mcfserial.c
+++ b/drivers/serial/mcfserial.c
@@ -60,7 +60,8 @@ struct timer_list mcfrs_timer_struct;
60#if defined(CONFIG_HW_FEITH) 60#if defined(CONFIG_HW_FEITH)
61#define CONSOLE_BAUD_RATE 38400 61#define CONSOLE_BAUD_RATE 38400
62#define DEFAULT_CBAUD B38400 62#define DEFAULT_CBAUD B38400
63#elif defined(CONFIG_MOD5272) || defined(CONFIG_M5208EVB) || defined(CONFIG_M5329EVB) 63#elif defined(CONFIG_MOD5272) || defined(CONFIG_M5208EVB) || \
64 defined(CONFIG_M5329EVB) || defined(CONFIG_GILBARCO)
64#define CONSOLE_BAUD_RATE 115200 65#define CONSOLE_BAUD_RATE 115200
65#define DEFAULT_CBAUD B115200 66#define DEFAULT_CBAUD B115200
66#elif defined(CONFIG_ARNEWSH) || defined(CONFIG_FREESCALE) || \ 67#elif defined(CONFIG_ARNEWSH) || defined(CONFIG_FREESCALE) || \
@@ -109,12 +110,30 @@ static struct mcf_serial mcfrs_table[] = {
109 .irq = IRQBASE, 110 .irq = IRQBASE,
110 .flags = ASYNC_BOOT_AUTOCONF, 111 .flags = ASYNC_BOOT_AUTOCONF,
111 }, 112 },
113#ifdef MCFUART_BASE2
112 { /* ttyS1 */ 114 { /* ttyS1 */
113 .magic = 0, 115 .magic = 0,
114 .addr = (volatile unsigned char *) (MCF_MBAR+MCFUART_BASE2), 116 .addr = (volatile unsigned char *) (MCF_MBAR+MCFUART_BASE2),
115 .irq = IRQBASE+1, 117 .irq = IRQBASE+1,
116 .flags = ASYNC_BOOT_AUTOCONF, 118 .flags = ASYNC_BOOT_AUTOCONF,
117 }, 119 },
120#endif
121#ifdef MCFUART_BASE3
122 { /* ttyS2 */
123 .magic = 0,
124 .addr = (volatile unsigned char *) (MCF_MBAR+MCFUART_BASE3),
125 .irq = IRQBASE+2,
126 .flags = ASYNC_BOOT_AUTOCONF,
127 },
128#endif
129#ifdef MCFUART_BASE4
130 { /* ttyS3 */
131 .magic = 0,
132 .addr = (volatile unsigned char *) (MCF_MBAR+MCFUART_BASE4),
133 .irq = IRQBASE+3,
134 .flags = ASYNC_BOOT_AUTOCONF,
135 },
136#endif
118}; 137};
119 138
120 139
@@ -1516,6 +1535,22 @@ static void mcfrs_irqinit(struct mcf_serial *info)
1516 imrp = (volatile unsigned long *) (MCF_MBAR + MCFICM_INTC0 + 1535 imrp = (volatile unsigned long *) (MCF_MBAR + MCFICM_INTC0 +
1517 MCFINTC_IMRL); 1536 MCFINTC_IMRL);
1518 *imrp &= ~((1 << (info->irq - MCFINT_VECBASE)) | 1); 1537 *imrp &= ~((1 << (info->irq - MCFINT_VECBASE)) | 1);
1538#if defined(CONFIG_M527x)
1539 {
1540 /*
1541 * External Pin Mask Setting & Enable External Pin for Interface
1542 * mrcbis@aliceposta.it
1543 */
1544 unsigned short *serpin_enable_mask;
1545 serpin_enable_mask = (MCF_IPSBAR + MCF_GPIO_PAR_UART);
1546 if (info->line == 0)
1547 *serpin_enable_mask |= UART0_ENABLE_MASK;
1548 else if (info->line == 1)
1549 *serpin_enable_mask |= UART1_ENABLE_MASK;
1550 else if (info->line == 2)
1551 *serpin_enable_mask |= UART2_ENABLE_MASK;
1552 }
1553#endif
1519#elif defined(CONFIG_M520x) 1554#elif defined(CONFIG_M520x)
1520 volatile unsigned char *icrp, *uartp; 1555 volatile unsigned char *icrp, *uartp;
1521 volatile unsigned long *imrp; 1556 volatile unsigned long *imrp;
@@ -1713,7 +1748,7 @@ mcfrs_init(void)
1713 /* Initialize the tty_driver structure */ 1748 /* Initialize the tty_driver structure */
1714 mcfrs_serial_driver->owner = THIS_MODULE; 1749 mcfrs_serial_driver->owner = THIS_MODULE;
1715 mcfrs_serial_driver->name = "ttyS"; 1750 mcfrs_serial_driver->name = "ttyS";
1716 mcfrs_serial_driver->driver_name = "serial"; 1751 mcfrs_serial_driver->driver_name = "mcfserial";
1717 mcfrs_serial_driver->major = TTY_MAJOR; 1752 mcfrs_serial_driver->major = TTY_MAJOR;
1718 mcfrs_serial_driver->minor_start = 64; 1753 mcfrs_serial_driver->minor_start = 64;
1719 mcfrs_serial_driver->type = TTY_DRIVER_TYPE_SERIAL; 1754 mcfrs_serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
@@ -1797,10 +1832,23 @@ void mcfrs_init_console(void)
1797 uartp[MCFUART_UMR] = MCFUART_MR1_PARITYNONE | MCFUART_MR1_CS8; 1832 uartp[MCFUART_UMR] = MCFUART_MR1_PARITYNONE | MCFUART_MR1_CS8;
1798 uartp[MCFUART_UMR] = MCFUART_MR2_STOP1; 1833 uartp[MCFUART_UMR] = MCFUART_MR2_STOP1;
1799 1834
1835#ifdef CONFIG_M5272
1836{
1837 /*
1838 * For the MCF5272, also compute the baudrate fraction.
1839 */
1840 int fraction = MCF_BUSCLK - (clk * 32 * mcfrs_console_baud);
1841 fraction *= 16;
1842 fraction /= (32 * mcfrs_console_baud);
1843 uartp[MCFUART_UFPD] = (fraction & 0xf); /* set fraction */
1844 clk = (MCF_BUSCLK / mcfrs_console_baud) / 32;
1845}
1846#else
1800 clk = ((MCF_BUSCLK / mcfrs_console_baud) + 16) / 32; /* set baud */ 1847 clk = ((MCF_BUSCLK / mcfrs_console_baud) + 16) / 32; /* set baud */
1848#endif
1849
1801 uartp[MCFUART_UBG1] = (clk & 0xff00) >> 8; /* set msb baud */ 1850 uartp[MCFUART_UBG1] = (clk & 0xff00) >> 8; /* set msb baud */
1802 uartp[MCFUART_UBG2] = (clk & 0xff); /* set lsb baud */ 1851 uartp[MCFUART_UBG2] = (clk & 0xff); /* set lsb baud */
1803
1804 uartp[MCFUART_UCSR] = MCFUART_UCSR_RXCLKTIMER | MCFUART_UCSR_TXCLKTIMER; 1852 uartp[MCFUART_UCSR] = MCFUART_UCSR_RXCLKTIMER | MCFUART_UCSR_TXCLKTIMER;
1805 uartp[MCFUART_UCR] = MCFUART_UCR_RXENABLE | MCFUART_UCR_TXENABLE; 1853 uartp[MCFUART_UCR] = MCFUART_UCR_RXENABLE | MCFUART_UCR_TXENABLE;
1806 1854
diff --git a/drivers/serial/mpsc.c b/drivers/serial/mpsc.c
index 8eea69f29989..29823bd60fb0 100644
--- a/drivers/serial/mpsc.c
+++ b/drivers/serial/mpsc.c
@@ -555,7 +555,7 @@ mpsc_sdma_start_tx(struct mpsc_port_info *pi)
555 if (!mpsc_sdma_tx_active(pi)) { 555 if (!mpsc_sdma_tx_active(pi)) {
556 txre = (struct mpsc_tx_desc *)(pi->txr + 556 txre = (struct mpsc_tx_desc *)(pi->txr +
557 (pi->txr_tail * MPSC_TXRE_SIZE)); 557 (pi->txr_tail * MPSC_TXRE_SIZE));
558 dma_cache_sync((void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE); 558 dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE);
559#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 559#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
560 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 560 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
561 invalidate_dcache_range((ulong)txre, 561 invalidate_dcache_range((ulong)txre,
@@ -931,7 +931,7 @@ mpsc_init_rings(struct mpsc_port_info *pi)
931 } 931 }
932 txre->link = cpu_to_be32(pi->txr_p); /* Wrap last back to first */ 932 txre->link = cpu_to_be32(pi->txr_p); /* Wrap last back to first */
933 933
934 dma_cache_sync((void *) pi->dma_region, MPSC_DMA_ALLOC_SIZE, 934 dma_cache_sync(pi->port.dev, (void *) pi->dma_region, MPSC_DMA_ALLOC_SIZE,
935 DMA_BIDIRECTIONAL); 935 DMA_BIDIRECTIONAL);
936#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 936#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
937 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 937 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
@@ -1005,7 +1005,7 @@ mpsc_rx_intr(struct mpsc_port_info *pi)
1005 1005
1006 rxre = (struct mpsc_rx_desc *)(pi->rxr + (pi->rxr_posn*MPSC_RXRE_SIZE)); 1006 rxre = (struct mpsc_rx_desc *)(pi->rxr + (pi->rxr_posn*MPSC_RXRE_SIZE));
1007 1007
1008 dma_cache_sync((void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE); 1008 dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE);
1009#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1009#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1010 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1010 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1011 invalidate_dcache_range((ulong)rxre, 1011 invalidate_dcache_range((ulong)rxre,
@@ -1029,7 +1029,7 @@ mpsc_rx_intr(struct mpsc_port_info *pi)
1029 } 1029 }
1030 1030
1031 bp = pi->rxb + (pi->rxr_posn * MPSC_RXBE_SIZE); 1031 bp = pi->rxb + (pi->rxr_posn * MPSC_RXBE_SIZE);
1032 dma_cache_sync((void *) bp, MPSC_RXBE_SIZE, DMA_FROM_DEVICE); 1032 dma_cache_sync(pi->port.dev, (void *) bp, MPSC_RXBE_SIZE, DMA_FROM_DEVICE);
1033#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1033#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1034 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1034 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1035 invalidate_dcache_range((ulong)bp, 1035 invalidate_dcache_range((ulong)bp,
@@ -1098,7 +1098,7 @@ next_frame:
1098 SDMA_DESC_CMDSTAT_F | 1098 SDMA_DESC_CMDSTAT_F |
1099 SDMA_DESC_CMDSTAT_L); 1099 SDMA_DESC_CMDSTAT_L);
1100 wmb(); 1100 wmb();
1101 dma_cache_sync((void *)rxre, MPSC_RXRE_SIZE, DMA_BIDIRECTIONAL); 1101 dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_BIDIRECTIONAL);
1102#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1102#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1103 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1103 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1104 flush_dcache_range((ulong)rxre, 1104 flush_dcache_range((ulong)rxre,
@@ -1109,7 +1109,7 @@ next_frame:
1109 pi->rxr_posn = (pi->rxr_posn + 1) & (MPSC_RXR_ENTRIES - 1); 1109 pi->rxr_posn = (pi->rxr_posn + 1) & (MPSC_RXR_ENTRIES - 1);
1110 rxre = (struct mpsc_rx_desc *)(pi->rxr + 1110 rxre = (struct mpsc_rx_desc *)(pi->rxr +
1111 (pi->rxr_posn * MPSC_RXRE_SIZE)); 1111 (pi->rxr_posn * MPSC_RXRE_SIZE));
1112 dma_cache_sync((void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE); 1112 dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE);
1113#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1113#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1114 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1114 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1115 invalidate_dcache_range((ulong)rxre, 1115 invalidate_dcache_range((ulong)rxre,
@@ -1143,7 +1143,7 @@ mpsc_setup_tx_desc(struct mpsc_port_info *pi, u32 count, u32 intr)
1143 SDMA_DESC_CMDSTAT_EI 1143 SDMA_DESC_CMDSTAT_EI
1144 : 0)); 1144 : 0));
1145 wmb(); 1145 wmb();
1146 dma_cache_sync((void *) txre, MPSC_TXRE_SIZE, DMA_BIDIRECTIONAL); 1146 dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_BIDIRECTIONAL);
1147#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1147#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1148 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1148 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1149 flush_dcache_range((ulong)txre, 1149 flush_dcache_range((ulong)txre,
@@ -1192,7 +1192,7 @@ mpsc_copy_tx_data(struct mpsc_port_info *pi)
1192 else /* All tx data copied into ring bufs */ 1192 else /* All tx data copied into ring bufs */
1193 return; 1193 return;
1194 1194
1195 dma_cache_sync((void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL); 1195 dma_cache_sync(pi->port.dev, (void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL);
1196#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1196#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1197 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1197 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1198 flush_dcache_range((ulong)bp, 1198 flush_dcache_range((ulong)bp,
@@ -1217,7 +1217,7 @@ mpsc_tx_intr(struct mpsc_port_info *pi)
1217 txre = (struct mpsc_tx_desc *)(pi->txr + 1217 txre = (struct mpsc_tx_desc *)(pi->txr +
1218 (pi->txr_tail * MPSC_TXRE_SIZE)); 1218 (pi->txr_tail * MPSC_TXRE_SIZE));
1219 1219
1220 dma_cache_sync((void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE); 1220 dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE);
1221#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1221#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1222 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1222 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1223 invalidate_dcache_range((ulong)txre, 1223 invalidate_dcache_range((ulong)txre,
@@ -1235,7 +1235,7 @@ mpsc_tx_intr(struct mpsc_port_info *pi)
1235 1235
1236 txre = (struct mpsc_tx_desc *)(pi->txr + 1236 txre = (struct mpsc_tx_desc *)(pi->txr +
1237 (pi->txr_tail * MPSC_TXRE_SIZE)); 1237 (pi->txr_tail * MPSC_TXRE_SIZE));
1238 dma_cache_sync((void *) txre, MPSC_TXRE_SIZE, 1238 dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE,
1239 DMA_FROM_DEVICE); 1239 DMA_FROM_DEVICE);
1240#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1240#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1241 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1241 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
@@ -1652,7 +1652,7 @@ mpsc_console_write(struct console *co, const char *s, uint count)
1652 count--; 1652 count--;
1653 } 1653 }
1654 1654
1655 dma_cache_sync((void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL); 1655 dma_cache_sync(pi->port.dev, (void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL);
1656#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1656#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1657 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1657 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1658 flush_dcache_range((ulong)bp, 1658 flush_dcache_range((ulong)bp,
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index cfcc3caf49d8..3b5f19ec2126 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -775,7 +775,7 @@ static int sci_notifier(struct notifier_block *self,
775 * 775 *
776 * Clean this up later.. 776 * Clean this up later..
777 */ 777 */
778 clk = clk_get("module_clk"); 778 clk = clk_get(NULL, "module_clk");
779 port->uartclk = clk_get_rate(clk) * 16; 779 port->uartclk = clk_get_rate(clk) * 16;
780 clk_put(clk); 780 clk_put(clk);
781 } 781 }
@@ -960,7 +960,7 @@ static void sci_set_termios(struct uart_port *port, struct termios *termios,
960 default: 960 default:
961 { 961 {
962#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) 962#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
963 struct clk *clk = clk_get("module_clk"); 963 struct clk *clk = clk_get(NULL, "module_clk");
964 t = SCBRR_VALUE(baud, clk_get_rate(clk)); 964 t = SCBRR_VALUE(baud, clk_get_rate(clk));
965 clk_put(clk); 965 clk_put(clk);
966#else 966#else
@@ -1128,7 +1128,7 @@ static void __init sci_init_ports(void)
1128 * XXX: We should use a proper SCI/SCIF clock 1128 * XXX: We should use a proper SCI/SCIF clock
1129 */ 1129 */
1130 { 1130 {
1131 struct clk *clk = clk_get("module_clk"); 1131 struct clk *clk = clk_get(NULL, "module_clk");
1132 sci_ports[i].port.uartclk = clk_get_rate(clk) * 16; 1132 sci_ports[i].port.uartclk = clk_get_rate(clk) * 16;
1133 clk_put(clk); 1133 clk_put(clk);
1134 } 1134 }
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index 7ee992146ae9..e4557cc4f74b 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -133,6 +133,20 @@
133# define SCIF_ORER 0x0001 /* Overrun error bit */ 133# define SCIF_ORER 0x0001 /* Overrun error bit */
134# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 134# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
135# define SCIF_ONLY 135# define SCIF_ONLY
136#elif defined(CONFIG_CPU_SUBTYPE_SH7206)
137# define SCSPTR0 0xfffe8020 /* 16 bit SCIF */
138# define SCSPTR1 0xfffe8820 /* 16 bit SCIF */
139# define SCSPTR2 0xfffe9020 /* 16 bit SCIF */
140# define SCSPTR3 0xfffe9820 /* 16 bit SCIF */
141# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
142# define SCIF_ONLY
143#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
144# define SCSPTR0 0xf8400020 /* 16 bit SCIF */
145# define SCSPTR1 0xf8410020 /* 16 bit SCIF */
146# define SCSPTR2 0xf8420020 /* 16 bit SCIF */
147# define SCIF_ORER 0x0001 /* overrun error bit */
148# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
149# define SCIF_ONLY
136#else 150#else
137# error CPU subtype not defined 151# error CPU subtype not defined
138#endif 152#endif
@@ -365,6 +379,7 @@ SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8)
365SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8) 379SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8)
366SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) 380SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16)
367#if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780) 381#if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780)
382SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
368SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) 383SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
369SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) 384SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
370SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) 385SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
@@ -544,6 +559,28 @@ static inline int sci_rxd_in(struct uart_port *port)
544 if (port->mapbase == 0xffe10000) 559 if (port->mapbase == 0xffe10000)
545 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ 560 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
546} 561}
562#elif defined(CONFIG_CPU_SUBTYPE_SH7206)
563static inline int sci_rxd_in(struct uart_port *port)
564{
565 if (port->mapbase == 0xfffe8000)
566 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
567 if (port->mapbase == 0xfffe8800)
568 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
569 if (port->mapbase == 0xfffe9000)
570 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
571 if (port->mapbase == 0xfffe9800)
572 return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
573}
574#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
575static inline int sci_rxd_in(struct uart_port *port)
576{
577 if (port->mapbase == 0xf8400000)
578 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
579 if (port->mapbase == 0xf8410000)
580 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
581 if (port->mapbase == 0xf8420000)
582 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
583}
547#endif 584#endif
548 585
549/* 586/*
diff --git a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c
new file mode 100644
index 000000000000..83690653b78b
--- /dev/null
+++ b/drivers/serial/uartlite.c
@@ -0,0 +1,505 @@
1/*
2 * uartlite.c: Serial driver for Xilinx uartlite serial controller
3 *
4 * Peter Korsgaard <jacmet@sunsite.dk>
5 *
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any
8 * kind, whether express or implied.
9 */
10
11#include <linux/platform_device.h>
12#include <linux/module.h>
13#include <linux/console.h>
14#include <linux/serial.h>
15#include <linux/serial_core.h>
16#include <linux/tty.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
19#include <asm/io.h>
20
21#define ULITE_MAJOR 204
22#define ULITE_MINOR 187
23#define ULITE_NR_UARTS 4
24
25/* For register details see datasheet:
26 http://www.xilinx.com/bvdocs/ipcenter/data_sheet/opb_uartlite.pdf
27*/
28#define ULITE_RX 0x00
29#define ULITE_TX 0x04
30#define ULITE_STATUS 0x08
31#define ULITE_CONTROL 0x0c
32
33#define ULITE_REGION 16
34
35#define ULITE_STATUS_RXVALID 0x01
36#define ULITE_STATUS_RXFULL 0x02
37#define ULITE_STATUS_TXEMPTY 0x04
38#define ULITE_STATUS_TXFULL 0x08
39#define ULITE_STATUS_IE 0x10
40#define ULITE_STATUS_OVERRUN 0x20
41#define ULITE_STATUS_FRAME 0x40
42#define ULITE_STATUS_PARITY 0x80
43
44#define ULITE_CONTROL_RST_TX 0x01
45#define ULITE_CONTROL_RST_RX 0x02
46#define ULITE_CONTROL_IE 0x10
47
48
49static struct uart_port ports[ULITE_NR_UARTS];
50
51static int ulite_receive(struct uart_port *port, int stat)
52{
53 struct tty_struct *tty = port->info->tty;
54 unsigned char ch = 0;
55 char flag = TTY_NORMAL;
56
57 if ((stat & (ULITE_STATUS_RXVALID | ULITE_STATUS_OVERRUN
58 | ULITE_STATUS_FRAME)) == 0)
59 return 0;
60
61 /* stats */
62 if (stat & ULITE_STATUS_RXVALID) {
63 port->icount.rx++;
64 ch = readb(port->membase + ULITE_RX);
65
66 if (stat & ULITE_STATUS_PARITY)
67 port->icount.parity++;
68 }
69
70 if (stat & ULITE_STATUS_OVERRUN)
71 port->icount.overrun++;
72
73 if (stat & ULITE_STATUS_FRAME)
74 port->icount.frame++;
75
76
77 /* drop byte with parity error if IGNPAR specificed */
78 if (stat & port->ignore_status_mask & ULITE_STATUS_PARITY)
79 stat &= ~ULITE_STATUS_RXVALID;
80
81 stat &= port->read_status_mask;
82
83 if (stat & ULITE_STATUS_PARITY)
84 flag = TTY_PARITY;
85
86
87 stat &= ~port->ignore_status_mask;
88
89 if (stat & ULITE_STATUS_RXVALID)
90 tty_insert_flip_char(tty, ch, flag);
91
92 if (stat & ULITE_STATUS_FRAME)
93 tty_insert_flip_char(tty, 0, TTY_FRAME);
94
95 if (stat & ULITE_STATUS_OVERRUN)
96 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
97
98 return 1;
99}
100
101static int ulite_transmit(struct uart_port *port, int stat)
102{
103 struct circ_buf *xmit = &port->info->xmit;
104
105 if (stat & ULITE_STATUS_TXFULL)
106 return 0;
107
108 if (port->x_char) {
109 writeb(port->x_char, port->membase + ULITE_TX);
110 port->x_char = 0;
111 port->icount.tx++;
112 return 1;
113 }
114
115 if (uart_circ_empty(xmit) || uart_tx_stopped(port))
116 return 0;
117
118 writeb(xmit->buf[xmit->tail], port->membase + ULITE_TX);
119 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE-1);
120 port->icount.tx++;
121
122 /* wake up */
123 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
124 uart_write_wakeup(port);
125
126 return 1;
127}
128
129static irqreturn_t ulite_isr(int irq, void *dev_id)
130{
131 struct uart_port *port = (struct uart_port *)dev_id;
132 int busy;
133
134 do {
135 int stat = readb(port->membase + ULITE_STATUS);
136 busy = ulite_receive(port, stat);
137 busy |= ulite_transmit(port, stat);
138 } while (busy);
139
140 tty_flip_buffer_push(port->info->tty);
141
142 return IRQ_HANDLED;
143}
144
145static unsigned int ulite_tx_empty(struct uart_port *port)
146{
147 unsigned long flags;
148 unsigned int ret;
149
150 spin_lock_irqsave(&port->lock, flags);
151 ret = readb(port->membase + ULITE_STATUS);
152 spin_unlock_irqrestore(&port->lock, flags);
153
154 return ret & ULITE_STATUS_TXEMPTY ? TIOCSER_TEMT : 0;
155}
156
157static unsigned int ulite_get_mctrl(struct uart_port *port)
158{
159 return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
160}
161
162static void ulite_set_mctrl(struct uart_port *port, unsigned int mctrl)
163{
164 /* N/A */
165}
166
167static void ulite_stop_tx(struct uart_port *port)
168{
169 /* N/A */
170}
171
172static void ulite_start_tx(struct uart_port *port)
173{
174 ulite_transmit(port, readb(port->membase + ULITE_STATUS));
175}
176
177static void ulite_stop_rx(struct uart_port *port)
178{
179 /* don't forward any more data (like !CREAD) */
180 port->ignore_status_mask = ULITE_STATUS_RXVALID | ULITE_STATUS_PARITY
181 | ULITE_STATUS_FRAME | ULITE_STATUS_OVERRUN;
182}
183
184static void ulite_enable_ms(struct uart_port *port)
185{
186 /* N/A */
187}
188
189static void ulite_break_ctl(struct uart_port *port, int ctl)
190{
191 /* N/A */
192}
193
194static int ulite_startup(struct uart_port *port)
195{
196 int ret;
197
198 ret = request_irq(port->irq, ulite_isr,
199 IRQF_DISABLED | IRQF_SAMPLE_RANDOM, "uartlite", port);
200 if (ret)
201 return ret;
202
203 writeb(ULITE_CONTROL_RST_RX | ULITE_CONTROL_RST_TX,
204 port->membase + ULITE_CONTROL);
205 writeb(ULITE_CONTROL_IE, port->membase + ULITE_CONTROL);
206
207 return 0;
208}
209
210static void ulite_shutdown(struct uart_port *port)
211{
212 writeb(0, port->membase + ULITE_CONTROL);
213 readb(port->membase + ULITE_CONTROL); /* dummy */
214 free_irq(port->irq, port);
215}
216
217static void ulite_set_termios(struct uart_port *port, struct termios *termios,
218 struct termios *old)
219{
220 unsigned long flags;
221 unsigned int baud;
222
223 spin_lock_irqsave(&port->lock, flags);
224
225 port->read_status_mask = ULITE_STATUS_RXVALID | ULITE_STATUS_OVERRUN
226 | ULITE_STATUS_TXFULL;
227
228 if (termios->c_iflag & INPCK)
229 port->read_status_mask |=
230 ULITE_STATUS_PARITY | ULITE_STATUS_FRAME;
231
232 port->ignore_status_mask = 0;
233 if (termios->c_iflag & IGNPAR)
234 port->ignore_status_mask |= ULITE_STATUS_PARITY
235 | ULITE_STATUS_FRAME | ULITE_STATUS_OVERRUN;
236
237 /* ignore all characters if CREAD is not set */
238 if ((termios->c_cflag & CREAD) == 0)
239 port->ignore_status_mask |=
240 ULITE_STATUS_RXVALID | ULITE_STATUS_PARITY
241 | ULITE_STATUS_FRAME | ULITE_STATUS_OVERRUN;
242
243 /* update timeout */
244 baud = uart_get_baud_rate(port, termios, old, 0, 460800);
245 uart_update_timeout(port, termios->c_cflag, baud);
246
247 spin_unlock_irqrestore(&port->lock, flags);
248}
249
250static const char *ulite_type(struct uart_port *port)
251{
252 return port->type == PORT_UARTLITE ? "uartlite" : NULL;
253}
254
255static void ulite_release_port(struct uart_port *port)
256{
257 release_mem_region(port->mapbase, ULITE_REGION);
258 iounmap(port->membase);
259 port->membase = 0;
260}
261
262static int ulite_request_port(struct uart_port *port)
263{
264 if (!request_mem_region(port->mapbase, ULITE_REGION, "uartlite")) {
265 dev_err(port->dev, "Memory region busy\n");
266 return -EBUSY;
267 }
268
269 port->membase = ioremap(port->mapbase, ULITE_REGION);
270 if (!port->membase) {
271 dev_err(port->dev, "Unable to map registers\n");
272 release_mem_region(port->mapbase, ULITE_REGION);
273 return -EBUSY;
274 }
275
276 return 0;
277}
278
279static void ulite_config_port(struct uart_port *port, int flags)
280{
281 ulite_request_port(port);
282 port->type = PORT_UARTLITE;
283}
284
285static int ulite_verify_port(struct uart_port *port, struct serial_struct *ser)
286{
287 /* we don't want the core code to modify any port params */
288 return -EINVAL;
289}
290
291static struct uart_ops ulite_ops = {
292 .tx_empty = ulite_tx_empty,
293 .set_mctrl = ulite_set_mctrl,
294 .get_mctrl = ulite_get_mctrl,
295 .stop_tx = ulite_stop_tx,
296 .start_tx = ulite_start_tx,
297 .stop_rx = ulite_stop_rx,
298 .enable_ms = ulite_enable_ms,
299 .break_ctl = ulite_break_ctl,
300 .startup = ulite_startup,
301 .shutdown = ulite_shutdown,
302 .set_termios = ulite_set_termios,
303 .type = ulite_type,
304 .release_port = ulite_release_port,
305 .request_port = ulite_request_port,
306 .config_port = ulite_config_port,
307 .verify_port = ulite_verify_port
308};
309
310#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
311static void ulite_console_wait_tx(struct uart_port *port)
312{
313 int i;
314
315 /* wait up to 10ms for the character(s) to be sent */
316 for (i = 0; i < 10000; i++) {
317 if (readb(port->membase + ULITE_STATUS) & ULITE_STATUS_TXEMPTY)
318 break;
319 udelay(1);
320 }
321}
322
323static void ulite_console_putchar(struct uart_port *port, int ch)
324{
325 ulite_console_wait_tx(port);
326 writeb(ch, port->membase + ULITE_TX);
327}
328
329static void ulite_console_write(struct console *co, const char *s,
330 unsigned int count)
331{
332 struct uart_port *port = &ports[co->index];
333 unsigned long flags;
334 unsigned int ier;
335 int locked = 1;
336
337 if (oops_in_progress) {
338 locked = spin_trylock_irqsave(&port->lock, flags);
339 } else
340 spin_lock_irqsave(&port->lock, flags);
341
342 /* save and disable interrupt */
343 ier = readb(port->membase + ULITE_STATUS) & ULITE_STATUS_IE;
344 writeb(0, port->membase + ULITE_CONTROL);
345
346 uart_console_write(port, s, count, ulite_console_putchar);
347
348 ulite_console_wait_tx(port);
349
350 /* restore interrupt state */
351 if (ier)
352 writeb(ULITE_CONTROL_IE, port->membase + ULITE_CONTROL);
353
354 if (locked)
355 spin_unlock_irqrestore(&port->lock, flags);
356}
357
358static int __init ulite_console_setup(struct console *co, char *options)
359{
360 struct uart_port *port;
361 int baud = 9600;
362 int bits = 8;
363 int parity = 'n';
364 int flow = 'n';
365
366 if (co->index < 0 || co->index >= ULITE_NR_UARTS)
367 return -EINVAL;
368
369 port = &ports[co->index];
370
371 /* not initialized yet? */
372 if (!port->membase)
373 return -ENODEV;
374
375 if (options)
376 uart_parse_options(options, &baud, &parity, &bits, &flow);
377
378 return uart_set_options(port, co, baud, parity, bits, flow);
379}
380
381static struct uart_driver ulite_uart_driver;
382
383static struct console ulite_console = {
384 .name = "ttyUL",
385 .write = ulite_console_write,
386 .device = uart_console_device,
387 .setup = ulite_console_setup,
388 .flags = CON_PRINTBUFFER,
389 .index = -1, /* Specified on the cmdline (e.g. console=ttyUL0 ) */
390 .data = &ulite_uart_driver,
391};
392
393static int __init ulite_console_init(void)
394{
395 register_console(&ulite_console);
396 return 0;
397}
398
399console_initcall(ulite_console_init);
400
401#endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */
402
403static struct uart_driver ulite_uart_driver = {
404 .owner = THIS_MODULE,
405 .driver_name = "uartlite",
406 .dev_name = "ttyUL",
407 .major = ULITE_MAJOR,
408 .minor = ULITE_MINOR,
409 .nr = ULITE_NR_UARTS,
410#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
411 .cons = &ulite_console,
412#endif
413};
414
415static int __devinit ulite_probe(struct platform_device *pdev)
416{
417 struct resource *res, *res2;
418 struct uart_port *port;
419
420 if (pdev->id < 0 || pdev->id >= ULITE_NR_UARTS)
421 return -EINVAL;
422
423 if (ports[pdev->id].membase)
424 return -EBUSY;
425
426 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
427 if (!res)
428 return -ENODEV;
429
430 res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
431 if (!res2)
432 return -ENODEV;
433
434 port = &ports[pdev->id];
435
436 port->fifosize = 16;
437 port->regshift = 2;
438 port->iotype = UPIO_MEM;
439 port->iobase = 1; /* mark port in use */
440 port->mapbase = res->start;
441 port->membase = 0;
442 port->ops = &ulite_ops;
443 port->irq = res2->start;
444 port->flags = UPF_BOOT_AUTOCONF;
445 port->dev = &pdev->dev;
446 port->type = PORT_UNKNOWN;
447 port->line = pdev->id;
448
449 uart_add_one_port(&ulite_uart_driver, port);
450 platform_set_drvdata(pdev, port);
451
452 return 0;
453}
454
455static int ulite_remove(struct platform_device *pdev)
456{
457 struct uart_port *port = platform_get_drvdata(pdev);
458
459 platform_set_drvdata(pdev, NULL);
460
461 if (port)
462 uart_remove_one_port(&ulite_uart_driver, port);
463
464 /* mark port as free */
465 port->membase = 0;
466
467 return 0;
468}
469
470static struct platform_driver ulite_platform_driver = {
471 .probe = ulite_probe,
472 .remove = ulite_remove,
473 .driver = {
474 .owner = THIS_MODULE,
475 .name = "uartlite",
476 },
477};
478
479int __init ulite_init(void)
480{
481 int ret;
482
483 ret = uart_register_driver(&ulite_uart_driver);
484 if (ret)
485 return ret;
486
487 ret = platform_driver_register(&ulite_platform_driver);
488 if (ret)
489 uart_unregister_driver(&ulite_uart_driver);
490
491 return ret;
492}
493
494void __exit ulite_exit(void)
495{
496 platform_driver_unregister(&ulite_platform_driver);
497 uart_unregister_driver(&ulite_uart_driver);
498}
499
500module_init(ulite_init);
501module_exit(ulite_exit);
502
503MODULE_AUTHOR("Peter Korsgaard <jacmet@sunsite.dk>");
504MODULE_DESCRIPTION("Xilinx uartlite serial driver");
505MODULE_LICENSE("GPL");
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index 72025df5561d..494d9b856488 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -148,7 +148,7 @@ struct chip_data {
148 void (*cs_control)(u32 command); 148 void (*cs_control)(u32 command);
149}; 149};
150 150
151static void pump_messages(void *data); 151static void pump_messages(struct work_struct *work);
152 152
153static int flush(struct driver_data *drv_data) 153static int flush(struct driver_data *drv_data)
154{ 154{
@@ -884,9 +884,10 @@ static void pump_transfers(unsigned long data)
884 } 884 }
885} 885}
886 886
887static void pump_messages(void *data) 887static void pump_messages(struct work_struct *work)
888{ 888{
889 struct driver_data *drv_data = data; 889 struct driver_data *drv_data =
890 container_of(work, struct driver_data, pump_messages);
890 unsigned long flags; 891 unsigned long flags;
891 892
892 /* Lock queue and check for queue work */ 893 /* Lock queue and check for queue work */
@@ -1098,7 +1099,7 @@ static int init_queue(struct driver_data *drv_data)
1098 tasklet_init(&drv_data->pump_transfers, 1099 tasklet_init(&drv_data->pump_transfers,
1099 pump_transfers, (unsigned long)drv_data); 1100 pump_transfers, (unsigned long)drv_data);
1100 1101
1101 INIT_WORK(&drv_data->pump_messages, pump_messages, drv_data); 1102 INIT_WORK(&drv_data->pump_messages, pump_messages);
1102 drv_data->workqueue = create_singlethread_workqueue( 1103 drv_data->workqueue = create_singlethread_workqueue(
1103 drv_data->master->cdev.dev->bus_id); 1104 drv_data->master->cdev.dev->bus_id);
1104 if (drv_data->workqueue == NULL) 1105 if (drv_data->workqueue == NULL)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index c3c0626f550b..270e6211c2e3 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -360,12 +360,13 @@ spi_alloc_master(struct device *dev, unsigned size)
360 if (!dev) 360 if (!dev)
361 return NULL; 361 return NULL;
362 362
363 master = kzalloc(size + sizeof *master, SLAB_KERNEL); 363 master = kzalloc(size + sizeof *master, GFP_KERNEL);
364 if (!master) 364 if (!master)
365 return NULL; 365 return NULL;
366 366
367 class_device_initialize(&master->cdev); 367 class_device_initialize(&master->cdev);
368 master->cdev.class = &spi_master_class; 368 master->cdev.class = &spi_master_class;
369 kobj_set_kset_s(&master->cdev, spi_master_class.subsys);
369 master->cdev.dev = get_device(dev); 370 master->cdev.dev = get_device(dev);
370 spi_master_set_devdata(master, &master[1]); 371 spi_master_set_devdata(master, &master[1]);
371 372
@@ -447,7 +448,9 @@ static int __unregister(struct device *dev, void *unused)
447 */ 448 */
448void spi_unregister_master(struct spi_master *master) 449void spi_unregister_master(struct spi_master *master)
449{ 450{
450 (void) device_for_each_child(master->cdev.dev, NULL, __unregister); 451 int dummy;
452
453 dummy = device_for_each_child(master->cdev.dev, NULL, __unregister);
451 class_device_unregister(&master->cdev); 454 class_device_unregister(&master->cdev);
452} 455}
453EXPORT_SYMBOL_GPL(spi_unregister_master); 456EXPORT_SYMBOL_GPL(spi_unregister_master);
@@ -463,15 +466,13 @@ EXPORT_SYMBOL_GPL(spi_unregister_master);
463 */ 466 */
464struct spi_master *spi_busnum_to_master(u16 bus_num) 467struct spi_master *spi_busnum_to_master(u16 bus_num)
465{ 468{
466 if (bus_num) { 469 char name[9];
467 char name[8]; 470 struct kobject *bus;
468 struct kobject *bus; 471
469 472 snprintf(name, sizeof name, "spi%u", bus_num);
470 snprintf(name, sizeof name, "spi%u", bus_num); 473 bus = kset_find_obj(&spi_master_class.subsys.kset, name);
471 bus = kset_find_obj(&spi_master_class.subsys.kset, name); 474 if (bus)
472 if (bus) 475 return container_of(bus, struct spi_master, cdev.kobj);
473 return container_of(bus, struct spi_master, cdev.kobj);
474 }
475 return NULL; 476 return NULL;
476} 477}
477EXPORT_SYMBOL_GPL(spi_busnum_to_master); 478EXPORT_SYMBOL_GPL(spi_busnum_to_master);
@@ -607,7 +608,7 @@ static int __init spi_init(void)
607{ 608{
608 int status; 609 int status;
609 610
610 buf = kmalloc(SPI_BUFSIZ, SLAB_KERNEL); 611 buf = kmalloc(SPI_BUFSIZ, GFP_KERNEL);
611 if (!buf) { 612 if (!buf) {
612 status = -ENOMEM; 613 status = -ENOMEM;
613 goto err0; 614 goto err0;
diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c
index a23862ef72b2..57289b61d0be 100644
--- a/drivers/spi/spi_bitbang.c
+++ b/drivers/spi/spi_bitbang.c
@@ -196,7 +196,7 @@ int spi_bitbang_setup(struct spi_device *spi)
196 return -EINVAL; 196 return -EINVAL;
197 197
198 if (!cs) { 198 if (!cs) {
199 cs = kzalloc(sizeof *cs, SLAB_KERNEL); 199 cs = kzalloc(sizeof *cs, GFP_KERNEL);
200 if (!cs) 200 if (!cs)
201 return -ENOMEM; 201 return -ENOMEM;
202 spi->controller_state = cs; 202 spi->controller_state = cs;
@@ -265,9 +265,10 @@ static int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t)
265 * Drivers can provide word-at-a-time i/o primitives, or provide 265 * Drivers can provide word-at-a-time i/o primitives, or provide
266 * transfer-at-a-time ones to leverage dma or fifo hardware. 266 * transfer-at-a-time ones to leverage dma or fifo hardware.
267 */ 267 */
268static void bitbang_work(void *_bitbang) 268static void bitbang_work(struct work_struct *work)
269{ 269{
270 struct spi_bitbang *bitbang = _bitbang; 270 struct spi_bitbang *bitbang =
271 container_of(work, struct spi_bitbang, work);
271 unsigned long flags; 272 unsigned long flags;
272 273
273 spin_lock_irqsave(&bitbang->lock, flags); 274 spin_lock_irqsave(&bitbang->lock, flags);
@@ -456,7 +457,7 @@ int spi_bitbang_start(struct spi_bitbang *bitbang)
456 if (!bitbang->master || !bitbang->chipselect) 457 if (!bitbang->master || !bitbang->chipselect)
457 return -EINVAL; 458 return -EINVAL;
458 459
459 INIT_WORK(&bitbang->work, bitbang_work, bitbang); 460 INIT_WORK(&bitbang->work, bitbang_work);
460 spin_lock_init(&bitbang->lock); 461 spin_lock_init(&bitbang->lock);
461 INIT_LIST_HEAD(&bitbang->queue); 462 INIT_LIST_HEAD(&bitbang->queue);
462 463
diff --git a/drivers/spi/spi_butterfly.c b/drivers/spi/spi_butterfly.c
index c2f601f8e4f2..312987a03210 100644
--- a/drivers/spi/spi_butterfly.c
+++ b/drivers/spi/spi_butterfly.c
@@ -251,6 +251,8 @@ static void butterfly_attach(struct parport *p)
251 * setting up a platform device like this is an ugly kluge... 251 * setting up a platform device like this is an ugly kluge...
252 */ 252 */
253 pdev = platform_device_register_simple("butterfly", -1, NULL, 0); 253 pdev = platform_device_register_simple("butterfly", -1, NULL, 0);
254 if (IS_ERR(pdev))
255 return;
254 256
255 master = spi_alloc_master(&pdev->dev, sizeof *pp); 257 master = spi_alloc_master(&pdev->dev, sizeof *pp);
256 if (!master) { 258 if (!master) {
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index e6565633ba0f..3dfa3e40e148 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -158,7 +158,7 @@ struct cxacru_data {
158 const struct cxacru_modem_type *modem_type; 158 const struct cxacru_modem_type *modem_type;
159 159
160 int line_status; 160 int line_status;
161 struct work_struct poll_work; 161 struct delayed_work poll_work;
162 162
163 /* contol handles */ 163 /* contol handles */
164 struct mutex cm_serialize; 164 struct mutex cm_serialize;
@@ -347,7 +347,7 @@ static int cxacru_card_status(struct cxacru_data *instance)
347 return 0; 347 return 0;
348} 348}
349 349
350static void cxacru_poll_status(struct cxacru_data *instance); 350static void cxacru_poll_status(struct work_struct *work);
351 351
352static int cxacru_atm_start(struct usbatm_data *usbatm_instance, 352static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
353 struct atm_dev *atm_dev) 353 struct atm_dev *atm_dev)
@@ -376,12 +376,14 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
376 } 376 }
377 377
378 /* Start status polling */ 378 /* Start status polling */
379 cxacru_poll_status(instance); 379 cxacru_poll_status(&instance->poll_work.work);
380 return 0; 380 return 0;
381} 381}
382 382
383static void cxacru_poll_status(struct cxacru_data *instance) 383static void cxacru_poll_status(struct work_struct *work)
384{ 384{
385 struct cxacru_data *instance =
386 container_of(work, struct cxacru_data, poll_work.work);
385 u32 buf[CXINF_MAX] = {}; 387 u32 buf[CXINF_MAX] = {};
386 struct usbatm_data *usbatm = instance->usbatm; 388 struct usbatm_data *usbatm = instance->usbatm;
387 struct atm_dev *atm_dev = usbatm->atm_dev; 389 struct atm_dev *atm_dev = usbatm->atm_dev;
@@ -720,7 +722,7 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
720 722
721 mutex_init(&instance->cm_serialize); 723 mutex_init(&instance->cm_serialize);
722 724
723 INIT_WORK(&instance->poll_work, (void *)cxacru_poll_status, instance); 725 INIT_DELAYED_WORK(&instance->poll_work, cxacru_poll_status);
724 726
725 usbatm_instance->driver_data = instance; 727 usbatm_instance->driver_data = instance;
726 728
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index a823486495c3..8ed6c75adf0f 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -142,7 +142,7 @@ struct speedtch_instance_data {
142 142
143 struct speedtch_params params; /* set in probe, constant afterwards */ 143 struct speedtch_params params; /* set in probe, constant afterwards */
144 144
145 struct work_struct status_checker; 145 struct delayed_work status_checker;
146 146
147 unsigned char last_status; 147 unsigned char last_status;
148 148
@@ -498,8 +498,11 @@ static int speedtch_start_synchro(struct speedtch_instance_data *instance)
498 return ret; 498 return ret;
499} 499}
500 500
501static void speedtch_check_status(struct speedtch_instance_data *instance) 501static void speedtch_check_status(struct work_struct *work)
502{ 502{
503 struct speedtch_instance_data *instance =
504 container_of(work, struct speedtch_instance_data,
505 status_checker.work);
503 struct usbatm_data *usbatm = instance->usbatm; 506 struct usbatm_data *usbatm = instance->usbatm;
504 struct atm_dev *atm_dev = usbatm->atm_dev; 507 struct atm_dev *atm_dev = usbatm->atm_dev;
505 unsigned char *buf = instance->scratch_buffer; 508 unsigned char *buf = instance->scratch_buffer;
@@ -576,7 +579,7 @@ static void speedtch_status_poll(unsigned long data)
576{ 579{
577 struct speedtch_instance_data *instance = (void *)data; 580 struct speedtch_instance_data *instance = (void *)data;
578 581
579 schedule_work(&instance->status_checker); 582 schedule_delayed_work(&instance->status_checker, 0);
580 583
581 /* The following check is racy, but the race is harmless */ 584 /* The following check is racy, but the race is harmless */
582 if (instance->poll_delay < MAX_POLL_DELAY) 585 if (instance->poll_delay < MAX_POLL_DELAY)
@@ -596,7 +599,7 @@ static void speedtch_resubmit_int(unsigned long data)
596 if (int_urb) { 599 if (int_urb) {
597 ret = usb_submit_urb(int_urb, GFP_ATOMIC); 600 ret = usb_submit_urb(int_urb, GFP_ATOMIC);
598 if (!ret) 601 if (!ret)
599 schedule_work(&instance->status_checker); 602 schedule_delayed_work(&instance->status_checker, 0);
600 else { 603 else {
601 atm_dbg(instance->usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret); 604 atm_dbg(instance->usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret);
602 mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY)); 605 mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY));
@@ -640,7 +643,7 @@ static void speedtch_handle_int(struct urb *int_urb)
640 643
641 if ((int_urb = instance->int_urb)) { 644 if ((int_urb = instance->int_urb)) {
642 ret = usb_submit_urb(int_urb, GFP_ATOMIC); 645 ret = usb_submit_urb(int_urb, GFP_ATOMIC);
643 schedule_work(&instance->status_checker); 646 schedule_delayed_work(&instance->status_checker, 0);
644 if (ret < 0) { 647 if (ret < 0) {
645 atm_dbg(usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret); 648 atm_dbg(usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret);
646 goto fail; 649 goto fail;
@@ -855,7 +858,7 @@ static int speedtch_bind(struct usbatm_data *usbatm,
855 858
856 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0); 859 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0);
857 860
858 INIT_WORK(&instance->status_checker, (void *)speedtch_check_status, instance); 861 INIT_DELAYED_WORK(&instance->status_checker, speedtch_check_status);
859 862
860 instance->status_checker.timer.function = speedtch_status_poll; 863 instance->status_checker.timer.function = speedtch_status_poll;
861 instance->status_checker.timer.data = (unsigned long)instance; 864 instance->status_checker.timer.data = (unsigned long)instance;
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index c137c041f7a4..dae4ef1e8fe5 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -64,6 +64,8 @@
64#include <linux/kthread.h> 64#include <linux/kthread.h>
65#include <linux/version.h> 65#include <linux/version.h>
66#include <linux/mutex.h> 66#include <linux/mutex.h>
67#include <linux/freezer.h>
68
67#include <asm/unaligned.h> 69#include <asm/unaligned.h>
68 70
69#include "usbatm.h" 71#include "usbatm.h"
@@ -655,9 +657,9 @@ static int request_dsp(struct uea_softc *sc)
655/* 657/*
656 * The uea_load_page() function must be called within a process context 658 * The uea_load_page() function must be called within a process context
657 */ 659 */
658static void uea_load_page(void *xsc) 660static void uea_load_page(struct work_struct *work)
659{ 661{
660 struct uea_softc *sc = xsc; 662 struct uea_softc *sc = container_of(work, struct uea_softc, task);
661 u16 pageno = sc->pageno; 663 u16 pageno = sc->pageno;
662 u16 ovl = sc->ovl; 664 u16 ovl = sc->ovl;
663 struct block_info bi; 665 struct block_info bi;
@@ -1348,7 +1350,7 @@ static int uea_boot(struct uea_softc *sc)
1348 1350
1349 uea_enters(INS_TO_USBDEV(sc)); 1351 uea_enters(INS_TO_USBDEV(sc));
1350 1352
1351 INIT_WORK(&sc->task, uea_load_page, sc); 1353 INIT_WORK(&sc->task, uea_load_page);
1352 init_waitqueue_head(&sc->sync_q); 1354 init_waitqueue_head(&sc->sync_q);
1353 init_waitqueue_head(&sc->cmv_ack_wait); 1355 init_waitqueue_head(&sc->cmv_ack_wait);
1354 1356
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index ec3438dc8ee5..7f1fa956dcdb 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -421,9 +421,9 @@ static void acm_write_bulk(struct urb *urb)
421 schedule_work(&acm->work); 421 schedule_work(&acm->work);
422} 422}
423 423
424static void acm_softint(void *private) 424static void acm_softint(struct work_struct *work)
425{ 425{
426 struct acm *acm = private; 426 struct acm *acm = container_of(work, struct acm, work);
427 dbg("Entering acm_softint."); 427 dbg("Entering acm_softint.");
428 428
429 if (!ACM_READY(acm)) 429 if (!ACM_READY(acm))
@@ -927,7 +927,7 @@ skip_normal_probe:
927 acm->rx_buflimit = num_rx_buf; 927 acm->rx_buflimit = num_rx_buf;
928 acm->urb_task.func = acm_rx_tasklet; 928 acm->urb_task.func = acm_rx_tasklet;
929 acm->urb_task.data = (unsigned long) acm; 929 acm->urb_task.data = (unsigned long) acm;
930 INIT_WORK(&acm->work, acm_softint, acm); 930 INIT_WORK(&acm->work, acm_softint);
931 spin_lock_init(&acm->throttle_lock); 931 spin_lock_init(&acm->throttle_lock);
932 spin_lock_init(&acm->write_lock); 932 spin_lock_init(&acm->write_lock);
933 spin_lock_init(&acm->read_lock); 933 spin_lock_init(&acm->read_lock);
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index 840442a25b61..c3915dc28608 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -93,7 +93,7 @@ void hcd_buffer_destroy (struct usb_hcd *hcd)
93} 93}
94 94
95 95
96/* sometimes alloc/free could use kmalloc with SLAB_DMA, for 96/* sometimes alloc/free could use kmalloc with GFP_DMA, for
97 * better sharing and to leverage mm/slab.c intelligence. 97 * better sharing and to leverage mm/slab.c intelligence.
98 */ 98 */
99 99
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 0ce393eb3c4b..2651c2e2a89f 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -22,6 +22,7 @@
22#include <linux/usbdevice_fs.h> 22#include <linux/usbdevice_fs.h>
23#include <linux/kthread.h> 23#include <linux/kthread.h>
24#include <linux/mutex.h> 24#include <linux/mutex.h>
25#include <linux/freezer.h>
25 26
26#include <asm/semaphore.h> 27#include <asm/semaphore.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
@@ -68,7 +69,7 @@ struct usb_hub {
68 69
69 unsigned has_indicators:1; 70 unsigned has_indicators:1;
70 u8 indicator[USB_MAXCHILDREN]; 71 u8 indicator[USB_MAXCHILDREN];
71 struct work_struct leds; 72 struct delayed_work leds;
72}; 73};
73 74
74 75
@@ -218,9 +219,10 @@ static void set_port_led(
218 219
219#define LED_CYCLE_PERIOD ((2*HZ)/3) 220#define LED_CYCLE_PERIOD ((2*HZ)/3)
220 221
221static void led_work (void *__hub) 222static void led_work (struct work_struct *work)
222{ 223{
223 struct usb_hub *hub = __hub; 224 struct usb_hub *hub =
225 container_of(work, struct usb_hub, leds.work);
224 struct usb_device *hdev = hub->hdev; 226 struct usb_device *hdev = hub->hdev;
225 unsigned i; 227 unsigned i;
226 unsigned changed = 0; 228 unsigned changed = 0;
@@ -405,9 +407,10 @@ hub_clear_tt_buffer (struct usb_device *hdev, u16 devinfo, u16 tt)
405 * talking to TTs must queue control transfers (not just bulk and iso), so 407 * talking to TTs must queue control transfers (not just bulk and iso), so
406 * both can talk to the same hub concurrently. 408 * both can talk to the same hub concurrently.
407 */ 409 */
408static void hub_tt_kevent (void *arg) 410static void hub_tt_kevent (struct work_struct *work)
409{ 411{
410 struct usb_hub *hub = arg; 412 struct usb_hub *hub =
413 container_of(work, struct usb_hub, tt.kevent);
411 unsigned long flags; 414 unsigned long flags;
412 415
413 spin_lock_irqsave (&hub->tt.lock, flags); 416 spin_lock_irqsave (&hub->tt.lock, flags);
@@ -458,7 +461,7 @@ void usb_hub_tt_clear_buffer (struct usb_device *udev, int pipe)
458 * since each TT has "at least two" buffers that can need it (and 461 * since each TT has "at least two" buffers that can need it (and
459 * there can be many TTs per hub). even if they're uncommon. 462 * there can be many TTs per hub). even if they're uncommon.
460 */ 463 */
461 if ((clear = kmalloc (sizeof *clear, SLAB_ATOMIC)) == NULL) { 464 if ((clear = kmalloc (sizeof *clear, GFP_ATOMIC)) == NULL) {
462 dev_err (&udev->dev, "can't save CLEAR_TT_BUFFER state\n"); 465 dev_err (&udev->dev, "can't save CLEAR_TT_BUFFER state\n");
463 /* FIXME recover somehow ... RESET_TT? */ 466 /* FIXME recover somehow ... RESET_TT? */
464 return; 467 return;
@@ -694,7 +697,7 @@ static int hub_configure(struct usb_hub *hub,
694 697
695 spin_lock_init (&hub->tt.lock); 698 spin_lock_init (&hub->tt.lock);
696 INIT_LIST_HEAD (&hub->tt.clear_list); 699 INIT_LIST_HEAD (&hub->tt.clear_list);
697 INIT_WORK (&hub->tt.kevent, hub_tt_kevent, hub); 700 INIT_WORK (&hub->tt.kevent, hub_tt_kevent);
698 switch (hdev->descriptor.bDeviceProtocol) { 701 switch (hdev->descriptor.bDeviceProtocol) {
699 case 0: 702 case 0:
700 break; 703 break;
@@ -938,7 +941,7 @@ descriptor_error:
938 INIT_LIST_HEAD(&hub->event_list); 941 INIT_LIST_HEAD(&hub->event_list);
939 hub->intfdev = &intf->dev; 942 hub->intfdev = &intf->dev;
940 hub->hdev = hdev; 943 hub->hdev = hdev;
941 INIT_WORK(&hub->leds, led_work, hub); 944 INIT_DELAYED_WORK(&hub->leds, led_work);
942 945
943 usb_set_intfdata (intf, hub); 946 usb_set_intfdata (intf, hub);
944 intf->needs_remote_wakeup = 1; 947 intf->needs_remote_wakeup = 1;
@@ -2369,7 +2372,7 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)
2369 struct usb_qualifier_descriptor *qual; 2372 struct usb_qualifier_descriptor *qual;
2370 int status; 2373 int status;
2371 2374
2372 qual = kmalloc (sizeof *qual, SLAB_KERNEL); 2375 qual = kmalloc (sizeof *qual, GFP_KERNEL);
2373 if (qual == NULL) 2376 if (qual == NULL)
2374 return; 2377 return;
2375 2378
@@ -2381,7 +2384,7 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)
2381 /* hub LEDs are probably harder to miss than syslog */ 2384 /* hub LEDs are probably harder to miss than syslog */
2382 if (hub->has_indicators) { 2385 if (hub->has_indicators) {
2383 hub->indicator[port1-1] = INDICATOR_GREEN_BLINK; 2386 hub->indicator[port1-1] = INDICATOR_GREEN_BLINK;
2384 schedule_work (&hub->leds); 2387 schedule_delayed_work (&hub->leds, 0);
2385 } 2388 }
2386 } 2389 }
2387 kfree(qual); 2390 kfree(qual);
@@ -2555,7 +2558,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2555 if (hub->has_indicators) { 2558 if (hub->has_indicators) {
2556 hub->indicator[port1-1] = 2559 hub->indicator[port1-1] =
2557 INDICATOR_AMBER_BLINK; 2560 INDICATOR_AMBER_BLINK;
2558 schedule_work (&hub->leds); 2561 schedule_delayed_work (&hub->leds, 0);
2559 } 2562 }
2560 status = -ENOTCONN; /* Don't retry */ 2563 status = -ENOTCONN; /* Don't retry */
2561 goto loop_disable; 2564 goto loop_disable;
@@ -2920,7 +2923,7 @@ static int config_descriptors_changed(struct usb_device *udev)
2920 if (len < le16_to_cpu(udev->config[index].desc.wTotalLength)) 2923 if (len < le16_to_cpu(udev->config[index].desc.wTotalLength))
2921 len = le16_to_cpu(udev->config[index].desc.wTotalLength); 2924 len = le16_to_cpu(udev->config[index].desc.wTotalLength);
2922 } 2925 }
2923 buf = kmalloc (len, SLAB_KERNEL); 2926 buf = kmalloc (len, GFP_KERNEL);
2924 if (buf == NULL) { 2927 if (buf == NULL) {
2925 dev_err(&udev->dev, "no mem to re-read configs after reset\n"); 2928 dev_err(&udev->dev, "no mem to re-read configs after reset\n");
2926 /* assume the worst */ 2929 /* assume the worst */
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 29b0fa9ff9d0..149aa8bfb1fe 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -488,7 +488,7 @@ void usb_sg_wait (struct usb_sg_request *io)
488 int retval; 488 int retval;
489 489
490 io->urbs [i]->dev = io->dev; 490 io->urbs [i]->dev = io->dev;
491 retval = usb_submit_urb (io->urbs [i], SLAB_ATOMIC); 491 retval = usb_submit_urb (io->urbs [i], GFP_ATOMIC);
492 492
493 /* after we submit, let completions or cancelations fire; 493 /* after we submit, let completions or cancelations fire;
494 * we handshake using io->status. 494 * we handshake using io->status.
@@ -1501,9 +1501,10 @@ struct set_config_request {
1501}; 1501};
1502 1502
1503/* Worker routine for usb_driver_set_configuration() */ 1503/* Worker routine for usb_driver_set_configuration() */
1504static void driver_set_config_work(void *_req) 1504static void driver_set_config_work(struct work_struct *work)
1505{ 1505{
1506 struct set_config_request *req = _req; 1506 struct set_config_request *req =
1507 container_of(work, struct set_config_request, work);
1507 1508
1508 usb_lock_device(req->udev); 1509 usb_lock_device(req->udev);
1509 usb_set_configuration(req->udev, req->config); 1510 usb_set_configuration(req->udev, req->config);
@@ -1541,7 +1542,7 @@ int usb_driver_set_configuration(struct usb_device *udev, int config)
1541 return -ENOMEM; 1542 return -ENOMEM;
1542 req->udev = udev; 1543 req->udev = udev;
1543 req->config = config; 1544 req->config = config;
1544 INIT_WORK(&req->work, driver_set_config_work, req); 1545 INIT_WORK(&req->work, driver_set_config_work);
1545 1546
1546 usb_get_dev(udev); 1547 usb_get_dev(udev);
1547 if (!schedule_work(&req->work)) { 1548 if (!schedule_work(&req->work)) {
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 81cb52564e68..02426d0b9a34 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -203,9 +203,10 @@ static void ksuspend_usb_cleanup(void)
203#ifdef CONFIG_USB_SUSPEND 203#ifdef CONFIG_USB_SUSPEND
204 204
205/* usb_autosuspend_work - callback routine to autosuspend a USB device */ 205/* usb_autosuspend_work - callback routine to autosuspend a USB device */
206static void usb_autosuspend_work(void *_udev) 206static void usb_autosuspend_work(struct work_struct *work)
207{ 207{
208 struct usb_device *udev = _udev; 208 struct usb_device *udev =
209 container_of(work, struct usb_device, autosuspend.work);
209 210
210 usb_pm_lock(udev); 211 usb_pm_lock(udev);
211 udev->auto_pm = 1; 212 udev->auto_pm = 1;
@@ -215,7 +216,7 @@ static void usb_autosuspend_work(void *_udev)
215 216
216#else 217#else
217 218
218static void usb_autosuspend_work(void *_udev) 219static void usb_autosuspend_work(struct work_struct *work)
219{} 220{}
220 221
221#endif /* CONFIG_USB_SUSPEND */ 222#endif /* CONFIG_USB_SUSPEND */
@@ -304,7 +305,7 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1)
304 305
305#ifdef CONFIG_PM 306#ifdef CONFIG_PM
306 mutex_init(&dev->pm_mutex); 307 mutex_init(&dev->pm_mutex);
307 INIT_WORK(&dev->autosuspend, usb_autosuspend_work, dev); 308 INIT_DELAYED_WORK(&dev->autosuspend, usb_autosuspend_work);
308#endif 309#endif
309 return dev; 310 return dev;
310} 311}
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 3bd1dfe565c1..d15bf22b9a03 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -1833,9 +1833,9 @@ static void rx_fill (struct eth_dev *dev, gfp_t gfp_flags)
1833 spin_unlock_irqrestore(&dev->req_lock, flags); 1833 spin_unlock_irqrestore(&dev->req_lock, flags);
1834} 1834}
1835 1835
1836static void eth_work (void *_dev) 1836static void eth_work (struct work_struct *work)
1837{ 1837{
1838 struct eth_dev *dev = _dev; 1838 struct eth_dev *dev = container_of(work, struct eth_dev, work);
1839 1839
1840 if (test_and_clear_bit (WORK_RX_MEMORY, &dev->todo)) { 1840 if (test_and_clear_bit (WORK_RX_MEMORY, &dev->todo)) {
1841 if (netif_running (dev->net)) 1841 if (netif_running (dev->net))
@@ -2398,7 +2398,7 @@ autoconf_fail:
2398 dev = netdev_priv(net); 2398 dev = netdev_priv(net);
2399 spin_lock_init (&dev->lock); 2399 spin_lock_init (&dev->lock);
2400 spin_lock_init (&dev->req_lock); 2400 spin_lock_init (&dev->req_lock);
2401 INIT_WORK (&dev->work, eth_work, dev); 2401 INIT_WORK (&dev->work, eth_work);
2402 INIT_LIST_HEAD (&dev->tx_reqs); 2402 INIT_LIST_HEAD (&dev->tx_reqs);
2403 INIT_LIST_HEAD (&dev->rx_reqs); 2403 INIT_LIST_HEAD (&dev->rx_reqs);
2404 2404
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 8b975d15538d..c98316ce8384 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -250,7 +250,7 @@
250#include <linux/slab.h> 250#include <linux/slab.h>
251#include <linux/spinlock.h> 251#include <linux/spinlock.h>
252#include <linux/string.h> 252#include <linux/string.h>
253#include <linux/suspend.h> 253#include <linux/freezer.h>
254#include <linux/utsname.h> 254#include <linux/utsname.h>
255 255
256#include <linux/usb_ch9.h> 256#include <linux/usb_ch9.h>
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
index 64554acad63f..31351826f2ba 100644
--- a/drivers/usb/gadget/gmidi.c
+++ b/drivers/usb/gadget/gmidi.c
@@ -1236,7 +1236,7 @@ autoconf_fail:
1236 1236
1237 1237
1238 /* ok, we made sense of the hardware ... */ 1238 /* ok, we made sense of the hardware ... */
1239 dev = kzalloc(sizeof(*dev), SLAB_KERNEL); 1239 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1240 if (!dev) { 1240 if (!dev) {
1241 return -ENOMEM; 1241 return -ENOMEM;
1242 } 1242 }
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index a3076da3f4eb..805a9826842d 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -1864,7 +1864,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1864 } 1864 }
1865 1865
1866 /* alloc, and start init */ 1866 /* alloc, and start init */
1867 dev = kmalloc (sizeof *dev, SLAB_KERNEL); 1867 dev = kmalloc (sizeof *dev, GFP_KERNEL);
1868 if (dev == NULL){ 1868 if (dev == NULL){
1869 pr_debug("enomem %s\n", pci_name(pdev)); 1869 pr_debug("enomem %s\n", pci_name(pdev));
1870 retval = -ENOMEM; 1870 retval = -ENOMEM;
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 86924f9cdd7e..3fb1044a4db0 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -412,7 +412,7 @@ ep_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr)
412 /* FIXME readahead for O_NONBLOCK and poll(); careful with ZLPs */ 412 /* FIXME readahead for O_NONBLOCK and poll(); careful with ZLPs */
413 413
414 value = -ENOMEM; 414 value = -ENOMEM;
415 kbuf = kmalloc (len, SLAB_KERNEL); 415 kbuf = kmalloc (len, GFP_KERNEL);
416 if (unlikely (!kbuf)) 416 if (unlikely (!kbuf))
417 goto free1; 417 goto free1;
418 418
@@ -456,7 +456,7 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
456 /* FIXME writebehind for O_NONBLOCK and poll(), qlen = 1 */ 456 /* FIXME writebehind for O_NONBLOCK and poll(), qlen = 1 */
457 457
458 value = -ENOMEM; 458 value = -ENOMEM;
459 kbuf = kmalloc (len, SLAB_KERNEL); 459 kbuf = kmalloc (len, GFP_KERNEL);
460 if (!kbuf) 460 if (!kbuf)
461 goto free1; 461 goto free1;
462 if (copy_from_user (kbuf, buf, len)) { 462 if (copy_from_user (kbuf, buf, len)) {
@@ -1898,7 +1898,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1898 buf += 4; 1898 buf += 4;
1899 length -= 4; 1899 length -= 4;
1900 1900
1901 kbuf = kmalloc (length, SLAB_KERNEL); 1901 kbuf = kmalloc (length, GFP_KERNEL);
1902 if (!kbuf) 1902 if (!kbuf)
1903 return -ENOMEM; 1903 return -ENOMEM;
1904 if (copy_from_user (kbuf, buf, length)) { 1904 if (copy_from_user (kbuf, buf, length)) {
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 0b590831582c..3024c679e38e 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -2861,7 +2861,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
2861 } 2861 }
2862 2862
2863 /* alloc, and start init */ 2863 /* alloc, and start init */
2864 dev = kzalloc (sizeof *dev, SLAB_KERNEL); 2864 dev = kzalloc (sizeof *dev, GFP_KERNEL);
2865 if (dev == NULL){ 2865 if (dev == NULL){
2866 retval = -ENOMEM; 2866 retval = -ENOMEM;
2867 goto done; 2867 goto done;
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 48a09fd89d18..030d87c28c2f 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -2581,7 +2581,7 @@ omap_udc_setup(struct platform_device *odev, struct otg_transceiver *xceiv)
2581 /* UDC_PULLUP_EN gates the chip clock */ 2581 /* UDC_PULLUP_EN gates the chip clock */
2582 // OTG_SYSCON_1_REG |= DEV_IDLE_EN; 2582 // OTG_SYSCON_1_REG |= DEV_IDLE_EN;
2583 2583
2584 udc = kzalloc(sizeof(*udc), SLAB_KERNEL); 2584 udc = kzalloc(sizeof(*udc), GFP_KERNEL);
2585 if (!udc) 2585 if (!udc)
2586 return -ENOMEM; 2586 return -ENOMEM;
2587 2587
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index 0f809dd68492..40710ea1b490 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -1190,7 +1190,7 @@ autoconf_fail:
1190 1190
1191 1191
1192 /* ok, we made sense of the hardware ... */ 1192 /* ok, we made sense of the hardware ... */
1193 dev = kzalloc(sizeof(*dev), SLAB_KERNEL); 1193 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1194 if (!dev) 1194 if (!dev)
1195 return -ENOMEM; 1195 return -ENOMEM;
1196 spin_lock_init (&dev->lock); 1196 spin_lock_init (&dev->lock);
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 34b7a31cd85b..56349d21e6ea 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -492,7 +492,7 @@ show_periodic (struct class_device *class_dev, char *buf)
492 unsigned i; 492 unsigned i;
493 __le32 tag; 493 __le32 tag;
494 494
495 if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, SLAB_ATOMIC))) 495 if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, GFP_ATOMIC)))
496 return 0; 496 return 0;
497 seen_count = 0; 497 seen_count = 0;
498 498
diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c
index 87eca6aeacf2..9325e46a68c0 100644
--- a/drivers/usb/host/hc_crisv10.c
+++ b/drivers/usb/host/hc_crisv10.c
@@ -188,7 +188,7 @@ static DEFINE_TIMER(bulk_eot_timer, NULL, 0, 0);
188#define CHECK_ALIGN(x) if (((__u32)(x)) & 0x00000003) \ 188#define CHECK_ALIGN(x) if (((__u32)(x)) & 0x00000003) \
189{panic("Alignment check (DWORD) failed at %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);} 189{panic("Alignment check (DWORD) failed at %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);}
190 190
191#define SLAB_FLAG (in_interrupt() ? SLAB_ATOMIC : SLAB_KERNEL) 191#define SLAB_FLAG (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL)
192#define KMALLOC_FLAG (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL) 192#define KMALLOC_FLAG (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL)
193 193
194/* Most helpful debugging aid */ 194/* Most helpful debugging aid */
@@ -275,13 +275,13 @@ static volatile USB_SB_Desc_t TxIntrSB_zout __attribute__ ((aligned (4)));
275static int zout_buffer[4] __attribute__ ((aligned (4))); 275static int zout_buffer[4] __attribute__ ((aligned (4)));
276 276
277/* Cache for allocating new EP and SB descriptors. */ 277/* Cache for allocating new EP and SB descriptors. */
278static kmem_cache_t *usb_desc_cache; 278static struct kmem_cache *usb_desc_cache;
279 279
280/* Cache for the registers allocated in the top half. */ 280/* Cache for the registers allocated in the top half. */
281static kmem_cache_t *top_half_reg_cache; 281static struct kmem_cache *top_half_reg_cache;
282 282
283/* Cache for the data allocated in the isoc descr top half. */ 283/* Cache for the data allocated in the isoc descr top half. */
284static kmem_cache_t *isoc_compl_cache; 284static struct kmem_cache *isoc_compl_cache;
285 285
286static struct usb_bus *etrax_usb_bus; 286static struct usb_bus *etrax_usb_bus;
287 287
@@ -1743,7 +1743,7 @@ static irqreturn_t etrax_usb_tx_interrupt(int irq, void *vhc)
1743 1743
1744 *R_DMA_CH8_SUB3_CLR_INTR = IO_STATE(R_DMA_CH8_SUB3_CLR_INTR, clr_descr, do); 1744 *R_DMA_CH8_SUB3_CLR_INTR = IO_STATE(R_DMA_CH8_SUB3_CLR_INTR, clr_descr, do);
1745 1745
1746 comp_data = (usb_isoc_complete_data_t*)kmem_cache_alloc(isoc_compl_cache, SLAB_ATOMIC); 1746 comp_data = (usb_isoc_complete_data_t*)kmem_cache_alloc(isoc_compl_cache, GFP_ATOMIC);
1747 assert(comp_data != NULL); 1747 assert(comp_data != NULL);
1748 1748
1749 INIT_WORK(&comp_data->usb_bh, etrax_usb_isoc_descr_interrupt_bottom_half, comp_data); 1749 INIT_WORK(&comp_data->usb_bh, etrax_usb_isoc_descr_interrupt_bottom_half, comp_data);
@@ -3010,7 +3010,7 @@ static void etrax_usb_add_to_isoc_sb_list(struct urb *urb, int epid)
3010 if (!urb->iso_frame_desc[i].length) 3010 if (!urb->iso_frame_desc[i].length)
3011 continue; 3011 continue;
3012 3012
3013 next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_ATOMIC); 3013 next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, GFP_ATOMIC);
3014 assert(next_sb_desc != NULL); 3014 assert(next_sb_desc != NULL);
3015 3015
3016 if (urb->iso_frame_desc[i].length > 0) { 3016 if (urb->iso_frame_desc[i].length > 0) {
@@ -3063,7 +3063,7 @@ static void etrax_usb_add_to_isoc_sb_list(struct urb *urb, int epid)
3063 if (TxIsocEPList[epid].sub == 0) { 3063 if (TxIsocEPList[epid].sub == 0) {
3064 dbg_isoc("Isoc traffic not already running, allocating SB"); 3064 dbg_isoc("Isoc traffic not already running, allocating SB");
3065 3065
3066 next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_ATOMIC); 3066 next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, GFP_ATOMIC);
3067 assert(next_sb_desc != NULL); 3067 assert(next_sb_desc != NULL);
3068 3068
3069 next_sb_desc->command = (IO_STATE(USB_SB_command, tt, in) | 3069 next_sb_desc->command = (IO_STATE(USB_SB_command, tt, in) |
@@ -3317,7 +3317,7 @@ static irqreturn_t etrax_usb_hc_interrupt_top_half(int irq, void *vhc)
3317 3317
3318 restore_flags(flags); 3318 restore_flags(flags);
3319 3319
3320 reg = (usb_interrupt_registers_t *)kmem_cache_alloc(top_half_reg_cache, SLAB_ATOMIC); 3320 reg = (usb_interrupt_registers_t *)kmem_cache_alloc(top_half_reg_cache, GFP_ATOMIC);
3321 3321
3322 assert(reg != NULL); 3322 assert(reg != NULL);
3323 3323
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index 8293c1d4be3f..0f47a57dac28 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -505,7 +505,7 @@ show_periodic (struct class_device *class_dev, char *buf)
505 char *next; 505 char *next;
506 unsigned i; 506 unsigned i;
507 507
508 if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, SLAB_ATOMIC))) 508 if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, GFP_ATOMIC)))
509 return 0; 509 return 0;
510 seen_count = 0; 510 seen_count = 0;
511 511
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c
index 2dbb77414905..7f26f9bdbaf1 100644
--- a/drivers/usb/host/ohci-pnx4008.c
+++ b/drivers/usb/host/ohci-pnx4008.c
@@ -134,7 +134,7 @@ static int isp1301_attach(struct i2c_adapter *adap, int addr, int kind)
134{ 134{
135 struct i2c_client *c; 135 struct i2c_client *c;
136 136
137 c = (struct i2c_client *)kzalloc(sizeof(*c), SLAB_KERNEL); 137 c = (struct i2c_client *)kzalloc(sizeof(*c), GFP_KERNEL);
138 138
139 if (!c) 139 if (!c)
140 return -ENOMEM; 140 return -ENOMEM;
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index ef54e310bfc4..a9d7119e3176 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -163,7 +163,7 @@ struct u132_endp {
163 u16 queue_next; 163 u16 queue_next;
164 struct urb *urb_list[ENDP_QUEUE_SIZE]; 164 struct urb *urb_list[ENDP_QUEUE_SIZE];
165 struct list_head urb_more; 165 struct list_head urb_more;
166 struct work_struct scheduler; 166 struct delayed_work scheduler;
167}; 167};
168struct u132_ring { 168struct u132_ring {
169 unsigned in_use:1; 169 unsigned in_use:1;
@@ -171,7 +171,7 @@ struct u132_ring {
171 u8 number; 171 u8 number;
172 struct u132 *u132; 172 struct u132 *u132;
173 struct u132_endp *curr_endp; 173 struct u132_endp *curr_endp;
174 struct work_struct scheduler; 174 struct delayed_work scheduler;
175}; 175};
176#define OHCI_QUIRK_AMD756 0x01 176#define OHCI_QUIRK_AMD756 0x01
177#define OHCI_QUIRK_SUPERIO 0x02 177#define OHCI_QUIRK_SUPERIO 0x02
@@ -198,7 +198,7 @@ struct u132 {
198 u32 hc_roothub_portstatus[MAX_ROOT_PORTS]; 198 u32 hc_roothub_portstatus[MAX_ROOT_PORTS];
199 int flags; 199 int flags;
200 unsigned long next_statechange; 200 unsigned long next_statechange;
201 struct work_struct monitor; 201 struct delayed_work monitor;
202 int num_endpoints; 202 int num_endpoints;
203 struct u132_addr addr[MAX_U132_ADDRS]; 203 struct u132_addr addr[MAX_U132_ADDRS];
204 struct u132_udev udev[MAX_U132_UDEVS]; 204 struct u132_udev udev[MAX_U132_UDEVS];
@@ -310,7 +310,7 @@ static void u132_ring_requeue_work(struct u132 *u132, struct u132_ring *ring,
310 if (delta > 0) { 310 if (delta > 0) {
311 if (queue_delayed_work(workqueue, &ring->scheduler, delta)) 311 if (queue_delayed_work(workqueue, &ring->scheduler, delta))
312 return; 312 return;
313 } else if (queue_work(workqueue, &ring->scheduler)) 313 } else if (queue_delayed_work(workqueue, &ring->scheduler, 0))
314 return; 314 return;
315 kref_put(&u132->kref, u132_hcd_delete); 315 kref_put(&u132->kref, u132_hcd_delete);
316 return; 316 return;
@@ -389,12 +389,8 @@ static inline void u132_endp_init_kref(struct u132 *u132,
389static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp, 389static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp,
390 unsigned int delta) 390 unsigned int delta)
391{ 391{
392 if (delta > 0) { 392 if (queue_delayed_work(workqueue, &endp->scheduler, delta))
393 if (queue_delayed_work(workqueue, &endp->scheduler, delta)) 393 kref_get(&endp->kref);
394 kref_get(&endp->kref);
395 } else if (queue_work(workqueue, &endp->scheduler))
396 kref_get(&endp->kref);
397 return;
398} 394}
399 395
400static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp) 396static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp)
@@ -410,24 +406,14 @@ static inline void u132_monitor_put_kref(struct u132 *u132)
410 406
411static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta) 407static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta)
412{ 408{
413 if (delta > 0) { 409 if (queue_delayed_work(workqueue, &u132->monitor, delta))
414 if (queue_delayed_work(workqueue, &u132->monitor, delta)) { 410 kref_get(&u132->kref);
415 kref_get(&u132->kref);
416 }
417 } else if (queue_work(workqueue, &u132->monitor))
418 kref_get(&u132->kref);
419 return;
420} 411}
421 412
422static void u132_monitor_requeue_work(struct u132 *u132, unsigned int delta) 413static void u132_monitor_requeue_work(struct u132 *u132, unsigned int delta)
423{ 414{
424 if (delta > 0) { 415 if (!queue_delayed_work(workqueue, &u132->monitor, delta))
425 if (queue_delayed_work(workqueue, &u132->monitor, delta)) 416 kref_put(&u132->kref, u132_hcd_delete);
426 return;
427 } else if (queue_work(workqueue, &u132->monitor))
428 return;
429 kref_put(&u132->kref, u132_hcd_delete);
430 return;
431} 417}
432 418
433static void u132_monitor_cancel_work(struct u132 *u132) 419static void u132_monitor_cancel_work(struct u132 *u132)
@@ -489,9 +475,9 @@ static int read_roothub_info(struct u132 *u132)
489 return 0; 475 return 0;
490} 476}
491 477
492static void u132_hcd_monitor_work(void *data) 478static void u132_hcd_monitor_work(struct work_struct *work)
493{ 479{
494 struct u132 *u132 = data; 480 struct u132 *u132 = container_of(work, struct u132, monitor.work);
495 if (u132->going > 1) { 481 if (u132->going > 1) {
496 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 482 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
497 , u132->going); 483 , u132->going);
@@ -1315,15 +1301,14 @@ static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf,
1315 } 1301 }
1316} 1302}
1317 1303
1318static void u132_hcd_ring_work_scheduler(void *data);
1319static void u132_hcd_endp_work_scheduler(void *data);
1320/* 1304/*
1321* this work function is only executed from the work queue 1305* this work function is only executed from the work queue
1322* 1306*
1323*/ 1307*/
1324static void u132_hcd_ring_work_scheduler(void *data) 1308static void u132_hcd_ring_work_scheduler(struct work_struct *work)
1325{ 1309{
1326 struct u132_ring *ring = data; 1310 struct u132_ring *ring =
1311 container_of(work, struct u132_ring, scheduler.work);
1327 struct u132 *u132 = ring->u132; 1312 struct u132 *u132 = ring->u132;
1328 down(&u132->scheduler_lock); 1313 down(&u132->scheduler_lock);
1329 if (ring->in_use) { 1314 if (ring->in_use) {
@@ -1382,10 +1367,11 @@ static void u132_hcd_ring_work_scheduler(void *data)
1382 } 1367 }
1383} 1368}
1384 1369
1385static void u132_hcd_endp_work_scheduler(void *data) 1370static void u132_hcd_endp_work_scheduler(struct work_struct *work)
1386{ 1371{
1387 struct u132_ring *ring; 1372 struct u132_ring *ring;
1388 struct u132_endp *endp = data; 1373 struct u132_endp *endp =
1374 container_of(work, struct u132_endp, scheduler.work);
1389 struct u132 *u132 = endp->u132; 1375 struct u132 *u132 = endp->u132;
1390 down(&u132->scheduler_lock); 1376 down(&u132->scheduler_lock);
1391 ring = endp->ring; 1377 ring = endp->ring;
@@ -1943,7 +1929,7 @@ static int create_endpoint_and_queue_int(struct u132 *u132,
1943 if (!endp) { 1929 if (!endp) {
1944 return -ENOMEM; 1930 return -ENOMEM;
1945 } 1931 }
1946 INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp); 1932 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
1947 spin_lock_init(&endp->queue_lock.slock); 1933 spin_lock_init(&endp->queue_lock.slock);
1948 INIT_LIST_HEAD(&endp->urb_more); 1934 INIT_LIST_HEAD(&endp->urb_more);
1949 ring = endp->ring = &u132->ring[0]; 1935 ring = endp->ring = &u132->ring[0];
@@ -2032,7 +2018,7 @@ static int create_endpoint_and_queue_bulk(struct u132 *u132,
2032 if (!endp) { 2018 if (!endp) {
2033 return -ENOMEM; 2019 return -ENOMEM;
2034 } 2020 }
2035 INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp); 2021 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
2036 spin_lock_init(&endp->queue_lock.slock); 2022 spin_lock_init(&endp->queue_lock.slock);
2037 INIT_LIST_HEAD(&endp->urb_more); 2023 INIT_LIST_HEAD(&endp->urb_more);
2038 endp->dequeueing = 0; 2024 endp->dequeueing = 0;
@@ -2117,7 +2103,7 @@ static int create_endpoint_and_queue_control(struct u132 *u132,
2117 if (!endp) { 2103 if (!endp) {
2118 return -ENOMEM; 2104 return -ENOMEM;
2119 } 2105 }
2120 INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp); 2106 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
2121 spin_lock_init(&endp->queue_lock.slock); 2107 spin_lock_init(&endp->queue_lock.slock);
2122 INIT_LIST_HEAD(&endp->urb_more); 2108 INIT_LIST_HEAD(&endp->urb_more);
2123 ring = endp->ring = &u132->ring[0]; 2109 ring = endp->ring = &u132->ring[0];
@@ -3096,10 +3082,10 @@ static void u132_initialise(struct u132 *u132, struct platform_device *pdev)
3096 ring->number = rings + 1; 3082 ring->number = rings + 1;
3097 ring->length = 0; 3083 ring->length = 0;
3098 ring->curr_endp = NULL; 3084 ring->curr_endp = NULL;
3099 INIT_WORK(&ring->scheduler, u132_hcd_ring_work_scheduler, 3085 INIT_DELAYED_WORK(&ring->scheduler,
3100 (void *)ring); 3086 u132_hcd_ring_work_scheduler);
3101 } down(&u132->sw_lock); 3087 } down(&u132->sw_lock);
3102 INIT_WORK(&u132->monitor, u132_hcd_monitor_work, (void *)u132); 3088 INIT_DELAYED_WORK(&u132->monitor, u132_hcd_monitor_work);
3103 while (ports-- > 0) { 3089 while (ports-- > 0) {
3104 struct u132_port *port = &u132->port[ports]; 3090 struct u132_port *port = &u132->port[ports];
3105 port->u132 = u132; 3091 port->u132 = u132;
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 226bf3de8edd..e87692c31be4 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -81,7 +81,7 @@ MODULE_PARM_DESC(debug, "Debug level");
81static char *errbuf; 81static char *errbuf;
82#define ERRBUF_LEN (32 * 1024) 82#define ERRBUF_LEN (32 * 1024)
83 83
84static kmem_cache_t *uhci_up_cachep; /* urb_priv */ 84static struct kmem_cache *uhci_up_cachep; /* urb_priv */
85 85
86static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state); 86static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state);
87static void wakeup_rh(struct uhci_hcd *uhci); 87static void wakeup_rh(struct uhci_hcd *uhci);
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 06115f22a4fa..30b88459ac7d 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -498,7 +498,7 @@ static inline struct urb_priv *uhci_alloc_urb_priv(struct uhci_hcd *uhci,
498{ 498{
499 struct urb_priv *urbp; 499 struct urb_priv *urbp;
500 500
501 urbp = kmem_cache_alloc(uhci_up_cachep, SLAB_ATOMIC); 501 urbp = kmem_cache_alloc(uhci_up_cachep, GFP_ATOMIC);
502 if (!urbp) 502 if (!urbp)
503 return NULL; 503 return NULL;
504 504
diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c
index 0096373b5f98..909138e5aa04 100644
--- a/drivers/usb/input/acecad.c
+++ b/drivers/usb/input/acecad.c
@@ -152,7 +152,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
152 if (!acecad || !input_dev) 152 if (!acecad || !input_dev)
153 goto fail1; 153 goto fail1;
154 154
155 acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma); 155 acecad->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &acecad->data_dma);
156 if (!acecad->data) 156 if (!acecad->data)
157 goto fail1; 157 goto fail1;
158 158
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c
index bf428184608f..9f52429ce654 100644
--- a/drivers/usb/input/aiptek.c
+++ b/drivers/usb/input/aiptek.c
@@ -1988,7 +1988,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
1988 goto fail1; 1988 goto fail1;
1989 1989
1990 aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH, 1990 aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH,
1991 SLAB_ATOMIC, &aiptek->data_dma); 1991 GFP_ATOMIC, &aiptek->data_dma);
1992 if (!aiptek->data) 1992 if (!aiptek->data)
1993 goto fail1; 1993 goto fail1;
1994 1994
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index ff23318dc301..b724e36f7b92 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -592,7 +592,7 @@ static void ati_remote_irq_in(struct urb *urb)
592 __FUNCTION__, urb->status); 592 __FUNCTION__, urb->status);
593 } 593 }
594 594
595 retval = usb_submit_urb(urb, SLAB_ATOMIC); 595 retval = usb_submit_urb(urb, GFP_ATOMIC);
596 if (retval) 596 if (retval)
597 dev_err(&ati_remote->interface->dev, "%s: usb_submit_urb()=%d\n", 597 dev_err(&ati_remote->interface->dev, "%s: usb_submit_urb()=%d\n",
598 __FUNCTION__, retval); 598 __FUNCTION__, retval);
@@ -604,12 +604,12 @@ static void ati_remote_irq_in(struct urb *urb)
604static int ati_remote_alloc_buffers(struct usb_device *udev, 604static int ati_remote_alloc_buffers(struct usb_device *udev,
605 struct ati_remote *ati_remote) 605 struct ati_remote *ati_remote)
606{ 606{
607 ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, 607 ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, GFP_ATOMIC,
608 &ati_remote->inbuf_dma); 608 &ati_remote->inbuf_dma);
609 if (!ati_remote->inbuf) 609 if (!ati_remote->inbuf)
610 return -1; 610 return -1;
611 611
612 ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, 612 ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, GFP_ATOMIC,
613 &ati_remote->outbuf_dma); 613 &ati_remote->outbuf_dma);
614 if (!ati_remote->outbuf) 614 if (!ati_remote->outbuf)
615 return -1; 615 return -1;
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index a49644b7c58e..f1d0e1d69828 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -969,9 +969,10 @@ static void hid_retry_timeout(unsigned long _hid)
969} 969}
970 970
971/* Workqueue routine to reset the device or clear a halt */ 971/* Workqueue routine to reset the device or clear a halt */
972static void hid_reset(void *_hid) 972static void hid_reset(struct work_struct *work)
973{ 973{
974 struct hid_device *hid = (struct hid_device *) _hid; 974 struct hid_device *hid =
975 container_of(work, struct hid_device, reset_work);
975 int rc_lock, rc = 0; 976 int rc_lock, rc = 0;
976 977
977 if (test_bit(HID_CLEAR_HALT, &hid->iofl)) { 978 if (test_bit(HID_CLEAR_HALT, &hid->iofl)) {
@@ -1078,7 +1079,7 @@ static void hid_irq_in(struct urb *urb)
1078 warn("input irq status %d received", urb->status); 1079 warn("input irq status %d received", urb->status);
1079 } 1080 }
1080 1081
1081 status = usb_submit_urb(urb, SLAB_ATOMIC); 1082 status = usb_submit_urb(urb, GFP_ATOMIC);
1082 if (status) { 1083 if (status) {
1083 clear_bit(HID_IN_RUNNING, &hid->iofl); 1084 clear_bit(HID_IN_RUNNING, &hid->iofl);
1084 if (status != -EPERM) { 1085 if (status != -EPERM) {
@@ -1863,13 +1864,13 @@ static void hid_find_max_report(struct hid_device *hid, unsigned int type, int *
1863 1864
1864static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) 1865static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid)
1865{ 1866{
1866 if (!(hid->inbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->inbuf_dma))) 1867 if (!(hid->inbuf = usb_buffer_alloc(dev, hid->bufsize, GFP_ATOMIC, &hid->inbuf_dma)))
1867 return -1; 1868 return -1;
1868 if (!(hid->outbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->outbuf_dma))) 1869 if (!(hid->outbuf = usb_buffer_alloc(dev, hid->bufsize, GFP_ATOMIC, &hid->outbuf_dma)))
1869 return -1; 1870 return -1;
1870 if (!(hid->cr = usb_buffer_alloc(dev, sizeof(*(hid->cr)), SLAB_ATOMIC, &hid->cr_dma))) 1871 if (!(hid->cr = usb_buffer_alloc(dev, sizeof(*(hid->cr)), GFP_ATOMIC, &hid->cr_dma)))
1871 return -1; 1872 return -1;
1872 if (!(hid->ctrlbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->ctrlbuf_dma))) 1873 if (!(hid->ctrlbuf = usb_buffer_alloc(dev, hid->bufsize, GFP_ATOMIC, &hid->ctrlbuf_dma)))
1873 return -1; 1874 return -1;
1874 1875
1875 return 0; 1876 return 0;
@@ -2043,7 +2044,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
2043 2044
2044 init_waitqueue_head(&hid->wait); 2045 init_waitqueue_head(&hid->wait);
2045 2046
2046 INIT_WORK(&hid->reset_work, hid_reset, hid); 2047 INIT_WORK(&hid->reset_work, hid_reset);
2047 setup_timer(&hid->io_retry, hid_retry_timeout, (unsigned long) hid); 2048 setup_timer(&hid->io_retry, hid_retry_timeout, (unsigned long) hid);
2048 2049
2049 spin_lock_init(&hid->inlock); 2050 spin_lock_init(&hid->inlock);
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c
index 50aa8108a50b..98bd323369c7 100644
--- a/drivers/usb/input/keyspan_remote.c
+++ b/drivers/usb/input/keyspan_remote.c
@@ -456,7 +456,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
456 remote->in_endpoint = endpoint; 456 remote->in_endpoint = endpoint;
457 remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */ 457 remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */
458 458
459 remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma); 459 remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, GFP_ATOMIC, &remote->in_dma);
460 if (!remote->in_buffer) { 460 if (!remote->in_buffer) {
461 retval = -ENOMEM; 461 retval = -ENOMEM;
462 goto fail1; 462 goto fail1;
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c
index 79a85d46cb13..92c4e07da4c8 100644
--- a/drivers/usb/input/mtouchusb.c
+++ b/drivers/usb/input/mtouchusb.c
@@ -164,7 +164,7 @@ static int mtouchusb_alloc_buffers(struct usb_device *udev, struct mtouch_usb *m
164 dbg("%s - called", __FUNCTION__); 164 dbg("%s - called", __FUNCTION__);
165 165
166 mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE, 166 mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE,
167 SLAB_ATOMIC, &mtouch->data_dma); 167 GFP_ATOMIC, &mtouch->data_dma);
168 168
169 if (!mtouch->data) 169 if (!mtouch->data)
170 return -1; 170 return -1;
diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c
index 0bf91778c40d..fea97e5437f8 100644
--- a/drivers/usb/input/powermate.c
+++ b/drivers/usb/input/powermate.c
@@ -277,12 +277,12 @@ static int powermate_input_event(struct input_dev *dev, unsigned int type, unsig
277static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_device *pm) 277static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_device *pm)
278{ 278{
279 pm->data = usb_buffer_alloc(udev, POWERMATE_PAYLOAD_SIZE_MAX, 279 pm->data = usb_buffer_alloc(udev, POWERMATE_PAYLOAD_SIZE_MAX,
280 SLAB_ATOMIC, &pm->data_dma); 280 GFP_ATOMIC, &pm->data_dma);
281 if (!pm->data) 281 if (!pm->data)
282 return -1; 282 return -1;
283 283
284 pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)), 284 pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)),
285 SLAB_ATOMIC, &pm->configcr_dma); 285 GFP_ATOMIC, &pm->configcr_dma);
286 if (!pm->configcr) 286 if (!pm->configcr)
287 return -1; 287 return -1;
288 288
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c
index 05c0d1ca39ab..2a314b065922 100644
--- a/drivers/usb/input/touchkitusb.c
+++ b/drivers/usb/input/touchkitusb.c
@@ -248,7 +248,7 @@ static int touchkit_alloc_buffers(struct usb_device *udev,
248 struct touchkit_usb *touchkit) 248 struct touchkit_usb *touchkit)
249{ 249{
250 touchkit->data = usb_buffer_alloc(udev, TOUCHKIT_REPORT_DATA_SIZE, 250 touchkit->data = usb_buffer_alloc(udev, TOUCHKIT_REPORT_DATA_SIZE,
251 SLAB_ATOMIC, &touchkit->data_dma); 251 GFP_ATOMIC, &touchkit->data_dma);
252 252
253 if (!touchkit->data) 253 if (!touchkit->data)
254 return -1; 254 return -1;
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c
index dac88640eab6..8505824848f6 100644
--- a/drivers/usb/input/usbkbd.c
+++ b/drivers/usb/input/usbkbd.c
@@ -122,7 +122,7 @@ static void usb_kbd_irq(struct urb *urb)
122 memcpy(kbd->old, kbd->new, 8); 122 memcpy(kbd->old, kbd->new, 8);
123 123
124resubmit: 124resubmit:
125 i = usb_submit_urb (urb, SLAB_ATOMIC); 125 i = usb_submit_urb (urb, GFP_ATOMIC);
126 if (i) 126 if (i)
127 err ("can't resubmit intr, %s-%s/input0, status %d", 127 err ("can't resubmit intr, %s-%s/input0, status %d",
128 kbd->usbdev->bus->bus_name, 128 kbd->usbdev->bus->bus_name,
@@ -196,11 +196,11 @@ static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd)
196 return -1; 196 return -1;
197 if (!(kbd->led = usb_alloc_urb(0, GFP_KERNEL))) 197 if (!(kbd->led = usb_alloc_urb(0, GFP_KERNEL)))
198 return -1; 198 return -1;
199 if (!(kbd->new = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &kbd->new_dma))) 199 if (!(kbd->new = usb_buffer_alloc(dev, 8, GFP_ATOMIC, &kbd->new_dma)))
200 return -1; 200 return -1;
201 if (!(kbd->cr = usb_buffer_alloc(dev, sizeof(struct usb_ctrlrequest), SLAB_ATOMIC, &kbd->cr_dma))) 201 if (!(kbd->cr = usb_buffer_alloc(dev, sizeof(struct usb_ctrlrequest), GFP_ATOMIC, &kbd->cr_dma)))
202 return -1; 202 return -1;
203 if (!(kbd->leds = usb_buffer_alloc(dev, 1, SLAB_ATOMIC, &kbd->leds_dma))) 203 if (!(kbd->leds = usb_buffer_alloc(dev, 1, GFP_ATOMIC, &kbd->leds_dma)))
204 return -1; 204 return -1;
205 205
206 return 0; 206 return 0;
diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c
index 68a55642c082..64a33e420cfb 100644
--- a/drivers/usb/input/usbmouse.c
+++ b/drivers/usb/input/usbmouse.c
@@ -86,7 +86,7 @@ static void usb_mouse_irq(struct urb *urb)
86 86
87 input_sync(dev); 87 input_sync(dev);
88resubmit: 88resubmit:
89 status = usb_submit_urb (urb, SLAB_ATOMIC); 89 status = usb_submit_urb (urb, GFP_ATOMIC);
90 if (status) 90 if (status)
91 err ("can't resubmit intr, %s-%s/input0, status %d", 91 err ("can't resubmit intr, %s-%s/input0, status %d",
92 mouse->usbdev->bus->bus_name, 92 mouse->usbdev->bus->bus_name,
@@ -137,7 +137,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
137 if (!mouse || !input_dev) 137 if (!mouse || !input_dev)
138 goto fail1; 138 goto fail1;
139 139
140 mouse->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &mouse->data_dma); 140 mouse->data = usb_buffer_alloc(dev, 8, GFP_ATOMIC, &mouse->data_dma);
141 if (!mouse->data) 141 if (!mouse->data)
142 goto fail1; 142 goto fail1;
143 143
diff --git a/drivers/usb/input/usbtouchscreen.c b/drivers/usb/input/usbtouchscreen.c
index 49704d4ed0e2..7f3c57da9bc0 100644
--- a/drivers/usb/input/usbtouchscreen.c
+++ b/drivers/usb/input/usbtouchscreen.c
@@ -680,7 +680,7 @@ static int usbtouch_probe(struct usb_interface *intf,
680 type->process_pkt = usbtouch_process_pkt; 680 type->process_pkt = usbtouch_process_pkt;
681 681
682 usbtouch->data = usb_buffer_alloc(udev, type->rept_size, 682 usbtouch->data = usb_buffer_alloc(udev, type->rept_size,
683 SLAB_KERNEL, &usbtouch->data_dma); 683 GFP_KERNEL, &usbtouch->data_dma);
684 if (!usbtouch->data) 684 if (!usbtouch->data)
685 goto out_free; 685 goto out_free;
686 686
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c
index df97e5c803f9..e4bc76ebc835 100644
--- a/drivers/usb/input/xpad.c
+++ b/drivers/usb/input/xpad.c
@@ -325,7 +325,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
325 goto fail1; 325 goto fail1;
326 326
327 xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN, 327 xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN,
328 SLAB_ATOMIC, &xpad->idata_dma); 328 GFP_ATOMIC, &xpad->idata_dma);
329 if (!xpad->idata) 329 if (!xpad->idata)
330 goto fail1; 330 goto fail1;
331 331
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c
index 2268ca311ade..caff8e6d7448 100644
--- a/drivers/usb/input/yealink.c
+++ b/drivers/usb/input/yealink.c
@@ -874,17 +874,17 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
874 874
875 /* allocate usb buffers */ 875 /* allocate usb buffers */
876 yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN, 876 yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN,
877 SLAB_ATOMIC, &yld->irq_dma); 877 GFP_ATOMIC, &yld->irq_dma);
878 if (yld->irq_data == NULL) 878 if (yld->irq_data == NULL)
879 return usb_cleanup(yld, -ENOMEM); 879 return usb_cleanup(yld, -ENOMEM);
880 880
881 yld->ctl_data = usb_buffer_alloc(udev, USB_PKT_LEN, 881 yld->ctl_data = usb_buffer_alloc(udev, USB_PKT_LEN,
882 SLAB_ATOMIC, &yld->ctl_dma); 882 GFP_ATOMIC, &yld->ctl_dma);
883 if (!yld->ctl_data) 883 if (!yld->ctl_data)
884 return usb_cleanup(yld, -ENOMEM); 884 return usb_cleanup(yld, -ENOMEM);
885 885
886 yld->ctl_req = usb_buffer_alloc(udev, sizeof(*(yld->ctl_req)), 886 yld->ctl_req = usb_buffer_alloc(udev, sizeof(*(yld->ctl_req)),
887 SLAB_ATOMIC, &yld->ctl_req_dma); 887 GFP_ATOMIC, &yld->ctl_req_dma);
888 if (yld->ctl_req == NULL) 888 if (yld->ctl_req == NULL)
889 return usb_cleanup(yld, -ENOMEM); 889 return usb_cleanup(yld, -ENOMEM);
890 890
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index ba30ca6a14aa..02cbb7fff24f 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -76,7 +76,7 @@ struct appledisplay {
76 char *urbdata; /* interrupt URB data buffer */ 76 char *urbdata; /* interrupt URB data buffer */
77 char *msgdata; /* control message data buffer */ 77 char *msgdata; /* control message data buffer */
78 78
79 struct work_struct work; 79 struct delayed_work work;
80 int button_pressed; 80 int button_pressed;
81 spinlock_t lock; 81 spinlock_t lock;
82}; 82};
@@ -117,7 +117,7 @@ static void appledisplay_complete(struct urb *urb)
117 case ACD_BTN_BRIGHT_UP: 117 case ACD_BTN_BRIGHT_UP:
118 case ACD_BTN_BRIGHT_DOWN: 118 case ACD_BTN_BRIGHT_DOWN:
119 pdata->button_pressed = 1; 119 pdata->button_pressed = 1;
120 queue_work(wq, &pdata->work); 120 queue_delayed_work(wq, &pdata->work, 0);
121 break; 121 break;
122 case ACD_BTN_NONE: 122 case ACD_BTN_NONE:
123 default: 123 default:
@@ -184,9 +184,10 @@ static struct backlight_properties appledisplay_bl_data = {
184 .max_brightness = 0xFF 184 .max_brightness = 0xFF
185}; 185};
186 186
187static void appledisplay_work(void *private) 187static void appledisplay_work(struct work_struct *work)
188{ 188{
189 struct appledisplay *pdata = private; 189 struct appledisplay *pdata =
190 container_of(work, struct appledisplay, work.work);
190 int retval; 191 int retval;
191 192
192 up(&pdata->bd->sem); 193 up(&pdata->bd->sem);
@@ -238,7 +239,7 @@ static int appledisplay_probe(struct usb_interface *iface,
238 pdata->udev = udev; 239 pdata->udev = udev;
239 240
240 spin_lock_init(&pdata->lock); 241 spin_lock_init(&pdata->lock);
241 INIT_WORK(&pdata->work, appledisplay_work, pdata); 242 INIT_DELAYED_WORK(&pdata->work, appledisplay_work);
242 243
243 /* Allocate buffer for control messages */ 244 /* Allocate buffer for control messages */
244 pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL); 245 pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL);
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
index cb0ba3107d7f..18b1925032a8 100644
--- a/drivers/usb/misc/ftdi-elan.c
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -156,9 +156,9 @@ struct usb_ftdi {
156 struct usb_device *udev; 156 struct usb_device *udev;
157 struct usb_interface *interface; 157 struct usb_interface *interface;
158 struct usb_class_driver *class; 158 struct usb_class_driver *class;
159 struct work_struct status_work; 159 struct delayed_work status_work;
160 struct work_struct command_work; 160 struct delayed_work command_work;
161 struct work_struct respond_work; 161 struct delayed_work respond_work;
162 struct u132_platform_data platform_data; 162 struct u132_platform_data platform_data;
163 struct resource resources[0]; 163 struct resource resources[0];
164 struct platform_device platform_dev; 164 struct platform_device platform_dev;
@@ -210,23 +210,14 @@ static void ftdi_elan_init_kref(struct usb_ftdi *ftdi)
210 210
211static void ftdi_status_requeue_work(struct usb_ftdi *ftdi, unsigned int delta) 211static void ftdi_status_requeue_work(struct usb_ftdi *ftdi, unsigned int delta)
212{ 212{
213 if (delta > 0) { 213 if (!queue_delayed_work(status_queue, &ftdi->status_work, delta))
214 if (queue_delayed_work(status_queue, &ftdi->status_work, delta)) 214 kref_put(&ftdi->kref, ftdi_elan_delete);
215 return;
216 } else if (queue_work(status_queue, &ftdi->status_work))
217 return;
218 kref_put(&ftdi->kref, ftdi_elan_delete);
219 return;
220} 215}
221 216
222static void ftdi_status_queue_work(struct usb_ftdi *ftdi, unsigned int delta) 217static void ftdi_status_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
223{ 218{
224 if (delta > 0) { 219 if (queue_delayed_work(status_queue, &ftdi->status_work, delta))
225 if (queue_delayed_work(status_queue, &ftdi->status_work, delta)) 220 kref_get(&ftdi->kref);
226 kref_get(&ftdi->kref);
227 } else if (queue_work(status_queue, &ftdi->status_work))
228 kref_get(&ftdi->kref);
229 return;
230} 221}
231 222
232static void ftdi_status_cancel_work(struct usb_ftdi *ftdi) 223static void ftdi_status_cancel_work(struct usb_ftdi *ftdi)
@@ -237,25 +228,14 @@ static void ftdi_status_cancel_work(struct usb_ftdi *ftdi)
237 228
238static void ftdi_command_requeue_work(struct usb_ftdi *ftdi, unsigned int delta) 229static void ftdi_command_requeue_work(struct usb_ftdi *ftdi, unsigned int delta)
239{ 230{
240 if (delta > 0) { 231 if (!queue_delayed_work(command_queue, &ftdi->command_work, delta))
241 if (queue_delayed_work(command_queue, &ftdi->command_work, 232 kref_put(&ftdi->kref, ftdi_elan_delete);
242 delta))
243 return;
244 } else if (queue_work(command_queue, &ftdi->command_work))
245 return;
246 kref_put(&ftdi->kref, ftdi_elan_delete);
247 return;
248} 233}
249 234
250static void ftdi_command_queue_work(struct usb_ftdi *ftdi, unsigned int delta) 235static void ftdi_command_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
251{ 236{
252 if (delta > 0) { 237 if (queue_delayed_work(command_queue, &ftdi->command_work, delta))
253 if (queue_delayed_work(command_queue, &ftdi->command_work, 238 kref_get(&ftdi->kref);
254 delta))
255 kref_get(&ftdi->kref);
256 } else if (queue_work(command_queue, &ftdi->command_work))
257 kref_get(&ftdi->kref);
258 return;
259} 239}
260 240
261static void ftdi_command_cancel_work(struct usb_ftdi *ftdi) 241static void ftdi_command_cancel_work(struct usb_ftdi *ftdi)
@@ -267,25 +247,14 @@ static void ftdi_command_cancel_work(struct usb_ftdi *ftdi)
267static void ftdi_response_requeue_work(struct usb_ftdi *ftdi, 247static void ftdi_response_requeue_work(struct usb_ftdi *ftdi,
268 unsigned int delta) 248 unsigned int delta)
269{ 249{
270 if (delta > 0) { 250 if (!queue_delayed_work(respond_queue, &ftdi->respond_work, delta))
271 if (queue_delayed_work(respond_queue, &ftdi->respond_work, 251 kref_put(&ftdi->kref, ftdi_elan_delete);
272 delta))
273 return;
274 } else if (queue_work(respond_queue, &ftdi->respond_work))
275 return;
276 kref_put(&ftdi->kref, ftdi_elan_delete);
277 return;
278} 252}
279 253
280static void ftdi_respond_queue_work(struct usb_ftdi *ftdi, unsigned int delta) 254static void ftdi_respond_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
281{ 255{
282 if (delta > 0) { 256 if (queue_delayed_work(respond_queue, &ftdi->respond_work, delta))
283 if (queue_delayed_work(respond_queue, &ftdi->respond_work, 257 kref_get(&ftdi->kref);
284 delta))
285 kref_get(&ftdi->kref);
286 } else if (queue_work(respond_queue, &ftdi->respond_work))
287 kref_get(&ftdi->kref);
288 return;
289} 258}
290 259
291static void ftdi_response_cancel_work(struct usb_ftdi *ftdi) 260static void ftdi_response_cancel_work(struct usb_ftdi *ftdi)
@@ -475,9 +444,11 @@ static void ftdi_elan_kick_command_queue(struct usb_ftdi *ftdi)
475 return; 444 return;
476} 445}
477 446
478static void ftdi_elan_command_work(void *data) 447static void ftdi_elan_command_work(struct work_struct *work)
479{ 448{
480 struct usb_ftdi *ftdi = data; 449 struct usb_ftdi *ftdi =
450 container_of(work, struct usb_ftdi, command_work.work);
451
481 if (ftdi->disconnected > 0) { 452 if (ftdi->disconnected > 0) {
482 ftdi_elan_put_kref(ftdi); 453 ftdi_elan_put_kref(ftdi);
483 return; 454 return;
@@ -500,9 +471,10 @@ static void ftdi_elan_kick_respond_queue(struct usb_ftdi *ftdi)
500 return; 471 return;
501} 472}
502 473
503static void ftdi_elan_respond_work(void *data) 474static void ftdi_elan_respond_work(struct work_struct *work)
504{ 475{
505 struct usb_ftdi *ftdi = data; 476 struct usb_ftdi *ftdi =
477 container_of(work, struct usb_ftdi, respond_work.work);
506 if (ftdi->disconnected > 0) { 478 if (ftdi->disconnected > 0) {
507 ftdi_elan_put_kref(ftdi); 479 ftdi_elan_put_kref(ftdi);
508 return; 480 return;
@@ -534,9 +506,10 @@ static void ftdi_elan_respond_work(void *data)
534* after the FTDI has been synchronized 506* after the FTDI has been synchronized
535* 507*
536*/ 508*/
537static void ftdi_elan_status_work(void *data) 509static void ftdi_elan_status_work(struct work_struct *work)
538{ 510{
539 struct usb_ftdi *ftdi = data; 511 struct usb_ftdi *ftdi =
512 container_of(work, struct usb_ftdi, status_work.work);
540 int work_delay_in_msec = 0; 513 int work_delay_in_msec = 0;
541 if (ftdi->disconnected > 0) { 514 if (ftdi->disconnected > 0) {
542 ftdi_elan_put_kref(ftdi); 515 ftdi_elan_put_kref(ftdi);
@@ -2677,12 +2650,9 @@ static int ftdi_elan_probe(struct usb_interface *interface,
2677 ftdi->class = NULL; 2650 ftdi->class = NULL;
2678 dev_info(&ftdi->udev->dev, "USB FDTI=%p ELAN interface %d now a" 2651 dev_info(&ftdi->udev->dev, "USB FDTI=%p ELAN interface %d now a"
2679 "ctivated\n", ftdi, iface_desc->desc.bInterfaceNumber); 2652 "ctivated\n", ftdi, iface_desc->desc.bInterfaceNumber);
2680 INIT_WORK(&ftdi->status_work, ftdi_elan_status_work, 2653 INIT_DELAYED_WORK(&ftdi->status_work, ftdi_elan_status_work);
2681 (void *)ftdi); 2654 INIT_DELAYED_WORK(&ftdi->command_work, ftdi_elan_command_work);
2682 INIT_WORK(&ftdi->command_work, ftdi_elan_command_work, 2655 INIT_DELAYED_WORK(&ftdi->respond_work, ftdi_elan_respond_work);
2683 (void *)ftdi);
2684 INIT_WORK(&ftdi->respond_work, ftdi_elan_respond_work,
2685 (void *)ftdi);
2686 ftdi_status_queue_work(ftdi, msecs_to_jiffies(3 *1000)); 2656 ftdi_status_queue_work(ftdi, msecs_to_jiffies(3 *1000));
2687 return 0; 2657 return 0;
2688 } else { 2658 } else {
diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c
index 9110793f81d3..371bf2b1197d 100644
--- a/drivers/usb/misc/phidgetkit.c
+++ b/drivers/usb/misc/phidgetkit.c
@@ -81,8 +81,8 @@ struct interfacekit {
81 unsigned char *data; 81 unsigned char *data;
82 dma_addr_t data_dma; 82 dma_addr_t data_dma;
83 83
84 struct work_struct do_notify; 84 struct delayed_work do_notify;
85 struct work_struct do_resubmit; 85 struct delayed_work do_resubmit;
86 unsigned long input_events; 86 unsigned long input_events;
87 unsigned long sensor_events; 87 unsigned long sensor_events;
88}; 88};
@@ -374,19 +374,20 @@ static void interfacekit_irq(struct urb *urb)
374 } 374 }
375 375
376 if (kit->input_events || kit->sensor_events) 376 if (kit->input_events || kit->sensor_events)
377 schedule_work(&kit->do_notify); 377 schedule_delayed_work(&kit->do_notify, 0);
378 378
379resubmit: 379resubmit:
380 status = usb_submit_urb(urb, SLAB_ATOMIC); 380 status = usb_submit_urb(urb, GFP_ATOMIC);
381 if (status) 381 if (status)
382 err("can't resubmit intr, %s-%s/interfacekit0, status %d", 382 err("can't resubmit intr, %s-%s/interfacekit0, status %d",
383 kit->udev->bus->bus_name, 383 kit->udev->bus->bus_name,
384 kit->udev->devpath, status); 384 kit->udev->devpath, status);
385} 385}
386 386
387static void do_notify(void *data) 387static void do_notify(struct work_struct *work)
388{ 388{
389 struct interfacekit *kit = data; 389 struct interfacekit *kit =
390 container_of(work, struct interfacekit, do_notify.work);
390 int i; 391 int i;
391 char sysfs_file[8]; 392 char sysfs_file[8];
392 393
@@ -405,9 +406,11 @@ static void do_notify(void *data)
405 } 406 }
406} 407}
407 408
408static void do_resubmit(void *data) 409static void do_resubmit(struct work_struct *work)
409{ 410{
410 set_outputs(data); 411 struct interfacekit *kit =
412 container_of(work, struct interfacekit, do_resubmit.work);
413 set_outputs(kit);
411} 414}
412 415
413#define show_set_output(value) \ 416#define show_set_output(value) \
@@ -565,7 +568,7 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
565 568
566 kit->dev_no = -1; 569 kit->dev_no = -1;
567 kit->ifkit = ifkit; 570 kit->ifkit = ifkit;
568 kit->data = usb_buffer_alloc(dev, URB_INT_SIZE, SLAB_ATOMIC, &kit->data_dma); 571 kit->data = usb_buffer_alloc(dev, URB_INT_SIZE, GFP_ATOMIC, &kit->data_dma);
569 if (!kit->data) 572 if (!kit->data)
570 goto out; 573 goto out;
571 574
@@ -575,8 +578,8 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
575 578
576 kit->udev = usb_get_dev(dev); 579 kit->udev = usb_get_dev(dev);
577 kit->intf = intf; 580 kit->intf = intf;
578 INIT_WORK(&kit->do_notify, do_notify, kit); 581 INIT_DELAYED_WORK(&kit->do_notify, do_notify);
579 INIT_WORK(&kit->do_resubmit, do_resubmit, kit); 582 INIT_DELAYED_WORK(&kit->do_resubmit, do_resubmit);
580 usb_fill_int_urb(kit->irq, kit->udev, pipe, kit->data, 583 usb_fill_int_urb(kit->irq, kit->udev, pipe, kit->data,
581 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp, 584 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp,
582 interfacekit_irq, kit, endpoint->bInterval); 585 interfacekit_irq, kit, endpoint->bInterval);
diff --git a/drivers/usb/misc/phidgetmotorcontrol.c b/drivers/usb/misc/phidgetmotorcontrol.c
index c3469b0a67c2..5727e1ea2f91 100644
--- a/drivers/usb/misc/phidgetmotorcontrol.c
+++ b/drivers/usb/misc/phidgetmotorcontrol.c
@@ -41,7 +41,7 @@ struct motorcontrol {
41 unsigned char *data; 41 unsigned char *data;
42 dma_addr_t data_dma; 42 dma_addr_t data_dma;
43 43
44 struct work_struct do_notify; 44 struct delayed_work do_notify;
45 unsigned long input_events; 45 unsigned long input_events;
46 unsigned long speed_events; 46 unsigned long speed_events;
47 unsigned long exceed_events; 47 unsigned long exceed_events;
@@ -148,10 +148,10 @@ static void motorcontrol_irq(struct urb *urb)
148 set_bit(1, &mc->exceed_events); 148 set_bit(1, &mc->exceed_events);
149 149
150 if (mc->input_events || mc->exceed_events || mc->speed_events) 150 if (mc->input_events || mc->exceed_events || mc->speed_events)
151 schedule_work(&mc->do_notify); 151 schedule_delayed_work(&mc->do_notify, 0);
152 152
153resubmit: 153resubmit:
154 status = usb_submit_urb(urb, SLAB_ATOMIC); 154 status = usb_submit_urb(urb, GFP_ATOMIC);
155 if (status) 155 if (status)
156 dev_err(&mc->intf->dev, 156 dev_err(&mc->intf->dev,
157 "can't resubmit intr, %s-%s/motorcontrol0, status %d", 157 "can't resubmit intr, %s-%s/motorcontrol0, status %d",
@@ -159,9 +159,10 @@ resubmit:
159 mc->udev->devpath, status); 159 mc->udev->devpath, status);
160} 160}
161 161
162static void do_notify(void *data) 162static void do_notify(struct work_struct *work)
163{ 163{
164 struct motorcontrol *mc = data; 164 struct motorcontrol *mc =
165 container_of(work, struct motorcontrol, do_notify.work);
165 int i; 166 int i;
166 char sysfs_file[8]; 167 char sysfs_file[8];
167 168
@@ -337,7 +338,7 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic
337 goto out; 338 goto out;
338 339
339 mc->dev_no = -1; 340 mc->dev_no = -1;
340 mc->data = usb_buffer_alloc(dev, URB_INT_SIZE, SLAB_ATOMIC, &mc->data_dma); 341 mc->data = usb_buffer_alloc(dev, URB_INT_SIZE, GFP_ATOMIC, &mc->data_dma);
341 if (!mc->data) 342 if (!mc->data)
342 goto out; 343 goto out;
343 344
@@ -348,7 +349,7 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic
348 mc->udev = usb_get_dev(dev); 349 mc->udev = usb_get_dev(dev);
349 mc->intf = intf; 350 mc->intf = intf;
350 mc->acceleration[0] = mc->acceleration[1] = 10; 351 mc->acceleration[0] = mc->acceleration[1] = 10;
351 INIT_WORK(&mc->do_notify, do_notify, mc); 352 INIT_DELAYED_WORK(&mc->do_notify, do_notify);
352 usb_fill_int_urb(mc->irq, mc->udev, pipe, mc->data, 353 usb_fill_int_urb(mc->irq, mc->udev, pipe, mc->data,
353 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp, 354 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp,
354 motorcontrol_irq, mc, endpoint->bInterval); 355 motorcontrol_irq, mc, endpoint->bInterval);
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 194065dbb51f..fb321864a92d 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -213,7 +213,7 @@ static struct urb *simple_alloc_urb (
213 213
214 if (bytes < 0) 214 if (bytes < 0)
215 return NULL; 215 return NULL;
216 urb = usb_alloc_urb (0, SLAB_KERNEL); 216 urb = usb_alloc_urb (0, GFP_KERNEL);
217 if (!urb) 217 if (!urb)
218 return urb; 218 return urb;
219 usb_fill_bulk_urb (urb, udev, pipe, NULL, bytes, simple_callback, NULL); 219 usb_fill_bulk_urb (urb, udev, pipe, NULL, bytes, simple_callback, NULL);
@@ -223,7 +223,7 @@ static struct urb *simple_alloc_urb (
223 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; 223 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
224 if (usb_pipein (pipe)) 224 if (usb_pipein (pipe))
225 urb->transfer_flags |= URB_SHORT_NOT_OK; 225 urb->transfer_flags |= URB_SHORT_NOT_OK;
226 urb->transfer_buffer = usb_buffer_alloc (udev, bytes, SLAB_KERNEL, 226 urb->transfer_buffer = usb_buffer_alloc (udev, bytes, GFP_KERNEL,
227 &urb->transfer_dma); 227 &urb->transfer_dma);
228 if (!urb->transfer_buffer) { 228 if (!urb->transfer_buffer) {
229 usb_free_urb (urb); 229 usb_free_urb (urb);
@@ -315,7 +315,7 @@ static int simple_io (
315 init_completion (&completion); 315 init_completion (&completion);
316 if (usb_pipeout (urb->pipe)) 316 if (usb_pipeout (urb->pipe))
317 simple_fill_buf (urb); 317 simple_fill_buf (urb);
318 if ((retval = usb_submit_urb (urb, SLAB_KERNEL)) != 0) 318 if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0)
319 break; 319 break;
320 320
321 /* NOTE: no timeouts; can't be broken out of by interrupt */ 321 /* NOTE: no timeouts; can't be broken out of by interrupt */
@@ -374,7 +374,7 @@ alloc_sglist (int nents, int max, int vary)
374 unsigned i; 374 unsigned i;
375 unsigned size = max; 375 unsigned size = max;
376 376
377 sg = kmalloc (nents * sizeof *sg, SLAB_KERNEL); 377 sg = kmalloc (nents * sizeof *sg, GFP_KERNEL);
378 if (!sg) 378 if (!sg)
379 return NULL; 379 return NULL;
380 380
@@ -382,7 +382,7 @@ alloc_sglist (int nents, int max, int vary)
382 char *buf; 382 char *buf;
383 unsigned j; 383 unsigned j;
384 384
385 buf = kzalloc (size, SLAB_KERNEL); 385 buf = kzalloc (size, GFP_KERNEL);
386 if (!buf) { 386 if (!buf) {
387 free_sglist (sg, i); 387 free_sglist (sg, i);
388 return NULL; 388 return NULL;
@@ -428,7 +428,7 @@ static int perform_sglist (
428 (udev->speed == USB_SPEED_HIGH) 428 (udev->speed == USB_SPEED_HIGH)
429 ? (INTERRUPT_RATE << 3) 429 ? (INTERRUPT_RATE << 3)
430 : INTERRUPT_RATE, 430 : INTERRUPT_RATE,
431 sg, nents, 0, SLAB_KERNEL); 431 sg, nents, 0, GFP_KERNEL);
432 432
433 if (retval) 433 if (retval)
434 break; 434 break;
@@ -819,7 +819,7 @@ error:
819 819
820 /* resubmit if we need to, else mark this as done */ 820 /* resubmit if we need to, else mark this as done */
821 if ((status == 0) && (ctx->pending < ctx->count)) { 821 if ((status == 0) && (ctx->pending < ctx->count)) {
822 if ((status = usb_submit_urb (urb, SLAB_ATOMIC)) != 0) { 822 if ((status = usb_submit_urb (urb, GFP_ATOMIC)) != 0) {
823 dbg ("can't resubmit ctrl %02x.%02x, err %d", 823 dbg ("can't resubmit ctrl %02x.%02x, err %d",
824 reqp->bRequestType, reqp->bRequest, status); 824 reqp->bRequestType, reqp->bRequest, status);
825 urb->dev = NULL; 825 urb->dev = NULL;
@@ -855,7 +855,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
855 * as with bulk/intr sglists, sglen is the queue depth; it also 855 * as with bulk/intr sglists, sglen is the queue depth; it also
856 * controls which subtests run (more tests than sglen) or rerun. 856 * controls which subtests run (more tests than sglen) or rerun.
857 */ 857 */
858 urb = kcalloc(param->sglen, sizeof(struct urb *), SLAB_KERNEL); 858 urb = kcalloc(param->sglen, sizeof(struct urb *), GFP_KERNEL);
859 if (!urb) 859 if (!urb)
860 return -ENOMEM; 860 return -ENOMEM;
861 for (i = 0; i < param->sglen; i++) { 861 for (i = 0; i < param->sglen; i++) {
@@ -981,7 +981,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
981 if (!u) 981 if (!u)
982 goto cleanup; 982 goto cleanup;
983 983
984 reqp = usb_buffer_alloc (udev, sizeof *reqp, SLAB_KERNEL, 984 reqp = usb_buffer_alloc (udev, sizeof *reqp, GFP_KERNEL,
985 &u->setup_dma); 985 &u->setup_dma);
986 if (!reqp) 986 if (!reqp)
987 goto cleanup; 987 goto cleanup;
@@ -999,7 +999,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
999 context.urb = urb; 999 context.urb = urb;
1000 spin_lock_irq (&context.lock); 1000 spin_lock_irq (&context.lock);
1001 for (i = 0; i < param->sglen; i++) { 1001 for (i = 0; i < param->sglen; i++) {
1002 context.status = usb_submit_urb (urb [i], SLAB_ATOMIC); 1002 context.status = usb_submit_urb (urb [i], GFP_ATOMIC);
1003 if (context.status != 0) { 1003 if (context.status != 0) {
1004 dbg ("can't submit urb[%d], status %d", 1004 dbg ("can't submit urb[%d], status %d",
1005 i, context.status); 1005 i, context.status);
@@ -1041,7 +1041,7 @@ static void unlink1_callback (struct urb *urb)
1041 1041
1042 // we "know" -EPIPE (stall) never happens 1042 // we "know" -EPIPE (stall) never happens
1043 if (!status) 1043 if (!status)
1044 status = usb_submit_urb (urb, SLAB_ATOMIC); 1044 status = usb_submit_urb (urb, GFP_ATOMIC);
1045 if (status) { 1045 if (status) {
1046 urb->status = status; 1046 urb->status = status;
1047 complete ((struct completion *) urb->context); 1047 complete ((struct completion *) urb->context);
@@ -1067,7 +1067,7 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
1067 * FIXME want additional tests for when endpoint is STALLing 1067 * FIXME want additional tests for when endpoint is STALLing
1068 * due to errors, or is just NAKing requests. 1068 * due to errors, or is just NAKing requests.
1069 */ 1069 */
1070 if ((retval = usb_submit_urb (urb, SLAB_KERNEL)) != 0) { 1070 if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) {
1071 dev_dbg (&dev->intf->dev, "submit fail %d\n", retval); 1071 dev_dbg (&dev->intf->dev, "submit fail %d\n", retval);
1072 return retval; 1072 return retval;
1073 } 1073 }
@@ -1251,7 +1251,7 @@ static int ctrl_out (struct usbtest_dev *dev,
1251 if (length < 1 || length > 0xffff || vary >= length) 1251 if (length < 1 || length > 0xffff || vary >= length)
1252 return -EINVAL; 1252 return -EINVAL;
1253 1253
1254 buf = kmalloc(length, SLAB_KERNEL); 1254 buf = kmalloc(length, GFP_KERNEL);
1255 if (!buf) 1255 if (!buf)
1256 return -ENOMEM; 1256 return -ENOMEM;
1257 1257
@@ -1403,7 +1403,7 @@ static struct urb *iso_alloc_urb (
1403 maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11)); 1403 maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11));
1404 packets = (bytes + maxp - 1) / maxp; 1404 packets = (bytes + maxp - 1) / maxp;
1405 1405
1406 urb = usb_alloc_urb (packets, SLAB_KERNEL); 1406 urb = usb_alloc_urb (packets, GFP_KERNEL);
1407 if (!urb) 1407 if (!urb)
1408 return urb; 1408 return urb;
1409 urb->dev = udev; 1409 urb->dev = udev;
@@ -1411,7 +1411,7 @@ static struct urb *iso_alloc_urb (
1411 1411
1412 urb->number_of_packets = packets; 1412 urb->number_of_packets = packets;
1413 urb->transfer_buffer_length = bytes; 1413 urb->transfer_buffer_length = bytes;
1414 urb->transfer_buffer = usb_buffer_alloc (udev, bytes, SLAB_KERNEL, 1414 urb->transfer_buffer = usb_buffer_alloc (udev, bytes, GFP_KERNEL,
1415 &urb->transfer_dma); 1415 &urb->transfer_dma);
1416 if (!urb->transfer_buffer) { 1416 if (!urb->transfer_buffer) {
1417 usb_free_urb (urb); 1417 usb_free_urb (urb);
@@ -1481,7 +1481,7 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,
1481 spin_lock_irq (&context.lock); 1481 spin_lock_irq (&context.lock);
1482 for (i = 0; i < param->sglen; i++) { 1482 for (i = 0; i < param->sglen; i++) {
1483 ++context.pending; 1483 ++context.pending;
1484 status = usb_submit_urb (urbs [i], SLAB_ATOMIC); 1484 status = usb_submit_urb (urbs [i], GFP_ATOMIC);
1485 if (status < 0) { 1485 if (status < 0) {
1486 ERROR (dev, "submit iso[%d], error %d\n", i, status); 1486 ERROR (dev, "submit iso[%d], error %d\n", i, status);
1487 if (i == 0) { 1487 if (i == 0) {
@@ -1900,7 +1900,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1900 } 1900 }
1901#endif 1901#endif
1902 1902
1903 dev = kzalloc(sizeof(*dev), SLAB_KERNEL); 1903 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1904 if (!dev) 1904 if (!dev)
1905 return -ENOMEM; 1905 return -ENOMEM;
1906 info = (struct usbtest_info *) id->driver_info; 1906 info = (struct usbtest_info *) id->driver_info;
@@ -1910,7 +1910,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1910 dev->intf = intf; 1910 dev->intf = intf;
1911 1911
1912 /* cacheline-aligned scratch for i/o */ 1912 /* cacheline-aligned scratch for i/o */
1913 if ((dev->buf = kmalloc (TBUF_SIZE, SLAB_KERNEL)) == NULL) { 1913 if ((dev->buf = kmalloc (TBUF_SIZE, GFP_KERNEL)) == NULL) {
1914 kfree (dev); 1914 kfree (dev);
1915 return -ENOMEM; 1915 return -ENOMEM;
1916 } 1916 }
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index 7a2346c53284..05cf2c9a8f84 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -50,7 +50,7 @@ struct mon_event_text {
50 50
51#define SLAB_NAME_SZ 30 51#define SLAB_NAME_SZ 30
52struct mon_reader_text { 52struct mon_reader_text {
53 kmem_cache_t *e_slab; 53 struct kmem_cache *e_slab;
54 int nevents; 54 int nevents;
55 struct list_head e_list; 55 struct list_head e_list;
56 struct mon_reader r; /* In C, parent class can be placed anywhere */ 56 struct mon_reader r; /* In C, parent class can be placed anywhere */
@@ -63,7 +63,7 @@ struct mon_reader_text {
63 char slab_name[SLAB_NAME_SZ]; 63 char slab_name[SLAB_NAME_SZ];
64}; 64};
65 65
66static void mon_text_ctor(void *, kmem_cache_t *, unsigned long); 66static void mon_text_ctor(void *, struct kmem_cache *, unsigned long);
67 67
68/* 68/*
69 * mon_text_submit 69 * mon_text_submit
@@ -147,7 +147,7 @@ static void mon_text_event(struct mon_reader_text *rp, struct urb *urb,
147 stamp = mon_get_timestamp(); 147 stamp = mon_get_timestamp();
148 148
149 if (rp->nevents >= EVENT_MAX || 149 if (rp->nevents >= EVENT_MAX ||
150 (ep = kmem_cache_alloc(rp->e_slab, SLAB_ATOMIC)) == NULL) { 150 (ep = kmem_cache_alloc(rp->e_slab, GFP_ATOMIC)) == NULL) {
151 rp->r.m_bus->cnt_text_lost++; 151 rp->r.m_bus->cnt_text_lost++;
152 return; 152 return;
153 } 153 }
@@ -188,7 +188,7 @@ static void mon_text_error(void *data, struct urb *urb, int error)
188 struct mon_event_text *ep; 188 struct mon_event_text *ep;
189 189
190 if (rp->nevents >= EVENT_MAX || 190 if (rp->nevents >= EVENT_MAX ||
191 (ep = kmem_cache_alloc(rp->e_slab, SLAB_ATOMIC)) == NULL) { 191 (ep = kmem_cache_alloc(rp->e_slab, GFP_ATOMIC)) == NULL) {
192 rp->r.m_bus->cnt_text_lost++; 192 rp->r.m_bus->cnt_text_lost++;
193 return; 193 return;
194 } 194 }
@@ -450,7 +450,7 @@ const struct file_operations mon_fops_text = {
450/* 450/*
451 * Slab interface: constructor. 451 * Slab interface: constructor.
452 */ 452 */
453static void mon_text_ctor(void *mem, kmem_cache_t *slab, unsigned long sflags) 453static void mon_text_ctor(void *mem, struct kmem_cache *slab, unsigned long sflags)
454{ 454{
455 /* 455 /*
456 * Nothing to initialize. No, really! 456 * Nothing to initialize. No, really!
diff --git a/drivers/usb/net/catc.c b/drivers/usb/net/catc.c
index 907b820a5faf..4852012735f6 100644
--- a/drivers/usb/net/catc.c
+++ b/drivers/usb/net/catc.c
@@ -345,7 +345,7 @@ static void catc_irq_done(struct urb *urb)
345 } 345 }
346 } 346 }
347resubmit: 347resubmit:
348 status = usb_submit_urb (urb, SLAB_ATOMIC); 348 status = usb_submit_urb (urb, GFP_ATOMIC);
349 if (status) 349 if (status)
350 err ("can't resubmit intr, %s-%s, status %d", 350 err ("can't resubmit intr, %s-%s, status %d",
351 catc->usbdev->bus->bus_name, 351 catc->usbdev->bus->bus_name,
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
index 7c906a43e497..fa78326d0bf0 100644
--- a/drivers/usb/net/kaweth.c
+++ b/drivers/usb/net/kaweth.c
@@ -222,7 +222,7 @@ struct kaweth_device
222 int suspend_lowmem_ctrl; 222 int suspend_lowmem_ctrl;
223 int linkstate; 223 int linkstate;
224 int opened; 224 int opened;
225 struct work_struct lowmem_work; 225 struct delayed_work lowmem_work;
226 226
227 struct usb_device *dev; 227 struct usb_device *dev;
228 struct net_device *net; 228 struct net_device *net;
@@ -530,9 +530,10 @@ resubmit:
530 kaweth_resubmit_int_urb(kaweth, GFP_ATOMIC); 530 kaweth_resubmit_int_urb(kaweth, GFP_ATOMIC);
531} 531}
532 532
533static void kaweth_resubmit_tl(void *d) 533static void kaweth_resubmit_tl(struct work_struct *work)
534{ 534{
535 struct kaweth_device *kaweth = (struct kaweth_device *)d; 535 struct kaweth_device *kaweth =
536 container_of(work, struct kaweth_device, lowmem_work.work);
536 537
537 if (IS_BLOCKED(kaweth->status)) 538 if (IS_BLOCKED(kaweth->status))
538 return; 539 return;
@@ -1126,7 +1127,7 @@ err_fw:
1126 1127
1127 /* kaweth is zeroed as part of alloc_netdev */ 1128 /* kaweth is zeroed as part of alloc_netdev */
1128 1129
1129 INIT_WORK(&kaweth->lowmem_work, kaweth_resubmit_tl, (void *)kaweth); 1130 INIT_DELAYED_WORK(&kaweth->lowmem_work, kaweth_resubmit_tl);
1130 1131
1131 SET_MODULE_OWNER(netdev); 1132 SET_MODULE_OWNER(netdev);
1132 1133
diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c
index a77410562e12..493635954513 100644
--- a/drivers/usb/net/net1080.c
+++ b/drivers/usb/net/net1080.c
@@ -383,7 +383,7 @@ static void nc_ensure_sync(struct usbnet *dev)
383 int status; 383 int status;
384 384
385 /* Send a flush */ 385 /* Send a flush */
386 urb = usb_alloc_urb(0, SLAB_ATOMIC); 386 urb = usb_alloc_urb(0, GFP_ATOMIC);
387 if (!urb) 387 if (!urb)
388 return; 388 return;
389 389
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
index 69eb0db399df..d48c024cff59 100644
--- a/drivers/usb/net/pegasus.c
+++ b/drivers/usb/net/pegasus.c
@@ -856,7 +856,7 @@ static void intr_callback(struct urb *urb)
856 pegasus->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4]; 856 pegasus->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4];
857 } 857 }
858 858
859 status = usb_submit_urb(urb, SLAB_ATOMIC); 859 status = usb_submit_urb(urb, GFP_ATOMIC);
860 if (status == -ENODEV) 860 if (status == -ENODEV)
861 netif_device_detach(pegasus->net); 861 netif_device_detach(pegasus->net);
862 if (status && netif_msg_timer(pegasus)) 862 if (status && netif_msg_timer(pegasus))
@@ -1281,9 +1281,9 @@ static inline void setup_pegasus_II(pegasus_t * pegasus)
1281static struct workqueue_struct *pegasus_workqueue = NULL; 1281static struct workqueue_struct *pegasus_workqueue = NULL;
1282#define CARRIER_CHECK_DELAY (2 * HZ) 1282#define CARRIER_CHECK_DELAY (2 * HZ)
1283 1283
1284static void check_carrier(void *data) 1284static void check_carrier(struct work_struct *work)
1285{ 1285{
1286 pegasus_t *pegasus = data; 1286 pegasus_t *pegasus = container_of(work, pegasus_t, carrier_check.work);
1287 set_carrier(pegasus->net); 1287 set_carrier(pegasus->net);
1288 if (!(pegasus->flags & PEGASUS_UNPLUG)) { 1288 if (!(pegasus->flags & PEGASUS_UNPLUG)) {
1289 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, 1289 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check,
@@ -1319,7 +1319,7 @@ static int pegasus_probe(struct usb_interface *intf,
1319 1319
1320 tasklet_init(&pegasus->rx_tl, rx_fixup, (unsigned long) pegasus); 1320 tasklet_init(&pegasus->rx_tl, rx_fixup, (unsigned long) pegasus);
1321 1321
1322 INIT_WORK(&pegasus->carrier_check, check_carrier, pegasus); 1322 INIT_DELAYED_WORK(&pegasus->carrier_check, check_carrier);
1323 1323
1324 pegasus->intf = intf; 1324 pegasus->intf = intf;
1325 pegasus->usb = dev; 1325 pegasus->usb = dev;
diff --git a/drivers/usb/net/pegasus.h b/drivers/usb/net/pegasus.h
index 006438069b66..98f6898cae1f 100644
--- a/drivers/usb/net/pegasus.h
+++ b/drivers/usb/net/pegasus.h
@@ -95,7 +95,7 @@ typedef struct pegasus {
95 int dev_index; 95 int dev_index;
96 int intr_interval; 96 int intr_interval;
97 struct tasklet_struct rx_tl; 97 struct tasklet_struct rx_tl;
98 struct work_struct carrier_check; 98 struct delayed_work carrier_check;
99 struct urb *ctrl_urb, *rx_urb, *tx_urb, *intr_urb; 99 struct urb *ctrl_urb, *rx_urb, *tx_urb, *intr_urb;
100 struct sk_buff *rx_pool[RX_SKBS]; 100 struct sk_buff *rx_pool[RX_SKBS];
101 struct sk_buff *rx_skb; 101 struct sk_buff *rx_skb;
diff --git a/drivers/usb/net/rndis_host.c b/drivers/usb/net/rndis_host.c
index c2a28d88ef3c..99f26b3e502f 100644
--- a/drivers/usb/net/rndis_host.c
+++ b/drivers/usb/net/rndis_host.c
@@ -469,7 +469,7 @@ static void rndis_unbind(struct usbnet *dev, struct usb_interface *intf)
469 struct rndis_halt *halt; 469 struct rndis_halt *halt;
470 470
471 /* try to clear any rndis state/activity (no i/o from stack!) */ 471 /* try to clear any rndis state/activity (no i/o from stack!) */
472 halt = kcalloc(1, sizeof *halt, SLAB_KERNEL); 472 halt = kcalloc(1, sizeof *halt, GFP_KERNEL);
473 if (halt) { 473 if (halt) {
474 halt->msg_type = RNDIS_MSG_HALT; 474 halt->msg_type = RNDIS_MSG_HALT;
475 halt->msg_len = ccpu2(sizeof *halt); 475 halt->msg_len = ccpu2(sizeof *halt);
diff --git a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c
index 72171f94ded4..c54235f73cb6 100644
--- a/drivers/usb/net/rtl8150.c
+++ b/drivers/usb/net/rtl8150.c
@@ -587,7 +587,7 @@ static void intr_callback(struct urb *urb)
587 } 587 }
588 588
589resubmit: 589resubmit:
590 status = usb_submit_urb (urb, SLAB_ATOMIC); 590 status = usb_submit_urb (urb, GFP_ATOMIC);
591 if (status == -ENODEV) 591 if (status == -ENODEV)
592 netif_device_detach(dev->netdev); 592 netif_device_detach(dev->netdev);
593 else if (status) 593 else if (status)
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index 7672e11c94c4..6e39e9988259 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -179,9 +179,9 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf)
179 period = max ((int) dev->status->desc.bInterval, 179 period = max ((int) dev->status->desc.bInterval,
180 (dev->udev->speed == USB_SPEED_HIGH) ? 7 : 3); 180 (dev->udev->speed == USB_SPEED_HIGH) ? 7 : 3);
181 181
182 buf = kmalloc (maxp, SLAB_KERNEL); 182 buf = kmalloc (maxp, GFP_KERNEL);
183 if (buf) { 183 if (buf) {
184 dev->interrupt = usb_alloc_urb (0, SLAB_KERNEL); 184 dev->interrupt = usb_alloc_urb (0, GFP_KERNEL);
185 if (!dev->interrupt) { 185 if (!dev->interrupt) {
186 kfree (buf); 186 kfree (buf);
187 return -ENOMEM; 187 return -ENOMEM;
@@ -782,9 +782,10 @@ static struct ethtool_ops usbnet_ethtool_ops = {
782 * especially now that control transfers can be queued. 782 * especially now that control transfers can be queued.
783 */ 783 */
784static void 784static void
785kevent (void *data) 785kevent (struct work_struct *work)
786{ 786{
787 struct usbnet *dev = data; 787 struct usbnet *dev =
788 container_of(work, struct usbnet, kevent);
788 int status; 789 int status;
789 790
790 /* usb_clear_halt() needs a thread context */ 791 /* usb_clear_halt() needs a thread context */
@@ -1146,7 +1147,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1146 skb_queue_head_init (&dev->done); 1147 skb_queue_head_init (&dev->done);
1147 dev->bh.func = usbnet_bh; 1148 dev->bh.func = usbnet_bh;
1148 dev->bh.data = (unsigned long) dev; 1149 dev->bh.data = (unsigned long) dev;
1149 INIT_WORK (&dev->kevent, kevent, dev); 1150 INIT_WORK (&dev->kevent, kevent);
1150 dev->delay.function = usbnet_bh; 1151 dev->delay.function = usbnet_bh;
1151 dev->delay.data = (unsigned long) dev; 1152 dev->delay.data = (unsigned long) dev;
1152 init_timer (&dev->delay); 1153 init_timer (&dev->delay);
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index b1b5707bc99a..86bcf63b6ba5 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -92,6 +92,7 @@ struct aircable_private {
92 struct circ_buf *rx_buf; /* read buffer */ 92 struct circ_buf *rx_buf; /* read buffer */
93 int rx_flags; /* for throttilng */ 93 int rx_flags; /* for throttilng */
94 struct work_struct rx_work; /* work cue for the receiving line */ 94 struct work_struct rx_work; /* work cue for the receiving line */
95 struct usb_serial_port *port; /* USB port with which associated */
95}; 96};
96 97
97/* Private methods */ 98/* Private methods */
@@ -251,10 +252,11 @@ static void aircable_send(struct usb_serial_port *port)
251 schedule_work(&port->work); 252 schedule_work(&port->work);
252} 253}
253 254
254static void aircable_read(void *params) 255static void aircable_read(struct work_struct *work)
255{ 256{
256 struct usb_serial_port *port = params; 257 struct aircable_private *priv =
257 struct aircable_private *priv = usb_get_serial_port_data(port); 258 container_of(work, struct aircable_private, rx_work);
259 struct usb_serial_port *port = priv->port;
258 struct tty_struct *tty; 260 struct tty_struct *tty;
259 unsigned char *data; 261 unsigned char *data;
260 int count; 262 int count;
@@ -349,7 +351,8 @@ static int aircable_attach (struct usb_serial *serial)
349 } 351 }
350 352
351 priv->rx_flags &= ~(THROTTLED | ACTUALLY_THROTTLED); 353 priv->rx_flags &= ~(THROTTLED | ACTUALLY_THROTTLED);
352 INIT_WORK(&priv->rx_work, aircable_read, port); 354 priv->port = port;
355 INIT_WORK(&priv->rx_work, aircable_read);
353 356
354 usb_set_serial_port_data(serial->port[0], priv); 357 usb_set_serial_port_data(serial->port[0], priv);
355 358
@@ -516,7 +519,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
516 package_length - shift); 519 package_length - shift);
517 } 520 }
518 } 521 }
519 aircable_read(port); 522 aircable_read(&priv->rx_work);
520 } 523 }
521 524
522 /* Schedule the next read _if_ we are still open */ 525 /* Schedule the next read _if_ we are still open */
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 5e3ac281a2f8..83d0e21145b0 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -430,13 +430,14 @@ struct digi_port {
430 int dp_in_close; /* close in progress */ 430 int dp_in_close; /* close in progress */
431 wait_queue_head_t dp_close_wait; /* wait queue for close */ 431 wait_queue_head_t dp_close_wait; /* wait queue for close */
432 struct work_struct dp_wakeup_work; 432 struct work_struct dp_wakeup_work;
433 struct usb_serial_port *dp_port;
433}; 434};
434 435
435 436
436/* Local Function Declarations */ 437/* Local Function Declarations */
437 438
438static void digi_wakeup_write( struct usb_serial_port *port ); 439static void digi_wakeup_write( struct usb_serial_port *port );
439static void digi_wakeup_write_lock(void *); 440static void digi_wakeup_write_lock(struct work_struct *work);
440static int digi_write_oob_command( struct usb_serial_port *port, 441static int digi_write_oob_command( struct usb_serial_port *port,
441 unsigned char *buf, int count, int interruptible ); 442 unsigned char *buf, int count, int interruptible );
442static int digi_write_inb_command( struct usb_serial_port *port, 443static int digi_write_inb_command( struct usb_serial_port *port,
@@ -598,11 +599,12 @@ static inline long cond_wait_interruptible_timeout_irqrestore(
598* on writes. 599* on writes.
599*/ 600*/
600 601
601static void digi_wakeup_write_lock(void *arg) 602static void digi_wakeup_write_lock(struct work_struct *work)
602{ 603{
603 struct usb_serial_port *port = arg; 604 struct digi_port *priv =
605 container_of(work, struct digi_port, dp_wakeup_work);
606 struct usb_serial_port *port = priv->dp_port;
604 unsigned long flags; 607 unsigned long flags;
605 struct digi_port *priv = usb_get_serial_port_data(port);
606 608
607 609
608 spin_lock_irqsave( &priv->dp_port_lock, flags ); 610 spin_lock_irqsave( &priv->dp_port_lock, flags );
@@ -1702,8 +1704,8 @@ dbg( "digi_startup: TOP" );
1702 init_waitqueue_head( &priv->dp_flush_wait ); 1704 init_waitqueue_head( &priv->dp_flush_wait );
1703 priv->dp_in_close = 0; 1705 priv->dp_in_close = 0;
1704 init_waitqueue_head( &priv->dp_close_wait ); 1706 init_waitqueue_head( &priv->dp_close_wait );
1705 INIT_WORK(&priv->dp_wakeup_work, 1707 INIT_WORK(&priv->dp_wakeup_work, digi_wakeup_write_lock);
1706 digi_wakeup_write_lock, serial->port[i]); 1708 priv->dp_port = serial->port[i];
1707 1709
1708 /* initialize write wait queue for this port */ 1710 /* initialize write wait queue for this port */
1709 init_waitqueue_head( &serial->port[i]->write_wait ); 1711 init_waitqueue_head( &serial->port[i]->write_wait );
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 89ce2775be15..72e4d48f51e9 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -559,7 +559,8 @@ struct ftdi_private {
559 char prev_status, diff_status; /* Used for TIOCMIWAIT */ 559 char prev_status, diff_status; /* Used for TIOCMIWAIT */
560 __u8 rx_flags; /* receive state flags (throttling) */ 560 __u8 rx_flags; /* receive state flags (throttling) */
561 spinlock_t rx_lock; /* spinlock for receive state */ 561 spinlock_t rx_lock; /* spinlock for receive state */
562 struct work_struct rx_work; 562 struct delayed_work rx_work;
563 struct usb_serial_port *port;
563 int rx_processed; 564 int rx_processed;
564 unsigned long rx_bytes; 565 unsigned long rx_bytes;
565 566
@@ -593,7 +594,7 @@ static int ftdi_write_room (struct usb_serial_port *port);
593static int ftdi_chars_in_buffer (struct usb_serial_port *port); 594static int ftdi_chars_in_buffer (struct usb_serial_port *port);
594static void ftdi_write_bulk_callback (struct urb *urb); 595static void ftdi_write_bulk_callback (struct urb *urb);
595static void ftdi_read_bulk_callback (struct urb *urb); 596static void ftdi_read_bulk_callback (struct urb *urb);
596static void ftdi_process_read (void *param); 597static void ftdi_process_read (struct work_struct *work);
597static void ftdi_set_termios (struct usb_serial_port *port, struct termios * old); 598static void ftdi_set_termios (struct usb_serial_port *port, struct termios * old);
598static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file); 599static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file);
599static int ftdi_tiocmset (struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear); 600static int ftdi_tiocmset (struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear);
@@ -1201,7 +1202,8 @@ static int ftdi_sio_attach (struct usb_serial *serial)
1201 port->read_urb->transfer_buffer_length = BUFSZ; 1202 port->read_urb->transfer_buffer_length = BUFSZ;
1202 } 1203 }
1203 1204
1204 INIT_WORK(&priv->rx_work, ftdi_process_read, port); 1205 INIT_DELAYED_WORK(&priv->rx_work, ftdi_process_read);
1206 priv->port = port;
1205 1207
1206 /* Free port's existing write urb and transfer buffer. */ 1208 /* Free port's existing write urb and transfer buffer. */
1207 if (port->write_urb) { 1209 if (port->write_urb) {
@@ -1640,17 +1642,18 @@ static void ftdi_read_bulk_callback (struct urb *urb)
1640 priv->rx_bytes += countread; 1642 priv->rx_bytes += countread;
1641 spin_unlock_irqrestore(&priv->rx_lock, flags); 1643 spin_unlock_irqrestore(&priv->rx_lock, flags);
1642 1644
1643 ftdi_process_read(port); 1645 ftdi_process_read(&priv->rx_work.work);
1644 1646
1645} /* ftdi_read_bulk_callback */ 1647} /* ftdi_read_bulk_callback */
1646 1648
1647 1649
1648static void ftdi_process_read (void *param) 1650static void ftdi_process_read (struct work_struct *work)
1649{ /* ftdi_process_read */ 1651{ /* ftdi_process_read */
1650 struct usb_serial_port *port = (struct usb_serial_port*)param; 1652 struct ftdi_private *priv =
1653 container_of(work, struct ftdi_private, rx_work.work);
1654 struct usb_serial_port *port = priv->port;
1651 struct urb *urb; 1655 struct urb *urb;
1652 struct tty_struct *tty; 1656 struct tty_struct *tty;
1653 struct ftdi_private *priv;
1654 char error_flag; 1657 char error_flag;
1655 unsigned char *data; 1658 unsigned char *data;
1656 1659
@@ -2179,7 +2182,7 @@ static void ftdi_unthrottle (struct usb_serial_port *port)
2179 spin_unlock_irqrestore(&priv->rx_lock, flags); 2182 spin_unlock_irqrestore(&priv->rx_lock, flags);
2180 2183
2181 if (actually_throttled) 2184 if (actually_throttled)
2182 schedule_work(&priv->rx_work); 2185 schedule_delayed_work(&priv->rx_work, 0);
2183} 2186}
2184 2187
2185static int __init ftdi_init (void) 2188static int __init ftdi_init (void)
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index 909005107ea2..e09a0bfe6231 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -120,6 +120,8 @@ struct keyspan_pda_private {
120 int tx_throttled; 120 int tx_throttled;
121 struct work_struct wakeup_work; 121 struct work_struct wakeup_work;
122 struct work_struct unthrottle_work; 122 struct work_struct unthrottle_work;
123 struct usb_serial *serial;
124 struct usb_serial_port *port;
123}; 125};
124 126
125 127
@@ -175,9 +177,11 @@ static struct usb_device_id id_table_fake_xircom [] = {
175}; 177};
176#endif 178#endif
177 179
178static void keyspan_pda_wakeup_write( struct usb_serial_port *port ) 180static void keyspan_pda_wakeup_write(struct work_struct *work)
179{ 181{
180 182 struct keyspan_pda_private *priv =
183 container_of(work, struct keyspan_pda_private, wakeup_work);
184 struct usb_serial_port *port = priv->port;
181 struct tty_struct *tty = port->tty; 185 struct tty_struct *tty = port->tty;
182 186
183 /* wake up port processes */ 187 /* wake up port processes */
@@ -187,8 +191,11 @@ static void keyspan_pda_wakeup_write( struct usb_serial_port *port )
187 tty_wakeup(tty); 191 tty_wakeup(tty);
188} 192}
189 193
190static void keyspan_pda_request_unthrottle( struct usb_serial *serial ) 194static void keyspan_pda_request_unthrottle(struct work_struct *work)
191{ 195{
196 struct keyspan_pda_private *priv =
197 container_of(work, struct keyspan_pda_private, unthrottle_work);
198 struct usb_serial *serial = priv->serial;
192 int result; 199 int result;
193 200
194 dbg(" request_unthrottle"); 201 dbg(" request_unthrottle");
@@ -765,11 +772,10 @@ static int keyspan_pda_startup (struct usb_serial *serial)
765 return (1); /* error */ 772 return (1); /* error */
766 usb_set_serial_port_data(serial->port[0], priv); 773 usb_set_serial_port_data(serial->port[0], priv);
767 init_waitqueue_head(&serial->port[0]->write_wait); 774 init_waitqueue_head(&serial->port[0]->write_wait);
768 INIT_WORK(&priv->wakeup_work, (void *)keyspan_pda_wakeup_write, 775 INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write);
769 (void *)(serial->port[0])); 776 INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle);
770 INIT_WORK(&priv->unthrottle_work, 777 priv->serial = serial;
771 (void *)keyspan_pda_request_unthrottle, 778 priv->port = serial->port[0];
772 (void *)(serial));
773 return (0); 779 return (0);
774} 780}
775 781
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 82cd15b894b0..70f93b18292f 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -363,7 +363,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
363 363
364 /* Initialising the write urb pool */ 364 /* Initialising the write urb pool */
365 for (j = 0; j < NUM_URBS; ++j) { 365 for (j = 0; j < NUM_URBS; ++j) {
366 urb = usb_alloc_urb(0,SLAB_ATOMIC); 366 urb = usb_alloc_urb(0,GFP_ATOMIC);
367 mos7720_port->write_urb_pool[j] = urb; 367 mos7720_port->write_urb_pool[j] = urb;
368 368
369 if (urb == NULL) { 369 if (urb == NULL) {
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 02c89e10b2cf..5432c6340086 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -826,7 +826,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
826 826
827 /* Initialising the write urb pool */ 827 /* Initialising the write urb pool */
828 for (j = 0; j < NUM_URBS; ++j) { 828 for (j = 0; j < NUM_URBS; ++j) {
829 urb = usb_alloc_urb(0, SLAB_ATOMIC); 829 urb = usb_alloc_urb(0, GFP_ATOMIC);
830 mos7840_port->write_urb_pool[j] = urb; 830 mos7840_port->write_urb_pool[j] = urb;
831 831
832 if (urb == NULL) { 832 if (urb == NULL) {
@@ -2786,7 +2786,7 @@ static int mos7840_startup(struct usb_serial *serial)
2786 i + 1, status); 2786 i + 1, status);
2787 2787
2788 } 2788 }
2789 mos7840_port->control_urb = usb_alloc_urb(0, SLAB_ATOMIC); 2789 mos7840_port->control_urb = usb_alloc_urb(0, GFP_ATOMIC);
2790 mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL); 2790 mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL);
2791 2791
2792 } 2792 }
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index c1257d5292f5..3d5072f14b8d 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -533,9 +533,10 @@ void usb_serial_port_softint(struct usb_serial_port *port)
533 schedule_work(&port->work); 533 schedule_work(&port->work);
534} 534}
535 535
536static void usb_serial_port_work(void *private) 536static void usb_serial_port_work(struct work_struct *work)
537{ 537{
538 struct usb_serial_port *port = private; 538 struct usb_serial_port *port =
539 container_of(work, struct usb_serial_port, work);
539 struct tty_struct *tty; 540 struct tty_struct *tty;
540 541
541 dbg("%s - port %d", __FUNCTION__, port->number); 542 dbg("%s - port %d", __FUNCTION__, port->number);
@@ -799,7 +800,7 @@ int usb_serial_probe(struct usb_interface *interface,
799 port->serial = serial; 800 port->serial = serial;
800 spin_lock_init(&port->lock); 801 spin_lock_init(&port->lock);
801 mutex_init(&port->mutex); 802 mutex_init(&port->mutex);
802 INIT_WORK(&port->work, usb_serial_port_work, port); 803 INIT_WORK(&port->work, usb_serial_port_work);
803 serial->port[i] = port; 804 serial->port[i] = port;
804 } 805 }
805 806
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 4d1cd7aeccd3..154c7d290597 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -227,6 +227,7 @@ struct whiteheat_private {
227 struct list_head rx_urbs_submitted; 227 struct list_head rx_urbs_submitted;
228 struct list_head rx_urb_q; 228 struct list_head rx_urb_q;
229 struct work_struct rx_work; 229 struct work_struct rx_work;
230 struct usb_serial_port *port;
230 struct list_head tx_urbs_free; 231 struct list_head tx_urbs_free;
231 struct list_head tx_urbs_submitted; 232 struct list_head tx_urbs_submitted;
232}; 233};
@@ -241,7 +242,7 @@ static void command_port_read_callback(struct urb *urb);
241static int start_port_read(struct usb_serial_port *port); 242static int start_port_read(struct usb_serial_port *port);
242static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, struct list_head *head); 243static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, struct list_head *head);
243static struct list_head *list_first(struct list_head *head); 244static struct list_head *list_first(struct list_head *head);
244static void rx_data_softint(void *private); 245static void rx_data_softint(struct work_struct *work);
245 246
246static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize); 247static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize);
247static int firm_open(struct usb_serial_port *port); 248static int firm_open(struct usb_serial_port *port);
@@ -424,7 +425,8 @@ static int whiteheat_attach (struct usb_serial *serial)
424 spin_lock_init(&info->lock); 425 spin_lock_init(&info->lock);
425 info->flags = 0; 426 info->flags = 0;
426 info->mcr = 0; 427 info->mcr = 0;
427 INIT_WORK(&info->rx_work, rx_data_softint, port); 428 INIT_WORK(&info->rx_work, rx_data_softint);
429 info->port = port;
428 430
429 INIT_LIST_HEAD(&info->rx_urbs_free); 431 INIT_LIST_HEAD(&info->rx_urbs_free);
430 INIT_LIST_HEAD(&info->rx_urbs_submitted); 432 INIT_LIST_HEAD(&info->rx_urbs_submitted);
@@ -949,7 +951,7 @@ static void whiteheat_unthrottle (struct usb_serial_port *port)
949 spin_unlock_irqrestore(&info->lock, flags); 951 spin_unlock_irqrestore(&info->lock, flags);
950 952
951 if (actually_throttled) 953 if (actually_throttled)
952 rx_data_softint(port); 954 rx_data_softint(&info->rx_work);
953 955
954 return; 956 return;
955} 957}
@@ -1400,10 +1402,11 @@ static struct list_head *list_first(struct list_head *head)
1400} 1402}
1401 1403
1402 1404
1403static void rx_data_softint(void *private) 1405static void rx_data_softint(struct work_struct *work)
1404{ 1406{
1405 struct usb_serial_port *port = (struct usb_serial_port *)private; 1407 struct whiteheat_private *info =
1406 struct whiteheat_private *info = usb_get_serial_port_data(port); 1408 container_of(work, struct whiteheat_private, rx_work);
1409 struct usb_serial_port *port = info->port;
1407 struct tty_struct *tty = port->tty; 1410 struct tty_struct *tty = port->tty;
1408 struct whiteheat_urb_wrap *wrap; 1411 struct whiteheat_urb_wrap *wrap;
1409 struct urb *urb; 1412 struct urb *urb;
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
index 3a158d58441f..e565d3d2ab29 100644
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -76,7 +76,7 @@ static void usb_onetouch_irq(struct urb *urb)
76 input_sync(dev); 76 input_sync(dev);
77 77
78resubmit: 78resubmit:
79 status = usb_submit_urb (urb, SLAB_ATOMIC); 79 status = usb_submit_urb (urb, GFP_ATOMIC);
80 if (status) 80 if (status)
81 err ("can't resubmit intr, %s-%s/input0, status %d", 81 err ("can't resubmit intr, %s-%s/input0, status %d",
82 onetouch->udev->bus->bus_name, 82 onetouch->udev->bus->bus_name,
@@ -154,7 +154,7 @@ int onetouch_connect_input(struct us_data *ss)
154 goto fail1; 154 goto fail1;
155 155
156 onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, 156 onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN,
157 SLAB_ATOMIC, &onetouch->data_dma); 157 GFP_ATOMIC, &onetouch->data_dma);
158 if (!onetouch->data) 158 if (!onetouch->data)
159 goto fail1; 159 goto fail1;
160 160
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 47644b5b6155..323293a3e61f 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -427,7 +427,7 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
427 US_DEBUGP("%s: xfer %u bytes, %d entries\n", __FUNCTION__, 427 US_DEBUGP("%s: xfer %u bytes, %d entries\n", __FUNCTION__,
428 length, num_sg); 428 length, num_sg);
429 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0, 429 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0,
430 sg, num_sg, length, SLAB_NOIO); 430 sg, num_sg, length, GFP_NOIO);
431 if (result) { 431 if (result) {
432 US_DEBUGP("usb_sg_init returned %d\n", result); 432 US_DEBUGP("usb_sg_init returned %d\n", result);
433 return USB_STOR_XFER_ERROR; 433 return USB_STOR_XFER_ERROR;
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index b401084b3d22..70644506651f 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -49,7 +49,7 @@
49 49
50#include <linux/sched.h> 50#include <linux/sched.h>
51#include <linux/errno.h> 51#include <linux/errno.h>
52#include <linux/suspend.h> 52#include <linux/freezer.h>
53#include <linux/module.h> 53#include <linux/module.h>
54#include <linux/init.h> 54#include <linux/init.h>
55#include <linux/slab.h> 55#include <linux/slab.h>
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 302174b8e477..31f476a64790 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -383,9 +383,9 @@ static void fbcon_update_softback(struct vc_data *vc)
383 softback_top = 0; 383 softback_top = 0;
384} 384}
385 385
386static void fb_flashcursor(void *private) 386static void fb_flashcursor(struct work_struct *work)
387{ 387{
388 struct fb_info *info = private; 388 struct fb_info *info = container_of(work, struct fb_info, queue);
389 struct fbcon_ops *ops = info->fbcon_par; 389 struct fbcon_ops *ops = info->fbcon_par;
390 struct display *p; 390 struct display *p;
391 struct vc_data *vc = NULL; 391 struct vc_data *vc = NULL;
@@ -442,7 +442,7 @@ static void fbcon_add_cursor_timer(struct fb_info *info)
442 if ((!info->queue.func || info->queue.func == fb_flashcursor) && 442 if ((!info->queue.func || info->queue.func == fb_flashcursor) &&
443 !(ops->flags & FBCON_FLAGS_CURSOR_TIMER)) { 443 !(ops->flags & FBCON_FLAGS_CURSOR_TIMER)) {
444 if (!info->queue.func) 444 if (!info->queue.func)
445 INIT_WORK(&info->queue, fb_flashcursor, info); 445 INIT_WORK(&info->queue, fb_flashcursor);
446 446
447 init_timer(&ops->cursor_timer); 447 init_timer(&ops->cursor_timer);
448 ops->cursor_timer.function = cursor_timer_handler; 448 ops->cursor_timer.function = cursor_timer_handler;
diff --git a/drivers/video/geode/gxfb_core.c b/drivers/video/geode/gxfb_core.c
index 0d3643fc6293..a454dcb8e215 100644
--- a/drivers/video/geode/gxfb_core.c
+++ b/drivers/video/geode/gxfb_core.c
@@ -380,7 +380,7 @@ static void gxfb_remove(struct pci_dev *pdev)
380} 380}
381 381
382static struct pci_device_id gxfb_id_table[] = { 382static struct pci_device_id gxfb_id_table[] = {
383 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_VIDEO, 383 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_GX_VIDEO,
384 PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16, 384 PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16,
385 0xff0000, 0 }, 385 0xff0000, 0 },
386 { 0, } 386 { 0, }
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 8a8ae55a7403..38eb0b69c2d7 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -964,9 +964,10 @@ static void set_ctrlr_state(struct pxafb_info *fbi, u_int state)
964 * Our LCD controller task (which is called when we blank or unblank) 964 * Our LCD controller task (which is called when we blank or unblank)
965 * via keventd. 965 * via keventd.
966 */ 966 */
967static void pxafb_task(void *dummy) 967static void pxafb_task(struct work_struct *work)
968{ 968{
969 struct pxafb_info *fbi = dummy; 969 struct pxafb_info *fbi =
970 container_of(work, struct pxafb_info, task);
970 u_int state = xchg(&fbi->task_state, -1); 971 u_int state = xchg(&fbi->task_state, -1);
971 972
972 set_ctrlr_state(fbi, state); 973 set_ctrlr_state(fbi, state);
@@ -1159,7 +1160,7 @@ static struct pxafb_info * __init pxafb_init_fbinfo(struct device *dev)
1159 } 1160 }
1160 1161
1161 init_waitqueue_head(&fbi->ctrlr_wait); 1162 init_waitqueue_head(&fbi->ctrlr_wait);
1162 INIT_WORK(&fbi->task, pxafb_task, fbi); 1163 INIT_WORK(&fbi->task, pxafb_task);
1163 init_MUTEX(&fbi->ctrlr_sem); 1164 init_MUTEX(&fbi->ctrlr_sem);
1164 1165
1165 return fbi; 1166 return fbi;
diff --git a/drivers/w1/Makefile b/drivers/w1/Makefile
index 93845a2c7c21..6bb0b54965f2 100644
--- a/drivers/w1/Makefile
+++ b/drivers/w1/Makefile
@@ -2,10 +2,6 @@
2# Makefile for the Dallas's 1-wire bus. 2# Makefile for the Dallas's 1-wire bus.
3# 3#
4 4
5ifeq ($(CONFIG_W1_DS2433_CRC), y)
6EXTRA_CFLAGS += -DCONFIG_W1_F23_CRC
7endif
8
9obj-$(CONFIG_W1) += wire.o 5obj-$(CONFIG_W1) += wire.o
10wire-objs := w1.o w1_int.o w1_family.o w1_netlink.o w1_io.o 6wire-objs := w1.o w1_int.o w1_family.o w1_netlink.o w1_io.o
11 7
diff --git a/drivers/w1/slaves/Makefile b/drivers/w1/slaves/Makefile
index 70e21e2d70c3..725dcfdfddb4 100644
--- a/drivers/w1/slaves/Makefile
+++ b/drivers/w1/slaves/Makefile
@@ -2,10 +2,6 @@
2# Makefile for the Dallas's 1-wire slaves. 2# Makefile for the Dallas's 1-wire slaves.
3# 3#
4 4
5ifeq ($(CONFIG_W1_SLAVE_DS2433_CRC), y)
6EXTRA_CFLAGS += -DCONFIG_W1_F23_CRC
7endif
8
9obj-$(CONFIG_W1_SLAVE_THERM) += w1_therm.o 5obj-$(CONFIG_W1_SLAVE_THERM) += w1_therm.o
10obj-$(CONFIG_W1_SLAVE_SMEM) += w1_smem.o 6obj-$(CONFIG_W1_SLAVE_SMEM) += w1_smem.o
11obj-$(CONFIG_W1_SLAVE_DS2433) += w1_ds2433.o 7obj-$(CONFIG_W1_SLAVE_DS2433) += w1_ds2433.o
diff --git a/drivers/w1/slaves/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c
index 2ac238f1480e..8ea17a53eed8 100644
--- a/drivers/w1/slaves/w1_ds2433.c
+++ b/drivers/w1/slaves/w1_ds2433.c
@@ -13,7 +13,7 @@
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#ifdef CONFIG_W1_F23_CRC 16#ifdef CONFIG_W1_SLAVE_DS2433_CRC
17#include <linux/crc16.h> 17#include <linux/crc16.h>
18 18
19#define CRC16_INIT 0 19#define CRC16_INIT 0
@@ -62,7 +62,7 @@ static inline size_t w1_f23_fix_count(loff_t off, size_t count, size_t size)
62 return count; 62 return count;
63} 63}
64 64
65#ifdef CONFIG_W1_F23_CRC 65#ifdef CONFIG_W1_SLAVE_DS2433_CRC
66static int w1_f23_refresh_block(struct w1_slave *sl, struct w1_f23_data *data, 66static int w1_f23_refresh_block(struct w1_slave *sl, struct w1_f23_data *data,
67 int block) 67 int block)
68{ 68{
@@ -89,13 +89,13 @@ static int w1_f23_refresh_block(struct w1_slave *sl, struct w1_f23_data *data,
89 89
90 return 0; 90 return 0;
91} 91}
92#endif /* CONFIG_W1_F23_CRC */ 92#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
93 93
94static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off, 94static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off,
95 size_t count) 95 size_t count)
96{ 96{
97 struct w1_slave *sl = kobj_to_w1_slave(kobj); 97 struct w1_slave *sl = kobj_to_w1_slave(kobj);
98#ifdef CONFIG_W1_F23_CRC 98#ifdef CONFIG_W1_SLAVE_DS2433_CRC
99 struct w1_f23_data *data = sl->family_data; 99 struct w1_f23_data *data = sl->family_data;
100 int i, min_page, max_page; 100 int i, min_page, max_page;
101#else 101#else
@@ -107,7 +107,7 @@ static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off,
107 107
108 mutex_lock(&sl->master->mutex); 108 mutex_lock(&sl->master->mutex);
109 109
110#ifdef CONFIG_W1_F23_CRC 110#ifdef CONFIG_W1_SLAVE_DS2433_CRC
111 111
112 min_page = (off >> W1_PAGE_BITS); 112 min_page = (off >> W1_PAGE_BITS);
113 max_page = (off + count - 1) >> W1_PAGE_BITS; 113 max_page = (off + count - 1) >> W1_PAGE_BITS;
@@ -119,7 +119,7 @@ static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off,
119 } 119 }
120 memcpy(buf, &data->memory[off], count); 120 memcpy(buf, &data->memory[off], count);
121 121
122#else /* CONFIG_W1_F23_CRC */ 122#else /* CONFIG_W1_SLAVE_DS2433_CRC */
123 123
124 /* read directly from the EEPROM */ 124 /* read directly from the EEPROM */
125 if (w1_reset_select_slave(sl)) { 125 if (w1_reset_select_slave(sl)) {
@@ -133,7 +133,7 @@ static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off,
133 w1_write_block(sl->master, wrbuf, 3); 133 w1_write_block(sl->master, wrbuf, 3);
134 w1_read_block(sl->master, buf, count); 134 w1_read_block(sl->master, buf, count);
135 135
136#endif /* CONFIG_W1_F23_CRC */ 136#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
137 137
138out_up: 138out_up:
139 mutex_unlock(&sl->master->mutex); 139 mutex_unlock(&sl->master->mutex);
@@ -208,7 +208,7 @@ static ssize_t w1_f23_write_bin(struct kobject *kobj, char *buf, loff_t off,
208 if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0) 208 if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0)
209 return 0; 209 return 0;
210 210
211#ifdef CONFIG_W1_F23_CRC 211#ifdef CONFIG_W1_SLAVE_DS2433_CRC
212 /* can only write full blocks in cached mode */ 212 /* can only write full blocks in cached mode */
213 if ((off & W1_PAGE_MASK) || (count & W1_PAGE_MASK)) { 213 if ((off & W1_PAGE_MASK) || (count & W1_PAGE_MASK)) {
214 dev_err(&sl->dev, "invalid offset/count off=%d cnt=%zd\n", 214 dev_err(&sl->dev, "invalid offset/count off=%d cnt=%zd\n",
@@ -223,7 +223,7 @@ static ssize_t w1_f23_write_bin(struct kobject *kobj, char *buf, loff_t off,
223 return -EINVAL; 223 return -EINVAL;
224 } 224 }
225 } 225 }
226#endif /* CONFIG_W1_F23_CRC */ 226#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
227 227
228 mutex_lock(&sl->master->mutex); 228 mutex_lock(&sl->master->mutex);
229 229
@@ -262,7 +262,7 @@ static struct bin_attribute w1_f23_bin_attr = {
262static int w1_f23_add_slave(struct w1_slave *sl) 262static int w1_f23_add_slave(struct w1_slave *sl)
263{ 263{
264 int err; 264 int err;
265#ifdef CONFIG_W1_F23_CRC 265#ifdef CONFIG_W1_SLAVE_DS2433_CRC
266 struct w1_f23_data *data; 266 struct w1_f23_data *data;
267 267
268 data = kmalloc(sizeof(struct w1_f23_data), GFP_KERNEL); 268 data = kmalloc(sizeof(struct w1_f23_data), GFP_KERNEL);
@@ -271,24 +271,24 @@ static int w1_f23_add_slave(struct w1_slave *sl)
271 memset(data, 0, sizeof(struct w1_f23_data)); 271 memset(data, 0, sizeof(struct w1_f23_data));
272 sl->family_data = data; 272 sl->family_data = data;
273 273
274#endif /* CONFIG_W1_F23_CRC */ 274#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
275 275
276 err = sysfs_create_bin_file(&sl->dev.kobj, &w1_f23_bin_attr); 276 err = sysfs_create_bin_file(&sl->dev.kobj, &w1_f23_bin_attr);
277 277
278#ifdef CONFIG_W1_F23_CRC 278#ifdef CONFIG_W1_SLAVE_DS2433_CRC
279 if (err) 279 if (err)
280 kfree(data); 280 kfree(data);
281#endif /* CONFIG_W1_F23_CRC */ 281#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
282 282
283 return err; 283 return err;
284} 284}
285 285
286static void w1_f23_remove_slave(struct w1_slave *sl) 286static void w1_f23_remove_slave(struct w1_slave *sl)
287{ 287{
288#ifdef CONFIG_W1_F23_CRC 288#ifdef CONFIG_W1_SLAVE_DS2433_CRC
289 kfree(sl->family_data); 289 kfree(sl->family_data);
290 sl->family_data = NULL; 290 sl->family_data = NULL;
291#endif /* CONFIG_W1_F23_CRC */ 291#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
292 sysfs_remove_bin_file(&sl->dev.kobj, &w1_f23_bin_attr); 292 sysfs_remove_bin_file(&sl->dev.kobj, &w1_f23_bin_attr);
293} 293}
294 294
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index de3e9791f80d..63c07243993c 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -31,6 +31,7 @@
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/sched.h> 32#include <linux/sched.h>
33#include <linux/kthread.h> 33#include <linux/kthread.h>
34#include <linux/freezer.h>
34 35
35#include <asm/atomic.h> 36#include <asm/atomic.h>
36 37
diff --git a/fs/9p/mux.c b/fs/9p/mux.c
index 90a79c784549..944273c3dbff 100644
--- a/fs/9p/mux.c
+++ b/fs/9p/mux.c
@@ -110,8 +110,8 @@ struct v9fs_mux_rpc {
110}; 110};
111 111
112static int v9fs_poll_proc(void *); 112static int v9fs_poll_proc(void *);
113static void v9fs_read_work(void *); 113static void v9fs_read_work(struct work_struct *work);
114static void v9fs_write_work(void *); 114static void v9fs_write_work(struct work_struct *work);
115static void v9fs_pollwait(struct file *filp, wait_queue_head_t * wait_address, 115static void v9fs_pollwait(struct file *filp, wait_queue_head_t * wait_address,
116 poll_table * p); 116 poll_table * p);
117static u16 v9fs_mux_get_tag(struct v9fs_mux_data *); 117static u16 v9fs_mux_get_tag(struct v9fs_mux_data *);
@@ -297,8 +297,8 @@ struct v9fs_mux_data *v9fs_mux_init(struct v9fs_transport *trans, int msize,
297 m->rbuf = NULL; 297 m->rbuf = NULL;
298 m->wpos = m->wsize = 0; 298 m->wpos = m->wsize = 0;
299 m->wbuf = NULL; 299 m->wbuf = NULL;
300 INIT_WORK(&m->rq, v9fs_read_work, m); 300 INIT_WORK(&m->rq, v9fs_read_work);
301 INIT_WORK(&m->wq, v9fs_write_work, m); 301 INIT_WORK(&m->wq, v9fs_write_work);
302 m->wsched = 0; 302 m->wsched = 0;
303 memset(&m->poll_waddr, 0, sizeof(m->poll_waddr)); 303 memset(&m->poll_waddr, 0, sizeof(m->poll_waddr));
304 m->poll_task = NULL; 304 m->poll_task = NULL;
@@ -458,13 +458,13 @@ static int v9fs_poll_proc(void *a)
458/** 458/**
459 * v9fs_write_work - called when a transport can send some data 459 * v9fs_write_work - called when a transport can send some data
460 */ 460 */
461static void v9fs_write_work(void *a) 461static void v9fs_write_work(struct work_struct *work)
462{ 462{
463 int n, err; 463 int n, err;
464 struct v9fs_mux_data *m; 464 struct v9fs_mux_data *m;
465 struct v9fs_req *req; 465 struct v9fs_req *req;
466 466
467 m = a; 467 m = container_of(work, struct v9fs_mux_data, wq);
468 468
469 if (m->err < 0) { 469 if (m->err < 0) {
470 clear_bit(Wworksched, &m->wsched); 470 clear_bit(Wworksched, &m->wsched);
@@ -564,7 +564,7 @@ static void process_request(struct v9fs_mux_data *m, struct v9fs_req *req)
564/** 564/**
565 * v9fs_read_work - called when there is some data to be read from a transport 565 * v9fs_read_work - called when there is some data to be read from a transport
566 */ 566 */
567static void v9fs_read_work(void *a) 567static void v9fs_read_work(struct work_struct *work)
568{ 568{
569 int n, err; 569 int n, err;
570 struct v9fs_mux_data *m; 570 struct v9fs_mux_data *m;
@@ -572,7 +572,7 @@ static void v9fs_read_work(void *a)
572 struct v9fs_fcall *rcall; 572 struct v9fs_fcall *rcall;
573 char *rbuf; 573 char *rbuf;
574 574
575 m = a; 575 m = container_of(work, struct v9fs_mux_data, rq);
576 576
577 if (m->err < 0) 577 if (m->err < 0)
578 return; 578 return;
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 5241c600ce28..18f26cdfd882 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -256,7 +256,7 @@ static int
256v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name, u32 perm, 256v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name, u32 perm,
257 u8 mode, char *extension, u32 *fidp, struct v9fs_qid *qid, u32 *iounit) 257 u8 mode, char *extension, u32 *fidp, struct v9fs_qid *qid, u32 *iounit)
258{ 258{
259 u32 fid; 259 int fid;
260 int err; 260 int err;
261 struct v9fs_fcall *fcall; 261 struct v9fs_fcall *fcall;
262 262
@@ -310,7 +310,7 @@ static struct v9fs_fid*
310v9fs_clone_walk(struct v9fs_session_info *v9ses, u32 fid, struct dentry *dentry) 310v9fs_clone_walk(struct v9fs_session_info *v9ses, u32 fid, struct dentry *dentry)
311{ 311{
312 int err; 312 int err;
313 u32 nfid; 313 int nfid;
314 struct v9fs_fid *ret; 314 struct v9fs_fid *ret;
315 struct v9fs_fcall *fcall; 315 struct v9fs_fcall *fcall;
316 316
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index 9ade139086fc..5023351a7afe 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -36,7 +36,7 @@ void __adfs_error(struct super_block *sb, const char *function, const char *fmt,
36 va_list args; 36 va_list args;
37 37
38 va_start(args, fmt); 38 va_start(args, fmt);
39 vsprintf(error_buf, fmt, args); 39 vsnprintf(error_buf, sizeof(error_buf), fmt, args);
40 va_end(args); 40 va_end(args);
41 41
42 printk(KERN_CRIT "ADFS-fs error (device %s)%s%s: %s\n", 42 printk(KERN_CRIT "ADFS-fs error (device %s)%s%s: %s\n",
@@ -212,12 +212,12 @@ static int adfs_statfs(struct dentry *dentry, struct kstatfs *buf)
212 return 0; 212 return 0;
213} 213}
214 214
215static kmem_cache_t *adfs_inode_cachep; 215static struct kmem_cache *adfs_inode_cachep;
216 216
217static struct inode *adfs_alloc_inode(struct super_block *sb) 217static struct inode *adfs_alloc_inode(struct super_block *sb)
218{ 218{
219 struct adfs_inode_info *ei; 219 struct adfs_inode_info *ei;
220 ei = (struct adfs_inode_info *)kmem_cache_alloc(adfs_inode_cachep, SLAB_KERNEL); 220 ei = (struct adfs_inode_info *)kmem_cache_alloc(adfs_inode_cachep, GFP_KERNEL);
221 if (!ei) 221 if (!ei)
222 return NULL; 222 return NULL;
223 return &ei->vfs_inode; 223 return &ei->vfs_inode;
@@ -228,7 +228,7 @@ static void adfs_destroy_inode(struct inode *inode)
228 kmem_cache_free(adfs_inode_cachep, ADFS_I(inode)); 228 kmem_cache_free(adfs_inode_cachep, ADFS_I(inode));
229} 229}
230 230
231static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 231static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
232{ 232{
233 struct adfs_inode_info *ei = (struct adfs_inode_info *) foo; 233 struct adfs_inode_info *ei = (struct adfs_inode_info *) foo;
234 234
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index ccd624ef4272..f4de4b98004f 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -445,7 +445,7 @@ affs_error(struct super_block *sb, const char *function, const char *fmt, ...)
445 va_list args; 445 va_list args;
446 446
447 va_start(args,fmt); 447 va_start(args,fmt);
448 vsprintf(ErrorBuffer,fmt,args); 448 vsnprintf(ErrorBuffer,sizeof(ErrorBuffer),fmt,args);
449 va_end(args); 449 va_end(args);
450 450
451 printk(KERN_CRIT "AFFS error (device %s): %s(): %s\n", sb->s_id, 451 printk(KERN_CRIT "AFFS error (device %s): %s(): %s\n", sb->s_id,
@@ -461,7 +461,7 @@ affs_warning(struct super_block *sb, const char *function, const char *fmt, ...)
461 va_list args; 461 va_list args;
462 462
463 va_start(args,fmt); 463 va_start(args,fmt);
464 vsprintf(ErrorBuffer,fmt,args); 464 vsnprintf(ErrorBuffer,sizeof(ErrorBuffer),fmt,args);
465 va_end(args); 465 va_end(args);
466 466
467 printk(KERN_WARNING "AFFS warning (device %s): %s(): %s\n", sb->s_id, 467 printk(KERN_WARNING "AFFS warning (device %s): %s(): %s\n", sb->s_id,
diff --git a/fs/affs/bitmap.c b/fs/affs/bitmap.c
index b0b953683c1a..b330009fe42d 100644
--- a/fs/affs/bitmap.c
+++ b/fs/affs/bitmap.c
@@ -289,12 +289,11 @@ int affs_init_bitmap(struct super_block *sb, int *flags)
289 sbi->s_bmap_count = (sbi->s_partition_size - sbi->s_reserved + 289 sbi->s_bmap_count = (sbi->s_partition_size - sbi->s_reserved +
290 sbi->s_bmap_bits - 1) / sbi->s_bmap_bits; 290 sbi->s_bmap_bits - 1) / sbi->s_bmap_bits;
291 size = sbi->s_bmap_count * sizeof(*bm); 291 size = sbi->s_bmap_count * sizeof(*bm);
292 bm = sbi->s_bitmap = kmalloc(size, GFP_KERNEL); 292 bm = sbi->s_bitmap = kzalloc(size, GFP_KERNEL);
293 if (!sbi->s_bitmap) { 293 if (!sbi->s_bitmap) {
294 printk(KERN_ERR "AFFS: Bitmap allocation failed\n"); 294 printk(KERN_ERR "AFFS: Bitmap allocation failed\n");
295 return -ENOMEM; 295 return -ENOMEM;
296 } 296 }
297 memset(sbi->s_bitmap, 0, size);
298 297
299 bmap_blk = (__be32 *)sbi->s_root_bh->b_data; 298 bmap_blk = (__be32 *)sbi->s_root_bh->b_data;
300 blk = sb->s_blocksize / 4 - 49; 299 blk = sb->s_blocksize / 4 - 49;
diff --git a/fs/affs/super.c b/fs/affs/super.c
index 5ea72c3a16c3..3de93e799949 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -66,12 +66,12 @@ affs_write_super(struct super_block *sb)
66 pr_debug("AFFS: write_super() at %lu, clean=%d\n", get_seconds(), clean); 66 pr_debug("AFFS: write_super() at %lu, clean=%d\n", get_seconds(), clean);
67} 67}
68 68
69static kmem_cache_t * affs_inode_cachep; 69static struct kmem_cache * affs_inode_cachep;
70 70
71static struct inode *affs_alloc_inode(struct super_block *sb) 71static struct inode *affs_alloc_inode(struct super_block *sb)
72{ 72{
73 struct affs_inode_info *ei; 73 struct affs_inode_info *ei;
74 ei = (struct affs_inode_info *)kmem_cache_alloc(affs_inode_cachep, SLAB_KERNEL); 74 ei = (struct affs_inode_info *)kmem_cache_alloc(affs_inode_cachep, GFP_KERNEL);
75 if (!ei) 75 if (!ei)
76 return NULL; 76 return NULL;
77 ei->vfs_inode.i_version = 1; 77 ei->vfs_inode.i_version = 1;
@@ -83,7 +83,7 @@ static void affs_destroy_inode(struct inode *inode)
83 kmem_cache_free(affs_inode_cachep, AFFS_I(inode)); 83 kmem_cache_free(affs_inode_cachep, AFFS_I(inode));
84} 84}
85 85
86static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 86static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
87{ 87{
88 struct affs_inode_info *ei = (struct affs_inode_info *) foo; 88 struct affs_inode_info *ei = (struct affs_inode_info *) foo;
89 89
diff --git a/fs/afs/kafsasyncd.c b/fs/afs/kafsasyncd.c
index f09a794f248e..615df2407cb2 100644
--- a/fs/afs/kafsasyncd.c
+++ b/fs/afs/kafsasyncd.c
@@ -20,6 +20,7 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/sched.h> 21#include <linux/sched.h>
22#include <linux/completion.h> 22#include <linux/completion.h>
23#include <linux/freezer.h>
23#include "cell.h" 24#include "cell.h"
24#include "server.h" 25#include "server.h"
25#include "volume.h" 26#include "volume.h"
diff --git a/fs/afs/kafstimod.c b/fs/afs/kafstimod.c
index 65bc05ab8182..694344e4d3c7 100644
--- a/fs/afs/kafstimod.c
+++ b/fs/afs/kafstimod.c
@@ -13,6 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/completion.h> 15#include <linux/completion.h>
16#include <linux/freezer.h>
16#include "cell.h" 17#include "cell.h"
17#include "volume.h" 18#include "volume.h"
18#include "kafstimod.h" 19#include "kafstimod.h"
diff --git a/fs/afs/server.c b/fs/afs/server.c
index 22afaae1a4ce..44aff81dc6a7 100644
--- a/fs/afs/server.c
+++ b/fs/afs/server.c
@@ -55,13 +55,12 @@ int afs_server_lookup(struct afs_cell *cell, const struct in_addr *addr,
55 _enter("%p,%08x,", cell, ntohl(addr->s_addr)); 55 _enter("%p,%08x,", cell, ntohl(addr->s_addr));
56 56
57 /* allocate and initialise a server record */ 57 /* allocate and initialise a server record */
58 server = kmalloc(sizeof(struct afs_server), GFP_KERNEL); 58 server = kzalloc(sizeof(struct afs_server), GFP_KERNEL);
59 if (!server) { 59 if (!server) {
60 _leave(" = -ENOMEM"); 60 _leave(" = -ENOMEM");
61 return -ENOMEM; 61 return -ENOMEM;
62 } 62 }
63 63
64 memset(server, 0, sizeof(struct afs_server));
65 atomic_set(&server->usage, 1); 64 atomic_set(&server->usage, 1);
66 65
67 INIT_LIST_HEAD(&server->link); 66 INIT_LIST_HEAD(&server->link);
diff --git a/fs/afs/super.c b/fs/afs/super.c
index 67d1f5c819ec..18d9b77ba40f 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -35,7 +35,7 @@ struct afs_mount_params {
35 struct afs_volume *volume; 35 struct afs_volume *volume;
36}; 36};
37 37
38static void afs_i_init_once(void *foo, kmem_cache_t *cachep, 38static void afs_i_init_once(void *foo, struct kmem_cache *cachep,
39 unsigned long flags); 39 unsigned long flags);
40 40
41static int afs_get_sb(struct file_system_type *fs_type, 41static int afs_get_sb(struct file_system_type *fs_type,
@@ -65,7 +65,7 @@ static struct super_operations afs_super_ops = {
65 .put_super = afs_put_super, 65 .put_super = afs_put_super,
66}; 66};
67 67
68static kmem_cache_t *afs_inode_cachep; 68static struct kmem_cache *afs_inode_cachep;
69static atomic_t afs_count_active_inodes; 69static atomic_t afs_count_active_inodes;
70 70
71/*****************************************************************************/ 71/*****************************************************************************/
@@ -242,14 +242,12 @@ static int afs_fill_super(struct super_block *sb, void *data, int silent)
242 kenter(""); 242 kenter("");
243 243
244 /* allocate a superblock info record */ 244 /* allocate a superblock info record */
245 as = kmalloc(sizeof(struct afs_super_info), GFP_KERNEL); 245 as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
246 if (!as) { 246 if (!as) {
247 _leave(" = -ENOMEM"); 247 _leave(" = -ENOMEM");
248 return -ENOMEM; 248 return -ENOMEM;
249 } 249 }
250 250
251 memset(as, 0, sizeof(struct afs_super_info));
252
253 afs_get_volume(params->volume); 251 afs_get_volume(params->volume);
254 as->volume = params->volume; 252 as->volume = params->volume;
255 253
@@ -384,7 +382,7 @@ static void afs_put_super(struct super_block *sb)
384/* 382/*
385 * initialise an inode cache slab element prior to any use 383 * initialise an inode cache slab element prior to any use
386 */ 384 */
387static void afs_i_init_once(void *_vnode, kmem_cache_t *cachep, 385static void afs_i_init_once(void *_vnode, struct kmem_cache *cachep,
388 unsigned long flags) 386 unsigned long flags)
389{ 387{
390 struct afs_vnode *vnode = (struct afs_vnode *) _vnode; 388 struct afs_vnode *vnode = (struct afs_vnode *) _vnode;
@@ -412,7 +410,7 @@ static struct inode *afs_alloc_inode(struct super_block *sb)
412 struct afs_vnode *vnode; 410 struct afs_vnode *vnode;
413 411
414 vnode = (struct afs_vnode *) 412 vnode = (struct afs_vnode *)
415 kmem_cache_alloc(afs_inode_cachep, SLAB_KERNEL); 413 kmem_cache_alloc(afs_inode_cachep, GFP_KERNEL);
416 if (!vnode) 414 if (!vnode)
417 return NULL; 415 return NULL;
418 416
diff --git a/fs/aio.c b/fs/aio.c
index 277a5f2d18ad..d3a6ec2c9627 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -47,19 +47,19 @@ unsigned long aio_nr; /* current system wide number of aio requests */
47unsigned long aio_max_nr = 0x10000; /* system wide maximum number of aio requests */ 47unsigned long aio_max_nr = 0x10000; /* system wide maximum number of aio requests */
48/*----end sysctl variables---*/ 48/*----end sysctl variables---*/
49 49
50static kmem_cache_t *kiocb_cachep; 50static struct kmem_cache *kiocb_cachep;
51static kmem_cache_t *kioctx_cachep; 51static struct kmem_cache *kioctx_cachep;
52 52
53static struct workqueue_struct *aio_wq; 53static struct workqueue_struct *aio_wq;
54 54
55/* Used for rare fput completion. */ 55/* Used for rare fput completion. */
56static void aio_fput_routine(void *); 56static void aio_fput_routine(struct work_struct *);
57static DECLARE_WORK(fput_work, aio_fput_routine, NULL); 57static DECLARE_WORK(fput_work, aio_fput_routine);
58 58
59static DEFINE_SPINLOCK(fput_lock); 59static DEFINE_SPINLOCK(fput_lock);
60static LIST_HEAD(fput_head); 60static LIST_HEAD(fput_head);
61 61
62static void aio_kick_handler(void *); 62static void aio_kick_handler(struct work_struct *);
63static void aio_queue_work(struct kioctx *); 63static void aio_queue_work(struct kioctx *);
64 64
65/* aio_setup 65/* aio_setup
@@ -227,7 +227,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
227 227
228 INIT_LIST_HEAD(&ctx->active_reqs); 228 INIT_LIST_HEAD(&ctx->active_reqs);
229 INIT_LIST_HEAD(&ctx->run_list); 229 INIT_LIST_HEAD(&ctx->run_list);
230 INIT_WORK(&ctx->wq, aio_kick_handler, ctx); 230 INIT_DELAYED_WORK(&ctx->wq, aio_kick_handler);
231 231
232 if (aio_setup_ring(ctx) < 0) 232 if (aio_setup_ring(ctx) < 0)
233 goto out_freectx; 233 goto out_freectx;
@@ -469,7 +469,7 @@ static inline void really_put_req(struct kioctx *ctx, struct kiocb *req)
469 wake_up(&ctx->wait); 469 wake_up(&ctx->wait);
470} 470}
471 471
472static void aio_fput_routine(void *data) 472static void aio_fput_routine(struct work_struct *data)
473{ 473{
474 spin_lock_irq(&fput_lock); 474 spin_lock_irq(&fput_lock);
475 while (likely(!list_empty(&fput_head))) { 475 while (likely(!list_empty(&fput_head))) {
@@ -666,17 +666,6 @@ static ssize_t aio_run_iocb(struct kiocb *iocb)
666 ssize_t (*retry)(struct kiocb *); 666 ssize_t (*retry)(struct kiocb *);
667 ssize_t ret; 667 ssize_t ret;
668 668
669 if (iocb->ki_retried++ > 1024*1024) {
670 printk("Maximal retry count. Bytes done %Zd\n",
671 iocb->ki_nbytes - iocb->ki_left);
672 return -EAGAIN;
673 }
674
675 if (!(iocb->ki_retried & 0xff)) {
676 pr_debug("%ld retry: %zd of %zd\n", iocb->ki_retried,
677 iocb->ki_nbytes - iocb->ki_left, iocb->ki_nbytes);
678 }
679
680 if (!(retry = iocb->ki_retry)) { 669 if (!(retry = iocb->ki_retry)) {
681 printk("aio_run_iocb: iocb->ki_retry = NULL\n"); 670 printk("aio_run_iocb: iocb->ki_retry = NULL\n");
682 return 0; 671 return 0;
@@ -857,9 +846,9 @@ static inline void aio_run_all_iocbs(struct kioctx *ctx)
857 * space. 846 * space.
858 * Run on aiod's context. 847 * Run on aiod's context.
859 */ 848 */
860static void aio_kick_handler(void *data) 849static void aio_kick_handler(struct work_struct *work)
861{ 850{
862 struct kioctx *ctx = data; 851 struct kioctx *ctx = container_of(work, struct kioctx, wq.work);
863 mm_segment_t oldfs = get_fs(); 852 mm_segment_t oldfs = get_fs();
864 int requeue; 853 int requeue;
865 854
@@ -874,7 +863,7 @@ static void aio_kick_handler(void *data)
874 * we're in a worker thread already, don't use queue_delayed_work, 863 * we're in a worker thread already, don't use queue_delayed_work,
875 */ 864 */
876 if (requeue) 865 if (requeue)
877 queue_work(aio_wq, &ctx->wq); 866 queue_delayed_work(aio_wq, &ctx->wq, 0);
878} 867}
879 868
880 869
@@ -1005,9 +994,6 @@ int fastcall aio_complete(struct kiocb *iocb, long res, long res2)
1005 kunmap_atomic(ring, KM_IRQ1); 994 kunmap_atomic(ring, KM_IRQ1);
1006 995
1007 pr_debug("added to ring %p at [%lu]\n", iocb, tail); 996 pr_debug("added to ring %p at [%lu]\n", iocb, tail);
1008
1009 pr_debug("%ld retries: %zd of %zd\n", iocb->ki_retried,
1010 iocb->ki_nbytes - iocb->ki_left, iocb->ki_nbytes);
1011put_rq: 997put_rq:
1012 /* everything turned out well, dispose of the aiocb. */ 998 /* everything turned out well, dispose of the aiocb. */
1013 ret = __aio_put_req(ctx, iocb); 999 ret = __aio_put_req(ctx, iocb);
@@ -1413,7 +1399,6 @@ static ssize_t aio_setup_single_vector(struct kiocb *kiocb)
1413 kiocb->ki_iovec->iov_len = kiocb->ki_left; 1399 kiocb->ki_iovec->iov_len = kiocb->ki_left;
1414 kiocb->ki_nr_segs = 1; 1400 kiocb->ki_nr_segs = 1;
1415 kiocb->ki_cur_seg = 0; 1401 kiocb->ki_cur_seg = 0;
1416 kiocb->ki_nbytes = kiocb->ki_left;
1417 return 0; 1402 return 0;
1418} 1403}
1419 1404
@@ -1591,7 +1576,6 @@ int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1591 req->ki_opcode = iocb->aio_lio_opcode; 1576 req->ki_opcode = iocb->aio_lio_opcode;
1592 init_waitqueue_func_entry(&req->ki_wait, aio_wake_function); 1577 init_waitqueue_func_entry(&req->ki_wait, aio_wake_function);
1593 INIT_LIST_HEAD(&req->ki_wait.task_list); 1578 INIT_LIST_HEAD(&req->ki_wait.task_list);
1594 req->ki_retried = 0;
1595 1579
1596 ret = aio_setup_iocb(req); 1580 ret = aio_setup_iocb(req);
1597 1581
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index 38ede5c9d6fd..f968d1342808 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -28,10 +28,11 @@ void autofs_kill_sb(struct super_block *sb)
28 /* 28 /*
29 * In the event of a failure in get_sb_nodev the superblock 29 * In the event of a failure in get_sb_nodev the superblock
30 * info is not present so nothing else has been setup, so 30 * info is not present so nothing else has been setup, so
31 * just exit when we are called from deactivate_super. 31 * just call kill_anon_super when we are called from
32 * deactivate_super.
32 */ 33 */
33 if (!sbi) 34 if (!sbi)
34 return; 35 goto out_kill_sb;
35 36
36 if ( !sbi->catatonic ) 37 if ( !sbi->catatonic )
37 autofs_catatonic_mode(sbi); /* Free wait queues, close pipe */ 38 autofs_catatonic_mode(sbi); /* Free wait queues, close pipe */
@@ -44,6 +45,7 @@ void autofs_kill_sb(struct super_block *sb)
44 45
45 kfree(sb->s_fs_info); 46 kfree(sb->s_fs_info);
46 47
48out_kill_sb:
47 DPRINTK(("autofs: shutting down\n")); 49 DPRINTK(("autofs: shutting down\n"));
48 kill_anon_super(sb); 50 kill_anon_super(sb);
49} 51}
@@ -209,7 +211,6 @@ fail_iput:
209fail_free: 211fail_free:
210 kfree(sbi); 212 kfree(sbi);
211 s->s_fs_info = NULL; 213 s->s_fs_info = NULL;
212 kill_anon_super(s);
213fail_unlock: 214fail_unlock:
214 return -EINVAL; 215 return -EINVAL;
215} 216}
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index ce7c0f1dd529..9c48250fd726 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -152,10 +152,11 @@ void autofs4_kill_sb(struct super_block *sb)
152 /* 152 /*
153 * In the event of a failure in get_sb_nodev the superblock 153 * In the event of a failure in get_sb_nodev the superblock
154 * info is not present so nothing else has been setup, so 154 * info is not present so nothing else has been setup, so
155 * just exit when we are called from deactivate_super. 155 * just call kill_anon_super when we are called from
156 * deactivate_super.
156 */ 157 */
157 if (!sbi) 158 if (!sbi)
158 return; 159 goto out_kill_sb;
159 160
160 sb->s_fs_info = NULL; 161 sb->s_fs_info = NULL;
161 162
@@ -167,6 +168,7 @@ void autofs4_kill_sb(struct super_block *sb)
167 168
168 kfree(sbi); 169 kfree(sbi);
169 170
171out_kill_sb:
170 DPRINTK("shutting down"); 172 DPRINTK("shutting down");
171 kill_anon_super(sb); 173 kill_anon_super(sb);
172} 174}
@@ -426,7 +428,6 @@ fail_ino:
426fail_free: 428fail_free:
427 kfree(sbi); 429 kfree(sbi);
428 s->s_fs_info = NULL; 430 s->s_fs_info = NULL;
429 kill_anon_super(s);
430fail_unlock: 431fail_unlock:
431 return -EINVAL; 432 return -EINVAL;
432} 433}
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 07f7144f0e2e..bce402eee554 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -61,7 +61,7 @@ static const struct super_operations befs_sops = {
61}; 61};
62 62
63/* slab cache for befs_inode_info objects */ 63/* slab cache for befs_inode_info objects */
64static kmem_cache_t *befs_inode_cachep; 64static struct kmem_cache *befs_inode_cachep;
65 65
66static const struct file_operations befs_dir_operations = { 66static const struct file_operations befs_dir_operations = {
67 .read = generic_read_dir, 67 .read = generic_read_dir,
@@ -277,7 +277,7 @@ befs_alloc_inode(struct super_block *sb)
277{ 277{
278 struct befs_inode_info *bi; 278 struct befs_inode_info *bi;
279 bi = (struct befs_inode_info *)kmem_cache_alloc(befs_inode_cachep, 279 bi = (struct befs_inode_info *)kmem_cache_alloc(befs_inode_cachep,
280 SLAB_KERNEL); 280 GFP_KERNEL);
281 if (!bi) 281 if (!bi)
282 return NULL; 282 return NULL;
283 return &bi->vfs_inode; 283 return &bi->vfs_inode;
@@ -289,7 +289,7 @@ befs_destroy_inode(struct inode *inode)
289 kmem_cache_free(befs_inode_cachep, BEFS_I(inode)); 289 kmem_cache_free(befs_inode_cachep, BEFS_I(inode));
290} 290}
291 291
292static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 292static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
293{ 293{
294 struct befs_inode_info *bi = (struct befs_inode_info *) foo; 294 struct befs_inode_info *bi = (struct befs_inode_info *) foo;
295 295
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index ed27ffb3459e..eac175ed9f44 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -228,12 +228,12 @@ static void bfs_write_super(struct super_block *s)
228 unlock_kernel(); 228 unlock_kernel();
229} 229}
230 230
231static kmem_cache_t * bfs_inode_cachep; 231static struct kmem_cache * bfs_inode_cachep;
232 232
233static struct inode *bfs_alloc_inode(struct super_block *sb) 233static struct inode *bfs_alloc_inode(struct super_block *sb)
234{ 234{
235 struct bfs_inode_info *bi; 235 struct bfs_inode_info *bi;
236 bi = kmem_cache_alloc(bfs_inode_cachep, SLAB_KERNEL); 236 bi = kmem_cache_alloc(bfs_inode_cachep, GFP_KERNEL);
237 if (!bi) 237 if (!bi)
238 return NULL; 238 return NULL;
239 return &bi->vfs_inode; 239 return &bi->vfs_inode;
@@ -244,7 +244,7 @@ static void bfs_destroy_inode(struct inode *inode)
244 kmem_cache_free(bfs_inode_cachep, BFS_I(inode)); 244 kmem_cache_free(bfs_inode_cachep, BFS_I(inode));
245} 245}
246 246
247static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 247static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
248{ 248{
249 struct bfs_inode_info *bi = foo; 249 struct bfs_inode_info *bi = foo;
250 250
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index cc72bb43061d..be5869d34999 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -47,10 +47,6 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs);
47static int load_elf_library(struct file *); 47static int load_elf_library(struct file *);
48static unsigned long elf_map (struct file *, unsigned long, struct elf_phdr *, int, int); 48static unsigned long elf_map (struct file *, unsigned long, struct elf_phdr *, int, int);
49 49
50#ifndef elf_addr_t
51#define elf_addr_t unsigned long
52#endif
53
54/* 50/*
55 * If we don't support core dumping, then supply a NULL so we 51 * If we don't support core dumping, then supply a NULL so we
56 * don't even try. 52 * don't even try.
@@ -243,8 +239,9 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
243 if (interp_aout) { 239 if (interp_aout) {
244 argv = sp + 2; 240 argv = sp + 2;
245 envp = argv + argc + 1; 241 envp = argv + argc + 1;
246 __put_user((elf_addr_t)(unsigned long)argv, sp++); 242 if (__put_user((elf_addr_t)(unsigned long)argv, sp++) ||
247 __put_user((elf_addr_t)(unsigned long)envp, sp++); 243 __put_user((elf_addr_t)(unsigned long)envp, sp++))
244 return -EFAULT;
248 } else { 245 } else {
249 argv = sp; 246 argv = sp;
250 envp = argv + argc + 1; 247 envp = argv + argc + 1;
@@ -254,7 +251,8 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
254 p = current->mm->arg_end = current->mm->arg_start; 251 p = current->mm->arg_end = current->mm->arg_start;
255 while (argc-- > 0) { 252 while (argc-- > 0) {
256 size_t len; 253 size_t len;
257 __put_user((elf_addr_t)p, argv++); 254 if (__put_user((elf_addr_t)p, argv++))
255 return -EFAULT;
258 len = strnlen_user((void __user *)p, PAGE_SIZE*MAX_ARG_PAGES); 256 len = strnlen_user((void __user *)p, PAGE_SIZE*MAX_ARG_PAGES);
259 if (!len || len > PAGE_SIZE*MAX_ARG_PAGES) 257 if (!len || len > PAGE_SIZE*MAX_ARG_PAGES)
260 return 0; 258 return 0;
@@ -265,7 +263,8 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
265 current->mm->arg_end = current->mm->env_start = p; 263 current->mm->arg_end = current->mm->env_start = p;
266 while (envc-- > 0) { 264 while (envc-- > 0) {
267 size_t len; 265 size_t len;
268 __put_user((elf_addr_t)p, envp++); 266 if (__put_user((elf_addr_t)p, envp++))
267 return -EFAULT;
269 len = strnlen_user((void __user *)p, PAGE_SIZE*MAX_ARG_PAGES); 268 len = strnlen_user((void __user *)p, PAGE_SIZE*MAX_ARG_PAGES);
270 if (!len || len > PAGE_SIZE*MAX_ARG_PAGES) 269 if (!len || len > PAGE_SIZE*MAX_ARG_PAGES)
271 return 0; 270 return 0;
@@ -545,7 +544,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
545 unsigned long reloc_func_desc = 0; 544 unsigned long reloc_func_desc = 0;
546 char passed_fileno[6]; 545 char passed_fileno[6];
547 struct files_struct *files; 546 struct files_struct *files;
548 int have_pt_gnu_stack, executable_stack = EXSTACK_DEFAULT; 547 int executable_stack = EXSTACK_DEFAULT;
549 unsigned long def_flags = 0; 548 unsigned long def_flags = 0;
550 struct { 549 struct {
551 struct elfhdr elf_ex; 550 struct elfhdr elf_ex;
@@ -708,7 +707,6 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
708 executable_stack = EXSTACK_DISABLE_X; 707 executable_stack = EXSTACK_DISABLE_X;
709 break; 708 break;
710 } 709 }
711 have_pt_gnu_stack = (i < loc->elf_ex.e_phnum);
712 710
713 /* Some simple consistency checks for the interpreter */ 711 /* Some simple consistency checks for the interpreter */
714 if (elf_interpreter) { 712 if (elf_interpreter) {
@@ -856,7 +854,13 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
856 * default mmap base, as well as whatever program they 854 * default mmap base, as well as whatever program they
857 * might try to exec. This is because the brk will 855 * might try to exec. This is because the brk will
858 * follow the loader, and is not movable. */ 856 * follow the loader, and is not movable. */
859 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr); 857 if (current->flags & PF_RANDOMIZE)
858 load_bias = randomize_range(0x10000,
859 ELF_ET_DYN_BASE,
860 0);
861 else
862 load_bias = ELF_ET_DYN_BASE;
863 load_bias = ELF_PAGESTART(load_bias - vaddr);
860 } 864 }
861 865
862 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt, 866 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index f86d5c9ce5eb..ed9a61c6beb3 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -40,9 +40,6 @@
40#include <asm/pgalloc.h> 40#include <asm/pgalloc.h>
41 41
42typedef char *elf_caddr_t; 42typedef char *elf_caddr_t;
43#ifndef elf_addr_t
44#define elf_addr_t unsigned long
45#endif
46 43
47#if 0 44#if 0
48#define kdebug(fmt, ...) printk("FDPIC "fmt"\n" ,##__VA_ARGS__ ) 45#define kdebug(fmt, ...) printk("FDPIC "fmt"\n" ,##__VA_ARGS__ )
diff --git a/fs/bio.c b/fs/bio.c
index aa4d09bd4e71..7ec737eda72b 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -30,7 +30,7 @@
30 30
31#define BIO_POOL_SIZE 256 31#define BIO_POOL_SIZE 256
32 32
33static kmem_cache_t *bio_slab __read_mostly; 33static struct kmem_cache *bio_slab __read_mostly;
34 34
35#define BIOVEC_NR_POOLS 6 35#define BIOVEC_NR_POOLS 6
36 36
@@ -44,7 +44,7 @@ mempool_t *bio_split_pool __read_mostly;
44struct biovec_slab { 44struct biovec_slab {
45 int nr_vecs; 45 int nr_vecs;
46 char *name; 46 char *name;
47 kmem_cache_t *slab; 47 struct kmem_cache *slab;
48}; 48};
49 49
50/* 50/*
@@ -940,16 +940,16 @@ static void bio_release_pages(struct bio *bio)
940 * run one bio_put() against the BIO. 940 * run one bio_put() against the BIO.
941 */ 941 */
942 942
943static void bio_dirty_fn(void *data); 943static void bio_dirty_fn(struct work_struct *work);
944 944
945static DECLARE_WORK(bio_dirty_work, bio_dirty_fn, NULL); 945static DECLARE_WORK(bio_dirty_work, bio_dirty_fn);
946static DEFINE_SPINLOCK(bio_dirty_lock); 946static DEFINE_SPINLOCK(bio_dirty_lock);
947static struct bio *bio_dirty_list; 947static struct bio *bio_dirty_list;
948 948
949/* 949/*
950 * This runs in process context 950 * This runs in process context
951 */ 951 */
952static void bio_dirty_fn(void *data) 952static void bio_dirty_fn(struct work_struct *work)
953{ 953{
954 unsigned long flags; 954 unsigned long flags;
955 struct bio *bio; 955 struct bio *bio;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 36c0e7af9d0f..13816b4d76f6 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -235,11 +235,11 @@ static int block_fsync(struct file *filp, struct dentry *dentry, int datasync)
235 */ 235 */
236 236
237static __cacheline_aligned_in_smp DEFINE_SPINLOCK(bdev_lock); 237static __cacheline_aligned_in_smp DEFINE_SPINLOCK(bdev_lock);
238static kmem_cache_t * bdev_cachep __read_mostly; 238static struct kmem_cache * bdev_cachep __read_mostly;
239 239
240static struct inode *bdev_alloc_inode(struct super_block *sb) 240static struct inode *bdev_alloc_inode(struct super_block *sb)
241{ 241{
242 struct bdev_inode *ei = kmem_cache_alloc(bdev_cachep, SLAB_KERNEL); 242 struct bdev_inode *ei = kmem_cache_alloc(bdev_cachep, GFP_KERNEL);
243 if (!ei) 243 if (!ei)
244 return NULL; 244 return NULL;
245 return &ei->vfs_inode; 245 return &ei->vfs_inode;
@@ -253,7 +253,7 @@ static void bdev_destroy_inode(struct inode *inode)
253 kmem_cache_free(bdev_cachep, bdi); 253 kmem_cache_free(bdev_cachep, bdi);
254} 254}
255 255
256static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 256static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
257{ 257{
258 struct bdev_inode *ei = (struct bdev_inode *) foo; 258 struct bdev_inode *ei = (struct bdev_inode *) foo;
259 struct block_device *bdev = &ei->bdev; 259 struct block_device *bdev = &ei->bdev;
diff --git a/fs/buffer.c b/fs/buffer.c
index 35527dca1dbc..517860f2d75b 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2908,7 +2908,7 @@ asmlinkage long sys_bdflush(int func, long data)
2908/* 2908/*
2909 * Buffer-head allocation 2909 * Buffer-head allocation
2910 */ 2910 */
2911static kmem_cache_t *bh_cachep; 2911static struct kmem_cache *bh_cachep;
2912 2912
2913/* 2913/*
2914 * Once the number of bh's in the machine exceeds this level, we start 2914 * Once the number of bh's in the machine exceeds this level, we start
@@ -2961,7 +2961,7 @@ void free_buffer_head(struct buffer_head *bh)
2961EXPORT_SYMBOL(free_buffer_head); 2961EXPORT_SYMBOL(free_buffer_head);
2962 2962
2963static void 2963static void
2964init_buffer_head(void *data, kmem_cache_t *cachep, unsigned long flags) 2964init_buffer_head(void *data, struct kmem_cache *cachep, unsigned long flags)
2965{ 2965{
2966 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == 2966 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
2967 SLAB_CTOR_CONSTRUCTOR) { 2967 SLAB_CTOR_CONSTRUCTOR) {
@@ -2972,7 +2972,6 @@ init_buffer_head(void *data, kmem_cache_t *cachep, unsigned long flags)
2972 } 2972 }
2973} 2973}
2974 2974
2975#ifdef CONFIG_HOTPLUG_CPU
2976static void buffer_exit_cpu(int cpu) 2975static void buffer_exit_cpu(int cpu)
2977{ 2976{
2978 int i; 2977 int i;
@@ -2994,7 +2993,6 @@ static int buffer_cpu_notify(struct notifier_block *self,
2994 buffer_exit_cpu((unsigned long)hcpu); 2993 buffer_exit_cpu((unsigned long)hcpu);
2995 return NOTIFY_OK; 2994 return NOTIFY_OK;
2996} 2995}
2997#endif /* CONFIG_HOTPLUG_CPU */
2998 2996
2999void __init buffer_init(void) 2997void __init buffer_init(void)
3000{ 2998{
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 84976cdbe713..71bc87a37fc1 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -34,6 +34,7 @@
34#include <linux/mempool.h> 34#include <linux/mempool.h>
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/kthread.h> 36#include <linux/kthread.h>
37#include <linux/freezer.h>
37#include "cifsfs.h" 38#include "cifsfs.h"
38#include "cifspdu.h" 39#include "cifspdu.h"
39#define DECLARE_GLOBALS_HERE 40#define DECLARE_GLOBALS_HERE
@@ -81,7 +82,7 @@ extern mempool_t *cifs_sm_req_poolp;
81extern mempool_t *cifs_req_poolp; 82extern mempool_t *cifs_req_poolp;
82extern mempool_t *cifs_mid_poolp; 83extern mempool_t *cifs_mid_poolp;
83 84
84extern kmem_cache_t *cifs_oplock_cachep; 85extern struct kmem_cache *cifs_oplock_cachep;
85 86
86static int 87static int
87cifs_read_super(struct super_block *sb, void *data, 88cifs_read_super(struct super_block *sb, void *data,
@@ -232,11 +233,11 @@ static int cifs_permission(struct inode * inode, int mask, struct nameidata *nd)
232 return generic_permission(inode, mask, NULL); 233 return generic_permission(inode, mask, NULL);
233} 234}
234 235
235static kmem_cache_t *cifs_inode_cachep; 236static struct kmem_cache *cifs_inode_cachep;
236static kmem_cache_t *cifs_req_cachep; 237static struct kmem_cache *cifs_req_cachep;
237static kmem_cache_t *cifs_mid_cachep; 238static struct kmem_cache *cifs_mid_cachep;
238kmem_cache_t *cifs_oplock_cachep; 239struct kmem_cache *cifs_oplock_cachep;
239static kmem_cache_t *cifs_sm_req_cachep; 240static struct kmem_cache *cifs_sm_req_cachep;
240mempool_t *cifs_sm_req_poolp; 241mempool_t *cifs_sm_req_poolp;
241mempool_t *cifs_req_poolp; 242mempool_t *cifs_req_poolp;
242mempool_t *cifs_mid_poolp; 243mempool_t *cifs_mid_poolp;
@@ -245,7 +246,7 @@ static struct inode *
245cifs_alloc_inode(struct super_block *sb) 246cifs_alloc_inode(struct super_block *sb)
246{ 247{
247 struct cifsInodeInfo *cifs_inode; 248 struct cifsInodeInfo *cifs_inode;
248 cifs_inode = kmem_cache_alloc(cifs_inode_cachep, SLAB_KERNEL); 249 cifs_inode = kmem_cache_alloc(cifs_inode_cachep, GFP_KERNEL);
249 if (!cifs_inode) 250 if (!cifs_inode)
250 return NULL; 251 return NULL;
251 cifs_inode->cifsAttrs = 0x20; /* default */ 252 cifs_inode->cifsAttrs = 0x20; /* default */
@@ -668,7 +669,7 @@ const struct file_operations cifs_dir_ops = {
668}; 669};
669 670
670static void 671static void
671cifs_init_once(void *inode, kmem_cache_t * cachep, unsigned long flags) 672cifs_init_once(void *inode, struct kmem_cache * cachep, unsigned long flags)
672{ 673{
673 struct cifsInodeInfo *cifsi = inode; 674 struct cifsInodeInfo *cifsi = inode;
674 675
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 71f77914ce93..2caca06b4bae 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -31,6 +31,7 @@
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/completion.h> 32#include <linux/completion.h>
33#include <linux/pagevec.h> 33#include <linux/pagevec.h>
34#include <linux/freezer.h>
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
35#include <asm/processor.h> 36#include <asm/processor.h>
36#include "cifspdu.h" 37#include "cifspdu.h"
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index bbc9cd34b6ea..aedf683f011f 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -153,7 +153,7 @@ cifs_buf_get(void)
153 albeit slightly larger than necessary and maxbuffersize 153 albeit slightly larger than necessary and maxbuffersize
154 defaults to this and can not be bigger */ 154 defaults to this and can not be bigger */
155 ret_buf = 155 ret_buf =
156 (struct smb_hdr *) mempool_alloc(cifs_req_poolp, SLAB_KERNEL | SLAB_NOFS); 156 (struct smb_hdr *) mempool_alloc(cifs_req_poolp, GFP_KERNEL | GFP_NOFS);
157 157
158 /* clear the first few header bytes */ 158 /* clear the first few header bytes */
159 /* for most paths, more is cleared in header_assemble */ 159 /* for most paths, more is cleared in header_assemble */
@@ -192,7 +192,7 @@ cifs_small_buf_get(void)
192 albeit slightly larger than necessary and maxbuffersize 192 albeit slightly larger than necessary and maxbuffersize
193 defaults to this and can not be bigger */ 193 defaults to this and can not be bigger */
194 ret_buf = 194 ret_buf =
195 (struct smb_hdr *) mempool_alloc(cifs_sm_req_poolp, SLAB_KERNEL | SLAB_NOFS); 195 (struct smb_hdr *) mempool_alloc(cifs_sm_req_poolp, GFP_KERNEL | GFP_NOFS);
196 if (ret_buf) { 196 if (ret_buf) {
197 /* No need to clear memory here, cleared in header assemble */ 197 /* No need to clear memory here, cleared in header assemble */
198 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/ 198 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 48d47b46b1fb..f80007eaebf4 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -34,7 +34,7 @@
34#include "cifs_debug.h" 34#include "cifs_debug.h"
35 35
36extern mempool_t *cifs_mid_poolp; 36extern mempool_t *cifs_mid_poolp;
37extern kmem_cache_t *cifs_oplock_cachep; 37extern struct kmem_cache *cifs_oplock_cachep;
38 38
39static struct mid_q_entry * 39static struct mid_q_entry *
40AllocMidQEntry(const struct smb_hdr *smb_buffer, struct cifsSesInfo *ses) 40AllocMidQEntry(const struct smb_hdr *smb_buffer, struct cifsSesInfo *ses)
@@ -51,7 +51,7 @@ AllocMidQEntry(const struct smb_hdr *smb_buffer, struct cifsSesInfo *ses)
51 } 51 }
52 52
53 temp = (struct mid_q_entry *) mempool_alloc(cifs_mid_poolp, 53 temp = (struct mid_q_entry *) mempool_alloc(cifs_mid_poolp,
54 SLAB_KERNEL | SLAB_NOFS); 54 GFP_KERNEL | GFP_NOFS);
55 if (temp == NULL) 55 if (temp == NULL)
56 return temp; 56 return temp;
57 else { 57 else {
@@ -118,7 +118,7 @@ AllocOplockQEntry(struct inode * pinode, __u16 fid, struct cifsTconInfo * tcon)
118 return NULL; 118 return NULL;
119 } 119 }
120 temp = (struct oplock_q_entry *) kmem_cache_alloc(cifs_oplock_cachep, 120 temp = (struct oplock_q_entry *) kmem_cache_alloc(cifs_oplock_cachep,
121 SLAB_KERNEL); 121 GFP_KERNEL);
122 if (temp == NULL) 122 if (temp == NULL)
123 return temp; 123 return temp;
124 else { 124 else {
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 88d123321164..b64659fa82d0 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -38,12 +38,12 @@ static void coda_clear_inode(struct inode *);
38static void coda_put_super(struct super_block *); 38static void coda_put_super(struct super_block *);
39static int coda_statfs(struct dentry *dentry, struct kstatfs *buf); 39static int coda_statfs(struct dentry *dentry, struct kstatfs *buf);
40 40
41static kmem_cache_t * coda_inode_cachep; 41static struct kmem_cache * coda_inode_cachep;
42 42
43static struct inode *coda_alloc_inode(struct super_block *sb) 43static struct inode *coda_alloc_inode(struct super_block *sb)
44{ 44{
45 struct coda_inode_info *ei; 45 struct coda_inode_info *ei;
46 ei = (struct coda_inode_info *)kmem_cache_alloc(coda_inode_cachep, SLAB_KERNEL); 46 ei = (struct coda_inode_info *)kmem_cache_alloc(coda_inode_cachep, GFP_KERNEL);
47 if (!ei) 47 if (!ei)
48 return NULL; 48 return NULL;
49 memset(&ei->c_fid, 0, sizeof(struct CodaFid)); 49 memset(&ei->c_fid, 0, sizeof(struct CodaFid));
@@ -58,7 +58,7 @@ static void coda_destroy_inode(struct inode *inode)
58 kmem_cache_free(coda_inode_cachep, ITOC(inode)); 58 kmem_cache_free(coda_inode_cachep, ITOC(inode));
59} 59}
60 60
61static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 61static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
62{ 62{
63 struct coda_inode_info *ei = (struct coda_inode_info *) foo; 63 struct coda_inode_info *ei = (struct coda_inode_info *) foo;
64 64
diff --git a/fs/compat.c b/fs/compat.c
index 06dad665b88f..a7e3f162fb15 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -871,7 +871,7 @@ asmlinkage long compat_sys_mount(char __user * dev_name, char __user * dir_name,
871 871
872 retval = -EINVAL; 872 retval = -EINVAL;
873 873
874 if (type_page) { 874 if (type_page && data_page) {
875 if (!strcmp((char *)type_page, SMBFS_NAME)) { 875 if (!strcmp((char *)type_page, SMBFS_NAME)) {
876 do_smb_super_data_conv((void *)data_page); 876 do_smb_super_data_conv((void *)data_page);
877 } else if (!strcmp((char *)type_page, NCPFS_NAME)) { 877 } else if (!strcmp((char *)type_page, NCPFS_NAME)) {
@@ -1144,7 +1144,9 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
1144 lastdirent = buf.previous; 1144 lastdirent = buf.previous;
1145 if (lastdirent) { 1145 if (lastdirent) {
1146 typeof(lastdirent->d_off) d_off = file->f_pos; 1146 typeof(lastdirent->d_off) d_off = file->f_pos;
1147 __put_user_unaligned(d_off, &lastdirent->d_off); 1147 error = -EFAULT;
1148 if (__put_user_unaligned(d_off, &lastdirent->d_off))
1149 goto out_putf;
1148 error = count - buf.count; 1150 error = count - buf.count;
1149 } 1151 }
1150 1152
@@ -1611,14 +1613,14 @@ int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1611 nr &= ~1UL; 1613 nr &= ~1UL;
1612 while (nr) { 1614 while (nr) {
1613 unsigned long h, l; 1615 unsigned long h, l;
1614 __get_user(l, ufdset); 1616 if (__get_user(l, ufdset) || __get_user(h, ufdset+1))
1615 __get_user(h, ufdset+1); 1617 return -EFAULT;
1616 ufdset += 2; 1618 ufdset += 2;
1617 *fdset++ = h << 32 | l; 1619 *fdset++ = h << 32 | l;
1618 nr -= 2; 1620 nr -= 2;
1619 } 1621 }
1620 if (odd) 1622 if (odd && __get_user(*fdset, ufdset))
1621 __get_user(*fdset, ufdset); 1623 return -EFAULT;
1622 } else { 1624 } else {
1623 /* Tricky, must clear full unsigned long in the 1625 /* Tricky, must clear full unsigned long in the
1624 * kernel fdset at the end, this makes sure that 1626 * kernel fdset at the end, this makes sure that
@@ -1630,14 +1632,14 @@ int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1630} 1632}
1631 1633
1632static 1634static
1633void compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset, 1635int compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1634 unsigned long *fdset) 1636 unsigned long *fdset)
1635{ 1637{
1636 unsigned long odd; 1638 unsigned long odd;
1637 nr = ROUND_UP(nr, __COMPAT_NFDBITS); 1639 nr = ROUND_UP(nr, __COMPAT_NFDBITS);
1638 1640
1639 if (!ufdset) 1641 if (!ufdset)
1640 return; 1642 return 0;
1641 1643
1642 odd = nr & 1UL; 1644 odd = nr & 1UL;
1643 nr &= ~1UL; 1645 nr &= ~1UL;
@@ -1645,13 +1647,14 @@ void compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1645 unsigned long h, l; 1647 unsigned long h, l;
1646 l = *fdset++; 1648 l = *fdset++;
1647 h = l >> 32; 1649 h = l >> 32;
1648 __put_user(l, ufdset); 1650 if (__put_user(l, ufdset) || __put_user(h, ufdset+1))
1649 __put_user(h, ufdset+1); 1651 return -EFAULT;
1650 ufdset += 2; 1652 ufdset += 2;
1651 nr -= 2; 1653 nr -= 2;
1652 } 1654 }
1653 if (odd) 1655 if (odd && __put_user(*fdset, ufdset))
1654 __put_user(*fdset, ufdset); 1656 return -EFAULT;
1657 return 0;
1655} 1658}
1656 1659
1657 1660
@@ -1726,10 +1729,10 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp,
1726 ret = 0; 1729 ret = 0;
1727 } 1730 }
1728 1731
1729 compat_set_fd_set(n, inp, fds.res_in); 1732 if (compat_set_fd_set(n, inp, fds.res_in) ||
1730 compat_set_fd_set(n, outp, fds.res_out); 1733 compat_set_fd_set(n, outp, fds.res_out) ||
1731 compat_set_fd_set(n, exp, fds.res_ex); 1734 compat_set_fd_set(n, exp, fds.res_ex))
1732 1735 ret = -EFAULT;
1733out: 1736out:
1734 kfree(bits); 1737 kfree(bits);
1735out_nofds: 1738out_nofds:
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 47bb78d1c3fb..bcc3caf5d820 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -211,8 +211,10 @@ static int do_video_stillpicture(unsigned int fd, unsigned int cmd, unsigned lon
211 up_native = 211 up_native =
212 compat_alloc_user_space(sizeof(struct video_still_picture)); 212 compat_alloc_user_space(sizeof(struct video_still_picture));
213 213
214 put_user(compat_ptr(fp), &up_native->iFrame); 214 err = put_user(compat_ptr(fp), &up_native->iFrame);
215 put_user(size, &up_native->size); 215 err |= put_user(size, &up_native->size);
216 if (err)
217 return -EFAULT;
216 218
217 err = sys_ioctl(fd, cmd, (unsigned long) up_native); 219 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
218 220
@@ -236,8 +238,10 @@ static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned
236 err |= get_user(length, &up->length); 238 err |= get_user(length, &up->length);
237 239
238 up_native = compat_alloc_user_space(sizeof(struct video_spu_palette)); 240 up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
239 put_user(compat_ptr(palp), &up_native->palette); 241 err = put_user(compat_ptr(palp), &up_native->palette);
240 put_user(length, &up_native->length); 242 err |= put_user(length, &up_native->length);
243 if (err)
244 return -EFAULT;
241 245
242 err = sys_ioctl(fd, cmd, (unsigned long) up_native); 246 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
243 247
@@ -2043,16 +2047,19 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2043 struct serial_struct ss; 2047 struct serial_struct ss;
2044 mm_segment_t oldseg = get_fs(); 2048 mm_segment_t oldseg = get_fs();
2045 __u32 udata; 2049 __u32 udata;
2050 unsigned int base;
2046 2051
2047 if (cmd == TIOCSSERIAL) { 2052 if (cmd == TIOCSSERIAL) {
2048 if (!access_ok(VERIFY_READ, ss32, sizeof(SS32))) 2053 if (!access_ok(VERIFY_READ, ss32, sizeof(SS32)))
2049 return -EFAULT; 2054 return -EFAULT;
2050 if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base))) 2055 if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base)))
2051 return -EFAULT; 2056 return -EFAULT;
2052 __get_user(udata, &ss32->iomem_base); 2057 if (__get_user(udata, &ss32->iomem_base))
2058 return -EFAULT;
2053 ss.iomem_base = compat_ptr(udata); 2059 ss.iomem_base = compat_ptr(udata);
2054 __get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift); 2060 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
2055 __get_user(ss.port_high, &ss32->port_high); 2061 __get_user(ss.port_high, &ss32->port_high))
2062 return -EFAULT;
2056 ss.iomap_base = 0UL; 2063 ss.iomap_base = 0UL;
2057 } 2064 }
2058 set_fs(KERNEL_DS); 2065 set_fs(KERNEL_DS);
@@ -2063,12 +2070,12 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2063 return -EFAULT; 2070 return -EFAULT;
2064 if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base))) 2071 if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base)))
2065 return -EFAULT; 2072 return -EFAULT;
2066 __put_user((unsigned long)ss.iomem_base >> 32 ? 2073 base = (unsigned long)ss.iomem_base >> 32 ?
2067 0xffffffff : (unsigned)(unsigned long)ss.iomem_base, 2074 0xffffffff : (unsigned)(unsigned long)ss.iomem_base;
2068 &ss32->iomem_base); 2075 if (__put_user(base, &ss32->iomem_base) ||
2069 __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift); 2076 __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
2070 __put_user(ss.port_high, &ss32->port_high); 2077 __put_user(ss.port_high, &ss32->port_high))
2071 2078 return -EFAULT;
2072 } 2079 }
2073 return err; 2080 return err;
2074} 2081}
diff --git a/fs/configfs/configfs_internal.h b/fs/configfs/configfs_internal.h
index 3f4ff7a242b9..f92cd303d2c9 100644
--- a/fs/configfs/configfs_internal.h
+++ b/fs/configfs/configfs_internal.h
@@ -49,7 +49,7 @@ struct configfs_dirent {
49#define CONFIGFS_NOT_PINNED (CONFIGFS_ITEM_ATTR) 49#define CONFIGFS_NOT_PINNED (CONFIGFS_ITEM_ATTR)
50 50
51extern struct vfsmount * configfs_mount; 51extern struct vfsmount * configfs_mount;
52extern kmem_cache_t *configfs_dir_cachep; 52extern struct kmem_cache *configfs_dir_cachep;
53 53
54extern int configfs_is_root(struct config_item *item); 54extern int configfs_is_root(struct config_item *item);
55 55
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c
index 68bd5c93ca52..ed678529ebb2 100644
--- a/fs/configfs/mount.c
+++ b/fs/configfs/mount.c
@@ -38,7 +38,7 @@
38 38
39struct vfsmount * configfs_mount = NULL; 39struct vfsmount * configfs_mount = NULL;
40struct super_block * configfs_sb = NULL; 40struct super_block * configfs_sb = NULL;
41kmem_cache_t *configfs_dir_cachep; 41struct kmem_cache *configfs_dir_cachep;
42static int configfs_mnt_count = 0; 42static int configfs_mnt_count = 0;
43 43
44static struct super_operations configfs_ops = { 44static struct super_operations configfs_ops = {
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index a624c3ec8189..0509cedd415c 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -481,6 +481,8 @@ static int cramfs_readpage(struct file *file, struct page * page)
481 pgdata = kmap(page); 481 pgdata = kmap(page);
482 if (compr_len == 0) 482 if (compr_len == 0)
483 ; /* hole */ 483 ; /* hole */
484 else if (compr_len > (PAGE_CACHE_SIZE << 1))
485 printk(KERN_ERR "cramfs: bad compressed blocksize %u\n", compr_len);
484 else { 486 else {
485 mutex_lock(&read_mutex); 487 mutex_lock(&read_mutex);
486 bytes_filled = cramfs_uncompress_block(pgdata, 488 bytes_filled = cramfs_uncompress_block(pgdata,
diff --git a/fs/dcache.c b/fs/dcache.c
index fd4a428998ef..d68631f18df1 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -43,7 +43,7 @@ static __cacheline_aligned_in_smp DEFINE_SEQLOCK(rename_lock);
43 43
44EXPORT_SYMBOL(dcache_lock); 44EXPORT_SYMBOL(dcache_lock);
45 45
46static kmem_cache_t *dentry_cache __read_mostly; 46static struct kmem_cache *dentry_cache __read_mostly;
47 47
48#define DNAME_INLINE_LEN (sizeof(struct dentry)-offsetof(struct dentry,d_iname)) 48#define DNAME_INLINE_LEN (sizeof(struct dentry)-offsetof(struct dentry,d_iname))
49 49
@@ -68,15 +68,19 @@ struct dentry_stat_t dentry_stat = {
68 .age_limit = 45, 68 .age_limit = 45,
69}; 69};
70 70
71static void d_callback(struct rcu_head *head) 71static void __d_free(struct dentry *dentry)
72{ 72{
73 struct dentry * dentry = container_of(head, struct dentry, d_u.d_rcu);
74
75 if (dname_external(dentry)) 73 if (dname_external(dentry))
76 kfree(dentry->d_name.name); 74 kfree(dentry->d_name.name);
77 kmem_cache_free(dentry_cache, dentry); 75 kmem_cache_free(dentry_cache, dentry);
78} 76}
79 77
78static void d_callback(struct rcu_head *head)
79{
80 struct dentry * dentry = container_of(head, struct dentry, d_u.d_rcu);
81 __d_free(dentry);
82}
83
80/* 84/*
81 * no dcache_lock, please. The caller must decrement dentry_stat.nr_dentry 85 * no dcache_lock, please. The caller must decrement dentry_stat.nr_dentry
82 * inside dcache_lock. 86 * inside dcache_lock.
@@ -85,7 +89,11 @@ static void d_free(struct dentry *dentry)
85{ 89{
86 if (dentry->d_op && dentry->d_op->d_release) 90 if (dentry->d_op && dentry->d_op->d_release)
87 dentry->d_op->d_release(dentry); 91 dentry->d_op->d_release(dentry);
88 call_rcu(&dentry->d_u.d_rcu, d_callback); 92 /* if dentry was never inserted into hash, immediate free is OK */
93 if (dentry->d_hash.pprev == NULL)
94 __d_free(dentry);
95 else
96 call_rcu(&dentry->d_u.d_rcu, d_callback);
89} 97}
90 98
91/* 99/*
@@ -2072,10 +2080,10 @@ static void __init dcache_init(unsigned long mempages)
2072} 2080}
2073 2081
2074/* SLAB cache for __getname() consumers */ 2082/* SLAB cache for __getname() consumers */
2075kmem_cache_t *names_cachep __read_mostly; 2083struct kmem_cache *names_cachep __read_mostly;
2076 2084
2077/* SLAB cache for file structures */ 2085/* SLAB cache for file structures */
2078kmem_cache_t *filp_cachep __read_mostly; 2086struct kmem_cache *filp_cachep __read_mostly;
2079 2087
2080EXPORT_SYMBOL(d_genocide); 2088EXPORT_SYMBOL(d_genocide);
2081 2089
diff --git a/fs/dcookies.c b/fs/dcookies.c
index 0c4b0674854b..21af1629f9bc 100644
--- a/fs/dcookies.c
+++ b/fs/dcookies.c
@@ -37,7 +37,7 @@ struct dcookie_struct {
37 37
38static LIST_HEAD(dcookie_users); 38static LIST_HEAD(dcookie_users);
39static DEFINE_MUTEX(dcookie_mutex); 39static DEFINE_MUTEX(dcookie_mutex);
40static kmem_cache_t *dcookie_cache __read_mostly; 40static struct kmem_cache *dcookie_cache __read_mostly;
41static struct list_head *dcookie_hashtable __read_mostly; 41static struct list_head *dcookie_hashtable __read_mostly;
42static size_t hash_size __read_mostly; 42static size_t hash_size __read_mostly;
43 43
diff --git a/fs/dlm/memory.c b/fs/dlm/memory.c
index 989b608fd836..5352b03ff5aa 100644
--- a/fs/dlm/memory.c
+++ b/fs/dlm/memory.c
@@ -15,7 +15,7 @@
15#include "config.h" 15#include "config.h"
16#include "memory.h" 16#include "memory.h"
17 17
18static kmem_cache_t *lkb_cache; 18static struct kmem_cache *lkb_cache;
19 19
20 20
21int dlm_memory_init(void) 21int dlm_memory_init(void)
diff --git a/fs/dnotify.c b/fs/dnotify.c
index 2b0442db67e0..1f26a2b9eee1 100644
--- a/fs/dnotify.c
+++ b/fs/dnotify.c
@@ -23,7 +23,7 @@
23 23
24int dir_notify_enable __read_mostly = 1; 24int dir_notify_enable __read_mostly = 1;
25 25
26static kmem_cache_t *dn_cache __read_mostly; 26static struct kmem_cache *dn_cache __read_mostly;
27 27
28static void redo_inode_mask(struct inode *inode) 28static void redo_inode_mask(struct inode *inode)
29{ 29{
@@ -77,7 +77,7 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
77 inode = filp->f_dentry->d_inode; 77 inode = filp->f_dentry->d_inode;
78 if (!S_ISDIR(inode->i_mode)) 78 if (!S_ISDIR(inode->i_mode))
79 return -ENOTDIR; 79 return -ENOTDIR;
80 dn = kmem_cache_alloc(dn_cache, SLAB_KERNEL); 80 dn = kmem_cache_alloc(dn_cache, GFP_KERNEL);
81 if (dn == NULL) 81 if (dn == NULL)
82 return -ENOMEM; 82 return -ENOMEM;
83 spin_lock(&inode->i_lock); 83 spin_lock(&inode->i_lock);
diff --git a/fs/dquot.c b/fs/dquot.c
index 9af789567e51..f9cd5e23ebdf 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -131,7 +131,7 @@ static struct quota_format_type *quota_formats; /* List of registered formats */
131static struct quota_module_name module_names[] = INIT_QUOTA_MODULE_NAMES; 131static struct quota_module_name module_names[] = INIT_QUOTA_MODULE_NAMES;
132 132
133/* SLAB cache for dquot structures */ 133/* SLAB cache for dquot structures */
134static kmem_cache_t *dquot_cachep; 134static struct kmem_cache *dquot_cachep;
135 135
136int register_quota_format(struct quota_format_type *fmt) 136int register_quota_format(struct quota_format_type *fmt)
137{ 137{
@@ -600,7 +600,7 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
600{ 600{
601 struct dquot *dquot; 601 struct dquot *dquot;
602 602
603 dquot = kmem_cache_alloc(dquot_cachep, SLAB_NOFS); 603 dquot = kmem_cache_alloc(dquot_cachep, GFP_NOFS);
604 if(!dquot) 604 if(!dquot)
605 return NODQUOT; 605 return NODQUOT;
606 606
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index f63a7755fe86..7196f50fe152 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -628,7 +628,7 @@ int ecryptfs_decrypt_page(struct file *file, struct page *page)
628 num_extents_per_page = PAGE_CACHE_SIZE / crypt_stat->extent_size; 628 num_extents_per_page = PAGE_CACHE_SIZE / crypt_stat->extent_size;
629 base_extent = (page->index * num_extents_per_page); 629 base_extent = (page->index * num_extents_per_page);
630 lower_page_virt = kmem_cache_alloc(ecryptfs_lower_page_cache, 630 lower_page_virt = kmem_cache_alloc(ecryptfs_lower_page_cache,
631 SLAB_KERNEL); 631 GFP_KERNEL);
632 if (!lower_page_virt) { 632 if (!lower_page_virt) {
633 rc = -ENOMEM; 633 rc = -ENOMEM;
634 ecryptfs_printk(KERN_ERR, "Error getting page for encrypted " 634 ecryptfs_printk(KERN_ERR, "Error getting page for encrypted "
@@ -1334,7 +1334,7 @@ int ecryptfs_write_headers(struct dentry *ecryptfs_dentry,
1334 goto out; 1334 goto out;
1335 } 1335 }
1336 /* Released in this function */ 1336 /* Released in this function */
1337 page_virt = kmem_cache_alloc(ecryptfs_header_cache_0, SLAB_USER); 1337 page_virt = kmem_cache_alloc(ecryptfs_header_cache_0, GFP_USER);
1338 if (!page_virt) { 1338 if (!page_virt) {
1339 ecryptfs_printk(KERN_ERR, "Out of memory\n"); 1339 ecryptfs_printk(KERN_ERR, "Out of memory\n");
1340 rc = -ENOMEM; 1340 rc = -ENOMEM;
@@ -1493,7 +1493,7 @@ int ecryptfs_read_headers(struct dentry *ecryptfs_dentry,
1493 &ecryptfs_inode_to_private(ecryptfs_dentry->d_inode)->crypt_stat; 1493 &ecryptfs_inode_to_private(ecryptfs_dentry->d_inode)->crypt_stat;
1494 1494
1495 /* Read the first page from the underlying file */ 1495 /* Read the first page from the underlying file */
1496 page_virt = kmem_cache_alloc(ecryptfs_header_cache_1, SLAB_USER); 1496 page_virt = kmem_cache_alloc(ecryptfs_header_cache_1, GFP_USER);
1497 if (!page_virt) { 1497 if (!page_virt) {
1498 rc = -ENOMEM; 1498 rc = -ENOMEM;
1499 ecryptfs_printk(KERN_ERR, "Unable to allocate page_virt\n"); 1499 ecryptfs_printk(KERN_ERR, "Unable to allocate page_virt\n");
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index a92ef05eff8f..42099e779a56 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -250,7 +250,7 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
250 int lower_flags; 250 int lower_flags;
251 251
252 /* Released in ecryptfs_release or end of function if failure */ 252 /* Released in ecryptfs_release or end of function if failure */
253 file_info = kmem_cache_alloc(ecryptfs_file_info_cache, SLAB_KERNEL); 253 file_info = kmem_cache_alloc(ecryptfs_file_info_cache, GFP_KERNEL);
254 ecryptfs_set_file_private(file, file_info); 254 ecryptfs_set_file_private(file, file_info);
255 if (!file_info) { 255 if (!file_info) {
256 ecryptfs_printk(KERN_ERR, 256 ecryptfs_printk(KERN_ERR,
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index dfcc68484f47..8a1945a84c36 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -369,7 +369,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
369 BUG_ON(!atomic_read(&lower_dentry->d_count)); 369 BUG_ON(!atomic_read(&lower_dentry->d_count));
370 ecryptfs_set_dentry_private(dentry, 370 ecryptfs_set_dentry_private(dentry,
371 kmem_cache_alloc(ecryptfs_dentry_info_cache, 371 kmem_cache_alloc(ecryptfs_dentry_info_cache,
372 SLAB_KERNEL)); 372 GFP_KERNEL));
373 if (!ecryptfs_dentry_to_private(dentry)) { 373 if (!ecryptfs_dentry_to_private(dentry)) {
374 rc = -ENOMEM; 374 rc = -ENOMEM;
375 ecryptfs_printk(KERN_ERR, "Out of memory whilst attempting " 375 ecryptfs_printk(KERN_ERR, "Out of memory whilst attempting "
@@ -404,7 +404,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
404 /* Released in this function */ 404 /* Released in this function */
405 page_virt = 405 page_virt =
406 (char *)kmem_cache_alloc(ecryptfs_header_cache_2, 406 (char *)kmem_cache_alloc(ecryptfs_header_cache_2,
407 SLAB_USER); 407 GFP_USER);
408 if (!page_virt) { 408 if (!page_virt) {
409 rc = -ENOMEM; 409 rc = -ENOMEM;
410 ecryptfs_printk(KERN_ERR, 410 ecryptfs_printk(KERN_ERR,
@@ -795,7 +795,7 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length)
795 /* Released at out_free: label */ 795 /* Released at out_free: label */
796 ecryptfs_set_file_private(&fake_ecryptfs_file, 796 ecryptfs_set_file_private(&fake_ecryptfs_file,
797 kmem_cache_alloc(ecryptfs_file_info_cache, 797 kmem_cache_alloc(ecryptfs_file_info_cache,
798 SLAB_KERNEL)); 798 GFP_KERNEL));
799 if (unlikely(!ecryptfs_file_to_private(&fake_ecryptfs_file))) { 799 if (unlikely(!ecryptfs_file_to_private(&fake_ecryptfs_file))) {
800 rc = -ENOMEM; 800 rc = -ENOMEM;
801 goto out; 801 goto out;
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index c3746f56d162..745c0f1bfbbd 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -207,7 +207,7 @@ parse_tag_3_packet(struct ecryptfs_crypt_stat *crypt_stat,
207 /* Released: wipe_auth_tok_list called in ecryptfs_parse_packet_set or 207 /* Released: wipe_auth_tok_list called in ecryptfs_parse_packet_set or
208 * at end of function upon failure */ 208 * at end of function upon failure */
209 auth_tok_list_item = 209 auth_tok_list_item =
210 kmem_cache_alloc(ecryptfs_auth_tok_list_item_cache, SLAB_KERNEL); 210 kmem_cache_alloc(ecryptfs_auth_tok_list_item_cache, GFP_KERNEL);
211 if (!auth_tok_list_item) { 211 if (!auth_tok_list_item) {
212 ecryptfs_printk(KERN_ERR, "Unable to allocate memory\n"); 212 ecryptfs_printk(KERN_ERR, "Unable to allocate memory\n");
213 rc = -ENOMEM; 213 rc = -ENOMEM;
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index a78d87d14baf..3ede12b25933 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -378,7 +378,7 @@ ecryptfs_fill_super(struct super_block *sb, void *raw_data, int silent)
378 /* Released in ecryptfs_put_super() */ 378 /* Released in ecryptfs_put_super() */
379 ecryptfs_set_superblock_private(sb, 379 ecryptfs_set_superblock_private(sb,
380 kmem_cache_alloc(ecryptfs_sb_info_cache, 380 kmem_cache_alloc(ecryptfs_sb_info_cache,
381 SLAB_KERNEL)); 381 GFP_KERNEL));
382 if (!ecryptfs_superblock_to_private(sb)) { 382 if (!ecryptfs_superblock_to_private(sb)) {
383 ecryptfs_printk(KERN_WARNING, "Out of memory\n"); 383 ecryptfs_printk(KERN_WARNING, "Out of memory\n");
384 rc = -ENOMEM; 384 rc = -ENOMEM;
@@ -402,7 +402,7 @@ ecryptfs_fill_super(struct super_block *sb, void *raw_data, int silent)
402 /* through deactivate_super(sb) from get_sb_nodev() */ 402 /* through deactivate_super(sb) from get_sb_nodev() */
403 ecryptfs_set_dentry_private(sb->s_root, 403 ecryptfs_set_dentry_private(sb->s_root,
404 kmem_cache_alloc(ecryptfs_dentry_info_cache, 404 kmem_cache_alloc(ecryptfs_dentry_info_cache,
405 SLAB_KERNEL)); 405 GFP_KERNEL));
406 if (!ecryptfs_dentry_to_private(sb->s_root)) { 406 if (!ecryptfs_dentry_to_private(sb->s_root)) {
407 ecryptfs_printk(KERN_ERR, 407 ecryptfs_printk(KERN_ERR,
408 "dentry_info_cache alloc failed\n"); 408 "dentry_info_cache alloc failed\n");
@@ -546,7 +546,7 @@ inode_info_init_once(void *vptr, struct kmem_cache *cachep, unsigned long flags)
546} 546}
547 547
548static struct ecryptfs_cache_info { 548static struct ecryptfs_cache_info {
549 kmem_cache_t **cache; 549 struct kmem_cache **cache;
550 const char *name; 550 const char *name;
551 size_t size; 551 size_t size;
552 void (*ctor)(void*, struct kmem_cache *, unsigned long); 552 void (*ctor)(void*, struct kmem_cache *, unsigned long);
@@ -691,7 +691,7 @@ static ssize_t version_show(struct ecryptfs_obj *obj, char *buff)
691 691
692static struct ecryptfs_attribute sysfs_attr_version = __ATTR_RO(version); 692static struct ecryptfs_attribute sysfs_attr_version = __ATTR_RO(version);
693 693
694struct ecryptfs_version_str_map_elem { 694static struct ecryptfs_version_str_map_elem {
695 u32 flag; 695 u32 flag;
696 char *str; 696 char *str;
697} ecryptfs_version_str_map[] = { 697} ecryptfs_version_str_map[] = {
diff --git a/fs/ecryptfs/super.c b/fs/ecryptfs/super.c
index 825757ae4867..eaa5daaf106e 100644
--- a/fs/ecryptfs/super.c
+++ b/fs/ecryptfs/super.c
@@ -50,7 +50,7 @@ static struct inode *ecryptfs_alloc_inode(struct super_block *sb)
50 struct inode *inode = NULL; 50 struct inode *inode = NULL;
51 51
52 ecryptfs_inode = kmem_cache_alloc(ecryptfs_inode_info_cache, 52 ecryptfs_inode = kmem_cache_alloc(ecryptfs_inode_info_cache,
53 SLAB_KERNEL); 53 GFP_KERNEL);
54 if (unlikely(!ecryptfs_inode)) 54 if (unlikely(!ecryptfs_inode))
55 goto out; 55 goto out;
56 ecryptfs_init_crypt_stat(&ecryptfs_inode->crypt_stat); 56 ecryptfs_init_crypt_stat(&ecryptfs_inode->crypt_stat);
diff --git a/fs/efs/super.c b/fs/efs/super.c
index b3f50651eb6b..dfebf21289f4 100644
--- a/fs/efs/super.c
+++ b/fs/efs/super.c
@@ -52,12 +52,12 @@ static struct pt_types sgi_pt_types[] = {
52}; 52};
53 53
54 54
55static kmem_cache_t * efs_inode_cachep; 55static struct kmem_cache * efs_inode_cachep;
56 56
57static struct inode *efs_alloc_inode(struct super_block *sb) 57static struct inode *efs_alloc_inode(struct super_block *sb)
58{ 58{
59 struct efs_inode_info *ei; 59 struct efs_inode_info *ei;
60 ei = (struct efs_inode_info *)kmem_cache_alloc(efs_inode_cachep, SLAB_KERNEL); 60 ei = (struct efs_inode_info *)kmem_cache_alloc(efs_inode_cachep, GFP_KERNEL);
61 if (!ei) 61 if (!ei)
62 return NULL; 62 return NULL;
63 return &ei->vfs_inode; 63 return &ei->vfs_inode;
@@ -68,7 +68,7 @@ static void efs_destroy_inode(struct inode *inode)
68 kmem_cache_free(efs_inode_cachep, INODE_INFO(inode)); 68 kmem_cache_free(efs_inode_cachep, INODE_INFO(inode));
69} 69}
70 70
71static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 71static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
72{ 72{
73 struct efs_inode_info *ei = (struct efs_inode_info *) foo; 73 struct efs_inode_info *ei = (struct efs_inode_info *) foo;
74 74
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index ae228ec54e94..88a6f8d0b88e 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -283,10 +283,10 @@ static struct mutex epmutex;
283static struct poll_safewake psw; 283static struct poll_safewake psw;
284 284
285/* Slab cache used to allocate "struct epitem" */ 285/* Slab cache used to allocate "struct epitem" */
286static kmem_cache_t *epi_cache __read_mostly; 286static struct kmem_cache *epi_cache __read_mostly;
287 287
288/* Slab cache used to allocate "struct eppoll_entry" */ 288/* Slab cache used to allocate "struct eppoll_entry" */
289static kmem_cache_t *pwq_cache __read_mostly; 289static struct kmem_cache *pwq_cache __read_mostly;
290 290
291/* Virtual fs used to allocate inodes for eventpoll files */ 291/* Virtual fs used to allocate inodes for eventpoll files */
292static struct vfsmount *eventpoll_mnt __read_mostly; 292static struct vfsmount *eventpoll_mnt __read_mostly;
@@ -961,7 +961,7 @@ static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead,
961 struct epitem *epi = ep_item_from_epqueue(pt); 961 struct epitem *epi = ep_item_from_epqueue(pt);
962 struct eppoll_entry *pwq; 962 struct eppoll_entry *pwq;
963 963
964 if (epi->nwait >= 0 && (pwq = kmem_cache_alloc(pwq_cache, SLAB_KERNEL))) { 964 if (epi->nwait >= 0 && (pwq = kmem_cache_alloc(pwq_cache, GFP_KERNEL))) {
965 init_waitqueue_func_entry(&pwq->wait, ep_poll_callback); 965 init_waitqueue_func_entry(&pwq->wait, ep_poll_callback);
966 pwq->whead = whead; 966 pwq->whead = whead;
967 pwq->base = epi; 967 pwq->base = epi;
@@ -1004,7 +1004,7 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event,
1004 struct ep_pqueue epq; 1004 struct ep_pqueue epq;
1005 1005
1006 error = -ENOMEM; 1006 error = -ENOMEM;
1007 if (!(epi = kmem_cache_alloc(epi_cache, SLAB_KERNEL))) 1007 if (!(epi = kmem_cache_alloc(epi_cache, GFP_KERNEL)))
1008 goto eexit_1; 1008 goto eexit_1;
1009 1009
1010 /* Item initialization follow here ... */ 1010 /* Item initialization follow here ... */
diff --git a/fs/exec.c b/fs/exec.c
index d993ea1a81ae..add0e03c3ea9 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -404,7 +404,7 @@ int setup_arg_pages(struct linux_binprm *bprm,
404 bprm->loader += stack_base; 404 bprm->loader += stack_base;
405 bprm->exec += stack_base; 405 bprm->exec += stack_base;
406 406
407 mpnt = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 407 mpnt = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
408 if (!mpnt) 408 if (!mpnt)
409 return -ENOMEM; 409 return -ENOMEM;
410 410
@@ -1515,7 +1515,8 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
1515 ispipe = 1; 1515 ispipe = 1;
1516 } else 1516 } else
1517 file = filp_open(corename, 1517 file = filp_open(corename,
1518 O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE, 0600); 1518 O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag,
1519 0600);
1519 if (IS_ERR(file)) 1520 if (IS_ERR(file))
1520 goto fail_unlock; 1521 goto fail_unlock;
1521 inode = file->f_dentry->d_inode; 1522 inode = file->f_dentry->d_inode;
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index 1dfba77eab10..e3cf8c81507f 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -44,6 +44,7 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
44 if (!S_ISDIR(inode->i_mode)) 44 if (!S_ISDIR(inode->i_mode))
45 flags &= ~EXT2_DIRSYNC_FL; 45 flags &= ~EXT2_DIRSYNC_FL;
46 46
47 mutex_lock(&inode->i_mutex);
47 oldflags = ei->i_flags; 48 oldflags = ei->i_flags;
48 49
49 /* 50 /*
@@ -53,13 +54,16 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
53 * This test looks nicer. Thanks to Pauline Middelink 54 * This test looks nicer. Thanks to Pauline Middelink
54 */ 55 */
55 if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) { 56 if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
56 if (!capable(CAP_LINUX_IMMUTABLE)) 57 if (!capable(CAP_LINUX_IMMUTABLE)) {
58 mutex_unlock(&inode->i_mutex);
57 return -EPERM; 59 return -EPERM;
60 }
58 } 61 }
59 62
60 flags = flags & EXT2_FL_USER_MODIFIABLE; 63 flags = flags & EXT2_FL_USER_MODIFIABLE;
61 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE; 64 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
62 ei->i_flags = flags; 65 ei->i_flags = flags;
66 mutex_unlock(&inode->i_mutex);
63 67
64 ext2_set_inode_flags(inode); 68 ext2_set_inode_flags(inode);
65 inode->i_ctime = CURRENT_TIME_SEC; 69 inode->i_ctime = CURRENT_TIME_SEC;
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index d8b9abd95d07..255cef5f7420 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -135,12 +135,12 @@ static void ext2_put_super (struct super_block * sb)
135 return; 135 return;
136} 136}
137 137
138static kmem_cache_t * ext2_inode_cachep; 138static struct kmem_cache * ext2_inode_cachep;
139 139
140static struct inode *ext2_alloc_inode(struct super_block *sb) 140static struct inode *ext2_alloc_inode(struct super_block *sb)
141{ 141{
142 struct ext2_inode_info *ei; 142 struct ext2_inode_info *ei;
143 ei = (struct ext2_inode_info *)kmem_cache_alloc(ext2_inode_cachep, SLAB_KERNEL); 143 ei = (struct ext2_inode_info *)kmem_cache_alloc(ext2_inode_cachep, GFP_KERNEL);
144 if (!ei) 144 if (!ei)
145 return NULL; 145 return NULL;
146#ifdef CONFIG_EXT2_FS_POSIX_ACL 146#ifdef CONFIG_EXT2_FS_POSIX_ACL
@@ -156,7 +156,7 @@ static void ext2_destroy_inode(struct inode *inode)
156 kmem_cache_free(ext2_inode_cachep, EXT2_I(inode)); 156 kmem_cache_free(ext2_inode_cachep, EXT2_I(inode));
157} 157}
158 158
159static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 159static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
160{ 160{
161 struct ext2_inode_info *ei = (struct ext2_inode_info *) foo; 161 struct ext2_inode_info *ei = (struct ext2_inode_info *) foo;
162 162
@@ -1090,8 +1090,10 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
1090{ 1090{
1091 struct super_block *sb = dentry->d_sb; 1091 struct super_block *sb = dentry->d_sb;
1092 struct ext2_sb_info *sbi = EXT2_SB(sb); 1092 struct ext2_sb_info *sbi = EXT2_SB(sb);
1093 struct ext2_super_block *es = sbi->s_es;
1093 unsigned long overhead; 1094 unsigned long overhead;
1094 int i; 1095 int i;
1096 u64 fsid;
1095 1097
1096 if (test_opt (sb, MINIX_DF)) 1098 if (test_opt (sb, MINIX_DF))
1097 overhead = 0; 1099 overhead = 0;
@@ -1104,7 +1106,7 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
1104 * All of the blocks before first_data_block are 1106 * All of the blocks before first_data_block are
1105 * overhead 1107 * overhead
1106 */ 1108 */
1107 overhead = le32_to_cpu(sbi->s_es->s_first_data_block); 1109 overhead = le32_to_cpu(es->s_first_data_block);
1108 1110
1109 /* 1111 /*
1110 * Add the overhead attributed to the superblock and 1112 * Add the overhead attributed to the superblock and
@@ -1125,14 +1127,18 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
1125 1127
1126 buf->f_type = EXT2_SUPER_MAGIC; 1128 buf->f_type = EXT2_SUPER_MAGIC;
1127 buf->f_bsize = sb->s_blocksize; 1129 buf->f_bsize = sb->s_blocksize;
1128 buf->f_blocks = le32_to_cpu(sbi->s_es->s_blocks_count) - overhead; 1130 buf->f_blocks = le32_to_cpu(es->s_blocks_count) - overhead;
1129 buf->f_bfree = ext2_count_free_blocks(sb); 1131 buf->f_bfree = ext2_count_free_blocks(sb);
1130 buf->f_bavail = buf->f_bfree - le32_to_cpu(sbi->s_es->s_r_blocks_count); 1132 buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count);
1131 if (buf->f_bfree < le32_to_cpu(sbi->s_es->s_r_blocks_count)) 1133 if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count))
1132 buf->f_bavail = 0; 1134 buf->f_bavail = 0;
1133 buf->f_files = le32_to_cpu(sbi->s_es->s_inodes_count); 1135 buf->f_files = le32_to_cpu(es->s_inodes_count);
1134 buf->f_ffree = ext2_count_free_inodes (sb); 1136 buf->f_ffree = ext2_count_free_inodes(sb);
1135 buf->f_namelen = EXT2_NAME_LEN; 1137 buf->f_namelen = EXT2_NAME_LEN;
1138 fsid = le64_to_cpup((void *)es->s_uuid) ^
1139 le64_to_cpup((void *)es->s_uuid + sizeof(u64));
1140 buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
1141 buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
1136 return 0; 1142 return 0;
1137} 1143}
1138 1144
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index af52a7f8b291..247efd0b51d6 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -342,12 +342,9 @@ static void ext2_xattr_update_super_block(struct super_block *sb)
342 if (EXT2_HAS_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR)) 342 if (EXT2_HAS_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR))
343 return; 343 return;
344 344
345 lock_super(sb); 345 EXT2_SET_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR);
346 EXT2_SB(sb)->s_es->s_feature_compat |=
347 cpu_to_le32(EXT2_FEATURE_COMPAT_EXT_ATTR);
348 sb->s_dirt = 1; 346 sb->s_dirt = 1;
349 mark_buffer_dirty(EXT2_SB(sb)->s_sbh); 347 mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
350 unlock_super(sb);
351} 348}
352 349
353/* 350/*
diff --git a/fs/ext3/Makefile b/fs/ext3/Makefile
index 704cd44a40c2..e77766a8b3f0 100644
--- a/fs/ext3/Makefile
+++ b/fs/ext3/Makefile
@@ -5,7 +5,7 @@
5obj-$(CONFIG_EXT3_FS) += ext3.o 5obj-$(CONFIG_EXT3_FS) += ext3.o
6 6
7ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ 7ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
8 ioctl.o namei.o super.o symlink.o hash.o resize.o 8 ioctl.o namei.o super.o symlink.o hash.o resize.o ext3_jbd.o
9 9
10ext3-$(CONFIG_EXT3_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o 10ext3-$(CONFIG_EXT3_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o
11ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o 11ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index b41a7d7e20f0..22161740ba29 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -144,7 +144,7 @@ restart:
144 144
145 printk("Block Allocation Reservation Windows Map (%s):\n", fn); 145 printk("Block Allocation Reservation Windows Map (%s):\n", fn);
146 while (n) { 146 while (n) {
147 rsv = list_entry(n, struct ext3_reserve_window_node, rsv_node); 147 rsv = rb_entry(n, struct ext3_reserve_window_node, rsv_node);
148 if (verbose) 148 if (verbose)
149 printk("reservation window 0x%p " 149 printk("reservation window 0x%p "
150 "start: %lu, end: %lu\n", 150 "start: %lu, end: %lu\n",
@@ -730,7 +730,7 @@ find_next_usable_block(ext3_grpblk_t start, struct buffer_head *bh,
730 here = 0; 730 here = 0;
731 731
732 p = ((char *)bh->b_data) + (here >> 3); 732 p = ((char *)bh->b_data) + (here >> 3);
733 r = memscan(p, 0, (maxblocks - here + 7) >> 3); 733 r = memscan(p, 0, ((maxblocks + 7) >> 3) - (here >> 3));
734 next = (r - ((char *)bh->b_data)) << 3; 734 next = (r - ((char *)bh->b_data)) << 3;
735 735
736 if (next < maxblocks && next >= start && ext3_test_allocatable(next, bh)) 736 if (next < maxblocks && next >= start && ext3_test_allocatable(next, bh))
@@ -949,7 +949,7 @@ static int find_next_reservable_window(
949 949
950 prev = rsv; 950 prev = rsv;
951 next = rb_next(&rsv->rsv_node); 951 next = rb_next(&rsv->rsv_node);
952 rsv = list_entry(next,struct ext3_reserve_window_node,rsv_node); 952 rsv = rb_entry(next,struct ext3_reserve_window_node,rsv_node);
953 953
954 /* 954 /*
955 * Reached the last reservation, we can just append to the 955 * Reached the last reservation, we can just append to the
@@ -1148,7 +1148,7 @@ retry:
1148 * check if the first free block is within the 1148 * check if the first free block is within the
1149 * free space we just reserved 1149 * free space we just reserved
1150 */ 1150 */
1151 if (start_block >= my_rsv->rsv_start && start_block < my_rsv->rsv_end) 1151 if (start_block >= my_rsv->rsv_start && start_block <= my_rsv->rsv_end)
1152 return 0; /* success */ 1152 return 0; /* success */
1153 /* 1153 /*
1154 * if the first free bit we found is out of the reservable space 1154 * if the first free bit we found is out of the reservable space
@@ -1193,7 +1193,7 @@ static void try_to_extend_reservation(struct ext3_reserve_window_node *my_rsv,
1193 if (!next) 1193 if (!next)
1194 my_rsv->rsv_end += size; 1194 my_rsv->rsv_end += size;
1195 else { 1195 else {
1196 next_rsv = list_entry(next, struct ext3_reserve_window_node, rsv_node); 1196 next_rsv = rb_entry(next, struct ext3_reserve_window_node, rsv_node);
1197 1197
1198 if ((next_rsv->rsv_start - my_rsv->rsv_end - 1) >= size) 1198 if ((next_rsv->rsv_start - my_rsv->rsv_end - 1) >= size)
1199 my_rsv->rsv_end += size; 1199 my_rsv->rsv_end += size;
@@ -1271,7 +1271,7 @@ ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1271 } 1271 }
1272 /* 1272 /*
1273 * grp_goal is a group relative block number (if there is a goal) 1273 * grp_goal is a group relative block number (if there is a goal)
1274 * 0 < grp_goal < EXT3_BLOCKS_PER_GROUP(sb) 1274 * 0 <= grp_goal < EXT3_BLOCKS_PER_GROUP(sb)
1275 * first block is a filesystem wide block number 1275 * first block is a filesystem wide block number
1276 * first block is the block number of the first block in this group 1276 * first block is the block number of the first block in this group
1277 */ 1277 */
@@ -1307,10 +1307,14 @@ ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1307 if (!goal_in_my_reservation(&my_rsv->rsv_window, 1307 if (!goal_in_my_reservation(&my_rsv->rsv_window,
1308 grp_goal, group, sb)) 1308 grp_goal, group, sb))
1309 grp_goal = -1; 1309 grp_goal = -1;
1310 } else if (grp_goal > 0 && 1310 } else if (grp_goal >= 0) {
1311 (my_rsv->rsv_end-grp_goal+1) < *count) 1311 int curr = my_rsv->rsv_end -
1312 try_to_extend_reservation(my_rsv, sb, 1312 (grp_goal + group_first_block) + 1;
1313 *count-my_rsv->rsv_end + grp_goal - 1); 1313
1314 if (curr < *count)
1315 try_to_extend_reservation(my_rsv, sb,
1316 *count - curr);
1317 }
1314 1318
1315 if ((my_rsv->rsv_start > group_last_block) || 1319 if ((my_rsv->rsv_start > group_last_block) ||
1316 (my_rsv->rsv_end < group_first_block)) { 1320 (my_rsv->rsv_end < group_first_block)) {
@@ -1511,10 +1515,8 @@ retry_alloc:
1511 if (group_no >= ngroups) 1515 if (group_no >= ngroups)
1512 group_no = 0; 1516 group_no = 0;
1513 gdp = ext3_get_group_desc(sb, group_no, &gdp_bh); 1517 gdp = ext3_get_group_desc(sb, group_no, &gdp_bh);
1514 if (!gdp) { 1518 if (!gdp)
1515 *errp = -EIO; 1519 goto io_error;
1516 goto out;
1517 }
1518 free_blocks = le16_to_cpu(gdp->bg_free_blocks_count); 1520 free_blocks = le16_to_cpu(gdp->bg_free_blocks_count);
1519 /* 1521 /*
1520 * skip this group if the number of 1522 * skip this group if the number of
@@ -1548,6 +1550,7 @@ retry_alloc:
1548 */ 1550 */
1549 if (my_rsv) { 1551 if (my_rsv) {
1550 my_rsv = NULL; 1552 my_rsv = NULL;
1553 windowsz = 0;
1551 group_no = goal_group; 1554 group_no = goal_group;
1552 goto retry_alloc; 1555 goto retry_alloc;
1553 } 1556 }
diff --git a/fs/ext3/dir.c b/fs/ext3/dir.c
index d0b54f30b914..5a9313ecd4ef 100644
--- a/fs/ext3/dir.c
+++ b/fs/ext3/dir.c
@@ -154,6 +154,9 @@ static int ext3_readdir(struct file * filp,
154 ext3_error (sb, "ext3_readdir", 154 ext3_error (sb, "ext3_readdir",
155 "directory #%lu contains a hole at offset %lu", 155 "directory #%lu contains a hole at offset %lu",
156 inode->i_ino, (unsigned long)filp->f_pos); 156 inode->i_ino, (unsigned long)filp->f_pos);
157 /* corrupt size? Maybe no more blocks to read */
158 if (filp->f_pos > inode->i_blocks << 9)
159 break;
157 filp->f_pos += sb->s_blocksize - offset; 160 filp->f_pos += sb->s_blocksize - offset;
158 continue; 161 continue;
159 } 162 }
diff --git a/fs/ext3/ext3_jbd.c b/fs/ext3/ext3_jbd.c
new file mode 100644
index 000000000000..e1f91fd26a93
--- /dev/null
+++ b/fs/ext3/ext3_jbd.c
@@ -0,0 +1,59 @@
1/*
2 * Interface between ext3 and JBD
3 */
4
5#include <linux/ext3_jbd.h>
6
7int __ext3_journal_get_undo_access(const char *where, handle_t *handle,
8 struct buffer_head *bh)
9{
10 int err = journal_get_undo_access(handle, bh);
11 if (err)
12 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
13 return err;
14}
15
16int __ext3_journal_get_write_access(const char *where, handle_t *handle,
17 struct buffer_head *bh)
18{
19 int err = journal_get_write_access(handle, bh);
20 if (err)
21 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
22 return err;
23}
24
25int __ext3_journal_forget(const char *where, handle_t *handle,
26 struct buffer_head *bh)
27{
28 int err = journal_forget(handle, bh);
29 if (err)
30 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
31 return err;
32}
33
34int __ext3_journal_revoke(const char *where, handle_t *handle,
35 unsigned long blocknr, struct buffer_head *bh)
36{
37 int err = journal_revoke(handle, blocknr, bh);
38 if (err)
39 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
40 return err;
41}
42
43int __ext3_journal_get_create_access(const char *where,
44 handle_t *handle, struct buffer_head *bh)
45{
46 int err = journal_get_create_access(handle, bh);
47 if (err)
48 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
49 return err;
50}
51
52int __ext3_journal_dirty_metadata(const char *where,
53 handle_t *handle, struct buffer_head *bh)
54{
55 int err = journal_dirty_metadata(handle, bh);
56 if (err)
57 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
58 return err;
59}
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 03ba5bcab186..beaf25f5112f 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -1148,37 +1148,102 @@ static int do_journal_get_write_access(handle_t *handle,
1148 return ext3_journal_get_write_access(handle, bh); 1148 return ext3_journal_get_write_access(handle, bh);
1149} 1149}
1150 1150
1151/*
1152 * The idea of this helper function is following:
1153 * if prepare_write has allocated some blocks, but not all of them, the
1154 * transaction must include the content of the newly allocated blocks.
1155 * This content is expected to be set to zeroes by block_prepare_write().
1156 * 2006/10/14 SAW
1157 */
1158static int ext3_prepare_failure(struct file *file, struct page *page,
1159 unsigned from, unsigned to)
1160{
1161 struct address_space *mapping;
1162 struct buffer_head *bh, *head, *next;
1163 unsigned block_start, block_end;
1164 unsigned blocksize;
1165 int ret;
1166 handle_t *handle = ext3_journal_current_handle();
1167
1168 mapping = page->mapping;
1169 if (ext3_should_writeback_data(mapping->host)) {
1170 /* optimization: no constraints about data */
1171skip:
1172 return ext3_journal_stop(handle);
1173 }
1174
1175 head = page_buffers(page);
1176 blocksize = head->b_size;
1177 for ( bh = head, block_start = 0;
1178 bh != head || !block_start;
1179 block_start = block_end, bh = next)
1180 {
1181 next = bh->b_this_page;
1182 block_end = block_start + blocksize;
1183 if (block_end <= from)
1184 continue;
1185 if (block_start >= to) {
1186 block_start = to;
1187 break;
1188 }
1189 if (!buffer_mapped(bh))
1190 /* prepare_write failed on this bh */
1191 break;
1192 if (ext3_should_journal_data(mapping->host)) {
1193 ret = do_journal_get_write_access(handle, bh);
1194 if (ret) {
1195 ext3_journal_stop(handle);
1196 return ret;
1197 }
1198 }
1199 /*
1200 * block_start here becomes the first block where the current iteration
1201 * of prepare_write failed.
1202 */
1203 }
1204 if (block_start <= from)
1205 goto skip;
1206
1207 /* commit allocated and zeroed buffers */
1208 return mapping->a_ops->commit_write(file, page, from, block_start);
1209}
1210
1151static int ext3_prepare_write(struct file *file, struct page *page, 1211static int ext3_prepare_write(struct file *file, struct page *page,
1152 unsigned from, unsigned to) 1212 unsigned from, unsigned to)
1153{ 1213{
1154 struct inode *inode = page->mapping->host; 1214 struct inode *inode = page->mapping->host;
1155 int ret, needed_blocks = ext3_writepage_trans_blocks(inode); 1215 int ret, ret2;
1216 int needed_blocks = ext3_writepage_trans_blocks(inode);
1156 handle_t *handle; 1217 handle_t *handle;
1157 int retries = 0; 1218 int retries = 0;
1158 1219
1159retry: 1220retry:
1160 handle = ext3_journal_start(inode, needed_blocks); 1221 handle = ext3_journal_start(inode, needed_blocks);
1161 if (IS_ERR(handle)) { 1222 if (IS_ERR(handle))
1162 ret = PTR_ERR(handle); 1223 return PTR_ERR(handle);
1163 goto out;
1164 }
1165 if (test_opt(inode->i_sb, NOBH) && ext3_should_writeback_data(inode)) 1224 if (test_opt(inode->i_sb, NOBH) && ext3_should_writeback_data(inode))
1166 ret = nobh_prepare_write(page, from, to, ext3_get_block); 1225 ret = nobh_prepare_write(page, from, to, ext3_get_block);
1167 else 1226 else
1168 ret = block_prepare_write(page, from, to, ext3_get_block); 1227 ret = block_prepare_write(page, from, to, ext3_get_block);
1169 if (ret) 1228 if (ret)
1170 goto prepare_write_failed; 1229 goto failure;
1171 1230
1172 if (ext3_should_journal_data(inode)) { 1231 if (ext3_should_journal_data(inode)) {
1173 ret = walk_page_buffers(handle, page_buffers(page), 1232 ret = walk_page_buffers(handle, page_buffers(page),
1174 from, to, NULL, do_journal_get_write_access); 1233 from, to, NULL, do_journal_get_write_access);
1234 if (ret)
1235 /* fatal error, just put the handle and return */
1236 journal_stop(handle);
1175 } 1237 }
1176prepare_write_failed: 1238 return ret;
1177 if (ret) 1239
1178 ext3_journal_stop(handle); 1240failure:
1241 ret2 = ext3_prepare_failure(file, page, from, to);
1242 if (ret2 < 0)
1243 return ret2;
1179 if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries)) 1244 if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries))
1180 goto retry; 1245 goto retry;
1181out: 1246 /* retry number exceeded, or other error like -EDQUOT */
1182 return ret; 1247 return ret;
1183} 1248}
1184 1249
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 906731a20f1a..60d2f9dbdb00 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -552,6 +552,15 @@ static int htree_dirblock_to_tree(struct file *dir_file,
552 dir->i_sb->s_blocksize - 552 dir->i_sb->s_blocksize -
553 EXT3_DIR_REC_LEN(0)); 553 EXT3_DIR_REC_LEN(0));
554 for (; de < top; de = ext3_next_entry(de)) { 554 for (; de < top; de = ext3_next_entry(de)) {
555 if (!ext3_check_dir_entry("htree_dirblock_to_tree", dir, de, bh,
556 (block<<EXT3_BLOCK_SIZE_BITS(dir->i_sb))
557 +((char *)de - bh->b_data))) {
558 /* On error, skip the f_pos to the next block. */
559 dir_file->f_pos = (dir_file->f_pos |
560 (dir->i_sb->s_blocksize - 1)) + 1;
561 brelse (bh);
562 return count;
563 }
555 ext3fs_dirhash(de->name, de->name_len, hinfo); 564 ext3fs_dirhash(de->name, de->name_len, hinfo);
556 if ((hinfo->hash < start_hash) || 565 if ((hinfo->hash < start_hash) ||
557 ((hinfo->hash == start_hash) && 566 ((hinfo->hash == start_hash) &&
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index afc2d4f42d77..580b8a6ca979 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -436,7 +436,7 @@ static void ext3_put_super (struct super_block * sb)
436 return; 436 return;
437} 437}
438 438
439static kmem_cache_t *ext3_inode_cachep; 439static struct kmem_cache *ext3_inode_cachep;
440 440
441/* 441/*
442 * Called inside transaction, so use GFP_NOFS 442 * Called inside transaction, so use GFP_NOFS
@@ -445,7 +445,7 @@ static struct inode *ext3_alloc_inode(struct super_block *sb)
445{ 445{
446 struct ext3_inode_info *ei; 446 struct ext3_inode_info *ei;
447 447
448 ei = kmem_cache_alloc(ext3_inode_cachep, SLAB_NOFS); 448 ei = kmem_cache_alloc(ext3_inode_cachep, GFP_NOFS);
449 if (!ei) 449 if (!ei)
450 return NULL; 450 return NULL;
451#ifdef CONFIG_EXT3_FS_POSIX_ACL 451#ifdef CONFIG_EXT3_FS_POSIX_ACL
@@ -462,7 +462,7 @@ static void ext3_destroy_inode(struct inode *inode)
462 kmem_cache_free(ext3_inode_cachep, EXT3_I(inode)); 462 kmem_cache_free(ext3_inode_cachep, EXT3_I(inode));
463} 463}
464 464
465static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 465static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
466{ 466{
467 struct ext3_inode_info *ei = (struct ext3_inode_info *) foo; 467 struct ext3_inode_info *ei = (struct ext3_inode_info *) foo;
468 468
@@ -1264,6 +1264,12 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1264 return; 1264 return;
1265 } 1265 }
1266 1266
1267 if (bdev_read_only(sb->s_bdev)) {
1268 printk(KERN_ERR "EXT3-fs: write access "
1269 "unavailable, skipping orphan cleanup.\n");
1270 return;
1271 }
1272
1267 if (EXT3_SB(sb)->s_mount_state & EXT3_ERROR_FS) { 1273 if (EXT3_SB(sb)->s_mount_state & EXT3_ERROR_FS) {
1268 if (es->s_last_orphan) 1274 if (es->s_last_orphan)
1269 jbd_debug(1, "Errors on filesystem, " 1275 jbd_debug(1, "Errors on filesystem, "
@@ -2387,6 +2393,7 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf)
2387 struct ext3_super_block *es = sbi->s_es; 2393 struct ext3_super_block *es = sbi->s_es;
2388 ext3_fsblk_t overhead; 2394 ext3_fsblk_t overhead;
2389 int i; 2395 int i;
2396 u64 fsid;
2390 2397
2391 if (test_opt (sb, MINIX_DF)) 2398 if (test_opt (sb, MINIX_DF))
2392 overhead = 0; 2399 overhead = 0;
@@ -2433,6 +2440,10 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf)
2433 buf->f_files = le32_to_cpu(es->s_inodes_count); 2440 buf->f_files = le32_to_cpu(es->s_inodes_count);
2434 buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter); 2441 buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter);
2435 buf->f_namelen = EXT3_NAME_LEN; 2442 buf->f_namelen = EXT3_NAME_LEN;
2443 fsid = le64_to_cpup((void *)es->s_uuid) ^
2444 le64_to_cpup((void *)es->s_uuid + sizeof(u64));
2445 buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
2446 buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
2436 return 0; 2447 return 0;
2437} 2448}
2438 2449
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
index f86f2482f01d..99857a400f4b 100644
--- a/fs/ext3/xattr.c
+++ b/fs/ext3/xattr.c
@@ -459,14 +459,11 @@ static void ext3_xattr_update_super_block(handle_t *handle,
459 if (EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_EXT_ATTR)) 459 if (EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_EXT_ATTR))
460 return; 460 return;
461 461
462 lock_super(sb);
463 if (ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh) == 0) { 462 if (ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh) == 0) {
464 EXT3_SB(sb)->s_es->s_feature_compat |= 463 EXT3_SET_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_EXT_ATTR);
465 cpu_to_le32(EXT3_FEATURE_COMPAT_EXT_ATTR);
466 sb->s_dirt = 1; 464 sb->s_dirt = 1;
467 ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh); 465 ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
468 } 466 }
469 unlock_super(sb);
470} 467}
471 468
472/* 469/*
diff --git a/fs/ext4/Makefile b/fs/ext4/Makefile
index a6acb96ebeb9..ae6e7e502ac9 100644
--- a/fs/ext4/Makefile
+++ b/fs/ext4/Makefile
@@ -5,7 +5,8 @@
5obj-$(CONFIG_EXT4DEV_FS) += ext4dev.o 5obj-$(CONFIG_EXT4DEV_FS) += ext4dev.o
6 6
7ext4dev-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ 7ext4dev-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
8 ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o 8 ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o \
9 ext4_jbd2.o
9 10
10ext4dev-$(CONFIG_EXT4DEV_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o 11ext4dev-$(CONFIG_EXT4DEV_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o
11ext4dev-$(CONFIG_EXT4DEV_FS_POSIX_ACL) += acl.o 12ext4dev-$(CONFIG_EXT4DEV_FS_POSIX_ACL) += acl.o
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 5d45582f9517..c4dd1103ccf1 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -165,7 +165,7 @@ restart:
165 165
166 printk("Block Allocation Reservation Windows Map (%s):\n", fn); 166 printk("Block Allocation Reservation Windows Map (%s):\n", fn);
167 while (n) { 167 while (n) {
168 rsv = list_entry(n, struct ext4_reserve_window_node, rsv_node); 168 rsv = rb_entry(n, struct ext4_reserve_window_node, rsv_node);
169 if (verbose) 169 if (verbose)
170 printk("reservation window 0x%p " 170 printk("reservation window 0x%p "
171 "start: %llu, end: %llu\n", 171 "start: %llu, end: %llu\n",
@@ -747,7 +747,7 @@ find_next_usable_block(ext4_grpblk_t start, struct buffer_head *bh,
747 here = 0; 747 here = 0;
748 748
749 p = ((char *)bh->b_data) + (here >> 3); 749 p = ((char *)bh->b_data) + (here >> 3);
750 r = memscan(p, 0, (maxblocks - here + 7) >> 3); 750 r = memscan(p, 0, ((maxblocks + 7) >> 3) - (here >> 3));
751 next = (r - ((char *)bh->b_data)) << 3; 751 next = (r - ((char *)bh->b_data)) << 3;
752 752
753 if (next < maxblocks && next >= start && ext4_test_allocatable(next, bh)) 753 if (next < maxblocks && next >= start && ext4_test_allocatable(next, bh))
@@ -966,7 +966,7 @@ static int find_next_reservable_window(
966 966
967 prev = rsv; 967 prev = rsv;
968 next = rb_next(&rsv->rsv_node); 968 next = rb_next(&rsv->rsv_node);
969 rsv = list_entry(next,struct ext4_reserve_window_node,rsv_node); 969 rsv = rb_entry(next,struct ext4_reserve_window_node,rsv_node);
970 970
971 /* 971 /*
972 * Reached the last reservation, we can just append to the 972 * Reached the last reservation, we can just append to the
@@ -1165,7 +1165,7 @@ retry:
1165 * check if the first free block is within the 1165 * check if the first free block is within the
1166 * free space we just reserved 1166 * free space we just reserved
1167 */ 1167 */
1168 if (start_block >= my_rsv->rsv_start && start_block < my_rsv->rsv_end) 1168 if (start_block >= my_rsv->rsv_start && start_block <= my_rsv->rsv_end)
1169 return 0; /* success */ 1169 return 0; /* success */
1170 /* 1170 /*
1171 * if the first free bit we found is out of the reservable space 1171 * if the first free bit we found is out of the reservable space
@@ -1210,7 +1210,7 @@ static void try_to_extend_reservation(struct ext4_reserve_window_node *my_rsv,
1210 if (!next) 1210 if (!next)
1211 my_rsv->rsv_end += size; 1211 my_rsv->rsv_end += size;
1212 else { 1212 else {
1213 next_rsv = list_entry(next, struct ext4_reserve_window_node, rsv_node); 1213 next_rsv = rb_entry(next, struct ext4_reserve_window_node, rsv_node);
1214 1214
1215 if ((next_rsv->rsv_start - my_rsv->rsv_end - 1) >= size) 1215 if ((next_rsv->rsv_start - my_rsv->rsv_end - 1) >= size)
1216 my_rsv->rsv_end += size; 1216 my_rsv->rsv_end += size;
@@ -1288,7 +1288,7 @@ ext4_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1288 } 1288 }
1289 /* 1289 /*
1290 * grp_goal is a group relative block number (if there is a goal) 1290 * grp_goal is a group relative block number (if there is a goal)
1291 * 0 < grp_goal < EXT4_BLOCKS_PER_GROUP(sb) 1291 * 0 <= grp_goal < EXT4_BLOCKS_PER_GROUP(sb)
1292 * first block is a filesystem wide block number 1292 * first block is a filesystem wide block number
1293 * first block is the block number of the first block in this group 1293 * first block is the block number of the first block in this group
1294 */ 1294 */
@@ -1324,10 +1324,14 @@ ext4_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1324 if (!goal_in_my_reservation(&my_rsv->rsv_window, 1324 if (!goal_in_my_reservation(&my_rsv->rsv_window,
1325 grp_goal, group, sb)) 1325 grp_goal, group, sb))
1326 grp_goal = -1; 1326 grp_goal = -1;
1327 } else if (grp_goal > 0 && 1327 } else if (grp_goal >= 0) {
1328 (my_rsv->rsv_end-grp_goal+1) < *count) 1328 int curr = my_rsv->rsv_end -
1329 try_to_extend_reservation(my_rsv, sb, 1329 (grp_goal + group_first_block) + 1;
1330 *count-my_rsv->rsv_end + grp_goal - 1); 1330
1331 if (curr < *count)
1332 try_to_extend_reservation(my_rsv, sb,
1333 *count - curr);
1334 }
1331 1335
1332 if ((my_rsv->rsv_start > group_last_block) || 1336 if ((my_rsv->rsv_start > group_last_block) ||
1333 (my_rsv->rsv_end < group_first_block)) { 1337 (my_rsv->rsv_end < group_first_block)) {
@@ -1525,10 +1529,8 @@ retry_alloc:
1525 if (group_no >= ngroups) 1529 if (group_no >= ngroups)
1526 group_no = 0; 1530 group_no = 0;
1527 gdp = ext4_get_group_desc(sb, group_no, &gdp_bh); 1531 gdp = ext4_get_group_desc(sb, group_no, &gdp_bh);
1528 if (!gdp) { 1532 if (!gdp)
1529 *errp = -EIO; 1533 goto io_error;
1530 goto out;
1531 }
1532 free_blocks = le16_to_cpu(gdp->bg_free_blocks_count); 1534 free_blocks = le16_to_cpu(gdp->bg_free_blocks_count);
1533 /* 1535 /*
1534 * skip this group if the number of 1536 * skip this group if the number of
@@ -1562,6 +1564,7 @@ retry_alloc:
1562 */ 1564 */
1563 if (my_rsv) { 1565 if (my_rsv) {
1564 my_rsv = NULL; 1566 my_rsv = NULL;
1567 windowsz = 0;
1565 group_no = goal_group; 1568 group_no = goal_group;
1566 goto retry_alloc; 1569 goto retry_alloc;
1567 } 1570 }
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index f8595787a70e..f2ed3e7fb9f5 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -153,6 +153,9 @@ static int ext4_readdir(struct file * filp,
153 ext4_error (sb, "ext4_readdir", 153 ext4_error (sb, "ext4_readdir",
154 "directory #%lu contains a hole at offset %lu", 154 "directory #%lu contains a hole at offset %lu",
155 inode->i_ino, (unsigned long)filp->f_pos); 155 inode->i_ino, (unsigned long)filp->f_pos);
156 /* corrupt size? Maybe no more blocks to read */
157 if (filp->f_pos > inode->i_blocks << 9)
158 break;
156 filp->f_pos += sb->s_blocksize - offset; 159 filp->f_pos += sb->s_blocksize - offset;
157 continue; 160 continue;
158 } 161 }
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
new file mode 100644
index 000000000000..d6afe4e27340
--- /dev/null
+++ b/fs/ext4/ext4_jbd2.c
@@ -0,0 +1,59 @@
1/*
2 * Interface between ext4 and JBD
3 */
4
5#include <linux/ext4_jbd2.h>
6
7int __ext4_journal_get_undo_access(const char *where, handle_t *handle,
8 struct buffer_head *bh)
9{
10 int err = jbd2_journal_get_undo_access(handle, bh);
11 if (err)
12 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
13 return err;
14}
15
16int __ext4_journal_get_write_access(const char *where, handle_t *handle,
17 struct buffer_head *bh)
18{
19 int err = jbd2_journal_get_write_access(handle, bh);
20 if (err)
21 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
22 return err;
23}
24
25int __ext4_journal_forget(const char *where, handle_t *handle,
26 struct buffer_head *bh)
27{
28 int err = jbd2_journal_forget(handle, bh);
29 if (err)
30 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
31 return err;
32}
33
34int __ext4_journal_revoke(const char *where, handle_t *handle,
35 ext4_fsblk_t blocknr, struct buffer_head *bh)
36{
37 int err = jbd2_journal_revoke(handle, blocknr, bh);
38 if (err)
39 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
40 return err;
41}
42
43int __ext4_journal_get_create_access(const char *where,
44 handle_t *handle, struct buffer_head *bh)
45{
46 int err = jbd2_journal_get_create_access(handle, bh);
47 if (err)
48 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
49 return err;
50}
51
52int __ext4_journal_dirty_metadata(const char *where,
53 handle_t *handle, struct buffer_head *bh)
54{
55 int err = jbd2_journal_dirty_metadata(handle, bh);
56 if (err)
57 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
58 return err;
59}
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 2608dce18f3e..dc2724fa7622 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -48,7 +48,7 @@
48 * ext_pblock: 48 * ext_pblock:
49 * combine low and high parts of physical block number into ext4_fsblk_t 49 * combine low and high parts of physical block number into ext4_fsblk_t
50 */ 50 */
51static inline ext4_fsblk_t ext_pblock(struct ext4_extent *ex) 51static ext4_fsblk_t ext_pblock(struct ext4_extent *ex)
52{ 52{
53 ext4_fsblk_t block; 53 ext4_fsblk_t block;
54 54
@@ -61,7 +61,7 @@ static inline ext4_fsblk_t ext_pblock(struct ext4_extent *ex)
61 * idx_pblock: 61 * idx_pblock:
62 * combine low and high parts of a leaf physical block number into ext4_fsblk_t 62 * combine low and high parts of a leaf physical block number into ext4_fsblk_t
63 */ 63 */
64static inline ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix) 64static ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix)
65{ 65{
66 ext4_fsblk_t block; 66 ext4_fsblk_t block;
67 67
@@ -75,7 +75,7 @@ static inline ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix)
75 * stores a large physical block number into an extent struct, 75 * stores a large physical block number into an extent struct,
76 * breaking it into parts 76 * breaking it into parts
77 */ 77 */
78static inline void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb) 78static void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)
79{ 79{
80 ex->ee_start = cpu_to_le32((unsigned long) (pb & 0xffffffff)); 80 ex->ee_start = cpu_to_le32((unsigned long) (pb & 0xffffffff));
81 ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff); 81 ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
@@ -86,7 +86,7 @@ static inline void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb
86 * stores a large physical block number into an index struct, 86 * stores a large physical block number into an index struct,
87 * breaking it into parts 87 * breaking it into parts
88 */ 88 */
89static inline void ext4_idx_store_pblock(struct ext4_extent_idx *ix, ext4_fsblk_t pb) 89static void ext4_idx_store_pblock(struct ext4_extent_idx *ix, ext4_fsblk_t pb)
90{ 90{
91 ix->ei_leaf = cpu_to_le32((unsigned long) (pb & 0xffffffff)); 91 ix->ei_leaf = cpu_to_le32((unsigned long) (pb & 0xffffffff));
92 ix->ei_leaf_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff); 92 ix->ei_leaf_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
@@ -186,7 +186,8 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode,
186 depth = path->p_depth; 186 depth = path->p_depth;
187 187
188 /* try to predict block placement */ 188 /* try to predict block placement */
189 if ((ex = path[depth].p_ext)) 189 ex = path[depth].p_ext;
190 if (ex)
190 return ext_pblock(ex)+(block-le32_to_cpu(ex->ee_block)); 191 return ext_pblock(ex)+(block-le32_to_cpu(ex->ee_block));
191 192
192 /* it looks like index is empty; 193 /* it looks like index is empty;
@@ -215,7 +216,7 @@ ext4_ext_new_block(handle_t *handle, struct inode *inode,
215 return newblock; 216 return newblock;
216} 217}
217 218
218static inline int ext4_ext_space_block(struct inode *inode) 219static int ext4_ext_space_block(struct inode *inode)
219{ 220{
220 int size; 221 int size;
221 222
@@ -228,7 +229,7 @@ static inline int ext4_ext_space_block(struct inode *inode)
228 return size; 229 return size;
229} 230}
230 231
231static inline int ext4_ext_space_block_idx(struct inode *inode) 232static int ext4_ext_space_block_idx(struct inode *inode)
232{ 233{
233 int size; 234 int size;
234 235
@@ -241,7 +242,7 @@ static inline int ext4_ext_space_block_idx(struct inode *inode)
241 return size; 242 return size;
242} 243}
243 244
244static inline int ext4_ext_space_root(struct inode *inode) 245static int ext4_ext_space_root(struct inode *inode)
245{ 246{
246 int size; 247 int size;
247 248
@@ -255,7 +256,7 @@ static inline int ext4_ext_space_root(struct inode *inode)
255 return size; 256 return size;
256} 257}
257 258
258static inline int ext4_ext_space_root_idx(struct inode *inode) 259static int ext4_ext_space_root_idx(struct inode *inode)
259{ 260{
260 int size; 261 int size;
261 262
@@ -476,13 +477,12 @@ ext4_ext_find_extent(struct inode *inode, int block, struct ext4_ext_path *path)
476 477
477 /* account possible depth increase */ 478 /* account possible depth increase */
478 if (!path) { 479 if (!path) {
479 path = kmalloc(sizeof(struct ext4_ext_path) * (depth + 2), 480 path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 2),
480 GFP_NOFS); 481 GFP_NOFS);
481 if (!path) 482 if (!path)
482 return ERR_PTR(-ENOMEM); 483 return ERR_PTR(-ENOMEM);
483 alloc = 1; 484 alloc = 1;
484 } 485 }
485 memset(path, 0, sizeof(struct ext4_ext_path) * (depth + 1));
486 path[0].p_hdr = eh; 486 path[0].p_hdr = eh;
487 487
488 /* walk through the tree */ 488 /* walk through the tree */
@@ -543,7 +543,8 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
543 struct ext4_extent_idx *ix; 543 struct ext4_extent_idx *ix;
544 int len, err; 544 int len, err;
545 545
546 if ((err = ext4_ext_get_access(handle, inode, curp))) 546 err = ext4_ext_get_access(handle, inode, curp);
547 if (err)
547 return err; 548 return err;
548 549
549 BUG_ON(logical == le32_to_cpu(curp->p_idx->ei_block)); 550 BUG_ON(logical == le32_to_cpu(curp->p_idx->ei_block));
@@ -641,10 +642,9 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
641 * We need this to handle errors and free blocks 642 * We need this to handle errors and free blocks
642 * upon them. 643 * upon them.
643 */ 644 */
644 ablocks = kmalloc(sizeof(ext4_fsblk_t) * depth, GFP_NOFS); 645 ablocks = kzalloc(sizeof(ext4_fsblk_t) * depth, GFP_NOFS);
645 if (!ablocks) 646 if (!ablocks)
646 return -ENOMEM; 647 return -ENOMEM;
647 memset(ablocks, 0, sizeof(ext4_fsblk_t) * depth);
648 648
649 /* allocate all needed blocks */ 649 /* allocate all needed blocks */
650 ext_debug("allocate %d blocks for indexes/leaf\n", depth - at); 650 ext_debug("allocate %d blocks for indexes/leaf\n", depth - at);
@@ -665,7 +665,8 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
665 } 665 }
666 lock_buffer(bh); 666 lock_buffer(bh);
667 667
668 if ((err = ext4_journal_get_create_access(handle, bh))) 668 err = ext4_journal_get_create_access(handle, bh);
669 if (err)
669 goto cleanup; 670 goto cleanup;
670 671
671 neh = ext_block_hdr(bh); 672 neh = ext_block_hdr(bh);
@@ -702,18 +703,21 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
702 set_buffer_uptodate(bh); 703 set_buffer_uptodate(bh);
703 unlock_buffer(bh); 704 unlock_buffer(bh);
704 705
705 if ((err = ext4_journal_dirty_metadata(handle, bh))) 706 err = ext4_journal_dirty_metadata(handle, bh);
707 if (err)
706 goto cleanup; 708 goto cleanup;
707 brelse(bh); 709 brelse(bh);
708 bh = NULL; 710 bh = NULL;
709 711
710 /* correct old leaf */ 712 /* correct old leaf */
711 if (m) { 713 if (m) {
712 if ((err = ext4_ext_get_access(handle, inode, path + depth))) 714 err = ext4_ext_get_access(handle, inode, path + depth);
715 if (err)
713 goto cleanup; 716 goto cleanup;
714 path[depth].p_hdr->eh_entries = 717 path[depth].p_hdr->eh_entries =
715 cpu_to_le16(le16_to_cpu(path[depth].p_hdr->eh_entries)-m); 718 cpu_to_le16(le16_to_cpu(path[depth].p_hdr->eh_entries)-m);
716 if ((err = ext4_ext_dirty(handle, inode, path + depth))) 719 err = ext4_ext_dirty(handle, inode, path + depth);
720 if (err)
717 goto cleanup; 721 goto cleanup;
718 722
719 } 723 }
@@ -736,7 +740,8 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
736 } 740 }
737 lock_buffer(bh); 741 lock_buffer(bh);
738 742
739 if ((err = ext4_journal_get_create_access(handle, bh))) 743 err = ext4_journal_get_create_access(handle, bh);
744 if (err)
740 goto cleanup; 745 goto cleanup;
741 746
742 neh = ext_block_hdr(bh); 747 neh = ext_block_hdr(bh);
@@ -780,7 +785,8 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
780 set_buffer_uptodate(bh); 785 set_buffer_uptodate(bh);
781 unlock_buffer(bh); 786 unlock_buffer(bh);
782 787
783 if ((err = ext4_journal_dirty_metadata(handle, bh))) 788 err = ext4_journal_dirty_metadata(handle, bh);
789 if (err)
784 goto cleanup; 790 goto cleanup;
785 brelse(bh); 791 brelse(bh);
786 bh = NULL; 792 bh = NULL;
@@ -800,9 +806,6 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
800 } 806 }
801 807
802 /* insert new index */ 808 /* insert new index */
803 if (err)
804 goto cleanup;
805
806 err = ext4_ext_insert_index(handle, inode, path + at, 809 err = ext4_ext_insert_index(handle, inode, path + at,
807 le32_to_cpu(border), newblock); 810 le32_to_cpu(border), newblock);
808 811
@@ -857,7 +860,8 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
857 } 860 }
858 lock_buffer(bh); 861 lock_buffer(bh);
859 862
860 if ((err = ext4_journal_get_create_access(handle, bh))) { 863 err = ext4_journal_get_create_access(handle, bh);
864 if (err) {
861 unlock_buffer(bh); 865 unlock_buffer(bh);
862 goto out; 866 goto out;
863 } 867 }
@@ -877,11 +881,13 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
877 set_buffer_uptodate(bh); 881 set_buffer_uptodate(bh);
878 unlock_buffer(bh); 882 unlock_buffer(bh);
879 883
880 if ((err = ext4_journal_dirty_metadata(handle, bh))) 884 err = ext4_journal_dirty_metadata(handle, bh);
885 if (err)
881 goto out; 886 goto out;
882 887
883 /* create index in new top-level index: num,max,pointer */ 888 /* create index in new top-level index: num,max,pointer */
884 if ((err = ext4_ext_get_access(handle, inode, curp))) 889 err = ext4_ext_get_access(handle, inode, curp);
890 if (err)
885 goto out; 891 goto out;
886 892
887 curp->p_hdr->eh_magic = EXT4_EXT_MAGIC; 893 curp->p_hdr->eh_magic = EXT4_EXT_MAGIC;
@@ -1073,27 +1079,31 @@ int ext4_ext_correct_indexes(handle_t *handle, struct inode *inode,
1073 */ 1079 */
1074 k = depth - 1; 1080 k = depth - 1;
1075 border = path[depth].p_ext->ee_block; 1081 border = path[depth].p_ext->ee_block;
1076 if ((err = ext4_ext_get_access(handle, inode, path + k))) 1082 err = ext4_ext_get_access(handle, inode, path + k);
1083 if (err)
1077 return err; 1084 return err;
1078 path[k].p_idx->ei_block = border; 1085 path[k].p_idx->ei_block = border;
1079 if ((err = ext4_ext_dirty(handle, inode, path + k))) 1086 err = ext4_ext_dirty(handle, inode, path + k);
1087 if (err)
1080 return err; 1088 return err;
1081 1089
1082 while (k--) { 1090 while (k--) {
1083 /* change all left-side indexes */ 1091 /* change all left-side indexes */
1084 if (path[k+1].p_idx != EXT_FIRST_INDEX(path[k+1].p_hdr)) 1092 if (path[k+1].p_idx != EXT_FIRST_INDEX(path[k+1].p_hdr))
1085 break; 1093 break;
1086 if ((err = ext4_ext_get_access(handle, inode, path + k))) 1094 err = ext4_ext_get_access(handle, inode, path + k);
1095 if (err)
1087 break; 1096 break;
1088 path[k].p_idx->ei_block = border; 1097 path[k].p_idx->ei_block = border;
1089 if ((err = ext4_ext_dirty(handle, inode, path + k))) 1098 err = ext4_ext_dirty(handle, inode, path + k);
1099 if (err)
1090 break; 1100 break;
1091 } 1101 }
1092 1102
1093 return err; 1103 return err;
1094} 1104}
1095 1105
1096static int inline 1106static int
1097ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1, 1107ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1,
1098 struct ext4_extent *ex2) 1108 struct ext4_extent *ex2)
1099{ 1109{
@@ -1145,7 +1155,8 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode,
1145 le16_to_cpu(newext->ee_len), 1155 le16_to_cpu(newext->ee_len),
1146 le32_to_cpu(ex->ee_block), 1156 le32_to_cpu(ex->ee_block),
1147 le16_to_cpu(ex->ee_len), ext_pblock(ex)); 1157 le16_to_cpu(ex->ee_len), ext_pblock(ex));
1148 if ((err = ext4_ext_get_access(handle, inode, path + depth))) 1158 err = ext4_ext_get_access(handle, inode, path + depth);
1159 if (err)
1149 return err; 1160 return err;
1150 ex->ee_len = cpu_to_le16(le16_to_cpu(ex->ee_len) 1161 ex->ee_len = cpu_to_le16(le16_to_cpu(ex->ee_len)
1151 + le16_to_cpu(newext->ee_len)); 1162 + le16_to_cpu(newext->ee_len));
@@ -1195,7 +1206,8 @@ repeat:
1195has_space: 1206has_space:
1196 nearex = path[depth].p_ext; 1207 nearex = path[depth].p_ext;
1197 1208
1198 if ((err = ext4_ext_get_access(handle, inode, path + depth))) 1209 err = ext4_ext_get_access(handle, inode, path + depth);
1210 if (err)
1199 goto cleanup; 1211 goto cleanup;
1200 1212
1201 if (!nearex) { 1213 if (!nearex) {
@@ -1383,7 +1395,7 @@ int ext4_ext_walk_space(struct inode *inode, unsigned long block,
1383 return err; 1395 return err;
1384} 1396}
1385 1397
1386static inline void 1398static void
1387ext4_ext_put_in_cache(struct inode *inode, __u32 block, 1399ext4_ext_put_in_cache(struct inode *inode, __u32 block,
1388 __u32 len, __u32 start, int type) 1400 __u32 len, __u32 start, int type)
1389{ 1401{
@@ -1401,7 +1413,7 @@ ext4_ext_put_in_cache(struct inode *inode, __u32 block,
1401 * calculate boundaries of the gap that the requested block fits into 1413 * calculate boundaries of the gap that the requested block fits into
1402 * and cache this gap 1414 * and cache this gap
1403 */ 1415 */
1404static inline void 1416static void
1405ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path, 1417ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path,
1406 unsigned long block) 1418 unsigned long block)
1407{ 1419{
@@ -1442,7 +1454,7 @@ ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path,
1442 ext4_ext_put_in_cache(inode, lblock, len, 0, EXT4_EXT_CACHE_GAP); 1454 ext4_ext_put_in_cache(inode, lblock, len, 0, EXT4_EXT_CACHE_GAP);
1443} 1455}
1444 1456
1445static inline int 1457static int
1446ext4_ext_in_cache(struct inode *inode, unsigned long block, 1458ext4_ext_in_cache(struct inode *inode, unsigned long block,
1447 struct ext4_extent *ex) 1459 struct ext4_extent *ex)
1448{ 1460{
@@ -1489,10 +1501,12 @@ int ext4_ext_rm_idx(handle_t *handle, struct inode *inode,
1489 path--; 1501 path--;
1490 leaf = idx_pblock(path->p_idx); 1502 leaf = idx_pblock(path->p_idx);
1491 BUG_ON(path->p_hdr->eh_entries == 0); 1503 BUG_ON(path->p_hdr->eh_entries == 0);
1492 if ((err = ext4_ext_get_access(handle, inode, path))) 1504 err = ext4_ext_get_access(handle, inode, path);
1505 if (err)
1493 return err; 1506 return err;
1494 path->p_hdr->eh_entries = cpu_to_le16(le16_to_cpu(path->p_hdr->eh_entries)-1); 1507 path->p_hdr->eh_entries = cpu_to_le16(le16_to_cpu(path->p_hdr->eh_entries)-1);
1495 if ((err = ext4_ext_dirty(handle, inode, path))) 1508 err = ext4_ext_dirty(handle, inode, path);
1509 if (err)
1496 return err; 1510 return err;
1497 ext_debug("index is empty, remove it, free block %llu\n", leaf); 1511 ext_debug("index is empty, remove it, free block %llu\n", leaf);
1498 bh = sb_find_get_block(inode->i_sb, leaf); 1512 bh = sb_find_get_block(inode->i_sb, leaf);
@@ -1509,7 +1523,7 @@ int ext4_ext_rm_idx(handle_t *handle, struct inode *inode,
1509 * the caller should calculate credits under truncate_mutex and 1523 * the caller should calculate credits under truncate_mutex and
1510 * pass the actual path. 1524 * pass the actual path.
1511 */ 1525 */
1512int inline ext4_ext_calc_credits_for_insert(struct inode *inode, 1526int ext4_ext_calc_credits_for_insert(struct inode *inode,
1513 struct ext4_ext_path *path) 1527 struct ext4_ext_path *path)
1514{ 1528{
1515 int depth, needed; 1529 int depth, needed;
@@ -1534,16 +1548,17 @@ int inline ext4_ext_calc_credits_for_insert(struct inode *inode,
1534 1548
1535 /* 1549 /*
1536 * tree can be full, so it would need to grow in depth: 1550 * tree can be full, so it would need to grow in depth:
1537 * allocation + old root + new root 1551 * we need one credit to modify old root, credits for
1552 * new root will be added in split accounting
1538 */ 1553 */
1539 needed += 2 + 1 + 1; 1554 needed += 1;
1540 1555
1541 /* 1556 /*
1542 * Index split can happen, we would need: 1557 * Index split can happen, we would need:
1543 * allocate intermediate indexes (bitmap + group) 1558 * allocate intermediate indexes (bitmap + group)
1544 * + change two blocks at each level, but root (already included) 1559 * + change two blocks at each level, but root (already included)
1545 */ 1560 */
1546 needed = (depth * 2) + (depth * 2); 1561 needed += (depth * 2) + (depth * 2);
1547 1562
1548 /* any allocation modifies superblock */ 1563 /* any allocation modifies superblock */
1549 needed += 1; 1564 needed += 1;
@@ -1718,7 +1733,7 @@ out:
1718 * ext4_ext_more_to_rm: 1733 * ext4_ext_more_to_rm:
1719 * returns 1 if current index has to be freed (even partial) 1734 * returns 1 if current index has to be freed (even partial)
1720 */ 1735 */
1721static int inline 1736static int
1722ext4_ext_more_to_rm(struct ext4_ext_path *path) 1737ext4_ext_more_to_rm(struct ext4_ext_path *path)
1723{ 1738{
1724 BUG_ON(path->p_idx == NULL); 1739 BUG_ON(path->p_idx == NULL);
@@ -1756,12 +1771,11 @@ int ext4_ext_remove_space(struct inode *inode, unsigned long start)
1756 * We start scanning from right side, freeing all the blocks 1771 * We start scanning from right side, freeing all the blocks
1757 * after i_size and walking into the tree depth-wise. 1772 * after i_size and walking into the tree depth-wise.
1758 */ 1773 */
1759 path = kmalloc(sizeof(struct ext4_ext_path) * (depth + 1), GFP_KERNEL); 1774 path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), GFP_KERNEL);
1760 if (path == NULL) { 1775 if (path == NULL) {
1761 ext4_journal_stop(handle); 1776 ext4_journal_stop(handle);
1762 return -ENOMEM; 1777 return -ENOMEM;
1763 } 1778 }
1764 memset(path, 0, sizeof(struct ext4_ext_path) * (depth + 1));
1765 path[0].p_hdr = ext_inode_hdr(inode); 1779 path[0].p_hdr = ext_inode_hdr(inode);
1766 if (ext4_ext_check_header(__FUNCTION__, inode, path[0].p_hdr)) { 1780 if (ext4_ext_check_header(__FUNCTION__, inode, path[0].p_hdr)) {
1767 err = -EIO; 1781 err = -EIO;
@@ -1932,7 +1946,8 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
1932 mutex_lock(&EXT4_I(inode)->truncate_mutex); 1946 mutex_lock(&EXT4_I(inode)->truncate_mutex);
1933 1947
1934 /* check in cache */ 1948 /* check in cache */
1935 if ((goal = ext4_ext_in_cache(inode, iblock, &newex))) { 1949 goal = ext4_ext_in_cache(inode, iblock, &newex);
1950 if (goal) {
1936 if (goal == EXT4_EXT_CACHE_GAP) { 1951 if (goal == EXT4_EXT_CACHE_GAP) {
1937 if (!create) { 1952 if (!create) {
1938 /* block isn't allocated yet and 1953 /* block isn't allocated yet and
@@ -1971,7 +1986,8 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
1971 */ 1986 */
1972 BUG_ON(path[depth].p_ext == NULL && depth != 0); 1987 BUG_ON(path[depth].p_ext == NULL && depth != 0);
1973 1988
1974 if ((ex = path[depth].p_ext)) { 1989 ex = path[depth].p_ext;
1990 if (ex) {
1975 unsigned long ee_block = le32_to_cpu(ex->ee_block); 1991 unsigned long ee_block = le32_to_cpu(ex->ee_block);
1976 ext4_fsblk_t ee_start = ext_pblock(ex); 1992 ext4_fsblk_t ee_start = ext_pblock(ex);
1977 unsigned short ee_len = le16_to_cpu(ex->ee_len); 1993 unsigned short ee_len = le16_to_cpu(ex->ee_len);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 0a60ec5a16db..1d85d4ec9598 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1147,37 +1147,102 @@ static int do_journal_get_write_access(handle_t *handle,
1147 return ext4_journal_get_write_access(handle, bh); 1147 return ext4_journal_get_write_access(handle, bh);
1148} 1148}
1149 1149
1150/*
1151 * The idea of this helper function is following:
1152 * if prepare_write has allocated some blocks, but not all of them, the
1153 * transaction must include the content of the newly allocated blocks.
1154 * This content is expected to be set to zeroes by block_prepare_write().
1155 * 2006/10/14 SAW
1156 */
1157static int ext4_prepare_failure(struct file *file, struct page *page,
1158 unsigned from, unsigned to)
1159{
1160 struct address_space *mapping;
1161 struct buffer_head *bh, *head, *next;
1162 unsigned block_start, block_end;
1163 unsigned blocksize;
1164 int ret;
1165 handle_t *handle = ext4_journal_current_handle();
1166
1167 mapping = page->mapping;
1168 if (ext4_should_writeback_data(mapping->host)) {
1169 /* optimization: no constraints about data */
1170skip:
1171 return ext4_journal_stop(handle);
1172 }
1173
1174 head = page_buffers(page);
1175 blocksize = head->b_size;
1176 for ( bh = head, block_start = 0;
1177 bh != head || !block_start;
1178 block_start = block_end, bh = next)
1179 {
1180 next = bh->b_this_page;
1181 block_end = block_start + blocksize;
1182 if (block_end <= from)
1183 continue;
1184 if (block_start >= to) {
1185 block_start = to;
1186 break;
1187 }
1188 if (!buffer_mapped(bh))
1189 /* prepare_write failed on this bh */
1190 break;
1191 if (ext4_should_journal_data(mapping->host)) {
1192 ret = do_journal_get_write_access(handle, bh);
1193 if (ret) {
1194 ext4_journal_stop(handle);
1195 return ret;
1196 }
1197 }
1198 /*
1199 * block_start here becomes the first block where the current iteration
1200 * of prepare_write failed.
1201 */
1202 }
1203 if (block_start <= from)
1204 goto skip;
1205
1206 /* commit allocated and zeroed buffers */
1207 return mapping->a_ops->commit_write(file, page, from, block_start);
1208}
1209
1150static int ext4_prepare_write(struct file *file, struct page *page, 1210static int ext4_prepare_write(struct file *file, struct page *page,
1151 unsigned from, unsigned to) 1211 unsigned from, unsigned to)
1152{ 1212{
1153 struct inode *inode = page->mapping->host; 1213 struct inode *inode = page->mapping->host;
1154 int ret, needed_blocks = ext4_writepage_trans_blocks(inode); 1214 int ret, ret2;
1215 int needed_blocks = ext4_writepage_trans_blocks(inode);
1155 handle_t *handle; 1216 handle_t *handle;
1156 int retries = 0; 1217 int retries = 0;
1157 1218
1158retry: 1219retry:
1159 handle = ext4_journal_start(inode, needed_blocks); 1220 handle = ext4_journal_start(inode, needed_blocks);
1160 if (IS_ERR(handle)) { 1221 if (IS_ERR(handle))
1161 ret = PTR_ERR(handle); 1222 return PTR_ERR(handle);
1162 goto out;
1163 }
1164 if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode)) 1223 if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode))
1165 ret = nobh_prepare_write(page, from, to, ext4_get_block); 1224 ret = nobh_prepare_write(page, from, to, ext4_get_block);
1166 else 1225 else
1167 ret = block_prepare_write(page, from, to, ext4_get_block); 1226 ret = block_prepare_write(page, from, to, ext4_get_block);
1168 if (ret) 1227 if (ret)
1169 goto prepare_write_failed; 1228 goto failure;
1170 1229
1171 if (ext4_should_journal_data(inode)) { 1230 if (ext4_should_journal_data(inode)) {
1172 ret = walk_page_buffers(handle, page_buffers(page), 1231 ret = walk_page_buffers(handle, page_buffers(page),
1173 from, to, NULL, do_journal_get_write_access); 1232 from, to, NULL, do_journal_get_write_access);
1233 if (ret)
1234 /* fatal error, just put the handle and return */
1235 journal_stop(handle);
1174 } 1236 }
1175prepare_write_failed: 1237 return ret;
1176 if (ret) 1238
1177 ext4_journal_stop(handle); 1239failure:
1240 ret2 = ext4_prepare_failure(file, page, from, to);
1241 if (ret2 < 0)
1242 return ret2;
1178 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) 1243 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
1179 goto retry; 1244 goto retry;
1180out: 1245 /* retry number exceeded, or other error like -EDQUOT */
1181 return ret; 1246 return ret;
1182} 1247}
1183 1248
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 8b1bd03d20f5..859990eac504 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -552,6 +552,15 @@ static int htree_dirblock_to_tree(struct file *dir_file,
552 dir->i_sb->s_blocksize - 552 dir->i_sb->s_blocksize -
553 EXT4_DIR_REC_LEN(0)); 553 EXT4_DIR_REC_LEN(0));
554 for (; de < top; de = ext4_next_entry(de)) { 554 for (; de < top; de = ext4_next_entry(de)) {
555 if (!ext4_check_dir_entry("htree_dirblock_to_tree", dir, de, bh,
556 (block<<EXT4_BLOCK_SIZE_BITS(dir->i_sb))
557 +((char *)de - bh->b_data))) {
558 /* On error, skip the f_pos to the next block. */
559 dir_file->f_pos = (dir_file->f_pos |
560 (dir->i_sb->s_blocksize - 1)) + 1;
561 brelse (bh);
562 return count;
563 }
555 ext4fs_dirhash(de->name, de->name_len, hinfo); 564 ext4fs_dirhash(de->name, de->name_len, hinfo);
556 if ((hinfo->hash < start_hash) || 565 if ((hinfo->hash < start_hash) ||
557 ((hinfo->hash == start_hash) && 566 ((hinfo->hash == start_hash) &&
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index b4b022aa2bc2..486a641ca71b 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -486,7 +486,7 @@ static void ext4_put_super (struct super_block * sb)
486 return; 486 return;
487} 487}
488 488
489static kmem_cache_t *ext4_inode_cachep; 489static struct kmem_cache *ext4_inode_cachep;
490 490
491/* 491/*
492 * Called inside transaction, so use GFP_NOFS 492 * Called inside transaction, so use GFP_NOFS
@@ -495,7 +495,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
495{ 495{
496 struct ext4_inode_info *ei; 496 struct ext4_inode_info *ei;
497 497
498 ei = kmem_cache_alloc(ext4_inode_cachep, SLAB_NOFS); 498 ei = kmem_cache_alloc(ext4_inode_cachep, GFP_NOFS);
499 if (!ei) 499 if (!ei)
500 return NULL; 500 return NULL;
501#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL 501#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
@@ -513,7 +513,7 @@ static void ext4_destroy_inode(struct inode *inode)
513 kmem_cache_free(ext4_inode_cachep, EXT4_I(inode)); 513 kmem_cache_free(ext4_inode_cachep, EXT4_I(inode));
514} 514}
515 515
516static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 516static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
517{ 517{
518 struct ext4_inode_info *ei = (struct ext4_inode_info *) foo; 518 struct ext4_inode_info *ei = (struct ext4_inode_info *) foo;
519 519
@@ -1321,6 +1321,12 @@ static void ext4_orphan_cleanup (struct super_block * sb,
1321 return; 1321 return;
1322 } 1322 }
1323 1323
1324 if (bdev_read_only(sb->s_bdev)) {
1325 printk(KERN_ERR "EXT4-fs: write access "
1326 "unavailable, skipping orphan cleanup.\n");
1327 return;
1328 }
1329
1324 if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) { 1330 if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) {
1325 if (es->s_last_orphan) 1331 if (es->s_last_orphan)
1326 jbd_debug(1, "Errors on filesystem, " 1332 jbd_debug(1, "Errors on filesystem, "
@@ -2460,6 +2466,7 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf)
2460 struct ext4_super_block *es = sbi->s_es; 2466 struct ext4_super_block *es = sbi->s_es;
2461 ext4_fsblk_t overhead; 2467 ext4_fsblk_t overhead;
2462 int i; 2468 int i;
2469 u64 fsid;
2463 2470
2464 if (test_opt (sb, MINIX_DF)) 2471 if (test_opt (sb, MINIX_DF))
2465 overhead = 0; 2472 overhead = 0;
@@ -2506,6 +2513,10 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf)
2506 buf->f_files = le32_to_cpu(es->s_inodes_count); 2513 buf->f_files = le32_to_cpu(es->s_inodes_count);
2507 buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter); 2514 buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter);
2508 buf->f_namelen = EXT4_NAME_LEN; 2515 buf->f_namelen = EXT4_NAME_LEN;
2516 fsid = le64_to_cpup((void *)es->s_uuid) ^
2517 le64_to_cpup((void *)es->s_uuid + sizeof(u64));
2518 buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
2519 buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
2509 return 0; 2520 return 0;
2510} 2521}
2511 2522
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 63233cd946a7..dc969c357aa1 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -459,14 +459,11 @@ static void ext4_xattr_update_super_block(handle_t *handle,
459 if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR)) 459 if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR))
460 return; 460 return;
461 461
462 lock_super(sb);
463 if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) { 462 if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) {
464 EXT4_SB(sb)->s_es->s_feature_compat |= 463 EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR);
465 cpu_to_le32(EXT4_FEATURE_COMPAT_EXT_ATTR);
466 sb->s_dirt = 1; 464 sb->s_dirt = 1;
467 ext4_journal_dirty_metadata(handle, EXT4_SB(sb)->s_sbh); 465 ext4_journal_dirty_metadata(handle, EXT4_SB(sb)->s_sbh);
468 } 466 }
469 unlock_super(sb);
470} 467}
471 468
472/* 469/*
diff --git a/fs/fat/cache.c b/fs/fat/cache.c
index 82cc4f59e3ba..05c2941c74f2 100644
--- a/fs/fat/cache.c
+++ b/fs/fat/cache.c
@@ -34,9 +34,9 @@ static inline int fat_max_cache(struct inode *inode)
34 return FAT_MAX_CACHE; 34 return FAT_MAX_CACHE;
35} 35}
36 36
37static kmem_cache_t *fat_cache_cachep; 37static struct kmem_cache *fat_cache_cachep;
38 38
39static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags) 39static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
40{ 40{
41 struct fat_cache *cache = (struct fat_cache *)foo; 41 struct fat_cache *cache = (struct fat_cache *)foo;
42 42
@@ -63,7 +63,7 @@ void fat_cache_destroy(void)
63 63
64static inline struct fat_cache *fat_cache_alloc(struct inode *inode) 64static inline struct fat_cache *fat_cache_alloc(struct inode *inode)
65{ 65{
66 return kmem_cache_alloc(fat_cache_cachep, SLAB_KERNEL); 66 return kmem_cache_alloc(fat_cache_cachep, GFP_KERNEL);
67} 67}
68 68
69static inline void fat_cache_free(struct fat_cache *cache) 69static inline void fat_cache_free(struct fat_cache *cache)
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 78945b53b0f8..a9e4688582a2 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -477,12 +477,12 @@ static void fat_put_super(struct super_block *sb)
477 kfree(sbi); 477 kfree(sbi);
478} 478}
479 479
480static kmem_cache_t *fat_inode_cachep; 480static struct kmem_cache *fat_inode_cachep;
481 481
482static struct inode *fat_alloc_inode(struct super_block *sb) 482static struct inode *fat_alloc_inode(struct super_block *sb)
483{ 483{
484 struct msdos_inode_info *ei; 484 struct msdos_inode_info *ei;
485 ei = kmem_cache_alloc(fat_inode_cachep, SLAB_KERNEL); 485 ei = kmem_cache_alloc(fat_inode_cachep, GFP_KERNEL);
486 if (!ei) 486 if (!ei)
487 return NULL; 487 return NULL;
488 return &ei->vfs_inode; 488 return &ei->vfs_inode;
@@ -493,7 +493,7 @@ static void fat_destroy_inode(struct inode *inode)
493 kmem_cache_free(fat_inode_cachep, MSDOS_I(inode)); 493 kmem_cache_free(fat_inode_cachep, MSDOS_I(inode));
494} 494}
495 495
496static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 496static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
497{ 497{
498 struct msdos_inode_info *ei = (struct msdos_inode_info *)foo; 498 struct msdos_inode_info *ei = (struct msdos_inode_info *)foo;
499 499
diff --git a/fs/fcntl.c b/fs/fcntl.c
index e4f26165f12a..4740d35e52cd 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -553,7 +553,7 @@ int send_sigurg(struct fown_struct *fown)
553} 553}
554 554
555static DEFINE_RWLOCK(fasync_lock); 555static DEFINE_RWLOCK(fasync_lock);
556static kmem_cache_t *fasync_cache __read_mostly; 556static struct kmem_cache *fasync_cache __read_mostly;
557 557
558/* 558/*
559 * fasync_helper() is used by some character device drivers (mainly mice) 559 * fasync_helper() is used by some character device drivers (mainly mice)
@@ -567,7 +567,7 @@ int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fap
567 int result = 0; 567 int result = 0;
568 568
569 if (on) { 569 if (on) {
570 new = kmem_cache_alloc(fasync_cache, SLAB_KERNEL); 570 new = kmem_cache_alloc(fasync_cache, GFP_KERNEL);
571 if (!new) 571 if (!new)
572 return -ENOMEM; 572 return -ENOMEM;
573 } 573 }
diff --git a/fs/file.c b/fs/file.c
index 8e81775c5dc8..51aef675470f 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -21,7 +21,6 @@
21struct fdtable_defer { 21struct fdtable_defer {
22 spinlock_t lock; 22 spinlock_t lock;
23 struct work_struct wq; 23 struct work_struct wq;
24 struct timer_list timer;
25 struct fdtable *next; 24 struct fdtable *next;
26}; 25};
27 26
@@ -75,24 +74,10 @@ static void __free_fdtable(struct fdtable *fdt)
75 kfree(fdt); 74 kfree(fdt);
76} 75}
77 76
78static void fdtable_timer(unsigned long data) 77static void free_fdtable_work(struct work_struct *work)
79{
80 struct fdtable_defer *fddef = (struct fdtable_defer *)data;
81
82 spin_lock(&fddef->lock);
83 /*
84 * If someone already emptied the queue return.
85 */
86 if (!fddef->next)
87 goto out;
88 if (!schedule_work(&fddef->wq))
89 mod_timer(&fddef->timer, 5);
90out:
91 spin_unlock(&fddef->lock);
92}
93
94static void free_fdtable_work(struct fdtable_defer *f)
95{ 78{
79 struct fdtable_defer *f =
80 container_of(work, struct fdtable_defer, wq);
96 struct fdtable *fdt; 81 struct fdtable *fdt;
97 82
98 spin_lock_bh(&f->lock); 83 spin_lock_bh(&f->lock);
@@ -142,13 +127,8 @@ static void free_fdtable_rcu(struct rcu_head *rcu)
142 spin_lock(&fddef->lock); 127 spin_lock(&fddef->lock);
143 fdt->next = fddef->next; 128 fdt->next = fddef->next;
144 fddef->next = fdt; 129 fddef->next = fdt;
145 /* 130 /* vmallocs are handled from the workqueue context */
146 * vmallocs are handled from the workqueue context. 131 schedule_work(&fddef->wq);
147 * If the per-cpu workqueue is running, then we
148 * defer work scheduling through a timer.
149 */
150 if (!schedule_work(&fddef->wq))
151 mod_timer(&fddef->timer, 5);
152 spin_unlock(&fddef->lock); 132 spin_unlock(&fddef->lock);
153 put_cpu_var(fdtable_defer_list); 133 put_cpu_var(fdtable_defer_list);
154 } 134 }
@@ -351,10 +331,7 @@ static void __devinit fdtable_defer_list_init(int cpu)
351{ 331{
352 struct fdtable_defer *fddef = &per_cpu(fdtable_defer_list, cpu); 332 struct fdtable_defer *fddef = &per_cpu(fdtable_defer_list, cpu);
353 spin_lock_init(&fddef->lock); 333 spin_lock_init(&fddef->lock);
354 INIT_WORK(&fddef->wq, (void (*)(void *))free_fdtable_work, fddef); 334 INIT_WORK(&fddef->wq, free_fdtable_work);
355 init_timer(&fddef->timer);
356 fddef->timer.data = (unsigned long)fddef;
357 fddef->timer.function = fdtable_timer;
358 fddef->next = NULL; 335 fddef->next = NULL;
359} 336}
360 337
diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c
index 4786d51ad3bd..0b7ae897cb78 100644
--- a/fs/freevxfs/vxfs_inode.c
+++ b/fs/freevxfs/vxfs_inode.c
@@ -46,7 +46,7 @@ extern const struct address_space_operations vxfs_immed_aops;
46 46
47extern struct inode_operations vxfs_immed_symlink_iops; 47extern struct inode_operations vxfs_immed_symlink_iops;
48 48
49kmem_cache_t *vxfs_inode_cachep; 49struct kmem_cache *vxfs_inode_cachep;
50 50
51 51
52#ifdef DIAGNOSTIC 52#ifdef DIAGNOSTIC
@@ -103,7 +103,7 @@ vxfs_blkiget(struct super_block *sbp, u_long extent, ino_t ino)
103 struct vxfs_inode_info *vip; 103 struct vxfs_inode_info *vip;
104 struct vxfs_dinode *dip; 104 struct vxfs_dinode *dip;
105 105
106 if (!(vip = kmem_cache_alloc(vxfs_inode_cachep, SLAB_KERNEL))) 106 if (!(vip = kmem_cache_alloc(vxfs_inode_cachep, GFP_KERNEL)))
107 goto fail; 107 goto fail;
108 dip = (struct vxfs_dinode *)(bp->b_data + offset); 108 dip = (struct vxfs_dinode *)(bp->b_data + offset);
109 memcpy(vip, dip, sizeof(*vip)); 109 memcpy(vip, dip, sizeof(*vip));
@@ -145,7 +145,7 @@ __vxfs_iget(ino_t ino, struct inode *ilistp)
145 struct vxfs_dinode *dip; 145 struct vxfs_dinode *dip;
146 caddr_t kaddr = (char *)page_address(pp); 146 caddr_t kaddr = (char *)page_address(pp);
147 147
148 if (!(vip = kmem_cache_alloc(vxfs_inode_cachep, SLAB_KERNEL))) 148 if (!(vip = kmem_cache_alloc(vxfs_inode_cachep, GFP_KERNEL)))
149 goto fail; 149 goto fail;
150 dip = (struct vxfs_dinode *)(kaddr + offset); 150 dip = (struct vxfs_dinode *)(kaddr + offset);
151 memcpy(vip, dip, sizeof(*vip)); 151 memcpy(vip, dip, sizeof(*vip));
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 66571eafbb1e..357764d85ff1 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -19,7 +19,7 @@
19 19
20MODULE_ALIAS_MISCDEV(FUSE_MINOR); 20MODULE_ALIAS_MISCDEV(FUSE_MINOR);
21 21
22static kmem_cache_t *fuse_req_cachep; 22static struct kmem_cache *fuse_req_cachep;
23 23
24static struct fuse_conn *fuse_get_conn(struct file *file) 24static struct fuse_conn *fuse_get_conn(struct file *file)
25{ 25{
@@ -41,7 +41,7 @@ static void fuse_request_init(struct fuse_req *req)
41 41
42struct fuse_req *fuse_request_alloc(void) 42struct fuse_req *fuse_request_alloc(void)
43{ 43{
44 struct fuse_req *req = kmem_cache_alloc(fuse_req_cachep, SLAB_KERNEL); 44 struct fuse_req *req = kmem_cache_alloc(fuse_req_cachep, GFP_KERNEL);
45 if (req) 45 if (req)
46 fuse_request_init(req); 46 fuse_request_init(req);
47 return req; 47 return req;
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index c71a6c092ad9..1cabdb229adb 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -141,9 +141,6 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd)
141 struct fuse_req *forget_req; 141 struct fuse_req *forget_req;
142 struct dentry *parent; 142 struct dentry *parent;
143 143
144 /* Doesn't hurt to "reset" the validity timeout */
145 fuse_invalidate_entry_cache(entry);
146
147 /* For negative dentries, always do a fresh lookup */ 144 /* For negative dentries, always do a fresh lookup */
148 if (!inode) 145 if (!inode)
149 return 0; 146 return 0;
@@ -1027,6 +1024,8 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr)
1027 if (attr->ia_valid & ATTR_SIZE) { 1024 if (attr->ia_valid & ATTR_SIZE) {
1028 unsigned long limit; 1025 unsigned long limit;
1029 is_truncate = 1; 1026 is_truncate = 1;
1027 if (IS_SWAPFILE(inode))
1028 return -ETXTBSY;
1030 limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur; 1029 limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
1031 if (limit != RLIM_INFINITY && attr->ia_size > (loff_t) limit) { 1030 if (limit != RLIM_INFINITY && attr->ia_size > (loff_t) limit) {
1032 send_sig(SIGXFSZ, current, 0); 1031 send_sig(SIGXFSZ, current, 0);
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 763a50daf1c0..128f79c40803 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -754,6 +754,42 @@ static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl)
754 return err; 754 return err;
755} 755}
756 756
757static sector_t fuse_bmap(struct address_space *mapping, sector_t block)
758{
759 struct inode *inode = mapping->host;
760 struct fuse_conn *fc = get_fuse_conn(inode);
761 struct fuse_req *req;
762 struct fuse_bmap_in inarg;
763 struct fuse_bmap_out outarg;
764 int err;
765
766 if (!inode->i_sb->s_bdev || fc->no_bmap)
767 return 0;
768
769 req = fuse_get_req(fc);
770 if (IS_ERR(req))
771 return 0;
772
773 memset(&inarg, 0, sizeof(inarg));
774 inarg.block = block;
775 inarg.blocksize = inode->i_sb->s_blocksize;
776 req->in.h.opcode = FUSE_BMAP;
777 req->in.h.nodeid = get_node_id(inode);
778 req->in.numargs = 1;
779 req->in.args[0].size = sizeof(inarg);
780 req->in.args[0].value = &inarg;
781 req->out.numargs = 1;
782 req->out.args[0].size = sizeof(outarg);
783 req->out.args[0].value = &outarg;
784 request_send(fc, req);
785 err = req->out.h.error;
786 fuse_put_request(fc, req);
787 if (err == -ENOSYS)
788 fc->no_bmap = 1;
789
790 return err ? 0 : outarg.block;
791}
792
757static const struct file_operations fuse_file_operations = { 793static const struct file_operations fuse_file_operations = {
758 .llseek = generic_file_llseek, 794 .llseek = generic_file_llseek,
759 .read = do_sync_read, 795 .read = do_sync_read,
@@ -787,6 +823,7 @@ static const struct address_space_operations fuse_file_aops = {
787 .commit_write = fuse_commit_write, 823 .commit_write = fuse_commit_write,
788 .readpages = fuse_readpages, 824 .readpages = fuse_readpages,
789 .set_page_dirty = fuse_set_page_dirty, 825 .set_page_dirty = fuse_set_page_dirty,
826 .bmap = fuse_bmap,
790}; 827};
791 828
792void fuse_init_file_inode(struct inode *inode) 829void fuse_init_file_inode(struct inode *inode)
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 91edb8932d90..b98b20de7405 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -298,6 +298,9 @@ struct fuse_conn {
298 reply, before any other request, and never cleared */ 298 reply, before any other request, and never cleared */
299 unsigned conn_error : 1; 299 unsigned conn_error : 1;
300 300
301 /** Connection successful. Only set in INIT */
302 unsigned conn_init : 1;
303
301 /** Do readpages asynchronously? Only set in INIT */ 304 /** Do readpages asynchronously? Only set in INIT */
302 unsigned async_read : 1; 305 unsigned async_read : 1;
303 306
@@ -339,6 +342,9 @@ struct fuse_conn {
339 /** Is interrupt not implemented by fs? */ 342 /** Is interrupt not implemented by fs? */
340 unsigned no_interrupt : 1; 343 unsigned no_interrupt : 1;
341 344
345 /** Is bmap not implemented by fs? */
346 unsigned no_bmap : 1;
347
342 /** The number of requests waiting for completion */ 348 /** The number of requests waiting for completion */
343 atomic_t num_waiting; 349 atomic_t num_waiting;
344 350
@@ -365,6 +371,9 @@ struct fuse_conn {
365 371
366 /** Key for lock owner ID scrambling */ 372 /** Key for lock owner ID scrambling */
367 u32 scramble_key[4]; 373 u32 scramble_key[4];
374
375 /** Reserved request for the DESTROY message */
376 struct fuse_req *destroy_req;
368}; 377};
369 378
370static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb) 379static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb)
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index fc4203570370..12450d2b320e 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -22,7 +22,7 @@ MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
22MODULE_DESCRIPTION("Filesystem in Userspace"); 22MODULE_DESCRIPTION("Filesystem in Userspace");
23MODULE_LICENSE("GPL"); 23MODULE_LICENSE("GPL");
24 24
25static kmem_cache_t *fuse_inode_cachep; 25static struct kmem_cache *fuse_inode_cachep;
26struct list_head fuse_conn_list; 26struct list_head fuse_conn_list;
27DEFINE_MUTEX(fuse_mutex); 27DEFINE_MUTEX(fuse_mutex);
28 28
@@ -39,6 +39,7 @@ struct fuse_mount_data {
39 unsigned group_id_present : 1; 39 unsigned group_id_present : 1;
40 unsigned flags; 40 unsigned flags;
41 unsigned max_read; 41 unsigned max_read;
42 unsigned blksize;
42}; 43};
43 44
44static struct inode *fuse_alloc_inode(struct super_block *sb) 45static struct inode *fuse_alloc_inode(struct super_block *sb)
@@ -46,7 +47,7 @@ static struct inode *fuse_alloc_inode(struct super_block *sb)
46 struct inode *inode; 47 struct inode *inode;
47 struct fuse_inode *fi; 48 struct fuse_inode *fi;
48 49
49 inode = kmem_cache_alloc(fuse_inode_cachep, SLAB_KERNEL); 50 inode = kmem_cache_alloc(fuse_inode_cachep, GFP_KERNEL);
50 if (!inode) 51 if (!inode)
51 return NULL; 52 return NULL;
52 53
@@ -205,10 +206,23 @@ static void fuse_umount_begin(struct vfsmount *vfsmnt, int flags)
205 fuse_abort_conn(get_fuse_conn_super(vfsmnt->mnt_sb)); 206 fuse_abort_conn(get_fuse_conn_super(vfsmnt->mnt_sb));
206} 207}
207 208
209static void fuse_send_destroy(struct fuse_conn *fc)
210{
211 struct fuse_req *req = fc->destroy_req;
212 if (req && fc->conn_init) {
213 fc->destroy_req = NULL;
214 req->in.h.opcode = FUSE_DESTROY;
215 req->force = 1;
216 request_send(fc, req);
217 fuse_put_request(fc, req);
218 }
219}
220
208static void fuse_put_super(struct super_block *sb) 221static void fuse_put_super(struct super_block *sb)
209{ 222{
210 struct fuse_conn *fc = get_fuse_conn_super(sb); 223 struct fuse_conn *fc = get_fuse_conn_super(sb);
211 224
225 fuse_send_destroy(fc);
212 spin_lock(&fc->lock); 226 spin_lock(&fc->lock);
213 fc->connected = 0; 227 fc->connected = 0;
214 fc->blocked = 0; 228 fc->blocked = 0;
@@ -274,6 +288,7 @@ enum {
274 OPT_DEFAULT_PERMISSIONS, 288 OPT_DEFAULT_PERMISSIONS,
275 OPT_ALLOW_OTHER, 289 OPT_ALLOW_OTHER,
276 OPT_MAX_READ, 290 OPT_MAX_READ,
291 OPT_BLKSIZE,
277 OPT_ERR 292 OPT_ERR
278}; 293};
279 294
@@ -285,14 +300,16 @@ static match_table_t tokens = {
285 {OPT_DEFAULT_PERMISSIONS, "default_permissions"}, 300 {OPT_DEFAULT_PERMISSIONS, "default_permissions"},
286 {OPT_ALLOW_OTHER, "allow_other"}, 301 {OPT_ALLOW_OTHER, "allow_other"},
287 {OPT_MAX_READ, "max_read=%u"}, 302 {OPT_MAX_READ, "max_read=%u"},
303 {OPT_BLKSIZE, "blksize=%u"},
288 {OPT_ERR, NULL} 304 {OPT_ERR, NULL}
289}; 305};
290 306
291static int parse_fuse_opt(char *opt, struct fuse_mount_data *d) 307static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev)
292{ 308{
293 char *p; 309 char *p;
294 memset(d, 0, sizeof(struct fuse_mount_data)); 310 memset(d, 0, sizeof(struct fuse_mount_data));
295 d->max_read = ~0; 311 d->max_read = ~0;
312 d->blksize = 512;
296 313
297 while ((p = strsep(&opt, ",")) != NULL) { 314 while ((p = strsep(&opt, ",")) != NULL) {
298 int token; 315 int token;
@@ -345,6 +362,12 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d)
345 d->max_read = value; 362 d->max_read = value;
346 break; 363 break;
347 364
365 case OPT_BLKSIZE:
366 if (!is_bdev || match_int(&args[0], &value))
367 return 0;
368 d->blksize = value;
369 break;
370
348 default: 371 default:
349 return 0; 372 return 0;
350 } 373 }
@@ -400,6 +423,8 @@ static struct fuse_conn *new_conn(void)
400void fuse_conn_put(struct fuse_conn *fc) 423void fuse_conn_put(struct fuse_conn *fc)
401{ 424{
402 if (atomic_dec_and_test(&fc->count)) { 425 if (atomic_dec_and_test(&fc->count)) {
426 if (fc->destroy_req)
427 fuse_request_free(fc->destroy_req);
403 mutex_destroy(&fc->inst_mutex); 428 mutex_destroy(&fc->inst_mutex);
404 kfree(fc); 429 kfree(fc);
405 } 430 }
@@ -456,6 +481,7 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
456 fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages); 481 fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages);
457 fc->minor = arg->minor; 482 fc->minor = arg->minor;
458 fc->max_write = arg->minor < 5 ? 4096 : arg->max_write; 483 fc->max_write = arg->minor < 5 ? 4096 : arg->max_write;
484 fc->conn_init = 1;
459 } 485 }
460 fuse_put_request(fc, req); 486 fuse_put_request(fc, req);
461 fc->blocked = 0; 487 fc->blocked = 0;
@@ -500,15 +526,23 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
500 struct dentry *root_dentry; 526 struct dentry *root_dentry;
501 struct fuse_req *init_req; 527 struct fuse_req *init_req;
502 int err; 528 int err;
529 int is_bdev = sb->s_bdev != NULL;
503 530
504 if (sb->s_flags & MS_MANDLOCK) 531 if (sb->s_flags & MS_MANDLOCK)
505 return -EINVAL; 532 return -EINVAL;
506 533
507 if (!parse_fuse_opt((char *) data, &d)) 534 if (!parse_fuse_opt((char *) data, &d, is_bdev))
508 return -EINVAL; 535 return -EINVAL;
509 536
510 sb->s_blocksize = PAGE_CACHE_SIZE; 537 if (is_bdev) {
511 sb->s_blocksize_bits = PAGE_CACHE_SHIFT; 538#ifdef CONFIG_BLOCK
539 if (!sb_set_blocksize(sb, d.blksize))
540 return -EINVAL;
541#endif
542 } else {
543 sb->s_blocksize = PAGE_CACHE_SIZE;
544 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
545 }
512 sb->s_magic = FUSE_SUPER_MAGIC; 546 sb->s_magic = FUSE_SUPER_MAGIC;
513 sb->s_op = &fuse_super_operations; 547 sb->s_op = &fuse_super_operations;
514 sb->s_maxbytes = MAX_LFS_FILESIZE; 548 sb->s_maxbytes = MAX_LFS_FILESIZE;
@@ -547,6 +581,12 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
547 if (!init_req) 581 if (!init_req)
548 goto err_put_root; 582 goto err_put_root;
549 583
584 if (is_bdev) {
585 fc->destroy_req = fuse_request_alloc();
586 if (!fc->destroy_req)
587 goto err_put_root;
588 }
589
550 mutex_lock(&fuse_mutex); 590 mutex_lock(&fuse_mutex);
551 err = -EINVAL; 591 err = -EINVAL;
552 if (file->private_data) 592 if (file->private_data)
@@ -598,10 +638,47 @@ static struct file_system_type fuse_fs_type = {
598 .kill_sb = kill_anon_super, 638 .kill_sb = kill_anon_super,
599}; 639};
600 640
641#ifdef CONFIG_BLOCK
642static int fuse_get_sb_blk(struct file_system_type *fs_type,
643 int flags, const char *dev_name,
644 void *raw_data, struct vfsmount *mnt)
645{
646 return get_sb_bdev(fs_type, flags, dev_name, raw_data, fuse_fill_super,
647 mnt);
648}
649
650static struct file_system_type fuseblk_fs_type = {
651 .owner = THIS_MODULE,
652 .name = "fuseblk",
653 .get_sb = fuse_get_sb_blk,
654 .kill_sb = kill_block_super,
655 .fs_flags = FS_REQUIRES_DEV,
656};
657
658static inline int register_fuseblk(void)
659{
660 return register_filesystem(&fuseblk_fs_type);
661}
662
663static inline void unregister_fuseblk(void)
664{
665 unregister_filesystem(&fuseblk_fs_type);
666}
667#else
668static inline int register_fuseblk(void)
669{
670 return 0;
671}
672
673static inline void unregister_fuseblk(void)
674{
675}
676#endif
677
601static decl_subsys(fuse, NULL, NULL); 678static decl_subsys(fuse, NULL, NULL);
602static decl_subsys(connections, NULL, NULL); 679static decl_subsys(connections, NULL, NULL);
603 680
604static void fuse_inode_init_once(void *foo, kmem_cache_t *cachep, 681static void fuse_inode_init_once(void *foo, struct kmem_cache *cachep,
605 unsigned long flags) 682 unsigned long flags)
606{ 683{
607 struct inode * inode = foo; 684 struct inode * inode = foo;
@@ -617,24 +694,34 @@ static int __init fuse_fs_init(void)
617 694
618 err = register_filesystem(&fuse_fs_type); 695 err = register_filesystem(&fuse_fs_type);
619 if (err) 696 if (err)
620 printk("fuse: failed to register filesystem\n"); 697 goto out;
621 else {
622 fuse_inode_cachep = kmem_cache_create("fuse_inode",
623 sizeof(struct fuse_inode),
624 0, SLAB_HWCACHE_ALIGN,
625 fuse_inode_init_once, NULL);
626 if (!fuse_inode_cachep) {
627 unregister_filesystem(&fuse_fs_type);
628 err = -ENOMEM;
629 }
630 }
631 698
699 err = register_fuseblk();
700 if (err)
701 goto out_unreg;
702
703 fuse_inode_cachep = kmem_cache_create("fuse_inode",
704 sizeof(struct fuse_inode),
705 0, SLAB_HWCACHE_ALIGN,
706 fuse_inode_init_once, NULL);
707 err = -ENOMEM;
708 if (!fuse_inode_cachep)
709 goto out_unreg2;
710
711 return 0;
712
713 out_unreg2:
714 unregister_fuseblk();
715 out_unreg:
716 unregister_filesystem(&fuse_fs_type);
717 out:
632 return err; 718 return err;
633} 719}
634 720
635static void fuse_fs_cleanup(void) 721static void fuse_fs_cleanup(void)
636{ 722{
637 unregister_filesystem(&fuse_fs_type); 723 unregister_filesystem(&fuse_fs_type);
724 unregister_fuseblk();
638 kmem_cache_destroy(fuse_inode_cachep); 725 kmem_cache_destroy(fuse_inode_cachep);
639} 726}
640 727
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 78fe0fae23ff..55f5333dae99 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -35,7 +35,7 @@
35 35
36struct greedy { 36struct greedy {
37 struct gfs2_holder gr_gh; 37 struct gfs2_holder gr_gh;
38 struct work_struct gr_work; 38 struct delayed_work gr_work;
39}; 39};
40 40
41struct gfs2_gl_hash_bucket { 41struct gfs2_gl_hash_bucket {
@@ -1368,9 +1368,9 @@ static void gfs2_glock_prefetch(struct gfs2_glock *gl, unsigned int state,
1368 glops->go_xmote_th(gl, state, flags); 1368 glops->go_xmote_th(gl, state, flags);
1369} 1369}
1370 1370
1371static void greedy_work(void *data) 1371static void greedy_work(struct work_struct *work)
1372{ 1372{
1373 struct greedy *gr = data; 1373 struct greedy *gr = container_of(work, struct greedy, gr_work.work);
1374 struct gfs2_holder *gh = &gr->gr_gh; 1374 struct gfs2_holder *gh = &gr->gr_gh;
1375 struct gfs2_glock *gl = gh->gh_gl; 1375 struct gfs2_glock *gl = gh->gh_gl;
1376 const struct gfs2_glock_operations *glops = gl->gl_ops; 1376 const struct gfs2_glock_operations *glops = gl->gl_ops;
@@ -1422,7 +1422,7 @@ int gfs2_glock_be_greedy(struct gfs2_glock *gl, unsigned int time)
1422 1422
1423 gfs2_holder_init(gl, 0, 0, gh); 1423 gfs2_holder_init(gl, 0, 0, gh);
1424 set_bit(HIF_GREEDY, &gh->gh_iflags); 1424 set_bit(HIF_GREEDY, &gh->gh_iflags);
1425 INIT_WORK(&gr->gr_work, greedy_work, gr); 1425 INIT_DELAYED_WORK(&gr->gr_work, greedy_work);
1426 1426
1427 set_bit(GLF_SKIP_WAITERS2, &gl->gl_flags); 1427 set_bit(GLF_SKIP_WAITERS2, &gl->gl_flags);
1428 schedule_delayed_work(&gr->gr_work, time); 1428 schedule_delayed_work(&gr->gr_work, time);
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c
index 9889c1eacec1..7c1a9e22a526 100644
--- a/fs/gfs2/main.c
+++ b/fs/gfs2/main.c
@@ -25,7 +25,7 @@
25#include "util.h" 25#include "util.h"
26#include "glock.h" 26#include "glock.h"
27 27
28static void gfs2_init_inode_once(void *foo, kmem_cache_t *cachep, unsigned long flags) 28static void gfs2_init_inode_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
29{ 29{
30 struct gfs2_inode *ip = foo; 30 struct gfs2_inode *ip = foo;
31 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == 31 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
@@ -37,7 +37,7 @@ static void gfs2_init_inode_once(void *foo, kmem_cache_t *cachep, unsigned long
37 } 37 }
38} 38}
39 39
40static void gfs2_init_glock_once(void *foo, kmem_cache_t *cachep, unsigned long flags) 40static void gfs2_init_glock_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
41{ 41{
42 struct gfs2_glock *gl = foo; 42 struct gfs2_glock *gl = foo;
43 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == 43 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c
index 196c604faadc..e5707a9f78c2 100644
--- a/fs/gfs2/util.c
+++ b/fs/gfs2/util.c
@@ -23,9 +23,9 @@
23#include "lm.h" 23#include "lm.h"
24#include "util.h" 24#include "util.h"
25 25
26kmem_cache_t *gfs2_glock_cachep __read_mostly; 26struct kmem_cache *gfs2_glock_cachep __read_mostly;
27kmem_cache_t *gfs2_inode_cachep __read_mostly; 27struct kmem_cache *gfs2_inode_cachep __read_mostly;
28kmem_cache_t *gfs2_bufdata_cachep __read_mostly; 28struct kmem_cache *gfs2_bufdata_cachep __read_mostly;
29 29
30void gfs2_assert_i(struct gfs2_sbd *sdp) 30void gfs2_assert_i(struct gfs2_sbd *sdp)
31{ 31{
diff --git a/fs/gfs2/util.h b/fs/gfs2/util.h
index 76a50899fe9e..7984dcf89ad0 100644
--- a/fs/gfs2/util.h
+++ b/fs/gfs2/util.h
@@ -146,9 +146,9 @@ int gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh,
146gfs2_io_error_bh_i((sdp), (bh), __FUNCTION__, __FILE__, __LINE__); 146gfs2_io_error_bh_i((sdp), (bh), __FUNCTION__, __FILE__, __LINE__);
147 147
148 148
149extern kmem_cache_t *gfs2_glock_cachep; 149extern struct kmem_cache *gfs2_glock_cachep;
150extern kmem_cache_t *gfs2_inode_cachep; 150extern struct kmem_cache *gfs2_inode_cachep;
151extern kmem_cache_t *gfs2_bufdata_cachep; 151extern struct kmem_cache *gfs2_bufdata_cachep;
152 152
153static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt, 153static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt,
154 unsigned int *p) 154 unsigned int *p)
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 85b17b3fa4a0..a36987966004 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -24,7 +24,7 @@
24#include "hfs_fs.h" 24#include "hfs_fs.h"
25#include "btree.h" 25#include "btree.h"
26 26
27static kmem_cache_t *hfs_inode_cachep; 27static struct kmem_cache *hfs_inode_cachep;
28 28
29MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
30 30
@@ -145,7 +145,7 @@ static struct inode *hfs_alloc_inode(struct super_block *sb)
145{ 145{
146 struct hfs_inode_info *i; 146 struct hfs_inode_info *i;
147 147
148 i = kmem_cache_alloc(hfs_inode_cachep, SLAB_KERNEL); 148 i = kmem_cache_alloc(hfs_inode_cachep, GFP_KERNEL);
149 return i ? &i->vfs_inode : NULL; 149 return i ? &i->vfs_inode : NULL;
150} 150}
151 151
@@ -430,7 +430,7 @@ static struct file_system_type hfs_fs_type = {
430 .fs_flags = FS_REQUIRES_DEV, 430 .fs_flags = FS_REQUIRES_DEV,
431}; 431};
432 432
433static void hfs_init_once(void *p, kmem_cache_t *cachep, unsigned long flags) 433static void hfs_init_once(void *p, struct kmem_cache *cachep, unsigned long flags)
434{ 434{
435 struct hfs_inode_info *i = p; 435 struct hfs_inode_info *i = p;
436 436
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 194eede52fa4..0f513c6bf843 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -434,13 +434,13 @@ MODULE_AUTHOR("Brad Boyer");
434MODULE_DESCRIPTION("Extended Macintosh Filesystem"); 434MODULE_DESCRIPTION("Extended Macintosh Filesystem");
435MODULE_LICENSE("GPL"); 435MODULE_LICENSE("GPL");
436 436
437static kmem_cache_t *hfsplus_inode_cachep; 437static struct kmem_cache *hfsplus_inode_cachep;
438 438
439static struct inode *hfsplus_alloc_inode(struct super_block *sb) 439static struct inode *hfsplus_alloc_inode(struct super_block *sb)
440{ 440{
441 struct hfsplus_inode_info *i; 441 struct hfsplus_inode_info *i;
442 442
443 i = kmem_cache_alloc(hfsplus_inode_cachep, SLAB_KERNEL); 443 i = kmem_cache_alloc(hfsplus_inode_cachep, GFP_KERNEL);
444 return i ? &i->vfs_inode : NULL; 444 return i ? &i->vfs_inode : NULL;
445} 445}
446 446
@@ -467,7 +467,7 @@ static struct file_system_type hfsplus_fs_type = {
467 .fs_flags = FS_REQUIRES_DEV, 467 .fs_flags = FS_REQUIRES_DEV,
468}; 468};
469 469
470static void hfsplus_init_once(void *p, kmem_cache_t *cachep, unsigned long flags) 470static void hfsplus_init_once(void *p, struct kmem_cache *cachep, unsigned long flags)
471{ 471{
472 struct hfsplus_inode_info *i = p; 472 struct hfsplus_inode_info *i = p;
473 473
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index ecc9180645ae..594f9c428fc2 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -84,7 +84,8 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
84 } 84 }
85 if (!fno->dirflag) { 85 if (!fno->dirflag) {
86 e = 1; 86 e = 1;
87 hpfs_error(inode->i_sb, "not a directory, fnode %08x",inode->i_ino); 87 hpfs_error(inode->i_sb, "not a directory, fnode %08lx",
88 (unsigned long)inode->i_ino);
88 } 89 }
89 if (hpfs_inode->i_dno != fno->u.external[0].disk_secno) { 90 if (hpfs_inode->i_dno != fno->u.external[0].disk_secno) {
90 e = 1; 91 e = 1;
@@ -144,8 +145,11 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
144 } 145 }
145 if (de->first || de->last) { 146 if (de->first || de->last) {
146 if (hpfs_sb(inode->i_sb)->sb_chk) { 147 if (hpfs_sb(inode->i_sb)->sb_chk) {
147 if (de->first && !de->last && (de->namelen != 2 || de ->name[0] != 1 || de->name[1] != 1)) hpfs_error(inode->i_sb, "hpfs_readdir: bad ^A^A entry; pos = %08x", old_pos); 148 if (de->first && !de->last && (de->namelen != 2
148 if (de->last && (de->namelen != 1 || de ->name[0] != 255)) hpfs_error(inode->i_sb, "hpfs_readdir: bad \\377 entry; pos = %08x", old_pos); 149 || de ->name[0] != 1 || de->name[1] != 1))
150 hpfs_error(inode->i_sb, "hpfs_readdir: bad ^A^A entry; pos = %08lx", old_pos);
151 if (de->last && (de->namelen != 1 || de ->name[0] != 255))
152 hpfs_error(inode->i_sb, "hpfs_readdir: bad \\377 entry; pos = %08lx", old_pos);
149 } 153 }
150 hpfs_brelse4(&qbh); 154 hpfs_brelse4(&qbh);
151 goto again; 155 goto again;
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c
index 229ff2fb1809..fe83c2b7d2d8 100644
--- a/fs/hpfs/dnode.c
+++ b/fs/hpfs/dnode.c
@@ -533,10 +533,13 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
533 struct buffer_head *bh; 533 struct buffer_head *bh;
534 struct dnode *d1; 534 struct dnode *d1;
535 struct quad_buffer_head qbh1; 535 struct quad_buffer_head qbh1;
536 if (hpfs_sb(i->i_sb)->sb_chk) if (up != i->i_ino) { 536 if (hpfs_sb(i->i_sb)->sb_chk)
537 hpfs_error(i->i_sb, "bad pointer to fnode, dnode %08x, pointing to %08x, should be %08x", dno, up, i->i_ino); 537 if (up != i->i_ino) {
538 hpfs_error(i->i_sb,
539 "bad pointer to fnode, dnode %08x, pointing to %08x, should be %08lx",
540 dno, up, (unsigned long)i->i_ino);
538 return; 541 return;
539 } 542 }
540 if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) { 543 if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) {
541 d1->up = up; 544 d1->up = up;
542 d1->root_dnode = 1; 545 d1->root_dnode = 1;
@@ -851,7 +854,9 @@ struct hpfs_dirent *map_pos_dirent(struct inode *inode, loff_t *posp,
851 /* Going to the next dirent */ 854 /* Going to the next dirent */
852 if ((d = de_next_de(de)) < dnode_end_de(dnode)) { 855 if ((d = de_next_de(de)) < dnode_end_de(dnode)) {
853 if (!(++*posp & 077)) { 856 if (!(++*posp & 077)) {
854 hpfs_error(inode->i_sb, "map_pos_dirent: pos crossed dnode boundary; pos = %08x", *posp); 857 hpfs_error(inode->i_sb,
858 "map_pos_dirent: pos crossed dnode boundary; pos = %08llx",
859 (unsigned long long)*posp);
855 goto bail; 860 goto bail;
856 } 861 }
857 /* We're going down the tree */ 862 /* We're going down the tree */
diff --git a/fs/hpfs/ea.c b/fs/hpfs/ea.c
index 66339dc030e4..547a8384571f 100644
--- a/fs/hpfs/ea.c
+++ b/fs/hpfs/ea.c
@@ -243,8 +243,9 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, char *key, char *data
243 fnode->ea_offs = 0xc4; 243 fnode->ea_offs = 0xc4;
244 } 244 }
245 if (fnode->ea_offs < 0xc4 || fnode->ea_offs + fnode->acl_size_s + fnode->ea_size_s > 0x200) { 245 if (fnode->ea_offs < 0xc4 || fnode->ea_offs + fnode->acl_size_s + fnode->ea_size_s > 0x200) {
246 hpfs_error(s, "fnode %08x: ea_offs == %03x, ea_size_s == %03x", 246 hpfs_error(s, "fnode %08lx: ea_offs == %03x, ea_size_s == %03x",
247 inode->i_ino, fnode->ea_offs, fnode->ea_size_s); 247 (unsigned long)inode->i_ino,
248 fnode->ea_offs, fnode->ea_size_s);
248 return; 249 return;
249 } 250 }
250 if ((fnode->ea_size_s || !fnode->ea_size_l) && 251 if ((fnode->ea_size_s || !fnode->ea_size_l) &&
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
index 32ab51e42b96..1c07aa82d327 100644
--- a/fs/hpfs/hpfs_fn.h
+++ b/fs/hpfs/hpfs_fn.h
@@ -317,7 +317,8 @@ static inline struct hpfs_sb_info *hpfs_sb(struct super_block *sb)
317 317
318/* super.c */ 318/* super.c */
319 319
320void hpfs_error(struct super_block *, char *, ...); 320void hpfs_error(struct super_block *, const char *, ...)
321 __attribute__((format (printf, 2, 3)));
321int hpfs_stop_cycles(struct super_block *, int, int *, int *, char *); 322int hpfs_stop_cycles(struct super_block *, int, int *, int *, char *);
322unsigned hpfs_count_one_bitmap(struct super_block *, secno); 323unsigned hpfs_count_one_bitmap(struct super_block *, secno);
323 324
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index 7faef8544f32..85d3e1d9ac00 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -251,7 +251,10 @@ void hpfs_write_inode_nolock(struct inode *i)
251 de->file_size = 0; 251 de->file_size = 0;
252 hpfs_mark_4buffers_dirty(&qbh); 252 hpfs_mark_4buffers_dirty(&qbh);
253 hpfs_brelse4(&qbh); 253 hpfs_brelse4(&qbh);
254 } else hpfs_error(i->i_sb, "directory %08x doesn't have '.' entry", i->i_ino); 254 } else
255 hpfs_error(i->i_sb,
256 "directory %08lx doesn't have '.' entry",
257 (unsigned long)i->i_ino);
255 } 258 }
256 mark_buffer_dirty(bh); 259 mark_buffer_dirty(bh);
257 brelse(bh); 260 brelse(bh);
diff --git a/fs/hpfs/map.c b/fs/hpfs/map.c
index 0fecdac22e4e..c4724589b2eb 100644
--- a/fs/hpfs/map.c
+++ b/fs/hpfs/map.c
@@ -126,32 +126,40 @@ struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_hea
126 struct extended_attribute *ea; 126 struct extended_attribute *ea;
127 struct extended_attribute *ea_end; 127 struct extended_attribute *ea_end;
128 if (fnode->magic != FNODE_MAGIC) { 128 if (fnode->magic != FNODE_MAGIC) {
129 hpfs_error(s, "bad magic on fnode %08x", ino); 129 hpfs_error(s, "bad magic on fnode %08lx",
130 (unsigned long)ino);
130 goto bail; 131 goto bail;
131 } 132 }
132 if (!fnode->dirflag) { 133 if (!fnode->dirflag) {
133 if ((unsigned)fnode->btree.n_used_nodes + (unsigned)fnode->btree.n_free_nodes != 134 if ((unsigned)fnode->btree.n_used_nodes + (unsigned)fnode->btree.n_free_nodes !=
134 (fnode->btree.internal ? 12 : 8)) { 135 (fnode->btree.internal ? 12 : 8)) {
135 hpfs_error(s, "bad number of nodes in fnode %08x", ino); 136 hpfs_error(s,
137 "bad number of nodes in fnode %08lx",
138 (unsigned long)ino);
136 goto bail; 139 goto bail;
137 } 140 }
138 if (fnode->btree.first_free != 141 if (fnode->btree.first_free !=
139 8 + fnode->btree.n_used_nodes * (fnode->btree.internal ? 8 : 12)) { 142 8 + fnode->btree.n_used_nodes * (fnode->btree.internal ? 8 : 12)) {
140 hpfs_error(s, "bad first_free pointer in fnode %08x", ino); 143 hpfs_error(s,
144 "bad first_free pointer in fnode %08lx",
145 (unsigned long)ino);
141 goto bail; 146 goto bail;
142 } 147 }
143 } 148 }
144 if (fnode->ea_size_s && ((signed int)fnode->ea_offs < 0xc4 || 149 if (fnode->ea_size_s && ((signed int)fnode->ea_offs < 0xc4 ||
145 (signed int)fnode->ea_offs + fnode->acl_size_s + fnode->ea_size_s > 0x200)) { 150 (signed int)fnode->ea_offs + fnode->acl_size_s + fnode->ea_size_s > 0x200)) {
146 hpfs_error(s, "bad EA info in fnode %08x: ea_offs == %04x ea_size_s == %04x", 151 hpfs_error(s,
147 ino, fnode->ea_offs, fnode->ea_size_s); 152 "bad EA info in fnode %08lx: ea_offs == %04x ea_size_s == %04x",
153 (unsigned long)ino,
154 fnode->ea_offs, fnode->ea_size_s);
148 goto bail; 155 goto bail;
149 } 156 }
150 ea = fnode_ea(fnode); 157 ea = fnode_ea(fnode);
151 ea_end = fnode_end_ea(fnode); 158 ea_end = fnode_end_ea(fnode);
152 while (ea != ea_end) { 159 while (ea != ea_end) {
153 if (ea > ea_end) { 160 if (ea > ea_end) {
154 hpfs_error(s, "bad EA in fnode %08x", ino); 161 hpfs_error(s, "bad EA in fnode %08lx",
162 (unsigned long)ino);
155 goto bail; 163 goto bail;
156 } 164 }
157 ea = next_ea(ea); 165 ea = next_ea(ea);
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 450b5e0b4785..d4abc1a1d566 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -46,21 +46,17 @@ static void unmark_dirty(struct super_block *s)
46} 46}
47 47
48/* Filesystem error... */ 48/* Filesystem error... */
49static char err_buf[1024];
49 50
50#define ERR_BUF_SIZE 1024 51void hpfs_error(struct super_block *s, const char *fmt, ...)
51
52void hpfs_error(struct super_block *s, char *m,...)
53{ 52{
54 char *buf; 53 va_list args;
55 va_list l; 54
56 va_start(l, m); 55 va_start(args, fmt);
57 if (!(buf = kmalloc(ERR_BUF_SIZE, GFP_KERNEL))) 56 vsnprintf(err_buf, sizeof(err_buf), fmt, args);
58 printk("HPFS: No memory for error message '%s'\n",m); 57 va_end(args);
59 else if (vsprintf(buf, m, l) >= ERR_BUF_SIZE) 58
60 printk("HPFS: Grrrr... Kernel memory corrupted ... going on, but it'll crash very soon :-(\n"); 59 printk("HPFS: filesystem error: %s", err_buf);
61 printk("HPFS: filesystem error: ");
62 if (buf) printk("%s", buf);
63 else printk("%s\n",m);
64 if (!hpfs_sb(s)->sb_was_error) { 60 if (!hpfs_sb(s)->sb_was_error) {
65 if (hpfs_sb(s)->sb_err == 2) { 61 if (hpfs_sb(s)->sb_err == 2) {
66 printk("; crashing the system because you wanted it\n"); 62 printk("; crashing the system because you wanted it\n");
@@ -76,7 +72,6 @@ void hpfs_error(struct super_block *s, char *m,...)
76 } else if (s->s_flags & MS_RDONLY) printk("; going on - but anything won't be destroyed because it's read-only\n"); 72 } else if (s->s_flags & MS_RDONLY) printk("; going on - but anything won't be destroyed because it's read-only\n");
77 else printk("; corrupted filesystem mounted read/write - your computer will explode within 20 seconds ... but you wanted it so!\n"); 73 else printk("; corrupted filesystem mounted read/write - your computer will explode within 20 seconds ... but you wanted it so!\n");
78 } else printk("\n"); 74 } else printk("\n");
79 kfree(buf);
80 hpfs_sb(s)->sb_was_error = 1; 75 hpfs_sb(s)->sb_was_error = 1;
81} 76}
82 77
@@ -160,12 +155,12 @@ static int hpfs_statfs(struct dentry *dentry, struct kstatfs *buf)
160 return 0; 155 return 0;
161} 156}
162 157
163static kmem_cache_t * hpfs_inode_cachep; 158static struct kmem_cache * hpfs_inode_cachep;
164 159
165static struct inode *hpfs_alloc_inode(struct super_block *sb) 160static struct inode *hpfs_alloc_inode(struct super_block *sb)
166{ 161{
167 struct hpfs_inode_info *ei; 162 struct hpfs_inode_info *ei;
168 ei = (struct hpfs_inode_info *)kmem_cache_alloc(hpfs_inode_cachep, SLAB_NOFS); 163 ei = (struct hpfs_inode_info *)kmem_cache_alloc(hpfs_inode_cachep, GFP_NOFS);
169 if (!ei) 164 if (!ei)
170 return NULL; 165 return NULL;
171 ei->vfs_inode.i_version = 1; 166 ei->vfs_inode.i_version = 1;
@@ -177,7 +172,7 @@ static void hpfs_destroy_inode(struct inode *inode)
177 kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode)); 172 kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode));
178} 173}
179 174
180static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 175static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
181{ 176{
182 struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo; 177 struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo;
183 178
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 7f4756963d05..0706f5aac6a2 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -513,7 +513,7 @@ static void hugetlbfs_inc_free_inodes(struct hugetlbfs_sb_info *sbinfo)
513} 513}
514 514
515 515
516static kmem_cache_t *hugetlbfs_inode_cachep; 516static struct kmem_cache *hugetlbfs_inode_cachep;
517 517
518static struct inode *hugetlbfs_alloc_inode(struct super_block *sb) 518static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)
519{ 519{
@@ -522,7 +522,7 @@ static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)
522 522
523 if (unlikely(!hugetlbfs_dec_free_inodes(sbinfo))) 523 if (unlikely(!hugetlbfs_dec_free_inodes(sbinfo)))
524 return NULL; 524 return NULL;
525 p = kmem_cache_alloc(hugetlbfs_inode_cachep, SLAB_KERNEL); 525 p = kmem_cache_alloc(hugetlbfs_inode_cachep, GFP_KERNEL);
526 if (unlikely(!p)) { 526 if (unlikely(!p)) {
527 hugetlbfs_inc_free_inodes(sbinfo); 527 hugetlbfs_inc_free_inodes(sbinfo);
528 return NULL; 528 return NULL;
@@ -545,7 +545,7 @@ static const struct address_space_operations hugetlbfs_aops = {
545}; 545};
546 546
547 547
548static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags) 548static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
549{ 549{
550 struct hugetlbfs_inode_info *ei = (struct hugetlbfs_inode_info *)foo; 550 struct hugetlbfs_inode_info *ei = (struct hugetlbfs_inode_info *)foo;
551 551
diff --git a/fs/inode.c b/fs/inode.c
index 26cdb115ce67..9ecccab7326d 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -97,7 +97,7 @@ static DEFINE_MUTEX(iprune_mutex);
97 */ 97 */
98struct inodes_stat_t inodes_stat; 98struct inodes_stat_t inodes_stat;
99 99
100static kmem_cache_t * inode_cachep __read_mostly; 100static struct kmem_cache * inode_cachep __read_mostly;
101 101
102static struct inode *alloc_inode(struct super_block *sb) 102static struct inode *alloc_inode(struct super_block *sb)
103{ 103{
@@ -109,7 +109,7 @@ static struct inode *alloc_inode(struct super_block *sb)
109 if (sb->s_op->alloc_inode) 109 if (sb->s_op->alloc_inode)
110 inode = sb->s_op->alloc_inode(sb); 110 inode = sb->s_op->alloc_inode(sb);
111 else 111 else
112 inode = (struct inode *) kmem_cache_alloc(inode_cachep, SLAB_KERNEL); 112 inode = (struct inode *) kmem_cache_alloc(inode_cachep, GFP_KERNEL);
113 113
114 if (inode) { 114 if (inode) {
115 struct address_space * const mapping = &inode->i_data; 115 struct address_space * const mapping = &inode->i_data;
@@ -209,7 +209,7 @@ void inode_init_once(struct inode *inode)
209 209
210EXPORT_SYMBOL(inode_init_once); 210EXPORT_SYMBOL(inode_init_once);
211 211
212static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 212static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
213{ 213{
214 struct inode * inode = (struct inode *) foo; 214 struct inode * inode = (struct inode *) foo;
215 215
@@ -1242,9 +1242,6 @@ EXPORT_SYMBOL(inode_needs_sync);
1242 */ 1242 */
1243#ifdef CONFIG_QUOTA 1243#ifdef CONFIG_QUOTA
1244 1244
1245/* Function back in dquot.c */
1246int remove_inode_dquot_ref(struct inode *, int, struct list_head *);
1247
1248void remove_dquot_ref(struct super_block *sb, int type, 1245void remove_dquot_ref(struct super_block *sb, int type,
1249 struct list_head *tofree_head) 1246 struct list_head *tofree_head)
1250{ 1247{
diff --git a/fs/inotify_user.c b/fs/inotify_user.c
index 017cb0f134d6..e1956e6f116c 100644
--- a/fs/inotify_user.c
+++ b/fs/inotify_user.c
@@ -34,8 +34,8 @@
34 34
35#include <asm/ioctls.h> 35#include <asm/ioctls.h>
36 36
37static kmem_cache_t *watch_cachep __read_mostly; 37static struct kmem_cache *watch_cachep __read_mostly;
38static kmem_cache_t *event_cachep __read_mostly; 38static struct kmem_cache *event_cachep __read_mostly;
39 39
40static struct vfsmount *inotify_mnt __read_mostly; 40static struct vfsmount *inotify_mnt __read_mostly;
41 41
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index c34b862cdbf2..ea55b6c469ec 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -57,12 +57,12 @@ static void isofs_put_super(struct super_block *sb)
57static void isofs_read_inode(struct inode *); 57static void isofs_read_inode(struct inode *);
58static int isofs_statfs (struct dentry *, struct kstatfs *); 58static int isofs_statfs (struct dentry *, struct kstatfs *);
59 59
60static kmem_cache_t *isofs_inode_cachep; 60static struct kmem_cache *isofs_inode_cachep;
61 61
62static struct inode *isofs_alloc_inode(struct super_block *sb) 62static struct inode *isofs_alloc_inode(struct super_block *sb)
63{ 63{
64 struct iso_inode_info *ei; 64 struct iso_inode_info *ei;
65 ei = kmem_cache_alloc(isofs_inode_cachep, SLAB_KERNEL); 65 ei = kmem_cache_alloc(isofs_inode_cachep, GFP_KERNEL);
66 if (!ei) 66 if (!ei)
67 return NULL; 67 return NULL;
68 return &ei->vfs_inode; 68 return &ei->vfs_inode;
@@ -73,7 +73,7 @@ static void isofs_destroy_inode(struct inode *inode)
73 kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode)); 73 kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode));
74} 74}
75 75
76static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags) 76static void init_once(void *foo, struct kmem_cache * cachep, unsigned long flags)
77{ 77{
78 struct iso_inode_info *ei = foo; 78 struct iso_inode_info *ei = foo;
79 79
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index b85c686b60db..10fff9443938 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -31,7 +31,7 @@
31#include <linux/smp_lock.h> 31#include <linux/smp_lock.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/mm.h> 33#include <linux/mm.h>
34#include <linux/suspend.h> 34#include <linux/freezer.h>
35#include <linux/pagemap.h> 35#include <linux/pagemap.h>
36#include <linux/kthread.h> 36#include <linux/kthread.h>
37#include <linux/poison.h> 37#include <linux/poison.h>
@@ -1630,7 +1630,7 @@ void * __jbd_kmalloc (const char *where, size_t size, gfp_t flags, int retry)
1630#define JBD_MAX_SLABS 5 1630#define JBD_MAX_SLABS 5
1631#define JBD_SLAB_INDEX(size) (size >> 11) 1631#define JBD_SLAB_INDEX(size) (size >> 11)
1632 1632
1633static kmem_cache_t *jbd_slab[JBD_MAX_SLABS]; 1633static struct kmem_cache *jbd_slab[JBD_MAX_SLABS];
1634static const char *jbd_slab_names[JBD_MAX_SLABS] = { 1634static const char *jbd_slab_names[JBD_MAX_SLABS] = {
1635 "jbd_1k", "jbd_2k", "jbd_4k", NULL, "jbd_8k" 1635 "jbd_1k", "jbd_2k", "jbd_4k", NULL, "jbd_8k"
1636}; 1636};
@@ -1693,7 +1693,7 @@ void jbd_slab_free(void *ptr, size_t size)
1693/* 1693/*
1694 * Journal_head storage management 1694 * Journal_head storage management
1695 */ 1695 */
1696static kmem_cache_t *journal_head_cache; 1696static struct kmem_cache *journal_head_cache;
1697#ifdef CONFIG_JBD_DEBUG 1697#ifdef CONFIG_JBD_DEBUG
1698static atomic_t nr_journal_heads = ATOMIC_INIT(0); 1698static atomic_t nr_journal_heads = ATOMIC_INIT(0);
1699#endif 1699#endif
@@ -1996,7 +1996,7 @@ static void __exit remove_jbd_proc_entry(void)
1996 1996
1997#endif 1997#endif
1998 1998
1999kmem_cache_t *jbd_handle_cache; 1999struct kmem_cache *jbd_handle_cache;
2000 2000
2001static int __init journal_init_handle_cache(void) 2001static int __init journal_init_handle_cache(void)
2002{ 2002{
diff --git a/fs/jbd/revoke.c b/fs/jbd/revoke.c
index c532429d8d9b..d204ab394f36 100644
--- a/fs/jbd/revoke.c
+++ b/fs/jbd/revoke.c
@@ -70,8 +70,8 @@
70#include <linux/init.h> 70#include <linux/init.h>
71#endif 71#endif
72 72
73static kmem_cache_t *revoke_record_cache; 73static struct kmem_cache *revoke_record_cache;
74static kmem_cache_t *revoke_table_cache; 74static struct kmem_cache *revoke_table_cache;
75 75
76/* Each revoke record represents one single revoked block. During 76/* Each revoke record represents one single revoked block. During
77 journal replay, this involves recording the transaction ID of the 77 journal replay, this involves recording the transaction ID of the
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index 4f82bcd63e48..d38e0d575e48 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -27,6 +27,8 @@
27#include <linux/mm.h> 27#include <linux/mm.h>
28#include <linux/highmem.h> 28#include <linux/highmem.h>
29 29
30static void __journal_temp_unlink_buffer(struct journal_head *jh);
31
30/* 32/*
31 * get_transaction: obtain a new transaction_t object. 33 * get_transaction: obtain a new transaction_t object.
32 * 34 *
@@ -1499,7 +1501,7 @@ __blist_del_buffer(struct journal_head **list, struct journal_head *jh)
1499 * 1501 *
1500 * Called under j_list_lock. The journal may not be locked. 1502 * Called under j_list_lock. The journal may not be locked.
1501 */ 1503 */
1502void __journal_temp_unlink_buffer(struct journal_head *jh) 1504static void __journal_temp_unlink_buffer(struct journal_head *jh)
1503{ 1505{
1504 struct journal_head **list = NULL; 1506 struct journal_head **list = NULL;
1505 transaction_t *transaction; 1507 transaction_t *transaction;
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index 70b2ae1ef281..6bd8005e3d34 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -248,8 +248,12 @@ write_out_data:
248 bufs = 0; 248 bufs = 0;
249 goto write_out_data; 249 goto write_out_data;
250 } 250 }
251 } 251 } else if (!locked && buffer_locked(bh)) {
252 else { 252 __jbd2_journal_file_buffer(jh, commit_transaction,
253 BJ_Locked);
254 jbd_unlock_bh_state(bh);
255 put_bh(bh);
256 } else {
253 BUFFER_TRACE(bh, "writeout complete: unfile"); 257 BUFFER_TRACE(bh, "writeout complete: unfile");
254 __jbd2_journal_unfile_buffer(jh); 258 __jbd2_journal_unfile_buffer(jh);
255 jbd_unlock_bh_state(bh); 259 jbd_unlock_bh_state(bh);
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index c60f378b0f76..44fc32bfd7f1 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -31,7 +31,7 @@
31#include <linux/smp_lock.h> 31#include <linux/smp_lock.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/mm.h> 33#include <linux/mm.h>
34#include <linux/suspend.h> 34#include <linux/freezer.h>
35#include <linux/pagemap.h> 35#include <linux/pagemap.h>
36#include <linux/kthread.h> 36#include <linux/kthread.h>
37#include <linux/poison.h> 37#include <linux/poison.h>
@@ -1641,7 +1641,7 @@ void * __jbd2_kmalloc (const char *where, size_t size, gfp_t flags, int retry)
1641#define JBD_MAX_SLABS 5 1641#define JBD_MAX_SLABS 5
1642#define JBD_SLAB_INDEX(size) (size >> 11) 1642#define JBD_SLAB_INDEX(size) (size >> 11)
1643 1643
1644static kmem_cache_t *jbd_slab[JBD_MAX_SLABS]; 1644static struct kmem_cache *jbd_slab[JBD_MAX_SLABS];
1645static const char *jbd_slab_names[JBD_MAX_SLABS] = { 1645static const char *jbd_slab_names[JBD_MAX_SLABS] = {
1646 "jbd2_1k", "jbd2_2k", "jbd2_4k", NULL, "jbd2_8k" 1646 "jbd2_1k", "jbd2_2k", "jbd2_4k", NULL, "jbd2_8k"
1647}; 1647};
@@ -1704,7 +1704,7 @@ void jbd2_slab_free(void *ptr, size_t size)
1704/* 1704/*
1705 * Journal_head storage management 1705 * Journal_head storage management
1706 */ 1706 */
1707static kmem_cache_t *jbd2_journal_head_cache; 1707static struct kmem_cache *jbd2_journal_head_cache;
1708#ifdef CONFIG_JBD_DEBUG 1708#ifdef CONFIG_JBD_DEBUG
1709static atomic_t nr_journal_heads = ATOMIC_INIT(0); 1709static atomic_t nr_journal_heads = ATOMIC_INIT(0);
1710#endif 1710#endif
@@ -2007,7 +2007,7 @@ static void __exit jbd2_remove_jbd_proc_entry(void)
2007 2007
2008#endif 2008#endif
2009 2009
2010kmem_cache_t *jbd2_handle_cache; 2010struct kmem_cache *jbd2_handle_cache;
2011 2011
2012static int __init journal_init_handle_cache(void) 2012static int __init journal_init_handle_cache(void)
2013{ 2013{
diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c
index 380d19917f37..f506646ad0ff 100644
--- a/fs/jbd2/revoke.c
+++ b/fs/jbd2/revoke.c
@@ -70,8 +70,8 @@
70#include <linux/init.h> 70#include <linux/init.h>
71#endif 71#endif
72 72
73static kmem_cache_t *jbd2_revoke_record_cache; 73static struct kmem_cache *jbd2_revoke_record_cache;
74static kmem_cache_t *jbd2_revoke_table_cache; 74static struct kmem_cache *jbd2_revoke_table_cache;
75 75
76/* Each revoke record represents one single revoked block. During 76/* Each revoke record represents one single revoked block. During
77 journal replay, this involves recording the transaction ID of the 77 journal replay, this involves recording the transaction ID of the
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index c051a94c8a97..3a8700153cb0 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -27,6 +27,8 @@
27#include <linux/mm.h> 27#include <linux/mm.h>
28#include <linux/highmem.h> 28#include <linux/highmem.h>
29 29
30static void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh);
31
30/* 32/*
31 * jbd2_get_transaction: obtain a new transaction_t object. 33 * jbd2_get_transaction: obtain a new transaction_t object.
32 * 34 *
diff --git a/fs/jffs/inode-v23.c b/fs/jffs/inode-v23.c
index 3f7899ea4cba..9f15bce92022 100644
--- a/fs/jffs/inode-v23.c
+++ b/fs/jffs/inode-v23.c
@@ -61,8 +61,8 @@ static const struct file_operations jffs_dir_operations;
61static struct inode_operations jffs_dir_inode_operations; 61static struct inode_operations jffs_dir_inode_operations;
62static const struct address_space_operations jffs_address_operations; 62static const struct address_space_operations jffs_address_operations;
63 63
64kmem_cache_t *node_cache = NULL; 64struct kmem_cache *node_cache = NULL;
65kmem_cache_t *fm_cache = NULL; 65struct kmem_cache *fm_cache = NULL;
66 66
67/* Called by the VFS at mount time to initialize the whole file system. */ 67/* Called by the VFS at mount time to initialize the whole file system. */
68static int jffs_fill_super(struct super_block *sb, void *data, int silent) 68static int jffs_fill_super(struct super_block *sb, void *data, int silent)
diff --git a/fs/jffs/intrep.c b/fs/jffs/intrep.c
index 4a543e114970..d0e783f199ea 100644
--- a/fs/jffs/intrep.c
+++ b/fs/jffs/intrep.c
@@ -66,6 +66,7 @@
66#include <linux/smp_lock.h> 66#include <linux/smp_lock.h>
67#include <linux/time.h> 67#include <linux/time.h>
68#include <linux/ctype.h> 68#include <linux/ctype.h>
69#include <linux/freezer.h>
69 70
70#include "intrep.h" 71#include "intrep.h"
71#include "jffs_fm.h" 72#include "jffs_fm.h"
@@ -591,7 +592,7 @@ jffs_add_virtual_root(struct jffs_control *c)
591 D2(printk("jffs_add_virtual_root(): " 592 D2(printk("jffs_add_virtual_root(): "
592 "Creating a virtual root directory.\n")); 593 "Creating a virtual root directory.\n"));
593 594
594 if (!(root = kmalloc(sizeof(struct jffs_file), GFP_KERNEL))) { 595 if (!(root = kzalloc(sizeof(struct jffs_file), GFP_KERNEL))) {
595 return -ENOMEM; 596 return -ENOMEM;
596 } 597 }
597 no_jffs_file++; 598 no_jffs_file++;
@@ -603,7 +604,6 @@ jffs_add_virtual_root(struct jffs_control *c)
603 DJM(no_jffs_node++); 604 DJM(no_jffs_node++);
604 memset(node, 0, sizeof(struct jffs_node)); 605 memset(node, 0, sizeof(struct jffs_node));
605 node->ino = JFFS_MIN_INO; 606 node->ino = JFFS_MIN_INO;
606 memset(root, 0, sizeof(struct jffs_file));
607 root->ino = JFFS_MIN_INO; 607 root->ino = JFFS_MIN_INO;
608 root->mode = S_IFDIR | S_IRWXU | S_IRGRP 608 root->mode = S_IFDIR | S_IRWXU | S_IRGRP
609 | S_IXGRP | S_IROTH | S_IXOTH; 609 | S_IXGRP | S_IROTH | S_IXOTH;
diff --git a/fs/jffs/jffs_fm.c b/fs/jffs/jffs_fm.c
index 29b68d939bd9..077258b2103e 100644
--- a/fs/jffs/jffs_fm.c
+++ b/fs/jffs/jffs_fm.c
@@ -29,8 +29,8 @@ static int jffs_mark_obsolete(struct jffs_fmcontrol *fmc, __u32 fm_offset);
29static struct jffs_fm *jffs_alloc_fm(void); 29static struct jffs_fm *jffs_alloc_fm(void);
30static void jffs_free_fm(struct jffs_fm *n); 30static void jffs_free_fm(struct jffs_fm *n);
31 31
32extern kmem_cache_t *fm_cache; 32extern struct kmem_cache *fm_cache;
33extern kmem_cache_t *node_cache; 33extern struct kmem_cache *node_cache;
34 34
35#if CONFIG_JFFS_FS_VERBOSE > 0 35#if CONFIG_JFFS_FS_VERBOSE > 0
36void 36void
diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c
index ff2a872e80e7..6eb3daebd563 100644
--- a/fs/jffs2/background.c
+++ b/fs/jffs2/background.c
@@ -16,6 +16,7 @@
16#include <linux/mtd/mtd.h> 16#include <linux/mtd/mtd.h>
17#include <linux/completion.h> 17#include <linux/completion.h>
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/freezer.h>
19#include "nodelist.h" 20#include "nodelist.h"
20 21
21 22
diff --git a/fs/jffs2/malloc.c b/fs/jffs2/malloc.c
index 33f291005012..83f9881ec4cc 100644
--- a/fs/jffs2/malloc.c
+++ b/fs/jffs2/malloc.c
@@ -19,16 +19,16 @@
19 19
20/* These are initialised to NULL in the kernel startup code. 20/* These are initialised to NULL in the kernel startup code.
21 If you're porting to other operating systems, beware */ 21 If you're porting to other operating systems, beware */
22static kmem_cache_t *full_dnode_slab; 22static struct kmem_cache *full_dnode_slab;
23static kmem_cache_t *raw_dirent_slab; 23static struct kmem_cache *raw_dirent_slab;
24static kmem_cache_t *raw_inode_slab; 24static struct kmem_cache *raw_inode_slab;
25static kmem_cache_t *tmp_dnode_info_slab; 25static struct kmem_cache *tmp_dnode_info_slab;
26static kmem_cache_t *raw_node_ref_slab; 26static struct kmem_cache *raw_node_ref_slab;
27static kmem_cache_t *node_frag_slab; 27static struct kmem_cache *node_frag_slab;
28static kmem_cache_t *inode_cache_slab; 28static struct kmem_cache *inode_cache_slab;
29#ifdef CONFIG_JFFS2_FS_XATTR 29#ifdef CONFIG_JFFS2_FS_XATTR
30static kmem_cache_t *xattr_datum_cache; 30static struct kmem_cache *xattr_datum_cache;
31static kmem_cache_t *xattr_ref_cache; 31static struct kmem_cache *xattr_ref_cache;
32#endif 32#endif
33 33
34int __init jffs2_create_slab_caches(void) 34int __init jffs2_create_slab_caches(void)
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index bc4b8106a490..7deb78254021 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -28,12 +28,12 @@
28 28
29static void jffs2_put_super(struct super_block *); 29static void jffs2_put_super(struct super_block *);
30 30
31static kmem_cache_t *jffs2_inode_cachep; 31static struct kmem_cache *jffs2_inode_cachep;
32 32
33static struct inode *jffs2_alloc_inode(struct super_block *sb) 33static struct inode *jffs2_alloc_inode(struct super_block *sb)
34{ 34{
35 struct jffs2_inode_info *ei; 35 struct jffs2_inode_info *ei;
36 ei = (struct jffs2_inode_info *)kmem_cache_alloc(jffs2_inode_cachep, SLAB_KERNEL); 36 ei = (struct jffs2_inode_info *)kmem_cache_alloc(jffs2_inode_cachep, GFP_KERNEL);
37 if (!ei) 37 if (!ei)
38 return NULL; 38 return NULL;
39 return &ei->vfs_inode; 39 return &ei->vfs_inode;
@@ -44,7 +44,7 @@ static void jffs2_destroy_inode(struct inode *inode)
44 kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode)); 44 kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode));
45} 45}
46 46
47static void jffs2_i_init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 47static void jffs2_i_init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
48{ 48{
49 struct jffs2_inode_info *ei = (struct jffs2_inode_info *) foo; 49 struct jffs2_inode_info *ei = (struct jffs2_inode_info *) foo;
50 50
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
index b89c9aba0466..5065baa530b6 100644
--- a/fs/jfs/jfs_logmgr.c
+++ b/fs/jfs/jfs_logmgr.c
@@ -67,7 +67,7 @@
67#include <linux/kthread.h> 67#include <linux/kthread.h>
68#include <linux/buffer_head.h> /* for sync_blockdev() */ 68#include <linux/buffer_head.h> /* for sync_blockdev() */
69#include <linux/bio.h> 69#include <linux/bio.h>
70#include <linux/suspend.h> 70#include <linux/freezer.h>
71#include <linux/delay.h> 71#include <linux/delay.h>
72#include <linux/mutex.h> 72#include <linux/mutex.h>
73#include "jfs_incore.h" 73#include "jfs_incore.h"
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 0cccd1c39d75..b1a1c7296014 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -74,7 +74,7 @@ static inline void lock_metapage(struct metapage *mp)
74} 74}
75 75
76#define METAPOOL_MIN_PAGES 32 76#define METAPOOL_MIN_PAGES 32
77static kmem_cache_t *metapage_cache; 77static struct kmem_cache *metapage_cache;
78static mempool_t *metapage_mempool; 78static mempool_t *metapage_mempool;
79 79
80#define MPS_PER_PAGE (PAGE_CACHE_SIZE >> L2PSIZE) 80#define MPS_PER_PAGE (PAGE_CACHE_SIZE >> L2PSIZE)
@@ -180,7 +180,7 @@ static inline void remove_metapage(struct page *page, struct metapage *mp)
180 180
181#endif 181#endif
182 182
183static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags) 183static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
184{ 184{
185 struct metapage *mp = (struct metapage *)foo; 185 struct metapage *mp = (struct metapage *)foo;
186 186
diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
index 81f6f04af192..d558e51b0df8 100644
--- a/fs/jfs/jfs_txnmgr.c
+++ b/fs/jfs/jfs_txnmgr.c
@@ -46,7 +46,7 @@
46#include <linux/vmalloc.h> 46#include <linux/vmalloc.h>
47#include <linux/smp_lock.h> 47#include <linux/smp_lock.h>
48#include <linux/completion.h> 48#include <linux/completion.h>
49#include <linux/suspend.h> 49#include <linux/freezer.h>
50#include <linux/module.h> 50#include <linux/module.h>
51#include <linux/moduleparam.h> 51#include <linux/moduleparam.h>
52#include <linux/kthread.h> 52#include <linux/kthread.h>
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 9c1c6e0e633d..846ac8f34513 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -44,7 +44,7 @@ MODULE_DESCRIPTION("The Journaled Filesystem (JFS)");
44MODULE_AUTHOR("Steve Best/Dave Kleikamp/Barry Arndt, IBM"); 44MODULE_AUTHOR("Steve Best/Dave Kleikamp/Barry Arndt, IBM");
45MODULE_LICENSE("GPL"); 45MODULE_LICENSE("GPL");
46 46
47static kmem_cache_t * jfs_inode_cachep; 47static struct kmem_cache * jfs_inode_cachep;
48 48
49static struct super_operations jfs_super_operations; 49static struct super_operations jfs_super_operations;
50static struct export_operations jfs_export_operations; 50static struct export_operations jfs_export_operations;
@@ -93,7 +93,7 @@ void jfs_error(struct super_block *sb, const char * function, ...)
93 va_list args; 93 va_list args;
94 94
95 va_start(args, function); 95 va_start(args, function);
96 vsprintf(error_buf, function, args); 96 vsnprintf(error_buf, sizeof(error_buf), function, args);
97 va_end(args); 97 va_end(args);
98 98
99 printk(KERN_ERR "ERROR: (device %s): %s\n", sb->s_id, error_buf); 99 printk(KERN_ERR "ERROR: (device %s): %s\n", sb->s_id, error_buf);
@@ -748,7 +748,7 @@ static struct file_system_type jfs_fs_type = {
748 .fs_flags = FS_REQUIRES_DEV, 748 .fs_flags = FS_REQUIRES_DEV,
749}; 749};
750 750
751static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags) 751static void init_once(void *foo, struct kmem_cache * cachep, unsigned long flags)
752{ 752{
753 struct jfs_inode_info *jfs_ip = (struct jfs_inode_info *) foo; 753 struct jfs_inode_info *jfs_ip = (struct jfs_inode_info *) foo;
754 754
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index 3d84f600b633..50643b6a5556 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -13,6 +13,7 @@
13#include <linux/nfs_fs.h> 13#include <linux/nfs_fs.h>
14#include <linux/utsname.h> 14#include <linux/utsname.h>
15#include <linux/smp_lock.h> 15#include <linux/smp_lock.h>
16#include <linux/freezer.h>
16#include <linux/sunrpc/clnt.h> 17#include <linux/sunrpc/clnt.h>
17#include <linux/sunrpc/svc.h> 18#include <linux/sunrpc/svc.h>
18#include <linux/lockd/lockd.h> 19#include <linux/lockd/lockd.h>
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index fb24a9730345..3d4610c2a266 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -36,34 +36,14 @@ static DEFINE_MUTEX(nlm_host_mutex);
36static void nlm_gc_hosts(void); 36static void nlm_gc_hosts(void);
37static struct nsm_handle * __nsm_find(const struct sockaddr_in *, 37static struct nsm_handle * __nsm_find(const struct sockaddr_in *,
38 const char *, int, int); 38 const char *, int, int);
39 39static struct nsm_handle * nsm_find(const struct sockaddr_in *sin,
40/* 40 const char *hostname,
41 * Find an NLM server handle in the cache. If there is none, create it. 41 int hostname_len);
42 */
43struct nlm_host *
44nlmclnt_lookup_host(const struct sockaddr_in *sin, int proto, int version,
45 const char *hostname, int hostname_len)
46{
47 return nlm_lookup_host(0, sin, proto, version,
48 hostname, hostname_len);
49}
50
51/*
52 * Find an NLM client handle in the cache. If there is none, create it.
53 */
54struct nlm_host *
55nlmsvc_lookup_host(struct svc_rqst *rqstp,
56 const char *hostname, int hostname_len)
57{
58 return nlm_lookup_host(1, &rqstp->rq_addr,
59 rqstp->rq_prot, rqstp->rq_vers,
60 hostname, hostname_len);
61}
62 42
63/* 43/*
64 * Common host lookup routine for server & client 44 * Common host lookup routine for server & client
65 */ 45 */
66struct nlm_host * 46static struct nlm_host *
67nlm_lookup_host(int server, const struct sockaddr_in *sin, 47nlm_lookup_host(int server, const struct sockaddr_in *sin,
68 int proto, int version, 48 int proto, int version,
69 const char *hostname, 49 const char *hostname,
@@ -195,6 +175,29 @@ nlm_destroy_host(struct nlm_host *host)
195} 175}
196 176
197/* 177/*
178 * Find an NLM server handle in the cache. If there is none, create it.
179 */
180struct nlm_host *
181nlmclnt_lookup_host(const struct sockaddr_in *sin, int proto, int version,
182 const char *hostname, int hostname_len)
183{
184 return nlm_lookup_host(0, sin, proto, version,
185 hostname, hostname_len);
186}
187
188/*
189 * Find an NLM client handle in the cache. If there is none, create it.
190 */
191struct nlm_host *
192nlmsvc_lookup_host(struct svc_rqst *rqstp,
193 const char *hostname, int hostname_len)
194{
195 return nlm_lookup_host(1, &rqstp->rq_addr,
196 rqstp->rq_prot, rqstp->rq_vers,
197 hostname, hostname_len);
198}
199
200/*
198 * Create the NLM RPC client for an NLM peer 201 * Create the NLM RPC client for an NLM peer
199 */ 202 */
200struct rpc_clnt * 203struct rpc_clnt *
@@ -495,7 +498,7 @@ out:
495 return nsm; 498 return nsm;
496} 499}
497 500
498struct nsm_handle * 501static struct nsm_handle *
499nsm_find(const struct sockaddr_in *sin, const char *hostname, int hostname_len) 502nsm_find(const struct sockaddr_in *sin, const char *hostname, int hostname_len)
500{ 503{
501 return __nsm_find(sin, hostname, hostname_len, 1); 504 return __nsm_find(sin, hostname, hostname_len, 1);
diff --git a/fs/locks.c b/fs/locks.c
index e0b6a80649a0..1cb0c57fedbd 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -142,12 +142,12 @@ int lease_break_time = 45;
142static LIST_HEAD(file_lock_list); 142static LIST_HEAD(file_lock_list);
143static LIST_HEAD(blocked_list); 143static LIST_HEAD(blocked_list);
144 144
145static kmem_cache_t *filelock_cache __read_mostly; 145static struct kmem_cache *filelock_cache __read_mostly;
146 146
147/* Allocate an empty lock structure. */ 147/* Allocate an empty lock structure. */
148static struct file_lock *locks_alloc_lock(void) 148static struct file_lock *locks_alloc_lock(void)
149{ 149{
150 return kmem_cache_alloc(filelock_cache, SLAB_KERNEL); 150 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
151} 151}
152 152
153static void locks_release_private(struct file_lock *fl) 153static void locks_release_private(struct file_lock *fl)
@@ -199,7 +199,7 @@ EXPORT_SYMBOL(locks_init_lock);
199 * Initialises the fields of the file lock which are invariant for 199 * Initialises the fields of the file lock which are invariant for
200 * free file_locks. 200 * free file_locks.
201 */ 201 */
202static void init_once(void *foo, kmem_cache_t *cache, unsigned long flags) 202static void init_once(void *foo, struct kmem_cache *cache, unsigned long flags)
203{ 203{
204 struct file_lock *lock = (struct file_lock *) foo; 204 struct file_lock *lock = (struct file_lock *) foo;
205 205
diff --git a/fs/mbcache.c b/fs/mbcache.c
index 0ff71256e65b..deeb9dc062d9 100644
--- a/fs/mbcache.c
+++ b/fs/mbcache.c
@@ -85,7 +85,7 @@ struct mb_cache {
85#ifndef MB_CACHE_INDEXES_COUNT 85#ifndef MB_CACHE_INDEXES_COUNT
86 int c_indexes_count; 86 int c_indexes_count;
87#endif 87#endif
88 kmem_cache_t *c_entry_cache; 88 struct kmem_cache *c_entry_cache;
89 struct list_head *c_block_hash; 89 struct list_head *c_block_hash;
90 struct list_head *c_indexes_hash[0]; 90 struct list_head *c_indexes_hash[0];
91}; 91};
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index 1e36bae4d0eb..629e09b38c5c 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -51,12 +51,12 @@ static void minix_put_super(struct super_block *sb)
51 return; 51 return;
52} 52}
53 53
54static kmem_cache_t * minix_inode_cachep; 54static struct kmem_cache * minix_inode_cachep;
55 55
56static struct inode *minix_alloc_inode(struct super_block *sb) 56static struct inode *minix_alloc_inode(struct super_block *sb)
57{ 57{
58 struct minix_inode_info *ei; 58 struct minix_inode_info *ei;
59 ei = (struct minix_inode_info *)kmem_cache_alloc(minix_inode_cachep, SLAB_KERNEL); 59 ei = (struct minix_inode_info *)kmem_cache_alloc(minix_inode_cachep, GFP_KERNEL);
60 if (!ei) 60 if (!ei)
61 return NULL; 61 return NULL;
62 return &ei->vfs_inode; 62 return &ei->vfs_inode;
@@ -67,7 +67,7 @@ static void minix_destroy_inode(struct inode *inode)
67 kmem_cache_free(minix_inode_cachep, minix_i(inode)); 67 kmem_cache_free(minix_inode_cachep, minix_i(inode));
68} 68}
69 69
70static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 70static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
71{ 71{
72 struct minix_inode_info *ei = (struct minix_inode_info *) foo; 72 struct minix_inode_info *ei = (struct minix_inode_info *) foo;
73 73
diff --git a/fs/namei.c b/fs/namei.c
index 28d49b301d55..db1bca26d88c 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -249,9 +249,11 @@ int permission(struct inode *inode, int mask, struct nameidata *nd)
249 249
250 /* 250 /*
251 * MAY_EXEC on regular files requires special handling: We override 251 * MAY_EXEC on regular files requires special handling: We override
252 * filesystem execute permissions if the mode bits aren't set. 252 * filesystem execute permissions if the mode bits aren't set or
253 * the fs is mounted with the "noexec" flag.
253 */ 254 */
254 if ((mask & MAY_EXEC) && S_ISREG(mode) && !(mode & S_IXUGO)) 255 if ((mask & MAY_EXEC) && S_ISREG(mode) && (!(mode & S_IXUGO) ||
256 (nd && nd->mnt && (nd->mnt->mnt_flags & MNT_NOEXEC))))
255 return -EACCES; 257 return -EACCES;
256 258
257 /* Ordinary permission routines do not understand MAY_APPEND. */ 259 /* Ordinary permission routines do not understand MAY_APPEND. */
@@ -1996,8 +1998,7 @@ asmlinkage long sys_mkdir(const char __user *pathname, int mode)
1996void dentry_unhash(struct dentry *dentry) 1998void dentry_unhash(struct dentry *dentry)
1997{ 1999{
1998 dget(dentry); 2000 dget(dentry);
1999 if (atomic_read(&dentry->d_count)) 2001 shrink_dcache_parent(dentry);
2000 shrink_dcache_parent(dentry);
2001 spin_lock(&dcache_lock); 2002 spin_lock(&dcache_lock);
2002 spin_lock(&dentry->d_lock); 2003 spin_lock(&dentry->d_lock);
2003 if (atomic_read(&dentry->d_count) == 2) 2004 if (atomic_read(&dentry->d_count) == 2)
diff --git a/fs/namespace.c b/fs/namespace.c
index 55442a6cf221..b00ac84ebbdd 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -36,7 +36,7 @@ static int event;
36 36
37static struct list_head *mount_hashtable __read_mostly; 37static struct list_head *mount_hashtable __read_mostly;
38static int hash_mask __read_mostly, hash_bits __read_mostly; 38static int hash_mask __read_mostly, hash_bits __read_mostly;
39static kmem_cache_t *mnt_cache __read_mostly; 39static struct kmem_cache *mnt_cache __read_mostly;
40static struct rw_semaphore namespace_sem; 40static struct rw_semaphore namespace_sem;
41 41
42/* /sys/fs */ 42/* /sys/fs */
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 42e3bef270c9..fae53243bb92 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -40,12 +40,12 @@ static void ncp_delete_inode(struct inode *);
40static void ncp_put_super(struct super_block *); 40static void ncp_put_super(struct super_block *);
41static int ncp_statfs(struct dentry *, struct kstatfs *); 41static int ncp_statfs(struct dentry *, struct kstatfs *);
42 42
43static kmem_cache_t * ncp_inode_cachep; 43static struct kmem_cache * ncp_inode_cachep;
44 44
45static struct inode *ncp_alloc_inode(struct super_block *sb) 45static struct inode *ncp_alloc_inode(struct super_block *sb)
46{ 46{
47 struct ncp_inode_info *ei; 47 struct ncp_inode_info *ei;
48 ei = (struct ncp_inode_info *)kmem_cache_alloc(ncp_inode_cachep, SLAB_KERNEL); 48 ei = (struct ncp_inode_info *)kmem_cache_alloc(ncp_inode_cachep, GFP_KERNEL);
49 if (!ei) 49 if (!ei)
50 return NULL; 50 return NULL;
51 return &ei->vfs_inode; 51 return &ei->vfs_inode;
@@ -56,7 +56,7 @@ static void ncp_destroy_inode(struct inode *inode)
56 kmem_cache_free(ncp_inode_cachep, NCP_FINFO(inode)); 56 kmem_cache_free(ncp_inode_cachep, NCP_FINFO(inode));
57} 57}
58 58
59static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 59static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
60{ 60{
61 struct ncp_inode_info *ei = (struct ncp_inode_info *) foo; 61 struct ncp_inode_info *ei = (struct ncp_inode_info *) foo;
62 62
@@ -577,12 +577,12 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
577 server->rcv.ptr = (unsigned char*)&server->rcv.buf; 577 server->rcv.ptr = (unsigned char*)&server->rcv.buf;
578 server->rcv.len = 10; 578 server->rcv.len = 10;
579 server->rcv.state = 0; 579 server->rcv.state = 0;
580 INIT_WORK(&server->rcv.tq, ncp_tcp_rcv_proc, server); 580 INIT_WORK(&server->rcv.tq, ncp_tcp_rcv_proc);
581 INIT_WORK(&server->tx.tq, ncp_tcp_tx_proc, server); 581 INIT_WORK(&server->tx.tq, ncp_tcp_tx_proc);
582 sock->sk->sk_write_space = ncp_tcp_write_space; 582 sock->sk->sk_write_space = ncp_tcp_write_space;
583 } else { 583 } else {
584 INIT_WORK(&server->rcv.tq, ncpdgram_rcv_proc, server); 584 INIT_WORK(&server->rcv.tq, ncpdgram_rcv_proc);
585 INIT_WORK(&server->timeout_tq, ncpdgram_timeout_proc, server); 585 INIT_WORK(&server->timeout_tq, ncpdgram_timeout_proc);
586 server->timeout_tm.data = (unsigned long)server; 586 server->timeout_tm.data = (unsigned long)server;
587 server->timeout_tm.function = ncpdgram_timeout_call; 587 server->timeout_tm.function = ncpdgram_timeout_call;
588 } 588 }
diff --git a/fs/ncpfs/sock.c b/fs/ncpfs/sock.c
index 11c2b252ebed..e496d8b65e92 100644
--- a/fs/ncpfs/sock.c
+++ b/fs/ncpfs/sock.c
@@ -350,9 +350,10 @@ static void info_server(struct ncp_server *server, unsigned int id, const void *
350 } 350 }
351} 351}
352 352
353void ncpdgram_rcv_proc(void *s) 353void ncpdgram_rcv_proc(struct work_struct *work)
354{ 354{
355 struct ncp_server *server = s; 355 struct ncp_server *server =
356 container_of(work, struct ncp_server, rcv.tq);
356 struct socket* sock; 357 struct socket* sock;
357 358
358 sock = server->ncp_sock; 359 sock = server->ncp_sock;
@@ -468,9 +469,10 @@ static void __ncpdgram_timeout_proc(struct ncp_server *server)
468 } 469 }
469} 470}
470 471
471void ncpdgram_timeout_proc(void *s) 472void ncpdgram_timeout_proc(struct work_struct *work)
472{ 473{
473 struct ncp_server *server = s; 474 struct ncp_server *server =
475 container_of(work, struct ncp_server, timeout_tq);
474 mutex_lock(&server->rcv.creq_mutex); 476 mutex_lock(&server->rcv.creq_mutex);
475 __ncpdgram_timeout_proc(server); 477 __ncpdgram_timeout_proc(server);
476 mutex_unlock(&server->rcv.creq_mutex); 478 mutex_unlock(&server->rcv.creq_mutex);
@@ -652,18 +654,20 @@ skipdata:;
652 } 654 }
653} 655}
654 656
655void ncp_tcp_rcv_proc(void *s) 657void ncp_tcp_rcv_proc(struct work_struct *work)
656{ 658{
657 struct ncp_server *server = s; 659 struct ncp_server *server =
660 container_of(work, struct ncp_server, rcv.tq);
658 661
659 mutex_lock(&server->rcv.creq_mutex); 662 mutex_lock(&server->rcv.creq_mutex);
660 __ncptcp_rcv_proc(server); 663 __ncptcp_rcv_proc(server);
661 mutex_unlock(&server->rcv.creq_mutex); 664 mutex_unlock(&server->rcv.creq_mutex);
662} 665}
663 666
664void ncp_tcp_tx_proc(void *s) 667void ncp_tcp_tx_proc(struct work_struct *work)
665{ 668{
666 struct ncp_server *server = s; 669 struct ncp_server *server =
670 container_of(work, struct ncp_server, tx.tq);
667 671
668 mutex_lock(&server->rcv.creq_mutex); 672 mutex_lock(&server->rcv.creq_mutex);
669 __ncptcp_try_send(server); 673 __ncptcp_try_send(server);
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 5fea638743e4..23ab145daa2d 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -143,7 +143,7 @@ static struct nfs_client *nfs_alloc_client(const char *hostname,
143 INIT_LIST_HEAD(&clp->cl_state_owners); 143 INIT_LIST_HEAD(&clp->cl_state_owners);
144 INIT_LIST_HEAD(&clp->cl_unused); 144 INIT_LIST_HEAD(&clp->cl_unused);
145 spin_lock_init(&clp->cl_lock); 145 spin_lock_init(&clp->cl_lock);
146 INIT_WORK(&clp->cl_renewd, nfs4_renew_state, clp); 146 INIT_DELAYED_WORK(&clp->cl_renewd, nfs4_renew_state);
147 rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client"); 147 rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client");
148 clp->cl_boot_time = CURRENT_TIME; 148 clp->cl_boot_time = CURRENT_TIME;
149 clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED; 149 clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index bdfabf854a51..2f488e1d9b6c 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -58,7 +58,7 @@
58 58
59#define NFSDBG_FACILITY NFSDBG_VFS 59#define NFSDBG_FACILITY NFSDBG_VFS
60 60
61static kmem_cache_t *nfs_direct_cachep; 61static struct kmem_cache *nfs_direct_cachep;
62 62
63/* 63/*
64 * This represents a set of asynchronous requests that we're waiting on 64 * This represents a set of asynchronous requests that we're waiting on
@@ -143,7 +143,7 @@ static inline struct nfs_direct_req *nfs_direct_req_alloc(void)
143{ 143{
144 struct nfs_direct_req *dreq; 144 struct nfs_direct_req *dreq;
145 145
146 dreq = kmem_cache_alloc(nfs_direct_cachep, SLAB_KERNEL); 146 dreq = kmem_cache_alloc(nfs_direct_cachep, GFP_KERNEL);
147 if (!dreq) 147 if (!dreq)
148 return NULL; 148 return NULL;
149 149
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 08cc4c5919ab..15afa460e629 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -55,7 +55,7 @@ static int nfs_update_inode(struct inode *, struct nfs_fattr *);
55 55
56static void nfs_zap_acl_cache(struct inode *); 56static void nfs_zap_acl_cache(struct inode *);
57 57
58static kmem_cache_t * nfs_inode_cachep; 58static struct kmem_cache * nfs_inode_cachep;
59 59
60static inline unsigned long 60static inline unsigned long
61nfs_fattr_to_ino_t(struct nfs_fattr *fattr) 61nfs_fattr_to_ino_t(struct nfs_fattr *fattr)
@@ -1080,7 +1080,7 @@ void nfs4_clear_inode(struct inode *inode)
1080struct inode *nfs_alloc_inode(struct super_block *sb) 1080struct inode *nfs_alloc_inode(struct super_block *sb)
1081{ 1081{
1082 struct nfs_inode *nfsi; 1082 struct nfs_inode *nfsi;
1083 nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, SLAB_KERNEL); 1083 nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, GFP_KERNEL);
1084 if (!nfsi) 1084 if (!nfsi)
1085 return NULL; 1085 return NULL;
1086 nfsi->flags = 0UL; 1086 nfsi->flags = 0UL;
@@ -1111,7 +1111,7 @@ static inline void nfs4_init_once(struct nfs_inode *nfsi)
1111#endif 1111#endif
1112} 1112}
1113 1113
1114static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 1114static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
1115{ 1115{
1116 struct nfs_inode *nfsi = (struct nfs_inode *) foo; 1116 struct nfs_inode *nfsi = (struct nfs_inode *) foo;
1117 1117
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index ec1114b33d89..371b804e7cc8 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -18,10 +18,10 @@
18 18
19#define NFSDBG_FACILITY NFSDBG_VFS 19#define NFSDBG_FACILITY NFSDBG_VFS
20 20
21static void nfs_expire_automounts(void *list); 21static void nfs_expire_automounts(struct work_struct *work);
22 22
23LIST_HEAD(nfs_automount_list); 23LIST_HEAD(nfs_automount_list);
24static DECLARE_WORK(nfs_automount_task, nfs_expire_automounts, &nfs_automount_list); 24static DECLARE_DELAYED_WORK(nfs_automount_task, nfs_expire_automounts);
25int nfs_mountpoint_expiry_timeout = 500 * HZ; 25int nfs_mountpoint_expiry_timeout = 500 * HZ;
26 26
27static struct vfsmount *nfs_do_submount(const struct vfsmount *mnt_parent, 27static struct vfsmount *nfs_do_submount(const struct vfsmount *mnt_parent,
@@ -164,9 +164,9 @@ struct inode_operations nfs_referral_inode_operations = {
164 .follow_link = nfs_follow_mountpoint, 164 .follow_link = nfs_follow_mountpoint,
165}; 165};
166 166
167static void nfs_expire_automounts(void *data) 167static void nfs_expire_automounts(struct work_struct *work)
168{ 168{
169 struct list_head *list = (struct list_head *)data; 169 struct list_head *list = &nfs_automount_list;
170 170
171 mark_mounts_for_expiry(list); 171 mark_mounts_for_expiry(list);
172 if (!list_empty(list)) 172 if (!list_empty(list))
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 6f346677332d..c26cd978c7cc 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -185,7 +185,7 @@ extern const u32 nfs4_fs_locations_bitmap[2];
185extern void nfs4_schedule_state_renewal(struct nfs_client *); 185extern void nfs4_schedule_state_renewal(struct nfs_client *);
186extern void nfs4_renewd_prepare_shutdown(struct nfs_server *); 186extern void nfs4_renewd_prepare_shutdown(struct nfs_server *);
187extern void nfs4_kill_renewd(struct nfs_client *); 187extern void nfs4_kill_renewd(struct nfs_client *);
188extern void nfs4_renew_state(void *); 188extern void nfs4_renew_state(struct work_struct *);
189 189
190/* nfs4state.c */ 190/* nfs4state.c */
191struct rpc_cred *nfs4_get_renew_cred(struct nfs_client *clp); 191struct rpc_cred *nfs4_get_renew_cred(struct nfs_client *clp);
diff --git a/fs/nfs/nfs4renewd.c b/fs/nfs/nfs4renewd.c
index 7b6df1852e75..823298561c0a 100644
--- a/fs/nfs/nfs4renewd.c
+++ b/fs/nfs/nfs4renewd.c
@@ -59,9 +59,10 @@
59#define NFSDBG_FACILITY NFSDBG_PROC 59#define NFSDBG_FACILITY NFSDBG_PROC
60 60
61void 61void
62nfs4_renew_state(void *data) 62nfs4_renew_state(struct work_struct *work)
63{ 63{
64 struct nfs_client *clp = (struct nfs_client *)data; 64 struct nfs_client *clp =
65 container_of(work, struct nfs_client, cl_renewd.work);
65 struct rpc_cred *cred; 66 struct rpc_cred *cred;
66 long lease, timeout; 67 long lease, timeout;
67 unsigned long last, now; 68 unsigned long last, now;
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 829af323f288..3fbfc2f03307 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -20,13 +20,13 @@
20 20
21#define NFS_PARANOIA 1 21#define NFS_PARANOIA 1
22 22
23static kmem_cache_t *nfs_page_cachep; 23static struct kmem_cache *nfs_page_cachep;
24 24
25static inline struct nfs_page * 25static inline struct nfs_page *
26nfs_page_alloc(void) 26nfs_page_alloc(void)
27{ 27{
28 struct nfs_page *p; 28 struct nfs_page *p;
29 p = kmem_cache_alloc(nfs_page_cachep, SLAB_KERNEL); 29 p = kmem_cache_alloc(nfs_page_cachep, GFP_KERNEL);
30 if (p) { 30 if (p) {
31 memset(p, 0, sizeof(*p)); 31 memset(p, 0, sizeof(*p));
32 INIT_LIST_HEAD(&p->wb_list); 32 INIT_LIST_HEAD(&p->wb_list);
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index c2e49c397a27..244a8c45b68e 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -38,7 +38,7 @@ static int nfs_pagein_one(struct list_head *, struct inode *);
38static const struct rpc_call_ops nfs_read_partial_ops; 38static const struct rpc_call_ops nfs_read_partial_ops;
39static const struct rpc_call_ops nfs_read_full_ops; 39static const struct rpc_call_ops nfs_read_full_ops;
40 40
41static kmem_cache_t *nfs_rdata_cachep; 41static struct kmem_cache *nfs_rdata_cachep;
42static mempool_t *nfs_rdata_mempool; 42static mempool_t *nfs_rdata_mempool;
43 43
44#define MIN_POOL_READ (32) 44#define MIN_POOL_READ (32)
@@ -46,7 +46,7 @@ static mempool_t *nfs_rdata_mempool;
46struct nfs_read_data *nfs_readdata_alloc(size_t len) 46struct nfs_read_data *nfs_readdata_alloc(size_t len)
47{ 47{
48 unsigned int pagecount = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; 48 unsigned int pagecount = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
49 struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, SLAB_NOFS); 49 struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, GFP_NOFS);
50 50
51 if (p) { 51 if (p) {
52 memset(p, 0, sizeof(*p)); 52 memset(p, 0, sizeof(*p));
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 883dd4a1c157..41b07288f99e 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -85,7 +85,7 @@ static const struct rpc_call_ops nfs_write_partial_ops;
85static const struct rpc_call_ops nfs_write_full_ops; 85static const struct rpc_call_ops nfs_write_full_ops;
86static const struct rpc_call_ops nfs_commit_ops; 86static const struct rpc_call_ops nfs_commit_ops;
87 87
88static kmem_cache_t *nfs_wdata_cachep; 88static struct kmem_cache *nfs_wdata_cachep;
89static mempool_t *nfs_wdata_mempool; 89static mempool_t *nfs_wdata_mempool;
90static mempool_t *nfs_commit_mempool; 90static mempool_t *nfs_commit_mempool;
91 91
@@ -93,7 +93,7 @@ static DECLARE_WAIT_QUEUE_HEAD(nfs_write_congestion);
93 93
94struct nfs_write_data *nfs_commit_alloc(void) 94struct nfs_write_data *nfs_commit_alloc(void)
95{ 95{
96 struct nfs_write_data *p = mempool_alloc(nfs_commit_mempool, SLAB_NOFS); 96 struct nfs_write_data *p = mempool_alloc(nfs_commit_mempool, GFP_NOFS);
97 97
98 if (p) { 98 if (p) {
99 memset(p, 0, sizeof(*p)); 99 memset(p, 0, sizeof(*p));
@@ -112,7 +112,7 @@ void nfs_commit_free(struct nfs_write_data *p)
112struct nfs_write_data *nfs_writedata_alloc(size_t len) 112struct nfs_write_data *nfs_writedata_alloc(size_t len)
113{ 113{
114 unsigned int pagecount = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; 114 unsigned int pagecount = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
115 struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, SLAB_NOFS); 115 struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, GFP_NOFS);
116 116
117 if (p) { 117 if (p) {
118 memset(p, 0, sizeof(*p)); 118 memset(p, 0, sizeof(*p));
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index b4baca3053c3..277df40f098d 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -24,10 +24,6 @@
24 24
25#define NFSDDBG_FACILITY NFSDDBG_XDR 25#define NFSDDBG_FACILITY NFSDDBG_XDR
26 26
27#ifdef NFSD_OPTIMIZE_SPACE
28# define inline
29#endif
30
31 27
32/* 28/*
33 * Mapping of S_IF* types to NFS file types 29 * Mapping of S_IF* types to NFS file types
@@ -42,14 +38,14 @@ static u32 nfs3_ftypes[] = {
42/* 38/*
43 * XDR functions for basic NFS types 39 * XDR functions for basic NFS types
44 */ 40 */
45static inline __be32 * 41static __be32 *
46encode_time3(__be32 *p, struct timespec *time) 42encode_time3(__be32 *p, struct timespec *time)
47{ 43{
48 *p++ = htonl((u32) time->tv_sec); *p++ = htonl(time->tv_nsec); 44 *p++ = htonl((u32) time->tv_sec); *p++ = htonl(time->tv_nsec);
49 return p; 45 return p;
50} 46}
51 47
52static inline __be32 * 48static __be32 *
53decode_time3(__be32 *p, struct timespec *time) 49decode_time3(__be32 *p, struct timespec *time)
54{ 50{
55 time->tv_sec = ntohl(*p++); 51 time->tv_sec = ntohl(*p++);
@@ -57,7 +53,7 @@ decode_time3(__be32 *p, struct timespec *time)
57 return p; 53 return p;
58} 54}
59 55
60static inline __be32 * 56static __be32 *
61decode_fh(__be32 *p, struct svc_fh *fhp) 57decode_fh(__be32 *p, struct svc_fh *fhp)
62{ 58{
63 unsigned int size; 59 unsigned int size;
@@ -77,7 +73,7 @@ __be32 *nfs3svc_decode_fh(__be32 *p, struct svc_fh *fhp)
77 return decode_fh(p, fhp); 73 return decode_fh(p, fhp);
78} 74}
79 75
80static inline __be32 * 76static __be32 *
81encode_fh(__be32 *p, struct svc_fh *fhp) 77encode_fh(__be32 *p, struct svc_fh *fhp)
82{ 78{
83 unsigned int size = fhp->fh_handle.fh_size; 79 unsigned int size = fhp->fh_handle.fh_size;
@@ -91,7 +87,7 @@ encode_fh(__be32 *p, struct svc_fh *fhp)
91 * Decode a file name and make sure that the path contains 87 * Decode a file name and make sure that the path contains
92 * no slashes or null bytes. 88 * no slashes or null bytes.
93 */ 89 */
94static inline __be32 * 90static __be32 *
95decode_filename(__be32 *p, char **namp, int *lenp) 91decode_filename(__be32 *p, char **namp, int *lenp)
96{ 92{
97 char *name; 93 char *name;
@@ -107,7 +103,7 @@ decode_filename(__be32 *p, char **namp, int *lenp)
107 return p; 103 return p;
108} 104}
109 105
110static inline __be32 * 106static __be32 *
111decode_sattr3(__be32 *p, struct iattr *iap) 107decode_sattr3(__be32 *p, struct iattr *iap)
112{ 108{
113 u32 tmp; 109 u32 tmp;
@@ -153,7 +149,7 @@ decode_sattr3(__be32 *p, struct iattr *iap)
153 return p; 149 return p;
154} 150}
155 151
156static inline __be32 * 152static __be32 *
157encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, 153encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
158 struct kstat *stat) 154 struct kstat *stat)
159{ 155{
@@ -186,7 +182,7 @@ encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
186 return p; 182 return p;
187} 183}
188 184
189static inline __be32 * 185static __be32 *
190encode_saved_post_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp) 186encode_saved_post_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
191{ 187{
192 struct inode *inode = fhp->fh_dentry->d_inode; 188 struct inode *inode = fhp->fh_dentry->d_inode;
@@ -776,7 +772,7 @@ nfs3svc_encode_readdirres(struct svc_rqst *rqstp, __be32 *p,
776 return xdr_ressize_check(rqstp, p); 772 return xdr_ressize_check(rqstp, p);
777} 773}
778 774
779static inline __be32 * 775static __be32 *
780encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, 776encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name,
781 int namlen, ino_t ino) 777 int namlen, ino_t ino)
782{ 778{
@@ -790,7 +786,7 @@ encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name,
790 return p; 786 return p;
791} 787}
792 788
793static inline __be32 * 789static __be32 *
794encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, 790encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p,
795 struct svc_fh *fhp) 791 struct svc_fh *fhp)
796{ 792{
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 293b6495829f..640c92b2a9f7 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -84,10 +84,10 @@ static void nfs4_set_recdir(char *recdir);
84 */ 84 */
85static DEFINE_MUTEX(client_mutex); 85static DEFINE_MUTEX(client_mutex);
86 86
87static kmem_cache_t *stateowner_slab = NULL; 87static struct kmem_cache *stateowner_slab = NULL;
88static kmem_cache_t *file_slab = NULL; 88static struct kmem_cache *file_slab = NULL;
89static kmem_cache_t *stateid_slab = NULL; 89static struct kmem_cache *stateid_slab = NULL;
90static kmem_cache_t *deleg_slab = NULL; 90static struct kmem_cache *deleg_slab = NULL;
91 91
92void 92void
93nfs4_lock_state(void) 93nfs4_lock_state(void)
@@ -1003,7 +1003,7 @@ alloc_init_file(struct inode *ino)
1003} 1003}
1004 1004
1005static void 1005static void
1006nfsd4_free_slab(kmem_cache_t **slab) 1006nfsd4_free_slab(struct kmem_cache **slab)
1007{ 1007{
1008 if (*slab == NULL) 1008 if (*slab == NULL)
1009 return; 1009 return;
@@ -1829,9 +1829,8 @@ out:
1829} 1829}
1830 1830
1831static struct workqueue_struct *laundry_wq; 1831static struct workqueue_struct *laundry_wq;
1832static struct work_struct laundromat_work; 1832static void laundromat_main(struct work_struct *);
1833static void laundromat_main(void *); 1833static DECLARE_DELAYED_WORK(laundromat_work, laundromat_main);
1834static DECLARE_WORK(laundromat_work, laundromat_main, NULL);
1835 1834
1836__be32 1835__be32
1837nfsd4_renew(clientid_t *clid) 1836nfsd4_renew(clientid_t *clid)
@@ -1940,7 +1939,7 @@ nfs4_laundromat(void)
1940} 1939}
1941 1940
1942void 1941void
1943laundromat_main(void *not_used) 1942laundromat_main(struct work_struct *not_used)
1944{ 1943{
1945 time_t t; 1944 time_t t;
1946 1945
diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c
index 56ebb1443e0e..f5243f943996 100644
--- a/fs/nfsd/nfsxdr.c
+++ b/fs/nfsd/nfsxdr.c
@@ -18,11 +18,6 @@
18 18
19#define NFSDDBG_FACILITY NFSDDBG_XDR 19#define NFSDDBG_FACILITY NFSDDBG_XDR
20 20
21
22#ifdef NFSD_OPTIMIZE_SPACE
23# define inline
24#endif
25
26/* 21/*
27 * Mapping of S_IF* types to NFS file types 22 * Mapping of S_IF* types to NFS file types
28 */ 23 */
@@ -55,7 +50,7 @@ __be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp)
55 return decode_fh(p, fhp); 50 return decode_fh(p, fhp);
56} 51}
57 52
58static inline __be32 * 53static __be32 *
59encode_fh(__be32 *p, struct svc_fh *fhp) 54encode_fh(__be32 *p, struct svc_fh *fhp)
60{ 55{
61 memcpy(p, &fhp->fh_handle.fh_base, NFS_FHSIZE); 56 memcpy(p, &fhp->fh_handle.fh_base, NFS_FHSIZE);
@@ -66,7 +61,7 @@ encode_fh(__be32 *p, struct svc_fh *fhp)
66 * Decode a file name and make sure that the path contains 61 * Decode a file name and make sure that the path contains
67 * no slashes or null bytes. 62 * no slashes or null bytes.
68 */ 63 */
69static inline __be32 * 64static __be32 *
70decode_filename(__be32 *p, char **namp, int *lenp) 65decode_filename(__be32 *p, char **namp, int *lenp)
71{ 66{
72 char *name; 67 char *name;
@@ -82,7 +77,7 @@ decode_filename(__be32 *p, char **namp, int *lenp)
82 return p; 77 return p;
83} 78}
84 79
85static inline __be32 * 80static __be32 *
86decode_pathname(__be32 *p, char **namp, int *lenp) 81decode_pathname(__be32 *p, char **namp, int *lenp)
87{ 82{
88 char *name; 83 char *name;
@@ -98,7 +93,7 @@ decode_pathname(__be32 *p, char **namp, int *lenp)
98 return p; 93 return p;
99} 94}
100 95
101static inline __be32 * 96static __be32 *
102decode_sattr(__be32 *p, struct iattr *iap) 97decode_sattr(__be32 *p, struct iattr *iap)
103{ 98{
104 u32 tmp, tmp1; 99 u32 tmp, tmp1;
diff --git a/fs/nls/nls_cp936.c b/fs/nls/nls_cp936.c
index 046fde8170ea..65e640c61c8b 100644
--- a/fs/nls/nls_cp936.c
+++ b/fs/nls/nls_cp936.c
@@ -4421,6 +4421,73 @@ static wchar_t *page_charset2uni[256] = {
4421 c2u_F8, c2u_F9, c2u_FA, c2u_FB, c2u_FC, c2u_FD, c2u_FE, NULL, 4421 c2u_F8, c2u_F9, c2u_FA, c2u_FB, c2u_FC, c2u_FD, c2u_FE, NULL,
4422}; 4422};
4423 4423
4424static unsigned char u2c_00[512] = {
4425 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */
4426 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */
4427 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0B */
4428 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0C-0x0F */
4429 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x13 */
4430 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x14-0x17 */
4431 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1B */
4432 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1C-0x1F */
4433 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x23 */
4434 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x24-0x27 */
4435 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2B */
4436 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2C-0x2F */
4437 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x33 */
4438 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x34-0x37 */
4439 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3B */
4440 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3C-0x3F */
4441 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x43 */
4442 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x44-0x47 */
4443 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4B */
4444 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x4C-0x4F */
4445 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x53 */
4446 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x54-0x57 */
4447 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5B */
4448 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x5C-0x5F */
4449 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x63 */
4450 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x64-0x67 */
4451 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6B */
4452 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x6C-0x6F */
4453 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x73 */
4454 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x74-0x77 */
4455 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7B */
4456 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x7C-0x7F */
4457 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x83 */
4458 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x84-0x87 */
4459 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8B */
4460 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x8C-0x8F */
4461 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x93 */
4462 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x94-0x97 */
4463 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9B */
4464 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x9C-0x9F */
4465 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA0-0xA3 */
4466 0xA1, 0xE8, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xEC, /* 0xA4-0xA7 */
4467 0xA1, 0xA7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA8-0xAB */
4468 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xAC-0xAF */
4469 0xA1, 0xE3, 0xA1, 0xC0, 0x00, 0x00, 0x00, 0x00, /* 0xB0-0xB3 */
4470 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xA4, /* 0xB4-0xB7 */
4471 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB8-0xBB */
4472 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xBC-0xBF */
4473 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC0-0xC3 */
4474 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC4-0xC7 */
4475 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC8-0xCB */
4476 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xCC-0xCF */
4477 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xD0-0xD3 */
4478 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xC1, /* 0xD4-0xD7 */
4479 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xD8-0xDB */
4480 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xDC-0xDF */
4481 0xA8, 0xA4, 0xA8, 0xA2, 0x00, 0x00, 0x00, 0x00, /* 0xE0-0xE3 */
4482 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xE4-0xE7 */
4483 0xA8, 0xA8, 0xA8, 0xA6, 0xA8, 0xBA, 0x00, 0x00, /* 0xE8-0xEB */
4484 0xA8, 0xAC, 0xA8, 0xAA, 0x00, 0x00, 0x00, 0x00, /* 0xEC-0xEF */
4485 0x00, 0x00, 0x00, 0x00, 0xA8, 0xB0, 0xA8, 0xAE, /* 0xF0-0xF3 */
4486 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xC2, /* 0xF4-0xF7 */
4487 0x00, 0x00, 0xA8, 0xB4, 0xA8, 0xB2, 0x00, 0x00, /* 0xF8-0xFB */
4488 0xA8, 0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xFC-0xFF */
4489};
4490
4424static unsigned char u2c_01[512] = { 4491static unsigned char u2c_01[512] = {
4425 0xA8, 0xA1, 0xA8, 0xA1, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */ 4492 0xA8, 0xA1, 0xA8, 0xA1, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */
4426 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */ 4493 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */
@@ -10825,7 +10892,7 @@ static unsigned char u2c_FF[512] = {
10825}; 10892};
10826 10893
10827static unsigned char *page_uni2charset[256] = { 10894static unsigned char *page_uni2charset[256] = {
10828 NULL, u2c_01, u2c_02, u2c_03, u2c_04, NULL, NULL, NULL, 10895 u2c_00, u2c_01, u2c_02, u2c_03, u2c_04, NULL, NULL, NULL,
10829 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 10896 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
10830 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 10897 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
10831 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 10898 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -10936,11 +11003,34 @@ static int uni2char(const wchar_t uni,
10936 unsigned char *uni2charset; 11003 unsigned char *uni2charset;
10937 unsigned char cl = uni&0xFF; 11004 unsigned char cl = uni&0xFF;
10938 unsigned char ch = (uni>>8)&0xFF; 11005 unsigned char ch = (uni>>8)&0xFF;
10939 int n; 11006 unsigned char out0,out1;
10940 11007
10941 if (boundlen <= 0) 11008 if (boundlen <= 0)
10942 return -ENAMETOOLONG; 11009 return -ENAMETOOLONG;
10943 11010
11011 if (uni == 0x20ac) {/* Euro symbol.The only exception with a non-ascii unicode */
11012 out[0] = 0x80;
11013 return 1;
11014 }
11015
11016 if (ch == 0) { /* handle the U00 plane*/
11017 /* if (cl == 0) return -EINVAL;*/ /*U0000 is legal in cp936*/
11018 out0 = u2c_00[cl*2];
11019 out1 = u2c_00[cl*2+1];
11020 if (out0 == 0x00 && out1 == 0x00) {
11021 if (cl<0x80) {
11022 out[0] = cl;
11023 return 1;
11024 }
11025 return -EINVAL;
11026 } else {
11027 if (boundlen <= 1)
11028 return -ENAMETOOLONG;
11029 out[0] = out0;
11030 out[1] = out1;
11031 return 2;
11032 }
11033 }
10944 11034
10945 uni2charset = page_uni2charset[ch]; 11035 uni2charset = page_uni2charset[ch];
10946 if (uni2charset) { 11036 if (uni2charset) {
@@ -10950,15 +11040,10 @@ static int uni2char(const wchar_t uni,
10950 out[1] = uni2charset[cl*2+1]; 11040 out[1] = uni2charset[cl*2+1];
10951 if (out[0] == 0x00 && out[1] == 0x00) 11041 if (out[0] == 0x00 && out[1] == 0x00)
10952 return -EINVAL; 11042 return -EINVAL;
10953 n = 2; 11043 return 2;
10954 } else if (ch==0 && cl) {
10955 out[0] = cl;
10956 n = 1;
10957 } 11044 }
10958 else 11045 else
10959 return -EINVAL; 11046 return -EINVAL;
10960
10961 return n;
10962} 11047}
10963 11048
10964static int char2uni(const unsigned char *rawstring, int boundlen, 11049static int char2uni(const unsigned char *rawstring, int boundlen,
@@ -10972,7 +11057,11 @@ static int char2uni(const unsigned char *rawstring, int boundlen,
10972 return -ENAMETOOLONG; 11057 return -ENAMETOOLONG;
10973 11058
10974 if (boundlen == 1) { 11059 if (boundlen == 1) {
10975 *uni = rawstring[0]; 11060 if (rawstring[0]==0x80) { /* Euro symbol.The only exception with a non-ascii unicode */
11061 *uni = 0x20ac;
11062 } else {
11063 *uni = rawstring[0];
11064 }
10976 return 1; 11065 return 1;
10977 } 11066 }
10978 11067
@@ -10986,7 +11075,11 @@ static int char2uni(const unsigned char *rawstring, int boundlen,
10986 return -EINVAL; 11075 return -EINVAL;
10987 n = 2; 11076 n = 2;
10988 } else{ 11077 } else{
10989 *uni = ch; 11078 if (ch==0x80) {/* Euro symbol.The only exception with a non-ascii unicode */
11079 *uni = 0x20ac;
11080 } else {
11081 *uni = ch;
11082 }
10990 n = 1; 11083 n = 1;
10991 } 11084 }
10992 return n; 11085 return n;
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
index 9f08e851cfb6..c577d8e1bd95 100644
--- a/fs/ntfs/attrib.c
+++ b/fs/ntfs/attrib.c
@@ -1272,7 +1272,7 @@ ntfs_attr_search_ctx *ntfs_attr_get_search_ctx(ntfs_inode *ni, MFT_RECORD *mrec)
1272{ 1272{
1273 ntfs_attr_search_ctx *ctx; 1273 ntfs_attr_search_ctx *ctx;
1274 1274
1275 ctx = kmem_cache_alloc(ntfs_attr_ctx_cache, SLAB_NOFS); 1275 ctx = kmem_cache_alloc(ntfs_attr_ctx_cache, GFP_NOFS);
1276 if (ctx) 1276 if (ctx)
1277 ntfs_attr_init_search_ctx(ctx, ni, mrec); 1277 ntfs_attr_init_search_ctx(ctx, ni, mrec);
1278 return ctx; 1278 return ctx;
diff --git a/fs/ntfs/index.c b/fs/ntfs/index.c
index e32cde486362..2194eff49743 100644
--- a/fs/ntfs/index.c
+++ b/fs/ntfs/index.c
@@ -38,7 +38,7 @@ ntfs_index_context *ntfs_index_ctx_get(ntfs_inode *idx_ni)
38{ 38{
39 ntfs_index_context *ictx; 39 ntfs_index_context *ictx;
40 40
41 ictx = kmem_cache_alloc(ntfs_index_ctx_cache, SLAB_NOFS); 41 ictx = kmem_cache_alloc(ntfs_index_ctx_cache, GFP_NOFS);
42 if (ictx) 42 if (ictx)
43 *ictx = (ntfs_index_context){ .idx_ni = idx_ni }; 43 *ictx = (ntfs_index_context){ .idx_ni = idx_ni };
44 return ictx; 44 return ictx;
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index 2d3de9c89818..247989891b4b 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -324,7 +324,7 @@ struct inode *ntfs_alloc_big_inode(struct super_block *sb)
324 ntfs_inode *ni; 324 ntfs_inode *ni;
325 325
326 ntfs_debug("Entering."); 326 ntfs_debug("Entering.");
327 ni = kmem_cache_alloc(ntfs_big_inode_cache, SLAB_NOFS); 327 ni = kmem_cache_alloc(ntfs_big_inode_cache, GFP_NOFS);
328 if (likely(ni != NULL)) { 328 if (likely(ni != NULL)) {
329 ni->state = 0; 329 ni->state = 0;
330 return VFS_I(ni); 330 return VFS_I(ni);
@@ -349,7 +349,7 @@ static inline ntfs_inode *ntfs_alloc_extent_inode(void)
349 ntfs_inode *ni; 349 ntfs_inode *ni;
350 350
351 ntfs_debug("Entering."); 351 ntfs_debug("Entering.");
352 ni = kmem_cache_alloc(ntfs_inode_cache, SLAB_NOFS); 352 ni = kmem_cache_alloc(ntfs_inode_cache, GFP_NOFS);
353 if (likely(ni != NULL)) { 353 if (likely(ni != NULL)) {
354 ni->state = 0; 354 ni->state = 0;
355 return ni; 355 return ni;
diff --git a/fs/ntfs/unistr.c b/fs/ntfs/unistr.c
index 6a495f7369f9..005ca4b0f132 100644
--- a/fs/ntfs/unistr.c
+++ b/fs/ntfs/unistr.c
@@ -266,7 +266,7 @@ int ntfs_nlstoucs(const ntfs_volume *vol, const char *ins,
266 266
267 /* We do not trust outside sources. */ 267 /* We do not trust outside sources. */
268 if (likely(ins)) { 268 if (likely(ins)) {
269 ucs = kmem_cache_alloc(ntfs_name_cache, SLAB_NOFS); 269 ucs = kmem_cache_alloc(ntfs_name_cache, GFP_NOFS);
270 if (likely(ucs)) { 270 if (likely(ucs)) {
271 for (i = o = 0; i < ins_len; i += wc_len) { 271 for (i = o = 0; i < ins_len; i += wc_len) {
272 wc_len = nls->char2uni(ins + i, ins_len - i, 272 wc_len = nls->char2uni(ins + i, ins_len - i,
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 85a048b7a67b..edc91ca3792a 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -1197,10 +1197,12 @@ int ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1197 return status; 1197 return status;
1198} 1198}
1199 1199
1200static void ocfs2_truncate_log_worker(void *data) 1200static void ocfs2_truncate_log_worker(struct work_struct *work)
1201{ 1201{
1202 int status; 1202 int status;
1203 struct ocfs2_super *osb = data; 1203 struct ocfs2_super *osb =
1204 container_of(work, struct ocfs2_super,
1205 osb_truncate_log_wq.work);
1204 1206
1205 mlog_entry_void(); 1207 mlog_entry_void();
1206 1208
@@ -1432,7 +1434,8 @@ int ocfs2_truncate_log_init(struct ocfs2_super *osb)
1432 /* ocfs2_truncate_log_shutdown keys on the existence of 1434 /* ocfs2_truncate_log_shutdown keys on the existence of
1433 * osb->osb_tl_inode so we don't set any of the osb variables 1435 * osb->osb_tl_inode so we don't set any of the osb variables
1434 * until we're sure all is well. */ 1436 * until we're sure all is well. */
1435 INIT_WORK(&osb->osb_truncate_log_wq, ocfs2_truncate_log_worker, osb); 1437 INIT_DELAYED_WORK(&osb->osb_truncate_log_wq,
1438 ocfs2_truncate_log_worker);
1436 osb->osb_tl_bh = tl_bh; 1439 osb->osb_tl_bh = tl_bh;
1437 osb->osb_tl_inode = tl_inode; 1440 osb->osb_tl_inode = tl_inode;
1438 1441
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 305cba3681fe..4cd9a9580456 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -141,7 +141,7 @@ struct o2hb_region {
141 * recognizes a node going up and down in one iteration */ 141 * recognizes a node going up and down in one iteration */
142 u64 hr_generation; 142 u64 hr_generation;
143 143
144 struct work_struct hr_write_timeout_work; 144 struct delayed_work hr_write_timeout_work;
145 unsigned long hr_last_timeout_start; 145 unsigned long hr_last_timeout_start;
146 146
147 /* Used during o2hb_check_slot to hold a copy of the block 147 /* Used during o2hb_check_slot to hold a copy of the block
@@ -156,9 +156,11 @@ struct o2hb_bio_wait_ctxt {
156 int wc_error; 156 int wc_error;
157}; 157};
158 158
159static void o2hb_write_timeout(void *arg) 159static void o2hb_write_timeout(struct work_struct *work)
160{ 160{
161 struct o2hb_region *reg = arg; 161 struct o2hb_region *reg =
162 container_of(work, struct o2hb_region,
163 hr_write_timeout_work.work);
162 164
163 mlog(ML_ERROR, "Heartbeat write timeout to device %s after %u " 165 mlog(ML_ERROR, "Heartbeat write timeout to device %s after %u "
164 "milliseconds\n", reg->hr_dev_name, 166 "milliseconds\n", reg->hr_dev_name,
@@ -1404,7 +1406,7 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg,
1404 goto out; 1406 goto out;
1405 } 1407 }
1406 1408
1407 INIT_WORK(&reg->hr_write_timeout_work, o2hb_write_timeout, reg); 1409 INIT_DELAYED_WORK(&reg->hr_write_timeout_work, o2hb_write_timeout);
1408 1410
1409 /* 1411 /*
1410 * A node is considered live after it has beat LIVE_THRESHOLD 1412 * A node is considered live after it has beat LIVE_THRESHOLD
diff --git a/fs/ocfs2/cluster/quorum.c b/fs/ocfs2/cluster/quorum.c
index 7bba98fbfc15..4705d659fe57 100644
--- a/fs/ocfs2/cluster/quorum.c
+++ b/fs/ocfs2/cluster/quorum.c
@@ -88,7 +88,7 @@ void o2quo_disk_timeout(void)
88 o2quo_fence_self(); 88 o2quo_fence_self();
89} 89}
90 90
91static void o2quo_make_decision(void *arg) 91static void o2quo_make_decision(struct work_struct *work)
92{ 92{
93 int quorum; 93 int quorum;
94 int lowest_hb, lowest_reachable = 0, fence = 0; 94 int lowest_hb, lowest_reachable = 0, fence = 0;
@@ -306,7 +306,7 @@ void o2quo_init(void)
306 struct o2quo_state *qs = &o2quo_state; 306 struct o2quo_state *qs = &o2quo_state;
307 307
308 spin_lock_init(&qs->qs_lock); 308 spin_lock_init(&qs->qs_lock);
309 INIT_WORK(&qs->qs_work, o2quo_make_decision, NULL); 309 INIT_WORK(&qs->qs_work, o2quo_make_decision);
310} 310}
311 311
312void o2quo_exit(void) 312void o2quo_exit(void)
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index b650efa8c8be..9b3209dc0b16 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -140,11 +140,11 @@ static int o2net_sys_err_translations[O2NET_ERR_MAX] =
140 [O2NET_ERR_DIED] = -EHOSTDOWN,}; 140 [O2NET_ERR_DIED] = -EHOSTDOWN,};
141 141
142/* can't quite avoid *all* internal declarations :/ */ 142/* can't quite avoid *all* internal declarations :/ */
143static void o2net_sc_connect_completed(void *arg); 143static void o2net_sc_connect_completed(struct work_struct *work);
144static void o2net_rx_until_empty(void *arg); 144static void o2net_rx_until_empty(struct work_struct *work);
145static void o2net_shutdown_sc(void *arg); 145static void o2net_shutdown_sc(struct work_struct *work);
146static void o2net_listen_data_ready(struct sock *sk, int bytes); 146static void o2net_listen_data_ready(struct sock *sk, int bytes);
147static void o2net_sc_send_keep_req(void *arg); 147static void o2net_sc_send_keep_req(struct work_struct *work);
148static void o2net_idle_timer(unsigned long data); 148static void o2net_idle_timer(unsigned long data);
149static void o2net_sc_postpone_idle(struct o2net_sock_container *sc); 149static void o2net_sc_postpone_idle(struct o2net_sock_container *sc);
150 150
@@ -308,10 +308,10 @@ static struct o2net_sock_container *sc_alloc(struct o2nm_node *node)
308 o2nm_node_get(node); 308 o2nm_node_get(node);
309 sc->sc_node = node; 309 sc->sc_node = node;
310 310
311 INIT_WORK(&sc->sc_connect_work, o2net_sc_connect_completed, sc); 311 INIT_WORK(&sc->sc_connect_work, o2net_sc_connect_completed);
312 INIT_WORK(&sc->sc_rx_work, o2net_rx_until_empty, sc); 312 INIT_WORK(&sc->sc_rx_work, o2net_rx_until_empty);
313 INIT_WORK(&sc->sc_shutdown_work, o2net_shutdown_sc, sc); 313 INIT_WORK(&sc->sc_shutdown_work, o2net_shutdown_sc);
314 INIT_WORK(&sc->sc_keepalive_work, o2net_sc_send_keep_req, sc); 314 INIT_DELAYED_WORK(&sc->sc_keepalive_work, o2net_sc_send_keep_req);
315 315
316 init_timer(&sc->sc_idle_timeout); 316 init_timer(&sc->sc_idle_timeout);
317 sc->sc_idle_timeout.function = o2net_idle_timer; 317 sc->sc_idle_timeout.function = o2net_idle_timer;
@@ -342,7 +342,7 @@ static void o2net_sc_queue_work(struct o2net_sock_container *sc,
342 sc_put(sc); 342 sc_put(sc);
343} 343}
344static void o2net_sc_queue_delayed_work(struct o2net_sock_container *sc, 344static void o2net_sc_queue_delayed_work(struct o2net_sock_container *sc,
345 struct work_struct *work, 345 struct delayed_work *work,
346 int delay) 346 int delay)
347{ 347{
348 sc_get(sc); 348 sc_get(sc);
@@ -350,7 +350,7 @@ static void o2net_sc_queue_delayed_work(struct o2net_sock_container *sc,
350 sc_put(sc); 350 sc_put(sc);
351} 351}
352static void o2net_sc_cancel_delayed_work(struct o2net_sock_container *sc, 352static void o2net_sc_cancel_delayed_work(struct o2net_sock_container *sc,
353 struct work_struct *work) 353 struct delayed_work *work)
354{ 354{
355 if (cancel_delayed_work(work)) 355 if (cancel_delayed_work(work))
356 sc_put(sc); 356 sc_put(sc);
@@ -564,9 +564,11 @@ static void o2net_ensure_shutdown(struct o2net_node *nn,
564 * ourselves as state_change couldn't get the nn_lock and call set_nn_state 564 * ourselves as state_change couldn't get the nn_lock and call set_nn_state
565 * itself. 565 * itself.
566 */ 566 */
567static void o2net_shutdown_sc(void *arg) 567static void o2net_shutdown_sc(struct work_struct *work)
568{ 568{
569 struct o2net_sock_container *sc = arg; 569 struct o2net_sock_container *sc =
570 container_of(work, struct o2net_sock_container,
571 sc_shutdown_work);
570 struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); 572 struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num);
571 573
572 sclog(sc, "shutting down\n"); 574 sclog(sc, "shutting down\n");
@@ -1201,9 +1203,10 @@ out:
1201/* this work func is triggerd by data ready. it reads until it can read no 1203/* this work func is triggerd by data ready. it reads until it can read no
1202 * more. it interprets 0, eof, as fatal. if data_ready hits while we're doing 1204 * more. it interprets 0, eof, as fatal. if data_ready hits while we're doing
1203 * our work the work struct will be marked and we'll be called again. */ 1205 * our work the work struct will be marked and we'll be called again. */
1204static void o2net_rx_until_empty(void *arg) 1206static void o2net_rx_until_empty(struct work_struct *work)
1205{ 1207{
1206 struct o2net_sock_container *sc = arg; 1208 struct o2net_sock_container *sc =
1209 container_of(work, struct o2net_sock_container, sc_rx_work);
1207 int ret; 1210 int ret;
1208 1211
1209 do { 1212 do {
@@ -1249,9 +1252,11 @@ static int o2net_set_nodelay(struct socket *sock)
1249 1252
1250/* called when a connect completes and after a sock is accepted. the 1253/* called when a connect completes and after a sock is accepted. the
1251 * rx path will see the response and mark the sc valid */ 1254 * rx path will see the response and mark the sc valid */
1252static void o2net_sc_connect_completed(void *arg) 1255static void o2net_sc_connect_completed(struct work_struct *work)
1253{ 1256{
1254 struct o2net_sock_container *sc = arg; 1257 struct o2net_sock_container *sc =
1258 container_of(work, struct o2net_sock_container,
1259 sc_connect_work);
1255 1260
1256 mlog(ML_MSG, "sc sending handshake with ver %llu id %llx\n", 1261 mlog(ML_MSG, "sc sending handshake with ver %llu id %llx\n",
1257 (unsigned long long)O2NET_PROTOCOL_VERSION, 1262 (unsigned long long)O2NET_PROTOCOL_VERSION,
@@ -1262,9 +1267,11 @@ static void o2net_sc_connect_completed(void *arg)
1262} 1267}
1263 1268
1264/* this is called as a work_struct func. */ 1269/* this is called as a work_struct func. */
1265static void o2net_sc_send_keep_req(void *arg) 1270static void o2net_sc_send_keep_req(struct work_struct *work)
1266{ 1271{
1267 struct o2net_sock_container *sc = arg; 1272 struct o2net_sock_container *sc =
1273 container_of(work, struct o2net_sock_container,
1274 sc_keepalive_work.work);
1268 1275
1269 o2net_sendpage(sc, o2net_keep_req, sizeof(*o2net_keep_req)); 1276 o2net_sendpage(sc, o2net_keep_req, sizeof(*o2net_keep_req));
1270 sc_put(sc); 1277 sc_put(sc);
@@ -1314,14 +1321,15 @@ static void o2net_sc_postpone_idle(struct o2net_sock_container *sc)
1314 * having a connect attempt fail, etc. This centralizes the logic which decides 1321 * having a connect attempt fail, etc. This centralizes the logic which decides
1315 * if a connect attempt should be made or if we should give up and all future 1322 * if a connect attempt should be made or if we should give up and all future
1316 * transmit attempts should fail */ 1323 * transmit attempts should fail */
1317static void o2net_start_connect(void *arg) 1324static void o2net_start_connect(struct work_struct *work)
1318{ 1325{
1319 struct o2net_node *nn = arg; 1326 struct o2net_node *nn =
1327 container_of(work, struct o2net_node, nn_connect_work.work);
1320 struct o2net_sock_container *sc = NULL; 1328 struct o2net_sock_container *sc = NULL;
1321 struct o2nm_node *node = NULL, *mynode = NULL; 1329 struct o2nm_node *node = NULL, *mynode = NULL;
1322 struct socket *sock = NULL; 1330 struct socket *sock = NULL;
1323 struct sockaddr_in myaddr = {0, }, remoteaddr = {0, }; 1331 struct sockaddr_in myaddr = {0, }, remoteaddr = {0, };
1324 int ret = 0; 1332 int ret = 0, stop;
1325 1333
1326 /* if we're greater we initiate tx, otherwise we accept */ 1334 /* if we're greater we initiate tx, otherwise we accept */
1327 if (o2nm_this_node() <= o2net_num_from_nn(nn)) 1335 if (o2nm_this_node() <= o2net_num_from_nn(nn))
@@ -1342,10 +1350,9 @@ static void o2net_start_connect(void *arg)
1342 1350
1343 spin_lock(&nn->nn_lock); 1351 spin_lock(&nn->nn_lock);
1344 /* see if we already have one pending or have given up */ 1352 /* see if we already have one pending or have given up */
1345 if (nn->nn_sc || nn->nn_persistent_error) 1353 stop = (nn->nn_sc || nn->nn_persistent_error);
1346 arg = NULL;
1347 spin_unlock(&nn->nn_lock); 1354 spin_unlock(&nn->nn_lock);
1348 if (arg == NULL) /* *shrug*, needed some indicator */ 1355 if (stop)
1349 goto out; 1356 goto out;
1350 1357
1351 nn->nn_last_connect_attempt = jiffies; 1358 nn->nn_last_connect_attempt = jiffies;
@@ -1421,9 +1428,10 @@ out:
1421 return; 1428 return;
1422} 1429}
1423 1430
1424static void o2net_connect_expired(void *arg) 1431static void o2net_connect_expired(struct work_struct *work)
1425{ 1432{
1426 struct o2net_node *nn = arg; 1433 struct o2net_node *nn =
1434 container_of(work, struct o2net_node, nn_connect_expired.work);
1427 1435
1428 spin_lock(&nn->nn_lock); 1436 spin_lock(&nn->nn_lock);
1429 if (!nn->nn_sc_valid) { 1437 if (!nn->nn_sc_valid) {
@@ -1436,9 +1444,10 @@ static void o2net_connect_expired(void *arg)
1436 spin_unlock(&nn->nn_lock); 1444 spin_unlock(&nn->nn_lock);
1437} 1445}
1438 1446
1439static void o2net_still_up(void *arg) 1447static void o2net_still_up(struct work_struct *work)
1440{ 1448{
1441 struct o2net_node *nn = arg; 1449 struct o2net_node *nn =
1450 container_of(work, struct o2net_node, nn_still_up.work);
1442 1451
1443 o2quo_hb_still_up(o2net_num_from_nn(nn)); 1452 o2quo_hb_still_up(o2net_num_from_nn(nn));
1444} 1453}
@@ -1644,9 +1653,9 @@ out:
1644 return ret; 1653 return ret;
1645} 1654}
1646 1655
1647static void o2net_accept_many(void *arg) 1656static void o2net_accept_many(struct work_struct *work)
1648{ 1657{
1649 struct socket *sock = arg; 1658 struct socket *sock = o2net_listen_sock;
1650 while (o2net_accept_one(sock) == 0) 1659 while (o2net_accept_one(sock) == 0)
1651 cond_resched(); 1660 cond_resched();
1652} 1661}
@@ -1700,7 +1709,7 @@ static int o2net_open_listening_sock(__be16 port)
1700 write_unlock_bh(&sock->sk->sk_callback_lock); 1709 write_unlock_bh(&sock->sk->sk_callback_lock);
1701 1710
1702 o2net_listen_sock = sock; 1711 o2net_listen_sock = sock;
1703 INIT_WORK(&o2net_listen_work, o2net_accept_many, sock); 1712 INIT_WORK(&o2net_listen_work, o2net_accept_many);
1704 1713
1705 sock->sk->sk_reuse = 1; 1714 sock->sk->sk_reuse = 1;
1706 ret = sock->ops->bind(sock, (struct sockaddr *)&sin, sizeof(sin)); 1715 ret = sock->ops->bind(sock, (struct sockaddr *)&sin, sizeof(sin));
@@ -1819,9 +1828,10 @@ int o2net_init(void)
1819 struct o2net_node *nn = o2net_nn_from_num(i); 1828 struct o2net_node *nn = o2net_nn_from_num(i);
1820 1829
1821 spin_lock_init(&nn->nn_lock); 1830 spin_lock_init(&nn->nn_lock);
1822 INIT_WORK(&nn->nn_connect_work, o2net_start_connect, nn); 1831 INIT_DELAYED_WORK(&nn->nn_connect_work, o2net_start_connect);
1823 INIT_WORK(&nn->nn_connect_expired, o2net_connect_expired, nn); 1832 INIT_DELAYED_WORK(&nn->nn_connect_expired,
1824 INIT_WORK(&nn->nn_still_up, o2net_still_up, nn); 1833 o2net_connect_expired);
1834 INIT_DELAYED_WORK(&nn->nn_still_up, o2net_still_up);
1825 /* until we see hb from a node we'll return einval */ 1835 /* until we see hb from a node we'll return einval */
1826 nn->nn_persistent_error = -ENOTCONN; 1836 nn->nn_persistent_error = -ENOTCONN;
1827 init_waitqueue_head(&nn->nn_sc_wq); 1837 init_waitqueue_head(&nn->nn_sc_wq);
diff --git a/fs/ocfs2/cluster/tcp_internal.h b/fs/ocfs2/cluster/tcp_internal.h
index 4b46aac7d243..daebbd3a2c8c 100644
--- a/fs/ocfs2/cluster/tcp_internal.h
+++ b/fs/ocfs2/cluster/tcp_internal.h
@@ -86,18 +86,18 @@ struct o2net_node {
86 * connect attempt fails and so can be self-arming. shutdown is 86 * connect attempt fails and so can be self-arming. shutdown is
87 * careful to first mark the nn such that no connects will be attempted 87 * careful to first mark the nn such that no connects will be attempted
88 * before canceling delayed connect work and flushing the queue. */ 88 * before canceling delayed connect work and flushing the queue. */
89 struct work_struct nn_connect_work; 89 struct delayed_work nn_connect_work;
90 unsigned long nn_last_connect_attempt; 90 unsigned long nn_last_connect_attempt;
91 91
92 /* this is queued as nodes come up and is canceled when a connection is 92 /* this is queued as nodes come up and is canceled when a connection is
93 * established. this expiring gives up on the node and errors out 93 * established. this expiring gives up on the node and errors out
94 * transmits */ 94 * transmits */
95 struct work_struct nn_connect_expired; 95 struct delayed_work nn_connect_expired;
96 96
97 /* after we give up on a socket we wait a while before deciding 97 /* after we give up on a socket we wait a while before deciding
98 * that it is still heartbeating and that we should do some 98 * that it is still heartbeating and that we should do some
99 * quorum work */ 99 * quorum work */
100 struct work_struct nn_still_up; 100 struct delayed_work nn_still_up;
101}; 101};
102 102
103struct o2net_sock_container { 103struct o2net_sock_container {
@@ -129,7 +129,7 @@ struct o2net_sock_container {
129 struct work_struct sc_shutdown_work; 129 struct work_struct sc_shutdown_work;
130 130
131 struct timer_list sc_idle_timeout; 131 struct timer_list sc_idle_timeout;
132 struct work_struct sc_keepalive_work; 132 struct delayed_work sc_keepalive_work;
133 133
134 unsigned sc_handshake_ok:1; 134 unsigned sc_handshake_ok:1;
135 135
diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h
index fa968180b072..6b6ff76538c5 100644
--- a/fs/ocfs2/dlm/dlmcommon.h
+++ b/fs/ocfs2/dlm/dlmcommon.h
@@ -153,7 +153,7 @@ static inline struct hlist_head *dlm_lockres_hash(struct dlm_ctxt *dlm, unsigned
153 * called functions that cannot be directly called from the 153 * called functions that cannot be directly called from the
154 * net message handlers for some reason, usually because 154 * net message handlers for some reason, usually because
155 * they need to send net messages of their own. */ 155 * they need to send net messages of their own. */
156void dlm_dispatch_work(void *data); 156void dlm_dispatch_work(struct work_struct *work);
157 157
158struct dlm_lock_resource; 158struct dlm_lock_resource;
159struct dlm_work_item; 159struct dlm_work_item;
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
index f6cdab3a2c6a..420a375a3949 100644
--- a/fs/ocfs2/dlm/dlmdomain.c
+++ b/fs/ocfs2/dlm/dlmdomain.c
@@ -1297,7 +1297,7 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
1297 1297
1298 spin_lock_init(&dlm->work_lock); 1298 spin_lock_init(&dlm->work_lock);
1299 INIT_LIST_HEAD(&dlm->work_list); 1299 INIT_LIST_HEAD(&dlm->work_list);
1300 INIT_WORK(&dlm->dispatched_work, dlm_dispatch_work, dlm); 1300 INIT_WORK(&dlm->dispatched_work, dlm_dispatch_work);
1301 1301
1302 kref_init(&dlm->dlm_refs); 1302 kref_init(&dlm->dlm_refs);
1303 dlm->dlm_state = DLM_CTXT_NEW; 1303 dlm->dlm_state = DLM_CTXT_NEW;
diff --git a/fs/ocfs2/dlm/dlmfs.c b/fs/ocfs2/dlm/dlmfs.c
index 16b8d1ba7066..941acf14e61f 100644
--- a/fs/ocfs2/dlm/dlmfs.c
+++ b/fs/ocfs2/dlm/dlmfs.c
@@ -66,7 +66,7 @@ static struct file_operations dlmfs_file_operations;
66static struct inode_operations dlmfs_dir_inode_operations; 66static struct inode_operations dlmfs_dir_inode_operations;
67static struct inode_operations dlmfs_root_inode_operations; 67static struct inode_operations dlmfs_root_inode_operations;
68static struct inode_operations dlmfs_file_inode_operations; 68static struct inode_operations dlmfs_file_inode_operations;
69static kmem_cache_t *dlmfs_inode_cache; 69static struct kmem_cache *dlmfs_inode_cache;
70 70
71struct workqueue_struct *user_dlm_worker; 71struct workqueue_struct *user_dlm_worker;
72 72
@@ -257,7 +257,7 @@ static ssize_t dlmfs_file_write(struct file *filp,
257} 257}
258 258
259static void dlmfs_init_once(void *foo, 259static void dlmfs_init_once(void *foo,
260 kmem_cache_t *cachep, 260 struct kmem_cache *cachep,
261 unsigned long flags) 261 unsigned long flags)
262{ 262{
263 struct dlmfs_inode_private *ip = 263 struct dlmfs_inode_private *ip =
@@ -276,7 +276,7 @@ static struct inode *dlmfs_alloc_inode(struct super_block *sb)
276{ 276{
277 struct dlmfs_inode_private *ip; 277 struct dlmfs_inode_private *ip;
278 278
279 ip = kmem_cache_alloc(dlmfs_inode_cache, SLAB_NOFS); 279 ip = kmem_cache_alloc(dlmfs_inode_cache, GFP_NOFS);
280 if (!ip) 280 if (!ip)
281 return NULL; 281 return NULL;
282 282
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index f784177b6241..856012b4fa49 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -221,7 +221,7 @@ EXPORT_SYMBOL_GPL(dlm_dump_all_mles);
221#endif /* 0 */ 221#endif /* 0 */
222 222
223 223
224static kmem_cache_t *dlm_mle_cache = NULL; 224static struct kmem_cache *dlm_mle_cache = NULL;
225 225
226 226
227static void dlm_mle_release(struct kref *kref); 227static void dlm_mle_release(struct kref *kref);
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index 9d950d7cea38..fb3e2b0817f1 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -153,9 +153,10 @@ static inline void dlm_reset_recovery(struct dlm_ctxt *dlm)
153} 153}
154 154
155/* Worker function used during recovery. */ 155/* Worker function used during recovery. */
156void dlm_dispatch_work(void *data) 156void dlm_dispatch_work(struct work_struct *work)
157{ 157{
158 struct dlm_ctxt *dlm = (struct dlm_ctxt *)data; 158 struct dlm_ctxt *dlm =
159 container_of(work, struct dlm_ctxt, dispatched_work);
159 LIST_HEAD(tmp_list); 160 LIST_HEAD(tmp_list);
160 struct list_head *iter, *iter2; 161 struct list_head *iter, *iter2;
161 struct dlm_work_item *item; 162 struct dlm_work_item *item;
diff --git a/fs/ocfs2/dlm/userdlm.c b/fs/ocfs2/dlm/userdlm.c
index eead48bbfac6..7d2f578b267d 100644
--- a/fs/ocfs2/dlm/userdlm.c
+++ b/fs/ocfs2/dlm/userdlm.c
@@ -171,15 +171,14 @@ static inline void user_dlm_grab_inode_ref(struct user_lock_res *lockres)
171 BUG(); 171 BUG();
172} 172}
173 173
174static void user_dlm_unblock_lock(void *opaque); 174static void user_dlm_unblock_lock(struct work_struct *work);
175 175
176static void __user_dlm_queue_lockres(struct user_lock_res *lockres) 176static void __user_dlm_queue_lockres(struct user_lock_res *lockres)
177{ 177{
178 if (!(lockres->l_flags & USER_LOCK_QUEUED)) { 178 if (!(lockres->l_flags & USER_LOCK_QUEUED)) {
179 user_dlm_grab_inode_ref(lockres); 179 user_dlm_grab_inode_ref(lockres);
180 180
181 INIT_WORK(&lockres->l_work, user_dlm_unblock_lock, 181 INIT_WORK(&lockres->l_work, user_dlm_unblock_lock);
182 lockres);
183 182
184 queue_work(user_dlm_worker, &lockres->l_work); 183 queue_work(user_dlm_worker, &lockres->l_work);
185 lockres->l_flags |= USER_LOCK_QUEUED; 184 lockres->l_flags |= USER_LOCK_QUEUED;
@@ -279,10 +278,11 @@ static inline void user_dlm_drop_inode_ref(struct user_lock_res *lockres)
279 iput(inode); 278 iput(inode);
280} 279}
281 280
282static void user_dlm_unblock_lock(void *opaque) 281static void user_dlm_unblock_lock(struct work_struct *work)
283{ 282{
284 int new_level, status; 283 int new_level, status;
285 struct user_lock_res *lockres = (struct user_lock_res *) opaque; 284 struct user_lock_res *lockres =
285 container_of(work, struct user_lock_res, l_work);
286 struct dlm_ctxt *dlm = dlm_ctxt_from_user_lockres(lockres); 286 struct dlm_ctxt *dlm = dlm_ctxt_from_user_lockres(lockres);
287 287
288 mlog(0, "processing lockres %.*s\n", lockres->l_namelen, 288 mlog(0, "processing lockres %.*s\n", lockres->l_namelen,
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c
index fcd4475d1f89..80ac69f11d9f 100644
--- a/fs/ocfs2/extent_map.c
+++ b/fs/ocfs2/extent_map.c
@@ -61,7 +61,7 @@ struct ocfs2_em_insert_context {
61 struct ocfs2_extent_map_entry *right_ent; 61 struct ocfs2_extent_map_entry *right_ent;
62}; 62};
63 63
64static kmem_cache_t *ocfs2_em_ent_cachep = NULL; 64static struct kmem_cache *ocfs2_em_ent_cachep = NULL;
65 65
66 66
67static struct ocfs2_extent_map_entry * 67static struct ocfs2_extent_map_entry *
diff --git a/fs/ocfs2/inode.h b/fs/ocfs2/inode.h
index 46a378fbc40b..1a7dd2945b34 100644
--- a/fs/ocfs2/inode.h
+++ b/fs/ocfs2/inode.h
@@ -106,7 +106,7 @@ static inline struct ocfs2_inode_info *OCFS2_I(struct inode *inode)
106#define INODE_JOURNAL(i) (OCFS2_I(i)->ip_flags & OCFS2_INODE_JOURNAL) 106#define INODE_JOURNAL(i) (OCFS2_I(i)->ip_flags & OCFS2_INODE_JOURNAL)
107#define SET_INODE_JOURNAL(i) (OCFS2_I(i)->ip_flags |= OCFS2_INODE_JOURNAL) 107#define SET_INODE_JOURNAL(i) (OCFS2_I(i)->ip_flags |= OCFS2_INODE_JOURNAL)
108 108
109extern kmem_cache_t *ocfs2_inode_cache; 109extern struct kmem_cache *ocfs2_inode_cache;
110 110
111extern const struct address_space_operations ocfs2_aops; 111extern const struct address_space_operations ocfs2_aops;
112 112
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index c0ad7cb59521..1d7f4ab1e5ed 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -703,11 +703,12 @@ struct ocfs2_la_recovery_item {
703 * NOTE: This function can and will sleep on recovery of other nodes 703 * NOTE: This function can and will sleep on recovery of other nodes
704 * during cluster locking, just like any other ocfs2 process. 704 * during cluster locking, just like any other ocfs2 process.
705 */ 705 */
706void ocfs2_complete_recovery(void *data) 706void ocfs2_complete_recovery(struct work_struct *work)
707{ 707{
708 int ret; 708 int ret;
709 struct ocfs2_super *osb = data; 709 struct ocfs2_journal *journal =
710 struct ocfs2_journal *journal = osb->journal; 710 container_of(work, struct ocfs2_journal, j_recovery_work);
711 struct ocfs2_super *osb = journal->j_osb;
711 struct ocfs2_dinode *la_dinode, *tl_dinode; 712 struct ocfs2_dinode *la_dinode, *tl_dinode;
712 struct ocfs2_la_recovery_item *item; 713 struct ocfs2_la_recovery_item *item;
713 struct list_head *p, *n; 714 struct list_head *p, *n;
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h
index d86cb960b7ec..899112ad8136 100644
--- a/fs/ocfs2/journal.h
+++ b/fs/ocfs2/journal.h
@@ -133,7 +133,7 @@ static inline void ocfs2_inode_set_new(struct ocfs2_super *osb,
133} 133}
134 134
135/* Exported only for the journal struct init code in super.c. Do not call. */ 135/* Exported only for the journal struct init code in super.c. Do not call. */
136void ocfs2_complete_recovery(void *data); 136void ocfs2_complete_recovery(struct work_struct *work);
137 137
138/* 138/*
139 * Journal Control: 139 * Journal Control:
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index 078883772bd6..b767fd7da6eb 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -285,7 +285,7 @@ struct ocfs2_super
285 /* Truncate log info */ 285 /* Truncate log info */
286 struct inode *osb_tl_inode; 286 struct inode *osb_tl_inode;
287 struct buffer_head *osb_tl_bh; 287 struct buffer_head *osb_tl_bh;
288 struct work_struct osb_truncate_log_wq; 288 struct delayed_work osb_truncate_log_wq;
289 289
290 struct ocfs2_node_map osb_recovering_orphan_dirs; 290 struct ocfs2_node_map osb_recovering_orphan_dirs;
291 unsigned int *osb_orphan_wipes; 291 unsigned int *osb_orphan_wipes;
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index b0992573dee2..4bf39540e652 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -68,7 +68,7 @@
68 68
69#include "buffer_head_io.h" 69#include "buffer_head_io.h"
70 70
71static kmem_cache_t *ocfs2_inode_cachep = NULL; 71static struct kmem_cache *ocfs2_inode_cachep = NULL;
72 72
73/* OCFS2 needs to schedule several differnt types of work which 73/* OCFS2 needs to schedule several differnt types of work which
74 * require cluster locking, disk I/O, recovery waits, etc. Since these 74 * require cluster locking, disk I/O, recovery waits, etc. Since these
@@ -303,7 +303,7 @@ static struct inode *ocfs2_alloc_inode(struct super_block *sb)
303{ 303{
304 struct ocfs2_inode_info *oi; 304 struct ocfs2_inode_info *oi;
305 305
306 oi = kmem_cache_alloc(ocfs2_inode_cachep, SLAB_NOFS); 306 oi = kmem_cache_alloc(ocfs2_inode_cachep, GFP_NOFS);
307 if (!oi) 307 if (!oi)
308 return NULL; 308 return NULL;
309 309
@@ -914,7 +914,7 @@ bail:
914} 914}
915 915
916static void ocfs2_inode_init_once(void *data, 916static void ocfs2_inode_init_once(void *data,
917 kmem_cache_t *cachep, 917 struct kmem_cache *cachep,
918 unsigned long flags) 918 unsigned long flags)
919{ 919{
920 struct ocfs2_inode_info *oi = data; 920 struct ocfs2_inode_info *oi = data;
@@ -1365,7 +1365,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
1365 spin_lock_init(&journal->j_lock); 1365 spin_lock_init(&journal->j_lock);
1366 journal->j_trans_id = (unsigned long) 1; 1366 journal->j_trans_id = (unsigned long) 1;
1367 INIT_LIST_HEAD(&journal->j_la_cleanups); 1367 INIT_LIST_HEAD(&journal->j_la_cleanups);
1368 INIT_WORK(&journal->j_recovery_work, ocfs2_complete_recovery, osb); 1368 INIT_WORK(&journal->j_recovery_work, ocfs2_complete_recovery);
1369 journal->j_state = OCFS2_JOURNAL_FREE; 1369 journal->j_state = OCFS2_JOURNAL_FREE;
1370 1370
1371 /* get some pseudo constants for clustersize bits */ 1371 /* get some pseudo constants for clustersize bits */
@@ -1674,7 +1674,7 @@ void __ocfs2_error(struct super_block *sb,
1674 va_list args; 1674 va_list args;
1675 1675
1676 va_start(args, fmt); 1676 va_start(args, fmt);
1677 vsprintf(error_buf, fmt, args); 1677 vsnprintf(error_buf, sizeof(error_buf), fmt, args);
1678 va_end(args); 1678 va_end(args);
1679 1679
1680 /* Not using mlog here because we want to show the actual 1680 /* Not using mlog here because we want to show the actual
@@ -1695,7 +1695,7 @@ void __ocfs2_abort(struct super_block* sb,
1695 va_list args; 1695 va_list args;
1696 1696
1697 va_start(args, fmt); 1697 va_start(args, fmt);
1698 vsprintf(error_buf, fmt, args); 1698 vsnprintf(error_buf, sizeof(error_buf), fmt, args);
1699 va_end(args); 1699 va_end(args);
1700 1700
1701 printk(KERN_CRIT "OCFS2: abort (device %s): %s: %s\n", 1701 printk(KERN_CRIT "OCFS2: abort (device %s): %s: %s\n",
diff --git a/fs/ocfs2/uptodate.c b/fs/ocfs2/uptodate.c
index 9707ed7a3206..39814b900fc0 100644
--- a/fs/ocfs2/uptodate.c
+++ b/fs/ocfs2/uptodate.c
@@ -69,7 +69,7 @@ struct ocfs2_meta_cache_item {
69 sector_t c_block; 69 sector_t c_block;
70}; 70};
71 71
72static kmem_cache_t *ocfs2_uptodate_cachep = NULL; 72static struct kmem_cache *ocfs2_uptodate_cachep = NULL;
73 73
74void ocfs2_metadata_cache_init(struct inode *inode) 74void ocfs2_metadata_cache_init(struct inode *inode)
75{ 75{
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
index 592a6402e851..26f44e0074ec 100644
--- a/fs/openpromfs/inode.c
+++ b/fs/openpromfs/inode.c
@@ -330,13 +330,13 @@ out:
330 return 0; 330 return 0;
331} 331}
332 332
333static kmem_cache_t *op_inode_cachep; 333static struct kmem_cache *op_inode_cachep;
334 334
335static struct inode *openprom_alloc_inode(struct super_block *sb) 335static struct inode *openprom_alloc_inode(struct super_block *sb)
336{ 336{
337 struct op_inode_info *oi; 337 struct op_inode_info *oi;
338 338
339 oi = kmem_cache_alloc(op_inode_cachep, SLAB_KERNEL); 339 oi = kmem_cache_alloc(op_inode_cachep, GFP_KERNEL);
340 if (!oi) 340 if (!oi)
341 return NULL; 341 return NULL;
342 342
@@ -415,7 +415,7 @@ static struct file_system_type openprom_fs_type = {
415 .kill_sb = kill_anon_super, 415 .kill_sb = kill_anon_super,
416}; 416};
417 417
418static void op_inode_init_once(void *data, kmem_cache_t * cachep, unsigned long flags) 418static void op_inode_init_once(void *data, struct kmem_cache * cachep, unsigned long flags)
419{ 419{
420 struct op_inode_info *oi = (struct op_inode_info *) data; 420 struct op_inode_info *oi = (struct op_inode_info *) data;
421 421
diff --git a/fs/partitions/amiga.c b/fs/partitions/amiga.c
index 3068528890a6..9917a8c360f2 100644
--- a/fs/partitions/amiga.c
+++ b/fs/partitions/amiga.c
@@ -43,6 +43,7 @@ amiga_partition(struct parsed_partitions *state, struct block_device *bdev)
43 if (warn_no_part) 43 if (warn_no_part)
44 printk("Dev %s: unable to read RDB block %d\n", 44 printk("Dev %s: unable to read RDB block %d\n",
45 bdevname(bdev, b), blk); 45 bdevname(bdev, b), blk);
46 res = -1;
46 goto rdb_done; 47 goto rdb_done;
47 } 48 }
48 if (*(__be32 *)data != cpu_to_be32(IDNAME_RIGIDDISK)) 49 if (*(__be32 *)data != cpu_to_be32(IDNAME_RIGIDDISK))
@@ -79,6 +80,7 @@ amiga_partition(struct parsed_partitions *state, struct block_device *bdev)
79 if (warn_no_part) 80 if (warn_no_part)
80 printk("Dev %s: unable to read partition block %d\n", 81 printk("Dev %s: unable to read partition block %d\n",
81 bdevname(bdev, b), blk); 82 bdevname(bdev, b), blk);
83 res = -1;
82 goto rdb_done; 84 goto rdb_done;
83 } 85 }
84 pb = (struct PartitionBlock *)data; 86 pb = (struct PartitionBlock *)data;
diff --git a/fs/partitions/atari.c b/fs/partitions/atari.c
index 192a6adfdefd..1f3572d5b755 100644
--- a/fs/partitions/atari.c
+++ b/fs/partitions/atari.c
@@ -88,7 +88,7 @@ int atari_partition(struct parsed_partitions *state, struct block_device *bdev)
88 if (!xrs) { 88 if (!xrs) {
89 printk (" block %ld read failed\n", partsect); 89 printk (" block %ld read failed\n", partsect);
90 put_dev_sector(sect); 90 put_dev_sector(sect);
91 return 0; 91 return -1;
92 } 92 }
93 93
94 /* ++roman: sanity check: bit 0 of flg field must be set */ 94 /* ++roman: sanity check: bit 0 of flg field must be set */
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 6fb4b6150d77..1901137f4eca 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -153,7 +153,7 @@ static struct parsed_partitions *
153check_partition(struct gendisk *hd, struct block_device *bdev) 153check_partition(struct gendisk *hd, struct block_device *bdev)
154{ 154{
155 struct parsed_partitions *state; 155 struct parsed_partitions *state;
156 int i, res; 156 int i, res, err;
157 157
158 state = kmalloc(sizeof(struct parsed_partitions), GFP_KERNEL); 158 state = kmalloc(sizeof(struct parsed_partitions), GFP_KERNEL);
159 if (!state) 159 if (!state)
@@ -165,19 +165,30 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
165 sprintf(state->name, "p"); 165 sprintf(state->name, "p");
166 166
167 state->limit = hd->minors; 167 state->limit = hd->minors;
168 i = res = 0; 168 i = res = err = 0;
169 while (!res && check_part[i]) { 169 while (!res && check_part[i]) {
170 memset(&state->parts, 0, sizeof(state->parts)); 170 memset(&state->parts, 0, sizeof(state->parts));
171 res = check_part[i++](state, bdev); 171 res = check_part[i++](state, bdev);
172 if (res < 0) {
173 /* We have hit an I/O error which we don't report now.
174 * But record it, and let the others do their job.
175 */
176 err = res;
177 res = 0;
178 }
179
172 } 180 }
173 if (res > 0) 181 if (res > 0)
174 return state; 182 return state;
183 if (!err)
184 /* The partition is unrecognized. So report I/O errors if there were any */
185 res = err;
175 if (!res) 186 if (!res)
176 printk(" unknown partition table\n"); 187 printk(" unknown partition table\n");
177 else if (warn_no_part) 188 else if (warn_no_part)
178 printk(" unable to read partition table\n"); 189 printk(" unable to read partition table\n");
179 kfree(state); 190 kfree(state);
180 return NULL; 191 return ERR_PTR(res);
181} 192}
182 193
183/* 194/*
@@ -494,6 +505,8 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
494 disk->fops->revalidate_disk(disk); 505 disk->fops->revalidate_disk(disk);
495 if (!get_capacity(disk) || !(state = check_partition(disk, bdev))) 506 if (!get_capacity(disk) || !(state = check_partition(disk, bdev)))
496 return 0; 507 return 0;
508 if (IS_ERR(state)) /* I/O error reading the partition table */
509 return PTR_ERR(state);
497 for (p = 1; p < state->limit; p++) { 510 for (p = 1; p < state->limit; p++) {
498 sector_t size = state->parts[p].size; 511 sector_t size = state->parts[p].size;
499 sector_t from = state->parts[p].from; 512 sector_t from = state->parts[p].from;
diff --git a/fs/partitions/ibm.c b/fs/partitions/ibm.c
index d352a7381fed..9f7ad4244f63 100644
--- a/fs/partitions/ibm.c
+++ b/fs/partitions/ibm.c
@@ -43,7 +43,7 @@ cchhb2blk (struct vtoc_cchhb *ptr, struct hd_geometry *geo) {
43int 43int
44ibm_partition(struct parsed_partitions *state, struct block_device *bdev) 44ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
45{ 45{
46 int blocksize, offset, size; 46 int blocksize, offset, size,res;
47 loff_t i_size; 47 loff_t i_size;
48 dasd_information_t *info; 48 dasd_information_t *info;
49 struct hd_geometry *geo; 49 struct hd_geometry *geo;
@@ -56,15 +56,16 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
56 unsigned char *data; 56 unsigned char *data;
57 Sector sect; 57 Sector sect;
58 58
59 res = 0;
59 blocksize = bdev_hardsect_size(bdev); 60 blocksize = bdev_hardsect_size(bdev);
60 if (blocksize <= 0) 61 if (blocksize <= 0)
61 return 0; 62 goto out_exit;
62 i_size = i_size_read(bdev->bd_inode); 63 i_size = i_size_read(bdev->bd_inode);
63 if (i_size == 0) 64 if (i_size == 0)
64 return 0; 65 goto out_exit;
65 66
66 if ((info = kmalloc(sizeof(dasd_information_t), GFP_KERNEL)) == NULL) 67 if ((info = kmalloc(sizeof(dasd_information_t), GFP_KERNEL)) == NULL)
67 goto out_noinfo; 68 goto out_exit;
68 if ((geo = kmalloc(sizeof(struct hd_geometry), GFP_KERNEL)) == NULL) 69 if ((geo = kmalloc(sizeof(struct hd_geometry), GFP_KERNEL)) == NULL)
69 goto out_nogeo; 70 goto out_nogeo;
70 if ((label = kmalloc(sizeof(union label_t), GFP_KERNEL)) == NULL) 71 if ((label = kmalloc(sizeof(union label_t), GFP_KERNEL)) == NULL)
@@ -72,7 +73,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
72 73
73 if (ioctl_by_bdev(bdev, BIODASDINFO, (unsigned long)info) != 0 || 74 if (ioctl_by_bdev(bdev, BIODASDINFO, (unsigned long)info) != 0 ||
74 ioctl_by_bdev(bdev, HDIO_GETGEO, (unsigned long)geo) != 0) 75 ioctl_by_bdev(bdev, HDIO_GETGEO, (unsigned long)geo) != 0)
75 goto out_noioctl; 76 goto out_freeall;
76 77
77 /* 78 /*
78 * Get volume label, extract name and type. 79 * Get volume label, extract name and type.
@@ -92,6 +93,8 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
92 EBCASC(type, 4); 93 EBCASC(type, 4);
93 EBCASC(name, 6); 94 EBCASC(name, 6);
94 95
96 res = 1;
97
95 /* 98 /*
96 * Three different types: CMS1, VOL1 and LNX1/unlabeled 99 * Three different types: CMS1, VOL1 and LNX1/unlabeled
97 */ 100 */
@@ -156,6 +159,9 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
156 counter++; 159 counter++;
157 blk++; 160 blk++;
158 } 161 }
162 if (!data)
163 /* Are we not supposed to report this ? */
164 goto out_readerr;
159 } else { 165 } else {
160 /* 166 /*
161 * Old style LNX1 or unlabeled disk 167 * Old style LNX1 or unlabeled disk
@@ -171,18 +177,17 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
171 } 177 }
172 178
173 printk("\n"); 179 printk("\n");
174 kfree(label); 180 goto out_freeall;
175 kfree(geo); 181
176 kfree(info);
177 return 1;
178 182
179out_readerr: 183out_readerr:
180out_noioctl: 184 res = -1;
185out_freeall:
181 kfree(label); 186 kfree(label);
182out_nolab: 187out_nolab:
183 kfree(geo); 188 kfree(geo);
184out_nogeo: 189out_nogeo:
185 kfree(info); 190 kfree(info);
186out_noinfo: 191out_exit:
187 return 0; 192 return res;
188} 193}
diff --git a/fs/pipe.c b/fs/pipe.c
index b1626f269a34..ae36b89b1a37 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -830,7 +830,14 @@ void free_pipe_info(struct inode *inode)
830static struct vfsmount *pipe_mnt __read_mostly; 830static struct vfsmount *pipe_mnt __read_mostly;
831static int pipefs_delete_dentry(struct dentry *dentry) 831static int pipefs_delete_dentry(struct dentry *dentry)
832{ 832{
833 return 1; 833 /*
834 * At creation time, we pretended this dentry was hashed
835 * (by clearing DCACHE_UNHASHED bit in d_flags)
836 * At delete time, we restore the truth : not hashed.
837 * (so that dput() can proceed correctly)
838 */
839 dentry->d_flags |= DCACHE_UNHASHED;
840 return 0;
834} 841}
835 842
836static struct dentry_operations pipefs_dentry_operations = { 843static struct dentry_operations pipefs_dentry_operations = {
@@ -891,17 +898,22 @@ struct file *create_write_pipe(void)
891 if (!inode) 898 if (!inode)
892 goto err_file; 899 goto err_file;
893 900
894 sprintf(name, "[%lu]", inode->i_ino); 901 this.len = sprintf(name, "[%lu]", inode->i_ino);
895 this.name = name; 902 this.name = name;
896 this.len = strlen(name); 903 this.hash = 0;
897 this.hash = inode->i_ino; /* will go */
898 err = -ENOMEM; 904 err = -ENOMEM;
899 dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &this); 905 dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &this);
900 if (!dentry) 906 if (!dentry)
901 goto err_inode; 907 goto err_inode;
902 908
903 dentry->d_op = &pipefs_dentry_operations; 909 dentry->d_op = &pipefs_dentry_operations;
904 d_add(dentry, inode); 910 /*
911 * We dont want to publish this dentry into global dentry hash table.
912 * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED
913 * This permits a working /proc/$pid/fd/XXX on pipes
914 */
915 dentry->d_flags &= ~DCACHE_UNHASHED;
916 d_instantiate(dentry, inode);
905 f->f_vfsmnt = mntget(pipe_mnt); 917 f->f_vfsmnt = mntget(pipe_mnt);
906 f->f_dentry = dentry; 918 f->f_dentry = dentry;
907 f->f_mapping = inode->i_mapping; 919 f->f_mapping = inode->i_mapping;
diff --git a/fs/proc/Makefile b/fs/proc/Makefile
index 7431d7ba2d09..f6c776272572 100644
--- a/fs/proc/Makefile
+++ b/fs/proc/Makefile
@@ -8,8 +8,9 @@ proc-y := nommu.o task_nommu.o
8proc-$(CONFIG_MMU) := mmu.o task_mmu.o 8proc-$(CONFIG_MMU) := mmu.o task_mmu.o
9 9
10proc-y += inode.o root.o base.o generic.o array.o \ 10proc-y += inode.o root.o base.o generic.o array.o \
11 kmsg.o proc_tty.o proc_misc.o 11 proc_tty.o proc_misc.o
12 12
13proc-$(CONFIG_PROC_KCORE) += kcore.o 13proc-$(CONFIG_PROC_KCORE) += kcore.o
14proc-$(CONFIG_PROC_VMCORE) += vmcore.o 14proc-$(CONFIG_PROC_VMCORE) += vmcore.o
15proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o 15proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o
16proc-$(CONFIG_PRINTK) += kmsg.o
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 795319c54f72..b859fc749c07 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -683,8 +683,6 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
683 char buffer[PROC_NUMBUF], *end; 683 char buffer[PROC_NUMBUF], *end;
684 int oom_adjust; 684 int oom_adjust;
685 685
686 if (!capable(CAP_SYS_RESOURCE))
687 return -EPERM;
688 memset(buffer, 0, sizeof(buffer)); 686 memset(buffer, 0, sizeof(buffer));
689 if (count > sizeof(buffer) - 1) 687 if (count > sizeof(buffer) - 1)
690 count = sizeof(buffer) - 1; 688 count = sizeof(buffer) - 1;
@@ -699,6 +697,10 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
699 task = get_proc_task(file->f_dentry->d_inode); 697 task = get_proc_task(file->f_dentry->d_inode);
700 if (!task) 698 if (!task)
701 return -ESRCH; 699 return -ESRCH;
700 if (oom_adjust < task->oomkilladj && !capable(CAP_SYS_RESOURCE)) {
701 put_task_struct(task);
702 return -EACCES;
703 }
702 task->oomkilladj = oom_adjust; 704 task->oomkilladj = oom_adjust;
703 put_task_struct(task); 705 put_task_struct(task);
704 if (end - buffer == 0) 706 if (end - buffer == 0)
@@ -1883,8 +1885,9 @@ out:
1883 return; 1885 return;
1884} 1886}
1885 1887
1886struct dentry *proc_pid_instantiate(struct inode *dir, 1888static struct dentry *proc_pid_instantiate(struct inode *dir,
1887 struct dentry * dentry, struct task_struct *task, void *ptr) 1889 struct dentry * dentry,
1890 struct task_struct *task, void *ptr)
1888{ 1891{
1889 struct dentry *error = ERR_PTR(-ENOENT); 1892 struct dentry *error = ERR_PTR(-ENOENT);
1890 struct inode *inode; 1893 struct inode *inode;
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 49dfb2ab783e..e26945ba685b 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -81,14 +81,14 @@ static void proc_read_inode(struct inode * inode)
81 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 81 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
82} 82}
83 83
84static kmem_cache_t * proc_inode_cachep; 84static struct kmem_cache * proc_inode_cachep;
85 85
86static struct inode *proc_alloc_inode(struct super_block *sb) 86static struct inode *proc_alloc_inode(struct super_block *sb)
87{ 87{
88 struct proc_inode *ei; 88 struct proc_inode *ei;
89 struct inode *inode; 89 struct inode *inode;
90 90
91 ei = (struct proc_inode *)kmem_cache_alloc(proc_inode_cachep, SLAB_KERNEL); 91 ei = (struct proc_inode *)kmem_cache_alloc(proc_inode_cachep, GFP_KERNEL);
92 if (!ei) 92 if (!ei)
93 return NULL; 93 return NULL;
94 ei->pid = NULL; 94 ei->pid = NULL;
@@ -105,7 +105,7 @@ static void proc_destroy_inode(struct inode *inode)
105 kmem_cache_free(proc_inode_cachep, PROC_I(inode)); 105 kmem_cache_free(proc_inode_cachep, PROC_I(inode));
106} 106}
107 107
108static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 108static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
109{ 109{
110 struct proc_inode *ei = (struct proc_inode *) foo; 110 struct proc_inode *ei = (struct proc_inode *) foo;
111 111
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index 1294eda4acae..1be73082edd3 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -22,6 +22,7 @@
22#include <asm/uaccess.h> 22#include <asm/uaccess.h>
23#include <asm/io.h> 23#include <asm/io.h>
24 24
25#define CORE_STR "CORE"
25 26
26static int open_kcore(struct inode * inode, struct file * filp) 27static int open_kcore(struct inode * inode, struct file * filp)
27{ 28{
@@ -82,10 +83,11 @@ static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
82 } 83 }
83 *elf_buflen = sizeof(struct elfhdr) + 84 *elf_buflen = sizeof(struct elfhdr) +
84 (*nphdr + 2)*sizeof(struct elf_phdr) + 85 (*nphdr + 2)*sizeof(struct elf_phdr) +
85 3 * (sizeof(struct elf_note) + 4) + 86 3 * ((sizeof(struct elf_note)) +
86 sizeof(struct elf_prstatus) + 87 roundup(sizeof(CORE_STR), 4)) +
87 sizeof(struct elf_prpsinfo) + 88 roundup(sizeof(struct elf_prstatus), 4) +
88 sizeof(struct task_struct); 89 roundup(sizeof(struct elf_prpsinfo), 4) +
90 roundup(sizeof(struct task_struct), 4);
89 *elf_buflen = PAGE_ALIGN(*elf_buflen); 91 *elf_buflen = PAGE_ALIGN(*elf_buflen);
90 return size + *elf_buflen; 92 return size + *elf_buflen;
91} 93}
@@ -210,7 +212,7 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
210 nhdr->p_offset = offset; 212 nhdr->p_offset = offset;
211 213
212 /* set up the process status */ 214 /* set up the process status */
213 notes[0].name = "CORE"; 215 notes[0].name = CORE_STR;
214 notes[0].type = NT_PRSTATUS; 216 notes[0].type = NT_PRSTATUS;
215 notes[0].datasz = sizeof(struct elf_prstatus); 217 notes[0].datasz = sizeof(struct elf_prstatus);
216 notes[0].data = &prstatus; 218 notes[0].data = &prstatus;
@@ -221,7 +223,7 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
221 bufp = storenote(&notes[0], bufp); 223 bufp = storenote(&notes[0], bufp);
222 224
223 /* set up the process info */ 225 /* set up the process info */
224 notes[1].name = "CORE"; 226 notes[1].name = CORE_STR;
225 notes[1].type = NT_PRPSINFO; 227 notes[1].type = NT_PRPSINFO;
226 notes[1].datasz = sizeof(struct elf_prpsinfo); 228 notes[1].datasz = sizeof(struct elf_prpsinfo);
227 notes[1].data = &prpsinfo; 229 notes[1].data = &prpsinfo;
@@ -238,7 +240,7 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
238 bufp = storenote(&notes[1], bufp); 240 bufp = storenote(&notes[1], bufp);
239 241
240 /* set up the task structure */ 242 /* set up the task structure */
241 notes[2].name = "CORE"; 243 notes[2].name = CORE_STR;
242 notes[2].type = NT_TASKSTRUCT; 244 notes[2].type = NT_TASKSTRUCT;
243 notes[2].datasz = sizeof(struct task_struct); 245 notes[2].datasz = sizeof(struct task_struct);
244 notes[2].data = current; 246 notes[2].data = current;
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 93c43b676e59..51815cece6f3 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -696,9 +696,11 @@ void __init proc_misc_init(void)
696 proc_symlink("mounts", NULL, "self/mounts"); 696 proc_symlink("mounts", NULL, "self/mounts");
697 697
698 /* And now for trickier ones */ 698 /* And now for trickier ones */
699#ifdef CONFIG_PRINTK
699 entry = create_proc_entry("kmsg", S_IRUSR, &proc_root); 700 entry = create_proc_entry("kmsg", S_IRUSR, &proc_root);
700 if (entry) 701 if (entry)
701 entry->proc_fops = &proc_kmsg_operations; 702 entry->proc_fops = &proc_kmsg_operations;
703#endif
702 create_seq_entry("devices", 0, &proc_devinfo_operations); 704 create_seq_entry("devices", 0, &proc_devinfo_operations);
703 create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations); 705 create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations);
704#ifdef CONFIG_BLOCK 706#ifdef CONFIG_BLOCK
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index 5a41db2a218d..c047dc654d5c 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -515,12 +515,12 @@ static void qnx4_read_inode(struct inode *inode)
515 brelse(bh); 515 brelse(bh);
516} 516}
517 517
518static kmem_cache_t *qnx4_inode_cachep; 518static struct kmem_cache *qnx4_inode_cachep;
519 519
520static struct inode *qnx4_alloc_inode(struct super_block *sb) 520static struct inode *qnx4_alloc_inode(struct super_block *sb)
521{ 521{
522 struct qnx4_inode_info *ei; 522 struct qnx4_inode_info *ei;
523 ei = kmem_cache_alloc(qnx4_inode_cachep, SLAB_KERNEL); 523 ei = kmem_cache_alloc(qnx4_inode_cachep, GFP_KERNEL);
524 if (!ei) 524 if (!ei)
525 return NULL; 525 return NULL;
526 return &ei->vfs_inode; 526 return &ei->vfs_inode;
@@ -531,7 +531,7 @@ static void qnx4_destroy_inode(struct inode *inode)
531 kmem_cache_free(qnx4_inode_cachep, qnx4_i(inode)); 531 kmem_cache_free(qnx4_inode_cachep, qnx4_i(inode));
532} 532}
533 533
534static void init_once(void *foo, kmem_cache_t * cachep, 534static void init_once(void *foo, struct kmem_cache * cachep,
535 unsigned long flags) 535 unsigned long flags)
536{ 536{
537 struct qnx4_inode_info *ei = (struct qnx4_inode_info *) foo; 537 struct qnx4_inode_info *ei = (struct qnx4_inode_info *) foo;
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index ac14318c81ba..373d862c3f87 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -317,12 +317,11 @@ static int reiserfs_allocate_blocks_for_region(struct reiserfs_transaction_handl
317 /* area filled with zeroes, to supply as list of zero blocknumbers 317 /* area filled with zeroes, to supply as list of zero blocknumbers
318 We allocate it outside of loop just in case loop would spin for 318 We allocate it outside of loop just in case loop would spin for
319 several iterations. */ 319 several iterations. */
320 char *zeros = kmalloc(to_paste * UNFM_P_SIZE, GFP_ATOMIC); // We cannot insert more than MAX_ITEM_LEN bytes anyway. 320 char *zeros = kzalloc(to_paste * UNFM_P_SIZE, GFP_ATOMIC); // We cannot insert more than MAX_ITEM_LEN bytes anyway.
321 if (!zeros) { 321 if (!zeros) {
322 res = -ENOMEM; 322 res = -ENOMEM;
323 goto error_exit_free_blocks; 323 goto error_exit_free_blocks;
324 } 324 }
325 memset(zeros, 0, to_paste * UNFM_P_SIZE);
326 do { 325 do {
327 to_paste = 326 to_paste =
328 min_t(__u64, hole_size, 327 min_t(__u64, hole_size,
@@ -407,6 +406,8 @@ static int reiserfs_allocate_blocks_for_region(struct reiserfs_transaction_handl
407 we restart it. This will also free the path. */ 406 we restart it. This will also free the path. */
408 if (journal_transaction_should_end 407 if (journal_transaction_should_end
409 (th, th->t_blocks_allocated)) { 408 (th, th->t_blocks_allocated)) {
409 inode->i_size = cpu_key_k_offset(&key) +
410 (to_paste << inode->i_blkbits);
410 res = 411 res =
411 restart_transaction(th, inode, 412 restart_transaction(th, inode,
412 &path); 413 &path);
@@ -1045,6 +1046,7 @@ static int reiserfs_prepare_file_region_for_write(struct inode *inode
1045 char *kaddr = kmap_atomic(prepared_pages[0], KM_USER0); 1046 char *kaddr = kmap_atomic(prepared_pages[0], KM_USER0);
1046 memset(kaddr, 0, from); 1047 memset(kaddr, 0, from);
1047 kunmap_atomic(kaddr, KM_USER0); 1048 kunmap_atomic(kaddr, KM_USER0);
1049 flush_dcache_page(prepared_pages[0]);
1048 } 1050 }
1049 if (to != PAGE_CACHE_SIZE) { /* Last page needs to be partially zeroed */ 1051 if (to != PAGE_CACHE_SIZE) { /* Last page needs to be partially zeroed */
1050 char *kaddr = 1052 char *kaddr =
@@ -1052,6 +1054,7 @@ static int reiserfs_prepare_file_region_for_write(struct inode *inode
1052 KM_USER0); 1054 KM_USER0);
1053 memset(kaddr + to, 0, PAGE_CACHE_SIZE - to); 1055 memset(kaddr + to, 0, PAGE_CACHE_SIZE - to);
1054 kunmap_atomic(kaddr, KM_USER0); 1056 kunmap_atomic(kaddr, KM_USER0);
1057 flush_dcache_page(prepared_pages[num_pages - 1]);
1055 } 1058 }
1056 1059
1057 /* Since all blocks are new - use already calculated value */ 1060 /* Since all blocks are new - use already calculated value */
@@ -1185,6 +1188,7 @@ static int reiserfs_prepare_file_region_for_write(struct inode *inode
1185 memset(kaddr + block_start, 0, 1188 memset(kaddr + block_start, 0,
1186 from - block_start); 1189 from - block_start);
1187 kunmap_atomic(kaddr, KM_USER0); 1190 kunmap_atomic(kaddr, KM_USER0);
1191 flush_dcache_page(prepared_pages[0]);
1188 set_buffer_uptodate(bh); 1192 set_buffer_uptodate(bh);
1189 } 1193 }
1190 } 1194 }
@@ -1222,6 +1226,7 @@ static int reiserfs_prepare_file_region_for_write(struct inode *inode
1222 KM_USER0); 1226 KM_USER0);
1223 memset(kaddr + to, 0, block_end - to); 1227 memset(kaddr + to, 0, block_end - to);
1224 kunmap_atomic(kaddr, KM_USER0); 1228 kunmap_atomic(kaddr, KM_USER0);
1229 flush_dcache_page(prepared_pages[num_pages - 1]);
1225 set_buffer_uptodate(bh); 1230 set_buffer_uptodate(bh);
1226 } 1231 }
1227 } 1232 }
@@ -1307,56 +1312,8 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
1307 count = MAX_NON_LFS - (unsigned long)*ppos; 1312 count = MAX_NON_LFS - (unsigned long)*ppos;
1308 } 1313 }
1309 1314
1310 if (file->f_flags & O_DIRECT) { // Direct IO needs treatment 1315 if (file->f_flags & O_DIRECT)
1311 ssize_t result, after_file_end = 0; 1316 return do_sync_write(file, buf, count, ppos);
1312 if ((*ppos + count >= inode->i_size)
1313 || (file->f_flags & O_APPEND)) {
1314 /* If we are appending a file, we need to put this savelink in here.
1315 If we will crash while doing direct io, finish_unfinished will
1316 cut the garbage from the file end. */
1317 reiserfs_write_lock(inode->i_sb);
1318 err =
1319 journal_begin(&th, inode->i_sb,
1320 JOURNAL_PER_BALANCE_CNT);
1321 if (err) {
1322 reiserfs_write_unlock(inode->i_sb);
1323 return err;
1324 }
1325 reiserfs_update_inode_transaction(inode);
1326 add_save_link(&th, inode, 1 /* Truncate */ );
1327 after_file_end = 1;
1328 err =
1329 journal_end(&th, inode->i_sb,
1330 JOURNAL_PER_BALANCE_CNT);
1331 reiserfs_write_unlock(inode->i_sb);
1332 if (err)
1333 return err;
1334 }
1335 result = do_sync_write(file, buf, count, ppos);
1336
1337 if (after_file_end) { /* Now update i_size and remove the savelink */
1338 struct reiserfs_transaction_handle th;
1339 reiserfs_write_lock(inode->i_sb);
1340 err = journal_begin(&th, inode->i_sb, 1);
1341 if (err) {
1342 reiserfs_write_unlock(inode->i_sb);
1343 return err;
1344 }
1345 reiserfs_update_inode_transaction(inode);
1346 mark_inode_dirty(inode);
1347 err = journal_end(&th, inode->i_sb, 1);
1348 if (err) {
1349 reiserfs_write_unlock(inode->i_sb);
1350 return err;
1351 }
1352 err = remove_save_link(inode, 1 /* truncate */ );
1353 reiserfs_write_unlock(inode->i_sb);
1354 if (err)
1355 return err;
1356 }
1357
1358 return result;
1359 }
1360 1317
1361 if (unlikely((ssize_t) count < 0)) 1318 if (unlikely((ssize_t) count < 0))
1362 return -EINVAL; 1319 return -EINVAL;
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 9c69bcacad22..254239e6f9e3 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -216,11 +216,12 @@ static int file_capable(struct inode *inode, long block)
216 BUG_ON(!th->t_trans_id); 216 BUG_ON(!th->t_trans_id);
217 BUG_ON(!th->t_refcount); 217 BUG_ON(!th->t_refcount);
218 218
219 pathrelse(path);
220
219 /* we cannot restart while nested */ 221 /* we cannot restart while nested */
220 if (th->t_refcount > 1) { 222 if (th->t_refcount > 1) {
221 return 0; 223 return 0;
222 } 224 }
223 pathrelse(path);
224 reiserfs_update_sd(th, inode); 225 reiserfs_update_sd(th, inode);
225 err = journal_end(th, s, len); 226 err = journal_end(th, s, len);
226 if (!err) { 227 if (!err) {
@@ -928,15 +929,12 @@ int reiserfs_get_block(struct inode *inode, sector_t block,
928 if (blocks_needed == 1) { 929 if (blocks_needed == 1) {
929 un = &unf_single; 930 un = &unf_single;
930 } else { 931 } else {
931 un = kmalloc(min(blocks_needed, max_to_insert) * UNFM_P_SIZE, GFP_ATOMIC); // We need to avoid scheduling. 932 un = kzalloc(min(blocks_needed, max_to_insert) * UNFM_P_SIZE, GFP_ATOMIC); // We need to avoid scheduling.
932 if (!un) { 933 if (!un) {
933 un = &unf_single; 934 un = &unf_single;
934 blocks_needed = 1; 935 blocks_needed = 1;
935 max_to_insert = 0; 936 max_to_insert = 0;
936 } else 937 }
937 memset(un, 0,
938 UNFM_P_SIZE * min(blocks_needed,
939 max_to_insert));
940 } 938 }
941 if (blocks_needed <= max_to_insert) { 939 if (blocks_needed <= max_to_insert) {
942 /* we are going to add target block to the file. Use allocated 940 /* we are going to add target block to the file. Use allocated
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index ac93174c9639..7280a23ef344 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -104,7 +104,7 @@ static int release_journal_dev(struct super_block *super,
104 struct reiserfs_journal *journal); 104 struct reiserfs_journal *journal);
105static int dirty_one_transaction(struct super_block *s, 105static int dirty_one_transaction(struct super_block *s,
106 struct reiserfs_journal_list *jl); 106 struct reiserfs_journal_list *jl);
107static void flush_async_commits(void *p); 107static void flush_async_commits(struct work_struct *work);
108static void queue_log_writer(struct super_block *s); 108static void queue_log_writer(struct super_block *s);
109 109
110/* values for join in do_journal_begin_r */ 110/* values for join in do_journal_begin_r */
@@ -2836,7 +2836,8 @@ int journal_init(struct super_block *p_s_sb, const char *j_dev_name,
2836 if (reiserfs_mounted_fs_count <= 1) 2836 if (reiserfs_mounted_fs_count <= 1)
2837 commit_wq = create_workqueue("reiserfs"); 2837 commit_wq = create_workqueue("reiserfs");
2838 2838
2839 INIT_WORK(&journal->j_work, flush_async_commits, p_s_sb); 2839 INIT_DELAYED_WORK(&journal->j_work, flush_async_commits);
2840 journal->j_work_sb = p_s_sb;
2840 return 0; 2841 return 0;
2841 free_and_return: 2842 free_and_return:
2842 free_journal_ram(p_s_sb); 2843 free_journal_ram(p_s_sb);
@@ -3447,10 +3448,11 @@ int journal_end_sync(struct reiserfs_transaction_handle *th,
3447/* 3448/*
3448** writeback the pending async commits to disk 3449** writeback the pending async commits to disk
3449*/ 3450*/
3450static void flush_async_commits(void *p) 3451static void flush_async_commits(struct work_struct *work)
3451{ 3452{
3452 struct super_block *p_s_sb = p; 3453 struct reiserfs_journal *journal =
3453 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 3454 container_of(work, struct reiserfs_journal, j_work.work);
3455 struct super_block *p_s_sb = journal->j_work_sb;
3454 struct reiserfs_journal_list *jl; 3456 struct reiserfs_journal_list *jl;
3455 struct list_head *entry; 3457 struct list_head *entry;
3456 3458
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 17249994110f..7fb5fb036f90 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -490,13 +490,13 @@ static void reiserfs_put_super(struct super_block *s)
490 return; 490 return;
491} 491}
492 492
493static kmem_cache_t *reiserfs_inode_cachep; 493static struct kmem_cache *reiserfs_inode_cachep;
494 494
495static struct inode *reiserfs_alloc_inode(struct super_block *sb) 495static struct inode *reiserfs_alloc_inode(struct super_block *sb)
496{ 496{
497 struct reiserfs_inode_info *ei; 497 struct reiserfs_inode_info *ei;
498 ei = (struct reiserfs_inode_info *) 498 ei = (struct reiserfs_inode_info *)
499 kmem_cache_alloc(reiserfs_inode_cachep, SLAB_KERNEL); 499 kmem_cache_alloc(reiserfs_inode_cachep, GFP_KERNEL);
500 if (!ei) 500 if (!ei)
501 return NULL; 501 return NULL;
502 return &ei->vfs_inode; 502 return &ei->vfs_inode;
@@ -507,7 +507,7 @@ static void reiserfs_destroy_inode(struct inode *inode)
507 kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode)); 507 kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode));
508} 508}
509 509
510static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags) 510static void init_once(void *foo, struct kmem_cache * cachep, unsigned long flags)
511{ 511{
512 struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo; 512 struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo;
513 513
@@ -1549,13 +1549,12 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1549 struct reiserfs_sb_info *sbi; 1549 struct reiserfs_sb_info *sbi;
1550 int errval = -EINVAL; 1550 int errval = -EINVAL;
1551 1551
1552 sbi = kmalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL); 1552 sbi = kzalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL);
1553 if (!sbi) { 1553 if (!sbi) {
1554 errval = -ENOMEM; 1554 errval = -ENOMEM;
1555 goto error; 1555 goto error;
1556 } 1556 }
1557 s->s_fs_info = sbi; 1557 s->s_fs_info = sbi;
1558 memset(sbi, 0, sizeof(struct reiserfs_sb_info));
1559 /* Set default values for options: non-aggressive tails, RO on errors */ 1558 /* Set default values for options: non-aggressive tails, RO on errors */
1560 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL); 1559 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL);
1561 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ERROR_RO); 1560 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ERROR_RO);
diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c
index ddcd9e1ef282..c5af088d4a4c 100644
--- a/fs/romfs/inode.c
+++ b/fs/romfs/inode.c
@@ -550,12 +550,12 @@ romfs_read_inode(struct inode *i)
550 } 550 }
551} 551}
552 552
553static kmem_cache_t * romfs_inode_cachep; 553static struct kmem_cache * romfs_inode_cachep;
554 554
555static struct inode *romfs_alloc_inode(struct super_block *sb) 555static struct inode *romfs_alloc_inode(struct super_block *sb)
556{ 556{
557 struct romfs_inode_info *ei; 557 struct romfs_inode_info *ei;
558 ei = (struct romfs_inode_info *)kmem_cache_alloc(romfs_inode_cachep, SLAB_KERNEL); 558 ei = (struct romfs_inode_info *)kmem_cache_alloc(romfs_inode_cachep, GFP_KERNEL);
559 if (!ei) 559 if (!ei)
560 return NULL; 560 return NULL;
561 return &ei->vfs_inode; 561 return &ei->vfs_inode;
@@ -566,7 +566,7 @@ static void romfs_destroy_inode(struct inode *inode)
566 kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode)); 566 kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode));
567} 567}
568 568
569static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 569static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
570{ 570{
571 struct romfs_inode_info *ei = (struct romfs_inode_info *) foo; 571 struct romfs_inode_info *ei = (struct romfs_inode_info *) foo;
572 572
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 555b9ac04c25..10690aa401c7 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -26,7 +26,7 @@
26 * ERR_PTR(error). In the end of sequence they return %NULL. ->show() 26 * ERR_PTR(error). In the end of sequence they return %NULL. ->show()
27 * returns 0 in case of success and negative number in case of error. 27 * returns 0 in case of success and negative number in case of error.
28 */ 28 */
29int seq_open(struct file *file, struct seq_operations *op) 29int seq_open(struct file *file, const struct seq_operations *op)
30{ 30{
31 struct seq_file *p = file->private_data; 31 struct seq_file *p = file->private_data;
32 32
@@ -408,7 +408,7 @@ EXPORT_SYMBOL(single_open);
408 408
409int single_release(struct inode *inode, struct file *file) 409int single_release(struct inode *inode, struct file *file)
410{ 410{
411 struct seq_operations *op = ((struct seq_file *)file->private_data)->op; 411 const struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
412 int res = seq_release(inode, file); 412 int res = seq_release(inode, file);
413 kfree(op); 413 kfree(op);
414 return res; 414 return res;
diff --git a/fs/smbfs/inode.c b/fs/smbfs/inode.c
index 2c122ee83adb..4af4cd729a5a 100644
--- a/fs/smbfs/inode.c
+++ b/fs/smbfs/inode.c
@@ -50,12 +50,12 @@ static void smb_put_super(struct super_block *);
50static int smb_statfs(struct dentry *, struct kstatfs *); 50static int smb_statfs(struct dentry *, struct kstatfs *);
51static int smb_show_options(struct seq_file *, struct vfsmount *); 51static int smb_show_options(struct seq_file *, struct vfsmount *);
52 52
53static kmem_cache_t *smb_inode_cachep; 53static struct kmem_cache *smb_inode_cachep;
54 54
55static struct inode *smb_alloc_inode(struct super_block *sb) 55static struct inode *smb_alloc_inode(struct super_block *sb)
56{ 56{
57 struct smb_inode_info *ei; 57 struct smb_inode_info *ei;
58 ei = (struct smb_inode_info *)kmem_cache_alloc(smb_inode_cachep, SLAB_KERNEL); 58 ei = (struct smb_inode_info *)kmem_cache_alloc(smb_inode_cachep, GFP_KERNEL);
59 if (!ei) 59 if (!ei)
60 return NULL; 60 return NULL;
61 return &ei->vfs_inode; 61 return &ei->vfs_inode;
@@ -66,7 +66,7 @@ static void smb_destroy_inode(struct inode *inode)
66 kmem_cache_free(smb_inode_cachep, SMB_I(inode)); 66 kmem_cache_free(smb_inode_cachep, SMB_I(inode));
67} 67}
68 68
69static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 69static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
70{ 70{
71 struct smb_inode_info *ei = (struct smb_inode_info *) foo; 71 struct smb_inode_info *ei = (struct smb_inode_info *) foo;
72 unsigned long flagmask = SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR; 72 unsigned long flagmask = SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR;
diff --git a/fs/smbfs/request.c b/fs/smbfs/request.c
index 0fb74697abc4..a4bcae8a9aff 100644
--- a/fs/smbfs/request.c
+++ b/fs/smbfs/request.c
@@ -25,7 +25,7 @@
25#define ROUND_UP(x) (((x)+3) & ~3) 25#define ROUND_UP(x) (((x)+3) & ~3)
26 26
27/* cache for request structures */ 27/* cache for request structures */
28static kmem_cache_t *req_cachep; 28static struct kmem_cache *req_cachep;
29 29
30static int smb_request_send_req(struct smb_request *req); 30static int smb_request_send_req(struct smb_request *req);
31 31
@@ -61,7 +61,7 @@ static struct smb_request *smb_do_alloc_request(struct smb_sb_info *server,
61 struct smb_request *req; 61 struct smb_request *req;
62 unsigned char *buf = NULL; 62 unsigned char *buf = NULL;
63 63
64 req = kmem_cache_alloc(req_cachep, SLAB_KERNEL); 64 req = kmem_cache_alloc(req_cachep, GFP_KERNEL);
65 VERBOSE("allocating request: %p\n", req); 65 VERBOSE("allocating request: %p\n", req);
66 if (!req) 66 if (!req)
67 goto out; 67 goto out;
diff --git a/fs/stat.c b/fs/stat.c
index bca07eb2003c..a0ebfc7f8a64 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -51,13 +51,6 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
51 return inode->i_op->getattr(mnt, dentry, stat); 51 return inode->i_op->getattr(mnt, dentry, stat);
52 52
53 generic_fillattr(inode, stat); 53 generic_fillattr(inode, stat);
54 if (!stat->blksize) {
55 struct super_block *s = inode->i_sb;
56 unsigned blocks;
57 blocks = (stat->size+s->s_blocksize-1) >> s->s_blocksize_bits;
58 stat->blocks = (s->s_blocksize / 512) * blocks;
59 stat->blksize = s->s_blocksize;
60 }
61 return 0; 54 return 0;
62} 55}
63 56
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 20551a1b8a56..e503f858fba8 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -16,7 +16,7 @@
16 16
17struct vfsmount *sysfs_mount; 17struct vfsmount *sysfs_mount;
18struct super_block * sysfs_sb = NULL; 18struct super_block * sysfs_sb = NULL;
19kmem_cache_t *sysfs_dir_cachep; 19struct kmem_cache *sysfs_dir_cachep;
20 20
21static struct super_operations sysfs_ops = { 21static struct super_operations sysfs_ops = {
22 .statfs = simple_statfs, 22 .statfs = simple_statfs,
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 6f3d6bd52887..bd7cec295dab 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -1,6 +1,6 @@
1 1
2extern struct vfsmount * sysfs_mount; 2extern struct vfsmount * sysfs_mount;
3extern kmem_cache_t *sysfs_dir_cachep; 3extern struct kmem_cache *sysfs_dir_cachep;
4 4
5extern struct inode * sysfs_new_inode(mode_t mode, struct sysfs_dirent *); 5extern struct inode * sysfs_new_inode(mode_t mode, struct sysfs_dirent *);
6extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *)); 6extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *));
diff --git a/fs/sysv/CHANGES b/fs/sysv/CHANGES
deleted file mode 100644
index 66ea6e92be66..000000000000
--- a/fs/sysv/CHANGES
+++ /dev/null
@@ -1,60 +0,0 @@
1Mon, 15 Dec 1997 Krzysztof G. Baranowski <kgb@manjak.knm.org.pl>
2 * namei.c: struct sysv_dir_inode_operations updated to use dentries.
3
4Fri, 23 Jan 1998 Krzysztof G. Baranowski <kgb@manjak.knm.org.pl>
5 * inode.c: corrected 1 track offset setting (in sb->sv_block_base).
6 Originally it was overridden (by setting to zero)
7 in detected_[xenix,sysv4,sysv2,coherent]. Thanks
8 to Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl>
9 for identifying the problem.
10
11Tue, 27 Jan 1998 Krzysztof G. Baranowski <kgb@manjak.knm.org.pl>
12 * inode.c: added 2048-byte block support to SystemV FS.
13 Merged detected_bs[512,1024,2048]() into one function:
14 void detected_bs (u_char type, struct super_block *sb).
15 Thanks to Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl>
16 for the patch.
17
18Wed, 4 Feb 1998 Krzysztof G. Baranowski <kgb@manjak.knm.org.pl>
19 * namei.c: removed static subdir(); is_subdir() from dcache.c
20 is used instead. Cosmetic changes.
21
22Thu, 3 Dec 1998 Al Viro (viro@parcelfarce.linux.theplanet.co.uk)
23 * namei.c (sysv_rmdir):
24 Bugectomy: old check for victim being busy
25 (inode->i_count) wasn't replaced (with checking
26 dentry->d_count) and escaped Linus in the last round
27 of changes. Shot and buried.
28
29Wed, 9 Dec 1998 AV
30 * namei.c (do_sysv_rename):
31 Fixed incorrect check for other owners + race.
32 Removed checks that went to VFS.
33 * namei.c (sysv_unlink):
34 Removed checks that went to VFS.
35
36Thu, 10 Dec 1998 AV
37 * namei.c (do_mknod):
38 Removed dead code - mknod is never asked to
39 create a symlink or directory. Incidentially,
40 it wouldn't do it right if it would be called.
41
42Sat, 26 Dec 1998 KGB
43 * inode.c (detect_sysv4):
44 Added detection of expanded s_type field (0x10,
45 0x20 and 0x30). Forced read-only access in this case.
46
47Sun, 21 Mar 1999 AV
48 * namei.c (sysv_link):
49 Fixed i_count usage that resulted in dcache corruption.
50 * inode.c:
51 Filled ->delete_inode() method with sysv_delete_inode().
52 sysv_put_inode() is gone, as it tried to do ->delete_
53 _inode()'s job.
54 * ialloc.c: (sysv_free_inode):
55 Fixed race.
56
57Sun, 30 Apr 1999 AV
58 * namei.c (sysv_mknod):
59 Removed dead code (S_IFREG case is now passed to
60 ->create() by VFS).
diff --git a/fs/sysv/ChangeLog b/fs/sysv/ChangeLog
deleted file mode 100644
index f403f8b91b80..000000000000
--- a/fs/sysv/ChangeLog
+++ /dev/null
@@ -1,106 +0,0 @@
1Thu Feb 14 2002 Andrew Morton <akpm@zip.com.au>
2
3 * dir_commit_chunk(): call writeout_one_page() as well as
4 waitfor_one_page() for IS_SYNC directories, so that we
5 actually do sync the directory. (forward-port from 2.4).
6
7Thu Feb 7 2002 Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
8
9 * super.c: switched to ->get_sb()
10 * ChangeLog: fixed dates ;-)
11
122002-01-24 David S. Miller <davem@redhat.com>
13
14 * inode.c: Include linux/init.h
15
16Mon Jan 21 2002 Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
17 * ialloc.c (sysv_new_inode): zero SYSV_I(inode)->i_data out.
18 * i_vnode renamed to vfs_inode. Sorry, but let's keep that
19 consistent.
20
21Sat Jan 19 2002 Christoph Hellwig <hch@infradead.org>
22
23 * include/linux/sysv_fs.h (SYSV_I): Get fs-private inode data using
24 list_entry() instead of inode->u.
25 * include/linux/sysv_fs_i.h: Add 'struct inode i_vnode' field to
26 sysv_inode_info structure.
27 * inode.c: Include <linux/slab.h>, implement alloc_inode/destroy_inode
28 sop methods, add infrastructure for per-fs inode slab cache.
29 * super.c (init_sysv_fs): Initialize inode cache, recover properly
30 in the case of failed register_filesystem for V7.
31 (exit_sysv_fs): Destroy inode cache.
32
33Sat Jan 19 2002 Christoph Hellwig <hch@infradead.org>
34
35 * include/linux/sysv_fs.h: Include <linux/sysv_fs_i.h>, declare SYSV_I().
36 * dir.c (sysv_find_entry): Use SYSV_I() instead of ->u.sysv_i to
37 access fs-private inode data.
38 * ialloc.c (sysv_new_inode): Likewise.
39 * inode.c (sysv_read_inode): Likewise.
40 (sysv_update_inode): Likewise.
41 * itree.c (get_branch): Likewise.
42 (sysv_truncate): Likewise.
43 * symlink.c (sysv_readlink): Likewise.
44 (sysv_follow_link): Likewise.
45
46Fri Jan 4 2002 Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
47
48 * ialloc.c (sysv_free_inode): Use sb->s_id instead of bdevname().
49 * inode.c (sysv_read_inode): Likewise.
50 (sysv_update_inode): Likewise.
51 (sysv_sync_inode): Likewise.
52 * super.c (detect_sysv): Likewise.
53 (complete_read_super): Likewise.
54 (sysv_read_super): Likewise.
55 (v7_read_super): Likewise.
56
57Sun Dec 30 2001 Manfred Spraul <manfred@colorfullife.com>
58
59 * dir.c (dir_commit_chunk): Do not set dir->i_version.
60 (sysv_readdir): Likewise.
61
62Thu Dec 27 2001 Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
63
64 * itree.c (get_block): Use map_bh() to fill out bh_result.
65
66Tue Dec 25 2001 Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
67
68 * super.c (sysv_read_super): Use sb_set_blocksize() to set blocksize.
69 (v7_read_super): Likewise.
70
71Tue Nov 27 2001 Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
72
73 * itree.c (get_block): Change type for iblock argument to sector_t.
74 * super.c (sysv_read_super): Set s_blocksize early.
75 (v7_read_super): Likewise.
76 * balloc.c (sysv_new_block): Use sb_bread(). instead of bread().
77 (sysv_count_free_blocks): Likewise.
78 * ialloc.c (sysv_raw_inode): Likewise.
79 * itree.c (get_branch): Likewise.
80 (free_branches): Likewise.
81 * super.c (sysv_read_super): Likewise.
82 (v7_read_super): Likewise.
83
84Sat Dec 15 2001 Christoph Hellwig <hch@infradead.org>
85
86 * inode.c (sysv_read_inode): Mark inode as bad in case of failure.
87 * super.c (complete_read_super): Check for bad root inode.
88
89Wed Nov 21 2001 Andrew Morton <andrewm@uow.edu.au>
90
91 * file.c (sysv_sync_file): Call fsync_inode_data_buffers.
92
93Fri Oct 26 2001 Christoph Hellwig <hch@infradead.org>
94
95 * dir.c, ialloc.c, namei.c, include/linux/sysv_fs_i.h:
96 Implement per-Inode lookup offset cache.
97 Modelled after Ted's ext2 patch.
98
99Fri Oct 26 2001 Christoph Hellwig <hch@infradead.org>
100
101 * inode.c, super.c, include/linux/sysv_fs.h,
102 include/linux/sysv_fs_sb.h:
103 Remove symlink faking. Noone really wants to use these as
104 linux filesystems and native OSes don't support it anyway.
105
106
diff --git a/fs/sysv/INTRO b/fs/sysv/INTRO
deleted file mode 100644
index de4e4d17cac6..000000000000
--- a/fs/sysv/INTRO
+++ /dev/null
@@ -1,182 +0,0 @@
1This is the implementation of the SystemV/Coherent filesystem for Linux.
2It grew out of separate filesystem implementations
3
4 Xenix FS Doug Evans <dje@cygnus.com> June 1992
5 SystemV FS Paul B. Monday <pmonday@eecs.wsu.edu> March-June 1993
6 Coherent FS B. Haible <haible@ma2s2.mathematik.uni-karlsruhe.de> June 1993
7
8and was merged together in July 1993.
9
10These filesystems are rather similar. Here is a comparison with Minix FS:
11
12* Linux fdisk reports on partitions
13 - Minix FS 0x81 Linux/Minix
14 - Xenix FS ??
15 - SystemV FS ??
16 - Coherent FS 0x08 AIX bootable
17
18* Size of a block or zone (data allocation unit on disk)
19 - Minix FS 1024
20 - Xenix FS 1024 (also 512 ??)
21 - SystemV FS 1024 (also 512 and 2048)
22 - Coherent FS 512
23
24* General layout: all have one boot block, one super block and
25 separate areas for inodes and for directories/data.
26 On SystemV Release 2 FS (e.g. Microport) the first track is reserved and
27 all the block numbers (including the super block) are offset by one track.
28
29* Byte ordering of "short" (16 bit entities) on disk:
30 - Minix FS little endian 0 1
31 - Xenix FS little endian 0 1
32 - SystemV FS little endian 0 1
33 - Coherent FS little endian 0 1
34 Of course, this affects only the file system, not the data of files on it!
35
36* Byte ordering of "long" (32 bit entities) on disk:
37 - Minix FS little endian 0 1 2 3
38 - Xenix FS little endian 0 1 2 3
39 - SystemV FS little endian 0 1 2 3
40 - Coherent FS PDP-11 2 3 0 1
41 Of course, this affects only the file system, not the data of files on it!
42
43* Inode on disk: "short", 0 means non-existent, the root dir ino is:
44 - Minix FS 1
45 - Xenix FS, SystemV FS, Coherent FS 2
46
47* Maximum number of hard links to a file:
48 - Minix FS 250
49 - Xenix FS ??
50 - SystemV FS ??
51 - Coherent FS >=10000
52
53* Free inode management:
54 - Minix FS a bitmap
55 - Xenix FS, SystemV FS, Coherent FS
56 There is a cache of a certain number of free inodes in the super-block.
57 When it is exhausted, new free inodes are found using a linear search.
58
59* Free block management:
60 - Minix FS a bitmap
61 - Xenix FS, SystemV FS, Coherent FS
62 Free blocks are organized in a "free list". Maybe a misleading term,
63 since it is not true that every free block contains a pointer to
64 the next free block. Rather, the free blocks are organized in chunks
65 of limited size, and every now and then a free block contains pointers
66 to the free blocks pertaining to the next chunk; the first of these
67 contains pointers and so on. The list terminates with a "block number"
68 0 on Xenix FS and SystemV FS, with a block zeroed out on Coherent FS.
69
70* Super-block location:
71 - Minix FS block 1 = bytes 1024..2047
72 - Xenix FS block 1 = bytes 1024..2047
73 - SystemV FS bytes 512..1023
74 - Coherent FS block 1 = bytes 512..1023
75
76* Super-block layout:
77 - Minix FS
78 unsigned short s_ninodes;
79 unsigned short s_nzones;
80 unsigned short s_imap_blocks;
81 unsigned short s_zmap_blocks;
82 unsigned short s_firstdatazone;
83 unsigned short s_log_zone_size;
84 unsigned long s_max_size;
85 unsigned short s_magic;
86 - Xenix FS, SystemV FS, Coherent FS
87 unsigned short s_firstdatazone;
88 unsigned long s_nzones;
89 unsigned short s_fzone_count;
90 unsigned long s_fzones[NICFREE];
91 unsigned short s_finode_count;
92 unsigned short s_finodes[NICINOD];
93 char s_flock;
94 char s_ilock;
95 char s_modified;
96 char s_rdonly;
97 unsigned long s_time;
98 short s_dinfo[4]; -- SystemV FS only
99 unsigned long s_free_zones;
100 unsigned short s_free_inodes;
101 short s_dinfo[4]; -- Xenix FS only
102 unsigned short s_interleave_m,s_interleave_n; -- Coherent FS only
103 char s_fname[6];
104 char s_fpack[6];
105 then they differ considerably:
106 Xenix FS
107 char s_clean;
108 char s_fill[371];
109 long s_magic;
110 long s_type;
111 SystemV FS
112 long s_fill[12 or 14];
113 long s_state;
114 long s_magic;
115 long s_type;
116 Coherent FS
117 unsigned long s_unique;
118 Note that Coherent FS has no magic.
119
120* Inode layout:
121 - Minix FS
122 unsigned short i_mode;
123 unsigned short i_uid;
124 unsigned long i_size;
125 unsigned long i_time;
126 unsigned char i_gid;
127 unsigned char i_nlinks;
128 unsigned short i_zone[7+1+1];
129 - Xenix FS, SystemV FS, Coherent FS
130 unsigned short i_mode;
131 unsigned short i_nlink;
132 unsigned short i_uid;
133 unsigned short i_gid;
134 unsigned long i_size;
135 unsigned char i_zone[3*(10+1+1+1)];
136 unsigned long i_atime;
137 unsigned long i_mtime;
138 unsigned long i_ctime;
139
140* Regular file data blocks are organized as
141 - Minix FS
142 7 direct blocks
143 1 indirect block (pointers to blocks)
144 1 double-indirect block (pointer to pointers to blocks)
145 - Xenix FS, SystemV FS, Coherent FS
146 10 direct blocks
147 1 indirect block (pointers to blocks)
148 1 double-indirect block (pointer to pointers to blocks)
149 1 triple-indirect block (pointer to pointers to pointers to blocks)
150
151* Inode size, inodes per block
152 - Minix FS 32 32
153 - Xenix FS 64 16
154 - SystemV FS 64 16
155 - Coherent FS 64 8
156
157* Directory entry on disk
158 - Minix FS
159 unsigned short inode;
160 char name[14/30];
161 - Xenix FS, SystemV FS, Coherent FS
162 unsigned short inode;
163 char name[14];
164
165* Dir entry size, dir entries per block
166 - Minix FS 16/32 64/32
167 - Xenix FS 16 64
168 - SystemV FS 16 64
169 - Coherent FS 16 32
170
171* How to implement symbolic links such that the host fsck doesn't scream:
172 - Minix FS normal
173 - Xenix FS kludge: as regular files with chmod 1000
174 - SystemV FS ??
175 - Coherent FS kludge: as regular files with chmod 1000
176
177
178Notation: We often speak of a "block" but mean a zone (the allocation unit)
179and not the disk driver's notion of "block".
180
181
182Bruno Haible <haible@ma2s2.mathematik.uni-karlsruhe.de>
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index d63c5e48b050..ead9864567e3 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -301,13 +301,13 @@ static void sysv_delete_inode(struct inode *inode)
301 unlock_kernel(); 301 unlock_kernel();
302} 302}
303 303
304static kmem_cache_t *sysv_inode_cachep; 304static struct kmem_cache *sysv_inode_cachep;
305 305
306static struct inode *sysv_alloc_inode(struct super_block *sb) 306static struct inode *sysv_alloc_inode(struct super_block *sb)
307{ 307{
308 struct sysv_inode_info *si; 308 struct sysv_inode_info *si;
309 309
310 si = kmem_cache_alloc(sysv_inode_cachep, SLAB_KERNEL); 310 si = kmem_cache_alloc(sysv_inode_cachep, GFP_KERNEL);
311 if (!si) 311 if (!si)
312 return NULL; 312 return NULL;
313 return &si->vfs_inode; 313 return &si->vfs_inode;
@@ -318,7 +318,7 @@ static void sysv_destroy_inode(struct inode *inode)
318 kmem_cache_free(sysv_inode_cachep, SYSV_I(inode)); 318 kmem_cache_free(sysv_inode_cachep, SYSV_I(inode));
319} 319}
320 320
321static void init_once(void *p, kmem_cache_t *cachep, unsigned long flags) 321static void init_once(void *p, struct kmem_cache *cachep, unsigned long flags)
322{ 322{
323 struct sysv_inode_info *si = (struct sysv_inode_info *)p; 323 struct sysv_inode_info *si = (struct sysv_inode_info *)p;
324 324
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 1aea6a4f9a4a..1dbc2955f02e 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -107,12 +107,12 @@ static struct file_system_type udf_fstype = {
107 .fs_flags = FS_REQUIRES_DEV, 107 .fs_flags = FS_REQUIRES_DEV,
108}; 108};
109 109
110static kmem_cache_t * udf_inode_cachep; 110static struct kmem_cache * udf_inode_cachep;
111 111
112static struct inode *udf_alloc_inode(struct super_block *sb) 112static struct inode *udf_alloc_inode(struct super_block *sb)
113{ 113{
114 struct udf_inode_info *ei; 114 struct udf_inode_info *ei;
115 ei = (struct udf_inode_info *)kmem_cache_alloc(udf_inode_cachep, SLAB_KERNEL); 115 ei = (struct udf_inode_info *)kmem_cache_alloc(udf_inode_cachep, GFP_KERNEL);
116 if (!ei) 116 if (!ei)
117 return NULL; 117 return NULL;
118 118
@@ -130,7 +130,7 @@ static void udf_destroy_inode(struct inode *inode)
130 kmem_cache_free(udf_inode_cachep, UDF_I(inode)); 130 kmem_cache_free(udf_inode_cachep, UDF_I(inode));
131} 131}
132 132
133static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 133static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
134{ 134{
135 struct udf_inode_info *ei = (struct udf_inode_info *) foo; 135 struct udf_inode_info *ei = (struct udf_inode_info *) foo;
136 136
@@ -1709,7 +1709,7 @@ void udf_error(struct super_block *sb, const char *function,
1709 sb->s_dirt = 1; 1709 sb->s_dirt = 1;
1710 } 1710 }
1711 va_start(args, fmt); 1711 va_start(args, fmt);
1712 vsprintf(error_buf, fmt, args); 1712 vsnprintf(error_buf, sizeof(error_buf), fmt, args);
1713 va_end(args); 1713 va_end(args);
1714 printk (KERN_CRIT "UDF-fs error (device %s): %s: %s\n", 1714 printk (KERN_CRIT "UDF-fs error (device %s): %s: %s\n",
1715 sb->s_id, function, error_buf); 1715 sb->s_id, function, error_buf);
@@ -1721,7 +1721,7 @@ void udf_warning(struct super_block *sb, const char *function,
1721 va_list args; 1721 va_list args;
1722 1722
1723 va_start (args, fmt); 1723 va_start (args, fmt);
1724 vsprintf(error_buf, fmt, args); 1724 vsnprintf(error_buf, sizeof(error_buf), fmt, args);
1725 va_end(args); 1725 va_end(args);
1726 printk(KERN_WARNING "UDF-fs warning (device %s): %s: %s\n", 1726 printk(KERN_WARNING "UDF-fs warning (device %s): %s: %s\n",
1727 sb->s_id, function, error_buf); 1727 sb->s_id, function, error_buf);
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index ec79e3091d1b..8a8e9382ec09 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -224,7 +224,7 @@ void ufs_error (struct super_block * sb, const char * function,
224 sb->s_flags |= MS_RDONLY; 224 sb->s_flags |= MS_RDONLY;
225 } 225 }
226 va_start (args, fmt); 226 va_start (args, fmt);
227 vsprintf (error_buf, fmt, args); 227 vsnprintf (error_buf, sizeof(error_buf), fmt, args);
228 va_end (args); 228 va_end (args);
229 switch (UFS_SB(sb)->s_mount_opt & UFS_MOUNT_ONERROR) { 229 switch (UFS_SB(sb)->s_mount_opt & UFS_MOUNT_ONERROR) {
230 case UFS_MOUNT_ONERROR_PANIC: 230 case UFS_MOUNT_ONERROR_PANIC:
@@ -255,7 +255,7 @@ void ufs_panic (struct super_block * sb, const char * function,
255 sb->s_dirt = 1; 255 sb->s_dirt = 1;
256 } 256 }
257 va_start (args, fmt); 257 va_start (args, fmt);
258 vsprintf (error_buf, fmt, args); 258 vsnprintf (error_buf, sizeof(error_buf), fmt, args);
259 va_end (args); 259 va_end (args);
260 sb->s_flags |= MS_RDONLY; 260 sb->s_flags |= MS_RDONLY;
261 printk (KERN_CRIT "UFS-fs panic (device %s): %s: %s\n", 261 printk (KERN_CRIT "UFS-fs panic (device %s): %s: %s\n",
@@ -268,7 +268,7 @@ void ufs_warning (struct super_block * sb, const char * function,
268 va_list args; 268 va_list args;
269 269
270 va_start (args, fmt); 270 va_start (args, fmt);
271 vsprintf (error_buf, fmt, args); 271 vsnprintf (error_buf, sizeof(error_buf), fmt, args);
272 va_end (args); 272 va_end (args);
273 printk (KERN_WARNING "UFS-fs warning (device %s): %s: %s\n", 273 printk (KERN_WARNING "UFS-fs warning (device %s): %s: %s\n",
274 sb->s_id, function, error_buf); 274 sb->s_id, function, error_buf);
@@ -1204,12 +1204,12 @@ static int ufs_statfs(struct dentry *dentry, struct kstatfs *buf)
1204 return 0; 1204 return 0;
1205} 1205}
1206 1206
1207static kmem_cache_t * ufs_inode_cachep; 1207static struct kmem_cache * ufs_inode_cachep;
1208 1208
1209static struct inode *ufs_alloc_inode(struct super_block *sb) 1209static struct inode *ufs_alloc_inode(struct super_block *sb)
1210{ 1210{
1211 struct ufs_inode_info *ei; 1211 struct ufs_inode_info *ei;
1212 ei = (struct ufs_inode_info *)kmem_cache_alloc(ufs_inode_cachep, SLAB_KERNEL); 1212 ei = (struct ufs_inode_info *)kmem_cache_alloc(ufs_inode_cachep, GFP_KERNEL);
1213 if (!ei) 1213 if (!ei)
1214 return NULL; 1214 return NULL;
1215 ei->vfs_inode.i_version = 1; 1215 ei->vfs_inode.i_version = 1;
@@ -1221,7 +1221,7 @@ static void ufs_destroy_inode(struct inode *inode)
1221 kmem_cache_free(ufs_inode_cachep, UFS_I(inode)); 1221 kmem_cache_free(ufs_inode_cachep, UFS_I(inode));
1222} 1222}
1223 1223
1224static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 1224static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
1225{ 1225{
1226 struct ufs_inode_info *ei = (struct ufs_inode_info *) foo; 1226 struct ufs_inode_info *ei = (struct ufs_inode_info *) foo;
1227 1227
diff --git a/fs/ufs/util.h b/fs/ufs/util.h
index 28fce6c239b5..7dd12bb1d62b 100644
--- a/fs/ufs/util.h
+++ b/fs/ufs/util.h
@@ -299,7 +299,7 @@ static inline void *get_usb_offset(struct ufs_sb_private_info *uspi,
299 299
300#define ubh_get_addr16(ubh,begin) \ 300#define ubh_get_addr16(ubh,begin) \
301 (((__fs16*)((ubh)->bh[(begin) >> (uspi->s_fshift-1)]->b_data)) + \ 301 (((__fs16*)((ubh)->bh[(begin) >> (uspi->s_fshift-1)]->b_data)) + \
302 ((begin) & (uspi->fsize>>1) - 1))) 302 ((begin) & ((uspi->fsize>>1) - 1)))
303 303
304#define ubh_get_addr32(ubh,begin) \ 304#define ubh_get_addr32(ubh,begin) \
305 (((__fs32*)((ubh)->bh[(begin) >> (uspi->s_fshift-2)]->b_data)) + \ 305 (((__fs32*)((ubh)->bh[(begin) >> (uspi->s_fshift-2)]->b_data)) + \
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 09360cf1e1f2..8e6b56fc1cad 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -149,9 +149,10 @@ xfs_destroy_ioend(
149 */ 149 */
150STATIC void 150STATIC void
151xfs_end_bio_delalloc( 151xfs_end_bio_delalloc(
152 void *data) 152 struct work_struct *work)
153{ 153{
154 xfs_ioend_t *ioend = data; 154 xfs_ioend_t *ioend =
155 container_of(work, xfs_ioend_t, io_work);
155 156
156 xfs_destroy_ioend(ioend); 157 xfs_destroy_ioend(ioend);
157} 158}
@@ -161,9 +162,10 @@ xfs_end_bio_delalloc(
161 */ 162 */
162STATIC void 163STATIC void
163xfs_end_bio_written( 164xfs_end_bio_written(
164 void *data) 165 struct work_struct *work)
165{ 166{
166 xfs_ioend_t *ioend = data; 167 xfs_ioend_t *ioend =
168 container_of(work, xfs_ioend_t, io_work);
167 169
168 xfs_destroy_ioend(ioend); 170 xfs_destroy_ioend(ioend);
169} 171}
@@ -176,9 +178,10 @@ xfs_end_bio_written(
176 */ 178 */
177STATIC void 179STATIC void
178xfs_end_bio_unwritten( 180xfs_end_bio_unwritten(
179 void *data) 181 struct work_struct *work)
180{ 182{
181 xfs_ioend_t *ioend = data; 183 xfs_ioend_t *ioend =
184 container_of(work, xfs_ioend_t, io_work);
182 bhv_vnode_t *vp = ioend->io_vnode; 185 bhv_vnode_t *vp = ioend->io_vnode;
183 xfs_off_t offset = ioend->io_offset; 186 xfs_off_t offset = ioend->io_offset;
184 size_t size = ioend->io_size; 187 size_t size = ioend->io_size;
@@ -220,11 +223,11 @@ xfs_alloc_ioend(
220 ioend->io_size = 0; 223 ioend->io_size = 0;
221 224
222 if (type == IOMAP_UNWRITTEN) 225 if (type == IOMAP_UNWRITTEN)
223 INIT_WORK(&ioend->io_work, xfs_end_bio_unwritten, ioend); 226 INIT_WORK(&ioend->io_work, xfs_end_bio_unwritten);
224 else if (type == IOMAP_DELAY) 227 else if (type == IOMAP_DELAY)
225 INIT_WORK(&ioend->io_work, xfs_end_bio_delalloc, ioend); 228 INIT_WORK(&ioend->io_work, xfs_end_bio_delalloc);
226 else 229 else
227 INIT_WORK(&ioend->io_work, xfs_end_bio_written, ioend); 230 INIT_WORK(&ioend->io_work, xfs_end_bio_written);
228 231
229 return ioend; 232 return ioend;
230} 233}
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index d3382843698e..4fb01ffdfd1a 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -32,6 +32,7 @@
32#include <linux/kthread.h> 32#include <linux/kthread.h>
33#include <linux/migrate.h> 33#include <linux/migrate.h>
34#include <linux/backing-dev.h> 34#include <linux/backing-dev.h>
35#include <linux/freezer.h>
35 36
36STATIC kmem_zone_t *xfs_buf_zone; 37STATIC kmem_zone_t *xfs_buf_zone;
37STATIC kmem_shaker_t xfs_buf_shake; 38STATIC kmem_shaker_t xfs_buf_shake;
@@ -994,9 +995,10 @@ xfs_buf_wait_unpin(
994 995
995STATIC void 996STATIC void
996xfs_buf_iodone_work( 997xfs_buf_iodone_work(
997 void *v) 998 struct work_struct *work)
998{ 999{
999 xfs_buf_t *bp = (xfs_buf_t *)v; 1000 xfs_buf_t *bp =
1001 container_of(work, xfs_buf_t, b_iodone_work);
1000 1002
1001 if (bp->b_iodone) 1003 if (bp->b_iodone)
1002 (*(bp->b_iodone))(bp); 1004 (*(bp->b_iodone))(bp);
@@ -1017,10 +1019,10 @@ xfs_buf_ioend(
1017 1019
1018 if ((bp->b_iodone) || (bp->b_flags & XBF_ASYNC)) { 1020 if ((bp->b_iodone) || (bp->b_flags & XBF_ASYNC)) {
1019 if (schedule) { 1021 if (schedule) {
1020 INIT_WORK(&bp->b_iodone_work, xfs_buf_iodone_work, bp); 1022 INIT_WORK(&bp->b_iodone_work, xfs_buf_iodone_work);
1021 queue_work(xfslogd_workqueue, &bp->b_iodone_work); 1023 queue_work(xfslogd_workqueue, &bp->b_iodone_work);
1022 } else { 1024 } else {
1023 xfs_buf_iodone_work(bp); 1025 xfs_buf_iodone_work(&bp->b_iodone_work);
1024 } 1026 }
1025 } else { 1027 } else {
1026 up(&bp->b_iodonesema); 1028 up(&bp->b_iodonesema);
@@ -1825,11 +1827,11 @@ xfs_buf_init(void)
1825 if (!xfs_buf_zone) 1827 if (!xfs_buf_zone)
1826 goto out_free_trace_buf; 1828 goto out_free_trace_buf;
1827 1829
1828 xfslogd_workqueue = create_workqueue("xfslogd"); 1830 xfslogd_workqueue = create_freezeable_workqueue("xfslogd");
1829 if (!xfslogd_workqueue) 1831 if (!xfslogd_workqueue)
1830 goto out_free_buf_zone; 1832 goto out_free_buf_zone;
1831 1833
1832 xfsdatad_workqueue = create_workqueue("xfsdatad"); 1834 xfsdatad_workqueue = create_freezeable_workqueue("xfsdatad");
1833 if (!xfsdatad_workqueue) 1835 if (!xfsdatad_workqueue)
1834 goto out_destroy_xfslogd_workqueue; 1836 goto out_destroy_xfslogd_workqueue;
1835 1837
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index de05abbbe7fd..b93265b7c79c 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -56,6 +56,7 @@
56#include <linux/mempool.h> 56#include <linux/mempool.h>
57#include <linux/writeback.h> 57#include <linux/writeback.h>
58#include <linux/kthread.h> 58#include <linux/kthread.h>
59#include <linux/freezer.h>
59 60
60STATIC struct quotactl_ops xfs_quotactl_operations; 61STATIC struct quotactl_ops xfs_quotactl_operations;
61STATIC struct super_operations xfs_super_operations; 62STATIC struct super_operations xfs_super_operations;
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index 47faf27913a5..7f1e92930b62 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -64,7 +64,7 @@
64/* Host-dependent types and defines */ 64/* Host-dependent types and defines */
65 65
66#define ACPI_MACHINE_WIDTH BITS_PER_LONG 66#define ACPI_MACHINE_WIDTH BITS_PER_LONG
67#define acpi_cache_t kmem_cache_t 67#define acpi_cache_t struct kmem_cache
68#define acpi_spinlock spinlock_t * 68#define acpi_spinlock spinlock_t *
69#define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol); 69#define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol);
70#define strtoul simple_strtoul 70#define strtoul simple_strtoul
diff --git a/include/asm-alpha/dma-mapping.h b/include/asm-alpha/dma-mapping.h
index b9ff4d8cb33a..57e09f5e3424 100644
--- a/include/asm-alpha/dma-mapping.h
+++ b/include/asm-alpha/dma-mapping.h
@@ -51,7 +51,7 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
51 51
52#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 52#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
53#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 53#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
54#define dma_is_consistent(dev) (1) 54#define dma_is_consistent(d, h) (1)
55 55
56int dma_set_mask(struct device *dev, u64 mask); 56int dma_set_mask(struct device *dev, u64 mask);
57 57
@@ -60,7 +60,7 @@ int dma_set_mask(struct device *dev, u64 mask);
60#define dma_sync_single_range(dev, addr, off, size, dir) do { } while (0) 60#define dma_sync_single_range(dev, addr, off, size, dir) do { } while (0)
61#define dma_sync_sg_for_cpu(dev, sg, nents, dir) do { } while (0) 61#define dma_sync_sg_for_cpu(dev, sg, nents, dir) do { } while (0)
62#define dma_sync_sg_for_device(dev, sg, nents, dir) do { } while (0) 62#define dma_sync_sg_for_device(dev, sg, nents, dir) do { } while (0)
63#define dma_cache_sync(va, size, dir) do { } while (0) 63#define dma_cache_sync(dev, va, size, dir) do { } while (0)
64 64
65#define dma_get_cache_alignment() L1_CACHE_BYTES 65#define dma_get_cache_alignment() L1_CACHE_BYTES
66 66
diff --git a/include/asm-alpha/unistd.h b/include/asm-alpha/unistd.h
index 2cabbd465c0c..84313d14e780 100644
--- a/include/asm-alpha/unistd.h
+++ b/include/asm-alpha/unistd.h
@@ -387,188 +387,6 @@
387 387
388#define NR_SYSCALLS 447 388#define NR_SYSCALLS 447
389 389
390#if defined(__GNUC__)
391
392#define _syscall_return(type) \
393 return (_sc_err ? errno = _sc_ret, _sc_ret = -1L : 0), (type) _sc_ret
394
395#define _syscall_clobbers \
396 "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", \
397 "$22", "$23", "$24", "$25", "$27", "$28" \
398
399#define _syscall0(type, name) \
400type name(void) \
401{ \
402 long _sc_ret, _sc_err; \
403 { \
404 register long _sc_0 __asm__("$0"); \
405 register long _sc_19 __asm__("$19"); \
406 \
407 _sc_0 = __NR_##name; \
408 __asm__("callsys # %0 %1 %2" \
409 : "=r"(_sc_0), "=r"(_sc_19) \
410 : "0"(_sc_0) \
411 : _syscall_clobbers); \
412 _sc_ret = _sc_0, _sc_err = _sc_19; \
413 } \
414 _syscall_return(type); \
415}
416
417#define _syscall1(type,name,type1,arg1) \
418type name(type1 arg1) \
419{ \
420 long _sc_ret, _sc_err; \
421 { \
422 register long _sc_0 __asm__("$0"); \
423 register long _sc_16 __asm__("$16"); \
424 register long _sc_19 __asm__("$19"); \
425 \
426 _sc_0 = __NR_##name; \
427 _sc_16 = (long) (arg1); \
428 __asm__("callsys # %0 %1 %2 %3" \
429 : "=r"(_sc_0), "=r"(_sc_19) \
430 : "0"(_sc_0), "r"(_sc_16) \
431 : _syscall_clobbers); \
432 _sc_ret = _sc_0, _sc_err = _sc_19; \
433 } \
434 _syscall_return(type); \
435}
436
437#define _syscall2(type,name,type1,arg1,type2,arg2) \
438type name(type1 arg1,type2 arg2) \
439{ \
440 long _sc_ret, _sc_err; \
441 { \
442 register long _sc_0 __asm__("$0"); \
443 register long _sc_16 __asm__("$16"); \
444 register long _sc_17 __asm__("$17"); \
445 register long _sc_19 __asm__("$19"); \
446 \
447 _sc_0 = __NR_##name; \
448 _sc_16 = (long) (arg1); \
449 _sc_17 = (long) (arg2); \
450 __asm__("callsys # %0 %1 %2 %3 %4" \
451 : "=r"(_sc_0), "=r"(_sc_19) \
452 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17) \
453 : _syscall_clobbers); \
454 _sc_ret = _sc_0, _sc_err = _sc_19; \
455 } \
456 _syscall_return(type); \
457}
458
459#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
460type name(type1 arg1,type2 arg2,type3 arg3) \
461{ \
462 long _sc_ret, _sc_err; \
463 { \
464 register long _sc_0 __asm__("$0"); \
465 register long _sc_16 __asm__("$16"); \
466 register long _sc_17 __asm__("$17"); \
467 register long _sc_18 __asm__("$18"); \
468 register long _sc_19 __asm__("$19"); \
469 \
470 _sc_0 = __NR_##name; \
471 _sc_16 = (long) (arg1); \
472 _sc_17 = (long) (arg2); \
473 _sc_18 = (long) (arg3); \
474 __asm__("callsys # %0 %1 %2 %3 %4 %5" \
475 : "=r"(_sc_0), "=r"(_sc_19) \
476 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
477 "r"(_sc_18) \
478 : _syscall_clobbers); \
479 _sc_ret = _sc_0, _sc_err = _sc_19; \
480 } \
481 _syscall_return(type); \
482}
483
484#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
485type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
486{ \
487 long _sc_ret, _sc_err; \
488 { \
489 register long _sc_0 __asm__("$0"); \
490 register long _sc_16 __asm__("$16"); \
491 register long _sc_17 __asm__("$17"); \
492 register long _sc_18 __asm__("$18"); \
493 register long _sc_19 __asm__("$19"); \
494 \
495 _sc_0 = __NR_##name; \
496 _sc_16 = (long) (arg1); \
497 _sc_17 = (long) (arg2); \
498 _sc_18 = (long) (arg3); \
499 _sc_19 = (long) (arg4); \
500 __asm__("callsys # %0 %1 %2 %3 %4 %5 %6" \
501 : "=r"(_sc_0), "=r"(_sc_19) \
502 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
503 "r"(_sc_18), "1"(_sc_19) \
504 : _syscall_clobbers); \
505 _sc_ret = _sc_0, _sc_err = _sc_19; \
506 } \
507 _syscall_return(type); \
508}
509
510#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
511 type5,arg5) \
512type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
513{ \
514 long _sc_ret, _sc_err; \
515 { \
516 register long _sc_0 __asm__("$0"); \
517 register long _sc_16 __asm__("$16"); \
518 register long _sc_17 __asm__("$17"); \
519 register long _sc_18 __asm__("$18"); \
520 register long _sc_19 __asm__("$19"); \
521 register long _sc_20 __asm__("$20"); \
522 \
523 _sc_0 = __NR_##name; \
524 _sc_16 = (long) (arg1); \
525 _sc_17 = (long) (arg2); \
526 _sc_18 = (long) (arg3); \
527 _sc_19 = (long) (arg4); \
528 _sc_20 = (long) (arg5); \
529 __asm__("callsys # %0 %1 %2 %3 %4 %5 %6 %7" \
530 : "=r"(_sc_0), "=r"(_sc_19) \
531 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
532 "r"(_sc_18), "1"(_sc_19), "r"(_sc_20) \
533 : _syscall_clobbers); \
534 _sc_ret = _sc_0, _sc_err = _sc_19; \
535 } \
536 _syscall_return(type); \
537}
538
539#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
540 type5,arg5,type6,arg6) \
541type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6)\
542{ \
543 long _sc_ret, _sc_err; \
544 { \
545 register long _sc_0 __asm__("$0"); \
546 register long _sc_16 __asm__("$16"); \
547 register long _sc_17 __asm__("$17"); \
548 register long _sc_18 __asm__("$18"); \
549 register long _sc_19 __asm__("$19"); \
550 register long _sc_20 __asm__("$20"); \
551 register long _sc_21 __asm__("$21"); \
552 \
553 _sc_0 = __NR_##name; \
554 _sc_16 = (long) (arg1); \
555 _sc_17 = (long) (arg2); \
556 _sc_18 = (long) (arg3); \
557 _sc_19 = (long) (arg4); \
558 _sc_20 = (long) (arg5); \
559 _sc_21 = (long) (arg6); \
560 __asm__("callsys # %0 %1 %2 %3 %4 %5 %6 %7 %8" \
561 : "=r"(_sc_0), "=r"(_sc_19) \
562 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
563 "r"(_sc_18), "1"(_sc_19), "r"(_sc_20), "r"(_sc_21) \
564 : _syscall_clobbers); \
565 _sc_ret = _sc_0, _sc_err = _sc_19; \
566 } \
567 _syscall_return(type); \
568}
569
570#endif /* __GNUC__ */
571
572#define __ARCH_WANT_IPC_PARSE_VERSION 390#define __ARCH_WANT_IPC_PARSE_VERSION
573#define __ARCH_WANT_OLD_READDIR 391#define __ARCH_WANT_OLD_READDIR
574#define __ARCH_WANT_STAT64 392#define __ARCH_WANT_STAT64
diff --git a/include/asm-arm/arch-omap/irda.h b/include/asm-arm/arch-omap/irda.h
index 805ae3575e44..345a649ec838 100644
--- a/include/asm-arm/arch-omap/irda.h
+++ b/include/asm-arm/arch-omap/irda.h
@@ -24,7 +24,7 @@ struct omap_irda_config {
24 /* Very specific to the needs of some platforms (h3,h4) 24 /* Very specific to the needs of some platforms (h3,h4)
25 * having calls which can sleep in irda_set_speed. 25 * having calls which can sleep in irda_set_speed.
26 */ 26 */
27 struct work_struct gpio_expa; 27 struct delayed_work gpio_expa;
28 int rx_channel; 28 int rx_channel;
29 int tx_channel; 29 int tx_channel;
30 unsigned long dest_start; 30 unsigned long dest_start;
diff --git a/include/asm-arm/dma-mapping.h b/include/asm-arm/dma-mapping.h
index 666617711c81..9bc46b486afb 100644
--- a/include/asm-arm/dma-mapping.h
+++ b/include/asm-arm/dma-mapping.h
@@ -48,7 +48,7 @@ static inline int dma_get_cache_alignment(void)
48 return 32; 48 return 32;
49} 49}
50 50
51static inline int dma_is_consistent(dma_addr_t handle) 51static inline int dma_is_consistent(struct device *dev, dma_addr_t handle)
52{ 52{
53 return !!arch_is_coherent(); 53 return !!arch_is_coherent();
54} 54}
diff --git a/include/asm-arm/setup.h b/include/asm-arm/setup.h
index aa4b5782f0c9..e5407392afca 100644
--- a/include/asm-arm/setup.h
+++ b/include/asm-arm/setup.h
@@ -14,55 +14,57 @@
14#ifndef __ASMARM_SETUP_H 14#ifndef __ASMARM_SETUP_H
15#define __ASMARM_SETUP_H 15#define __ASMARM_SETUP_H
16 16
17#include <asm/types.h>
18
17#define COMMAND_LINE_SIZE 1024 19#define COMMAND_LINE_SIZE 1024
18 20
19/* The list ends with an ATAG_NONE node. */ 21/* The list ends with an ATAG_NONE node. */
20#define ATAG_NONE 0x00000000 22#define ATAG_NONE 0x00000000
21 23
22struct tag_header { 24struct tag_header {
23 u32 size; 25 __u32 size;
24 u32 tag; 26 __u32 tag;
25}; 27};
26 28
27/* The list must start with an ATAG_CORE node */ 29/* The list must start with an ATAG_CORE node */
28#define ATAG_CORE 0x54410001 30#define ATAG_CORE 0x54410001
29 31
30struct tag_core { 32struct tag_core {
31 u32 flags; /* bit 0 = read-only */ 33 __u32 flags; /* bit 0 = read-only */
32 u32 pagesize; 34 __u32 pagesize;
33 u32 rootdev; 35 __u32 rootdev;
34}; 36};
35 37
36/* it is allowed to have multiple ATAG_MEM nodes */ 38/* it is allowed to have multiple ATAG_MEM nodes */
37#define ATAG_MEM 0x54410002 39#define ATAG_MEM 0x54410002
38 40
39struct tag_mem32 { 41struct tag_mem32 {
40 u32 size; 42 __u32 size;
41 u32 start; /* physical start address */ 43 __u32 start; /* physical start address */
42}; 44};
43 45
44/* VGA text type displays */ 46/* VGA text type displays */
45#define ATAG_VIDEOTEXT 0x54410003 47#define ATAG_VIDEOTEXT 0x54410003
46 48
47struct tag_videotext { 49struct tag_videotext {
48 u8 x; 50 __u8 x;
49 u8 y; 51 __u8 y;
50 u16 video_page; 52 __u16 video_page;
51 u8 video_mode; 53 __u8 video_mode;
52 u8 video_cols; 54 __u8 video_cols;
53 u16 video_ega_bx; 55 __u16 video_ega_bx;
54 u8 video_lines; 56 __u8 video_lines;
55 u8 video_isvga; 57 __u8 video_isvga;
56 u16 video_points; 58 __u16 video_points;
57}; 59};
58 60
59/* describes how the ramdisk will be used in kernel */ 61/* describes how the ramdisk will be used in kernel */
60#define ATAG_RAMDISK 0x54410004 62#define ATAG_RAMDISK 0x54410004
61 63
62struct tag_ramdisk { 64struct tag_ramdisk {
63 u32 flags; /* bit 0 = load, bit 1 = prompt */ 65 __u32 flags; /* bit 0 = load, bit 1 = prompt */
64 u32 size; /* decompressed ramdisk size in _kilo_ bytes */ 66 __u32 size; /* decompressed ramdisk size in _kilo_ bytes */
65 u32 start; /* starting block of floppy-based RAM disk image */ 67 __u32 start; /* starting block of floppy-based RAM disk image */
66}; 68};
67 69
68/* describes where the compressed ramdisk image lives (virtual address) */ 70/* describes where the compressed ramdisk image lives (virtual address) */
@@ -76,23 +78,23 @@ struct tag_ramdisk {
76#define ATAG_INITRD2 0x54420005 78#define ATAG_INITRD2 0x54420005
77 79
78struct tag_initrd { 80struct tag_initrd {
79 u32 start; /* physical start address */ 81 __u32 start; /* physical start address */
80 u32 size; /* size of compressed ramdisk image in bytes */ 82 __u32 size; /* size of compressed ramdisk image in bytes */
81}; 83};
82 84
83/* board serial number. "64 bits should be enough for everybody" */ 85/* board serial number. "64 bits should be enough for everybody" */
84#define ATAG_SERIAL 0x54410006 86#define ATAG_SERIAL 0x54410006
85 87
86struct tag_serialnr { 88struct tag_serialnr {
87 u32 low; 89 __u32 low;
88 u32 high; 90 __u32 high;
89}; 91};
90 92
91/* board revision */ 93/* board revision */
92#define ATAG_REVISION 0x54410007 94#define ATAG_REVISION 0x54410007
93 95
94struct tag_revision { 96struct tag_revision {
95 u32 rev; 97 __u32 rev;
96}; 98};
97 99
98/* initial values for vesafb-type framebuffers. see struct screen_info 100/* initial values for vesafb-type framebuffers. see struct screen_info
@@ -101,20 +103,20 @@ struct tag_revision {
101#define ATAG_VIDEOLFB 0x54410008 103#define ATAG_VIDEOLFB 0x54410008
102 104
103struct tag_videolfb { 105struct tag_videolfb {
104 u16 lfb_width; 106 __u16 lfb_width;
105 u16 lfb_height; 107 __u16 lfb_height;
106 u16 lfb_depth; 108 __u16 lfb_depth;
107 u16 lfb_linelength; 109 __u16 lfb_linelength;
108 u32 lfb_base; 110 __u32 lfb_base;
109 u32 lfb_size; 111 __u32 lfb_size;
110 u8 red_size; 112 __u8 red_size;
111 u8 red_pos; 113 __u8 red_pos;
112 u8 green_size; 114 __u8 green_size;
113 u8 green_pos; 115 __u8 green_pos;
114 u8 blue_size; 116 __u8 blue_size;
115 u8 blue_pos; 117 __u8 blue_pos;
116 u8 rsvd_size; 118 __u8 rsvd_size;
117 u8 rsvd_pos; 119 __u8 rsvd_pos;
118}; 120};
119 121
120/* command line: \0 terminated string */ 122/* command line: \0 terminated string */
@@ -128,17 +130,17 @@ struct tag_cmdline {
128#define ATAG_ACORN 0x41000101 130#define ATAG_ACORN 0x41000101
129 131
130struct tag_acorn { 132struct tag_acorn {
131 u32 memc_control_reg; 133 __u32 memc_control_reg;
132 u32 vram_pages; 134 __u32 vram_pages;
133 u8 sounddefault; 135 __u8 sounddefault;
134 u8 adfsdrives; 136 __u8 adfsdrives;
135}; 137};
136 138
137/* footbridge memory clock, see arch/arm/mach-footbridge/arch.c */ 139/* footbridge memory clock, see arch/arm/mach-footbridge/arch.c */
138#define ATAG_MEMCLK 0x41000402 140#define ATAG_MEMCLK 0x41000402
139 141
140struct tag_memclk { 142struct tag_memclk {
141 u32 fmemclk; 143 __u32 fmemclk;
142}; 144};
143 145
144struct tag { 146struct tag {
@@ -167,24 +169,26 @@ struct tag {
167}; 169};
168 170
169struct tagtable { 171struct tagtable {
170 u32 tag; 172 __u32 tag;
171 int (*parse)(const struct tag *); 173 int (*parse)(const struct tag *);
172}; 174};
173 175
174#define __tag __attribute_used__ __attribute__((__section__(".taglist.init")))
175#define __tagtable(tag, fn) \
176static struct tagtable __tagtable_##fn __tag = { tag, fn }
177
178#define tag_member_present(tag,member) \ 176#define tag_member_present(tag,member) \
179 ((unsigned long)(&((struct tag *)0L)->member + 1) \ 177 ((unsigned long)(&((struct tag *)0L)->member + 1) \
180 <= (tag)->hdr.size * 4) 178 <= (tag)->hdr.size * 4)
181 179
182#define tag_next(t) ((struct tag *)((u32 *)(t) + (t)->hdr.size)) 180#define tag_next(t) ((struct tag *)((__u32 *)(t) + (t)->hdr.size))
183#define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2) 181#define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2)
184 182
185#define for_each_tag(t,base) \ 183#define for_each_tag(t,base) \
186 for (t = base; t->hdr.size; t = tag_next(t)) 184 for (t = base; t->hdr.size; t = tag_next(t))
187 185
186#ifdef __KERNEL__
187
188#define __tag __attribute_used__ __attribute__((__section__(".taglist.init")))
189#define __tagtable(tag, fn) \
190static struct tagtable __tagtable_##fn __tag = { tag, fn }
191
188/* 192/*
189 * Memory map description 193 * Memory map description
190 */ 194 */
@@ -217,4 +221,6 @@ struct early_params {
217static struct early_params __early_##fn __attribute_used__ \ 221static struct early_params __early_##fn __attribute_used__ \
218__attribute__((__section__(".early_param.init"))) = { name, fn } 222__attribute__((__section__(".early_param.init"))) = { name, fn }
219 223
224#endif /* __KERNEL__ */
225
220#endif 226#endif
diff --git a/include/asm-arm/unistd.h b/include/asm-arm/unistd.h
index 14a87eec5a2d..d44c629d8424 100644
--- a/include/asm-arm/unistd.h
+++ b/include/asm-arm/unistd.h
@@ -377,156 +377,6 @@
377#endif 377#endif
378 378
379#ifdef __KERNEL__ 379#ifdef __KERNEL__
380#include <linux/err.h>
381#include <linux/linkage.h>
382
383#define __sys2(x) #x
384#define __sys1(x) __sys2(x)
385
386#ifndef __syscall
387#if defined(__thumb__) || defined(__ARM_EABI__)
388#define __SYS_REG(name) register long __sysreg __asm__("r7") = __NR_##name;
389#define __SYS_REG_LIST(regs...) "r" (__sysreg) , ##regs
390#define __syscall(name) "swi\t0"
391#else
392#define __SYS_REG(name)
393#define __SYS_REG_LIST(regs...) regs
394#define __syscall(name) "swi\t" __sys1(__NR_##name) ""
395#endif
396#endif
397
398#define __syscall_return(type, res) \
399do { \
400 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
401 errno = -(res); \
402 res = -1; \
403 } \
404 return (type) (res); \
405} while (0)
406
407#define _syscall0(type,name) \
408type name(void) { \
409 __SYS_REG(name) \
410 register long __res_r0 __asm__("r0"); \
411 long __res; \
412 __asm__ __volatile__ ( \
413 __syscall(name) \
414 : "=r" (__res_r0) \
415 : __SYS_REG_LIST() \
416 : "memory" ); \
417 __res = __res_r0; \
418 __syscall_return(type,__res); \
419}
420
421#define _syscall1(type,name,type1,arg1) \
422type name(type1 arg1) { \
423 __SYS_REG(name) \
424 register long __r0 __asm__("r0") = (long)arg1; \
425 register long __res_r0 __asm__("r0"); \
426 long __res; \
427 __asm__ __volatile__ ( \
428 __syscall(name) \
429 : "=r" (__res_r0) \
430 : __SYS_REG_LIST( "0" (__r0) ) \
431 : "memory" ); \
432 __res = __res_r0; \
433 __syscall_return(type,__res); \
434}
435
436#define _syscall2(type,name,type1,arg1,type2,arg2) \
437type name(type1 arg1,type2 arg2) { \
438 __SYS_REG(name) \
439 register long __r0 __asm__("r0") = (long)arg1; \
440 register long __r1 __asm__("r1") = (long)arg2; \
441 register long __res_r0 __asm__("r0"); \
442 long __res; \
443 __asm__ __volatile__ ( \
444 __syscall(name) \
445 : "=r" (__res_r0) \
446 : __SYS_REG_LIST( "0" (__r0), "r" (__r1) ) \
447 : "memory" ); \
448 __res = __res_r0; \
449 __syscall_return(type,__res); \
450}
451
452
453#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
454type name(type1 arg1,type2 arg2,type3 arg3) { \
455 __SYS_REG(name) \
456 register long __r0 __asm__("r0") = (long)arg1; \
457 register long __r1 __asm__("r1") = (long)arg2; \
458 register long __r2 __asm__("r2") = (long)arg3; \
459 register long __res_r0 __asm__("r0"); \
460 long __res; \
461 __asm__ __volatile__ ( \
462 __syscall(name) \
463 : "=r" (__res_r0) \
464 : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2) ) \
465 : "memory" ); \
466 __res = __res_r0; \
467 __syscall_return(type,__res); \
468}
469
470
471#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4)\
472type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
473 __SYS_REG(name) \
474 register long __r0 __asm__("r0") = (long)arg1; \
475 register long __r1 __asm__("r1") = (long)arg2; \
476 register long __r2 __asm__("r2") = (long)arg3; \
477 register long __r3 __asm__("r3") = (long)arg4; \
478 register long __res_r0 __asm__("r0"); \
479 long __res; \
480 __asm__ __volatile__ ( \
481 __syscall(name) \
482 : "=r" (__res_r0) \
483 : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2), "r" (__r3) ) \
484 : "memory" ); \
485 __res = __res_r0; \
486 __syscall_return(type,__res); \
487}
488
489
490#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
491type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) { \
492 __SYS_REG(name) \
493 register long __r0 __asm__("r0") = (long)arg1; \
494 register long __r1 __asm__("r1") = (long)arg2; \
495 register long __r2 __asm__("r2") = (long)arg3; \
496 register long __r3 __asm__("r3") = (long)arg4; \
497 register long __r4 __asm__("r4") = (long)arg5; \
498 register long __res_r0 __asm__("r0"); \
499 long __res; \
500 __asm__ __volatile__ ( \
501 __syscall(name) \
502 : "=r" (__res_r0) \
503 : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2), \
504 "r" (__r3), "r" (__r4) ) \
505 : "memory" ); \
506 __res = __res_r0; \
507 __syscall_return(type,__res); \
508}
509
510#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
511type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) { \
512 __SYS_REG(name) \
513 register long __r0 __asm__("r0") = (long)arg1; \
514 register long __r1 __asm__("r1") = (long)arg2; \
515 register long __r2 __asm__("r2") = (long)arg3; \
516 register long __r3 __asm__("r3") = (long)arg4; \
517 register long __r4 __asm__("r4") = (long)arg5; \
518 register long __r5 __asm__("r5") = (long)arg6; \
519 register long __res_r0 __asm__("r0"); \
520 long __res; \
521 __asm__ __volatile__ ( \
522 __syscall(name) \
523 : "=r" (__res_r0) \
524 : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2), \
525 "r" (__r3), "r" (__r4), "r" (__r5) ) \
526 : "memory" ); \
527 __res = __res_r0; \
528 __syscall_return(type,__res); \
529}
530 380
531#define __ARCH_WANT_IPC_PARSE_VERSION 381#define __ARCH_WANT_IPC_PARSE_VERSION
532#define __ARCH_WANT_STAT64 382#define __ARCH_WANT_STAT64
diff --git a/include/asm-arm26/pgalloc.h b/include/asm-arm26/pgalloc.h
index 6437167b1ffe..7725af3ddb4d 100644
--- a/include/asm-arm26/pgalloc.h
+++ b/include/asm-arm26/pgalloc.h
@@ -15,7 +15,7 @@
15#include <asm/tlbflush.h> 15#include <asm/tlbflush.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17 17
18extern kmem_cache_t *pte_cache; 18extern struct kmem_cache *pte_cache;
19 19
20static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr){ 20static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr){
21 return kmem_cache_alloc(pte_cache, GFP_KERNEL); 21 return kmem_cache_alloc(pte_cache, GFP_KERNEL);
diff --git a/include/asm-arm26/setup.h b/include/asm-arm26/setup.h
index 6348931be65d..1a867b4e8d53 100644
--- a/include/asm-arm26/setup.h
+++ b/include/asm-arm26/setup.h
@@ -16,6 +16,8 @@
16 16
17#define COMMAND_LINE_SIZE 1024 17#define COMMAND_LINE_SIZE 1024
18 18
19#ifdef __KERNEL__
20
19/* The list ends with an ATAG_NONE node. */ 21/* The list ends with an ATAG_NONE node. */
20#define ATAG_NONE 0x00000000 22#define ATAG_NONE 0x00000000
21 23
@@ -202,4 +204,6 @@ struct meminfo {
202 204
203extern struct meminfo meminfo; 205extern struct meminfo meminfo;
204 206
207#endif /* __KERNEL__ */
208
205#endif 209#endif
diff --git a/include/asm-arm26/unistd.h b/include/asm-arm26/unistd.h
index 25a5eead85be..4c3b919177e5 100644
--- a/include/asm-arm26/unistd.h
+++ b/include/asm-arm26/unistd.h
@@ -311,139 +311,6 @@
311#define __ARM_NR_usr26 (__ARM_NR_BASE+3) 311#define __ARM_NR_usr26 (__ARM_NR_BASE+3)
312 312
313#ifdef __KERNEL__ 313#ifdef __KERNEL__
314#include <linux/err.h>
315#include <linux/linkage.h>
316
317#define __sys2(x) #x
318#define __sys1(x) __sys2(x)
319
320#ifndef __syscall
321#define __syscall(name) "swi\t" __sys1(__NR_##name) ""
322#endif
323
324#define __syscall_return(type, res) \
325do { \
326 if ((unsigned long)(res) >= (unsigned long)-MAX_ERRNO) { \
327 errno = -(res); \
328 res = -1; \
329 } \
330 return (type) (res); \
331} while (0)
332
333#define _syscall0(type,name) \
334type name(void) { \
335 register long __res_r0 __asm__("r0"); \
336 long __res; \
337 __asm__ __volatile__ ( \
338 __syscall(name) \
339 : "=r" (__res_r0) \
340 : \
341 : "lr"); \
342 __res = __res_r0; \
343 __syscall_return(type,__res); \
344}
345
346#define _syscall1(type,name,type1,arg1) \
347type name(type1 arg1) { \
348 register long __r0 __asm__("r0") = (long)arg1; \
349 register long __res_r0 __asm__("r0"); \
350 long __res; \
351 __asm__ __volatile__ ( \
352 __syscall(name) \
353 : "=r" (__res_r0) \
354 : "r" (__r0) \
355 : "lr"); \
356 __res = __res_r0; \
357 __syscall_return(type,__res); \
358}
359
360#define _syscall2(type,name,type1,arg1,type2,arg2) \
361type name(type1 arg1,type2 arg2) { \
362 register long __r0 __asm__("r0") = (long)arg1; \
363 register long __r1 __asm__("r1") = (long)arg2; \
364 register long __res_r0 __asm__("r0"); \
365 long __res; \
366 __asm__ __volatile__ ( \
367 __syscall(name) \
368 : "=r" (__res_r0) \
369 : "r" (__r0),"r" (__r1) \
370 : "lr"); \
371 __res = __res_r0; \
372 __syscall_return(type,__res); \
373}
374
375
376#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
377type name(type1 arg1,type2 arg2,type3 arg3) { \
378 register long __r0 __asm__("r0") = (long)arg1; \
379 register long __r1 __asm__("r1") = (long)arg2; \
380 register long __r2 __asm__("r2") = (long)arg3; \
381 register long __res_r0 __asm__("r0"); \
382 long __res; \
383 __asm__ __volatile__ ( \
384 __syscall(name) \
385 : "=r" (__res_r0) \
386 : "r" (__r0),"r" (__r1),"r" (__r2) \
387 : "lr"); \
388 __res = __res_r0; \
389 __syscall_return(type,__res); \
390}
391
392
393#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4)\
394type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
395 register long __r0 __asm__("r0") = (long)arg1; \
396 register long __r1 __asm__("r1") = (long)arg2; \
397 register long __r2 __asm__("r2") = (long)arg3; \
398 register long __r3 __asm__("r3") = (long)arg4; \
399 register long __res_r0 __asm__("r0"); \
400 long __res; \
401 __asm__ __volatile__ ( \
402 __syscall(name) \
403 : "=r" (__res_r0) \
404 : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3) \
405 : "lr"); \
406 __res = __res_r0; \
407 __syscall_return(type,__res); \
408}
409
410
411#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
412type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) { \
413 register long __r0 __asm__("r0") = (long)arg1; \
414 register long __r1 __asm__("r1") = (long)arg2; \
415 register long __r2 __asm__("r2") = (long)arg3; \
416 register long __r3 __asm__("r3") = (long)arg4; \
417 register long __r4 __asm__("r4") = (long)arg5; \
418 register long __res_r0 __asm__("r0"); \
419 long __res; \
420 __asm__ __volatile__ ( \
421 __syscall(name) \
422 : "=r" (__res_r0) \
423 : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3),"r" (__r4) \
424 : "lr"); \
425 __res = __res_r0; \
426 __syscall_return(type,__res); \
427}
428
429#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
430type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) { \
431 register long __r0 __asm__("r0") = (long)arg1; \
432 register long __r1 __asm__("r1") = (long)arg2; \
433 register long __r2 __asm__("r2") = (long)arg3; \
434 register long __r3 __asm__("r3") = (long)arg4; \
435 register long __r4 __asm__("r4") = (long)arg5; \
436 register long __r5 __asm__("r5") = (long)arg6; \
437 register long __res_r0 __asm__("r0"); \
438 long __res; \
439 __asm__ __volatile__ ( \
440 __syscall(name) \
441 : "=r" (__res_r0) \
442 : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3), "r" (__r4),"r" (__r5) \
443 : "lr"); \
444 __res = __res_r0; \
445 __syscall_return(type,__res); \
446}
447 314
448#define __ARCH_WANT_IPC_PARSE_VERSION 315#define __ARCH_WANT_IPC_PARSE_VERSION
449#define __ARCH_WANT_OLD_READDIR 316#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-avr32/dma-mapping.h b/include/asm-avr32/dma-mapping.h
index 4c40cb41cdf8..0580b5d62bba 100644
--- a/include/asm-avr32/dma-mapping.h
+++ b/include/asm-avr32/dma-mapping.h
@@ -8,7 +8,8 @@
8#include <asm/cacheflush.h> 8#include <asm/cacheflush.h>
9#include <asm/io.h> 9#include <asm/io.h>
10 10
11extern void dma_cache_sync(void *vaddr, size_t size, int direction); 11extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
12 int direction);
12 13
13/* 14/*
14 * Return whether the given device DMA address mask can be supported 15 * Return whether the given device DMA address mask can be supported
@@ -307,7 +308,7 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
307#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 308#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
308#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 309#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
309 310
310static inline int dma_is_consistent(dma_addr_t dma_addr) 311static inline int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
311{ 312{
312 return 1; 313 return 1;
313} 314}
diff --git a/include/asm-avr32/setup.h b/include/asm-avr32/setup.h
index 10193da4113b..0a5224245e44 100644
--- a/include/asm-avr32/setup.h
+++ b/include/asm-avr32/setup.h
@@ -13,6 +13,8 @@
13 13
14#define COMMAND_LINE_SIZE 256 14#define COMMAND_LINE_SIZE 256
15 15
16#ifdef __KERNEL__
17
16/* Magic number indicating that a tag table is present */ 18/* Magic number indicating that a tag table is present */
17#define ATAG_MAGIC 0xa2a25441 19#define ATAG_MAGIC 0xa2a25441
18 20
@@ -138,4 +140,6 @@ void chip_enable_sdram(void);
138 140
139#endif /* !__ASSEMBLY__ */ 141#endif /* !__ASSEMBLY__ */
140 142
143#endif /* __KERNEL__ */
144
141#endif /* __ASM_AVR32_SETUP_H__ */ 145#endif /* __ASM_AVR32_SETUP_H__ */
diff --git a/include/asm-cris/arch-v10/bitops.h b/include/asm-cris/arch-v10/bitops.h
index b73f5396e5a6..be85f6de25d3 100644
--- a/include/asm-cris/arch-v10/bitops.h
+++ b/include/asm-cris/arch-v10/bitops.h
@@ -10,7 +10,7 @@
10 * number. They differ in that the first function also inverts all bits 10 * number. They differ in that the first function also inverts all bits
11 * in the input. 11 * in the input.
12 */ 12 */
13extern inline unsigned long cris_swapnwbrlz(unsigned long w) 13static inline unsigned long cris_swapnwbrlz(unsigned long w)
14{ 14{
15 /* Let's just say we return the result in the same register as the 15 /* Let's just say we return the result in the same register as the
16 input. Saying we clobber the input but can return the result 16 input. Saying we clobber the input but can return the result
@@ -26,7 +26,7 @@ extern inline unsigned long cris_swapnwbrlz(unsigned long w)
26 return res; 26 return res;
27} 27}
28 28
29extern inline unsigned long cris_swapwbrlz(unsigned long w) 29static inline unsigned long cris_swapwbrlz(unsigned long w)
30{ 30{
31 unsigned res; 31 unsigned res;
32 __asm__ ("swapwbr %0 \n\t" 32 __asm__ ("swapwbr %0 \n\t"
@@ -40,7 +40,7 @@ extern inline unsigned long cris_swapwbrlz(unsigned long w)
40 * ffz = Find First Zero in word. Undefined if no zero exists, 40 * ffz = Find First Zero in word. Undefined if no zero exists,
41 * so code should check against ~0UL first.. 41 * so code should check against ~0UL first..
42 */ 42 */
43extern inline unsigned long ffz(unsigned long w) 43static inline unsigned long ffz(unsigned long w)
44{ 44{
45 return cris_swapnwbrlz(w); 45 return cris_swapnwbrlz(w);
46} 46}
@@ -51,7 +51,7 @@ extern inline unsigned long ffz(unsigned long w)
51 * 51 *
52 * Undefined if no bit exists, so code should check against 0 first. 52 * Undefined if no bit exists, so code should check against 0 first.
53 */ 53 */
54extern inline unsigned long __ffs(unsigned long word) 54static inline unsigned long __ffs(unsigned long word)
55{ 55{
56 return cris_swapnwbrlz(~word); 56 return cris_swapnwbrlz(~word);
57} 57}
@@ -65,7 +65,7 @@ extern inline unsigned long __ffs(unsigned long word)
65 * differs in spirit from the above ffz (man ffs). 65 * differs in spirit from the above ffz (man ffs).
66 */ 66 */
67 67
68extern inline unsigned long kernel_ffs(unsigned long w) 68static inline unsigned long kernel_ffs(unsigned long w)
69{ 69{
70 return w ? cris_swapwbrlz (w) + 1 : 0; 70 return w ? cris_swapwbrlz (w) + 1 : 0;
71} 71}
diff --git a/include/asm-cris/dma-mapping.h b/include/asm-cris/dma-mapping.h
index cbf1a98f0129..662cea70152d 100644
--- a/include/asm-cris/dma-mapping.h
+++ b/include/asm-cris/dma-mapping.h
@@ -156,10 +156,10 @@ dma_get_cache_alignment(void)
156 return (1 << INTERNODE_CACHE_SHIFT); 156 return (1 << INTERNODE_CACHE_SHIFT);
157} 157}
158 158
159#define dma_is_consistent(d) (1) 159#define dma_is_consistent(d, h) (1)
160 160
161static inline void 161static inline void
162dma_cache_sync(void *vaddr, size_t size, 162dma_cache_sync(struct device *dev, void *vaddr, size_t size,
163 enum dma_data_direction direction) 163 enum dma_data_direction direction)
164{ 164{
165} 165}
diff --git a/include/asm-cris/semaphore-helper.h b/include/asm-cris/semaphore-helper.h
index dbd0f30b85b6..a8e1e6cb7cd0 100644
--- a/include/asm-cris/semaphore-helper.h
+++ b/include/asm-cris/semaphore-helper.h
@@ -20,12 +20,12 @@
20/* 20/*
21 * These two _must_ execute atomically wrt each other. 21 * These two _must_ execute atomically wrt each other.
22 */ 22 */
23extern inline void wake_one_more(struct semaphore * sem) 23static inline void wake_one_more(struct semaphore * sem)
24{ 24{
25 atomic_inc(&sem->waking); 25 atomic_inc(&sem->waking);
26} 26}
27 27
28extern inline int waking_non_zero(struct semaphore *sem) 28static inline int waking_non_zero(struct semaphore *sem)
29{ 29{
30 unsigned long flags; 30 unsigned long flags;
31 int ret = 0; 31 int ret = 0;
@@ -40,7 +40,7 @@ extern inline int waking_non_zero(struct semaphore *sem)
40 return ret; 40 return ret;
41} 41}
42 42
43extern inline int waking_non_zero_interruptible(struct semaphore *sem, 43static inline int waking_non_zero_interruptible(struct semaphore *sem,
44 struct task_struct *tsk) 44 struct task_struct *tsk)
45{ 45{
46 int ret = 0; 46 int ret = 0;
@@ -59,7 +59,7 @@ extern inline int waking_non_zero_interruptible(struct semaphore *sem,
59 return ret; 59 return ret;
60} 60}
61 61
62extern inline int waking_non_zero_trylock(struct semaphore *sem) 62static inline int waking_non_zero_trylock(struct semaphore *sem)
63{ 63{
64 int ret = 1; 64 int ret = 1;
65 unsigned long flags; 65 unsigned long flags;
diff --git a/include/asm-frv/dma-mapping.h b/include/asm-frv/dma-mapping.h
index e9fc1d47797e..bcb2df68496e 100644
--- a/include/asm-frv/dma-mapping.h
+++ b/include/asm-frv/dma-mapping.h
@@ -172,10 +172,10 @@ int dma_get_cache_alignment(void)
172 return 1 << L1_CACHE_SHIFT; 172 return 1 << L1_CACHE_SHIFT;
173} 173}
174 174
175#define dma_is_consistent(d) (1) 175#define dma_is_consistent(d, h) (1)
176 176
177static inline 177static inline
178void dma_cache_sync(void *vaddr, size_t size, 178void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
179 enum dma_data_direction direction) 179 enum dma_data_direction direction)
180{ 180{
181 flush_write_buffers(); 181 flush_write_buffers();
diff --git a/include/asm-frv/highmem.h b/include/asm-frv/highmem.h
index 0f390f41f816..ff4d6cdeb152 100644
--- a/include/asm-frv/highmem.h
+++ b/include/asm-frv/highmem.h
@@ -115,7 +115,7 @@ static inline void *kmap_atomic(struct page *page, enum km_type type)
115{ 115{
116 unsigned long paddr; 116 unsigned long paddr;
117 117
118 inc_preempt_count(); 118 pagefault_disable();
119 paddr = page_to_phys(page); 119 paddr = page_to_phys(page);
120 120
121 switch (type) { 121 switch (type) {
@@ -170,8 +170,7 @@ static inline void kunmap_atomic(void *kvaddr, enum km_type type)
170 default: 170 default:
171 BUG(); 171 BUG();
172 } 172 }
173 dec_preempt_count(); 173 pagefault_enable();
174 preempt_check_resched();
175} 174}
176 175
177#endif /* !__ASSEMBLY__ */ 176#endif /* !__ASSEMBLY__ */
diff --git a/include/asm-frv/param.h b/include/asm-frv/param.h
index 168381ebb41a..365653b1726c 100644
--- a/include/asm-frv/param.h
+++ b/include/asm-frv/param.h
@@ -18,6 +18,5 @@
18#endif 18#endif
19 19
20#define MAXHOSTNAMELEN 64 /* max length of hostname */ 20#define MAXHOSTNAMELEN 64 /* max length of hostname */
21#define COMMAND_LINE_SIZE 512
22 21
23#endif /* _ASM_PARAM_H */ 22#endif /* _ASM_PARAM_H */
diff --git a/include/asm-frv/setup.h b/include/asm-frv/setup.h
index 0d293b9a5857..afd787ceede6 100644
--- a/include/asm-frv/setup.h
+++ b/include/asm-frv/setup.h
@@ -12,6 +12,10 @@
12#ifndef _ASM_SETUP_H 12#ifndef _ASM_SETUP_H
13#define _ASM_SETUP_H 13#define _ASM_SETUP_H
14 14
15#define COMMAND_LINE_SIZE 512
16
17#ifdef __KERNEL__
18
15#include <linux/init.h> 19#include <linux/init.h>
16 20
17#ifndef __ASSEMBLY__ 21#ifndef __ASSEMBLY__
@@ -22,4 +26,6 @@ extern unsigned long __initdata num_mappedpages;
22 26
23#endif /* !__ASSEMBLY__ */ 27#endif /* !__ASSEMBLY__ */
24 28
29#endif /* __KERNEL__ */
30
25#endif /* _ASM_SETUP_H */ 31#endif /* _ASM_SETUP_H */
diff --git a/include/asm-frv/unistd.h b/include/asm-frv/unistd.h
index 725e854928cf..584c0417ae4d 100644
--- a/include/asm-frv/unistd.h
+++ b/include/asm-frv/unistd.h
@@ -320,125 +320,6 @@
320#ifdef __KERNEL__ 320#ifdef __KERNEL__
321 321
322#define NR_syscalls 310 322#define NR_syscalls 310
323#include <linux/err.h>
324
325/*
326 * process the return value of a syscall, consigning it to one of two possible fates
327 * - user-visible error numbers are in the range -1 - -4095: see <asm-frv/errno.h>
328 */
329#undef __syscall_return
330#define __syscall_return(type, res) \
331do { \
332 unsigned long __sr2 = (res); \
333 if (__builtin_expect(__sr2 >= (unsigned long)(-MAX_ERRNO), 0)) { \
334 errno = (-__sr2); \
335 __sr2 = ~0UL; \
336 } \
337 return (type) __sr2; \
338} while (0)
339
340/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
341
342#undef _syscall0
343#define _syscall0(type,name) \
344type name(void) \
345{ \
346 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
347 register unsigned long __sc0 __asm__ ("gr8"); \
348 __asm__ __volatile__ ("tira gr0,#0" \
349 : "=r" (__sc0) \
350 : "r" (__scnum)); \
351 __syscall_return(type, __sc0); \
352}
353
354#undef _syscall1
355#define _syscall1(type,name,type1,arg1) \
356type name(type1 arg1) \
357{ \
358 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
359 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
360 __asm__ __volatile__ ("tira gr0,#0" \
361 : "+r" (__sc0) \
362 : "r" (__scnum)); \
363 __syscall_return(type, __sc0); \
364}
365
366#undef _syscall2
367#define _syscall2(type,name,type1,arg1,type2,arg2) \
368type name(type1 arg1,type2 arg2) \
369{ \
370 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
371 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
372 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
373 __asm__ __volatile__ ("tira gr0,#0" \
374 : "+r" (__sc0) \
375 : "r" (__scnum), "r" (__sc1)); \
376 __syscall_return(type, __sc0); \
377}
378
379#undef _syscall3
380#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
381type name(type1 arg1,type2 arg2,type3 arg3) \
382{ \
383 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
384 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
385 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
386 register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
387 __asm__ __volatile__ ("tira gr0,#0" \
388 : "+r" (__sc0) \
389 : "r" (__scnum), "r" (__sc1), "r" (__sc2)); \
390 __syscall_return(type, __sc0); \
391}
392
393#undef _syscall4
394#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
395type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
396{ \
397 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
398 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
399 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
400 register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
401 register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \
402 __asm__ __volatile__ ("tira gr0,#0" \
403 : "+r" (__sc0) \
404 : "r" (__scnum), "r" (__sc1), "r" (__sc2), "r" (__sc3)); \
405 __syscall_return(type, __sc0); \
406}
407
408#undef _syscall5
409#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
410type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
411{ \
412 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
413 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
414 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
415 register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
416 register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \
417 register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5; \
418 __asm__ __volatile__ ("tira gr0,#0" \
419 : "+r" (__sc0) \
420 : "r" (__scnum), "r" (__sc1), "r" (__sc2), \
421 "r" (__sc3), "r" (__sc4)); \
422 __syscall_return(type, __sc0); \
423}
424
425#undef _syscall6
426#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5, type6, arg6) \
427type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
428{ \
429 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
430 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
431 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
432 register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
433 register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \
434 register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5; \
435 register unsigned long __sc5 __asm__ ("gr13") = (unsigned long) arg6; \
436 __asm__ __volatile__ ("tira gr0,#0" \
437 : "+r" (__sc0) \
438 : "r" (__scnum), "r" (__sc1), "r" (__sc2), \
439 "r" (__sc3), "r" (__sc4), "r" (__sc5)); \
440 __syscall_return(type, __sc0); \
441}
442 323
443#define __ARCH_WANT_IPC_PARSE_VERSION 324#define __ARCH_WANT_IPC_PARSE_VERSION
444/* #define __ARCH_WANT_OLD_READDIR */ 325/* #define __ARCH_WANT_OLD_READDIR */
diff --git a/include/asm-generic/Kbuild b/include/asm-generic/Kbuild
index 3c06be381701..fa14f8cd30c5 100644
--- a/include/asm-generic/Kbuild
+++ b/include/asm-generic/Kbuild
@@ -1,4 +1,3 @@
1header-y += atomic.h
2header-y += errno-base.h 1header-y += errno-base.h
3header-y += errno.h 2header-y += errno.h
4header-y += fcntl.h 3header-y += fcntl.h
diff --git a/include/asm-generic/Kbuild.asm b/include/asm-generic/Kbuild.asm
index a84c3d88a189..a37e95fe58d6 100644
--- a/include/asm-generic/Kbuild.asm
+++ b/include/asm-generic/Kbuild.asm
@@ -14,6 +14,7 @@ unifdef-y += posix_types.h
14unifdef-y += ptrace.h 14unifdef-y += ptrace.h
15unifdef-y += resource.h 15unifdef-y += resource.h
16unifdef-y += sembuf.h 16unifdef-y += sembuf.h
17unifdef-y += setup.h
17unifdef-y += shmbuf.h 18unifdef-y += shmbuf.h
18unifdef-y += sigcontext.h 19unifdef-y += sigcontext.h
19unifdef-y += siginfo.h 20unifdef-y += siginfo.h
diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
index 42a95d9a0641..b7e4a0467cb1 100644
--- a/include/asm-generic/atomic.h
+++ b/include/asm-generic/atomic.h
@@ -66,7 +66,7 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66 atomic64_sub(i, v); 66 atomic64_sub(i, v);
67} 67}
68 68
69#else 69#else /* BITS_PER_LONG == 64 */
70 70
71typedef atomic_t atomic_long_t; 71typedef atomic_t atomic_long_t;
72 72
@@ -113,5 +113,6 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
113 atomic_sub(i, v); 113 atomic_sub(i, v);
114} 114}
115 115
116#endif 116#endif /* BITS_PER_LONG == 64 */
117#endif 117
118#endif /* _ASM_GENERIC_ATOMIC_H */
diff --git a/include/asm-generic/dma-mapping.h b/include/asm-generic/dma-mapping.h
index b541e48cc545..783ab9944d70 100644
--- a/include/asm-generic/dma-mapping.h
+++ b/include/asm-generic/dma-mapping.h
@@ -266,7 +266,7 @@ dma_error(dma_addr_t dma_addr)
266 266
267#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 267#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
268#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 268#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
269#define dma_is_consistent(d) (1) 269#define dma_is_consistent(d, h) (1)
270 270
271static inline int 271static inline int
272dma_get_cache_alignment(void) 272dma_get_cache_alignment(void)
@@ -295,7 +295,7 @@ dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
295} 295}
296 296
297static inline void 297static inline void
298dma_cache_sync(void *vaddr, size_t size, 298dma_cache_sync(struct device *dev, void *vaddr, size_t size,
299 enum dma_data_direction direction) 299 enum dma_data_direction direction)
300{ 300{
301 /* could define this in terms of the dma_cache ... operations, 301 /* could define this in terms of the dma_cache ... operations,
diff --git a/include/asm-generic/futex.h b/include/asm-generic/futex.h
index df893c160318..f422df0956a2 100644
--- a/include/asm-generic/futex.h
+++ b/include/asm-generic/futex.h
@@ -21,7 +21,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
21 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) 21 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
22 return -EFAULT; 22 return -EFAULT;
23 23
24 inc_preempt_count(); 24 pagefault_disable();
25 25
26 switch (op) { 26 switch (op) {
27 case FUTEX_OP_SET: 27 case FUTEX_OP_SET:
@@ -33,7 +33,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
33 ret = -ENOSYS; 33 ret = -ENOSYS;
34 } 34 }
35 35
36 dec_preempt_count(); 36 pagefault_enable();
37 37
38 if (!ret) { 38 if (!ret) {
39 switch (cmp) { 39 switch (cmp) {
diff --git a/include/asm-h8300/delay.h b/include/asm-h8300/delay.h
index cbccbbdd640f..743beba70f82 100644
--- a/include/asm-h8300/delay.h
+++ b/include/asm-h8300/delay.h
@@ -9,7 +9,7 @@
9 * Delay routines, using a pre-computed "loops_per_second" value. 9 * Delay routines, using a pre-computed "loops_per_second" value.
10 */ 10 */
11 11
12extern __inline__ void __delay(unsigned long loops) 12static inline void __delay(unsigned long loops)
13{ 13{
14 __asm__ __volatile__ ("1:\n\t" 14 __asm__ __volatile__ ("1:\n\t"
15 "dec.l #1,%0\n\t" 15 "dec.l #1,%0\n\t"
@@ -27,7 +27,7 @@ extern __inline__ void __delay(unsigned long loops)
27 27
28extern unsigned long loops_per_jiffy; 28extern unsigned long loops_per_jiffy;
29 29
30extern __inline__ void udelay(unsigned long usecs) 30static inline void udelay(unsigned long usecs)
31{ 31{
32 usecs *= 4295; /* 2**32 / 1000000 */ 32 usecs *= 4295; /* 2**32 / 1000000 */
33 usecs /= (loops_per_jiffy*HZ); 33 usecs /= (loops_per_jiffy*HZ);
diff --git a/include/asm-h8300/mmu_context.h b/include/asm-h8300/mmu_context.h
index 855721a5dcc9..5c165f7bee0e 100644
--- a/include/asm-h8300/mmu_context.h
+++ b/include/asm-h8300/mmu_context.h
@@ -9,7 +9,7 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
9{ 9{
10} 10}
11 11
12extern inline int 12static inline int
13init_new_context(struct task_struct *tsk, struct mm_struct *mm) 13init_new_context(struct task_struct *tsk, struct mm_struct *mm)
14{ 14{
15 // mm->context = virt_to_phys(mm->pgd); 15 // mm->context = virt_to_phys(mm->pgd);
@@ -23,7 +23,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, str
23{ 23{
24} 24}
25 25
26extern inline void activate_mm(struct mm_struct *prev_mm, 26static inline void activate_mm(struct mm_struct *prev_mm,
27 struct mm_struct *next_mm) 27 struct mm_struct *next_mm)
28{ 28{
29} 29}
diff --git a/include/asm-h8300/pci.h b/include/asm-h8300/pci.h
index 5edad5b70fd5..0c771b05fdd5 100644
--- a/include/asm-h8300/pci.h
+++ b/include/asm-h8300/pci.h
@@ -10,12 +10,12 @@
10#define pcibios_assign_all_busses() 0 10#define pcibios_assign_all_busses() 0
11#define pcibios_scan_all_fns(a, b) 0 11#define pcibios_scan_all_fns(a, b) 0
12 12
13extern inline void pcibios_set_master(struct pci_dev *dev) 13static inline void pcibios_set_master(struct pci_dev *dev)
14{ 14{
15 /* No special bus mastering setup handling */ 15 /* No special bus mastering setup handling */
16} 16}
17 17
18extern inline void pcibios_penalize_isa_irq(int irq, int active) 18static inline void pcibios_penalize_isa_irq(int irq, int active)
19{ 19{
20 /* We don't do dynamic PCI IRQ allocation */ 20 /* We don't do dynamic PCI IRQ allocation */
21} 21}
diff --git a/include/asm-h8300/tlbflush.h b/include/asm-h8300/tlbflush.h
index bbdffbeeedef..9a2c5c9fd700 100644
--- a/include/asm-h8300/tlbflush.h
+++ b/include/asm-h8300/tlbflush.h
@@ -47,12 +47,12 @@ static inline void flush_tlb_range(struct mm_struct *mm,
47 BUG(); 47 BUG();
48} 48}
49 49
50extern inline void flush_tlb_kernel_page(unsigned long addr) 50static inline void flush_tlb_kernel_page(unsigned long addr)
51{ 51{
52 BUG(); 52 BUG();
53} 53}
54 54
55extern inline void flush_tlb_pgtables(struct mm_struct *mm, 55static inline void flush_tlb_pgtables(struct mm_struct *mm,
56 unsigned long start, unsigned long end) 56 unsigned long start, unsigned long end)
57{ 57{
58 BUG(); 58 BUG();
diff --git a/include/asm-h8300/unistd.h b/include/asm-h8300/unistd.h
index 747788d629ae..7ddd414f8d16 100644
--- a/include/asm-h8300/unistd.h
+++ b/include/asm-h8300/unistd.h
@@ -295,172 +295,6 @@
295#ifdef __KERNEL__ 295#ifdef __KERNEL__
296 296
297#define NR_syscalls 289 297#define NR_syscalls 289
298#include <linux/err.h>
299
300/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
301 <asm-m68k/errno.h> */
302
303#define __syscall_return(type, res) \
304do { \
305 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
306 /* avoid using res which is declared to be in register d0; \
307 errno might expand to a function call and clobber it. */ \
308 int __err = -(res); \
309 errno = __err; \
310 res = -1; \
311 } \
312 return (type) (res); \
313} while (0)
314
315#define _syscall0(type, name) \
316type name(void) \
317{ \
318 register long __res __asm__("er0"); \
319 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
320 "trapa #0\n\t" \
321 : "=r" (__res) \
322 : "g" (__NR_##name) \
323 : "cc", "memory"); \
324 __syscall_return(type, __res); \
325}
326
327#define _syscall1(type, name, atype, a) \
328type name(atype a) \
329{ \
330 register long __res __asm__("er0"); \
331 register long _a __asm__("er1"); \
332 _a = (long)a; \
333 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
334 "trapa #0\n\t" \
335 : "=r" (__res) \
336 : "g" (__NR_##name), \
337 "g" (_a) \
338 : "cc", "memory"); \
339 __syscall_return(type, __res); \
340}
341
342#define _syscall2(type, name, atype, a, btype, b) \
343type name(atype a, btype b) \
344{ \
345 register long __res __asm__("er0"); \
346 register long _a __asm__("er1"); \
347 register long _b __asm__("er2"); \
348 _a = (long)a; \
349 _b = (long)b; \
350 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
351 "trapa #0\n\t" \
352 : "=r" (__res) \
353 : "g" (__NR_##name), \
354 "g" (_a), \
355 "g" (_b) \
356 : "cc", "memory"); \
357 __syscall_return(type, __res); \
358}
359
360#define _syscall3(type, name, atype, a, btype, b, ctype, c) \
361type name(atype a, btype b, ctype c) \
362{ \
363 register long __res __asm__("er0"); \
364 register long _a __asm__("er1"); \
365 register long _b __asm__("er2"); \
366 register long _c __asm__("er3"); \
367 _a = (long)a; \
368 _b = (long)b; \
369 _c = (long)c; \
370 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
371 "trapa #0\n\t" \
372 : "=r" (__res) \
373 : "g" (__NR_##name), \
374 "g" (_a), \
375 "g" (_b), \
376 "g" (_c) \
377 : "cc", "memory"); \
378 __syscall_return(type, __res); \
379}
380
381#define _syscall4(type, name, atype, a, btype, b, \
382 ctype, c, dtype, d) \
383type name(atype a, btype b, ctype c, dtype d) \
384{ \
385 register long __res __asm__("er0"); \
386 register long _a __asm__("er1"); \
387 register long _b __asm__("er2"); \
388 register long _c __asm__("er3"); \
389 register long _d __asm__("er4"); \
390 _a = (long)a; \
391 _b = (long)b; \
392 _c = (long)c; \
393 _d = (long)d; \
394 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
395 "trapa #0\n\t" \
396 : "=r" (__res) \
397 : "g" (__NR_##name), \
398 "g" (_a), \
399 "g" (_b), \
400 "g" (_c), \
401 "g" (_d) \
402 : "cc", "memory"); \
403 __syscall_return(type, __res); \
404}
405
406#define _syscall5(type, name, atype, a, btype, b, \
407 ctype, c, dtype, d, etype, e) \
408type name(atype a, btype b, ctype c, dtype d, etype e) \
409{ \
410 register long __res __asm__("er0"); \
411 register long _a __asm__("er1"); \
412 register long _b __asm__("er2"); \
413 register long _c __asm__("er3"); \
414 register long _d __asm__("er4"); \
415 register long _e __asm__("er5"); \
416 _a = (long)a; \
417 _b = (long)b; \
418 _c = (long)c; \
419 _d = (long)d; \
420 _e = (long)e; \
421 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
422 "trapa #0\n\t" \
423 : "=r" (__res) \
424 : "g" (__NR_##name), \
425 "g" (_a), \
426 "g" (_b), \
427 "g" (_c), \
428 "g" (_d), \
429 "g" (_e) \
430 : "cc", "memory"); \
431 __syscall_return(type, __res); \
432}
433
434#define _syscall6(type, name, atype, a, btype, b, \
435 ctype, c, dtype, d, etype, e, ftype, f) \
436type name(atype a, btype b, ctype c, dtype d, etype e, ftype f) \
437{ \
438 register long __res __asm__("er0"); \
439 register long _a __asm__("er1"); \
440 register long _b __asm__("er2"); \
441 register long _c __asm__("er3"); \
442 register long _d __asm__("er4"); \
443 register long _e __asm__("er5"); \
444 register long _f __asm__("er6"); \
445 _a = (long)a; \
446 _b = (long)b; \
447 _c = (long)c; \
448 _d = (long)d; \
449 _e = (long)e; \
450 _f = (long)f; \
451 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
452 "trapa #0\n\t" \
453 : "=r" (__res) \
454 : "g" (__NR_##name), \
455 "g" (_a), \
456 "g" (_b), \
457 "g" (_c), \
458 "g" (_d), \
459 "g" (_e) \
460 "g" (_f) \
461 : "cc", "memory"); \
462 __syscall_return(type, __res); \
463}
464 298
465#define __ARCH_WANT_IPC_PARSE_VERSION 299#define __ARCH_WANT_IPC_PARSE_VERSION
466#define __ARCH_WANT_OLD_READDIR 300#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-i386/Kbuild b/include/asm-i386/Kbuild
index 147e4ac1ebf0..5ae93afc67e1 100644
--- a/include/asm-i386/Kbuild
+++ b/include/asm-i386/Kbuild
@@ -7,5 +7,4 @@ header-y += ptrace-abi.h
7header-y += ucontext.h 7header-y += ucontext.h
8 8
9unifdef-y += mtrr.h 9unifdef-y += mtrr.h
10unifdef-y += setup.h
11unifdef-y += vm86.h 10unifdef-y += vm86.h
diff --git a/include/asm-i386/atomic.h b/include/asm-i386/atomic.h
index 6aab7a105fad..c57441bb2905 100644
--- a/include/asm-i386/atomic.h
+++ b/include/asm-i386/atomic.h
@@ -14,7 +14,7 @@
14 * on us. We need to use _exactly_ the address the user gave us, 14 * on us. We need to use _exactly_ the address the user gave us,
15 * not some alias that contains the same information. 15 * not some alias that contains the same information.
16 */ 16 */
17typedef struct { volatile int counter; } atomic_t; 17typedef struct { int counter; } atomic_t;
18 18
19#define ATOMIC_INIT(i) { (i) } 19#define ATOMIC_INIT(i) { (i) }
20 20
diff --git a/include/asm-i386/dma-mapping.h b/include/asm-i386/dma-mapping.h
index 81999a3ebe7c..183eebeebbdc 100644
--- a/include/asm-i386/dma-mapping.h
+++ b/include/asm-i386/dma-mapping.h
@@ -156,10 +156,10 @@ dma_get_cache_alignment(void)
156 return (1 << INTERNODE_CACHE_SHIFT); 156 return (1 << INTERNODE_CACHE_SHIFT);
157} 157}
158 158
159#define dma_is_consistent(d) (1) 159#define dma_is_consistent(d, h) (1)
160 160
161static inline void 161static inline void
162dma_cache_sync(void *vaddr, size_t size, 162dma_cache_sync(struct device *dev, void *vaddr, size_t size,
163 enum dma_data_direction direction) 163 enum dma_data_direction direction)
164{ 164{
165 flush_write_buffers(); 165 flush_write_buffers();
diff --git a/include/asm-i386/futex.h b/include/asm-i386/futex.h
index 946d97cfea23..438ef0ec7101 100644
--- a/include/asm-i386/futex.h
+++ b/include/asm-i386/futex.h
@@ -56,7 +56,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
56 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) 56 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
57 return -EFAULT; 57 return -EFAULT;
58 58
59 inc_preempt_count(); 59 pagefault_disable();
60 60
61 if (op == FUTEX_OP_SET) 61 if (op == FUTEX_OP_SET)
62 __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg); 62 __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
@@ -88,7 +88,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
88 } 88 }
89 } 89 }
90 90
91 dec_preempt_count(); 91 pagefault_enable();
92 92
93 if (!ret) { 93 if (!ret) {
94 switch (cmp) { 94 switch (cmp) {
diff --git a/include/asm-i386/mmzone.h b/include/asm-i386/mmzone.h
index 61b073322006..3503ad66945e 100644
--- a/include/asm-i386/mmzone.h
+++ b/include/asm-i386/mmzone.h
@@ -120,13 +120,26 @@ static inline int pfn_valid(int pfn)
120 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) 120 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
121#define alloc_bootmem_low_pages(x) \ 121#define alloc_bootmem_low_pages(x) \
122 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0) 122 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
123#define alloc_bootmem_node(ignore, x) \ 123#define alloc_bootmem_node(pgdat, x) \
124 __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) 124({ \
125#define alloc_bootmem_pages_node(ignore, x) \ 125 struct pglist_data __attribute__ ((unused)) \
126 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) 126 *__alloc_bootmem_node__pgdat = (pgdat); \
127#define alloc_bootmem_low_pages_node(ignore, x) \ 127 __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, \
128 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0) 128 __pa(MAX_DMA_ADDRESS)); \
129 129})
130#define alloc_bootmem_pages_node(pgdat, x) \
131({ \
132 struct pglist_data __attribute__ ((unused)) \
133 *__alloc_bootmem_node__pgdat = (pgdat); \
134 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, \
135 __pa(MAX_DMA_ADDRESS)) \
136})
137#define alloc_bootmem_low_pages_node(pgdat, x) \
138({ \
139 struct pglist_data __attribute__ ((unused)) \
140 *__alloc_bootmem_node__pgdat = (pgdat); \
141 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0); \
142})
130#endif /* CONFIG_NEED_MULTIPLE_NODES */ 143#endif /* CONFIG_NEED_MULTIPLE_NODES */
131 144
132#endif /* _ASM_MMZONE_H_ */ 145#endif /* _ASM_MMZONE_H_ */
diff --git a/include/asm-i386/param.h b/include/asm-i386/param.h
index 745dc5bd0fbc..21b32466fcdc 100644
--- a/include/asm-i386/param.h
+++ b/include/asm-i386/param.h
@@ -18,6 +18,5 @@
18#endif 18#endif
19 19
20#define MAXHOSTNAMELEN 64 /* max length of hostname */ 20#define MAXHOSTNAMELEN 64 /* max length of hostname */
21#define COMMAND_LINE_SIZE 256
22 21
23#endif 22#endif
diff --git a/include/asm-i386/pgtable.h b/include/asm-i386/pgtable.h
index b4a301f647ba..e6a4723f0eb1 100644
--- a/include/asm-i386/pgtable.h
+++ b/include/asm-i386/pgtable.h
@@ -35,14 +35,14 @@ struct vm_area_struct;
35#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) 35#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
36extern unsigned long empty_zero_page[1024]; 36extern unsigned long empty_zero_page[1024];
37extern pgd_t swapper_pg_dir[1024]; 37extern pgd_t swapper_pg_dir[1024];
38extern kmem_cache_t *pgd_cache; 38extern struct kmem_cache *pgd_cache;
39extern kmem_cache_t *pmd_cache; 39extern struct kmem_cache *pmd_cache;
40extern spinlock_t pgd_lock; 40extern spinlock_t pgd_lock;
41extern struct page *pgd_list; 41extern struct page *pgd_list;
42 42
43void pmd_ctor(void *, kmem_cache_t *, unsigned long); 43void pmd_ctor(void *, struct kmem_cache *, unsigned long);
44void pgd_ctor(void *, kmem_cache_t *, unsigned long); 44void pgd_ctor(void *, struct kmem_cache *, unsigned long);
45void pgd_dtor(void *, kmem_cache_t *, unsigned long); 45void pgd_dtor(void *, struct kmem_cache *, unsigned long);
46void pgtable_cache_init(void); 46void pgtable_cache_init(void);
47void paging_init(void); 47void paging_init(void);
48 48
diff --git a/include/asm-i386/rwsem.h b/include/asm-i386/rwsem.h
index bc598d6388e3..041906f3c6df 100644
--- a/include/asm-i386/rwsem.h
+++ b/include/asm-i386/rwsem.h
@@ -75,8 +75,8 @@ struct rw_semaphore {
75 75
76 76
77#define __RWSEM_INITIALIZER(name) \ 77#define __RWSEM_INITIALIZER(name) \
78{ RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, LIST_HEAD_INIT((name).wait_list) \ 78{ RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \
79 __RWSEM_DEP_MAP_INIT(name) } 79 LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) }
80 80
81#define DECLARE_RWSEM(name) \ 81#define DECLARE_RWSEM(name) \
82 struct rw_semaphore name = __RWSEM_INITIALIZER(name) 82 struct rw_semaphore name = __RWSEM_INITIALIZER(name)
diff --git a/include/asm-i386/setup.h b/include/asm-i386/setup.h
index 9930c5a355fc..67659dbaf120 100644
--- a/include/asm-i386/setup.h
+++ b/include/asm-i386/setup.h
@@ -6,6 +6,8 @@
6#ifndef _i386_SETUP_H 6#ifndef _i386_SETUP_H
7#define _i386_SETUP_H 7#define _i386_SETUP_H
8 8
9#define COMMAND_LINE_SIZE 256
10
9#ifdef __KERNEL__ 11#ifdef __KERNEL__
10#include <linux/pfn.h> 12#include <linux/pfn.h>
11 13
@@ -14,10 +16,8 @@
14 */ 16 */
15#define MAXMEM_PFN PFN_DOWN(MAXMEM) 17#define MAXMEM_PFN PFN_DOWN(MAXMEM)
16#define MAX_NONPAE_PFN (1 << 20) 18#define MAX_NONPAE_PFN (1 << 20)
17#endif
18 19
19#define PARAM_SIZE 4096 20#define PARAM_SIZE 4096
20#define COMMAND_LINE_SIZE 256
21 21
22#define OLD_CL_MAGIC_ADDR 0x90020 22#define OLD_CL_MAGIC_ADDR 0x90020
23#define OLD_CL_MAGIC 0xA33F 23#define OLD_CL_MAGIC 0xA33F
@@ -79,4 +79,6 @@ void __init add_memory_region(unsigned long long start,
79 79
80#endif /* __ASSEMBLY__ */ 80#endif /* __ASSEMBLY__ */
81 81
82#endif /* __KERNEL__ */
83
82#endif /* _i386_SETUP_H */ 84#endif /* _i386_SETUP_H */
diff --git a/include/asm-i386/spinlock_types.h b/include/asm-i386/spinlock_types.h
index 59efe849f351..4da9345c1500 100644
--- a/include/asm-i386/spinlock_types.h
+++ b/include/asm-i386/spinlock_types.h
@@ -6,13 +6,13 @@
6#endif 6#endif
7 7
8typedef struct { 8typedef struct {
9 volatile unsigned int slock; 9 unsigned int slock;
10} raw_spinlock_t; 10} raw_spinlock_t;
11 11
12#define __RAW_SPIN_LOCK_UNLOCKED { 1 } 12#define __RAW_SPIN_LOCK_UNLOCKED { 1 }
13 13
14typedef struct { 14typedef struct {
15 volatile unsigned int lock; 15 unsigned int lock;
16} raw_rwlock_t; 16} raw_rwlock_t;
17 17
18#define __RAW_RW_LOCK_UNLOCKED { RW_LOCK_BIAS } 18#define __RAW_RW_LOCK_UNLOCKED { RW_LOCK_BIAS }
diff --git a/include/asm-i386/suspend.h b/include/asm-i386/suspend.h
index 30361526d568..8dbaafe611ff 100644
--- a/include/asm-i386/suspend.h
+++ b/include/asm-i386/suspend.h
@@ -6,18 +6,7 @@
6#include <asm/desc.h> 6#include <asm/desc.h>
7#include <asm/i387.h> 7#include <asm/i387.h>
8 8
9static inline int 9static inline int arch_prepare_suspend(void) { return 0; }
10arch_prepare_suspend(void)
11{
12 /* If you want to make non-PSE machine work, turn off paging
13 in swsusp_arch_suspend. swsusp_pg_dir should have identity mapping, so
14 it could work... */
15 if (!cpu_has_pse) {
16 printk(KERN_ERR "PSE is required for swsusp.\n");
17 return -EPERM;
18 }
19 return 0;
20}
21 10
22/* image of the saved processor state */ 11/* image of the saved processor state */
23struct saved_context { 12struct saved_context {
diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h
index beeeaf6b054a..833fa1704ff9 100644
--- a/include/asm-i386/unistd.h
+++ b/include/asm-i386/unistd.h
@@ -329,104 +329,6 @@
329#ifdef __KERNEL__ 329#ifdef __KERNEL__
330 330
331#define NR_syscalls 320 331#define NR_syscalls 320
332#include <linux/err.h>
333
334/*
335 * user-visible error numbers are in the range -1 - -MAX_ERRNO: see
336 * <asm-i386/errno.h>
337 */
338#define __syscall_return(type, res) \
339do { \
340 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
341 errno = -(res); \
342 res = -1; \
343 } \
344 return (type) (res); \
345} while (0)
346
347/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
348#define _syscall0(type,name) \
349type name(void) \
350{ \
351long __res; \
352__asm__ volatile ("int $0x80" \
353 : "=a" (__res) \
354 : "0" (__NR_##name)); \
355__syscall_return(type,__res); \
356}
357
358#define _syscall1(type,name,type1,arg1) \
359type name(type1 arg1) \
360{ \
361long __res; \
362__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
363 : "=a" (__res) \
364 : "0" (__NR_##name),"ri" ((long)(arg1)) : "memory"); \
365__syscall_return(type,__res); \
366}
367
368#define _syscall2(type,name,type1,arg1,type2,arg2) \
369type name(type1 arg1,type2 arg2) \
370{ \
371long __res; \
372__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
373 : "=a" (__res) \
374 : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)) \
375 : "memory"); \
376__syscall_return(type,__res); \
377}
378
379#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
380type name(type1 arg1,type2 arg2,type3 arg3) \
381{ \
382long __res; \
383__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
384 : "=a" (__res) \
385 : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
386 "d" ((long)(arg3)) : "memory"); \
387__syscall_return(type,__res); \
388}
389
390#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
391type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
392{ \
393long __res; \
394__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
395 : "=a" (__res) \
396 : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
397 "d" ((long)(arg3)),"S" ((long)(arg4)) : "memory"); \
398__syscall_return(type,__res); \
399}
400
401#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
402 type5,arg5) \
403type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
404{ \
405long __res; \
406__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; movl %1,%%eax ; " \
407 "int $0x80 ; pop %%ebx" \
408 : "=a" (__res) \
409 : "i" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
410 "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
411 : "memory"); \
412__syscall_return(type,__res); \
413}
414
415#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
416 type5,arg5,type6,arg6) \
417type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
418{ \
419long __res; \
420 struct { long __a1; long __a6; } __s = { (long)arg1, (long)arg6 }; \
421__asm__ volatile ("push %%ebp ; push %%ebx ; movl 4(%2),%%ebp ; " \
422 "movl 0(%2),%%ebx ; movl %1,%%eax ; int $0x80 ; " \
423 "pop %%ebx ; pop %%ebp" \
424 : "=a" (__res) \
425 : "i" (__NR_##name),"0" ((long)(&__s)),"c" ((long)(arg2)), \
426 "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
427 : "memory"); \
428__syscall_return(type,__res); \
429}
430 332
431#define __ARCH_WANT_IPC_PARSE_VERSION 333#define __ARCH_WANT_IPC_PARSE_VERSION
432#define __ARCH_WANT_OLD_READDIR 334#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-ia64/Kbuild b/include/asm-ia64/Kbuild
index 15818a18bc52..4a1e48b9f403 100644
--- a/include/asm-ia64/Kbuild
+++ b/include/asm-ia64/Kbuild
@@ -10,7 +10,6 @@ header-y += intrinsics.h
10header-y += perfmon_default_smpl.h 10header-y += perfmon_default_smpl.h
11header-y += ptrace_offsets.h 11header-y += ptrace_offsets.h
12header-y += rse.h 12header-y += rse.h
13header-y += setup.h
14header-y += ucontext.h 13header-y += ucontext.h
15 14
16unifdef-y += perfmon.h 15unifdef-y += perfmon.h
diff --git a/include/asm-ia64/dma-mapping.h b/include/asm-ia64/dma-mapping.h
index 99a8f8e1218c..ebd5887f4b1a 100644
--- a/include/asm-ia64/dma-mapping.h
+++ b/include/asm-ia64/dma-mapping.h
@@ -50,7 +50,8 @@ dma_set_mask (struct device *dev, u64 mask)
50extern int dma_get_cache_alignment(void); 50extern int dma_get_cache_alignment(void);
51 51
52static inline void 52static inline void
53dma_cache_sync (void *vaddr, size_t size, enum dma_data_direction dir) 53dma_cache_sync (struct device *dev, void *vaddr, size_t size,
54 enum dma_data_direction dir)
54{ 55{
55 /* 56 /*
56 * IA-64 is cache-coherent, so this is mostly a no-op. However, we do need to 57 * IA-64 is cache-coherent, so this is mostly a no-op. However, we do need to
@@ -59,6 +60,6 @@ dma_cache_sync (void *vaddr, size_t size, enum dma_data_direction dir)
59 mb(); 60 mb();
60} 61}
61 62
62#define dma_is_consistent(dma_handle) (1) /* all we do is coherent memory... */ 63#define dma_is_consistent(d, h) (1) /* all we do is coherent memory... */
63 64
64#endif /* _ASM_IA64_DMA_MAPPING_H */ 65#endif /* _ASM_IA64_DMA_MAPPING_H */
diff --git a/include/asm-ia64/futex.h b/include/asm-ia64/futex.h
index 07d77f3a8cbe..8a98a2654139 100644
--- a/include/asm-ia64/futex.h
+++ b/include/asm-ia64/futex.h
@@ -59,7 +59,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
59 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) 59 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
60 return -EFAULT; 60 return -EFAULT;
61 61
62 inc_preempt_count(); 62 pagefault_disable();
63 63
64 switch (op) { 64 switch (op) {
65 case FUTEX_OP_SET: 65 case FUTEX_OP_SET:
@@ -83,7 +83,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
83 ret = -ENOSYS; 83 ret = -ENOSYS;
84 } 84 }
85 85
86 dec_preempt_count(); 86 pagefault_enable();
87 87
88 if (!ret) { 88 if (!ret) {
89 switch (cmp) { 89 switch (cmp) {
diff --git a/include/asm-ia64/pgalloc.h b/include/asm-ia64/pgalloc.h
index 9cb68e9b377e..393e04c42a2c 100644
--- a/include/asm-ia64/pgalloc.h
+++ b/include/asm-ia64/pgalloc.h
@@ -60,7 +60,7 @@ static inline void *pgtable_quicklist_alloc(void)
60static inline void pgtable_quicklist_free(void *pgtable_entry) 60static inline void pgtable_quicklist_free(void *pgtable_entry)
61{ 61{
62#ifdef CONFIG_NUMA 62#ifdef CONFIG_NUMA
63 unsigned long nid = page_to_nid(virt_to_page(pgtable_entry)); 63 int nid = page_to_nid(virt_to_page(pgtable_entry));
64 64
65 if (unlikely(nid != numa_node_id())) { 65 if (unlikely(nid != numa_node_id())) {
66 free_page((unsigned long)pgtable_entry); 66 free_page((unsigned long)pgtable_entry);
diff --git a/include/asm-m32r/setup.h b/include/asm-m32r/setup.h
index 52f4fa29abfc..6a0b32202d4e 100644
--- a/include/asm-m32r/setup.h
+++ b/include/asm-m32r/setup.h
@@ -1,6 +1,11 @@
1/* 1/*
2 * This is set up by the setup-routine at boot-time 2 * This is set up by the setup-routine at boot-time
3 */ 3 */
4
5#define COMMAND_LINE_SIZE 512
6
7#ifdef __KERNEL__
8
4#define PARAM ((unsigned char *)empty_zero_page) 9#define PARAM ((unsigned char *)empty_zero_page)
5 10
6#define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000)) 11#define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000))
@@ -18,8 +23,6 @@
18 23
19#define SCREEN_INFO (*(struct screen_info *) (PARAM+0x200)) 24#define SCREEN_INFO (*(struct screen_info *) (PARAM+0x200))
20 25
21#define COMMAND_LINE_SIZE (512)
22
23#define RAMDISK_IMAGE_START_MASK (0x07FF) 26#define RAMDISK_IMAGE_START_MASK (0x07FF)
24#define RAMDISK_PROMPT_FLAG (0x8000) 27#define RAMDISK_PROMPT_FLAG (0x8000)
25#define RAMDISK_LOAD_FLAG (0x4000) 28#define RAMDISK_LOAD_FLAG (0x4000)
@@ -27,3 +30,5 @@
27extern unsigned long memory_start; 30extern unsigned long memory_start;
28extern unsigned long memory_end; 31extern unsigned long memory_end;
29 32
33#endif /* __KERNEL__ */
34
diff --git a/include/asm-m32r/unistd.h b/include/asm-m32r/unistd.h
index 95aa34298d82..5b66bd3c6ed6 100644
--- a/include/asm-m32r/unistd.h
+++ b/include/asm-m32r/unistd.h
@@ -296,117 +296,6 @@
296#ifdef __KERNEL__ 296#ifdef __KERNEL__
297 297
298#define NR_syscalls 285 298#define NR_syscalls 285
299#include <linux/err.h>
300
301/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
302 * <asm-m32r/errno.h>
303 */
304
305#include <asm/syscall.h> /* SYSCALL_* */
306
307#define __syscall_return(type, res) \
308do { \
309 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
310 /* Avoid using "res" which is declared to be in register r0; \
311 errno might expand to a function call and clobber it. */ \
312 int __err = -(res); \
313 errno = __err; \
314 res = -1; \
315 } \
316 return (type) (res); \
317} while (0)
318
319#define _syscall0(type,name) \
320type name(void) \
321{ \
322register long __scno __asm__ ("r7") = __NR_##name; \
323register long __res __asm__("r0"); \
324__asm__ __volatile__ (\
325 "trap #" SYSCALL_VECTOR "|| nop"\
326 : "=r" (__res) \
327 : "r" (__scno) \
328 : "memory"); \
329__syscall_return(type,__res); \
330}
331
332#define _syscall1(type,name,type1,arg1) \
333type name(type1 arg1) \
334{ \
335register long __scno __asm__ ("r7") = __NR_##name; \
336register long __res __asm__ ("r0") = (long)(arg1); \
337__asm__ __volatile__ (\
338 "trap #" SYSCALL_VECTOR "|| nop"\
339 : "=r" (__res) \
340 : "r" (__scno), "0" (__res) \
341 : "memory"); \
342__syscall_return(type,__res); \
343}
344
345#define _syscall2(type,name,type1,arg1,type2,arg2) \
346type name(type1 arg1,type2 arg2) \
347{ \
348register long __scno __asm__ ("r7") = __NR_##name; \
349register long __arg2 __asm__ ("r1") = (long)(arg2); \
350register long __res __asm__ ("r0") = (long)(arg1); \
351__asm__ __volatile__ (\
352 "trap #" SYSCALL_VECTOR "|| nop"\
353 : "=r" (__res) \
354 : "r" (__scno), "0" (__res), "r" (__arg2) \
355 : "memory"); \
356__syscall_return(type,__res); \
357}
358
359#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
360type name(type1 arg1,type2 arg2,type3 arg3) \
361{ \
362register long __scno __asm__ ("r7") = __NR_##name; \
363register long __arg3 __asm__ ("r2") = (long)(arg3); \
364register long __arg2 __asm__ ("r1") = (long)(arg2); \
365register long __res __asm__ ("r0") = (long)(arg1); \
366__asm__ __volatile__ (\
367 "trap #" SYSCALL_VECTOR "|| nop"\
368 : "=r" (__res) \
369 : "r" (__scno), "0" (__res), "r" (__arg2), \
370 "r" (__arg3) \
371 : "memory"); \
372__syscall_return(type,__res); \
373}
374
375#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
376type name(type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
377{ \
378register long __scno __asm__ ("r7") = __NR_##name; \
379register long __arg4 __asm__ ("r3") = (long)(arg4); \
380register long __arg3 __asm__ ("r2") = (long)(arg3); \
381register long __arg2 __asm__ ("r1") = (long)(arg2); \
382register long __res __asm__ ("r0") = (long)(arg1); \
383__asm__ __volatile__ (\
384 "trap #" SYSCALL_VECTOR "|| nop"\
385 : "=r" (__res) \
386 : "r" (__scno), "0" (__res), "r" (__arg2), \
387 "r" (__arg3), "r" (__arg4) \
388 : "memory"); \
389__syscall_return(type,__res); \
390}
391
392#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
393 type5,arg5) \
394type name(type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
395{ \
396register long __scno __asm__ ("r7") = __NR_##name; \
397register long __arg5 __asm__ ("r4") = (long)(arg5); \
398register long __arg4 __asm__ ("r3") = (long)(arg4); \
399register long __arg3 __asm__ ("r2") = (long)(arg3); \
400register long __arg2 __asm__ ("r1") = (long)(arg2); \
401register long __res __asm__ ("r0") = (long)(arg1); \
402__asm__ __volatile__ (\
403 "trap #" SYSCALL_VECTOR "|| nop"\
404 : "=r" (__res) \
405 : "r" (__scno), "0" (__res), "r" (__arg2), \
406 "r" (__arg3), "r" (__arg4), "r" (__arg5) \
407 : "memory"); \
408__syscall_return(type,__res); \
409}
410 299
411#define __ARCH_WANT_IPC_PARSE_VERSION 300#define __ARCH_WANT_IPC_PARSE_VERSION
412#define __ARCH_WANT_STAT64 301#define __ARCH_WANT_STAT64
diff --git a/include/asm-m68k/dma-mapping.h b/include/asm-m68k/dma-mapping.h
index d90d841d3dfd..00259ed6fc95 100644
--- a/include/asm-m68k/dma-mapping.h
+++ b/include/asm-m68k/dma-mapping.h
@@ -21,7 +21,7 @@ static inline int dma_get_cache_alignment(void)
21 return 1 << L1_CACHE_SHIFT; 21 return 1 << L1_CACHE_SHIFT;
22} 22}
23 23
24static inline int dma_is_consistent(dma_addr_t dma_addr) 24static inline int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
25{ 25{
26 return 0; 26 return 0;
27} 27}
@@ -41,7 +41,7 @@ static inline void dma_free_noncoherent(struct device *dev, size_t size,
41{ 41{
42 dma_free_coherent(dev, size, addr, handle); 42 dma_free_coherent(dev, size, addr, handle);
43} 43}
44static inline void dma_cache_sync(void *vaddr, size_t size, 44static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
45 enum dma_data_direction dir) 45 enum dma_data_direction dir)
46{ 46{
47 /* we use coherent allocation, so not much to do here. */ 47 /* we use coherent allocation, so not much to do here. */
diff --git a/include/asm-m68k/setup.h b/include/asm-m68k/setup.h
index 7facc9a46e74..2a8853cd6554 100644
--- a/include/asm-m68k/setup.h
+++ b/include/asm-m68k/setup.h
@@ -41,8 +41,12 @@
41#define MACH_Q40 10 41#define MACH_Q40 10
42#define MACH_SUN3X 11 42#define MACH_SUN3X 11
43 43
44#define COMMAND_LINE_SIZE 256
45
44#ifdef __KERNEL__ 46#ifdef __KERNEL__
45 47
48#define CL_SIZE COMMAND_LINE_SIZE
49
46#ifndef __ASSEMBLY__ 50#ifndef __ASSEMBLY__
47extern unsigned long m68k_machtype; 51extern unsigned long m68k_machtype;
48#endif /* !__ASSEMBLY__ */ 52#endif /* !__ASSEMBLY__ */
@@ -355,8 +359,6 @@ extern int m68k_is040or060;
355 */ 359 */
356 360
357#define NUM_MEMINFO 4 361#define NUM_MEMINFO 4
358#define CL_SIZE 256
359#define COMMAND_LINE_SIZE CL_SIZE
360 362
361#ifndef __ASSEMBLY__ 363#ifndef __ASSEMBLY__
362struct mem_info { 364struct mem_info {
diff --git a/include/asm-m68k/unistd.h b/include/asm-m68k/unistd.h
index ad4348058c66..fdbb60e6a0d4 100644
--- a/include/asm-m68k/unistd.h
+++ b/include/asm-m68k/unistd.h
@@ -317,103 +317,6 @@
317#ifdef __KERNEL__ 317#ifdef __KERNEL__
318 318
319#define NR_syscalls 311 319#define NR_syscalls 311
320#include <linux/err.h>
321
322/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
323 <asm-m68k/errno.h> */
324
325#define __syscall_return(type, res) \
326do { \
327 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
328 /* avoid using res which is declared to be in register d0; \
329 errno might expand to a function call and clobber it. */ \
330 int __err = -(res); \
331 errno = __err; \
332 res = -1; \
333 } \
334 return (type) (res); \
335} while (0)
336
337#define _syscall0(type,name) \
338type name(void) \
339{ \
340register long __res __asm__ ("%d0") = __NR_##name; \
341__asm__ __volatile__ ("trap #0" \
342 : "+d" (__res) ); \
343__syscall_return(type,__res); \
344}
345
346#define _syscall1(type,name,atype,a) \
347type name(atype a) \
348{ \
349register long __res __asm__ ("%d0") = __NR_##name; \
350register long __a __asm__ ("%d1") = (long)(a); \
351__asm__ __volatile__ ("trap #0" \
352 : "+d" (__res) \
353 : "d" (__a) ); \
354__syscall_return(type,__res); \
355}
356
357#define _syscall2(type,name,atype,a,btype,b) \
358type name(atype a,btype b) \
359{ \
360register long __res __asm__ ("%d0") = __NR_##name; \
361register long __a __asm__ ("%d1") = (long)(a); \
362register long __b __asm__ ("%d2") = (long)(b); \
363__asm__ __volatile__ ("trap #0" \
364 : "+d" (__res) \
365 : "d" (__a), "d" (__b) \
366 ); \
367__syscall_return(type,__res); \
368}
369
370#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
371type name(atype a,btype b,ctype c) \
372{ \
373register long __res __asm__ ("%d0") = __NR_##name; \
374register long __a __asm__ ("%d1") = (long)(a); \
375register long __b __asm__ ("%d2") = (long)(b); \
376register long __c __asm__ ("%d3") = (long)(c); \
377__asm__ __volatile__ ("trap #0" \
378 : "+d" (__res) \
379 : "d" (__a), "d" (__b), \
380 "d" (__c) \
381 ); \
382__syscall_return(type,__res); \
383}
384
385#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
386type name (atype a, btype b, ctype c, dtype d) \
387{ \
388register long __res __asm__ ("%d0") = __NR_##name; \
389register long __a __asm__ ("%d1") = (long)(a); \
390register long __b __asm__ ("%d2") = (long)(b); \
391register long __c __asm__ ("%d3") = (long)(c); \
392register long __d __asm__ ("%d4") = (long)(d); \
393__asm__ __volatile__ ("trap #0" \
394 : "+d" (__res) \
395 : "d" (__a), "d" (__b), \
396 "d" (__c), "d" (__d) \
397 ); \
398__syscall_return(type,__res); \
399}
400
401#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
402type name (atype a,btype b,ctype c,dtype d,etype e) \
403{ \
404register long __res __asm__ ("%d0") = __NR_##name; \
405register long __a __asm__ ("%d1") = (long)(a); \
406register long __b __asm__ ("%d2") = (long)(b); \
407register long __c __asm__ ("%d3") = (long)(c); \
408register long __d __asm__ ("%d4") = (long)(d); \
409register long __e __asm__ ("%d5") = (long)(e); \
410__asm__ __volatile__ ("trap #0" \
411 : "+d" (__res) \
412 : "d" (__a), "d" (__b), \
413 "d" (__c), "d" (__d), "d" (__e) \
414 ); \
415__syscall_return(type,__res); \
416}
417 320
418#define __ARCH_WANT_IPC_PARSE_VERSION 321#define __ARCH_WANT_IPC_PARSE_VERSION
419#define __ARCH_WANT_OLD_READDIR 322#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-m68knommu/irq.h b/include/asm-m68knommu/irq.h
index 45e7a2fd1689..7b8f874f8429 100644
--- a/include/asm-m68knommu/irq.h
+++ b/include/asm-m68knommu/irq.h
@@ -86,5 +86,6 @@ extern void (*mach_disable_irq)(unsigned int);
86#define enable_irq(x) do { } while (0) 86#define enable_irq(x) do { } while (0)
87#define disable_irq(x) do { } while (0) 87#define disable_irq(x) do { } while (0)
88#define disable_irq_nosync(x) disable_irq(x) 88#define disable_irq_nosync(x) disable_irq(x)
89#define irq_canonicalize(irq) (irq)
89 90
90#endif /* _M68K_IRQ_H_ */ 91#endif /* _M68K_IRQ_H_ */
diff --git a/include/asm-m68knommu/rtc.h b/include/asm-m68knommu/rtc.h
new file mode 100644
index 000000000000..eaf18ec83c8e
--- /dev/null
+++ b/include/asm-m68knommu/rtc.h
@@ -0,0 +1 @@
#include <asm-m68k/rtc.h>
diff --git a/include/asm-m68knommu/setup.h b/include/asm-m68knommu/setup.h
index d2b0fcce41b2..fb86bb2a6078 100644
--- a/include/asm-m68knommu/setup.h
+++ b/include/asm-m68knommu/setup.h
@@ -1,5 +1,10 @@
1#ifdef __KERNEL__
2
1#include <asm-m68k/setup.h> 3#include <asm-m68k/setup.h>
2 4
3/* We have a bigger command line buffer. */ 5/* We have a bigger command line buffer. */
4#undef COMMAND_LINE_SIZE 6#undef COMMAND_LINE_SIZE
7
8#endif /* __KERNEL__ */
9
5#define COMMAND_LINE_SIZE 512 10#define COMMAND_LINE_SIZE 512
diff --git a/include/asm-m68knommu/ucontext.h b/include/asm-m68knommu/ucontext.h
index 5d570cedbb02..713a27f901cd 100644
--- a/include/asm-m68knommu/ucontext.h
+++ b/include/asm-m68knommu/ucontext.h
@@ -5,21 +5,17 @@ typedef int greg_t;
5#define NGREG 18 5#define NGREG 18
6typedef greg_t gregset_t[NGREG]; 6typedef greg_t gregset_t[NGREG];
7 7
8#ifdef CONFIG_FPU
9typedef struct fpregset { 8typedef struct fpregset {
10 int f_pcr; 9 int f_pcr;
11 int f_psr; 10 int f_psr;
12 int f_fpiaddr; 11 int f_fpiaddr;
13 int f_fpregs[8][3]; 12 int f_fpregs[8][3];
14} fpregset_t; 13} fpregset_t;
15#endif
16 14
17struct mcontext { 15struct mcontext {
18 int version; 16 int version;
19 gregset_t gregs; 17 gregset_t gregs;
20#ifdef CONFIG_FPU
21 fpregset_t fpregs; 18 fpregset_t fpregs;
22#endif
23}; 19};
24 20
25#define MCONTEXT_VERSION 2 21#define MCONTEXT_VERSION 2
@@ -29,9 +25,7 @@ struct ucontext {
29 struct ucontext *uc_link; 25 struct ucontext *uc_link;
30 stack_t uc_stack; 26 stack_t uc_stack;
31 struct mcontext uc_mcontext; 27 struct mcontext uc_mcontext;
32#ifdef CONFIG_FPU
33 unsigned long uc_filler[80]; 28 unsigned long uc_filler[80];
34#endif
35 sigset_t uc_sigmask; /* mask last for extensibility */ 29 sigset_t uc_sigmask; /* mask last for extensibility */
36}; 30};
37 31
diff --git a/include/asm-m68knommu/unistd.h b/include/asm-m68knommu/unistd.h
index ebaf03197114..82e03195f325 100644
--- a/include/asm-m68knommu/unistd.h
+++ b/include/asm-m68knommu/unistd.h
@@ -318,156 +318,6 @@
318#ifdef __KERNEL__ 318#ifdef __KERNEL__
319 319
320#define NR_syscalls 311 320#define NR_syscalls 311
321#include <linux/err.h>
322
323/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
324 <asm-m68k/errno.h> */
325
326#define __syscall_return(type, res) \
327do { \
328 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
329 /* avoid using res which is declared to be in register d0; \
330 errno might expand to a function call and clobber it. */ \
331 int __err = -(res); \
332 errno = __err; \
333 res = -1; \
334 } \
335 return (type) (res); \
336} while (0)
337
338#define _syscall0(type, name) \
339type name(void) \
340{ \
341 long __res; \
342 __asm__ __volatile__ ("movel %1, %%d0\n\t" \
343 "trap #0\n\t" \
344 "movel %%d0, %0" \
345 : "=g" (__res) \
346 : "i" (__NR_##name) \
347 : "cc", "%d0"); \
348 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
349 errno = -__res; \
350 __res = -1; \
351 } \
352 return (type)__res; \
353}
354
355#define _syscall1(type, name, atype, a) \
356type name(atype a) \
357{ \
358 long __res; \
359 __asm__ __volatile__ ("movel %2, %%d1\n\t" \
360 "movel %1, %%d0\n\t" \
361 "trap #0\n\t" \
362 "movel %%d0, %0" \
363 : "=g" (__res) \
364 : "i" (__NR_##name), \
365 "g" ((long)a) \
366 : "cc", "%d0", "%d1"); \
367 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
368 errno = -__res; \
369 __res = -1; \
370 } \
371 return (type)__res; \
372}
373
374#define _syscall2(type, name, atype, a, btype, b) \
375type name(atype a, btype b) \
376{ \
377 long __res; \
378 __asm__ __volatile__ ("movel %3, %%d2\n\t" \
379 "movel %2, %%d1\n\t" \
380 "movel %1, %%d0\n\t" \
381 "trap #0\n\t" \
382 "movel %%d0, %0" \
383 : "=g" (__res) \
384 : "i" (__NR_##name), \
385 "a" ((long)a), \
386 "g" ((long)b) \
387 : "cc", "%d0", "%d1", "%d2"); \
388 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
389 errno = -__res; \
390 __res = -1; \
391 } \
392 return (type)__res; \
393}
394
395#define _syscall3(type, name, atype, a, btype, b, ctype, c) \
396type name(atype a, btype b, ctype c) \
397{ \
398 long __res; \
399 __asm__ __volatile__ ("movel %4, %%d3\n\t" \
400 "movel %3, %%d2\n\t" \
401 "movel %2, %%d1\n\t" \
402 "movel %1, %%d0\n\t" \
403 "trap #0\n\t" \
404 "movel %%d0, %0" \
405 : "=g" (__res) \
406 : "i" (__NR_##name), \
407 "a" ((long)a), \
408 "a" ((long)b), \
409 "g" ((long)c) \
410 : "cc", "%d0", "%d1", "%d2", "%d3"); \
411 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
412 errno = -__res; \
413 __res = -1; \
414 } \
415 return (type)__res; \
416}
417
418#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d) \
419type name(atype a, btype b, ctype c, dtype d) \
420{ \
421 long __res; \
422 __asm__ __volatile__ ("movel %5, %%d4\n\t" \
423 "movel %4, %%d3\n\t" \
424 "movel %3, %%d2\n\t" \
425 "movel %2, %%d1\n\t" \
426 "movel %1, %%d0\n\t" \
427 "trap #0\n\t" \
428 "movel %%d0, %0" \
429 : "=g" (__res) \
430 : "i" (__NR_##name), \
431 "a" ((long)a), \
432 "a" ((long)b), \
433 "a" ((long)c), \
434 "g" ((long)d) \
435 : "cc", "%d0", "%d1", "%d2", "%d3", \
436 "%d4"); \
437 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
438 errno = -__res; \
439 __res = -1; \
440 } \
441 return (type)__res; \
442}
443
444#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e) \
445type name(atype a, btype b, ctype c, dtype d, etype e) \
446{ \
447 long __res; \
448 __asm__ __volatile__ ("movel %6, %%d5\n\t" \
449 "movel %5, %%d4\n\t" \
450 "movel %4, %%d3\n\t" \
451 "movel %3, %%d2\n\t" \
452 "movel %2, %%d1\n\t" \
453 "movel %1, %%d0\n\t" \
454 "trap #0\n\t" \
455 "movel %%d0, %0" \
456 : "=g" (__res) \
457 : "i" (__NR_##name), \
458 "a" ((long)a), \
459 "a" ((long)b), \
460 "a" ((long)c), \
461 "a" ((long)d), \
462 "g" ((long)e) \
463 : "cc", "%d0", "%d1", "%d2", "%d3", \
464 "%d4", "%d5"); \
465 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
466 errno = -__res; \
467 __res = -1; \
468 } \
469 return (type)__res; \
470}
471 321
472#define __ARCH_WANT_IPC_PARSE_VERSION 322#define __ARCH_WANT_IPC_PARSE_VERSION
473#define __ARCH_WANT_OLD_READDIR 323#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-mips/dma-mapping.h b/include/asm-mips/dma-mapping.h
index 43288634c38a..236d1a467cc7 100644
--- a/include/asm-mips/dma-mapping.h
+++ b/include/asm-mips/dma-mapping.h
@@ -63,9 +63,9 @@ dma_get_cache_alignment(void)
63 return 128; 63 return 128;
64} 64}
65 65
66extern int dma_is_consistent(dma_addr_t dma_addr); 66extern int dma_is_consistent(struct device *dev, dma_addr_t dma_addr);
67 67
68extern void dma_cache_sync(void *vaddr, size_t size, 68extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
69 enum dma_data_direction direction); 69 enum dma_data_direction direction);
70 70
71#define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY 71#define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
diff --git a/include/asm-mips/futex.h b/include/asm-mips/futex.h
index 927a216bd530..47e5679c2353 100644
--- a/include/asm-mips/futex.h
+++ b/include/asm-mips/futex.h
@@ -88,7 +88,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
88 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) 88 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
89 return -EFAULT; 89 return -EFAULT;
90 90
91 inc_preempt_count(); 91 pagefault_disable();
92 92
93 switch (op) { 93 switch (op) {
94 case FUTEX_OP_SET: 94 case FUTEX_OP_SET:
@@ -115,7 +115,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
115 ret = -ENOSYS; 115 ret = -ENOSYS;
116 } 116 }
117 117
118 dec_preempt_count(); 118 pagefault_enable();
119 119
120 if (!ret) { 120 if (!ret) {
121 switch (cmp) { 121 switch (cmp) {
diff --git a/include/asm-mips/highmem.h b/include/asm-mips/highmem.h
index c976bfaaba83..f8c8182f7f2e 100644
--- a/include/asm-mips/highmem.h
+++ b/include/asm-mips/highmem.h
@@ -21,6 +21,7 @@
21 21
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/uaccess.h>
24#include <asm/kmap_types.h> 25#include <asm/kmap_types.h>
25 26
26/* undef for production */ 27/* undef for production */
@@ -70,11 +71,16 @@ static inline void *kmap(struct page *page)
70 71
71static inline void *kmap_atomic(struct page *page, enum km_type type) 72static inline void *kmap_atomic(struct page *page, enum km_type type)
72{ 73{
74 pagefault_disable();
73 return page_address(page); 75 return page_address(page);
74} 76}
75 77
76static inline void kunmap_atomic(void *kvaddr, enum km_type type) { } 78static inline void kunmap_atomic(void *kvaddr, enum km_type type)
77#define kmap_atomic_pfn(pfn, idx) page_address(pfn_to_page(pfn)) 79{
80 pagefault_enable();
81}
82
83#define kmap_atomic_pfn(pfn, idx) kmap_atomic(pfn_to_page(pfn), (idx))
78 84
79#define kmap_atomic_to_page(ptr) virt_to_page(ptr) 85#define kmap_atomic_to_page(ptr) virt_to_page(ptr)
80 86
diff --git a/include/asm-mips/i8259.h b/include/asm-mips/i8259.h
index 0214abe3f0af..4df8d8b118c0 100644
--- a/include/asm-mips/i8259.h
+++ b/include/asm-mips/i8259.h
@@ -19,10 +19,31 @@
19 19
20#include <asm/io.h> 20#include <asm/io.h>
21 21
22/* i8259A PIC registers */
23#define PIC_MASTER_CMD 0x20
24#define PIC_MASTER_IMR 0x21
25#define PIC_MASTER_ISR PIC_MASTER_CMD
26#define PIC_MASTER_POLL PIC_MASTER_ISR
27#define PIC_MASTER_OCW3 PIC_MASTER_ISR
28#define PIC_SLAVE_CMD 0xa0
29#define PIC_SLAVE_IMR 0xa1
30
31/* i8259A PIC related value */
32#define PIC_CASCADE_IR 2
33#define MASTER_ICW4_DEFAULT 0x01
34#define SLAVE_ICW4_DEFAULT 0x01
35#define PIC_ICW4_AEOI 2
36
22extern spinlock_t i8259A_lock; 37extern spinlock_t i8259A_lock;
23 38
39extern void init_8259A(int auto_eoi);
40extern void enable_8259A_irq(unsigned int irq);
41extern void disable_8259A_irq(unsigned int irq);
42
24extern void init_i8259_irqs(void); 43extern void init_i8259_irqs(void);
25 44
45#define I8259A_IRQ_BASE 0
46
26/* 47/*
27 * Do the traditional i8259 interrupt polling thing. This is for the few 48 * Do the traditional i8259 interrupt polling thing. This is for the few
28 * cases where no better interrupt acknowledge method is available and we 49 * cases where no better interrupt acknowledge method is available and we
@@ -35,15 +56,15 @@ static inline int i8259_irq(void)
35 spin_lock(&i8259A_lock); 56 spin_lock(&i8259A_lock);
36 57
37 /* Perform an interrupt acknowledge cycle on controller 1. */ 58 /* Perform an interrupt acknowledge cycle on controller 1. */
38 outb(0x0C, 0x20); /* prepare for poll */ 59 outb(0x0C, PIC_MASTER_CMD); /* prepare for poll */
39 irq = inb(0x20) & 7; 60 irq = inb(PIC_MASTER_CMD) & 7;
40 if (irq == 2) { 61 if (irq == PIC_CASCADE_IR) {
41 /* 62 /*
42 * Interrupt is cascaded so perform interrupt 63 * Interrupt is cascaded so perform interrupt
43 * acknowledge on controller 2. 64 * acknowledge on controller 2.
44 */ 65 */
45 outb(0x0C, 0xA0); /* prepare for poll */ 66 outb(0x0C, PIC_SLAVE_CMD); /* prepare for poll */
46 irq = (inb(0xA0) & 7) + 8; 67 irq = (inb(PIC_SLAVE_CMD) & 7) + 8;
47 } 68 }
48 69
49 if (unlikely(irq == 7)) { 70 if (unlikely(irq == 7)) {
@@ -54,14 +75,14 @@ static inline int i8259_irq(void)
54 * significant bit is not set then there is no valid 75 * significant bit is not set then there is no valid
55 * interrupt. 76 * interrupt.
56 */ 77 */
57 outb(0x0B, 0x20); /* ISR register */ 78 outb(0x0B, PIC_MASTER_ISR); /* ISR register */
58 if(~inb(0x20) & 0x80) 79 if(~inb(PIC_MASTER_ISR) & 0x80)
59 irq = -1; 80 irq = -1;
60 } 81 }
61 82
62 spin_unlock(&i8259A_lock); 83 spin_unlock(&i8259A_lock);
63 84
64 return irq; 85 return likely(irq >= 0) ? irq + I8259A_IRQ_BASE : irq;
65} 86}
66 87
67#endif /* _ASM_I8259_H */ 88#endif /* _ASM_I8259_H */
diff --git a/include/asm-mips/pgtable-32.h b/include/asm-mips/pgtable-32.h
index d20f2e9b28be..2fbd47eba32d 100644
--- a/include/asm-mips/pgtable-32.h
+++ b/include/asm-mips/pgtable-32.h
@@ -156,9 +156,9 @@ pfn_pte(unsigned long pfn, pgprot_t prot)
156#define __pte_offset(address) \ 156#define __pte_offset(address) \
157 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) 157 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
158#define pte_offset(dir, address) \ 158#define pte_offset(dir, address) \
159 ((pte_t *) (pmd_page_vaddr(*dir)) + __pte_offset(address)) 159 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
160#define pte_offset_kernel(dir, address) \ 160#define pte_offset_kernel(dir, address) \
161 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address)) 161 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
162 162
163#define pte_offset_map(dir, address) \ 163#define pte_offset_map(dir, address) \
164 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address)) 164 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
diff --git a/include/asm-mips/pgtable-64.h b/include/asm-mips/pgtable-64.h
index b9b1e86493ee..a5b18710b6a4 100644
--- a/include/asm-mips/pgtable-64.h
+++ b/include/asm-mips/pgtable-64.h
@@ -212,9 +212,9 @@ static inline pmd_t *pmd_offset(pud_t * pud, unsigned long address)
212#define __pte_offset(address) \ 212#define __pte_offset(address) \
213 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) 213 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
214#define pte_offset(dir, address) \ 214#define pte_offset(dir, address) \
215 ((pte_t *) (pmd_page_vaddr(*dir)) + __pte_offset(address)) 215 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
216#define pte_offset_kernel(dir, address) \ 216#define pte_offset_kernel(dir, address) \
217 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address)) 217 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
218#define pte_offset_map(dir, address) \ 218#define pte_offset_map(dir, address) \
219 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address)) 219 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
220#define pte_offset_map_nested(dir, address) \ 220#define pte_offset_map_nested(dir, address) \
diff --git a/include/asm-mips/setup.h b/include/asm-mips/setup.h
index 737fa4a6912e..70009a902639 100644
--- a/include/asm-mips/setup.h
+++ b/include/asm-mips/setup.h
@@ -1,8 +1,6 @@
1#ifdef __KERNEL__
2#ifndef _MIPS_SETUP_H 1#ifndef _MIPS_SETUP_H
3#define _MIPS_SETUP_H 2#define _MIPS_SETUP_H
4 3
5#define COMMAND_LINE_SIZE 256 4#define COMMAND_LINE_SIZE 256
6 5
7#endif /* __SETUP_H */ 6#endif /* __SETUP_H */
8#endif /* __KERNEL__ */
diff --git a/include/asm-mips/unistd.h b/include/asm-mips/unistd.h
index ec56aa52f669..696cff39a1d3 100644
--- a/include/asm-mips/unistd.h
+++ b/include/asm-mips/unistd.h
@@ -933,268 +933,6 @@
933 933
934#ifndef __ASSEMBLY__ 934#ifndef __ASSEMBLY__
935 935
936/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
937#define _syscall0(type,name) \
938type name(void) \
939{ \
940 register unsigned long __a3 asm("$7"); \
941 unsigned long __v0; \
942 \
943 __asm__ volatile ( \
944 ".set\tnoreorder\n\t" \
945 "li\t$2, %2\t\t\t# " #name "\n\t" \
946 "syscall\n\t" \
947 "move\t%0, $2\n\t" \
948 ".set\treorder" \
949 : "=&r" (__v0), "=r" (__a3) \
950 : "i" (__NR_##name) \
951 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
952 "memory"); \
953 \
954 if (__a3 == 0) \
955 return (type) __v0; \
956 errno = __v0; \
957 return (type) -1; \
958}
959
960/*
961 * DANGER: This macro isn't usable for the pipe(2) call
962 * which has a unusual return convention.
963 */
964#define _syscall1(type,name,atype,a) \
965type name(atype a) \
966{ \
967 register unsigned long __a0 asm("$4") = (unsigned long) a; \
968 register unsigned long __a3 asm("$7"); \
969 unsigned long __v0; \
970 \
971 __asm__ volatile ( \
972 ".set\tnoreorder\n\t" \
973 "li\t$2, %3\t\t\t# " #name "\n\t" \
974 "syscall\n\t" \
975 "move\t%0, $2\n\t" \
976 ".set\treorder" \
977 : "=&r" (__v0), "=r" (__a3) \
978 : "r" (__a0), "i" (__NR_##name) \
979 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
980 "memory"); \
981 \
982 if (__a3 == 0) \
983 return (type) __v0; \
984 errno = __v0; \
985 return (type) -1; \
986}
987
988#define _syscall2(type,name,atype,a,btype,b) \
989type name(atype a, btype b) \
990{ \
991 register unsigned long __a0 asm("$4") = (unsigned long) a; \
992 register unsigned long __a1 asm("$5") = (unsigned long) b; \
993 register unsigned long __a3 asm("$7"); \
994 unsigned long __v0; \
995 \
996 __asm__ volatile ( \
997 ".set\tnoreorder\n\t" \
998 "li\t$2, %4\t\t\t# " #name "\n\t" \
999 "syscall\n\t" \
1000 "move\t%0, $2\n\t" \
1001 ".set\treorder" \
1002 : "=&r" (__v0), "=r" (__a3) \
1003 : "r" (__a0), "r" (__a1), "i" (__NR_##name) \
1004 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1005 "memory"); \
1006 \
1007 if (__a3 == 0) \
1008 return (type) __v0; \
1009 errno = __v0; \
1010 return (type) -1; \
1011}
1012
1013#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
1014type name(atype a, btype b, ctype c) \
1015{ \
1016 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1017 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1018 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1019 register unsigned long __a3 asm("$7"); \
1020 unsigned long __v0; \
1021 \
1022 __asm__ volatile ( \
1023 ".set\tnoreorder\n\t" \
1024 "li\t$2, %5\t\t\t# " #name "\n\t" \
1025 "syscall\n\t" \
1026 "move\t%0, $2\n\t" \
1027 ".set\treorder" \
1028 : "=&r" (__v0), "=r" (__a3) \
1029 : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name) \
1030 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1031 "memory"); \
1032 \
1033 if (__a3 == 0) \
1034 return (type) __v0; \
1035 errno = __v0; \
1036 return (type) -1; \
1037}
1038
1039#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
1040type name(atype a, btype b, ctype c, dtype d) \
1041{ \
1042 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1043 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1044 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1045 register unsigned long __a3 asm("$7") = (unsigned long) d; \
1046 unsigned long __v0; \
1047 \
1048 __asm__ volatile ( \
1049 ".set\tnoreorder\n\t" \
1050 "li\t$2, %5\t\t\t# " #name "\n\t" \
1051 "syscall\n\t" \
1052 "move\t%0, $2\n\t" \
1053 ".set\treorder" \
1054 : "=&r" (__v0), "+r" (__a3) \
1055 : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name) \
1056 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1057 "memory"); \
1058 \
1059 if (__a3 == 0) \
1060 return (type) __v0; \
1061 errno = __v0; \
1062 return (type) -1; \
1063}
1064
1065#if (_MIPS_SIM == _MIPS_SIM_ABI32)
1066
1067/*
1068 * Using those means your brain needs more than an oil change ;-)
1069 */
1070
1071#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
1072type name(atype a, btype b, ctype c, dtype d, etype e) \
1073{ \
1074 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1075 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1076 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1077 register unsigned long __a3 asm("$7") = (unsigned long) d; \
1078 unsigned long __v0; \
1079 \
1080 __asm__ volatile ( \
1081 ".set\tnoreorder\n\t" \
1082 "lw\t$2, %6\n\t" \
1083 "subu\t$29, 32\n\t" \
1084 "sw\t$2, 16($29)\n\t" \
1085 "li\t$2, %5\t\t\t# " #name "\n\t" \
1086 "syscall\n\t" \
1087 "move\t%0, $2\n\t" \
1088 "addiu\t$29, 32\n\t" \
1089 ".set\treorder" \
1090 : "=&r" (__v0), "+r" (__a3) \
1091 : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name), \
1092 "m" ((unsigned long)e) \
1093 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1094 "memory"); \
1095 \
1096 if (__a3 == 0) \
1097 return (type) __v0; \
1098 errno = __v0; \
1099 return (type) -1; \
1100}
1101
1102#define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \
1103type name(atype a, btype b, ctype c, dtype d, etype e, ftype f) \
1104{ \
1105 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1106 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1107 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1108 register unsigned long __a3 asm("$7") = (unsigned long) d; \
1109 unsigned long __v0; \
1110 \
1111 __asm__ volatile ( \
1112 ".set\tnoreorder\n\t" \
1113 "lw\t$2, %6\n\t" \
1114 "lw\t$8, %7\n\t" \
1115 "subu\t$29, 32\n\t" \
1116 "sw\t$2, 16($29)\n\t" \
1117 "sw\t$8, 20($29)\n\t" \
1118 "li\t$2, %5\t\t\t# " #name "\n\t" \
1119 "syscall\n\t" \
1120 "move\t%0, $2\n\t" \
1121 "addiu\t$29, 32\n\t" \
1122 ".set\treorder" \
1123 : "=&r" (__v0), "+r" (__a3) \
1124 : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name), \
1125 "m" ((unsigned long)e), "m" ((unsigned long)f) \
1126 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1127 "memory"); \
1128 \
1129 if (__a3 == 0) \
1130 return (type) __v0; \
1131 errno = __v0; \
1132 return (type) -1; \
1133}
1134
1135#endif /* (_MIPS_SIM == _MIPS_SIM_ABI32) */
1136
1137#if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
1138
1139#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
1140type name (atype a,btype b,ctype c,dtype d,etype e) \
1141{ \
1142 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1143 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1144 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1145 register unsigned long __a3 asm("$7") = (unsigned long) d; \
1146 register unsigned long __a4 asm("$8") = (unsigned long) e; \
1147 unsigned long __v0; \
1148 \
1149 __asm__ volatile ( \
1150 ".set\tnoreorder\n\t" \
1151 "li\t$2, %6\t\t\t# " #name "\n\t" \
1152 "syscall\n\t" \
1153 "move\t%0, $2\n\t" \
1154 ".set\treorder" \
1155 : "=&r" (__v0), "+r" (__a3) \
1156 : "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), "i" (__NR_##name) \
1157 : "$2", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1158 "memory"); \
1159 \
1160 if (__a3 == 0) \
1161 return (type) __v0; \
1162 errno = __v0; \
1163 return (type) -1; \
1164}
1165
1166#define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \
1167type name (atype a,btype b,ctype c,dtype d,etype e,ftype f) \
1168{ \
1169 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1170 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1171 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1172 register unsigned long __a3 asm("$7") = (unsigned long) d; \
1173 register unsigned long __a4 asm("$8") = (unsigned long) e; \
1174 register unsigned long __a5 asm("$9") = (unsigned long) f; \
1175 unsigned long __v0; \
1176 \
1177 __asm__ volatile ( \
1178 ".set\tnoreorder\n\t" \
1179 "li\t$2, %7\t\t\t# " #name "\n\t" \
1180 "syscall\n\t" \
1181 "move\t%0, $2\n\t" \
1182 ".set\treorder" \
1183 : "=&r" (__v0), "+r" (__a3) \
1184 : "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), "r" (__a5), \
1185 "i" (__NR_##name) \
1186 : "$2", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1187 "memory"); \
1188 \
1189 if (__a3 == 0) \
1190 return (type) __v0; \
1191 errno = __v0; \
1192 return (type) -1; \
1193}
1194
1195#endif /* (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64) */
1196
1197
1198#define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 936#define __ARCH_OMIT_COMPAT_SYS_GETDENTS64
1199#define __ARCH_WANT_IPC_PARSE_VERSION 937#define __ARCH_WANT_IPC_PARSE_VERSION
1200#define __ARCH_WANT_OLD_READDIR 938#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-parisc/dma-mapping.h b/include/asm-parisc/dma-mapping.h
index 1e387e1dad30..66f0b408c669 100644
--- a/include/asm-parisc/dma-mapping.h
+++ b/include/asm-parisc/dma-mapping.h
@@ -191,13 +191,13 @@ dma_get_cache_alignment(void)
191} 191}
192 192
193static inline int 193static inline int
194dma_is_consistent(dma_addr_t dma_addr) 194dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
195{ 195{
196 return (hppa_dma_ops->dma_sync_single_for_cpu == NULL); 196 return (hppa_dma_ops->dma_sync_single_for_cpu == NULL);
197} 197}
198 198
199static inline void 199static inline void
200dma_cache_sync(void *vaddr, size_t size, 200dma_cache_sync(struct device *dev, void *vaddr, size_t size,
201 enum dma_data_direction direction) 201 enum dma_data_direction direction)
202{ 202{
203 if(hppa_dma_ops->dma_sync_single_for_cpu) 203 if(hppa_dma_ops->dma_sync_single_for_cpu)
diff --git a/include/asm-parisc/futex.h b/include/asm-parisc/futex.h
index d84bbb283fd1..dbee6e60aa81 100644
--- a/include/asm-parisc/futex.h
+++ b/include/asm-parisc/futex.h
@@ -21,7 +21,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
21 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) 21 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
22 return -EFAULT; 22 return -EFAULT;
23 23
24 inc_preempt_count(); 24 pagefault_disable();
25 25
26 switch (op) { 26 switch (op) {
27 case FUTEX_OP_SET: 27 case FUTEX_OP_SET:
@@ -33,7 +33,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
33 ret = -ENOSYS; 33 ret = -ENOSYS;
34 } 34 }
35 35
36 dec_preempt_count(); 36 pagefault_enable();
37 37
38 if (!ret) { 38 if (!ret) {
39 switch (cmp) { 39 switch (cmp) {
diff --git a/include/asm-powerpc/dma-mapping.h b/include/asm-powerpc/dma-mapping.h
index 7e38b5fddada..7c7de87bd8ae 100644
--- a/include/asm-powerpc/dma-mapping.h
+++ b/include/asm-powerpc/dma-mapping.h
@@ -342,9 +342,9 @@ static inline int dma_mapping_error(dma_addr_t dma_addr)
342#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 342#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
343#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 343#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
344#ifdef CONFIG_NOT_COHERENT_CACHE 344#ifdef CONFIG_NOT_COHERENT_CACHE
345#define dma_is_consistent(d) (0) 345#define dma_is_consistent(d, h) (0)
346#else 346#else
347#define dma_is_consistent(d) (1) 347#define dma_is_consistent(d, h) (1)
348#endif 348#endif
349 349
350static inline int dma_get_cache_alignment(void) 350static inline int dma_get_cache_alignment(void)
@@ -378,7 +378,7 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
378 dma_sync_single_for_device(dev, dma_handle, offset + size, direction); 378 dma_sync_single_for_device(dev, dma_handle, offset + size, direction);
379} 379}
380 380
381static inline void dma_cache_sync(void *vaddr, size_t size, 381static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
382 enum dma_data_direction direction) 382 enum dma_data_direction direction)
383{ 383{
384 BUG_ON(direction == DMA_NONE); 384 BUG_ON(direction == DMA_NONE);
diff --git a/include/asm-powerpc/elf.h b/include/asm-powerpc/elf.h
index b5436642a109..d36426c01b6b 100644
--- a/include/asm-powerpc/elf.h
+++ b/include/asm-powerpc/elf.h
@@ -124,12 +124,10 @@ typedef elf_greg_t32 elf_gregset_t32[ELF_NGREG];
124# define ELF_DATA ELFDATA2MSB 124# define ELF_DATA ELFDATA2MSB
125 typedef elf_greg_t64 elf_greg_t; 125 typedef elf_greg_t64 elf_greg_t;
126 typedef elf_gregset_t64 elf_gregset_t; 126 typedef elf_gregset_t64 elf_gregset_t;
127# define elf_addr_t unsigned long
128#else 127#else
129 /* Assumption: ELF_ARCH == EM_PPC and ELF_CLASS == ELFCLASS32 */ 128 /* Assumption: ELF_ARCH == EM_PPC and ELF_CLASS == ELFCLASS32 */
130 typedef elf_greg_t32 elf_greg_t; 129 typedef elf_greg_t32 elf_greg_t;
131 typedef elf_gregset_t32 elf_gregset_t; 130 typedef elf_gregset_t32 elf_gregset_t;
132# define elf_addr_t __u32
133#endif /* ELF_ARCH */ 131#endif /* ELF_ARCH */
134 132
135/* Floating point registers */ 133/* Floating point registers */
diff --git a/include/asm-powerpc/futex.h b/include/asm-powerpc/futex.h
index 936422e54891..3f3673fd3ff3 100644
--- a/include/asm-powerpc/futex.h
+++ b/include/asm-powerpc/futex.h
@@ -43,7 +43,7 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
43 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) 43 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
44 return -EFAULT; 44 return -EFAULT;
45 45
46 inc_preempt_count(); 46 pagefault_disable();
47 47
48 switch (op) { 48 switch (op) {
49 case FUTEX_OP_SET: 49 case FUTEX_OP_SET:
@@ -65,7 +65,7 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
65 ret = -ENOSYS; 65 ret = -ENOSYS;
66 } 66 }
67 67
68 dec_preempt_count(); 68 pagefault_enable();
69 69
70 if (!ret) { 70 if (!ret) {
71 switch (cmp) { 71 switch (cmp) {
diff --git a/include/asm-powerpc/pgalloc.h b/include/asm-powerpc/pgalloc.h
index ae63db7b3e7d..b0830db68f8a 100644
--- a/include/asm-powerpc/pgalloc.h
+++ b/include/asm-powerpc/pgalloc.h
@@ -11,7 +11,7 @@
11#include <linux/cpumask.h> 11#include <linux/cpumask.h>
12#include <linux/percpu.h> 12#include <linux/percpu.h>
13 13
14extern kmem_cache_t *pgtable_cache[]; 14extern struct kmem_cache *pgtable_cache[];
15 15
16#ifdef CONFIG_PPC_64K_PAGES 16#ifdef CONFIG_PPC_64K_PAGES
17#define PTE_CACHE_NUM 0 17#define PTE_CACHE_NUM 0
diff --git a/include/asm-powerpc/setup.h b/include/asm-powerpc/setup.h
index 3d9740aae018..817fac0a0714 100644
--- a/include/asm-powerpc/setup.h
+++ b/include/asm-powerpc/setup.h
@@ -1,9 +1,6 @@
1#ifndef _ASM_POWERPC_SETUP_H 1#ifndef _ASM_POWERPC_SETUP_H
2#define _ASM_POWERPC_SETUP_H 2#define _ASM_POWERPC_SETUP_H
3 3
4#ifdef __KERNEL__
5
6#define COMMAND_LINE_SIZE 512 4#define COMMAND_LINE_SIZE 512
7 5
8#endif /* __KERNEL__ */
9#endif /* _ASM_POWERPC_SETUP_H */ 6#endif /* _ASM_POWERPC_SETUP_H */
diff --git a/include/asm-powerpc/unistd.h b/include/asm-powerpc/unistd.h
index 04b6c17cc59b..0ae954e3d258 100644
--- a/include/asm-powerpc/unistd.h
+++ b/include/asm-powerpc/unistd.h
@@ -334,115 +334,6 @@
334 334
335#ifndef __ASSEMBLY__ 335#ifndef __ASSEMBLY__
336 336
337/* On powerpc a system call basically clobbers the same registers like a
338 * function call, with the exception of LR (which is needed for the
339 * "sc; bnslr" sequence) and CR (where only CR0.SO is clobbered to signal
340 * an error return status).
341 */
342
343#define __syscall_nr(nr, type, name, args...) \
344 unsigned long __sc_ret, __sc_err; \
345 { \
346 register unsigned long __sc_0 __asm__ ("r0"); \
347 register unsigned long __sc_3 __asm__ ("r3"); \
348 register unsigned long __sc_4 __asm__ ("r4"); \
349 register unsigned long __sc_5 __asm__ ("r5"); \
350 register unsigned long __sc_6 __asm__ ("r6"); \
351 register unsigned long __sc_7 __asm__ ("r7"); \
352 register unsigned long __sc_8 __asm__ ("r8"); \
353 \
354 __sc_loadargs_##nr(name, args); \
355 __asm__ __volatile__ \
356 ("sc \n\t" \
357 "mfcr %0 " \
358 : "=&r" (__sc_0), \
359 "=&r" (__sc_3), "=&r" (__sc_4), \
360 "=&r" (__sc_5), "=&r" (__sc_6), \
361 "=&r" (__sc_7), "=&r" (__sc_8) \
362 : __sc_asm_input_##nr \
363 : "cr0", "ctr", "memory", \
364 "r9", "r10","r11", "r12"); \
365 __sc_ret = __sc_3; \
366 __sc_err = __sc_0; \
367 } \
368 if (__sc_err & 0x10000000) \
369 { \
370 errno = __sc_ret; \
371 __sc_ret = -1; \
372 } \
373 return (type) __sc_ret
374
375#define __sc_loadargs_0(name, dummy...) \
376 __sc_0 = __NR_##name
377#define __sc_loadargs_1(name, arg1) \
378 __sc_loadargs_0(name); \
379 __sc_3 = (unsigned long) (arg1)
380#define __sc_loadargs_2(name, arg1, arg2) \
381 __sc_loadargs_1(name, arg1); \
382 __sc_4 = (unsigned long) (arg2)
383#define __sc_loadargs_3(name, arg1, arg2, arg3) \
384 __sc_loadargs_2(name, arg1, arg2); \
385 __sc_5 = (unsigned long) (arg3)
386#define __sc_loadargs_4(name, arg1, arg2, arg3, arg4) \
387 __sc_loadargs_3(name, arg1, arg2, arg3); \
388 __sc_6 = (unsigned long) (arg4)
389#define __sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5) \
390 __sc_loadargs_4(name, arg1, arg2, arg3, arg4); \
391 __sc_7 = (unsigned long) (arg5)
392#define __sc_loadargs_6(name, arg1, arg2, arg3, arg4, arg5, arg6) \
393 __sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5); \
394 __sc_8 = (unsigned long) (arg6)
395
396#define __sc_asm_input_0 "0" (__sc_0)
397#define __sc_asm_input_1 __sc_asm_input_0, "1" (__sc_3)
398#define __sc_asm_input_2 __sc_asm_input_1, "2" (__sc_4)
399#define __sc_asm_input_3 __sc_asm_input_2, "3" (__sc_5)
400#define __sc_asm_input_4 __sc_asm_input_3, "4" (__sc_6)
401#define __sc_asm_input_5 __sc_asm_input_4, "5" (__sc_7)
402#define __sc_asm_input_6 __sc_asm_input_5, "6" (__sc_8)
403
404#define _syscall0(type,name) \
405type name(void) \
406{ \
407 __syscall_nr(0, type, name); \
408}
409
410#define _syscall1(type,name,type1,arg1) \
411type name(type1 arg1) \
412{ \
413 __syscall_nr(1, type, name, arg1); \
414}
415
416#define _syscall2(type,name,type1,arg1,type2,arg2) \
417type name(type1 arg1, type2 arg2) \
418{ \
419 __syscall_nr(2, type, name, arg1, arg2); \
420}
421
422#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
423type name(type1 arg1, type2 arg2, type3 arg3) \
424{ \
425 __syscall_nr(3, type, name, arg1, arg2, arg3); \
426}
427
428#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
429type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
430{ \
431 __syscall_nr(4, type, name, arg1, arg2, arg3, arg4); \
432}
433
434#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
435type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
436{ \
437 __syscall_nr(5, type, name, arg1, arg2, arg3, arg4, arg5); \
438}
439#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
440type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
441{ \
442 __syscall_nr(6, type, name, arg1, arg2, arg3, arg4, arg5, arg6); \
443}
444
445
446#include <linux/types.h> 337#include <linux/types.h>
447#include <linux/compiler.h> 338#include <linux/compiler.h>
448#include <linux/linkage.h> 339#include <linux/linkage.h>
diff --git a/include/asm-ppc/highmem.h b/include/asm-ppc/highmem.h
index 1d2c4ef81c22..f7b21ee302b4 100644
--- a/include/asm-ppc/highmem.h
+++ b/include/asm-ppc/highmem.h
@@ -79,7 +79,7 @@ static inline void *kmap_atomic(struct page *page, enum km_type type)
79 unsigned long vaddr; 79 unsigned long vaddr;
80 80
81 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ 81 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
82 inc_preempt_count(); 82 pagefault_disable();
83 if (!PageHighMem(page)) 83 if (!PageHighMem(page))
84 return page_address(page); 84 return page_address(page);
85 85
@@ -101,8 +101,7 @@ static inline void kunmap_atomic(void *kvaddr, enum km_type type)
101 unsigned int idx = type + KM_TYPE_NR*smp_processor_id(); 101 unsigned int idx = type + KM_TYPE_NR*smp_processor_id();
102 102
103 if (vaddr < KMAP_FIX_BEGIN) { // FIXME 103 if (vaddr < KMAP_FIX_BEGIN) { // FIXME
104 dec_preempt_count(); 104 pagefault_enable();
105 preempt_check_resched();
106 return; 105 return;
107 } 106 }
108 107
@@ -115,8 +114,7 @@ static inline void kunmap_atomic(void *kvaddr, enum km_type type)
115 pte_clear(&init_mm, vaddr, kmap_pte+idx); 114 pte_clear(&init_mm, vaddr, kmap_pte+idx);
116 flush_tlb_page(NULL, vaddr); 115 flush_tlb_page(NULL, vaddr);
117#endif 116#endif
118 dec_preempt_count(); 117 pagefault_enable();
119 preempt_check_resched();
120} 118}
121 119
122static inline struct page *kmap_atomic_to_page(void *ptr) 120static inline struct page *kmap_atomic_to_page(void *ptr)
diff --git a/include/asm-s390/setup.h b/include/asm-s390/setup.h
index 7664bacdd832..9574fe80a046 100644
--- a/include/asm-s390/setup.h
+++ b/include/asm-s390/setup.h
@@ -8,12 +8,13 @@
8#ifndef _ASM_S390_SETUP_H 8#ifndef _ASM_S390_SETUP_H
9#define _ASM_S390_SETUP_H 9#define _ASM_S390_SETUP_H
10 10
11#define COMMAND_LINE_SIZE 896
12
11#ifdef __KERNEL__ 13#ifdef __KERNEL__
12 14
13#include <asm/types.h> 15#include <asm/types.h>
14 16
15#define PARMAREA 0x10400 17#define PARMAREA 0x10400
16#define COMMAND_LINE_SIZE 896
17#define MEMORY_CHUNKS 16 /* max 0x7fff */ 18#define MEMORY_CHUNKS 16 /* max 0x7fff */
18#define IPL_PARMBLOCK_ORIGIN 0x2000 19#define IPL_PARMBLOCK_ORIGIN 0x2000
19 20
diff --git a/include/asm-s390/unistd.h b/include/asm-s390/unistd.h
index 71d3c21b84f0..fb6fef97d739 100644
--- a/include/asm-s390/unistd.h
+++ b/include/asm-s390/unistd.h
@@ -345,160 +345,6 @@
345 345
346#ifdef __KERNEL__ 346#ifdef __KERNEL__
347 347
348#include <linux/err.h>
349
350#define __syscall_return(type, res) \
351do { \
352 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
353 errno = -(res); \
354 res = -1; \
355 } \
356 return (type) (res); \
357} while (0)
358
359#define _svc_clobber "1", "cc", "memory"
360
361#define _syscall0(type,name) \
362type name(void) { \
363 register long __svcres asm("2"); \
364 long __res; \
365 asm volatile( \
366 " .if %1 < 256\n" \
367 " svc %b1\n" \
368 " .else\n" \
369 " la %%r1,%1\n" \
370 " svc 0\n" \
371 " .endif" \
372 : "=d" (__svcres) \
373 : "i" (__NR_##name) \
374 : _svc_clobber); \
375 __res = __svcres; \
376 __syscall_return(type,__res); \
377}
378
379#define _syscall1(type,name,type1,arg1) \
380type name(type1 arg1) { \
381 register type1 __arg1 asm("2") = arg1; \
382 register long __svcres asm("2"); \
383 long __res; \
384 asm volatile( \
385 " .if %1 < 256\n" \
386 " svc %b1\n" \
387 " .else\n" \
388 " la %%r1,%1\n" \
389 " svc 0\n" \
390 " .endif" \
391 : "=d" (__svcres) \
392 : "i" (__NR_##name), \
393 "0" (__arg1) \
394 : _svc_clobber); \
395 __res = __svcres; \
396 __syscall_return(type,__res); \
397}
398
399#define _syscall2(type,name,type1,arg1,type2,arg2) \
400type name(type1 arg1, type2 arg2) { \
401 register type1 __arg1 asm("2") = arg1; \
402 register type2 __arg2 asm("3") = arg2; \
403 register long __svcres asm("2"); \
404 long __res; \
405 asm volatile( \
406 " .if %1 < 256\n" \
407 " svc %b1\n" \
408 " .else\n" \
409 " la %%r1,%1\n" \
410 " svc 0\n" \
411 " .endif" \
412 : "=d" (__svcres) \
413 : "i" (__NR_##name), \
414 "0" (__arg1), \
415 "d" (__arg2) \
416 : _svc_clobber ); \
417 __res = __svcres; \
418 __syscall_return(type,__res); \
419}
420
421#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
422type name(type1 arg1, type2 arg2, type3 arg3) { \
423 register type1 __arg1 asm("2") = arg1; \
424 register type2 __arg2 asm("3") = arg2; \
425 register type3 __arg3 asm("4") = arg3; \
426 register long __svcres asm("2"); \
427 long __res; \
428 asm volatile( \
429 " .if %1 < 256\n" \
430 " svc %b1\n" \
431 " .else\n" \
432 " la %%r1,%1\n" \
433 " svc 0\n" \
434 " .endif" \
435 : "=d" (__svcres) \
436 : "i" (__NR_##name), \
437 "0" (__arg1), \
438 "d" (__arg2), \
439 "d" (__arg3) \
440 : _svc_clobber); \
441 __res = __svcres; \
442 __syscall_return(type,__res); \
443}
444
445#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3, \
446 type4,name4) \
447type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
448 register type1 __arg1 asm("2") = arg1; \
449 register type2 __arg2 asm("3") = arg2; \
450 register type3 __arg3 asm("4") = arg3; \
451 register type4 __arg4 asm("5") = arg4; \
452 register long __svcres asm("2"); \
453 long __res; \
454 asm volatile( \
455 " .if %1 < 256\n" \
456 " svc %b1\n" \
457 " .else\n" \
458 " la %%r1,%1\n" \
459 " svc 0\n" \
460 " .endif" \
461 : "=d" (__svcres) \
462 : "i" (__NR_##name), \
463 "0" (__arg1), \
464 "d" (__arg2), \
465 "d" (__arg3), \
466 "d" (__arg4) \
467 : _svc_clobber); \
468 __res = __svcres; \
469 __syscall_return(type,__res); \
470}
471
472#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3, \
473 type4,name4,type5,name5) \
474type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
475 type5 arg5) { \
476 register type1 __arg1 asm("2") = arg1; \
477 register type2 __arg2 asm("3") = arg2; \
478 register type3 __arg3 asm("4") = arg3; \
479 register type4 __arg4 asm("5") = arg4; \
480 register type5 __arg5 asm("6") = arg5; \
481 register long __svcres asm("2"); \
482 long __res; \
483 asm volatile( \
484 " .if %1 < 256\n" \
485 " svc %b1\n" \
486 " .else\n" \
487 " la %%r1,%1\n" \
488 " svc 0\n" \
489 " .endif" \
490 : "=d" (__svcres) \
491 : "i" (__NR_##name), \
492 "0" (__arg1), \
493 "d" (__arg2), \
494 "d" (__arg3), \
495 "d" (__arg4), \
496 "d" (__arg5) \
497 : _svc_clobber); \
498 __res = __svcres; \
499 __syscall_return(type,__res); \
500}
501
502#define __ARCH_WANT_IPC_PARSE_VERSION 348#define __ARCH_WANT_IPC_PARSE_VERSION
503#define __ARCH_WANT_OLD_READDIR 349#define __ARCH_WANT_OLD_READDIR
504#define __ARCH_WANT_SYS_ALARM 350#define __ARCH_WANT_SYS_ALARM
diff --git a/include/asm-sh/atomic.h b/include/asm-sh/atomic.h
index 8bdc1ba56f73..28305c3cbddf 100644
--- a/include/asm-sh/atomic.h
+++ b/include/asm-sh/atomic.h
@@ -28,11 +28,11 @@ static inline void atomic_add(int i, atomic_t *v)
28 unsigned long tmp; 28 unsigned long tmp;
29 29
30 __asm__ __volatile__ ( 30 __asm__ __volatile__ (
31"1: movli.l @%3, %0 ! atomic_add \n" 31"1: movli.l @%2, %0 ! atomic_add \n"
32" add %2, %0 \n" 32" add %1, %0 \n"
33" movco.l %0, @%3 \n" 33" movco.l %0, @%2 \n"
34" bf 1b \n" 34" bf 1b \n"
35 : "=&z" (tmp), "=r" (&v->counter) 35 : "=&z" (tmp)
36 : "r" (i), "r" (&v->counter) 36 : "r" (i), "r" (&v->counter)
37 : "t"); 37 : "t");
38#else 38#else
@@ -50,11 +50,11 @@ static inline void atomic_sub(int i, atomic_t *v)
50 unsigned long tmp; 50 unsigned long tmp;
51 51
52 __asm__ __volatile__ ( 52 __asm__ __volatile__ (
53"1: movli.l @%3, %0 ! atomic_sub \n" 53"1: movli.l @%2, %0 ! atomic_sub \n"
54" sub %2, %0 \n" 54" sub %1, %0 \n"
55" movco.l %0, @%3 \n" 55" movco.l %0, @%2 \n"
56" bf 1b \n" 56" bf 1b \n"
57 : "=&z" (tmp), "=r" (&v->counter) 57 : "=&z" (tmp)
58 : "r" (i), "r" (&v->counter) 58 : "r" (i), "r" (&v->counter)
59 : "t"); 59 : "t");
60#else 60#else
@@ -80,12 +80,12 @@ static inline int atomic_add_return(int i, atomic_t *v)
80 80
81#ifdef CONFIG_CPU_SH4A 81#ifdef CONFIG_CPU_SH4A
82 __asm__ __volatile__ ( 82 __asm__ __volatile__ (
83"1: movli.l @%3, %0 ! atomic_add_return \n" 83"1: movli.l @%2, %0 ! atomic_add_return \n"
84" add %2, %0 \n" 84" add %1, %0 \n"
85" movco.l %0, @%3 \n" 85" movco.l %0, @%2 \n"
86" bf 1b \n" 86" bf 1b \n"
87" synco \n" 87" synco \n"
88 : "=&z" (temp), "=r" (&v->counter) 88 : "=&z" (temp)
89 : "r" (i), "r" (&v->counter) 89 : "r" (i), "r" (&v->counter)
90 : "t"); 90 : "t");
91#else 91#else
@@ -109,12 +109,12 @@ static inline int atomic_sub_return(int i, atomic_t *v)
109 109
110#ifdef CONFIG_CPU_SH4A 110#ifdef CONFIG_CPU_SH4A
111 __asm__ __volatile__ ( 111 __asm__ __volatile__ (
112"1: movli.l @%3, %0 ! atomic_sub_return \n" 112"1: movli.l @%2, %0 ! atomic_sub_return \n"
113" sub %2, %0 \n" 113" sub %1, %0 \n"
114" movco.l %0, @%3 \n" 114" movco.l %0, @%2 \n"
115" bf 1b \n" 115" bf 1b \n"
116" synco \n" 116" synco \n"
117 : "=&z" (temp), "=r" (&v->counter) 117 : "=&z" (temp)
118 : "r" (i), "r" (&v->counter) 118 : "r" (i), "r" (&v->counter)
119 : "t"); 119 : "t");
120#else 120#else
@@ -186,11 +186,11 @@ static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
186 unsigned long tmp; 186 unsigned long tmp;
187 187
188 __asm__ __volatile__ ( 188 __asm__ __volatile__ (
189"1: movli.l @%3, %0 ! atomic_clear_mask \n" 189"1: movli.l @%2, %0 ! atomic_clear_mask \n"
190" and %2, %0 \n" 190" and %1, %0 \n"
191" movco.l %0, @%3 \n" 191" movco.l %0, @%2 \n"
192" bf 1b \n" 192" bf 1b \n"
193 : "=&z" (tmp), "=r" (&v->counter) 193 : "=&z" (tmp)
194 : "r" (~mask), "r" (&v->counter) 194 : "r" (~mask), "r" (&v->counter)
195 : "t"); 195 : "t");
196#else 196#else
@@ -208,11 +208,11 @@ static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
208 unsigned long tmp; 208 unsigned long tmp;
209 209
210 __asm__ __volatile__ ( 210 __asm__ __volatile__ (
211"1: movli.l @%3, %0 ! atomic_set_mask \n" 211"1: movli.l @%2, %0 ! atomic_set_mask \n"
212" or %2, %0 \n" 212" or %1, %0 \n"
213" movco.l %0, @%3 \n" 213" movco.l %0, @%2 \n"
214" bf 1b \n" 214" bf 1b \n"
215 : "=&z" (tmp), "=r" (&v->counter) 215 : "=&z" (tmp)
216 : "r" (mask), "r" (&v->counter) 216 : "r" (mask), "r" (&v->counter)
217 : "t"); 217 : "t");
218#else 218#else
diff --git a/include/asm-sh/bugs.h b/include/asm-sh/bugs.h
index beeea40f549e..795047da5e17 100644
--- a/include/asm-sh/bugs.h
+++ b/include/asm-sh/bugs.h
@@ -23,16 +23,20 @@ static void __init check_bugs(void)
23 cpu_data->loops_per_jiffy = loops_per_jiffy; 23 cpu_data->loops_per_jiffy = loops_per_jiffy;
24 24
25 switch (cpu_data->type) { 25 switch (cpu_data->type) {
26 case CPU_SH7604: 26 case CPU_SH7604 ... CPU_SH7619:
27 *p++ = '2'; 27 *p++ = '2';
28 break; 28 break;
29 case CPU_SH7206:
30 *p++ = '2';
31 *p++ = 'a';
32 break;
29 case CPU_SH7705 ... CPU_SH7300: 33 case CPU_SH7705 ... CPU_SH7300:
30 *p++ = '3'; 34 *p++ = '3';
31 break; 35 break;
32 case CPU_SH7750 ... CPU_SH4_501: 36 case CPU_SH7750 ... CPU_SH4_501:
33 *p++ = '4'; 37 *p++ = '4';
34 break; 38 break;
35 case CPU_SH7770 ... CPU_SH7781: 39 case CPU_SH7770 ... CPU_SH7785:
36 *p++ = '4'; 40 *p++ = '4';
37 *p++ = 'a'; 41 *p++ = 'a';
38 break; 42 break;
diff --git a/include/asm-sh/clock.h b/include/asm-sh/clock.h
index fdfb75b30f0d..1df92807f8c5 100644
--- a/include/asm-sh/clock.h
+++ b/include/asm-sh/clock.h
@@ -4,6 +4,7 @@
4#include <linux/kref.h> 4#include <linux/kref.h>
5#include <linux/list.h> 5#include <linux/list.h>
6#include <linux/seq_file.h> 6#include <linux/seq_file.h>
7#include <linux/clk.h>
7 8
8struct clk; 9struct clk;
9 10
@@ -18,7 +19,7 @@ struct clk_ops {
18struct clk { 19struct clk {
19 struct list_head node; 20 struct list_head node;
20 const char *name; 21 const char *name;
21 22 int id;
22 struct module *owner; 23 struct module *owner;
23 24
24 struct clk *parent; 25 struct clk *parent;
@@ -40,22 +41,13 @@ void arch_init_clk_ops(struct clk_ops **, int type);
40int clk_init(void); 41int clk_init(void);
41 42
42int __clk_enable(struct clk *); 43int __clk_enable(struct clk *);
43int clk_enable(struct clk *);
44
45void __clk_disable(struct clk *); 44void __clk_disable(struct clk *);
46void clk_disable(struct clk *);
47 45
48int clk_set_rate(struct clk *, unsigned long rate);
49unsigned long clk_get_rate(struct clk *);
50void clk_recalc_rate(struct clk *); 46void clk_recalc_rate(struct clk *);
51 47
52struct clk *clk_get(const char *id);
53void clk_put(struct clk *);
54
55int clk_register(struct clk *); 48int clk_register(struct clk *);
56void clk_unregister(struct clk *); 49void clk_unregister(struct clk *);
57 50
58int show_clocks(struct seq_file *m); 51int show_clocks(struct seq_file *m);
59 52
60#endif /* __ASM_SH_CLOCK_H */ 53#endif /* __ASM_SH_CLOCK_H */
61
diff --git a/include/asm-sh/cpu-sh2/cache.h b/include/asm-sh/cpu-sh2/cache.h
index cd96402e8562..20b9796842dc 100644
--- a/include/asm-sh/cpu-sh2/cache.h
+++ b/include/asm-sh/cpu-sh2/cache.h
@@ -12,6 +12,7 @@
12 12
13#define L1_CACHE_SHIFT 4 13#define L1_CACHE_SHIFT 4
14 14
15#if defined(CONFIG_CPU_SUBTYPE_SH7604)
15#define CCR 0xfffffe92 /* Address of Cache Control Register */ 16#define CCR 0xfffffe92 /* Address of Cache Control Register */
16 17
17#define CCR_CACHE_CE 0x01 /* Cache enable */ 18#define CCR_CACHE_CE 0x01 /* Cache enable */
@@ -27,5 +28,26 @@
27#define CCR_CACHE_ORA CCR_CACHE_TW 28#define CCR_CACHE_ORA CCR_CACHE_TW
28#define CCR_CACHE_WT 0x00 /* SH-2 is _always_ write-through */ 29#define CCR_CACHE_WT 0x00 /* SH-2 is _always_ write-through */
29 30
31#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
32#define CCR1 0xffffffec
33#define CCR CCR1
34
35#define CCR_CACHE_CE 0x01 /* Cache enable */
36#define CCR_CACHE_WT 0x06 /* CCR[bit1=1,bit2=1] */
37 /* 0x00000000-0x7fffffff: Write-through */
38 /* 0x80000000-0x9fffffff: Write-back */
39 /* 0xc0000000-0xdfffffff: Write-through */
40#define CCR_CACHE_CB 0x00 /* CCR[bit1=0,bit2=0] */
41 /* 0x00000000-0x7fffffff: Write-back */
42 /* 0x80000000-0x9fffffff: Write-through */
43 /* 0xc0000000-0xdfffffff: Write-back */
44#define CCR_CACHE_CF 0x08 /* Cache invalidate */
45
46#define CACHE_OC_ADDRESS_ARRAY 0xf0000000
47#define CACHE_OC_DATA_ARRAY 0xf1000000
48
49#define CCR_CACHE_ENABLE CCR_CACHE_CE
50#define CCR_CACHE_INVALIDATE CCR_CACHE_CF
51#endif
30#endif /* __ASM_CPU_SH2_CACHE_H */ 52#endif /* __ASM_CPU_SH2_CACHE_H */
31 53
diff --git a/include/asm-sh/cpu-sh2/freq.h b/include/asm-sh/cpu-sh2/freq.h
new file mode 100644
index 000000000000..31de475da70b
--- /dev/null
+++ b/include/asm-sh/cpu-sh2/freq.h
@@ -0,0 +1,18 @@
1/*
2 * include/asm-sh/cpu-sh2/freq.h
3 *
4 * Copyright (C) 2006 Yoshinori Sato
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#ifndef __ASM_CPU_SH2_FREQ_H
11#define __ASM_CPU_SH2_FREQ_H
12
13#if defined(CONFIG_CPU_SUBTYPE_SH7619)
14#define FREQCR 0xf815ff80
15#endif
16
17#endif /* __ASM_CPU_SH2_FREQ_H */
18
diff --git a/include/asm-sh/cpu-sh2/mmu_context.h b/include/asm-sh/cpu-sh2/mmu_context.h
new file mode 100644
index 000000000000..beeb299e01ec
--- /dev/null
+++ b/include/asm-sh/cpu-sh2/mmu_context.h
@@ -0,0 +1,16 @@
1/*
2 * include/asm-sh/cpu-sh2/mmu_context.h
3 *
4 * Copyright (C) 2003 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#ifndef __ASM_CPU_SH2_MMU_CONTEXT_H
11#define __ASM_CPU_SH2_MMU_CONTEXT_H
12
13/* No MMU */
14
15#endif /* __ASM_CPU_SH2_MMU_CONTEXT_H */
16
diff --git a/include/asm-sh/cpu-sh2/timer.h b/include/asm-sh/cpu-sh2/timer.h
new file mode 100644
index 000000000000..a39c241e8195
--- /dev/null
+++ b/include/asm-sh/cpu-sh2/timer.h
@@ -0,0 +1,6 @@
1#ifndef __ASM_CPU_SH2_TIMER_H
2#define __ASM_CPU_SH2_TIMER_H
3
4/* Nothing needed yet */
5
6#endif /* __ASM_CPU_SH2_TIMER_H */
diff --git a/include/asm-sh/cpu-sh2a/addrspace.h b/include/asm-sh/cpu-sh2a/addrspace.h
new file mode 100644
index 000000000000..3d2e9aa21522
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/addrspace.h
@@ -0,0 +1 @@
#include <asm/cpu-sh2/addrspace.h>
diff --git a/include/asm-sh/cpu-sh2a/cache.h b/include/asm-sh/cpu-sh2a/cache.h
new file mode 100644
index 000000000000..3e4b9e480982
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/cache.h
@@ -0,0 +1,39 @@
1/*
2 * include/asm-sh/cpu-sh2a/cache.h
3 *
4 * Copyright (C) 2004 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#ifndef __ASM_CPU_SH2A_CACHE_H
11#define __ASM_CPU_SH2A_CACHE_H
12
13#define L1_CACHE_SHIFT 4
14
15#define CCR1 0xfffc1000
16#define CCR2 0xfffc1004
17
18/* CCR1 behaves more like the traditional CCR */
19#define CCR CCR1
20
21/*
22 * Most of the SH-2A CCR1 definitions resemble the SH-4 ones. All others not
23 * listed here are reserved.
24 */
25#define CCR_CACHE_CB 0x0000 /* Hack */
26#define CCR_CACHE_OCE 0x0001
27#define CCR_CACHE_WT 0x0002
28#define CCR_CACHE_OCI 0x0008 /* OCF */
29#define CCR_CACHE_ICE 0x0100
30#define CCR_CACHE_ICI 0x0800 /* ICF */
31
32#define CACHE_IC_ADDRESS_ARRAY 0xf0000000
33#define CACHE_OC_ADDRESS_ARRAY 0xf0800000
34
35#define CCR_CACHE_ENABLE (CCR_CACHE_OCE | CCR_CACHE_ICE)
36#define CCR_CACHE_INVALIDATE (CCR_CACHE_OCI | CCR_CACHE_ICI)
37
38#endif /* __ASM_CPU_SH2A_CACHE_H */
39
diff --git a/include/asm-sh/cpu-sh2a/cacheflush.h b/include/asm-sh/cpu-sh2a/cacheflush.h
new file mode 100644
index 000000000000..fa3186c73350
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/cacheflush.h
@@ -0,0 +1 @@
#include <asm/cpu-sh2/cacheflush.h>
diff --git a/include/asm-sh/cpu-sh2a/dma.h b/include/asm-sh/cpu-sh2a/dma.h
new file mode 100644
index 000000000000..0d5ad85c1de8
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/dma.h
@@ -0,0 +1 @@
#include <asm/cpu-sh2/dma.h>
diff --git a/include/asm-sh/cpu-sh2a/freq.h b/include/asm-sh/cpu-sh2a/freq.h
new file mode 100644
index 000000000000..e518fff6d10f
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/freq.h
@@ -0,0 +1,18 @@
1/*
2 * include/asm-sh/cpu-sh2a/freq.h
3 *
4 * Copyright (C) 2006 Yoshinori Sato
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#ifndef __ASM_CPU_SH2A_FREQ_H
11#define __ASM_CPU_SH2A_FREQ_H
12
13#if defined(CONFIG_CPU_SUBTYPE_SH7206)
14#define FREQCR 0xfffe0010
15#endif
16
17#endif /* __ASM_CPU_SH2A_FREQ_H */
18
diff --git a/include/asm-sh/cpu-sh2a/mmu_context.h b/include/asm-sh/cpu-sh2a/mmu_context.h
new file mode 100644
index 000000000000..cd2387f7db9e
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/mmu_context.h
@@ -0,0 +1 @@
#include <asm/cpu-sh2/mmu_context.h>
diff --git a/include/asm-sh/cpu-sh2a/timer.h b/include/asm-sh/cpu-sh2a/timer.h
new file mode 100644
index 000000000000..fee504adf11e
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/timer.h
@@ -0,0 +1 @@
#include <asm/cpu-sh2/timer.h>
diff --git a/include/asm-sh/cpu-sh2a/ubc.h b/include/asm-sh/cpu-sh2a/ubc.h
new file mode 100644
index 000000000000..cf28062b96a2
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/ubc.h
@@ -0,0 +1 @@
#include <asm/cpu-sh2/ubc.h>
diff --git a/include/asm-sh/cpu-sh2a/watchdog.h b/include/asm-sh/cpu-sh2a/watchdog.h
new file mode 100644
index 000000000000..c1b3e2488478
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/watchdog.h
@@ -0,0 +1 @@
#include <asm/cpu-sh2/watchdog.h>
diff --git a/include/asm-sh/dma-mapping.h b/include/asm-sh/dma-mapping.h
index 56cd4b977232..37ab0c131a4d 100644
--- a/include/asm-sh/dma-mapping.h
+++ b/include/asm-sh/dma-mapping.h
@@ -53,7 +53,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,
53 consistent_free(vaddr, size); 53 consistent_free(vaddr, size);
54} 54}
55 55
56static inline void dma_cache_sync(void *vaddr, size_t size, 56static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
57 enum dma_data_direction dir) 57 enum dma_data_direction dir)
58{ 58{
59 consistent_sync(vaddr, size, (int)dir); 59 consistent_sync(vaddr, size, (int)dir);
diff --git a/include/asm-sh/dma.h b/include/asm-sh/dma.h
index d9daa028689f..faf3051cd429 100644
--- a/include/asm-sh/dma.h
+++ b/include/asm-sh/dma.h
@@ -14,9 +14,7 @@
14#include <linux/spinlock.h> 14#include <linux/spinlock.h>
15#include <linux/wait.h> 15#include <linux/wait.h>
16#include <linux/sysdev.h> 16#include <linux/sysdev.h>
17#include <linux/device.h>
18#include <asm/cpu/dma.h> 17#include <asm/cpu/dma.h>
19#include <asm/semaphore.h>
20 18
21/* The maximum address that we can perform a DMA transfer to on this platform */ 19/* The maximum address that we can perform a DMA transfer to on this platform */
22/* Don't define MAX_DMA_ADDRESS; it's useless on the SuperH and any 20/* Don't define MAX_DMA_ADDRESS; it's useless on the SuperH and any
@@ -46,16 +44,21 @@
46 * DMAC (dma_info) flags 44 * DMAC (dma_info) flags
47 */ 45 */
48enum { 46enum {
49 DMAC_CHANNELS_CONFIGURED = 0x00, 47 DMAC_CHANNELS_CONFIGURED = 0x01,
50 DMAC_CHANNELS_TEI_CAPABLE = 0x01, 48 DMAC_CHANNELS_TEI_CAPABLE = 0x02, /* Transfer end interrupt */
51}; 49};
52 50
53/* 51/*
54 * DMA channel capabilities / flags 52 * DMA channel capabilities / flags
55 */ 53 */
56enum { 54enum {
57 DMA_TEI_CAPABLE = 0x01, 55 DMA_CONFIGURED = 0x01,
58 DMA_CONFIGURED = 0x02, 56
57 /*
58 * Transfer end interrupt, inherited from DMAC.
59 * wait_queue used in dma_wait_for_completion.
60 */
61 DMA_TEI_CAPABLE = 0x02,
59}; 62};
60 63
61extern spinlock_t dma_spin_lock; 64extern spinlock_t dma_spin_lock;
@@ -68,28 +71,31 @@ struct dma_ops {
68 71
69 int (*get_residue)(struct dma_channel *chan); 72 int (*get_residue)(struct dma_channel *chan);
70 int (*xfer)(struct dma_channel *chan); 73 int (*xfer)(struct dma_channel *chan);
71 void (*configure)(struct dma_channel *chan, unsigned long flags); 74 int (*configure)(struct dma_channel *chan, unsigned long flags);
75 int (*extend)(struct dma_channel *chan, unsigned long op, void *param);
72}; 76};
73 77
74struct dma_channel { 78struct dma_channel {
75 char dev_id[16]; 79 char dev_id[16]; /* unique name per DMAC of channel */
76 80
77 unsigned int chan; /* Physical channel number */ 81 unsigned int chan; /* DMAC channel number */
78 unsigned int vchan; /* Virtual channel number */ 82 unsigned int vchan; /* Virtual channel number */
83
79 unsigned int mode; 84 unsigned int mode;
80 unsigned int count; 85 unsigned int count;
81 86
82 unsigned long sar; 87 unsigned long sar;
83 unsigned long dar; 88 unsigned long dar;
84 89
90 const char **caps;
91
85 unsigned long flags; 92 unsigned long flags;
86 atomic_t busy; 93 atomic_t busy;
87 94
88 struct semaphore sem;
89 wait_queue_head_t wait_queue; 95 wait_queue_head_t wait_queue;
90 96
91 struct sys_device dev; 97 struct sys_device dev;
92 char *name; 98 void *priv_data;
93}; 99};
94 100
95struct dma_info { 101struct dma_info {
@@ -103,6 +109,12 @@ struct dma_info {
103 struct dma_channel *channels; 109 struct dma_channel *channels;
104 110
105 struct list_head list; 111 struct list_head list;
112 int first_channel_nr;
113};
114
115struct dma_chan_caps {
116 int ch_num;
117 const char **caplist;
106}; 118};
107 119
108#define to_dma_channel(channel) container_of(channel, struct dma_channel, dev) 120#define to_dma_channel(channel) container_of(channel, struct dma_channel, dev)
@@ -121,6 +133,8 @@ extern int dma_xfer(unsigned int chan, unsigned long from,
121#define dma_read_page(chan, from, to) \ 133#define dma_read_page(chan, from, to) \
122 dma_read(chan, from, to, PAGE_SIZE) 134 dma_read(chan, from, to, PAGE_SIZE)
123 135
136extern int request_dma_bycap(const char **dmac, const char **caps,
137 const char *dev_id);
124extern int request_dma(unsigned int chan, const char *dev_id); 138extern int request_dma(unsigned int chan, const char *dev_id);
125extern void free_dma(unsigned int chan); 139extern void free_dma(unsigned int chan);
126extern int get_dma_residue(unsigned int chan); 140extern int get_dma_residue(unsigned int chan);
@@ -131,6 +145,10 @@ extern void dma_configure_channel(unsigned int chan, unsigned long flags);
131 145
132extern int register_dmac(struct dma_info *info); 146extern int register_dmac(struct dma_info *info);
133extern void unregister_dmac(struct dma_info *info); 147extern void unregister_dmac(struct dma_info *info);
148extern struct dma_info *get_dma_info_by_name(const char *dmac_name);
149
150extern int dma_extend(unsigned int chan, unsigned long op, void *param);
151extern int register_chan_caps(const char *dmac, struct dma_chan_caps *capslist);
134 152
135#ifdef CONFIG_SYSFS 153#ifdef CONFIG_SYSFS
136/* arch/sh/drivers/dma/dma-sysfs.c */ 154/* arch/sh/drivers/dma/dma-sysfs.c */
diff --git a/include/asm-sh/elf.h b/include/asm-sh/elf.h
index fc050fd7645e..43ca244564b1 100644
--- a/include/asm-sh/elf.h
+++ b/include/asm-sh/elf.h
@@ -74,7 +74,7 @@ typedef struct user_fpu_struct elf_fpregset_t;
74#define ELF_ARCH EM_SH 74#define ELF_ARCH EM_SH
75 75
76#define USE_ELF_CORE_DUMP 76#define USE_ELF_CORE_DUMP
77#define ELF_EXEC_PAGESIZE 4096 77#define ELF_EXEC_PAGESIZE PAGE_SIZE
78 78
79/* This is the location that an ET_DYN program is loaded if exec'ed. Typical 79/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
80 use of this is to invoke "./ld.so someprog" to test out a new version of 80 use of this is to invoke "./ld.so someprog" to test out a new version of
diff --git a/include/asm-sh/entry-macros.S b/include/asm-sh/entry-macros.S
new file mode 100644
index 000000000000..500030eae7aa
--- /dev/null
+++ b/include/asm-sh/entry-macros.S
@@ -0,0 +1,33 @@
1! entry.S macro define
2
3 .macro cli
4 stc sr, r0
5 or #0xf0, r0
6 ldc r0, sr
7 .endm
8
9 .macro sti
10 mov #0xf0, r11
11 extu.b r11, r11
12 not r11, r11
13 stc sr, r10
14 and r11, r10
15#ifdef CONFIG_HAS_SR_RB
16 stc k_g_imask, r11
17 or r11, r10
18#endif
19 ldc r10, sr
20 .endm
21
22 .macro get_current_thread_info, ti, tmp
23#ifdef CONFIG_HAS_SR_RB
24 stc r7_bank, \ti
25#else
26 mov #((THREAD_SIZE - 1) >> 10) ^ 0xff, \tmp
27 shll8 \tmp
28 shll2 \tmp
29 mov r15, \ti
30 and \tmp, \ti
31#endif
32 .endm
33
diff --git a/include/asm-sh/irq-sh73180.h b/include/asm-sh/irq-sh73180.h
deleted file mode 100644
index b28af9a69d72..000000000000
--- a/include/asm-sh/irq-sh73180.h
+++ /dev/null
@@ -1,314 +0,0 @@
1#ifndef __ASM_SH_IRQ_SH73180_H
2#define __ASM_SH_IRQ_SH73180_H
3
4/*
5 * linux/include/asm-sh/irq-sh73180.h
6 *
7 * Copyright (C) 2004 Takashi SHUDO <shudo@hitachi-ul.co.jp>
8 */
9
10#undef INTC_IPRA
11#undef INTC_IPRB
12#undef INTC_IPRC
13#undef INTC_IPRD
14
15#undef DMTE0_IRQ
16#undef DMTE1_IRQ
17#undef DMTE2_IRQ
18#undef DMTE3_IRQ
19#undef DMTE4_IRQ
20#undef DMTE5_IRQ
21#undef DMTE6_IRQ
22#undef DMTE7_IRQ
23#undef DMAE_IRQ
24#undef DMA_IPR_ADDR
25#undef DMA_IPR_POS
26#undef DMA_PRIORITY
27
28#undef INTC_IMCR0
29#undef INTC_IMCR1
30#undef INTC_IMCR2
31#undef INTC_IMCR3
32#undef INTC_IMCR4
33#undef INTC_IMCR5
34#undef INTC_IMCR6
35#undef INTC_IMCR7
36#undef INTC_IMCR8
37#undef INTC_IMCR9
38#undef INTC_IMCR10
39
40
41#define INTC_IPRA 0xA4080000UL
42#define INTC_IPRB 0xA4080004UL
43#define INTC_IPRC 0xA4080008UL
44#define INTC_IPRD 0xA408000CUL
45#define INTC_IPRE 0xA4080010UL
46#define INTC_IPRF 0xA4080014UL
47#define INTC_IPRG 0xA4080018UL
48#define INTC_IPRH 0xA408001CUL
49#define INTC_IPRI 0xA4080020UL
50#define INTC_IPRJ 0xA4080024UL
51#define INTC_IPRK 0xA4080028UL
52
53#define INTC_IMR0 0xA4080080UL
54#define INTC_IMR1 0xA4080084UL
55#define INTC_IMR2 0xA4080088UL
56#define INTC_IMR3 0xA408008CUL
57#define INTC_IMR4 0xA4080090UL
58#define INTC_IMR5 0xA4080094UL
59#define INTC_IMR6 0xA4080098UL
60#define INTC_IMR7 0xA408009CUL
61#define INTC_IMR8 0xA40800A0UL
62#define INTC_IMR9 0xA40800A4UL
63#define INTC_IMR10 0xA40800A8UL
64#define INTC_IMR11 0xA40800ACUL
65
66#define INTC_IMCR0 0xA40800C0UL
67#define INTC_IMCR1 0xA40800C4UL
68#define INTC_IMCR2 0xA40800C8UL
69#define INTC_IMCR3 0xA40800CCUL
70#define INTC_IMCR4 0xA40800D0UL
71#define INTC_IMCR5 0xA40800D4UL
72#define INTC_IMCR6 0xA40800D8UL
73#define INTC_IMCR7 0xA40800DCUL
74#define INTC_IMCR8 0xA40800E0UL
75#define INTC_IMCR9 0xA40800E4UL
76#define INTC_IMCR10 0xA40800E8UL
77#define INTC_IMCR11 0xA40800ECUL
78
79#define INTC_ICR0 0xA4140000UL
80#define INTC_ICR1 0xA414001CUL
81
82#define INTMSK0 0xa4140044
83#define INTMSKCLR0 0xa4140064
84#define INTC_INTPRI0 0xa4140010
85
86/*
87 NOTE:
88
89 *_IRQ = (INTEVT2 - 0x200)/0x20
90*/
91
92/* TMU0 */
93#define TMU0_IRQ 16
94#define TMU0_IPR_ADDR INTC_IPRA
95#define TMU0_IPR_POS 3
96#define TMU0_PRIORITY 2
97
98#define TIMER_IRQ 16
99#define TIMER_IPR_ADDR INTC_IPRA
100#define TIMER_IPR_POS 3
101#define TIMER_PRIORITY 2
102
103/* TMU1 */
104#define TMU1_IRQ 17
105#define TMU1_IPR_ADDR INTC_IPRA
106#define TMU1_IPR_POS 2
107#define TMU1_PRIORITY 2
108
109/* TMU2 */
110#define TMU2_IRQ 18
111#define TMU2_IPR_ADDR INTC_IPRA
112#define TMU2_IPR_POS 1
113#define TMU2_PRIORITY 2
114
115/* LCDC */
116#define LCDC_IRQ 28
117#define LCDC_IPR_ADDR INTC_IPRB
118#define LCDC_IPR_POS 2
119#define LCDC_PRIORITY 2
120
121/* VIO (Video I/O) */
122#define CEU_IRQ 52
123#define BEU_IRQ 53
124#define VEU_IRQ 54
125#define VOU_IRQ 55
126#define VIO_IPR_ADDR INTC_IPRE
127#define VIO_IPR_POS 2
128#define VIO_PRIORITY 2
129
130/* MFI (Multi Functional Interface) */
131#define MFI_IRQ 56
132#define MFI_IPR_ADDR INTC_IPRE
133#define MFI_IPR_POS 1
134#define MFI_PRIORITY 2
135
136/* VPU (Video Processing Unit) */
137#define VPU_IRQ 60
138#define VPU_IPR_ADDR INTC_IPRE
139#define VPU_IPR_POS 0
140#define VPU_PRIORITY 2
141
142/* 3DG */
143#define TDG_IRQ 63
144#define TDG_IPR_ADDR INTC_IPRJ
145#define TDG_IPR_POS 2
146#define TDG_PRIORITY 2
147
148/* DMAC(1) */
149#define DMTE0_IRQ 48
150#define DMTE1_IRQ 49
151#define DMTE2_IRQ 50
152#define DMTE3_IRQ 51
153#define DMA1_IPR_ADDR INTC_IPRE
154#define DMA1_IPR_POS 3
155#define DMA1_PRIORITY 7
156
157/* DMAC(2) */
158#define DMTE4_IRQ 76
159#define DMTE5_IRQ 77
160#define DMA2_IPR_ADDR INTC_IPRF
161#define DMA2_IPR_POS 2
162#define DMA2_PRIORITY 7
163
164/* SCIF0 */
165#define SCIF_ERI_IRQ 80
166#define SCIF_RXI_IRQ 81
167#define SCIF_BRI_IRQ 82
168#define SCIF_TXI_IRQ 83
169#define SCIF_IPR_ADDR INTC_IPRG
170#define SCIF_IPR_POS 3
171#define SCIF_PRIORITY 3
172
173/* SIOF0 */
174#define SIOF0_IRQ 84
175#define SIOF0_IPR_ADDR INTC_IPRH
176#define SIOF0_IPR_POS 3
177#define SIOF0_PRIORITY 3
178
179/* FLCTL (Flash Memory Controller) */
180#define FLSTE_IRQ 92
181#define FLTEND_IRQ 93
182#define FLTRQ0_IRQ 94
183#define FLTRQ1_IRQ 95
184#define FLCTL_IPR_ADDR INTC_IPRH
185#define FLCTL_IPR_POS 1
186#define FLCTL_PRIORITY 3
187
188/* IIC(0) (IIC Bus Interface) */
189#define IIC0_ALI_IRQ 96
190#define IIC0_TACKI_IRQ 97
191#define IIC0_WAITI_IRQ 98
192#define IIC0_DTEI_IRQ 99
193#define IIC0_IPR_ADDR INTC_IPRH
194#define IIC0_IPR_POS 0
195#define IIC0_PRIORITY 3
196
197/* IIC(1) (IIC Bus Interface) */
198#define IIC1_ALI_IRQ 44
199#define IIC1_TACKI_IRQ 45
200#define IIC1_WAITI_IRQ 46
201#define IIC1_DTEI_IRQ 47
202#define IIC1_IPR_ADDR INTC_IPRG
203#define IIC1_IPR_POS 0
204#define IIC1_PRIORITY 3
205
206/* SIO0 */
207#define SIO0_IRQ 88
208#define SIO0_IPR_ADDR INTC_IPRI
209#define SIO0_IPR_POS 3
210#define SIO0_PRIORITY 3
211
212/* SDHI */
213#define SDHI_SDHII0_IRQ 100
214#define SDHI_SDHII1_IRQ 101
215#define SDHI_SDHII2_IRQ 102
216#define SDHI_SDHII3_IRQ 103
217#define SDHI_IPR_ADDR INTC_IPRK
218#define SDHI_IPR_POS 0
219#define SDHI_PRIORITY 3
220
221/* SIU (Sound Interface Unit) */
222#define SIU_IRQ 108
223#define SIU_IPR_ADDR INTC_IPRJ
224#define SIU_IPR_POS 1
225#define SIU_PRIORITY 3
226
227#define PORT_PACR 0xA4050100UL
228#define PORT_PBCR 0xA4050102UL
229#define PORT_PCCR 0xA4050104UL
230#define PORT_PDCR 0xA4050106UL
231#define PORT_PECR 0xA4050108UL
232#define PORT_PFCR 0xA405010AUL
233#define PORT_PGCR 0xA405010CUL
234#define PORT_PHCR 0xA405010EUL
235#define PORT_PJCR 0xA4050110UL
236#define PORT_PKCR 0xA4050112UL
237#define PORT_PLCR 0xA4050114UL
238#define PORT_SCPCR 0xA4050116UL
239#define PORT_PMCR 0xA4050118UL
240#define PORT_PNCR 0xA405011AUL
241#define PORT_PQCR 0xA405011CUL
242#define PORT_PRCR 0xA405011EUL
243#define PORT_PTCR 0xA405014CUL
244#define PORT_PUCR 0xA405014EUL
245#define PORT_PVCR 0xA4050150UL
246
247#define PORT_PSELA 0xA4050140UL
248#define PORT_PSELB 0xA4050142UL
249#define PORT_PSELC 0xA4050144UL
250#define PORT_PSELE 0xA4050158UL
251
252#define PORT_HIZCRA 0xA4050146UL
253#define PORT_HIZCRB 0xA4050148UL
254#define PORT_DRVCR 0xA405014AUL
255
256#define PORT_PADR 0xA4050120UL
257#define PORT_PBDR 0xA4050122UL
258#define PORT_PCDR 0xA4050124UL
259#define PORT_PDDR 0xA4050126UL
260#define PORT_PEDR 0xA4050128UL
261#define PORT_PFDR 0xA405012AUL
262#define PORT_PGDR 0xA405012CUL
263#define PORT_PHDR 0xA405012EUL
264#define PORT_PJDR 0xA4050130UL
265#define PORT_PKDR 0xA4050132UL
266#define PORT_PLDR 0xA4050134UL
267#define PORT_SCPDR 0xA4050136UL
268#define PORT_PMDR 0xA4050138UL
269#define PORT_PNDR 0xA405013AUL
270#define PORT_PQDR 0xA405013CUL
271#define PORT_PRDR 0xA405013EUL
272#define PORT_PTDR 0xA405016CUL
273#define PORT_PUDR 0xA405016EUL
274#define PORT_PVDR 0xA4050170UL
275
276#define IRQ0_IRQ 32
277#define IRQ1_IRQ 33
278#define IRQ2_IRQ 34
279#define IRQ3_IRQ 35
280#define IRQ4_IRQ 36
281#define IRQ5_IRQ 37
282#define IRQ6_IRQ 38
283#define IRQ7_IRQ 39
284
285#define INTPRI00 0xA4140010UL
286
287#define IRQ0_IPR_ADDR INTPRI00
288#define IRQ1_IPR_ADDR INTPRI00
289#define IRQ2_IPR_ADDR INTPRI00
290#define IRQ3_IPR_ADDR INTPRI00
291#define IRQ4_IPR_ADDR INTPRI00
292#define IRQ5_IPR_ADDR INTPRI00
293#define IRQ6_IPR_ADDR INTPRI00
294#define IRQ7_IPR_ADDR INTPRI00
295
296#define IRQ0_IPR_POS 7
297#define IRQ1_IPR_POS 6
298#define IRQ2_IPR_POS 5
299#define IRQ3_IPR_POS 4
300#define IRQ4_IPR_POS 3
301#define IRQ5_IPR_POS 2
302#define IRQ6_IPR_POS 1
303#define IRQ7_IPR_POS 0
304
305#define IRQ0_PRIORITY 1
306#define IRQ1_PRIORITY 1
307#define IRQ2_PRIORITY 1
308#define IRQ3_PRIORITY 1
309#define IRQ4_PRIORITY 1
310#define IRQ5_PRIORITY 1
311#define IRQ6_PRIORITY 1
312#define IRQ7_PRIORITY 1
313
314#endif /* __ASM_SH_IRQ_SH73180_H */
diff --git a/include/asm-sh/irq-sh7343.h b/include/asm-sh/irq-sh7343.h
deleted file mode 100644
index 5d15419b53b0..000000000000
--- a/include/asm-sh/irq-sh7343.h
+++ /dev/null
@@ -1,317 +0,0 @@
1#ifndef __ASM_SH_IRQ_SH7343_H
2#define __ASM_SH_IRQ_SH7343_H
3
4/*
5 * linux/include/asm-sh/irq-sh7343.h
6 *
7 * Copyright (C) 2006 Kenati Technologies Inc.
8 * Andre Mccurdy <andre@kenati.com>
9 * Ranjit Deshpande <ranjit@kenati.com>
10 */
11
12#undef INTC_IPRA
13#undef INTC_IPRB
14#undef INTC_IPRC
15#undef INTC_IPRD
16
17#undef DMTE0_IRQ
18#undef DMTE1_IRQ
19#undef DMTE2_IRQ
20#undef DMTE3_IRQ
21#undef DMTE4_IRQ
22#undef DMTE5_IRQ
23#undef DMTE6_IRQ
24#undef DMTE7_IRQ
25#undef DMAE_IRQ
26#undef DMA_IPR_ADDR
27#undef DMA_IPR_POS
28#undef DMA_PRIORITY
29
30#undef INTC_IMCR0
31#undef INTC_IMCR1
32#undef INTC_IMCR2
33#undef INTC_IMCR3
34#undef INTC_IMCR4
35#undef INTC_IMCR5
36#undef INTC_IMCR6
37#undef INTC_IMCR7
38#undef INTC_IMCR8
39#undef INTC_IMCR9
40#undef INTC_IMCR10
41
42
43#define INTC_IPRA 0xA4080000UL
44#define INTC_IPRB 0xA4080004UL
45#define INTC_IPRC 0xA4080008UL
46#define INTC_IPRD 0xA408000CUL
47#define INTC_IPRE 0xA4080010UL
48#define INTC_IPRF 0xA4080014UL
49#define INTC_IPRG 0xA4080018UL
50#define INTC_IPRH 0xA408001CUL
51#define INTC_IPRI 0xA4080020UL
52#define INTC_IPRJ 0xA4080024UL
53#define INTC_IPRK 0xA4080028UL
54#define INTC_IPRL 0xA408002CUL
55
56#define INTC_IMR0 0xA4080080UL
57#define INTC_IMR1 0xA4080084UL
58#define INTC_IMR2 0xA4080088UL
59#define INTC_IMR3 0xA408008CUL
60#define INTC_IMR4 0xA4080090UL
61#define INTC_IMR5 0xA4080094UL
62#define INTC_IMR6 0xA4080098UL
63#define INTC_IMR7 0xA408009CUL
64#define INTC_IMR8 0xA40800A0UL
65#define INTC_IMR9 0xA40800A4UL
66#define INTC_IMR10 0xA40800A8UL
67#define INTC_IMR11 0xA40800ACUL
68
69#define INTC_IMCR0 0xA40800C0UL
70#define INTC_IMCR1 0xA40800C4UL
71#define INTC_IMCR2 0xA40800C8UL
72#define INTC_IMCR3 0xA40800CCUL
73#define INTC_IMCR4 0xA40800D0UL
74#define INTC_IMCR5 0xA40800D4UL
75#define INTC_IMCR6 0xA40800D8UL
76#define INTC_IMCR7 0xA40800DCUL
77#define INTC_IMCR8 0xA40800E0UL
78#define INTC_IMCR9 0xA40800E4UL
79#define INTC_IMCR10 0xA40800E8UL
80#define INTC_IMCR11 0xA40800ECUL
81
82#define INTC_ICR0 0xA4140000UL
83#define INTC_ICR1 0xA414001CUL
84
85#define INTMSK0 0xa4140044
86#define INTMSKCLR0 0xa4140064
87#define INTC_INTPRI0 0xa4140010
88
89/*
90 NOTE:
91
92 *_IRQ = (INTEVT2 - 0x200)/0x20
93*/
94
95/* TMU0 */
96#define TMU0_IRQ 16
97#define TMU0_IPR_ADDR INTC_IPRA
98#define TMU0_IPR_POS 3
99#define TMU0_PRIORITY 2
100
101#define TIMER_IRQ 16
102#define TIMER_IPR_ADDR INTC_IPRA
103#define TIMER_IPR_POS 3
104#define TIMER_PRIORITY 2
105
106/* TMU1 */
107#define TMU1_IRQ 17
108#define TMU1_IPR_ADDR INTC_IPRA
109#define TMU1_IPR_POS 2
110#define TMU1_PRIORITY 2
111
112/* TMU2 */
113#define TMU2_IRQ 18
114#define TMU2_IPR_ADDR INTC_IPRA
115#define TMU2_IPR_POS 1
116#define TMU2_PRIORITY 2
117
118/* LCDC */
119#define LCDC_IRQ 28
120#define LCDC_IPR_ADDR INTC_IPRB
121#define LCDC_IPR_POS 2
122#define LCDC_PRIORITY 2
123
124/* VIO (Video I/O) */
125#define CEU_IRQ 52
126#define BEU_IRQ 53
127#define VEU_IRQ 54
128#define VOU_IRQ 55
129#define VIO_IPR_ADDR INTC_IPRE
130#define VIO_IPR_POS 2
131#define VIO_PRIORITY 2
132
133/* MFI (Multi Functional Interface) */
134#define MFI_IRQ 56
135#define MFI_IPR_ADDR INTC_IPRE
136#define MFI_IPR_POS 1
137#define MFI_PRIORITY 2
138
139/* VPU (Video Processing Unit) */
140#define VPU_IRQ 60
141#define VPU_IPR_ADDR INTC_IPRE
142#define VPU_IPR_POS 0
143#define VPU_PRIORITY 2
144
145/* 3DG */
146#define TDG_IRQ 63
147#define TDG_IPR_ADDR INTC_IPRJ
148#define TDG_IPR_POS 2
149#define TDG_PRIORITY 2
150
151/* DMAC(1) */
152#define DMTE0_IRQ 48
153#define DMTE1_IRQ 49
154#define DMTE2_IRQ 50
155#define DMTE3_IRQ 51
156#define DMA1_IPR_ADDR INTC_IPRE
157#define DMA1_IPR_POS 3
158#define DMA1_PRIORITY 7
159
160/* DMAC(2) */
161#define DMTE4_IRQ 76
162#define DMTE5_IRQ 77
163#define DMA2_IPR_ADDR INTC_IPRF
164#define DMA2_IPR_POS 2
165#define DMA2_PRIORITY 7
166
167/* SCIF0 */
168#define SCIF_ERI_IRQ 80
169#define SCIF_RXI_IRQ 81
170#define SCIF_BRI_IRQ 82
171#define SCIF_TXI_IRQ 83
172#define SCIF_IPR_ADDR INTC_IPRG
173#define SCIF_IPR_POS 3
174#define SCIF_PRIORITY 3
175
176/* SIOF0 */
177#define SIOF0_IRQ 84
178#define SIOF0_IPR_ADDR INTC_IPRH
179#define SIOF0_IPR_POS 3
180#define SIOF0_PRIORITY 3
181
182/* FLCTL (Flash Memory Controller) */
183#define FLSTE_IRQ 92
184#define FLTEND_IRQ 93
185#define FLTRQ0_IRQ 94
186#define FLTRQ1_IRQ 95
187#define FLCTL_IPR_ADDR INTC_IPRH
188#define FLCTL_IPR_POS 1
189#define FLCTL_PRIORITY 3
190
191/* IIC(0) (IIC Bus Interface) */
192#define IIC0_ALI_IRQ 96
193#define IIC0_TACKI_IRQ 97
194#define IIC0_WAITI_IRQ 98
195#define IIC0_DTEI_IRQ 99
196#define IIC0_IPR_ADDR INTC_IPRH
197#define IIC0_IPR_POS 0
198#define IIC0_PRIORITY 3
199
200/* IIC(1) (IIC Bus Interface) */
201#define IIC1_ALI_IRQ 44
202#define IIC1_TACKI_IRQ 45
203#define IIC1_WAITI_IRQ 46
204#define IIC1_DTEI_IRQ 47
205#define IIC1_IPR_ADDR INTC_IPRI
206#define IIC1_IPR_POS 0
207#define IIC1_PRIORITY 3
208
209/* SIO0 */
210#define SIO0_IRQ 88
211#define SIO0_IPR_ADDR INTC_IPRI
212#define SIO0_IPR_POS 3
213#define SIO0_PRIORITY 3
214
215/* SDHI */
216#define SDHI_SDHII0_IRQ 100
217#define SDHI_SDHII1_IRQ 101
218#define SDHI_SDHII2_IRQ 102
219#define SDHI_SDHII3_IRQ 103
220#define SDHI_IPR_ADDR INTC_IPRK
221#define SDHI_IPR_POS 0
222#define SDHI_PRIORITY 3
223
224/* SIU (Sound Interface Unit) */
225#define SIU_IRQ 108
226#define SIU_IPR_ADDR INTC_IPRJ
227#define SIU_IPR_POS 1
228#define SIU_PRIORITY 3
229
230#define PORT_PACR 0xA4050100UL
231#define PORT_PBCR 0xA4050102UL
232#define PORT_PCCR 0xA4050104UL
233#define PORT_PDCR 0xA4050106UL
234#define PORT_PECR 0xA4050108UL
235#define PORT_PFCR 0xA405010AUL
236#define PORT_PGCR 0xA405010CUL
237#define PORT_PHCR 0xA405010EUL
238#define PORT_PJCR 0xA4050110UL
239#define PORT_PKCR 0xA4050112UL
240#define PORT_PLCR 0xA4050114UL
241#define PORT_SCPCR 0xA4050116UL
242#define PORT_PMCR 0xA4050118UL
243#define PORT_PNCR 0xA405011AUL
244#define PORT_PQCR 0xA405011CUL
245#define PORT_PRCR 0xA405011EUL
246#define PORT_PTCR 0xA405014CUL
247#define PORT_PUCR 0xA405014EUL
248#define PORT_PVCR 0xA4050150UL
249
250#define PORT_PSELA 0xA4050140UL
251#define PORT_PSELB 0xA4050142UL
252#define PORT_PSELC 0xA4050144UL
253#define PORT_PSELE 0xA4050158UL
254
255#define PORT_HIZCRA 0xA4050146UL
256#define PORT_HIZCRB 0xA4050148UL
257#define PORT_DRVCR 0xA405014AUL
258
259#define PORT_PADR 0xA4050120UL
260#define PORT_PBDR 0xA4050122UL
261#define PORT_PCDR 0xA4050124UL
262#define PORT_PDDR 0xA4050126UL
263#define PORT_PEDR 0xA4050128UL
264#define PORT_PFDR 0xA405012AUL
265#define PORT_PGDR 0xA405012CUL
266#define PORT_PHDR 0xA405012EUL
267#define PORT_PJDR 0xA4050130UL
268#define PORT_PKDR 0xA4050132UL
269#define PORT_PLDR 0xA4050134UL
270#define PORT_SCPDR 0xA4050136UL
271#define PORT_PMDR 0xA4050138UL
272#define PORT_PNDR 0xA405013AUL
273#define PORT_PQDR 0xA405013CUL
274#define PORT_PRDR 0xA405013EUL
275#define PORT_PTDR 0xA405016CUL
276#define PORT_PUDR 0xA405016EUL
277#define PORT_PVDR 0xA4050170UL
278
279#define IRQ0_IRQ 32
280#define IRQ1_IRQ 33
281#define IRQ2_IRQ 34
282#define IRQ3_IRQ 35
283#define IRQ4_IRQ 36
284#define IRQ5_IRQ 37
285#define IRQ6_IRQ 38
286#define IRQ7_IRQ 39
287
288#define INTPRI00 0xA4140010UL
289
290#define IRQ0_IPR_ADDR INTPRI00
291#define IRQ1_IPR_ADDR INTPRI00
292#define IRQ2_IPR_ADDR INTPRI00
293#define IRQ3_IPR_ADDR INTPRI00
294#define IRQ4_IPR_ADDR INTPRI00
295#define IRQ5_IPR_ADDR INTPRI00
296#define IRQ6_IPR_ADDR INTPRI00
297#define IRQ7_IPR_ADDR INTPRI00
298
299#define IRQ0_IPR_POS 7
300#define IRQ1_IPR_POS 6
301#define IRQ2_IPR_POS 5
302#define IRQ3_IPR_POS 4
303#define IRQ4_IPR_POS 3
304#define IRQ5_IPR_POS 2
305#define IRQ6_IPR_POS 1
306#define IRQ7_IPR_POS 0
307
308#define IRQ0_PRIORITY 1
309#define IRQ1_PRIORITY 1
310#define IRQ2_PRIORITY 1
311#define IRQ3_PRIORITY 1
312#define IRQ4_PRIORITY 1
313#define IRQ5_PRIORITY 1
314#define IRQ6_PRIORITY 1
315#define IRQ7_PRIORITY 1
316
317#endif /* __ASM_SH_IRQ_SH7343_H */
diff --git a/include/asm-sh/irq-sh7780.h b/include/asm-sh/irq-sh7780.h
deleted file mode 100644
index 19912ae6a7f7..000000000000
--- a/include/asm-sh/irq-sh7780.h
+++ /dev/null
@@ -1,311 +0,0 @@
1#ifndef __ASM_SH_IRQ_SH7780_H
2#define __ASM_SH_IRQ_SH7780_H
3
4/*
5 * linux/include/asm-sh/irq-sh7780.h
6 *
7 * Copyright (C) 2004 Takashi SHUDO <shudo@hitachi-ul.co.jp>
8 */
9#define INTC_BASE 0xffd00000
10#define INTC_ICR0 (INTC_BASE+0x0)
11#define INTC_ICR1 (INTC_BASE+0x1c)
12#define INTC_INTPRI (INTC_BASE+0x10)
13#define INTC_INTREQ (INTC_BASE+0x24)
14#define INTC_INTMSK0 (INTC_BASE+0x44)
15#define INTC_INTMSK1 (INTC_BASE+0x48)
16#define INTC_INTMSK2 (INTC_BASE+0x40080)
17#define INTC_INTMSKCLR0 (INTC_BASE+0x64)
18#define INTC_INTMSKCLR1 (INTC_BASE+0x68)
19#define INTC_INTMSKCLR2 (INTC_BASE+0x40084)
20#define INTC_NMIFCR (INTC_BASE+0xc0)
21#define INTC_USERIMASK (INTC_BASE+0x30000)
22
23#define INTC_INT2PRI0 (INTC_BASE+0x40000)
24#define INTC_INT2PRI1 (INTC_BASE+0x40004)
25#define INTC_INT2PRI2 (INTC_BASE+0x40008)
26#define INTC_INT2PRI3 (INTC_BASE+0x4000c)
27#define INTC_INT2PRI4 (INTC_BASE+0x40010)
28#define INTC_INT2PRI5 (INTC_BASE+0x40014)
29#define INTC_INT2PRI6 (INTC_BASE+0x40018)
30#define INTC_INT2PRI7 (INTC_BASE+0x4001c)
31#define INTC_INT2A0 (INTC_BASE+0x40030)
32#define INTC_INT2A1 (INTC_BASE+0x40034)
33#define INTC_INT2MSKR (INTC_BASE+0x40038)
34#define INTC_INT2MSKCR (INTC_BASE+0x4003c)
35#define INTC_INT2B0 (INTC_BASE+0x40040)
36#define INTC_INT2B1 (INTC_BASE+0x40044)
37#define INTC_INT2B2 (INTC_BASE+0x40048)
38#define INTC_INT2B3 (INTC_BASE+0x4004c)
39#define INTC_INT2B4 (INTC_BASE+0x40050)
40#define INTC_INT2B5 (INTC_BASE+0x40054)
41#define INTC_INT2B6 (INTC_BASE+0x40058)
42#define INTC_INT2B7 (INTC_BASE+0x4005c)
43#define INTC_INT2GPIC (INTC_BASE+0x40090)
44/*
45 NOTE:
46 *_IRQ = (INTEVT2 - 0x200)/0x20
47*/
48/* IRQ 0-7 line external int*/
49#define IRQ0_IRQ 2
50#define IRQ0_IPR_ADDR INTC_INTPRI
51#define IRQ0_IPR_POS 7
52#define IRQ0_PRIORITY 2
53
54#define IRQ1_IRQ 4
55#define IRQ1_IPR_ADDR INTC_INTPRI
56#define IRQ1_IPR_POS 6
57#define IRQ1_PRIORITY 2
58
59#define IRQ2_IRQ 6
60#define IRQ2_IPR_ADDR INTC_INTPRI
61#define IRQ2_IPR_POS 5
62#define IRQ2_PRIORITY 2
63
64#define IRQ3_IRQ 8
65#define IRQ3_IPR_ADDR INTC_INTPRI
66#define IRQ3_IPR_POS 4
67#define IRQ3_PRIORITY 2
68
69#define IRQ4_IRQ 10
70#define IRQ4_IPR_ADDR INTC_INTPRI
71#define IRQ4_IPR_POS 3
72#define IRQ4_PRIORITY 2
73
74#define IRQ5_IRQ 12
75#define IRQ5_IPR_ADDR INTC_INTPRI
76#define IRQ5_IPR_POS 2
77#define IRQ5_PRIORITY 2
78
79#define IRQ6_IRQ 14
80#define IRQ6_IPR_ADDR INTC_INTPRI
81#define IRQ6_IPR_POS 1
82#define IRQ6_PRIORITY 2
83
84#define IRQ7_IRQ 0
85#define IRQ7_IPR_ADDR INTC_INTPRI
86#define IRQ7_IPR_POS 0
87#define IRQ7_PRIORITY 2
88
89/* TMU */
90/* ch0 */
91#define TMU_IRQ 28
92#define TMU_IPR_ADDR INTC_INT2PRI0
93#define TMU_IPR_POS 3
94#define TMU_PRIORITY 2
95
96#define TIMER_IRQ 28
97#define TIMER_IPR_ADDR INTC_INT2PRI0
98#define TIMER_IPR_POS 3
99#define TIMER_PRIORITY 2
100
101/* ch 1*/
102#define TMU_CH1_IRQ 29
103#define TMU_CH1_IPR_ADDR INTC_INT2PRI0
104#define TMU_CH1_IPR_POS 2
105#define TMU_CH1_PRIORITY 2
106
107#define TIMER1_IRQ 29
108#define TIMER1_IPR_ADDR INTC_INT2PRI0
109#define TIMER1_IPR_POS 2
110#define TIMER1_PRIORITY 2
111
112/* ch 2*/
113#define TMU_CH2_IRQ 30
114#define TMU_CH2_IPR_ADDR INTC_INT2PRI0
115#define TMU_CH2_IPR_POS 1
116#define TMU_CH2_PRIORITY 2
117/* ch 2 Input capture */
118#define TMU_CH2IC_IRQ 31
119#define TMU_CH2IC_IPR_ADDR INTC_INT2PRI0
120#define TMU_CH2IC_IPR_POS 0
121#define TMU_CH2IC_PRIORITY 2
122/* ch 3 */
123#define TMU_CH3_IRQ 96
124#define TMU_CH3_IPR_ADDR INTC_INT2PRI1
125#define TMU_CH3_IPR_POS 3
126#define TMU_CH3_PRIORITY 2
127/* ch 4 */
128#define TMU_CH4_IRQ 97
129#define TMU_CH4_IPR_ADDR INTC_INT2PRI1
130#define TMU_CH4_IPR_POS 2
131#define TMU_CH4_PRIORITY 2
132/* ch 5*/
133#define TMU_CH5_IRQ 98
134#define TMU_CH5_IPR_ADDR INTC_INT2PRI1
135#define TMU_CH5_IPR_POS 1
136#define TMU_CH5_PRIORITY 2
137
138/* SCIF0 */
139#define SCIF0_ERI_IRQ 40
140#define SCIF0_RXI_IRQ 41
141#define SCIF0_BRI_IRQ 42
142#define SCIF0_TXI_IRQ 43
143#define SCIF0_IPR_ADDR INTC_INT2PRI2
144#define SCIF0_IPR_POS 3
145#define SCIF0_PRIORITY 3
146
147/* SCIF1 */
148#define SCIF1_ERI_IRQ 76
149#define SCIF1_RXI_IRQ 77
150#define SCIF1_BRI_IRQ 78
151#define SCIF1_TXI_IRQ 79
152#define SCIF1_IPR_ADDR INTC_INT2PRI2
153#define SCIF1_IPR_POS 2
154#define SCIF1_PRIORITY 3
155
156#define WDT_IRQ 27
157#define WDT_IPR_ADDR INTC_INT2PRI2
158#define WDT_IPR_POS 1
159#define WDT_PRIORITY 2
160
161/* DMAC(0) */
162#define DMINT0_IRQ 34
163#define DMINT1_IRQ 35
164#define DMINT2_IRQ 36
165#define DMINT3_IRQ 37
166#define DMINT4_IRQ 44
167#define DMINT5_IRQ 45
168#define DMINT6_IRQ 46
169#define DMINT7_IRQ 47
170#define DMAE_IRQ 38
171#define DMA0_IPR_ADDR INTC_INT2PRI3
172#define DMA0_IPR_POS 2
173#define DMA0_PRIORITY 7
174
175/* DMAC(1) */
176#define DMINT8_IRQ 92
177#define DMINT9_IRQ 93
178#define DMINT10_IRQ 94
179#define DMINT11_IRQ 95
180#define DMA1_IPR_ADDR INTC_INT2PRI3
181#define DMA1_IPR_POS 1
182#define DMA1_PRIORITY 7
183
184#define DMTE0_IRQ DMINT0_IRQ
185#define DMTE4_IRQ DMINT4_IRQ
186#define DMA_IPR_ADDR DMA0_IPR_ADDR
187#define DMA_IPR_POS DMA0_IPR_POS
188#define DMA_PRIORITY DMA0_PRIORITY
189
190/* CMT */
191#define CMT_IRQ 56
192#define CMT_IPR_ADDR INTC_INT2PRI4
193#define CMT_IPR_POS 3
194#define CMT_PRIORITY 0
195
196/* HAC */
197#define HAC_IRQ 60
198#define HAC_IPR_ADDR INTC_INT2PRI4
199#define HAC_IPR_POS 2
200#define CMT_PRIORITY 0
201
202/* PCIC(0) */
203#define PCIC0_IRQ 64
204#define PCIC0_IPR_ADDR INTC_INT2PRI4
205#define PCIC0_IPR_POS 1
206#define PCIC0_PRIORITY 2
207
208/* PCIC(1) */
209#define PCIC1_IRQ 65
210#define PCIC1_IPR_ADDR INTC_INT2PRI4
211#define PCIC1_IPR_POS 0
212#define PCIC1_PRIORITY 2
213
214/* PCIC(2) */
215#define PCIC2_IRQ 66
216#define PCIC2_IPR_ADDR INTC_INT2PRI5
217#define PCIC2_IPR_POS 3
218#define PCIC2_PRIORITY 2
219
220/* PCIC(3) */
221#define PCIC3_IRQ 67
222#define PCIC3_IPR_ADDR INTC_INT2PRI5
223#define PCIC3_IPR_POS 2
224#define PCIC3_PRIORITY 2
225
226/* PCIC(4) */
227#define PCIC4_IRQ 68
228#define PCIC4_IPR_ADDR INTC_INT2PRI5
229#define PCIC4_IPR_POS 1
230#define PCIC4_PRIORITY 2
231
232/* PCIC(5) */
233#define PCICERR_IRQ 69
234#define PCICPWD3_IRQ 70
235#define PCICPWD2_IRQ 71
236#define PCICPWD1_IRQ 72
237#define PCICPWD0_IRQ 73
238#define PCIC5_IPR_ADDR INTC_INT2PRI5
239#define PCIC5_IPR_POS 0
240#define PCIC5_PRIORITY 2
241
242/* SIOF */
243#define SIOF_IRQ 80
244#define SIOF_IPR_ADDR INTC_INT2PRI6
245#define SIOF_IPR_POS 3
246#define SIOF_PRIORITY 3
247
248/* HSPI */
249#define HSPI_IRQ 84
250#define HSPI_IPR_ADDR INTC_INT2PRI6
251#define HSPI_IPR_POS 2
252#define HSPI_PRIORITY 3
253
254/* MMCIF */
255#define MMCIF_FSTAT_IRQ 88
256#define MMCIF_TRAN_IRQ 89
257#define MMCIF_ERR_IRQ 90
258#define MMCIF_FRDY_IRQ 91
259#define MMCIF_IPR_ADDR INTC_INT2PRI6
260#define MMCIF_IPR_POS 1
261#define HSPI_PRIORITY 3
262
263/* SSI */
264#define SSI_IRQ 100
265#define SSI_IPR_ADDR INTC_INT2PRI6
266#define SSI_IPR_POS 0
267#define SSI_PRIORITY 3
268
269/* FLCTL */
270#define FLCTL_FLSTE_IRQ 104
271#define FLCTL_FLTEND_IRQ 105
272#define FLCTL_FLTRQ0_IRQ 106
273#define FLCTL_FLTRQ1_IRQ 107
274#define FLCTL_IPR_ADDR INTC_INT2PRI7
275#define FLCTL_IPR_POS 3
276#define FLCTL_PRIORITY 3
277
278/* GPIO */
279#define GPIO0_IRQ 108
280#define GPIO1_IRQ 109
281#define GPIO2_IRQ 110
282#define GPIO3_IRQ 111
283#define GPIO_IPR_ADDR INTC_INT2PRI7
284#define GPIO_IPR_POS 2
285#define GPIO_PRIORITY 3
286
287#define INTC_TMU0_MSK 0
288#define INTC_TMU3_MSK 1
289#define INTC_RTC_MSK 2
290#define INTC_SCIF0_MSK 3
291#define INTC_SCIF1_MSK 4
292#define INTC_WDT_MSK 5
293#define INTC_HUID_MSK 7
294#define INTC_DMAC0_MSK 8
295#define INTC_DMAC1_MSK 9
296#define INTC_CMT_MSK 12
297#define INTC_HAC_MSK 13
298#define INTC_PCIC0_MSK 14
299#define INTC_PCIC1_MSK 15
300#define INTC_PCIC2_MSK 16
301#define INTC_PCIC3_MSK 17
302#define INTC_PCIC4_MSK 18
303#define INTC_PCIC5_MSK 19
304#define INTC_SIOF_MSK 20
305#define INTC_HSPI_MSK 21
306#define INTC_MMCIF_MSK 22
307#define INTC_SSI_MSK 23
308#define INTC_FLCTL_MSK 24
309#define INTC_GPIO_MSK 25
310
311#endif /* __ASM_SH_IRQ_SH7780_H */
diff --git a/include/asm-sh/irq.h b/include/asm-sh/irq.h
index 6cd3e9e2a76a..fd576088e47e 100644
--- a/include/asm-sh/irq.h
+++ b/include/asm-sh/irq.h
@@ -1,233 +1,9 @@
1#ifndef __ASM_SH_IRQ_H 1#ifndef __ASM_SH_IRQ_H
2#define __ASM_SH_IRQ_H 2#define __ASM_SH_IRQ_H
3 3
4/*
5 *
6 * linux/include/asm-sh/irq.h
7 *
8 * Copyright (C) 1999 Niibe Yutaka & Takeshi Yaegashi
9 * Copyright (C) 2000 Kazumoto Kojima
10 * Copyright (C) 2003 Paul Mundt
11 *
12 */
13
14#include <asm/machvec.h> 4#include <asm/machvec.h>
15#include <asm/ptrace.h> /* for pt_regs */ 5#include <asm/ptrace.h> /* for pt_regs */
16 6
17#ifndef CONFIG_CPU_SUBTYPE_SH7780
18
19#define INTC_DMAC0_MSK 0
20
21#if defined(CONFIG_CPU_SH3)
22#define INTC_IPRA 0xfffffee2UL
23#define INTC_IPRB 0xfffffee4UL
24#elif defined(CONFIG_CPU_SH4)
25#define INTC_IPRA 0xffd00004UL
26#define INTC_IPRB 0xffd00008UL
27#define INTC_IPRC 0xffd0000cUL
28#define INTC_IPRD 0xffd00010UL
29#endif
30
31#define TIMER_IRQ 16
32#define TIMER_IPR_ADDR INTC_IPRA
33#define TIMER_IPR_POS 3
34#define TIMER_PRIORITY 2
35
36#define TIMER1_IRQ 17
37#define TIMER1_IPR_ADDR INTC_IPRA
38#define TIMER1_IPR_POS 2
39#define TIMER1_PRIORITY 4
40
41#define RTC_IRQ 22
42#define RTC_IPR_ADDR INTC_IPRA
43#define RTC_IPR_POS 0
44#define RTC_PRIORITY TIMER_PRIORITY
45
46#if defined(CONFIG_CPU_SH3)
47#define DMTE0_IRQ 48
48#define DMTE1_IRQ 49
49#define DMTE2_IRQ 50
50#define DMTE3_IRQ 51
51#define DMA_IPR_ADDR INTC_IPRE
52#define DMA_IPR_POS 3
53#define DMA_PRIORITY 7
54#if defined(CONFIG_CPU_SUBTYPE_SH7300)
55/* TMU2 */
56#define TIMER2_IRQ 18
57#define TIMER2_IPR_ADDR INTC_IPRA
58#define TIMER2_IPR_POS 1
59#define TIMER2_PRIORITY 2
60
61/* WDT */
62#define WDT_IRQ 27
63#define WDT_IPR_ADDR INTC_IPRB
64#define WDT_IPR_POS 3
65#define WDT_PRIORITY 2
66
67/* SIM (SIM Card Module) */
68#define SIM_ERI_IRQ 23
69#define SIM_RXI_IRQ 24
70#define SIM_TXI_IRQ 25
71#define SIM_TEND_IRQ 26
72#define SIM_IPR_ADDR INTC_IPRB
73#define SIM_IPR_POS 1
74#define SIM_PRIORITY 2
75
76/* VIO (Video I/O) */
77#define VIO_IRQ 52
78#define VIO_IPR_ADDR INTC_IPRE
79#define VIO_IPR_POS 2
80#define VIO_PRIORITY 2
81
82/* MFI (Multi Functional Interface) */
83#define MFI_IRQ 56
84#define MFI_IPR_ADDR INTC_IPRE
85#define MFI_IPR_POS 1
86#define MFI_PRIORITY 2
87
88/* VPU (Video Processing Unit) */
89#define VPU_IRQ 60
90#define VPU_IPR_ADDR INTC_IPRE
91#define VPU_IPR_POS 0
92#define VPU_PRIORITY 2
93
94/* KEY (Key Scan Interface) */
95#define KEY_IRQ 79
96#define KEY_IPR_ADDR INTC_IPRF
97#define KEY_IPR_POS 3
98#define KEY_PRIORITY 2
99
100/* CMT (Compare Match Timer) */
101#define CMT_IRQ 104
102#define CMT_IPR_ADDR INTC_IPRF
103#define CMT_IPR_POS 0
104#define CMT_PRIORITY 2
105
106/* DMAC(1) */
107#define DMTE0_IRQ 48
108#define DMTE1_IRQ 49
109#define DMTE2_IRQ 50
110#define DMTE3_IRQ 51
111#define DMA1_IPR_ADDR INTC_IPRE
112#define DMA1_IPR_POS 3
113#define DMA1_PRIORITY 7
114
115/* DMAC(2) */
116#define DMTE4_IRQ 76
117#define DMTE5_IRQ 77
118#define DMA2_IPR_ADDR INTC_IPRF
119#define DMA2_IPR_POS 2
120#define DMA2_PRIORITY 7
121
122/* SIOF0 */
123#define SIOF0_IRQ 84
124#define SIOF0_IPR_ADDR INTC_IPRH
125#define SIOF0_IPR_POS 3
126#define SIOF0_PRIORITY 3
127
128/* FLCTL (Flash Memory Controller) */
129#define FLSTE_IRQ 92
130#define FLTEND_IRQ 93
131#define FLTRQ0_IRQ 94
132#define FLTRQ1_IRQ 95
133#define FLCTL_IPR_ADDR INTC_IPRH
134#define FLCTL_IPR_POS 1
135#define FLCTL_PRIORITY 3
136
137/* IIC (IIC Bus Interface) */
138#define IIC_ALI_IRQ 96
139#define IIC_TACKI_IRQ 97
140#define IIC_WAITI_IRQ 98
141#define IIC_DTEI_IRQ 99
142#define IIC_IPR_ADDR INTC_IPRH
143#define IIC_IPR_POS 0
144#define IIC_PRIORITY 3
145
146/* SIO0 */
147#define SIO0_IRQ 88
148#define SIO0_IPR_ADDR INTC_IPRI
149#define SIO0_IPR_POS 3
150#define SIO0_PRIORITY 3
151
152/* SIU (Sound Interface Unit) */
153#define SIU_IRQ 108
154#define SIU_IPR_ADDR INTC_IPRJ
155#define SIU_IPR_POS 1
156#define SIU_PRIORITY 3
157
158#endif
159#elif defined(CONFIG_CPU_SH4)
160#define DMTE0_IRQ 34
161#define DMTE1_IRQ 35
162#define DMTE2_IRQ 36
163#define DMTE3_IRQ 37
164#define DMTE4_IRQ 44 /* 7751R only */
165#define DMTE5_IRQ 45 /* 7751R only */
166#define DMTE6_IRQ 46 /* 7751R only */
167#define DMTE7_IRQ 47 /* 7751R only */
168#define DMAE_IRQ 38
169#define DMA_IPR_ADDR INTC_IPRC
170#define DMA_IPR_POS 2
171#define DMA_PRIORITY 7
172#endif
173
174#if defined (CONFIG_CPU_SUBTYPE_SH7707) || defined (CONFIG_CPU_SUBTYPE_SH7708) || \
175 defined (CONFIG_CPU_SUBTYPE_SH7709) || defined (CONFIG_CPU_SUBTYPE_SH7750) || \
176 defined (CONFIG_CPU_SUBTYPE_SH7751) || defined (CONFIG_CPU_SUBTYPE_SH7706)
177#define SCI_ERI_IRQ 23
178#define SCI_RXI_IRQ 24
179#define SCI_TXI_IRQ 25
180#define SCI_IPR_ADDR INTC_IPRB
181#define SCI_IPR_POS 1
182#define SCI_PRIORITY 3
183#endif
184
185#if defined(CONFIG_CPU_SUBTYPE_SH7300)
186#define SCIF0_IRQ 80
187#define SCIF0_IPR_ADDR INTC_IPRG
188#define SCIF0_IPR_POS 3
189#define SCIF0_PRIORITY 3
190#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
191 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
192 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
193 defined(CONFIG_CPU_SUBTYPE_SH7709)
194#define SCIF_ERI_IRQ 56
195#define SCIF_RXI_IRQ 57
196#define SCIF_BRI_IRQ 58
197#define SCIF_TXI_IRQ 59
198#define SCIF_IPR_ADDR INTC_IPRE
199#define SCIF_IPR_POS 1
200#define SCIF_PRIORITY 3
201
202#define IRDA_ERI_IRQ 52
203#define IRDA_RXI_IRQ 53
204#define IRDA_BRI_IRQ 54
205#define IRDA_TXI_IRQ 55
206#define IRDA_IPR_ADDR INTC_IPRE
207#define IRDA_IPR_POS 2
208#define IRDA_PRIORITY 3
209#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) || \
210 defined(CONFIG_CPU_SUBTYPE_ST40STB1) || defined(CONFIG_CPU_SUBTYPE_SH4_202)
211#define SCIF_ERI_IRQ 40
212#define SCIF_RXI_IRQ 41
213#define SCIF_BRI_IRQ 42
214#define SCIF_TXI_IRQ 43
215#define SCIF_IPR_ADDR INTC_IPRC
216#define SCIF_IPR_POS 1
217#define SCIF_PRIORITY 3
218#if defined(CONFIG_CPU_SUBTYPE_ST40STB1)
219#define SCIF1_ERI_IRQ 23
220#define SCIF1_RXI_IRQ 24
221#define SCIF1_BRI_IRQ 25
222#define SCIF1_TXI_IRQ 26
223#define SCIF1_IPR_ADDR INTC_IPRB
224#define SCIF1_IPR_POS 1
225#define SCIF1_PRIORITY 3
226#endif /* ST40STB1 */
227
228#endif /* 775x / SH4-202 / ST40STB1 */
229#endif /* 7780 */
230
231/* NR_IRQS is made from three components: 7/* NR_IRQS is made from three components:
232 * 1. ONCHIP_NR_IRQS - number of IRLS + on-chip peripherial modules 8 * 1. ONCHIP_NR_IRQS - number of IRLS + on-chip peripherial modules
233 * 2. PINT_NR_IRQS - number of PINT interrupts 9 * 2. PINT_NR_IRQS - number of PINT interrupts
@@ -265,6 +41,10 @@
265# define ONCHIP_NR_IRQS 109 41# define ONCHIP_NR_IRQS 109
266#elif defined(CONFIG_CPU_SUBTYPE_SH7780) 42#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
267# define ONCHIP_NR_IRQS 111 43# define ONCHIP_NR_IRQS 111
44#elif defined(CONFIG_CPU_SUBTYPE_SH7206)
45# define ONCHIP_NR_IRQS 256
46#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
47# define ONCHIP_NR_IRQS 128
268#elif defined(CONFIG_SH_UNKNOWN) /* Most be last */ 48#elif defined(CONFIG_SH_UNKNOWN) /* Most be last */
269# define ONCHIP_NR_IRQS 144 49# define ONCHIP_NR_IRQS 144
270#endif 50#endif
@@ -312,9 +92,11 @@
312/* NR_IRQS. 1+2+3 */ 92/* NR_IRQS. 1+2+3 */
313#define NR_IRQS (ONCHIP_NR_IRQS + PINT_NR_IRQS + OFFCHIP_NR_IRQS) 93#define NR_IRQS (ONCHIP_NR_IRQS + PINT_NR_IRQS + OFFCHIP_NR_IRQS)
314 94
315extern void disable_irq(unsigned int); 95/*
316extern void disable_irq_nosync(unsigned int); 96 * Convert back and forth between INTEVT and IRQ values.
317extern void enable_irq(unsigned int); 97 */
98#define evt2irq(evt) (((evt) >> 5) - 16)
99#define irq2evt(irq) (((irq) + 16) << 5)
318 100
319/* 101/*
320 * Simple Mask Register Support 102 * Simple Mask Register Support
@@ -327,362 +109,36 @@ extern unsigned short *irq_mask_register;
327 */ 109 */
328void init_IRQ_pint(void); 110void init_IRQ_pint(void);
329 111
112/*
113 * The shift value is now the number of bits to shift, not the number of
114 * bits/4. This is to make it easier to read the value directly from the
115 * datasheets. The IPR address, addr, will be set from ipr_idx via the
116 * map_ipridx_to_addr function.
117 */
330struct ipr_data { 118struct ipr_data {
331 unsigned int irq; 119 unsigned int irq;
332 unsigned int addr; /* Address of Interrupt Priority Register */ 120 int ipr_idx; /* Index for the IPR registered */
333 int shift; /* Shifts of the 16-bit data */ 121 int shift; /* Number of bits to shift the data */
334 int priority; /* The priority */ 122 int priority; /* The priority */
123 unsigned int addr; /* Address of Interrupt Priority Register */
335}; 124};
336 125
337/* 126/*
338 * Function for "on chip support modules". 127 * Given an IPR IDX, map the value to an IPR register address.
339 */ 128 */
340extern void make_ipr_irq(struct ipr_data *table, unsigned int nr_irqs); 129unsigned int map_ipridx_to_addr(int idx);
341extern void make_imask_irq(unsigned int irq);
342
343#if defined(CONFIG_CPU_SUBTYPE_SH7300)
344#undef INTC_IPRA
345#undef INTC_IPRB
346#define INTC_IPRA 0xA414FEE2UL
347#define INTC_IPRB 0xA414FEE4UL
348#define INTC_IPRC 0xA4140016UL
349#define INTC_IPRD 0xA4140018UL
350#define INTC_IPRE 0xA414001AUL
351#define INTC_IPRF 0xA4080000UL
352#define INTC_IPRG 0xA4080002UL
353#define INTC_IPRH 0xA4080004UL
354#define INTC_IPRI 0xA4080006UL
355#define INTC_IPRJ 0xA4080008UL
356
357#define INTC_IMR0 0xA4080040UL
358#define INTC_IMR1 0xA4080042UL
359#define INTC_IMR2 0xA4080044UL
360#define INTC_IMR3 0xA4080046UL
361#define INTC_IMR4 0xA4080048UL
362#define INTC_IMR5 0xA408004AUL
363#define INTC_IMR6 0xA408004CUL
364#define INTC_IMR7 0xA408004EUL
365#define INTC_IMR8 0xA4080050UL
366#define INTC_IMR9 0xA4080052UL
367#define INTC_IMR10 0xA4080054UL
368
369#define INTC_IMCR0 0xA4080060UL
370#define INTC_IMCR1 0xA4080062UL
371#define INTC_IMCR2 0xA4080064UL
372#define INTC_IMCR3 0xA4080066UL
373#define INTC_IMCR4 0xA4080068UL
374#define INTC_IMCR5 0xA408006AUL
375#define INTC_IMCR6 0xA408006CUL
376#define INTC_IMCR7 0xA408006EUL
377#define INTC_IMCR8 0xA4080070UL
378#define INTC_IMCR9 0xA4080072UL
379#define INTC_IMCR10 0xA4080074UL
380
381#define INTC_ICR0 0xA414FEE0UL
382#define INTC_ICR1 0xA4140010UL
383
384#define INTC_IRR0 0xA4140004UL
385
386#define PORT_PACR 0xA4050100UL
387#define PORT_PBCR 0xA4050102UL
388#define PORT_PCCR 0xA4050104UL
389#define PORT_PDCR 0xA4050106UL
390#define PORT_PECR 0xA4050108UL
391#define PORT_PFCR 0xA405010AUL
392#define PORT_PGCR 0xA405010CUL
393#define PORT_PHCR 0xA405010EUL
394#define PORT_PJCR 0xA4050110UL
395#define PORT_PKCR 0xA4050112UL
396#define PORT_PLCR 0xA4050114UL
397#define PORT_SCPCR 0xA4050116UL
398#define PORT_PMCR 0xA4050118UL
399#define PORT_PNCR 0xA405011AUL
400#define PORT_PQCR 0xA405011CUL
401
402#define PORT_PSELA 0xA4050140UL
403#define PORT_PSELB 0xA4050142UL
404#define PORT_PSELC 0xA4050144UL
405
406#define PORT_HIZCRA 0xA4050146UL
407#define PORT_HIZCRB 0xA4050148UL
408#define PORT_DRVCR 0xA4050150UL
409
410#define PORT_PADR 0xA4050120UL
411#define PORT_PBDR 0xA4050122UL
412#define PORT_PCDR 0xA4050124UL
413#define PORT_PDDR 0xA4050126UL
414#define PORT_PEDR 0xA4050128UL
415#define PORT_PFDR 0xA405012AUL
416#define PORT_PGDR 0xA405012CUL
417#define PORT_PHDR 0xA405012EUL
418#define PORT_PJDR 0xA4050130UL
419#define PORT_PKDR 0xA4050132UL
420#define PORT_PLDR 0xA4050134UL
421#define PORT_SCPDR 0xA4050136UL
422#define PORT_PMDR 0xA4050138UL
423#define PORT_PNDR 0xA405013AUL
424#define PORT_PQDR 0xA405013CUL
425
426#define IRQ0_IRQ 32
427#define IRQ1_IRQ 33
428#define IRQ2_IRQ 34
429#define IRQ3_IRQ 35
430#define IRQ4_IRQ 36
431#define IRQ5_IRQ 37
432
433#define IRQ0_IPR_ADDR INTC_IPRC
434#define IRQ1_IPR_ADDR INTC_IPRC
435#define IRQ2_IPR_ADDR INTC_IPRC
436#define IRQ3_IPR_ADDR INTC_IPRC
437#define IRQ4_IPR_ADDR INTC_IPRD
438#define IRQ5_IPR_ADDR INTC_IPRD
439
440#define IRQ0_IPR_POS 0
441#define IRQ1_IPR_POS 1
442#define IRQ2_IPR_POS 2
443#define IRQ3_IPR_POS 3
444#define IRQ4_IPR_POS 0
445#define IRQ5_IPR_POS 1
446 130
447#define IRQ0_PRIORITY 1 131/*
448#define IRQ1_PRIORITY 1 132 * Enable individual interrupt mode for external IPR IRQs.
449#define IRQ2_PRIORITY 1 133 */
450#define IRQ3_PRIORITY 1 134void ipr_irq_enable_irlm(void);
451#define IRQ4_PRIORITY 1
452#define IRQ5_PRIORITY 1
453
454extern int ipr_irq_demux(int irq);
455#define __irq_demux(irq) ipr_irq_demux(irq)
456
457#elif defined(CONFIG_CPU_SUBTYPE_SH7604)
458#define INTC_IPRA 0xfffffee2UL
459#define INTC_IPRB 0xfffffe60UL
460
461#define INTC_VCRA 0xfffffe62UL
462#define INTC_VCRB 0xfffffe64UL
463#define INTC_VCRC 0xfffffe66UL
464#define INTC_VCRD 0xfffffe68UL
465
466#define INTC_VCRWDT 0xfffffee4UL
467#define INTC_VCRDIV 0xffffff0cUL
468#define INTC_VCRDMA0 0xffffffa0UL
469#define INTC_VCRDMA1 0xffffffa8UL
470
471#define INTC_ICR 0xfffffee0UL
472#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
473 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
474 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
475 defined(CONFIG_CPU_SUBTYPE_SH7709) || \
476 defined(CONFIG_CPU_SUBTYPE_SH7710)
477#define INTC_IRR0 0xa4000004UL
478#define INTC_IRR1 0xa4000006UL
479#define INTC_IRR2 0xa4000008UL
480
481#define INTC_ICR0 0xfffffee0UL
482#define INTC_ICR1 0xa4000010UL
483#define INTC_ICR2 0xa4000012UL
484#define INTC_INTER 0xa4000014UL
485
486#define INTC_IPRC 0xa4000016UL
487#define INTC_IPRD 0xa4000018UL
488#define INTC_IPRE 0xa400001aUL
489#if defined(CONFIG_CPU_SUBTYPE_SH7707)
490#define INTC_IPRF 0xa400001cUL
491#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
492#define INTC_IPRF 0xa4080000UL
493#define INTC_IPRG 0xa4080002UL
494#define INTC_IPRH 0xa4080004UL
495#elif defined(CONFIG_CPU_SUBTYPE_SH7710)
496/* Interrupt Controller Registers */
497#undef INTC_IPRA
498#undef INTC_IPRB
499#define INTC_IPRA 0xA414FEE2UL
500#define INTC_IPRB 0xA414FEE4UL
501#define INTC_IPRF 0xA4080000UL
502#define INTC_IPRG 0xA4080002UL
503#define INTC_IPRH 0xA4080004UL
504#define INTC_IPRI 0xA4080006UL
505
506#undef INTC_ICR0
507#undef INTC_ICR1
508#define INTC_ICR0 0xA414FEE0UL
509#define INTC_ICR1 0xA4140010UL
510
511#define INTC_IRR0 0xa4000004UL
512#define INTC_IRR1 0xa4000006UL
513#define INTC_IRR2 0xa4000008UL
514#define INTC_IRR3 0xa400000AUL
515#define INTC_IRR4 0xa400000CUL
516#define INTC_IRR5 0xa4080020UL
517#define INTC_IRR7 0xa4080024UL
518#define INTC_IRR8 0xa4080026UL
519
520/* Interrupt numbers */
521#define TIMER2_IRQ 18
522#define TIMER2_IPR_ADDR INTC_IPRA
523#define TIMER2_IPR_POS 1
524#define TIMER2_PRIORITY 2
525
526/* WDT */
527#define WDT_IRQ 27
528#define WDT_IPR_ADDR INTC_IPRB
529#define WDT_IPR_POS 3
530#define WDT_PRIORITY 2
531
532#define SCIF0_ERI_IRQ 52
533#define SCIF0_RXI_IRQ 53
534#define SCIF0_BRI_IRQ 54
535#define SCIF0_TXI_IRQ 55
536#define SCIF0_IPR_ADDR INTC_IPRE
537#define SCIF0_IPR_POS 2
538#define SCIF0_PRIORITY 3
539
540#define DMTE4_IRQ 76
541#define DMTE5_IRQ 77
542#define DMA2_IPR_ADDR INTC_IPRF
543#define DMA2_IPR_POS 2
544#define DMA2_PRIORITY 7
545
546#define IPSEC_IRQ 79
547#define IPSEC_IPR_ADDR INTC_IPRF
548#define IPSEC_IPR_POS 3
549#define IPSEC_PRIORITY 3
550
551/* EDMAC */
552#define EDMAC0_IRQ 80
553#define EDMAC0_IPR_ADDR INTC_IPRG
554#define EDMAC0_IPR_POS 3
555#define EDMAC0_PRIORITY 3
556
557#define EDMAC1_IRQ 81
558#define EDMAC1_IPR_ADDR INTC_IPRG
559#define EDMAC1_IPR_POS 2
560#define EDMAC1_PRIORITY 3
561
562#define EDMAC2_IRQ 82
563#define EDMAC2_IPR_ADDR INTC_IPRG
564#define EDMAC2_IPR_POS 1
565#define EDMAC2_PRIORITY 3
566
567/* SIOF */
568#define SIOF0_ERI_IRQ 96
569#define SIOF0_TXI_IRQ 97
570#define SIOF0_RXI_IRQ 98
571#define SIOF0_CCI_IRQ 99
572#define SIOF0_IPR_ADDR INTC_IPRH
573#define SIOF0_IPR_POS 0
574#define SIOF0_PRIORITY 7
575
576#define SIOF1_ERI_IRQ 100
577#define SIOF1_TXI_IRQ 101
578#define SIOF1_RXI_IRQ 102
579#define SIOF1_CCI_IRQ 103
580#define SIOF1_IPR_ADDR INTC_IPRI
581#define SIOF1_IPR_POS 1
582#define SIOF1_PRIORITY 7
583#endif /* CONFIG_CPU_SUBTYPE_SH7710 */
584
585#if defined(CONFIG_CPU_SUBTYPE_SH7710)
586#define PORT_PACR 0xa4050100UL
587#define PORT_PBCR 0xa4050102UL
588#define PORT_PCCR 0xa4050104UL
589#define PORT_PETCR 0xa4050106UL
590#define PORT_PADR 0xa4050120UL
591#define PORT_PBDR 0xa4050122UL
592#define PORT_PCDR 0xa4050124UL
593#else
594#define PORT_PACR 0xa4000100UL
595#define PORT_PBCR 0xa4000102UL
596#define PORT_PCCR 0xa4000104UL
597#define PORT_PFCR 0xa400010aUL
598#define PORT_PADR 0xa4000120UL
599#define PORT_PBDR 0xa4000122UL
600#define PORT_PCDR 0xa4000124UL
601#define PORT_PFDR 0xa400012aUL
602#endif
603
604#define IRQ0_IRQ 32
605#define IRQ1_IRQ 33
606#define IRQ2_IRQ 34
607#define IRQ3_IRQ 35
608#define IRQ4_IRQ 36
609#define IRQ5_IRQ 37
610
611#define IRQ0_IPR_ADDR INTC_IPRC
612#define IRQ1_IPR_ADDR INTC_IPRC
613#define IRQ2_IPR_ADDR INTC_IPRC
614#define IRQ3_IPR_ADDR INTC_IPRC
615#define IRQ4_IPR_ADDR INTC_IPRD
616#define IRQ5_IPR_ADDR INTC_IPRD
617
618#define IRQ0_IPR_POS 0
619#define IRQ1_IPR_POS 1
620#define IRQ2_IPR_POS 2
621#define IRQ3_IPR_POS 3
622#define IRQ4_IPR_POS 0
623#define IRQ5_IPR_POS 1
624
625#define IRQ0_PRIORITY 1
626#define IRQ1_PRIORITY 1
627#define IRQ2_PRIORITY 1
628#define IRQ3_PRIORITY 1
629#define IRQ4_PRIORITY 1
630#define IRQ5_PRIORITY 1
631
632#define PINT0_IRQ 40
633#define PINT8_IRQ 41
634
635#define PINT0_IPR_ADDR INTC_IPRD
636#define PINT8_IPR_ADDR INTC_IPRD
637
638#define PINT0_IPR_POS 3
639#define PINT8_IPR_POS 2
640#define PINT0_PRIORITY 2
641#define PINT8_PRIORITY 2
642
643extern int ipr_irq_demux(int irq);
644#define __irq_demux(irq) ipr_irq_demux(irq)
645#endif /* CONFIG_CPU_SUBTYPE_SH7707 || CONFIG_CPU_SUBTYPE_SH7709 */
646
647#if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) || \
648 defined(CONFIG_CPU_SUBTYPE_ST40STB1) || defined(CONFIG_CPU_SUBTYPE_SH4_202)
649#define INTC_ICR 0xffd00000
650#define INTC_ICR_NMIL (1<<15)
651#define INTC_ICR_MAI (1<<14)
652#define INTC_ICR_NMIB (1<<9)
653#define INTC_ICR_NMIE (1<<8)
654#define INTC_ICR_IRLM (1<<7)
655#endif
656
657#ifdef CONFIG_CPU_SUBTYPE_SH7780
658#include <asm/irq-sh7780.h>
659#endif
660
661/* SH with INTC2-style interrupts */
662#ifdef CONFIG_CPU_HAS_INTC2_IRQ
663#if defined(CONFIG_CPU_SUBTYPE_ST40STB1)
664#define INTC2_BASE 0xfe080000
665#define INTC2_FIRST_IRQ 64
666#define INTC2_INTREQ_OFFSET 0x20
667#define INTC2_INTMSK_OFFSET 0x40
668#define INTC2_INTMSKCLR_OFFSET 0x60
669#define NR_INTC2_IRQS 25
670#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
671#define INTC2_BASE 0xfe080000
672#define INTC2_FIRST_IRQ 48 /* INTEVT 0x800 */
673#define INTC2_INTREQ_OFFSET 0x20
674#define INTC2_INTMSK_OFFSET 0x40
675#define INTC2_INTMSKCLR_OFFSET 0x60
676#define NR_INTC2_IRQS 64
677#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
678#define INTC2_BASE 0xffd40000
679#define INTC2_FIRST_IRQ 21
680#define INTC2_INTMSK_OFFSET (0x38)
681#define INTC2_INTMSKCLR_OFFSET (0x3c)
682#define NR_INTC2_IRQS 60
683#endif
684 135
685#define INTC2_INTPRI_OFFSET 0x00 136/*
137 * Function for "on chip support modules".
138 */
139void make_ipr_irq(struct ipr_data *table, unsigned int nr_irqs);
140void make_imask_irq(unsigned int irq);
141void init_IRQ_ipr(void);
686 142
687struct intc2_data { 143struct intc2_data {
688 unsigned short irq; 144 unsigned short irq;
@@ -693,20 +149,14 @@ struct intc2_data {
693 149
694void make_intc2_irq(struct intc2_data *, unsigned int nr_irqs); 150void make_intc2_irq(struct intc2_data *, unsigned int nr_irqs);
695void init_IRQ_intc2(void); 151void init_IRQ_intc2(void);
696#endif
697
698extern int shmse_irq_demux(int irq);
699 152
700static inline int generic_irq_demux(int irq) 153static inline int generic_irq_demux(int irq)
701{ 154{
702 return irq; 155 return irq;
703} 156}
704 157
705#ifndef __irq_demux
706#define __irq_demux(irq) (irq)
707#endif
708#define irq_canonicalize(irq) (irq) 158#define irq_canonicalize(irq) (irq)
709#define irq_demux(irq) __irq_demux(sh_mv.mv_irq_demux(irq)) 159#define irq_demux(irq) sh_mv.mv_irq_demux(irq)
710 160
711#ifdef CONFIG_4KSTACKS 161#ifdef CONFIG_4KSTACKS
712extern void irq_ctx_init(int cpu); 162extern void irq_ctx_init(int cpu);
@@ -717,12 +167,4 @@ extern void irq_ctx_exit(int cpu);
717# define irq_ctx_exit(cpu) do { } while (0) 167# define irq_ctx_exit(cpu) do { } while (0)
718#endif 168#endif
719 169
720#if defined(CONFIG_CPU_SUBTYPE_SH73180)
721#include <asm/irq-sh73180.h>
722#endif
723
724#if defined(CONFIG_CPU_SUBTYPE_SH7343)
725#include <asm/irq-sh7343.h>
726#endif
727
728#endif /* __ASM_SH_IRQ_H */ 170#endif /* __ASM_SH_IRQ_H */
diff --git a/include/asm-sh/irqflags.h b/include/asm-sh/irqflags.h
new file mode 100644
index 000000000000..9dedc1b693e3
--- /dev/null
+++ b/include/asm-sh/irqflags.h
@@ -0,0 +1,123 @@
1#ifndef __ASM_SH_IRQFLAGS_H
2#define __ASM_SH_IRQFLAGS_H
3
4static inline void raw_local_irq_enable(void)
5{
6 unsigned long __dummy0, __dummy1;
7
8 __asm__ __volatile__ (
9 "stc sr, %0\n\t"
10 "and %1, %0\n\t"
11#ifdef CONFIG_CPU_HAS_SR_RB
12 "stc r6_bank, %1\n\t"
13 "or %1, %0\n\t"
14#endif
15 "ldc %0, sr\n\t"
16 : "=&r" (__dummy0), "=r" (__dummy1)
17 : "1" (~0x000000f0)
18 : "memory"
19 );
20}
21
22static inline void raw_local_irq_disable(void)
23{
24 unsigned long flags;
25
26 __asm__ __volatile__ (
27 "stc sr, %0\n\t"
28 "or #0xf0, %0\n\t"
29 "ldc %0, sr\n\t"
30 : "=&z" (flags)
31 : /* no inputs */
32 : "memory"
33 );
34}
35
36static inline void set_bl_bit(void)
37{
38 unsigned long __dummy0, __dummy1;
39
40 __asm__ __volatile__ (
41 "stc sr, %0\n\t"
42 "or %2, %0\n\t"
43 "and %3, %0\n\t"
44 "ldc %0, sr\n\t"
45 : "=&r" (__dummy0), "=r" (__dummy1)
46 : "r" (0x10000000), "r" (0xffffff0f)
47 : "memory"
48 );
49}
50
51static inline void clear_bl_bit(void)
52{
53 unsigned long __dummy0, __dummy1;
54
55 __asm__ __volatile__ (
56 "stc sr, %0\n\t"
57 "and %2, %0\n\t"
58 "ldc %0, sr\n\t"
59 : "=&r" (__dummy0), "=r" (__dummy1)
60 : "1" (~0x10000000)
61 : "memory"
62 );
63}
64
65static inline unsigned long __raw_local_save_flags(void)
66{
67 unsigned long flags;
68
69 __asm__ __volatile__ (
70 "stc sr, %0\n\t"
71 "and #0xf0, %0\n\t"
72 : "=&z" (flags)
73 : /* no inputs */
74 : "memory"
75 );
76
77 return flags;
78}
79
80#define raw_local_save_flags(flags) \
81 do { (flags) = __raw_local_save_flags(); } while (0)
82
83static inline int raw_irqs_disabled_flags(unsigned long flags)
84{
85 return (flags != 0);
86}
87
88static inline int raw_irqs_disabled(void)
89{
90 unsigned long flags = __raw_local_save_flags();
91
92 return raw_irqs_disabled_flags(flags);
93}
94
95static inline unsigned long __raw_local_irq_save(void)
96{
97 unsigned long flags, __dummy;
98
99 __asm__ __volatile__ (
100 "stc sr, %1\n\t"
101 "mov %1, %0\n\t"
102 "or #0xf0, %0\n\t"
103 "ldc %0, sr\n\t"
104 "mov %1, %0\n\t"
105 "and #0xf0, %0\n\t"
106 : "=&z" (flags), "=&r" (__dummy)
107 : /* no inputs */
108 : "memory"
109 );
110
111 return flags;
112}
113
114#define raw_local_irq_save(flags) \
115 do { (flags) = __raw_local_irq_save(); } while (0)
116
117static inline void raw_local_irq_restore(unsigned long flags)
118{
119 if ((flags & 0xf0) != 0xf0)
120 raw_local_irq_enable();
121}
122
123#endif /* __ASM_SH_IRQFLAGS_H */
diff --git a/include/asm-sh/mmu_context.h b/include/asm-sh/mmu_context.h
index c7088efe579a..46f04e23bd45 100644
--- a/include/asm-sh/mmu_context.h
+++ b/include/asm-sh/mmu_context.h
@@ -10,7 +10,6 @@
10 10
11#include <asm/cpu/mmu_context.h> 11#include <asm/cpu/mmu_context.h>
12#include <asm/tlbflush.h> 12#include <asm/tlbflush.h>
13#include <asm/pgalloc.h>
14#include <asm/uaccess.h> 13#include <asm/uaccess.h>
15#include <asm/io.h> 14#include <asm/io.h>
16 15
@@ -42,10 +41,8 @@ extern unsigned long mmu_context_cache;
42/* 41/*
43 * Get MMU context if needed. 42 * Get MMU context if needed.
44 */ 43 */
45static __inline__ void 44static inline void get_mmu_context(struct mm_struct *mm)
46get_mmu_context(struct mm_struct *mm)
47{ 45{
48 extern void flush_tlb_all(void);
49 unsigned long mc = mmu_context_cache; 46 unsigned long mc = mmu_context_cache;
50 47
51 /* Check if we have old version of context. */ 48 /* Check if we have old version of context. */
@@ -61,6 +58,7 @@ get_mmu_context(struct mm_struct *mm)
61 * Flush all TLB and start new cycle. 58 * Flush all TLB and start new cycle.
62 */ 59 */
63 flush_tlb_all(); 60 flush_tlb_all();
61
64 /* 62 /*
65 * Fix version; Note that we avoid version #0 63 * Fix version; Note that we avoid version #0
66 * to distingush NO_CONTEXT. 64 * to distingush NO_CONTEXT.
@@ -75,11 +73,10 @@ get_mmu_context(struct mm_struct *mm)
75 * Initialize the context related info for a new mm_struct 73 * Initialize the context related info for a new mm_struct
76 * instance. 74 * instance.
77 */ 75 */
78static __inline__ int init_new_context(struct task_struct *tsk, 76static inline int init_new_context(struct task_struct *tsk,
79 struct mm_struct *mm) 77 struct mm_struct *mm)
80{ 78{
81 mm->context.id = NO_CONTEXT; 79 mm->context.id = NO_CONTEXT;
82
83 return 0; 80 return 0;
84} 81}
85 82
@@ -87,12 +84,12 @@ static __inline__ int init_new_context(struct task_struct *tsk,
87 * Destroy context related info for an mm_struct that is about 84 * Destroy context related info for an mm_struct that is about
88 * to be put to rest. 85 * to be put to rest.
89 */ 86 */
90static __inline__ void destroy_context(struct mm_struct *mm) 87static inline void destroy_context(struct mm_struct *mm)
91{ 88{
92 /* Do nothing */ 89 /* Do nothing */
93} 90}
94 91
95static __inline__ void set_asid(unsigned long asid) 92static inline void set_asid(unsigned long asid)
96{ 93{
97 unsigned long __dummy; 94 unsigned long __dummy;
98 95
@@ -105,7 +102,7 @@ static __inline__ void set_asid(unsigned long asid)
105 "r" (0xffffff00)); 102 "r" (0xffffff00));
106} 103}
107 104
108static __inline__ unsigned long get_asid(void) 105static inline unsigned long get_asid(void)
109{ 106{
110 unsigned long asid; 107 unsigned long asid;
111 108
@@ -120,24 +117,29 @@ static __inline__ unsigned long get_asid(void)
120 * After we have set current->mm to a new value, this activates 117 * After we have set current->mm to a new value, this activates
121 * the context for the new mm so we see the new mappings. 118 * the context for the new mm so we see the new mappings.
122 */ 119 */
123static __inline__ void activate_context(struct mm_struct *mm) 120static inline void activate_context(struct mm_struct *mm)
124{ 121{
125 get_mmu_context(mm); 122 get_mmu_context(mm);
126 set_asid(mm->context.id & MMU_CONTEXT_ASID_MASK); 123 set_asid(mm->context.id & MMU_CONTEXT_ASID_MASK);
127} 124}
128 125
129/* MMU_TTB can be used for optimizing the fault handling. 126/* MMU_TTB is used for optimizing the fault handling. */
130 (Currently not used) */ 127static inline void set_TTB(pgd_t *pgd)
131static __inline__ void switch_mm(struct mm_struct *prev,
132 struct mm_struct *next,
133 struct task_struct *tsk)
134{ 128{
135 if (likely(prev != next)) { 129 ctrl_outl((unsigned long)pgd, MMU_TTB);
136 unsigned long __pgdir = (unsigned long)next->pgd; 130}
137 131
138 __asm__ __volatile__("mov.l %0, %1" 132static inline pgd_t *get_TTB(void)
139 : /* no output */ 133{
140 : "r" (__pgdir), "m" (__m(MMU_TTB))); 134 return (pgd_t *)ctrl_inl(MMU_TTB);
135}
136
137static inline void switch_mm(struct mm_struct *prev,
138 struct mm_struct *next,
139 struct task_struct *tsk)
140{
141 if (likely(prev != next)) {
142 set_TTB(next->pgd);
141 activate_context(next); 143 activate_context(next);
142 } 144 }
143} 145}
@@ -147,7 +149,7 @@ static __inline__ void switch_mm(struct mm_struct *prev,
147#define activate_mm(prev, next) \ 149#define activate_mm(prev, next) \
148 switch_mm((prev),(next),NULL) 150 switch_mm((prev),(next),NULL)
149 151
150static __inline__ void 152static inline void
151enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) 153enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
152{ 154{
153} 155}
diff --git a/include/asm-sh/page.h b/include/asm-sh/page.h
index ca8b26d90475..380fd62dd05a 100644
--- a/include/asm-sh/page.h
+++ b/include/asm-sh/page.h
@@ -13,9 +13,16 @@
13 [ P4 control ] 0xE0000000 13 [ P4 control ] 0xE0000000
14 */ 14 */
15 15
16
17/* PAGE_SHIFT determines the page size */ 16/* PAGE_SHIFT determines the page size */
18#define PAGE_SHIFT 12 17#if defined(CONFIG_PAGE_SIZE_4KB)
18# define PAGE_SHIFT 12
19#elif defined(CONFIG_PAGE_SIZE_8KB)
20# define PAGE_SHIFT 13
21#elif defined(CONFIG_PAGE_SIZE_64KB)
22# define PAGE_SHIFT 16
23#else
24# error "Bogus kernel page size?"
25#endif
19 26
20#ifdef __ASSEMBLY__ 27#ifdef __ASSEMBLY__
21#define PAGE_SIZE (1 << PAGE_SHIFT) 28#define PAGE_SIZE (1 << PAGE_SHIFT)
@@ -28,8 +35,14 @@
28 35
29#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K) 36#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
30#define HPAGE_SHIFT 16 37#define HPAGE_SHIFT 16
38#elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K)
39#define HPAGE_SHIFT 18
31#elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB) 40#elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
32#define HPAGE_SHIFT 20 41#define HPAGE_SHIFT 20
42#elif defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
43#define HPAGE_SHIFT 22
44#elif defined(CONFIG_HUGETLB_PAGE_SIZE_64MB)
45#define HPAGE_SHIFT 26
33#endif 46#endif
34 47
35#ifdef CONFIG_HUGETLB_PAGE 48#ifdef CONFIG_HUGETLB_PAGE
@@ -69,15 +82,25 @@ extern void __copy_user_page(void *to, void *from, void *orig_to);
69/* 82/*
70 * These are used to make use of C type-checking.. 83 * These are used to make use of C type-checking..
71 */ 84 */
72typedef struct { unsigned long pte; } pte_t; 85#ifdef CONFIG_X2TLB
73typedef struct { unsigned long pgd; } pgd_t; 86typedef struct { unsigned long pte_low, pte_high; } pte_t;
87typedef struct { unsigned long long pgprot; } pgprot_t;
88#define pte_val(x) \
89 ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
90#define __pte(x) \
91 ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
92#else
93typedef struct { unsigned long pte_low; } pte_t;
74typedef struct { unsigned long pgprot; } pgprot_t; 94typedef struct { unsigned long pgprot; } pgprot_t;
95#define pte_val(x) ((x).pte_low)
96#define __pte(x) ((pte_t) { (x) } )
97#endif
98
99typedef struct { unsigned long pgd; } pgd_t;
75 100
76#define pte_val(x) ((x).pte)
77#define pgd_val(x) ((x).pgd) 101#define pgd_val(x) ((x).pgd)
78#define pgprot_val(x) ((x).pgprot) 102#define pgprot_val(x) ((x).pgprot)
79 103
80#define __pte(x) ((pte_t) { (x) } )
81#define __pgd(x) ((pgd_t) { (x) } ) 104#define __pgd(x) ((pgd_t) { (x) } )
82#define __pgprot(x) ((pgprot_t) { (x) } ) 105#define __pgprot(x) ((pgprot_t) { (x) } )
83 106
diff --git a/include/asm-sh/pgalloc.h b/include/asm-sh/pgalloc.h
index e841465ab4d2..888e4529e6fe 100644
--- a/include/asm-sh/pgalloc.h
+++ b/include/asm-sh/pgalloc.h
@@ -1,13 +1,16 @@
1#ifndef __ASM_SH_PGALLOC_H 1#ifndef __ASM_SH_PGALLOC_H
2#define __ASM_SH_PGALLOC_H 2#define __ASM_SH_PGALLOC_H
3 3
4#define pmd_populate_kernel(mm, pmd, pte) \ 4static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
5 set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte))) 5 pte_t *pte)
6{
7 set_pmd(pmd, __pmd((unsigned long)pte));
8}
6 9
7static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, 10static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
8 struct page *pte) 11 struct page *pte)
9{ 12{
10 set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(pte))); 13 set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
11} 14}
12 15
13/* 16/*
@@ -15,7 +18,16 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
15 */ 18 */
16static inline pgd_t *pgd_alloc(struct mm_struct *mm) 19static inline pgd_t *pgd_alloc(struct mm_struct *mm)
17{ 20{
18 return (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO); 21 pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT);
22
23 if (pgd) {
24 memset(pgd, 0, USER_PTRS_PER_PGD * sizeof(pgd_t));
25 memcpy(pgd + USER_PTRS_PER_PGD,
26 swapper_pg_dir + USER_PTRS_PER_PGD,
27 (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
28 }
29
30 return pgd;
19} 31}
20 32
21static inline void pgd_free(pgd_t *pgd) 33static inline void pgd_free(pgd_t *pgd)
diff --git a/include/asm-sh/pgtable-2level.h b/include/asm-sh/pgtable-2level.h
deleted file mode 100644
index b525db6f61c6..000000000000
--- a/include/asm-sh/pgtable-2level.h
+++ /dev/null
@@ -1,70 +0,0 @@
1#ifndef __ASM_SH_PGTABLE_2LEVEL_H
2#define __ASM_SH_PGTABLE_2LEVEL_H
3
4/*
5 * traditional two-level paging structure:
6 */
7
8#define PGDIR_SHIFT 22
9#define PTRS_PER_PGD 1024
10
11/*
12 * this is two-level, so we don't really have any
13 * PMD directory physically.
14 */
15#define PMD_SHIFT 22
16#define PTRS_PER_PMD 1
17
18#define PTRS_PER_PTE 1024
19
20#ifndef __ASSEMBLY__
21#define pte_ERROR(e) \
22 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
23#define pmd_ERROR(e) \
24 printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))
25#define pgd_ERROR(e) \
26 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
27
28/*
29 * The "pgd_xxx()" functions here are trivial for a folded two-level
30 * setup: the pgd is never bad, and a pmd always exists (as it's folded
31 * into the pgd entry)
32 */
33static inline int pgd_none(pgd_t pgd) { return 0; }
34static inline int pgd_bad(pgd_t pgd) { return 0; }
35static inline int pgd_present(pgd_t pgd) { return 1; }
36static inline void pgd_clear (pgd_t * pgdp) { }
37
38/*
39 * Certain architectures need to do special things when PTEs
40 * within a page table are directly modified. Thus, the following
41 * hook is made available.
42 */
43#define set_pte(pteptr, pteval) (*(pteptr) = pteval)
44#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
45
46/*
47 * (pmds are folded into pgds so this doesn't get actually called,
48 * but the define is needed for a generic inline function.)
49 */
50#define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
51#define set_pgd(pgdptr, pgdval) (*(pgdptr) = pgdval)
52
53#define pgd_page_vaddr(pgd) \
54((unsigned long) __va(pgd_val(pgd) & PAGE_MASK))
55
56#define pgd_page(pgd) \
57 (phys_to_page(pgd_val(pgd)))
58
59static inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
60{
61 return (pmd_t *) dir;
62}
63
64#define pte_pfn(x) ((unsigned long)(((x).pte >> PAGE_SHIFT)))
65#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
66#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
67
68#endif /* !__ASSEMBLY__ */
69
70#endif /* __ASM_SH_PGTABLE_2LEVEL_H */
diff --git a/include/asm-sh/pgtable.h b/include/asm-sh/pgtable.h
index 2c8682ad1012..c84901dbd8e5 100644
--- a/include/asm-sh/pgtable.h
+++ b/include/asm-sh/pgtable.h
@@ -15,15 +15,10 @@
15#include <asm-generic/pgtable-nopmd.h> 15#include <asm-generic/pgtable-nopmd.h>
16#include <asm/page.h> 16#include <asm/page.h>
17 17
18#define PTRS_PER_PGD 1024
19
20#ifndef __ASSEMBLY__ 18#ifndef __ASSEMBLY__
21#include <asm/addrspace.h> 19#include <asm/addrspace.h>
22#include <asm/fixmap.h> 20#include <asm/fixmap.h>
23 21
24extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
25extern void paging_init(void);
26
27/* 22/*
28 * ZERO_PAGE is a global shared page that is always zero: used 23 * ZERO_PAGE is a global shared page that is always zero: used
29 * for zero-mapped memory areas etc.. 24 * for zero-mapped memory areas etc..
@@ -33,15 +28,28 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
33 28
34#endif /* !__ASSEMBLY__ */ 29#endif /* !__ASSEMBLY__ */
35 30
36/* traditional two-level paging structure */ 31/*
37#define PGDIR_SHIFT 22 32 * traditional two-level paging structure
38#define PTRS_PER_PMD 1 33 */
39#define PTRS_PER_PTE 1024 34/* PTE bits */
40#define PMD_SIZE (1UL << PMD_SHIFT) 35#ifdef CONFIG_X2TLB
41#define PMD_MASK (~(PMD_SIZE-1)) 36# define PTE_MAGNITUDE 3 /* 64-bit PTEs on extended mode SH-X2 TLB */
42#define PGDIR_SIZE (1UL << PGDIR_SHIFT) 37#else
38# define PTE_MAGNITUDE 2 /* 32-bit PTEs */
39#endif
40#define PTE_SHIFT PAGE_SHIFT
41#define PTE_BITS (PTE_SHIFT - PTE_MAGNITUDE)
42
43/* PGD bits */
44#define PGDIR_SHIFT (PTE_SHIFT + PTE_BITS)
45#define PGDIR_BITS (32 - PGDIR_SHIFT)
46#define PGDIR_SIZE (1 << PGDIR_SHIFT)
43#define PGDIR_MASK (~(PGDIR_SIZE-1)) 47#define PGDIR_MASK (~(PGDIR_SIZE-1))
44 48
49/* Entries per level */
50#define PTRS_PER_PTE (PAGE_SIZE / 4)
51#define PTRS_PER_PGD (PAGE_SIZE / 4)
52
45#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE) 53#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
46#define FIRST_USER_ADDRESS 0 54#define FIRST_USER_ADDRESS 0
47 55
@@ -49,7 +57,7 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
49 57
50/* 58/*
51 * First 1MB map is used by fixed purpose. 59 * First 1MB map is used by fixed purpose.
52 * Currently only 4-enty (16kB) is used (see arch/sh/mm/cache.c) 60 * Currently only 4-entry (16kB) is used (see arch/sh/mm/cache.c)
53 */ 61 */
54#define VMALLOC_START (P3SEG+0x00100000) 62#define VMALLOC_START (P3SEG+0x00100000)
55#define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE) 63#define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
@@ -57,7 +65,8 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
57/* 65/*
58 * Linux PTEL encoding. 66 * Linux PTEL encoding.
59 * 67 *
60 * Hardware and software bit definitions for the PTEL value: 68 * Hardware and software bit definitions for the PTEL value (see below for
69 * notes on SH-X2 MMUs and 64-bit PTEs):
61 * 70 *
62 * - Bits 0 and 7 are reserved on SH-3 (_PAGE_WT and _PAGE_SZ1 on SH-4). 71 * - Bits 0 and 7 are reserved on SH-3 (_PAGE_WT and _PAGE_SZ1 on SH-4).
63 * 72 *
@@ -76,20 +85,57 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
76 * 85 *
77 * - Bits 31, 30, and 29 remain unused by everyone and can be used for future 86 * - Bits 31, 30, and 29 remain unused by everyone and can be used for future
78 * software flags, although care must be taken to update _PAGE_CLEAR_FLAGS. 87 * software flags, although care must be taken to update _PAGE_CLEAR_FLAGS.
88 *
89 * XXX: Leave the _PAGE_FILE and _PAGE_WT overhaul for a rainy day.
90 *
91 * SH-X2 MMUs and extended PTEs
92 *
93 * SH-X2 supports an extended mode TLB with split data arrays due to the
94 * number of bits needed for PR and SZ (now EPR and ESZ) encodings. The PR and
95 * SZ bit placeholders still exist in data array 1, but are implemented as
96 * reserved bits, with the real logic existing in data array 2.
97 *
98 * The downside to this is that we can no longer fit everything in to a 32-bit
99 * PTE encoding, so a 64-bit pte_t is necessary for these parts. On the plus
100 * side, this gives us quite a few spare bits to play with for future usage.
79 */ 101 */
102/* Legacy and compat mode bits */
80#define _PAGE_WT 0x001 /* WT-bit on SH-4, 0 on SH-3 */ 103#define _PAGE_WT 0x001 /* WT-bit on SH-4, 0 on SH-3 */
81#define _PAGE_HW_SHARED 0x002 /* SH-bit : shared among processes */ 104#define _PAGE_HW_SHARED 0x002 /* SH-bit : shared among processes */
82#define _PAGE_DIRTY 0x004 /* D-bit : page changed */ 105#define _PAGE_DIRTY 0x004 /* D-bit : page changed */
83#define _PAGE_CACHABLE 0x008 /* C-bit : cachable */ 106#define _PAGE_CACHABLE 0x008 /* C-bit : cachable */
84#define _PAGE_SZ0 0x010 /* SZ0-bit : Size of page */ 107#ifndef CONFIG_X2TLB
85#define _PAGE_RW 0x020 /* PR0-bit : write access allowed */ 108# define _PAGE_SZ0 0x010 /* SZ0-bit : Size of page */
86#define _PAGE_USER 0x040 /* PR1-bit : user space access allowed */ 109# define _PAGE_RW 0x020 /* PR0-bit : write access allowed */
87#define _PAGE_SZ1 0x080 /* SZ1-bit : Size of page (on SH-4) */ 110# define _PAGE_USER 0x040 /* PR1-bit : user space access allowed*/
111# define _PAGE_SZ1 0x080 /* SZ1-bit : Size of page (on SH-4) */
112#endif
88#define _PAGE_PRESENT 0x100 /* V-bit : page is valid */ 113#define _PAGE_PRESENT 0x100 /* V-bit : page is valid */
89#define _PAGE_PROTNONE 0x200 /* software: if not present */ 114#define _PAGE_PROTNONE 0x200 /* software: if not present */
90#define _PAGE_ACCESSED 0x400 /* software: page referenced */ 115#define _PAGE_ACCESSED 0x400 /* software: page referenced */
91#define _PAGE_FILE _PAGE_WT /* software: pagecache or swap? */ 116#define _PAGE_FILE _PAGE_WT /* software: pagecache or swap? */
92 117
118/* Extended mode bits */
119#define _PAGE_EXT_ESZ0 0x0010 /* ESZ0-bit: Size of page */
120#define _PAGE_EXT_ESZ1 0x0020 /* ESZ1-bit: Size of page */
121#define _PAGE_EXT_ESZ2 0x0040 /* ESZ2-bit: Size of page */
122#define _PAGE_EXT_ESZ3 0x0080 /* ESZ3-bit: Size of page */
123
124#define _PAGE_EXT_USER_EXEC 0x0100 /* EPR0-bit: User space executable */
125#define _PAGE_EXT_USER_WRITE 0x0200 /* EPR1-bit: User space writable */
126#define _PAGE_EXT_USER_READ 0x0400 /* EPR2-bit: User space readable */
127
128#define _PAGE_EXT_KERN_EXEC 0x0800 /* EPR3-bit: Kernel space executable */
129#define _PAGE_EXT_KERN_WRITE 0x1000 /* EPR4-bit: Kernel space writable */
130#define _PAGE_EXT_KERN_READ 0x2000 /* EPR5-bit: Kernel space readable */
131
132/* Wrapper for extended mode pgprot twiddling */
133#ifdef CONFIG_X2TLB
134# define _PAGE_EXT(x) ((unsigned long long)(x) << 32)
135#else
136# define _PAGE_EXT(x) (0)
137#endif
138
93/* software: moves to PTEA.TC (Timing Control) */ 139/* software: moves to PTEA.TC (Timing Control) */
94#define _PAGE_PCC_AREA5 0x00000000 /* use BSC registers for area5 */ 140#define _PAGE_PCC_AREA5 0x00000000 /* use BSC registers for area5 */
95#define _PAGE_PCC_AREA6 0x80000000 /* use BSC registers for area6 */ 141#define _PAGE_PCC_AREA6 0x80000000 /* use BSC registers for area6 */
@@ -114,37 +160,160 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
114 160
115#define _PAGE_FLAGS_HARDWARE_MASK (0x1fffffff & ~(_PAGE_CLEAR_FLAGS)) 161#define _PAGE_FLAGS_HARDWARE_MASK (0x1fffffff & ~(_PAGE_CLEAR_FLAGS))
116 162
117/* Hardware flags: SZ0=1 (4k-byte) */ 163/* Hardware flags, page size encoding */
118#define _PAGE_FLAGS_HARD _PAGE_SZ0 164#if defined(CONFIG_X2TLB)
165# if defined(CONFIG_PAGE_SIZE_4KB)
166# define _PAGE_FLAGS_HARD _PAGE_EXT(_PAGE_EXT_ESZ0)
167# elif defined(CONFIG_PAGE_SIZE_8KB)
168# define _PAGE_FLAGS_HARD _PAGE_EXT(_PAGE_EXT_ESZ1)
169# elif defined(CONFIG_PAGE_SIZE_64KB)
170# define _PAGE_FLAGS_HARD _PAGE_EXT(_PAGE_EXT_ESZ2)
171# endif
172#else
173# if defined(CONFIG_PAGE_SIZE_4KB)
174# define _PAGE_FLAGS_HARD _PAGE_SZ0
175# elif defined(CONFIG_PAGE_SIZE_64KB)
176# define _PAGE_FLAGS_HARD _PAGE_SZ1
177# endif
178#endif
119 179
120#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K) 180#if defined(CONFIG_X2TLB)
121#define _PAGE_SZHUGE (_PAGE_SZ1) 181# if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
122#elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB) 182# define _PAGE_SZHUGE (_PAGE_EXT_ESZ2)
123#define _PAGE_SZHUGE (_PAGE_SZ0 | _PAGE_SZ1) 183# elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K)
184# define _PAGE_SZHUGE (_PAGE_EXT_ESZ0 | _PAGE_EXT_ESZ2)
185# elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
186# define _PAGE_SZHUGE (_PAGE_EXT_ESZ0 | _PAGE_EXT_ESZ1 | _PAGE_EXT_ESZ2)
187# elif defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
188# define _PAGE_SZHUGE (_PAGE_EXT_ESZ3)
189# elif defined(CONFIG_HUGETLB_PAGE_SIZE_64MB)
190# define _PAGE_SZHUGE (_PAGE_EXT_ESZ2 | _PAGE_EXT_ESZ3)
191# endif
192#else
193# if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
194# define _PAGE_SZHUGE (_PAGE_SZ1)
195# elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
196# define _PAGE_SZHUGE (_PAGE_SZ0 | _PAGE_SZ1)
197# endif
198#endif
199
200/*
201 * Stub out _PAGE_SZHUGE if we don't have a good definition for it,
202 * to make pte_mkhuge() happy.
203 */
204#ifndef _PAGE_SZHUGE
205# define _PAGE_SZHUGE (_PAGE_FLAGS_HARD)
124#endif 206#endif
125 207
126#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY) 208#define _PAGE_CHG_MASK \
127#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) 209 (PTE_MASK | _PAGE_ACCESSED | _PAGE_CACHABLE | _PAGE_DIRTY)
128#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_CACHABLE | _PAGE_DIRTY)
129 210
130#ifndef __ASSEMBLY__ 211#ifndef __ASSEMBLY__
131 212
132#ifdef CONFIG_MMU 213#if defined(CONFIG_X2TLB) /* SH-X2 TLB */
133#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_CACHABLE |_PAGE_ACCESSED | _PAGE_FLAGS_HARD) 214#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_CACHABLE | \
134#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_CACHABLE |_PAGE_ACCESSED | _PAGE_FLAGS_HARD) 215 _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
135#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | _PAGE_ACCESSED | _PAGE_FLAGS_HARD) 216
136#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | _PAGE_ACCESSED | _PAGE_FLAGS_HARD) 217#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
137#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_CACHABLE | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_HW_SHARED | _PAGE_FLAGS_HARD) 218 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
219 _PAGE_EXT(_PAGE_EXT_USER_READ | \
220 _PAGE_EXT_USER_WRITE))
221
222#define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
223 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
224 _PAGE_EXT(_PAGE_EXT_USER_EXEC | \
225 _PAGE_EXT_USER_READ))
226
227#define PAGE_COPY PAGE_EXECREAD
228
229#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
230 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
231 _PAGE_EXT(_PAGE_EXT_USER_READ))
232
233#define PAGE_WRITEONLY __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
234 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
235 _PAGE_EXT(_PAGE_EXT_USER_WRITE))
236
237#define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
238 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
239 _PAGE_EXT(_PAGE_EXT_USER_WRITE | \
240 _PAGE_EXT_USER_READ | \
241 _PAGE_EXT_USER_EXEC))
242
243#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_CACHABLE | \
244 _PAGE_DIRTY | _PAGE_ACCESSED | \
245 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD | \
246 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
247 _PAGE_EXT_KERN_WRITE | \
248 _PAGE_EXT_KERN_EXEC))
249
138#define PAGE_KERNEL_NOCACHE \ 250#define PAGE_KERNEL_NOCACHE \
139 __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_HW_SHARED | _PAGE_FLAGS_HARD) 251 __pgprot(_PAGE_PRESENT | _PAGE_DIRTY | \
140#define PAGE_KERNEL_RO __pgprot(_PAGE_PRESENT | _PAGE_CACHABLE | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_HW_SHARED | _PAGE_FLAGS_HARD) 252 _PAGE_ACCESSED | _PAGE_HW_SHARED | \
253 _PAGE_FLAGS_HARD | \
254 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
255 _PAGE_EXT_KERN_WRITE | \
256 _PAGE_EXT_KERN_EXEC))
257
258#define PAGE_KERNEL_RO __pgprot(_PAGE_PRESENT | _PAGE_CACHABLE | \
259 _PAGE_DIRTY | _PAGE_ACCESSED | \
260 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD | \
261 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
262 _PAGE_EXT_KERN_EXEC))
263
264#define PAGE_KERNEL_PCC(slot, type) \
265 __pgprot(_PAGE_PRESENT | _PAGE_DIRTY | \
266 _PAGE_ACCESSED | _PAGE_FLAGS_HARD | \
267 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
268 _PAGE_EXT_KERN_WRITE | \
269 _PAGE_EXT_KERN_EXEC) \
270 (slot ? _PAGE_PCC_AREA5 : _PAGE_PCC_AREA6) | \
271 (type))
272
273#elif defined(CONFIG_MMU) /* SH-X TLB */
274#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_CACHABLE | \
275 _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
276
277#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \
278 _PAGE_CACHABLE | _PAGE_ACCESSED | \
279 _PAGE_FLAGS_HARD)
280
281#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | \
282 _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
283
284#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | \
285 _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
286
287#define PAGE_EXECREAD PAGE_READONLY
288#define PAGE_RWX PAGE_SHARED
289#define PAGE_WRITEONLY PAGE_SHARED
290
291#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_CACHABLE | \
292 _PAGE_DIRTY | _PAGE_ACCESSED | \
293 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD)
294
295#define PAGE_KERNEL_NOCACHE \
296 __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | \
297 _PAGE_ACCESSED | _PAGE_HW_SHARED | \
298 _PAGE_FLAGS_HARD)
299
300#define PAGE_KERNEL_RO __pgprot(_PAGE_PRESENT | _PAGE_CACHABLE | \
301 _PAGE_DIRTY | _PAGE_ACCESSED | \
302 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD)
303
141#define PAGE_KERNEL_PCC(slot, type) \ 304#define PAGE_KERNEL_PCC(slot, type) \
142 __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_FLAGS_HARD | (slot ? _PAGE_PCC_AREA5 : _PAGE_PCC_AREA6) | (type)) 305 __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | \
306 _PAGE_ACCESSED | _PAGE_FLAGS_HARD | \
307 (slot ? _PAGE_PCC_AREA5 : _PAGE_PCC_AREA6) | \
308 (type))
143#else /* no mmu */ 309#else /* no mmu */
144#define PAGE_NONE __pgprot(0) 310#define PAGE_NONE __pgprot(0)
145#define PAGE_SHARED __pgprot(0) 311#define PAGE_SHARED __pgprot(0)
146#define PAGE_COPY __pgprot(0) 312#define PAGE_COPY __pgprot(0)
313#define PAGE_EXECREAD __pgprot(0)
314#define PAGE_RWX __pgprot(0)
147#define PAGE_READONLY __pgprot(0) 315#define PAGE_READONLY __pgprot(0)
316#define PAGE_WRITEONLY __pgprot(0)
148#define PAGE_KERNEL __pgprot(0) 317#define PAGE_KERNEL __pgprot(0)
149#define PAGE_KERNEL_NOCACHE __pgprot(0) 318#define PAGE_KERNEL_NOCACHE __pgprot(0)
150#define PAGE_KERNEL_RO __pgprot(0) 319#define PAGE_KERNEL_RO __pgprot(0)
@@ -154,27 +323,32 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
154#endif /* __ASSEMBLY__ */ 323#endif /* __ASSEMBLY__ */
155 324
156/* 325/*
157 * As i386 and MIPS, SuperH can't do page protection for execute, and 326 * SH-X and lower (legacy) SuperH parts (SH-3, SH-4, some SH-4A) can't do page
158 * considers that the same as a read. Also, write permissions imply 327 * protection for execute, and considers it the same as a read. Also, write
159 * read permissions. This is the closest we can get.. 328 * permission implies read permission. This is the closest we can get..
329 *
330 * SH-X2 (SH7785) and later parts take this to the opposite end of the extreme,
331 * not only supporting separate execute, read, and write bits, but having
332 * completely separate permission bits for user and kernel space.
160 */ 333 */
334 /*xwr*/
161#define __P000 PAGE_NONE 335#define __P000 PAGE_NONE
162#define __P001 PAGE_READONLY 336#define __P001 PAGE_READONLY
163#define __P010 PAGE_COPY 337#define __P010 PAGE_COPY
164#define __P011 PAGE_COPY 338#define __P011 PAGE_COPY
165#define __P100 PAGE_READONLY 339#define __P100 PAGE_EXECREAD
166#define __P101 PAGE_READONLY 340#define __P101 PAGE_EXECREAD
167#define __P110 PAGE_COPY 341#define __P110 PAGE_COPY
168#define __P111 PAGE_COPY 342#define __P111 PAGE_COPY
169 343
170#define __S000 PAGE_NONE 344#define __S000 PAGE_NONE
171#define __S001 PAGE_READONLY 345#define __S001 PAGE_READONLY
172#define __S010 PAGE_SHARED 346#define __S010 PAGE_WRITEONLY
173#define __S011 PAGE_SHARED 347#define __S011 PAGE_SHARED
174#define __S100 PAGE_READONLY 348#define __S100 PAGE_EXECREAD
175#define __S101 PAGE_READONLY 349#define __S101 PAGE_EXECREAD
176#define __S110 PAGE_SHARED 350#define __S110 PAGE_RWX
177#define __S111 PAGE_SHARED 351#define __S111 PAGE_RWX
178 352
179#ifndef __ASSEMBLY__ 353#ifndef __ASSEMBLY__
180 354
@@ -183,7 +357,17 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
183 * within a page table are directly modified. Thus, the following 357 * within a page table are directly modified. Thus, the following
184 * hook is made available. 358 * hook is made available.
185 */ 359 */
360#ifdef CONFIG_X2TLB
361static inline void set_pte(pte_t *ptep, pte_t pte)
362{
363 ptep->pte_high = pte.pte_high;
364 smp_wmb();
365 ptep->pte_low = pte.pte_low;
366}
367#else
186#define set_pte(pteptr, pteval) (*(pteptr) = pteval) 368#define set_pte(pteptr, pteval) (*(pteptr) = pteval)
369#endif
370
187#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) 371#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
188 372
189/* 373/*
@@ -192,18 +376,18 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
192 */ 376 */
193#define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval) 377#define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
194 378
195#define pte_pfn(x) ((unsigned long)(((x).pte >> PAGE_SHIFT))) 379#define pte_pfn(x) ((unsigned long)(((x).pte_low >> PAGE_SHIFT)))
196#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) 380#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
197#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) 381#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
198 382
199#define pte_none(x) (!pte_val(x)) 383#define pte_none(x) (!pte_val(x))
200#define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE)) 384#define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE))
201#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0) 385#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
202 386
203#define pmd_none(x) (!pmd_val(x)) 387#define pmd_none(x) (!pmd_val(x))
204#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT) 388#define pmd_present(x) (pmd_val(x))
205#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0) 389#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0)
206#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE) 390#define pmd_bad(x) (pmd_val(x) & ~PAGE_MASK)
207 391
208#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) 392#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
209#define pte_page(x) phys_to_page(pte_val(x)&PTE_PHYS_MASK) 393#define pte_page(x) phys_to_page(pte_val(x)&PTE_PHYS_MASK)
@@ -212,28 +396,52 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
212 * The following only work if pte_present() is true. 396 * The following only work if pte_present() is true.
213 * Undefined behaviour if not.. 397 * Undefined behaviour if not..
214 */ 398 */
215static inline int pte_read(pte_t pte) { return pte_val(pte) & _PAGE_USER; } 399#define pte_not_present(pte) (!(pte_val(pte) & _PAGE_PRESENT))
216static inline int pte_exec(pte_t pte) { return pte_val(pte) & _PAGE_USER; } 400#define pte_dirty(pte) (pte_val(pte) & _PAGE_DIRTY)
217static inline int pte_dirty(pte_t pte){ return pte_val(pte) & _PAGE_DIRTY; } 401#define pte_young(pte) (pte_val(pte) & _PAGE_ACCESSED)
218static inline int pte_young(pte_t pte){ return pte_val(pte) & _PAGE_ACCESSED; } 402#define pte_file(pte) (pte_val(pte) & _PAGE_FILE)
219static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } 403
220static inline int pte_write(pte_t pte){ return pte_val(pte) & _PAGE_RW; } 404#ifdef CONFIG_X2TLB
221static inline int pte_not_present(pte_t pte){ return !(pte_val(pte) & _PAGE_PRESENT); } 405#define pte_read(pte) ((pte).pte_high & _PAGE_EXT_USER_READ)
222 406#define pte_exec(pte) ((pte).pte_high & _PAGE_EXT_USER_EXEC)
223static inline pte_t pte_rdprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_USER)); return pte; } 407#define pte_write(pte) ((pte).pte_high & _PAGE_EXT_USER_WRITE)
224static inline pte_t pte_exprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_USER)); return pte; } 408#else
225static inline pte_t pte_mkclean(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_DIRTY)); return pte; } 409#define pte_read(pte) (pte_val(pte) & _PAGE_USER)
226static inline pte_t pte_mkold(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_ACCESSED)); return pte; } 410#define pte_exec(pte) (pte_val(pte) & _PAGE_USER)
227static inline pte_t pte_wrprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_RW)); return pte; } 411#define pte_write(pte) (pte_val(pte) & _PAGE_RW)
228static inline pte_t pte_mkread(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_USER)); return pte; }
229static inline pte_t pte_mkexec(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_USER)); return pte; }
230static inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; }
231static inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; }
232static inline pte_t pte_mkwrite(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_RW)); return pte; }
233#ifdef CONFIG_HUGETLB_PAGE
234static inline pte_t pte_mkhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_SZHUGE)); return pte; }
235#endif 412#endif
236 413
414#define PTE_BIT_FUNC(h,fn,op) \
415static inline pte_t pte_##fn(pte_t pte) { pte.pte_##h op; return pte; }
416
417#ifdef CONFIG_X2TLB
418/*
419 * We cheat a bit in the SH-X2 TLB case. As the permission bits are
420 * individually toggled (and user permissions are entirely decoupled from
421 * kernel permissions), we attempt to couple them a bit more sanely here.
422 */
423PTE_BIT_FUNC(high, rdprotect, &= ~_PAGE_EXT_USER_READ);
424PTE_BIT_FUNC(high, mkread, |= _PAGE_EXT_USER_READ | _PAGE_EXT_KERN_READ);
425PTE_BIT_FUNC(high, wrprotect, &= ~_PAGE_EXT_USER_WRITE);
426PTE_BIT_FUNC(high, mkwrite, |= _PAGE_EXT_USER_WRITE | _PAGE_EXT_KERN_WRITE);
427PTE_BIT_FUNC(high, exprotect, &= ~_PAGE_EXT_USER_EXEC);
428PTE_BIT_FUNC(high, mkexec, |= _PAGE_EXT_USER_EXEC | _PAGE_EXT_KERN_EXEC);
429PTE_BIT_FUNC(high, mkhuge, |= _PAGE_SZHUGE);
430#else
431PTE_BIT_FUNC(low, rdprotect, &= ~_PAGE_USER);
432PTE_BIT_FUNC(low, mkread, |= _PAGE_USER);
433PTE_BIT_FUNC(low, wrprotect, &= ~_PAGE_RW);
434PTE_BIT_FUNC(low, mkwrite, |= _PAGE_RW);
435PTE_BIT_FUNC(low, exprotect, &= ~_PAGE_USER);
436PTE_BIT_FUNC(low, mkexec, |= _PAGE_USER);
437PTE_BIT_FUNC(low, mkhuge, |= _PAGE_SZHUGE);
438#endif
439
440PTE_BIT_FUNC(low, mkclean, &= ~_PAGE_DIRTY);
441PTE_BIT_FUNC(low, mkdirty, |= _PAGE_DIRTY);
442PTE_BIT_FUNC(low, mkold, &= ~_PAGE_ACCESSED);
443PTE_BIT_FUNC(low, mkyoung, |= _PAGE_ACCESSED);
444
237/* 445/*
238 * Macro and implementation to make a page protection as uncachable. 446 * Macro and implementation to make a page protection as uncachable.
239 */ 447 */
@@ -258,13 +466,14 @@ static inline pgprot_t pgprot_noncached(pgprot_t _prot)
258#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) 466#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
259 467
260static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 468static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
261{ set_pte(&pte, __pte((pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot))); return pte; } 469{
262 470 set_pte(&pte, __pte((pte_val(pte) & _PAGE_CHG_MASK) |
263#define pmd_page_vaddr(pmd) \ 471 pgprot_val(newprot)));
264((unsigned long) __va(pmd_val(pmd) & PAGE_MASK)) 472 return pte;
473}
265 474
266#define pmd_page(pmd) \ 475#define pmd_page_vaddr(pmd) pmd_val(pmd)
267 (phys_to_page(pmd_val(pmd))) 476#define pmd_page(pmd) (virt_to_page(pmd_val(pmd)))
268 477
269/* to find an entry in a page-table-directory. */ 478/* to find an entry in a page-table-directory. */
270#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) 479#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
@@ -283,8 +492,15 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
283#define pte_unmap(pte) do { } while (0) 492#define pte_unmap(pte) do { } while (0)
284#define pte_unmap_nested(pte) do { } while (0) 493#define pte_unmap_nested(pte) do { } while (0)
285 494
495#ifdef CONFIG_X2TLB
496#define pte_ERROR(e) \
497 printk("%s:%d: bad pte %p(%08lx%08lx).\n", __FILE__, __LINE__, \
498 &(e), (e).pte_high, (e).pte_low)
499#else
286#define pte_ERROR(e) \ 500#define pte_ERROR(e) \
287 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e)) 501 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
502#endif
503
288#define pgd_ERROR(e) \ 504#define pgd_ERROR(e) \
289 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e)) 505 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
290 506
@@ -337,6 +553,9 @@ extern unsigned int kobjsize(const void *objp);
337extern pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep); 553extern pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
338#endif 554#endif
339 555
556extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
557extern void paging_init(void);
558
340#include <asm-generic/pgtable.h> 559#include <asm-generic/pgtable.h>
341 560
342#endif /* !__ASSEMBLY__ */ 561#endif /* !__ASSEMBLY__ */
diff --git a/include/asm-sh/processor.h b/include/asm-sh/processor.h
index 45bb74e35d32..6f1dd7ca1b1d 100644
--- a/include/asm-sh/processor.h
+++ b/include/asm-sh/processor.h
@@ -36,7 +36,10 @@
36 */ 36 */
37enum cpu_type { 37enum cpu_type {
38 /* SH-2 types */ 38 /* SH-2 types */
39 CPU_SH7604, 39 CPU_SH7604, CPU_SH7619,
40
41 /* SH-2A types */
42 CPU_SH7206,
40 43
41 /* SH-3 types */ 44 /* SH-3 types */
42 CPU_SH7705, CPU_SH7706, CPU_SH7707, 45 CPU_SH7705, CPU_SH7706, CPU_SH7707,
@@ -47,7 +50,10 @@ enum cpu_type {
47 /* SH-4 types */ 50 /* SH-4 types */
48 CPU_SH7750, CPU_SH7750S, CPU_SH7750R, CPU_SH7751, CPU_SH7751R, 51 CPU_SH7750, CPU_SH7750S, CPU_SH7750R, CPU_SH7751, CPU_SH7751R,
49 CPU_SH7760, CPU_ST40RA, CPU_ST40GX1, CPU_SH4_202, CPU_SH4_501, 52 CPU_SH7760, CPU_ST40RA, CPU_ST40GX1, CPU_SH4_202, CPU_SH4_501,
53
54 /* SH-4A types */
50 CPU_SH73180, CPU_SH7343, CPU_SH7770, CPU_SH7780, CPU_SH7781, 55 CPU_SH73180, CPU_SH7343, CPU_SH7770, CPU_SH7780, CPU_SH7781,
56 CPU_SH7785,
51 57
52 /* Unknown subtype */ 58 /* Unknown subtype */
53 CPU_SH_NONE 59 CPU_SH_NONE
@@ -130,12 +136,11 @@ union sh_fpu_union {
130}; 136};
131 137
132struct thread_struct { 138struct thread_struct {
139 /* Saved registers when thread is descheduled */
133 unsigned long sp; 140 unsigned long sp;
134 unsigned long pc; 141 unsigned long pc;
135 142
136 unsigned long trap_no, error_code; 143 /* Hardware debugging registers */
137 unsigned long address;
138 /* Hardware debugging registers may come here */
139 unsigned long ubc_pc; 144 unsigned long ubc_pc;
140 145
141 /* floating point info */ 146 /* floating point info */
@@ -150,12 +155,7 @@ typedef struct {
150extern int ubc_usercnt; 155extern int ubc_usercnt;
151 156
152#define INIT_THREAD { \ 157#define INIT_THREAD { \
153 sizeof(init_stack) + (long) &init_stack, /* sp */ \ 158 .sp = sizeof(init_stack) + (long) &init_stack, \
154 0, /* pc */ \
155 0, 0, \
156 0, \
157 0, \
158 {{{0,}},} /* fpu state */ \
159} 159}
160 160
161/* 161/*
@@ -259,8 +259,8 @@ void show_trace(struct task_struct *tsk, unsigned long *sp,
259 struct pt_regs *regs); 259 struct pt_regs *regs);
260extern unsigned long get_wchan(struct task_struct *p); 260extern unsigned long get_wchan(struct task_struct *p);
261 261
262#define KSTK_EIP(tsk) ((tsk)->thread.pc) 262#define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)
263#define KSTK_ESP(tsk) ((tsk)->thread.sp) 263#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[15])
264 264
265#define cpu_sleep() __asm__ __volatile__ ("sleep" : : : "memory") 265#define cpu_sleep() __asm__ __volatile__ ("sleep" : : : "memory")
266#define cpu_relax() barrier() 266#define cpu_relax() barrier()
diff --git a/include/asm-sh/push-switch.h b/include/asm-sh/push-switch.h
new file mode 100644
index 000000000000..dfc6bad567f0
--- /dev/null
+++ b/include/asm-sh/push-switch.h
@@ -0,0 +1,28 @@
1#ifndef __ASM_SH_PUSH_SWITCH_H
2#define __ASM_SH_PUSH_SWITCH_H
3
4#include <linux/timer.h>
5#include <linux/interrupt.h>
6#include <linux/workqueue.h>
7
8struct push_switch {
9 /* switch state */
10 unsigned int state:1;
11 /* debounce timer */
12 struct timer_list debounce;
13 /* workqueue */
14 struct work_struct work;
15};
16
17struct push_switch_platform_info {
18 /* IRQ handler */
19 irqreturn_t (*irq_handler)(int irq, void *data);
20 /* Special IRQ flags */
21 unsigned int irq_flags;
22 /* Bit location of switch */
23 unsigned int bit;
24 /* Symbolic switch name */
25 const char *name;
26};
27
28#endif /* __ASM_SH_PUSH_SWITCH_H */
diff --git a/include/asm-sh/rwsem.h b/include/asm-sh/rwsem.h
index 9d2aea5e8488..4931ba817d73 100644
--- a/include/asm-sh/rwsem.h
+++ b/include/asm-sh/rwsem.h
@@ -25,11 +25,21 @@ struct rw_semaphore {
25#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) 25#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
26 spinlock_t wait_lock; 26 spinlock_t wait_lock;
27 struct list_head wait_list; 27 struct list_head wait_list;
28#ifdef CONFIG_DEBUG_LOCK_ALLOC
29 struct lockdep_map dep_map;
30#endif
28}; 31};
29 32
33#ifdef CONFIG_DEBUG_LOCK_ALLOC
34# define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname }
35#else
36# define __RWSEM_DEP_MAP_INIT(lockname)
37#endif
38
30#define __RWSEM_INITIALIZER(name) \ 39#define __RWSEM_INITIALIZER(name) \
31 { RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, \ 40 { RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, \
32 LIST_HEAD_INIT((name).wait_list) } 41 LIST_HEAD_INIT((name).wait_list) \
42 __RWSEM_DEP_MAP_INIT(name) }
33 43
34#define DECLARE_RWSEM(name) \ 44#define DECLARE_RWSEM(name) \
35 struct rw_semaphore name = __RWSEM_INITIALIZER(name) 45 struct rw_semaphore name = __RWSEM_INITIALIZER(name)
@@ -39,6 +49,16 @@ extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem);
39extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); 49extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem);
40extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); 50extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
41 51
52extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
53 struct lock_class_key *key);
54
55#define init_rwsem(sem) \
56do { \
57 static struct lock_class_key __key; \
58 \
59 __init_rwsem((sem), #sem, &__key); \
60} while (0)
61
42static inline void init_rwsem(struct rw_semaphore *sem) 62static inline void init_rwsem(struct rw_semaphore *sem)
43{ 63{
44 sem->count = RWSEM_UNLOCKED_VALUE; 64 sem->count = RWSEM_UNLOCKED_VALUE;
@@ -141,6 +161,11 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
141 rwsem_downgrade_wake(sem); 161 rwsem_downgrade_wake(sem);
142} 162}
143 163
164static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
165{
166 __down_write(sem);
167}
168
144/* 169/*
145 * implement exchange and add functionality 170 * implement exchange and add functionality
146 */ 171 */
diff --git a/include/asm-sh/se7206.h b/include/asm-sh/se7206.h
new file mode 100644
index 000000000000..698eb80389ab
--- /dev/null
+++ b/include/asm-sh/se7206.h
@@ -0,0 +1,13 @@
1#ifndef __ASM_SH_SE7206_H
2#define __ASM_SH_SE7206_H
3
4#define PA_SMSC 0x30000000
5#define PA_MRSHPC 0x34000000
6#define PA_LED 0x31400000
7
8void init_se7206_IRQ(void);
9
10#define __IO_PREFIX se7206
11#include <asm/io_generic.h>
12
13#endif /* __ASM_SH_SE7206_H */
diff --git a/include/asm-sh/setup.h b/include/asm-sh/setup.h
index 34ca8a7f06ba..1583c6b7bdaa 100644
--- a/include/asm-sh/setup.h
+++ b/include/asm-sh/setup.h
@@ -1,10 +1,12 @@
1#ifdef __KERNEL__
2#ifndef _SH_SETUP_H 1#ifndef _SH_SETUP_H
3#define _SH_SETUP_H 2#define _SH_SETUP_H
4 3
5#define COMMAND_LINE_SIZE 256 4#define COMMAND_LINE_SIZE 256
6 5
6#ifdef __KERNEL__
7
7int setup_early_printk(char *); 8int setup_early_printk(char *);
8 9
9#endif /* _SH_SETUP_H */
10#endif /* __KERNEL__ */ 10#endif /* __KERNEL__ */
11
12#endif /* _SH_SETUP_H */
diff --git a/include/asm-sh/system.h b/include/asm-sh/system.h
index 3340126f4e0f..b1e42e7f998b 100644
--- a/include/asm-sh/system.h
+++ b/include/asm-sh/system.h
@@ -6,6 +6,7 @@
6 * Copyright (C) 2002 Paul Mundt 6 * Copyright (C) 2002 Paul Mundt
7 */ 7 */
8 8
9#include <linux/irqflags.h>
9#include <asm/types.h> 10#include <asm/types.h>
10 11
11/* 12/*
@@ -131,103 +132,6 @@ static inline unsigned long tas(volatile int *m)
131 132
132#define set_mb(var, value) do { xchg(&var, value); } while (0) 133#define set_mb(var, value) do { xchg(&var, value); } while (0)
133 134
134/* Interrupt Control */
135#ifdef CONFIG_CPU_HAS_SR_RB
136static inline void local_irq_enable(void)
137{
138 unsigned long __dummy0, __dummy1;
139
140 __asm__ __volatile__("stc sr, %0\n\t"
141 "and %1, %0\n\t"
142 "stc r6_bank, %1\n\t"
143 "or %1, %0\n\t"
144 "ldc %0, sr"
145 : "=&r" (__dummy0), "=r" (__dummy1)
146 : "1" (~0x000000f0)
147 : "memory");
148}
149#else
150static inline void local_irq_enable(void)
151{
152 unsigned long __dummy0, __dummy1;
153
154 __asm__ __volatile__ (
155 "stc sr, %0\n\t"
156 "and %1, %0\n\t"
157 "ldc %0, sr\n\t"
158 : "=&r" (__dummy0), "=r" (__dummy1)
159 : "1" (~0x000000f0)
160 : "memory");
161}
162#endif
163
164static inline void local_irq_disable(void)
165{
166 unsigned long __dummy;
167 __asm__ __volatile__("stc sr, %0\n\t"
168 "or #0xf0, %0\n\t"
169 "ldc %0, sr"
170 : "=&z" (__dummy)
171 : /* no inputs */
172 : "memory");
173}
174
175static inline void set_bl_bit(void)
176{
177 unsigned long __dummy0, __dummy1;
178
179 __asm__ __volatile__ ("stc sr, %0\n\t"
180 "or %2, %0\n\t"
181 "and %3, %0\n\t"
182 "ldc %0, sr"
183 : "=&r" (__dummy0), "=r" (__dummy1)
184 : "r" (0x10000000), "r" (0xffffff0f)
185 : "memory");
186}
187
188static inline void clear_bl_bit(void)
189{
190 unsigned long __dummy0, __dummy1;
191
192 __asm__ __volatile__ ("stc sr, %0\n\t"
193 "and %2, %0\n\t"
194 "ldc %0, sr"
195 : "=&r" (__dummy0), "=r" (__dummy1)
196 : "1" (~0x10000000)
197 : "memory");
198}
199
200#define local_save_flags(x) \
201 __asm__("stc sr, %0; and #0xf0, %0" : "=&z" (x) :/**/: "memory" )
202
203#define irqs_disabled() \
204({ \
205 unsigned long flags; \
206 local_save_flags(flags); \
207 (flags != 0); \
208})
209
210static inline unsigned long local_irq_save(void)
211{
212 unsigned long flags, __dummy;
213
214 __asm__ __volatile__("stc sr, %1\n\t"
215 "mov %1, %0\n\t"
216 "or #0xf0, %0\n\t"
217 "ldc %0, sr\n\t"
218 "mov %1, %0\n\t"
219 "and #0xf0, %0"
220 : "=&z" (flags), "=&r" (__dummy)
221 :/**/
222 : "memory" );
223 return flags;
224}
225
226#define local_irq_restore(x) do { \
227 if ((x & 0x000000f0) != 0x000000f0) \
228 local_irq_enable(); \
229} while (0)
230
231/* 135/*
232 * Jump to P2 area. 136 * Jump to P2 area.
233 * When handling TLB or caches, we need to do it from P2 area. 137 * When handling TLB or caches, we need to do it from P2 area.
@@ -264,9 +168,6 @@ do { \
264 : "=&r" (__dummy)); \ 168 : "=&r" (__dummy)); \
265} while (0) 169} while (0)
266 170
267/* For spinlocks etc */
268#define local_irq_save(x) x = local_irq_save()
269
270static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val) 171static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val)
271{ 172{
272 unsigned long flags, retval; 173 unsigned long flags, retval;
diff --git a/include/asm-sh/thread_info.h b/include/asm-sh/thread_info.h
index 3ebc3f9039eb..0c01dc550819 100644
--- a/include/asm-sh/thread_info.h
+++ b/include/asm-sh/thread_info.h
@@ -90,13 +90,7 @@ static inline struct thread_info *current_thread_info(void)
90#endif 90#endif
91#define free_thread_info(ti) kfree(ti) 91#define free_thread_info(ti) kfree(ti)
92 92
93#else /* !__ASSEMBLY__ */ 93#endif /* __ASSEMBLY__ */
94
95/* how to get the thread information struct from ASM */
96#define GET_THREAD_INFO(reg) \
97 stc r7_bank, reg
98
99#endif
100 94
101/* 95/*
102 * thread information flags 96 * thread information flags
diff --git a/include/asm-sh/timer.h b/include/asm-sh/timer.h
index 5df842bcf7b6..17b5e76a4c31 100644
--- a/include/asm-sh/timer.h
+++ b/include/asm-sh/timer.h
@@ -18,11 +18,32 @@ struct sys_timer {
18 18
19 struct sys_device dev; 19 struct sys_device dev;
20 struct sys_timer_ops *ops; 20 struct sys_timer_ops *ops;
21
22#ifdef CONFIG_NO_IDLE_HZ
23 struct dyn_tick_timer *dyn_tick;
24#endif
21}; 25};
22 26
27#ifdef CONFIG_NO_IDLE_HZ
28#define DYN_TICK_ENABLED (1 << 1)
29
30struct dyn_tick_timer {
31 spinlock_t lock;
32 unsigned int state; /* Current state */
33 int (*enable)(void); /* Enables dynamic tick */
34 int (*disable)(void); /* Disables dynamic tick */
35 void (*reprogram)(unsigned long); /* Reprograms the timer */
36 int (*handler)(int, void *);
37};
38
39void timer_dyn_reprogram(void);
40#else
41#define timer_dyn_reprogram() do { } while (0)
42#endif
43
23#define TICK_SIZE (tick_nsec / 1000) 44#define TICK_SIZE (tick_nsec / 1000)
24 45
25extern struct sys_timer tmu_timer; 46extern struct sys_timer tmu_timer, cmt_timer, mtu2_timer;
26extern struct sys_timer *sys_timer; 47extern struct sys_timer *sys_timer;
27 48
28#ifndef CONFIG_GENERIC_TIME 49#ifndef CONFIG_GENERIC_TIME
diff --git a/include/asm-sh/titan.h b/include/asm-sh/titan.h
index 270a4f4bc8a9..03f3583c8918 100644
--- a/include/asm-sh/titan.h
+++ b/include/asm-sh/titan.h
@@ -1,9 +1,8 @@
1/* 1/*
2 * Platform defintions for Titan 2 * Platform defintions for Titan
3 */ 3 */
4 4#ifndef _ASM_SH_TITAN_H
5#ifndef _ASM_SH_TITAN_TITAN_H 5#define _ASM_SH_TITAN_H
6#define _ASM_SH_TITAN_TITAN_H
7 6
8#define __IO_PREFIX titan 7#define __IO_PREFIX titan
9#include <asm/io_generic.h> 8#include <asm/io_generic.h>
@@ -15,29 +14,4 @@
15#define TITAN_IRQ_MPCIB 11 /* mPCI B */ 14#define TITAN_IRQ_MPCIB 11 /* mPCI B */
16#define TITAN_IRQ_USB 11 /* USB */ 15#define TITAN_IRQ_USB 11 /* USB */
17 16
18/* 17#endif /* __ASM_SH_TITAN_H */
19 * The external interrupt lines, these take up ints 0 - 15 inclusive
20 * depending on the priority for the interrupt. In fact the priority
21 * is the interrupt :-)
22 */
23#define IRL0_IRQ 0
24#define IRL0_IPR_ADDR INTC_IPRD
25#define IRL0_IPR_POS 3
26#define IRL0_PRIORITY 8
27
28#define IRL1_IRQ 1
29#define IRL1_IPR_ADDR INTC_IPRD
30#define IRL1_IPR_POS 2
31#define IRL1_PRIORITY 8
32
33#define IRL2_IRQ 2
34#define IRL2_IPR_ADDR INTC_IPRD
35#define IRL2_IPR_POS 1
36#define IRL2_PRIORITY 8
37
38#define IRL3_IRQ 3
39#define IRL3_IPR_ADDR INTC_IPRD
40#define IRL3_IPR_POS 0
41#define IRL3_PRIORITY 8
42
43#endif
diff --git a/include/asm-sh/unistd.h b/include/asm-sh/unistd.h
index 1c2abde122cd..f982073dc6c6 100644
--- a/include/asm-sh/unistd.h
+++ b/include/asm-sh/unistd.h
@@ -332,125 +332,6 @@
332 332
333#ifdef __KERNEL__ 333#ifdef __KERNEL__
334 334
335#include <linux/err.h>
336
337/* user-visible error numbers are in the range -1 - -MAX_ERRNO:
338 * see <asm-sh/errno.h> */
339
340#define __syscall_return(type, res) \
341do { \
342 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
343 /* Avoid using "res" which is declared to be in register r0; \
344 errno might expand to a function call and clobber it. */ \
345 int __err = -(res); \
346 errno = __err; \
347 res = -1; \
348 } \
349 return (type) (res); \
350} while (0)
351
352/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
353#define _syscall0(type,name) \
354type name(void) \
355{ \
356register long __sc0 __asm__ ("r3") = __NR_##name; \
357__asm__ __volatile__ ("trapa #0x10" \
358 : "=z" (__sc0) \
359 : "0" (__sc0) \
360 : "memory" ); \
361__syscall_return(type,__sc0); \
362}
363
364#define _syscall1(type,name,type1,arg1) \
365type name(type1 arg1) \
366{ \
367register long __sc0 __asm__ ("r3") = __NR_##name; \
368register long __sc4 __asm__ ("r4") = (long) arg1; \
369__asm__ __volatile__ ("trapa #0x11" \
370 : "=z" (__sc0) \
371 : "0" (__sc0), "r" (__sc4) \
372 : "memory"); \
373__syscall_return(type,__sc0); \
374}
375
376#define _syscall2(type,name,type1,arg1,type2,arg2) \
377type name(type1 arg1,type2 arg2) \
378{ \
379register long __sc0 __asm__ ("r3") = __NR_##name; \
380register long __sc4 __asm__ ("r4") = (long) arg1; \
381register long __sc5 __asm__ ("r5") = (long) arg2; \
382__asm__ __volatile__ ("trapa #0x12" \
383 : "=z" (__sc0) \
384 : "0" (__sc0), "r" (__sc4), "r" (__sc5) \
385 : "memory"); \
386__syscall_return(type,__sc0); \
387}
388
389#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
390type name(type1 arg1,type2 arg2,type3 arg3) \
391{ \
392register long __sc0 __asm__ ("r3") = __NR_##name; \
393register long __sc4 __asm__ ("r4") = (long) arg1; \
394register long __sc5 __asm__ ("r5") = (long) arg2; \
395register long __sc6 __asm__ ("r6") = (long) arg3; \
396__asm__ __volatile__ ("trapa #0x13" \
397 : "=z" (__sc0) \
398 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6) \
399 : "memory"); \
400__syscall_return(type,__sc0); \
401}
402
403#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
404type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
405{ \
406register long __sc0 __asm__ ("r3") = __NR_##name; \
407register long __sc4 __asm__ ("r4") = (long) arg1; \
408register long __sc5 __asm__ ("r5") = (long) arg2; \
409register long __sc6 __asm__ ("r6") = (long) arg3; \
410register long __sc7 __asm__ ("r7") = (long) arg4; \
411__asm__ __volatile__ ("trapa #0x14" \
412 : "=z" (__sc0) \
413 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), \
414 "r" (__sc7) \
415 : "memory" ); \
416__syscall_return(type,__sc0); \
417}
418
419#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
420type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
421{ \
422register long __sc3 __asm__ ("r3") = __NR_##name; \
423register long __sc4 __asm__ ("r4") = (long) arg1; \
424register long __sc5 __asm__ ("r5") = (long) arg2; \
425register long __sc6 __asm__ ("r6") = (long) arg3; \
426register long __sc7 __asm__ ("r7") = (long) arg4; \
427register long __sc0 __asm__ ("r0") = (long) arg5; \
428__asm__ __volatile__ ("trapa #0x15" \
429 : "=z" (__sc0) \
430 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), \
431 "r" (__sc3) \
432 : "memory" ); \
433__syscall_return(type,__sc0); \
434}
435
436#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
437type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
438{ \
439register long __sc3 __asm__ ("r3") = __NR_##name; \
440register long __sc4 __asm__ ("r4") = (long) arg1; \
441register long __sc5 __asm__ ("r5") = (long) arg2; \
442register long __sc6 __asm__ ("r6") = (long) arg3; \
443register long __sc7 __asm__ ("r7") = (long) arg4; \
444register long __sc0 __asm__ ("r0") = (long) arg5; \
445register long __sc1 __asm__ ("r1") = (long) arg6; \
446__asm__ __volatile__ ("trapa #0x16" \
447 : "=z" (__sc0) \
448 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), \
449 "r" (__sc3), "r" (__sc1) \
450 : "memory" ); \
451__syscall_return(type,__sc0); \
452}
453
454#define __ARCH_WANT_IPC_PARSE_VERSION 335#define __ARCH_WANT_IPC_PARSE_VERSION
455#define __ARCH_WANT_OLD_READDIR 336#define __ARCH_WANT_OLD_READDIR
456#define __ARCH_WANT_OLD_STAT 337#define __ARCH_WANT_OLD_STAT
diff --git a/include/asm-sh64/dma-mapping.h b/include/asm-sh64/dma-mapping.h
index 68e27a8fca31..5efe906c59f7 100644
--- a/include/asm-sh64/dma-mapping.h
+++ b/include/asm-sh64/dma-mapping.h
@@ -35,7 +35,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,
35 consistent_free(NULL, size, vaddr, dma_handle); 35 consistent_free(NULL, size, vaddr, dma_handle);
36} 36}
37 37
38static inline void dma_cache_sync(void *vaddr, size_t size, 38static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
39 enum dma_data_direction dir) 39 enum dma_data_direction dir)
40{ 40{
41 dma_cache_wback_inv((unsigned long)vaddr, size); 41 dma_cache_wback_inv((unsigned long)vaddr, size);
diff --git a/include/asm-sh64/setup.h b/include/asm-sh64/setup.h
index ebd42eb1b709..5b07b14c2927 100644
--- a/include/asm-sh64/setup.h
+++ b/include/asm-sh64/setup.h
@@ -1,6 +1,10 @@
1#ifndef __ASM_SH64_SETUP_H 1#ifndef __ASM_SH64_SETUP_H
2#define __ASM_SH64_SETUP_H 2#define __ASM_SH64_SETUP_H
3 3
4#define COMMAND_LINE_SIZE 256
5
6#ifdef __KERNEL__
7
4#define PARAM ((unsigned char *)empty_zero_page) 8#define PARAM ((unsigned char *)empty_zero_page)
5#define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000)) 9#define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000))
6#define RAMDISK_FLAGS (*(unsigned long *) (PARAM+0x004)) 10#define RAMDISK_FLAGS (*(unsigned long *) (PARAM+0x004))
@@ -12,5 +16,7 @@
12#define COMMAND_LINE ((char *) (PARAM+256)) 16#define COMMAND_LINE ((char *) (PARAM+256))
13#define COMMAND_LINE_SIZE 256 17#define COMMAND_LINE_SIZE 256
14 18
19#endif /* __KERNEL__ */
20
15#endif /* __ASM_SH64_SETUP_H */ 21#endif /* __ASM_SH64_SETUP_H */
16 22
diff --git a/include/asm-sh64/unistd.h b/include/asm-sh64/unistd.h
index ee7828b27ad1..1f38a7aacaaf 100644
--- a/include/asm-sh64/unistd.h
+++ b/include/asm-sh64/unistd.h
@@ -347,148 +347,6 @@
347#ifdef __KERNEL__ 347#ifdef __KERNEL__
348 348
349#define NR_syscalls 321 349#define NR_syscalls 321
350#include <linux/err.h>
351
352/* user-visible error numbers are in the range -1 - -MAX_ERRNO:
353 * see <asm-sh64/errno.h> */
354
355#define __syscall_return(type, res) \
356do { \
357 /* Note: when returning from kernel the return value is in r9 \
358 ** This prevents conflicts between return value and arg1 \
359 ** when dispatching signal handler, in other words makes \
360 ** life easier in the system call epilogue (see entry.S) \
361 */ \
362 register unsigned long __sr2 __asm__ ("r2") = res; \
363 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
364 errno = -(res); \
365 __sr2 = -1; \
366 } \
367 return (type) (__sr2); \
368} while (0)
369
370/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
371
372#define _syscall0(type,name) \
373type name(void) \
374{ \
375register unsigned long __sc0 __asm__ ("r9") = ((0x10 << 16) | __NR_##name); \
376__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "()" \
377 : "=r" (__sc0) \
378 : "r" (__sc0) ); \
379__syscall_return(type,__sc0); \
380}
381
382 /*
383 * The apparent spurious "dummy" assembler comment is *needed*,
384 * as without it, the compiler treats the arg<n> variables
385 * as no longer live just before the asm. The compiler can
386 * then optimize the storage into any registers it wishes.
387 * The additional dummy statement forces the compiler to put
388 * the arguments into the correct registers before the TRAPA.
389 */
390#define _syscall1(type,name,type1,arg1) \
391type name(type1 arg1) \
392{ \
393register unsigned long __sc0 __asm__ ("r9") = ((0x11 << 16) | __NR_##name); \
394register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
395__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2)" \
396 : "=r" (__sc0) \
397 : "r" (__sc0), "r" (__sc2)); \
398__asm__ __volatile__ ("!dummy %0 %1" \
399 : \
400 : "r" (__sc0), "r" (__sc2)); \
401__syscall_return(type,__sc0); \
402}
403
404#define _syscall2(type,name,type1,arg1,type2,arg2) \
405type name(type1 arg1,type2 arg2) \
406{ \
407register unsigned long __sc0 __asm__ ("r9") = ((0x12 << 16) | __NR_##name); \
408register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
409register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
410__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2,%3)" \
411 : "=r" (__sc0) \
412 : "r" (__sc0), "r" (__sc2), "r" (__sc3) ); \
413__asm__ __volatile__ ("!dummy %0 %1 %2" \
414 : \
415 : "r" (__sc0), "r" (__sc2), "r" (__sc3) ); \
416__syscall_return(type,__sc0); \
417}
418
419#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
420type name(type1 arg1,type2 arg2,type3 arg3) \
421{ \
422register unsigned long __sc0 __asm__ ("r9") = ((0x13 << 16) | __NR_##name); \
423register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
424register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
425register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3; \
426__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2,%3,%4)" \
427 : "=r" (__sc0) \
428 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) ); \
429__asm__ __volatile__ ("!dummy %0 %1 %2 %3" \
430 : \
431 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) ); \
432__syscall_return(type,__sc0); \
433}
434
435#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
436type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
437{ \
438register unsigned long __sc0 __asm__ ("r9") = ((0x14 << 16) | __NR_##name); \
439register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
440register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
441register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3; \
442register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4; \
443__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2,%3,%4,%5)" \
444 : "=r" (__sc0) \
445 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5) );\
446__asm__ __volatile__ ("!dummy %0 %1 %2 %3 %4" \
447 : \
448 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5) );\
449__syscall_return(type,__sc0); \
450}
451
452#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
453type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
454{ \
455register unsigned long __sc0 __asm__ ("r9") = ((0x15 << 16) | __NR_##name); \
456register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
457register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
458register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3; \
459register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4; \
460register unsigned long __sc6 __asm__ ("r6") = (unsigned long) arg5; \
461__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2,%3,%4,%5,%6)" \
462 : "=r" (__sc0) \
463 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5), \
464 "r" (__sc6)); \
465__asm__ __volatile__ ("!dummy %0 %1 %2 %3 %4 %5" \
466 : \
467 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5), \
468 "r" (__sc6)); \
469__syscall_return(type,__sc0); \
470}
471
472#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5, type6, arg6) \
473type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
474{ \
475register unsigned long __sc0 __asm__ ("r9") = ((0x16 << 16) | __NR_##name); \
476register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
477register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
478register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3; \
479register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4; \
480register unsigned long __sc6 __asm__ ("r6") = (unsigned long) arg5; \
481register unsigned long __sc7 __asm__ ("r7") = (unsigned long) arg6; \
482__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2,%3,%4,%5,%6,%7)" \
483 : "=r" (__sc0) \
484 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5), \
485 "r" (__sc6), "r" (__sc7)); \
486__asm__ __volatile__ ("!dummy %0 %1 %2 %3 %4 %5 %6" \
487 : \
488 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5), \
489 "r" (__sc6), "r" (__sc7)); \
490__syscall_return(type,__sc0); \
491}
492 350
493#define __ARCH_WANT_IPC_PARSE_VERSION 351#define __ARCH_WANT_IPC_PARSE_VERSION
494#define __ARCH_WANT_OLD_READDIR 352#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-sparc/unistd.h b/include/asm-sparc/unistd.h
index f7827fa4cd5e..d5b2f8053b3b 100644
--- a/include/asm-sparc/unistd.h
+++ b/include/asm-sparc/unistd.h
@@ -329,136 +329,6 @@
329 * find a free slot in the 0-302 range. 329 * find a free slot in the 0-302 range.
330 */ 330 */
331 331
332#define _syscall0(type,name) \
333type name(void) \
334{ \
335long __res; \
336register long __g1 __asm__ ("g1") = __NR_##name; \
337__asm__ __volatile__ ("t 0x10\n\t" \
338 "bcc 1f\n\t" \
339 "mov %%o0, %0\n\t" \
340 "sub %%g0, %%o0, %0\n\t" \
341 "1:\n\t" \
342 : "=r" (__res)\
343 : "r" (__g1) \
344 : "o0", "cc"); \
345if (__res < -255 || __res >= 0) \
346 return (type) __res; \
347errno = -__res; \
348return -1; \
349}
350
351#define _syscall1(type,name,type1,arg1) \
352type name(type1 arg1) \
353{ \
354long __res; \
355register long __g1 __asm__ ("g1") = __NR_##name; \
356register long __o0 __asm__ ("o0") = (long)(arg1); \
357__asm__ __volatile__ ("t 0x10\n\t" \
358 "bcc 1f\n\t" \
359 "mov %%o0, %0\n\t" \
360 "sub %%g0, %%o0, %0\n\t" \
361 "1:\n\t" \
362 : "=r" (__res), "=&r" (__o0) \
363 : "1" (__o0), "r" (__g1) \
364 : "cc"); \
365if (__res < -255 || __res >= 0) \
366 return (type) __res; \
367errno = -__res; \
368return -1; \
369}
370
371#define _syscall2(type,name,type1,arg1,type2,arg2) \
372type name(type1 arg1,type2 arg2) \
373{ \
374long __res; \
375register long __g1 __asm__ ("g1") = __NR_##name; \
376register long __o0 __asm__ ("o0") = (long)(arg1); \
377register long __o1 __asm__ ("o1") = (long)(arg2); \
378__asm__ __volatile__ ("t 0x10\n\t" \
379 "bcc 1f\n\t" \
380 "mov %%o0, %0\n\t" \
381 "sub %%g0, %%o0, %0\n\t" \
382 "1:\n\t" \
383 : "=r" (__res), "=&r" (__o0) \
384 : "1" (__o0), "r" (__o1), "r" (__g1) \
385 : "cc"); \
386if (__res < -255 || __res >= 0) \
387 return (type) __res; \
388errno = -__res; \
389return -1; \
390}
391
392#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
393type name(type1 arg1,type2 arg2,type3 arg3) \
394{ \
395long __res; \
396register long __g1 __asm__ ("g1") = __NR_##name; \
397register long __o0 __asm__ ("o0") = (long)(arg1); \
398register long __o1 __asm__ ("o1") = (long)(arg2); \
399register long __o2 __asm__ ("o2") = (long)(arg3); \
400__asm__ __volatile__ ("t 0x10\n\t" \
401 "bcc 1f\n\t" \
402 "mov %%o0, %0\n\t" \
403 "sub %%g0, %%o0, %0\n\t" \
404 "1:\n\t" \
405 : "=r" (__res), "=&r" (__o0) \
406 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
407 : "cc"); \
408if (__res < -255 || __res>=0) \
409 return (type) __res; \
410errno = -__res; \
411return -1; \
412}
413
414#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
415type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
416{ \
417long __res; \
418register long __g1 __asm__ ("g1") = __NR_##name; \
419register long __o0 __asm__ ("o0") = (long)(arg1); \
420register long __o1 __asm__ ("o1") = (long)(arg2); \
421register long __o2 __asm__ ("o2") = (long)(arg3); \
422register long __o3 __asm__ ("o3") = (long)(arg4); \
423__asm__ __volatile__ ("t 0x10\n\t" \
424 "bcc 1f\n\t" \
425 "mov %%o0, %0\n\t" \
426 "sub %%g0, %%o0, %0\n\t" \
427 "1:\n\t" \
428 : "=r" (__res), "=&r" (__o0) \
429 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
430 : "cc"); \
431if (__res < -255 || __res>=0) \
432 return (type) __res; \
433errno = -__res; \
434return -1; \
435}
436
437#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
438 type5,arg5) \
439type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
440{ \
441long __res; \
442register long __g1 __asm__ ("g1") = __NR_##name; \
443register long __o0 __asm__ ("o0") = (long)(arg1); \
444register long __o1 __asm__ ("o1") = (long)(arg2); \
445register long __o2 __asm__ ("o2") = (long)(arg3); \
446register long __o3 __asm__ ("o3") = (long)(arg4); \
447register long __o4 __asm__ ("o4") = (long)(arg5); \
448__asm__ __volatile__ ("t 0x10\n\t" \
449 "bcc 1f\n\t" \
450 "mov %%o0, %0\n\t" \
451 "sub %%g0, %%o0, %0\n\t" \
452 "1:\n\t" \
453 : "=r" (__res), "=&r" (__o0) \
454 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
455 : "cc"); \
456if (__res < -255 || __res>=0) \
457 return (type) __res; \
458errno = -__res; \
459return -1; \
460}
461
462#define __ARCH_WANT_IPC_PARSE_VERSION 332#define __ARCH_WANT_IPC_PARSE_VERSION
463#define __ARCH_WANT_OLD_READDIR 333#define __ARCH_WANT_OLD_READDIR
464#define __ARCH_WANT_STAT64 334#define __ARCH_WANT_STAT64
diff --git a/include/asm-sparc64/dma-mapping.h b/include/asm-sparc64/dma-mapping.h
index 27c46fbeebd6..2f858a2df94a 100644
--- a/include/asm-sparc64/dma-mapping.h
+++ b/include/asm-sparc64/dma-mapping.h
@@ -181,7 +181,7 @@ dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t siz
181 181
182#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 182#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
183#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 183#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
184#define dma_is_consistent(d) (1) 184#define dma_is_consistent(d, h) (1)
185 185
186static inline int 186static inline int
187dma_get_cache_alignment(void) 187dma_get_cache_alignment(void)
@@ -210,7 +210,7 @@ dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
210} 210}
211 211
212static inline void 212static inline void
213dma_cache_sync(void *vaddr, size_t size, 213dma_cache_sync(struct device *dev, void *vaddr, size_t size,
214 enum dma_data_direction direction) 214 enum dma_data_direction direction)
215{ 215{
216 /* could define this in terms of the dma_cache ... operations, 216 /* could define this in terms of the dma_cache ... operations,
diff --git a/include/asm-sparc64/futex.h b/include/asm-sparc64/futex.h
index 7392fc4a954e..876312fe82cc 100644
--- a/include/asm-sparc64/futex.h
+++ b/include/asm-sparc64/futex.h
@@ -45,7 +45,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
45 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 45 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
46 oparg = 1 << oparg; 46 oparg = 1 << oparg;
47 47
48 inc_preempt_count(); 48 pagefault_disable();
49 49
50 switch (op) { 50 switch (op) {
51 case FUTEX_OP_SET: 51 case FUTEX_OP_SET:
@@ -67,7 +67,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
67 ret = -ENOSYS; 67 ret = -ENOSYS;
68 } 68 }
69 69
70 dec_preempt_count(); 70 pagefault_enable();
71 71
72 if (!ret) { 72 if (!ret) {
73 switch (cmp) { 73 switch (cmp) {
diff --git a/include/asm-sparc64/pgalloc.h b/include/asm-sparc64/pgalloc.h
index 010f9cd0a672..5891ff7ba760 100644
--- a/include/asm-sparc64/pgalloc.h
+++ b/include/asm-sparc64/pgalloc.h
@@ -13,7 +13,7 @@
13#include <asm/page.h> 13#include <asm/page.h>
14 14
15/* Page table allocation/freeing. */ 15/* Page table allocation/freeing. */
16extern kmem_cache_t *pgtable_cache; 16extern struct kmem_cache *pgtable_cache;
17 17
18static inline pgd_t *pgd_alloc(struct mm_struct *mm) 18static inline pgd_t *pgd_alloc(struct mm_struct *mm)
19{ 19{
diff --git a/include/asm-sparc64/unistd.h b/include/asm-sparc64/unistd.h
index 63669dad0d72..47047536f261 100644
--- a/include/asm-sparc64/unistd.h
+++ b/include/asm-sparc64/unistd.h
@@ -332,124 +332,6 @@
332 * find a free slot in the 0-302 range. 332 * find a free slot in the 0-302 range.
333 */ 333 */
334 334
335#define _syscall0(type,name) \
336type name(void) \
337{ \
338long __res; \
339register long __g1 __asm__ ("g1") = __NR_##name; \
340__asm__ __volatile__ ("t 0x6d\n\t" \
341 "sub %%g0, %%o0, %0\n\t" \
342 "movcc %%xcc, %%o0, %0\n\t" \
343 : "=r" (__res)\
344 : "r" (__g1) \
345 : "o0", "cc"); \
346if (__res >= 0) \
347 return (type) __res; \
348errno = -__res; \
349return -1; \
350}
351
352#define _syscall1(type,name,type1,arg1) \
353type name(type1 arg1) \
354{ \
355long __res; \
356register long __g1 __asm__ ("g1") = __NR_##name; \
357register long __o0 __asm__ ("o0") = (long)(arg1); \
358__asm__ __volatile__ ("t 0x6d\n\t" \
359 "sub %%g0, %%o0, %0\n\t" \
360 "movcc %%xcc, %%o0, %0\n\t" \
361 : "=r" (__res), "=&r" (__o0) \
362 : "1" (__o0), "r" (__g1) \
363 : "cc"); \
364if (__res >= 0) \
365 return (type) __res; \
366errno = -__res; \
367return -1; \
368}
369
370#define _syscall2(type,name,type1,arg1,type2,arg2) \
371type name(type1 arg1,type2 arg2) \
372{ \
373long __res; \
374register long __g1 __asm__ ("g1") = __NR_##name; \
375register long __o0 __asm__ ("o0") = (long)(arg1); \
376register long __o1 __asm__ ("o1") = (long)(arg2); \
377__asm__ __volatile__ ("t 0x6d\n\t" \
378 "sub %%g0, %%o0, %0\n\t" \
379 "movcc %%xcc, %%o0, %0\n\t" \
380 : "=r" (__res), "=&r" (__o0) \
381 : "1" (__o0), "r" (__o1), "r" (__g1) \
382 : "cc"); \
383if (__res >= 0) \
384 return (type) __res; \
385errno = -__res; \
386return -1; \
387}
388
389#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
390type name(type1 arg1,type2 arg2,type3 arg3) \
391{ \
392long __res; \
393register long __g1 __asm__ ("g1") = __NR_##name; \
394register long __o0 __asm__ ("o0") = (long)(arg1); \
395register long __o1 __asm__ ("o1") = (long)(arg2); \
396register long __o2 __asm__ ("o2") = (long)(arg3); \
397__asm__ __volatile__ ("t 0x6d\n\t" \
398 "sub %%g0, %%o0, %0\n\t" \
399 "movcc %%xcc, %%o0, %0\n\t" \
400 : "=r" (__res), "=&r" (__o0) \
401 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
402 : "cc"); \
403if (__res>=0) \
404 return (type) __res; \
405errno = -__res; \
406return -1; \
407}
408
409#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
410type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
411{ \
412long __res; \
413register long __g1 __asm__ ("g1") = __NR_##name; \
414register long __o0 __asm__ ("o0") = (long)(arg1); \
415register long __o1 __asm__ ("o1") = (long)(arg2); \
416register long __o2 __asm__ ("o2") = (long)(arg3); \
417register long __o3 __asm__ ("o3") = (long)(arg4); \
418__asm__ __volatile__ ("t 0x6d\n\t" \
419 "sub %%g0, %%o0, %0\n\t" \
420 "movcc %%xcc, %%o0, %0\n\t" \
421 : "=r" (__res), "=&r" (__o0) \
422 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
423 : "cc"); \
424if (__res>=0) \
425 return (type) __res; \
426errno = -__res; \
427return -1; \
428}
429
430#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
431 type5,arg5) \
432type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
433{ \
434long __res; \
435register long __g1 __asm__ ("g1") = __NR_##name; \
436register long __o0 __asm__ ("o0") = (long)(arg1); \
437register long __o1 __asm__ ("o1") = (long)(arg2); \
438register long __o2 __asm__ ("o2") = (long)(arg3); \
439register long __o3 __asm__ ("o3") = (long)(arg4); \
440register long __o4 __asm__ ("o4") = (long)(arg5); \
441__asm__ __volatile__ ("t 0x6d\n\t" \
442 "sub %%g0, %%o0, %0\n\t" \
443 "movcc %%xcc, %%o0, %0\n\t" \
444 : "=r" (__res), "=&r" (__o0) \
445 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
446 : "cc"); \
447if (__res>=0) \
448 return (type) __res; \
449errno = -__res; \
450return -1; \
451}
452
453/* sysconf options, for SunOS compatibility */ 335/* sysconf options, for SunOS compatibility */
454#define _SC_ARG_MAX 1 336#define _SC_ARG_MAX 1
455#define _SC_CHILD_MAX 2 337#define _SC_CHILD_MAX 2
diff --git a/include/asm-um/dma-mapping.h b/include/asm-um/dma-mapping.h
index babd29895114..f0ee4fb55911 100644
--- a/include/asm-um/dma-mapping.h
+++ b/include/asm-um/dma-mapping.h
@@ -94,7 +94,7 @@ dma_sync_sg(struct device *dev, struct scatterlist *sg, int nelems,
94 94
95#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 95#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
96#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 96#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
97#define dma_is_consistent(d) (1) 97#define dma_is_consistent(d, h) (1)
98 98
99static inline int 99static inline int
100dma_get_cache_alignment(void) 100dma_get_cache_alignment(void)
@@ -112,7 +112,7 @@ dma_sync_single_range(struct device *dev, dma_addr_t dma_handle,
112} 112}
113 113
114static inline void 114static inline void
115dma_cache_sync(void *vaddr, size_t size, 115dma_cache_sync(struct device *dev, void *vaddr, size_t size,
116 enum dma_data_direction direction) 116 enum dma_data_direction direction)
117{ 117{
118 BUG(); 118 BUG();
diff --git a/include/asm-v850/irq.h b/include/asm-v850/irq.h
index 1bf096db8f4c..88687c181f01 100644
--- a/include/asm-v850/irq.h
+++ b/include/asm-v850/irq.h
@@ -46,8 +46,6 @@ extern void
46init_irq_handlers (int base_irq, int num, int interval, 46init_irq_handlers (int base_irq, int num, int interval,
47 struct hw_interrupt_type *irq_type); 47 struct hw_interrupt_type *irq_type);
48 48
49typedef void (*irq_handler_t)(int irq, void *data, struct pt_regs *regs);
50
51/* Handle interrupt IRQ. REGS are the registers at the time of ther 49/* Handle interrupt IRQ. REGS are the registers at the time of ther
52 interrupt. */ 50 interrupt. */
53extern unsigned int handle_irq (int irq, struct pt_regs *regs); 51extern unsigned int handle_irq (int irq, struct pt_regs *regs);
diff --git a/include/asm-v850/unistd.h b/include/asm-v850/unistd.h
index 737401e7d3ad..2241ed45ecfe 100644
--- a/include/asm-v850/unistd.h
+++ b/include/asm-v850/unistd.h
@@ -204,168 +204,8 @@
204#define __NR_gettid 201 204#define __NR_gettid 201
205#define __NR_tkill 202 205#define __NR_tkill 202
206 206
207
208/* Syscall protocol:
209 Syscall number in r12, args in r6-r9, r13-r14
210 Return value in r10
211 Trap 0 for `short' syscalls, where all the args can fit in function
212 call argument registers, and trap 1 when there are additional args in
213 r13-r14. */
214
215#define SYSCALL_NUM "r12"
216#define SYSCALL_ARG0 "r6"
217#define SYSCALL_ARG1 "r7"
218#define SYSCALL_ARG2 "r8"
219#define SYSCALL_ARG3 "r9"
220#define SYSCALL_ARG4 "r13"
221#define SYSCALL_ARG5 "r14"
222#define SYSCALL_RET "r10"
223
224#define SYSCALL_SHORT_TRAP "0"
225#define SYSCALL_LONG_TRAP "1"
226
227/* Registers clobbered by any syscall. This _doesn't_ include the syscall
228 number (r12) or the `extended arg' registers (r13, r14), even though
229 they are actually clobbered too (this is because gcc's `asm' statement
230 doesn't allow a clobber to be used as an input or output). */
231#define SYSCALL_CLOBBERS "r1", "r5", "r11", "r15", "r16", \
232 "r17", "r18", "r19"
233
234/* Registers clobbered by a `short' syscall. This includes all clobbers
235 except the syscall number (r12). */
236#define SYSCALL_SHORT_CLOBBERS SYSCALL_CLOBBERS, "r13", "r14"
237
238#ifdef __KERNEL__ 207#ifdef __KERNEL__
239 208
240#include <asm/clinkage.h>
241#include <linux/err.h>
242
243#define __syscall_return(type, res) \
244 do { \
245 /* user-visible error numbers are in the range -1 - -MAX_ERRNO: \
246 see <asm-v850/errno.h> */ \
247 if (__builtin_expect ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO), 0)) { \
248 errno = -(res); \
249 res = -1; \
250 } \
251 return (type) (res); \
252 } while (0)
253
254
255#define _syscall0(type, name) \
256type name (void) \
257{ \
258 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
259 register unsigned long __ret __asm__ (SYSCALL_RET); \
260 __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \
261 : "=r" (__ret), "=r" (__syscall) \
262 : "1" (__syscall) \
263 : SYSCALL_SHORT_CLOBBERS); \
264 __syscall_return (type, __ret); \
265}
266
267#define _syscall1(type, name, atype, a) \
268type name (atype a) \
269{ \
270 register atype __a __asm__ (SYSCALL_ARG0) = a; \
271 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
272 register unsigned long __ret __asm__ (SYSCALL_RET); \
273 __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \
274 : "=r" (__ret), "=r" (__syscall) \
275 : "1" (__syscall), "r" (__a) \
276 : SYSCALL_SHORT_CLOBBERS); \
277 __syscall_return (type, __ret); \
278}
279
280#define _syscall2(type, name, atype, a, btype, b) \
281type name (atype a, btype b) \
282{ \
283 register atype __a __asm__ (SYSCALL_ARG0) = a; \
284 register btype __b __asm__ (SYSCALL_ARG1) = b; \
285 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
286 register unsigned long __ret __asm__ (SYSCALL_RET); \
287 __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \
288 : "=r" (__ret), "=r" (__syscall) \
289 : "1" (__syscall), "r" (__a), "r" (__b) \
290 : SYSCALL_SHORT_CLOBBERS); \
291 __syscall_return (type, __ret); \
292}
293
294#define _syscall3(type, name, atype, a, btype, b, ctype, c) \
295type name (atype a, btype b, ctype c) \
296{ \
297 register atype __a __asm__ (SYSCALL_ARG0) = a; \
298 register btype __b __asm__ (SYSCALL_ARG1) = b; \
299 register ctype __c __asm__ (SYSCALL_ARG2) = c; \
300 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
301 register unsigned long __ret __asm__ (SYSCALL_RET); \
302 __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \
303 : "=r" (__ret), "=r" (__syscall) \
304 : "1" (__syscall), "r" (__a), "r" (__b), "r" (__c) \
305 : SYSCALL_SHORT_CLOBBERS); \
306 __syscall_return (type, __ret); \
307}
308
309#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d) \
310type name (atype a, btype b, ctype c, dtype d) \
311{ \
312 register atype __a __asm__ (SYSCALL_ARG0) = a; \
313 register btype __b __asm__ (SYSCALL_ARG1) = b; \
314 register ctype __c __asm__ (SYSCALL_ARG2) = c; \
315 register dtype __d __asm__ (SYSCALL_ARG3) = d; \
316 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
317 register unsigned long __ret __asm__ (SYSCALL_RET); \
318 __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \
319 : "=r" (__ret), "=r" (__syscall) \
320 : "1" (__syscall), \
321 "r" (__a), "r" (__b), "r" (__c), "r" (__d) \
322 : SYSCALL_SHORT_CLOBBERS); \
323 __syscall_return (type, __ret); \
324}
325
326#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype,e)\
327type name (atype a, btype b, ctype c, dtype d, etype e) \
328{ \
329 register atype __a __asm__ (SYSCALL_ARG0) = a; \
330 register btype __b __asm__ (SYSCALL_ARG1) = b; \
331 register ctype __c __asm__ (SYSCALL_ARG2) = c; \
332 register dtype __d __asm__ (SYSCALL_ARG3) = d; \
333 register etype __e __asm__ (SYSCALL_ARG4) = e; \
334 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
335 register unsigned long __ret __asm__ (SYSCALL_RET); \
336 __asm__ __volatile__ ("trap " SYSCALL_LONG_TRAP \
337 : "=r" (__ret), "=r" (__syscall), "=r" (__e) \
338 : "1" (__syscall), \
339 "r" (__a), "r" (__b), "r" (__c), "r" (__d), "2" (__e) \
340 : SYSCALL_CLOBBERS); \
341 __syscall_return (type, __ret); \
342}
343
344#define __SYSCALL6_TRAP(syscall, ret, a, b, c, d, e, f) \
345 __asm__ __volatile__ ("trap " SYSCALL_LONG_TRAP \
346 : "=r" (ret), "=r" (syscall), \
347 "=r" (e), "=r" (f) \
348 : "1" (syscall), \
349 "r" (a), "r" (b), "r" (c), "r" (d), \
350 "2" (e), "3" (f) \
351 : SYSCALL_CLOBBERS);
352
353#define _syscall6(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e, ftype, f) \
354type name (atype a, btype b, ctype c, dtype d, etype e, ftype f) \
355{ \
356 register atype __a __asm__ (SYSCALL_ARG0) = a; \
357 register btype __b __asm__ (SYSCALL_ARG1) = b; \
358 register ctype __c __asm__ (SYSCALL_ARG2) = c; \
359 register dtype __d __asm__ (SYSCALL_ARG3) = d; \
360 register etype __e __asm__ (SYSCALL_ARG4) = e; \
361 register etype __f __asm__ (SYSCALL_ARG5) = f; \
362 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
363 register unsigned long __ret __asm__ (SYSCALL_RET); \
364 __SYSCALL6_TRAP(__syscall, __ret, __a, __b, __c, __d, __e, __f); \
365 __syscall_return (type, __ret); \
366}
367
368
369#define __ARCH_WANT_IPC_PARSE_VERSION 209#define __ARCH_WANT_IPC_PARSE_VERSION
370#define __ARCH_WANT_OLD_READDIR 210#define __ARCH_WANT_OLD_READDIR
371#define __ARCH_WANT_STAT64 211#define __ARCH_WANT_STAT64
diff --git a/include/asm-x86_64/Kbuild b/include/asm-x86_64/Kbuild
index 6c455b4068c0..ebd7117782a6 100644
--- a/include/asm-x86_64/Kbuild
+++ b/include/asm-x86_64/Kbuild
@@ -11,7 +11,6 @@ header-y += ldt.h
11header-y += msr.h 11header-y += msr.h
12header-y += prctl.h 12header-y += prctl.h
13header-y += ptrace-abi.h 13header-y += ptrace-abi.h
14header-y += setup.h
15header-y += sigcontext32.h 14header-y += sigcontext32.h
16header-y += ucontext.h 15header-y += ucontext.h
17header-y += vsyscall32.h 16header-y += vsyscall32.h
diff --git a/include/asm-x86_64/atomic.h b/include/asm-x86_64/atomic.h
index 626d3715fbb5..706ca4b60000 100644
--- a/include/asm-x86_64/atomic.h
+++ b/include/asm-x86_64/atomic.h
@@ -21,7 +21,7 @@
21 * on us. We need to use _exactly_ the address the user gave us, 21 * on us. We need to use _exactly_ the address the user gave us,
22 * not some alias that contains the same information. 22 * not some alias that contains the same information.
23 */ 23 */
24typedef struct { volatile int counter; } atomic_t; 24typedef struct { int counter; } atomic_t;
25 25
26#define ATOMIC_INIT(i) { (i) } 26#define ATOMIC_INIT(i) { (i) }
27 27
diff --git a/include/asm-x86_64/dma-mapping.h b/include/asm-x86_64/dma-mapping.h
index 10174b110a5c..be9ec6890723 100644
--- a/include/asm-x86_64/dma-mapping.h
+++ b/include/asm-x86_64/dma-mapping.h
@@ -180,12 +180,13 @@ static inline int dma_get_cache_alignment(void)
180 return boot_cpu_data.x86_clflush_size; 180 return boot_cpu_data.x86_clflush_size;
181} 181}
182 182
183#define dma_is_consistent(h) 1 183#define dma_is_consistent(d, h) 1
184 184
185extern int dma_set_mask(struct device *dev, u64 mask); 185extern int dma_set_mask(struct device *dev, u64 mask);
186 186
187static inline void 187static inline void
188dma_cache_sync(void *vaddr, size_t size, enum dma_data_direction dir) 188dma_cache_sync(struct device *dev, void *vaddr, size_t size,
189 enum dma_data_direction dir)
189{ 190{
190 flush_write_buffers(); 191 flush_write_buffers();
191} 192}
diff --git a/include/asm-x86_64/futex.h b/include/asm-x86_64/futex.h
index 9804bf07b092..5cdfb08013c3 100644
--- a/include/asm-x86_64/futex.h
+++ b/include/asm-x86_64/futex.h
@@ -55,7 +55,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
55 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) 55 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
56 return -EFAULT; 56 return -EFAULT;
57 57
58 inc_preempt_count(); 58 pagefault_disable();
59 59
60 switch (op) { 60 switch (op) {
61 case FUTEX_OP_SET: 61 case FUTEX_OP_SET:
@@ -78,7 +78,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
78 ret = -ENOSYS; 78 ret = -ENOSYS;
79 } 79 }
80 80
81 dec_preempt_count(); 81 pagefault_enable();
82 82
83 if (!ret) { 83 if (!ret) {
84 switch (cmp) { 84 switch (cmp) {
diff --git a/include/asm-x86_64/smp.h b/include/asm-x86_64/smp.h
index 7ae7e7d89d16..e17b9ec42e98 100644
--- a/include/asm-x86_64/smp.h
+++ b/include/asm-x86_64/smp.h
@@ -113,13 +113,6 @@ static __inline int logical_smp_processor_id(void)
113#define cpu_physical_id(cpu) x86_cpu_to_apicid[cpu] 113#define cpu_physical_id(cpu) x86_cpu_to_apicid[cpu]
114#else 114#else
115#define cpu_physical_id(cpu) boot_cpu_id 115#define cpu_physical_id(cpu) boot_cpu_id
116static inline int smp_call_function_single(int cpuid, void (*func) (void *info),
117 void *info, int retry, int wait)
118{
119 /* Disable interrupts here? */
120 func(info);
121 return 0;
122}
123#endif /* !CONFIG_SMP */ 116#endif /* !CONFIG_SMP */
124#endif 117#endif
125 118
diff --git a/include/asm-x86_64/spinlock_types.h b/include/asm-x86_64/spinlock_types.h
index 59efe849f351..4da9345c1500 100644
--- a/include/asm-x86_64/spinlock_types.h
+++ b/include/asm-x86_64/spinlock_types.h
@@ -6,13 +6,13 @@
6#endif 6#endif
7 7
8typedef struct { 8typedef struct {
9 volatile unsigned int slock; 9 unsigned int slock;
10} raw_spinlock_t; 10} raw_spinlock_t;
11 11
12#define __RAW_SPIN_LOCK_UNLOCKED { 1 } 12#define __RAW_SPIN_LOCK_UNLOCKED { 1 }
13 13
14typedef struct { 14typedef struct {
15 volatile unsigned int lock; 15 unsigned int lock;
16} raw_rwlock_t; 16} raw_rwlock_t;
17 17
18#define __RAW_RW_LOCK_UNLOCKED { RW_LOCK_BIAS } 18#define __RAW_RW_LOCK_UNLOCKED { RW_LOCK_BIAS }
diff --git a/include/asm-x86_64/unistd.h b/include/asm-x86_64/unistd.h
index 777288eb7e75..c5f596e71faa 100644
--- a/include/asm-x86_64/unistd.h
+++ b/include/asm-x86_64/unistd.h
@@ -622,25 +622,7 @@ __SYSCALL(__NR_move_pages, sys_move_pages)
622 622
623#define __NR_syscall_max __NR_move_pages 623#define __NR_syscall_max __NR_move_pages
624 624
625#ifdef __KERNEL__
626#include <linux/err.h>
627#endif
628
629#ifndef __NO_STUBS 625#ifndef __NO_STUBS
630
631/* user-visible error numbers are in the range -1 - -MAX_ERRNO */
632
633#define __syscall_clobber "r11","rcx","memory"
634
635#define __syscall_return(type, res) \
636do { \
637 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
638 errno = -(res); \
639 res = -1; \
640 } \
641 return (type) (res); \
642} while (0)
643
644#define __ARCH_WANT_OLD_READDIR 626#define __ARCH_WANT_OLD_READDIR
645#define __ARCH_WANT_OLD_STAT 627#define __ARCH_WANT_OLD_STAT
646#define __ARCH_WANT_SYS_ALARM 628#define __ARCH_WANT_SYS_ALARM
@@ -664,87 +646,6 @@ do { \
664#define __ARCH_WANT_SYS_TIME 646#define __ARCH_WANT_SYS_TIME
665#define __ARCH_WANT_COMPAT_SYS_TIME 647#define __ARCH_WANT_COMPAT_SYS_TIME
666 648
667#define __syscall "syscall"
668
669#define _syscall0(type,name) \
670type name(void) \
671{ \
672long __res; \
673__asm__ volatile (__syscall \
674 : "=a" (__res) \
675 : "0" (__NR_##name) : __syscall_clobber ); \
676__syscall_return(type,__res); \
677}
678
679#define _syscall1(type,name,type1,arg1) \
680type name(type1 arg1) \
681{ \
682long __res; \
683__asm__ volatile (__syscall \
684 : "=a" (__res) \
685 : "0" (__NR_##name),"D" ((long)(arg1)) : __syscall_clobber ); \
686__syscall_return(type,__res); \
687}
688
689#define _syscall2(type,name,type1,arg1,type2,arg2) \
690type name(type1 arg1,type2 arg2) \
691{ \
692long __res; \
693__asm__ volatile (__syscall \
694 : "=a" (__res) \
695 : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)) : __syscall_clobber ); \
696__syscall_return(type,__res); \
697}
698
699#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
700type name(type1 arg1,type2 arg2,type3 arg3) \
701{ \
702long __res; \
703__asm__ volatile (__syscall \
704 : "=a" (__res) \
705 : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
706 "d" ((long)(arg3)) : __syscall_clobber); \
707__syscall_return(type,__res); \
708}
709
710#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
711type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
712{ \
713long __res; \
714__asm__ volatile ("movq %5,%%r10 ;" __syscall \
715 : "=a" (__res) \
716 : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
717 "d" ((long)(arg3)),"g" ((long)(arg4)) : __syscall_clobber,"r10" ); \
718__syscall_return(type,__res); \
719}
720
721#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
722 type5,arg5) \
723type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
724{ \
725long __res; \
726__asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall \
727 : "=a" (__res) \
728 : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
729 "d" ((long)(arg3)),"g" ((long)(arg4)),"g" ((long)(arg5)) : \
730 __syscall_clobber,"r8","r10" ); \
731__syscall_return(type,__res); \
732}
733
734#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
735 type5,arg5,type6,arg6) \
736type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
737{ \
738long __res; \
739__asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; movq %7,%%r9 ; " __syscall \
740 : "=a" (__res) \
741 : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
742 "d" ((long)(arg3)), "g" ((long)(arg4)), "g" ((long)(arg5)), \
743 "g" ((long)(arg6)) : \
744 __syscall_clobber,"r8","r10","r9" ); \
745__syscall_return(type,__res); \
746}
747
748#ifdef __KERNEL__ 649#ifdef __KERNEL__
749#ifndef __ASSEMBLY__ 650#ifndef __ASSEMBLY__
750 651
diff --git a/include/asm-xtensa/dma-mapping.h b/include/asm-xtensa/dma-mapping.h
index c39c91dfcc69..82b03b3a2ee6 100644
--- a/include/asm-xtensa/dma-mapping.h
+++ b/include/asm-xtensa/dma-mapping.h
@@ -170,10 +170,10 @@ dma_get_cache_alignment(void)
170 return L1_CACHE_BYTES; 170 return L1_CACHE_BYTES;
171} 171}
172 172
173#define dma_is_consistent(d) (1) 173#define dma_is_consistent(d, h) (1)
174 174
175static inline void 175static inline void
176dma_cache_sync(void *vaddr, size_t size, 176dma_cache_sync(struct device *dev, void *vaddr, size_t size,
177 enum dma_data_direction direction) 177 enum dma_data_direction direction)
178{ 178{
179 consistent_sync(vaddr, size, direction); 179 consistent_sync(vaddr, size, direction);
diff --git a/include/asm-xtensa/unistd.h b/include/asm-xtensa/unistd.h
index 411f810a55c6..2e1a1b997e7d 100644
--- a/include/asm-xtensa/unistd.h
+++ b/include/asm-xtensa/unistd.h
@@ -218,190 +218,6 @@
218 218
219#define SYSXTENSA_COUNT 5 /* count of syscall0 functions*/ 219#define SYSXTENSA_COUNT 5 /* count of syscall0 functions*/
220 220
221#ifdef __KERNEL__
222#include <linux/linkage.h>
223
224#define __syscall_return(type, res) return ((type)(res))
225
226/* Tensilica's xt-xcc compiler is much more agressive at code
227 * optimization than gcc. Multiple __asm__ statements are
228 * insufficient for xt-xcc because subsequent optimization passes
229 * (beyond the front-end that knows of __asm__ statements and other
230 * such GNU Extensions to C) can modify the register selection for
231 * containment of C variables.
232 *
233 * xt-xcc cannot modify the contents of a single __asm__ statement, so
234 * we create single-asm versions of the syscall macros that are
235 * suitable and optimal for both xt-xcc and gcc.
236 *
237 * Linux takes system-call arguments in registers. The following
238 * design is optimized for user-land apps (e.g., glibc) which
239 * typically have a function wrapper around the "syscall" assembly
240 * instruction. It satisfies the Xtensa ABI while minizing argument
241 * shifting.
242 *
243 * The Xtensa ABI and software conventions require the system-call
244 * number in a2. If an argument exists in a2, we move it to the next
245 * available register. Note that for improved efficiency, we do NOT
246 * shift all parameters down one register to maintain the original
247 * order.
248 *
249 * At best case (zero arguments), we just write the syscall number to
250 * a2. At worst case (1 to 6 arguments), we move the argument in a2
251 * to the next available register, then write the syscall number to
252 * a2.
253 *
254 * For clarity, the following truth table enumerates all possibilities.
255 *
256 * arguments syscall number arg0, arg1, arg2, arg3, arg4, arg5
257 * --------- -------------- ----------------------------------
258 * 0 a2
259 * 1 a2 a3
260 * 2 a2 a4, a3
261 * 3 a2 a5, a3, a4
262 * 4 a2 a6, a3, a4, a5
263 * 5 a2 a7, a3, a4, a5, a6
264 * 6 a2 a8, a3, a4, a5, a6, a7
265 */
266
267#define _syscall0(type,name) \
268type name(void) \
269{ \
270long __res; \
271__asm__ __volatile__ ( \
272 " movi a2, %1 \n" \
273 " syscall \n" \
274 " mov %0, a2 \n" \
275 : "=a" (__res) \
276 : "i" (__NR_##name) \
277 : "a2" \
278 ); \
279__syscall_return(type,__res); \
280}
281
282#define _syscall1(type,name,type0,arg0) \
283type name(type0 arg0) \
284{ \
285long __res; \
286__asm__ __volatile__ ( \
287 " mov a3, %2 \n" \
288 " movi a2, %1 \n" \
289 " syscall \n" \
290 " mov %0, a2 \n" \
291 : "=a" (__res) \
292 : "i" (__NR_##name), "a" (arg0) \
293 : "a2", "a3" \
294 ); \
295__syscall_return(type,__res); \
296}
297
298#define _syscall2(type,name,type0,arg0,type1,arg1) \
299type name(type0 arg0,type1 arg1) \
300{ \
301long __res; \
302__asm__ __volatile__ ( \
303 " mov a4, %2 \n" \
304 " mov a3, %3 \n" \
305 " movi a2, %1 \n" \
306 " syscall \n" \
307 " mov %0, a2 \n" \
308 : "=a" (__res) \
309 : "i" (__NR_##name), "a" (arg0), "a" (arg1) \
310 : "a2", "a3", "a4" \
311 ); \
312__syscall_return(type,__res); \
313}
314
315#define _syscall3(type,name,type0,arg0,type1,arg1,type2,arg2) \
316type name(type0 arg0,type1 arg1,type2 arg2) \
317{ \
318long __res; \
319__asm__ __volatile__ ( \
320 " mov a5, %2 \n" \
321 " mov a4, %4 \n" \
322 " mov a3, %3 \n" \
323 " movi a2, %1 \n" \
324 " syscall \n" \
325 " mov %0, a2 \n" \
326 : "=a" (__res) \
327 : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2) \
328 : "a2", "a3", "a4", "a5" \
329 ); \
330__syscall_return(type,__res); \
331}
332
333#define _syscall4(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3) \
334type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3) \
335{ \
336long __res; \
337__asm__ __volatile__ ( \
338 " mov a6, %2 \n" \
339 " mov a5, %5 \n" \
340 " mov a4, %4 \n" \
341 " mov a3, %3 \n" \
342 " movi a2, %1 \n" \
343 " syscall \n" \
344 " mov %0, a2 \n" \
345 : "=a" (__res) \
346 : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), "a" (arg3) \
347 : "a2", "a3", "a4", "a5", "a6" \
348 ); \
349__syscall_return(type,__res); \
350}
351
352/* Note that we save and restore the a7 frame pointer.
353 * Including a7 in the clobber list doesn't do what you'd expect.
354 */
355#define _syscall5(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
356type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
357{ \
358long __res; \
359__asm__ __volatile__ ( \
360 " mov a9, a7 \n" \
361 " mov a7, %2 \n" \
362 " mov a6, %6 \n" \
363 " mov a5, %5 \n" \
364 " mov a4, %4 \n" \
365 " mov a3, %3 \n" \
366 " movi a2, %1 \n" \
367 " syscall \n" \
368 " mov a7, a9 \n" \
369 " mov %0, a2 \n" \
370 : "=a" (__res) \
371 : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), \
372 "a" (arg3), "a" (arg4) \
373 : "a2", "a3", "a4", "a5", "a6", "a9" \
374 ); \
375__syscall_return(type,__res); \
376}
377
378/* Note that we save and restore the a7 frame pointer.
379 * Including a7 in the clobber list doesn't do what you'd expect.
380 */
381#define _syscall6(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
382type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
383{ \
384long __res; \
385__asm__ __volatile__ ( \
386 " mov a9, a7 \n" \
387 " mov a8, %2 \n" \
388 " mov a7, %7 \n" \
389 " mov a6, %6 \n" \
390 " mov a5, %5 \n" \
391 " mov a4, %4 \n" \
392 " mov a3, %3 \n" \
393 " movi a2, %1 \n" \
394 " syscall \n" \
395 " mov a7, a9 \n" \
396 " mov %0, a2 \n" \
397 : "=a" (__res) \
398 : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), \
399 "a" (arg3), "a" (arg4), "a" (arg5) \
400 : "a2", "a3", "a4", "a5", "a6", "a8", "a9" \
401 ); \
402__syscall_return(type,__res); \
403}
404
405/* 221/*
406 * "Conditional" syscalls 222 * "Conditional" syscalls
407 * 223 *
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index ff433126361f..e618b25b5add 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -221,6 +221,7 @@ unifdef-y += if_bridge.h
221unifdef-y += if_ec.h 221unifdef-y += if_ec.h
222unifdef-y += if_eql.h 222unifdef-y += if_eql.h
223unifdef-y += if_ether.h 223unifdef-y += if_ether.h
224unifdef-y += if_fddi.h
224unifdef-y += if_frad.h 225unifdef-y += if_frad.h
225unifdef-y += if_ltalk.h 226unifdef-y += if_ltalk.h
226unifdef-y += if_pppox.h 227unifdef-y += if_pppox.h
@@ -282,6 +283,7 @@ unifdef-y += nvram.h
282unifdef-y += parport.h 283unifdef-y += parport.h
283unifdef-y += patchkey.h 284unifdef-y += patchkey.h
284unifdef-y += pci.h 285unifdef-y += pci.h
286unifdef-y += personality.h
285unifdef-y += pktcdvd.h 287unifdef-y += pktcdvd.h
286unifdef-y += pmu.h 288unifdef-y += pmu.h
287unifdef-y += poll.h 289unifdef-y += poll.h
@@ -337,6 +339,7 @@ unifdef-y += videodev.h
337unifdef-y += wait.h 339unifdef-y += wait.h
338unifdef-y += wanrouter.h 340unifdef-y += wanrouter.h
339unifdef-y += watchdog.h 341unifdef-y += watchdog.h
342unifdef-y += wireless.h
340unifdef-y += xfrm.h 343unifdef-y += xfrm.h
341 344
342objhdr-y += version.h 345objhdr-y += version.h
diff --git a/include/linux/aio.h b/include/linux/aio.h
index 0d71c0041f13..3372ec6bf53a 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -111,7 +111,6 @@ struct kiocb {
111 size_t ki_nbytes; /* copy of iocb->aio_nbytes */ 111 size_t ki_nbytes; /* copy of iocb->aio_nbytes */
112 char __user *ki_buf; /* remaining iocb->aio_buf */ 112 char __user *ki_buf; /* remaining iocb->aio_buf */
113 size_t ki_left; /* remaining bytes */ 113 size_t ki_left; /* remaining bytes */
114 long ki_retried; /* just for testing */
115 struct iovec ki_inline_vec; /* inline vector */ 114 struct iovec ki_inline_vec; /* inline vector */
116 struct iovec *ki_iovec; 115 struct iovec *ki_iovec;
117 unsigned long ki_nr_segs; 116 unsigned long ki_nr_segs;
@@ -194,7 +193,7 @@ struct kioctx {
194 193
195 struct aio_ring_info ring_info; 194 struct aio_ring_info ring_info;
196 195
197 struct work_struct wq; 196 struct delayed_work wq;
198}; 197};
199 198
200/* prototypes */ 199/* prototypes */
@@ -238,7 +237,6 @@ do { \
238} while (0) 237} while (0)
239 238
240#define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait) 239#define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait)
241#define is_retried_kiocb(iocb) ((iocb)->ki_retried > 1)
242 240
243#include <linux/aio_abi.h> 241#include <linux/aio_abi.h>
244 242
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 31e9abb6d977..2275f2748708 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -119,8 +119,7 @@ extern void *alloc_large_system_hash(const char *tablename,
119 unsigned int *_hash_mask, 119 unsigned int *_hash_mask,
120 unsigned long limit); 120 unsigned long limit);
121 121
122#define HASH_HIGHMEM 0x00000001 /* Consider highmem? */ 122#define HASH_EARLY 0x00000001 /* Allocating during early boot? */
123#define HASH_EARLY 0x00000002 /* Allocating during early boot? */
124 123
125/* Only NUMA needs hash distribution. 124/* Only NUMA needs hash distribution.
126 * IA64 is known to have sufficient vmalloc space. 125 * IA64 is known to have sufficient vmalloc space.
diff --git a/include/linux/bottom_half.h b/include/linux/bottom_half.h
new file mode 100644
index 000000000000..777dbf695d44
--- /dev/null
+++ b/include/linux/bottom_half.h
@@ -0,0 +1,10 @@
1#ifndef _LINUX_BH_H
2#define _LINUX_BH_H
3
4extern void local_bh_disable(void);
5extern void __local_bh_enable(void);
6extern void _local_bh_enable(void);
7extern void local_bh_enable(void);
8extern void local_bh_enable_ip(unsigned long ip);
9
10#endif /* _LINUX_BH_H */
diff --git a/include/linux/carta_random32.h b/include/linux/carta_random32.h
deleted file mode 100644
index f6f3bd9f20b5..000000000000
--- a/include/linux/carta_random32.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * Fast, simple, yet decent quality random number generator based on
3 * a paper by David G. Carta ("Two Fast Implementations of the
4 * `Minimal Standard' Random Number Generator," Communications of the
5 * ACM, January, 1990).
6 *
7 * Copyright (c) 2002-2006 Hewlett-Packard Development Company, L.P.
8 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */
24#ifndef _LINUX_CARTA_RANDOM32_H_
25#define _LINUX_CARTA_RANDOM32_H_
26
27u64 carta_random32(u64 seed);
28
29#endif /* _LINUX_CARTA_RANDOM32_H_ */
diff --git a/include/linux/cciss_ioctl.h b/include/linux/cciss_ioctl.h
index 6e27f42e3a57..cb57c30081a8 100644
--- a/include/linux/cciss_ioctl.h
+++ b/include/linux/cciss_ioctl.h
@@ -80,7 +80,7 @@ typedef __u32 DriverVer_type;
80#define HWORD __u16 80#define HWORD __u16
81#define DWORD __u32 81#define DWORD __u32
82 82
83#define CISS_MAX_LUN 16 83#define CISS_MAX_LUN 1024
84 84
85#define LEVEL2LUN 1 // index into Target(x) structure, due to byte swapping 85#define LEVEL2LUN 1 // index into Target(x) structure, due to byte swapping
86#define LEVEL3LUN 0 86#define LEVEL3LUN 0
diff --git a/include/linux/cdev.h b/include/linux/cdev.h
index ee5f53f2ca15..f309b00e986e 100644
--- a/include/linux/cdev.h
+++ b/include/linux/cdev.h
@@ -2,6 +2,10 @@
2#define _LINUX_CDEV_H 2#define _LINUX_CDEV_H
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5#include <linux/kobject.h>
6#include <linux/kdev_t.h>
7#include <linux/list.h>
8
5struct cdev { 9struct cdev {
6 struct kobject kobj; 10 struct kobject kobj;
7 struct module *owner; 11 struct module *owner;
diff --git a/include/linux/connector.h b/include/linux/connector.h
index 4c02119c6ab9..3ea1cd58de97 100644
--- a/include/linux/connector.h
+++ b/include/linux/connector.h
@@ -133,7 +133,7 @@ struct cn_callback_data {
133struct cn_callback_entry { 133struct cn_callback_entry {
134 struct list_head callback_entry; 134 struct list_head callback_entry;
135 struct cn_callback *cb; 135 struct cn_callback *cb;
136 struct work_struct work; 136 struct delayed_work work;
137 struct cn_queue_dev *pdev; 137 struct cn_queue_dev *pdev;
138 138
139 struct cn_callback_id id; 139 struct cn_callback_id id;
@@ -170,7 +170,7 @@ void cn_queue_free_dev(struct cn_queue_dev *dev);
170 170
171int cn_cb_equal(struct cb_id *, struct cb_id *); 171int cn_cb_equal(struct cb_id *, struct cb_id *);
172 172
173void cn_queue_wrapper(void *data); 173void cn_queue_wrapper(struct work_struct *work);
174 174
175extern int cn_already_initialized; 175extern int cn_already_initialized;
176 176
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index ad90340e7dba..bfb520212d71 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -24,6 +24,7 @@
24#include <linux/compiler.h> 24#include <linux/compiler.h>
25#include <linux/cpumask.h> 25#include <linux/cpumask.h>
26#include <asm/semaphore.h> 26#include <asm/semaphore.h>
27#include <linux/mutex.h>
27 28
28struct cpu { 29struct cpu {
29 int node_id; /* The node which contains the CPU */ 30 int node_id; /* The node which contains the CPU */
@@ -74,6 +75,17 @@ extern struct sysdev_class cpu_sysdev_class;
74 75
75#ifdef CONFIG_HOTPLUG_CPU 76#ifdef CONFIG_HOTPLUG_CPU
76/* Stop CPUs going up and down. */ 77/* Stop CPUs going up and down. */
78
79static inline void cpuhotplug_mutex_lock(struct mutex *cpu_hp_mutex)
80{
81 mutex_lock(cpu_hp_mutex);
82}
83
84static inline void cpuhotplug_mutex_unlock(struct mutex *cpu_hp_mutex)
85{
86 mutex_unlock(cpu_hp_mutex);
87}
88
77extern void lock_cpu_hotplug(void); 89extern void lock_cpu_hotplug(void);
78extern void unlock_cpu_hotplug(void); 90extern void unlock_cpu_hotplug(void);
79#define hotcpu_notifier(fn, pri) { \ 91#define hotcpu_notifier(fn, pri) { \
@@ -85,17 +97,24 @@ extern void unlock_cpu_hotplug(void);
85#define unregister_hotcpu_notifier(nb) unregister_cpu_notifier(nb) 97#define unregister_hotcpu_notifier(nb) unregister_cpu_notifier(nb)
86int cpu_down(unsigned int cpu); 98int cpu_down(unsigned int cpu);
87#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu)) 99#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
88#else 100
101#else /* CONFIG_HOTPLUG_CPU */
102
103static inline void cpuhotplug_mutex_lock(struct mutex *cpu_hp_mutex)
104{ }
105static inline void cpuhotplug_mutex_unlock(struct mutex *cpu_hp_mutex)
106{ }
107
89#define lock_cpu_hotplug() do { } while (0) 108#define lock_cpu_hotplug() do { } while (0)
90#define unlock_cpu_hotplug() do { } while (0) 109#define unlock_cpu_hotplug() do { } while (0)
91#define lock_cpu_hotplug_interruptible() 0 110#define lock_cpu_hotplug_interruptible() 0
92#define hotcpu_notifier(fn, pri) do { } while (0) 111#define hotcpu_notifier(fn, pri) do { (void)(fn); } while (0)
93#define register_hotcpu_notifier(nb) do { } while (0) 112#define register_hotcpu_notifier(nb) do { (void)(nb); } while (0)
94#define unregister_hotcpu_notifier(nb) do { } while (0) 113#define unregister_hotcpu_notifier(nb) do { (void)(nb); } while (0)
95 114
96/* CPUs don't go offline once they're online w/o CONFIG_HOTPLUG_CPU */ 115/* CPUs don't go offline once they're online w/o CONFIG_HOTPLUG_CPU */
97static inline int cpu_is_offline(int cpu) { return 0; } 116static inline int cpu_is_offline(int cpu) { return 0; }
98#endif 117#endif /* CONFIG_HOTPLUG_CPU */
99 118
100#ifdef CONFIG_SUSPEND_SMP 119#ifdef CONFIG_SUSPEND_SMP
101extern int disable_nonboot_cpus(void); 120extern int disable_nonboot_cpus(void);
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 4d8adf663681..8821e1f75b44 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -23,6 +23,7 @@ extern void cpuset_fork(struct task_struct *p);
23extern void cpuset_exit(struct task_struct *p); 23extern void cpuset_exit(struct task_struct *p);
24extern cpumask_t cpuset_cpus_allowed(struct task_struct *p); 24extern cpumask_t cpuset_cpus_allowed(struct task_struct *p);
25extern nodemask_t cpuset_mems_allowed(struct task_struct *p); 25extern nodemask_t cpuset_mems_allowed(struct task_struct *p);
26#define cpuset_current_mems_allowed (current->mems_allowed)
26void cpuset_init_current_mems_allowed(void); 27void cpuset_init_current_mems_allowed(void);
27void cpuset_update_task_memory_state(void); 28void cpuset_update_task_memory_state(void);
28#define cpuset_nodes_subset_current_mems_allowed(nodes) \ 29#define cpuset_nodes_subset_current_mems_allowed(nodes) \
@@ -45,7 +46,7 @@ extern int cpuset_excl_nodes_overlap(const struct task_struct *p);
45extern int cpuset_memory_pressure_enabled; 46extern int cpuset_memory_pressure_enabled;
46extern void __cpuset_memory_pressure_bump(void); 47extern void __cpuset_memory_pressure_bump(void);
47 48
48extern struct file_operations proc_cpuset_operations; 49extern const struct file_operations proc_cpuset_operations;
49extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer); 50extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer);
50 51
51extern void cpuset_lock(void); 52extern void cpuset_lock(void);
@@ -83,6 +84,7 @@ static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
83 return node_possible_map; 84 return node_possible_map;
84} 85}
85 86
87#define cpuset_current_mems_allowed (node_online_map)
86static inline void cpuset_init_current_mems_allowed(void) {} 88static inline void cpuset_init_current_mems_allowed(void) {}
87static inline void cpuset_update_task_memory_state(void) {} 89static inline void cpuset_update_task_memory_state(void) {}
88#define cpuset_nodes_subset_current_mems_allowed(nodes) (1) 90#define cpuset_nodes_subset_current_mems_allowed(nodes) (1)
diff --git a/include/linux/debug_locks.h b/include/linux/debug_locks.h
index 952bee79a8f3..a1c10b0c4cf0 100644
--- a/include/linux/debug_locks.h
+++ b/include/linux/debug_locks.h
@@ -24,7 +24,7 @@ extern int debug_locks_off(void);
24 int __ret = 0; \ 24 int __ret = 0; \
25 \ 25 \
26 if (unlikely(c)) { \ 26 if (unlikely(c)) { \
27 if (debug_locks_off()) \ 27 if (debug_locks_silent || debug_locks_off()) \
28 WARN_ON(1); \ 28 WARN_ON(1); \
29 __ret = 1; \ 29 __ret = 1; \
30 } \ 30 } \
diff --git a/include/linux/delayacct.h b/include/linux/delayacct.h
index 561e2a77805c..55d1ca5e60f5 100644
--- a/include/linux/delayacct.h
+++ b/include/linux/delayacct.h
@@ -30,7 +30,7 @@
30#ifdef CONFIG_TASK_DELAY_ACCT 30#ifdef CONFIG_TASK_DELAY_ACCT
31 31
32extern int delayacct_on; /* Delay accounting turned on/off */ 32extern int delayacct_on; /* Delay accounting turned on/off */
33extern kmem_cache_t *delayacct_cache; 33extern struct kmem_cache *delayacct_cache;
34extern void delayacct_init(void); 34extern void delayacct_init(void);
35extern void __delayacct_tsk_init(struct task_struct *); 35extern void __delayacct_tsk_init(struct task_struct *);
36extern void __delayacct_tsk_exit(struct task_struct *); 36extern void __delayacct_tsk_exit(struct task_struct *);
diff --git a/include/linux/device.h b/include/linux/device.h
index 583a341e016c..49ab53ce92dc 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -371,6 +371,9 @@ struct device {
371 core doesn't touch it */ 371 core doesn't touch it */
372 struct dev_pm_info power; 372 struct dev_pm_info power;
373 373
374#ifdef CONFIG_NUMA
375 int numa_node; /* NUMA node this device is close to */
376#endif
374 u64 *dma_mask; /* dma mask (if dma'able device) */ 377 u64 *dma_mask; /* dma mask (if dma'able device) */
375 u64 coherent_dma_mask;/* Like dma_mask, but for 378 u64 coherent_dma_mask;/* Like dma_mask, but for
376 alloc_coherent mappings as 379 alloc_coherent mappings as
@@ -394,6 +397,25 @@ struct device {
394 void (*release)(struct device * dev); 397 void (*release)(struct device * dev);
395}; 398};
396 399
400#ifdef CONFIG_NUMA
401static inline int dev_to_node(struct device *dev)
402{
403 return dev->numa_node;
404}
405static inline void set_dev_node(struct device *dev, int node)
406{
407 dev->numa_node = node;
408}
409#else
410static inline int dev_to_node(struct device *dev)
411{
412 return -1;
413}
414static inline void set_dev_node(struct device *dev, int node)
415{
416}
417#endif
418
397static inline void * 419static inline void *
398dev_get_drvdata (struct device *dev) 420dev_get_drvdata (struct device *dev)
399{ 421{
diff --git a/include/linux/elf.h b/include/linux/elf.h
index 743d5c8e6d36..60713e6ea297 100644
--- a/include/linux/elf.h
+++ b/include/linux/elf.h
@@ -6,6 +6,8 @@
6#include <linux/elf-em.h> 6#include <linux/elf-em.h>
7#include <asm/elf.h> 7#include <asm/elf.h>
8 8
9struct file;
10
9#ifndef elf_read_implies_exec 11#ifndef elf_read_implies_exec
10 /* Executables for which elf_read_implies_exec() returns TRUE will 12 /* Executables for which elf_read_implies_exec() returns TRUE will
11 have the READ_IMPLIES_EXEC personality flag set automatically. 13 have the READ_IMPLIES_EXEC personality flag set automatically.
@@ -358,6 +360,7 @@ extern Elf32_Dyn _DYNAMIC [];
358#define elfhdr elf32_hdr 360#define elfhdr elf32_hdr
359#define elf_phdr elf32_phdr 361#define elf_phdr elf32_phdr
360#define elf_note elf32_note 362#define elf_note elf32_note
363#define elf_addr_t Elf32_Off
361 364
362#else 365#else
363 366
@@ -365,6 +368,7 @@ extern Elf64_Dyn _DYNAMIC [];
365#define elfhdr elf64_hdr 368#define elfhdr elf64_hdr
366#define elf_phdr elf64_phdr 369#define elf_phdr elf64_phdr
367#define elf_note elf64_note 370#define elf_note elf64_note
371#define elf_addr_t Elf64_Off
368 372
369#endif 373#endif
370 374
diff --git a/include/linux/ext3_jbd.h b/include/linux/ext3_jbd.h
index ce0e6109aff0..8c43b13a02fe 100644
--- a/include/linux/ext3_jbd.h
+++ b/include/linux/ext3_jbd.h
@@ -109,74 +109,32 @@ int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode);
109 * been done yet. 109 * been done yet.
110 */ 110 */
111 111
112void ext3_journal_abort_handle(const char *caller, const char *err_fn, 112static inline void ext3_journal_release_buffer(handle_t *handle,
113 struct buffer_head *bh, handle_t *handle, int err); 113 struct buffer_head *bh)
114
115static inline int
116__ext3_journal_get_undo_access(const char *where, handle_t *handle,
117 struct buffer_head *bh)
118{ 114{
119 int err = journal_get_undo_access(handle, bh); 115 journal_release_buffer(handle, bh);
120 if (err)
121 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
122 return err;
123} 116}
124 117
125static inline int 118void ext3_journal_abort_handle(const char *caller, const char *err_fn,
126__ext3_journal_get_write_access(const char *where, handle_t *handle, 119 struct buffer_head *bh, handle_t *handle, int err);
127 struct buffer_head *bh)
128{
129 int err = journal_get_write_access(handle, bh);
130 if (err)
131 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
132 return err;
133}
134 120
135static inline void 121int __ext3_journal_get_undo_access(const char *where, handle_t *handle,
136ext3_journal_release_buffer(handle_t *handle, struct buffer_head *bh) 122 struct buffer_head *bh);
137{
138 journal_release_buffer(handle, bh);
139}
140 123
141static inline int 124int __ext3_journal_get_write_access(const char *where, handle_t *handle,
142__ext3_journal_forget(const char *where, handle_t *handle, struct buffer_head *bh) 125 struct buffer_head *bh);
143{
144 int err = journal_forget(handle, bh);
145 if (err)
146 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
147 return err;
148}
149 126
150static inline int 127int __ext3_journal_forget(const char *where, handle_t *handle,
151__ext3_journal_revoke(const char *where, handle_t *handle, 128 struct buffer_head *bh);
152 unsigned long blocknr, struct buffer_head *bh)
153{
154 int err = journal_revoke(handle, blocknr, bh);
155 if (err)
156 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
157 return err;
158}
159 129
160static inline int 130int __ext3_journal_revoke(const char *where, handle_t *handle,
161__ext3_journal_get_create_access(const char *where, 131 unsigned long blocknr, struct buffer_head *bh);
162 handle_t *handle, struct buffer_head *bh)
163{
164 int err = journal_get_create_access(handle, bh);
165 if (err)
166 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
167 return err;
168}
169 132
170static inline int 133int __ext3_journal_get_create_access(const char *where,
171__ext3_journal_dirty_metadata(const char *where, 134 handle_t *handle, struct buffer_head *bh);
172 handle_t *handle, struct buffer_head *bh)
173{
174 int err = journal_dirty_metadata(handle, bh);
175 if (err)
176 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
177 return err;
178}
179 135
136int __ext3_journal_dirty_metadata(const char *where,
137 handle_t *handle, struct buffer_head *bh);
180 138
181#define ext3_journal_get_undo_access(handle, bh) \ 139#define ext3_journal_get_undo_access(handle, bh) \
182 __ext3_journal_get_undo_access(__FUNCTION__, (handle), (bh)) 140 __ext3_journal_get_undo_access(__FUNCTION__, (handle), (bh))
diff --git a/include/linux/ext4_jbd2.h b/include/linux/ext4_jbd2.h
index 72dd631912e4..d716e6392cf6 100644
--- a/include/linux/ext4_jbd2.h
+++ b/include/linux/ext4_jbd2.h
@@ -114,74 +114,32 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode);
114 * been done yet. 114 * been done yet.
115 */ 115 */
116 116
117void ext4_journal_abort_handle(const char *caller, const char *err_fn, 117static inline void ext4_journal_release_buffer(handle_t *handle,
118 struct buffer_head *bh, handle_t *handle, int err); 118 struct buffer_head *bh)
119
120static inline int
121__ext4_journal_get_undo_access(const char *where, handle_t *handle,
122 struct buffer_head *bh)
123{ 119{
124 int err = jbd2_journal_get_undo_access(handle, bh); 120 jbd2_journal_release_buffer(handle, bh);
125 if (err)
126 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
127 return err;
128} 121}
129 122
130static inline int 123void ext4_journal_abort_handle(const char *caller, const char *err_fn,
131__ext4_journal_get_write_access(const char *where, handle_t *handle, 124 struct buffer_head *bh, handle_t *handle, int err);
132 struct buffer_head *bh)
133{
134 int err = jbd2_journal_get_write_access(handle, bh);
135 if (err)
136 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
137 return err;
138}
139 125
140static inline void 126int __ext4_journal_get_undo_access(const char *where, handle_t *handle,
141ext4_journal_release_buffer(handle_t *handle, struct buffer_head *bh) 127 struct buffer_head *bh);
142{
143 jbd2_journal_release_buffer(handle, bh);
144}
145 128
146static inline int 129int __ext4_journal_get_write_access(const char *where, handle_t *handle,
147__ext4_journal_forget(const char *where, handle_t *handle, struct buffer_head *bh) 130 struct buffer_head *bh);
148{
149 int err = jbd2_journal_forget(handle, bh);
150 if (err)
151 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
152 return err;
153}
154 131
155static inline int 132int __ext4_journal_forget(const char *where, handle_t *handle,
156__ext4_journal_revoke(const char *where, handle_t *handle, 133 struct buffer_head *bh);
157 ext4_fsblk_t blocknr, struct buffer_head *bh)
158{
159 int err = jbd2_journal_revoke(handle, blocknr, bh);
160 if (err)
161 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
162 return err;
163}
164 134
165static inline int 135int __ext4_journal_revoke(const char *where, handle_t *handle,
166__ext4_journal_get_create_access(const char *where, 136 ext4_fsblk_t blocknr, struct buffer_head *bh);
167 handle_t *handle, struct buffer_head *bh)
168{
169 int err = jbd2_journal_get_create_access(handle, bh);
170 if (err)
171 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
172 return err;
173}
174 137
175static inline int 138int __ext4_journal_get_create_access(const char *where,
176__ext4_journal_dirty_metadata(const char *where, 139 handle_t *handle, struct buffer_head *bh);
177 handle_t *handle, struct buffer_head *bh)
178{
179 int err = jbd2_journal_dirty_metadata(handle, bh);
180 if (err)
181 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
182 return err;
183}
184 140
141int __ext4_journal_dirty_metadata(const char *where,
142 handle_t *handle, struct buffer_head *bh);
185 143
186#define ext4_journal_get_undo_access(handle, bh) \ 144#define ext4_journal_get_undo_access(handle, bh) \
187 __ext4_journal_get_undo_access(__FUNCTION__, (handle), (bh)) 145 __ext4_journal_get_undo_access(__FUNCTION__, (handle), (bh))
diff --git a/include/linux/file.h b/include/linux/file.h
index 74183e6f7f45..6e77b9177f9e 100644
--- a/include/linux/file.h
+++ b/include/linux/file.h
@@ -64,6 +64,8 @@ struct files_struct {
64 64
65#define files_fdtable(files) (rcu_dereference((files)->fdt)) 65#define files_fdtable(files) (rcu_dereference((files)->fdt))
66 66
67extern struct kmem_cache *filp_cachep;
68
67extern void FASTCALL(__fput(struct file *)); 69extern void FASTCALL(__fput(struct file *));
68extern void FASTCALL(fput(struct file *)); 70extern void FASTCALL(fput(struct file *));
69 71
@@ -114,4 +116,6 @@ struct files_struct *get_files_struct(struct task_struct *);
114void FASTCALL(put_files_struct(struct files_struct *fs)); 116void FASTCALL(put_files_struct(struct files_struct *fs));
115void reset_files_struct(struct task_struct *, struct files_struct *); 117void reset_files_struct(struct task_struct *, struct files_struct *);
116 118
119extern struct kmem_cache *files_cachep;
120
117#endif /* __LINUX_FILE_H */ 121#endif /* __LINUX_FILE_H */
diff --git a/include/linux/freezer.h b/include/linux/freezer.h
new file mode 100644
index 000000000000..6e05e3e7ce39
--- /dev/null
+++ b/include/linux/freezer.h
@@ -0,0 +1,87 @@
1/* Freezer declarations */
2
3#ifdef CONFIG_PM
4/*
5 * Check if a process has been frozen
6 */
7static inline int frozen(struct task_struct *p)
8{
9 return p->flags & PF_FROZEN;
10}
11
12/*
13 * Check if there is a request to freeze a process
14 */
15static inline int freezing(struct task_struct *p)
16{
17 return p->flags & PF_FREEZE;
18}
19
20/*
21 * Request that a process be frozen
22 * FIXME: SMP problem. We may not modify other process' flags!
23 */
24static inline void freeze(struct task_struct *p)
25{
26 p->flags |= PF_FREEZE;
27}
28
29/*
30 * Sometimes we may need to cancel the previous 'freeze' request
31 */
32static inline void do_not_freeze(struct task_struct *p)
33{
34 p->flags &= ~PF_FREEZE;
35}
36
37/*
38 * Wake up a frozen process
39 */
40static inline int thaw_process(struct task_struct *p)
41{
42 if (frozen(p)) {
43 p->flags &= ~PF_FROZEN;
44 wake_up_process(p);
45 return 1;
46 }
47 return 0;
48}
49
50/*
51 * freezing is complete, mark process as frozen
52 */
53static inline void frozen_process(struct task_struct *p)
54{
55 p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN;
56}
57
58extern void refrigerator(void);
59extern int freeze_processes(void);
60extern void thaw_processes(void);
61
62static inline int try_to_freeze(void)
63{
64 if (freezing(current)) {
65 refrigerator();
66 return 1;
67 } else
68 return 0;
69}
70
71extern void thaw_some_processes(int all);
72
73#else
74static inline int frozen(struct task_struct *p) { return 0; }
75static inline int freezing(struct task_struct *p) { return 0; }
76static inline void freeze(struct task_struct *p) { BUG(); }
77static inline int thaw_process(struct task_struct *p) { return 1; }
78static inline void frozen_process(struct task_struct *p) { BUG(); }
79
80static inline void refrigerator(void) {}
81static inline int freeze_processes(void) { BUG(); return 0; }
82static inline void thaw_processes(void) {}
83
84static inline int try_to_freeze(void) { return 0; }
85
86
87#endif
diff --git a/include/linux/fs.h b/include/linux/fs.h
index cac7b1ef9543..70b99fbb560b 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -543,19 +543,22 @@ struct inode {
543 struct list_head i_dentry; 543 struct list_head i_dentry;
544 unsigned long i_ino; 544 unsigned long i_ino;
545 atomic_t i_count; 545 atomic_t i_count;
546 umode_t i_mode;
547 unsigned int i_nlink; 546 unsigned int i_nlink;
548 uid_t i_uid; 547 uid_t i_uid;
549 gid_t i_gid; 548 gid_t i_gid;
550 dev_t i_rdev; 549 dev_t i_rdev;
550 unsigned long i_version;
551 loff_t i_size; 551 loff_t i_size;
552#ifdef __NEED_I_SIZE_ORDERED
553 seqcount_t i_size_seqcount;
554#endif
552 struct timespec i_atime; 555 struct timespec i_atime;
553 struct timespec i_mtime; 556 struct timespec i_mtime;
554 struct timespec i_ctime; 557 struct timespec i_ctime;
555 unsigned int i_blkbits; 558 unsigned int i_blkbits;
556 unsigned long i_version;
557 blkcnt_t i_blocks; 559 blkcnt_t i_blocks;
558 unsigned short i_bytes; 560 unsigned short i_bytes;
561 umode_t i_mode;
559 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */ 562 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
560 struct mutex i_mutex; 563 struct mutex i_mutex;
561 struct rw_semaphore i_alloc_sem; 564 struct rw_semaphore i_alloc_sem;
@@ -598,9 +601,6 @@ struct inode {
598 void *i_security; 601 void *i_security;
599#endif 602#endif
600 void *i_private; /* fs or device private pointer */ 603 void *i_private; /* fs or device private pointer */
601#ifdef __NEED_I_SIZE_ORDERED
602 seqcount_t i_size_seqcount;
603#endif
604}; 604};
605 605
606/* 606/*
@@ -636,7 +636,7 @@ extern void inode_double_unlock(struct inode *inode1, struct inode *inode2);
636 * cmpxchg8b without the need of the lock prefix). For SMP compiles 636 * cmpxchg8b without the need of the lock prefix). For SMP compiles
637 * and 64bit archs it makes no difference if preempt is enabled or not. 637 * and 64bit archs it makes no difference if preempt is enabled or not.
638 */ 638 */
639static inline loff_t i_size_read(struct inode *inode) 639static inline loff_t i_size_read(const struct inode *inode)
640{ 640{
641#if BITS_PER_LONG==32 && defined(CONFIG_SMP) 641#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
642 loff_t i_size; 642 loff_t i_size;
@@ -679,12 +679,12 @@ static inline void i_size_write(struct inode *inode, loff_t i_size)
679#endif 679#endif
680} 680}
681 681
682static inline unsigned iminor(struct inode *inode) 682static inline unsigned iminor(const struct inode *inode)
683{ 683{
684 return MINOR(inode->i_rdev); 684 return MINOR(inode->i_rdev);
685} 685}
686 686
687static inline unsigned imajor(struct inode *inode) 687static inline unsigned imajor(const struct inode *inode)
688{ 688{
689 return MAJOR(inode->i_rdev); 689 return MAJOR(inode->i_rdev);
690} 690}
@@ -1481,7 +1481,9 @@ extern char * getname(const char __user *);
1481extern void __init vfs_caches_init_early(void); 1481extern void __init vfs_caches_init_early(void);
1482extern void __init vfs_caches_init(unsigned long); 1482extern void __init vfs_caches_init(unsigned long);
1483 1483
1484#define __getname() kmem_cache_alloc(names_cachep, SLAB_KERNEL) 1484extern struct kmem_cache *names_cachep;
1485
1486#define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL)
1485#define __putname(name) kmem_cache_free(names_cachep, (void *)(name)) 1487#define __putname(name) kmem_cache_free(names_cachep, (void *)(name))
1486#ifndef CONFIG_AUDITSYSCALL 1488#ifndef CONFIG_AUDITSYSCALL
1487#define putname(name) __putname(name) 1489#define putname(name) __putname(name)
diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
index c623d12a486e..11a36ceddf73 100644
--- a/include/linux/fs_struct.h
+++ b/include/linux/fs_struct.h
@@ -18,6 +18,8 @@ struct fs_struct {
18 .umask = 0022, \ 18 .umask = 0022, \
19} 19}
20 20
21extern struct kmem_cache *fs_cachep;
22
21extern void exit_fs(struct task_struct *); 23extern void exit_fs(struct task_struct *);
22extern void set_fs_altroot(void); 24extern void set_fs_altroot(void);
23extern void set_fs_root(struct fs_struct *, struct vfsmount *, struct dentry *); 25extern void set_fs_root(struct fs_struct *, struct vfsmount *, struct dentry *);
diff --git a/include/linux/fuse.h b/include/linux/fuse.h
index 9fc48a674b82..534744efe30d 100644
--- a/include/linux/fuse.h
+++ b/include/linux/fuse.h
@@ -15,7 +15,7 @@
15#define FUSE_KERNEL_VERSION 7 15#define FUSE_KERNEL_VERSION 7
16 16
17/** Minor version number of this interface */ 17/** Minor version number of this interface */
18#define FUSE_KERNEL_MINOR_VERSION 7 18#define FUSE_KERNEL_MINOR_VERSION 8
19 19
20/** The node ID of the root inode */ 20/** The node ID of the root inode */
21#define FUSE_ROOT_ID 1 21#define FUSE_ROOT_ID 1
@@ -92,6 +92,11 @@ struct fuse_file_lock {
92#define FUSE_ASYNC_READ (1 << 0) 92#define FUSE_ASYNC_READ (1 << 0)
93#define FUSE_POSIX_LOCKS (1 << 1) 93#define FUSE_POSIX_LOCKS (1 << 1)
94 94
95/**
96 * Release flags
97 */
98#define FUSE_RELEASE_FLUSH (1 << 0)
99
95enum fuse_opcode { 100enum fuse_opcode {
96 FUSE_LOOKUP = 1, 101 FUSE_LOOKUP = 1,
97 FUSE_FORGET = 2, /* no reply */ 102 FUSE_FORGET = 2, /* no reply */
@@ -127,6 +132,8 @@ enum fuse_opcode {
127 FUSE_ACCESS = 34, 132 FUSE_ACCESS = 34,
128 FUSE_CREATE = 35, 133 FUSE_CREATE = 35,
129 FUSE_INTERRUPT = 36, 134 FUSE_INTERRUPT = 36,
135 FUSE_BMAP = 37,
136 FUSE_DESTROY = 38,
130}; 137};
131 138
132/* The read buffer is required to be at least 8k, but may be much larger */ 139/* The read buffer is required to be at least 8k, but may be much larger */
@@ -205,12 +212,13 @@ struct fuse_open_out {
205struct fuse_release_in { 212struct fuse_release_in {
206 __u64 fh; 213 __u64 fh;
207 __u32 flags; 214 __u32 flags;
208 __u32 padding; 215 __u32 release_flags;
216 __u64 lock_owner;
209}; 217};
210 218
211struct fuse_flush_in { 219struct fuse_flush_in {
212 __u64 fh; 220 __u64 fh;
213 __u32 flush_flags; 221 __u32 unused;
214 __u32 padding; 222 __u32 padding;
215 __u64 lock_owner; 223 __u64 lock_owner;
216}; 224};
@@ -296,6 +304,16 @@ struct fuse_interrupt_in {
296 __u64 unique; 304 __u64 unique;
297}; 305};
298 306
307struct fuse_bmap_in {
308 __u64 block;
309 __u32 blocksize;
310 __u32 padding;
311};
312
313struct fuse_bmap_out {
314 __u64 block;
315};
316
299struct fuse_in_header { 317struct fuse_in_header {
300 __u32 len; 318 __u32 len;
301 __u32 opcode; 319 __u32 opcode;
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index bf2b6bc3f6fd..00c314aedab7 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -116,6 +116,9 @@ static inline enum zone_type gfp_zone(gfp_t flags)
116#ifndef HAVE_ARCH_FREE_PAGE 116#ifndef HAVE_ARCH_FREE_PAGE
117static inline void arch_free_page(struct page *page, int order) { } 117static inline void arch_free_page(struct page *page, int order) { }
118#endif 118#endif
119#ifndef HAVE_ARCH_ALLOC_PAGE
120static inline void arch_alloc_page(struct page *page, int order) { }
121#endif
119 122
120extern struct page * 123extern struct page *
121FASTCALL(__alloc_pages(gfp_t, unsigned int, struct zonelist *)); 124FASTCALL(__alloc_pages(gfp_t, unsigned int, struct zonelist *));
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index fd7d12daa94f..3d8768b619e9 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/fs.h> 4#include <linux/fs.h>
5#include <linux/mm.h> 5#include <linux/mm.h>
6#include <linux/uaccess.h>
6 7
7#include <asm/cacheflush.h> 8#include <asm/cacheflush.h>
8 9
@@ -41,9 +42,10 @@ static inline void *kmap(struct page *page)
41 42
42#define kunmap(page) do { (void) (page); } while (0) 43#define kunmap(page) do { (void) (page); } while (0)
43 44
44#define kmap_atomic(page, idx) page_address(page) 45#define kmap_atomic(page, idx) \
45#define kunmap_atomic(addr, idx) do { } while (0) 46 ({ pagefault_disable(); page_address(page); })
46#define kmap_atomic_pfn(pfn, idx) page_address(pfn_to_page(pfn)) 47#define kunmap_atomic(addr, idx) do { pagefault_enable(); } while (0)
48#define kmap_atomic_pfn(pfn, idx) kmap_atomic(pfn_to_page(pfn), (idx))
47#define kmap_atomic_to_page(ptr) virt_to_page(ptr) 49#define kmap_atomic_to_page(ptr) virt_to_page(ptr)
48#endif 50#endif
49 51
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index ace64e57e17f..a60995afe334 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -35,6 +35,7 @@ extern int sysctl_hugetlb_shm_group;
35 35
36pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr); 36pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr);
37pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr); 37pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr);
38int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep);
38struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address, 39struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address,
39 int write); 40 int write);
40struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address, 41struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
diff --git a/include/linux/i2o.h b/include/linux/i2o.h
index c115e9e840b4..52f53e2e70c3 100644
--- a/include/linux/i2o.h
+++ b/include/linux/i2o.h
@@ -461,7 +461,7 @@ struct i2o_driver {
461 int (*reply) (struct i2o_controller *, u32, struct i2o_message *); 461 int (*reply) (struct i2o_controller *, u32, struct i2o_message *);
462 462
463 /* Event handler */ 463 /* Event handler */
464 void (*event) (struct i2o_event *); 464 work_func_t event;
465 465
466 struct workqueue_struct *event_queue; /* Event queue */ 466 struct workqueue_struct *event_queue; /* Event queue */
467 467
@@ -490,7 +490,7 @@ struct i2o_dma {
490 */ 490 */
491struct i2o_pool { 491struct i2o_pool {
492 char *name; 492 char *name;
493 kmem_cache_t *slab; 493 struct kmem_cache *slab;
494 mempool_t *mempool; 494 mempool_t *mempool;
495}; 495};
496 496
@@ -986,7 +986,8 @@ extern void i2o_driver_unregister(struct i2o_driver *);
986 986
987/** 987/**
988 * i2o_driver_notify_controller_add - Send notification of added controller 988 * i2o_driver_notify_controller_add - Send notification of added controller
989 * to a single I2O driver 989 * @drv: I2O driver
990 * @c: I2O controller
990 * 991 *
991 * Send notification of added controller to a single registered driver. 992 * Send notification of added controller to a single registered driver.
992 */ 993 */
@@ -998,8 +999,9 @@ static inline void i2o_driver_notify_controller_add(struct i2o_driver *drv,
998}; 999};
999 1000
1000/** 1001/**
1001 * i2o_driver_notify_controller_remove - Send notification of removed 1002 * i2o_driver_notify_controller_remove - Send notification of removed controller
1002 * controller to a single I2O driver 1003 * @drv: I2O driver
1004 * @c: I2O controller
1003 * 1005 *
1004 * Send notification of removed controller to a single registered driver. 1006 * Send notification of removed controller to a single registered driver.
1005 */ 1007 */
@@ -1011,8 +1013,9 @@ static inline void i2o_driver_notify_controller_remove(struct i2o_driver *drv,
1011}; 1013};
1012 1014
1013/** 1015/**
1014 * i2o_driver_notify_device_add - Send notification of added device to a 1016 * i2o_driver_notify_device_add - Send notification of added device
1015 * single I2O driver 1017 * @drv: I2O driver
1018 * @i2o_dev: the added i2o_device
1016 * 1019 *
1017 * Send notification of added device to a single registered driver. 1020 * Send notification of added device to a single registered driver.
1018 */ 1021 */
@@ -1025,7 +1028,8 @@ static inline void i2o_driver_notify_device_add(struct i2o_driver *drv,
1025 1028
1026/** 1029/**
1027 * i2o_driver_notify_device_remove - Send notification of removed device 1030 * i2o_driver_notify_device_remove - Send notification of removed device
1028 * to a single I2O driver 1031 * @drv: I2O driver
1032 * @i2o_dev: the added i2o_device
1029 * 1033 *
1030 * Send notification of removed device to a single registered driver. 1034 * Send notification of removed device to a single registered driver.
1031 */ 1035 */
@@ -1148,7 +1152,7 @@ static inline void i2o_msg_post(struct i2o_controller *c,
1148/** 1152/**
1149 * i2o_msg_post_wait - Post and wait a message and wait until return 1153 * i2o_msg_post_wait - Post and wait a message and wait until return
1150 * @c: controller 1154 * @c: controller
1151 * @m: message to post 1155 * @msg: message to post
1152 * @timeout: time in seconds to wait 1156 * @timeout: time in seconds to wait
1153 * 1157 *
1154 * This API allows an OSM to post a message and then be told whether or 1158 * This API allows an OSM to post a message and then be told whether or
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 33c5daacc743..733790d4f7db 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -73,7 +73,7 @@
73extern struct nsproxy init_nsproxy; 73extern struct nsproxy init_nsproxy;
74#define INIT_NSPROXY(nsproxy) { \ 74#define INIT_NSPROXY(nsproxy) { \
75 .count = ATOMIC_INIT(1), \ 75 .count = ATOMIC_INIT(1), \
76 .nslock = SPIN_LOCK_UNLOCKED, \ 76 .nslock = __SPIN_LOCK_UNLOCKED(nsproxy.nslock), \
77 .uts_ns = &init_uts_ns, \ 77 .uts_ns = &init_uts_ns, \
78 .namespace = NULL, \ 78 .namespace = NULL, \
79 INIT_IPC_NS(ipc_ns) \ 79 INIT_IPC_NS(ipc_ns) \
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 5b83e7b59621..de7593f4e895 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -11,6 +11,7 @@
11#include <linux/hardirq.h> 11#include <linux/hardirq.h>
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <linux/irqflags.h> 13#include <linux/irqflags.h>
14#include <linux/bottom_half.h>
14#include <asm/atomic.h> 15#include <asm/atomic.h>
15#include <asm/ptrace.h> 16#include <asm/ptrace.h>
16#include <asm/system.h> 17#include <asm/system.h>
@@ -217,12 +218,6 @@ static inline void __deprecated save_and_cli(unsigned long *x)
217#define save_and_cli(x) save_and_cli(&x) 218#define save_and_cli(x) save_and_cli(&x)
218#endif /* CONFIG_SMP */ 219#endif /* CONFIG_SMP */
219 220
220extern void local_bh_disable(void);
221extern void __local_bh_enable(void);
222extern void _local_bh_enable(void);
223extern void local_bh_enable(void);
224extern void local_bh_enable_ip(unsigned long ip);
225
226/* PLEASE, avoid to allocate new softirqs, if you need not _really_ high 221/* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
227 frequency threaded job scheduling. For almost all the purposes 222 frequency threaded job scheduling. For almost all the purposes
228 tasklets are more than enough. F.e. all serial device BHs et 223 tasklets are more than enough. F.e. all serial device BHs et
diff --git a/include/linux/ipmi.h b/include/linux/ipmi.h
index 796ca009fd46..7a9db390c56a 100644
--- a/include/linux/ipmi.h
+++ b/include/linux/ipmi.h
@@ -208,6 +208,15 @@ struct kernel_ipmi_msg
208 code as the first byte of the incoming data, unlike a response. */ 208 code as the first byte of the incoming data, unlike a response. */
209 209
210 210
211/*
212 * Modes for ipmi_set_maint_mode() and the userland IOCTL. The AUTO
213 * setting is the default and means it will be set on certain
214 * commands. Hard setting it on and off will override automatic
215 * operation.
216 */
217#define IPMI_MAINTENANCE_MODE_AUTO 0
218#define IPMI_MAINTENANCE_MODE_OFF 1
219#define IPMI_MAINTENANCE_MODE_ON 2
211 220
212#ifdef __KERNEL__ 221#ifdef __KERNEL__
213 222
@@ -374,6 +383,35 @@ int ipmi_unregister_for_cmd(ipmi_user_t user,
374 unsigned int chans); 383 unsigned int chans);
375 384
376/* 385/*
386 * Go into a mode where the driver will not autonomously attempt to do
387 * things with the interface. It will still respond to attentions and
388 * interrupts, and it will expect that commands will complete. It
389 * will not automatcially check for flags, events, or things of that
390 * nature.
391 *
392 * This is primarily used for firmware upgrades. The idea is that
393 * when you go into firmware upgrade mode, you do this operation
394 * and the driver will not attempt to do anything but what you tell
395 * it or what the BMC asks for.
396 *
397 * Note that if you send a command that resets the BMC, the driver
398 * will still expect a response from that command. So the BMC should
399 * reset itself *after* the response is sent. Resetting before the
400 * response is just silly.
401 *
402 * If in auto maintenance mode, the driver will automatically go into
403 * maintenance mode for 30 seconds if it sees a cold reset, a warm
404 * reset, or a firmware NetFN. This means that code that uses only
405 * firmware NetFN commands to do upgrades will work automatically
406 * without change, assuming it sends a message every 30 seconds or
407 * less.
408 *
409 * See the IPMI_MAINTENANCE_MODE_xxx defines for what the mode means.
410 */
411int ipmi_get_maintenance_mode(ipmi_user_t user);
412int ipmi_set_maintenance_mode(ipmi_user_t user, int mode);
413
414/*
377 * Allow run-to-completion mode to be set for the interface of 415 * Allow run-to-completion mode to be set for the interface of
378 * a specific user. 416 * a specific user.
379 */ 417 */
@@ -656,4 +694,11 @@ struct ipmi_timing_parms
656#define IPMICTL_GET_TIMING_PARMS_CMD _IOR(IPMI_IOC_MAGIC, 23, \ 694#define IPMICTL_GET_TIMING_PARMS_CMD _IOR(IPMI_IOC_MAGIC, 23, \
657 struct ipmi_timing_parms) 695 struct ipmi_timing_parms)
658 696
697/*
698 * Set the maintenance mode. See ipmi_set_maintenance_mode() above
699 * for a description of what this does.
700 */
701#define IPMICTL_GET_MAINTENANCE_MODE_CMD _IOR(IPMI_IOC_MAGIC, 30, int)
702#define IPMICTL_SET_MAINTENANCE_MODE_CMD _IOW(IPMI_IOC_MAGIC, 31, int)
703
659#endif /* __LINUX_IPMI_H */ 704#endif /* __LINUX_IPMI_H */
diff --git a/include/linux/ipmi_msgdefs.h b/include/linux/ipmi_msgdefs.h
index 4d04d8b58a0a..b56a158d587a 100644
--- a/include/linux/ipmi_msgdefs.h
+++ b/include/linux/ipmi_msgdefs.h
@@ -46,6 +46,8 @@
46#define IPMI_NETFN_APP_REQUEST 0x06 46#define IPMI_NETFN_APP_REQUEST 0x06
47#define IPMI_NETFN_APP_RESPONSE 0x07 47#define IPMI_NETFN_APP_RESPONSE 0x07
48#define IPMI_GET_DEVICE_ID_CMD 0x01 48#define IPMI_GET_DEVICE_ID_CMD 0x01
49#define IPMI_COLD_RESET_CMD 0x02
50#define IPMI_WARM_RESET_CMD 0x03
49#define IPMI_CLEAR_MSG_FLAGS_CMD 0x30 51#define IPMI_CLEAR_MSG_FLAGS_CMD 0x30
50#define IPMI_GET_DEVICE_GUID_CMD 0x08 52#define IPMI_GET_DEVICE_GUID_CMD 0x08
51#define IPMI_GET_MSG_FLAGS_CMD 0x31 53#define IPMI_GET_MSG_FLAGS_CMD 0x31
@@ -60,20 +62,27 @@
60#define IPMI_NETFN_STORAGE_RESPONSE 0x0b 62#define IPMI_NETFN_STORAGE_RESPONSE 0x0b
61#define IPMI_ADD_SEL_ENTRY_CMD 0x44 63#define IPMI_ADD_SEL_ENTRY_CMD 0x44
62 64
65#define IPMI_NETFN_FIRMWARE_REQUEST 0x08
66#define IPMI_NETFN_FIRMWARE_RESPONSE 0x09
67
63/* The default slave address */ 68/* The default slave address */
64#define IPMI_BMC_SLAVE_ADDR 0x20 69#define IPMI_BMC_SLAVE_ADDR 0x20
65 70
66/* The BT interface on high-end HP systems supports up to 255 bytes in 71/* The BT interface on high-end HP systems supports up to 255 bytes in
67 * one transfer. Its "virtual" BMC supports some commands that are longer 72 * one transfer. Its "virtual" BMC supports some commands that are longer
68 * than 128 bytes. Use the full 256, plus NetFn/LUN, Cmd, cCode, plus 73 * than 128 bytes. Use the full 256, plus NetFn/LUN, Cmd, cCode, plus
69 * some overhead. It would be nice to base this on the "BT Capabilities" 74 * some overhead; it's not worth the effort to dynamically size this based
70 * but that's too hard to propagate to the rest of the driver. */ 75 * on the results of the "Get BT Capabilities" command. */
71#define IPMI_MAX_MSG_LENGTH 272 /* multiple of 16 */ 76#define IPMI_MAX_MSG_LENGTH 272 /* multiple of 16 */
72 77
73#define IPMI_CC_NO_ERROR 0x00 78#define IPMI_CC_NO_ERROR 0x00
74#define IPMI_NODE_BUSY_ERR 0xc0 79#define IPMI_NODE_BUSY_ERR 0xc0
75#define IPMI_INVALID_COMMAND_ERR 0xc1 80#define IPMI_INVALID_COMMAND_ERR 0xc1
81#define IPMI_TIMEOUT_ERR 0xc3
76#define IPMI_ERR_MSG_TRUNCATED 0xc6 82#define IPMI_ERR_MSG_TRUNCATED 0xc6
83#define IPMI_REQ_LEN_INVALID_ERR 0xc7
84#define IPMI_REQ_LEN_EXCEEDED_ERR 0xc8
85#define IPMI_NOT_IN_MY_STATE_ERR 0xd5 /* IPMI 2.0 */
77#define IPMI_LOST_ARBITRATION_ERR 0x81 86#define IPMI_LOST_ARBITRATION_ERR 0x81
78#define IPMI_BUS_ERR 0x82 87#define IPMI_BUS_ERR 0x82
79#define IPMI_NAK_ON_WRITE_ERR 0x83 88#define IPMI_NAK_ON_WRITE_ERR 0x83
diff --git a/include/linux/ipmi_smi.h b/include/linux/ipmi_smi.h
index 6d9c7e4da472..c0633108d05d 100644
--- a/include/linux/ipmi_smi.h
+++ b/include/linux/ipmi_smi.h
@@ -115,6 +115,13 @@ struct ipmi_smi_handlers
115 poll for operations during things like crash dumps. */ 115 poll for operations during things like crash dumps. */
116 void (*poll)(void *send_info); 116 void (*poll)(void *send_info);
117 117
118 /* Enable/disable firmware maintenance mode. Note that this
119 is *not* the modes defined, this is simply an on/off
120 setting. The message handler does the mode handling. Note
121 that this is called from interupt context, so it cannot
122 block. */
123 void (*set_maintenance_mode)(void *send_info, int enable);
124
118 /* Tell the handler that we are using it/not using it. The 125 /* Tell the handler that we are using it/not using it. The
119 message handler get the modules that this handler belongs 126 message handler get the modules that this handler belongs
120 to; this function lets the SMI claim any modules that it 127 to; this function lets the SMI claim any modules that it
@@ -173,6 +180,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
173 void *send_info, 180 void *send_info,
174 struct ipmi_device_id *device_id, 181 struct ipmi_device_id *device_id,
175 struct device *dev, 182 struct device *dev,
183 const char *sysfs_name,
176 unsigned char slave_addr); 184 unsigned char slave_addr);
177 185
178/* 186/*
diff --git a/include/linux/jbd.h b/include/linux/jbd.h
index fe89444b1c6f..452737551260 100644
--- a/include/linux/jbd.h
+++ b/include/linux/jbd.h
@@ -839,7 +839,6 @@ struct journal_s
839 */ 839 */
840 840
841/* Filing buffers */ 841/* Filing buffers */
842extern void __journal_temp_unlink_buffer(struct journal_head *jh);
843extern void journal_unfile_buffer(journal_t *, struct journal_head *); 842extern void journal_unfile_buffer(journal_t *, struct journal_head *);
844extern void __journal_unfile_buffer(struct journal_head *); 843extern void __journal_unfile_buffer(struct journal_head *);
845extern void __journal_refile_buffer(struct journal_head *); 844extern void __journal_refile_buffer(struct journal_head *);
@@ -949,7 +948,7 @@ void journal_put_journal_head(struct journal_head *jh);
949/* 948/*
950 * handle management 949 * handle management
951 */ 950 */
952extern kmem_cache_t *jbd_handle_cache; 951extern struct kmem_cache *jbd_handle_cache;
953 952
954static inline handle_t *jbd_alloc_handle(gfp_t gfp_flags) 953static inline handle_t *jbd_alloc_handle(gfp_t gfp_flags)
955{ 954{
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index ddb128795781..0e0fedd2039a 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -848,7 +848,6 @@ struct journal_s
848 */ 848 */
849 849
850/* Filing buffers */ 850/* Filing buffers */
851extern void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh);
852extern void jbd2_journal_unfile_buffer(journal_t *, struct journal_head *); 851extern void jbd2_journal_unfile_buffer(journal_t *, struct journal_head *);
853extern void __jbd2_journal_unfile_buffer(struct journal_head *); 852extern void __jbd2_journal_unfile_buffer(struct journal_head *);
854extern void __jbd2_journal_refile_buffer(struct journal_head *); 853extern void __jbd2_journal_refile_buffer(struct journal_head *);
@@ -958,7 +957,7 @@ void jbd2_journal_put_journal_head(struct journal_head *jh);
958/* 957/*
959 * handle management 958 * handle management
960 */ 959 */
961extern kmem_cache_t *jbd2_handle_cache; 960extern struct kmem_cache *jbd2_handle_cache;
962 961
963static inline handle_t *jbd_alloc_handle(gfp_t gfp_flags) 962static inline handle_t *jbd_alloc_handle(gfp_t gfp_flags)
964{ 963{
diff --git a/include/linux/kbd_kern.h b/include/linux/kbd_kern.h
index efe0ee4cc80b..06c58c423fe1 100644
--- a/include/linux/kbd_kern.h
+++ b/include/linux/kbd_kern.h
@@ -158,7 +158,7 @@ static inline void con_schedule_flip(struct tty_struct *t)
158 if (t->buf.tail != NULL) 158 if (t->buf.tail != NULL)
159 t->buf.tail->commit = t->buf.tail->used; 159 t->buf.tail->commit = t->buf.tail->used;
160 spin_unlock_irqrestore(&t->buf.lock, flags); 160 spin_unlock_irqrestore(&t->buf.lock, flags);
161 schedule_work(&t->buf.work); 161 schedule_delayed_work(&t->buf.work, 0);
162} 162}
163 163
164#endif 164#endif
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index a4ede62b339d..e3abcec6c51c 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -105,6 +105,7 @@ extern struct page *kimage_alloc_control_pages(struct kimage *image,
105 unsigned int order); 105 unsigned int order);
106extern void crash_kexec(struct pt_regs *); 106extern void crash_kexec(struct pt_regs *);
107int kexec_should_crash(struct task_struct *); 107int kexec_should_crash(struct task_struct *);
108void crash_save_cpu(struct pt_regs *regs, int cpu);
108extern struct kimage *kexec_image; 109extern struct kimage *kexec_image;
109extern struct kimage *kexec_crash_image; 110extern struct kimage *kexec_crash_image;
110 111
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index ac4c0559f751..769be39b9681 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -165,7 +165,7 @@ extern void arch_disarm_kprobe(struct kprobe *p);
165extern int arch_init_kprobes(void); 165extern int arch_init_kprobes(void);
166extern void show_registers(struct pt_regs *regs); 166extern void show_registers(struct pt_regs *regs);
167extern kprobe_opcode_t *get_insn_slot(void); 167extern kprobe_opcode_t *get_insn_slot(void);
168extern void free_insn_slot(kprobe_opcode_t *slot); 168extern void free_insn_slot(kprobe_opcode_t *slot, int dirty);
169extern void kprobes_inc_nmissed_count(struct kprobe *p); 169extern void kprobes_inc_nmissed_count(struct kprobe *p);
170 170
171/* Get the kprobe at this addr (if any) - called with preemption disabled */ 171/* Get the kprobe at this addr (if any) - called with preemption disabled */
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 84eeecd60a02..611f17f79eef 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -248,9 +248,9 @@ static inline struct timeval ktime_to_timeval(const ktime_t kt)
248 * 248 *
249 * Returns the scalar nanoseconds representation of kt 249 * Returns the scalar nanoseconds representation of kt
250 */ 250 */
251static inline u64 ktime_to_ns(const ktime_t kt) 251static inline s64 ktime_to_ns(const ktime_t kt)
252{ 252{
253 return (u64) kt.tv.sec * NSEC_PER_SEC + kt.tv.nsec; 253 return (s64) kt.tv.sec * NSEC_PER_SEC + kt.tv.nsec;
254} 254}
255 255
256#endif 256#endif
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 202283b5df96..ab2754830322 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -575,8 +575,9 @@ struct ata_port {
575 struct ata_host *host; 575 struct ata_host *host;
576 struct device *dev; 576 struct device *dev;
577 577
578 struct work_struct port_task; 578 void *port_task_data;
579 struct work_struct hotplug_task; 579 struct delayed_work port_task;
580 struct delayed_work hotplug_task;
580 struct work_struct scsi_rescan_task; 581 struct work_struct scsi_rescan_task;
581 582
582 unsigned int hsm_task_state; 583 unsigned int hsm_task_state;
@@ -755,7 +756,7 @@ extern void ata_host_resume(struct ata_host *host);
755extern int ata_ratelimit(void); 756extern int ata_ratelimit(void);
756extern int ata_busy_sleep(struct ata_port *ap, 757extern int ata_busy_sleep(struct ata_port *ap,
757 unsigned long timeout_pat, unsigned long timeout); 758 unsigned long timeout_pat, unsigned long timeout);
758extern void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), 759extern void ata_port_queue_task(struct ata_port *ap, work_func_t fn,
759 void *data, unsigned long delay); 760 void *data, unsigned long delay);
760extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, 761extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
761 unsigned long interval_msec, 762 unsigned long interval_msec,
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 862d9730a60d..8c39654549d8 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -164,14 +164,12 @@ void nlmclnt_next_cookie(struct nlm_cookie *);
164 */ 164 */
165struct nlm_host * nlmclnt_lookup_host(const struct sockaddr_in *, int, int, const char *, int); 165struct nlm_host * nlmclnt_lookup_host(const struct sockaddr_in *, int, int, const char *, int);
166struct nlm_host * nlmsvc_lookup_host(struct svc_rqst *, const char *, int); 166struct nlm_host * nlmsvc_lookup_host(struct svc_rqst *, const char *, int);
167struct nlm_host * nlm_lookup_host(int server, const struct sockaddr_in *, int, int, const char *, int);
168struct rpc_clnt * nlm_bind_host(struct nlm_host *); 167struct rpc_clnt * nlm_bind_host(struct nlm_host *);
169void nlm_rebind_host(struct nlm_host *); 168void nlm_rebind_host(struct nlm_host *);
170struct nlm_host * nlm_get_host(struct nlm_host *); 169struct nlm_host * nlm_get_host(struct nlm_host *);
171void nlm_release_host(struct nlm_host *); 170void nlm_release_host(struct nlm_host *);
172void nlm_shutdown_hosts(void); 171void nlm_shutdown_hosts(void);
173extern void nlm_host_rebooted(const struct sockaddr_in *, const char *, int, u32); 172extern void nlm_host_rebooted(const struct sockaddr_in *, const char *, int, u32);
174struct nsm_handle *nsm_find(const struct sockaddr_in *, const char *, int);
175void nsm_release(struct nsm_handle *); 173void nsm_release(struct nsm_handle *);
176 174
177 175
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 819f08f1310d..498bfbd3b4e1 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -193,7 +193,6 @@ extern void lockdep_free_key_range(void *start, unsigned long size);
193 193
194extern void lockdep_off(void); 194extern void lockdep_off(void);
195extern void lockdep_on(void); 195extern void lockdep_on(void);
196extern int lockdep_internal(void);
197 196
198/* 197/*
199 * These methods are used by specific locking variants (spinlocks, 198 * These methods are used by specific locking variants (spinlocks,
@@ -243,6 +242,8 @@ extern void lock_release(struct lockdep_map *lock, int nested,
243 242
244# define INIT_LOCKDEP .lockdep_recursion = 0, 243# define INIT_LOCKDEP .lockdep_recursion = 0,
245 244
245#define lockdep_depth(tsk) ((tsk)->lockdep_depth)
246
246#else /* !LOCKDEP */ 247#else /* !LOCKDEP */
247 248
248static inline void lockdep_off(void) 249static inline void lockdep_off(void)
@@ -253,11 +254,6 @@ static inline void lockdep_on(void)
253{ 254{
254} 255}
255 256
256static inline int lockdep_internal(void)
257{
258 return 0;
259}
260
261# define lock_acquire(l, s, t, r, c, i) do { } while (0) 257# define lock_acquire(l, s, t, r, c, i) do { } while (0)
262# define lock_release(l, n, i) do { } while (0) 258# define lock_release(l, n, i) do { } while (0)
263# define lockdep_init() do { } while (0) 259# define lockdep_init() do { } while (0)
@@ -277,6 +273,9 @@ static inline int lockdep_internal(void)
277 * The class key takes no space if lockdep is disabled: 273 * The class key takes no space if lockdep is disabled:
278 */ 274 */
279struct lock_class_key { }; 275struct lock_class_key { };
276
277#define lockdep_depth(tsk) (0)
278
280#endif /* !LOCKDEP */ 279#endif /* !LOCKDEP */
281 280
282#if defined(CONFIG_TRACE_IRQFLAGS) && defined(CONFIG_GENERIC_HARDIRQS) 281#if defined(CONFIG_TRACE_IRQFLAGS) && defined(CONFIG_GENERIC_HARDIRQS)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index d538de901965..a17b147c61e7 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -114,6 +114,8 @@ struct vm_area_struct {
114#endif 114#endif
115}; 115};
116 116
117extern struct kmem_cache *vm_area_cachep;
118
117/* 119/*
118 * This struct defines the per-mm list of VMAs for uClinux. If CONFIG_MMU is 120 * This struct defines the per-mm list of VMAs for uClinux. If CONFIG_MMU is
119 * disabled, then there's a single shared list of VMAs maintained by the 121 * disabled, then there's a single shared list of VMAs maintained by the
@@ -294,6 +296,24 @@ void put_pages_list(struct list_head *pages);
294void split_page(struct page *page, unsigned int order); 296void split_page(struct page *page, unsigned int order);
295 297
296/* 298/*
299 * Compound pages have a destructor function. Provide a
300 * prototype for that function and accessor functions.
301 * These are _only_ valid on the head of a PG_compound page.
302 */
303typedef void compound_page_dtor(struct page *);
304
305static inline void set_compound_page_dtor(struct page *page,
306 compound_page_dtor *dtor)
307{
308 page[1].lru.next = (void *)dtor;
309}
310
311static inline compound_page_dtor *get_compound_page_dtor(struct page *page)
312{
313 return (compound_page_dtor *)page[1].lru.next;
314}
315
316/*
297 * Multiple processes may "see" the same page. E.g. for untouched 317 * Multiple processes may "see" the same page. E.g. for untouched
298 * mappings of /dev/null, all processes see the same page full of 318 * mappings of /dev/null, all processes see the same page full of
299 * zeroes, and text pages of executables and shared libraries have 319 * zeroes, and text pages of executables and shared libraries have
@@ -396,7 +416,9 @@ void split_page(struct page *page, unsigned int order);
396 * We are going to use the flags for the page to node mapping if its in 416 * We are going to use the flags for the page to node mapping if its in
397 * there. This includes the case where there is no node, so it is implicit. 417 * there. This includes the case where there is no node, so it is implicit.
398 */ 418 */
399#define FLAGS_HAS_NODE (NODES_WIDTH > 0 || NODES_SHIFT == 0) 419#if !(NODES_WIDTH > 0 || NODES_SHIFT == 0)
420#define NODE_NOT_IN_PAGE_FLAGS
421#endif
400 422
401#ifndef PFN_SECTION_SHIFT 423#ifndef PFN_SECTION_SHIFT
402#define PFN_SECTION_SHIFT 0 424#define PFN_SECTION_SHIFT 0
@@ -411,13 +433,18 @@ void split_page(struct page *page, unsigned int order);
411#define NODES_PGSHIFT (NODES_PGOFF * (NODES_WIDTH != 0)) 433#define NODES_PGSHIFT (NODES_PGOFF * (NODES_WIDTH != 0))
412#define ZONES_PGSHIFT (ZONES_PGOFF * (ZONES_WIDTH != 0)) 434#define ZONES_PGSHIFT (ZONES_PGOFF * (ZONES_WIDTH != 0))
413 435
414/* NODE:ZONE or SECTION:ZONE is used to lookup the zone from a page. */ 436/* NODE:ZONE or SECTION:ZONE is used to ID a zone for the buddy allcator */
415#if FLAGS_HAS_NODE 437#ifdef NODE_NOT_IN_PAGEFLAGS
416#define ZONETABLE_SHIFT (NODES_SHIFT + ZONES_SHIFT) 438#define ZONEID_SHIFT (SECTIONS_SHIFT + ZONES_SHIFT)
439#else
440#define ZONEID_SHIFT (NODES_SHIFT + ZONES_SHIFT)
441#endif
442
443#if ZONES_WIDTH > 0
444#define ZONEID_PGSHIFT ZONES_PGSHIFT
417#else 445#else
418#define ZONETABLE_SHIFT (SECTIONS_SHIFT + ZONES_SHIFT) 446#define ZONEID_PGSHIFT NODES_PGOFF
419#endif 447#endif
420#define ZONETABLE_PGSHIFT ZONES_PGSHIFT
421 448
422#if SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED 449#if SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED
423#error SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED 450#error SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED
@@ -426,26 +453,28 @@ void split_page(struct page *page, unsigned int order);
426#define ZONES_MASK ((1UL << ZONES_WIDTH) - 1) 453#define ZONES_MASK ((1UL << ZONES_WIDTH) - 1)
427#define NODES_MASK ((1UL << NODES_WIDTH) - 1) 454#define NODES_MASK ((1UL << NODES_WIDTH) - 1)
428#define SECTIONS_MASK ((1UL << SECTIONS_WIDTH) - 1) 455#define SECTIONS_MASK ((1UL << SECTIONS_WIDTH) - 1)
429#define ZONETABLE_MASK ((1UL << ZONETABLE_SHIFT) - 1) 456#define ZONEID_MASK ((1UL << ZONEID_SHIFT) - 1)
430 457
431static inline enum zone_type page_zonenum(struct page *page) 458static inline enum zone_type page_zonenum(struct page *page)
432{ 459{
433 return (page->flags >> ZONES_PGSHIFT) & ZONES_MASK; 460 return (page->flags >> ZONES_PGSHIFT) & ZONES_MASK;
434} 461}
435 462
436struct zone; 463/*
437extern struct zone *zone_table[]; 464 * The identification function is only used by the buddy allocator for
438 465 * determining if two pages could be buddies. We are not really
466 * identifying a zone since we could be using a the section number
467 * id if we have not node id available in page flags.
468 * We guarantee only that it will return the same value for two
469 * combinable pages in a zone.
470 */
439static inline int page_zone_id(struct page *page) 471static inline int page_zone_id(struct page *page)
440{ 472{
441 return (page->flags >> ZONETABLE_PGSHIFT) & ZONETABLE_MASK; 473 BUILD_BUG_ON(ZONEID_PGSHIFT == 0 && ZONEID_MASK);
442} 474 return (page->flags >> ZONEID_PGSHIFT) & ZONEID_MASK;
443static inline struct zone *page_zone(struct page *page)
444{
445 return zone_table[page_zone_id(page)];
446} 475}
447 476
448static inline unsigned long zone_to_nid(struct zone *zone) 477static inline int zone_to_nid(struct zone *zone)
449{ 478{
450#ifdef CONFIG_NUMA 479#ifdef CONFIG_NUMA
451 return zone->node; 480 return zone->node;
@@ -454,13 +483,20 @@ static inline unsigned long zone_to_nid(struct zone *zone)
454#endif 483#endif
455} 484}
456 485
457static inline unsigned long page_to_nid(struct page *page) 486#ifdef NODE_NOT_IN_PAGE_FLAGS
487extern int page_to_nid(struct page *page);
488#else
489static inline int page_to_nid(struct page *page)
490{
491 return (page->flags >> NODES_PGSHIFT) & NODES_MASK;
492}
493#endif
494
495static inline struct zone *page_zone(struct page *page)
458{ 496{
459 if (FLAGS_HAS_NODE) 497 return &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)];
460 return (page->flags >> NODES_PGSHIFT) & NODES_MASK;
461 else
462 return zone_to_nid(page_zone(page));
463} 498}
499
464static inline unsigned long page_to_section(struct page *page) 500static inline unsigned long page_to_section(struct page *page)
465{ 501{
466 return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK; 502 return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK;
@@ -477,6 +513,7 @@ static inline void set_page_node(struct page *page, unsigned long node)
477 page->flags &= ~(NODES_MASK << NODES_PGSHIFT); 513 page->flags &= ~(NODES_MASK << NODES_PGSHIFT);
478 page->flags |= (node & NODES_MASK) << NODES_PGSHIFT; 514 page->flags |= (node & NODES_MASK) << NODES_PGSHIFT;
479} 515}
516
480static inline void set_page_section(struct page *page, unsigned long section) 517static inline void set_page_section(struct page *page, unsigned long section)
481{ 518{
482 page->flags &= ~(SECTIONS_MASK << SECTIONS_PGSHIFT); 519 page->flags &= ~(SECTIONS_MASK << SECTIONS_PGSHIFT);
@@ -947,8 +984,6 @@ extern void mem_init(void);
947extern void show_mem(void); 984extern void show_mem(void);
948extern void si_meminfo(struct sysinfo * val); 985extern void si_meminfo(struct sysinfo * val);
949extern void si_meminfo_node(struct sysinfo *val, int nid); 986extern void si_meminfo_node(struct sysinfo *val, int nid);
950extern void zonetable_add(struct zone *zone, int nid, enum zone_type zid,
951 unsigned long pfn, unsigned long size);
952 987
953#ifdef CONFIG_NUMA 988#ifdef CONFIG_NUMA
954extern void setup_per_cpu_pageset(void); 989extern void setup_per_cpu_pageset(void);
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 528e7d3fecb1..c15ae1986b98 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -110,7 +110,7 @@ struct mmc_host {
110 struct mmc_card *card_busy; /* the MMC card claiming host */ 110 struct mmc_card *card_busy; /* the MMC card claiming host */
111 struct mmc_card *card_selected; /* the selected MMC card */ 111 struct mmc_card *card_selected; /* the selected MMC card */
112 112
113 struct work_struct detect; 113 struct delayed_work detect;
114 114
115 unsigned long private[0] ____cacheline_aligned; 115 unsigned long private[0] ____cacheline_aligned;
116}; 116};
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index e06683e2bea3..e339a7345f25 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -278,7 +278,7 @@ struct zone {
278 /* 278 /*
279 * rarely used fields: 279 * rarely used fields:
280 */ 280 */
281 char *name; 281 const char *name;
282} ____cacheline_internodealigned_in_smp; 282} ____cacheline_internodealigned_in_smp;
283 283
284/* 284/*
@@ -288,19 +288,94 @@ struct zone {
288 */ 288 */
289#define DEF_PRIORITY 12 289#define DEF_PRIORITY 12
290 290
291/* Maximum number of zones on a zonelist */
292#define MAX_ZONES_PER_ZONELIST (MAX_NUMNODES * MAX_NR_ZONES)
293
294#ifdef CONFIG_NUMA
295/*
296 * We cache key information from each zonelist for smaller cache
297 * footprint when scanning for free pages in get_page_from_freelist().
298 *
299 * 1) The BITMAP fullzones tracks which zones in a zonelist have come
300 * up short of free memory since the last time (last_fullzone_zap)
301 * we zero'd fullzones.
302 * 2) The array z_to_n[] maps each zone in the zonelist to its node
303 * id, so that we can efficiently evaluate whether that node is
304 * set in the current tasks mems_allowed.
305 *
306 * Both fullzones and z_to_n[] are one-to-one with the zonelist,
307 * indexed by a zones offset in the zonelist zones[] array.
308 *
309 * The get_page_from_freelist() routine does two scans. During the
310 * first scan, we skip zones whose corresponding bit in 'fullzones'
311 * is set or whose corresponding node in current->mems_allowed (which
312 * comes from cpusets) is not set. During the second scan, we bypass
313 * this zonelist_cache, to ensure we look methodically at each zone.
314 *
315 * Once per second, we zero out (zap) fullzones, forcing us to
316 * reconsider nodes that might have regained more free memory.
317 * The field last_full_zap is the time we last zapped fullzones.
318 *
319 * This mechanism reduces the amount of time we waste repeatedly
320 * reexaming zones for free memory when they just came up low on
321 * memory momentarilly ago.
322 *
323 * The zonelist_cache struct members logically belong in struct
324 * zonelist. However, the mempolicy zonelists constructed for
325 * MPOL_BIND are intentionally variable length (and usually much
326 * shorter). A general purpose mechanism for handling structs with
327 * multiple variable length members is more mechanism than we want
328 * here. We resort to some special case hackery instead.
329 *
330 * The MPOL_BIND zonelists don't need this zonelist_cache (in good
331 * part because they are shorter), so we put the fixed length stuff
332 * at the front of the zonelist struct, ending in a variable length
333 * zones[], as is needed by MPOL_BIND.
334 *
335 * Then we put the optional zonelist cache on the end of the zonelist
336 * struct. This optional stuff is found by a 'zlcache_ptr' pointer in
337 * the fixed length portion at the front of the struct. This pointer
338 * both enables us to find the zonelist cache, and in the case of
339 * MPOL_BIND zonelists, (which will just set the zlcache_ptr to NULL)
340 * to know that the zonelist cache is not there.
341 *
342 * The end result is that struct zonelists come in two flavors:
343 * 1) The full, fixed length version, shown below, and
344 * 2) The custom zonelists for MPOL_BIND.
345 * The custom MPOL_BIND zonelists have a NULL zlcache_ptr and no zlcache.
346 *
347 * Even though there may be multiple CPU cores on a node modifying
348 * fullzones or last_full_zap in the same zonelist_cache at the same
349 * time, we don't lock it. This is just hint data - if it is wrong now
350 * and then, the allocator will still function, perhaps a bit slower.
351 */
352
353
354struct zonelist_cache {
355 unsigned short z_to_n[MAX_ZONES_PER_ZONELIST]; /* zone->nid */
356 DECLARE_BITMAP(fullzones, MAX_ZONES_PER_ZONELIST); /* zone full? */
357 unsigned long last_full_zap; /* when last zap'd (jiffies) */
358};
359#else
360struct zonelist_cache;
361#endif
362
291/* 363/*
292 * One allocation request operates on a zonelist. A zonelist 364 * One allocation request operates on a zonelist. A zonelist
293 * is a list of zones, the first one is the 'goal' of the 365 * is a list of zones, the first one is the 'goal' of the
294 * allocation, the other zones are fallback zones, in decreasing 366 * allocation, the other zones are fallback zones, in decreasing
295 * priority. 367 * priority.
296 * 368 *
297 * Right now a zonelist takes up less than a cacheline. We never 369 * If zlcache_ptr is not NULL, then it is just the address of zlcache,
298 * modify it apart from boot-up, and only a few indices are used, 370 * as explained above. If zlcache_ptr is NULL, there is no zlcache.
299 * so despite the zonelist table being relatively big, the cache
300 * footprint of this construct is very small.
301 */ 371 */
372
302struct zonelist { 373struct zonelist {
303 struct zone *zones[MAX_NUMNODES * MAX_NR_ZONES + 1]; // NULL delimited 374 struct zonelist_cache *zlcache_ptr; // NULL or &zlcache
375 struct zone *zones[MAX_ZONES_PER_ZONELIST + 1]; // NULL delimited
376#ifdef CONFIG_NUMA
377 struct zonelist_cache zlcache; // optional ...
378#endif
304}; 379};
305 380
306#ifdef CONFIG_ARCH_POPULATES_NODE_MAP 381#ifdef CONFIG_ARCH_POPULATES_NODE_MAP
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 7c0c2c198f1f..4a189dadb160 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -63,6 +63,9 @@ struct kparam_array
63 not there, read bits mean it's readable, write bits mean it's 63 not there, read bits mean it's readable, write bits mean it's
64 writable. */ 64 writable. */
65#define __module_param_call(prefix, name, set, get, arg, perm) \ 65#define __module_param_call(prefix, name, set, get, arg, perm) \
66 /* Default value instead of permissions? */ \
67 static int __param_perm_check_##name __attribute__((unused)) = \
68 BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)); \
66 static char __param_str_##name[] = prefix #name; \ 69 static char __param_str_##name[] = prefix #name; \
67 static struct kernel_param const __param_##name \ 70 static struct kernel_param const __param_##name \
68 __attribute_used__ \ 71 __attribute_used__ \
diff --git a/include/linux/msg.h b/include/linux/msg.h
index acc7c174ff00..f1b60740d641 100644
--- a/include/linux/msg.h
+++ b/include/linux/msg.h
@@ -92,6 +92,12 @@ struct msg_queue {
92 struct list_head q_senders; 92 struct list_head q_senders;
93}; 93};
94 94
95/* Helper routines for sys_msgsnd and sys_msgrcv */
96extern long do_msgsnd(int msqid, long mtype, void __user *mtext,
97 size_t msgsz, int msgflg);
98extern long do_msgrcv(int msqid, long *pmtype, void __user *mtext,
99 size_t msgsz, long msgtyp, int msgflg);
100
95#endif /* __KERNEL__ */ 101#endif /* __KERNEL__ */
96 102
97#endif /* _LINUX_MSG_H */ 103#endif /* _LINUX_MSG_H */
diff --git a/include/linux/mutex.h b/include/linux/mutex.h
index 27c48daa3183..b2b91c477563 100644
--- a/include/linux/mutex.h
+++ b/include/linux/mutex.h
@@ -94,7 +94,7 @@ do { \
94 94
95#define __MUTEX_INITIALIZER(lockname) \ 95#define __MUTEX_INITIALIZER(lockname) \
96 { .count = ATOMIC_INIT(1) \ 96 { .count = ATOMIC_INIT(1) \
97 , .wait_lock = SPIN_LOCK_UNLOCKED \ 97 , .wait_lock = __SPIN_LOCK_UNLOCKED(lockname.wait_lock) \
98 , .wait_list = LIST_HEAD_INIT(lockname.wait_list) \ 98 , .wait_list = LIST_HEAD_INIT(lockname.wait_list) \
99 __DEBUG_MUTEX_INITIALIZER(lockname) \ 99 __DEBUG_MUTEX_INITIALIZER(lockname) \
100 __DEP_MAP_MUTEX_INITIALIZER(lockname) } 100 __DEP_MAP_MUTEX_INITIALIZER(lockname) }
diff --git a/include/linux/nbd.h b/include/linux/nbd.h
index d6b6dc09ad97..0f3e69302540 100644
--- a/include/linux/nbd.h
+++ b/include/linux/nbd.h
@@ -64,6 +64,7 @@ struct nbd_device {
64 struct gendisk *disk; 64 struct gendisk *disk;
65 int blksize; 65 int blksize;
66 u64 bytesize; 66 u64 bytesize;
67 pid_t pid; /* pid of nbd-client, if attached */
67}; 68};
68 69
69#endif 70#endif
diff --git a/include/linux/ncp_fs_sb.h b/include/linux/ncp_fs_sb.h
index b089d9506283..a503052138bd 100644
--- a/include/linux/ncp_fs_sb.h
+++ b/include/linux/ncp_fs_sb.h
@@ -127,10 +127,10 @@ struct ncp_server {
127 } unexpected_packet; 127 } unexpected_packet;
128}; 128};
129 129
130extern void ncp_tcp_rcv_proc(void *server); 130extern void ncp_tcp_rcv_proc(struct work_struct *work);
131extern void ncp_tcp_tx_proc(void *server); 131extern void ncp_tcp_tx_proc(struct work_struct *work);
132extern void ncpdgram_rcv_proc(void *server); 132extern void ncpdgram_rcv_proc(struct work_struct *work);
133extern void ncpdgram_timeout_proc(void *server); 133extern void ncpdgram_timeout_proc(struct work_struct *work);
134extern void ncpdgram_timeout_call(unsigned long server); 134extern void ncpdgram_timeout_call(unsigned long server);
135extern void ncp_tcp_data_ready(struct sock* sk, int len); 135extern void ncp_tcp_data_ready(struct sock* sk, int len);
136extern void ncp_tcp_write_space(struct sock* sk); 136extern void ncp_tcp_write_space(struct sock* sk);
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index 2cc9867b1626..29930b71a9aa 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -32,7 +32,7 @@ struct netpoll_info {
32 struct netpoll *rx_np; /* netpoll that registered an rx_hook */ 32 struct netpoll *rx_np; /* netpoll that registered an rx_hook */
33 struct sk_buff_head arp_tx; /* list of arp requests to reply to */ 33 struct sk_buff_head arp_tx; /* list of arp requests to reply to */
34 struct sk_buff_head txq; 34 struct sk_buff_head txq;
35 struct work_struct tx_work; 35 struct delayed_work tx_work;
36}; 36};
37 37
38void netpoll_poll(struct netpoll *np); 38void netpoll_poll(struct netpoll *np);
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index 7ccfc7ef0a83..95796e6924f1 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -51,7 +51,7 @@ struct nfs_client {
51 51
52 unsigned long cl_lease_time; 52 unsigned long cl_lease_time;
53 unsigned long cl_last_renewal; 53 unsigned long cl_last_renewal;
54 struct work_struct cl_renewd; 54 struct delayed_work cl_renewd;
55 55
56 struct rpc_wait_queue cl_rpcwaitq; 56 struct rpc_wait_queue cl_rpcwaitq;
57 57
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index c09da1e30c54..ff2dcb436cd0 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -390,7 +390,7 @@
390#define PCI_DEVICE_ID_NS_CS5535_IDE 0x002d 390#define PCI_DEVICE_ID_NS_CS5535_IDE 0x002d
391#define PCI_DEVICE_ID_NS_CS5535_AUDIO 0x002e 391#define PCI_DEVICE_ID_NS_CS5535_AUDIO 0x002e
392#define PCI_DEVICE_ID_NS_CS5535_USB 0x002f 392#define PCI_DEVICE_ID_NS_CS5535_USB 0x002f
393#define PCI_DEVICE_ID_NS_CS5535_VIDEO 0x0030 393#define PCI_DEVICE_ID_NS_GX_VIDEO 0x0030
394#define PCI_DEVICE_ID_NS_SATURN 0x0035 394#define PCI_DEVICE_ID_NS_SATURN 0x0035
395#define PCI_DEVICE_ID_NS_SCx200_BRIDGE 0x0500 395#define PCI_DEVICE_ID_NS_SCx200_BRIDGE 0x0500
396#define PCI_DEVICE_ID_NS_SCx200_SMI 0x0501 396#define PCI_DEVICE_ID_NS_SCx200_SMI 0x0501
@@ -403,8 +403,7 @@
403#define PCI_DEVICE_ID_NS_SC1100_XBUS 0x0515 403#define PCI_DEVICE_ID_NS_SC1100_XBUS 0x0515
404#define PCI_DEVICE_ID_NS_87410 0xd001 404#define PCI_DEVICE_ID_NS_87410 0xd001
405 405
406#define PCI_DEVICE_ID_NS_CS5535_HOST_BRIDGE 0x0028 406#define PCI_DEVICE_ID_NS_GX_HOST_BRIDGE 0x0028
407#define PCI_DEVICE_ID_NS_CS5535_ISA_BRIDGE 0x002b
408 407
409#define PCI_VENDOR_ID_TSENG 0x100c 408#define PCI_VENDOR_ID_TSENG 0x100c
410#define PCI_DEVICE_ID_TSENG_W32P_2 0x3202 409#define PCI_DEVICE_ID_TSENG_W32P_2 0x3202
@@ -1864,6 +1863,7 @@
1864#define PCI_DEVICE_ID_OXSEMI_16PCI95N 0x9511 1863#define PCI_DEVICE_ID_OXSEMI_16PCI95N 0x9511
1865#define PCI_DEVICE_ID_OXSEMI_16PCI954PP 0x9513 1864#define PCI_DEVICE_ID_OXSEMI_16PCI954PP 0x9513
1866#define PCI_DEVICE_ID_OXSEMI_16PCI952 0x9521 1865#define PCI_DEVICE_ID_OXSEMI_16PCI952 0x9521
1866#define PCI_DEVICE_ID_OXSEMI_16PCI952PP 0x9523
1867 1867
1868#define PCI_VENDOR_ID_SAMSUNG 0x144d 1868#define PCI_VENDOR_ID_SAMSUNG 0x144d
1869 1869
diff --git a/include/linux/profile.h b/include/linux/profile.h
index acce53fd38b6..5670b340c4ef 100644
--- a/include/linux/profile.h
+++ b/include/linux/profile.h
@@ -6,10 +6,15 @@
6#include <linux/kernel.h> 6#include <linux/kernel.h>
7#include <linux/init.h> 7#include <linux/init.h>
8#include <linux/cpumask.h> 8#include <linux/cpumask.h>
9#include <linux/cache.h>
10
9#include <asm/errno.h> 11#include <asm/errno.h>
10 12
13extern int prof_on __read_mostly;
14
11#define CPU_PROFILING 1 15#define CPU_PROFILING 1
12#define SCHED_PROFILING 2 16#define SCHED_PROFILING 2
17#define SLEEP_PROFILING 3
13 18
14struct proc_dir_entry; 19struct proc_dir_entry;
15struct pt_regs; 20struct pt_regs;
@@ -18,7 +23,24 @@ struct notifier_block;
18/* init basic kernel profiler */ 23/* init basic kernel profiler */
19void __init profile_init(void); 24void __init profile_init(void);
20void profile_tick(int); 25void profile_tick(int);
21void profile_hit(int, void *); 26
27/*
28 * Add multiple profiler hits to a given address:
29 */
30void profile_hits(int, void *ip, unsigned int nr_hits);
31
32/*
33 * Single profiler hit:
34 */
35static inline void profile_hit(int type, void *ip)
36{
37 /*
38 * Speedup for the common (no profiling enabled) case:
39 */
40 if (unlikely(prof_on == type))
41 profile_hits(type, ip, 1);
42}
43
22#ifdef CONFIG_PROC_FS 44#ifdef CONFIG_PROC_FS
23void create_prof_cpu_mask(struct proc_dir_entry *); 45void create_prof_cpu_mask(struct proc_dir_entry *);
24#else 46#else
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index 5110201a4159..90c23f690c0d 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -37,6 +37,9 @@ extern int dquot_release(struct dquot *dquot);
37extern int dquot_commit_info(struct super_block *sb, int type); 37extern int dquot_commit_info(struct super_block *sb, int type);
38extern int dquot_mark_dquot_dirty(struct dquot *dquot); 38extern int dquot_mark_dquot_dirty(struct dquot *dquot);
39 39
40int remove_inode_dquot_ref(struct inode *inode, int type,
41 struct list_head *tofree_head);
42
40extern int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path); 43extern int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path);
41extern int vfs_quota_on_mount(struct super_block *sb, char *qf_name, 44extern int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
42 int format_id, int type); 45 int format_id, int type);
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index cbfa11537421..0deb842541ac 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -1,6 +1,7 @@
1/* 1/*
2 * Copyright (C) 2001 Momchil Velikov 2 * Copyright (C) 2001 Momchil Velikov
3 * Portions Copyright (C) 2001 Christoph Hellwig 3 * Portions Copyright (C) 2001 Christoph Hellwig
4 * Copyright (C) 2006 Nick Piggin
4 * 5 *
5 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as 7 * modify it under the terms of the GNU General Public License as
@@ -21,6 +22,35 @@
21 22
22#include <linux/preempt.h> 23#include <linux/preempt.h>
23#include <linux/types.h> 24#include <linux/types.h>
25#include <linux/kernel.h>
26#include <linux/rcupdate.h>
27
28/*
29 * A direct pointer (root->rnode pointing directly to a data item,
30 * rather than another radix_tree_node) is signalled by the low bit
31 * set in the root->rnode pointer.
32 *
33 * In this case root->height is also NULL, but the direct pointer tests are
34 * needed for RCU lookups when root->height is unreliable.
35 */
36#define RADIX_TREE_DIRECT_PTR 1
37
38static inline void *radix_tree_ptr_to_direct(void *ptr)
39{
40 return (void *)((unsigned long)ptr | RADIX_TREE_DIRECT_PTR);
41}
42
43static inline void *radix_tree_direct_to_ptr(void *ptr)
44{
45 return (void *)((unsigned long)ptr & ~RADIX_TREE_DIRECT_PTR);
46}
47
48static inline int radix_tree_is_direct_ptr(void *ptr)
49{
50 return (int)((unsigned long)ptr & RADIX_TREE_DIRECT_PTR);
51}
52
53/*** radix-tree API starts here ***/
24 54
25#define RADIX_TREE_MAX_TAGS 2 55#define RADIX_TREE_MAX_TAGS 2
26 56
@@ -47,6 +77,77 @@ do { \
47 (root)->rnode = NULL; \ 77 (root)->rnode = NULL; \
48} while (0) 78} while (0)
49 79
80/**
81 * Radix-tree synchronization
82 *
83 * The radix-tree API requires that users provide all synchronisation (with
84 * specific exceptions, noted below).
85 *
86 * Synchronization of access to the data items being stored in the tree, and
87 * management of their lifetimes must be completely managed by API users.
88 *
89 * For API usage, in general,
90 * - any function _modifying_ the the tree or tags (inserting or deleting
91 * items, setting or clearing tags must exclude other modifications, and
92 * exclude any functions reading the tree.
93 * - any function _reading_ the the tree or tags (looking up items or tags,
94 * gang lookups) must exclude modifications to the tree, but may occur
95 * concurrently with other readers.
96 *
97 * The notable exceptions to this rule are the following functions:
98 * radix_tree_lookup
99 * radix_tree_tag_get
100 * radix_tree_gang_lookup
101 * radix_tree_gang_lookup_tag
102 * radix_tree_tagged
103 *
104 * The first 4 functions are able to be called locklessly, using RCU. The
105 * caller must ensure calls to these functions are made within rcu_read_lock()
106 * regions. Other readers (lock-free or otherwise) and modifications may be
107 * running concurrently.
108 *
109 * It is still required that the caller manage the synchronization and lifetimes
110 * of the items. So if RCU lock-free lookups are used, typically this would mean
111 * that the items have their own locks, or are amenable to lock-free access; and
112 * that the items are freed by RCU (or only freed after having been deleted from
113 * the radix tree *and* a synchronize_rcu() grace period).
114 *
115 * (Note, rcu_assign_pointer and rcu_dereference are not needed to control
116 * access to data items when inserting into or looking up from the radix tree)
117 *
118 * radix_tree_tagged is able to be called without locking or RCU.
119 */
120
121/**
122 * radix_tree_deref_slot - dereference a slot
123 * @pslot: pointer to slot, returned by radix_tree_lookup_slot
124 * Returns: item that was stored in that slot with any direct pointer flag
125 * removed.
126 *
127 * For use with radix_tree_lookup_slot(). Caller must hold tree at least read
128 * locked across slot lookup and dereference. More likely, will be used with
129 * radix_tree_replace_slot(), as well, so caller will hold tree write locked.
130 */
131static inline void *radix_tree_deref_slot(void **pslot)
132{
133 return radix_tree_direct_to_ptr(*pslot);
134}
135/**
136 * radix_tree_replace_slot - replace item in a slot
137 * @pslot: pointer to slot, returned by radix_tree_lookup_slot
138 * @item: new item to store in the slot.
139 *
140 * For use with radix_tree_lookup_slot(). Caller must hold tree write locked
141 * across slot lookup and replacement.
142 */
143static inline void radix_tree_replace_slot(void **pslot, void *item)
144{
145 BUG_ON(radix_tree_is_direct_ptr(item));
146 rcu_assign_pointer(*pslot,
147 (void *)((unsigned long)item |
148 ((unsigned long)*pslot & RADIX_TREE_DIRECT_PTR)));
149}
150
50int radix_tree_insert(struct radix_tree_root *, unsigned long, void *); 151int radix_tree_insert(struct radix_tree_root *, unsigned long, void *);
51void *radix_tree_lookup(struct radix_tree_root *, unsigned long); 152void *radix_tree_lookup(struct radix_tree_root *, unsigned long);
52void **radix_tree_lookup_slot(struct radix_tree_root *, unsigned long); 153void **radix_tree_lookup_slot(struct radix_tree_root *, unsigned long);
diff --git a/include/linux/raid/raid5.h b/include/linux/raid/raid5.h
index f13299a15591..03636d7918fe 100644
--- a/include/linux/raid/raid5.h
+++ b/include/linux/raid/raid5.h
@@ -235,7 +235,7 @@ struct raid5_private_data {
235 */ 235 */
236 int active_name; 236 int active_name;
237 char cache_name[2][20]; 237 char cache_name[2][20];
238 kmem_cache_t *slab_cache; /* for allocating stripes */ 238 struct kmem_cache *slab_cache; /* for allocating stripes */
239 239
240 int seq_flush, seq_write; 240 int seq_flush, seq_write;
241 int quiesce; 241 int quiesce;
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index 7bc6bfb86253..d0e4dce33ad5 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -739,7 +739,7 @@ struct block_head {
739#define PUT_B_FREE_SPACE(p_s_bh,val) do { set_blkh_free_space(B_BLK_HEAD(p_s_bh),val); } while (0) 739#define PUT_B_FREE_SPACE(p_s_bh,val) do { set_blkh_free_space(B_BLK_HEAD(p_s_bh),val); } while (0)
740 740
741/* Get right delimiting key. -- little endian */ 741/* Get right delimiting key. -- little endian */
742#define B_PRIGHT_DELIM_KEY(p_s_bh) (&(blk_right_delim_key(B_BLK_HEAD(p_s_bh)) 742#define B_PRIGHT_DELIM_KEY(p_s_bh) (&(blk_right_delim_key(B_BLK_HEAD(p_s_bh))))
743 743
744/* Does the buffer contain a disk leaf. */ 744/* Does the buffer contain a disk leaf. */
745#define B_IS_ITEMS_LEVEL(p_s_bh) (B_LEVEL(p_s_bh) == DISK_LEAF_NODE_LEVEL) 745#define B_IS_ITEMS_LEVEL(p_s_bh) (B_LEVEL(p_s_bh) == DISK_LEAF_NODE_LEVEL)
diff --git a/include/linux/reiserfs_fs_sb.h b/include/linux/reiserfs_fs_sb.h
index 62a7169aed8b..3a28742d86f9 100644
--- a/include/linux/reiserfs_fs_sb.h
+++ b/include/linux/reiserfs_fs_sb.h
@@ -249,7 +249,8 @@ struct reiserfs_journal {
249 int j_errno; 249 int j_errno;
250 250
251 /* when flushing ordered buffers, throttle new ordered writers */ 251 /* when flushing ordered buffers, throttle new ordered writers */
252 struct work_struct j_work; 252 struct delayed_work j_work;
253 struct super_block *j_work_sb;
253 atomic_t j_async_throttle; 254 atomic_t j_async_throttle;
254}; 255};
255 256
diff --git a/include/linux/relay.h b/include/linux/relay.h
index 24accb483849..c6a48bfc8b14 100644
--- a/include/linux/relay.h
+++ b/include/linux/relay.h
@@ -38,7 +38,7 @@ struct rchan_buf
38 size_t subbufs_consumed; /* count of sub-buffers consumed */ 38 size_t subbufs_consumed; /* count of sub-buffers consumed */
39 struct rchan *chan; /* associated channel */ 39 struct rchan *chan; /* associated channel */
40 wait_queue_head_t read_wait; /* reader wait queue */ 40 wait_queue_head_t read_wait; /* reader wait queue */
41 struct work_struct wake_readers; /* reader wake-up work struct */ 41 struct delayed_work wake_readers; /* reader wake-up work struct */
42 struct dentry *dentry; /* channel file dentry */ 42 struct dentry *dentry; /* channel file dentry */
43 struct kref kref; /* channel buffer refcount */ 43 struct kref kref; /* channel buffer refcount */
44 struct page **page_array; /* array of current buffer pages */ 44 struct page **page_array; /* array of current buffer pages */
@@ -274,7 +274,7 @@ static inline void subbuf_start_reserve(struct rchan_buf *buf,
274/* 274/*
275 * exported relay file operations, kernel/relay.c 275 * exported relay file operations, kernel/relay.c
276 */ 276 */
277extern struct file_operations relay_file_operations; 277extern const struct file_operations relay_file_operations;
278 278
279#endif /* _LINUX_RELAY_H */ 279#endif /* _LINUX_RELAY_H */
280 280
diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index db2c1df4fef9..36f850373d2c 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -30,11 +30,11 @@ struct anon_vma {
30 30
31#ifdef CONFIG_MMU 31#ifdef CONFIG_MMU
32 32
33extern kmem_cache_t *anon_vma_cachep; 33extern struct kmem_cache *anon_vma_cachep;
34 34
35static inline struct anon_vma *anon_vma_alloc(void) 35static inline struct anon_vma *anon_vma_alloc(void)
36{ 36{
37 return kmem_cache_alloc(anon_vma_cachep, SLAB_KERNEL); 37 return kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL);
38} 38}
39 39
40static inline void anon_vma_free(struct anon_vma *anon_vma) 40static inline void anon_vma_free(struct anon_vma *anon_vma)
diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h
index 5d41dee82f80..b0090e9f7884 100644
--- a/include/linux/rtmutex.h
+++ b/include/linux/rtmutex.h
@@ -63,7 +63,7 @@ struct hrtimer_sleeper;
63#endif 63#endif
64 64
65#define __RT_MUTEX_INITIALIZER(mutexname) \ 65#define __RT_MUTEX_INITIALIZER(mutexname) \
66 { .wait_lock = SPIN_LOCK_UNLOCKED \ 66 { .wait_lock = __SPIN_LOCK_UNLOCKED(mutexname.wait_lock) \
67 , .wait_list = PLIST_HEAD_INIT(mutexname.wait_list, mutexname.wait_lock) \ 67 , .wait_list = PLIST_HEAD_INIT(mutexname.wait_list, mutexname.wait_lock) \
68 , .owner = NULL \ 68 , .owner = NULL \
69 __DEBUG_RT_MUTEX_INITIALIZER(mutexname)} 69 __DEBUG_RT_MUTEX_INITIALIZER(mutexname)}
diff --git a/include/linux/rwsem-spinlock.h b/include/linux/rwsem-spinlock.h
index ae1fcadd598e..813cee13da0d 100644
--- a/include/linux/rwsem-spinlock.h
+++ b/include/linux/rwsem-spinlock.h
@@ -44,7 +44,8 @@ struct rw_semaphore {
44#endif 44#endif
45 45
46#define __RWSEM_INITIALIZER(name) \ 46#define __RWSEM_INITIALIZER(name) \
47{ 0, SPIN_LOCK_UNLOCKED, LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) } 47{ 0, __SPIN_LOCK_UNLOCKED(name.wait_lock), LIST_HEAD_INIT((name).wait_list) \
48 __RWSEM_DEP_MAP_INIT(name) }
48 49
49#define DECLARE_RWSEM(name) \ 50#define DECLARE_RWSEM(name) \
50 struct rw_semaphore name = __RWSEM_INITIALIZER(name) 51 struct rw_semaphore name = __RWSEM_INITIALIZER(name)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index eafe4a7b8237..dede82c63445 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -194,7 +194,16 @@ extern void init_idle(struct task_struct *idle, int cpu);
194 194
195extern cpumask_t nohz_cpu_mask; 195extern cpumask_t nohz_cpu_mask;
196 196
197extern void show_state(void); 197/*
198 * Only dump TASK_* tasks. (-1 for all tasks)
199 */
200extern void show_state_filter(unsigned long state_filter);
201
202static inline void show_state(void)
203{
204 show_state_filter(-1);
205}
206
198extern void show_regs(struct pt_regs *); 207extern void show_regs(struct pt_regs *);
199 208
200/* 209/*
@@ -338,15 +347,23 @@ struct mm_struct {
338 347
339 unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */ 348 unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
340 349
341 unsigned dumpable:2;
342 cpumask_t cpu_vm_mask; 350 cpumask_t cpu_vm_mask;
343 351
344 /* Architecture-specific MM context */ 352 /* Architecture-specific MM context */
345 mm_context_t context; 353 mm_context_t context;
346 354
347 /* Token based thrashing protection. */ 355 /* Swap token stuff */
348 unsigned long swap_token_time; 356 /*
349 char recent_pagein; 357 * Last value of global fault stamp as seen by this process.
358 * In other words, this value gives an indication of how long
359 * it has been since this task got the token.
360 * Look at mm/thrash.c
361 */
362 unsigned int faultstamp;
363 unsigned int token_priority;
364 unsigned int last_interval;
365
366 unsigned char dumpable:2;
350 367
351 /* coredumping support */ 368 /* coredumping support */
352 int core_waiters; 369 int core_waiters;
@@ -556,7 +573,7 @@ struct sched_info {
556#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */ 573#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
557 574
558#ifdef CONFIG_SCHEDSTATS 575#ifdef CONFIG_SCHEDSTATS
559extern struct file_operations proc_schedstat_operations; 576extern const struct file_operations proc_schedstat_operations;
560#endif /* CONFIG_SCHEDSTATS */ 577#endif /* CONFIG_SCHEDSTATS */
561 578
562#ifdef CONFIG_TASK_DELAY_ACCT 579#ifdef CONFIG_TASK_DELAY_ACCT
@@ -1288,7 +1305,6 @@ extern int kill_pgrp(struct pid *pid, int sig, int priv);
1288extern int kill_pid(struct pid *pid, int sig, int priv); 1305extern int kill_pid(struct pid *pid, int sig, int priv);
1289extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp); 1306extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp);
1290extern int kill_pg_info(int, struct siginfo *, pid_t); 1307extern int kill_pg_info(int, struct siginfo *, pid_t);
1291extern int kill_proc_info(int, struct siginfo *, pid_t);
1292extern void do_notify_parent(struct task_struct *, int); 1308extern void do_notify_parent(struct task_struct *, int);
1293extern void force_sig(int, struct task_struct *); 1309extern void force_sig(int, struct task_struct *);
1294extern void force_sig_specific(int, struct task_struct *); 1310extern void force_sig_specific(int, struct task_struct *);
@@ -1610,87 +1626,6 @@ extern int sched_create_sysfs_power_savings_entries(struct sysdev_class *cls);
1610 1626
1611extern void normalize_rt_tasks(void); 1627extern void normalize_rt_tasks(void);
1612 1628
1613#ifdef CONFIG_PM
1614/*
1615 * Check if a process has been frozen
1616 */
1617static inline int frozen(struct task_struct *p)
1618{
1619 return p->flags & PF_FROZEN;
1620}
1621
1622/*
1623 * Check if there is a request to freeze a process
1624 */
1625static inline int freezing(struct task_struct *p)
1626{
1627 return p->flags & PF_FREEZE;
1628}
1629
1630/*
1631 * Request that a process be frozen
1632 * FIXME: SMP problem. We may not modify other process' flags!
1633 */
1634static inline void freeze(struct task_struct *p)
1635{
1636 p->flags |= PF_FREEZE;
1637}
1638
1639/*
1640 * Sometimes we may need to cancel the previous 'freeze' request
1641 */
1642static inline void do_not_freeze(struct task_struct *p)
1643{
1644 p->flags &= ~PF_FREEZE;
1645}
1646
1647/*
1648 * Wake up a frozen process
1649 */
1650static inline int thaw_process(struct task_struct *p)
1651{
1652 if (frozen(p)) {
1653 p->flags &= ~PF_FROZEN;
1654 wake_up_process(p);
1655 return 1;
1656 }
1657 return 0;
1658}
1659
1660/*
1661 * freezing is complete, mark process as frozen
1662 */
1663static inline void frozen_process(struct task_struct *p)
1664{
1665 p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN;
1666}
1667
1668extern void refrigerator(void);
1669extern int freeze_processes(void);
1670extern void thaw_processes(void);
1671
1672static inline int try_to_freeze(void)
1673{
1674 if (freezing(current)) {
1675 refrigerator();
1676 return 1;
1677 } else
1678 return 0;
1679}
1680#else
1681static inline int frozen(struct task_struct *p) { return 0; }
1682static inline int freezing(struct task_struct *p) { return 0; }
1683static inline void freeze(struct task_struct *p) { BUG(); }
1684static inline int thaw_process(struct task_struct *p) { return 1; }
1685static inline void frozen_process(struct task_struct *p) { BUG(); }
1686
1687static inline void refrigerator(void) {}
1688static inline int freeze_processes(void) { BUG(); return 0; }
1689static inline void thaw_processes(void) {}
1690
1691static inline int try_to_freeze(void) { return 0; }
1692
1693#endif /* CONFIG_PM */
1694#endif /* __KERNEL__ */ 1629#endif /* __KERNEL__ */
1695 1630
1696#endif 1631#endif
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index b95f6eb7254c..3e3cccbb1cac 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -20,7 +20,7 @@ struct seq_file {
20 loff_t index; 20 loff_t index;
21 loff_t version; 21 loff_t version;
22 struct mutex lock; 22 struct mutex lock;
23 struct seq_operations *op; 23 const struct seq_operations *op;
24 void *private; 24 void *private;
25}; 25};
26 26
@@ -31,7 +31,7 @@ struct seq_operations {
31 int (*show) (struct seq_file *m, void *v); 31 int (*show) (struct seq_file *m, void *v);
32}; 32};
33 33
34int seq_open(struct file *, struct seq_operations *); 34int seq_open(struct file *, const struct seq_operations *);
35ssize_t seq_read(struct file *, char __user *, size_t, loff_t *); 35ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
36loff_t seq_lseek(struct file *, loff_t, int); 36loff_t seq_lseek(struct file *, loff_t, int);
37int seq_release(struct inode *, struct file *); 37int seq_release(struct inode *, struct file *);
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index 8e9681413726..71310d80c09a 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -41,6 +41,7 @@ enum {
41 PLAT8250_DEV_FOURPORT, 41 PLAT8250_DEV_FOURPORT,
42 PLAT8250_DEV_ACCENT, 42 PLAT8250_DEV_ACCENT,
43 PLAT8250_DEV_BOCA, 43 PLAT8250_DEV_BOCA,
44 PLAT8250_DEV_EXAR_ST16C554,
44 PLAT8250_DEV_HUB6, 45 PLAT8250_DEV_HUB6,
45 PLAT8250_DEV_MCA, 46 PLAT8250_DEV_MCA,
46 PLAT8250_DEV_AU1X00, 47 PLAT8250_DEV_AU1X00,
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 463ab953b092..827672136646 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -132,6 +132,8 @@
132 132
133#define PORT_S3C2412 73 133#define PORT_S3C2412 73
134 134
135/* Xilinx uartlite */
136#define PORT_UARTLITE 74
135 137
136#ifdef __KERNEL__ 138#ifdef __KERNEL__
137 139
diff --git a/include/linux/signal.h b/include/linux/signal.h
index 117135e33d67..14749056dd63 100644
--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -241,6 +241,8 @@ extern int sigprocmask(int, sigset_t *, sigset_t *);
241struct pt_regs; 241struct pt_regs;
242extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie); 242extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
243 243
244extern struct kmem_cache *sighand_cachep;
245
244#endif /* __KERNEL__ */ 246#endif /* __KERNEL__ */
245 247
246#endif /* _LINUX_SIGNAL_H */ 248#endif /* _LINUX_SIGNAL_H */
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a05a5f7c0b73..4ff3940210d8 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -332,20 +332,20 @@ struct sk_buff {
332extern void kfree_skb(struct sk_buff *skb); 332extern void kfree_skb(struct sk_buff *skb);
333extern void __kfree_skb(struct sk_buff *skb); 333extern void __kfree_skb(struct sk_buff *skb);
334extern struct sk_buff *__alloc_skb(unsigned int size, 334extern struct sk_buff *__alloc_skb(unsigned int size,
335 gfp_t priority, int fclone); 335 gfp_t priority, int fclone, int node);
336static inline struct sk_buff *alloc_skb(unsigned int size, 336static inline struct sk_buff *alloc_skb(unsigned int size,
337 gfp_t priority) 337 gfp_t priority)
338{ 338{
339 return __alloc_skb(size, priority, 0); 339 return __alloc_skb(size, priority, 0, -1);
340} 340}
341 341
342static inline struct sk_buff *alloc_skb_fclone(unsigned int size, 342static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
343 gfp_t priority) 343 gfp_t priority)
344{ 344{
345 return __alloc_skb(size, priority, 1); 345 return __alloc_skb(size, priority, 1, -1);
346} 346}
347 347
348extern struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp, 348extern struct sk_buff *alloc_skb_from_cache(struct kmem_cache *cp,
349 unsigned int size, 349 unsigned int size,
350 gfp_t priority); 350 gfp_t priority);
351extern void kfree_skbmem(struct sk_buff *skb); 351extern void kfree_skbmem(struct sk_buff *skb);
diff --git a/include/linux/slab.h b/include/linux/slab.h
index c4947b8a2c03..2271886744f8 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -7,27 +7,17 @@
7#ifndef _LINUX_SLAB_H 7#ifndef _LINUX_SLAB_H
8#define _LINUX_SLAB_H 8#define _LINUX_SLAB_H
9 9
10#if defined(__KERNEL__) 10#ifdef __KERNEL__
11 11
12typedef struct kmem_cache kmem_cache_t; 12#include <linux/gfp.h>
13#include <linux/init.h>
14#include <linux/types.h>
15#include <asm/page.h> /* kmalloc_sizes.h needs PAGE_SIZE */
16#include <asm/cache.h> /* kmalloc_sizes.h needs L1_CACHE_BYTES */
17#include <linux/compiler.h>
13 18
14#include <linux/gfp.h> 19/* kmem_cache_t exists for legacy reasons and is not used by code in mm */
15#include <linux/init.h> 20typedef struct kmem_cache kmem_cache_t __deprecated;
16#include <linux/types.h>
17#include <asm/page.h> /* kmalloc_sizes.h needs PAGE_SIZE */
18#include <asm/cache.h> /* kmalloc_sizes.h needs L1_CACHE_BYTES */
19
20/* flags for kmem_cache_alloc() */
21#define SLAB_NOFS GFP_NOFS
22#define SLAB_NOIO GFP_NOIO
23#define SLAB_ATOMIC GFP_ATOMIC
24#define SLAB_USER GFP_USER
25#define SLAB_KERNEL GFP_KERNEL
26#define SLAB_DMA GFP_DMA
27
28#define SLAB_LEVEL_MASK GFP_LEVEL_MASK
29
30#define SLAB_NO_GROW __GFP_NO_GROW /* don't grow a cache */
31 21
32/* flags to pass to kmem_cache_create(). 22/* flags to pass to kmem_cache_create().
33 * The first 3 are only valid when the allocator as been build 23 * The first 3 are only valid when the allocator as been build
@@ -57,22 +47,23 @@ typedef struct kmem_cache kmem_cache_t;
57/* prototypes */ 47/* prototypes */
58extern void __init kmem_cache_init(void); 48extern void __init kmem_cache_init(void);
59 49
60extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned long, 50extern struct kmem_cache *kmem_cache_create(const char *, size_t, size_t,
61 void (*)(void *, kmem_cache_t *, unsigned long), 51 unsigned long,
62 void (*)(void *, kmem_cache_t *, unsigned long)); 52 void (*)(void *, struct kmem_cache *, unsigned long),
63extern void kmem_cache_destroy(kmem_cache_t *); 53 void (*)(void *, struct kmem_cache *, unsigned long));
64extern int kmem_cache_shrink(kmem_cache_t *); 54extern void kmem_cache_destroy(struct kmem_cache *);
65extern void *kmem_cache_alloc(kmem_cache_t *, gfp_t); 55extern int kmem_cache_shrink(struct kmem_cache *);
56extern void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
66extern void *kmem_cache_zalloc(struct kmem_cache *, gfp_t); 57extern void *kmem_cache_zalloc(struct kmem_cache *, gfp_t);
67extern void kmem_cache_free(kmem_cache_t *, void *); 58extern void kmem_cache_free(struct kmem_cache *, void *);
68extern unsigned int kmem_cache_size(kmem_cache_t *); 59extern unsigned int kmem_cache_size(struct kmem_cache *);
69extern const char *kmem_cache_name(kmem_cache_t *); 60extern const char *kmem_cache_name(struct kmem_cache *);
70 61
71/* Size description struct for general caches. */ 62/* Size description struct for general caches. */
72struct cache_sizes { 63struct cache_sizes {
73 size_t cs_size; 64 size_t cs_size;
74 kmem_cache_t *cs_cachep; 65 struct kmem_cache *cs_cachep;
75 kmem_cache_t *cs_dmacachep; 66 struct kmem_cache *cs_dmacachep;
76}; 67};
77extern struct cache_sizes malloc_sizes[]; 68extern struct cache_sizes malloc_sizes[];
78 69
@@ -211,7 +202,7 @@ extern unsigned int ksize(const void *);
211extern int slab_is_available(void); 202extern int slab_is_available(void);
212 203
213#ifdef CONFIG_NUMA 204#ifdef CONFIG_NUMA
214extern void *kmem_cache_alloc_node(kmem_cache_t *, gfp_t flags, int node); 205extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
215extern void *__kmalloc_node(size_t size, gfp_t flags, int node); 206extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
216 207
217static inline void *kmalloc_node(size_t size, gfp_t flags, int node) 208static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
@@ -236,8 +227,27 @@ found:
236 } 227 }
237 return __kmalloc_node(size, flags, node); 228 return __kmalloc_node(size, flags, node);
238} 229}
230
231/*
232 * kmalloc_node_track_caller is a special version of kmalloc_node that
233 * records the calling function of the routine calling it for slab leak
234 * tracking instead of just the calling function (confusing, eh?).
235 * It's useful when the call to kmalloc_node comes from a widely-used
236 * standard allocator where we care about the real place the memory
237 * allocation request comes from.
238 */
239#ifndef CONFIG_DEBUG_SLAB
240#define kmalloc_node_track_caller(size, flags, node) \
241 __kmalloc_node(size, flags, node)
239#else 242#else
240static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, gfp_t flags, int node) 243extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, void *);
244#define kmalloc_node_track_caller(size, flags, node) \
245 __kmalloc_node_track_caller(size, flags, node, \
246 __builtin_return_address(0))
247#endif
248#else /* CONFIG_NUMA */
249static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
250 gfp_t flags, int node)
241{ 251{
242 return kmem_cache_alloc(cachep, flags); 252 return kmem_cache_alloc(cachep, flags);
243} 253}
@@ -245,10 +255,13 @@ static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
245{ 255{
246 return kmalloc(size, flags); 256 return kmalloc(size, flags);
247} 257}
258
259#define kmalloc_node_track_caller(size, flags, node) \
260 kmalloc_track_caller(size, flags)
248#endif 261#endif
249 262
250extern int FASTCALL(kmem_cache_reap(int)); 263extern int FASTCALL(kmem_cache_reap(int));
251extern int FASTCALL(kmem_ptr_validate(kmem_cache_t *cachep, void *ptr)); 264extern int FASTCALL(kmem_ptr_validate(struct kmem_cache *cachep, void *ptr));
252 265
253#else /* CONFIG_SLOB */ 266#else /* CONFIG_SLOB */
254 267
@@ -283,16 +296,9 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
283#define kzalloc(s, f) __kzalloc(s, f) 296#define kzalloc(s, f) __kzalloc(s, f)
284#define kmalloc_track_caller kmalloc 297#define kmalloc_track_caller kmalloc
285 298
286#endif /* CONFIG_SLOB */ 299#define kmalloc_node_track_caller kmalloc_node
287 300
288/* System wide caches */ 301#endif /* CONFIG_SLOB */
289extern kmem_cache_t *vm_area_cachep;
290extern kmem_cache_t *names_cachep;
291extern kmem_cache_t *files_cachep;
292extern kmem_cache_t *filp_cachep;
293extern kmem_cache_t *fs_cachep;
294extern kmem_cache_t *sighand_cachep;
295extern kmem_cache_t *bio_cachep;
296 302
297#endif /* __KERNEL__ */ 303#endif /* __KERNEL__ */
298 304
diff --git a/include/linux/smp.h b/include/linux/smp.h
index 51649987f691..7ba23ec8211b 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -99,6 +99,13 @@ static inline int up_smp_call_function(void)
99static inline void smp_send_reschedule(int cpu) { } 99static inline void smp_send_reschedule(int cpu) { }
100#define num_booting_cpus() 1 100#define num_booting_cpus() 1
101#define smp_prepare_boot_cpu() do {} while (0) 101#define smp_prepare_boot_cpu() do {} while (0)
102static inline int smp_call_function_single(int cpuid, void (*func) (void *info),
103 void *info, int retry, int wait)
104{
105 /* Disable interrupts here? */
106 func(info);
107 return 0;
108}
102 109
103#endif /* !SMP */ 110#endif /* !SMP */
104 111
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 8451052ca66f..94b767d64275 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -52,6 +52,7 @@
52#include <linux/thread_info.h> 52#include <linux/thread_info.h>
53#include <linux/kernel.h> 53#include <linux/kernel.h>
54#include <linux/stringify.h> 54#include <linux/stringify.h>
55#include <linux/bottom_half.h>
55 56
56#include <asm/system.h> 57#include <asm/system.h>
57 58
diff --git a/include/linux/sunrpc/rpc_pipe_fs.h b/include/linux/sunrpc/rpc_pipe_fs.h
index a2eb9b4a9de3..4a68125b6de6 100644
--- a/include/linux/sunrpc/rpc_pipe_fs.h
+++ b/include/linux/sunrpc/rpc_pipe_fs.h
@@ -30,7 +30,7 @@ struct rpc_inode {
30#define RPC_PIPE_WAIT_FOR_OPEN 1 30#define RPC_PIPE_WAIT_FOR_OPEN 1
31 int flags; 31 int flags;
32 struct rpc_pipe_ops *ops; 32 struct rpc_pipe_ops *ops;
33 struct work_struct queue_timeout; 33 struct delayed_work queue_timeout;
34}; 34};
35 35
36static inline struct rpc_inode * 36static inline struct rpc_inode *
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
index f399c138f79d..0746c3b16f3a 100644
--- a/include/linux/sunrpc/sched.h
+++ b/include/linux/sunrpc/sched.h
@@ -222,7 +222,7 @@ struct rpc_wait_queue {
222 222
223#ifndef RPC_DEBUG 223#ifndef RPC_DEBUG
224# define RPC_WAITQ_INIT(var,qname) { \ 224# define RPC_WAITQ_INIT(var,qname) { \
225 .lock = SPIN_LOCK_UNLOCKED, \ 225 .lock = __SPIN_LOCK_UNLOCKED(var.lock), \
226 .tasks = { \ 226 .tasks = { \
227 [0] = LIST_HEAD_INIT(var.tasks[0]), \ 227 [0] = LIST_HEAD_INIT(var.tasks[0]), \
228 [1] = LIST_HEAD_INIT(var.tasks[1]), \ 228 [1] = LIST_HEAD_INIT(var.tasks[1]), \
@@ -231,7 +231,7 @@ struct rpc_wait_queue {
231 } 231 }
232#else 232#else
233# define RPC_WAITQ_INIT(var,qname) { \ 233# define RPC_WAITQ_INIT(var,qname) { \
234 .lock = SPIN_LOCK_UNLOCKED, \ 234 .lock = __SPIN_LOCK_UNLOCKED(var.lock), \
235 .tasks = { \ 235 .tasks = { \
236 [0] = LIST_HEAD_INIT(var.tasks[0]), \ 236 [0] = LIST_HEAD_INIT(var.tasks[0]), \
237 [1] = LIST_HEAD_INIT(var.tasks[1]), \ 237 [1] = LIST_HEAD_INIT(var.tasks[1]), \
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index 60394fbc4c70..3e04c1512fc4 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -177,7 +177,7 @@ struct rpc_xprt {
177 unsigned long connect_timeout, 177 unsigned long connect_timeout,
178 bind_timeout, 178 bind_timeout,
179 reestablish_timeout; 179 reestablish_timeout;
180 struct work_struct connect_worker; 180 struct delayed_work connect_worker;
181 unsigned short port; 181 unsigned short port;
182 182
183 /* 183 /*
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index b1237f16ecde..bf99bd49f8ef 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -9,10 +9,13 @@
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/pm.h> 10#include <linux/pm.h>
11 11
12/* page backup entry */ 12/* struct pbe is used for creating lists of pages that should be restored
13 * atomically during the resume from disk, because the page frames they have
14 * occupied before the suspend are in use.
15 */
13struct pbe { 16struct pbe {
14 unsigned long address; /* address of the copy */ 17 void *address; /* address of the copy */
15 unsigned long orig_address; /* original address of page */ 18 void *orig_address; /* original address of a page */
16 struct pbe *next; 19 struct pbe *next;
17}; 20};
18 21
diff --git a/include/linux/swap.h b/include/linux/swap.h
index e7c36ba2a2db..add51cebc8d9 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -218,8 +218,6 @@ extern void swap_unplug_io_fn(struct backing_dev_info *, struct page *);
218/* linux/mm/page_io.c */ 218/* linux/mm/page_io.c */
219extern int swap_readpage(struct file *, struct page *); 219extern int swap_readpage(struct file *, struct page *);
220extern int swap_writepage(struct page *page, struct writeback_control *wbc); 220extern int swap_writepage(struct page *page, struct writeback_control *wbc);
221extern int rw_swap_page_sync(int rw, swp_entry_t entry, struct page *page,
222 struct bio **bio_chain);
223extern int end_swap_bio_read(struct bio *bio, unsigned int bytes_done, int err); 221extern int end_swap_bio_read(struct bio *bio, unsigned int bytes_done, int err);
224 222
225/* linux/mm/swap_state.c */ 223/* linux/mm/swap_state.c */
@@ -247,9 +245,10 @@ extern int swap_duplicate(swp_entry_t);
247extern int valid_swaphandles(swp_entry_t, unsigned long *); 245extern int valid_swaphandles(swp_entry_t, unsigned long *);
248extern void swap_free(swp_entry_t); 246extern void swap_free(swp_entry_t);
249extern void free_swap_and_cache(swp_entry_t); 247extern void free_swap_and_cache(swp_entry_t);
250extern int swap_type_of(dev_t); 248extern int swap_type_of(dev_t, sector_t);
251extern unsigned int count_swap_pages(int, int); 249extern unsigned int count_swap_pages(int, int);
252extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t); 250extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t);
251extern sector_t swapdev_block(int, pgoff_t);
253extern struct swap_info_struct *get_swap_info_struct(unsigned); 252extern struct swap_info_struct *get_swap_info_struct(unsigned);
254extern int can_share_swap_page(struct page *); 253extern int can_share_swap_page(struct page *);
255extern int remove_exclusive_swap_page(struct page *); 254extern int remove_exclusive_swap_page(struct page *);
@@ -259,7 +258,6 @@ extern spinlock_t swap_lock;
259 258
260/* linux/mm/thrash.c */ 259/* linux/mm/thrash.c */
261extern struct mm_struct * swap_token_mm; 260extern struct mm_struct * swap_token_mm;
262extern unsigned long swap_token_default_timeout;
263extern void grab_swap_token(void); 261extern void grab_swap_token(void);
264extern void __put_swap_token(struct mm_struct *); 262extern void __put_swap_token(struct mm_struct *);
265 263
diff --git a/include/linux/taskstats_kern.h b/include/linux/taskstats_kern.h
index 6562a2050a25..7e9680f4afdd 100644
--- a/include/linux/taskstats_kern.h
+++ b/include/linux/taskstats_kern.h
@@ -12,64 +12,27 @@
12#include <net/genetlink.h> 12#include <net/genetlink.h>
13 13
14#ifdef CONFIG_TASKSTATS 14#ifdef CONFIG_TASKSTATS
15extern kmem_cache_t *taskstats_cache; 15extern struct kmem_cache *taskstats_cache;
16extern struct mutex taskstats_exit_mutex; 16extern struct mutex taskstats_exit_mutex;
17 17
18static inline void taskstats_exit_free(struct taskstats *tidstats)
19{
20 if (tidstats)
21 kmem_cache_free(taskstats_cache, tidstats);
22}
23
24static inline void taskstats_tgid_init(struct signal_struct *sig) 18static inline void taskstats_tgid_init(struct signal_struct *sig)
25{ 19{
26 sig->stats = NULL; 20 sig->stats = NULL;
27} 21}
28 22
29static inline void taskstats_tgid_alloc(struct task_struct *tsk)
30{
31 struct signal_struct *sig = tsk->signal;
32 struct taskstats *stats;
33
34 if (sig->stats != NULL)
35 return;
36
37 /* No problem if kmem_cache_zalloc() fails */
38 stats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL);
39
40 spin_lock_irq(&tsk->sighand->siglock);
41 if (!sig->stats) {
42 sig->stats = stats;
43 stats = NULL;
44 }
45 spin_unlock_irq(&tsk->sighand->siglock);
46
47 if (stats)
48 kmem_cache_free(taskstats_cache, stats);
49}
50
51static inline void taskstats_tgid_free(struct signal_struct *sig) 23static inline void taskstats_tgid_free(struct signal_struct *sig)
52{ 24{
53 if (sig->stats) 25 if (sig->stats)
54 kmem_cache_free(taskstats_cache, sig->stats); 26 kmem_cache_free(taskstats_cache, sig->stats);
55} 27}
56 28
57extern void taskstats_exit_alloc(struct taskstats **, unsigned int *); 29extern void taskstats_exit(struct task_struct *, int group_dead);
58extern void taskstats_exit_send(struct task_struct *, struct taskstats *, int, unsigned int);
59extern void taskstats_init_early(void); 30extern void taskstats_init_early(void);
60#else 31#else
61static inline void taskstats_exit_alloc(struct taskstats **ptidstats, unsigned int *mycpu) 32static inline void taskstats_exit(struct task_struct *tsk, int group_dead)
62{}
63static inline void taskstats_exit_free(struct taskstats *ptidstats)
64{}
65static inline void taskstats_exit_send(struct task_struct *tsk,
66 struct taskstats *tidstats,
67 int group_dead, unsigned int cpu)
68{} 33{}
69static inline void taskstats_tgid_init(struct signal_struct *sig) 34static inline void taskstats_tgid_init(struct signal_struct *sig)
70{} 35{}
71static inline void taskstats_tgid_alloc(struct task_struct *tsk)
72{}
73static inline void taskstats_tgid_free(struct signal_struct *sig) 36static inline void taskstats_tgid_free(struct signal_struct *sig)
74{} 37{}
75static inline void taskstats_init_early(void) 38static inline void taskstats_init_early(void)
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 65321f911c1e..f717f0898238 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -53,7 +53,7 @@ struct tty_buffer {
53}; 53};
54 54
55struct tty_bufhead { 55struct tty_bufhead {
56 struct work_struct work; 56 struct delayed_work work;
57 struct semaphore pty_sem; 57 struct semaphore pty_sem;
58 spinlock_t lock; 58 spinlock_t lock;
59 struct tty_buffer *head; /* Queue head */ 59 struct tty_buffer *head; /* Queue head */
diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index 65a68da8bd5d..975c963e5789 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -1,8 +1,43 @@
1#ifndef __LINUX_UACCESS_H__ 1#ifndef __LINUX_UACCESS_H__
2#define __LINUX_UACCESS_H__ 2#define __LINUX_UACCESS_H__
3 3
4#include <linux/preempt.h>
4#include <asm/uaccess.h> 5#include <asm/uaccess.h>
5 6
7/*
8 * These routines enable/disable the pagefault handler in that
9 * it will not take any locks and go straight to the fixup table.
10 *
11 * They have great resemblance to the preempt_disable/enable calls
12 * and in fact they are identical; this is because currently there is
13 * no other way to make the pagefault handlers do this. So we do
14 * disable preemption but we don't necessarily care about that.
15 */
16static inline void pagefault_disable(void)
17{
18 inc_preempt_count();
19 /*
20 * make sure to have issued the store before a pagefault
21 * can hit.
22 */
23 barrier();
24}
25
26static inline void pagefault_enable(void)
27{
28 /*
29 * make sure to issue those last loads/stores before enabling
30 * the pagefault handler again.
31 */
32 barrier();
33 dec_preempt_count();
34 /*
35 * make sure we do..
36 */
37 barrier();
38 preempt_check_resched();
39}
40
6#ifndef ARCH_HAS_NOCACHE_UACCESS 41#ifndef ARCH_HAS_NOCACHE_UACCESS
7 42
8static inline unsigned long __copy_from_user_inatomic_nocache(void *to, 43static inline unsigned long __copy_from_user_inatomic_nocache(void *to,
@@ -30,14 +65,22 @@ static inline unsigned long __copy_from_user_nocache(void *to,
30 * do_page_fault() doesn't attempt to take mmap_sem. This makes 65 * do_page_fault() doesn't attempt to take mmap_sem. This makes
31 * probe_kernel_address() suitable for use within regions where the caller 66 * probe_kernel_address() suitable for use within regions where the caller
32 * already holds mmap_sem, or other locks which nest inside mmap_sem. 67 * already holds mmap_sem, or other locks which nest inside mmap_sem.
68 * This must be a macro because __get_user() needs to know the types of the
69 * args.
70 *
71 * We don't include enough header files to be able to do the set_fs(). We
72 * require that the probe_kernel_address() caller will do that.
33 */ 73 */
34#define probe_kernel_address(addr, retval) \ 74#define probe_kernel_address(addr, retval) \
35 ({ \ 75 ({ \
36 long ret; \ 76 long ret; \
77 mm_segment_t old_fs = get_fs(); \
37 \ 78 \
38 inc_preempt_count(); \ 79 set_fs(KERNEL_DS); \
39 ret = __get_user(retval, (__force typeof(*addr) __user *)addr);\ 80 pagefault_disable(); \
40 dec_preempt_count(); \ 81 ret = __get_user(retval, (__force typeof(retval) __user *)(addr)); \
82 pagefault_enable(); \
83 set_fs(old_fs); \
41 ret; \ 84 ret; \
42 }) 85 })
43 86
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 0cd73edeef13..aab5b1b72021 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -388,7 +388,7 @@ struct usb_device {
388 388
389 int pm_usage_cnt; /* usage counter for autosuspend */ 389 int pm_usage_cnt; /* usage counter for autosuspend */
390#ifdef CONFIG_PM 390#ifdef CONFIG_PM
391 struct work_struct autosuspend; /* for delayed autosuspends */ 391 struct delayed_work autosuspend; /* for delayed autosuspends */
392 struct mutex pm_mutex; /* protects PM operations */ 392 struct mutex pm_mutex; /* protects PM operations */
393 393
394 unsigned auto_pm:1; /* autosuspend/resume in progress */ 394 unsigned auto_pm:1; /* autosuspend/resume in progress */
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index 9bca3539a1e5..f0cb1df7b475 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -11,12 +11,23 @@
11 11
12struct workqueue_struct; 12struct workqueue_struct;
13 13
14struct work_struct;
15typedef void (*work_func_t)(struct work_struct *work);
16
14struct work_struct { 17struct work_struct {
15 unsigned long pending; 18 /* the first word is the work queue pointer and the flags rolled into
19 * one */
20 unsigned long management;
21#define WORK_STRUCT_PENDING 0 /* T if work item pending execution */
22#define WORK_STRUCT_NOAUTOREL 1 /* F if work item automatically released on exec */
23#define WORK_STRUCT_FLAG_MASK (3UL)
24#define WORK_STRUCT_WQ_DATA_MASK (~WORK_STRUCT_FLAG_MASK)
16 struct list_head entry; 25 struct list_head entry;
17 void (*func)(void *); 26 work_func_t func;
18 void *data; 27};
19 void *wq_data; 28
29struct delayed_work {
30 struct work_struct work;
20 struct timer_list timer; 31 struct timer_list timer;
21}; 32};
22 33
@@ -24,77 +35,159 @@ struct execute_work {
24 struct work_struct work; 35 struct work_struct work;
25}; 36};
26 37
27#define __WORK_INITIALIZER(n, f, d) { \ 38#define __WORK_INITIALIZER(n, f) { \
39 .management = 0, \
40 .entry = { &(n).entry, &(n).entry }, \
41 .func = (f), \
42 }
43
44#define __WORK_INITIALIZER_NAR(n, f) { \
45 .management = (1 << WORK_STRUCT_NOAUTOREL), \
28 .entry = { &(n).entry, &(n).entry }, \ 46 .entry = { &(n).entry, &(n).entry }, \
29 .func = (f), \ 47 .func = (f), \
30 .data = (d), \ 48 }
49
50#define __DELAYED_WORK_INITIALIZER(n, f) { \
51 .work = __WORK_INITIALIZER((n).work, (f)), \
52 .timer = TIMER_INITIALIZER(NULL, 0, 0), \
53 }
54
55#define __DELAYED_WORK_INITIALIZER_NAR(n, f) { \
56 .work = __WORK_INITIALIZER_NAR((n).work, (f)), \
31 .timer = TIMER_INITIALIZER(NULL, 0, 0), \ 57 .timer = TIMER_INITIALIZER(NULL, 0, 0), \
32 } 58 }
33 59
34#define DECLARE_WORK(n, f, d) \ 60#define DECLARE_WORK(n, f) \
35 struct work_struct n = __WORK_INITIALIZER(n, f, d) 61 struct work_struct n = __WORK_INITIALIZER(n, f)
62
63#define DECLARE_WORK_NAR(n, f) \
64 struct work_struct n = __WORK_INITIALIZER_NAR(n, f)
65
66#define DECLARE_DELAYED_WORK(n, f) \
67 struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f)
68
69#define DECLARE_DELAYED_WORK_NAR(n, f) \
70 struct dwork_struct n = __DELAYED_WORK_INITIALIZER_NAR(n, f)
36 71
37/* 72/*
38 * initialize a work-struct's func and data pointers: 73 * initialize a work item's function pointer
39 */ 74 */
40#define PREPARE_WORK(_work, _func, _data) \ 75#define PREPARE_WORK(_work, _func) \
41 do { \ 76 do { \
42 (_work)->func = _func; \ 77 (_work)->func = (_func); \
43 (_work)->data = _data; \
44 } while (0) 78 } while (0)
45 79
80#define PREPARE_DELAYED_WORK(_work, _func) \
81 PREPARE_WORK(&(_work)->work, (_func))
82
46/* 83/*
47 * initialize all of a work-struct: 84 * initialize all of a work item in one go
48 */ 85 */
49#define INIT_WORK(_work, _func, _data) \ 86#define INIT_WORK(_work, _func) \
50 do { \ 87 do { \
88 (_work)->management = 0; \
51 INIT_LIST_HEAD(&(_work)->entry); \ 89 INIT_LIST_HEAD(&(_work)->entry); \
52 (_work)->pending = 0; \ 90 PREPARE_WORK((_work), (_func)); \
53 PREPARE_WORK((_work), (_func), (_data)); \ 91 } while (0)
92
93#define INIT_WORK_NAR(_work, _func) \
94 do { \
95 (_work)->management = (1 << WORK_STRUCT_NOAUTOREL); \
96 INIT_LIST_HEAD(&(_work)->entry); \
97 PREPARE_WORK((_work), (_func)); \
98 } while (0)
99
100#define INIT_DELAYED_WORK(_work, _func) \
101 do { \
102 INIT_WORK(&(_work)->work, (_func)); \
103 init_timer(&(_work)->timer); \
104 } while (0)
105
106#define INIT_DELAYED_WORK_NAR(_work, _func) \
107 do { \
108 INIT_WORK_NAR(&(_work)->work, (_func)); \
54 init_timer(&(_work)->timer); \ 109 init_timer(&(_work)->timer); \
55 } while (0) 110 } while (0)
56 111
112/**
113 * work_pending - Find out whether a work item is currently pending
114 * @work: The work item in question
115 */
116#define work_pending(work) \
117 test_bit(WORK_STRUCT_PENDING, &(work)->management)
118
119/**
120 * delayed_work_pending - Find out whether a delayable work item is currently
121 * pending
122 * @work: The work item in question
123 */
124#define delayed_work_pending(work) \
125 test_bit(WORK_STRUCT_PENDING, &(work)->work.management)
126
127/**
128 * work_release - Release a work item under execution
129 * @work: The work item to release
130 *
131 * This is used to release a work item that has been initialised with automatic
132 * release mode disabled (WORK_STRUCT_NOAUTOREL is set). This gives the work
133 * function the opportunity to grab auxiliary data from the container of the
134 * work_struct before clearing the pending bit as the work_struct may be
135 * subject to deallocation the moment the pending bit is cleared.
136 *
137 * In such a case, this should be called in the work function after it has
138 * fetched any data it may require from the containter of the work_struct.
139 * After this function has been called, the work_struct may be scheduled for
140 * further execution or it may be deallocated unless other precautions are
141 * taken.
142 *
143 * This should also be used to release a delayed work item.
144 */
145#define work_release(work) \
146 clear_bit(WORK_STRUCT_PENDING, &(work)->management)
147
148
57extern struct workqueue_struct *__create_workqueue(const char *name, 149extern struct workqueue_struct *__create_workqueue(const char *name,
58 int singlethread); 150 int singlethread,
59#define create_workqueue(name) __create_workqueue((name), 0) 151 int freezeable);
60#define create_singlethread_workqueue(name) __create_workqueue((name), 1) 152#define create_workqueue(name) __create_workqueue((name), 0, 0)
153#define create_freezeable_workqueue(name) __create_workqueue((name), 0, 1)
154#define create_singlethread_workqueue(name) __create_workqueue((name), 1, 0)
61 155
62extern void destroy_workqueue(struct workqueue_struct *wq); 156extern void destroy_workqueue(struct workqueue_struct *wq);
63 157
64extern int FASTCALL(queue_work(struct workqueue_struct *wq, struct work_struct *work)); 158extern int FASTCALL(queue_work(struct workqueue_struct *wq, struct work_struct *work));
65extern int FASTCALL(queue_delayed_work(struct workqueue_struct *wq, struct work_struct *work, unsigned long delay)); 159extern int FASTCALL(queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *work, unsigned long delay));
66extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq, 160extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
67 struct work_struct *work, unsigned long delay); 161 struct delayed_work *work, unsigned long delay);
68extern void FASTCALL(flush_workqueue(struct workqueue_struct *wq)); 162extern void FASTCALL(flush_workqueue(struct workqueue_struct *wq));
69 163
70extern int FASTCALL(schedule_work(struct work_struct *work)); 164extern int FASTCALL(schedule_work(struct work_struct *work));
71extern int FASTCALL(schedule_delayed_work(struct work_struct *work, unsigned long delay)); 165extern int FASTCALL(schedule_delayed_work(struct delayed_work *work, unsigned long delay));
72 166
73extern int schedule_delayed_work_on(int cpu, struct work_struct *work, unsigned long delay); 167extern int schedule_delayed_work_on(int cpu, struct delayed_work *work, unsigned long delay);
74extern int schedule_on_each_cpu(void (*func)(void *info), void *info); 168extern int schedule_on_each_cpu(work_func_t func);
75extern void flush_scheduled_work(void); 169extern void flush_scheduled_work(void);
76extern int current_is_keventd(void); 170extern int current_is_keventd(void);
77extern int keventd_up(void); 171extern int keventd_up(void);
78 172
79extern void init_workqueues(void); 173extern void init_workqueues(void);
80void cancel_rearming_delayed_work(struct work_struct *work); 174void cancel_rearming_delayed_work(struct delayed_work *work);
81void cancel_rearming_delayed_workqueue(struct workqueue_struct *, 175void cancel_rearming_delayed_workqueue(struct workqueue_struct *,
82 struct work_struct *); 176 struct delayed_work *);
83int execute_in_process_context(void (*fn)(void *), void *, 177int execute_in_process_context(work_func_t fn, struct execute_work *);
84 struct execute_work *);
85 178
86/* 179/*
87 * Kill off a pending schedule_delayed_work(). Note that the work callback 180 * Kill off a pending schedule_delayed_work(). Note that the work callback
88 * function may still be running on return from cancel_delayed_work(). Run 181 * function may still be running on return from cancel_delayed_work(). Run
89 * flush_scheduled_work() to wait on it. 182 * flush_scheduled_work() to wait on it.
90 */ 183 */
91static inline int cancel_delayed_work(struct work_struct *work) 184static inline int cancel_delayed_work(struct delayed_work *work)
92{ 185{
93 int ret; 186 int ret;
94 187
95 ret = del_timer_sync(&work->timer); 188 ret = del_timer_sync(&work->timer);
96 if (ret) 189 if (ret)
97 clear_bit(0, &work->pending); 190 clear_bit(WORK_STRUCT_PENDING, &work->work.management);
98 return ret; 191 return ret;
99} 192}
100 193
diff --git a/include/net/dst.h b/include/net/dst.h
index e156e38e4ac3..62b7e7598e9a 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -98,7 +98,7 @@ struct dst_ops
98 int entry_size; 98 int entry_size;
99 99
100 atomic_t entries; 100 atomic_t entries;
101 kmem_cache_t *kmem_cachep; 101 struct kmem_cache *kmem_cachep;
102}; 102};
103 103
104#ifdef __KERNEL__ 104#ifdef __KERNEL__
diff --git a/include/net/ieee80211softmac.h b/include/net/ieee80211softmac.h
index 617b672b1132..89119277553d 100644
--- a/include/net/ieee80211softmac.h
+++ b/include/net/ieee80211softmac.h
@@ -108,8 +108,8 @@ struct ieee80211softmac_assoc_info {
108 /* Scan retries remaining */ 108 /* Scan retries remaining */
109 int scan_retry; 109 int scan_retry;
110 110
111 struct work_struct work; 111 struct delayed_work work;
112 struct work_struct timeout; 112 struct delayed_work timeout;
113}; 113};
114 114
115struct ieee80211softmac_bss_info { 115struct ieee80211softmac_bss_info {
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index a9eb2eaf094e..34cc76e3ddb4 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -125,7 +125,7 @@ struct inet_hashinfo {
125 rwlock_t lhash_lock ____cacheline_aligned; 125 rwlock_t lhash_lock ____cacheline_aligned;
126 atomic_t lhash_users; 126 atomic_t lhash_users;
127 wait_queue_head_t lhash_wait; 127 wait_queue_head_t lhash_wait;
128 kmem_cache_t *bind_bucket_cachep; 128 struct kmem_cache *bind_bucket_cachep;
129}; 129};
130 130
131static inline struct inet_ehash_bucket *inet_ehash_bucket( 131static inline struct inet_ehash_bucket *inet_ehash_bucket(
@@ -136,10 +136,10 @@ static inline struct inet_ehash_bucket *inet_ehash_bucket(
136} 136}
137 137
138extern struct inet_bind_bucket * 138extern struct inet_bind_bucket *
139 inet_bind_bucket_create(kmem_cache_t *cachep, 139 inet_bind_bucket_create(struct kmem_cache *cachep,
140 struct inet_bind_hashbucket *head, 140 struct inet_bind_hashbucket *head,
141 const unsigned short snum); 141 const unsigned short snum);
142extern void inet_bind_bucket_destroy(kmem_cache_t *cachep, 142extern void inet_bind_bucket_destroy(struct kmem_cache *cachep,
143 struct inet_bind_bucket *tb); 143 struct inet_bind_bucket *tb);
144 144
145static inline int inet_bhashfn(const __u16 lport, const int bhash_size) 145static inline int inet_bhashfn(const __u16 lport, const int bhash_size)
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h
index 5f48748fe017..f7be1ac73601 100644
--- a/include/net/inet_timewait_sock.h
+++ b/include/net/inet_timewait_sock.h
@@ -84,7 +84,7 @@ struct inet_timewait_death_row {
84}; 84};
85 85
86extern void inet_twdr_hangman(unsigned long data); 86extern void inet_twdr_hangman(unsigned long data);
87extern void inet_twdr_twkill_work(void *data); 87extern void inet_twdr_twkill_work(struct work_struct *work);
88extern void inet_twdr_twcal_tick(unsigned long data); 88extern void inet_twdr_twcal_tick(unsigned long data);
89 89
90#if (BITS_PER_LONG == 64) 90#if (BITS_PER_LONG == 64)
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index c8aacbd2e333..23967031ddb7 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -160,7 +160,7 @@ struct neigh_table
160 atomic_t entries; 160 atomic_t entries;
161 rwlock_t lock; 161 rwlock_t lock;
162 unsigned long last_rand; 162 unsigned long last_rand;
163 kmem_cache_t *kmem_cachep; 163 struct kmem_cache *kmem_cachep;
164 struct neigh_statistics *stats; 164 struct neigh_statistics *stats;
165 struct neighbour **hash_buckets; 165 struct neighbour **hash_buckets;
166 unsigned int hash_mask; 166 unsigned int hash_mask;
diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h
index cef3136e22a3..41bcc9eb4206 100644
--- a/include/net/netfilter/nf_conntrack_expect.h
+++ b/include/net/netfilter/nf_conntrack_expect.h
@@ -7,7 +7,7 @@
7#include <net/netfilter/nf_conntrack.h> 7#include <net/netfilter/nf_conntrack.h>
8 8
9extern struct list_head nf_conntrack_expect_list; 9extern struct list_head nf_conntrack_expect_list;
10extern kmem_cache_t *nf_conntrack_expect_cachep; 10extern struct kmem_cache *nf_conntrack_expect_cachep;
11extern struct file_operations exp_file_ops; 11extern struct file_operations exp_file_ops;
12 12
13struct nf_conntrack_expect 13struct nf_conntrack_expect
diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index e37baaf2080b..7aed02ce2b65 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -29,7 +29,7 @@ struct proto;
29struct request_sock_ops { 29struct request_sock_ops {
30 int family; 30 int family;
31 int obj_size; 31 int obj_size;
32 kmem_cache_t *slab; 32 struct kmem_cache *slab;
33 int (*rtx_syn_ack)(struct sock *sk, 33 int (*rtx_syn_ack)(struct sock *sk,
34 struct request_sock *req, 34 struct request_sock *req,
35 struct dst_entry *dst); 35 struct dst_entry *dst);
@@ -60,7 +60,7 @@ struct request_sock {
60 60
61static inline struct request_sock *reqsk_alloc(const struct request_sock_ops *ops) 61static inline struct request_sock *reqsk_alloc(const struct request_sock_ops *ops)
62{ 62{
63 struct request_sock *req = kmem_cache_alloc(ops->slab, SLAB_ATOMIC); 63 struct request_sock *req = kmem_cache_alloc(ops->slab, GFP_ATOMIC);
64 64
65 if (req != NULL) 65 if (req != NULL)
66 req->rsk_ops = ops; 66 req->rsk_ops = ops;
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index f8cbe40f52c0..c089f93ba591 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -1030,7 +1030,7 @@ void sctp_inq_init(struct sctp_inq *);
1030void sctp_inq_free(struct sctp_inq *); 1030void sctp_inq_free(struct sctp_inq *);
1031void sctp_inq_push(struct sctp_inq *, struct sctp_chunk *packet); 1031void sctp_inq_push(struct sctp_inq *, struct sctp_chunk *packet);
1032struct sctp_chunk *sctp_inq_pop(struct sctp_inq *); 1032struct sctp_chunk *sctp_inq_pop(struct sctp_inq *);
1033void sctp_inq_set_th_handler(struct sctp_inq *, void (*)(void *), void *); 1033void sctp_inq_set_th_handler(struct sctp_inq *, work_func_t);
1034 1034
1035/* This is the structure we use to hold outbound chunks. You push 1035/* This is the structure we use to hold outbound chunks. You push
1036 * chunks in and they automatically pop out the other end as bundled 1036 * chunks in and they automatically pop out the other end as bundled
diff --git a/include/net/sock.h b/include/net/sock.h
index fe3a33fad03f..03684e702d13 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -571,7 +571,7 @@ struct proto {
571 int *sysctl_rmem; 571 int *sysctl_rmem;
572 int max_header; 572 int max_header;
573 573
574 kmem_cache_t *slab; 574 struct kmem_cache *slab;
575 unsigned int obj_size; 575 unsigned int obj_size;
576 576
577 atomic_t *orphan_count; 577 atomic_t *orphan_count;
@@ -746,6 +746,25 @@ static inline int sk_stream_wmem_schedule(struct sock *sk, int size)
746 */ 746 */
747#define sock_owned_by_user(sk) ((sk)->sk_lock.owner) 747#define sock_owned_by_user(sk) ((sk)->sk_lock.owner)
748 748
749/*
750 * Macro so as to not evaluate some arguments when
751 * lockdep is not enabled.
752 *
753 * Mark both the sk_lock and the sk_lock.slock as a
754 * per-address-family lock class.
755 */
756#define sock_lock_init_class_and_name(sk, sname, skey, name, key) \
757do { \
758 sk->sk_lock.owner = NULL; \
759 init_waitqueue_head(&sk->sk_lock.wq); \
760 spin_lock_init(&(sk)->sk_lock.slock); \
761 debug_check_no_locks_freed((void *)&(sk)->sk_lock, \
762 sizeof((sk)->sk_lock)); \
763 lockdep_set_class_and_name(&(sk)->sk_lock.slock, \
764 (skey), (sname)); \
765 lockdep_init_map(&(sk)->sk_lock.dep_map, (name), (key), 0); \
766} while (0)
767
749extern void FASTCALL(lock_sock_nested(struct sock *sk, int subclass)); 768extern void FASTCALL(lock_sock_nested(struct sock *sk, int subclass));
750 769
751static inline void lock_sock(struct sock *sk) 770static inline void lock_sock(struct sock *sk)
diff --git a/include/net/timewait_sock.h b/include/net/timewait_sock.h
index d7a306ea560d..1e1ee3253fd8 100644
--- a/include/net/timewait_sock.h
+++ b/include/net/timewait_sock.h
@@ -15,7 +15,7 @@
15#include <net/sock.h> 15#include <net/sock.h>
16 16
17struct timewait_sock_ops { 17struct timewait_sock_ops {
18 kmem_cache_t *twsk_slab; 18 struct kmem_cache *twsk_slab;
19 unsigned int twsk_obj_size; 19 unsigned int twsk_obj_size;
20 int (*twsk_unique)(struct sock *sk, 20 int (*twsk_unique)(struct sock *sk,
21 struct sock *sktw, void *twp); 21 struct sock *sktw, void *twp);
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 44b2f82a6eec..0c775fceb675 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -201,9 +201,14 @@ struct domain_device {
201 void *lldd_dev; 201 void *lldd_dev;
202}; 202};
203 203
204struct sas_discovery_event {
205 struct work_struct work;
206 struct asd_sas_port *port;
207};
208
204struct sas_discovery { 209struct sas_discovery {
205 spinlock_t disc_event_lock; 210 spinlock_t disc_event_lock;
206 struct work_struct disc_work[DISC_NUM_EVENTS]; 211 struct sas_discovery_event disc_work[DISC_NUM_EVENTS];
207 unsigned long pending; 212 unsigned long pending;
208 u8 fanout_sas_addr[8]; 213 u8 fanout_sas_addr[8];
209 u8 eeds_a[8]; 214 u8 eeds_a[8];
@@ -249,14 +254,19 @@ struct asd_sas_port {
249 void *lldd_port; /* not touched by the sas class code */ 254 void *lldd_port; /* not touched by the sas class code */
250}; 255};
251 256
257struct asd_sas_event {
258 struct work_struct work;
259 struct asd_sas_phy *phy;
260};
261
252/* The phy pretty much is controlled by the LLDD. 262/* The phy pretty much is controlled by the LLDD.
253 * The class only reads those fields. 263 * The class only reads those fields.
254 */ 264 */
255struct asd_sas_phy { 265struct asd_sas_phy {
256/* private: */ 266/* private: */
257 /* protected by ha->event_lock */ 267 /* protected by ha->event_lock */
258 struct work_struct port_events[PORT_NUM_EVENTS]; 268 struct asd_sas_event port_events[PORT_NUM_EVENTS];
259 struct work_struct phy_events[PHY_NUM_EVENTS]; 269 struct asd_sas_event phy_events[PHY_NUM_EVENTS];
260 270
261 unsigned long port_events_pending; 271 unsigned long port_events_pending;
262 unsigned long phy_events_pending; 272 unsigned long phy_events_pending;
@@ -308,10 +318,15 @@ struct scsi_core {
308 int queue_thread_kill; 318 int queue_thread_kill;
309}; 319};
310 320
321struct sas_ha_event {
322 struct work_struct work;
323 struct sas_ha_struct *ha;
324};
325
311struct sas_ha_struct { 326struct sas_ha_struct {
312/* private: */ 327/* private: */
313 spinlock_t event_lock; 328 spinlock_t event_lock;
314 struct work_struct ha_events[HA_NUM_EVENTS]; 329 struct sas_ha_event ha_events[HA_NUM_EVENTS];
315 unsigned long pending; 330 unsigned long pending;
316 331
317 struct scsi_core core; 332 struct scsi_core core;
@@ -542,7 +557,7 @@ struct sas_task {
542 557
543static inline struct sas_task *sas_alloc_task(gfp_t flags) 558static inline struct sas_task *sas_alloc_task(gfp_t flags)
544{ 559{
545 extern kmem_cache_t *sas_task_cache; 560 extern struct kmem_cache *sas_task_cache;
546 struct sas_task *task = kmem_cache_alloc(sas_task_cache, flags); 561 struct sas_task *task = kmem_cache_alloc(sas_task_cache, flags);
547 562
548 if (task) { 563 if (task) {
@@ -560,7 +575,7 @@ static inline struct sas_task *sas_alloc_task(gfp_t flags)
560static inline void sas_free_task(struct sas_task *task) 575static inline void sas_free_task(struct sas_task *task)
561{ 576{
562 if (task) { 577 if (task) {
563 extern kmem_cache_t *sas_task_cache; 578 extern struct kmem_cache *sas_task_cache;
564 BUG_ON(!list_empty(&task->list)); 579 BUG_ON(!list_empty(&task->list));
565 kmem_cache_free(sas_task_cache, task); 580 kmem_cache_free(sas_task_cache, task);
566 } 581 }
@@ -631,6 +646,6 @@ void sas_unregister_dev(struct domain_device *);
631 646
632void sas_init_dev(struct domain_device *); 647void sas_init_dev(struct domain_device *);
633 648
634void sas_task_abort(struct sas_task *task); 649void sas_task_abort(struct work_struct *);
635 650
636#endif /* _SASLIB_H_ */ 651#endif /* _SASLIB_H_ */
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
index fd352323378b..798f7c7ee426 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -206,9 +206,9 @@ struct fc_rport { /* aka fc_starget_attrs */
206 u8 flags; 206 u8 flags;
207 struct list_head peers; 207 struct list_head peers;
208 struct device dev; 208 struct device dev;
209 struct work_struct dev_loss_work; 209 struct delayed_work dev_loss_work;
210 struct work_struct scan_work; 210 struct work_struct scan_work;
211 struct work_struct fail_io_work; 211 struct delayed_work fail_io_work;
212 struct work_struct stgt_delete_work; 212 struct work_struct stgt_delete_work;
213 struct work_struct rport_delete_work; 213 struct work_struct rport_delete_work;
214} __attribute__((aligned(sizeof(unsigned long)))); 214} __attribute__((aligned(sizeof(unsigned long))));
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 4b95c89c95c9..d5c218ddc527 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -176,7 +176,7 @@ struct iscsi_cls_session {
176 176
177 /* recovery fields */ 177 /* recovery fields */
178 int recovery_tmo; 178 int recovery_tmo;
179 struct work_struct recovery_work; 179 struct delayed_work recovery_work;
180 180
181 int target_id; 181 int target_id;
182 182
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 4c43521cc493..33720397a904 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -511,7 +511,7 @@ struct snd_ac97 {
511#ifdef CONFIG_SND_AC97_POWER_SAVE 511#ifdef CONFIG_SND_AC97_POWER_SAVE
512 unsigned int power_up; /* power states */ 512 unsigned int power_up; /* power states */
513 struct workqueue_struct *power_workq; 513 struct workqueue_struct *power_workq;
514 struct work_struct power_work; 514 struct delayed_work power_work;
515#endif 515#endif
516 struct device dev; 516 struct device dev;
517}; 517};
diff --git a/include/sound/ak4114.h b/include/sound/ak4114.h
index 11702aa0bea9..2ee061625fd0 100644
--- a/include/sound/ak4114.h
+++ b/include/sound/ak4114.h
@@ -182,7 +182,7 @@ struct ak4114 {
182 unsigned char rcs0; 182 unsigned char rcs0;
183 unsigned char rcs1; 183 unsigned char rcs1;
184 struct workqueue_struct *workqueue; 184 struct workqueue_struct *workqueue;
185 struct work_struct work; 185 struct delayed_work work;
186 void *change_callback_private; 186 void *change_callback_private;
187 void (*change_callback)(struct ak4114 *ak4114, unsigned char c0, unsigned char c1); 187 void (*change_callback)(struct ak4114 *ak4114, unsigned char c0, unsigned char c1);
188}; 188};
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index 919a80cb322e..2cfd7cb36e79 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -6,6 +6,7 @@
6#include <linux/romfs_fs.h> 6#include <linux/romfs_fs.h>
7#include <linux/initrd.h> 7#include <linux/initrd.h>
8#include <linux/sched.h> 8#include <linux/sched.h>
9#include <linux/freezer.h>
9 10
10#include "do_mounts.h" 11#include "do_mounts.h"
11 12
diff --git a/init/initramfs.c b/init/initramfs.c
index d28c1094d7e5..85f04037ade1 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -182,6 +182,10 @@ static int __init do_collect(void)
182 182
183static int __init do_header(void) 183static int __init do_header(void)
184{ 184{
185 if (memcmp(collected, "070707", 6)==0) {
186 error("incorrect cpio method used: use -H newc option");
187 return 1;
188 }
185 if (memcmp(collected, "070701", 6)) { 189 if (memcmp(collected, "070701", 6)) {
186 error("no cpio magic"); 190 error("no cpio magic");
187 return 1; 191 return 1;
diff --git a/init/main.c b/init/main.c
index 985c9ed86050..1174ae3aec8c 100644
--- a/init/main.c
+++ b/init/main.c
@@ -74,6 +74,10 @@
74#error Sorry, your GCC is too old. It builds incorrect kernels. 74#error Sorry, your GCC is too old. It builds incorrect kernels.
75#endif 75#endif
76 76
77#if __GNUC__ == 4 && __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ == 0
78#warning gcc-4.1.0 is known to miscompile the kernel. A different compiler version is recommended.
79#endif
80
77static int init(void *); 81static int init(void *);
78 82
79extern void init_IRQ(void); 83extern void init_IRQ(void);
diff --git a/ipc/compat.c b/ipc/compat.c
index 4d20cfd38f0a..fa18141539fb 100644
--- a/ipc/compat.c
+++ b/ipc/compat.c
@@ -115,7 +115,6 @@ struct compat_shm_info {
115 115
116extern int sem_ctls[]; 116extern int sem_ctls[];
117#define sc_semopm (sem_ctls[2]) 117#define sc_semopm (sem_ctls[2])
118#define MAXBUF (64*1024)
119 118
120static inline int compat_ipc_parse_version(int *cmd) 119static inline int compat_ipc_parse_version(int *cmd)
121{ 120{
@@ -307,35 +306,30 @@ long compat_sys_semctl(int first, int second, int third, void __user *uptr)
307 306
308long compat_sys_msgsnd(int first, int second, int third, void __user *uptr) 307long compat_sys_msgsnd(int first, int second, int third, void __user *uptr)
309{ 308{
310 struct msgbuf __user *p;
311 struct compat_msgbuf __user *up = uptr; 309 struct compat_msgbuf __user *up = uptr;
312 long type; 310 long type;
313 311
314 if (first < 0) 312 if (first < 0)
315 return -EINVAL; 313 return -EINVAL;
316 if (second < 0 || (second >= MAXBUF - sizeof(struct msgbuf))) 314 if (second < 0)
317 return -EINVAL; 315 return -EINVAL;
318 316
319 p = compat_alloc_user_space(second + sizeof(struct msgbuf)); 317 if (get_user(type, &up->mtype))
320 if (get_user(type, &up->mtype) ||
321 put_user(type, &p->mtype) ||
322 copy_in_user(p->mtext, up->mtext, second))
323 return -EFAULT; 318 return -EFAULT;
324 319
325 return sys_msgsnd(first, p, second, third); 320 return do_msgsnd(first, type, up->mtext, second, third);
326} 321}
327 322
328long compat_sys_msgrcv(int first, int second, int msgtyp, int third, 323long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
329 int version, void __user *uptr) 324 int version, void __user *uptr)
330{ 325{
331 struct msgbuf __user *p;
332 struct compat_msgbuf __user *up; 326 struct compat_msgbuf __user *up;
333 long type; 327 long type;
334 int err; 328 int err;
335 329
336 if (first < 0) 330 if (first < 0)
337 return -EINVAL; 331 return -EINVAL;
338 if (second < 0 || (second >= MAXBUF - sizeof(struct msgbuf))) 332 if (second < 0)
339 return -EINVAL; 333 return -EINVAL;
340 334
341 if (!version) { 335 if (!version) {
@@ -349,14 +343,11 @@ long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
349 uptr = compat_ptr(ipck.msgp); 343 uptr = compat_ptr(ipck.msgp);
350 msgtyp = ipck.msgtyp; 344 msgtyp = ipck.msgtyp;
351 } 345 }
352 p = compat_alloc_user_space(second + sizeof(struct msgbuf)); 346 up = uptr;
353 err = sys_msgrcv(first, p, second, msgtyp, third); 347 err = do_msgrcv(first, &type, up->mtext, second, msgtyp, third);
354 if (err < 0) 348 if (err < 0)
355 goto out; 349 goto out;
356 up = uptr; 350 if (put_user(type, &up->mtype))
357 if (get_user(type, &p->mtype) ||
358 put_user(type, &up->mtype) ||
359 copy_in_user(up->mtext, p->mtext, err))
360 err = -EFAULT; 351 err = -EFAULT;
361out: 352out:
362 return err; 353 return err;
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 7c274002c9f5..3acc1661e517 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -90,7 +90,7 @@ static struct super_operations mqueue_super_ops;
90static void remove_notification(struct mqueue_inode_info *info); 90static void remove_notification(struct mqueue_inode_info *info);
91 91
92static spinlock_t mq_lock; 92static spinlock_t mq_lock;
93static kmem_cache_t *mqueue_inode_cachep; 93static struct kmem_cache *mqueue_inode_cachep;
94static struct vfsmount *mqueue_mnt; 94static struct vfsmount *mqueue_mnt;
95 95
96static unsigned int queues_count; 96static unsigned int queues_count;
@@ -211,7 +211,7 @@ static int mqueue_get_sb(struct file_system_type *fs_type,
211 return get_sb_single(fs_type, flags, data, mqueue_fill_super, mnt); 211 return get_sb_single(fs_type, flags, data, mqueue_fill_super, mnt);
212} 212}
213 213
214static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags) 214static void init_once(void *foo, struct kmem_cache * cachep, unsigned long flags)
215{ 215{
216 struct mqueue_inode_info *p = (struct mqueue_inode_info *) foo; 216 struct mqueue_inode_info *p = (struct mqueue_inode_info *) foo;
217 217
@@ -224,7 +224,7 @@ static struct inode *mqueue_alloc_inode(struct super_block *sb)
224{ 224{
225 struct mqueue_inode_info *ei; 225 struct mqueue_inode_info *ei;
226 226
227 ei = kmem_cache_alloc(mqueue_inode_cachep, SLAB_KERNEL); 227 ei = kmem_cache_alloc(mqueue_inode_cachep, GFP_KERNEL);
228 if (!ei) 228 if (!ei)
229 return NULL; 229 return NULL;
230 return &ei->vfs_inode; 230 return &ei->vfs_inode;
diff --git a/ipc/msg.c b/ipc/msg.c
index 1266b1d0c8e3..a388824740e7 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -626,12 +626,11 @@ static inline int pipelined_send(struct msg_queue *msq, struct msg_msg *msg)
626 return 0; 626 return 0;
627} 627}
628 628
629asmlinkage long 629long do_msgsnd(int msqid, long mtype, void __user *mtext,
630sys_msgsnd(int msqid, struct msgbuf __user *msgp, size_t msgsz, int msgflg) 630 size_t msgsz, int msgflg)
631{ 631{
632 struct msg_queue *msq; 632 struct msg_queue *msq;
633 struct msg_msg *msg; 633 struct msg_msg *msg;
634 long mtype;
635 int err; 634 int err;
636 struct ipc_namespace *ns; 635 struct ipc_namespace *ns;
637 636
@@ -639,12 +638,10 @@ sys_msgsnd(int msqid, struct msgbuf __user *msgp, size_t msgsz, int msgflg)
639 638
640 if (msgsz > ns->msg_ctlmax || (long) msgsz < 0 || msqid < 0) 639 if (msgsz > ns->msg_ctlmax || (long) msgsz < 0 || msqid < 0)
641 return -EINVAL; 640 return -EINVAL;
642 if (get_user(mtype, &msgp->mtype))
643 return -EFAULT;
644 if (mtype < 1) 641 if (mtype < 1)
645 return -EINVAL; 642 return -EINVAL;
646 643
647 msg = load_msg(msgp->mtext, msgsz); 644 msg = load_msg(mtext, msgsz);
648 if (IS_ERR(msg)) 645 if (IS_ERR(msg))
649 return PTR_ERR(msg); 646 return PTR_ERR(msg);
650 647
@@ -723,6 +720,16 @@ out_free:
723 return err; 720 return err;
724} 721}
725 722
723asmlinkage long
724sys_msgsnd(int msqid, struct msgbuf __user *msgp, size_t msgsz, int msgflg)
725{
726 long mtype;
727
728 if (get_user(mtype, &msgp->mtype))
729 return -EFAULT;
730 return do_msgsnd(msqid, mtype, msgp->mtext, msgsz, msgflg);
731}
732
726static inline int convert_mode(long *msgtyp, int msgflg) 733static inline int convert_mode(long *msgtyp, int msgflg)
727{ 734{
728 /* 735 /*
@@ -742,8 +749,8 @@ static inline int convert_mode(long *msgtyp, int msgflg)
742 return SEARCH_EQUAL; 749 return SEARCH_EQUAL;
743} 750}
744 751
745asmlinkage long sys_msgrcv(int msqid, struct msgbuf __user *msgp, size_t msgsz, 752long do_msgrcv(int msqid, long *pmtype, void __user *mtext,
746 long msgtyp, int msgflg) 753 size_t msgsz, long msgtyp, int msgflg)
747{ 754{
748 struct msg_queue *msq; 755 struct msg_queue *msq;
749 struct msg_msg *msg; 756 struct msg_msg *msg;
@@ -889,15 +896,30 @@ out_unlock:
889 return PTR_ERR(msg); 896 return PTR_ERR(msg);
890 897
891 msgsz = (msgsz > msg->m_ts) ? msg->m_ts : msgsz; 898 msgsz = (msgsz > msg->m_ts) ? msg->m_ts : msgsz;
892 if (put_user (msg->m_type, &msgp->mtype) || 899 *pmtype = msg->m_type;
893 store_msg(msgp->mtext, msg, msgsz)) { 900 if (store_msg(mtext, msg, msgsz))
894 msgsz = -EFAULT; 901 msgsz = -EFAULT;
895 } 902
896 free_msg(msg); 903 free_msg(msg);
897 904
898 return msgsz; 905 return msgsz;
899} 906}
900 907
908asmlinkage long sys_msgrcv(int msqid, struct msgbuf __user *msgp, size_t msgsz,
909 long msgtyp, int msgflg)
910{
911 long err, mtype;
912
913 err = do_msgrcv(msqid, &mtype, msgp->mtext, msgsz, msgtyp, msgflg);
914 if (err < 0)
915 goto out;
916
917 if (put_user(mtype, &msgp->mtype))
918 err = -EFAULT;
919out:
920 return err;
921}
922
901#ifdef CONFIG_PROC_FS 923#ifdef CONFIG_PROC_FS
902static int sysvipc_msg_proc_show(struct seq_file *s, void *it) 924static int sysvipc_msg_proc_show(struct seq_file *s, void *it)
903{ 925{
diff --git a/ipc/sem.c b/ipc/sem.c
index 21b3289d640c..d3e12efd55cb 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1070,14 +1070,13 @@ static struct sem_undo *find_undo(struct ipc_namespace *ns, int semid)
1070 ipc_rcu_getref(sma); 1070 ipc_rcu_getref(sma);
1071 sem_unlock(sma); 1071 sem_unlock(sma);
1072 1072
1073 new = (struct sem_undo *) kmalloc(sizeof(struct sem_undo) + sizeof(short)*nsems, GFP_KERNEL); 1073 new = kzalloc(sizeof(struct sem_undo) + sizeof(short)*nsems, GFP_KERNEL);
1074 if (!new) { 1074 if (!new) {
1075 ipc_lock_by_ptr(&sma->sem_perm); 1075 ipc_lock_by_ptr(&sma->sem_perm);
1076 ipc_rcu_putref(sma); 1076 ipc_rcu_putref(sma);
1077 sem_unlock(sma); 1077 sem_unlock(sma);
1078 return ERR_PTR(-ENOMEM); 1078 return ERR_PTR(-ENOMEM);
1079 } 1079 }
1080 memset(new, 0, sizeof(struct sem_undo) + sizeof(short)*nsems);
1081 new->semadj = (short *) &new[1]; 1080 new->semadj = (short *) &new[1];
1082 new->semid = semid; 1081 new->semid = semid;
1083 1082
diff --git a/ipc/util.c b/ipc/util.c
index cd8bb14a431f..a9b7a227b8d4 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -514,6 +514,11 @@ void ipc_rcu_getref(void *ptr)
514 container_of(ptr, struct ipc_rcu_hdr, data)->refcount++; 514 container_of(ptr, struct ipc_rcu_hdr, data)->refcount++;
515} 515}
516 516
517static void ipc_do_vfree(struct work_struct *work)
518{
519 vfree(container_of(work, struct ipc_rcu_sched, work));
520}
521
517/** 522/**
518 * ipc_schedule_free - free ipc + rcu space 523 * ipc_schedule_free - free ipc + rcu space
519 * @head: RCU callback structure for queued work 524 * @head: RCU callback structure for queued work
@@ -528,7 +533,7 @@ static void ipc_schedule_free(struct rcu_head *head)
528 struct ipc_rcu_sched *sched = 533 struct ipc_rcu_sched *sched =
529 container_of(&(grace->data[0]), struct ipc_rcu_sched, data[0]); 534 container_of(&(grace->data[0]), struct ipc_rcu_sched, data[0]);
530 535
531 INIT_WORK(&sched->work, vfree, sched); 536 INIT_WORK(&sched->work, ipc_do_vfree);
532 schedule_work(&sched->work); 537 schedule_work(&sched->work);
533} 538}
534 539
diff --git a/kernel/Kconfig.hz b/kernel/Kconfig.hz
index 248e1c396f8b..4af15802ccd4 100644
--- a/kernel/Kconfig.hz
+++ b/kernel/Kconfig.hz
@@ -7,7 +7,7 @@ choice
7 default HZ_250 7 default HZ_250
8 help 8 help
9 Allows the configuration of the timer frequency. It is customary 9 Allows the configuration of the timer frequency. It is customary
10 to have the timer interrupt run at 1000 HZ but 100 HZ may be more 10 to have the timer interrupt run at 1000 Hz but 100 Hz may be more
11 beneficial for servers and NUMA systems that do not need to have 11 beneficial for servers and NUMA systems that do not need to have
12 a fast response for user interaction and that may experience bus 12 a fast response for user interaction and that may experience bus
13 contention and cacheline bounces as a result of timer interrupts. 13 contention and cacheline bounces as a result of timer interrupts.
@@ -19,21 +19,30 @@ choice
19 config HZ_100 19 config HZ_100
20 bool "100 HZ" 20 bool "100 HZ"
21 help 21 help
22 100 HZ is a typical choice for servers, SMP and NUMA systems 22 100 Hz is a typical choice for servers, SMP and NUMA systems
23 with lots of processors that may show reduced performance if 23 with lots of processors that may show reduced performance if
24 too many timer interrupts are occurring. 24 too many timer interrupts are occurring.
25 25
26 config HZ_250 26 config HZ_250
27 bool "250 HZ" 27 bool "250 HZ"
28 help 28 help
29 250 HZ is a good compromise choice allowing server performance 29 250 Hz is a good compromise choice allowing server performance
30 while also showing good interactive responsiveness even 30 while also showing good interactive responsiveness even
31 on SMP and NUMA systems. 31 on SMP and NUMA systems. If you are going to be using NTSC video
32 or multimedia, selected 300Hz instead.
33
34 config HZ_300
35 bool "300 HZ"
36 help
37 300 Hz is a good compromise choice allowing server performance
38 while also showing good interactive responsiveness even
39 on SMP and NUMA systems and exactly dividing by both PAL and
40 NTSC frame rates for video and multimedia work.
32 41
33 config HZ_1000 42 config HZ_1000
34 bool "1000 HZ" 43 bool "1000 HZ"
35 help 44 help
36 1000 HZ is the preferred choice for desktop systems and other 45 1000 Hz is the preferred choice for desktop systems and other
37 systems requiring fast interactive responses to events. 46 systems requiring fast interactive responses to events.
38 47
39endchoice 48endchoice
@@ -42,5 +51,6 @@ config HZ
42 int 51 int
43 default 100 if HZ_100 52 default 100 if HZ_100
44 default 250 if HZ_250 53 default 250 if HZ_250
54 default 300 if HZ_300
45 default 1000 if HZ_1000 55 default 1000 if HZ_1000
46 56
diff --git a/kernel/acct.c b/kernel/acct.c
index 0aad5ca36a81..dc12db8600e7 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -89,7 +89,8 @@ struct acct_glbs {
89 struct timer_list timer; 89 struct timer_list timer;
90}; 90};
91 91
92static struct acct_glbs acct_globals __cacheline_aligned = {SPIN_LOCK_UNLOCKED}; 92static struct acct_glbs acct_globals __cacheline_aligned =
93 {__SPIN_LOCK_UNLOCKED(acct_globals.lock)};
93 94
94/* 95/*
95 * Called whenever the timer says to check the free space. 96 * Called whenever the timer says to check the free space.
diff --git a/kernel/audit.c b/kernel/audit.c
index 98106f6078b0..d9b690ac684b 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -57,6 +57,7 @@
57#include <linux/netlink.h> 57#include <linux/netlink.h>
58#include <linux/selinux.h> 58#include <linux/selinux.h>
59#include <linux/inotify.h> 59#include <linux/inotify.h>
60#include <linux/freezer.h>
60 61
61#include "audit.h" 62#include "audit.h"
62 63
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index 4f40d923af8e..2e896f8ae29e 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -636,10 +636,9 @@ static struct audit_rule *audit_krule_to_rule(struct audit_krule *krule)
636 struct audit_rule *rule; 636 struct audit_rule *rule;
637 int i; 637 int i;
638 638
639 rule = kmalloc(sizeof(*rule), GFP_KERNEL); 639 rule = kzalloc(sizeof(*rule), GFP_KERNEL);
640 if (unlikely(!rule)) 640 if (unlikely(!rule))
641 return NULL; 641 return NULL;
642 memset(rule, 0, sizeof(*rule));
643 642
644 rule->flags = krule->flags | krule->listnr; 643 rule->flags = krule->flags | krule->listnr;
645 rule->action = krule->action; 644 rule->action = krule->action;
diff --git a/kernel/configs.c b/kernel/configs.c
index f9e31974f4ad..8fa1fb28f8a7 100644
--- a/kernel/configs.c
+++ b/kernel/configs.c
@@ -75,7 +75,7 @@ ikconfig_read_current(struct file *file, char __user *buf,
75 return count; 75 return count;
76} 76}
77 77
78static struct file_operations ikconfig_file_ops = { 78static const struct file_operations ikconfig_file_ops = {
79 .owner = THIS_MODULE, 79 .owner = THIS_MODULE,
80 .read = ikconfig_read_current, 80 .read = ikconfig_read_current,
81}; 81};
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 272254f20d97..9124669f4586 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -270,11 +270,7 @@ int disable_nonboot_cpus(void)
270 goto out; 270 goto out;
271 } 271 }
272 } 272 }
273 error = set_cpus_allowed(current, cpumask_of_cpu(first_cpu)); 273
274 if (error) {
275 printk(KERN_ERR "Could not run on CPU%d\n", first_cpu);
276 goto out;
277 }
278 /* We take down all of the non-boot CPUs in one shot to avoid races 274 /* We take down all of the non-boot CPUs in one shot to avoid races
279 * with the userspace trying to use the CPU hotplug at the same time 275 * with the userspace trying to use the CPU hotplug at the same time
280 */ 276 */
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 6313c38c930e..0a6b4d89f9a0 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -729,9 +729,11 @@ static int validate_change(const struct cpuset *cur, const struct cpuset *trial)
729 } 729 }
730 730
731 /* Remaining checks don't apply to root cpuset */ 731 /* Remaining checks don't apply to root cpuset */
732 if ((par = cur->parent) == NULL) 732 if (cur == &top_cpuset)
733 return 0; 733 return 0;
734 734
735 par = cur->parent;
736
735 /* We must be a subset of our parent cpuset */ 737 /* We must be a subset of our parent cpuset */
736 if (!is_cpuset_subset(trial, par)) 738 if (!is_cpuset_subset(trial, par))
737 return -EACCES; 739 return -EACCES;
@@ -1060,10 +1062,7 @@ static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs, char *buf)
1060 cpu_exclusive_changed = 1062 cpu_exclusive_changed =
1061 (is_cpu_exclusive(cs) != is_cpu_exclusive(&trialcs)); 1063 (is_cpu_exclusive(cs) != is_cpu_exclusive(&trialcs));
1062 mutex_lock(&callback_mutex); 1064 mutex_lock(&callback_mutex);
1063 if (turning_on) 1065 cs->flags = trialcs.flags;
1064 set_bit(bit, &cs->flags);
1065 else
1066 clear_bit(bit, &cs->flags);
1067 mutex_unlock(&callback_mutex); 1066 mutex_unlock(&callback_mutex);
1068 1067
1069 if (cpu_exclusive_changed) 1068 if (cpu_exclusive_changed)
@@ -1281,7 +1280,8 @@ typedef enum {
1281 FILE_TASKLIST, 1280 FILE_TASKLIST,
1282} cpuset_filetype_t; 1281} cpuset_filetype_t;
1283 1282
1284static ssize_t cpuset_common_file_write(struct file *file, const char __user *userbuf, 1283static ssize_t cpuset_common_file_write(struct file *file,
1284 const char __user *userbuf,
1285 size_t nbytes, loff_t *unused_ppos) 1285 size_t nbytes, loff_t *unused_ppos)
1286{ 1286{
1287 struct cpuset *cs = __d_cs(file->f_dentry->d_parent); 1287 struct cpuset *cs = __d_cs(file->f_dentry->d_parent);
@@ -1292,7 +1292,7 @@ static ssize_t cpuset_common_file_write(struct file *file, const char __user *us
1292 int retval = 0; 1292 int retval = 0;
1293 1293
1294 /* Crude upper limit on largest legitimate cpulist user might write. */ 1294 /* Crude upper limit on largest legitimate cpulist user might write. */
1295 if (nbytes > 100 + 6 * NR_CPUS) 1295 if (nbytes > 100 + 6 * max(NR_CPUS, MAX_NUMNODES))
1296 return -E2BIG; 1296 return -E2BIG;
1297 1297
1298 /* +1 for nul-terminator */ 1298 /* +1 for nul-terminator */
@@ -1532,7 +1532,7 @@ static int cpuset_rename(struct inode *old_dir, struct dentry *old_dentry,
1532 return simple_rename(old_dir, old_dentry, new_dir, new_dentry); 1532 return simple_rename(old_dir, old_dentry, new_dir, new_dentry);
1533} 1533}
1534 1534
1535static struct file_operations cpuset_file_operations = { 1535static const struct file_operations cpuset_file_operations = {
1536 .read = cpuset_file_read, 1536 .read = cpuset_file_read,
1537 .write = cpuset_file_write, 1537 .write = cpuset_file_write,
1538 .llseek = generic_file_llseek, 1538 .llseek = generic_file_llseek,
@@ -2045,7 +2045,6 @@ out:
2045 return err; 2045 return err;
2046} 2046}
2047 2047
2048#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_MEMORY_HOTPLUG)
2049/* 2048/*
2050 * If common_cpu_mem_hotplug_unplug(), below, unplugs any CPUs 2049 * If common_cpu_mem_hotplug_unplug(), below, unplugs any CPUs
2051 * or memory nodes, we need to walk over the cpuset hierarchy, 2050 * or memory nodes, we need to walk over the cpuset hierarchy,
@@ -2109,9 +2108,7 @@ static void common_cpu_mem_hotplug_unplug(void)
2109 mutex_unlock(&callback_mutex); 2108 mutex_unlock(&callback_mutex);
2110 mutex_unlock(&manage_mutex); 2109 mutex_unlock(&manage_mutex);
2111} 2110}
2112#endif
2113 2111
2114#ifdef CONFIG_HOTPLUG_CPU
2115/* 2112/*
2116 * The top_cpuset tracks what CPUs and Memory Nodes are online, 2113 * The top_cpuset tracks what CPUs and Memory Nodes are online,
2117 * period. This is necessary in order to make cpusets transparent 2114 * period. This is necessary in order to make cpusets transparent
@@ -2128,7 +2125,6 @@ static int cpuset_handle_cpuhp(struct notifier_block *nb,
2128 common_cpu_mem_hotplug_unplug(); 2125 common_cpu_mem_hotplug_unplug();
2129 return 0; 2126 return 0;
2130} 2127}
2131#endif
2132 2128
2133#ifdef CONFIG_MEMORY_HOTPLUG 2129#ifdef CONFIG_MEMORY_HOTPLUG
2134/* 2130/*
@@ -2610,7 +2606,7 @@ static int cpuset_open(struct inode *inode, struct file *file)
2610 return single_open(file, proc_cpuset_show, pid); 2606 return single_open(file, proc_cpuset_show, pid);
2611} 2607}
2612 2608
2613struct file_operations proc_cpuset_operations = { 2609const struct file_operations proc_cpuset_operations = {
2614 .open = cpuset_open, 2610 .open = cpuset_open,
2615 .read = seq_read, 2611 .read = seq_read,
2616 .llseek = seq_lseek, 2612 .llseek = seq_lseek,
diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index 66a0ea48751d..766d5912b26a 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -20,7 +20,7 @@
20#include <linux/delayacct.h> 20#include <linux/delayacct.h>
21 21
22int delayacct_on __read_mostly = 1; /* Delay accounting turned on/off */ 22int delayacct_on __read_mostly = 1; /* Delay accounting turned on/off */
23kmem_cache_t *delayacct_cache; 23struct kmem_cache *delayacct_cache;
24 24
25static int __init delayacct_setup_disable(char *str) 25static int __init delayacct_setup_disable(char *str)
26{ 26{
@@ -41,7 +41,7 @@ void delayacct_init(void)
41 41
42void __delayacct_tsk_init(struct task_struct *tsk) 42void __delayacct_tsk_init(struct task_struct *tsk)
43{ 43{
44 tsk->delays = kmem_cache_zalloc(delayacct_cache, SLAB_KERNEL); 44 tsk->delays = kmem_cache_zalloc(delayacct_cache, GFP_KERNEL);
45 if (tsk->delays) 45 if (tsk->delays)
46 spin_lock_init(&tsk->delays->lock); 46 spin_lock_init(&tsk->delays->lock);
47} 47}
diff --git a/kernel/dma.c b/kernel/dma.c
index 2020644c938a..937b13ca33ba 100644
--- a/kernel/dma.c
+++ b/kernel/dma.c
@@ -140,7 +140,7 @@ static int proc_dma_open(struct inode *inode, struct file *file)
140 return single_open(file, proc_dma_show, NULL); 140 return single_open(file, proc_dma_show, NULL);
141} 141}
142 142
143static struct file_operations proc_dma_operations = { 143static const struct file_operations proc_dma_operations = {
144 .open = proc_dma_open, 144 .open = proc_dma_open,
145 .read = seq_read, 145 .read = seq_read,
146 .llseek = seq_lseek, 146 .llseek = seq_lseek,
diff --git a/kernel/exit.c b/kernel/exit.c
index 06de6c4e8ca3..4e3f919edc48 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -850,9 +850,7 @@ static void exit_notify(struct task_struct *tsk)
850fastcall NORET_TYPE void do_exit(long code) 850fastcall NORET_TYPE void do_exit(long code)
851{ 851{
852 struct task_struct *tsk = current; 852 struct task_struct *tsk = current;
853 struct taskstats *tidstats;
854 int group_dead; 853 int group_dead;
855 unsigned int mycpu;
856 854
857 profile_task_exit(tsk); 855 profile_task_exit(tsk);
858 856
@@ -890,8 +888,6 @@ fastcall NORET_TYPE void do_exit(long code)
890 current->comm, current->pid, 888 current->comm, current->pid,
891 preempt_count()); 889 preempt_count());
892 890
893 taskstats_exit_alloc(&tidstats, &mycpu);
894
895 acct_update_integrals(tsk); 891 acct_update_integrals(tsk);
896 if (tsk->mm) { 892 if (tsk->mm) {
897 update_hiwater_rss(tsk->mm); 893 update_hiwater_rss(tsk->mm);
@@ -911,8 +907,8 @@ fastcall NORET_TYPE void do_exit(long code)
911#endif 907#endif
912 if (unlikely(tsk->audit_context)) 908 if (unlikely(tsk->audit_context))
913 audit_free(tsk); 909 audit_free(tsk);
914 taskstats_exit_send(tsk, tidstats, group_dead, mycpu); 910
915 taskstats_exit_free(tidstats); 911 taskstats_exit(tsk, group_dead);
916 912
917 exit_mm(tsk); 913 exit_mm(tsk);
918 914
diff --git a/kernel/fork.c b/kernel/fork.c
index fd22245e3881..7f2e31ba33af 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -82,26 +82,26 @@ int nr_processes(void)
82#ifndef __HAVE_ARCH_TASK_STRUCT_ALLOCATOR 82#ifndef __HAVE_ARCH_TASK_STRUCT_ALLOCATOR
83# define alloc_task_struct() kmem_cache_alloc(task_struct_cachep, GFP_KERNEL) 83# define alloc_task_struct() kmem_cache_alloc(task_struct_cachep, GFP_KERNEL)
84# define free_task_struct(tsk) kmem_cache_free(task_struct_cachep, (tsk)) 84# define free_task_struct(tsk) kmem_cache_free(task_struct_cachep, (tsk))
85static kmem_cache_t *task_struct_cachep; 85static struct kmem_cache *task_struct_cachep;
86#endif 86#endif
87 87
88/* SLAB cache for signal_struct structures (tsk->signal) */ 88/* SLAB cache for signal_struct structures (tsk->signal) */
89static kmem_cache_t *signal_cachep; 89static struct kmem_cache *signal_cachep;
90 90
91/* SLAB cache for sighand_struct structures (tsk->sighand) */ 91/* SLAB cache for sighand_struct structures (tsk->sighand) */
92kmem_cache_t *sighand_cachep; 92struct kmem_cache *sighand_cachep;
93 93
94/* SLAB cache for files_struct structures (tsk->files) */ 94/* SLAB cache for files_struct structures (tsk->files) */
95kmem_cache_t *files_cachep; 95struct kmem_cache *files_cachep;
96 96
97/* SLAB cache for fs_struct structures (tsk->fs) */ 97/* SLAB cache for fs_struct structures (tsk->fs) */
98kmem_cache_t *fs_cachep; 98struct kmem_cache *fs_cachep;
99 99
100/* SLAB cache for vm_area_struct structures */ 100/* SLAB cache for vm_area_struct structures */
101kmem_cache_t *vm_area_cachep; 101struct kmem_cache *vm_area_cachep;
102 102
103/* SLAB cache for mm_struct structures (tsk->mm) */ 103/* SLAB cache for mm_struct structures (tsk->mm) */
104static kmem_cache_t *mm_cachep; 104static struct kmem_cache *mm_cachep;
105 105
106void free_task(struct task_struct *tsk) 106void free_task(struct task_struct *tsk)
107{ 107{
@@ -237,7 +237,7 @@ static inline int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
237 goto fail_nomem; 237 goto fail_nomem;
238 charge = len; 238 charge = len;
239 } 239 }
240 tmp = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 240 tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
241 if (!tmp) 241 if (!tmp)
242 goto fail_nomem; 242 goto fail_nomem;
243 *tmp = *mpnt; 243 *tmp = *mpnt;
@@ -319,7 +319,7 @@ static inline void mm_free_pgd(struct mm_struct * mm)
319 319
320 __cacheline_aligned_in_smp DEFINE_SPINLOCK(mmlist_lock); 320 __cacheline_aligned_in_smp DEFINE_SPINLOCK(mmlist_lock);
321 321
322#define allocate_mm() (kmem_cache_alloc(mm_cachep, SLAB_KERNEL)) 322#define allocate_mm() (kmem_cache_alloc(mm_cachep, GFP_KERNEL))
323#define free_mm(mm) (kmem_cache_free(mm_cachep, (mm))) 323#define free_mm(mm) (kmem_cache_free(mm_cachep, (mm)))
324 324
325#include <linux/init_task.h> 325#include <linux/init_task.h>
@@ -448,7 +448,16 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
448 tsk->vfork_done = NULL; 448 tsk->vfork_done = NULL;
449 complete(vfork_done); 449 complete(vfork_done);
450 } 450 }
451 if (tsk->clear_child_tid && atomic_read(&mm->mm_users) > 1) { 451
452 /*
453 * If we're exiting normally, clear a user-space tid field if
454 * requested. We leave this alone when dying by signal, to leave
455 * the value intact in a core dump, and to save the unnecessary
456 * trouble otherwise. Userland only wants this done for a sys_exit.
457 */
458 if (tsk->clear_child_tid
459 && !(tsk->flags & PF_SIGNALED)
460 && atomic_read(&mm->mm_users) > 1) {
452 u32 __user * tidptr = tsk->clear_child_tid; 461 u32 __user * tidptr = tsk->clear_child_tid;
453 tsk->clear_child_tid = NULL; 462 tsk->clear_child_tid = NULL;
454 463
@@ -479,6 +488,10 @@ static struct mm_struct *dup_mm(struct task_struct *tsk)
479 488
480 memcpy(mm, oldmm, sizeof(*mm)); 489 memcpy(mm, oldmm, sizeof(*mm));
481 490
491 /* Initializing for Swap token stuff */
492 mm->token_priority = 0;
493 mm->last_interval = 0;
494
482 if (!mm_init(mm)) 495 if (!mm_init(mm))
483 goto fail_nomem; 496 goto fail_nomem;
484 497
@@ -542,6 +555,10 @@ static int copy_mm(unsigned long clone_flags, struct task_struct * tsk)
542 goto fail_nomem; 555 goto fail_nomem;
543 556
544good_mm: 557good_mm:
558 /* Initializing for Swap token stuff */
559 mm->token_priority = 0;
560 mm->last_interval = 0;
561
545 tsk->mm = mm; 562 tsk->mm = mm;
546 tsk->active_mm = mm; 563 tsk->active_mm = mm;
547 return 0; 564 return 0;
@@ -613,7 +630,7 @@ static struct files_struct *alloc_files(void)
613 struct files_struct *newf; 630 struct files_struct *newf;
614 struct fdtable *fdt; 631 struct fdtable *fdt;
615 632
616 newf = kmem_cache_alloc(files_cachep, SLAB_KERNEL); 633 newf = kmem_cache_alloc(files_cachep, GFP_KERNEL);
617 if (!newf) 634 if (!newf)
618 goto out; 635 goto out;
619 636
@@ -830,7 +847,6 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts
830 if (clone_flags & CLONE_THREAD) { 847 if (clone_flags & CLONE_THREAD) {
831 atomic_inc(&current->signal->count); 848 atomic_inc(&current->signal->count);
832 atomic_inc(&current->signal->live); 849 atomic_inc(&current->signal->live);
833 taskstats_tgid_alloc(current);
834 return 0; 850 return 0;
835 } 851 }
836 sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL); 852 sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL);
@@ -1413,7 +1429,7 @@ long do_fork(unsigned long clone_flags,
1413#define ARCH_MIN_MMSTRUCT_ALIGN 0 1429#define ARCH_MIN_MMSTRUCT_ALIGN 0
1414#endif 1430#endif
1415 1431
1416static void sighand_ctor(void *data, kmem_cache_t *cachep, unsigned long flags) 1432static void sighand_ctor(void *data, struct kmem_cache *cachep, unsigned long flags)
1417{ 1433{
1418 struct sighand_struct *sighand = data; 1434 struct sighand_struct *sighand = data;
1419 1435
diff --git a/kernel/futex.c b/kernel/futex.c
index 93ef30ba209f..95989a3b4168 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -282,9 +282,9 @@ static inline int get_futex_value_locked(u32 *dest, u32 __user *from)
282{ 282{
283 int ret; 283 int ret;
284 284
285 inc_preempt_count(); 285 pagefault_disable();
286 ret = __copy_from_user_inatomic(dest, from, sizeof(u32)); 286 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
287 dec_preempt_count(); 287 pagefault_enable();
288 288
289 return ret ? -EFAULT : 0; 289 return ret ? -EFAULT : 0;
290} 290}
@@ -324,12 +324,11 @@ static int refill_pi_state_cache(void)
324 if (likely(current->pi_state_cache)) 324 if (likely(current->pi_state_cache))
325 return 0; 325 return 0;
326 326
327 pi_state = kmalloc(sizeof(*pi_state), GFP_KERNEL); 327 pi_state = kzalloc(sizeof(*pi_state), GFP_KERNEL);
328 328
329 if (!pi_state) 329 if (!pi_state)
330 return -ENOMEM; 330 return -ENOMEM;
331 331
332 memset(pi_state, 0, sizeof(*pi_state));
333 INIT_LIST_HEAD(&pi_state->list); 332 INIT_LIST_HEAD(&pi_state->list);
334 /* pi_mutex gets initialized later */ 333 /* pi_mutex gets initialized later */
335 pi_state->owner = NULL; 334 pi_state->owner = NULL;
@@ -553,7 +552,7 @@ static void wake_futex(struct futex_q *q)
553 * at the end of wake_up_all() does not prevent this store from 552 * at the end of wake_up_all() does not prevent this store from
554 * moving. 553 * moving.
555 */ 554 */
556 wmb(); 555 smp_wmb();
557 q->lock_ptr = NULL; 556 q->lock_ptr = NULL;
558} 557}
559 558
@@ -585,9 +584,9 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this)
585 if (!(uval & FUTEX_OWNER_DIED)) { 584 if (!(uval & FUTEX_OWNER_DIED)) {
586 newval = FUTEX_WAITERS | new_owner->pid; 585 newval = FUTEX_WAITERS | new_owner->pid;
587 586
588 inc_preempt_count(); 587 pagefault_disable();
589 curval = futex_atomic_cmpxchg_inatomic(uaddr, uval, newval); 588 curval = futex_atomic_cmpxchg_inatomic(uaddr, uval, newval);
590 dec_preempt_count(); 589 pagefault_enable();
591 if (curval == -EFAULT) 590 if (curval == -EFAULT)
592 return -EFAULT; 591 return -EFAULT;
593 if (curval != uval) 592 if (curval != uval)
@@ -618,9 +617,9 @@ static int unlock_futex_pi(u32 __user *uaddr, u32 uval)
618 * There is no waiter, so we unlock the futex. The owner died 617 * There is no waiter, so we unlock the futex. The owner died
619 * bit has not to be preserved here. We are the owner: 618 * bit has not to be preserved here. We are the owner:
620 */ 619 */
621 inc_preempt_count(); 620 pagefault_disable();
622 oldval = futex_atomic_cmpxchg_inatomic(uaddr, uval, 0); 621 oldval = futex_atomic_cmpxchg_inatomic(uaddr, uval, 0);
623 dec_preempt_count(); 622 pagefault_enable();
624 623
625 if (oldval == -EFAULT) 624 if (oldval == -EFAULT)
626 return oldval; 625 return oldval;
@@ -1158,9 +1157,9 @@ static int futex_lock_pi(u32 __user *uaddr, int detect, unsigned long sec,
1158 */ 1157 */
1159 newval = current->pid; 1158 newval = current->pid;
1160 1159
1161 inc_preempt_count(); 1160 pagefault_disable();
1162 curval = futex_atomic_cmpxchg_inatomic(uaddr, 0, newval); 1161 curval = futex_atomic_cmpxchg_inatomic(uaddr, 0, newval);
1163 dec_preempt_count(); 1162 pagefault_enable();
1164 1163
1165 if (unlikely(curval == -EFAULT)) 1164 if (unlikely(curval == -EFAULT))
1166 goto uaddr_faulted; 1165 goto uaddr_faulted;
@@ -1183,9 +1182,9 @@ static int futex_lock_pi(u32 __user *uaddr, int detect, unsigned long sec,
1183 uval = curval; 1182 uval = curval;
1184 newval = uval | FUTEX_WAITERS; 1183 newval = uval | FUTEX_WAITERS;
1185 1184
1186 inc_preempt_count(); 1185 pagefault_disable();
1187 curval = futex_atomic_cmpxchg_inatomic(uaddr, uval, newval); 1186 curval = futex_atomic_cmpxchg_inatomic(uaddr, uval, newval);
1188 dec_preempt_count(); 1187 pagefault_enable();
1189 1188
1190 if (unlikely(curval == -EFAULT)) 1189 if (unlikely(curval == -EFAULT))
1191 goto uaddr_faulted; 1190 goto uaddr_faulted;
@@ -1215,10 +1214,10 @@ static int futex_lock_pi(u32 __user *uaddr, int detect, unsigned long sec,
1215 newval = current->pid | 1214 newval = current->pid |
1216 FUTEX_OWNER_DIED | FUTEX_WAITERS; 1215 FUTEX_OWNER_DIED | FUTEX_WAITERS;
1217 1216
1218 inc_preempt_count(); 1217 pagefault_disable();
1219 curval = futex_atomic_cmpxchg_inatomic(uaddr, 1218 curval = futex_atomic_cmpxchg_inatomic(uaddr,
1220 uval, newval); 1219 uval, newval);
1221 dec_preempt_count(); 1220 pagefault_enable();
1222 1221
1223 if (unlikely(curval == -EFAULT)) 1222 if (unlikely(curval == -EFAULT))
1224 goto uaddr_faulted; 1223 goto uaddr_faulted;
@@ -1390,9 +1389,9 @@ retry_locked:
1390 * anyone else up: 1389 * anyone else up:
1391 */ 1390 */
1392 if (!(uval & FUTEX_OWNER_DIED)) { 1391 if (!(uval & FUTEX_OWNER_DIED)) {
1393 inc_preempt_count(); 1392 pagefault_disable();
1394 uval = futex_atomic_cmpxchg_inatomic(uaddr, current->pid, 0); 1393 uval = futex_atomic_cmpxchg_inatomic(uaddr, current->pid, 0);
1395 dec_preempt_count(); 1394 pagefault_enable();
1396 } 1395 }
1397 1396
1398 if (unlikely(uval == -EFAULT)) 1397 if (unlikely(uval == -EFAULT))
@@ -1493,7 +1492,7 @@ static unsigned int futex_poll(struct file *filp,
1493 return ret; 1492 return ret;
1494} 1493}
1495 1494
1496static struct file_operations futex_fops = { 1495static const struct file_operations futex_fops = {
1497 .release = futex_close, 1496 .release = futex_close,
1498 .poll = futex_poll, 1497 .poll = futex_poll,
1499}; 1498};
@@ -1858,10 +1857,16 @@ static struct file_system_type futex_fs_type = {
1858 1857
1859static int __init init(void) 1858static int __init init(void)
1860{ 1859{
1861 unsigned int i; 1860 int i = register_filesystem(&futex_fs_type);
1861
1862 if (i)
1863 return i;
1862 1864
1863 register_filesystem(&futex_fs_type);
1864 futex_mnt = kern_mount(&futex_fs_type); 1865 futex_mnt = kern_mount(&futex_fs_type);
1866 if (IS_ERR(futex_mnt)) {
1867 unregister_filesystem(&futex_fs_type);
1868 return PTR_ERR(futex_mnt);
1869 }
1865 1870
1866 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) { 1871 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
1867 INIT_LIST_HEAD(&futex_queues[i].chain); 1872 INIT_LIST_HEAD(&futex_queues[i].chain);
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index a681912bc89a..aff1f0fabb0d 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -54,7 +54,7 @@ struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned = {
54 .chip = &no_irq_chip, 54 .chip = &no_irq_chip,
55 .handle_irq = handle_bad_irq, 55 .handle_irq = handle_bad_irq,
56 .depth = 1, 56 .depth = 1,
57 .lock = SPIN_LOCK_UNLOCKED, 57 .lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock),
58#ifdef CONFIG_SMP 58#ifdef CONFIG_SMP
59 .affinity = CPU_MASK_ALL 59 .affinity = CPU_MASK_ALL
60#endif 60#endif
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index eeac3e313b2b..ab63cfc42992 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -20,6 +20,7 @@
20#include <linux/proc_fs.h> 20#include <linux/proc_fs.h>
21#include <linux/sched.h> /* for cond_resched */ 21#include <linux/sched.h> /* for cond_resched */
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/ctype.h>
23 24
24#include <asm/sections.h> 25#include <asm/sections.h>
25 26
@@ -301,13 +302,6 @@ struct kallsym_iter
301 char name[KSYM_NAME_LEN+1]; 302 char name[KSYM_NAME_LEN+1];
302}; 303};
303 304
304/* Only label it "global" if it is exported. */
305static void upcase_if_global(struct kallsym_iter *iter)
306{
307 if (is_exported(iter->name, iter->owner))
308 iter->type += 'A' - 'a';
309}
310
311static int get_ksymbol_mod(struct kallsym_iter *iter) 305static int get_ksymbol_mod(struct kallsym_iter *iter)
312{ 306{
313 iter->owner = module_get_kallsym(iter->pos - kallsyms_num_syms, 307 iter->owner = module_get_kallsym(iter->pos - kallsyms_num_syms,
@@ -316,7 +310,10 @@ static int get_ksymbol_mod(struct kallsym_iter *iter)
316 if (iter->owner == NULL) 310 if (iter->owner == NULL)
317 return 0; 311 return 0;
318 312
319 upcase_if_global(iter); 313 /* Label it "global" if it is exported, "local" if not exported. */
314 iter->type = is_exported(iter->name, iter->owner)
315 ? toupper(iter->type) : tolower(iter->type);
316
320 return 1; 317 return 1;
321} 318}
322 319
@@ -401,7 +398,7 @@ static int s_show(struct seq_file *m, void *p)
401 return 0; 398 return 0;
402} 399}
403 400
404static struct seq_operations kallsyms_op = { 401static const struct seq_operations kallsyms_op = {
405 .start = s_start, 402 .start = s_start,
406 .next = s_next, 403 .next = s_next,
407 .stop = s_stop, 404 .stop = s_stop,
@@ -436,7 +433,7 @@ static int kallsyms_release(struct inode *inode, struct file *file)
436 return seq_release(inode, file); 433 return seq_release(inode, file);
437} 434}
438 435
439static struct file_operations kallsyms_operations = { 436static const struct file_operations kallsyms_operations = {
440 .open = kallsyms_open, 437 .open = kallsyms_open,
441 .read = seq_read, 438 .read = seq_read,
442 .llseek = seq_lseek, 439 .llseek = seq_lseek,
diff --git a/kernel/kexec.c b/kernel/kexec.c
index fcdd5d2bc3f4..afbbbe981be2 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -20,6 +20,8 @@
20#include <linux/syscalls.h> 20#include <linux/syscalls.h>
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/hardirq.h> 22#include <linux/hardirq.h>
23#include <linux/elf.h>
24#include <linux/elfcore.h>
23 25
24#include <asm/page.h> 26#include <asm/page.h>
25#include <asm/uaccess.h> 27#include <asm/uaccess.h>
@@ -108,11 +110,10 @@ static int do_kimage_alloc(struct kimage **rimage, unsigned long entry,
108 110
109 /* Allocate a controlling structure */ 111 /* Allocate a controlling structure */
110 result = -ENOMEM; 112 result = -ENOMEM;
111 image = kmalloc(sizeof(*image), GFP_KERNEL); 113 image = kzalloc(sizeof(*image), GFP_KERNEL);
112 if (!image) 114 if (!image)
113 goto out; 115 goto out;
114 116
115 memset(image, 0, sizeof(*image));
116 image->head = 0; 117 image->head = 0;
117 image->entry = &image->head; 118 image->entry = &image->head;
118 image->last_entry = &image->head; 119 image->last_entry = &image->head;
@@ -1067,6 +1068,60 @@ void crash_kexec(struct pt_regs *regs)
1067 } 1068 }
1068} 1069}
1069 1070
1071static u32 *append_elf_note(u32 *buf, char *name, unsigned type, void *data,
1072 size_t data_len)
1073{
1074 struct elf_note note;
1075
1076 note.n_namesz = strlen(name) + 1;
1077 note.n_descsz = data_len;
1078 note.n_type = type;
1079 memcpy(buf, &note, sizeof(note));
1080 buf += (sizeof(note) + 3)/4;
1081 memcpy(buf, name, note.n_namesz);
1082 buf += (note.n_namesz + 3)/4;
1083 memcpy(buf, data, note.n_descsz);
1084 buf += (note.n_descsz + 3)/4;
1085
1086 return buf;
1087}
1088
1089static void final_note(u32 *buf)
1090{
1091 struct elf_note note;
1092
1093 note.n_namesz = 0;
1094 note.n_descsz = 0;
1095 note.n_type = 0;
1096 memcpy(buf, &note, sizeof(note));
1097}
1098
1099void crash_save_cpu(struct pt_regs *regs, int cpu)
1100{
1101 struct elf_prstatus prstatus;
1102 u32 *buf;
1103
1104 if ((cpu < 0) || (cpu >= NR_CPUS))
1105 return;
1106
1107 /* Using ELF notes here is opportunistic.
1108 * I need a well defined structure format
1109 * for the data I pass, and I need tags
1110 * on the data to indicate what information I have
1111 * squirrelled away. ELF notes happen to provide
1112 * all of that, so there is no need to invent something new.
1113 */
1114 buf = (u32*)per_cpu_ptr(crash_notes, cpu);
1115 if (!buf)
1116 return;
1117 memset(&prstatus, 0, sizeof(prstatus));
1118 prstatus.pr_pid = current->pid;
1119 elf_core_copy_regs(&prstatus.pr_reg, regs);
1120 buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
1121 sizeof(prstatus));
1122 final_note(buf);
1123}
1124
1070static int __init crash_notes_memory_init(void) 1125static int __init crash_notes_memory_init(void)
1071{ 1126{
1072 /* Allocate memory for saving cpu registers. */ 1127 /* Allocate memory for saving cpu registers. */
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 2b76dee28496..8d2bea09a4ec 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -114,6 +114,7 @@ EXPORT_SYMBOL(request_module);
114#endif /* CONFIG_KMOD */ 114#endif /* CONFIG_KMOD */
115 115
116struct subprocess_info { 116struct subprocess_info {
117 struct work_struct work;
117 struct completion *complete; 118 struct completion *complete;
118 char *path; 119 char *path;
119 char **argv; 120 char **argv;
@@ -221,9 +222,10 @@ static int wait_for_helper(void *data)
221} 222}
222 223
223/* This is run by khelper thread */ 224/* This is run by khelper thread */
224static void __call_usermodehelper(void *data) 225static void __call_usermodehelper(struct work_struct *work)
225{ 226{
226 struct subprocess_info *sub_info = data; 227 struct subprocess_info *sub_info =
228 container_of(work, struct subprocess_info, work);
227 pid_t pid; 229 pid_t pid;
228 int wait = sub_info->wait; 230 int wait = sub_info->wait;
229 231
@@ -264,6 +266,8 @@ int call_usermodehelper_keys(char *path, char **argv, char **envp,
264{ 266{
265 DECLARE_COMPLETION_ONSTACK(done); 267 DECLARE_COMPLETION_ONSTACK(done);
266 struct subprocess_info sub_info = { 268 struct subprocess_info sub_info = {
269 .work = __WORK_INITIALIZER(sub_info.work,
270 __call_usermodehelper),
267 .complete = &done, 271 .complete = &done,
268 .path = path, 272 .path = path,
269 .argv = argv, 273 .argv = argv,
@@ -272,7 +276,6 @@ int call_usermodehelper_keys(char *path, char **argv, char **envp,
272 .wait = wait, 276 .wait = wait,
273 .retval = 0, 277 .retval = 0,
274 }; 278 };
275 DECLARE_WORK(work, __call_usermodehelper, &sub_info);
276 279
277 if (!khelper_wq) 280 if (!khelper_wq)
278 return -EBUSY; 281 return -EBUSY;
@@ -280,7 +283,7 @@ int call_usermodehelper_keys(char *path, char **argv, char **envp,
280 if (path[0] == '\0') 283 if (path[0] == '\0')
281 return 0; 284 return 0;
282 285
283 queue_work(khelper_wq, &work); 286 queue_work(khelper_wq, &sub_info.work);
284 wait_for_completion(&done); 287 wait_for_completion(&done);
285 return sub_info.retval; 288 return sub_info.retval;
286} 289}
@@ -291,6 +294,8 @@ int call_usermodehelper_pipe(char *path, char **argv, char **envp,
291{ 294{
292 DECLARE_COMPLETION(done); 295 DECLARE_COMPLETION(done);
293 struct subprocess_info sub_info = { 296 struct subprocess_info sub_info = {
297 .work = __WORK_INITIALIZER(sub_info.work,
298 __call_usermodehelper),
294 .complete = &done, 299 .complete = &done,
295 .path = path, 300 .path = path,
296 .argv = argv, 301 .argv = argv,
@@ -298,7 +303,6 @@ int call_usermodehelper_pipe(char *path, char **argv, char **envp,
298 .retval = 0, 303 .retval = 0,
299 }; 304 };
300 struct file *f; 305 struct file *f;
301 DECLARE_WORK(work, __call_usermodehelper, &sub_info);
302 306
303 if (!khelper_wq) 307 if (!khelper_wq)
304 return -EBUSY; 308 return -EBUSY;
@@ -318,7 +322,7 @@ int call_usermodehelper_pipe(char *path, char **argv, char **envp,
318 } 322 }
319 sub_info.stdin = f; 323 sub_info.stdin = f;
320 324
321 queue_work(khelper_wq, &work); 325 queue_work(khelper_wq, &sub_info.work);
322 wait_for_completion(&done); 326 wait_for_completion(&done);
323 return sub_info.retval; 327 return sub_info.retval;
324} 328}
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 610c837ad9e0..17ec4afb0994 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -38,6 +38,7 @@
38#include <linux/module.h> 38#include <linux/module.h>
39#include <linux/moduleloader.h> 39#include <linux/moduleloader.h>
40#include <linux/kallsyms.h> 40#include <linux/kallsyms.h>
41#include <linux/freezer.h>
41#include <asm-generic/sections.h> 42#include <asm-generic/sections.h>
42#include <asm/cacheflush.h> 43#include <asm/cacheflush.h>
43#include <asm/errno.h> 44#include <asm/errno.h>
@@ -83,9 +84,36 @@ struct kprobe_insn_page {
83 kprobe_opcode_t *insns; /* Page of instruction slots */ 84 kprobe_opcode_t *insns; /* Page of instruction slots */
84 char slot_used[INSNS_PER_PAGE]; 85 char slot_used[INSNS_PER_PAGE];
85 int nused; 86 int nused;
87 int ngarbage;
86}; 88};
87 89
88static struct hlist_head kprobe_insn_pages; 90static struct hlist_head kprobe_insn_pages;
91static int kprobe_garbage_slots;
92static int collect_garbage_slots(void);
93
94static int __kprobes check_safety(void)
95{
96 int ret = 0;
97#if defined(CONFIG_PREEMPT) && defined(CONFIG_PM)
98 ret = freeze_processes();
99 if (ret == 0) {
100 struct task_struct *p, *q;
101 do_each_thread(p, q) {
102 if (p != current && p->state == TASK_RUNNING &&
103 p->pid != 0) {
104 printk("Check failed: %s is running\n",p->comm);
105 ret = -1;
106 goto loop_end;
107 }
108 } while_each_thread(p, q);
109 }
110loop_end:
111 thaw_processes();
112#else
113 synchronize_sched();
114#endif
115 return ret;
116}
89 117
90/** 118/**
91 * get_insn_slot() - Find a slot on an executable page for an instruction. 119 * get_insn_slot() - Find a slot on an executable page for an instruction.
@@ -96,6 +124,7 @@ kprobe_opcode_t __kprobes *get_insn_slot(void)
96 struct kprobe_insn_page *kip; 124 struct kprobe_insn_page *kip;
97 struct hlist_node *pos; 125 struct hlist_node *pos;
98 126
127 retry:
99 hlist_for_each(pos, &kprobe_insn_pages) { 128 hlist_for_each(pos, &kprobe_insn_pages) {
100 kip = hlist_entry(pos, struct kprobe_insn_page, hlist); 129 kip = hlist_entry(pos, struct kprobe_insn_page, hlist);
101 if (kip->nused < INSNS_PER_PAGE) { 130 if (kip->nused < INSNS_PER_PAGE) {
@@ -112,7 +141,11 @@ kprobe_opcode_t __kprobes *get_insn_slot(void)
112 } 141 }
113 } 142 }
114 143
115 /* All out of space. Need to allocate a new page. Use slot 0.*/ 144 /* If there are any garbage slots, collect it and try again. */
145 if (kprobe_garbage_slots && collect_garbage_slots() == 0) {
146 goto retry;
147 }
148 /* All out of space. Need to allocate a new page. Use slot 0. */
116 kip = kmalloc(sizeof(struct kprobe_insn_page), GFP_KERNEL); 149 kip = kmalloc(sizeof(struct kprobe_insn_page), GFP_KERNEL);
117 if (!kip) { 150 if (!kip) {
118 return NULL; 151 return NULL;
@@ -133,10 +166,62 @@ kprobe_opcode_t __kprobes *get_insn_slot(void)
133 memset(kip->slot_used, 0, INSNS_PER_PAGE); 166 memset(kip->slot_used, 0, INSNS_PER_PAGE);
134 kip->slot_used[0] = 1; 167 kip->slot_used[0] = 1;
135 kip->nused = 1; 168 kip->nused = 1;
169 kip->ngarbage = 0;
136 return kip->insns; 170 return kip->insns;
137} 171}
138 172
139void __kprobes free_insn_slot(kprobe_opcode_t *slot) 173/* Return 1 if all garbages are collected, otherwise 0. */
174static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
175{
176 kip->slot_used[idx] = 0;
177 kip->nused--;
178 if (kip->nused == 0) {
179 /*
180 * Page is no longer in use. Free it unless
181 * it's the last one. We keep the last one
182 * so as not to have to set it up again the
183 * next time somebody inserts a probe.
184 */
185 hlist_del(&kip->hlist);
186 if (hlist_empty(&kprobe_insn_pages)) {
187 INIT_HLIST_NODE(&kip->hlist);
188 hlist_add_head(&kip->hlist,
189 &kprobe_insn_pages);
190 } else {
191 module_free(NULL, kip->insns);
192 kfree(kip);
193 }
194 return 1;
195 }
196 return 0;
197}
198
199static int __kprobes collect_garbage_slots(void)
200{
201 struct kprobe_insn_page *kip;
202 struct hlist_node *pos, *next;
203
204 /* Ensure no-one is preepmted on the garbages */
205 if (check_safety() != 0)
206 return -EAGAIN;
207
208 hlist_for_each_safe(pos, next, &kprobe_insn_pages) {
209 int i;
210 kip = hlist_entry(pos, struct kprobe_insn_page, hlist);
211 if (kip->ngarbage == 0)
212 continue;
213 kip->ngarbage = 0; /* we will collect all garbages */
214 for (i = 0; i < INSNS_PER_PAGE; i++) {
215 if (kip->slot_used[i] == -1 &&
216 collect_one_slot(kip, i))
217 break;
218 }
219 }
220 kprobe_garbage_slots = 0;
221 return 0;
222}
223
224void __kprobes free_insn_slot(kprobe_opcode_t * slot, int dirty)
140{ 225{
141 struct kprobe_insn_page *kip; 226 struct kprobe_insn_page *kip;
142 struct hlist_node *pos; 227 struct hlist_node *pos;
@@ -146,28 +231,18 @@ void __kprobes free_insn_slot(kprobe_opcode_t *slot)
146 if (kip->insns <= slot && 231 if (kip->insns <= slot &&
147 slot < kip->insns + (INSNS_PER_PAGE * MAX_INSN_SIZE)) { 232 slot < kip->insns + (INSNS_PER_PAGE * MAX_INSN_SIZE)) {
148 int i = (slot - kip->insns) / MAX_INSN_SIZE; 233 int i = (slot - kip->insns) / MAX_INSN_SIZE;
149 kip->slot_used[i] = 0; 234 if (dirty) {
150 kip->nused--; 235 kip->slot_used[i] = -1;
151 if (kip->nused == 0) { 236 kip->ngarbage++;
152 /* 237 } else {
153 * Page is no longer in use. Free it unless 238 collect_one_slot(kip, i);
154 * it's the last one. We keep the last one
155 * so as not to have to set it up again the
156 * next time somebody inserts a probe.
157 */
158 hlist_del(&kip->hlist);
159 if (hlist_empty(&kprobe_insn_pages)) {
160 INIT_HLIST_NODE(&kip->hlist);
161 hlist_add_head(&kip->hlist,
162 &kprobe_insn_pages);
163 } else {
164 module_free(NULL, kip->insns);
165 kfree(kip);
166 }
167 } 239 }
168 return; 240 break;
169 } 241 }
170 } 242 }
243 if (dirty && (++kprobe_garbage_slots > INSNS_PER_PAGE)) {
244 collect_garbage_slots();
245 }
171} 246}
172#endif 247#endif
173 248
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 4f9c60ef95e8..1db8c72d0d38 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -31,6 +31,8 @@ struct kthread_create_info
31 /* Result passed back to kthread_create() from keventd. */ 31 /* Result passed back to kthread_create() from keventd. */
32 struct task_struct *result; 32 struct task_struct *result;
33 struct completion done; 33 struct completion done;
34
35 struct work_struct work;
34}; 36};
35 37
36struct kthread_stop_info 38struct kthread_stop_info
@@ -111,9 +113,10 @@ static int kthread(void *_create)
111} 113}
112 114
113/* We are keventd: create a thread. */ 115/* We are keventd: create a thread. */
114static void keventd_create_kthread(void *_create) 116static void keventd_create_kthread(struct work_struct *work)
115{ 117{
116 struct kthread_create_info *create = _create; 118 struct kthread_create_info *create =
119 container_of(work, struct kthread_create_info, work);
117 int pid; 120 int pid;
118 121
119 /* We want our own signal handler (we take no signals by default). */ 122 /* We want our own signal handler (we take no signals by default). */
@@ -154,20 +157,20 @@ struct task_struct *kthread_create(int (*threadfn)(void *data),
154 ...) 157 ...)
155{ 158{
156 struct kthread_create_info create; 159 struct kthread_create_info create;
157 DECLARE_WORK(work, keventd_create_kthread, &create);
158 160
159 create.threadfn = threadfn; 161 create.threadfn = threadfn;
160 create.data = data; 162 create.data = data;
161 init_completion(&create.started); 163 init_completion(&create.started);
162 init_completion(&create.done); 164 init_completion(&create.done);
165 INIT_WORK(&create.work, keventd_create_kthread);
163 166
164 /* 167 /*
165 * The workqueue needs to start up first: 168 * The workqueue needs to start up first:
166 */ 169 */
167 if (!helper_wq) 170 if (!helper_wq)
168 work.func(work.data); 171 create.work.func(&create.work);
169 else { 172 else {
170 queue_work(helper_wq, &work); 173 queue_work(helper_wq, &create.work);
171 wait_for_completion(&create.done); 174 wait_for_completion(&create.done);
172 } 175 }
173 if (!IS_ERR(create.result)) { 176 if (!IS_ERR(create.result)) {
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 9bb8d784eb02..b02032476dc2 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -140,13 +140,6 @@ void lockdep_on(void)
140 140
141EXPORT_SYMBOL(lockdep_on); 141EXPORT_SYMBOL(lockdep_on);
142 142
143int lockdep_internal(void)
144{
145 return current->lockdep_recursion != 0;
146}
147
148EXPORT_SYMBOL(lockdep_internal);
149
150/* 143/*
151 * Debugging switches: 144 * Debugging switches:
152 */ 145 */
@@ -233,8 +226,10 @@ static int save_trace(struct stack_trace *trace)
233 trace->max_entries = trace->nr_entries; 226 trace->max_entries = trace->nr_entries;
234 227
235 nr_stack_trace_entries += trace->nr_entries; 228 nr_stack_trace_entries += trace->nr_entries;
236 if (DEBUG_LOCKS_WARN_ON(nr_stack_trace_entries > MAX_STACK_TRACE_ENTRIES)) 229 if (DEBUG_LOCKS_WARN_ON(nr_stack_trace_entries > MAX_STACK_TRACE_ENTRIES)) {
230 __raw_spin_unlock(&hash_lock);
237 return 0; 231 return 0;
232 }
238 233
239 if (nr_stack_trace_entries == MAX_STACK_TRACE_ENTRIES) { 234 if (nr_stack_trace_entries == MAX_STACK_TRACE_ENTRIES) {
240 __raw_spin_unlock(&hash_lock); 235 __raw_spin_unlock(&hash_lock);
@@ -353,7 +348,7 @@ get_usage_chars(struct lock_class *class, char *c1, char *c2, char *c3, char *c4
353 348
354static void print_lock_name(struct lock_class *class) 349static void print_lock_name(struct lock_class *class)
355{ 350{
356 char str[128], c1, c2, c3, c4; 351 char str[KSYM_NAME_LEN + 1], c1, c2, c3, c4;
357 const char *name; 352 const char *name;
358 353
359 get_usage_chars(class, &c1, &c2, &c3, &c4); 354 get_usage_chars(class, &c1, &c2, &c3, &c4);
@@ -375,7 +370,7 @@ static void print_lock_name(struct lock_class *class)
375static void print_lockdep_cache(struct lockdep_map *lock) 370static void print_lockdep_cache(struct lockdep_map *lock)
376{ 371{
377 const char *name; 372 const char *name;
378 char str[128]; 373 char str[KSYM_NAME_LEN + 1];
379 374
380 name = lock->name; 375 name = lock->name;
381 if (!name) 376 if (!name)
@@ -445,7 +440,9 @@ static void print_lock_dependencies(struct lock_class *class, int depth)
445 print_lock_class_header(class, depth); 440 print_lock_class_header(class, depth);
446 441
447 list_for_each_entry(entry, &class->locks_after, entry) { 442 list_for_each_entry(entry, &class->locks_after, entry) {
448 DEBUG_LOCKS_WARN_ON(!entry->class); 443 if (DEBUG_LOCKS_WARN_ON(!entry->class))
444 return;
445
449 print_lock_dependencies(entry->class, depth + 1); 446 print_lock_dependencies(entry->class, depth + 1);
450 447
451 printk("%*s ... acquired at:\n",depth,""); 448 printk("%*s ... acquired at:\n",depth,"");
@@ -470,7 +467,8 @@ static int add_lock_to_list(struct lock_class *class, struct lock_class *this,
470 return 0; 467 return 0;
471 468
472 entry->class = this; 469 entry->class = this;
473 save_trace(&entry->trace); 470 if (!save_trace(&entry->trace))
471 return 0;
474 472
475 /* 473 /*
476 * Since we never remove from the dependency list, the list can 474 * Since we never remove from the dependency list, the list can
@@ -558,8 +556,12 @@ static noinline int print_circular_bug_tail(void)
558 if (debug_locks_silent) 556 if (debug_locks_silent)
559 return 0; 557 return 0;
560 558
559 /* hash_lock unlocked by the header */
560 __raw_spin_lock(&hash_lock);
561 this.class = check_source->class; 561 this.class = check_source->class;
562 save_trace(&this.trace); 562 if (!save_trace(&this.trace))
563 return 0;
564 __raw_spin_unlock(&hash_lock);
563 print_circular_bug_entry(&this, 0); 565 print_circular_bug_entry(&this, 0);
564 566
565 printk("\nother info that might help us debug this:\n\n"); 567 printk("\nother info that might help us debug this:\n\n");
@@ -962,14 +964,11 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
962 &prev->class->locks_after, next->acquire_ip); 964 &prev->class->locks_after, next->acquire_ip);
963 if (!ret) 965 if (!ret)
964 return 0; 966 return 0;
965 /* 967
966 * Return value of 2 signals 'dependency already added',
967 * in that case we dont have to add the backlink either.
968 */
969 if (ret == 2)
970 return 2;
971 ret = add_lock_to_list(next->class, prev->class, 968 ret = add_lock_to_list(next->class, prev->class,
972 &next->class->locks_before, next->acquire_ip); 969 &next->class->locks_before, next->acquire_ip);
970 if (!ret)
971 return 0;
973 972
974 /* 973 /*
975 * Debugging printouts: 974 * Debugging printouts:
@@ -1021,7 +1020,8 @@ check_prevs_add(struct task_struct *curr, struct held_lock *next)
1021 * added: 1020 * added:
1022 */ 1021 */
1023 if (hlock->read != 2) { 1022 if (hlock->read != 2) {
1024 check_prev_add(curr, hlock, next); 1023 if (!check_prev_add(curr, hlock, next))
1024 return 0;
1025 /* 1025 /*
1026 * Stop after the first non-trylock entry, 1026 * Stop after the first non-trylock entry,
1027 * as non-trylock entries have added their 1027 * as non-trylock entries have added their
@@ -1178,6 +1178,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
1178 struct lockdep_subclass_key *key; 1178 struct lockdep_subclass_key *key;
1179 struct list_head *hash_head; 1179 struct list_head *hash_head;
1180 struct lock_class *class; 1180 struct lock_class *class;
1181 unsigned long flags;
1181 1182
1182 class = look_up_lock_class(lock, subclass); 1183 class = look_up_lock_class(lock, subclass);
1183 if (likely(class)) 1184 if (likely(class))
@@ -1199,6 +1200,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
1199 key = lock->key->subkeys + subclass; 1200 key = lock->key->subkeys + subclass;
1200 hash_head = classhashentry(key); 1201 hash_head = classhashentry(key);
1201 1202
1203 raw_local_irq_save(flags);
1202 __raw_spin_lock(&hash_lock); 1204 __raw_spin_lock(&hash_lock);
1203 /* 1205 /*
1204 * We have to do the hash-walk again, to avoid races 1206 * We have to do the hash-walk again, to avoid races
@@ -1213,6 +1215,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
1213 */ 1215 */
1214 if (nr_lock_classes >= MAX_LOCKDEP_KEYS) { 1216 if (nr_lock_classes >= MAX_LOCKDEP_KEYS) {
1215 __raw_spin_unlock(&hash_lock); 1217 __raw_spin_unlock(&hash_lock);
1218 raw_local_irq_restore(flags);
1216 debug_locks_off(); 1219 debug_locks_off();
1217 printk("BUG: MAX_LOCKDEP_KEYS too low!\n"); 1220 printk("BUG: MAX_LOCKDEP_KEYS too low!\n");
1218 printk("turning off the locking correctness validator.\n"); 1221 printk("turning off the locking correctness validator.\n");
@@ -1235,15 +1238,18 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
1235 1238
1236 if (verbose(class)) { 1239 if (verbose(class)) {
1237 __raw_spin_unlock(&hash_lock); 1240 __raw_spin_unlock(&hash_lock);
1241 raw_local_irq_restore(flags);
1238 printk("\nnew class %p: %s", class->key, class->name); 1242 printk("\nnew class %p: %s", class->key, class->name);
1239 if (class->name_version > 1) 1243 if (class->name_version > 1)
1240 printk("#%d", class->name_version); 1244 printk("#%d", class->name_version);
1241 printk("\n"); 1245 printk("\n");
1242 dump_stack(); 1246 dump_stack();
1247 raw_local_irq_save(flags);
1243 __raw_spin_lock(&hash_lock); 1248 __raw_spin_lock(&hash_lock);
1244 } 1249 }
1245out_unlock_set: 1250out_unlock_set:
1246 __raw_spin_unlock(&hash_lock); 1251 __raw_spin_unlock(&hash_lock);
1252 raw_local_irq_restore(flags);
1247 1253
1248 if (!subclass || force) 1254 if (!subclass || force)
1249 lock->class_cache = class; 1255 lock->class_cache = class;
@@ -1724,6 +1730,7 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
1724 debug_atomic_dec(&nr_unused_locks); 1730 debug_atomic_dec(&nr_unused_locks);
1725 break; 1731 break;
1726 default: 1732 default:
1733 __raw_spin_unlock(&hash_lock);
1727 debug_locks_off(); 1734 debug_locks_off();
1728 WARN_ON(1); 1735 WARN_ON(1);
1729 return 0; 1736 return 0;
@@ -2641,6 +2648,7 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
2641 } 2648 }
2642 local_irq_restore(flags); 2649 local_irq_restore(flags);
2643} 2650}
2651EXPORT_SYMBOL_GPL(debug_check_no_locks_freed);
2644 2652
2645static void print_held_locks_bug(struct task_struct *curr) 2653static void print_held_locks_bug(struct task_struct *curr)
2646{ 2654{
diff --git a/kernel/lockdep_internals.h b/kernel/lockdep_internals.h
index eab043c83bb2..8ce09bc4613d 100644
--- a/kernel/lockdep_internals.h
+++ b/kernel/lockdep_internals.h
@@ -20,7 +20,7 @@
20#define MAX_LOCKDEP_KEYS_BITS 11 20#define MAX_LOCKDEP_KEYS_BITS 11
21#define MAX_LOCKDEP_KEYS (1UL << MAX_LOCKDEP_KEYS_BITS) 21#define MAX_LOCKDEP_KEYS (1UL << MAX_LOCKDEP_KEYS_BITS)
22 22
23#define MAX_LOCKDEP_CHAINS_BITS 13 23#define MAX_LOCKDEP_CHAINS_BITS 14
24#define MAX_LOCKDEP_CHAINS (1UL << MAX_LOCKDEP_CHAINS_BITS) 24#define MAX_LOCKDEP_CHAINS (1UL << MAX_LOCKDEP_CHAINS_BITS)
25 25
26/* 26/*
diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
index f6e72eaab3fa..b554b40a4aa6 100644
--- a/kernel/lockdep_proc.c
+++ b/kernel/lockdep_proc.c
@@ -113,7 +113,7 @@ static int l_show(struct seq_file *m, void *v)
113 return 0; 113 return 0;
114} 114}
115 115
116static struct seq_operations lockdep_ops = { 116static const struct seq_operations lockdep_ops = {
117 .start = l_start, 117 .start = l_start,
118 .next = l_next, 118 .next = l_next,
119 .stop = l_stop, 119 .stop = l_stop,
@@ -135,7 +135,7 @@ static int lockdep_open(struct inode *inode, struct file *file)
135 return res; 135 return res;
136} 136}
137 137
138static struct file_operations proc_lockdep_operations = { 138static const struct file_operations proc_lockdep_operations = {
139 .open = lockdep_open, 139 .open = lockdep_open,
140 .read = seq_read, 140 .read = seq_read,
141 .llseek = seq_lseek, 141 .llseek = seq_lseek,
@@ -319,7 +319,7 @@ static int lockdep_stats_open(struct inode *inode, struct file *file)
319 return single_open(file, lockdep_stats_show, NULL); 319 return single_open(file, lockdep_stats_show, NULL);
320} 320}
321 321
322static struct file_operations proc_lockdep_stats_operations = { 322static const struct file_operations proc_lockdep_stats_operations = {
323 .open = lockdep_stats_open, 323 .open = lockdep_stats_open,
324 .read = seq_read, 324 .read = seq_read,
325 .llseek = seq_lseek, 325 .llseek = seq_lseek,
diff --git a/kernel/module.c b/kernel/module.c
index e2d09d604ca0..d9eae45d0145 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2209,7 +2209,7 @@ static int m_show(struct seq_file *m, void *p)
2209 Where refcount is a number or -, and deps is a comma-separated list 2209 Where refcount is a number or -, and deps is a comma-separated list
2210 of depends or -. 2210 of depends or -.
2211*/ 2211*/
2212struct seq_operations modules_op = { 2212const struct seq_operations modules_op = {
2213 .start = m_start, 2213 .start = m_start,
2214 .next = m_next, 2214 .next = m_next,
2215 .stop = m_stop, 2215 .stop = m_stop,
diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
index 18651641a7b5..841539d72c55 100644
--- a/kernel/mutex-debug.c
+++ b/kernel/mutex-debug.c
@@ -77,6 +77,9 @@ void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77 77
78void debug_mutex_unlock(struct mutex *lock) 78void debug_mutex_unlock(struct mutex *lock)
79{ 79{
80 if (unlikely(!debug_locks))
81 return;
82
80 DEBUG_LOCKS_WARN_ON(lock->owner != current_thread_info()); 83 DEBUG_LOCKS_WARN_ON(lock->owner != current_thread_info());
81 DEBUG_LOCKS_WARN_ON(lock->magic != lock); 84 DEBUG_LOCKS_WARN_ON(lock->magic != lock);
82 DEBUG_LOCKS_WARN_ON(!lock->wait_list.prev && !lock->wait_list.next); 85 DEBUG_LOCKS_WARN_ON(!lock->wait_list.prev && !lock->wait_list.next);
diff --git a/kernel/pid.c b/kernel/pid.c
index b914392085f9..a48879b0b921 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -31,7 +31,7 @@
31#define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift) 31#define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift)
32static struct hlist_head *pid_hash; 32static struct hlist_head *pid_hash;
33static int pidhash_shift; 33static int pidhash_shift;
34static kmem_cache_t *pid_cachep; 34static struct kmem_cache *pid_cachep;
35 35
36int pid_max = PID_MAX_DEFAULT; 36int pid_max = PID_MAX_DEFAULT;
37 37
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index 9cbb5d1be06f..5fe87de10ff0 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -70,7 +70,7 @@
70/* 70/*
71 * Lets keep our timers in a slab cache :-) 71 * Lets keep our timers in a slab cache :-)
72 */ 72 */
73static kmem_cache_t *posix_timers_cache; 73static struct kmem_cache *posix_timers_cache;
74static struct idr posix_timers_id; 74static struct idr posix_timers_id;
75static DEFINE_SPINLOCK(idr_lock); 75static DEFINE_SPINLOCK(idr_lock);
76 76
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index 825068ca3479..710ed084e7c5 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -78,7 +78,7 @@ config PM_SYSFS_DEPRECATED
78 78
79config SOFTWARE_SUSPEND 79config SOFTWARE_SUSPEND
80 bool "Software Suspend" 80 bool "Software Suspend"
81 depends on PM && SWAP && ((X86 && (!SMP || SUSPEND_SMP) && !X86_PAE) || ((FRV || PPC32) && !SMP)) 81 depends on PM && SWAP && ((X86 && (!SMP || SUSPEND_SMP)) || ((FRV || PPC32) && !SMP))
82 ---help--- 82 ---help---
83 Enable the possibility of suspending the machine. 83 Enable the possibility of suspending the machine.
84 It doesn't need ACPI or APM. 84 It doesn't need ACPI or APM.
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index b1fb7866b0b3..0b00f56c2ad0 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -20,6 +20,7 @@
20#include <linux/pm.h> 20#include <linux/pm.h>
21#include <linux/console.h> 21#include <linux/console.h>
22#include <linux/cpu.h> 22#include <linux/cpu.h>
23#include <linux/freezer.h>
23 24
24#include "power.h" 25#include "power.h"
25 26
@@ -27,6 +28,23 @@
27static int noresume = 0; 28static int noresume = 0;
28char resume_file[256] = CONFIG_PM_STD_PARTITION; 29char resume_file[256] = CONFIG_PM_STD_PARTITION;
29dev_t swsusp_resume_device; 30dev_t swsusp_resume_device;
31sector_t swsusp_resume_block;
32
33/**
34 * platform_prepare - prepare the machine for hibernation using the
35 * platform driver if so configured and return an error code if it fails
36 */
37
38static inline int platform_prepare(void)
39{
40 int error = 0;
41
42 if (pm_disk_mode == PM_DISK_PLATFORM) {
43 if (pm_ops && pm_ops->prepare)
44 error = pm_ops->prepare(PM_SUSPEND_DISK);
45 }
46 return error;
47}
30 48
31/** 49/**
32 * power_down - Shut machine down for hibernate. 50 * power_down - Shut machine down for hibernate.
@@ -40,12 +58,10 @@ dev_t swsusp_resume_device;
40 58
41static void power_down(suspend_disk_method_t mode) 59static void power_down(suspend_disk_method_t mode)
42{ 60{
43 int error = 0;
44
45 switch(mode) { 61 switch(mode) {
46 case PM_DISK_PLATFORM: 62 case PM_DISK_PLATFORM:
47 kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK); 63 kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK);
48 error = pm_ops->enter(PM_SUSPEND_DISK); 64 pm_ops->enter(PM_SUSPEND_DISK);
49 break; 65 break;
50 case PM_DISK_SHUTDOWN: 66 case PM_DISK_SHUTDOWN:
51 kernel_power_off(); 67 kernel_power_off();
@@ -90,12 +106,18 @@ static int prepare_processes(void)
90 goto thaw; 106 goto thaw;
91 } 107 }
92 108
109 error = platform_prepare();
110 if (error)
111 goto thaw;
112
93 /* Free memory before shutting down devices. */ 113 /* Free memory before shutting down devices. */
94 if (!(error = swsusp_shrink_memory())) 114 if (!(error = swsusp_shrink_memory()))
95 return 0; 115 return 0;
96thaw: 116
117 platform_finish();
118 thaw:
97 thaw_processes(); 119 thaw_processes();
98enable_cpus: 120 enable_cpus:
99 enable_nonboot_cpus(); 121 enable_nonboot_cpus();
100 pm_restore_console(); 122 pm_restore_console();
101 return error; 123 return error;
@@ -127,7 +149,7 @@ int pm_suspend_disk(void)
127 return error; 149 return error;
128 150
129 if (pm_disk_mode == PM_DISK_TESTPROC) 151 if (pm_disk_mode == PM_DISK_TESTPROC)
130 goto Thaw; 152 return 0;
131 153
132 suspend_console(); 154 suspend_console();
133 error = device_suspend(PMSG_FREEZE); 155 error = device_suspend(PMSG_FREEZE);
@@ -189,10 +211,10 @@ static int software_resume(void)
189{ 211{
190 int error; 212 int error;
191 213
192 down(&pm_sem); 214 mutex_lock(&pm_mutex);
193 if (!swsusp_resume_device) { 215 if (!swsusp_resume_device) {
194 if (!strlen(resume_file)) { 216 if (!strlen(resume_file)) {
195 up(&pm_sem); 217 mutex_unlock(&pm_mutex);
196 return -ENOENT; 218 return -ENOENT;
197 } 219 }
198 swsusp_resume_device = name_to_dev_t(resume_file); 220 swsusp_resume_device = name_to_dev_t(resume_file);
@@ -207,7 +229,7 @@ static int software_resume(void)
207 * FIXME: If noresume is specified, we need to find the partition 229 * FIXME: If noresume is specified, we need to find the partition
208 * and reset it back to normal swap space. 230 * and reset it back to normal swap space.
209 */ 231 */
210 up(&pm_sem); 232 mutex_unlock(&pm_mutex);
211 return 0; 233 return 0;
212 } 234 }
213 235
@@ -251,7 +273,7 @@ static int software_resume(void)
251 unprepare_processes(); 273 unprepare_processes();
252 Done: 274 Done:
253 /* For success case, the suspend path will release the lock */ 275 /* For success case, the suspend path will release the lock */
254 up(&pm_sem); 276 mutex_unlock(&pm_mutex);
255 pr_debug("PM: Resume from disk failed.\n"); 277 pr_debug("PM: Resume from disk failed.\n");
256 return 0; 278 return 0;
257} 279}
@@ -312,7 +334,7 @@ static ssize_t disk_store(struct subsystem * s, const char * buf, size_t n)
312 p = memchr(buf, '\n', n); 334 p = memchr(buf, '\n', n);
313 len = p ? p - buf : n; 335 len = p ? p - buf : n;
314 336
315 down(&pm_sem); 337 mutex_lock(&pm_mutex);
316 for (i = PM_DISK_FIRMWARE; i < PM_DISK_MAX; i++) { 338 for (i = PM_DISK_FIRMWARE; i < PM_DISK_MAX; i++) {
317 if (!strncmp(buf, pm_disk_modes[i], len)) { 339 if (!strncmp(buf, pm_disk_modes[i], len)) {
318 mode = i; 340 mode = i;
@@ -336,7 +358,7 @@ static ssize_t disk_store(struct subsystem * s, const char * buf, size_t n)
336 358
337 pr_debug("PM: suspend-to-disk mode set to '%s'\n", 359 pr_debug("PM: suspend-to-disk mode set to '%s'\n",
338 pm_disk_modes[mode]); 360 pm_disk_modes[mode]);
339 up(&pm_sem); 361 mutex_unlock(&pm_mutex);
340 return error ? error : n; 362 return error ? error : n;
341} 363}
342 364
@@ -361,14 +383,14 @@ static ssize_t resume_store(struct subsystem *subsys, const char *buf, size_t n)
361 if (maj != MAJOR(res) || min != MINOR(res)) 383 if (maj != MAJOR(res) || min != MINOR(res))
362 goto out; 384 goto out;
363 385
364 down(&pm_sem); 386 mutex_lock(&pm_mutex);
365 swsusp_resume_device = res; 387 swsusp_resume_device = res;
366 up(&pm_sem); 388 mutex_unlock(&pm_mutex);
367 printk("Attempting manual resume\n"); 389 printk("Attempting manual resume\n");
368 noresume = 0; 390 noresume = 0;
369 software_resume(); 391 software_resume();
370 ret = n; 392 ret = n;
371out: 393 out:
372 return ret; 394 return ret;
373} 395}
374 396
@@ -423,6 +445,19 @@ static int __init resume_setup(char *str)
423 return 1; 445 return 1;
424} 446}
425 447
448static int __init resume_offset_setup(char *str)
449{
450 unsigned long long offset;
451
452 if (noresume)
453 return 1;
454
455 if (sscanf(str, "%llu", &offset) == 1)
456 swsusp_resume_block = offset;
457
458 return 1;
459}
460
426static int __init noresume_setup(char *str) 461static int __init noresume_setup(char *str)
427{ 462{
428 noresume = 1; 463 noresume = 1;
@@ -430,4 +465,5 @@ static int __init noresume_setup(char *str)
430} 465}
431 466
432__setup("noresume", noresume_setup); 467__setup("noresume", noresume_setup);
468__setup("resume_offset=", resume_offset_setup);
433__setup("resume=", resume_setup); 469__setup("resume=", resume_setup);
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 873228c71dab..500eb87f643d 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -8,6 +8,7 @@
8 * 8 *
9 */ 9 */
10 10
11#include <linux/module.h>
11#include <linux/suspend.h> 12#include <linux/suspend.h>
12#include <linux/kobject.h> 13#include <linux/kobject.h>
13#include <linux/string.h> 14#include <linux/string.h>
@@ -18,13 +19,14 @@
18#include <linux/console.h> 19#include <linux/console.h>
19#include <linux/cpu.h> 20#include <linux/cpu.h>
20#include <linux/resume-trace.h> 21#include <linux/resume-trace.h>
22#include <linux/freezer.h>
21 23
22#include "power.h" 24#include "power.h"
23 25
24/*This is just an arbitrary number */ 26/*This is just an arbitrary number */
25#define FREE_PAGE_NUMBER (100) 27#define FREE_PAGE_NUMBER (100)
26 28
27DECLARE_MUTEX(pm_sem); 29DEFINE_MUTEX(pm_mutex);
28 30
29struct pm_ops *pm_ops; 31struct pm_ops *pm_ops;
30suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN; 32suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN;
@@ -36,9 +38,9 @@ suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN;
36 38
37void pm_set_ops(struct pm_ops * ops) 39void pm_set_ops(struct pm_ops * ops)
38{ 40{
39 down(&pm_sem); 41 mutex_lock(&pm_mutex);
40 pm_ops = ops; 42 pm_ops = ops;
41 up(&pm_sem); 43 mutex_unlock(&pm_mutex);
42} 44}
43 45
44 46
@@ -182,7 +184,7 @@ static int enter_state(suspend_state_t state)
182 184
183 if (!valid_state(state)) 185 if (!valid_state(state))
184 return -ENODEV; 186 return -ENODEV;
185 if (down_trylock(&pm_sem)) 187 if (!mutex_trylock(&pm_mutex))
186 return -EBUSY; 188 return -EBUSY;
187 189
188 if (state == PM_SUSPEND_DISK) { 190 if (state == PM_SUSPEND_DISK) {
@@ -200,7 +202,7 @@ static int enter_state(suspend_state_t state)
200 pr_debug("PM: Finishing wakeup.\n"); 202 pr_debug("PM: Finishing wakeup.\n");
201 suspend_finish(state); 203 suspend_finish(state);
202 Unlock: 204 Unlock:
203 up(&pm_sem); 205 mutex_unlock(&pm_mutex);
204 return error; 206 return error;
205} 207}
206 208
@@ -229,7 +231,7 @@ int pm_suspend(suspend_state_t state)
229 return -EINVAL; 231 return -EINVAL;
230} 232}
231 233
232 234EXPORT_SYMBOL(pm_suspend);
233 235
234decl_subsys(power,NULL,NULL); 236decl_subsys(power,NULL,NULL);
235 237
diff --git a/kernel/power/power.h b/kernel/power/power.h
index bfe999f7b272..eb461b816bf4 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -22,7 +22,9 @@ static inline int pm_suspend_disk(void)
22 return -EPERM; 22 return -EPERM;
23} 23}
24#endif 24#endif
25extern struct semaphore pm_sem; 25
26extern struct mutex pm_mutex;
27
26#define power_attr(_name) \ 28#define power_attr(_name) \
27static struct subsys_attribute _name##_attr = { \ 29static struct subsys_attribute _name##_attr = { \
28 .attr = { \ 30 .attr = { \
@@ -42,6 +44,7 @@ extern const void __nosave_begin, __nosave_end;
42extern unsigned long image_size; 44extern unsigned long image_size;
43extern int in_suspend; 45extern int in_suspend;
44extern dev_t swsusp_resume_device; 46extern dev_t swsusp_resume_device;
47extern sector_t swsusp_resume_block;
45 48
46extern asmlinkage int swsusp_arch_suspend(void); 49extern asmlinkage int swsusp_arch_suspend(void);
47extern asmlinkage int swsusp_arch_resume(void); 50extern asmlinkage int swsusp_arch_resume(void);
@@ -102,8 +105,18 @@ struct snapshot_handle {
102extern unsigned int snapshot_additional_pages(struct zone *zone); 105extern unsigned int snapshot_additional_pages(struct zone *zone);
103extern int snapshot_read_next(struct snapshot_handle *handle, size_t count); 106extern int snapshot_read_next(struct snapshot_handle *handle, size_t count);
104extern int snapshot_write_next(struct snapshot_handle *handle, size_t count); 107extern int snapshot_write_next(struct snapshot_handle *handle, size_t count);
108extern void snapshot_write_finalize(struct snapshot_handle *handle);
105extern int snapshot_image_loaded(struct snapshot_handle *handle); 109extern int snapshot_image_loaded(struct snapshot_handle *handle);
106extern void snapshot_free_unused_memory(struct snapshot_handle *handle); 110
111/*
112 * This structure is used to pass the values needed for the identification
113 * of the resume swap area from a user space to the kernel via the
114 * SNAPSHOT_SET_SWAP_AREA ioctl
115 */
116struct resume_swap_area {
117 loff_t offset;
118 u_int32_t dev;
119} __attribute__((packed));
107 120
108#define SNAPSHOT_IOC_MAGIC '3' 121#define SNAPSHOT_IOC_MAGIC '3'
109#define SNAPSHOT_FREEZE _IO(SNAPSHOT_IOC_MAGIC, 1) 122#define SNAPSHOT_FREEZE _IO(SNAPSHOT_IOC_MAGIC, 1)
@@ -117,7 +130,14 @@ extern void snapshot_free_unused_memory(struct snapshot_handle *handle);
117#define SNAPSHOT_FREE_SWAP_PAGES _IO(SNAPSHOT_IOC_MAGIC, 9) 130#define SNAPSHOT_FREE_SWAP_PAGES _IO(SNAPSHOT_IOC_MAGIC, 9)
118#define SNAPSHOT_SET_SWAP_FILE _IOW(SNAPSHOT_IOC_MAGIC, 10, unsigned int) 131#define SNAPSHOT_SET_SWAP_FILE _IOW(SNAPSHOT_IOC_MAGIC, 10, unsigned int)
119#define SNAPSHOT_S2RAM _IO(SNAPSHOT_IOC_MAGIC, 11) 132#define SNAPSHOT_S2RAM _IO(SNAPSHOT_IOC_MAGIC, 11)
120#define SNAPSHOT_IOC_MAXNR 11 133#define SNAPSHOT_PMOPS _IOW(SNAPSHOT_IOC_MAGIC, 12, unsigned int)
134#define SNAPSHOT_SET_SWAP_AREA _IOW(SNAPSHOT_IOC_MAGIC, 13, \
135 struct resume_swap_area)
136#define SNAPSHOT_IOC_MAXNR 13
137
138#define PMOPS_PREPARE 1
139#define PMOPS_ENTER 2
140#define PMOPS_FINISH 3
121 141
122/** 142/**
123 * The bitmap is used for tracing allocated swap pages 143 * The bitmap is used for tracing allocated swap pages
@@ -141,7 +161,7 @@ struct bitmap_page {
141 161
142extern void free_bitmap(struct bitmap_page *bitmap); 162extern void free_bitmap(struct bitmap_page *bitmap);
143extern struct bitmap_page *alloc_bitmap(unsigned int nr_bits); 163extern struct bitmap_page *alloc_bitmap(unsigned int nr_bits);
144extern unsigned long alloc_swap_page(int swap, struct bitmap_page *bitmap); 164extern sector_t alloc_swapdev_block(int swap, struct bitmap_page *bitmap);
145extern void free_all_swap_pages(int swap, struct bitmap_page *bitmap); 165extern void free_all_swap_pages(int swap, struct bitmap_page *bitmap);
146 166
147extern int swsusp_check(void); 167extern int swsusp_check(void);
@@ -153,3 +173,7 @@ extern int swsusp_read(void);
153extern int swsusp_write(void); 173extern int swsusp_write(void);
154extern void swsusp_close(void); 174extern void swsusp_close(void);
155extern int suspend_enter(suspend_state_t state); 175extern int suspend_enter(suspend_state_t state);
176
177struct timeval;
178extern void swsusp_show_speed(struct timeval *, struct timeval *,
179 unsigned int, char *);
diff --git a/kernel/power/poweroff.c b/kernel/power/poweroff.c
index f1f900ac3164..678ec736076b 100644
--- a/kernel/power/poweroff.c
+++ b/kernel/power/poweroff.c
@@ -16,12 +16,12 @@
16 * callback we use. 16 * callback we use.
17 */ 17 */
18 18
19static void do_poweroff(void *dummy) 19static void do_poweroff(struct work_struct *dummy)
20{ 20{
21 kernel_power_off(); 21 kernel_power_off();
22} 22}
23 23
24static DECLARE_WORK(poweroff_work, do_poweroff, NULL); 24static DECLARE_WORK(poweroff_work, do_poweroff);
25 25
26static void handle_poweroff(int key, struct tty_struct *tty) 26static void handle_poweroff(int key, struct tty_struct *tty)
27{ 27{
diff --git a/kernel/power/process.c b/kernel/power/process.c
index 72e72d2c61e6..99eeb119b06d 100644
--- a/kernel/power/process.c
+++ b/kernel/power/process.c
@@ -13,12 +13,15 @@
13#include <linux/suspend.h> 13#include <linux/suspend.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/syscalls.h> 15#include <linux/syscalls.h>
16#include <linux/freezer.h>
16 17
17/* 18/*
18 * Timeout for stopping processes 19 * Timeout for stopping processes
19 */ 20 */
20#define TIMEOUT (20 * HZ) 21#define TIMEOUT (20 * HZ)
21 22
23#define FREEZER_KERNEL_THREADS 0
24#define FREEZER_USER_SPACE 1
22 25
23static inline int freezeable(struct task_struct * p) 26static inline int freezeable(struct task_struct * p)
24{ 27{
@@ -39,7 +42,6 @@ void refrigerator(void)
39 long save; 42 long save;
40 save = current->state; 43 save = current->state;
41 pr_debug("%s entered refrigerator\n", current->comm); 44 pr_debug("%s entered refrigerator\n", current->comm);
42 printk("=");
43 45
44 frozen_process(current); 46 frozen_process(current);
45 spin_lock_irq(&current->sighand->siglock); 47 spin_lock_irq(&current->sighand->siglock);
@@ -79,96 +81,136 @@ static void cancel_freezing(struct task_struct *p)
79 } 81 }
80} 82}
81 83
82/* 0 = success, else # of processes that we failed to stop */ 84static inline int is_user_space(struct task_struct *p)
83int freeze_processes(void) 85{
86 return p->mm && !(p->flags & PF_BORROWED_MM);
87}
88
89static unsigned int try_to_freeze_tasks(int freeze_user_space)
84{ 90{
85 int todo, nr_user, user_frozen;
86 unsigned long start_time;
87 struct task_struct *g, *p; 91 struct task_struct *g, *p;
92 unsigned long end_time;
93 unsigned int todo;
88 94
89 printk( "Stopping tasks: " ); 95 end_time = jiffies + TIMEOUT;
90 start_time = jiffies;
91 user_frozen = 0;
92 do { 96 do {
93 nr_user = todo = 0; 97 todo = 0;
94 read_lock(&tasklist_lock); 98 read_lock(&tasklist_lock);
95 do_each_thread(g, p) { 99 do_each_thread(g, p) {
96 if (!freezeable(p)) 100 if (!freezeable(p))
97 continue; 101 continue;
102
98 if (frozen(p)) 103 if (frozen(p))
99 continue; 104 continue;
100 if (p->state == TASK_TRACED && frozen(p->parent)) { 105
106 if (p->state == TASK_TRACED &&
107 (frozen(p->parent) ||
108 p->parent->state == TASK_STOPPED)) {
101 cancel_freezing(p); 109 cancel_freezing(p);
102 continue; 110 continue;
103 } 111 }
104 if (p->mm && !(p->flags & PF_BORROWED_MM)) { 112 if (is_user_space(p)) {
105 /* The task is a user-space one. 113 if (!freeze_user_space)
106 * Freeze it unless there's a vfork completion 114 continue;
107 * pending 115
116 /* Freeze the task unless there is a vfork
117 * completion pending
108 */ 118 */
109 if (!p->vfork_done) 119 if (!p->vfork_done)
110 freeze_process(p); 120 freeze_process(p);
111 nr_user++;
112 } else { 121 } else {
113 /* Freeze only if the user space is frozen */ 122 if (freeze_user_space)
114 if (user_frozen) 123 continue;
115 freeze_process(p); 124
116 todo++; 125 freeze_process(p);
117 } 126 }
127 todo++;
118 } while_each_thread(g, p); 128 } while_each_thread(g, p);
119 read_unlock(&tasklist_lock); 129 read_unlock(&tasklist_lock);
120 todo += nr_user;
121 if (!user_frozen && !nr_user) {
122 sys_sync();
123 start_time = jiffies;
124 }
125 user_frozen = !nr_user;
126 yield(); /* Yield is okay here */ 130 yield(); /* Yield is okay here */
127 if (todo && time_after(jiffies, start_time + TIMEOUT)) 131 if (todo && time_after(jiffies, end_time))
128 break; 132 break;
129 } while(todo); 133 } while (todo);
130 134
131 /* This does not unfreeze processes that are already frozen
132 * (we have slightly ugly calling convention in that respect,
133 * and caller must call thaw_processes() if something fails),
134 * but it cleans up leftover PF_FREEZE requests.
135 */
136 if (todo) { 135 if (todo) {
137 printk( "\n" ); 136 /* This does not unfreeze processes that are already frozen
138 printk(KERN_ERR " stopping tasks timed out " 137 * (we have slightly ugly calling convention in that respect,
139 "after %d seconds (%d tasks remaining):\n", 138 * and caller must call thaw_processes() if something fails),
140 TIMEOUT / HZ, todo); 139 * but it cleans up leftover PF_FREEZE requests.
140 */
141 printk("\n");
142 printk(KERN_ERR "Stopping %s timed out after %d seconds "
143 "(%d tasks refusing to freeze):\n",
144 freeze_user_space ? "user space processes" :
145 "kernel threads",
146 TIMEOUT / HZ, todo);
141 read_lock(&tasklist_lock); 147 read_lock(&tasklist_lock);
142 do_each_thread(g, p) { 148 do_each_thread(g, p) {
149 if (is_user_space(p) == !freeze_user_space)
150 continue;
151
143 if (freezeable(p) && !frozen(p)) 152 if (freezeable(p) && !frozen(p))
144 printk(KERN_ERR " %s\n", p->comm); 153 printk(KERN_ERR " %s\n", p->comm);
154
145 cancel_freezing(p); 155 cancel_freezing(p);
146 } while_each_thread(g, p); 156 } while_each_thread(g, p);
147 read_unlock(&tasklist_lock); 157 read_unlock(&tasklist_lock);
148 return todo;
149 } 158 }
150 159
151 printk( "|\n" ); 160 return todo;
161}
162
163/**
164 * freeze_processes - tell processes to enter the refrigerator
165 *
166 * Returns 0 on success, or the number of processes that didn't freeze,
167 * although they were told to.
168 */
169int freeze_processes(void)
170{
171 unsigned int nr_unfrozen;
172
173 printk("Stopping tasks ... ");
174 nr_unfrozen = try_to_freeze_tasks(FREEZER_USER_SPACE);
175 if (nr_unfrozen)
176 return nr_unfrozen;
177
178 sys_sync();
179 nr_unfrozen = try_to_freeze_tasks(FREEZER_KERNEL_THREADS);
180 if (nr_unfrozen)
181 return nr_unfrozen;
182
183 printk("done.\n");
152 BUG_ON(in_atomic()); 184 BUG_ON(in_atomic());
153 return 0; 185 return 0;
154} 186}
155 187
156void thaw_processes(void) 188static void thaw_tasks(int thaw_user_space)
157{ 189{
158 struct task_struct *g, *p; 190 struct task_struct *g, *p;
159 191
160 printk( "Restarting tasks..." );
161 read_lock(&tasklist_lock); 192 read_lock(&tasklist_lock);
162 do_each_thread(g, p) { 193 do_each_thread(g, p) {
163 if (!freezeable(p)) 194 if (!freezeable(p))
164 continue; 195 continue;
196
197 if (is_user_space(p) == !thaw_user_space)
198 continue;
199
165 if (!thaw_process(p)) 200 if (!thaw_process(p))
166 printk(KERN_INFO " Strange, %s not stopped\n", p->comm ); 201 printk(KERN_WARNING " Strange, %s not stopped\n",
202 p->comm );
167 } while_each_thread(g, p); 203 } while_each_thread(g, p);
168
169 read_unlock(&tasklist_lock); 204 read_unlock(&tasklist_lock);
205}
206
207void thaw_processes(void)
208{
209 printk("Restarting tasks ... ");
210 thaw_tasks(FREEZER_KERNEL_THREADS);
211 thaw_tasks(FREEZER_USER_SPACE);
170 schedule(); 212 schedule();
171 printk( " done\n" ); 213 printk("done.\n");
172} 214}
173 215
174EXPORT_SYMBOL(refrigerator); 216EXPORT_SYMBOL(refrigerator);
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index 99f9b7d177d6..c024606221c4 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -1,15 +1,15 @@
1/* 1/*
2 * linux/kernel/power/snapshot.c 2 * linux/kernel/power/snapshot.c
3 * 3 *
4 * This file provide system snapshot/restore functionality. 4 * This file provides system snapshot/restore functionality for swsusp.
5 * 5 *
6 * Copyright (C) 1998-2005 Pavel Machek <pavel@suse.cz> 6 * Copyright (C) 1998-2005 Pavel Machek <pavel@suse.cz>
7 * Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
7 * 8 *
8 * This file is released under the GPLv2, and is based on swsusp.c. 9 * This file is released under the GPLv2.
9 * 10 *
10 */ 11 */
11 12
12
13#include <linux/version.h> 13#include <linux/version.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/mm.h> 15#include <linux/mm.h>
@@ -34,137 +34,24 @@
34 34
35#include "power.h" 35#include "power.h"
36 36
37/* List of PBEs used for creating and restoring the suspend image */ 37/* List of PBEs needed for restoring the pages that were allocated before
38 * the suspend and included in the suspend image, but have also been
39 * allocated by the "resume" kernel, so their contents cannot be written
40 * directly to their "original" page frames.
41 */
38struct pbe *restore_pblist; 42struct pbe *restore_pblist;
39 43
40static unsigned int nr_copy_pages; 44/* Pointer to an auxiliary buffer (1 page) */
41static unsigned int nr_meta_pages;
42static void *buffer; 45static void *buffer;
43 46
44#ifdef CONFIG_HIGHMEM
45unsigned int count_highmem_pages(void)
46{
47 struct zone *zone;
48 unsigned long zone_pfn;
49 unsigned int n = 0;
50
51 for_each_zone (zone)
52 if (is_highmem(zone)) {
53 mark_free_pages(zone);
54 for (zone_pfn = 0; zone_pfn < zone->spanned_pages; zone_pfn++) {
55 struct page *page;
56 unsigned long pfn = zone_pfn + zone->zone_start_pfn;
57 if (!pfn_valid(pfn))
58 continue;
59 page = pfn_to_page(pfn);
60 if (PageReserved(page))
61 continue;
62 if (PageNosaveFree(page))
63 continue;
64 n++;
65 }
66 }
67 return n;
68}
69
70struct highmem_page {
71 char *data;
72 struct page *page;
73 struct highmem_page *next;
74};
75
76static struct highmem_page *highmem_copy;
77
78static int save_highmem_zone(struct zone *zone)
79{
80 unsigned long zone_pfn;
81 mark_free_pages(zone);
82 for (zone_pfn = 0; zone_pfn < zone->spanned_pages; ++zone_pfn) {
83 struct page *page;
84 struct highmem_page *save;
85 void *kaddr;
86 unsigned long pfn = zone_pfn + zone->zone_start_pfn;
87
88 if (!(pfn%10000))
89 printk(".");
90 if (!pfn_valid(pfn))
91 continue;
92 page = pfn_to_page(pfn);
93 /*
94 * This condition results from rvmalloc() sans vmalloc_32()
95 * and architectural memory reservations. This should be
96 * corrected eventually when the cases giving rise to this
97 * are better understood.
98 */
99 if (PageReserved(page))
100 continue;
101 BUG_ON(PageNosave(page));
102 if (PageNosaveFree(page))
103 continue;
104 save = kmalloc(sizeof(struct highmem_page), GFP_ATOMIC);
105 if (!save)
106 return -ENOMEM;
107 save->next = highmem_copy;
108 save->page = page;
109 save->data = (void *) get_zeroed_page(GFP_ATOMIC);
110 if (!save->data) {
111 kfree(save);
112 return -ENOMEM;
113 }
114 kaddr = kmap_atomic(page, KM_USER0);
115 memcpy(save->data, kaddr, PAGE_SIZE);
116 kunmap_atomic(kaddr, KM_USER0);
117 highmem_copy = save;
118 }
119 return 0;
120}
121
122int save_highmem(void)
123{
124 struct zone *zone;
125 int res = 0;
126
127 pr_debug("swsusp: Saving Highmem");
128 drain_local_pages();
129 for_each_zone (zone) {
130 if (is_highmem(zone))
131 res = save_highmem_zone(zone);
132 if (res)
133 return res;
134 }
135 printk("\n");
136 return 0;
137}
138
139int restore_highmem(void)
140{
141 printk("swsusp: Restoring Highmem\n");
142 while (highmem_copy) {
143 struct highmem_page *save = highmem_copy;
144 void *kaddr;
145 highmem_copy = save->next;
146
147 kaddr = kmap_atomic(save->page, KM_USER0);
148 memcpy(kaddr, save->data, PAGE_SIZE);
149 kunmap_atomic(kaddr, KM_USER0);
150 free_page((long) save->data);
151 kfree(save);
152 }
153 return 0;
154}
155#else
156static inline unsigned int count_highmem_pages(void) {return 0;}
157static inline int save_highmem(void) {return 0;}
158static inline int restore_highmem(void) {return 0;}
159#endif
160
161/** 47/**
162 * @safe_needed - on resume, for storing the PBE list and the image, 48 * @safe_needed - on resume, for storing the PBE list and the image,
163 * we can only use memory pages that do not conflict with the pages 49 * we can only use memory pages that do not conflict with the pages
164 * used before suspend. 50 * used before suspend. The unsafe pages have PageNosaveFree set
51 * and we count them using unsafe_pages.
165 * 52 *
166 * The unsafe pages are marked with the PG_nosave_free flag 53 * Each allocated image page is marked as PageNosave and PageNosaveFree
167 * and we count them using unsafe_pages 54 * so that swsusp_free() can release it.
168 */ 55 */
169 56
170#define PG_ANY 0 57#define PG_ANY 0
@@ -174,7 +61,7 @@ static inline int restore_highmem(void) {return 0;}
174 61
175static unsigned int allocated_unsafe_pages; 62static unsigned int allocated_unsafe_pages;
176 63
177static void *alloc_image_page(gfp_t gfp_mask, int safe_needed) 64static void *get_image_page(gfp_t gfp_mask, int safe_needed)
178{ 65{
179 void *res; 66 void *res;
180 67
@@ -195,20 +82,39 @@ static void *alloc_image_page(gfp_t gfp_mask, int safe_needed)
195 82
196unsigned long get_safe_page(gfp_t gfp_mask) 83unsigned long get_safe_page(gfp_t gfp_mask)
197{ 84{
198 return (unsigned long)alloc_image_page(gfp_mask, PG_SAFE); 85 return (unsigned long)get_image_page(gfp_mask, PG_SAFE);
86}
87
88static struct page *alloc_image_page(gfp_t gfp_mask)
89{
90 struct page *page;
91
92 page = alloc_page(gfp_mask);
93 if (page) {
94 SetPageNosave(page);
95 SetPageNosaveFree(page);
96 }
97 return page;
199} 98}
200 99
201/** 100/**
202 * free_image_page - free page represented by @addr, allocated with 101 * free_image_page - free page represented by @addr, allocated with
203 * alloc_image_page (page flags set by it must be cleared) 102 * get_image_page (page flags set by it must be cleared)
204 */ 103 */
205 104
206static inline void free_image_page(void *addr, int clear_nosave_free) 105static inline void free_image_page(void *addr, int clear_nosave_free)
207{ 106{
208 ClearPageNosave(virt_to_page(addr)); 107 struct page *page;
108
109 BUG_ON(!virt_addr_valid(addr));
110
111 page = virt_to_page(addr);
112
113 ClearPageNosave(page);
209 if (clear_nosave_free) 114 if (clear_nosave_free)
210 ClearPageNosaveFree(virt_to_page(addr)); 115 ClearPageNosaveFree(page);
211 free_page((unsigned long)addr); 116
117 __free_page(page);
212} 118}
213 119
214/* struct linked_page is used to build chains of pages */ 120/* struct linked_page is used to build chains of pages */
@@ -269,7 +175,7 @@ static void *chain_alloc(struct chain_allocator *ca, unsigned int size)
269 if (LINKED_PAGE_DATA_SIZE - ca->used_space < size) { 175 if (LINKED_PAGE_DATA_SIZE - ca->used_space < size) {
270 struct linked_page *lp; 176 struct linked_page *lp;
271 177
272 lp = alloc_image_page(ca->gfp_mask, ca->safe_needed); 178 lp = get_image_page(ca->gfp_mask, ca->safe_needed);
273 if (!lp) 179 if (!lp)
274 return NULL; 180 return NULL;
275 181
@@ -446,8 +352,8 @@ memory_bm_create(struct memory_bitmap *bm, gfp_t gfp_mask, int safe_needed)
446 352
447 /* Compute the number of zones */ 353 /* Compute the number of zones */
448 nr = 0; 354 nr = 0;
449 for_each_zone (zone) 355 for_each_zone(zone)
450 if (populated_zone(zone) && !is_highmem(zone)) 356 if (populated_zone(zone))
451 nr++; 357 nr++;
452 358
453 /* Allocate the list of zones bitmap objects */ 359 /* Allocate the list of zones bitmap objects */
@@ -459,10 +365,10 @@ memory_bm_create(struct memory_bitmap *bm, gfp_t gfp_mask, int safe_needed)
459 } 365 }
460 366
461 /* Initialize the zone bitmap objects */ 367 /* Initialize the zone bitmap objects */
462 for_each_zone (zone) { 368 for_each_zone(zone) {
463 unsigned long pfn; 369 unsigned long pfn;
464 370
465 if (!populated_zone(zone) || is_highmem(zone)) 371 if (!populated_zone(zone))
466 continue; 372 continue;
467 373
468 zone_bm->start_pfn = zone->zone_start_pfn; 374 zone_bm->start_pfn = zone->zone_start_pfn;
@@ -481,7 +387,7 @@ memory_bm_create(struct memory_bitmap *bm, gfp_t gfp_mask, int safe_needed)
481 while (bb) { 387 while (bb) {
482 unsigned long *ptr; 388 unsigned long *ptr;
483 389
484 ptr = alloc_image_page(gfp_mask, safe_needed); 390 ptr = get_image_page(gfp_mask, safe_needed);
485 bb->data = ptr; 391 bb->data = ptr;
486 if (!ptr) 392 if (!ptr)
487 goto Free; 393 goto Free;
@@ -505,7 +411,7 @@ memory_bm_create(struct memory_bitmap *bm, gfp_t gfp_mask, int safe_needed)
505 memory_bm_position_reset(bm); 411 memory_bm_position_reset(bm);
506 return 0; 412 return 0;
507 413
508Free: 414 Free:
509 bm->p_list = ca.chain; 415 bm->p_list = ca.chain;
510 memory_bm_free(bm, PG_UNSAFE_CLEAR); 416 memory_bm_free(bm, PG_UNSAFE_CLEAR);
511 return -ENOMEM; 417 return -ENOMEM;
@@ -651,7 +557,7 @@ static unsigned long memory_bm_next_pfn(struct memory_bitmap *bm)
651 memory_bm_position_reset(bm); 557 memory_bm_position_reset(bm);
652 return BM_END_OF_MAP; 558 return BM_END_OF_MAP;
653 559
654Return_pfn: 560 Return_pfn:
655 bm->cur.chunk = chunk; 561 bm->cur.chunk = chunk;
656 bm->cur.bit = bit; 562 bm->cur.bit = bit;
657 return bb->start_pfn + chunk * BM_BITS_PER_CHUNK + bit; 563 return bb->start_pfn + chunk * BM_BITS_PER_CHUNK + bit;
@@ -669,10 +575,82 @@ unsigned int snapshot_additional_pages(struct zone *zone)
669 575
670 res = DIV_ROUND_UP(zone->spanned_pages, BM_BITS_PER_BLOCK); 576 res = DIV_ROUND_UP(zone->spanned_pages, BM_BITS_PER_BLOCK);
671 res += DIV_ROUND_UP(res * sizeof(struct bm_block), PAGE_SIZE); 577 res += DIV_ROUND_UP(res * sizeof(struct bm_block), PAGE_SIZE);
672 return res; 578 return 2 * res;
579}
580
581#ifdef CONFIG_HIGHMEM
582/**
583 * count_free_highmem_pages - compute the total number of free highmem
584 * pages, system-wide.
585 */
586
587static unsigned int count_free_highmem_pages(void)
588{
589 struct zone *zone;
590 unsigned int cnt = 0;
591
592 for_each_zone(zone)
593 if (populated_zone(zone) && is_highmem(zone))
594 cnt += zone->free_pages;
595
596 return cnt;
597}
598
599/**
600 * saveable_highmem_page - Determine whether a highmem page should be
601 * included in the suspend image.
602 *
603 * We should save the page if it isn't Nosave or NosaveFree, or Reserved,
604 * and it isn't a part of a free chunk of pages.
605 */
606
607static struct page *saveable_highmem_page(unsigned long pfn)
608{
609 struct page *page;
610
611 if (!pfn_valid(pfn))
612 return NULL;
613
614 page = pfn_to_page(pfn);
615
616 BUG_ON(!PageHighMem(page));
617
618 if (PageNosave(page) || PageReserved(page) || PageNosaveFree(page))
619 return NULL;
620
621 return page;
673} 622}
674 623
675/** 624/**
625 * count_highmem_pages - compute the total number of saveable highmem
626 * pages.
627 */
628
629unsigned int count_highmem_pages(void)
630{
631 struct zone *zone;
632 unsigned int n = 0;
633
634 for_each_zone(zone) {
635 unsigned long pfn, max_zone_pfn;
636
637 if (!is_highmem(zone))
638 continue;
639
640 mark_free_pages(zone);
641 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
642 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
643 if (saveable_highmem_page(pfn))
644 n++;
645 }
646 return n;
647}
648#else
649static inline void *saveable_highmem_page(unsigned long pfn) { return NULL; }
650static inline unsigned int count_highmem_pages(void) { return 0; }
651#endif /* CONFIG_HIGHMEM */
652
653/**
676 * pfn_is_nosave - check if given pfn is in the 'nosave' section 654 * pfn_is_nosave - check if given pfn is in the 'nosave' section
677 */ 655 */
678 656
@@ -684,12 +662,12 @@ static inline int pfn_is_nosave(unsigned long pfn)
684} 662}
685 663
686/** 664/**
687 * saveable - Determine whether a page should be cloned or not. 665 * saveable - Determine whether a non-highmem page should be included in
688 * @pfn: The page 666 * the suspend image.
689 * 667 *
690 * We save a page if it isn't Nosave, and is not in the range of pages 668 * We should save the page if it isn't Nosave, and is not in the range
691 * statically defined as 'unsaveable', and it 669 * of pages statically defined as 'unsaveable', and it isn't a part of
692 * isn't a part of a free chunk of pages. 670 * a free chunk of pages.
693 */ 671 */
694 672
695static struct page *saveable_page(unsigned long pfn) 673static struct page *saveable_page(unsigned long pfn)
@@ -701,76 +679,130 @@ static struct page *saveable_page(unsigned long pfn)
701 679
702 page = pfn_to_page(pfn); 680 page = pfn_to_page(pfn);
703 681
704 if (PageNosave(page)) 682 BUG_ON(PageHighMem(page));
683
684 if (PageNosave(page) || PageNosaveFree(page))
705 return NULL; 685 return NULL;
686
706 if (PageReserved(page) && pfn_is_nosave(pfn)) 687 if (PageReserved(page) && pfn_is_nosave(pfn))
707 return NULL; 688 return NULL;
708 if (PageNosaveFree(page))
709 return NULL;
710 689
711 return page; 690 return page;
712} 691}
713 692
693/**
694 * count_data_pages - compute the total number of saveable non-highmem
695 * pages.
696 */
697
714unsigned int count_data_pages(void) 698unsigned int count_data_pages(void)
715{ 699{
716 struct zone *zone; 700 struct zone *zone;
717 unsigned long pfn, max_zone_pfn; 701 unsigned long pfn, max_zone_pfn;
718 unsigned int n = 0; 702 unsigned int n = 0;
719 703
720 for_each_zone (zone) { 704 for_each_zone(zone) {
721 if (is_highmem(zone)) 705 if (is_highmem(zone))
722 continue; 706 continue;
707
723 mark_free_pages(zone); 708 mark_free_pages(zone);
724 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages; 709 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
725 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) 710 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
726 n += !!saveable_page(pfn); 711 if(saveable_page(pfn))
712 n++;
727 } 713 }
728 return n; 714 return n;
729} 715}
730 716
731static inline void copy_data_page(long *dst, long *src) 717/* This is needed, because copy_page and memcpy are not usable for copying
718 * task structs.
719 */
720static inline void do_copy_page(long *dst, long *src)
732{ 721{
733 int n; 722 int n;
734 723
735 /* copy_page and memcpy are not usable for copying task structs. */
736 for (n = PAGE_SIZE / sizeof(long); n; n--) 724 for (n = PAGE_SIZE / sizeof(long); n; n--)
737 *dst++ = *src++; 725 *dst++ = *src++;
738} 726}
739 727
728#ifdef CONFIG_HIGHMEM
729static inline struct page *
730page_is_saveable(struct zone *zone, unsigned long pfn)
731{
732 return is_highmem(zone) ?
733 saveable_highmem_page(pfn) : saveable_page(pfn);
734}
735
736static inline void
737copy_data_page(unsigned long dst_pfn, unsigned long src_pfn)
738{
739 struct page *s_page, *d_page;
740 void *src, *dst;
741
742 s_page = pfn_to_page(src_pfn);
743 d_page = pfn_to_page(dst_pfn);
744 if (PageHighMem(s_page)) {
745 src = kmap_atomic(s_page, KM_USER0);
746 dst = kmap_atomic(d_page, KM_USER1);
747 do_copy_page(dst, src);
748 kunmap_atomic(src, KM_USER0);
749 kunmap_atomic(dst, KM_USER1);
750 } else {
751 src = page_address(s_page);
752 if (PageHighMem(d_page)) {
753 /* Page pointed to by src may contain some kernel
754 * data modified by kmap_atomic()
755 */
756 do_copy_page(buffer, src);
757 dst = kmap_atomic(pfn_to_page(dst_pfn), KM_USER0);
758 memcpy(dst, buffer, PAGE_SIZE);
759 kunmap_atomic(dst, KM_USER0);
760 } else {
761 dst = page_address(d_page);
762 do_copy_page(dst, src);
763 }
764 }
765}
766#else
767#define page_is_saveable(zone, pfn) saveable_page(pfn)
768
769static inline void
770copy_data_page(unsigned long dst_pfn, unsigned long src_pfn)
771{
772 do_copy_page(page_address(pfn_to_page(dst_pfn)),
773 page_address(pfn_to_page(src_pfn)));
774}
775#endif /* CONFIG_HIGHMEM */
776
740static void 777static void
741copy_data_pages(struct memory_bitmap *copy_bm, struct memory_bitmap *orig_bm) 778copy_data_pages(struct memory_bitmap *copy_bm, struct memory_bitmap *orig_bm)
742{ 779{
743 struct zone *zone; 780 struct zone *zone;
744 unsigned long pfn; 781 unsigned long pfn;
745 782
746 for_each_zone (zone) { 783 for_each_zone(zone) {
747 unsigned long max_zone_pfn; 784 unsigned long max_zone_pfn;
748 785
749 if (is_highmem(zone))
750 continue;
751
752 mark_free_pages(zone); 786 mark_free_pages(zone);
753 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages; 787 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
754 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) 788 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
755 if (saveable_page(pfn)) 789 if (page_is_saveable(zone, pfn))
756 memory_bm_set_bit(orig_bm, pfn); 790 memory_bm_set_bit(orig_bm, pfn);
757 } 791 }
758 memory_bm_position_reset(orig_bm); 792 memory_bm_position_reset(orig_bm);
759 memory_bm_position_reset(copy_bm); 793 memory_bm_position_reset(copy_bm);
760 do { 794 do {
761 pfn = memory_bm_next_pfn(orig_bm); 795 pfn = memory_bm_next_pfn(orig_bm);
762 if (likely(pfn != BM_END_OF_MAP)) { 796 if (likely(pfn != BM_END_OF_MAP))
763 struct page *page; 797 copy_data_page(memory_bm_next_pfn(copy_bm), pfn);
764 void *src;
765
766 page = pfn_to_page(pfn);
767 src = page_address(page);
768 page = pfn_to_page(memory_bm_next_pfn(copy_bm));
769 copy_data_page(page_address(page), src);
770 }
771 } while (pfn != BM_END_OF_MAP); 798 } while (pfn != BM_END_OF_MAP);
772} 799}
773 800
801/* Total number of image pages */
802static unsigned int nr_copy_pages;
803/* Number of pages needed for saving the original pfns of the image pages */
804static unsigned int nr_meta_pages;
805
774/** 806/**
775 * swsusp_free - free pages allocated for the suspend. 807 * swsusp_free - free pages allocated for the suspend.
776 * 808 *
@@ -792,7 +824,7 @@ void swsusp_free(void)
792 if (PageNosave(page) && PageNosaveFree(page)) { 824 if (PageNosave(page) && PageNosaveFree(page)) {
793 ClearPageNosave(page); 825 ClearPageNosave(page);
794 ClearPageNosaveFree(page); 826 ClearPageNosaveFree(page);
795 free_page((long) page_address(page)); 827 __free_page(page);
796 } 828 }
797 } 829 }
798 } 830 }
@@ -802,34 +834,108 @@ void swsusp_free(void)
802 buffer = NULL; 834 buffer = NULL;
803} 835}
804 836
837#ifdef CONFIG_HIGHMEM
838/**
839 * count_pages_for_highmem - compute the number of non-highmem pages
840 * that will be necessary for creating copies of highmem pages.
841 */
842
843static unsigned int count_pages_for_highmem(unsigned int nr_highmem)
844{
845 unsigned int free_highmem = count_free_highmem_pages();
846
847 if (free_highmem >= nr_highmem)
848 nr_highmem = 0;
849 else
850 nr_highmem -= free_highmem;
851
852 return nr_highmem;
853}
854#else
855static unsigned int
856count_pages_for_highmem(unsigned int nr_highmem) { return 0; }
857#endif /* CONFIG_HIGHMEM */
805 858
806/** 859/**
807 * enough_free_mem - Make sure we enough free memory to snapshot. 860 * enough_free_mem - Make sure we have enough free memory for the
808 * 861 * snapshot image.
809 * Returns TRUE or FALSE after checking the number of available
810 * free pages.
811 */ 862 */
812 863
813static int enough_free_mem(unsigned int nr_pages) 864static int enough_free_mem(unsigned int nr_pages, unsigned int nr_highmem)
814{ 865{
815 struct zone *zone; 866 struct zone *zone;
816 unsigned int free = 0, meta = 0; 867 unsigned int free = 0, meta = 0;
817 868
818 for_each_zone (zone) 869 for_each_zone(zone) {
819 if (!is_highmem(zone)) { 870 meta += snapshot_additional_pages(zone);
871 if (!is_highmem(zone))
820 free += zone->free_pages; 872 free += zone->free_pages;
821 meta += snapshot_additional_pages(zone); 873 }
822 }
823 874
824 pr_debug("swsusp: pages needed: %u + %u + %u, available pages: %u\n", 875 nr_pages += count_pages_for_highmem(nr_highmem);
876 pr_debug("swsusp: Normal pages needed: %u + %u + %u, available pages: %u\n",
825 nr_pages, PAGES_FOR_IO, meta, free); 877 nr_pages, PAGES_FOR_IO, meta, free);
826 878
827 return free > nr_pages + PAGES_FOR_IO + meta; 879 return free > nr_pages + PAGES_FOR_IO + meta;
828} 880}
829 881
882#ifdef CONFIG_HIGHMEM
883/**
884 * get_highmem_buffer - if there are some highmem pages in the suspend
885 * image, we may need the buffer to copy them and/or load their data.
886 */
887
888static inline int get_highmem_buffer(int safe_needed)
889{
890 buffer = get_image_page(GFP_ATOMIC | __GFP_COLD, safe_needed);
891 return buffer ? 0 : -ENOMEM;
892}
893
894/**
895 * alloc_highmem_image_pages - allocate some highmem pages for the image.
896 * Try to allocate as many pages as needed, but if the number of free
897 * highmem pages is lesser than that, allocate them all.
898 */
899
900static inline unsigned int
901alloc_highmem_image_pages(struct memory_bitmap *bm, unsigned int nr_highmem)
902{
903 unsigned int to_alloc = count_free_highmem_pages();
904
905 if (to_alloc > nr_highmem)
906 to_alloc = nr_highmem;
907
908 nr_highmem -= to_alloc;
909 while (to_alloc-- > 0) {
910 struct page *page;
911
912 page = alloc_image_page(__GFP_HIGHMEM);
913 memory_bm_set_bit(bm, page_to_pfn(page));
914 }
915 return nr_highmem;
916}
917#else
918static inline int get_highmem_buffer(int safe_needed) { return 0; }
919
920static inline unsigned int
921alloc_highmem_image_pages(struct memory_bitmap *bm, unsigned int n) { return 0; }
922#endif /* CONFIG_HIGHMEM */
923
924/**
925 * swsusp_alloc - allocate memory for the suspend image
926 *
927 * We first try to allocate as many highmem pages as there are
928 * saveable highmem pages in the system. If that fails, we allocate
929 * non-highmem pages for the copies of the remaining highmem ones.
930 *
931 * In this approach it is likely that the copies of highmem pages will
932 * also be located in the high memory, because of the way in which
933 * copy_data_pages() works.
934 */
935
830static int 936static int
831swsusp_alloc(struct memory_bitmap *orig_bm, struct memory_bitmap *copy_bm, 937swsusp_alloc(struct memory_bitmap *orig_bm, struct memory_bitmap *copy_bm,
832 unsigned int nr_pages) 938 unsigned int nr_pages, unsigned int nr_highmem)
833{ 939{
834 int error; 940 int error;
835 941
@@ -841,46 +947,61 @@ swsusp_alloc(struct memory_bitmap *orig_bm, struct memory_bitmap *copy_bm,
841 if (error) 947 if (error)
842 goto Free; 948 goto Free;
843 949
950 if (nr_highmem > 0) {
951 error = get_highmem_buffer(PG_ANY);
952 if (error)
953 goto Free;
954
955 nr_pages += alloc_highmem_image_pages(copy_bm, nr_highmem);
956 }
844 while (nr_pages-- > 0) { 957 while (nr_pages-- > 0) {
845 struct page *page = alloc_page(GFP_ATOMIC | __GFP_COLD); 958 struct page *page = alloc_image_page(GFP_ATOMIC | __GFP_COLD);
959
846 if (!page) 960 if (!page)
847 goto Free; 961 goto Free;
848 962
849 SetPageNosave(page);
850 SetPageNosaveFree(page);
851 memory_bm_set_bit(copy_bm, page_to_pfn(page)); 963 memory_bm_set_bit(copy_bm, page_to_pfn(page));
852 } 964 }
853 return 0; 965 return 0;
854 966
855Free: 967 Free:
856 swsusp_free(); 968 swsusp_free();
857 return -ENOMEM; 969 return -ENOMEM;
858} 970}
859 971
860/* Memory bitmap used for marking saveable pages */ 972/* Memory bitmap used for marking saveable pages (during suspend) or the
973 * suspend image pages (during resume)
974 */
861static struct memory_bitmap orig_bm; 975static struct memory_bitmap orig_bm;
862/* Memory bitmap used for marking allocated pages that will contain the copies 976/* Memory bitmap used on suspend for marking allocated pages that will contain
863 * of saveable pages 977 * the copies of saveable pages. During resume it is initially used for
978 * marking the suspend image pages, but then its set bits are duplicated in
979 * @orig_bm and it is released. Next, on systems with high memory, it may be
980 * used for marking "safe" highmem pages, but it has to be reinitialized for
981 * this purpose.
864 */ 982 */
865static struct memory_bitmap copy_bm; 983static struct memory_bitmap copy_bm;
866 984
867asmlinkage int swsusp_save(void) 985asmlinkage int swsusp_save(void)
868{ 986{
869 unsigned int nr_pages; 987 unsigned int nr_pages, nr_highmem;
870 988
871 pr_debug("swsusp: critical section: \n"); 989 printk("swsusp: critical section: \n");
872 990
873 drain_local_pages(); 991 drain_local_pages();
874 nr_pages = count_data_pages(); 992 nr_pages = count_data_pages();
875 printk("swsusp: Need to copy %u pages\n", nr_pages); 993 nr_highmem = count_highmem_pages();
994 printk("swsusp: Need to copy %u pages\n", nr_pages + nr_highmem);
876 995
877 if (!enough_free_mem(nr_pages)) { 996 if (!enough_free_mem(nr_pages, nr_highmem)) {
878 printk(KERN_ERR "swsusp: Not enough free memory\n"); 997 printk(KERN_ERR "swsusp: Not enough free memory\n");
879 return -ENOMEM; 998 return -ENOMEM;
880 } 999 }
881 1000
882 if (swsusp_alloc(&orig_bm, &copy_bm, nr_pages)) 1001 if (swsusp_alloc(&orig_bm, &copy_bm, nr_pages, nr_highmem)) {
1002 printk(KERN_ERR "swsusp: Memory allocation failed\n");
883 return -ENOMEM; 1003 return -ENOMEM;
1004 }
884 1005
885 /* During allocating of suspend pagedir, new cold pages may appear. 1006 /* During allocating of suspend pagedir, new cold pages may appear.
886 * Kill them. 1007 * Kill them.
@@ -894,10 +1015,12 @@ asmlinkage int swsusp_save(void)
894 * touch swap space! Except we must write out our image of course. 1015 * touch swap space! Except we must write out our image of course.
895 */ 1016 */
896 1017
1018 nr_pages += nr_highmem;
897 nr_copy_pages = nr_pages; 1019 nr_copy_pages = nr_pages;
898 nr_meta_pages = (nr_pages * sizeof(long) + PAGE_SIZE - 1) >> PAGE_SHIFT; 1020 nr_meta_pages = DIV_ROUND_UP(nr_pages * sizeof(long), PAGE_SIZE);
899 1021
900 printk("swsusp: critical section/: done (%d pages copied)\n", nr_pages); 1022 printk("swsusp: critical section/: done (%d pages copied)\n", nr_pages);
1023
901 return 0; 1024 return 0;
902} 1025}
903 1026
@@ -960,7 +1083,7 @@ int snapshot_read_next(struct snapshot_handle *handle, size_t count)
960 1083
961 if (!buffer) { 1084 if (!buffer) {
962 /* This makes the buffer be freed by swsusp_free() */ 1085 /* This makes the buffer be freed by swsusp_free() */
963 buffer = alloc_image_page(GFP_ATOMIC, PG_ANY); 1086 buffer = get_image_page(GFP_ATOMIC, PG_ANY);
964 if (!buffer) 1087 if (!buffer)
965 return -ENOMEM; 1088 return -ENOMEM;
966 } 1089 }
@@ -975,9 +1098,23 @@ int snapshot_read_next(struct snapshot_handle *handle, size_t count)
975 memset(buffer, 0, PAGE_SIZE); 1098 memset(buffer, 0, PAGE_SIZE);
976 pack_pfns(buffer, &orig_bm); 1099 pack_pfns(buffer, &orig_bm);
977 } else { 1100 } else {
978 unsigned long pfn = memory_bm_next_pfn(&copy_bm); 1101 struct page *page;
979 1102
980 handle->buffer = page_address(pfn_to_page(pfn)); 1103 page = pfn_to_page(memory_bm_next_pfn(&copy_bm));
1104 if (PageHighMem(page)) {
1105 /* Highmem pages are copied to the buffer,
1106 * because we can't return with a kmapped
1107 * highmem page (we may not be called again).
1108 */
1109 void *kaddr;
1110
1111 kaddr = kmap_atomic(page, KM_USER0);
1112 memcpy(buffer, kaddr, PAGE_SIZE);
1113 kunmap_atomic(kaddr, KM_USER0);
1114 handle->buffer = buffer;
1115 } else {
1116 handle->buffer = page_address(page);
1117 }
981 } 1118 }
982 handle->prev = handle->cur; 1119 handle->prev = handle->cur;
983 } 1120 }
@@ -1005,7 +1142,7 @@ static int mark_unsafe_pages(struct memory_bitmap *bm)
1005 unsigned long pfn, max_zone_pfn; 1142 unsigned long pfn, max_zone_pfn;
1006 1143
1007 /* Clear page flags */ 1144 /* Clear page flags */
1008 for_each_zone (zone) { 1145 for_each_zone(zone) {
1009 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages; 1146 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
1010 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) 1147 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
1011 if (pfn_valid(pfn)) 1148 if (pfn_valid(pfn))
@@ -1101,6 +1238,218 @@ unpack_orig_pfns(unsigned long *buf, struct memory_bitmap *bm)
1101 } 1238 }
1102} 1239}
1103 1240
1241/* List of "safe" pages that may be used to store data loaded from the suspend
1242 * image
1243 */
1244static struct linked_page *safe_pages_list;
1245
1246#ifdef CONFIG_HIGHMEM
1247/* struct highmem_pbe is used for creating the list of highmem pages that
1248 * should be restored atomically during the resume from disk, because the page
1249 * frames they have occupied before the suspend are in use.
1250 */
1251struct highmem_pbe {
1252 struct page *copy_page; /* data is here now */
1253 struct page *orig_page; /* data was here before the suspend */
1254 struct highmem_pbe *next;
1255};
1256
1257/* List of highmem PBEs needed for restoring the highmem pages that were
1258 * allocated before the suspend and included in the suspend image, but have
1259 * also been allocated by the "resume" kernel, so their contents cannot be
1260 * written directly to their "original" page frames.
1261 */
1262static struct highmem_pbe *highmem_pblist;
1263
1264/**
1265 * count_highmem_image_pages - compute the number of highmem pages in the
1266 * suspend image. The bits in the memory bitmap @bm that correspond to the
1267 * image pages are assumed to be set.
1268 */
1269
1270static unsigned int count_highmem_image_pages(struct memory_bitmap *bm)
1271{
1272 unsigned long pfn;
1273 unsigned int cnt = 0;
1274
1275 memory_bm_position_reset(bm);
1276 pfn = memory_bm_next_pfn(bm);
1277 while (pfn != BM_END_OF_MAP) {
1278 if (PageHighMem(pfn_to_page(pfn)))
1279 cnt++;
1280
1281 pfn = memory_bm_next_pfn(bm);
1282 }
1283 return cnt;
1284}
1285
1286/**
1287 * prepare_highmem_image - try to allocate as many highmem pages as
1288 * there are highmem image pages (@nr_highmem_p points to the variable
1289 * containing the number of highmem image pages). The pages that are
1290 * "safe" (ie. will not be overwritten when the suspend image is
1291 * restored) have the corresponding bits set in @bm (it must be
1292 * unitialized).
1293 *
1294 * NOTE: This function should not be called if there are no highmem
1295 * image pages.
1296 */
1297
1298static unsigned int safe_highmem_pages;
1299
1300static struct memory_bitmap *safe_highmem_bm;
1301
1302static int
1303prepare_highmem_image(struct memory_bitmap *bm, unsigned int *nr_highmem_p)
1304{
1305 unsigned int to_alloc;
1306
1307 if (memory_bm_create(bm, GFP_ATOMIC, PG_SAFE))
1308 return -ENOMEM;
1309
1310 if (get_highmem_buffer(PG_SAFE))
1311 return -ENOMEM;
1312
1313 to_alloc = count_free_highmem_pages();
1314 if (to_alloc > *nr_highmem_p)
1315 to_alloc = *nr_highmem_p;
1316 else
1317 *nr_highmem_p = to_alloc;
1318
1319 safe_highmem_pages = 0;
1320 while (to_alloc-- > 0) {
1321 struct page *page;
1322
1323 page = alloc_page(__GFP_HIGHMEM);
1324 if (!PageNosaveFree(page)) {
1325 /* The page is "safe", set its bit the bitmap */
1326 memory_bm_set_bit(bm, page_to_pfn(page));
1327 safe_highmem_pages++;
1328 }
1329 /* Mark the page as allocated */
1330 SetPageNosave(page);
1331 SetPageNosaveFree(page);
1332 }
1333 memory_bm_position_reset(bm);
1334 safe_highmem_bm = bm;
1335 return 0;
1336}
1337
1338/**
1339 * get_highmem_page_buffer - for given highmem image page find the buffer
1340 * that suspend_write_next() should set for its caller to write to.
1341 *
1342 * If the page is to be saved to its "original" page frame or a copy of
1343 * the page is to be made in the highmem, @buffer is returned. Otherwise,
1344 * the copy of the page is to be made in normal memory, so the address of
1345 * the copy is returned.
1346 *
1347 * If @buffer is returned, the caller of suspend_write_next() will write
1348 * the page's contents to @buffer, so they will have to be copied to the
1349 * right location on the next call to suspend_write_next() and it is done
1350 * with the help of copy_last_highmem_page(). For this purpose, if
1351 * @buffer is returned, @last_highmem page is set to the page to which
1352 * the data will have to be copied from @buffer.
1353 */
1354
1355static struct page *last_highmem_page;
1356
1357static void *
1358get_highmem_page_buffer(struct page *page, struct chain_allocator *ca)
1359{
1360 struct highmem_pbe *pbe;
1361 void *kaddr;
1362
1363 if (PageNosave(page) && PageNosaveFree(page)) {
1364 /* We have allocated the "original" page frame and we can
1365 * use it directly to store the loaded page.
1366 */
1367 last_highmem_page = page;
1368 return buffer;
1369 }
1370 /* The "original" page frame has not been allocated and we have to
1371 * use a "safe" page frame to store the loaded page.
1372 */
1373 pbe = chain_alloc(ca, sizeof(struct highmem_pbe));
1374 if (!pbe) {
1375 swsusp_free();
1376 return NULL;
1377 }
1378 pbe->orig_page = page;
1379 if (safe_highmem_pages > 0) {
1380 struct page *tmp;
1381
1382 /* Copy of the page will be stored in high memory */
1383 kaddr = buffer;
1384 tmp = pfn_to_page(memory_bm_next_pfn(safe_highmem_bm));
1385 safe_highmem_pages--;
1386 last_highmem_page = tmp;
1387 pbe->copy_page = tmp;
1388 } else {
1389 /* Copy of the page will be stored in normal memory */
1390 kaddr = safe_pages_list;
1391 safe_pages_list = safe_pages_list->next;
1392 pbe->copy_page = virt_to_page(kaddr);
1393 }
1394 pbe->next = highmem_pblist;
1395 highmem_pblist = pbe;
1396 return kaddr;
1397}
1398
1399/**
1400 * copy_last_highmem_page - copy the contents of a highmem image from
1401 * @buffer, where the caller of snapshot_write_next() has place them,
1402 * to the right location represented by @last_highmem_page .
1403 */
1404
1405static void copy_last_highmem_page(void)
1406{
1407 if (last_highmem_page) {
1408 void *dst;
1409
1410 dst = kmap_atomic(last_highmem_page, KM_USER0);
1411 memcpy(dst, buffer, PAGE_SIZE);
1412 kunmap_atomic(dst, KM_USER0);
1413 last_highmem_page = NULL;
1414 }
1415}
1416
1417static inline int last_highmem_page_copied(void)
1418{
1419 return !last_highmem_page;
1420}
1421
1422static inline void free_highmem_data(void)
1423{
1424 if (safe_highmem_bm)
1425 memory_bm_free(safe_highmem_bm, PG_UNSAFE_CLEAR);
1426
1427 if (buffer)
1428 free_image_page(buffer, PG_UNSAFE_CLEAR);
1429}
1430#else
1431static inline int get_safe_write_buffer(void) { return 0; }
1432
1433static unsigned int
1434count_highmem_image_pages(struct memory_bitmap *bm) { return 0; }
1435
1436static inline int
1437prepare_highmem_image(struct memory_bitmap *bm, unsigned int *nr_highmem_p)
1438{
1439 return 0;
1440}
1441
1442static inline void *
1443get_highmem_page_buffer(struct page *page, struct chain_allocator *ca)
1444{
1445 return NULL;
1446}
1447
1448static inline void copy_last_highmem_page(void) {}
1449static inline int last_highmem_page_copied(void) { return 1; }
1450static inline void free_highmem_data(void) {}
1451#endif /* CONFIG_HIGHMEM */
1452
1104/** 1453/**
1105 * prepare_image - use the memory bitmap @bm to mark the pages that will 1454 * prepare_image - use the memory bitmap @bm to mark the pages that will
1106 * be overwritten in the process of restoring the system memory state 1455 * be overwritten in the process of restoring the system memory state
@@ -1110,20 +1459,25 @@ unpack_orig_pfns(unsigned long *buf, struct memory_bitmap *bm)
1110 * The idea is to allocate a new memory bitmap first and then allocate 1459 * The idea is to allocate a new memory bitmap first and then allocate
1111 * as many pages as needed for the image data, but not to assign these 1460 * as many pages as needed for the image data, but not to assign these
1112 * pages to specific tasks initially. Instead, we just mark them as 1461 * pages to specific tasks initially. Instead, we just mark them as
1113 * allocated and create a list of "safe" pages that will be used later. 1462 * allocated and create a lists of "safe" pages that will be used
1463 * later. On systems with high memory a list of "safe" highmem pages is
1464 * also created.
1114 */ 1465 */
1115 1466
1116#define PBES_PER_LINKED_PAGE (LINKED_PAGE_DATA_SIZE / sizeof(struct pbe)) 1467#define PBES_PER_LINKED_PAGE (LINKED_PAGE_DATA_SIZE / sizeof(struct pbe))
1117 1468
1118static struct linked_page *safe_pages_list;
1119
1120static int 1469static int
1121prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm) 1470prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)
1122{ 1471{
1123 unsigned int nr_pages; 1472 unsigned int nr_pages, nr_highmem;
1124 struct linked_page *sp_list, *lp; 1473 struct linked_page *sp_list, *lp;
1125 int error; 1474 int error;
1126 1475
1476 /* If there is no highmem, the buffer will not be necessary */
1477 free_image_page(buffer, PG_UNSAFE_CLEAR);
1478 buffer = NULL;
1479
1480 nr_highmem = count_highmem_image_pages(bm);
1127 error = mark_unsafe_pages(bm); 1481 error = mark_unsafe_pages(bm);
1128 if (error) 1482 if (error)
1129 goto Free; 1483 goto Free;
@@ -1134,6 +1488,11 @@ prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)
1134 1488
1135 duplicate_memory_bitmap(new_bm, bm); 1489 duplicate_memory_bitmap(new_bm, bm);
1136 memory_bm_free(bm, PG_UNSAFE_KEEP); 1490 memory_bm_free(bm, PG_UNSAFE_KEEP);
1491 if (nr_highmem > 0) {
1492 error = prepare_highmem_image(bm, &nr_highmem);
1493 if (error)
1494 goto Free;
1495 }
1137 /* Reserve some safe pages for potential later use. 1496 /* Reserve some safe pages for potential later use.
1138 * 1497 *
1139 * NOTE: This way we make sure there will be enough safe pages for the 1498 * NOTE: This way we make sure there will be enough safe pages for the
@@ -1142,10 +1501,10 @@ prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)
1142 */ 1501 */
1143 sp_list = NULL; 1502 sp_list = NULL;
1144 /* nr_copy_pages cannot be lesser than allocated_unsafe_pages */ 1503 /* nr_copy_pages cannot be lesser than allocated_unsafe_pages */
1145 nr_pages = nr_copy_pages - allocated_unsafe_pages; 1504 nr_pages = nr_copy_pages - nr_highmem - allocated_unsafe_pages;
1146 nr_pages = DIV_ROUND_UP(nr_pages, PBES_PER_LINKED_PAGE); 1505 nr_pages = DIV_ROUND_UP(nr_pages, PBES_PER_LINKED_PAGE);
1147 while (nr_pages > 0) { 1506 while (nr_pages > 0) {
1148 lp = alloc_image_page(GFP_ATOMIC, PG_SAFE); 1507 lp = get_image_page(GFP_ATOMIC, PG_SAFE);
1149 if (!lp) { 1508 if (!lp) {
1150 error = -ENOMEM; 1509 error = -ENOMEM;
1151 goto Free; 1510 goto Free;
@@ -1156,7 +1515,7 @@ prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)
1156 } 1515 }
1157 /* Preallocate memory for the image */ 1516 /* Preallocate memory for the image */
1158 safe_pages_list = NULL; 1517 safe_pages_list = NULL;
1159 nr_pages = nr_copy_pages - allocated_unsafe_pages; 1518 nr_pages = nr_copy_pages - nr_highmem - allocated_unsafe_pages;
1160 while (nr_pages > 0) { 1519 while (nr_pages > 0) {
1161 lp = (struct linked_page *)get_zeroed_page(GFP_ATOMIC); 1520 lp = (struct linked_page *)get_zeroed_page(GFP_ATOMIC);
1162 if (!lp) { 1521 if (!lp) {
@@ -1181,7 +1540,7 @@ prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)
1181 } 1540 }
1182 return 0; 1541 return 0;
1183 1542
1184Free: 1543 Free:
1185 swsusp_free(); 1544 swsusp_free();
1186 return error; 1545 return error;
1187} 1546}
@@ -1196,6 +1555,9 @@ static void *get_buffer(struct memory_bitmap *bm, struct chain_allocator *ca)
1196 struct pbe *pbe; 1555 struct pbe *pbe;
1197 struct page *page = pfn_to_page(memory_bm_next_pfn(bm)); 1556 struct page *page = pfn_to_page(memory_bm_next_pfn(bm));
1198 1557
1558 if (PageHighMem(page))
1559 return get_highmem_page_buffer(page, ca);
1560
1199 if (PageNosave(page) && PageNosaveFree(page)) 1561 if (PageNosave(page) && PageNosaveFree(page))
1200 /* We have allocated the "original" page frame and we can 1562 /* We have allocated the "original" page frame and we can
1201 * use it directly to store the loaded page. 1563 * use it directly to store the loaded page.
@@ -1210,12 +1572,12 @@ static void *get_buffer(struct memory_bitmap *bm, struct chain_allocator *ca)
1210 swsusp_free(); 1572 swsusp_free();
1211 return NULL; 1573 return NULL;
1212 } 1574 }
1213 pbe->orig_address = (unsigned long)page_address(page); 1575 pbe->orig_address = page_address(page);
1214 pbe->address = (unsigned long)safe_pages_list; 1576 pbe->address = safe_pages_list;
1215 safe_pages_list = safe_pages_list->next; 1577 safe_pages_list = safe_pages_list->next;
1216 pbe->next = restore_pblist; 1578 pbe->next = restore_pblist;
1217 restore_pblist = pbe; 1579 restore_pblist = pbe;
1218 return (void *)pbe->address; 1580 return pbe->address;
1219} 1581}
1220 1582
1221/** 1583/**
@@ -1249,14 +1611,16 @@ int snapshot_write_next(struct snapshot_handle *handle, size_t count)
1249 if (handle->prev && handle->cur > nr_meta_pages + nr_copy_pages) 1611 if (handle->prev && handle->cur > nr_meta_pages + nr_copy_pages)
1250 return 0; 1612 return 0;
1251 1613
1252 if (!buffer) { 1614 if (handle->offset == 0) {
1253 /* This makes the buffer be freed by swsusp_free() */ 1615 if (!buffer)
1254 buffer = alloc_image_page(GFP_ATOMIC, PG_ANY); 1616 /* This makes the buffer be freed by swsusp_free() */
1617 buffer = get_image_page(GFP_ATOMIC, PG_ANY);
1618
1255 if (!buffer) 1619 if (!buffer)
1256 return -ENOMEM; 1620 return -ENOMEM;
1257 } 1621
1258 if (!handle->offset)
1259 handle->buffer = buffer; 1622 handle->buffer = buffer;
1623 }
1260 handle->sync_read = 1; 1624 handle->sync_read = 1;
1261 if (handle->prev < handle->cur) { 1625 if (handle->prev < handle->cur) {
1262 if (handle->prev == 0) { 1626 if (handle->prev == 0) {
@@ -1284,8 +1648,10 @@ int snapshot_write_next(struct snapshot_handle *handle, size_t count)
1284 return -ENOMEM; 1648 return -ENOMEM;
1285 } 1649 }
1286 } else { 1650 } else {
1651 copy_last_highmem_page();
1287 handle->buffer = get_buffer(&orig_bm, &ca); 1652 handle->buffer = get_buffer(&orig_bm, &ca);
1288 handle->sync_read = 0; 1653 if (handle->buffer != buffer)
1654 handle->sync_read = 0;
1289 } 1655 }
1290 handle->prev = handle->cur; 1656 handle->prev = handle->cur;
1291 } 1657 }
@@ -1301,15 +1667,73 @@ int snapshot_write_next(struct snapshot_handle *handle, size_t count)
1301 return count; 1667 return count;
1302} 1668}
1303 1669
1670/**
1671 * snapshot_write_finalize - must be called after the last call to
1672 * snapshot_write_next() in case the last page in the image happens
1673 * to be a highmem page and its contents should be stored in the
1674 * highmem. Additionally, it releases the memory that will not be
1675 * used any more.
1676 */
1677
1678void snapshot_write_finalize(struct snapshot_handle *handle)
1679{
1680 copy_last_highmem_page();
1681 /* Free only if we have loaded the image entirely */
1682 if (handle->prev && handle->cur > nr_meta_pages + nr_copy_pages) {
1683 memory_bm_free(&orig_bm, PG_UNSAFE_CLEAR);
1684 free_highmem_data();
1685 }
1686}
1687
1304int snapshot_image_loaded(struct snapshot_handle *handle) 1688int snapshot_image_loaded(struct snapshot_handle *handle)
1305{ 1689{
1306 return !(!nr_copy_pages || 1690 return !(!nr_copy_pages || !last_highmem_page_copied() ||
1307 handle->cur <= nr_meta_pages + nr_copy_pages); 1691 handle->cur <= nr_meta_pages + nr_copy_pages);
1308} 1692}
1309 1693
1310void snapshot_free_unused_memory(struct snapshot_handle *handle) 1694#ifdef CONFIG_HIGHMEM
1695/* Assumes that @buf is ready and points to a "safe" page */
1696static inline void
1697swap_two_pages_data(struct page *p1, struct page *p2, void *buf)
1311{ 1698{
1312 /* Free only if we have loaded the image entirely */ 1699 void *kaddr1, *kaddr2;
1313 if (handle->prev && handle->cur > nr_meta_pages + nr_copy_pages) 1700
1314 memory_bm_free(&orig_bm, PG_UNSAFE_CLEAR); 1701 kaddr1 = kmap_atomic(p1, KM_USER0);
1702 kaddr2 = kmap_atomic(p2, KM_USER1);
1703 memcpy(buf, kaddr1, PAGE_SIZE);
1704 memcpy(kaddr1, kaddr2, PAGE_SIZE);
1705 memcpy(kaddr2, buf, PAGE_SIZE);
1706 kunmap_atomic(kaddr1, KM_USER0);
1707 kunmap_atomic(kaddr2, KM_USER1);
1708}
1709
1710/**
1711 * restore_highmem - for each highmem page that was allocated before
1712 * the suspend and included in the suspend image, and also has been
1713 * allocated by the "resume" kernel swap its current (ie. "before
1714 * resume") contents with the previous (ie. "before suspend") one.
1715 *
1716 * If the resume eventually fails, we can call this function once
1717 * again and restore the "before resume" highmem state.
1718 */
1719
1720int restore_highmem(void)
1721{
1722 struct highmem_pbe *pbe = highmem_pblist;
1723 void *buf;
1724
1725 if (!pbe)
1726 return 0;
1727
1728 buf = get_image_page(GFP_ATOMIC, PG_SAFE);
1729 if (!buf)
1730 return -ENOMEM;
1731
1732 while (pbe) {
1733 swap_two_pages_data(pbe->copy_page, pbe->orig_page, buf);
1734 pbe = pbe->next;
1735 }
1736 free_image_page(buf, PG_UNSAFE_CLEAR);
1737 return 0;
1315} 1738}
1739#endif /* CONFIG_HIGHMEM */
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 1a3b0dd2c3fc..f133d4a6d817 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -34,34 +34,123 @@ extern char resume_file[];
34#define SWSUSP_SIG "S1SUSPEND" 34#define SWSUSP_SIG "S1SUSPEND"
35 35
36static struct swsusp_header { 36static struct swsusp_header {
37 char reserved[PAGE_SIZE - 20 - sizeof(swp_entry_t)]; 37 char reserved[PAGE_SIZE - 20 - sizeof(sector_t)];
38 swp_entry_t image; 38 sector_t image;
39 char orig_sig[10]; 39 char orig_sig[10];
40 char sig[10]; 40 char sig[10];
41} __attribute__((packed, aligned(PAGE_SIZE))) swsusp_header; 41} __attribute__((packed, aligned(PAGE_SIZE))) swsusp_header;
42 42
43/* 43/*
44 * Saving part... 44 * General things
45 */ 45 */
46 46
47static unsigned short root_swap = 0xffff; 47static unsigned short root_swap = 0xffff;
48static struct block_device *resume_bdev;
49
50/**
51 * submit - submit BIO request.
52 * @rw: READ or WRITE.
53 * @off physical offset of page.
54 * @page: page we're reading or writing.
55 * @bio_chain: list of pending biod (for async reading)
56 *
57 * Straight from the textbook - allocate and initialize the bio.
58 * If we're reading, make sure the page is marked as dirty.
59 * Then submit it and, if @bio_chain == NULL, wait.
60 */
61static int submit(int rw, pgoff_t page_off, struct page *page,
62 struct bio **bio_chain)
63{
64 struct bio *bio;
65
66 bio = bio_alloc(__GFP_WAIT | __GFP_HIGH, 1);
67 if (!bio)
68 return -ENOMEM;
69 bio->bi_sector = page_off * (PAGE_SIZE >> 9);
70 bio->bi_bdev = resume_bdev;
71 bio->bi_end_io = end_swap_bio_read;
72
73 if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
74 printk("swsusp: ERROR: adding page to bio at %ld\n", page_off);
75 bio_put(bio);
76 return -EFAULT;
77 }
78
79 lock_page(page);
80 bio_get(bio);
81
82 if (bio_chain == NULL) {
83 submit_bio(rw | (1 << BIO_RW_SYNC), bio);
84 wait_on_page_locked(page);
85 if (rw == READ)
86 bio_set_pages_dirty(bio);
87 bio_put(bio);
88 } else {
89 if (rw == READ)
90 get_page(page); /* These pages are freed later */
91 bio->bi_private = *bio_chain;
92 *bio_chain = bio;
93 submit_bio(rw | (1 << BIO_RW_SYNC), bio);
94 }
95 return 0;
96}
97
98static int bio_read_page(pgoff_t page_off, void *addr, struct bio **bio_chain)
99{
100 return submit(READ, page_off, virt_to_page(addr), bio_chain);
101}
102
103static int bio_write_page(pgoff_t page_off, void *addr, struct bio **bio_chain)
104{
105 return submit(WRITE, page_off, virt_to_page(addr), bio_chain);
106}
107
108static int wait_on_bio_chain(struct bio **bio_chain)
109{
110 struct bio *bio;
111 struct bio *next_bio;
112 int ret = 0;
113
114 if (bio_chain == NULL)
115 return 0;
116
117 bio = *bio_chain;
118 if (bio == NULL)
119 return 0;
120 while (bio) {
121 struct page *page;
122
123 next_bio = bio->bi_private;
124 page = bio->bi_io_vec[0].bv_page;
125 wait_on_page_locked(page);
126 if (!PageUptodate(page) || PageError(page))
127 ret = -EIO;
128 put_page(page);
129 bio_put(bio);
130 bio = next_bio;
131 }
132 *bio_chain = NULL;
133 return ret;
134}
135
136/*
137 * Saving part
138 */
48 139
49static int mark_swapfiles(swp_entry_t start) 140static int mark_swapfiles(sector_t start)
50{ 141{
51 int error; 142 int error;
52 143
53 rw_swap_page_sync(READ, swp_entry(root_swap, 0), 144 bio_read_page(swsusp_resume_block, &swsusp_header, NULL);
54 virt_to_page((unsigned long)&swsusp_header), NULL);
55 if (!memcmp("SWAP-SPACE",swsusp_header.sig, 10) || 145 if (!memcmp("SWAP-SPACE",swsusp_header.sig, 10) ||
56 !memcmp("SWAPSPACE2",swsusp_header.sig, 10)) { 146 !memcmp("SWAPSPACE2",swsusp_header.sig, 10)) {
57 memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10); 147 memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10);
58 memcpy(swsusp_header.sig,SWSUSP_SIG, 10); 148 memcpy(swsusp_header.sig,SWSUSP_SIG, 10);
59 swsusp_header.image = start; 149 swsusp_header.image = start;
60 error = rw_swap_page_sync(WRITE, swp_entry(root_swap, 0), 150 error = bio_write_page(swsusp_resume_block,
61 virt_to_page((unsigned long)&swsusp_header), 151 &swsusp_header, NULL);
62 NULL);
63 } else { 152 } else {
64 pr_debug("swsusp: Partition is not swap space.\n"); 153 printk(KERN_ERR "swsusp: Swap header not found!\n");
65 error = -ENODEV; 154 error = -ENODEV;
66 } 155 }
67 return error; 156 return error;
@@ -74,12 +163,21 @@ static int mark_swapfiles(swp_entry_t start)
74 163
75static int swsusp_swap_check(void) /* This is called before saving image */ 164static int swsusp_swap_check(void) /* This is called before saving image */
76{ 165{
77 int res = swap_type_of(swsusp_resume_device); 166 int res;
167
168 res = swap_type_of(swsusp_resume_device, swsusp_resume_block);
169 if (res < 0)
170 return res;
171
172 root_swap = res;
173 resume_bdev = open_by_devnum(swsusp_resume_device, FMODE_WRITE);
174 if (IS_ERR(resume_bdev))
175 return PTR_ERR(resume_bdev);
176
177 res = set_blocksize(resume_bdev, PAGE_SIZE);
178 if (res < 0)
179 blkdev_put(resume_bdev);
78 180
79 if (res >= 0) {
80 root_swap = res;
81 return 0;
82 }
83 return res; 181 return res;
84} 182}
85 183
@@ -90,36 +188,26 @@ static int swsusp_swap_check(void) /* This is called before saving image */
90 * @bio_chain: Link the next write BIO here 188 * @bio_chain: Link the next write BIO here
91 */ 189 */
92 190
93static int write_page(void *buf, unsigned long offset, struct bio **bio_chain) 191static int write_page(void *buf, sector_t offset, struct bio **bio_chain)
94{ 192{
95 swp_entry_t entry; 193 void *src;
96 int error = -ENOSPC; 194
97 195 if (!offset)
98 if (offset) { 196 return -ENOSPC;
99 struct page *page = virt_to_page(buf); 197
100 198 if (bio_chain) {
101 if (bio_chain) { 199 src = (void *)__get_free_page(__GFP_WAIT | __GFP_HIGH);
102 /* 200 if (src) {
103 * Whether or not we successfully allocated a copy page, 201 memcpy(src, buf, PAGE_SIZE);
104 * we take a ref on the page here. It gets undone in 202 } else {
105 * wait_on_bio_chain(). 203 WARN_ON_ONCE(1);
106 */ 204 bio_chain = NULL; /* Go synchronous */
107 struct page *page_copy; 205 src = buf;
108 page_copy = alloc_page(GFP_ATOMIC);
109 if (page_copy == NULL) {
110 WARN_ON_ONCE(1);
111 bio_chain = NULL; /* Go synchronous */
112 get_page(page);
113 } else {
114 memcpy(page_address(page_copy),
115 page_address(page), PAGE_SIZE);
116 page = page_copy;
117 }
118 } 206 }
119 entry = swp_entry(root_swap, offset); 207 } else {
120 error = rw_swap_page_sync(WRITE, entry, page, bio_chain); 208 src = buf;
121 } 209 }
122 return error; 210 return bio_write_page(offset, src, bio_chain);
123} 211}
124 212
125/* 213/*
@@ -137,11 +225,11 @@ static int write_page(void *buf, unsigned long offset, struct bio **bio_chain)
137 * at a time. 225 * at a time.
138 */ 226 */
139 227
140#define MAP_PAGE_ENTRIES (PAGE_SIZE / sizeof(long) - 1) 228#define MAP_PAGE_ENTRIES (PAGE_SIZE / sizeof(sector_t) - 1)
141 229
142struct swap_map_page { 230struct swap_map_page {
143 unsigned long entries[MAP_PAGE_ENTRIES]; 231 sector_t entries[MAP_PAGE_ENTRIES];
144 unsigned long next_swap; 232 sector_t next_swap;
145}; 233};
146 234
147/** 235/**
@@ -151,7 +239,7 @@ struct swap_map_page {
151 239
152struct swap_map_handle { 240struct swap_map_handle {
153 struct swap_map_page *cur; 241 struct swap_map_page *cur;
154 unsigned long cur_swap; 242 sector_t cur_swap;
155 struct bitmap_page *bitmap; 243 struct bitmap_page *bitmap;
156 unsigned int k; 244 unsigned int k;
157}; 245};
@@ -166,26 +254,6 @@ static void release_swap_writer(struct swap_map_handle *handle)
166 handle->bitmap = NULL; 254 handle->bitmap = NULL;
167} 255}
168 256
169static void show_speed(struct timeval *start, struct timeval *stop,
170 unsigned nr_pages, char *msg)
171{
172 s64 elapsed_centisecs64;
173 int centisecs;
174 int k;
175 int kps;
176
177 elapsed_centisecs64 = timeval_to_ns(stop) - timeval_to_ns(start);
178 do_div(elapsed_centisecs64, NSEC_PER_SEC / 100);
179 centisecs = elapsed_centisecs64;
180 if (centisecs == 0)
181 centisecs = 1; /* avoid div-by-zero */
182 k = nr_pages * (PAGE_SIZE / 1024);
183 kps = (k * 100) / centisecs;
184 printk("%s %d kbytes in %d.%02d seconds (%d.%02d MB/s)\n", msg, k,
185 centisecs / 100, centisecs % 100,
186 kps / 1000, (kps % 1000) / 10);
187}
188
189static int get_swap_writer(struct swap_map_handle *handle) 257static int get_swap_writer(struct swap_map_handle *handle)
190{ 258{
191 handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_KERNEL); 259 handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_KERNEL);
@@ -196,7 +264,7 @@ static int get_swap_writer(struct swap_map_handle *handle)
196 release_swap_writer(handle); 264 release_swap_writer(handle);
197 return -ENOMEM; 265 return -ENOMEM;
198 } 266 }
199 handle->cur_swap = alloc_swap_page(root_swap, handle->bitmap); 267 handle->cur_swap = alloc_swapdev_block(root_swap, handle->bitmap);
200 if (!handle->cur_swap) { 268 if (!handle->cur_swap) {
201 release_swap_writer(handle); 269 release_swap_writer(handle);
202 return -ENOSPC; 270 return -ENOSPC;
@@ -205,43 +273,15 @@ static int get_swap_writer(struct swap_map_handle *handle)
205 return 0; 273 return 0;
206} 274}
207 275
208static int wait_on_bio_chain(struct bio **bio_chain)
209{
210 struct bio *bio;
211 struct bio *next_bio;
212 int ret = 0;
213
214 if (bio_chain == NULL)
215 return 0;
216
217 bio = *bio_chain;
218 if (bio == NULL)
219 return 0;
220 while (bio) {
221 struct page *page;
222
223 next_bio = bio->bi_private;
224 page = bio->bi_io_vec[0].bv_page;
225 wait_on_page_locked(page);
226 if (!PageUptodate(page) || PageError(page))
227 ret = -EIO;
228 put_page(page);
229 bio_put(bio);
230 bio = next_bio;
231 }
232 *bio_chain = NULL;
233 return ret;
234}
235
236static int swap_write_page(struct swap_map_handle *handle, void *buf, 276static int swap_write_page(struct swap_map_handle *handle, void *buf,
237 struct bio **bio_chain) 277 struct bio **bio_chain)
238{ 278{
239 int error = 0; 279 int error = 0;
240 unsigned long offset; 280 sector_t offset;
241 281
242 if (!handle->cur) 282 if (!handle->cur)
243 return -EINVAL; 283 return -EINVAL;
244 offset = alloc_swap_page(root_swap, handle->bitmap); 284 offset = alloc_swapdev_block(root_swap, handle->bitmap);
245 error = write_page(buf, offset, bio_chain); 285 error = write_page(buf, offset, bio_chain);
246 if (error) 286 if (error)
247 return error; 287 return error;
@@ -250,7 +290,7 @@ static int swap_write_page(struct swap_map_handle *handle, void *buf,
250 error = wait_on_bio_chain(bio_chain); 290 error = wait_on_bio_chain(bio_chain);
251 if (error) 291 if (error)
252 goto out; 292 goto out;
253 offset = alloc_swap_page(root_swap, handle->bitmap); 293 offset = alloc_swapdev_block(root_swap, handle->bitmap);
254 if (!offset) 294 if (!offset)
255 return -ENOSPC; 295 return -ENOSPC;
256 handle->cur->next_swap = offset; 296 handle->cur->next_swap = offset;
@@ -261,7 +301,7 @@ static int swap_write_page(struct swap_map_handle *handle, void *buf,
261 handle->cur_swap = offset; 301 handle->cur_swap = offset;
262 handle->k = 0; 302 handle->k = 0;
263 } 303 }
264out: 304 out:
265 return error; 305 return error;
266} 306}
267 307
@@ -315,7 +355,7 @@ static int save_image(struct swap_map_handle *handle,
315 error = err2; 355 error = err2;
316 if (!error) 356 if (!error)
317 printk("\b\b\b\bdone\n"); 357 printk("\b\b\b\bdone\n");
318 show_speed(&start, &stop, nr_to_write, "Wrote"); 358 swsusp_show_speed(&start, &stop, nr_to_write, "Wrote");
319 return error; 359 return error;
320} 360}
321 361
@@ -350,100 +390,50 @@ int swsusp_write(void)
350 struct swsusp_info *header; 390 struct swsusp_info *header;
351 int error; 391 int error;
352 392
353 if ((error = swsusp_swap_check())) { 393 error = swsusp_swap_check();
394 if (error) {
354 printk(KERN_ERR "swsusp: Cannot find swap device, try " 395 printk(KERN_ERR "swsusp: Cannot find swap device, try "
355 "swapon -a.\n"); 396 "swapon -a.\n");
356 return error; 397 return error;
357 } 398 }
358 memset(&snapshot, 0, sizeof(struct snapshot_handle)); 399 memset(&snapshot, 0, sizeof(struct snapshot_handle));
359 error = snapshot_read_next(&snapshot, PAGE_SIZE); 400 error = snapshot_read_next(&snapshot, PAGE_SIZE);
360 if (error < PAGE_SIZE) 401 if (error < PAGE_SIZE) {
361 return error < 0 ? error : -EFAULT; 402 if (error >= 0)
403 error = -EFAULT;
404
405 goto out;
406 }
362 header = (struct swsusp_info *)data_of(snapshot); 407 header = (struct swsusp_info *)data_of(snapshot);
363 if (!enough_swap(header->pages)) { 408 if (!enough_swap(header->pages)) {
364 printk(KERN_ERR "swsusp: Not enough free swap\n"); 409 printk(KERN_ERR "swsusp: Not enough free swap\n");
365 return -ENOSPC; 410 error = -ENOSPC;
411 goto out;
366 } 412 }
367 error = get_swap_writer(&handle); 413 error = get_swap_writer(&handle);
368 if (!error) { 414 if (!error) {
369 unsigned long start = handle.cur_swap; 415 sector_t start = handle.cur_swap;
416
370 error = swap_write_page(&handle, header, NULL); 417 error = swap_write_page(&handle, header, NULL);
371 if (!error) 418 if (!error)
372 error = save_image(&handle, &snapshot, 419 error = save_image(&handle, &snapshot,
373 header->pages - 1); 420 header->pages - 1);
421
374 if (!error) { 422 if (!error) {
375 flush_swap_writer(&handle); 423 flush_swap_writer(&handle);
376 printk("S"); 424 printk("S");
377 error = mark_swapfiles(swp_entry(root_swap, start)); 425 error = mark_swapfiles(start);
378 printk("|\n"); 426 printk("|\n");
379 } 427 }
380 } 428 }
381 if (error) 429 if (error)
382 free_all_swap_pages(root_swap, handle.bitmap); 430 free_all_swap_pages(root_swap, handle.bitmap);
383 release_swap_writer(&handle); 431 release_swap_writer(&handle);
432 out:
433 swsusp_close();
384 return error; 434 return error;
385} 435}
386 436
387static struct block_device *resume_bdev;
388
389/**
390 * submit - submit BIO request.
391 * @rw: READ or WRITE.
392 * @off physical offset of page.
393 * @page: page we're reading or writing.
394 * @bio_chain: list of pending biod (for async reading)
395 *
396 * Straight from the textbook - allocate and initialize the bio.
397 * If we're reading, make sure the page is marked as dirty.
398 * Then submit it and, if @bio_chain == NULL, wait.
399 */
400static int submit(int rw, pgoff_t page_off, struct page *page,
401 struct bio **bio_chain)
402{
403 struct bio *bio;
404
405 bio = bio_alloc(GFP_ATOMIC, 1);
406 if (!bio)
407 return -ENOMEM;
408 bio->bi_sector = page_off * (PAGE_SIZE >> 9);
409 bio->bi_bdev = resume_bdev;
410 bio->bi_end_io = end_swap_bio_read;
411
412 if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
413 printk("swsusp: ERROR: adding page to bio at %ld\n", page_off);
414 bio_put(bio);
415 return -EFAULT;
416 }
417
418 lock_page(page);
419 bio_get(bio);
420
421 if (bio_chain == NULL) {
422 submit_bio(rw | (1 << BIO_RW_SYNC), bio);
423 wait_on_page_locked(page);
424 if (rw == READ)
425 bio_set_pages_dirty(bio);
426 bio_put(bio);
427 } else {
428 if (rw == READ)
429 get_page(page); /* These pages are freed later */
430 bio->bi_private = *bio_chain;
431 *bio_chain = bio;
432 submit_bio(rw | (1 << BIO_RW_SYNC), bio);
433 }
434 return 0;
435}
436
437static int bio_read_page(pgoff_t page_off, void *addr, struct bio **bio_chain)
438{
439 return submit(READ, page_off, virt_to_page(addr), bio_chain);
440}
441
442static int bio_write_page(pgoff_t page_off, void *addr)
443{
444 return submit(WRITE, page_off, virt_to_page(addr), NULL);
445}
446
447/** 437/**
448 * The following functions allow us to read data using a swap map 438 * The following functions allow us to read data using a swap map
449 * in a file-alike way 439 * in a file-alike way
@@ -456,17 +446,18 @@ static void release_swap_reader(struct swap_map_handle *handle)
456 handle->cur = NULL; 446 handle->cur = NULL;
457} 447}
458 448
459static int get_swap_reader(struct swap_map_handle *handle, 449static int get_swap_reader(struct swap_map_handle *handle, sector_t start)
460 swp_entry_t start)
461{ 450{
462 int error; 451 int error;
463 452
464 if (!swp_offset(start)) 453 if (!start)
465 return -EINVAL; 454 return -EINVAL;
466 handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_ATOMIC); 455
456 handle->cur = (struct swap_map_page *)get_zeroed_page(__GFP_WAIT | __GFP_HIGH);
467 if (!handle->cur) 457 if (!handle->cur)
468 return -ENOMEM; 458 return -ENOMEM;
469 error = bio_read_page(swp_offset(start), handle->cur, NULL); 459
460 error = bio_read_page(start, handle->cur, NULL);
470 if (error) { 461 if (error) {
471 release_swap_reader(handle); 462 release_swap_reader(handle);
472 return error; 463 return error;
@@ -478,7 +469,7 @@ static int get_swap_reader(struct swap_map_handle *handle,
478static int swap_read_page(struct swap_map_handle *handle, void *buf, 469static int swap_read_page(struct swap_map_handle *handle, void *buf,
479 struct bio **bio_chain) 470 struct bio **bio_chain)
480{ 471{
481 unsigned long offset; 472 sector_t offset;
482 int error; 473 int error;
483 474
484 if (!handle->cur) 475 if (!handle->cur)
@@ -547,11 +538,11 @@ static int load_image(struct swap_map_handle *handle,
547 error = err2; 538 error = err2;
548 if (!error) { 539 if (!error) {
549 printk("\b\b\b\bdone\n"); 540 printk("\b\b\b\bdone\n");
550 snapshot_free_unused_memory(snapshot); 541 snapshot_write_finalize(snapshot);
551 if (!snapshot_image_loaded(snapshot)) 542 if (!snapshot_image_loaded(snapshot))
552 error = -ENODATA; 543 error = -ENODATA;
553 } 544 }
554 show_speed(&start, &stop, nr_to_read, "Read"); 545 swsusp_show_speed(&start, &stop, nr_to_read, "Read");
555 return error; 546 return error;
556} 547}
557 548
@@ -600,12 +591,16 @@ int swsusp_check(void)
600 if (!IS_ERR(resume_bdev)) { 591 if (!IS_ERR(resume_bdev)) {
601 set_blocksize(resume_bdev, PAGE_SIZE); 592 set_blocksize(resume_bdev, PAGE_SIZE);
602 memset(&swsusp_header, 0, sizeof(swsusp_header)); 593 memset(&swsusp_header, 0, sizeof(swsusp_header));
603 if ((error = bio_read_page(0, &swsusp_header, NULL))) 594 error = bio_read_page(swsusp_resume_block,
595 &swsusp_header, NULL);
596 if (error)
604 return error; 597 return error;
598
605 if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) { 599 if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) {
606 memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10); 600 memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10);
607 /* Reset swap signature now */ 601 /* Reset swap signature now */
608 error = bio_write_page(0, &swsusp_header); 602 error = bio_write_page(swsusp_resume_block,
603 &swsusp_header, NULL);
609 } else { 604 } else {
610 return -EINVAL; 605 return -EINVAL;
611 } 606 }
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index 0b66659dc516..31aa0390c777 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -49,6 +49,7 @@
49#include <linux/bootmem.h> 49#include <linux/bootmem.h>
50#include <linux/syscalls.h> 50#include <linux/syscalls.h>
51#include <linux/highmem.h> 51#include <linux/highmem.h>
52#include <linux/time.h>
52 53
53#include "power.h" 54#include "power.h"
54 55
@@ -64,10 +65,8 @@ int in_suspend __nosavedata = 0;
64 65
65#ifdef CONFIG_HIGHMEM 66#ifdef CONFIG_HIGHMEM
66unsigned int count_highmem_pages(void); 67unsigned int count_highmem_pages(void);
67int save_highmem(void);
68int restore_highmem(void); 68int restore_highmem(void);
69#else 69#else
70static inline int save_highmem(void) { return 0; }
71static inline int restore_highmem(void) { return 0; } 70static inline int restore_highmem(void) { return 0; }
72static inline unsigned int count_highmem_pages(void) { return 0; } 71static inline unsigned int count_highmem_pages(void) { return 0; }
73#endif 72#endif
@@ -134,18 +133,18 @@ static int bitmap_set(struct bitmap_page *bitmap, unsigned long bit)
134 return 0; 133 return 0;
135} 134}
136 135
137unsigned long alloc_swap_page(int swap, struct bitmap_page *bitmap) 136sector_t alloc_swapdev_block(int swap, struct bitmap_page *bitmap)
138{ 137{
139 unsigned long offset; 138 unsigned long offset;
140 139
141 offset = swp_offset(get_swap_page_of_type(swap)); 140 offset = swp_offset(get_swap_page_of_type(swap));
142 if (offset) { 141 if (offset) {
143 if (bitmap_set(bitmap, offset)) { 142 if (bitmap_set(bitmap, offset))
144 swap_free(swp_entry(swap, offset)); 143 swap_free(swp_entry(swap, offset));
145 offset = 0; 144 else
146 } 145 return swapdev_block(swap, offset);
147 } 146 }
148 return offset; 147 return 0;
149} 148}
150 149
151void free_all_swap_pages(int swap, struct bitmap_page *bitmap) 150void free_all_swap_pages(int swap, struct bitmap_page *bitmap)
@@ -166,6 +165,34 @@ void free_all_swap_pages(int swap, struct bitmap_page *bitmap)
166} 165}
167 166
168/** 167/**
168 * swsusp_show_speed - print the time elapsed between two events represented by
169 * @start and @stop
170 *
171 * @nr_pages - number of pages processed between @start and @stop
172 * @msg - introductory message to print
173 */
174
175void swsusp_show_speed(struct timeval *start, struct timeval *stop,
176 unsigned nr_pages, char *msg)
177{
178 s64 elapsed_centisecs64;
179 int centisecs;
180 int k;
181 int kps;
182
183 elapsed_centisecs64 = timeval_to_ns(stop) - timeval_to_ns(start);
184 do_div(elapsed_centisecs64, NSEC_PER_SEC / 100);
185 centisecs = elapsed_centisecs64;
186 if (centisecs == 0)
187 centisecs = 1; /* avoid div-by-zero */
188 k = nr_pages * (PAGE_SIZE / 1024);
189 kps = (k * 100) / centisecs;
190 printk("%s %d kbytes in %d.%02d seconds (%d.%02d MB/s)\n", msg, k,
191 centisecs / 100, centisecs % 100,
192 kps / 1000, (kps % 1000) / 10);
193}
194
195/**
169 * swsusp_shrink_memory - Try to free as much memory as needed 196 * swsusp_shrink_memory - Try to free as much memory as needed
170 * 197 *
171 * ... but do not OOM-kill anyone 198 * ... but do not OOM-kill anyone
@@ -184,23 +211,37 @@ static inline unsigned long __shrink_memory(long tmp)
184 211
185int swsusp_shrink_memory(void) 212int swsusp_shrink_memory(void)
186{ 213{
187 long size, tmp; 214 long tmp;
188 struct zone *zone; 215 struct zone *zone;
189 unsigned long pages = 0; 216 unsigned long pages = 0;
190 unsigned int i = 0; 217 unsigned int i = 0;
191 char *p = "-\\|/"; 218 char *p = "-\\|/";
219 struct timeval start, stop;
192 220
193 printk("Shrinking memory... "); 221 printk("Shrinking memory... ");
222 do_gettimeofday(&start);
194 do { 223 do {
195 size = 2 * count_highmem_pages(); 224 long size, highmem_size;
196 size += size / 50 + count_data_pages() + PAGES_FOR_IO; 225
226 highmem_size = count_highmem_pages();
227 size = count_data_pages() + PAGES_FOR_IO;
197 tmp = size; 228 tmp = size;
229 size += highmem_size;
198 for_each_zone (zone) 230 for_each_zone (zone)
199 if (!is_highmem(zone) && populated_zone(zone)) { 231 if (populated_zone(zone)) {
200 tmp -= zone->free_pages; 232 if (is_highmem(zone)) {
201 tmp += zone->lowmem_reserve[ZONE_NORMAL]; 233 highmem_size -= zone->free_pages;
202 tmp += snapshot_additional_pages(zone); 234 } else {
235 tmp -= zone->free_pages;
236 tmp += zone->lowmem_reserve[ZONE_NORMAL];
237 tmp += snapshot_additional_pages(zone);
238 }
203 } 239 }
240
241 if (highmem_size < 0)
242 highmem_size = 0;
243
244 tmp += highmem_size;
204 if (tmp > 0) { 245 if (tmp > 0) {
205 tmp = __shrink_memory(tmp); 246 tmp = __shrink_memory(tmp);
206 if (!tmp) 247 if (!tmp)
@@ -212,7 +253,9 @@ int swsusp_shrink_memory(void)
212 } 253 }
213 printk("\b%c", p[i++%4]); 254 printk("\b%c", p[i++%4]);
214 } while (tmp > 0); 255 } while (tmp > 0);
256 do_gettimeofday(&stop);
215 printk("\bdone (%lu pages freed)\n", pages); 257 printk("\bdone (%lu pages freed)\n", pages);
258 swsusp_show_speed(&start, &stop, pages, "Freed");
216 259
217 return 0; 260 return 0;
218} 261}
@@ -223,6 +266,7 @@ int swsusp_suspend(void)
223 266
224 if ((error = arch_prepare_suspend())) 267 if ((error = arch_prepare_suspend()))
225 return error; 268 return error;
269
226 local_irq_disable(); 270 local_irq_disable();
227 /* At this point, device_suspend() has been called, but *not* 271 /* At this point, device_suspend() has been called, but *not*
228 * device_power_down(). We *must* device_power_down() now. 272 * device_power_down(). We *must* device_power_down() now.
@@ -235,23 +279,16 @@ int swsusp_suspend(void)
235 goto Enable_irqs; 279 goto Enable_irqs;
236 } 280 }
237 281
238 if ((error = save_highmem())) {
239 printk(KERN_ERR "swsusp: Not enough free pages for highmem\n");
240 goto Restore_highmem;
241 }
242
243 save_processor_state(); 282 save_processor_state();
244 if ((error = swsusp_arch_suspend())) 283 if ((error = swsusp_arch_suspend()))
245 printk(KERN_ERR "Error %d suspending\n", error); 284 printk(KERN_ERR "Error %d suspending\n", error);
246 /* Restore control flow magically appears here */ 285 /* Restore control flow magically appears here */
247 restore_processor_state(); 286 restore_processor_state();
248Restore_highmem:
249 restore_highmem();
250 /* NOTE: device_power_up() is just a resume() for devices 287 /* NOTE: device_power_up() is just a resume() for devices
251 * that suspended with irqs off ... no overall powerup. 288 * that suspended with irqs off ... no overall powerup.
252 */ 289 */
253 device_power_up(); 290 device_power_up();
254Enable_irqs: 291 Enable_irqs:
255 local_irq_enable(); 292 local_irq_enable();
256 return error; 293 return error;
257} 294}
@@ -268,18 +305,23 @@ int swsusp_resume(void)
268 printk(KERN_ERR "Some devices failed to power down, very bad\n"); 305 printk(KERN_ERR "Some devices failed to power down, very bad\n");
269 /* We'll ignore saved state, but this gets preempt count (etc) right */ 306 /* We'll ignore saved state, but this gets preempt count (etc) right */
270 save_processor_state(); 307 save_processor_state();
271 error = swsusp_arch_resume(); 308 error = restore_highmem();
272 /* Code below is only ever reached in case of failure. Otherwise 309 if (!error) {
273 * execution continues at place where swsusp_arch_suspend was called 310 error = swsusp_arch_resume();
274 */ 311 /* The code below is only ever reached in case of a failure.
275 BUG_ON(!error); 312 * Otherwise execution continues at place where
313 * swsusp_arch_suspend() was called
314 */
315 BUG_ON(!error);
316 /* This call to restore_highmem() undos the previous one */
317 restore_highmem();
318 }
276 /* The only reason why swsusp_arch_resume() can fail is memory being 319 /* The only reason why swsusp_arch_resume() can fail is memory being
277 * very tight, so we have to free it as soon as we can to avoid 320 * very tight, so we have to free it as soon as we can to avoid
278 * subsequent failures 321 * subsequent failures
279 */ 322 */
280 swsusp_free(); 323 swsusp_free();
281 restore_processor_state(); 324 restore_processor_state();
282 restore_highmem();
283 touch_softlockup_watchdog(); 325 touch_softlockup_watchdog();
284 device_power_up(); 326 device_power_up();
285 local_irq_enable(); 327 local_irq_enable();
diff --git a/kernel/power/user.c b/kernel/power/user.c
index d991d3b0e5a4..89443b85163b 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/suspend.h> 12#include <linux/suspend.h>
13#include <linux/syscalls.h> 13#include <linux/syscalls.h>
14#include <linux/reboot.h>
14#include <linux/string.h> 15#include <linux/string.h>
15#include <linux/device.h> 16#include <linux/device.h>
16#include <linux/miscdevice.h> 17#include <linux/miscdevice.h>
@@ -21,6 +22,7 @@
21#include <linux/fs.h> 22#include <linux/fs.h>
22#include <linux/console.h> 23#include <linux/console.h>
23#include <linux/cpu.h> 24#include <linux/cpu.h>
25#include <linux/freezer.h>
24 26
25#include <asm/uaccess.h> 27#include <asm/uaccess.h>
26 28
@@ -54,7 +56,8 @@ static int snapshot_open(struct inode *inode, struct file *filp)
54 filp->private_data = data; 56 filp->private_data = data;
55 memset(&data->handle, 0, sizeof(struct snapshot_handle)); 57 memset(&data->handle, 0, sizeof(struct snapshot_handle));
56 if ((filp->f_flags & O_ACCMODE) == O_RDONLY) { 58 if ((filp->f_flags & O_ACCMODE) == O_RDONLY) {
57 data->swap = swsusp_resume_device ? swap_type_of(swsusp_resume_device) : -1; 59 data->swap = swsusp_resume_device ?
60 swap_type_of(swsusp_resume_device, 0) : -1;
58 data->mode = O_RDONLY; 61 data->mode = O_RDONLY;
59 } else { 62 } else {
60 data->swap = -1; 63 data->swap = -1;
@@ -76,10 +79,10 @@ static int snapshot_release(struct inode *inode, struct file *filp)
76 free_all_swap_pages(data->swap, data->bitmap); 79 free_all_swap_pages(data->swap, data->bitmap);
77 free_bitmap(data->bitmap); 80 free_bitmap(data->bitmap);
78 if (data->frozen) { 81 if (data->frozen) {
79 down(&pm_sem); 82 mutex_lock(&pm_mutex);
80 thaw_processes(); 83 thaw_processes();
81 enable_nonboot_cpus(); 84 enable_nonboot_cpus();
82 up(&pm_sem); 85 mutex_unlock(&pm_mutex);
83 } 86 }
84 atomic_inc(&device_available); 87 atomic_inc(&device_available);
85 return 0; 88 return 0;
@@ -124,7 +127,8 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
124{ 127{
125 int error = 0; 128 int error = 0;
126 struct snapshot_data *data; 129 struct snapshot_data *data;
127 loff_t offset, avail; 130 loff_t avail;
131 sector_t offset;
128 132
129 if (_IOC_TYPE(cmd) != SNAPSHOT_IOC_MAGIC) 133 if (_IOC_TYPE(cmd) != SNAPSHOT_IOC_MAGIC)
130 return -ENOTTY; 134 return -ENOTTY;
@@ -140,7 +144,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
140 case SNAPSHOT_FREEZE: 144 case SNAPSHOT_FREEZE:
141 if (data->frozen) 145 if (data->frozen)
142 break; 146 break;
143 down(&pm_sem); 147 mutex_lock(&pm_mutex);
144 error = disable_nonboot_cpus(); 148 error = disable_nonboot_cpus();
145 if (!error) { 149 if (!error) {
146 error = freeze_processes(); 150 error = freeze_processes();
@@ -150,7 +154,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
150 error = -EBUSY; 154 error = -EBUSY;
151 } 155 }
152 } 156 }
153 up(&pm_sem); 157 mutex_unlock(&pm_mutex);
154 if (!error) 158 if (!error)
155 data->frozen = 1; 159 data->frozen = 1;
156 break; 160 break;
@@ -158,10 +162,10 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
158 case SNAPSHOT_UNFREEZE: 162 case SNAPSHOT_UNFREEZE:
159 if (!data->frozen) 163 if (!data->frozen)
160 break; 164 break;
161 down(&pm_sem); 165 mutex_lock(&pm_mutex);
162 thaw_processes(); 166 thaw_processes();
163 enable_nonboot_cpus(); 167 enable_nonboot_cpus();
164 up(&pm_sem); 168 mutex_unlock(&pm_mutex);
165 data->frozen = 0; 169 data->frozen = 0;
166 break; 170 break;
167 171
@@ -170,7 +174,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
170 error = -EPERM; 174 error = -EPERM;
171 break; 175 break;
172 } 176 }
173 down(&pm_sem); 177 mutex_lock(&pm_mutex);
174 /* Free memory before shutting down devices. */ 178 /* Free memory before shutting down devices. */
175 error = swsusp_shrink_memory(); 179 error = swsusp_shrink_memory();
176 if (!error) { 180 if (!error) {
@@ -183,7 +187,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
183 } 187 }
184 resume_console(); 188 resume_console();
185 } 189 }
186 up(&pm_sem); 190 mutex_unlock(&pm_mutex);
187 if (!error) 191 if (!error)
188 error = put_user(in_suspend, (unsigned int __user *)arg); 192 error = put_user(in_suspend, (unsigned int __user *)arg);
189 if (!error) 193 if (!error)
@@ -191,13 +195,13 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
191 break; 195 break;
192 196
193 case SNAPSHOT_ATOMIC_RESTORE: 197 case SNAPSHOT_ATOMIC_RESTORE:
198 snapshot_write_finalize(&data->handle);
194 if (data->mode != O_WRONLY || !data->frozen || 199 if (data->mode != O_WRONLY || !data->frozen ||
195 !snapshot_image_loaded(&data->handle)) { 200 !snapshot_image_loaded(&data->handle)) {
196 error = -EPERM; 201 error = -EPERM;
197 break; 202 break;
198 } 203 }
199 snapshot_free_unused_memory(&data->handle); 204 mutex_lock(&pm_mutex);
200 down(&pm_sem);
201 pm_prepare_console(); 205 pm_prepare_console();
202 suspend_console(); 206 suspend_console();
203 error = device_suspend(PMSG_PRETHAW); 207 error = device_suspend(PMSG_PRETHAW);
@@ -207,7 +211,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
207 } 211 }
208 resume_console(); 212 resume_console();
209 pm_restore_console(); 213 pm_restore_console();
210 up(&pm_sem); 214 mutex_unlock(&pm_mutex);
211 break; 215 break;
212 216
213 case SNAPSHOT_FREE: 217 case SNAPSHOT_FREE:
@@ -238,10 +242,10 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
238 break; 242 break;
239 } 243 }
240 } 244 }
241 offset = alloc_swap_page(data->swap, data->bitmap); 245 offset = alloc_swapdev_block(data->swap, data->bitmap);
242 if (offset) { 246 if (offset) {
243 offset <<= PAGE_SHIFT; 247 offset <<= PAGE_SHIFT;
244 error = put_user(offset, (loff_t __user *)arg); 248 error = put_user(offset, (sector_t __user *)arg);
245 } else { 249 } else {
246 error = -ENOSPC; 250 error = -ENOSPC;
247 } 251 }
@@ -264,7 +268,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
264 * so we need to recode them 268 * so we need to recode them
265 */ 269 */
266 if (old_decode_dev(arg)) { 270 if (old_decode_dev(arg)) {
267 data->swap = swap_type_of(old_decode_dev(arg)); 271 data->swap = swap_type_of(old_decode_dev(arg), 0);
268 if (data->swap < 0) 272 if (data->swap < 0)
269 error = -ENODEV; 273 error = -ENODEV;
270 } else { 274 } else {
@@ -282,7 +286,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
282 break; 286 break;
283 } 287 }
284 288
285 if (down_trylock(&pm_sem)) { 289 if (!mutex_trylock(&pm_mutex)) {
286 error = -EBUSY; 290 error = -EBUSY;
287 break; 291 break;
288 } 292 }
@@ -309,8 +313,66 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
309 if (pm_ops->finish) 313 if (pm_ops->finish)
310 pm_ops->finish(PM_SUSPEND_MEM); 314 pm_ops->finish(PM_SUSPEND_MEM);
311 315
312OutS3: 316 OutS3:
313 up(&pm_sem); 317 mutex_unlock(&pm_mutex);
318 break;
319
320 case SNAPSHOT_PMOPS:
321 switch (arg) {
322
323 case PMOPS_PREPARE:
324 if (pm_ops->prepare) {
325 error = pm_ops->prepare(PM_SUSPEND_DISK);
326 }
327 break;
328
329 case PMOPS_ENTER:
330 kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK);
331 error = pm_ops->enter(PM_SUSPEND_DISK);
332 break;
333
334 case PMOPS_FINISH:
335 if (pm_ops && pm_ops->finish) {
336 pm_ops->finish(PM_SUSPEND_DISK);
337 }
338 break;
339
340 default:
341 printk(KERN_ERR "SNAPSHOT_PMOPS: invalid argument %ld\n", arg);
342 error = -EINVAL;
343
344 }
345 break;
346
347 case SNAPSHOT_SET_SWAP_AREA:
348 if (data->bitmap) {
349 error = -EPERM;
350 } else {
351 struct resume_swap_area swap_area;
352 dev_t swdev;
353
354 error = copy_from_user(&swap_area, (void __user *)arg,
355 sizeof(struct resume_swap_area));
356 if (error) {
357 error = -EFAULT;
358 break;
359 }
360
361 /*
362 * User space encodes device types as two-byte values,
363 * so we need to recode them
364 */
365 swdev = old_decode_dev(swap_area.dev);
366 if (swdev) {
367 offset = swap_area.offset;
368 data->swap = swap_type_of(swdev, offset);
369 if (data->swap < 0)
370 error = -ENODEV;
371 } else {
372 data->swap = -1;
373 error = -EINVAL;
374 }
375 }
314 break; 376 break;
315 377
316 default: 378 default:
@@ -321,7 +383,7 @@ OutS3:
321 return error; 383 return error;
322} 384}
323 385
324static struct file_operations snapshot_fops = { 386static const struct file_operations snapshot_fops = {
325 .open = snapshot_open, 387 .open = snapshot_open,
326 .release = snapshot_release, 388 .release = snapshot_release,
327 .read = snapshot_read, 389 .read = snapshot_read,
diff --git a/kernel/printk.c b/kernel/printk.c
index 66426552fbfe..185bb45eacf7 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -53,8 +53,6 @@ int console_printk[4] = {
53 DEFAULT_CONSOLE_LOGLEVEL, /* default_console_loglevel */ 53 DEFAULT_CONSOLE_LOGLEVEL, /* default_console_loglevel */
54}; 54};
55 55
56EXPORT_UNUSED_SYMBOL(console_printk); /* June 2006 */
57
58/* 56/*
59 * Low lever drivers may need that to know if they can schedule in 57 * Low lever drivers may need that to know if they can schedule in
60 * their unblank() callback or not. So let's export it. 58 * their unblank() callback or not. So let's export it.
@@ -335,13 +333,25 @@ static void __call_console_drivers(unsigned long start, unsigned long end)
335 } 333 }
336} 334}
337 335
336static int __read_mostly ignore_loglevel;
337
338int __init ignore_loglevel_setup(char *str)
339{
340 ignore_loglevel = 1;
341 printk(KERN_INFO "debug: ignoring loglevel setting.\n");
342
343 return 1;
344}
345
346__setup("ignore_loglevel", ignore_loglevel_setup);
347
338/* 348/*
339 * Write out chars from start to end - 1 inclusive 349 * Write out chars from start to end - 1 inclusive
340 */ 350 */
341static void _call_console_drivers(unsigned long start, 351static void _call_console_drivers(unsigned long start,
342 unsigned long end, int msg_log_level) 352 unsigned long end, int msg_log_level)
343{ 353{
344 if (msg_log_level < console_loglevel && 354 if ((msg_log_level < console_loglevel || ignore_loglevel) &&
345 console_drivers && start != end) { 355 console_drivers && start != end) {
346 if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) { 356 if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) {
347 /* wrapped write */ 357 /* wrapped write */
@@ -631,12 +641,7 @@ EXPORT_SYMBOL(vprintk);
631 641
632asmlinkage long sys_syslog(int type, char __user *buf, int len) 642asmlinkage long sys_syslog(int type, char __user *buf, int len)
633{ 643{
634 return 0; 644 return -ENOSYS;
635}
636
637int do_syslog(int type, char __user *buf, int len)
638{
639 return 0;
640} 645}
641 646
642static void call_console_drivers(unsigned long start, unsigned long end) 647static void call_console_drivers(unsigned long start, unsigned long end)
@@ -777,7 +782,6 @@ int is_console_locked(void)
777{ 782{
778 return console_locked; 783 return console_locked;
779} 784}
780EXPORT_UNUSED_SYMBOL(is_console_locked); /* June 2006 */
781 785
782/** 786/**
783 * release_console_sem - unlock the console system 787 * release_console_sem - unlock the console system
diff --git a/kernel/profile.c b/kernel/profile.c
index f940b462eec9..fb5e03d57e9d 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -40,7 +40,7 @@ int (*timer_hook)(struct pt_regs *) __read_mostly;
40 40
41static atomic_t *prof_buffer; 41static atomic_t *prof_buffer;
42static unsigned long prof_len, prof_shift; 42static unsigned long prof_len, prof_shift;
43static int prof_on __read_mostly; 43int prof_on __read_mostly;
44static cpumask_t prof_cpu_mask = CPU_MASK_ALL; 44static cpumask_t prof_cpu_mask = CPU_MASK_ALL;
45#ifdef CONFIG_SMP 45#ifdef CONFIG_SMP
46static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits); 46static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits);
@@ -51,9 +51,19 @@ static DEFINE_MUTEX(profile_flip_mutex);
51static int __init profile_setup(char * str) 51static int __init profile_setup(char * str)
52{ 52{
53 static char __initdata schedstr[] = "schedule"; 53 static char __initdata schedstr[] = "schedule";
54 static char __initdata sleepstr[] = "sleep";
54 int par; 55 int par;
55 56
56 if (!strncmp(str, schedstr, strlen(schedstr))) { 57 if (!strncmp(str, sleepstr, strlen(sleepstr))) {
58 prof_on = SLEEP_PROFILING;
59 if (str[strlen(sleepstr)] == ',')
60 str += strlen(sleepstr) + 1;
61 if (get_option(&str, &par))
62 prof_shift = par;
63 printk(KERN_INFO
64 "kernel sleep profiling enabled (shift: %ld)\n",
65 prof_shift);
66 } else if (!strncmp(str, sleepstr, strlen(sleepstr))) {
57 prof_on = SCHED_PROFILING; 67 prof_on = SCHED_PROFILING;
58 if (str[strlen(schedstr)] == ',') 68 if (str[strlen(schedstr)] == ',')
59 str += strlen(schedstr) + 1; 69 str += strlen(schedstr) + 1;
@@ -204,7 +214,8 @@ EXPORT_SYMBOL_GPL(profile_event_unregister);
204 * positions to which hits are accounted during short intervals (e.g. 214 * positions to which hits are accounted during short intervals (e.g.
205 * several seconds) is usually very small. Exclusion from buffer 215 * several seconds) is usually very small. Exclusion from buffer
206 * flipping is provided by interrupt disablement (note that for 216 * flipping is provided by interrupt disablement (note that for
207 * SCHED_PROFILING profile_hit() may be called from process context). 217 * SCHED_PROFILING or SLEEP_PROFILING profile_hit() may be called from
218 * process context).
208 * The hash function is meant to be lightweight as opposed to strong, 219 * The hash function is meant to be lightweight as opposed to strong,
209 * and was vaguely inspired by ppc64 firmware-supported inverted 220 * and was vaguely inspired by ppc64 firmware-supported inverted
210 * pagetable hash functions, but uses a full hashtable full of finite 221 * pagetable hash functions, but uses a full hashtable full of finite
@@ -257,7 +268,7 @@ static void profile_discard_flip_buffers(void)
257 mutex_unlock(&profile_flip_mutex); 268 mutex_unlock(&profile_flip_mutex);
258} 269}
259 270
260void profile_hit(int type, void *__pc) 271void profile_hits(int type, void *__pc, unsigned int nr_hits)
261{ 272{
262 unsigned long primary, secondary, flags, pc = (unsigned long)__pc; 273 unsigned long primary, secondary, flags, pc = (unsigned long)__pc;
263 int i, j, cpu; 274 int i, j, cpu;
@@ -274,21 +285,31 @@ void profile_hit(int type, void *__pc)
274 put_cpu(); 285 put_cpu();
275 return; 286 return;
276 } 287 }
288 /*
289 * We buffer the global profiler buffer into a per-CPU
290 * queue and thus reduce the number of global (and possibly
291 * NUMA-alien) accesses. The write-queue is self-coalescing:
292 */
277 local_irq_save(flags); 293 local_irq_save(flags);
278 do { 294 do {
279 for (j = 0; j < PROFILE_GRPSZ; ++j) { 295 for (j = 0; j < PROFILE_GRPSZ; ++j) {
280 if (hits[i + j].pc == pc) { 296 if (hits[i + j].pc == pc) {
281 hits[i + j].hits++; 297 hits[i + j].hits += nr_hits;
282 goto out; 298 goto out;
283 } else if (!hits[i + j].hits) { 299 } else if (!hits[i + j].hits) {
284 hits[i + j].pc = pc; 300 hits[i + j].pc = pc;
285 hits[i + j].hits = 1; 301 hits[i + j].hits = nr_hits;
286 goto out; 302 goto out;
287 } 303 }
288 } 304 }
289 i = (i + secondary) & (NR_PROFILE_HIT - 1); 305 i = (i + secondary) & (NR_PROFILE_HIT - 1);
290 } while (i != primary); 306 } while (i != primary);
291 atomic_inc(&prof_buffer[pc]); 307
308 /*
309 * Add the current hit(s) and flush the write-queue out
310 * to the global buffer:
311 */
312 atomic_add(nr_hits, &prof_buffer[pc]);
292 for (i = 0; i < NR_PROFILE_HIT; ++i) { 313 for (i = 0; i < NR_PROFILE_HIT; ++i) {
293 atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]); 314 atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
294 hits[i].pc = hits[i].hits = 0; 315 hits[i].pc = hits[i].hits = 0;
@@ -298,7 +319,6 @@ out:
298 put_cpu(); 319 put_cpu();
299} 320}
300 321
301#ifdef CONFIG_HOTPLUG_CPU
302static int __devinit profile_cpu_callback(struct notifier_block *info, 322static int __devinit profile_cpu_callback(struct notifier_block *info,
303 unsigned long action, void *__cpu) 323 unsigned long action, void *__cpu)
304{ 324{
@@ -351,19 +371,19 @@ static int __devinit profile_cpu_callback(struct notifier_block *info,
351 } 371 }
352 return NOTIFY_OK; 372 return NOTIFY_OK;
353} 373}
354#endif /* CONFIG_HOTPLUG_CPU */
355#else /* !CONFIG_SMP */ 374#else /* !CONFIG_SMP */
356#define profile_flip_buffers() do { } while (0) 375#define profile_flip_buffers() do { } while (0)
357#define profile_discard_flip_buffers() do { } while (0) 376#define profile_discard_flip_buffers() do { } while (0)
377#define profile_cpu_callback NULL
358 378
359void profile_hit(int type, void *__pc) 379void profile_hits(int type, void *__pc, unsigned int nr_hits)
360{ 380{
361 unsigned long pc; 381 unsigned long pc;
362 382
363 if (prof_on != type || !prof_buffer) 383 if (prof_on != type || !prof_buffer)
364 return; 384 return;
365 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift; 385 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
366 atomic_inc(&prof_buffer[min(pc, prof_len - 1)]); 386 atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
367} 387}
368#endif /* !CONFIG_SMP */ 388#endif /* !CONFIG_SMP */
369 389
@@ -442,7 +462,8 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
442 read = 0; 462 read = 0;
443 463
444 while (p < sizeof(unsigned int) && count > 0) { 464 while (p < sizeof(unsigned int) && count > 0) {
445 put_user(*((char *)(&sample_step)+p),buf); 465 if (put_user(*((char *)(&sample_step)+p),buf))
466 return -EFAULT;
446 buf++; p++; count--; read++; 467 buf++; p++; count--; read++;
447 } 468 }
448 pnt = (char *)prof_buffer + p - sizeof(atomic_t); 469 pnt = (char *)prof_buffer + p - sizeof(atomic_t);
@@ -480,7 +501,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
480 return count; 501 return count;
481} 502}
482 503
483static struct file_operations proc_profile_operations = { 504static const struct file_operations proc_profile_operations = {
484 .read = read_profile, 505 .read = read_profile,
485 .write = write_profile, 506 .write = write_profile,
486}; 507};
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index 26bb5ffe1ef1..3554b76da84c 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -235,12 +235,14 @@ static void rcu_do_batch(struct rcu_data *rdp)
235 235
236 list = rdp->donelist; 236 list = rdp->donelist;
237 while (list) { 237 while (list) {
238 next = rdp->donelist = list->next; 238 next = list->next;
239 prefetch(next);
239 list->func(list); 240 list->func(list);
240 list = next; 241 list = next;
241 if (++count >= rdp->blimit) 242 if (++count >= rdp->blimit)
242 break; 243 break;
243 } 244 }
245 rdp->donelist = list;
244 246
245 local_irq_disable(); 247 local_irq_disable();
246 rdp->qlen -= count; 248 rdp->qlen -= count;
diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
index e2bda18f6f42..c52f981ea008 100644
--- a/kernel/rcutorture.c
+++ b/kernel/rcutorture.c
@@ -401,7 +401,7 @@ static void srcu_torture_cleanup(void)
401 cleanup_srcu_struct(&srcu_ctl); 401 cleanup_srcu_struct(&srcu_ctl);
402} 402}
403 403
404static int srcu_torture_read_lock(void) 404static int srcu_torture_read_lock(void) __acquires(&srcu_ctl)
405{ 405{
406 return srcu_read_lock(&srcu_ctl); 406 return srcu_read_lock(&srcu_ctl);
407} 407}
@@ -419,7 +419,7 @@ static void srcu_read_delay(struct rcu_random_state *rrsp)
419 schedule_timeout_interruptible(longdelay); 419 schedule_timeout_interruptible(longdelay);
420} 420}
421 421
422static void srcu_torture_read_unlock(int idx) 422static void srcu_torture_read_unlock(int idx) __releases(&srcu_ctl)
423{ 423{
424 srcu_read_unlock(&srcu_ctl, idx); 424 srcu_read_unlock(&srcu_ctl, idx);
425} 425}
diff --git a/kernel/relay.c b/kernel/relay.c
index f04bbdb56ac2..75a3a9a7efc2 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -308,9 +308,10 @@ static struct rchan_callbacks default_channel_callbacks = {
308 * reason waking is deferred is that calling directly from write 308 * reason waking is deferred is that calling directly from write
309 * causes problems if you're writing from say the scheduler. 309 * causes problems if you're writing from say the scheduler.
310 */ 310 */
311static void wakeup_readers(void *private) 311static void wakeup_readers(struct work_struct *work)
312{ 312{
313 struct rchan_buf *buf = private; 313 struct rchan_buf *buf =
314 container_of(work, struct rchan_buf, wake_readers.work);
314 wake_up_interruptible(&buf->read_wait); 315 wake_up_interruptible(&buf->read_wait);
315} 316}
316 317
@@ -328,7 +329,7 @@ static inline void __relay_reset(struct rchan_buf *buf, unsigned int init)
328 if (init) { 329 if (init) {
329 init_waitqueue_head(&buf->read_wait); 330 init_waitqueue_head(&buf->read_wait);
330 kref_init(&buf->kref); 331 kref_init(&buf->kref);
331 INIT_WORK(&buf->wake_readers, NULL, NULL); 332 INIT_DELAYED_WORK(&buf->wake_readers, NULL);
332 } else { 333 } else {
333 cancel_delayed_work(&buf->wake_readers); 334 cancel_delayed_work(&buf->wake_readers);
334 flush_scheduled_work(); 335 flush_scheduled_work();
@@ -549,7 +550,8 @@ size_t relay_switch_subbuf(struct rchan_buf *buf, size_t length)
549 buf->padding[old_subbuf]; 550 buf->padding[old_subbuf];
550 smp_mb(); 551 smp_mb();
551 if (waitqueue_active(&buf->read_wait)) { 552 if (waitqueue_active(&buf->read_wait)) {
552 PREPARE_WORK(&buf->wake_readers, wakeup_readers, buf); 553 PREPARE_DELAYED_WORK(&buf->wake_readers,
554 wakeup_readers);
553 schedule_delayed_work(&buf->wake_readers, 1); 555 schedule_delayed_work(&buf->wake_readers, 1);
554 } 556 }
555 } 557 }
@@ -1011,7 +1013,7 @@ static ssize_t relay_file_sendfile(struct file *filp,
1011 actor, &desc); 1013 actor, &desc);
1012} 1014}
1013 1015
1014struct file_operations relay_file_operations = { 1016const struct file_operations relay_file_operations = {
1015 .open = relay_file_open, 1017 .open = relay_file_open,
1016 .poll = relay_file_poll, 1018 .poll = relay_file_poll,
1017 .mmap = relay_file_mmap, 1019 .mmap = relay_file_mmap,
diff --git a/kernel/resource.c b/kernel/resource.c
index 6de60c12143e..7b9a497419d9 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -88,7 +88,7 @@ static int r_show(struct seq_file *m, void *v)
88 return 0; 88 return 0;
89} 89}
90 90
91static struct seq_operations resource_op = { 91static const struct seq_operations resource_op = {
92 .start = r_start, 92 .start = r_start,
93 .next = r_next, 93 .next = r_next,
94 .stop = r_stop, 94 .stop = r_stop,
@@ -115,14 +115,14 @@ static int iomem_open(struct inode *inode, struct file *file)
115 return res; 115 return res;
116} 116}
117 117
118static struct file_operations proc_ioports_operations = { 118static const struct file_operations proc_ioports_operations = {
119 .open = ioports_open, 119 .open = ioports_open,
120 .read = seq_read, 120 .read = seq_read,
121 .llseek = seq_lseek, 121 .llseek = seq_lseek,
122 .release = seq_release, 122 .release = seq_release,
123}; 123};
124 124
125static struct file_operations proc_iomem_operations = { 125static const struct file_operations proc_iomem_operations = {
126 .open = iomem_open, 126 .open = iomem_open,
127 .read = seq_read, 127 .read = seq_read,
128 .llseek = seq_lseek, 128 .llseek = seq_lseek,
diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
index 6dcea9dd8c94..015fc633c96c 100644
--- a/kernel/rtmutex-tester.c
+++ b/kernel/rtmutex-tester.c
@@ -13,6 +13,7 @@
13#include <linux/spinlock.h> 13#include <linux/spinlock.h>
14#include <linux/sysdev.h> 14#include <linux/sysdev.h>
15#include <linux/timer.h> 15#include <linux/timer.h>
16#include <linux/freezer.h>
16 17
17#include "rtmutex.h" 18#include "rtmutex.h"
18 19
diff --git a/kernel/sched.c b/kernel/sched.c
index 3399701c680e..f385eff4682d 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -34,7 +34,7 @@
34#include <linux/security.h> 34#include <linux/security.h>
35#include <linux/notifier.h> 35#include <linux/notifier.h>
36#include <linux/profile.h> 36#include <linux/profile.h>
37#include <linux/suspend.h> 37#include <linux/freezer.h>
38#include <linux/vmalloc.h> 38#include <linux/vmalloc.h>
39#include <linux/blkdev.h> 39#include <linux/blkdev.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
@@ -505,7 +505,7 @@ static int schedstat_open(struct inode *inode, struct file *file)
505 return res; 505 return res;
506} 506}
507 507
508struct file_operations proc_schedstat_operations = { 508const struct file_operations proc_schedstat_operations = {
509 .open = schedstat_open, 509 .open = schedstat_open,
510 .read = seq_read, 510 .read = seq_read,
511 .llseek = seq_lseek, 511 .llseek = seq_lseek,
@@ -948,6 +948,17 @@ static void activate_task(struct task_struct *p, struct rq *rq, int local)
948 } 948 }
949#endif 949#endif
950 950
951 /*
952 * Sleep time is in units of nanosecs, so shift by 20 to get a
953 * milliseconds-range estimation of the amount of time that the task
954 * spent sleeping:
955 */
956 if (unlikely(prof_on == SLEEP_PROFILING)) {
957 if (p->state == TASK_UNINTERRUPTIBLE)
958 profile_hits(SLEEP_PROFILING, (void *)get_wchan(p),
959 (now - p->timestamp) >> 20);
960 }
961
951 if (!rt_task(p)) 962 if (!rt_task(p))
952 p->prio = recalc_task_prio(p, now); 963 p->prio = recalc_task_prio(p, now);
953 964
@@ -3333,6 +3344,7 @@ asmlinkage void __sched schedule(void)
3333 printk(KERN_ERR "BUG: scheduling while atomic: " 3344 printk(KERN_ERR "BUG: scheduling while atomic: "
3334 "%s/0x%08x/%d\n", 3345 "%s/0x%08x/%d\n",
3335 current->comm, preempt_count(), current->pid); 3346 current->comm, preempt_count(), current->pid);
3347 debug_show_held_locks(current);
3336 dump_stack(); 3348 dump_stack();
3337 } 3349 }
3338 profile_hit(SCHED_PROFILING, __builtin_return_address(0)); 3350 profile_hit(SCHED_PROFILING, __builtin_return_address(0));
@@ -4804,18 +4816,18 @@ static void show_task(struct task_struct *p)
4804 show_stack(p, NULL); 4816 show_stack(p, NULL);
4805} 4817}
4806 4818
4807void show_state(void) 4819void show_state_filter(unsigned long state_filter)
4808{ 4820{
4809 struct task_struct *g, *p; 4821 struct task_struct *g, *p;
4810 4822
4811#if (BITS_PER_LONG == 32) 4823#if (BITS_PER_LONG == 32)
4812 printk("\n" 4824 printk("\n"
4813 " sibling\n"); 4825 " free sibling\n");
4814 printk(" task PC pid father child younger older\n"); 4826 printk(" task PC stack pid father child younger older\n");
4815#else 4827#else
4816 printk("\n" 4828 printk("\n"
4817 " sibling\n"); 4829 " free sibling\n");
4818 printk(" task PC pid father child younger older\n"); 4830 printk(" task PC stack pid father child younger older\n");
4819#endif 4831#endif
4820 read_lock(&tasklist_lock); 4832 read_lock(&tasklist_lock);
4821 do_each_thread(g, p) { 4833 do_each_thread(g, p) {
@@ -4824,11 +4836,16 @@ void show_state(void)
4824 * console might take alot of time: 4836 * console might take alot of time:
4825 */ 4837 */
4826 touch_nmi_watchdog(); 4838 touch_nmi_watchdog();
4827 show_task(p); 4839 if (p->state & state_filter)
4840 show_task(p);
4828 } while_each_thread(g, p); 4841 } while_each_thread(g, p);
4829 4842
4830 read_unlock(&tasklist_lock); 4843 read_unlock(&tasklist_lock);
4831 debug_show_all_locks(); 4844 /*
4845 * Only show locks if all tasks are dumped:
4846 */
4847 if (state_filter == -1)
4848 debug_show_all_locks();
4832} 4849}
4833 4850
4834/** 4851/**
@@ -6723,8 +6740,6 @@ SYSDEV_ATTR(sched_smt_power_savings, 0644, sched_smt_power_savings_show,
6723 sched_smt_power_savings_store); 6740 sched_smt_power_savings_store);
6724#endif 6741#endif
6725 6742
6726
6727#ifdef CONFIG_HOTPLUG_CPU
6728/* 6743/*
6729 * Force a reinitialization of the sched domains hierarchy. The domains 6744 * Force a reinitialization of the sched domains hierarchy. The domains
6730 * and groups cannot be updated in place without racing with the balancing 6745 * and groups cannot be updated in place without racing with the balancing
@@ -6757,7 +6772,6 @@ static int update_sched_domains(struct notifier_block *nfb,
6757 6772
6758 return NOTIFY_OK; 6773 return NOTIFY_OK;
6759} 6774}
6760#endif
6761 6775
6762void __init sched_init_smp(void) 6776void __init sched_init_smp(void)
6763{ 6777{
@@ -6867,6 +6881,7 @@ void __might_sleep(char *file, int line)
6867 " context at %s:%d\n", file, line); 6881 " context at %s:%d\n", file, line);
6868 printk("in_atomic():%d, irqs_disabled():%d\n", 6882 printk("in_atomic():%d, irqs_disabled():%d\n",
6869 in_atomic(), irqs_disabled()); 6883 in_atomic(), irqs_disabled());
6884 debug_show_held_locks(current);
6870 dump_stack(); 6885 dump_stack();
6871 } 6886 }
6872#endif 6887#endif
diff --git a/kernel/signal.c b/kernel/signal.c
index df18c167a2a7..ec81defde339 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -23,6 +23,7 @@
23#include <linux/ptrace.h> 23#include <linux/ptrace.h>
24#include <linux/signal.h> 24#include <linux/signal.h>
25#include <linux/capability.h> 25#include <linux/capability.h>
26#include <linux/freezer.h>
26#include <asm/param.h> 27#include <asm/param.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
28#include <asm/unistd.h> 29#include <asm/unistd.h>
@@ -33,7 +34,7 @@
33 * SLAB caches for signal bits. 34 * SLAB caches for signal bits.
34 */ 35 */
35 36
36static kmem_cache_t *sigqueue_cachep; 37static struct kmem_cache *sigqueue_cachep;
37 38
38/* 39/*
39 * In POSIX a signal is sent either to a specific thread (Linux task) 40 * In POSIX a signal is sent either to a specific thread (Linux task)
@@ -1133,8 +1134,7 @@ int kill_pid_info(int sig, struct siginfo *info, struct pid *pid)
1133 return error; 1134 return error;
1134} 1135}
1135 1136
1136int 1137static int kill_proc_info(int sig, struct siginfo *info, pid_t pid)
1137kill_proc_info(int sig, struct siginfo *info, pid_t pid)
1138{ 1138{
1139 int error; 1139 int error;
1140 rcu_read_lock(); 1140 rcu_read_lock();
diff --git a/kernel/softirq.c b/kernel/softirq.c
index bf25015dce16..918e52df090e 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -574,8 +574,6 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
574 574
575 switch (action) { 575 switch (action) {
576 case CPU_UP_PREPARE: 576 case CPU_UP_PREPARE:
577 BUG_ON(per_cpu(tasklet_vec, hotcpu).list);
578 BUG_ON(per_cpu(tasklet_hi_vec, hotcpu).list);
579 p = kthread_create(ksoftirqd, hcpu, "ksoftirqd/%d", hotcpu); 577 p = kthread_create(ksoftirqd, hcpu, "ksoftirqd/%d", hotcpu);
580 if (IS_ERR(p)) { 578 if (IS_ERR(p)) {
581 printk("ksoftirqd for %i failed\n", hotcpu); 579 printk("ksoftirqd for %i failed\n", hotcpu);
diff --git a/kernel/sys.c b/kernel/sys.c
index 98489d82801b..a0c1a29a507f 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -880,7 +880,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
880 return 0; 880 return 0;
881} 881}
882 882
883static void deferred_cad(void *dummy) 883static void deferred_cad(struct work_struct *dummy)
884{ 884{
885 kernel_restart(NULL); 885 kernel_restart(NULL);
886} 886}
@@ -892,7 +892,7 @@ static void deferred_cad(void *dummy)
892 */ 892 */
893void ctrl_alt_del(void) 893void ctrl_alt_del(void)
894{ 894{
895 static DECLARE_WORK(cad_work, deferred_cad, NULL); 895 static DECLARE_WORK(cad_work, deferred_cad);
896 896
897 if (C_A_D) 897 if (C_A_D)
898 schedule_work(&cad_work); 898 schedule_work(&cad_work);
@@ -1102,14 +1102,14 @@ asmlinkage long sys_setreuid(uid_t ruid, uid_t euid)
1102asmlinkage long sys_setuid(uid_t uid) 1102asmlinkage long sys_setuid(uid_t uid)
1103{ 1103{
1104 int old_euid = current->euid; 1104 int old_euid = current->euid;
1105 int old_ruid, old_suid, new_ruid, new_suid; 1105 int old_ruid, old_suid, new_suid;
1106 int retval; 1106 int retval;
1107 1107
1108 retval = security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_ID); 1108 retval = security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_ID);
1109 if (retval) 1109 if (retval)
1110 return retval; 1110 return retval;
1111 1111
1112 old_ruid = new_ruid = current->uid; 1112 old_ruid = current->uid;
1113 old_suid = current->suid; 1113 old_suid = current->suid;
1114 new_suid = old_suid; 1114 new_suid = old_suid;
1115 1115
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 6fc5e17086f4..8e9f00fd6d18 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -171,7 +171,7 @@ static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
171static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *); 171static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
172static int proc_opensys(struct inode *, struct file *); 172static int proc_opensys(struct inode *, struct file *);
173 173
174struct file_operations proc_sys_file_operations = { 174const struct file_operations proc_sys_file_operations = {
175 .open = proc_opensys, 175 .open = proc_opensys,
176 .read = proc_readsys, 176 .read = proc_readsys,
177 .write = proc_writesys, 177 .write = proc_writesys,
@@ -986,17 +986,6 @@ static ctl_table vm_table[] = {
986 .extra1 = &zero, 986 .extra1 = &zero,
987 }, 987 },
988#endif 988#endif
989#ifdef CONFIG_SWAP
990 {
991 .ctl_name = VM_SWAP_TOKEN_TIMEOUT,
992 .procname = "swap_token_timeout",
993 .data = &swap_token_default_timeout,
994 .maxlen = sizeof(swap_token_default_timeout),
995 .mode = 0644,
996 .proc_handler = &proc_dointvec_jiffies,
997 .strategy = &sysctl_jiffies,
998 },
999#endif
1000#ifdef CONFIG_NUMA 989#ifdef CONFIG_NUMA
1001 { 990 {
1002 .ctl_name = VM_ZONE_RECLAIM_MODE, 991 .ctl_name = VM_ZONE_RECLAIM_MODE,
@@ -1895,7 +1884,7 @@ static int __do_proc_dointvec(void *tbl_data, ctl_table *table,
1895 p = buf; 1884 p = buf;
1896 if (*p == '-' && left > 1) { 1885 if (*p == '-' && left > 1) {
1897 neg = 1; 1886 neg = 1;
1898 left--, p++; 1887 p++;
1899 } 1888 }
1900 if (*p < '0' || *p > '9') 1889 if (*p < '0' || *p > '9')
1901 break; 1890 break;
@@ -2146,7 +2135,7 @@ static int __do_proc_doulongvec_minmax(void *data, ctl_table *table, int write,
2146 p = buf; 2135 p = buf;
2147 if (*p == '-' && left > 1) { 2136 if (*p == '-' && left > 1) {
2148 neg = 1; 2137 neg = 1;
2149 left--, p++; 2138 p++;
2150 } 2139 }
2151 if (*p < '0' || *p > '9') 2140 if (*p < '0' || *p > '9')
2152 break; 2141 break;
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index d3d28919d4b4..4c3476fa058d 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -34,7 +34,7 @@
34 34
35static DEFINE_PER_CPU(__u32, taskstats_seqnum) = { 0 }; 35static DEFINE_PER_CPU(__u32, taskstats_seqnum) = { 0 };
36static int family_registered; 36static int family_registered;
37kmem_cache_t *taskstats_cache; 37struct kmem_cache *taskstats_cache;
38 38
39static struct genl_family family = { 39static struct genl_family family = {
40 .id = GENL_ID_GENERATE, 40 .id = GENL_ID_GENERATE,
@@ -69,7 +69,7 @@ enum actions {
69}; 69};
70 70
71static int prepare_reply(struct genl_info *info, u8 cmd, struct sk_buff **skbp, 71static int prepare_reply(struct genl_info *info, u8 cmd, struct sk_buff **skbp,
72 void **replyp, size_t size) 72 size_t size)
73{ 73{
74 struct sk_buff *skb; 74 struct sk_buff *skb;
75 void *reply; 75 void *reply;
@@ -94,7 +94,6 @@ static int prepare_reply(struct genl_info *info, u8 cmd, struct sk_buff **skbp,
94 } 94 }
95 95
96 *skbp = skb; 96 *skbp = skb;
97 *replyp = reply;
98 return 0; 97 return 0;
99} 98}
100 99
@@ -119,10 +118,10 @@ static int send_reply(struct sk_buff *skb, pid_t pid)
119/* 118/*
120 * Send taskstats data in @skb to listeners registered for @cpu's exit data 119 * Send taskstats data in @skb to listeners registered for @cpu's exit data
121 */ 120 */
122static void send_cpu_listeners(struct sk_buff *skb, unsigned int cpu) 121static void send_cpu_listeners(struct sk_buff *skb,
122 struct listener_list *listeners)
123{ 123{
124 struct genlmsghdr *genlhdr = nlmsg_data((struct nlmsghdr *)skb->data); 124 struct genlmsghdr *genlhdr = nlmsg_data((struct nlmsghdr *)skb->data);
125 struct listener_list *listeners;
126 struct listener *s, *tmp; 125 struct listener *s, *tmp;
127 struct sk_buff *skb_next, *skb_cur = skb; 126 struct sk_buff *skb_next, *skb_cur = skb;
128 void *reply = genlmsg_data(genlhdr); 127 void *reply = genlmsg_data(genlhdr);
@@ -135,7 +134,6 @@ static void send_cpu_listeners(struct sk_buff *skb, unsigned int cpu)
135 } 134 }
136 135
137 rc = 0; 136 rc = 0;
138 listeners = &per_cpu(listener_array, cpu);
139 down_read(&listeners->sem); 137 down_read(&listeners->sem);
140 list_for_each_entry(s, &listeners->list, list) { 138 list_for_each_entry(s, &listeners->list, list) {
141 skb_next = NULL; 139 skb_next = NULL;
@@ -186,6 +184,7 @@ static int fill_pid(pid_t pid, struct task_struct *tsk,
186 } else 184 } else
187 get_task_struct(tsk); 185 get_task_struct(tsk);
188 186
187 memset(stats, 0, sizeof(*stats));
189 /* 188 /*
190 * Each accounting subsystem adds calls to its functions to 189 * Each accounting subsystem adds calls to its functions to
191 * fill in relevant parts of struct taskstsats as follows 190 * fill in relevant parts of struct taskstsats as follows
@@ -228,6 +227,8 @@ static int fill_tgid(pid_t tgid, struct task_struct *first,
228 227
229 if (first->signal->stats) 228 if (first->signal->stats)
230 memcpy(stats, first->signal->stats, sizeof(*stats)); 229 memcpy(stats, first->signal->stats, sizeof(*stats));
230 else
231 memset(stats, 0, sizeof(*stats));
231 232
232 tsk = first; 233 tsk = first;
233 do { 234 do {
@@ -344,14 +345,36 @@ static int parse(struct nlattr *na, cpumask_t *mask)
344 return ret; 345 return ret;
345} 346}
346 347
348static struct taskstats *mk_reply(struct sk_buff *skb, int type, u32 pid)
349{
350 struct nlattr *na, *ret;
351 int aggr;
352
353 aggr = (type == TASKSTATS_TYPE_PID)
354 ? TASKSTATS_TYPE_AGGR_PID
355 : TASKSTATS_TYPE_AGGR_TGID;
356
357 na = nla_nest_start(skb, aggr);
358 if (!na)
359 goto err;
360 if (nla_put(skb, type, sizeof(pid), &pid) < 0)
361 goto err;
362 ret = nla_reserve(skb, TASKSTATS_TYPE_STATS, sizeof(struct taskstats));
363 if (!ret)
364 goto err;
365 nla_nest_end(skb, na);
366
367 return nla_data(ret);
368err:
369 return NULL;
370}
371
347static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info) 372static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
348{ 373{
349 int rc = 0; 374 int rc = 0;
350 struct sk_buff *rep_skb; 375 struct sk_buff *rep_skb;
351 struct taskstats stats; 376 struct taskstats *stats;
352 void *reply;
353 size_t size; 377 size_t size;
354 struct nlattr *na;
355 cpumask_t mask; 378 cpumask_t mask;
356 379
357 rc = parse(info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK], &mask); 380 rc = parse(info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK], &mask);
@@ -372,83 +395,71 @@ static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
372 size = nla_total_size(sizeof(u32)) + 395 size = nla_total_size(sizeof(u32)) +
373 nla_total_size(sizeof(struct taskstats)) + nla_total_size(0); 396 nla_total_size(sizeof(struct taskstats)) + nla_total_size(0);
374 397
375 memset(&stats, 0, sizeof(stats)); 398 rc = prepare_reply(info, TASKSTATS_CMD_NEW, &rep_skb, size);
376 rc = prepare_reply(info, TASKSTATS_CMD_NEW, &rep_skb, &reply, size);
377 if (rc < 0) 399 if (rc < 0)
378 return rc; 400 return rc;
379 401
402 rc = -EINVAL;
380 if (info->attrs[TASKSTATS_CMD_ATTR_PID]) { 403 if (info->attrs[TASKSTATS_CMD_ATTR_PID]) {
381 u32 pid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_PID]); 404 u32 pid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_PID]);
382 rc = fill_pid(pid, NULL, &stats); 405 stats = mk_reply(rep_skb, TASKSTATS_TYPE_PID, pid);
383 if (rc < 0) 406 if (!stats)
384 goto err; 407 goto err;
385 408
386 na = nla_nest_start(rep_skb, TASKSTATS_TYPE_AGGR_PID); 409 rc = fill_pid(pid, NULL, stats);
387 NLA_PUT_U32(rep_skb, TASKSTATS_TYPE_PID, pid); 410 if (rc < 0)
388 NLA_PUT_TYPE(rep_skb, struct taskstats, TASKSTATS_TYPE_STATS, 411 goto err;
389 stats);
390 } else if (info->attrs[TASKSTATS_CMD_ATTR_TGID]) { 412 } else if (info->attrs[TASKSTATS_CMD_ATTR_TGID]) {
391 u32 tgid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_TGID]); 413 u32 tgid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_TGID]);
392 rc = fill_tgid(tgid, NULL, &stats); 414 stats = mk_reply(rep_skb, TASKSTATS_TYPE_TGID, tgid);
393 if (rc < 0) 415 if (!stats)
394 goto err; 416 goto err;
395 417
396 na = nla_nest_start(rep_skb, TASKSTATS_TYPE_AGGR_TGID); 418 rc = fill_tgid(tgid, NULL, stats);
397 NLA_PUT_U32(rep_skb, TASKSTATS_TYPE_TGID, tgid); 419 if (rc < 0)
398 NLA_PUT_TYPE(rep_skb, struct taskstats, TASKSTATS_TYPE_STATS, 420 goto err;
399 stats); 421 } else
400 } else {
401 rc = -EINVAL;
402 goto err; 422 goto err;
403 }
404
405 nla_nest_end(rep_skb, na);
406 423
407 return send_reply(rep_skb, info->snd_pid); 424 return send_reply(rep_skb, info->snd_pid);
408
409nla_put_failure:
410 rc = genlmsg_cancel(rep_skb, reply);
411err: 425err:
412 nlmsg_free(rep_skb); 426 nlmsg_free(rep_skb);
413 return rc; 427 return rc;
414} 428}
415 429
416void taskstats_exit_alloc(struct taskstats **ptidstats, unsigned int *mycpu) 430static struct taskstats *taskstats_tgid_alloc(struct task_struct *tsk)
417{ 431{
418 struct listener_list *listeners; 432 struct signal_struct *sig = tsk->signal;
419 struct taskstats *tmp; 433 struct taskstats *stats;
420 /*
421 * This is the cpu on which the task is exiting currently and will
422 * be the one for which the exit event is sent, even if the cpu
423 * on which this function is running changes later.
424 */
425 *mycpu = raw_smp_processor_id();
426 434
427 *ptidstats = NULL; 435 if (sig->stats || thread_group_empty(tsk))
428 tmp = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL); 436 goto ret;
429 if (!tmp)
430 return;
431 437
432 listeners = &per_cpu(listener_array, *mycpu); 438 /* No problem if kmem_cache_zalloc() fails */
433 down_read(&listeners->sem); 439 stats = kmem_cache_zalloc(taskstats_cache, GFP_KERNEL);
434 if (!list_empty(&listeners->list)) { 440
435 *ptidstats = tmp; 441 spin_lock_irq(&tsk->sighand->siglock);
436 tmp = NULL; 442 if (!sig->stats) {
443 sig->stats = stats;
444 stats = NULL;
437 } 445 }
438 up_read(&listeners->sem); 446 spin_unlock_irq(&tsk->sighand->siglock);
439 kfree(tmp); 447
448 if (stats)
449 kmem_cache_free(taskstats_cache, stats);
450ret:
451 return sig->stats;
440} 452}
441 453
442/* Send pid data out on exit */ 454/* Send pid data out on exit */
443void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats, 455void taskstats_exit(struct task_struct *tsk, int group_dead)
444 int group_dead, unsigned int mycpu)
445{ 456{
446 int rc; 457 int rc;
458 struct listener_list *listeners;
459 struct taskstats *stats;
447 struct sk_buff *rep_skb; 460 struct sk_buff *rep_skb;
448 void *reply;
449 size_t size; 461 size_t size;
450 int is_thread_group; 462 int is_thread_group;
451 struct nlattr *na;
452 463
453 if (!family_registered) 464 if (!family_registered)
454 return; 465 return;
@@ -459,7 +470,7 @@ void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats,
459 size = nla_total_size(sizeof(u32)) + 470 size = nla_total_size(sizeof(u32)) +
460 nla_total_size(sizeof(struct taskstats)) + nla_total_size(0); 471 nla_total_size(sizeof(struct taskstats)) + nla_total_size(0);
461 472
462 is_thread_group = (tsk->signal->stats != NULL); 473 is_thread_group = !!taskstats_tgid_alloc(tsk);
463 if (is_thread_group) { 474 if (is_thread_group) {
464 /* PID + STATS + TGID + STATS */ 475 /* PID + STATS + TGID + STATS */
465 size = 2 * size; 476 size = 2 * size;
@@ -467,49 +478,39 @@ void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats,
467 fill_tgid_exit(tsk); 478 fill_tgid_exit(tsk);
468 } 479 }
469 480
470 if (!tidstats) 481 listeners = &__raw_get_cpu_var(listener_array);
482 if (list_empty(&listeners->list))
471 return; 483 return;
472 484
473 rc = prepare_reply(NULL, TASKSTATS_CMD_NEW, &rep_skb, &reply, size); 485 rc = prepare_reply(NULL, TASKSTATS_CMD_NEW, &rep_skb, size);
474 if (rc < 0)
475 goto ret;
476
477 rc = fill_pid(tsk->pid, tsk, tidstats);
478 if (rc < 0) 486 if (rc < 0)
479 goto err_skb; 487 return;
480 488
481 na = nla_nest_start(rep_skb, TASKSTATS_TYPE_AGGR_PID); 489 stats = mk_reply(rep_skb, TASKSTATS_TYPE_PID, tsk->pid);
482 NLA_PUT_U32(rep_skb, TASKSTATS_TYPE_PID, (u32)tsk->pid); 490 if (!stats)
483 NLA_PUT_TYPE(rep_skb, struct taskstats, TASKSTATS_TYPE_STATS, 491 goto err;
484 *tidstats);
485 nla_nest_end(rep_skb, na);
486 492
487 if (!is_thread_group) 493 rc = fill_pid(tsk->pid, tsk, stats);
488 goto send; 494 if (rc < 0)
495 goto err;
489 496
490 /* 497 /*
491 * Doesn't matter if tsk is the leader or the last group member leaving 498 * Doesn't matter if tsk is the leader or the last group member leaving
492 */ 499 */
493 if (!group_dead) 500 if (!is_thread_group || !group_dead)
494 goto send; 501 goto send;
495 502
496 na = nla_nest_start(rep_skb, TASKSTATS_TYPE_AGGR_TGID); 503 stats = mk_reply(rep_skb, TASKSTATS_TYPE_TGID, tsk->tgid);
497 NLA_PUT_U32(rep_skb, TASKSTATS_TYPE_TGID, (u32)tsk->tgid); 504 if (!stats)
498 /* No locking needed for tsk->signal->stats since group is dead */ 505 goto err;
499 NLA_PUT_TYPE(rep_skb, struct taskstats, TASKSTATS_TYPE_STATS, 506
500 *tsk->signal->stats); 507 memcpy(stats, tsk->signal->stats, sizeof(*stats));
501 nla_nest_end(rep_skb, na);
502 508
503send: 509send:
504 send_cpu_listeners(rep_skb, mycpu); 510 send_cpu_listeners(rep_skb, listeners);
505 return; 511 return;
506 512err:
507nla_put_failure:
508 genlmsg_cancel(rep_skb, reply);
509err_skb:
510 nlmsg_free(rep_skb); 513 nlmsg_free(rep_skb);
511ret:
512 return;
513} 514}
514 515
515static struct genl_ops taskstats_ops = { 516static struct genl_ops taskstats_ops = {
diff --git a/kernel/user.c b/kernel/user.c
index 220e586127a0..4869563080e9 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -26,7 +26,7 @@
26#define __uidhashfn(uid) (((uid >> UIDHASH_BITS) + uid) & UIDHASH_MASK) 26#define __uidhashfn(uid) (((uid >> UIDHASH_BITS) + uid) & UIDHASH_MASK)
27#define uidhashentry(uid) (uidhash_table + __uidhashfn((uid))) 27#define uidhashentry(uid) (uidhash_table + __uidhashfn((uid)))
28 28
29static kmem_cache_t *uid_cachep; 29static struct kmem_cache *uid_cachep;
30static struct list_head uidhash_table[UIDHASH_SZ]; 30static struct list_head uidhash_table[UIDHASH_SZ];
31 31
32/* 32/*
@@ -132,7 +132,7 @@ struct user_struct * alloc_uid(uid_t uid)
132 if (!up) { 132 if (!up) {
133 struct user_struct *new; 133 struct user_struct *new;
134 134
135 new = kmem_cache_alloc(uid_cachep, SLAB_KERNEL); 135 new = kmem_cache_alloc(uid_cachep, GFP_KERNEL);
136 if (!new) 136 if (!new)
137 return NULL; 137 return NULL;
138 new->uid = uid; 138 new->uid = uid;
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 17c2f03d2c27..c5257316f4b9 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -29,6 +29,9 @@
29#include <linux/kthread.h> 29#include <linux/kthread.h>
30#include <linux/hardirq.h> 30#include <linux/hardirq.h>
31#include <linux/mempolicy.h> 31#include <linux/mempolicy.h>
32#include <linux/freezer.h>
33#include <linux/kallsyms.h>
34#include <linux/debug_locks.h>
32 35
33/* 36/*
34 * The per-CPU workqueue (if single thread, we always use the first 37 * The per-CPU workqueue (if single thread, we always use the first
@@ -55,6 +58,8 @@ struct cpu_workqueue_struct {
55 struct task_struct *thread; 58 struct task_struct *thread;
56 59
57 int run_depth; /* Detect run_workqueue() recursion depth */ 60 int run_depth; /* Detect run_workqueue() recursion depth */
61
62 int freezeable; /* Freeze the thread during suspend */
58} ____cacheline_aligned; 63} ____cacheline_aligned;
59 64
60/* 65/*
@@ -80,6 +85,29 @@ static inline int is_single_threaded(struct workqueue_struct *wq)
80 return list_empty(&wq->list); 85 return list_empty(&wq->list);
81} 86}
82 87
88static inline void set_wq_data(struct work_struct *work, void *wq)
89{
90 unsigned long new, old, res;
91
92 /* assume the pending flag is already set and that the task has already
93 * been queued on this workqueue */
94 new = (unsigned long) wq | (1UL << WORK_STRUCT_PENDING);
95 res = work->management;
96 if (res != new) {
97 do {
98 old = res;
99 new = (unsigned long) wq;
100 new |= (old & WORK_STRUCT_FLAG_MASK);
101 res = cmpxchg(&work->management, old, new);
102 } while (res != old);
103 }
104}
105
106static inline void *get_wq_data(struct work_struct *work)
107{
108 return (void *) (work->management & WORK_STRUCT_WQ_DATA_MASK);
109}
110
83/* Preempt must be disabled. */ 111/* Preempt must be disabled. */
84static void __queue_work(struct cpu_workqueue_struct *cwq, 112static void __queue_work(struct cpu_workqueue_struct *cwq,
85 struct work_struct *work) 113 struct work_struct *work)
@@ -87,7 +115,7 @@ static void __queue_work(struct cpu_workqueue_struct *cwq,
87 unsigned long flags; 115 unsigned long flags;
88 116
89 spin_lock_irqsave(&cwq->lock, flags); 117 spin_lock_irqsave(&cwq->lock, flags);
90 work->wq_data = cwq; 118 set_wq_data(work, cwq);
91 list_add_tail(&work->entry, &cwq->worklist); 119 list_add_tail(&work->entry, &cwq->worklist);
92 cwq->insert_sequence++; 120 cwq->insert_sequence++;
93 wake_up(&cwq->more_work); 121 wake_up(&cwq->more_work);
@@ -108,7 +136,7 @@ int fastcall queue_work(struct workqueue_struct *wq, struct work_struct *work)
108{ 136{
109 int ret = 0, cpu = get_cpu(); 137 int ret = 0, cpu = get_cpu();
110 138
111 if (!test_and_set_bit(0, &work->pending)) { 139 if (!test_and_set_bit(WORK_STRUCT_PENDING, &work->management)) {
112 if (unlikely(is_single_threaded(wq))) 140 if (unlikely(is_single_threaded(wq)))
113 cpu = singlethread_cpu; 141 cpu = singlethread_cpu;
114 BUG_ON(!list_empty(&work->entry)); 142 BUG_ON(!list_empty(&work->entry));
@@ -122,38 +150,42 @@ EXPORT_SYMBOL_GPL(queue_work);
122 150
123static void delayed_work_timer_fn(unsigned long __data) 151static void delayed_work_timer_fn(unsigned long __data)
124{ 152{
125 struct work_struct *work = (struct work_struct *)__data; 153 struct delayed_work *dwork = (struct delayed_work *)__data;
126 struct workqueue_struct *wq = work->wq_data; 154 struct workqueue_struct *wq = get_wq_data(&dwork->work);
127 int cpu = smp_processor_id(); 155 int cpu = smp_processor_id();
128 156
129 if (unlikely(is_single_threaded(wq))) 157 if (unlikely(is_single_threaded(wq)))
130 cpu = singlethread_cpu; 158 cpu = singlethread_cpu;
131 159
132 __queue_work(per_cpu_ptr(wq->cpu_wq, cpu), work); 160 __queue_work(per_cpu_ptr(wq->cpu_wq, cpu), &dwork->work);
133} 161}
134 162
135/** 163/**
136 * queue_delayed_work - queue work on a workqueue after delay 164 * queue_delayed_work - queue work on a workqueue after delay
137 * @wq: workqueue to use 165 * @wq: workqueue to use
138 * @work: work to queue 166 * @work: delayable work to queue
139 * @delay: number of jiffies to wait before queueing 167 * @delay: number of jiffies to wait before queueing
140 * 168 *
141 * Returns 0 if @work was already on a queue, non-zero otherwise. 169 * Returns 0 if @work was already on a queue, non-zero otherwise.
142 */ 170 */
143int fastcall queue_delayed_work(struct workqueue_struct *wq, 171int fastcall queue_delayed_work(struct workqueue_struct *wq,
144 struct work_struct *work, unsigned long delay) 172 struct delayed_work *dwork, unsigned long delay)
145{ 173{
146 int ret = 0; 174 int ret = 0;
147 struct timer_list *timer = &work->timer; 175 struct timer_list *timer = &dwork->timer;
176 struct work_struct *work = &dwork->work;
177
178 if (delay == 0)
179 return queue_work(wq, work);
148 180
149 if (!test_and_set_bit(0, &work->pending)) { 181 if (!test_and_set_bit(WORK_STRUCT_PENDING, &work->management)) {
150 BUG_ON(timer_pending(timer)); 182 BUG_ON(timer_pending(timer));
151 BUG_ON(!list_empty(&work->entry)); 183 BUG_ON(!list_empty(&work->entry));
152 184
153 /* This stores wq for the moment, for the timer_fn */ 185 /* This stores wq for the moment, for the timer_fn */
154 work->wq_data = wq; 186 set_wq_data(work, wq);
155 timer->expires = jiffies + delay; 187 timer->expires = jiffies + delay;
156 timer->data = (unsigned long)work; 188 timer->data = (unsigned long)dwork;
157 timer->function = delayed_work_timer_fn; 189 timer->function = delayed_work_timer_fn;
158 add_timer(timer); 190 add_timer(timer);
159 ret = 1; 191 ret = 1;
@@ -172,19 +204,20 @@ EXPORT_SYMBOL_GPL(queue_delayed_work);
172 * Returns 0 if @work was already on a queue, non-zero otherwise. 204 * Returns 0 if @work was already on a queue, non-zero otherwise.
173 */ 205 */
174int queue_delayed_work_on(int cpu, struct workqueue_struct *wq, 206int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
175 struct work_struct *work, unsigned long delay) 207 struct delayed_work *dwork, unsigned long delay)
176{ 208{
177 int ret = 0; 209 int ret = 0;
178 struct timer_list *timer = &work->timer; 210 struct timer_list *timer = &dwork->timer;
211 struct work_struct *work = &dwork->work;
179 212
180 if (!test_and_set_bit(0, &work->pending)) { 213 if (!test_and_set_bit(WORK_STRUCT_PENDING, &work->management)) {
181 BUG_ON(timer_pending(timer)); 214 BUG_ON(timer_pending(timer));
182 BUG_ON(!list_empty(&work->entry)); 215 BUG_ON(!list_empty(&work->entry));
183 216
184 /* This stores wq for the moment, for the timer_fn */ 217 /* This stores wq for the moment, for the timer_fn */
185 work->wq_data = wq; 218 set_wq_data(work, wq);
186 timer->expires = jiffies + delay; 219 timer->expires = jiffies + delay;
187 timer->data = (unsigned long)work; 220 timer->data = (unsigned long)dwork;
188 timer->function = delayed_work_timer_fn; 221 timer->function = delayed_work_timer_fn;
189 add_timer_on(timer, cpu); 222 add_timer_on(timer, cpu);
190 ret = 1; 223 ret = 1;
@@ -212,15 +245,26 @@ static void run_workqueue(struct cpu_workqueue_struct *cwq)
212 while (!list_empty(&cwq->worklist)) { 245 while (!list_empty(&cwq->worklist)) {
213 struct work_struct *work = list_entry(cwq->worklist.next, 246 struct work_struct *work = list_entry(cwq->worklist.next,
214 struct work_struct, entry); 247 struct work_struct, entry);
215 void (*f) (void *) = work->func; 248 work_func_t f = work->func;
216 void *data = work->data;
217 249
218 list_del_init(cwq->worklist.next); 250 list_del_init(cwq->worklist.next);
219 spin_unlock_irqrestore(&cwq->lock, flags); 251 spin_unlock_irqrestore(&cwq->lock, flags);
220 252
221 BUG_ON(work->wq_data != cwq); 253 BUG_ON(get_wq_data(work) != cwq);
222 clear_bit(0, &work->pending); 254 if (!test_bit(WORK_STRUCT_NOAUTOREL, &work->management))
223 f(data); 255 work_release(work);
256 f(work);
257
258 if (unlikely(in_atomic() || lockdep_depth(current) > 0)) {
259 printk(KERN_ERR "BUG: workqueue leaked lock or atomic: "
260 "%s/0x%08x/%d\n",
261 current->comm, preempt_count(),
262 current->pid);
263 printk(KERN_ERR " last function: ");
264 print_symbol("%s\n", (unsigned long)f);
265 debug_show_held_locks(current);
266 dump_stack();
267 }
224 268
225 spin_lock_irqsave(&cwq->lock, flags); 269 spin_lock_irqsave(&cwq->lock, flags);
226 cwq->remove_sequence++; 270 cwq->remove_sequence++;
@@ -237,7 +281,8 @@ static int worker_thread(void *__cwq)
237 struct k_sigaction sa; 281 struct k_sigaction sa;
238 sigset_t blocked; 282 sigset_t blocked;
239 283
240 current->flags |= PF_NOFREEZE; 284 if (!cwq->freezeable)
285 current->flags |= PF_NOFREEZE;
241 286
242 set_user_nice(current, -5); 287 set_user_nice(current, -5);
243 288
@@ -260,6 +305,9 @@ static int worker_thread(void *__cwq)
260 305
261 set_current_state(TASK_INTERRUPTIBLE); 306 set_current_state(TASK_INTERRUPTIBLE);
262 while (!kthread_should_stop()) { 307 while (!kthread_should_stop()) {
308 if (cwq->freezeable)
309 try_to_freeze();
310
263 add_wait_queue(&cwq->more_work, &wait); 311 add_wait_queue(&cwq->more_work, &wait);
264 if (list_empty(&cwq->worklist)) 312 if (list_empty(&cwq->worklist))
265 schedule(); 313 schedule();
@@ -336,7 +384,7 @@ void fastcall flush_workqueue(struct workqueue_struct *wq)
336EXPORT_SYMBOL_GPL(flush_workqueue); 384EXPORT_SYMBOL_GPL(flush_workqueue);
337 385
338static struct task_struct *create_workqueue_thread(struct workqueue_struct *wq, 386static struct task_struct *create_workqueue_thread(struct workqueue_struct *wq,
339 int cpu) 387 int cpu, int freezeable)
340{ 388{
341 struct cpu_workqueue_struct *cwq = per_cpu_ptr(wq->cpu_wq, cpu); 389 struct cpu_workqueue_struct *cwq = per_cpu_ptr(wq->cpu_wq, cpu);
342 struct task_struct *p; 390 struct task_struct *p;
@@ -346,6 +394,7 @@ static struct task_struct *create_workqueue_thread(struct workqueue_struct *wq,
346 cwq->thread = NULL; 394 cwq->thread = NULL;
347 cwq->insert_sequence = 0; 395 cwq->insert_sequence = 0;
348 cwq->remove_sequence = 0; 396 cwq->remove_sequence = 0;
397 cwq->freezeable = freezeable;
349 INIT_LIST_HEAD(&cwq->worklist); 398 INIT_LIST_HEAD(&cwq->worklist);
350 init_waitqueue_head(&cwq->more_work); 399 init_waitqueue_head(&cwq->more_work);
351 init_waitqueue_head(&cwq->work_done); 400 init_waitqueue_head(&cwq->work_done);
@@ -361,7 +410,7 @@ static struct task_struct *create_workqueue_thread(struct workqueue_struct *wq,
361} 410}
362 411
363struct workqueue_struct *__create_workqueue(const char *name, 412struct workqueue_struct *__create_workqueue(const char *name,
364 int singlethread) 413 int singlethread, int freezeable)
365{ 414{
366 int cpu, destroy = 0; 415 int cpu, destroy = 0;
367 struct workqueue_struct *wq; 416 struct workqueue_struct *wq;
@@ -381,7 +430,7 @@ struct workqueue_struct *__create_workqueue(const char *name,
381 mutex_lock(&workqueue_mutex); 430 mutex_lock(&workqueue_mutex);
382 if (singlethread) { 431 if (singlethread) {
383 INIT_LIST_HEAD(&wq->list); 432 INIT_LIST_HEAD(&wq->list);
384 p = create_workqueue_thread(wq, singlethread_cpu); 433 p = create_workqueue_thread(wq, singlethread_cpu, freezeable);
385 if (!p) 434 if (!p)
386 destroy = 1; 435 destroy = 1;
387 else 436 else
@@ -389,7 +438,7 @@ struct workqueue_struct *__create_workqueue(const char *name,
389 } else { 438 } else {
390 list_add(&wq->list, &workqueues); 439 list_add(&wq->list, &workqueues);
391 for_each_online_cpu(cpu) { 440 for_each_online_cpu(cpu) {
392 p = create_workqueue_thread(wq, cpu); 441 p = create_workqueue_thread(wq, cpu, freezeable);
393 if (p) { 442 if (p) {
394 kthread_bind(p, cpu); 443 kthread_bind(p, cpu);
395 wake_up_process(p); 444 wake_up_process(p);
@@ -468,38 +517,37 @@ EXPORT_SYMBOL(schedule_work);
468 517
469/** 518/**
470 * schedule_delayed_work - put work task in global workqueue after delay 519 * schedule_delayed_work - put work task in global workqueue after delay
471 * @work: job to be done 520 * @dwork: job to be done
472 * @delay: number of jiffies to wait 521 * @delay: number of jiffies to wait or 0 for immediate execution
473 * 522 *
474 * After waiting for a given time this puts a job in the kernel-global 523 * After waiting for a given time this puts a job in the kernel-global
475 * workqueue. 524 * workqueue.
476 */ 525 */
477int fastcall schedule_delayed_work(struct work_struct *work, unsigned long delay) 526int fastcall schedule_delayed_work(struct delayed_work *dwork, unsigned long delay)
478{ 527{
479 return queue_delayed_work(keventd_wq, work, delay); 528 return queue_delayed_work(keventd_wq, dwork, delay);
480} 529}
481EXPORT_SYMBOL(schedule_delayed_work); 530EXPORT_SYMBOL(schedule_delayed_work);
482 531
483/** 532/**
484 * schedule_delayed_work_on - queue work in global workqueue on CPU after delay 533 * schedule_delayed_work_on - queue work in global workqueue on CPU after delay
485 * @cpu: cpu to use 534 * @cpu: cpu to use
486 * @work: job to be done 535 * @dwork: job to be done
487 * @delay: number of jiffies to wait 536 * @delay: number of jiffies to wait
488 * 537 *
489 * After waiting for a given time this puts a job in the kernel-global 538 * After waiting for a given time this puts a job in the kernel-global
490 * workqueue on the specified CPU. 539 * workqueue on the specified CPU.
491 */ 540 */
492int schedule_delayed_work_on(int cpu, 541int schedule_delayed_work_on(int cpu,
493 struct work_struct *work, unsigned long delay) 542 struct delayed_work *dwork, unsigned long delay)
494{ 543{
495 return queue_delayed_work_on(cpu, keventd_wq, work, delay); 544 return queue_delayed_work_on(cpu, keventd_wq, dwork, delay);
496} 545}
497EXPORT_SYMBOL(schedule_delayed_work_on); 546EXPORT_SYMBOL(schedule_delayed_work_on);
498 547
499/** 548/**
500 * schedule_on_each_cpu - call a function on each online CPU from keventd 549 * schedule_on_each_cpu - call a function on each online CPU from keventd
501 * @func: the function to call 550 * @func: the function to call
502 * @info: a pointer to pass to func()
503 * 551 *
504 * Returns zero on success. 552 * Returns zero on success.
505 * Returns -ve errno on failure. 553 * Returns -ve errno on failure.
@@ -508,7 +556,7 @@ EXPORT_SYMBOL(schedule_delayed_work_on);
508 * 556 *
509 * schedule_on_each_cpu() is very slow. 557 * schedule_on_each_cpu() is very slow.
510 */ 558 */
511int schedule_on_each_cpu(void (*func)(void *info), void *info) 559int schedule_on_each_cpu(work_func_t func)
512{ 560{
513 int cpu; 561 int cpu;
514 struct work_struct *works; 562 struct work_struct *works;
@@ -519,7 +567,7 @@ int schedule_on_each_cpu(void (*func)(void *info), void *info)
519 567
520 mutex_lock(&workqueue_mutex); 568 mutex_lock(&workqueue_mutex);
521 for_each_online_cpu(cpu) { 569 for_each_online_cpu(cpu) {
522 INIT_WORK(per_cpu_ptr(works, cpu), func, info); 570 INIT_WORK(per_cpu_ptr(works, cpu), func);
523 __queue_work(per_cpu_ptr(keventd_wq->cpu_wq, cpu), 571 __queue_work(per_cpu_ptr(keventd_wq->cpu_wq, cpu),
524 per_cpu_ptr(works, cpu)); 572 per_cpu_ptr(works, cpu));
525 } 573 }
@@ -539,12 +587,12 @@ EXPORT_SYMBOL(flush_scheduled_work);
539 * cancel_rearming_delayed_workqueue - reliably kill off a delayed 587 * cancel_rearming_delayed_workqueue - reliably kill off a delayed
540 * work whose handler rearms the delayed work. 588 * work whose handler rearms the delayed work.
541 * @wq: the controlling workqueue structure 589 * @wq: the controlling workqueue structure
542 * @work: the delayed work struct 590 * @dwork: the delayed work struct
543 */ 591 */
544void cancel_rearming_delayed_workqueue(struct workqueue_struct *wq, 592void cancel_rearming_delayed_workqueue(struct workqueue_struct *wq,
545 struct work_struct *work) 593 struct delayed_work *dwork)
546{ 594{
547 while (!cancel_delayed_work(work)) 595 while (!cancel_delayed_work(dwork))
548 flush_workqueue(wq); 596 flush_workqueue(wq);
549} 597}
550EXPORT_SYMBOL(cancel_rearming_delayed_workqueue); 598EXPORT_SYMBOL(cancel_rearming_delayed_workqueue);
@@ -552,18 +600,17 @@ EXPORT_SYMBOL(cancel_rearming_delayed_workqueue);
552/** 600/**
553 * cancel_rearming_delayed_work - reliably kill off a delayed keventd 601 * cancel_rearming_delayed_work - reliably kill off a delayed keventd
554 * work whose handler rearms the delayed work. 602 * work whose handler rearms the delayed work.
555 * @work: the delayed work struct 603 * @dwork: the delayed work struct
556 */ 604 */
557void cancel_rearming_delayed_work(struct work_struct *work) 605void cancel_rearming_delayed_work(struct delayed_work *dwork)
558{ 606{
559 cancel_rearming_delayed_workqueue(keventd_wq, work); 607 cancel_rearming_delayed_workqueue(keventd_wq, dwork);
560} 608}
561EXPORT_SYMBOL(cancel_rearming_delayed_work); 609EXPORT_SYMBOL(cancel_rearming_delayed_work);
562 610
563/** 611/**
564 * execute_in_process_context - reliably execute the routine with user context 612 * execute_in_process_context - reliably execute the routine with user context
565 * @fn: the function to execute 613 * @fn: the function to execute
566 * @data: data to pass to the function
567 * @ew: guaranteed storage for the execute work structure (must 614 * @ew: guaranteed storage for the execute work structure (must
568 * be available when the work executes) 615 * be available when the work executes)
569 * 616 *
@@ -573,15 +620,14 @@ EXPORT_SYMBOL(cancel_rearming_delayed_work);
573 * Returns: 0 - function was executed 620 * Returns: 0 - function was executed
574 * 1 - function was scheduled for execution 621 * 1 - function was scheduled for execution
575 */ 622 */
576int execute_in_process_context(void (*fn)(void *data), void *data, 623int execute_in_process_context(work_func_t fn, struct execute_work *ew)
577 struct execute_work *ew)
578{ 624{
579 if (!in_interrupt()) { 625 if (!in_interrupt()) {
580 fn(data); 626 fn(&ew->work);
581 return 0; 627 return 0;
582 } 628 }
583 629
584 INIT_WORK(&ew->work, fn, data); 630 INIT_WORK(&ew->work, fn);
585 schedule_work(&ew->work); 631 schedule_work(&ew->work);
586 632
587 return 1; 633 return 1;
@@ -609,7 +655,6 @@ int current_is_keventd(void)
609 655
610} 656}
611 657
612#ifdef CONFIG_HOTPLUG_CPU
613/* Take the work from this (downed) CPU. */ 658/* Take the work from this (downed) CPU. */
614static void take_over_work(struct workqueue_struct *wq, unsigned int cpu) 659static void take_over_work(struct workqueue_struct *wq, unsigned int cpu)
615{ 660{
@@ -642,7 +687,7 @@ static int __devinit workqueue_cpu_callback(struct notifier_block *nfb,
642 mutex_lock(&workqueue_mutex); 687 mutex_lock(&workqueue_mutex);
643 /* Create a new workqueue thread for it. */ 688 /* Create a new workqueue thread for it. */
644 list_for_each_entry(wq, &workqueues, list) { 689 list_for_each_entry(wq, &workqueues, list) {
645 if (!create_workqueue_thread(wq, hotcpu)) { 690 if (!create_workqueue_thread(wq, hotcpu, 0)) {
646 printk("workqueue for %i failed\n", hotcpu); 691 printk("workqueue for %i failed\n", hotcpu);
647 return NOTIFY_BAD; 692 return NOTIFY_BAD;
648 } 693 }
@@ -692,7 +737,6 @@ static int __devinit workqueue_cpu_callback(struct notifier_block *nfb,
692 737
693 return NOTIFY_OK; 738 return NOTIFY_OK;
694} 739}
695#endif
696 740
697void init_workqueues(void) 741void init_workqueues(void)
698{ 742{
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index d3679103a8e4..b75fed737f25 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1,6 +1,7 @@
1 1
2config PRINTK_TIME 2config PRINTK_TIME
3 bool "Show timing information on printks" 3 bool "Show timing information on printks"
4 depends on PRINTK
4 help 5 help
5 Selecting this option causes timing information to be 6 Selecting this option causes timing information to be
6 included in printk output. This allows you to measure 7 included in printk output. This allows you to measure
diff --git a/lib/Makefile b/lib/Makefile
index cf98fabaa549..fea8f9035f07 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -25,7 +25,7 @@ lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
25lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o 25lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
26lib-$(CONFIG_SEMAPHORE_SLEEPERS) += semaphore-sleepers.o 26lib-$(CONFIG_SEMAPHORE_SLEEPERS) += semaphore-sleepers.o
27lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o 27lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o
28lib-$(CONFIG_GENERIC_HWEIGHT) += hweight.o 28obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
29obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o 29obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o
30obj-$(CONFIG_PLIST) += plist.o 30obj-$(CONFIG_PLIST) += plist.o
31obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o 31obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
diff --git a/lib/cmdline.c b/lib/cmdline.c
index 0331ed825ea7..8a5b5303bd4f 100644
--- a/lib/cmdline.c
+++ b/lib/cmdline.c
@@ -16,6 +16,23 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/string.h> 17#include <linux/string.h>
18 18
19/*
20 * If a hyphen was found in get_option, this will handle the
21 * range of numbers, M-N. This will expand the range and insert
22 * the values[M, M+1, ..., N] into the ints array in get_options.
23 */
24
25static int get_range(char **str, int *pint)
26{
27 int x, inc_counter, upper_range;
28
29 (*str)++;
30 upper_range = simple_strtol((*str), NULL, 0);
31 inc_counter = upper_range - *pint;
32 for (x = *pint; x < upper_range; x++)
33 *pint++ = x;
34 return inc_counter;
35}
19 36
20/** 37/**
21 * get_option - Parse integer from an option string 38 * get_option - Parse integer from an option string
@@ -29,6 +46,7 @@
29 * 0 : no int in string 46 * 0 : no int in string
30 * 1 : int found, no subsequent comma 47 * 1 : int found, no subsequent comma
31 * 2 : int found including a subsequent comma 48 * 2 : int found including a subsequent comma
49 * 3 : hyphen found to denote a range
32 */ 50 */
33 51
34int get_option (char **str, int *pint) 52int get_option (char **str, int *pint)
@@ -44,6 +62,8 @@ int get_option (char **str, int *pint)
44 (*str)++; 62 (*str)++;
45 return 2; 63 return 2;
46 } 64 }
65 if (**str == '-')
66 return 3;
47 67
48 return 1; 68 return 1;
49} 69}
@@ -55,7 +75,8 @@ int get_option (char **str, int *pint)
55 * @ints: integer array 75 * @ints: integer array
56 * 76 *
57 * This function parses a string containing a comma-separated 77 * This function parses a string containing a comma-separated
58 * list of integers. The parse halts when the array is 78 * list of integers, a hyphen-separated range of _positive_ integers,
79 * or a combination of both. The parse halts when the array is
59 * full, or when no more numbers can be retrieved from the 80 * full, or when no more numbers can be retrieved from the
60 * string. 81 * string.
61 * 82 *
@@ -72,6 +93,18 @@ char *get_options(const char *str, int nints, int *ints)
72 res = get_option ((char **)&str, ints + i); 93 res = get_option ((char **)&str, ints + i);
73 if (res == 0) 94 if (res == 0)
74 break; 95 break;
96 if (res == 3) {
97 int range_nums;
98 range_nums = get_range((char **)&str, ints + i);
99 if (range_nums < 0)
100 break;
101 /*
102 * Decrement the result by one to leave out the
103 * last number in the range. The next iteration
104 * will handle the upper number in the range
105 */
106 i += (range_nums - 1);
107 }
75 i++; 108 i++;
76 if (res == 1) 109 if (res == 1)
77 break; 110 break;
diff --git a/lib/idr.c b/lib/idr.c
index 16d2143fea48..71853531d3b0 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -33,7 +33,7 @@
33#include <linux/string.h> 33#include <linux/string.h>
34#include <linux/idr.h> 34#include <linux/idr.h>
35 35
36static kmem_cache_t *idr_layer_cache; 36static struct kmem_cache *idr_layer_cache;
37 37
38static struct idr_layer *alloc_layer(struct idr *idp) 38static struct idr_layer *alloc_layer(struct idr *idp)
39{ 39{
@@ -445,7 +445,7 @@ void *idr_replace(struct idr *idp, void *ptr, int id)
445} 445}
446EXPORT_SYMBOL(idr_replace); 446EXPORT_SYMBOL(idr_replace);
447 447
448static void idr_cache_ctor(void * idr_layer, kmem_cache_t *idr_layer_cache, 448static void idr_cache_ctor(void * idr_layer, struct kmem_cache *idr_layer_cache,
449 unsigned long flags) 449 unsigned long flags)
450{ 450{
451 memset(idr_layer, 0, sizeof(struct idr_layer)); 451 memset(idr_layer, 0, sizeof(struct idr_layer));
diff --git a/lib/kobject.c b/lib/kobject.c
index 744a4b102c7f..7ce6dc138e90 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -111,10 +111,9 @@ char *kobject_get_path(struct kobject *kobj, gfp_t gfp_mask)
111 len = get_kobj_path_length(kobj); 111 len = get_kobj_path_length(kobj);
112 if (len == 0) 112 if (len == 0)
113 return NULL; 113 return NULL;
114 path = kmalloc(len, gfp_mask); 114 path = kzalloc(len, gfp_mask);
115 if (!path) 115 if (!path)
116 return NULL; 116 return NULL;
117 memset(path, 0x00, len);
118 fill_kobj_path(kobj, path, len); 117 fill_kobj_path(kobj, path, len);
119 118
120 return path; 119 return path;
diff --git a/lib/list_debug.c b/lib/list_debug.c
index 7ba9d823d388..4350ba9655bd 100644
--- a/lib/list_debug.c
+++ b/lib/list_debug.c
@@ -21,13 +21,15 @@ void __list_add(struct list_head *new,
21 struct list_head *next) 21 struct list_head *next)
22{ 22{
23 if (unlikely(next->prev != prev)) { 23 if (unlikely(next->prev != prev)) {
24 printk(KERN_ERR "list_add corruption. next->prev should be %p, but was %p\n", 24 printk(KERN_ERR "list_add corruption. next->prev should be "
25 prev, next->prev); 25 "prev (%p), but was %p. (next=%p).\n",
26 prev, next->prev, next);
26 BUG(); 27 BUG();
27 } 28 }
28 if (unlikely(prev->next != next)) { 29 if (unlikely(prev->next != next)) {
29 printk(KERN_ERR "list_add corruption. prev->next should be %p, but was %p\n", 30 printk(KERN_ERR "list_add corruption. prev->next should be "
30 next, prev->next); 31 "next (%p), but was %p. (prev=%p).\n",
32 next, prev->next, prev);
31 BUG(); 33 BUG();
32 } 34 }
33 next->prev = new; 35 next->prev = new;
diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index 7945787f439a..280332c1827c 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -963,7 +963,9 @@ static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask)
963 printk("failed|"); 963 printk("failed|");
964 } else { 964 } else {
965 unexpected_testcase_failures++; 965 unexpected_testcase_failures++;
966
966 printk("FAILED|"); 967 printk("FAILED|");
968 dump_stack();
967 } 969 }
968 } else { 970 } else {
969 testcase_successes++; 971 testcase_successes++;
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index aa9bfd0bdbd1..d69ddbe43865 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -2,6 +2,7 @@
2 * Copyright (C) 2001 Momchil Velikov 2 * Copyright (C) 2001 Momchil Velikov
3 * Portions Copyright (C) 2001 Christoph Hellwig 3 * Portions Copyright (C) 2001 Christoph Hellwig
4 * Copyright (C) 2005 SGI, Christoph Lameter <clameter@sgi.com> 4 * Copyright (C) 2005 SGI, Christoph Lameter <clameter@sgi.com>
5 * Copyright (C) 2006 Nick Piggin
5 * 6 *
6 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as 8 * modify it under the terms of the GNU General Public License as
@@ -30,6 +31,7 @@
30#include <linux/gfp.h> 31#include <linux/gfp.h>
31#include <linux/string.h> 32#include <linux/string.h>
32#include <linux/bitops.h> 33#include <linux/bitops.h>
34#include <linux/rcupdate.h>
33 35
34 36
35#ifdef __KERNEL__ 37#ifdef __KERNEL__
@@ -45,7 +47,9 @@
45 ((RADIX_TREE_MAP_SIZE + BITS_PER_LONG - 1) / BITS_PER_LONG) 47 ((RADIX_TREE_MAP_SIZE + BITS_PER_LONG - 1) / BITS_PER_LONG)
46 48
47struct radix_tree_node { 49struct radix_tree_node {
50 unsigned int height; /* Height from the bottom */
48 unsigned int count; 51 unsigned int count;
52 struct rcu_head rcu_head;
49 void *slots[RADIX_TREE_MAP_SIZE]; 53 void *slots[RADIX_TREE_MAP_SIZE];
50 unsigned long tags[RADIX_TREE_MAX_TAGS][RADIX_TREE_TAG_LONGS]; 54 unsigned long tags[RADIX_TREE_MAX_TAGS][RADIX_TREE_TAG_LONGS];
51}; 55};
@@ -63,7 +67,7 @@ static unsigned long height_to_maxindex[RADIX_TREE_MAX_PATH] __read_mostly;
63/* 67/*
64 * Radix tree node cache. 68 * Radix tree node cache.
65 */ 69 */
66static kmem_cache_t *radix_tree_node_cachep; 70static struct kmem_cache *radix_tree_node_cachep;
67 71
68/* 72/*
69 * Per-cpu pool of preloaded nodes 73 * Per-cpu pool of preloaded nodes
@@ -100,13 +104,21 @@ radix_tree_node_alloc(struct radix_tree_root *root)
100 rtp->nr--; 104 rtp->nr--;
101 } 105 }
102 } 106 }
107 BUG_ON(radix_tree_is_direct_ptr(ret));
103 return ret; 108 return ret;
104} 109}
105 110
111static void radix_tree_node_rcu_free(struct rcu_head *head)
112{
113 struct radix_tree_node *node =
114 container_of(head, struct radix_tree_node, rcu_head);
115 kmem_cache_free(radix_tree_node_cachep, node);
116}
117
106static inline void 118static inline void
107radix_tree_node_free(struct radix_tree_node *node) 119radix_tree_node_free(struct radix_tree_node *node)
108{ 120{
109 kmem_cache_free(radix_tree_node_cachep, node); 121 call_rcu(&node->rcu_head, radix_tree_node_rcu_free);
110} 122}
111 123
112/* 124/*
@@ -222,11 +234,12 @@ static int radix_tree_extend(struct radix_tree_root *root, unsigned long index)
222 } 234 }
223 235
224 do { 236 do {
237 unsigned int newheight;
225 if (!(node = radix_tree_node_alloc(root))) 238 if (!(node = radix_tree_node_alloc(root)))
226 return -ENOMEM; 239 return -ENOMEM;
227 240
228 /* Increase the height. */ 241 /* Increase the height. */
229 node->slots[0] = root->rnode; 242 node->slots[0] = radix_tree_direct_to_ptr(root->rnode);
230 243
231 /* Propagate the aggregated tag info into the new root */ 244 /* Propagate the aggregated tag info into the new root */
232 for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) { 245 for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) {
@@ -234,9 +247,11 @@ static int radix_tree_extend(struct radix_tree_root *root, unsigned long index)
234 tag_set(node, tag, 0); 247 tag_set(node, tag, 0);
235 } 248 }
236 249
250 newheight = root->height+1;
251 node->height = newheight;
237 node->count = 1; 252 node->count = 1;
238 root->rnode = node; 253 rcu_assign_pointer(root->rnode, node);
239 root->height++; 254 root->height = newheight;
240 } while (height > root->height); 255 } while (height > root->height);
241out: 256out:
242 return 0; 257 return 0;
@@ -258,6 +273,8 @@ int radix_tree_insert(struct radix_tree_root *root,
258 int offset; 273 int offset;
259 int error; 274 int error;
260 275
276 BUG_ON(radix_tree_is_direct_ptr(item));
277
261 /* Make sure the tree is high enough. */ 278 /* Make sure the tree is high enough. */
262 if (index > radix_tree_maxindex(root->height)) { 279 if (index > radix_tree_maxindex(root->height)) {
263 error = radix_tree_extend(root, index); 280 error = radix_tree_extend(root, index);
@@ -275,11 +292,12 @@ int radix_tree_insert(struct radix_tree_root *root,
275 /* Have to add a child node. */ 292 /* Have to add a child node. */
276 if (!(slot = radix_tree_node_alloc(root))) 293 if (!(slot = radix_tree_node_alloc(root)))
277 return -ENOMEM; 294 return -ENOMEM;
295 slot->height = height;
278 if (node) { 296 if (node) {
279 node->slots[offset] = slot; 297 rcu_assign_pointer(node->slots[offset], slot);
280 node->count++; 298 node->count++;
281 } else 299 } else
282 root->rnode = slot; 300 rcu_assign_pointer(root->rnode, slot);
283 } 301 }
284 302
285 /* Go a level down */ 303 /* Go a level down */
@@ -295,11 +313,11 @@ int radix_tree_insert(struct radix_tree_root *root,
295 313
296 if (node) { 314 if (node) {
297 node->count++; 315 node->count++;
298 node->slots[offset] = item; 316 rcu_assign_pointer(node->slots[offset], item);
299 BUG_ON(tag_get(node, 0, offset)); 317 BUG_ON(tag_get(node, 0, offset));
300 BUG_ON(tag_get(node, 1, offset)); 318 BUG_ON(tag_get(node, 1, offset));
301 } else { 319 } else {
302 root->rnode = item; 320 rcu_assign_pointer(root->rnode, radix_tree_ptr_to_direct(item));
303 BUG_ON(root_tag_get(root, 0)); 321 BUG_ON(root_tag_get(root, 0));
304 BUG_ON(root_tag_get(root, 1)); 322 BUG_ON(root_tag_get(root, 1));
305 } 323 }
@@ -308,49 +326,54 @@ int radix_tree_insert(struct radix_tree_root *root,
308} 326}
309EXPORT_SYMBOL(radix_tree_insert); 327EXPORT_SYMBOL(radix_tree_insert);
310 328
311static inline void **__lookup_slot(struct radix_tree_root *root, 329/**
312 unsigned long index) 330 * radix_tree_lookup_slot - lookup a slot in a radix tree
331 * @root: radix tree root
332 * @index: index key
333 *
334 * Returns: the slot corresponding to the position @index in the
335 * radix tree @root. This is useful for update-if-exists operations.
336 *
337 * This function cannot be called under rcu_read_lock, it must be
338 * excluded from writers, as must the returned slot for subsequent
339 * use by radix_tree_deref_slot() and radix_tree_replace slot.
340 * Caller must hold tree write locked across slot lookup and
341 * replace.
342 */
343void **radix_tree_lookup_slot(struct radix_tree_root *root, unsigned long index)
313{ 344{
314 unsigned int height, shift; 345 unsigned int height, shift;
315 struct radix_tree_node **slot; 346 struct radix_tree_node *node, **slot;
316
317 height = root->height;
318 347
319 if (index > radix_tree_maxindex(height)) 348 node = root->rnode;
349 if (node == NULL)
320 return NULL; 350 return NULL;
321 351
322 if (height == 0 && root->rnode) 352 if (radix_tree_is_direct_ptr(node)) {
353 if (index > 0)
354 return NULL;
323 return (void **)&root->rnode; 355 return (void **)&root->rnode;
356 }
357
358 height = node->height;
359 if (index > radix_tree_maxindex(height))
360 return NULL;
324 361
325 shift = (height-1) * RADIX_TREE_MAP_SHIFT; 362 shift = (height-1) * RADIX_TREE_MAP_SHIFT;
326 slot = &root->rnode;
327 363
328 while (height > 0) { 364 do {
329 if (*slot == NULL) 365 slot = (struct radix_tree_node **)
366 (node->slots + ((index>>shift) & RADIX_TREE_MAP_MASK));
367 node = *slot;
368 if (node == NULL)
330 return NULL; 369 return NULL;
331 370
332 slot = (struct radix_tree_node **)
333 ((*slot)->slots +
334 ((index >> shift) & RADIX_TREE_MAP_MASK));
335 shift -= RADIX_TREE_MAP_SHIFT; 371 shift -= RADIX_TREE_MAP_SHIFT;
336 height--; 372 height--;
337 } 373 } while (height > 0);
338 374
339 return (void **)slot; 375 return (void **)slot;
340} 376}
341
342/**
343 * radix_tree_lookup_slot - lookup a slot in a radix tree
344 * @root: radix tree root
345 * @index: index key
346 *
347 * Lookup the slot corresponding to the position @index in the radix tree
348 * @root. This is useful for update-if-exists operations.
349 */
350void **radix_tree_lookup_slot(struct radix_tree_root *root, unsigned long index)
351{
352 return __lookup_slot(root, index);
353}
354EXPORT_SYMBOL(radix_tree_lookup_slot); 377EXPORT_SYMBOL(radix_tree_lookup_slot);
355 378
356/** 379/**
@@ -359,13 +382,45 @@ EXPORT_SYMBOL(radix_tree_lookup_slot);
359 * @index: index key 382 * @index: index key
360 * 383 *
361 * Lookup the item at the position @index in the radix tree @root. 384 * Lookup the item at the position @index in the radix tree @root.
385 *
386 * This function can be called under rcu_read_lock, however the caller
387 * must manage lifetimes of leaf nodes (eg. RCU may also be used to free
388 * them safely). No RCU barriers are required to access or modify the
389 * returned item, however.
362 */ 390 */
363void *radix_tree_lookup(struct radix_tree_root *root, unsigned long index) 391void *radix_tree_lookup(struct radix_tree_root *root, unsigned long index)
364{ 392{
365 void **slot; 393 unsigned int height, shift;
394 struct radix_tree_node *node, **slot;
395
396 node = rcu_dereference(root->rnode);
397 if (node == NULL)
398 return NULL;
399
400 if (radix_tree_is_direct_ptr(node)) {
401 if (index > 0)
402 return NULL;
403 return radix_tree_direct_to_ptr(node);
404 }
405
406 height = node->height;
407 if (index > radix_tree_maxindex(height))
408 return NULL;
409
410 shift = (height-1) * RADIX_TREE_MAP_SHIFT;
366 411
367 slot = __lookup_slot(root, index); 412 do {
368 return slot != NULL ? *slot : NULL; 413 slot = (struct radix_tree_node **)
414 (node->slots + ((index>>shift) & RADIX_TREE_MAP_MASK));
415 node = rcu_dereference(*slot);
416 if (node == NULL)
417 return NULL;
418
419 shift -= RADIX_TREE_MAP_SHIFT;
420 height--;
421 } while (height > 0);
422
423 return node;
369} 424}
370EXPORT_SYMBOL(radix_tree_lookup); 425EXPORT_SYMBOL(radix_tree_lookup);
371 426
@@ -495,27 +550,30 @@ int radix_tree_tag_get(struct radix_tree_root *root,
495 unsigned long index, unsigned int tag) 550 unsigned long index, unsigned int tag)
496{ 551{
497 unsigned int height, shift; 552 unsigned int height, shift;
498 struct radix_tree_node *slot; 553 struct radix_tree_node *node;
499 int saw_unset_tag = 0; 554 int saw_unset_tag = 0;
500 555
501 height = root->height;
502 if (index > radix_tree_maxindex(height))
503 return 0;
504
505 /* check the root's tag bit */ 556 /* check the root's tag bit */
506 if (!root_tag_get(root, tag)) 557 if (!root_tag_get(root, tag))
507 return 0; 558 return 0;
508 559
509 if (height == 0) 560 node = rcu_dereference(root->rnode);
510 return 1; 561 if (node == NULL)
562 return 0;
563
564 if (radix_tree_is_direct_ptr(node))
565 return (index == 0);
566
567 height = node->height;
568 if (index > radix_tree_maxindex(height))
569 return 0;
511 570
512 shift = (height - 1) * RADIX_TREE_MAP_SHIFT; 571 shift = (height - 1) * RADIX_TREE_MAP_SHIFT;
513 slot = root->rnode;
514 572
515 for ( ; ; ) { 573 for ( ; ; ) {
516 int offset; 574 int offset;
517 575
518 if (slot == NULL) 576 if (node == NULL)
519 return 0; 577 return 0;
520 578
521 offset = (index >> shift) & RADIX_TREE_MAP_MASK; 579 offset = (index >> shift) & RADIX_TREE_MAP_MASK;
@@ -524,15 +582,15 @@ int radix_tree_tag_get(struct radix_tree_root *root,
524 * This is just a debug check. Later, we can bale as soon as 582 * This is just a debug check. Later, we can bale as soon as
525 * we see an unset tag. 583 * we see an unset tag.
526 */ 584 */
527 if (!tag_get(slot, tag, offset)) 585 if (!tag_get(node, tag, offset))
528 saw_unset_tag = 1; 586 saw_unset_tag = 1;
529 if (height == 1) { 587 if (height == 1) {
530 int ret = tag_get(slot, tag, offset); 588 int ret = tag_get(node, tag, offset);
531 589
532 BUG_ON(ret && saw_unset_tag); 590 BUG_ON(ret && saw_unset_tag);
533 return !!ret; 591 return !!ret;
534 } 592 }
535 slot = slot->slots[offset]; 593 node = rcu_dereference(node->slots[offset]);
536 shift -= RADIX_TREE_MAP_SHIFT; 594 shift -= RADIX_TREE_MAP_SHIFT;
537 height--; 595 height--;
538 } 596 }
@@ -541,47 +599,45 @@ EXPORT_SYMBOL(radix_tree_tag_get);
541#endif 599#endif
542 600
543static unsigned int 601static unsigned int
544__lookup(struct radix_tree_root *root, void **results, unsigned long index, 602__lookup(struct radix_tree_node *slot, void **results, unsigned long index,
545 unsigned int max_items, unsigned long *next_index) 603 unsigned int max_items, unsigned long *next_index)
546{ 604{
547 unsigned int nr_found = 0; 605 unsigned int nr_found = 0;
548 unsigned int shift, height; 606 unsigned int shift, height;
549 struct radix_tree_node *slot;
550 unsigned long i; 607 unsigned long i;
551 608
552 height = root->height; 609 height = slot->height;
553 if (height == 0) { 610 if (height == 0)
554 if (root->rnode && index == 0)
555 results[nr_found++] = root->rnode;
556 goto out; 611 goto out;
557 }
558
559 shift = (height-1) * RADIX_TREE_MAP_SHIFT; 612 shift = (height-1) * RADIX_TREE_MAP_SHIFT;
560 slot = root->rnode;
561 613
562 for ( ; height > 1; height--) { 614 for ( ; height > 1; height--) {
563 615 i = (index >> shift) & RADIX_TREE_MAP_MASK;
564 for (i = (index >> shift) & RADIX_TREE_MAP_MASK ; 616 for (;;) {
565 i < RADIX_TREE_MAP_SIZE; i++) {
566 if (slot->slots[i] != NULL) 617 if (slot->slots[i] != NULL)
567 break; 618 break;
568 index &= ~((1UL << shift) - 1); 619 index &= ~((1UL << shift) - 1);
569 index += 1UL << shift; 620 index += 1UL << shift;
570 if (index == 0) 621 if (index == 0)
571 goto out; /* 32-bit wraparound */ 622 goto out; /* 32-bit wraparound */
623 i++;
624 if (i == RADIX_TREE_MAP_SIZE)
625 goto out;
572 } 626 }
573 if (i == RADIX_TREE_MAP_SIZE)
574 goto out;
575 627
576 shift -= RADIX_TREE_MAP_SHIFT; 628 shift -= RADIX_TREE_MAP_SHIFT;
577 slot = slot->slots[i]; 629 slot = rcu_dereference(slot->slots[i]);
630 if (slot == NULL)
631 goto out;
578 } 632 }
579 633
580 /* Bottom level: grab some items */ 634 /* Bottom level: grab some items */
581 for (i = index & RADIX_TREE_MAP_MASK; i < RADIX_TREE_MAP_SIZE; i++) { 635 for (i = index & RADIX_TREE_MAP_MASK; i < RADIX_TREE_MAP_SIZE; i++) {
636 struct radix_tree_node *node;
582 index++; 637 index++;
583 if (slot->slots[i]) { 638 node = slot->slots[i];
584 results[nr_found++] = slot->slots[i]; 639 if (node) {
640 results[nr_found++] = rcu_dereference(node);
585 if (nr_found == max_items) 641 if (nr_found == max_items)
586 goto out; 642 goto out;
587 } 643 }
@@ -603,28 +659,51 @@ out:
603 * *@results. 659 * *@results.
604 * 660 *
605 * The implementation is naive. 661 * The implementation is naive.
662 *
663 * Like radix_tree_lookup, radix_tree_gang_lookup may be called under
664 * rcu_read_lock. In this case, rather than the returned results being
665 * an atomic snapshot of the tree at a single point in time, the semantics
666 * of an RCU protected gang lookup are as though multiple radix_tree_lookups
667 * have been issued in individual locks, and results stored in 'results'.
606 */ 668 */
607unsigned int 669unsigned int
608radix_tree_gang_lookup(struct radix_tree_root *root, void **results, 670radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
609 unsigned long first_index, unsigned int max_items) 671 unsigned long first_index, unsigned int max_items)
610{ 672{
611 const unsigned long max_index = radix_tree_maxindex(root->height); 673 unsigned long max_index;
674 struct radix_tree_node *node;
612 unsigned long cur_index = first_index; 675 unsigned long cur_index = first_index;
613 unsigned int ret = 0; 676 unsigned int ret;
677
678 node = rcu_dereference(root->rnode);
679 if (!node)
680 return 0;
614 681
682 if (radix_tree_is_direct_ptr(node)) {
683 if (first_index > 0)
684 return 0;
685 node = radix_tree_direct_to_ptr(node);
686 results[0] = rcu_dereference(node);
687 return 1;
688 }
689
690 max_index = radix_tree_maxindex(node->height);
691
692 ret = 0;
615 while (ret < max_items) { 693 while (ret < max_items) {
616 unsigned int nr_found; 694 unsigned int nr_found;
617 unsigned long next_index; /* Index of next search */ 695 unsigned long next_index; /* Index of next search */
618 696
619 if (cur_index > max_index) 697 if (cur_index > max_index)
620 break; 698 break;
621 nr_found = __lookup(root, results + ret, cur_index, 699 nr_found = __lookup(node, results + ret, cur_index,
622 max_items - ret, &next_index); 700 max_items - ret, &next_index);
623 ret += nr_found; 701 ret += nr_found;
624 if (next_index == 0) 702 if (next_index == 0)
625 break; 703 break;
626 cur_index = next_index; 704 cur_index = next_index;
627 } 705 }
706
628 return ret; 707 return ret;
629} 708}
630EXPORT_SYMBOL(radix_tree_gang_lookup); 709EXPORT_SYMBOL(radix_tree_gang_lookup);
@@ -634,55 +713,64 @@ EXPORT_SYMBOL(radix_tree_gang_lookup);
634 * open-coding the search. 713 * open-coding the search.
635 */ 714 */
636static unsigned int 715static unsigned int
637__lookup_tag(struct radix_tree_root *root, void **results, unsigned long index, 716__lookup_tag(struct radix_tree_node *slot, void **results, unsigned long index,
638 unsigned int max_items, unsigned long *next_index, unsigned int tag) 717 unsigned int max_items, unsigned long *next_index, unsigned int tag)
639{ 718{
640 unsigned int nr_found = 0; 719 unsigned int nr_found = 0;
641 unsigned int shift; 720 unsigned int shift, height;
642 unsigned int height = root->height;
643 struct radix_tree_node *slot;
644 721
645 if (height == 0) { 722 height = slot->height;
646 if (root->rnode && index == 0) 723 if (height == 0)
647 results[nr_found++] = root->rnode;
648 goto out; 724 goto out;
649 } 725 shift = (height-1) * RADIX_TREE_MAP_SHIFT;
650
651 shift = (height - 1) * RADIX_TREE_MAP_SHIFT;
652 slot = root->rnode;
653 726
654 do { 727 while (height > 0) {
655 unsigned long i = (index >> shift) & RADIX_TREE_MAP_MASK; 728 unsigned long i = (index >> shift) & RADIX_TREE_MAP_MASK ;
656 729
657 for ( ; i < RADIX_TREE_MAP_SIZE; i++) { 730 for (;;) {
658 if (tag_get(slot, tag, i)) { 731 if (tag_get(slot, tag, i))
659 BUG_ON(slot->slots[i] == NULL);
660 break; 732 break;
661 }
662 index &= ~((1UL << shift) - 1); 733 index &= ~((1UL << shift) - 1);
663 index += 1UL << shift; 734 index += 1UL << shift;
664 if (index == 0) 735 if (index == 0)
665 goto out; /* 32-bit wraparound */ 736 goto out; /* 32-bit wraparound */
737 i++;
738 if (i == RADIX_TREE_MAP_SIZE)
739 goto out;
666 } 740 }
667 if (i == RADIX_TREE_MAP_SIZE)
668 goto out;
669 height--; 741 height--;
670 if (height == 0) { /* Bottom level: grab some items */ 742 if (height == 0) { /* Bottom level: grab some items */
671 unsigned long j = index & RADIX_TREE_MAP_MASK; 743 unsigned long j = index & RADIX_TREE_MAP_MASK;
672 744
673 for ( ; j < RADIX_TREE_MAP_SIZE; j++) { 745 for ( ; j < RADIX_TREE_MAP_SIZE; j++) {
746 struct radix_tree_node *node;
674 index++; 747 index++;
675 if (tag_get(slot, tag, j)) { 748 if (!tag_get(slot, tag, j))
676 BUG_ON(slot->slots[j] == NULL); 749 continue;
677 results[nr_found++] = slot->slots[j]; 750 node = slot->slots[j];
751 /*
752 * Even though the tag was found set, we need to
753 * recheck that we have a non-NULL node, because
754 * if this lookup is lockless, it may have been
755 * subsequently deleted.
756 *
757 * Similar care must be taken in any place that
758 * lookup ->slots[x] without a lock (ie. can't
759 * rely on its value remaining the same).
760 */
761 if (node) {
762 node = rcu_dereference(node);
763 results[nr_found++] = node;
678 if (nr_found == max_items) 764 if (nr_found == max_items)
679 goto out; 765 goto out;
680 } 766 }
681 } 767 }
682 } 768 }
683 shift -= RADIX_TREE_MAP_SHIFT; 769 shift -= RADIX_TREE_MAP_SHIFT;
684 slot = slot->slots[i]; 770 slot = rcu_dereference(slot->slots[i]);
685 } while (height > 0); 771 if (slot == NULL)
772 break;
773 }
686out: 774out:
687 *next_index = index; 775 *next_index = index;
688 return nr_found; 776 return nr_found;
@@ -706,27 +794,44 @@ radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
706 unsigned long first_index, unsigned int max_items, 794 unsigned long first_index, unsigned int max_items,
707 unsigned int tag) 795 unsigned int tag)
708{ 796{
709 const unsigned long max_index = radix_tree_maxindex(root->height); 797 struct radix_tree_node *node;
798 unsigned long max_index;
710 unsigned long cur_index = first_index; 799 unsigned long cur_index = first_index;
711 unsigned int ret = 0; 800 unsigned int ret;
712 801
713 /* check the root's tag bit */ 802 /* check the root's tag bit */
714 if (!root_tag_get(root, tag)) 803 if (!root_tag_get(root, tag))
715 return 0; 804 return 0;
716 805
806 node = rcu_dereference(root->rnode);
807 if (!node)
808 return 0;
809
810 if (radix_tree_is_direct_ptr(node)) {
811 if (first_index > 0)
812 return 0;
813 node = radix_tree_direct_to_ptr(node);
814 results[0] = rcu_dereference(node);
815 return 1;
816 }
817
818 max_index = radix_tree_maxindex(node->height);
819
820 ret = 0;
717 while (ret < max_items) { 821 while (ret < max_items) {
718 unsigned int nr_found; 822 unsigned int nr_found;
719 unsigned long next_index; /* Index of next search */ 823 unsigned long next_index; /* Index of next search */
720 824
721 if (cur_index > max_index) 825 if (cur_index > max_index)
722 break; 826 break;
723 nr_found = __lookup_tag(root, results + ret, cur_index, 827 nr_found = __lookup_tag(node, results + ret, cur_index,
724 max_items - ret, &next_index, tag); 828 max_items - ret, &next_index, tag);
725 ret += nr_found; 829 ret += nr_found;
726 if (next_index == 0) 830 if (next_index == 0)
727 break; 831 break;
728 cur_index = next_index; 832 cur_index = next_index;
729 } 833 }
834
730 return ret; 835 return ret;
731} 836}
732EXPORT_SYMBOL(radix_tree_gang_lookup_tag); 837EXPORT_SYMBOL(radix_tree_gang_lookup_tag);
@@ -742,8 +847,19 @@ static inline void radix_tree_shrink(struct radix_tree_root *root)
742 root->rnode->count == 1 && 847 root->rnode->count == 1 &&
743 root->rnode->slots[0]) { 848 root->rnode->slots[0]) {
744 struct radix_tree_node *to_free = root->rnode; 849 struct radix_tree_node *to_free = root->rnode;
850 void *newptr;
745 851
746 root->rnode = to_free->slots[0]; 852 /*
853 * We don't need rcu_assign_pointer(), since we are simply
854 * moving the node from one part of the tree to another. If
855 * it was safe to dereference the old pointer to it
856 * (to_free->slots[0]), it will be safe to dereference the new
857 * one (root->rnode).
858 */
859 newptr = to_free->slots[0];
860 if (root->height == 1)
861 newptr = radix_tree_ptr_to_direct(newptr);
862 root->rnode = newptr;
747 root->height--; 863 root->height--;
748 /* must only free zeroed nodes into the slab */ 864 /* must only free zeroed nodes into the slab */
749 tag_clear(to_free, 0, 0); 865 tag_clear(to_free, 0, 0);
@@ -767,6 +883,7 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
767{ 883{
768 struct radix_tree_path path[RADIX_TREE_MAX_PATH], *pathp = path; 884 struct radix_tree_path path[RADIX_TREE_MAX_PATH], *pathp = path;
769 struct radix_tree_node *slot = NULL; 885 struct radix_tree_node *slot = NULL;
886 struct radix_tree_node *to_free;
770 unsigned int height, shift; 887 unsigned int height, shift;
771 int tag; 888 int tag;
772 int offset; 889 int offset;
@@ -777,6 +894,7 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
777 894
778 slot = root->rnode; 895 slot = root->rnode;
779 if (height == 0 && root->rnode) { 896 if (height == 0 && root->rnode) {
897 slot = radix_tree_direct_to_ptr(slot);
780 root_tag_clear_all(root); 898 root_tag_clear_all(root);
781 root->rnode = NULL; 899 root->rnode = NULL;
782 goto out; 900 goto out;
@@ -809,10 +927,17 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
809 radix_tree_tag_clear(root, index, tag); 927 radix_tree_tag_clear(root, index, tag);
810 } 928 }
811 929
930 to_free = NULL;
812 /* Now free the nodes we do not need anymore */ 931 /* Now free the nodes we do not need anymore */
813 while (pathp->node) { 932 while (pathp->node) {
814 pathp->node->slots[pathp->offset] = NULL; 933 pathp->node->slots[pathp->offset] = NULL;
815 pathp->node->count--; 934 pathp->node->count--;
935 /*
936 * Queue the node for deferred freeing after the
937 * last reference to it disappears (set NULL, above).
938 */
939 if (to_free)
940 radix_tree_node_free(to_free);
816 941
817 if (pathp->node->count) { 942 if (pathp->node->count) {
818 if (pathp->node == root->rnode) 943 if (pathp->node == root->rnode)
@@ -821,13 +946,15 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
821 } 946 }
822 947
823 /* Node with zero slots in use so free it */ 948 /* Node with zero slots in use so free it */
824 radix_tree_node_free(pathp->node); 949 to_free = pathp->node;
825
826 pathp--; 950 pathp--;
951
827 } 952 }
828 root_tag_clear_all(root); 953 root_tag_clear_all(root);
829 root->height = 0; 954 root->height = 0;
830 root->rnode = NULL; 955 root->rnode = NULL;
956 if (to_free)
957 radix_tree_node_free(to_free);
831 958
832out: 959out:
833 return slot; 960 return slot;
@@ -846,7 +973,7 @@ int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag)
846EXPORT_SYMBOL(radix_tree_tagged); 973EXPORT_SYMBOL(radix_tree_tagged);
847 974
848static void 975static void
849radix_tree_node_ctor(void *node, kmem_cache_t *cachep, unsigned long flags) 976radix_tree_node_ctor(void *node, struct kmem_cache *cachep, unsigned long flags)
850{ 977{
851 memset(node, 0, sizeof(struct radix_tree_node)); 978 memset(node, 0, sizeof(struct radix_tree_node));
852} 979}
@@ -869,7 +996,6 @@ static __init void radix_tree_init_maxindex(void)
869 height_to_maxindex[i] = __maxindex(i); 996 height_to_maxindex[i] = __maxindex(i);
870} 997}
871 998
872#ifdef CONFIG_HOTPLUG_CPU
873static int radix_tree_callback(struct notifier_block *nfb, 999static int radix_tree_callback(struct notifier_block *nfb,
874 unsigned long action, 1000 unsigned long action,
875 void *hcpu) 1001 void *hcpu)
@@ -889,7 +1015,6 @@ static int radix_tree_callback(struct notifier_block *nfb,
889 } 1015 }
890 return NOTIFY_OK; 1016 return NOTIFY_OK;
891} 1017}
892#endif /* CONFIG_HOTPLUG_CPU */
893 1018
894void __init radix_tree_init(void) 1019void __init radix_tree_init(void)
895{ 1020{
diff --git a/mm/allocpercpu.c b/mm/allocpercpu.c
index eaa9abeea536..b2486cf887a0 100644
--- a/mm/allocpercpu.c
+++ b/mm/allocpercpu.c
@@ -17,10 +17,9 @@
17void percpu_depopulate(void *__pdata, int cpu) 17void percpu_depopulate(void *__pdata, int cpu)
18{ 18{
19 struct percpu_data *pdata = __percpu_disguise(__pdata); 19 struct percpu_data *pdata = __percpu_disguise(__pdata);
20 if (pdata->ptrs[cpu]) { 20
21 kfree(pdata->ptrs[cpu]); 21 kfree(pdata->ptrs[cpu]);
22 pdata->ptrs[cpu] = NULL; 22 pdata->ptrs[cpu] = NULL;
23 }
24} 23}
25EXPORT_SYMBOL_GPL(percpu_depopulate); 24EXPORT_SYMBOL_GPL(percpu_depopulate);
26 25
@@ -123,6 +122,8 @@ EXPORT_SYMBOL_GPL(__percpu_alloc_mask);
123 */ 122 */
124void percpu_free(void *__pdata) 123void percpu_free(void *__pdata)
125{ 124{
125 if (unlikely(!__pdata))
126 return;
126 __percpu_depopulate_mask(__pdata, &cpu_possible_map); 127 __percpu_depopulate_mask(__pdata, &cpu_possible_map);
127 kfree(__percpu_disguise(__pdata)); 128 kfree(__percpu_disguise(__pdata));
128} 129}
diff --git a/mm/bootmem.c b/mm/bootmem.c
index d53112fcb404..00a96970b237 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -27,8 +27,6 @@ unsigned long max_low_pfn;
27unsigned long min_low_pfn; 27unsigned long min_low_pfn;
28unsigned long max_pfn; 28unsigned long max_pfn;
29 29
30EXPORT_UNUSED_SYMBOL(max_pfn); /* June 2006 */
31
32static LIST_HEAD(bdata_list); 30static LIST_HEAD(bdata_list);
33#ifdef CONFIG_CRASH_DUMP 31#ifdef CONFIG_CRASH_DUMP
34/* 32/*
@@ -196,6 +194,10 @@ __alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size,
196 if (limit && bdata->node_boot_start >= limit) 194 if (limit && bdata->node_boot_start >= limit)
197 return NULL; 195 return NULL;
198 196
197 /* on nodes without memory - bootmem_map is NULL */
198 if (!bdata->node_bootmem_map)
199 return NULL;
200
199 end_pfn = bdata->node_low_pfn; 201 end_pfn = bdata->node_low_pfn;
200 limit = PFN_DOWN(limit); 202 limit = PFN_DOWN(limit);
201 if (limit && end_pfn > limit) 203 if (limit && end_pfn > limit)
diff --git a/mm/filemap.c b/mm/filemap.c
index 13df01c50479..af7e2f5caea9 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1445,7 +1445,6 @@ no_cached_page:
1445 * effect. 1445 * effect.
1446 */ 1446 */
1447 error = page_cache_read(file, pgoff); 1447 error = page_cache_read(file, pgoff);
1448 grab_swap_token();
1449 1448
1450 /* 1449 /*
1451 * The page we want has now been added to the page cache. 1450 * The page we want has now been added to the page cache.
diff --git a/mm/fremap.c b/mm/fremap.c
index 7a9d0f5d246d..b77a002c3352 100644
--- a/mm/fremap.c
+++ b/mm/fremap.c
@@ -101,7 +101,6 @@ int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma,
101{ 101{
102 int err = -ENOMEM; 102 int err = -ENOMEM;
103 pte_t *pte; 103 pte_t *pte;
104 pte_t pte_val;
105 spinlock_t *ptl; 104 spinlock_t *ptl;
106 105
107 pte = get_locked_pte(mm, addr, &ptl); 106 pte = get_locked_pte(mm, addr, &ptl);
@@ -114,7 +113,6 @@ int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma,
114 } 113 }
115 114
116 set_pte_at(mm, addr, pte, pgoff_to_pte(pgoff)); 115 set_pte_at(mm, addr, pte, pgoff_to_pte(pgoff));
117 pte_val = *pte;
118 /* 116 /*
119 * We don't need to run update_mmu_cache() here because the "file pte" 117 * We don't need to run update_mmu_cache() here because the "file pte"
120 * being installed by install_file_pte() is not a real pte - it's a 118 * being installed by install_file_pte() is not a real pte - it's a
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index a088f593a807..0ccc7f230252 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -109,7 +109,7 @@ static int alloc_fresh_huge_page(void)
109 if (nid == MAX_NUMNODES) 109 if (nid == MAX_NUMNODES)
110 nid = first_node(node_online_map); 110 nid = first_node(node_online_map);
111 if (page) { 111 if (page) {
112 page[1].lru.next = (void *)free_huge_page; /* dtor */ 112 set_compound_page_dtor(page, free_huge_page);
113 spin_lock(&hugetlb_lock); 113 spin_lock(&hugetlb_lock);
114 nr_huge_pages++; 114 nr_huge_pages++;
115 nr_huge_pages_node[page_to_nid(page)]++; 115 nr_huge_pages_node[page_to_nid(page)]++;
@@ -344,7 +344,6 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
344 entry = *src_pte; 344 entry = *src_pte;
345 ptepage = pte_page(entry); 345 ptepage = pte_page(entry);
346 get_page(ptepage); 346 get_page(ptepage);
347 add_mm_counter(dst, file_rss, HPAGE_SIZE / PAGE_SIZE);
348 set_huge_pte_at(dst, addr, dst_pte, entry); 347 set_huge_pte_at(dst, addr, dst_pte, entry);
349 } 348 }
350 spin_unlock(&src->page_table_lock); 349 spin_unlock(&src->page_table_lock);
@@ -365,6 +364,11 @@ void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
365 pte_t pte; 364 pte_t pte;
366 struct page *page; 365 struct page *page;
367 struct page *tmp; 366 struct page *tmp;
367 /*
368 * A page gathering list, protected by per file i_mmap_lock. The
369 * lock is used to avoid list corruption from multiple unmapping
370 * of the same page since we are using page->lru.
371 */
368 LIST_HEAD(page_list); 372 LIST_HEAD(page_list);
369 373
370 WARN_ON(!is_vm_hugetlb_page(vma)); 374 WARN_ON(!is_vm_hugetlb_page(vma));
@@ -372,24 +376,21 @@ void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
372 BUG_ON(end & ~HPAGE_MASK); 376 BUG_ON(end & ~HPAGE_MASK);
373 377
374 spin_lock(&mm->page_table_lock); 378 spin_lock(&mm->page_table_lock);
375
376 /* Update high watermark before we lower rss */
377 update_hiwater_rss(mm);
378
379 for (address = start; address < end; address += HPAGE_SIZE) { 379 for (address = start; address < end; address += HPAGE_SIZE) {
380 ptep = huge_pte_offset(mm, address); 380 ptep = huge_pte_offset(mm, address);
381 if (!ptep) 381 if (!ptep)
382 continue; 382 continue;
383 383
384 if (huge_pmd_unshare(mm, &address, ptep))
385 continue;
386
384 pte = huge_ptep_get_and_clear(mm, address, ptep); 387 pte = huge_ptep_get_and_clear(mm, address, ptep);
385 if (pte_none(pte)) 388 if (pte_none(pte))
386 continue; 389 continue;
387 390
388 page = pte_page(pte); 391 page = pte_page(pte);
389 list_add(&page->lru, &page_list); 392 list_add(&page->lru, &page_list);
390 add_mm_counter(mm, file_rss, (int) -(HPAGE_SIZE / PAGE_SIZE));
391 } 393 }
392
393 spin_unlock(&mm->page_table_lock); 394 spin_unlock(&mm->page_table_lock);
394 flush_tlb_range(vma, start, end); 395 flush_tlb_range(vma, start, end);
395 list_for_each_entry_safe(page, tmp, &page_list, lru) { 396 list_for_each_entry_safe(page, tmp, &page_list, lru) {
@@ -515,7 +516,6 @@ retry:
515 if (!pte_none(*ptep)) 516 if (!pte_none(*ptep))
516 goto backout; 517 goto backout;
517 518
518 add_mm_counter(mm, file_rss, HPAGE_SIZE / PAGE_SIZE);
519 new_pte = make_huge_pte(vma, page, ((vma->vm_flags & VM_WRITE) 519 new_pte = make_huge_pte(vma, page, ((vma->vm_flags & VM_WRITE)
520 && (vma->vm_flags & VM_SHARED))); 520 && (vma->vm_flags & VM_SHARED)));
521 set_huge_pte_at(mm, address, ptep, new_pte); 521 set_huge_pte_at(mm, address, ptep, new_pte);
@@ -653,11 +653,14 @@ void hugetlb_change_protection(struct vm_area_struct *vma,
653 BUG_ON(address >= end); 653 BUG_ON(address >= end);
654 flush_cache_range(vma, address, end); 654 flush_cache_range(vma, address, end);
655 655
656 spin_lock(&vma->vm_file->f_mapping->i_mmap_lock);
656 spin_lock(&mm->page_table_lock); 657 spin_lock(&mm->page_table_lock);
657 for (; address < end; address += HPAGE_SIZE) { 658 for (; address < end; address += HPAGE_SIZE) {
658 ptep = huge_pte_offset(mm, address); 659 ptep = huge_pte_offset(mm, address);
659 if (!ptep) 660 if (!ptep)
660 continue; 661 continue;
662 if (huge_pmd_unshare(mm, &address, ptep))
663 continue;
661 if (!pte_none(*ptep)) { 664 if (!pte_none(*ptep)) {
662 pte = huge_ptep_get_and_clear(mm, address, ptep); 665 pte = huge_ptep_get_and_clear(mm, address, ptep);
663 pte = pte_mkhuge(pte_modify(pte, newprot)); 666 pte = pte_mkhuge(pte_modify(pte, newprot));
@@ -666,6 +669,7 @@ void hugetlb_change_protection(struct vm_area_struct *vma,
666 } 669 }
667 } 670 }
668 spin_unlock(&mm->page_table_lock); 671 spin_unlock(&mm->page_table_lock);
672 spin_unlock(&vma->vm_file->f_mapping->i_mmap_lock);
669 673
670 flush_tlb_range(vma, start, end); 674 flush_tlb_range(vma, start, end);
671} 675}
diff --git a/mm/memory.c b/mm/memory.c
index 156861fcac43..4198df0dff1c 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1902,7 +1902,6 @@ int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end)
1902 1902
1903 return 0; 1903 return 0;
1904} 1904}
1905EXPORT_UNUSED_SYMBOL(vmtruncate_range); /* June 2006 */
1906 1905
1907/** 1906/**
1908 * swapin_readahead - swap in pages in hope we need them soon 1907 * swapin_readahead - swap in pages in hope we need them soon
@@ -1991,6 +1990,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
1991 delayacct_set_flag(DELAYACCT_PF_SWAPIN); 1990 delayacct_set_flag(DELAYACCT_PF_SWAPIN);
1992 page = lookup_swap_cache(entry); 1991 page = lookup_swap_cache(entry);
1993 if (!page) { 1992 if (!page) {
1993 grab_swap_token(); /* Contend for token _before_ read-in */
1994 swapin_readahead(entry, address, vma); 1994 swapin_readahead(entry, address, vma);
1995 page = read_swap_cache_async(entry, vma, address); 1995 page = read_swap_cache_async(entry, vma, address);
1996 if (!page) { 1996 if (!page) {
@@ -2008,7 +2008,6 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
2008 /* Had to read the page from swap area: Major fault */ 2008 /* Had to read the page from swap area: Major fault */
2009 ret = VM_FAULT_MAJOR; 2009 ret = VM_FAULT_MAJOR;
2010 count_vm_event(PGMAJFAULT); 2010 count_vm_event(PGMAJFAULT);
2011 grab_swap_token();
2012 } 2011 }
2013 2012
2014 delayacct_clear_flag(DELAYACCT_PF_SWAPIN); 2013 delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index fd678a662eae..0c055a090f4d 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -72,7 +72,6 @@ static int __add_zone(struct zone *zone, unsigned long phys_start_pfn)
72 return ret; 72 return ret;
73 } 73 }
74 memmap_init_zone(nr_pages, nid, zone_type, phys_start_pfn); 74 memmap_init_zone(nr_pages, nid, zone_type, phys_start_pfn);
75 zonetable_add(zone, nid, zone_type, phys_start_pfn, nr_pages);
76 return 0; 75 return 0;
77} 76}
78 77
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 617fb31086ee..b917d6fdc1bb 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -141,9 +141,11 @@ static struct zonelist *bind_zonelist(nodemask_t *nodes)
141 enum zone_type k; 141 enum zone_type k;
142 142
143 max = 1 + MAX_NR_ZONES * nodes_weight(*nodes); 143 max = 1 + MAX_NR_ZONES * nodes_weight(*nodes);
144 max++; /* space for zlcache_ptr (see mmzone.h) */
144 zl = kmalloc(sizeof(struct zone *) * max, GFP_KERNEL); 145 zl = kmalloc(sizeof(struct zone *) * max, GFP_KERNEL);
145 if (!zl) 146 if (!zl)
146 return NULL; 147 return NULL;
148 zl->zlcache_ptr = NULL;
147 num = 0; 149 num = 0;
148 /* First put in the highest zones from all nodes, then all the next 150 /* First put in the highest zones from all nodes, then all the next
149 lower zones etc. Avoid empty zones because the memory allocator 151 lower zones etc. Avoid empty zones because the memory allocator
@@ -219,7 +221,7 @@ static int check_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
219 orig_pte = pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); 221 orig_pte = pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
220 do { 222 do {
221 struct page *page; 223 struct page *page;
222 unsigned int nid; 224 int nid;
223 225
224 if (!pte_present(*pte)) 226 if (!pte_present(*pte))
225 continue; 227 continue;
@@ -1324,7 +1326,7 @@ struct mempolicy *__mpol_copy(struct mempolicy *old)
1324 atomic_set(&new->refcnt, 1); 1326 atomic_set(&new->refcnt, 1);
1325 if (new->policy == MPOL_BIND) { 1327 if (new->policy == MPOL_BIND) {
1326 int sz = ksize(old->v.zonelist); 1328 int sz = ksize(old->v.zonelist);
1327 new->v.zonelist = kmemdup(old->v.zonelist, sz, SLAB_KERNEL); 1329 new->v.zonelist = kmemdup(old->v.zonelist, sz, GFP_KERNEL);
1328 if (!new->v.zonelist) { 1330 if (!new->v.zonelist) {
1329 kmem_cache_free(policy_cache, new); 1331 kmem_cache_free(policy_cache, new);
1330 return ERR_PTR(-ENOMEM); 1332 return ERR_PTR(-ENOMEM);
@@ -1705,8 +1707,8 @@ void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new)
1705 * Display pages allocated per node and memory policy via /proc. 1707 * Display pages allocated per node and memory policy via /proc.
1706 */ 1708 */
1707 1709
1708static const char *policy_types[] = { "default", "prefer", "bind", 1710static const char * const policy_types[] =
1709 "interleave" }; 1711 { "default", "prefer", "bind", "interleave" };
1710 1712
1711/* 1713/*
1712 * Convert a mempolicy into a string. 1714 * Convert a mempolicy into a string.
diff --git a/mm/migrate.c b/mm/migrate.c
index b4979d423d2b..e9b161bde95b 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -294,7 +294,7 @@ out:
294static int migrate_page_move_mapping(struct address_space *mapping, 294static int migrate_page_move_mapping(struct address_space *mapping,
295 struct page *newpage, struct page *page) 295 struct page *newpage, struct page *page)
296{ 296{
297 struct page **radix_pointer; 297 void **pslot;
298 298
299 if (!mapping) { 299 if (!mapping) {
300 /* Anonymous page */ 300 /* Anonymous page */
@@ -305,12 +305,11 @@ static int migrate_page_move_mapping(struct address_space *mapping,
305 305
306 write_lock_irq(&mapping->tree_lock); 306 write_lock_irq(&mapping->tree_lock);
307 307
308 radix_pointer = (struct page **)radix_tree_lookup_slot( 308 pslot = radix_tree_lookup_slot(&mapping->page_tree,
309 &mapping->page_tree, 309 page_index(page));
310 page_index(page));
311 310
312 if (page_count(page) != 2 + !!PagePrivate(page) || 311 if (page_count(page) != 2 + !!PagePrivate(page) ||
313 *radix_pointer != page) { 312 (struct page *)radix_tree_deref_slot(pslot) != page) {
314 write_unlock_irq(&mapping->tree_lock); 313 write_unlock_irq(&mapping->tree_lock);
315 return -EAGAIN; 314 return -EAGAIN;
316 } 315 }
@@ -318,7 +317,7 @@ static int migrate_page_move_mapping(struct address_space *mapping,
318 /* 317 /*
319 * Now we know that no one else is looking at the page. 318 * Now we know that no one else is looking at the page.
320 */ 319 */
321 get_page(newpage); 320 get_page(newpage); /* add cache reference */
322#ifdef CONFIG_SWAP 321#ifdef CONFIG_SWAP
323 if (PageSwapCache(page)) { 322 if (PageSwapCache(page)) {
324 SetPageSwapCache(newpage); 323 SetPageSwapCache(newpage);
@@ -326,8 +325,14 @@ static int migrate_page_move_mapping(struct address_space *mapping,
326 } 325 }
327#endif 326#endif
328 327
329 *radix_pointer = newpage; 328 radix_tree_replace_slot(pslot, newpage);
329
330 /*
331 * Drop cache reference from old page.
332 * We know this isn't the last reference.
333 */
330 __put_page(page); 334 __put_page(page);
335
331 write_unlock_irq(&mapping->tree_lock); 336 write_unlock_irq(&mapping->tree_lock);
332 337
333 return 0; 338 return 0;
diff --git a/mm/mlock.c b/mm/mlock.c
index b90c59573abf..3446b7ef731e 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -65,7 +65,7 @@ success:
65 ret = make_pages_present(start, end); 65 ret = make_pages_present(start, end);
66 } 66 }
67 67
68 vma->vm_mm->locked_vm -= pages; 68 mm->locked_vm -= pages;
69out: 69out:
70 if (ret == -ENOMEM) 70 if (ret == -ENOMEM)
71 ret = -EAGAIN; 71 ret = -EAGAIN;
diff --git a/mm/mmap.c b/mm/mmap.c
index 7b40abd7cba2..7be110e98d4c 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1736,7 +1736,7 @@ int split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
1736 if (mm->map_count >= sysctl_max_map_count) 1736 if (mm->map_count >= sysctl_max_map_count)
1737 return -ENOMEM; 1737 return -ENOMEM;
1738 1738
1739 new = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 1739 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
1740 if (!new) 1740 if (!new)
1741 return -ENOMEM; 1741 return -ENOMEM;
1742 1742
@@ -2057,7 +2057,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
2057 vma_start < new_vma->vm_end) 2057 vma_start < new_vma->vm_end)
2058 *vmap = new_vma; 2058 *vmap = new_vma;
2059 } else { 2059 } else {
2060 new_vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 2060 new_vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
2061 if (new_vma) { 2061 if (new_vma) {
2062 *new_vma = *vma; 2062 *new_vma = *vma;
2063 pol = mpol_copy(vma_policy(vma)); 2063 pol = mpol_copy(vma_policy(vma));
diff --git a/mm/mmzone.c b/mm/mmzone.c
index febea1c98168..eb5838634f18 100644
--- a/mm/mmzone.c
+++ b/mm/mmzone.c
@@ -14,8 +14,6 @@ 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_UNUSED_SYMBOL(first_online_pgdat); /* June 2006 */
18
19struct pglist_data *next_online_pgdat(struct pglist_data *pgdat) 17struct pglist_data *next_online_pgdat(struct pglist_data *pgdat)
20{ 18{
21 int nid = next_online_node(pgdat->node_id); 19 int nid = next_online_node(pgdat->node_id);
@@ -24,8 +22,6 @@ struct pglist_data *next_online_pgdat(struct pglist_data *pgdat)
24 return NULL; 22 return NULL;
25 return NODE_DATA(nid); 23 return NODE_DATA(nid);
26} 24}
27EXPORT_UNUSED_SYMBOL(next_online_pgdat); /* June 2006 */
28
29 25
30/* 26/*
31 * next_zone - helper magic for for_each_zone() 27 * next_zone - helper magic for for_each_zone()
@@ -45,5 +41,4 @@ struct zone *next_zone(struct zone *zone)
45 } 41 }
46 return zone; 42 return zone;
47} 43}
48EXPORT_UNUSED_SYMBOL(next_zone); /* June 2006 */
49 44
diff --git a/mm/nommu.c b/mm/nommu.c
index 8bdde9508f3b..af874569d0f1 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -497,15 +497,17 @@ static int validate_mmap_request(struct file *file,
497 (flags & MAP_TYPE) != MAP_SHARED) 497 (flags & MAP_TYPE) != MAP_SHARED)
498 return -EINVAL; 498 return -EINVAL;
499 499
500 if (PAGE_ALIGN(len) == 0) 500 if (!len)
501 return addr;
502
503 if (len > TASK_SIZE)
504 return -EINVAL; 501 return -EINVAL;
505 502
503 /* Careful about overflows.. */
504 len = PAGE_ALIGN(len);
505 if (!len || len > TASK_SIZE)
506 return -ENOMEM;
507
506 /* offset overflow? */ 508 /* offset overflow? */
507 if ((pgoff + (len >> PAGE_SHIFT)) < pgoff) 509 if ((pgoff + (len >> PAGE_SHIFT)) < pgoff)
508 return -EINVAL; 510 return -EOVERFLOW;
509 511
510 if (file) { 512 if (file) {
511 /* validate file mapping requests */ 513 /* validate file mapping requests */
@@ -806,10 +808,9 @@ unsigned long do_mmap_pgoff(struct file *file,
806 vm_flags = determine_vm_flags(file, prot, flags, capabilities); 808 vm_flags = determine_vm_flags(file, prot, flags, capabilities);
807 809
808 /* we're going to need to record the mapping if it works */ 810 /* we're going to need to record the mapping if it works */
809 vml = kmalloc(sizeof(struct vm_list_struct), GFP_KERNEL); 811 vml = kzalloc(sizeof(struct vm_list_struct), GFP_KERNEL);
810 if (!vml) 812 if (!vml)
811 goto error_getting_vml; 813 goto error_getting_vml;
812 memset(vml, 0, sizeof(*vml));
813 814
814 down_write(&nommu_vma_sem); 815 down_write(&nommu_vma_sem);
815 816
@@ -885,11 +886,10 @@ unsigned long do_mmap_pgoff(struct file *file,
885 } 886 }
886 887
887 /* we're going to need a VMA struct as well */ 888 /* we're going to need a VMA struct as well */
888 vma = kmalloc(sizeof(struct vm_area_struct), GFP_KERNEL); 889 vma = kzalloc(sizeof(struct vm_area_struct), GFP_KERNEL);
889 if (!vma) 890 if (!vma)
890 goto error_getting_vma; 891 goto error_getting_vma;
891 892
892 memset(vma, 0, sizeof(*vma));
893 INIT_LIST_HEAD(&vma->anon_vma_node); 893 INIT_LIST_HEAD(&vma->anon_vma_node);
894 atomic_set(&vma->vm_usage, 1); 894 atomic_set(&vma->vm_usage, 1);
895 if (file) 895 if (file)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 2e3ce3a928b9..223d9ccb7d64 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -264,7 +264,7 @@ static struct task_struct *select_bad_process(unsigned long *ppoints)
264 * flag though it's unlikely that we select a process with CAP_SYS_RAW_IO 264 * flag though it's unlikely that we select a process with CAP_SYS_RAW_IO
265 * set. 265 * set.
266 */ 266 */
267static void __oom_kill_task(struct task_struct *p, const char *message) 267static void __oom_kill_task(struct task_struct *p, int verbose)
268{ 268{
269 if (is_init(p)) { 269 if (is_init(p)) {
270 WARN_ON(1); 270 WARN_ON(1);
@@ -278,10 +278,8 @@ static void __oom_kill_task(struct task_struct *p, const char *message)
278 return; 278 return;
279 } 279 }
280 280
281 if (message) { 281 if (verbose)
282 printk(KERN_ERR "%s: Killed process %d (%s).\n", 282 printk(KERN_ERR "Killed process %d (%s)\n", p->pid, p->comm);
283 message, p->pid, p->comm);
284 }
285 283
286 /* 284 /*
287 * We give our sacrificial lamb high priority and access to 285 * We give our sacrificial lamb high priority and access to
@@ -294,7 +292,7 @@ static void __oom_kill_task(struct task_struct *p, const char *message)
294 force_sig(SIGKILL, p); 292 force_sig(SIGKILL, p);
295} 293}
296 294
297static int oom_kill_task(struct task_struct *p, const char *message) 295static int oom_kill_task(struct task_struct *p)
298{ 296{
299 struct mm_struct *mm; 297 struct mm_struct *mm;
300 struct task_struct *g, *q; 298 struct task_struct *g, *q;
@@ -313,15 +311,25 @@ static int oom_kill_task(struct task_struct *p, const char *message)
313 if (mm == NULL) 311 if (mm == NULL)
314 return 1; 312 return 1;
315 313
316 __oom_kill_task(p, message); 314 /*
315 * Don't kill the process if any threads are set to OOM_DISABLE
316 */
317 do_each_thread(g, q) {
318 if (q->mm == mm && p->oomkilladj == OOM_DISABLE)
319 return 1;
320 } while_each_thread(g, q);
321
322 __oom_kill_task(p, 1);
323
317 /* 324 /*
318 * kill all processes that share the ->mm (i.e. all threads), 325 * kill all processes that share the ->mm (i.e. all threads),
319 * but are in a different thread group 326 * but are in a different thread group. Don't let them have access
327 * to memory reserves though, otherwise we might deplete all memory.
320 */ 328 */
321 do_each_thread(g, q) 329 do_each_thread(g, q) {
322 if (q->mm == mm && q->tgid != p->tgid) 330 if (q->mm == mm && q->tgid != p->tgid)
323 __oom_kill_task(q, message); 331 force_sig(SIGKILL, p);
324 while_each_thread(g, q); 332 } while_each_thread(g, q);
325 333
326 return 0; 334 return 0;
327} 335}
@@ -337,21 +345,22 @@ static int oom_kill_process(struct task_struct *p, unsigned long points,
337 * its children or threads, just set TIF_MEMDIE so it can die quickly 345 * its children or threads, just set TIF_MEMDIE so it can die quickly
338 */ 346 */
339 if (p->flags & PF_EXITING) { 347 if (p->flags & PF_EXITING) {
340 __oom_kill_task(p, NULL); 348 __oom_kill_task(p, 0);
341 return 0; 349 return 0;
342 } 350 }
343 351
344 printk(KERN_ERR "Out of Memory: Kill process %d (%s) score %li" 352 printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
345 " and children.\n", p->pid, p->comm, points); 353 message, p->pid, p->comm, points);
354
346 /* Try to kill a child first */ 355 /* Try to kill a child first */
347 list_for_each(tsk, &p->children) { 356 list_for_each(tsk, &p->children) {
348 c = list_entry(tsk, struct task_struct, sibling); 357 c = list_entry(tsk, struct task_struct, sibling);
349 if (c->mm == p->mm) 358 if (c->mm == p->mm)
350 continue; 359 continue;
351 if (!oom_kill_task(c, message)) 360 if (!oom_kill_task(c))
352 return 0; 361 return 0;
353 } 362 }
354 return oom_kill_task(p, message); 363 return oom_kill_task(p);
355} 364}
356 365
357static BLOCKING_NOTIFIER_HEAD(oom_notify_list); 366static BLOCKING_NOTIFIER_HEAD(oom_notify_list);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index aa6fcc7ca66f..cace22b3ac25 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -83,14 +83,7 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = {
83 83
84EXPORT_SYMBOL(totalram_pages); 84EXPORT_SYMBOL(totalram_pages);
85 85
86/* 86static char * const zone_names[MAX_NR_ZONES] = {
87 * Used by page_zone() to look up the address of the struct zone whose
88 * id is encoded in the upper bits of page->flags
89 */
90struct zone *zone_table[1 << ZONETABLE_SHIFT] __read_mostly;
91EXPORT_SYMBOL(zone_table);
92
93static char *zone_names[MAX_NR_ZONES] = {
94 "DMA", 87 "DMA",
95#ifdef CONFIG_ZONE_DMA32 88#ifdef CONFIG_ZONE_DMA32
96 "DMA32", 89 "DMA32",
@@ -237,7 +230,7 @@ static void prep_compound_page(struct page *page, unsigned long order)
237 int i; 230 int i;
238 int nr_pages = 1 << order; 231 int nr_pages = 1 << order;
239 232
240 page[1].lru.next = (void *)free_compound_page; /* set dtor */ 233 set_compound_page_dtor(page, free_compound_page);
241 page[1].lru.prev = (void *)order; 234 page[1].lru.prev = (void *)order;
242 for (i = 0; i < nr_pages; i++) { 235 for (i = 0; i < nr_pages; i++) {
243 struct page *p = page + i; 236 struct page *p = page + i;
@@ -486,7 +479,7 @@ static void free_one_page(struct zone *zone, struct page *page, int order)
486 spin_lock(&zone->lock); 479 spin_lock(&zone->lock);
487 zone->all_unreclaimable = 0; 480 zone->all_unreclaimable = 0;
488 zone->pages_scanned = 0; 481 zone->pages_scanned = 0;
489 __free_one_page(page, zone ,order); 482 __free_one_page(page, zone, order);
490 spin_unlock(&zone->lock); 483 spin_unlock(&zone->lock);
491} 484}
492 485
@@ -605,6 +598,8 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
605 1 << PG_checked | 1 << PG_mappedtodisk); 598 1 << PG_checked | 1 << PG_mappedtodisk);
606 set_page_private(page, 0); 599 set_page_private(page, 0);
607 set_page_refcounted(page); 600 set_page_refcounted(page);
601
602 arch_alloc_page(page, order);
608 kernel_map_pages(page, 1 << order, 1); 603 kernel_map_pages(page, 1 << order, 1);
609 604
610 if (gfp_flags & __GFP_ZERO) 605 if (gfp_flags & __GFP_ZERO)
@@ -690,9 +685,15 @@ void drain_node_pages(int nodeid)
690 685
691 pcp = &pset->pcp[i]; 686 pcp = &pset->pcp[i];
692 if (pcp->count) { 687 if (pcp->count) {
688 int to_drain;
689
693 local_irq_save(flags); 690 local_irq_save(flags);
694 free_pages_bulk(zone, pcp->count, &pcp->list, 0); 691 if (pcp->count >= pcp->batch)
695 pcp->count = 0; 692 to_drain = pcp->batch;
693 else
694 to_drain = pcp->count;
695 free_pages_bulk(zone, to_drain, &pcp->list, 0);
696 pcp->count -= to_drain;
696 local_irq_restore(flags); 697 local_irq_restore(flags);
697 } 698 }
698 } 699 }
@@ -700,7 +701,6 @@ void drain_node_pages(int nodeid)
700} 701}
701#endif 702#endif
702 703
703#if defined(CONFIG_PM) || defined(CONFIG_HOTPLUG_CPU)
704static void __drain_pages(unsigned int cpu) 704static void __drain_pages(unsigned int cpu)
705{ 705{
706 unsigned long flags; 706 unsigned long flags;
@@ -722,7 +722,6 @@ static void __drain_pages(unsigned int cpu)
722 } 722 }
723 } 723 }
724} 724}
725#endif /* CONFIG_PM || CONFIG_HOTPLUG_CPU */
726 725
727#ifdef CONFIG_PM 726#ifdef CONFIG_PM
728 727
@@ -925,31 +924,160 @@ int zone_watermark_ok(struct zone *z, int order, unsigned long mark,
925 return 1; 924 return 1;
926} 925}
927 926
927#ifdef CONFIG_NUMA
928/*
929 * zlc_setup - Setup for "zonelist cache". Uses cached zone data to
930 * skip over zones that are not allowed by the cpuset, or that have
931 * been recently (in last second) found to be nearly full. See further
932 * comments in mmzone.h. Reduces cache footprint of zonelist scans
933 * that have to skip over alot of full or unallowed zones.
934 *
935 * If the zonelist cache is present in the passed in zonelist, then
936 * returns a pointer to the allowed node mask (either the current
937 * tasks mems_allowed, or node_online_map.)
938 *
939 * If the zonelist cache is not available for this zonelist, does
940 * nothing and returns NULL.
941 *
942 * If the fullzones BITMAP in the zonelist cache is stale (more than
943 * a second since last zap'd) then we zap it out (clear its bits.)
944 *
945 * We hold off even calling zlc_setup, until after we've checked the
946 * first zone in the zonelist, on the theory that most allocations will
947 * be satisfied from that first zone, so best to examine that zone as
948 * quickly as we can.
949 */
950static nodemask_t *zlc_setup(struct zonelist *zonelist, int alloc_flags)
951{
952 struct zonelist_cache *zlc; /* cached zonelist speedup info */
953 nodemask_t *allowednodes; /* zonelist_cache approximation */
954
955 zlc = zonelist->zlcache_ptr;
956 if (!zlc)
957 return NULL;
958
959 if (jiffies - zlc->last_full_zap > 1 * HZ) {
960 bitmap_zero(zlc->fullzones, MAX_ZONES_PER_ZONELIST);
961 zlc->last_full_zap = jiffies;
962 }
963
964 allowednodes = !in_interrupt() && (alloc_flags & ALLOC_CPUSET) ?
965 &cpuset_current_mems_allowed :
966 &node_online_map;
967 return allowednodes;
968}
969
970/*
971 * Given 'z' scanning a zonelist, run a couple of quick checks to see
972 * if it is worth looking at further for free memory:
973 * 1) Check that the zone isn't thought to be full (doesn't have its
974 * bit set in the zonelist_cache fullzones BITMAP).
975 * 2) Check that the zones node (obtained from the zonelist_cache
976 * z_to_n[] mapping) is allowed in the passed in allowednodes mask.
977 * Return true (non-zero) if zone is worth looking at further, or
978 * else return false (zero) if it is not.
979 *
980 * This check -ignores- the distinction between various watermarks,
981 * such as GFP_HIGH, GFP_ATOMIC, PF_MEMALLOC, ... If a zone is
982 * found to be full for any variation of these watermarks, it will
983 * be considered full for up to one second by all requests, unless
984 * we are so low on memory on all allowed nodes that we are forced
985 * into the second scan of the zonelist.
986 *
987 * In the second scan we ignore this zonelist cache and exactly
988 * apply the watermarks to all zones, even it is slower to do so.
989 * We are low on memory in the second scan, and should leave no stone
990 * unturned looking for a free page.
991 */
992static int zlc_zone_worth_trying(struct zonelist *zonelist, struct zone **z,
993 nodemask_t *allowednodes)
994{
995 struct zonelist_cache *zlc; /* cached zonelist speedup info */
996 int i; /* index of *z in zonelist zones */
997 int n; /* node that zone *z is on */
998
999 zlc = zonelist->zlcache_ptr;
1000 if (!zlc)
1001 return 1;
1002
1003 i = z - zonelist->zones;
1004 n = zlc->z_to_n[i];
1005
1006 /* This zone is worth trying if it is allowed but not full */
1007 return node_isset(n, *allowednodes) && !test_bit(i, zlc->fullzones);
1008}
1009
928/* 1010/*
929 * get_page_from_freeliest goes through the zonelist trying to allocate 1011 * Given 'z' scanning a zonelist, set the corresponding bit in
1012 * zlc->fullzones, so that subsequent attempts to allocate a page
1013 * from that zone don't waste time re-examining it.
1014 */
1015static void zlc_mark_zone_full(struct zonelist *zonelist, struct zone **z)
1016{
1017 struct zonelist_cache *zlc; /* cached zonelist speedup info */
1018 int i; /* index of *z in zonelist zones */
1019
1020 zlc = zonelist->zlcache_ptr;
1021 if (!zlc)
1022 return;
1023
1024 i = z - zonelist->zones;
1025
1026 set_bit(i, zlc->fullzones);
1027}
1028
1029#else /* CONFIG_NUMA */
1030
1031static nodemask_t *zlc_setup(struct zonelist *zonelist, int alloc_flags)
1032{
1033 return NULL;
1034}
1035
1036static int zlc_zone_worth_trying(struct zonelist *zonelist, struct zone **z,
1037 nodemask_t *allowednodes)
1038{
1039 return 1;
1040}
1041
1042static void zlc_mark_zone_full(struct zonelist *zonelist, struct zone **z)
1043{
1044}
1045#endif /* CONFIG_NUMA */
1046
1047/*
1048 * get_page_from_freelist goes through the zonelist trying to allocate
930 * a page. 1049 * a page.
931 */ 1050 */
932static struct page * 1051static struct page *
933get_page_from_freelist(gfp_t gfp_mask, unsigned int order, 1052get_page_from_freelist(gfp_t gfp_mask, unsigned int order,
934 struct zonelist *zonelist, int alloc_flags) 1053 struct zonelist *zonelist, int alloc_flags)
935{ 1054{
936 struct zone **z = zonelist->zones; 1055 struct zone **z;
937 struct page *page = NULL; 1056 struct page *page = NULL;
938 int classzone_idx = zone_idx(*z); 1057 int classzone_idx = zone_idx(zonelist->zones[0]);
939 struct zone *zone; 1058 struct zone *zone;
1059 nodemask_t *allowednodes = NULL;/* zonelist_cache approximation */
1060 int zlc_active = 0; /* set if using zonelist_cache */
1061 int did_zlc_setup = 0; /* just call zlc_setup() one time */
940 1062
1063zonelist_scan:
941 /* 1064 /*
942 * Go through the zonelist once, looking for a zone with enough free. 1065 * Scan zonelist, looking for a zone with enough free.
943 * See also cpuset_zone_allowed() comment in kernel/cpuset.c. 1066 * See also cpuset_zone_allowed() comment in kernel/cpuset.c.
944 */ 1067 */
1068 z = zonelist->zones;
1069
945 do { 1070 do {
1071 if (NUMA_BUILD && zlc_active &&
1072 !zlc_zone_worth_trying(zonelist, z, allowednodes))
1073 continue;
946 zone = *z; 1074 zone = *z;
947 if (unlikely(NUMA_BUILD && (gfp_mask & __GFP_THISNODE) && 1075 if (unlikely(NUMA_BUILD && (gfp_mask & __GFP_THISNODE) &&
948 zone->zone_pgdat != zonelist->zones[0]->zone_pgdat)) 1076 zone->zone_pgdat != zonelist->zones[0]->zone_pgdat))
949 break; 1077 break;
950 if ((alloc_flags & ALLOC_CPUSET) && 1078 if ((alloc_flags & ALLOC_CPUSET) &&
951 !cpuset_zone_allowed(zone, gfp_mask)) 1079 !cpuset_zone_allowed(zone, gfp_mask))
952 continue; 1080 goto try_next_zone;
953 1081
954 if (!(alloc_flags & ALLOC_NO_WATERMARKS)) { 1082 if (!(alloc_flags & ALLOC_NO_WATERMARKS)) {
955 unsigned long mark; 1083 unsigned long mark;
@@ -959,18 +1087,34 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order,
959 mark = zone->pages_low; 1087 mark = zone->pages_low;
960 else 1088 else
961 mark = zone->pages_high; 1089 mark = zone->pages_high;
962 if (!zone_watermark_ok(zone , order, mark, 1090 if (!zone_watermark_ok(zone, order, mark,
963 classzone_idx, alloc_flags)) 1091 classzone_idx, alloc_flags)) {
964 if (!zone_reclaim_mode || 1092 if (!zone_reclaim_mode ||
965 !zone_reclaim(zone, gfp_mask, order)) 1093 !zone_reclaim(zone, gfp_mask, order))
966 continue; 1094 goto this_zone_full;
1095 }
967 } 1096 }
968 1097
969 page = buffered_rmqueue(zonelist, zone, order, gfp_mask); 1098 page = buffered_rmqueue(zonelist, zone, order, gfp_mask);
970 if (page) { 1099 if (page)
971 break; 1100 break;
1101this_zone_full:
1102 if (NUMA_BUILD)
1103 zlc_mark_zone_full(zonelist, z);
1104try_next_zone:
1105 if (NUMA_BUILD && !did_zlc_setup) {
1106 /* we do zlc_setup after the first zone is tried */
1107 allowednodes = zlc_setup(zonelist, alloc_flags);
1108 zlc_active = 1;
1109 did_zlc_setup = 1;
972 } 1110 }
973 } while (*(++z) != NULL); 1111 } while (*(++z) != NULL);
1112
1113 if (unlikely(NUMA_BUILD && page == NULL && zlc_active)) {
1114 /* Disable zlc cache for second zonelist scan */
1115 zlc_active = 0;
1116 goto zonelist_scan;
1117 }
974 return page; 1118 return page;
975} 1119}
976 1120
@@ -1005,9 +1149,19 @@ restart:
1005 if (page) 1149 if (page)
1006 goto got_pg; 1150 goto got_pg;
1007 1151
1008 do { 1152 /*
1153 * GFP_THISNODE (meaning __GFP_THISNODE, __GFP_NORETRY and
1154 * __GFP_NOWARN set) should not cause reclaim since the subsystem
1155 * (f.e. slab) using GFP_THISNODE may choose to trigger reclaim
1156 * using a larger set of nodes after it has established that the
1157 * allowed per node queues are empty and that nodes are
1158 * over allocated.
1159 */
1160 if (NUMA_BUILD && (gfp_mask & GFP_THISNODE) == GFP_THISNODE)
1161 goto nopage;
1162
1163 for (z = zonelist->zones; *z; z++)
1009 wakeup_kswapd(*z, order); 1164 wakeup_kswapd(*z, order);
1010 } while (*(++z));
1011 1165
1012 /* 1166 /*
1013 * OK, we're below the kswapd watermark and have kicked background 1167 * OK, we're below the kswapd watermark and have kicked background
@@ -1041,6 +1195,7 @@ restart:
1041 1195
1042 /* This allocation should allow future memory freeing. */ 1196 /* This allocation should allow future memory freeing. */
1043 1197
1198rebalance:
1044 if (((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE))) 1199 if (((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE)))
1045 && !in_interrupt()) { 1200 && !in_interrupt()) {
1046 if (!(gfp_mask & __GFP_NOMEMALLOC)) { 1201 if (!(gfp_mask & __GFP_NOMEMALLOC)) {
@@ -1062,7 +1217,6 @@ nofail_alloc:
1062 if (!wait) 1217 if (!wait)
1063 goto nopage; 1218 goto nopage;
1064 1219
1065rebalance:
1066 cond_resched(); 1220 cond_resched();
1067 1221
1068 /* We now go into synchronous reclaim */ 1222 /* We now go into synchronous reclaim */
@@ -1262,7 +1416,7 @@ unsigned int nr_free_pagecache_pages(void)
1262static inline void show_node(struct zone *zone) 1416static inline void show_node(struct zone *zone)
1263{ 1417{
1264 if (NUMA_BUILD) 1418 if (NUMA_BUILD)
1265 printk("Node %ld ", zone_to_nid(zone)); 1419 printk("Node %d ", zone_to_nid(zone));
1266} 1420}
1267 1421
1268void si_meminfo(struct sysinfo *val) 1422void si_meminfo(struct sysinfo *val)
@@ -1542,6 +1696,24 @@ static void __meminit build_zonelists(pg_data_t *pgdat)
1542 } 1696 }
1543} 1697}
1544 1698
1699/* Construct the zonelist performance cache - see further mmzone.h */
1700static void __meminit build_zonelist_cache(pg_data_t *pgdat)
1701{
1702 int i;
1703
1704 for (i = 0; i < MAX_NR_ZONES; i++) {
1705 struct zonelist *zonelist;
1706 struct zonelist_cache *zlc;
1707 struct zone **z;
1708
1709 zonelist = pgdat->node_zonelists + i;
1710 zonelist->zlcache_ptr = zlc = &zonelist->zlcache;
1711 bitmap_zero(zlc->fullzones, MAX_ZONES_PER_ZONELIST);
1712 for (z = zonelist->zones; *z; z++)
1713 zlc->z_to_n[z - zonelist->zones] = zone_to_nid(*z);
1714 }
1715}
1716
1545#else /* CONFIG_NUMA */ 1717#else /* CONFIG_NUMA */
1546 1718
1547static void __meminit build_zonelists(pg_data_t *pgdat) 1719static void __meminit build_zonelists(pg_data_t *pgdat)
@@ -1579,14 +1751,26 @@ static void __meminit build_zonelists(pg_data_t *pgdat)
1579 } 1751 }
1580} 1752}
1581 1753
1754/* non-NUMA variant of zonelist performance cache - just NULL zlcache_ptr */
1755static void __meminit build_zonelist_cache(pg_data_t *pgdat)
1756{
1757 int i;
1758
1759 for (i = 0; i < MAX_NR_ZONES; i++)
1760 pgdat->node_zonelists[i].zlcache_ptr = NULL;
1761}
1762
1582#endif /* CONFIG_NUMA */ 1763#endif /* CONFIG_NUMA */
1583 1764
1584/* return values int ....just for stop_machine_run() */ 1765/* return values int ....just for stop_machine_run() */
1585static int __meminit __build_all_zonelists(void *dummy) 1766static int __meminit __build_all_zonelists(void *dummy)
1586{ 1767{
1587 int nid; 1768 int nid;
1588 for_each_online_node(nid) 1769
1770 for_each_online_node(nid) {
1589 build_zonelists(NODE_DATA(nid)); 1771 build_zonelists(NODE_DATA(nid));
1772 build_zonelist_cache(NODE_DATA(nid));
1773 }
1590 return 0; 1774 return 0;
1591} 1775}
1592 1776
@@ -1715,20 +1899,6 @@ void zone_init_free_lists(struct pglist_data *pgdat, struct zone *zone,
1715 } 1899 }
1716} 1900}
1717 1901
1718#define ZONETABLE_INDEX(x, zone_nr) ((x << ZONES_SHIFT) | zone_nr)
1719void zonetable_add(struct zone *zone, int nid, enum zone_type zid,
1720 unsigned long pfn, unsigned long size)
1721{
1722 unsigned long snum = pfn_to_section_nr(pfn);
1723 unsigned long end = pfn_to_section_nr(pfn + size);
1724
1725 if (FLAGS_HAS_NODE)
1726 zone_table[ZONETABLE_INDEX(nid, zid)] = zone;
1727 else
1728 for (; snum <= end; snum++)
1729 zone_table[ZONETABLE_INDEX(snum, zid)] = zone;
1730}
1731
1732#ifndef __HAVE_ARCH_MEMMAP_INIT 1902#ifndef __HAVE_ARCH_MEMMAP_INIT
1733#define memmap_init(size, nid, zone, start_pfn) \ 1903#define memmap_init(size, nid, zone, start_pfn) \
1734 memmap_init_zone((size), (nid), (zone), (start_pfn)) 1904 memmap_init_zone((size), (nid), (zone), (start_pfn))
@@ -1881,16 +2051,16 @@ static int __cpuinit pageset_cpuup_callback(struct notifier_block *nfb,
1881 int ret = NOTIFY_OK; 2051 int ret = NOTIFY_OK;
1882 2052
1883 switch (action) { 2053 switch (action) {
1884 case CPU_UP_PREPARE: 2054 case CPU_UP_PREPARE:
1885 if (process_zones(cpu)) 2055 if (process_zones(cpu))
1886 ret = NOTIFY_BAD; 2056 ret = NOTIFY_BAD;
1887 break; 2057 break;
1888 case CPU_UP_CANCELED: 2058 case CPU_UP_CANCELED:
1889 case CPU_DEAD: 2059 case CPU_DEAD:
1890 free_zone_pagesets(cpu); 2060 free_zone_pagesets(cpu);
1891 break; 2061 break;
1892 default: 2062 default:
1893 break; 2063 break;
1894 } 2064 }
1895 return ret; 2065 return ret;
1896} 2066}
@@ -2421,7 +2591,6 @@ static void __meminit free_area_init_core(struct pglist_data *pgdat,
2421 if (!size) 2591 if (!size)
2422 continue; 2592 continue;
2423 2593
2424 zonetable_add(zone, nid, j, zone_start_pfn, size);
2425 ret = init_currently_empty_zone(zone, zone_start_pfn, size); 2594 ret = init_currently_empty_zone(zone, zone_start_pfn, size);
2426 BUG_ON(ret); 2595 BUG_ON(ret);
2427 zone_start_pfn += size; 2596 zone_start_pfn += size;
@@ -2736,7 +2905,6 @@ void __init free_area_init(unsigned long *zones_size)
2736 __pa(PAGE_OFFSET) >> PAGE_SHIFT, NULL); 2905 __pa(PAGE_OFFSET) >> PAGE_SHIFT, NULL);
2737} 2906}
2738 2907
2739#ifdef CONFIG_HOTPLUG_CPU
2740static int page_alloc_cpu_notify(struct notifier_block *self, 2908static int page_alloc_cpu_notify(struct notifier_block *self,
2741 unsigned long action, void *hcpu) 2909 unsigned long action, void *hcpu)
2742{ 2910{
@@ -2751,7 +2919,6 @@ static int page_alloc_cpu_notify(struct notifier_block *self,
2751 } 2919 }
2752 return NOTIFY_OK; 2920 return NOTIFY_OK;
2753} 2921}
2754#endif /* CONFIG_HOTPLUG_CPU */
2755 2922
2756void __init page_alloc_init(void) 2923void __init page_alloc_init(void)
2757{ 2924{
@@ -3055,7 +3222,7 @@ void *__init alloc_large_system_hash(const char *tablename,
3055 /* allow the kernel cmdline to have a say */ 3222 /* allow the kernel cmdline to have a say */
3056 if (!numentries) { 3223 if (!numentries) {
3057 /* round applicable memory size up to nearest megabyte */ 3224 /* round applicable memory size up to nearest megabyte */
3058 numentries = (flags & HASH_HIGHMEM) ? nr_all_pages : nr_kernel_pages; 3225 numentries = nr_kernel_pages;
3059 numentries += (1UL << (20 - PAGE_SHIFT)) - 1; 3226 numentries += (1UL << (20 - PAGE_SHIFT)) - 1;
3060 numentries >>= 20 - PAGE_SHIFT; 3227 numentries >>= 20 - PAGE_SHIFT;
3061 numentries <<= 20 - PAGE_SHIFT; 3228 numentries <<= 20 - PAGE_SHIFT;
diff --git a/mm/page_io.c b/mm/page_io.c
index d4840ecbf8f9..dbffec0d78c9 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -147,48 +147,3 @@ int swap_readpage(struct file *file, struct page *page)
147out: 147out:
148 return ret; 148 return ret;
149} 149}
150
151#ifdef CONFIG_SOFTWARE_SUSPEND
152/*
153 * A scruffy utility function to read or write an arbitrary swap page
154 * and wait on the I/O. The caller must have a ref on the page.
155 *
156 * We use end_swap_bio_read() even for writes, because it happens to do what
157 * we want.
158 */
159int rw_swap_page_sync(int rw, swp_entry_t entry, struct page *page,
160 struct bio **bio_chain)
161{
162 struct bio *bio;
163 int ret = 0;
164 int bio_rw;
165
166 lock_page(page);
167
168 bio = get_swap_bio(GFP_KERNEL, entry.val, page, end_swap_bio_read);
169 if (bio == NULL) {
170 unlock_page(page);
171 ret = -ENOMEM;
172 goto out;
173 }
174
175 bio_rw = rw;
176 if (!bio_chain)
177 bio_rw |= (1 << BIO_RW_SYNC);
178 if (bio_chain)
179 bio_get(bio);
180 submit_bio(bio_rw, bio);
181 if (bio_chain == NULL) {
182 wait_on_page_locked(page);
183
184 if (!PageUptodate(page) || PageError(page))
185 ret = -EIO;
186 }
187 if (bio_chain) {
188 bio->bi_private = *bio_chain;
189 *bio_chain = bio;
190 }
191out:
192 return ret;
193}
194#endif
diff --git a/mm/pdflush.c b/mm/pdflush.c
index b02102feeb4b..8ce0900dc95c 100644
--- a/mm/pdflush.c
+++ b/mm/pdflush.c
@@ -21,6 +21,7 @@
21#include <linux/writeback.h> // Prototypes pdflush_operation() 21#include <linux/writeback.h> // Prototypes pdflush_operation()
22#include <linux/kthread.h> 22#include <linux/kthread.h>
23#include <linux/cpuset.h> 23#include <linux/cpuset.h>
24#include <linux/freezer.h>
24 25
25 26
26/* 27/*
diff --git a/mm/readahead.c b/mm/readahead.c
index 23cb61a01c6e..a386f2b6b335 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -148,13 +148,7 @@ int read_cache_pages(struct address_space *mapping, struct list_head *pages,
148 if (!pagevec_add(&lru_pvec, page)) 148 if (!pagevec_add(&lru_pvec, page))
149 __pagevec_lru_add(&lru_pvec); 149 __pagevec_lru_add(&lru_pvec);
150 if (ret) { 150 if (ret) {
151 while (!list_empty(pages)) { 151 put_pages_list(pages);
152 struct page *victim;
153
154 victim = list_to_page(pages);
155 list_del(&victim->lru);
156 page_cache_release(victim);
157 }
158 break; 152 break;
159 } 153 }
160 } 154 }
diff --git a/mm/shmem.c b/mm/shmem.c
index 4959535fc14c..c820b4f77b8d 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -177,7 +177,7 @@ static inline void shmem_unacct_blocks(unsigned long flags, long pages)
177 177
178static struct super_operations shmem_ops; 178static struct super_operations shmem_ops;
179static const struct address_space_operations shmem_aops; 179static const struct address_space_operations shmem_aops;
180static struct file_operations shmem_file_operations; 180static const struct file_operations shmem_file_operations;
181static struct inode_operations shmem_inode_operations; 181static struct inode_operations shmem_inode_operations;
182static struct inode_operations shmem_dir_inode_operations; 182static struct inode_operations shmem_dir_inode_operations;
183static struct inode_operations shmem_special_inode_operations; 183static struct inode_operations shmem_special_inode_operations;
@@ -1943,7 +1943,7 @@ static int shmem_xattr_security_set(struct inode *inode, const char *name,
1943 return security_inode_setsecurity(inode, name, value, size, flags); 1943 return security_inode_setsecurity(inode, name, value, size, flags);
1944} 1944}
1945 1945
1946struct xattr_handler shmem_xattr_security_handler = { 1946static struct xattr_handler shmem_xattr_security_handler = {
1947 .prefix = XATTR_SECURITY_PREFIX, 1947 .prefix = XATTR_SECURITY_PREFIX,
1948 .list = shmem_xattr_security_list, 1948 .list = shmem_xattr_security_list,
1949 .get = shmem_xattr_security_get, 1949 .get = shmem_xattr_security_get,
@@ -2263,7 +2263,7 @@ static struct kmem_cache *shmem_inode_cachep;
2263static struct inode *shmem_alloc_inode(struct super_block *sb) 2263static struct inode *shmem_alloc_inode(struct super_block *sb)
2264{ 2264{
2265 struct shmem_inode_info *p; 2265 struct shmem_inode_info *p;
2266 p = (struct shmem_inode_info *)kmem_cache_alloc(shmem_inode_cachep, SLAB_KERNEL); 2266 p = (struct shmem_inode_info *)kmem_cache_alloc(shmem_inode_cachep, GFP_KERNEL);
2267 if (!p) 2267 if (!p)
2268 return NULL; 2268 return NULL;
2269 return &p->vfs_inode; 2269 return &p->vfs_inode;
@@ -2319,7 +2319,7 @@ static const struct address_space_operations shmem_aops = {
2319 .migratepage = migrate_page, 2319 .migratepage = migrate_page,
2320}; 2320};
2321 2321
2322static struct file_operations shmem_file_operations = { 2322static const struct file_operations shmem_file_operations = {
2323 .mmap = shmem_mmap, 2323 .mmap = shmem_mmap,
2324#ifdef CONFIG_TMPFS 2324#ifdef CONFIG_TMPFS
2325 .llseek = generic_file_llseek, 2325 .llseek = generic_file_llseek,
diff --git a/mm/slab.c b/mm/slab.c
index 3c4a7e34eddc..068cb4503c15 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -103,12 +103,12 @@
103#include <linux/module.h> 103#include <linux/module.h>
104#include <linux/rcupdate.h> 104#include <linux/rcupdate.h>
105#include <linux/string.h> 105#include <linux/string.h>
106#include <linux/uaccess.h>
106#include <linux/nodemask.h> 107#include <linux/nodemask.h>
107#include <linux/mempolicy.h> 108#include <linux/mempolicy.h>
108#include <linux/mutex.h> 109#include <linux/mutex.h>
109#include <linux/rtmutex.h> 110#include <linux/rtmutex.h>
110 111
111#include <asm/uaccess.h>
112#include <asm/cacheflush.h> 112#include <asm/cacheflush.h>
113#include <asm/tlbflush.h> 113#include <asm/tlbflush.h>
114#include <asm/page.h> 114#include <asm/page.h>
@@ -313,7 +313,7 @@ static int drain_freelist(struct kmem_cache *cache,
313static void free_block(struct kmem_cache *cachep, void **objpp, int len, 313static void free_block(struct kmem_cache *cachep, void **objpp, int len,
314 int node); 314 int node);
315static int enable_cpucache(struct kmem_cache *cachep); 315static int enable_cpucache(struct kmem_cache *cachep);
316static void cache_reap(void *unused); 316static void cache_reap(struct work_struct *unused);
317 317
318/* 318/*
319 * This function must be completely optimized away if a constant is passed to 319 * This function must be completely optimized away if a constant is passed to
@@ -730,7 +730,10 @@ static inline void init_lock_keys(void)
730} 730}
731#endif 731#endif
732 732
733/* Guard access to the cache-chain. */ 733/*
734 * 1. Guard access to the cache-chain.
735 * 2. Protect sanity of cpu_online_map against cpu hotplug events
736 */
734static DEFINE_MUTEX(cache_chain_mutex); 737static DEFINE_MUTEX(cache_chain_mutex);
735static struct list_head cache_chain; 738static struct list_head cache_chain;
736 739
@@ -753,7 +756,7 @@ int slab_is_available(void)
753 return g_cpucache_up == FULL; 756 return g_cpucache_up == FULL;
754} 757}
755 758
756static DEFINE_PER_CPU(struct work_struct, reap_work); 759static DEFINE_PER_CPU(struct delayed_work, reap_work);
757 760
758static inline struct array_cache *cpu_cache_get(struct kmem_cache *cachep) 761static inline struct array_cache *cpu_cache_get(struct kmem_cache *cachep)
759{ 762{
@@ -866,6 +869,22 @@ static void __slab_error(const char *function, struct kmem_cache *cachep,
866 dump_stack(); 869 dump_stack();
867} 870}
868 871
872/*
873 * By default on NUMA we use alien caches to stage the freeing of
874 * objects allocated from other nodes. This causes massive memory
875 * inefficiencies when using fake NUMA setup to split memory into a
876 * large number of small nodes, so it can be disabled on the command
877 * line
878 */
879
880static int use_alien_caches __read_mostly = 1;
881static int __init noaliencache_setup(char *s)
882{
883 use_alien_caches = 0;
884 return 1;
885}
886__setup("noaliencache", noaliencache_setup);
887
869#ifdef CONFIG_NUMA 888#ifdef CONFIG_NUMA
870/* 889/*
871 * Special reaping functions for NUMA systems called from cache_reap(). 890 * Special reaping functions for NUMA systems called from cache_reap().
@@ -916,16 +935,16 @@ static void next_reap_node(void)
916 */ 935 */
917static void __devinit start_cpu_timer(int cpu) 936static void __devinit start_cpu_timer(int cpu)
918{ 937{
919 struct work_struct *reap_work = &per_cpu(reap_work, cpu); 938 struct delayed_work *reap_work = &per_cpu(reap_work, cpu);
920 939
921 /* 940 /*
922 * When this gets called from do_initcalls via cpucache_init(), 941 * When this gets called from do_initcalls via cpucache_init(),
923 * init_workqueues() has already run, so keventd will be setup 942 * init_workqueues() has already run, so keventd will be setup
924 * at that time. 943 * at that time.
925 */ 944 */
926 if (keventd_up() && reap_work->func == NULL) { 945 if (keventd_up() && reap_work->work.func == NULL) {
927 init_reap_node(cpu); 946 init_reap_node(cpu);
928 INIT_WORK(reap_work, cache_reap, NULL); 947 INIT_DELAYED_WORK(reap_work, cache_reap);
929 schedule_delayed_work_on(cpu, reap_work, HZ + 3 * cpu); 948 schedule_delayed_work_on(cpu, reap_work, HZ + 3 * cpu);
930 } 949 }
931} 950}
@@ -996,7 +1015,7 @@ static inline void *alternate_node_alloc(struct kmem_cache *cachep,
996 return NULL; 1015 return NULL;
997} 1016}
998 1017
999static inline void *__cache_alloc_node(struct kmem_cache *cachep, 1018static inline void *____cache_alloc_node(struct kmem_cache *cachep,
1000 gfp_t flags, int nodeid) 1019 gfp_t flags, int nodeid)
1001{ 1020{
1002 return NULL; 1021 return NULL;
@@ -1004,7 +1023,7 @@ static inline void *__cache_alloc_node(struct kmem_cache *cachep,
1004 1023
1005#else /* CONFIG_NUMA */ 1024#else /* CONFIG_NUMA */
1006 1025
1007static void *__cache_alloc_node(struct kmem_cache *, gfp_t, int); 1026static void *____cache_alloc_node(struct kmem_cache *, gfp_t, int);
1008static void *alternate_node_alloc(struct kmem_cache *, gfp_t); 1027static void *alternate_node_alloc(struct kmem_cache *, gfp_t);
1009 1028
1010static struct array_cache **alloc_alien_cache(int node, int limit) 1029static struct array_cache **alloc_alien_cache(int node, int limit)
@@ -1114,7 +1133,7 @@ static inline int cache_free_alien(struct kmem_cache *cachep, void *objp)
1114 * Make sure we are not freeing a object from another node to the array 1133 * Make sure we are not freeing a object from another node to the array
1115 * cache on this cpu. 1134 * cache on this cpu.
1116 */ 1135 */
1117 if (likely(slabp->nodeid == node)) 1136 if (likely(slabp->nodeid == node) || unlikely(!use_alien_caches))
1118 return 0; 1137 return 0;
1119 1138
1120 l3 = cachep->nodelists[node]; 1139 l3 = cachep->nodelists[node];
@@ -1192,7 +1211,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
1192 list_for_each_entry(cachep, &cache_chain, next) { 1211 list_for_each_entry(cachep, &cache_chain, next) {
1193 struct array_cache *nc; 1212 struct array_cache *nc;
1194 struct array_cache *shared; 1213 struct array_cache *shared;
1195 struct array_cache **alien; 1214 struct array_cache **alien = NULL;
1196 1215
1197 nc = alloc_arraycache(node, cachep->limit, 1216 nc = alloc_arraycache(node, cachep->limit,
1198 cachep->batchcount); 1217 cachep->batchcount);
@@ -1204,9 +1223,11 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
1204 if (!shared) 1223 if (!shared)
1205 goto bad; 1224 goto bad;
1206 1225
1207 alien = alloc_alien_cache(node, cachep->limit); 1226 if (use_alien_caches) {
1208 if (!alien) 1227 alien = alloc_alien_cache(node, cachep->limit);
1209 goto bad; 1228 if (!alien)
1229 goto bad;
1230 }
1210 cachep->array[cpu] = nc; 1231 cachep->array[cpu] = nc;
1211 l3 = cachep->nodelists[node]; 1232 l3 = cachep->nodelists[node];
1212 BUG_ON(!l3); 1233 BUG_ON(!l3);
@@ -1230,12 +1251,18 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
1230 kfree(shared); 1251 kfree(shared);
1231 free_alien_cache(alien); 1252 free_alien_cache(alien);
1232 } 1253 }
1233 mutex_unlock(&cache_chain_mutex);
1234 break; 1254 break;
1235 case CPU_ONLINE: 1255 case CPU_ONLINE:
1256 mutex_unlock(&cache_chain_mutex);
1236 start_cpu_timer(cpu); 1257 start_cpu_timer(cpu);
1237 break; 1258 break;
1238#ifdef CONFIG_HOTPLUG_CPU 1259#ifdef CONFIG_HOTPLUG_CPU
1260 case CPU_DOWN_PREPARE:
1261 mutex_lock(&cache_chain_mutex);
1262 break;
1263 case CPU_DOWN_FAILED:
1264 mutex_unlock(&cache_chain_mutex);
1265 break;
1239 case CPU_DEAD: 1266 case CPU_DEAD:
1240 /* 1267 /*
1241 * Even if all the cpus of a node are down, we don't free the 1268 * Even if all the cpus of a node are down, we don't free the
@@ -1246,8 +1273,8 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
1246 * gets destroyed at kmem_cache_destroy(). 1273 * gets destroyed at kmem_cache_destroy().
1247 */ 1274 */
1248 /* fall thru */ 1275 /* fall thru */
1276#endif
1249 case CPU_UP_CANCELED: 1277 case CPU_UP_CANCELED:
1250 mutex_lock(&cache_chain_mutex);
1251 list_for_each_entry(cachep, &cache_chain, next) { 1278 list_for_each_entry(cachep, &cache_chain, next) {
1252 struct array_cache *nc; 1279 struct array_cache *nc;
1253 struct array_cache *shared; 1280 struct array_cache *shared;
@@ -1308,11 +1335,9 @@ free_array_cache:
1308 } 1335 }
1309 mutex_unlock(&cache_chain_mutex); 1336 mutex_unlock(&cache_chain_mutex);
1310 break; 1337 break;
1311#endif
1312 } 1338 }
1313 return NOTIFY_OK; 1339 return NOTIFY_OK;
1314bad: 1340bad:
1315 mutex_unlock(&cache_chain_mutex);
1316 return NOTIFY_BAD; 1341 return NOTIFY_BAD;
1317} 1342}
1318 1343
@@ -1580,12 +1605,7 @@ static void *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, int nodeid)
1580 flags |= __GFP_COMP; 1605 flags |= __GFP_COMP;
1581#endif 1606#endif
1582 1607
1583 /* 1608 flags |= cachep->gfpflags;
1584 * Under NUMA we want memory on the indicated node. We will handle
1585 * the needed fallback ourselves since we want to serve from our
1586 * per node object lists first for other nodes.
1587 */
1588 flags |= cachep->gfpflags | GFP_THISNODE;
1589 1609
1590 page = alloc_pages_node(nodeid, flags, cachep->gfporder); 1610 page = alloc_pages_node(nodeid, flags, cachep->gfporder);
1591 if (!page) 1611 if (!page)
@@ -2098,15 +2118,12 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2098 } 2118 }
2099 2119
2100 /* 2120 /*
2101 * Prevent CPUs from coming and going. 2121 * We use cache_chain_mutex to ensure a consistent view of
2102 * lock_cpu_hotplug() nests outside cache_chain_mutex 2122 * cpu_online_map as well. Please see cpuup_callback
2103 */ 2123 */
2104 lock_cpu_hotplug();
2105
2106 mutex_lock(&cache_chain_mutex); 2124 mutex_lock(&cache_chain_mutex);
2107 2125
2108 list_for_each_entry(pc, &cache_chain, next) { 2126 list_for_each_entry(pc, &cache_chain, next) {
2109 mm_segment_t old_fs = get_fs();
2110 char tmp; 2127 char tmp;
2111 int res; 2128 int res;
2112 2129
@@ -2115,9 +2132,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2115 * destroy its slab cache and no-one else reuses the vmalloc 2132 * destroy its slab cache and no-one else reuses the vmalloc
2116 * area of the module. Print a warning. 2133 * area of the module. Print a warning.
2117 */ 2134 */
2118 set_fs(KERNEL_DS); 2135 res = probe_kernel_address(pc->name, tmp);
2119 res = __get_user(tmp, pc->name);
2120 set_fs(old_fs);
2121 if (res) { 2136 if (res) {
2122 printk("SLAB: cache with size %d has lost its name\n", 2137 printk("SLAB: cache with size %d has lost its name\n",
2123 pc->buffer_size); 2138 pc->buffer_size);
@@ -2197,25 +2212,24 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2197 if (flags & SLAB_RED_ZONE || flags & SLAB_STORE_USER) 2212 if (flags & SLAB_RED_ZONE || flags & SLAB_STORE_USER)
2198 ralign = BYTES_PER_WORD; 2213 ralign = BYTES_PER_WORD;
2199 2214
2200 /* 2) arch mandated alignment: disables debug if necessary */ 2215 /* 2) arch mandated alignment */
2201 if (ralign < ARCH_SLAB_MINALIGN) { 2216 if (ralign < ARCH_SLAB_MINALIGN) {
2202 ralign = ARCH_SLAB_MINALIGN; 2217 ralign = ARCH_SLAB_MINALIGN;
2203 if (ralign > BYTES_PER_WORD)
2204 flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
2205 } 2218 }
2206 /* 3) caller mandated alignment: disables debug if necessary */ 2219 /* 3) caller mandated alignment */
2207 if (ralign < align) { 2220 if (ralign < align) {
2208 ralign = align; 2221 ralign = align;
2209 if (ralign > BYTES_PER_WORD)
2210 flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
2211 } 2222 }
2223 /* disable debug if necessary */
2224 if (ralign > BYTES_PER_WORD)
2225 flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
2212 /* 2226 /*
2213 * 4) Store it. 2227 * 4) Store it.
2214 */ 2228 */
2215 align = ralign; 2229 align = ralign;
2216 2230
2217 /* Get cache's description obj. */ 2231 /* Get cache's description obj. */
2218 cachep = kmem_cache_zalloc(&cache_cache, SLAB_KERNEL); 2232 cachep = kmem_cache_zalloc(&cache_cache, GFP_KERNEL);
2219 if (!cachep) 2233 if (!cachep)
2220 goto oops; 2234 goto oops;
2221 2235
@@ -2326,7 +2340,6 @@ oops:
2326 panic("kmem_cache_create(): failed to create slab `%s'\n", 2340 panic("kmem_cache_create(): failed to create slab `%s'\n",
2327 name); 2341 name);
2328 mutex_unlock(&cache_chain_mutex); 2342 mutex_unlock(&cache_chain_mutex);
2329 unlock_cpu_hotplug();
2330 return cachep; 2343 return cachep;
2331} 2344}
2332EXPORT_SYMBOL(kmem_cache_create); 2345EXPORT_SYMBOL(kmem_cache_create);
@@ -2444,6 +2457,7 @@ out:
2444 return nr_freed; 2457 return nr_freed;
2445} 2458}
2446 2459
2460/* Called with cache_chain_mutex held to protect against cpu hotplug */
2447static int __cache_shrink(struct kmem_cache *cachep) 2461static int __cache_shrink(struct kmem_cache *cachep)
2448{ 2462{
2449 int ret = 0, i = 0; 2463 int ret = 0, i = 0;
@@ -2474,9 +2488,13 @@ static int __cache_shrink(struct kmem_cache *cachep)
2474 */ 2488 */
2475int kmem_cache_shrink(struct kmem_cache *cachep) 2489int kmem_cache_shrink(struct kmem_cache *cachep)
2476{ 2490{
2491 int ret;
2477 BUG_ON(!cachep || in_interrupt()); 2492 BUG_ON(!cachep || in_interrupt());
2478 2493
2479 return __cache_shrink(cachep); 2494 mutex_lock(&cache_chain_mutex);
2495 ret = __cache_shrink(cachep);
2496 mutex_unlock(&cache_chain_mutex);
2497 return ret;
2480} 2498}
2481EXPORT_SYMBOL(kmem_cache_shrink); 2499EXPORT_SYMBOL(kmem_cache_shrink);
2482 2500
@@ -2500,23 +2518,16 @@ void kmem_cache_destroy(struct kmem_cache *cachep)
2500{ 2518{
2501 BUG_ON(!cachep || in_interrupt()); 2519 BUG_ON(!cachep || in_interrupt());
2502 2520
2503 /* Don't let CPUs to come and go */
2504 lock_cpu_hotplug();
2505
2506 /* Find the cache in the chain of caches. */ 2521 /* Find the cache in the chain of caches. */
2507 mutex_lock(&cache_chain_mutex); 2522 mutex_lock(&cache_chain_mutex);
2508 /* 2523 /*
2509 * the chain is never empty, cache_cache is never destroyed 2524 * the chain is never empty, cache_cache is never destroyed
2510 */ 2525 */
2511 list_del(&cachep->next); 2526 list_del(&cachep->next);
2512 mutex_unlock(&cache_chain_mutex);
2513
2514 if (__cache_shrink(cachep)) { 2527 if (__cache_shrink(cachep)) {
2515 slab_error(cachep, "Can't free all objects"); 2528 slab_error(cachep, "Can't free all objects");
2516 mutex_lock(&cache_chain_mutex);
2517 list_add(&cachep->next, &cache_chain); 2529 list_add(&cachep->next, &cache_chain);
2518 mutex_unlock(&cache_chain_mutex); 2530 mutex_unlock(&cache_chain_mutex);
2519 unlock_cpu_hotplug();
2520 return; 2531 return;
2521 } 2532 }
2522 2533
@@ -2524,7 +2535,7 @@ void kmem_cache_destroy(struct kmem_cache *cachep)
2524 synchronize_rcu(); 2535 synchronize_rcu();
2525 2536
2526 __kmem_cache_destroy(cachep); 2537 __kmem_cache_destroy(cachep);
2527 unlock_cpu_hotplug(); 2538 mutex_unlock(&cache_chain_mutex);
2528} 2539}
2529EXPORT_SYMBOL(kmem_cache_destroy); 2540EXPORT_SYMBOL(kmem_cache_destroy);
2530 2541
@@ -2548,7 +2559,7 @@ static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp,
2548 if (OFF_SLAB(cachep)) { 2559 if (OFF_SLAB(cachep)) {
2549 /* Slab management obj is off-slab. */ 2560 /* Slab management obj is off-slab. */
2550 slabp = kmem_cache_alloc_node(cachep->slabp_cache, 2561 slabp = kmem_cache_alloc_node(cachep->slabp_cache,
2551 local_flags, nodeid); 2562 local_flags & ~GFP_THISNODE, nodeid);
2552 if (!slabp) 2563 if (!slabp)
2553 return NULL; 2564 return NULL;
2554 } else { 2565 } else {
@@ -2618,7 +2629,7 @@ static void cache_init_objs(struct kmem_cache *cachep,
2618 2629
2619static void kmem_flagcheck(struct kmem_cache *cachep, gfp_t flags) 2630static void kmem_flagcheck(struct kmem_cache *cachep, gfp_t flags)
2620{ 2631{
2621 if (flags & SLAB_DMA) 2632 if (flags & GFP_DMA)
2622 BUG_ON(!(cachep->gfpflags & GFP_DMA)); 2633 BUG_ON(!(cachep->gfpflags & GFP_DMA));
2623 else 2634 else
2624 BUG_ON(cachep->gfpflags & GFP_DMA); 2635 BUG_ON(cachep->gfpflags & GFP_DMA);
@@ -2689,10 +2700,10 @@ static void slab_map_pages(struct kmem_cache *cache, struct slab *slab,
2689 * Grow (by 1) the number of slabs within a cache. This is called by 2700 * Grow (by 1) the number of slabs within a cache. This is called by
2690 * kmem_cache_alloc() when there are no active objs left in a cache. 2701 * kmem_cache_alloc() when there are no active objs left in a cache.
2691 */ 2702 */
2692static int cache_grow(struct kmem_cache *cachep, gfp_t flags, int nodeid) 2703static int cache_grow(struct kmem_cache *cachep,
2704 gfp_t flags, int nodeid, void *objp)
2693{ 2705{
2694 struct slab *slabp; 2706 struct slab *slabp;
2695 void *objp;
2696 size_t offset; 2707 size_t offset;
2697 gfp_t local_flags; 2708 gfp_t local_flags;
2698 unsigned long ctor_flags; 2709 unsigned long ctor_flags;
@@ -2702,12 +2713,12 @@ static int cache_grow(struct kmem_cache *cachep, gfp_t flags, int nodeid)
2702 * Be lazy and only check for valid flags here, keeping it out of the 2713 * Be lazy and only check for valid flags here, keeping it out of the
2703 * critical path in kmem_cache_alloc(). 2714 * critical path in kmem_cache_alloc().
2704 */ 2715 */
2705 BUG_ON(flags & ~(SLAB_DMA | SLAB_LEVEL_MASK | SLAB_NO_GROW)); 2716 BUG_ON(flags & ~(GFP_DMA | GFP_LEVEL_MASK | __GFP_NO_GROW));
2706 if (flags & SLAB_NO_GROW) 2717 if (flags & __GFP_NO_GROW)
2707 return 0; 2718 return 0;
2708 2719
2709 ctor_flags = SLAB_CTOR_CONSTRUCTOR; 2720 ctor_flags = SLAB_CTOR_CONSTRUCTOR;
2710 local_flags = (flags & SLAB_LEVEL_MASK); 2721 local_flags = (flags & GFP_LEVEL_MASK);
2711 if (!(local_flags & __GFP_WAIT)) 2722 if (!(local_flags & __GFP_WAIT))
2712 /* 2723 /*
2713 * Not allowed to sleep. Need to tell a constructor about 2724 * Not allowed to sleep. Need to tell a constructor about
@@ -2744,12 +2755,14 @@ static int cache_grow(struct kmem_cache *cachep, gfp_t flags, int nodeid)
2744 * Get mem for the objs. Attempt to allocate a physical page from 2755 * Get mem for the objs. Attempt to allocate a physical page from
2745 * 'nodeid'. 2756 * 'nodeid'.
2746 */ 2757 */
2747 objp = kmem_getpages(cachep, flags, nodeid); 2758 if (!objp)
2759 objp = kmem_getpages(cachep, flags, nodeid);
2748 if (!objp) 2760 if (!objp)
2749 goto failed; 2761 goto failed;
2750 2762
2751 /* Get slab management. */ 2763 /* Get slab management. */
2752 slabp = alloc_slabmgmt(cachep, objp, offset, local_flags, nodeid); 2764 slabp = alloc_slabmgmt(cachep, objp, offset,
2765 local_flags & ~GFP_THISNODE, nodeid);
2753 if (!slabp) 2766 if (!slabp)
2754 goto opps1; 2767 goto opps1;
2755 2768
@@ -2987,7 +3000,7 @@ alloc_done:
2987 3000
2988 if (unlikely(!ac->avail)) { 3001 if (unlikely(!ac->avail)) {
2989 int x; 3002 int x;
2990 x = cache_grow(cachep, flags, node); 3003 x = cache_grow(cachep, flags | GFP_THISNODE, node, NULL);
2991 3004
2992 /* cache_grow can reenable interrupts, then ac could change. */ 3005 /* cache_grow can reenable interrupts, then ac could change. */
2993 ac = cpu_cache_get(cachep); 3006 ac = cpu_cache_get(cachep);
@@ -3063,6 +3076,12 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep,
3063 3076
3064 cachep->ctor(objp, cachep, ctor_flags); 3077 cachep->ctor(objp, cachep, ctor_flags);
3065 } 3078 }
3079#if ARCH_SLAB_MINALIGN
3080 if ((u32)objp & (ARCH_SLAB_MINALIGN-1)) {
3081 printk(KERN_ERR "0x%p: not aligned to ARCH_SLAB_MINALIGN=%d\n",
3082 objp, ARCH_SLAB_MINALIGN);
3083 }
3084#endif
3066 return objp; 3085 return objp;
3067} 3086}
3068#else 3087#else
@@ -3105,10 +3124,10 @@ static __always_inline void *__cache_alloc(struct kmem_cache *cachep,
3105 objp = ____cache_alloc(cachep, flags); 3124 objp = ____cache_alloc(cachep, flags);
3106 /* 3125 /*
3107 * We may just have run out of memory on the local node. 3126 * We may just have run out of memory on the local node.
3108 * __cache_alloc_node() knows how to locate memory on other nodes 3127 * ____cache_alloc_node() knows how to locate memory on other nodes
3109 */ 3128 */
3110 if (NUMA_BUILD && !objp) 3129 if (NUMA_BUILD && !objp)
3111 objp = __cache_alloc_node(cachep, flags, numa_node_id()); 3130 objp = ____cache_alloc_node(cachep, flags, numa_node_id());
3112 local_irq_restore(save_flags); 3131 local_irq_restore(save_flags);
3113 objp = cache_alloc_debugcheck_after(cachep, flags, objp, 3132 objp = cache_alloc_debugcheck_after(cachep, flags, objp,
3114 caller); 3133 caller);
@@ -3135,15 +3154,17 @@ static void *alternate_node_alloc(struct kmem_cache *cachep, gfp_t flags)
3135 else if (current->mempolicy) 3154 else if (current->mempolicy)
3136 nid_alloc = slab_node(current->mempolicy); 3155 nid_alloc = slab_node(current->mempolicy);
3137 if (nid_alloc != nid_here) 3156 if (nid_alloc != nid_here)
3138 return __cache_alloc_node(cachep, flags, nid_alloc); 3157 return ____cache_alloc_node(cachep, flags, nid_alloc);
3139 return NULL; 3158 return NULL;
3140} 3159}
3141 3160
3142/* 3161/*
3143 * Fallback function if there was no memory available and no objects on a 3162 * Fallback function if there was no memory available and no objects on a
3144 * certain node and we are allowed to fall back. We mimick the behavior of 3163 * certain node and fall back is permitted. First we scan all the
3145 * the page allocator. We fall back according to a zonelist determined by 3164 * available nodelists for available objects. If that fails then we
3146 * the policy layer while obeying cpuset constraints. 3165 * perform an allocation without specifying a node. This allows the page
3166 * allocator to do its reclaim / fallback magic. We then insert the
3167 * slab into the proper nodelist and then allocate from it.
3147 */ 3168 */
3148void *fallback_alloc(struct kmem_cache *cache, gfp_t flags) 3169void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
3149{ 3170{
@@ -3151,15 +3172,51 @@ void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
3151 ->node_zonelists[gfp_zone(flags)]; 3172 ->node_zonelists[gfp_zone(flags)];
3152 struct zone **z; 3173 struct zone **z;
3153 void *obj = NULL; 3174 void *obj = NULL;
3175 int nid;
3154 3176
3177retry:
3178 /*
3179 * Look through allowed nodes for objects available
3180 * from existing per node queues.
3181 */
3155 for (z = zonelist->zones; *z && !obj; z++) { 3182 for (z = zonelist->zones; *z && !obj; z++) {
3156 int nid = zone_to_nid(*z); 3183 nid = zone_to_nid(*z);
3184
3185 if (cpuset_zone_allowed(*z, flags) &&
3186 cache->nodelists[nid] &&
3187 cache->nodelists[nid]->free_objects)
3188 obj = ____cache_alloc_node(cache,
3189 flags | GFP_THISNODE, nid);
3190 }
3157 3191
3158 if (zone_idx(*z) <= ZONE_NORMAL && 3192 if (!obj) {
3159 cpuset_zone_allowed(*z, flags) && 3193 /*
3160 cache->nodelists[nid]) 3194 * This allocation will be performed within the constraints
3161 obj = __cache_alloc_node(cache, 3195 * of the current cpuset / memory policy requirements.
3162 flags | __GFP_THISNODE, nid); 3196 * We may trigger various forms of reclaim on the allowed
3197 * set and go into memory reserves if necessary.
3198 */
3199 obj = kmem_getpages(cache, flags, -1);
3200 if (obj) {
3201 /*
3202 * Insert into the appropriate per node queues
3203 */
3204 nid = page_to_nid(virt_to_page(obj));
3205 if (cache_grow(cache, flags, nid, obj)) {
3206 obj = ____cache_alloc_node(cache,
3207 flags | GFP_THISNODE, nid);
3208 if (!obj)
3209 /*
3210 * Another processor may allocate the
3211 * objects in the slab since we are
3212 * not holding any locks.
3213 */
3214 goto retry;
3215 } else {
3216 kmem_freepages(cache, obj);
3217 obj = NULL;
3218 }
3219 }
3163 } 3220 }
3164 return obj; 3221 return obj;
3165} 3222}
@@ -3167,7 +3224,7 @@ void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
3167/* 3224/*
3168 * A interface to enable slab creation on nodeid 3225 * A interface to enable slab creation on nodeid
3169 */ 3226 */
3170static void *__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, 3227static void *____cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
3171 int nodeid) 3228 int nodeid)
3172{ 3229{
3173 struct list_head *entry; 3230 struct list_head *entry;
@@ -3216,7 +3273,7 @@ retry:
3216 3273
3217must_grow: 3274must_grow:
3218 spin_unlock(&l3->list_lock); 3275 spin_unlock(&l3->list_lock);
3219 x = cache_grow(cachep, flags, nodeid); 3276 x = cache_grow(cachep, flags | GFP_THISNODE, nodeid, NULL);
3220 if (x) 3277 if (x)
3221 goto retry; 3278 goto retry;
3222 3279
@@ -3434,35 +3491,59 @@ out:
3434 * @flags: See kmalloc(). 3491 * @flags: See kmalloc().
3435 * @nodeid: node number of the target node. 3492 * @nodeid: node number of the target node.
3436 * 3493 *
3437 * Identical to kmem_cache_alloc, except that this function is slow 3494 * Identical to kmem_cache_alloc but it will allocate memory on the given
3438 * and can sleep. And it will allocate memory on the given node, which 3495 * node, which can improve the performance for cpu bound structures.
3439 * can improve the performance for cpu bound structures. 3496 *
3440 * New and improved: it will now make sure that the object gets 3497 * Fallback to other node is possible if __GFP_THISNODE is not set.
3441 * put on the correct node list so that there is no false sharing.
3442 */ 3498 */
3443void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid) 3499static __always_inline void *
3500__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
3501 int nodeid, void *caller)
3444{ 3502{
3445 unsigned long save_flags; 3503 unsigned long save_flags;
3446 void *ptr; 3504 void *ptr = NULL;
3447 3505
3448 cache_alloc_debugcheck_before(cachep, flags); 3506 cache_alloc_debugcheck_before(cachep, flags);
3449 local_irq_save(save_flags); 3507 local_irq_save(save_flags);
3450 3508
3451 if (nodeid == -1 || nodeid == numa_node_id() || 3509 if (unlikely(nodeid == -1))
3452 !cachep->nodelists[nodeid]) 3510 nodeid = numa_node_id();
3453 ptr = ____cache_alloc(cachep, flags); 3511
3454 else 3512 if (likely(cachep->nodelists[nodeid])) {
3455 ptr = __cache_alloc_node(cachep, flags, nodeid); 3513 if (nodeid == numa_node_id()) {
3456 local_irq_restore(save_flags); 3514 /*
3515 * Use the locally cached objects if possible.
3516 * However ____cache_alloc does not allow fallback
3517 * to other nodes. It may fail while we still have
3518 * objects on other nodes available.
3519 */
3520 ptr = ____cache_alloc(cachep, flags);
3521 }
3522 if (!ptr) {
3523 /* ___cache_alloc_node can fall back to other nodes */
3524 ptr = ____cache_alloc_node(cachep, flags, nodeid);
3525 }
3526 } else {
3527 /* Node not bootstrapped yet */
3528 if (!(flags & __GFP_THISNODE))
3529 ptr = fallback_alloc(cachep, flags);
3530 }
3457 3531
3458 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, 3532 local_irq_restore(save_flags);
3459 __builtin_return_address(0)); 3533 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
3460 3534
3461 return ptr; 3535 return ptr;
3462} 3536}
3537
3538void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
3539{
3540 return __cache_alloc_node(cachep, flags, nodeid,
3541 __builtin_return_address(0));
3542}
3463EXPORT_SYMBOL(kmem_cache_alloc_node); 3543EXPORT_SYMBOL(kmem_cache_alloc_node);
3464 3544
3465void *__kmalloc_node(size_t size, gfp_t flags, int node) 3545static __always_inline void *
3546__do_kmalloc_node(size_t size, gfp_t flags, int node, void *caller)
3466{ 3547{
3467 struct kmem_cache *cachep; 3548 struct kmem_cache *cachep;
3468 3549
@@ -3471,8 +3552,29 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
3471 return NULL; 3552 return NULL;
3472 return kmem_cache_alloc_node(cachep, flags, node); 3553 return kmem_cache_alloc_node(cachep, flags, node);
3473} 3554}
3555
3556#ifdef CONFIG_DEBUG_SLAB
3557void *__kmalloc_node(size_t size, gfp_t flags, int node)
3558{
3559 return __do_kmalloc_node(size, flags, node,
3560 __builtin_return_address(0));
3561}
3474EXPORT_SYMBOL(__kmalloc_node); 3562EXPORT_SYMBOL(__kmalloc_node);
3475#endif 3563
3564void *__kmalloc_node_track_caller(size_t size, gfp_t flags,
3565 int node, void *caller)
3566{
3567 return __do_kmalloc_node(size, flags, node, caller);
3568}
3569EXPORT_SYMBOL(__kmalloc_node_track_caller);
3570#else
3571void *__kmalloc_node(size_t size, gfp_t flags, int node)
3572{
3573 return __do_kmalloc_node(size, flags, node, NULL);
3574}
3575EXPORT_SYMBOL(__kmalloc_node);
3576#endif /* CONFIG_DEBUG_SLAB */
3577#endif /* CONFIG_NUMA */
3476 3578
3477/** 3579/**
3478 * __do_kmalloc - allocate memory 3580 * __do_kmalloc - allocate memory
@@ -3583,13 +3685,15 @@ static int alloc_kmemlist(struct kmem_cache *cachep)
3583 int node; 3685 int node;
3584 struct kmem_list3 *l3; 3686 struct kmem_list3 *l3;
3585 struct array_cache *new_shared; 3687 struct array_cache *new_shared;
3586 struct array_cache **new_alien; 3688 struct array_cache **new_alien = NULL;
3587 3689
3588 for_each_online_node(node) { 3690 for_each_online_node(node) {
3589 3691
3590 new_alien = alloc_alien_cache(node, cachep->limit); 3692 if (use_alien_caches) {
3591 if (!new_alien) 3693 new_alien = alloc_alien_cache(node, cachep->limit);
3592 goto fail; 3694 if (!new_alien)
3695 goto fail;
3696 }
3593 3697
3594 new_shared = alloc_arraycache(node, 3698 new_shared = alloc_arraycache(node,
3595 cachep->shared*cachep->batchcount, 3699 cachep->shared*cachep->batchcount,
@@ -3815,7 +3919,7 @@ void drain_array(struct kmem_cache *cachep, struct kmem_list3 *l3,
3815 * If we cannot acquire the cache chain mutex then just give up - we'll try 3919 * If we cannot acquire the cache chain mutex then just give up - we'll try
3816 * again on the next iteration. 3920 * again on the next iteration.
3817 */ 3921 */
3818static void cache_reap(void *unused) 3922static void cache_reap(struct work_struct *unused)
3819{ 3923{
3820 struct kmem_cache *searchp; 3924 struct kmem_cache *searchp;
3821 struct kmem_list3 *l3; 3925 struct kmem_list3 *l3;
@@ -4038,7 +4142,7 @@ static int s_show(struct seq_file *m, void *p)
4038 * + further values on SMP and with statistics enabled 4142 * + further values on SMP and with statistics enabled
4039 */ 4143 */
4040 4144
4041struct seq_operations slabinfo_op = { 4145const struct seq_operations slabinfo_op = {
4042 .start = s_start, 4146 .start = s_start,
4043 .next = s_next, 4147 .next = s_next,
4044 .stop = s_stop, 4148 .stop = s_stop,
@@ -4236,7 +4340,7 @@ static int leaks_show(struct seq_file *m, void *p)
4236 return 0; 4340 return 0;
4237} 4341}
4238 4342
4239struct seq_operations slabstats_op = { 4343const struct seq_operations slabstats_op = {
4240 .start = leaks_start, 4344 .start = leaks_start,
4241 .next = s_next, 4345 .next = s_next,
4242 .stop = s_stop, 4346 .stop = s_stop,
diff --git a/mm/sparse.c b/mm/sparse.c
index b3c82ba30012..ac26eb0d73cd 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -24,6 +24,25 @@ struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT]
24#endif 24#endif
25EXPORT_SYMBOL(mem_section); 25EXPORT_SYMBOL(mem_section);
26 26
27#ifdef NODE_NOT_IN_PAGE_FLAGS
28/*
29 * If we did not store the node number in the page then we have to
30 * do a lookup in the section_to_node_table in order to find which
31 * node the page belongs to.
32 */
33#if MAX_NUMNODES <= 256
34static u8 section_to_node_table[NR_MEM_SECTIONS] __cacheline_aligned;
35#else
36static u16 section_to_node_table[NR_MEM_SECTIONS] __cacheline_aligned;
37#endif
38
39int page_to_nid(struct page *page)
40{
41 return section_to_node_table[page_to_section(page)];
42}
43EXPORT_SYMBOL(page_to_nid);
44#endif
45
27#ifdef CONFIG_SPARSEMEM_EXTREME 46#ifdef CONFIG_SPARSEMEM_EXTREME
28static struct mem_section *sparse_index_alloc(int nid) 47static struct mem_section *sparse_index_alloc(int nid)
29{ 48{
@@ -49,6 +68,10 @@ static int sparse_index_init(unsigned long section_nr, int nid)
49 struct mem_section *section; 68 struct mem_section *section;
50 int ret = 0; 69 int ret = 0;
51 70
71#ifdef NODE_NOT_IN_PAGE_FLAGS
72 section_to_node_table[section_nr] = nid;
73#endif
74
52 if (mem_section[root]) 75 if (mem_section[root])
53 return -EEXIST; 76 return -EEXIST;
54 77
diff --git a/mm/swap.c b/mm/swap.c
index 2e0e871f542f..2ed7be39795e 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -57,9 +57,9 @@ static void put_compound_page(struct page *page)
57{ 57{
58 page = (struct page *)page_private(page); 58 page = (struct page *)page_private(page);
59 if (put_page_testzero(page)) { 59 if (put_page_testzero(page)) {
60 void (*dtor)(struct page *page); 60 compound_page_dtor *dtor;
61 61
62 dtor = (void (*)(struct page *))page[1].lru.next; 62 dtor = get_compound_page_dtor(page);
63 (*dtor)(page); 63 (*dtor)(page);
64 } 64 }
65} 65}
@@ -216,7 +216,7 @@ void lru_add_drain(void)
216} 216}
217 217
218#ifdef CONFIG_NUMA 218#ifdef CONFIG_NUMA
219static void lru_add_drain_per_cpu(void *dummy) 219static void lru_add_drain_per_cpu(struct work_struct *dummy)
220{ 220{
221 lru_add_drain(); 221 lru_add_drain();
222} 222}
@@ -226,7 +226,7 @@ static void lru_add_drain_per_cpu(void *dummy)
226 */ 226 */
227int lru_add_drain_all(void) 227int lru_add_drain_all(void)
228{ 228{
229 return schedule_on_each_cpu(lru_add_drain_per_cpu, NULL); 229 return schedule_on_each_cpu(lru_add_drain_per_cpu);
230} 230}
231 231
232#else 232#else
@@ -514,5 +514,7 @@ void __init swap_setup(void)
514 * Right now other parts of the system means that we 514 * Right now other parts of the system means that we
515 * _really_ don't want to cluster much more 515 * _really_ don't want to cluster much more
516 */ 516 */
517#ifdef CONFIG_HOTPLUG_CPU
517 hotcpu_notifier(cpu_swap_callback, 0); 518 hotcpu_notifier(cpu_swap_callback, 0);
519#endif
518} 520}
diff --git a/mm/swapfile.c b/mm/swapfile.c
index a15def63f28f..c5431072f422 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -427,34 +427,48 @@ void free_swap_and_cache(swp_entry_t entry)
427 427
428#ifdef CONFIG_SOFTWARE_SUSPEND 428#ifdef CONFIG_SOFTWARE_SUSPEND
429/* 429/*
430 * Find the swap type that corresponds to given device (if any) 430 * Find the swap type that corresponds to given device (if any).
431 * 431 *
432 * This is needed for software suspend and is done in such a way that inode 432 * @offset - number of the PAGE_SIZE-sized block of the device, starting
433 * aliasing is allowed. 433 * from 0, in which the swap header is expected to be located.
434 *
435 * This is needed for the suspend to disk (aka swsusp).
434 */ 436 */
435int swap_type_of(dev_t device) 437int swap_type_of(dev_t device, sector_t offset)
436{ 438{
439 struct block_device *bdev = NULL;
437 int i; 440 int i;
438 441
442 if (device)
443 bdev = bdget(device);
444
439 spin_lock(&swap_lock); 445 spin_lock(&swap_lock);
440 for (i = 0; i < nr_swapfiles; i++) { 446 for (i = 0; i < nr_swapfiles; i++) {
441 struct inode *inode; 447 struct swap_info_struct *sis = swap_info + i;
442 448
443 if (!(swap_info[i].flags & SWP_WRITEOK)) 449 if (!(sis->flags & SWP_WRITEOK))
444 continue; 450 continue;
445 451
446 if (!device) { 452 if (!bdev) {
447 spin_unlock(&swap_lock); 453 spin_unlock(&swap_lock);
448 return i; 454 return i;
449 } 455 }
450 inode = swap_info[i].swap_file->f_dentry->d_inode; 456 if (bdev == sis->bdev) {
451 if (S_ISBLK(inode->i_mode) && 457 struct swap_extent *se;
452 device == MKDEV(imajor(inode), iminor(inode))) { 458
453 spin_unlock(&swap_lock); 459 se = list_entry(sis->extent_list.next,
454 return i; 460 struct swap_extent, list);
461 if (se->start_block == offset) {
462 spin_unlock(&swap_lock);
463 bdput(bdev);
464 return i;
465 }
455 } 466 }
456 } 467 }
457 spin_unlock(&swap_lock); 468 spin_unlock(&swap_lock);
469 if (bdev)
470 bdput(bdev);
471
458 return -ENODEV; 472 return -ENODEV;
459} 473}
460 474
@@ -931,6 +945,23 @@ sector_t map_swap_page(struct swap_info_struct *sis, pgoff_t offset)
931 } 945 }
932} 946}
933 947
948#ifdef CONFIG_SOFTWARE_SUSPEND
949/*
950 * Get the (PAGE_SIZE) block corresponding to given offset on the swapdev
951 * corresponding to given index in swap_info (swap type).
952 */
953sector_t swapdev_block(int swap_type, pgoff_t offset)
954{
955 struct swap_info_struct *sis;
956
957 if (swap_type >= nr_swapfiles)
958 return 0;
959
960 sis = swap_info + swap_type;
961 return (sis->flags & SWP_WRITEOK) ? map_swap_page(sis, offset) : 0;
962}
963#endif /* CONFIG_SOFTWARE_SUSPEND */
964
934/* 965/*
935 * Free all of a swapdev's extent information 966 * Free all of a swapdev's extent information
936 */ 967 */
@@ -1274,10 +1305,13 @@ static void *swap_start(struct seq_file *swap, loff_t *pos)
1274 1305
1275 mutex_lock(&swapon_mutex); 1306 mutex_lock(&swapon_mutex);
1276 1307
1308 if (!l)
1309 return SEQ_START_TOKEN;
1310
1277 for (i = 0; i < nr_swapfiles; i++, ptr++) { 1311 for (i = 0; i < nr_swapfiles; i++, ptr++) {
1278 if (!(ptr->flags & SWP_USED) || !ptr->swap_map) 1312 if (!(ptr->flags & SWP_USED) || !ptr->swap_map)
1279 continue; 1313 continue;
1280 if (!l--) 1314 if (!--l)
1281 return ptr; 1315 return ptr;
1282 } 1316 }
1283 1317
@@ -1286,10 +1320,17 @@ static void *swap_start(struct seq_file *swap, loff_t *pos)
1286 1320
1287static void *swap_next(struct seq_file *swap, void *v, loff_t *pos) 1321static void *swap_next(struct seq_file *swap, void *v, loff_t *pos)
1288{ 1322{
1289 struct swap_info_struct *ptr = v; 1323 struct swap_info_struct *ptr;
1290 struct swap_info_struct *endptr = swap_info + nr_swapfiles; 1324 struct swap_info_struct *endptr = swap_info + nr_swapfiles;
1291 1325
1292 for (++ptr; ptr < endptr; ptr++) { 1326 if (v == SEQ_START_TOKEN)
1327 ptr = swap_info;
1328 else {
1329 ptr = v;
1330 ptr++;
1331 }
1332
1333 for (; ptr < endptr; ptr++) {
1293 if (!(ptr->flags & SWP_USED) || !ptr->swap_map) 1334 if (!(ptr->flags & SWP_USED) || !ptr->swap_map)
1294 continue; 1335 continue;
1295 ++*pos; 1336 ++*pos;
@@ -1310,8 +1351,10 @@ static int swap_show(struct seq_file *swap, void *v)
1310 struct file *file; 1351 struct file *file;
1311 int len; 1352 int len;
1312 1353
1313 if (v == swap_info) 1354 if (ptr == SEQ_START_TOKEN) {
1314 seq_puts(swap, "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n"); 1355 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
1356 return 0;
1357 }
1315 1358
1316 file = ptr->swap_file; 1359 file = ptr->swap_file;
1317 len = seq_path(swap, file->f_vfsmnt, file->f_dentry, " \t\n\\"); 1360 len = seq_path(swap, file->f_vfsmnt, file->f_dentry, " \t\n\\");
@@ -1325,7 +1368,7 @@ static int swap_show(struct seq_file *swap, void *v)
1325 return 0; 1368 return 0;
1326} 1369}
1327 1370
1328static struct seq_operations swaps_op = { 1371static const struct seq_operations swaps_op = {
1329 .start = swap_start, 1372 .start = swap_start,
1330 .next = swap_next, 1373 .next = swap_next,
1331 .stop = swap_stop, 1374 .stop = swap_stop,
@@ -1337,7 +1380,7 @@ static int swaps_open(struct inode *inode, struct file *file)
1337 return seq_open(file, &swaps_op); 1380 return seq_open(file, &swaps_op);
1338} 1381}
1339 1382
1340static struct file_operations proc_swaps_operations = { 1383static const struct file_operations proc_swaps_operations = {
1341 .open = swaps_open, 1384 .open = swaps_open,
1342 .read = seq_read, 1385 .read = seq_read,
1343 .llseek = seq_lseek, 1386 .llseek = seq_lseek,
@@ -1540,6 +1583,11 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
1540 error = -EINVAL; 1583 error = -EINVAL;
1541 if (!maxpages) 1584 if (!maxpages)
1542 goto bad_swap; 1585 goto bad_swap;
1586 if (swapfilesize && maxpages > swapfilesize) {
1587 printk(KERN_WARNING
1588 "Swap area shorter than signature indicates\n");
1589 goto bad_swap;
1590 }
1543 if (swap_header->info.nr_badpages && S_ISREG(inode->i_mode)) 1591 if (swap_header->info.nr_badpages && S_ISREG(inode->i_mode))
1544 goto bad_swap; 1592 goto bad_swap;
1545 if (swap_header->info.nr_badpages > MAX_SWAP_BADPAGES) 1593 if (swap_header->info.nr_badpages > MAX_SWAP_BADPAGES)
@@ -1567,12 +1615,6 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
1567 goto bad_swap; 1615 goto bad_swap;
1568 } 1616 }
1569 1617
1570 if (swapfilesize && maxpages > swapfilesize) {
1571 printk(KERN_WARNING
1572 "Swap area shorter than signature indicates\n");
1573 error = -EINVAL;
1574 goto bad_swap;
1575 }
1576 if (nr_good_pages) { 1618 if (nr_good_pages) {
1577 p->swap_map[0] = SWAP_MAP_BAD; 1619 p->swap_map[0] = SWAP_MAP_BAD;
1578 p->max = maxpages; 1620 p->max = maxpages;
diff --git a/mm/thrash.c b/mm/thrash.c
index f4c560b4a2b7..9ef9071f99bc 100644
--- a/mm/thrash.c
+++ b/mm/thrash.c
@@ -7,100 +7,74 @@
7 * 7 *
8 * Simple token based thrashing protection, using the algorithm 8 * Simple token based thrashing protection, using the algorithm
9 * described in: http://www.cs.wm.edu/~sjiang/token.pdf 9 * described in: http://www.cs.wm.edu/~sjiang/token.pdf
10 *
11 * Sep 2006, Ashwin Chaugule <ashwin.chaugule@celunite.com>
12 * Improved algorithm to pass token:
13 * Each task has a priority which is incremented if it contended
14 * for the token in an interval less than its previous attempt.
15 * If the token is acquired, that task's priority is boosted to prevent
16 * the token from bouncing around too often and to let the task make
17 * some progress in its execution.
10 */ 18 */
19
11#include <linux/jiffies.h> 20#include <linux/jiffies.h>
12#include <linux/mm.h> 21#include <linux/mm.h>
13#include <linux/sched.h> 22#include <linux/sched.h>
14#include <linux/swap.h> 23#include <linux/swap.h>
15 24
16static DEFINE_SPINLOCK(swap_token_lock); 25static DEFINE_SPINLOCK(swap_token_lock);
17static unsigned long swap_token_timeout; 26struct mm_struct *swap_token_mm;
18static unsigned long swap_token_check; 27static unsigned int global_faults;
19struct mm_struct * swap_token_mm = &init_mm;
20
21#define SWAP_TOKEN_CHECK_INTERVAL (HZ * 2)
22#define SWAP_TOKEN_TIMEOUT (300 * HZ)
23/*
24 * Currently disabled; Needs further code to work at HZ * 300.
25 */
26unsigned long swap_token_default_timeout = SWAP_TOKEN_TIMEOUT;
27
28/*
29 * Take the token away if the process had no page faults
30 * in the last interval, or if it has held the token for
31 * too long.
32 */
33#define SWAP_TOKEN_ENOUGH_RSS 1
34#define SWAP_TOKEN_TIMED_OUT 2
35static int should_release_swap_token(struct mm_struct *mm)
36{
37 int ret = 0;
38 if (!mm->recent_pagein)
39 ret = SWAP_TOKEN_ENOUGH_RSS;
40 else if (time_after(jiffies, swap_token_timeout))
41 ret = SWAP_TOKEN_TIMED_OUT;
42 mm->recent_pagein = 0;
43 return ret;
44}
45 28
46/*
47 * Try to grab the swapout protection token. We only try to
48 * grab it once every TOKEN_CHECK_INTERVAL, both to prevent
49 * SMP lock contention and to check that the process that held
50 * the token before is no longer thrashing.
51 */
52void grab_swap_token(void) 29void grab_swap_token(void)
53{ 30{
54 struct mm_struct *mm; 31 int current_interval;
55 int reason;
56 32
57 /* We have the token. Let others know we still need it. */ 33 global_faults++;
58 if (has_swap_token(current->mm)) {
59 current->mm->recent_pagein = 1;
60 if (unlikely(!swap_token_default_timeout))
61 disable_swap_token();
62 return;
63 }
64
65 if (time_after(jiffies, swap_token_check)) {
66 34
67 if (!swap_token_default_timeout) { 35 current_interval = global_faults - current->mm->faultstamp;
68 swap_token_check = jiffies + SWAP_TOKEN_CHECK_INTERVAL;
69 return;
70 }
71
72 /* ... or if we recently held the token. */
73 if (time_before(jiffies, current->mm->swap_token_time))
74 return;
75 36
76 if (!spin_trylock(&swap_token_lock)) 37 if (!spin_trylock(&swap_token_lock))
77 return; 38 return;
78 39
79 swap_token_check = jiffies + SWAP_TOKEN_CHECK_INTERVAL; 40 /* First come first served */
41 if (swap_token_mm == NULL) {
42 current->mm->token_priority = current->mm->token_priority + 2;
43 swap_token_mm = current->mm;
44 goto out;
45 }
80 46
81 mm = swap_token_mm; 47 if (current->mm != swap_token_mm) {
82 if ((reason = should_release_swap_token(mm))) { 48 if (current_interval < current->mm->last_interval)
83 unsigned long eligible = jiffies; 49 current->mm->token_priority++;
84 if (reason == SWAP_TOKEN_TIMED_OUT) { 50 else {
85 eligible += swap_token_default_timeout; 51 current->mm->token_priority--;
86 } 52 if (unlikely(current->mm->token_priority < 0))
87 mm->swap_token_time = eligible; 53 current->mm->token_priority = 0;
88 swap_token_timeout = jiffies + swap_token_default_timeout; 54 }
55 /* Check if we deserve the token */
56 if (current->mm->token_priority >
57 swap_token_mm->token_priority) {
58 current->mm->token_priority += 2;
89 swap_token_mm = current->mm; 59 swap_token_mm = current->mm;
90 } 60 }
91 spin_unlock(&swap_token_lock); 61 } else {
62 /* Token holder came in again! */
63 current->mm->token_priority += 2;
92 } 64 }
93 return; 65
66out:
67 current->mm->faultstamp = global_faults;
68 current->mm->last_interval = current_interval;
69 spin_unlock(&swap_token_lock);
70return;
94} 71}
95 72
96/* Called on process exit. */ 73/* Called on process exit. */
97void __put_swap_token(struct mm_struct *mm) 74void __put_swap_token(struct mm_struct *mm)
98{ 75{
99 spin_lock(&swap_token_lock); 76 spin_lock(&swap_token_lock);
100 if (likely(mm == swap_token_mm)) { 77 if (likely(mm == swap_token_mm))
101 mm->swap_token_time = jiffies + SWAP_TOKEN_CHECK_INTERVAL; 78 swap_token_mm = NULL;
102 swap_token_mm = &init_mm;
103 swap_token_check = jiffies;
104 }
105 spin_unlock(&swap_token_lock); 79 spin_unlock(&swap_token_lock);
106} 80}
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 518540a4a2a6..093f5fe6dd77 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -36,6 +36,7 @@
36#include <linux/rwsem.h> 36#include <linux/rwsem.h>
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <linux/kthread.h> 38#include <linux/kthread.h>
39#include <linux/freezer.h>
39 40
40#include <asm/tlbflush.h> 41#include <asm/tlbflush.h>
41#include <asm/div64.h> 42#include <asm/div64.h>
@@ -1172,11 +1173,12 @@ loop_again:
1172 if (!zone_watermark_ok(zone, order, zone->pages_high, 1173 if (!zone_watermark_ok(zone, order, zone->pages_high,
1173 0, 0)) { 1174 0, 0)) {
1174 end_zone = i; 1175 end_zone = i;
1175 goto scan; 1176 break;
1176 } 1177 }
1177 } 1178 }
1178 goto out; 1179 if (i < 0)
1179scan: 1180 goto out;
1181
1180 for (i = 0; i <= end_zone; i++) { 1182 for (i = 0; i <= end_zone; i++) {
1181 struct zone *zone = pgdat->node_zones + i; 1183 struct zone *zone = pgdat->node_zones + i;
1182 1184
@@ -1259,6 +1261,9 @@ out:
1259 } 1261 }
1260 if (!all_zones_ok) { 1262 if (!all_zones_ok) {
1261 cond_resched(); 1263 cond_resched();
1264
1265 try_to_freeze();
1266
1262 goto loop_again; 1267 goto loop_again;
1263 } 1268 }
1264 1269
@@ -1508,7 +1513,6 @@ out:
1508} 1513}
1509#endif 1514#endif
1510 1515
1511#ifdef CONFIG_HOTPLUG_CPU
1512/* It's optimal to keep kswapds on the same CPUs as their memory, but 1516/* It's optimal to keep kswapds on the same CPUs as their memory, but
1513 not required for correctness. So if the last cpu in a node goes 1517 not required for correctness. So if the last cpu in a node goes
1514 away, we get changed to run anywhere: as the first one comes back, 1518 away, we get changed to run anywhere: as the first one comes back,
@@ -1529,7 +1533,6 @@ static int __devinit cpu_callback(struct notifier_block *nfb,
1529 } 1533 }
1530 return NOTIFY_OK; 1534 return NOTIFY_OK;
1531} 1535}
1532#endif /* CONFIG_HOTPLUG_CPU */
1533 1536
1534/* 1537/*
1535 * This kswapd start function will be called by init and node-hot-add. 1538 * This kswapd start function will be called by init and node-hot-add.
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 8614e8f6743b..dc005a0c96ae 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -430,7 +430,7 @@ static int frag_show(struct seq_file *m, void *arg)
430 return 0; 430 return 0;
431} 431}
432 432
433struct seq_operations fragmentation_op = { 433const struct seq_operations fragmentation_op = {
434 .start = frag_start, 434 .start = frag_start,
435 .next = frag_next, 435 .next = frag_next,
436 .stop = frag_stop, 436 .stop = frag_stop,
@@ -452,7 +452,7 @@ struct seq_operations fragmentation_op = {
452#define TEXTS_FOR_ZONES(xx) xx "_dma", TEXT_FOR_DMA32(xx) xx "_normal", \ 452#define TEXTS_FOR_ZONES(xx) xx "_dma", TEXT_FOR_DMA32(xx) xx "_normal", \
453 TEXT_FOR_HIGHMEM(xx) 453 TEXT_FOR_HIGHMEM(xx)
454 454
455static char *vmstat_text[] = { 455static const char * const vmstat_text[] = {
456 /* Zoned VM counters */ 456 /* Zoned VM counters */
457 "nr_anon_pages", 457 "nr_anon_pages",
458 "nr_mapped", 458 "nr_mapped",
@@ -597,7 +597,7 @@ static int zoneinfo_show(struct seq_file *m, void *arg)
597 return 0; 597 return 0;
598} 598}
599 599
600struct seq_operations zoneinfo_op = { 600const struct seq_operations zoneinfo_op = {
601 .start = frag_start, /* iterate over all zones. The same as in 601 .start = frag_start, /* iterate over all zones. The same as in
602 * fragmentation. */ 602 * fragmentation. */
603 .next = frag_next, 603 .next = frag_next,
@@ -660,7 +660,7 @@ static void vmstat_stop(struct seq_file *m, void *arg)
660 m->private = NULL; 660 m->private = NULL;
661} 661}
662 662
663struct seq_operations vmstat_op = { 663const struct seq_operations vmstat_op = {
664 .start = vmstat_start, 664 .start = vmstat_start,
665 .next = vmstat_next, 665 .next = vmstat_next,
666 .stop = vmstat_stop, 666 .stop = vmstat_stop,
@@ -679,13 +679,13 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
679 void *hcpu) 679 void *hcpu)
680{ 680{
681 switch (action) { 681 switch (action) {
682 case CPU_UP_PREPARE: 682 case CPU_UP_PREPARE:
683 case CPU_UP_CANCELED: 683 case CPU_UP_CANCELED:
684 case CPU_DEAD: 684 case CPU_DEAD:
685 refresh_zone_stat_thresholds(); 685 refresh_zone_stat_thresholds();
686 break; 686 break;
687 default: 687 default:
688 break; 688 break;
689 } 689 }
690 return NOTIFY_OK; 690 return NOTIFY_OK;
691} 691}
diff --git a/net/atm/lec.c b/net/atm/lec.c
index 5946ec63724f..3fc0abeeaf34 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -1454,7 +1454,7 @@ static void lane2_associate_ind(struct net_device *dev, u8 *mac_addr,
1454 1454
1455#define LEC_ARP_REFRESH_INTERVAL (3*HZ) 1455#define LEC_ARP_REFRESH_INTERVAL (3*HZ)
1456 1456
1457static void lec_arp_check_expire(void *data); 1457static void lec_arp_check_expire(struct work_struct *work);
1458static void lec_arp_expire_arp(unsigned long data); 1458static void lec_arp_expire_arp(unsigned long data);
1459 1459
1460/* 1460/*
@@ -1477,7 +1477,7 @@ static void lec_arp_init(struct lec_priv *priv)
1477 INIT_HLIST_HEAD(&priv->lec_no_forward); 1477 INIT_HLIST_HEAD(&priv->lec_no_forward);
1478 INIT_HLIST_HEAD(&priv->mcast_fwds); 1478 INIT_HLIST_HEAD(&priv->mcast_fwds);
1479 spin_lock_init(&priv->lec_arp_lock); 1479 spin_lock_init(&priv->lec_arp_lock);
1480 INIT_WORK(&priv->lec_arp_work, lec_arp_check_expire, priv); 1480 INIT_DELAYED_WORK(&priv->lec_arp_work, lec_arp_check_expire);
1481 schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL); 1481 schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL);
1482} 1482}
1483 1483
@@ -1875,10 +1875,11 @@ static void lec_arp_expire_vcc(unsigned long data)
1875 * to ESI_FORWARD_DIRECT. This causes the flush period to end 1875 * to ESI_FORWARD_DIRECT. This causes the flush period to end
1876 * regardless of the progress of the flush protocol. 1876 * regardless of the progress of the flush protocol.
1877 */ 1877 */
1878static void lec_arp_check_expire(void *data) 1878static void lec_arp_check_expire(struct work_struct *work)
1879{ 1879{
1880 unsigned long flags; 1880 unsigned long flags;
1881 struct lec_priv *priv = data; 1881 struct lec_priv *priv =
1882 container_of(work, struct lec_priv, lec_arp_work.work);
1882 struct hlist_node *node, *next; 1883 struct hlist_node *node, *next;
1883 struct lec_arp_table *entry; 1884 struct lec_arp_table *entry;
1884 unsigned long now; 1885 unsigned long now;
diff --git a/net/atm/lec.h b/net/atm/lec.h
index 24cc95f86741..99136babd535 100644
--- a/net/atm/lec.h
+++ b/net/atm/lec.h
@@ -92,7 +92,7 @@ struct lec_priv {
92 spinlock_t lec_arp_lock; 92 spinlock_t lec_arp_lock;
93 struct atm_vcc *mcast_vcc; /* Default Multicast Send VCC */ 93 struct atm_vcc *mcast_vcc; /* Default Multicast Send VCC */
94 struct atm_vcc *lecd; 94 struct atm_vcc *lecd;
95 struct work_struct lec_arp_work; /* C10 */ 95 struct delayed_work lec_arp_work; /* C10 */
96 unsigned int maximum_unknown_frame_count; 96 unsigned int maximum_unknown_frame_count;
97 /* 97 /*
98 * Within the period of time defined by this variable, the client will send 98 * Within the period of time defined by this variable, the client will send
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 3eeeb7a86e75..d4c935692ccf 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -237,9 +237,9 @@ static void bt_release(struct device *dev)
237 kfree(data); 237 kfree(data);
238} 238}
239 239
240static void add_conn(void *data) 240static void add_conn(struct work_struct *work)
241{ 241{
242 struct hci_conn *conn = data; 242 struct hci_conn *conn = container_of(work, struct hci_conn, work);
243 int i; 243 int i;
244 244
245 if (device_register(&conn->dev) < 0) { 245 if (device_register(&conn->dev) < 0) {
@@ -272,14 +272,14 @@ void hci_conn_add_sysfs(struct hci_conn *conn)
272 272
273 dev_set_drvdata(&conn->dev, conn); 273 dev_set_drvdata(&conn->dev, conn);
274 274
275 INIT_WORK(&conn->work, add_conn, (void *) conn); 275 INIT_WORK(&conn->work, add_conn);
276 276
277 schedule_work(&conn->work); 277 schedule_work(&conn->work);
278} 278}
279 279
280static void del_conn(void *data) 280static void del_conn(struct work_struct *work)
281{ 281{
282 struct hci_conn *conn = data; 282 struct hci_conn *conn = container_of(work, struct hci_conn, work);
283 device_del(&conn->dev); 283 device_del(&conn->dev);
284} 284}
285 285
@@ -287,7 +287,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn)
287{ 287{
288 BT_DBG("conn %p", conn); 288 BT_DBG("conn %p", conn);
289 289
290 INIT_WORK(&conn->work, del_conn, (void *) conn); 290 INIT_WORK(&conn->work, del_conn);
291 291
292 schedule_work(&conn->work); 292 schedule_work(&conn->work);
293} 293}
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index d9f04864d15d..8ca448db7a0d 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -23,7 +23,7 @@
23#include <asm/atomic.h> 23#include <asm/atomic.h>
24#include "br_private.h" 24#include "br_private.h"
25 25
26static kmem_cache_t *br_fdb_cache __read_mostly; 26static struct kmem_cache *br_fdb_cache __read_mostly;
27static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source, 27static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
28 const unsigned char *addr); 28 const unsigned char *addr);
29 29
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index f753c40c11d2..55bb2634c088 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -77,12 +77,16 @@ static int port_cost(struct net_device *dev)
77 * Called from work queue to allow for calling functions that 77 * Called from work queue to allow for calling functions that
78 * might sleep (such as speed check), and to debounce. 78 * might sleep (such as speed check), and to debounce.
79 */ 79 */
80static void port_carrier_check(void *arg) 80static void port_carrier_check(struct work_struct *work)
81{ 81{
82 struct net_device *dev = arg;
83 struct net_bridge_port *p; 82 struct net_bridge_port *p;
83 struct net_device *dev;
84 struct net_bridge *br; 84 struct net_bridge *br;
85 85
86 dev = container_of(work, struct net_bridge_port,
87 carrier_check.work)->dev;
88 work_release(work);
89
86 rtnl_lock(); 90 rtnl_lock();
87 p = dev->br_port; 91 p = dev->br_port;
88 if (!p) 92 if (!p)
@@ -276,7 +280,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br,
276 p->port_no = index; 280 p->port_no = index;
277 br_init_port(p); 281 br_init_port(p);
278 p->state = BR_STATE_DISABLED; 282 p->state = BR_STATE_DISABLED;
279 INIT_WORK(&p->carrier_check, port_carrier_check, dev); 283 INIT_DELAYED_WORK_NAR(&p->carrier_check, port_carrier_check);
280 br_stp_port_timer_init(p); 284 br_stp_port_timer_init(p);
281 285
282 kobject_init(&p->kobj); 286 kobject_init(&p->kobj);
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 74258d86f256..3a534e94c7f3 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -82,7 +82,7 @@ struct net_bridge_port
82 struct timer_list hold_timer; 82 struct timer_list hold_timer;
83 struct timer_list message_age_timer; 83 struct timer_list message_age_timer;
84 struct kobject kobj; 84 struct kobject kobj;
85 struct work_struct carrier_check; 85 struct delayed_work carrier_check;
86 struct rcu_head rcu; 86 struct rcu_head rcu;
87}; 87};
88 88
diff --git a/net/core/dev.c b/net/core/dev.c
index 59d058a3b504..e660cb57e42a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3340,7 +3340,6 @@ void unregister_netdev(struct net_device *dev)
3340 3340
3341EXPORT_SYMBOL(unregister_netdev); 3341EXPORT_SYMBOL(unregister_netdev);
3342 3342
3343#ifdef CONFIG_HOTPLUG_CPU
3344static int dev_cpu_callback(struct notifier_block *nfb, 3343static int dev_cpu_callback(struct notifier_block *nfb,
3345 unsigned long action, 3344 unsigned long action,
3346 void *ocpu) 3345 void *ocpu)
@@ -3384,7 +3383,6 @@ static int dev_cpu_callback(struct notifier_block *nfb,
3384 3383
3385 return NOTIFY_OK; 3384 return NOTIFY_OK;
3386} 3385}
3387#endif /* CONFIG_HOTPLUG_CPU */
3388 3386
3389#ifdef CONFIG_NET_DMA 3387#ifdef CONFIG_NET_DMA
3390/** 3388/**
diff --git a/net/core/dst.c b/net/core/dst.c
index 1a5e49da0e77..836ec6606925 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -125,7 +125,7 @@ void * dst_alloc(struct dst_ops * ops)
125 if (ops->gc()) 125 if (ops->gc())
126 return NULL; 126 return NULL;
127 } 127 }
128 dst = kmem_cache_alloc(ops->kmem_cachep, SLAB_ATOMIC); 128 dst = kmem_cache_alloc(ops->kmem_cachep, GFP_ATOMIC);
129 if (!dst) 129 if (!dst)
130 return NULL; 130 return NULL;
131 memset(dst, 0, ops->entry_size); 131 memset(dst, 0, ops->entry_size);
diff --git a/net/core/flow.c b/net/core/flow.c
index b16d31ae5e54..d137f971f97d 100644
--- a/net/core/flow.c
+++ b/net/core/flow.c
@@ -44,7 +44,7 @@ static DEFINE_PER_CPU(struct flow_cache_entry **, flow_tables) = { NULL };
44 44
45#define flow_table(cpu) (per_cpu(flow_tables, cpu)) 45#define flow_table(cpu) (per_cpu(flow_tables, cpu))
46 46
47static kmem_cache_t *flow_cachep __read_mostly; 47static struct kmem_cache *flow_cachep __read_mostly;
48 48
49static int flow_lwm, flow_hwm; 49static int flow_lwm, flow_hwm;
50 50
@@ -211,7 +211,7 @@ void *flow_cache_lookup(struct flowi *key, u16 family, u8 dir,
211 if (flow_count(cpu) > flow_hwm) 211 if (flow_count(cpu) > flow_hwm)
212 flow_cache_shrink(cpu); 212 flow_cache_shrink(cpu);
213 213
214 fle = kmem_cache_alloc(flow_cachep, SLAB_ATOMIC); 214 fle = kmem_cache_alloc(flow_cachep, GFP_ATOMIC);
215 if (fle) { 215 if (fle) {
216 fle->next = *head; 216 fle->next = *head;
217 *head = fle; 217 *head = fle;
@@ -340,7 +340,6 @@ static void __devinit flow_cache_cpu_prepare(int cpu)
340 tasklet_init(tasklet, flow_cache_flush_tasklet, 0); 340 tasklet_init(tasklet, flow_cache_flush_tasklet, 0);
341} 341}
342 342
343#ifdef CONFIG_HOTPLUG_CPU
344static int flow_cache_cpu(struct notifier_block *nfb, 343static int flow_cache_cpu(struct notifier_block *nfb,
345 unsigned long action, 344 unsigned long action,
346 void *hcpu) 345 void *hcpu)
@@ -349,7 +348,6 @@ static int flow_cache_cpu(struct notifier_block *nfb,
349 __flow_cache_shrink((unsigned long)hcpu, 0); 348 __flow_cache_shrink((unsigned long)hcpu, 0);
350 return NOTIFY_OK; 349 return NOTIFY_OK;
351} 350}
352#endif /* CONFIG_HOTPLUG_CPU */
353 351
354static int __init flow_cache_init(void) 352static int __init flow_cache_init(void)
355{ 353{
diff --git a/net/core/link_watch.c b/net/core/link_watch.c
index 4b36114744c5..549a2ce951b0 100644
--- a/net/core/link_watch.c
+++ b/net/core/link_watch.c
@@ -34,8 +34,8 @@ enum lw_bits {
34static unsigned long linkwatch_flags; 34static unsigned long linkwatch_flags;
35static unsigned long linkwatch_nextevent; 35static unsigned long linkwatch_nextevent;
36 36
37static void linkwatch_event(void *dummy); 37static void linkwatch_event(struct work_struct *dummy);
38static DECLARE_WORK(linkwatch_work, linkwatch_event, NULL); 38static DECLARE_DELAYED_WORK(linkwatch_work, linkwatch_event);
39 39
40static LIST_HEAD(lweventlist); 40static LIST_HEAD(lweventlist);
41static DEFINE_SPINLOCK(lweventlist_lock); 41static DEFINE_SPINLOCK(lweventlist_lock);
@@ -127,7 +127,7 @@ void linkwatch_run_queue(void)
127} 127}
128 128
129 129
130static void linkwatch_event(void *dummy) 130static void linkwatch_event(struct work_struct *dummy)
131{ 131{
132 /* Limit the number of linkwatch events to one 132 /* Limit the number of linkwatch events to one
133 * per second so that a runaway driver does not 133 * per second so that a runaway driver does not
@@ -171,10 +171,9 @@ void linkwatch_fire_event(struct net_device *dev)
171 unsigned long delay = linkwatch_nextevent - jiffies; 171 unsigned long delay = linkwatch_nextevent - jiffies;
172 172
173 /* If we wrap around we'll delay it by at most HZ. */ 173 /* If we wrap around we'll delay it by at most HZ. */
174 if (!delay || delay > HZ) 174 if (delay > HZ)
175 schedule_work(&linkwatch_work); 175 delay = 0;
176 else 176 schedule_delayed_work(&linkwatch_work, delay);
177 schedule_delayed_work(&linkwatch_work, delay);
178 } 177 }
179 } 178 }
180} 179}
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index ba509a4a8e92..0ab1987b9348 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -251,7 +251,7 @@ static struct neighbour *neigh_alloc(struct neigh_table *tbl)
251 goto out_entries; 251 goto out_entries;
252 } 252 }
253 253
254 n = kmem_cache_alloc(tbl->kmem_cachep, SLAB_ATOMIC); 254 n = kmem_cache_alloc(tbl->kmem_cachep, GFP_ATOMIC);
255 if (!n) 255 if (!n)
256 goto out_entries; 256 goto out_entries;
257 257
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 3c58846fcaa5..b3c559b9ac35 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -50,9 +50,10 @@ static atomic_t trapped;
50static void zap_completion_queue(void); 50static void zap_completion_queue(void);
51static void arp_reply(struct sk_buff *skb); 51static void arp_reply(struct sk_buff *skb);
52 52
53static void queue_process(void *p) 53static void queue_process(struct work_struct *work)
54{ 54{
55 struct netpoll_info *npinfo = p; 55 struct netpoll_info *npinfo =
56 container_of(work, struct netpoll_info, tx_work.work);
56 struct sk_buff *skb; 57 struct sk_buff *skb;
57 58
58 while ((skb = skb_dequeue(&npinfo->txq))) { 59 while ((skb = skb_dequeue(&npinfo->txq))) {
@@ -72,8 +73,6 @@ static void queue_process(void *p)
72 schedule_delayed_work(&npinfo->tx_work, HZ/10); 73 schedule_delayed_work(&npinfo->tx_work, HZ/10);
73 return; 74 return;
74 } 75 }
75
76 netif_tx_unlock_bh(dev);
77 } 76 }
78} 77}
79 78
@@ -263,7 +262,7 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
263 262
264 if (status != NETDEV_TX_OK) { 263 if (status != NETDEV_TX_OK) {
265 skb_queue_tail(&npinfo->txq, skb); 264 skb_queue_tail(&npinfo->txq, skb);
266 schedule_work(&npinfo->tx_work); 265 schedule_delayed_work(&npinfo->tx_work,0);
267 } 266 }
268} 267}
269 268
@@ -628,7 +627,7 @@ int netpoll_setup(struct netpoll *np)
628 spin_lock_init(&npinfo->rx_lock); 627 spin_lock_init(&npinfo->rx_lock);
629 skb_queue_head_init(&npinfo->arp_tx); 628 skb_queue_head_init(&npinfo->arp_tx);
630 skb_queue_head_init(&npinfo->txq); 629 skb_queue_head_init(&npinfo->txq);
631 INIT_WORK(&npinfo->tx_work, queue_process, npinfo); 630 INIT_DELAYED_WORK(&npinfo->tx_work, queue_process);
632 631
633 atomic_set(&npinfo->refcnt, 1); 632 atomic_set(&npinfo->refcnt, 1);
634 } else { 633 } else {
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 8e1c385e5ba9..de7801d589e7 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -68,8 +68,8 @@
68 68
69#include "kmap_skb.h" 69#include "kmap_skb.h"
70 70
71static kmem_cache_t *skbuff_head_cache __read_mostly; 71static struct kmem_cache *skbuff_head_cache __read_mostly;
72static kmem_cache_t *skbuff_fclone_cache __read_mostly; 72static struct kmem_cache *skbuff_fclone_cache __read_mostly;
73 73
74/* 74/*
75 * Keep out-of-line to prevent kernel bloat. 75 * Keep out-of-line to prevent kernel bloat.
@@ -132,6 +132,7 @@ EXPORT_SYMBOL(skb_truesize_bug);
132 * @gfp_mask: allocation mask 132 * @gfp_mask: allocation mask
133 * @fclone: allocate from fclone cache instead of head cache 133 * @fclone: allocate from fclone cache instead of head cache
134 * and allocate a cloned (child) skb 134 * and allocate a cloned (child) skb
135 * @node: numa node to allocate memory on
135 * 136 *
136 * Allocate a new &sk_buff. The returned buffer has no headroom and a 137 * Allocate a new &sk_buff. The returned buffer has no headroom and a
137 * tail room of size bytes. The object has a reference count of one. 138 * tail room of size bytes. The object has a reference count of one.
@@ -141,9 +142,9 @@ EXPORT_SYMBOL(skb_truesize_bug);
141 * %GFP_ATOMIC. 142 * %GFP_ATOMIC.
142 */ 143 */
143struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask, 144struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
144 int fclone) 145 int fclone, int node)
145{ 146{
146 kmem_cache_t *cache; 147 struct kmem_cache *cache;
147 struct skb_shared_info *shinfo; 148 struct skb_shared_info *shinfo;
148 struct sk_buff *skb; 149 struct sk_buff *skb;
149 u8 *data; 150 u8 *data;
@@ -151,14 +152,14 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
151 cache = fclone ? skbuff_fclone_cache : skbuff_head_cache; 152 cache = fclone ? skbuff_fclone_cache : skbuff_head_cache;
152 153
153 /* Get the HEAD */ 154 /* Get the HEAD */
154 skb = kmem_cache_alloc(cache, gfp_mask & ~__GFP_DMA); 155 skb = kmem_cache_alloc_node(cache, gfp_mask & ~__GFP_DMA, node);
155 if (!skb) 156 if (!skb)
156 goto out; 157 goto out;
157 158
158 /* Get the DATA. Size must match skb_add_mtu(). */ 159 /* Get the DATA. Size must match skb_add_mtu(). */
159 size = SKB_DATA_ALIGN(size); 160 size = SKB_DATA_ALIGN(size);
160 data = kmalloc_track_caller(size + sizeof(struct skb_shared_info), 161 data = kmalloc_node_track_caller(size + sizeof(struct skb_shared_info),
161 gfp_mask); 162 gfp_mask, node);
162 if (!data) 163 if (!data)
163 goto nodata; 164 goto nodata;
164 165
@@ -210,7 +211,7 @@ nodata:
210 * Buffers may only be allocated from interrupts using a @gfp_mask of 211 * Buffers may only be allocated from interrupts using a @gfp_mask of
211 * %GFP_ATOMIC. 212 * %GFP_ATOMIC.
212 */ 213 */
213struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp, 214struct sk_buff *alloc_skb_from_cache(struct kmem_cache *cp,
214 unsigned int size, 215 unsigned int size,
215 gfp_t gfp_mask) 216 gfp_t gfp_mask)
216{ 217{
@@ -267,9 +268,10 @@ nodata:
267struct sk_buff *__netdev_alloc_skb(struct net_device *dev, 268struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
268 unsigned int length, gfp_t gfp_mask) 269 unsigned int length, gfp_t gfp_mask)
269{ 270{
271 int node = dev->class_dev.dev ? dev_to_node(dev->class_dev.dev) : -1;
270 struct sk_buff *skb; 272 struct sk_buff *skb;
271 273
272 skb = alloc_skb(length + NET_SKB_PAD, gfp_mask); 274 skb = __alloc_skb(length + NET_SKB_PAD, gfp_mask, 0, node);
273 if (likely(skb)) { 275 if (likely(skb)) {
274 skb_reserve(skb, NET_SKB_PAD); 276 skb_reserve(skb, NET_SKB_PAD);
275 skb->dev = dev; 277 skb->dev = dev;
diff --git a/net/core/sock.c b/net/core/sock.c
index 419c7d3289c7..0ed5b4f0bc40 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -810,24 +810,11 @@ lenout:
810 */ 810 */
811static void inline sock_lock_init(struct sock *sk) 811static void inline sock_lock_init(struct sock *sk)
812{ 812{
813 spin_lock_init(&sk->sk_lock.slock); 813 sock_lock_init_class_and_name(sk,
814 sk->sk_lock.owner = NULL; 814 af_family_slock_key_strings[sk->sk_family],
815 init_waitqueue_head(&sk->sk_lock.wq); 815 af_family_slock_keys + sk->sk_family,
816 /* 816 af_family_key_strings[sk->sk_family],
817 * Make sure we are not reinitializing a held lock: 817 af_family_keys + sk->sk_family);
818 */
819 debug_check_no_locks_freed((void *)&sk->sk_lock, sizeof(sk->sk_lock));
820
821 /*
822 * Mark both the sk_lock and the sk_lock.slock as a
823 * per-address-family lock class:
824 */
825 lockdep_set_class_and_name(&sk->sk_lock.slock,
826 af_family_slock_keys + sk->sk_family,
827 af_family_slock_key_strings[sk->sk_family]);
828 lockdep_init_map(&sk->sk_lock.dep_map,
829 af_family_key_strings[sk->sk_family],
830 af_family_keys + sk->sk_family, 0);
831} 818}
832 819
833/** 820/**
@@ -841,7 +828,7 @@ struct sock *sk_alloc(int family, gfp_t priority,
841 struct proto *prot, int zero_it) 828 struct proto *prot, int zero_it)
842{ 829{
843 struct sock *sk = NULL; 830 struct sock *sk = NULL;
844 kmem_cache_t *slab = prot->slab; 831 struct kmem_cache *slab = prot->slab;
845 832
846 if (slab != NULL) 833 if (slab != NULL)
847 sk = kmem_cache_alloc(slab, priority); 834 sk = kmem_cache_alloc(slab, priority);
diff --git a/net/dccp/ackvec.c b/net/dccp/ackvec.c
index bdf1bb7a82c0..1f4727ddbdbf 100644
--- a/net/dccp/ackvec.c
+++ b/net/dccp/ackvec.c
@@ -21,8 +21,8 @@
21 21
22#include <net/sock.h> 22#include <net/sock.h>
23 23
24static kmem_cache_t *dccp_ackvec_slab; 24static struct kmem_cache *dccp_ackvec_slab;
25static kmem_cache_t *dccp_ackvec_record_slab; 25static struct kmem_cache *dccp_ackvec_record_slab;
26 26
27static struct dccp_ackvec_record *dccp_ackvec_record_new(void) 27static struct dccp_ackvec_record *dccp_ackvec_record_new(void)
28{ 28{
diff --git a/net/dccp/ccid.c b/net/dccp/ccid.c
index ff05e59043cd..d8cf92f09e68 100644
--- a/net/dccp/ccid.c
+++ b/net/dccp/ccid.c
@@ -55,9 +55,9 @@ static inline void ccids_read_unlock(void)
55#define ccids_read_unlock() do { } while(0) 55#define ccids_read_unlock() do { } while(0)
56#endif 56#endif
57 57
58static kmem_cache_t *ccid_kmem_cache_create(int obj_size, const char *fmt,...) 58static struct kmem_cache *ccid_kmem_cache_create(int obj_size, const char *fmt,...)
59{ 59{
60 kmem_cache_t *slab; 60 struct kmem_cache *slab;
61 char slab_name_fmt[32], *slab_name; 61 char slab_name_fmt[32], *slab_name;
62 va_list args; 62 va_list args;
63 63
@@ -75,7 +75,7 @@ static kmem_cache_t *ccid_kmem_cache_create(int obj_size, const char *fmt,...)
75 return slab; 75 return slab;
76} 76}
77 77
78static void ccid_kmem_cache_destroy(kmem_cache_t *slab) 78static void ccid_kmem_cache_destroy(struct kmem_cache *slab)
79{ 79{
80 if (slab != NULL) { 80 if (slab != NULL) {
81 const char *name = kmem_cache_name(slab); 81 const char *name = kmem_cache_name(slab);
diff --git a/net/dccp/ccid.h b/net/dccp/ccid.h
index c7c29514dce8..bcc2d12ae81c 100644
--- a/net/dccp/ccid.h
+++ b/net/dccp/ccid.h
@@ -27,9 +27,9 @@ struct ccid_operations {
27 unsigned char ccid_id; 27 unsigned char ccid_id;
28 const char *ccid_name; 28 const char *ccid_name;
29 struct module *ccid_owner; 29 struct module *ccid_owner;
30 kmem_cache_t *ccid_hc_rx_slab; 30 struct kmem_cache *ccid_hc_rx_slab;
31 __u32 ccid_hc_rx_obj_size; 31 __u32 ccid_hc_rx_obj_size;
32 kmem_cache_t *ccid_hc_tx_slab; 32 struct kmem_cache *ccid_hc_tx_slab;
33 __u32 ccid_hc_tx_obj_size; 33 __u32 ccid_hc_tx_obj_size;
34 int (*ccid_hc_rx_init)(struct ccid *ccid, struct sock *sk); 34 int (*ccid_hc_rx_init)(struct ccid *ccid, struct sock *sk);
35 int (*ccid_hc_tx_init)(struct ccid *ccid, struct sock *sk); 35 int (*ccid_hc_tx_init)(struct ccid *ccid, struct sock *sk);
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index cf8c07b2704f..66a27b9688ca 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -295,7 +295,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
295 new_packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist); 295 new_packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist);
296 if (new_packet == NULL || new_packet->dccphtx_sent) { 296 if (new_packet == NULL || new_packet->dccphtx_sent) {
297 new_packet = dccp_tx_hist_entry_new(ccid3_tx_hist, 297 new_packet = dccp_tx_hist_entry_new(ccid3_tx_hist,
298 SLAB_ATOMIC); 298 GFP_ATOMIC);
299 299
300 if (unlikely(new_packet == NULL)) { 300 if (unlikely(new_packet == NULL)) {
301 DCCP_WARN("%s, sk=%p, not enough mem to add to history," 301 DCCP_WARN("%s, sk=%p, not enough mem to add to history,"
@@ -889,7 +889,7 @@ static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss)
889 /* new loss event detected */ 889 /* new loss event detected */
890 /* calculate last interval length */ 890 /* calculate last interval length */
891 seq_temp = dccp_delta_seqno(head->dccplih_seqno, seq_loss); 891 seq_temp = dccp_delta_seqno(head->dccplih_seqno, seq_loss);
892 entry = dccp_li_hist_entry_new(ccid3_li_hist, SLAB_ATOMIC); 892 entry = dccp_li_hist_entry_new(ccid3_li_hist, GFP_ATOMIC);
893 893
894 if (entry == NULL) { 894 if (entry == NULL) {
895 DCCP_BUG("out of memory - can not allocate entry"); 895 DCCP_BUG("out of memory - can not allocate entry");
@@ -1011,7 +1011,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
1011 } 1011 }
1012 1012
1013 packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp, 1013 packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp,
1014 skb, SLAB_ATOMIC); 1014 skb, GFP_ATOMIC);
1015 if (unlikely(packet == NULL)) { 1015 if (unlikely(packet == NULL)) {
1016 DCCP_WARN("%s, sk=%p, Not enough mem to add rx packet " 1016 DCCP_WARN("%s, sk=%p, Not enough mem to add rx packet "
1017 "to history, consider it lost!\n", dccp_role(sk), sk); 1017 "to history, consider it lost!\n", dccp_role(sk), sk);
diff --git a/net/dccp/ccids/lib/loss_interval.c b/net/dccp/ccids/lib/loss_interval.c
index 48b9b93f8acb..0a0baef16b3e 100644
--- a/net/dccp/ccids/lib/loss_interval.c
+++ b/net/dccp/ccids/lib/loss_interval.c
@@ -125,7 +125,7 @@ int dccp_li_hist_interval_new(struct dccp_li_hist *hist,
125 int i; 125 int i;
126 126
127 for (i = 0; i < DCCP_LI_HIST_IVAL_F_LENGTH; i++) { 127 for (i = 0; i < DCCP_LI_HIST_IVAL_F_LENGTH; i++) {
128 entry = dccp_li_hist_entry_new(hist, SLAB_ATOMIC); 128 entry = dccp_li_hist_entry_new(hist, GFP_ATOMIC);
129 if (entry == NULL) { 129 if (entry == NULL) {
130 dccp_li_hist_purge(hist, list); 130 dccp_li_hist_purge(hist, list);
131 DCCP_BUG("loss interval list entry is NULL"); 131 DCCP_BUG("loss interval list entry is NULL");
diff --git a/net/dccp/ccids/lib/loss_interval.h b/net/dccp/ccids/lib/loss_interval.h
index 0ae85f0340b2..eb257014dd74 100644
--- a/net/dccp/ccids/lib/loss_interval.h
+++ b/net/dccp/ccids/lib/loss_interval.h
@@ -20,7 +20,7 @@
20#define DCCP_LI_HIST_IVAL_F_LENGTH 8 20#define DCCP_LI_HIST_IVAL_F_LENGTH 8
21 21
22struct dccp_li_hist { 22struct dccp_li_hist {
23 kmem_cache_t *dccplih_slab; 23 struct kmem_cache *dccplih_slab;
24}; 24};
25 25
26extern struct dccp_li_hist *dccp_li_hist_new(const char *name); 26extern struct dccp_li_hist *dccp_li_hist_new(const char *name);
diff --git a/net/dccp/ccids/lib/packet_history.h b/net/dccp/ccids/lib/packet_history.h
index 067cf1c85a37..9a8bcf224aa7 100644
--- a/net/dccp/ccids/lib/packet_history.h
+++ b/net/dccp/ccids/lib/packet_history.h
@@ -68,14 +68,14 @@ struct dccp_rx_hist_entry {
68}; 68};
69 69
70struct dccp_tx_hist { 70struct dccp_tx_hist {
71 kmem_cache_t *dccptxh_slab; 71 struct kmem_cache *dccptxh_slab;
72}; 72};
73 73
74extern struct dccp_tx_hist *dccp_tx_hist_new(const char *name); 74extern struct dccp_tx_hist *dccp_tx_hist_new(const char *name);
75extern void dccp_tx_hist_delete(struct dccp_tx_hist *hist); 75extern void dccp_tx_hist_delete(struct dccp_tx_hist *hist);
76 76
77struct dccp_rx_hist { 77struct dccp_rx_hist {
78 kmem_cache_t *dccprxh_slab; 78 struct kmem_cache *dccprxh_slab;
79}; 79};
80 80
81extern struct dccp_rx_hist *dccp_rx_hist_new(const char *name); 81extern struct dccp_rx_hist *dccp_rx_hist_new(const char *name);
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c
index 7b52f2a03eef..4c9e26775f72 100644
--- a/net/dccp/minisocks.c
+++ b/net/dccp/minisocks.c
@@ -32,8 +32,7 @@ struct inet_timewait_death_row dccp_death_row = {
32 .tw_timer = TIMER_INITIALIZER(inet_twdr_hangman, 0, 32 .tw_timer = TIMER_INITIALIZER(inet_twdr_hangman, 0,
33 (unsigned long)&dccp_death_row), 33 (unsigned long)&dccp_death_row),
34 .twkill_work = __WORK_INITIALIZER(dccp_death_row.twkill_work, 34 .twkill_work = __WORK_INITIALIZER(dccp_death_row.twkill_work,
35 inet_twdr_twkill_work, 35 inet_twdr_twkill_work),
36 &dccp_death_row),
37/* Short-time timewait calendar */ 36/* Short-time timewait calendar */
38 37
39 .twcal_hand = -1, 38 .twcal_hand = -1,
diff --git a/net/decnet/dn_table.c b/net/decnet/dn_table.c
index bdbc3f431668..13b2421991ba 100644
--- a/net/decnet/dn_table.c
+++ b/net/decnet/dn_table.c
@@ -79,7 +79,7 @@ for( ; ((f) = *(fp)) != NULL && dn_key_eq((f)->fn_key, (key)); (fp) = &(f)->fn_n
79static struct hlist_head dn_fib_table_hash[DN_FIB_TABLE_HASHSZ]; 79static struct hlist_head dn_fib_table_hash[DN_FIB_TABLE_HASHSZ];
80static DEFINE_RWLOCK(dn_fib_tables_lock); 80static DEFINE_RWLOCK(dn_fib_tables_lock);
81 81
82static kmem_cache_t *dn_hash_kmem __read_mostly; 82static struct kmem_cache *dn_hash_kmem __read_mostly;
83static int dn_fib_hash_zombies; 83static int dn_fib_hash_zombies;
84 84
85static inline dn_fib_idx_t dn_hash(dn_fib_key_t key, struct dn_zone *dz) 85static inline dn_fib_idx_t dn_hash(dn_fib_key_t key, struct dn_zone *dz)
@@ -590,7 +590,7 @@ create:
590 590
591replace: 591replace:
592 err = -ENOBUFS; 592 err = -ENOBUFS;
593 new_f = kmem_cache_alloc(dn_hash_kmem, SLAB_KERNEL); 593 new_f = kmem_cache_alloc(dn_hash_kmem, GFP_KERNEL);
594 if (new_f == NULL) 594 if (new_f == NULL)
595 goto out; 595 goto out;
596 596
diff --git a/net/ieee80211/softmac/ieee80211softmac_assoc.c b/net/ieee80211/softmac/ieee80211softmac_assoc.c
index cf51c87a971d..08386c102954 100644
--- a/net/ieee80211/softmac/ieee80211softmac_assoc.c
+++ b/net/ieee80211/softmac/ieee80211softmac_assoc.c
@@ -58,9 +58,11 @@ ieee80211softmac_assoc(struct ieee80211softmac_device *mac, struct ieee80211soft
58} 58}
59 59
60void 60void
61ieee80211softmac_assoc_timeout(void *d) 61ieee80211softmac_assoc_timeout(struct work_struct *work)
62{ 62{
63 struct ieee80211softmac_device *mac = (struct ieee80211softmac_device *)d; 63 struct ieee80211softmac_device *mac =
64 container_of(work, struct ieee80211softmac_device,
65 associnfo.timeout.work);
64 struct ieee80211softmac_network *n; 66 struct ieee80211softmac_network *n;
65 67
66 mutex_lock(&mac->associnfo.mutex); 68 mutex_lock(&mac->associnfo.mutex);
@@ -186,9 +188,11 @@ ieee80211softmac_assoc_notify_auth(struct net_device *dev, int event_type, void
186 188
187/* This function is called to handle userspace requests (asynchronously) */ 189/* This function is called to handle userspace requests (asynchronously) */
188void 190void
189ieee80211softmac_assoc_work(void *d) 191ieee80211softmac_assoc_work(struct work_struct *work)
190{ 192{
191 struct ieee80211softmac_device *mac = (struct ieee80211softmac_device *)d; 193 struct ieee80211softmac_device *mac =
194 container_of(work, struct ieee80211softmac_device,
195 associnfo.work.work);
192 struct ieee80211softmac_network *found = NULL; 196 struct ieee80211softmac_network *found = NULL;
193 struct ieee80211_network *net = NULL, *best = NULL; 197 struct ieee80211_network *net = NULL, *best = NULL;
194 int bssvalid; 198 int bssvalid;
@@ -412,7 +416,7 @@ ieee80211softmac_handle_assoc_response(struct net_device * dev,
412 network->authenticated = 0; 416 network->authenticated = 0;
413 /* we don't want to do this more than once ... */ 417 /* we don't want to do this more than once ... */
414 network->auth_desynced_once = 1; 418 network->auth_desynced_once = 1;
415 schedule_work(&mac->associnfo.work); 419 schedule_delayed_work(&mac->associnfo.work, 0);
416 break; 420 break;
417 } 421 }
418 default: 422 default:
@@ -446,7 +450,7 @@ ieee80211softmac_handle_disassoc(struct net_device * dev,
446 ieee80211softmac_disassoc(mac); 450 ieee80211softmac_disassoc(mac);
447 451
448 /* try to reassociate */ 452 /* try to reassociate */
449 schedule_work(&mac->associnfo.work); 453 schedule_delayed_work(&mac->associnfo.work, 0);
450 454
451 return 0; 455 return 0;
452} 456}
@@ -466,7 +470,7 @@ ieee80211softmac_handle_reassoc_req(struct net_device * dev,
466 dprintkl(KERN_INFO PFX "reassoc request from unknown network\n"); 470 dprintkl(KERN_INFO PFX "reassoc request from unknown network\n");
467 return 0; 471 return 0;
468 } 472 }
469 schedule_work(&mac->associnfo.work); 473 schedule_delayed_work(&mac->associnfo.work, 0);
470 474
471 return 0; 475 return 0;
472} 476}
diff --git a/net/ieee80211/softmac/ieee80211softmac_auth.c b/net/ieee80211/softmac/ieee80211softmac_auth.c
index 0612015f1c78..6012705aa4f8 100644
--- a/net/ieee80211/softmac/ieee80211softmac_auth.c
+++ b/net/ieee80211/softmac/ieee80211softmac_auth.c
@@ -26,7 +26,7 @@
26 26
27#include "ieee80211softmac_priv.h" 27#include "ieee80211softmac_priv.h"
28 28
29static void ieee80211softmac_auth_queue(void *data); 29static void ieee80211softmac_auth_queue(struct work_struct *work);
30 30
31/* Queues an auth request to the desired AP */ 31/* Queues an auth request to the desired AP */
32int 32int
@@ -54,14 +54,14 @@ ieee80211softmac_auth_req(struct ieee80211softmac_device *mac,
54 auth->mac = mac; 54 auth->mac = mac;
55 auth->retry = IEEE80211SOFTMAC_AUTH_RETRY_LIMIT; 55 auth->retry = IEEE80211SOFTMAC_AUTH_RETRY_LIMIT;
56 auth->state = IEEE80211SOFTMAC_AUTH_OPEN_REQUEST; 56 auth->state = IEEE80211SOFTMAC_AUTH_OPEN_REQUEST;
57 INIT_WORK(&auth->work, &ieee80211softmac_auth_queue, (void *)auth); 57 INIT_DELAYED_WORK(&auth->work, ieee80211softmac_auth_queue);
58 58
59 /* Lock (for list) */ 59 /* Lock (for list) */
60 spin_lock_irqsave(&mac->lock, flags); 60 spin_lock_irqsave(&mac->lock, flags);
61 61
62 /* add to list */ 62 /* add to list */
63 list_add_tail(&auth->list, &mac->auth_queue); 63 list_add_tail(&auth->list, &mac->auth_queue);
64 schedule_work(&auth->work); 64 schedule_delayed_work(&auth->work, 0);
65 spin_unlock_irqrestore(&mac->lock, flags); 65 spin_unlock_irqrestore(&mac->lock, flags);
66 66
67 return 0; 67 return 0;
@@ -70,14 +70,15 @@ ieee80211softmac_auth_req(struct ieee80211softmac_device *mac,
70 70
71/* Sends an auth request to the desired AP and handles timeouts */ 71/* Sends an auth request to the desired AP and handles timeouts */
72static void 72static void
73ieee80211softmac_auth_queue(void *data) 73ieee80211softmac_auth_queue(struct work_struct *work)
74{ 74{
75 struct ieee80211softmac_device *mac; 75 struct ieee80211softmac_device *mac;
76 struct ieee80211softmac_auth_queue_item *auth; 76 struct ieee80211softmac_auth_queue_item *auth;
77 struct ieee80211softmac_network *net; 77 struct ieee80211softmac_network *net;
78 unsigned long flags; 78 unsigned long flags;
79 79
80 auth = (struct ieee80211softmac_auth_queue_item *)data; 80 auth = container_of(work, struct ieee80211softmac_auth_queue_item,
81 work.work);
81 net = auth->net; 82 net = auth->net;
82 mac = auth->mac; 83 mac = auth->mac;
83 84
@@ -118,9 +119,11 @@ ieee80211softmac_auth_queue(void *data)
118 119
119/* Sends a response to an auth challenge (for shared key auth). */ 120/* Sends a response to an auth challenge (for shared key auth). */
120static void 121static void
121ieee80211softmac_auth_challenge_response(void *_aq) 122ieee80211softmac_auth_challenge_response(struct work_struct *work)
122{ 123{
123 struct ieee80211softmac_auth_queue_item *aq = _aq; 124 struct ieee80211softmac_auth_queue_item *aq =
125 container_of(work, struct ieee80211softmac_auth_queue_item,
126 work.work);
124 127
125 /* Send our response */ 128 /* Send our response */
126 ieee80211softmac_send_mgt_frame(aq->mac, aq->net, IEEE80211_STYPE_AUTH, aq->state); 129 ieee80211softmac_send_mgt_frame(aq->mac, aq->net, IEEE80211_STYPE_AUTH, aq->state);
@@ -234,8 +237,8 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
234 * we have obviously already sent the initial auth 237 * we have obviously already sent the initial auth
235 * request. */ 238 * request. */
236 cancel_delayed_work(&aq->work); 239 cancel_delayed_work(&aq->work);
237 INIT_WORK(&aq->work, &ieee80211softmac_auth_challenge_response, (void *)aq); 240 INIT_DELAYED_WORK(&aq->work, &ieee80211softmac_auth_challenge_response);
238 schedule_work(&aq->work); 241 schedule_delayed_work(&aq->work, 0);
239 spin_unlock_irqrestore(&mac->lock, flags); 242 spin_unlock_irqrestore(&mac->lock, flags);
240 return 0; 243 return 0;
241 case IEEE80211SOFTMAC_AUTH_SHARED_PASS: 244 case IEEE80211SOFTMAC_AUTH_SHARED_PASS:
@@ -398,6 +401,6 @@ ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_deauth *de
398 ieee80211softmac_deauth_from_net(mac, net); 401 ieee80211softmac_deauth_from_net(mac, net);
399 402
400 /* let's try to re-associate */ 403 /* let's try to re-associate */
401 schedule_work(&mac->associnfo.work); 404 schedule_delayed_work(&mac->associnfo.work, 0);
402 return 0; 405 return 0;
403} 406}
diff --git a/net/ieee80211/softmac/ieee80211softmac_event.c b/net/ieee80211/softmac/ieee80211softmac_event.c
index f34fa2ef666b..b9015656cfb3 100644
--- a/net/ieee80211/softmac/ieee80211softmac_event.c
+++ b/net/ieee80211/softmac/ieee80211softmac_event.c
@@ -73,10 +73,12 @@ static char *event_descriptions[IEEE80211SOFTMAC_EVENT_LAST+1] = {
73 73
74 74
75static void 75static void
76ieee80211softmac_notify_callback(void *d) 76ieee80211softmac_notify_callback(struct work_struct *work)
77{ 77{
78 struct ieee80211softmac_event event = *(struct ieee80211softmac_event*) d; 78 struct ieee80211softmac_event *pevent =
79 kfree(d); 79 container_of(work, struct ieee80211softmac_event, work.work);
80 struct ieee80211softmac_event event = *pevent;
81 kfree(pevent);
80 82
81 event.fun(event.mac->dev, event.event_type, event.context); 83 event.fun(event.mac->dev, event.event_type, event.context);
82} 84}
@@ -99,7 +101,7 @@ ieee80211softmac_notify_internal(struct ieee80211softmac_device *mac,
99 return -ENOMEM; 101 return -ENOMEM;
100 102
101 eventptr->event_type = event; 103 eventptr->event_type = event;
102 INIT_WORK(&eventptr->work, ieee80211softmac_notify_callback, eventptr); 104 INIT_DELAYED_WORK(&eventptr->work, ieee80211softmac_notify_callback);
103 eventptr->fun = fun; 105 eventptr->fun = fun;
104 eventptr->context = context; 106 eventptr->context = context;
105 eventptr->mac = mac; 107 eventptr->mac = mac;
@@ -170,7 +172,7 @@ ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int eve
170 /* User may have subscribed to ANY event, so 172 /* User may have subscribed to ANY event, so
171 * we tell them which event triggered it. */ 173 * we tell them which event triggered it. */
172 eventptr->event_type = event; 174 eventptr->event_type = event;
173 schedule_work(&eventptr->work); 175 schedule_delayed_work(&eventptr->work, 0);
174 } 176 }
175 } 177 }
176} 178}
diff --git a/net/ieee80211/softmac/ieee80211softmac_module.c b/net/ieee80211/softmac/ieee80211softmac_module.c
index 33aff4f4a471..256207b71dc9 100644
--- a/net/ieee80211/softmac/ieee80211softmac_module.c
+++ b/net/ieee80211/softmac/ieee80211softmac_module.c
@@ -58,8 +58,8 @@ struct net_device *alloc_ieee80211softmac(int sizeof_priv)
58 INIT_LIST_HEAD(&softmac->events); 58 INIT_LIST_HEAD(&softmac->events);
59 59
60 mutex_init(&softmac->associnfo.mutex); 60 mutex_init(&softmac->associnfo.mutex);
61 INIT_WORK(&softmac->associnfo.work, ieee80211softmac_assoc_work, softmac); 61 INIT_DELAYED_WORK(&softmac->associnfo.work, ieee80211softmac_assoc_work);
62 INIT_WORK(&softmac->associnfo.timeout, ieee80211softmac_assoc_timeout, softmac); 62 INIT_DELAYED_WORK(&softmac->associnfo.timeout, ieee80211softmac_assoc_timeout);
63 softmac->start_scan = ieee80211softmac_start_scan_implementation; 63 softmac->start_scan = ieee80211softmac_start_scan_implementation;
64 softmac->wait_for_scan = ieee80211softmac_wait_for_scan_implementation; 64 softmac->wait_for_scan = ieee80211softmac_wait_for_scan_implementation;
65 softmac->stop_scan = ieee80211softmac_stop_scan_implementation; 65 softmac->stop_scan = ieee80211softmac_stop_scan_implementation;
diff --git a/net/ieee80211/softmac/ieee80211softmac_priv.h b/net/ieee80211/softmac/ieee80211softmac_priv.h
index 0642e090b8a7..c0dbe070e548 100644
--- a/net/ieee80211/softmac/ieee80211softmac_priv.h
+++ b/net/ieee80211/softmac/ieee80211softmac_priv.h
@@ -78,7 +78,7 @@
78/* private definitions and prototypes */ 78/* private definitions and prototypes */
79 79
80/*** prototypes from _scan.c */ 80/*** prototypes from _scan.c */
81void ieee80211softmac_scan(void *sm); 81void ieee80211softmac_scan(struct work_struct *work);
82/* for internal use if scanning is needed */ 82/* for internal use if scanning is needed */
83int ieee80211softmac_start_scan(struct ieee80211softmac_device *mac); 83int ieee80211softmac_start_scan(struct ieee80211softmac_device *mac);
84void ieee80211softmac_stop_scan(struct ieee80211softmac_device *mac); 84void ieee80211softmac_stop_scan(struct ieee80211softmac_device *mac);
@@ -149,7 +149,7 @@ int ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *au
149int ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_deauth *deauth); 149int ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_deauth *deauth);
150 150
151/*** prototypes from _assoc.c */ 151/*** prototypes from _assoc.c */
152void ieee80211softmac_assoc_work(void *d); 152void ieee80211softmac_assoc_work(struct work_struct *work);
153int ieee80211softmac_handle_assoc_response(struct net_device * dev, 153int ieee80211softmac_handle_assoc_response(struct net_device * dev,
154 struct ieee80211_assoc_response * resp, 154 struct ieee80211_assoc_response * resp,
155 struct ieee80211_network * network); 155 struct ieee80211_network * network);
@@ -157,7 +157,7 @@ int ieee80211softmac_handle_disassoc(struct net_device * dev,
157 struct ieee80211_disassoc * disassoc); 157 struct ieee80211_disassoc * disassoc);
158int ieee80211softmac_handle_reassoc_req(struct net_device * dev, 158int ieee80211softmac_handle_reassoc_req(struct net_device * dev,
159 struct ieee80211_reassoc_request * reassoc); 159 struct ieee80211_reassoc_request * reassoc);
160void ieee80211softmac_assoc_timeout(void *d); 160void ieee80211softmac_assoc_timeout(struct work_struct *work);
161void ieee80211softmac_send_disassoc_req(struct ieee80211softmac_device *mac, u16 reason); 161void ieee80211softmac_send_disassoc_req(struct ieee80211softmac_device *mac, u16 reason);
162void ieee80211softmac_disassoc(struct ieee80211softmac_device *mac); 162void ieee80211softmac_disassoc(struct ieee80211softmac_device *mac);
163 163
@@ -207,7 +207,7 @@ struct ieee80211softmac_auth_queue_item {
207 struct ieee80211softmac_device *mac; /* SoftMAC device */ 207 struct ieee80211softmac_device *mac; /* SoftMAC device */
208 u8 retry; /* Retry limit */ 208 u8 retry; /* Retry limit */
209 u8 state; /* Auth State */ 209 u8 state; /* Auth State */
210 struct work_struct work; /* Work queue */ 210 struct delayed_work work; /* Work queue */
211}; 211};
212 212
213/* scanning information */ 213/* scanning information */
@@ -219,7 +219,8 @@ struct ieee80211softmac_scaninfo {
219 stop:1; 219 stop:1;
220 u8 skip_flags; 220 u8 skip_flags;
221 struct completion finished; 221 struct completion finished;
222 struct work_struct softmac_scan; 222 struct delayed_work softmac_scan;
223 struct ieee80211softmac_device *mac;
223}; 224};
224 225
225/* private event struct */ 226/* private event struct */
@@ -227,7 +228,7 @@ struct ieee80211softmac_event {
227 struct list_head list; 228 struct list_head list;
228 int event_type; 229 int event_type;
229 void *event_context; 230 void *event_context;
230 struct work_struct work; 231 struct delayed_work work;
231 notify_function_ptr fun; 232 notify_function_ptr fun;
232 void *context; 233 void *context;
233 struct ieee80211softmac_device *mac; 234 struct ieee80211softmac_device *mac;
diff --git a/net/ieee80211/softmac/ieee80211softmac_scan.c b/net/ieee80211/softmac/ieee80211softmac_scan.c
index 5507feab32de..0c85d6c24cdb 100644
--- a/net/ieee80211/softmac/ieee80211softmac_scan.c
+++ b/net/ieee80211/softmac/ieee80211softmac_scan.c
@@ -90,12 +90,14 @@ ieee80211softmac_wait_for_scan(struct ieee80211softmac_device *sm)
90 90
91 91
92/* internal scanning implementation follows */ 92/* internal scanning implementation follows */
93void ieee80211softmac_scan(void *d) 93void ieee80211softmac_scan(struct work_struct *work)
94{ 94{
95 int invalid_channel; 95 int invalid_channel;
96 u8 current_channel_idx; 96 u8 current_channel_idx;
97 struct ieee80211softmac_device *sm = (struct ieee80211softmac_device *)d; 97 struct ieee80211softmac_scaninfo *si =
98 struct ieee80211softmac_scaninfo *si = sm->scaninfo; 98 container_of(work, struct ieee80211softmac_scaninfo,
99 softmac_scan.work);
100 struct ieee80211softmac_device *sm = si->mac;
99 unsigned long flags; 101 unsigned long flags;
100 102
101 while (!(si->stop) && (si->current_channel_idx < si->number_channels)) { 103 while (!(si->stop) && (si->current_channel_idx < si->number_channels)) {
@@ -146,7 +148,8 @@ static inline struct ieee80211softmac_scaninfo *allocate_scaninfo(struct ieee802
146 struct ieee80211softmac_scaninfo *info = kmalloc(sizeof(struct ieee80211softmac_scaninfo), GFP_ATOMIC); 148 struct ieee80211softmac_scaninfo *info = kmalloc(sizeof(struct ieee80211softmac_scaninfo), GFP_ATOMIC);
147 if (unlikely(!info)) 149 if (unlikely(!info))
148 return NULL; 150 return NULL;
149 INIT_WORK(&info->softmac_scan, ieee80211softmac_scan, mac); 151 INIT_DELAYED_WORK(&info->softmac_scan, ieee80211softmac_scan);
152 info->mac = mac;
150 init_completion(&info->finished); 153 init_completion(&info->finished);
151 return info; 154 return info;
152} 155}
@@ -187,7 +190,7 @@ int ieee80211softmac_start_scan_implementation(struct net_device *dev)
187 sm->scaninfo->started = 1; 190 sm->scaninfo->started = 1;
188 sm->scaninfo->stop = 0; 191 sm->scaninfo->stop = 0;
189 INIT_COMPLETION(sm->scaninfo->finished); 192 INIT_COMPLETION(sm->scaninfo->finished);
190 schedule_work(&sm->scaninfo->softmac_scan); 193 schedule_delayed_work(&sm->scaninfo->softmac_scan, 0);
191 spin_unlock_irqrestore(&sm->lock, flags); 194 spin_unlock_irqrestore(&sm->lock, flags);
192 return 0; 195 return 0;
193} 196}
diff --git a/net/ieee80211/softmac/ieee80211softmac_wx.c b/net/ieee80211/softmac/ieee80211softmac_wx.c
index 23068a830f7d..2ffaebd21c53 100644
--- a/net/ieee80211/softmac/ieee80211softmac_wx.c
+++ b/net/ieee80211/softmac/ieee80211softmac_wx.c
@@ -122,7 +122,7 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev,
122 122
123 sm->associnfo.associating = 1; 123 sm->associnfo.associating = 1;
124 /* queue lower level code to do work (if necessary) */ 124 /* queue lower level code to do work (if necessary) */
125 schedule_work(&sm->associnfo.work); 125 schedule_delayed_work(&sm->associnfo.work, 0);
126out: 126out:
127 mutex_unlock(&sm->associnfo.mutex); 127 mutex_unlock(&sm->associnfo.mutex);
128 128
@@ -356,7 +356,7 @@ ieee80211softmac_wx_set_wap(struct net_device *net_dev,
356 /* force reassociation */ 356 /* force reassociation */
357 mac->associnfo.bssvalid = 0; 357 mac->associnfo.bssvalid = 0;
358 if (mac->associnfo.associated) 358 if (mac->associnfo.associated)
359 schedule_work(&mac->associnfo.work); 359 schedule_delayed_work(&mac->associnfo.work, 0);
360 } else if (is_zero_ether_addr(data->ap_addr.sa_data)) { 360 } else if (is_zero_ether_addr(data->ap_addr.sa_data)) {
361 /* the bssid we have is no longer fixed */ 361 /* the bssid we have is no longer fixed */
362 mac->associnfo.bssfixed = 0; 362 mac->associnfo.bssfixed = 0;
@@ -373,7 +373,7 @@ ieee80211softmac_wx_set_wap(struct net_device *net_dev,
373 /* tell the other code that this bssid should be used no matter what */ 373 /* tell the other code that this bssid should be used no matter what */
374 mac->associnfo.bssfixed = 1; 374 mac->associnfo.bssfixed = 1;
375 /* queue associate if new bssid or (old one again and not associated) */ 375 /* queue associate if new bssid or (old one again and not associated) */
376 schedule_work(&mac->associnfo.work); 376 schedule_delayed_work(&mac->associnfo.work, 0);
377 } 377 }
378 378
379 out: 379 out:
diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c
index 107bb6cbb0b3..648f47c1c399 100644
--- a/net/ipv4/fib_hash.c
+++ b/net/ipv4/fib_hash.c
@@ -45,8 +45,8 @@
45 45
46#include "fib_lookup.h" 46#include "fib_lookup.h"
47 47
48static kmem_cache_t *fn_hash_kmem __read_mostly; 48static struct kmem_cache *fn_hash_kmem __read_mostly;
49static kmem_cache_t *fn_alias_kmem __read_mostly; 49static struct kmem_cache *fn_alias_kmem __read_mostly;
50 50
51struct fib_node { 51struct fib_node {
52 struct hlist_node fn_hash; 52 struct hlist_node fn_hash;
@@ -485,13 +485,13 @@ static int fn_hash_insert(struct fib_table *tb, struct fib_config *cfg)
485 goto out; 485 goto out;
486 486
487 err = -ENOBUFS; 487 err = -ENOBUFS;
488 new_fa = kmem_cache_alloc(fn_alias_kmem, SLAB_KERNEL); 488 new_fa = kmem_cache_alloc(fn_alias_kmem, GFP_KERNEL);
489 if (new_fa == NULL) 489 if (new_fa == NULL)
490 goto out; 490 goto out;
491 491
492 new_f = NULL; 492 new_f = NULL;
493 if (!f) { 493 if (!f) {
494 new_f = kmem_cache_alloc(fn_hash_kmem, SLAB_KERNEL); 494 new_f = kmem_cache_alloc(fn_hash_kmem, GFP_KERNEL);
495 if (new_f == NULL) 495 if (new_f == NULL)
496 goto out_free_new_fa; 496 goto out_free_new_fa;
497 497
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index d17990ec724f..cfb249cc0a58 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -172,7 +172,7 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn);
172static struct tnode *halve(struct trie *t, struct tnode *tn); 172static struct tnode *halve(struct trie *t, struct tnode *tn);
173static void tnode_free(struct tnode *tn); 173static void tnode_free(struct tnode *tn);
174 174
175static kmem_cache_t *fn_alias_kmem __read_mostly; 175static struct kmem_cache *fn_alias_kmem __read_mostly;
176static struct trie *trie_local = NULL, *trie_main = NULL; 176static struct trie *trie_local = NULL, *trie_main = NULL;
177 177
178 178
@@ -1187,7 +1187,7 @@ static int fn_trie_insert(struct fib_table *tb, struct fib_config *cfg)
1187 u8 state; 1187 u8 state;
1188 1188
1189 err = -ENOBUFS; 1189 err = -ENOBUFS;
1190 new_fa = kmem_cache_alloc(fn_alias_kmem, SLAB_KERNEL); 1190 new_fa = kmem_cache_alloc(fn_alias_kmem, GFP_KERNEL);
1191 if (new_fa == NULL) 1191 if (new_fa == NULL)
1192 goto out; 1192 goto out;
1193 1193
@@ -1232,7 +1232,7 @@ static int fn_trie_insert(struct fib_table *tb, struct fib_config *cfg)
1232 goto out; 1232 goto out;
1233 1233
1234 err = -ENOBUFS; 1234 err = -ENOBUFS;
1235 new_fa = kmem_cache_alloc(fn_alias_kmem, SLAB_KERNEL); 1235 new_fa = kmem_cache_alloc(fn_alias_kmem, GFP_KERNEL);
1236 if (new_fa == NULL) 1236 if (new_fa == NULL)
1237 goto out; 1237 goto out;
1238 1238
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 244c4f445c7d..8c79c8a4ea5c 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -27,11 +27,11 @@
27 * Allocate and initialize a new local port bind bucket. 27 * Allocate and initialize a new local port bind bucket.
28 * The bindhash mutex for snum's hash chain must be held here. 28 * The bindhash mutex for snum's hash chain must be held here.
29 */ 29 */
30struct inet_bind_bucket *inet_bind_bucket_create(kmem_cache_t *cachep, 30struct inet_bind_bucket *inet_bind_bucket_create(struct kmem_cache *cachep,
31 struct inet_bind_hashbucket *head, 31 struct inet_bind_hashbucket *head,
32 const unsigned short snum) 32 const unsigned short snum)
33{ 33{
34 struct inet_bind_bucket *tb = kmem_cache_alloc(cachep, SLAB_ATOMIC); 34 struct inet_bind_bucket *tb = kmem_cache_alloc(cachep, GFP_ATOMIC);
35 35
36 if (tb != NULL) { 36 if (tb != NULL) {
37 tb->port = snum; 37 tb->port = snum;
@@ -45,7 +45,7 @@ struct inet_bind_bucket *inet_bind_bucket_create(kmem_cache_t *cachep,
45/* 45/*
46 * Caller must hold hashbucket lock for this tb with local BH disabled 46 * Caller must hold hashbucket lock for this tb with local BH disabled
47 */ 47 */
48void inet_bind_bucket_destroy(kmem_cache_t *cachep, struct inet_bind_bucket *tb) 48void inet_bind_bucket_destroy(struct kmem_cache *cachep, struct inet_bind_bucket *tb)
49{ 49{
50 if (hlist_empty(&tb->owners)) { 50 if (hlist_empty(&tb->owners)) {
51 __hlist_del(&tb->node); 51 __hlist_del(&tb->node);
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
index cdd805344c61..e28330aa4139 100644
--- a/net/ipv4/inet_timewait_sock.c
+++ b/net/ipv4/inet_timewait_sock.c
@@ -91,7 +91,7 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int stat
91{ 91{
92 struct inet_timewait_sock *tw = 92 struct inet_timewait_sock *tw =
93 kmem_cache_alloc(sk->sk_prot_creator->twsk_prot->twsk_slab, 93 kmem_cache_alloc(sk->sk_prot_creator->twsk_prot->twsk_slab,
94 SLAB_ATOMIC); 94 GFP_ATOMIC);
95 if (tw != NULL) { 95 if (tw != NULL) {
96 const struct inet_sock *inet = inet_sk(sk); 96 const struct inet_sock *inet = inet_sk(sk);
97 97
@@ -197,9 +197,10 @@ EXPORT_SYMBOL_GPL(inet_twdr_hangman);
197 197
198extern void twkill_slots_invalid(void); 198extern void twkill_slots_invalid(void);
199 199
200void inet_twdr_twkill_work(void *data) 200void inet_twdr_twkill_work(struct work_struct *work)
201{ 201{
202 struct inet_timewait_death_row *twdr = data; 202 struct inet_timewait_death_row *twdr =
203 container_of(work, struct inet_timewait_death_row, twkill_work);
203 int i; 204 int i;
204 205
205 if ((INET_TWDR_TWKILL_SLOTS - 1) > (sizeof(twdr->thread_slots) * 8)) 206 if ((INET_TWDR_TWKILL_SLOTS - 1) > (sizeof(twdr->thread_slots) * 8))
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index f072f3875af8..711eb6d0285a 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -73,7 +73,7 @@
73/* Exported for inet_getid inline function. */ 73/* Exported for inet_getid inline function. */
74DEFINE_SPINLOCK(inet_peer_idlock); 74DEFINE_SPINLOCK(inet_peer_idlock);
75 75
76static kmem_cache_t *peer_cachep __read_mostly; 76static struct kmem_cache *peer_cachep __read_mostly;
77 77
78#define node_height(x) x->avl_height 78#define node_height(x) x->avl_height
79static struct inet_peer peer_fake_node = { 79static struct inet_peer peer_fake_node = {
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index efcf45ecc818..ecb5422ea237 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -105,7 +105,7 @@ static DEFINE_SPINLOCK(mfc_unres_lock);
105 In this case data path is free of exclusive locks at all. 105 In this case data path is free of exclusive locks at all.
106 */ 106 */
107 107
108static kmem_cache_t *mrt_cachep __read_mostly; 108static struct kmem_cache *mrt_cachep __read_mostly;
109 109
110static int ip_mr_forward(struct sk_buff *skb, struct mfc_cache *cache, int local); 110static int ip_mr_forward(struct sk_buff *skb, struct mfc_cache *cache, int local);
111static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert); 111static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert);
diff --git a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c
index 8832eb517d52..8086787a2c51 100644
--- a/net/ipv4/ipvs/ip_vs_conn.c
+++ b/net/ipv4/ipvs/ip_vs_conn.c
@@ -44,7 +44,7 @@
44static struct list_head *ip_vs_conn_tab; 44static struct list_head *ip_vs_conn_tab;
45 45
46/* SLAB cache for IPVS connections */ 46/* SLAB cache for IPVS connections */
47static kmem_cache_t *ip_vs_conn_cachep __read_mostly; 47static struct kmem_cache *ip_vs_conn_cachep __read_mostly;
48 48
49/* counter for current IPVS connections */ 49/* counter for current IPVS connections */
50static atomic_t ip_vs_conn_count = ATOMIC_INIT(0); 50static atomic_t ip_vs_conn_count = ATOMIC_INIT(0);
diff --git a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c
index f261616e4602..9b933381ebbe 100644
--- a/net/ipv4/ipvs/ip_vs_ctl.c
+++ b/net/ipv4/ipvs/ip_vs_ctl.c
@@ -221,10 +221,10 @@ static void update_defense_level(void)
221 * Timer for checking the defense 221 * Timer for checking the defense
222 */ 222 */
223#define DEFENSE_TIMER_PERIOD 1*HZ 223#define DEFENSE_TIMER_PERIOD 1*HZ
224static void defense_work_handler(void *data); 224static void defense_work_handler(struct work_struct *work);
225static DECLARE_WORK(defense_work, defense_work_handler, NULL); 225static DECLARE_DELAYED_WORK(defense_work, defense_work_handler);
226 226
227static void defense_work_handler(void *data) 227static void defense_work_handler(struct work_struct *work)
228{ 228{
229 update_defense_level(); 229 update_defense_level();
230 if (atomic_read(&ip_vs_dropentry)) 230 if (atomic_read(&ip_vs_dropentry))
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
index f4b0e68a16d2..8556a4f4f60a 100644
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -65,8 +65,8 @@ static LIST_HEAD(helpers);
65unsigned int ip_conntrack_htable_size __read_mostly = 0; 65unsigned int ip_conntrack_htable_size __read_mostly = 0;
66int ip_conntrack_max __read_mostly; 66int ip_conntrack_max __read_mostly;
67struct list_head *ip_conntrack_hash __read_mostly; 67struct list_head *ip_conntrack_hash __read_mostly;
68static kmem_cache_t *ip_conntrack_cachep __read_mostly; 68static struct kmem_cache *ip_conntrack_cachep __read_mostly;
69static kmem_cache_t *ip_conntrack_expect_cachep __read_mostly; 69static struct kmem_cache *ip_conntrack_expect_cachep __read_mostly;
70struct ip_conntrack ip_conntrack_untracked; 70struct ip_conntrack ip_conntrack_untracked;
71unsigned int ip_ct_log_invalid __read_mostly; 71unsigned int ip_ct_log_invalid __read_mostly;
72static LIST_HEAD(unconfirmed); 72static LIST_HEAD(unconfirmed);
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 6dddf59c1fb9..4a3889dd1943 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -45,8 +45,7 @@ struct inet_timewait_death_row tcp_death_row = {
45 .tw_timer = TIMER_INITIALIZER(inet_twdr_hangman, 0, 45 .tw_timer = TIMER_INITIALIZER(inet_twdr_hangman, 0,
46 (unsigned long)&tcp_death_row), 46 (unsigned long)&tcp_death_row),
47 .twkill_work = __WORK_INITIALIZER(tcp_death_row.twkill_work, 47 .twkill_work = __WORK_INITIALIZER(tcp_death_row.twkill_work,
48 inet_twdr_twkill_work, 48 inet_twdr_twkill_work),
49 &tcp_death_row),
50/* Short-time timewait calendar */ 49/* Short-time timewait calendar */
51 50
52 .twcal_hand = -1, 51 .twcal_hand = -1,
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 87c8f54872b7..e5cd83b2205d 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -720,10 +720,8 @@ snmp6_mib_free(void *ptr[2])
720{ 720{
721 if (ptr == NULL) 721 if (ptr == NULL)
722 return; 722 return;
723 if (ptr[0]) 723 free_percpu(ptr[0]);
724 free_percpu(ptr[0]); 724 free_percpu(ptr[1]);
725 if (ptr[1])
726 free_percpu(ptr[1]);
727 ptr[0] = ptr[1] = NULL; 725 ptr[0] = ptr[1] = NULL;
728} 726}
729 727
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index bf526115e518..96d8310ae9c8 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -50,7 +50,7 @@
50 50
51struct rt6_statistics rt6_stats; 51struct rt6_statistics rt6_stats;
52 52
53static kmem_cache_t * fib6_node_kmem __read_mostly; 53static struct kmem_cache * fib6_node_kmem __read_mostly;
54 54
55enum fib_walk_state_t 55enum fib_walk_state_t
56{ 56{
@@ -150,7 +150,7 @@ static __inline__ struct fib6_node * node_alloc(void)
150{ 150{
151 struct fib6_node *fn; 151 struct fib6_node *fn;
152 152
153 if ((fn = kmem_cache_alloc(fib6_node_kmem, SLAB_ATOMIC)) != NULL) 153 if ((fn = kmem_cache_alloc(fib6_node_kmem, GFP_ATOMIC)) != NULL)
154 memset(fn, 0, sizeof(struct fib6_node)); 154 memset(fn, 0, sizeof(struct fib6_node));
155 155
156 return fn; 156 return fn;
diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
index 01a5c52a2be3..12e426b9aacd 100644
--- a/net/ipv6/xfrm6_tunnel.c
+++ b/net/ipv6/xfrm6_tunnel.c
@@ -50,7 +50,7 @@ static u32 xfrm6_tunnel_spi;
50#define XFRM6_TUNNEL_SPI_MIN 1 50#define XFRM6_TUNNEL_SPI_MIN 1
51#define XFRM6_TUNNEL_SPI_MAX 0xffffffff 51#define XFRM6_TUNNEL_SPI_MAX 0xffffffff
52 52
53static kmem_cache_t *xfrm6_tunnel_spi_kmem __read_mostly; 53static struct kmem_cache *xfrm6_tunnel_spi_kmem __read_mostly;
54 54
55#define XFRM6_TUNNEL_SPI_BYADDR_HSIZE 256 55#define XFRM6_TUNNEL_SPI_BYADDR_HSIZE 256
56#define XFRM6_TUNNEL_SPI_BYSPI_HSIZE 256 56#define XFRM6_TUNNEL_SPI_BYSPI_HSIZE 256
@@ -180,7 +180,7 @@ try_next_2:;
180 spi = 0; 180 spi = 0;
181 goto out; 181 goto out;
182alloc_spi: 182alloc_spi:
183 x6spi = kmem_cache_alloc(xfrm6_tunnel_spi_kmem, SLAB_ATOMIC); 183 x6spi = kmem_cache_alloc(xfrm6_tunnel_spi_kmem, GFP_ATOMIC);
184 if (!x6spi) 184 if (!x6spi)
185 goto out; 185 goto out;
186 186
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index d50a02030ad7..262bda808d96 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -61,7 +61,7 @@ static void ircomm_tty_flush_buffer(struct tty_struct *tty);
61static void ircomm_tty_send_xchar(struct tty_struct *tty, char ch); 61static void ircomm_tty_send_xchar(struct tty_struct *tty, char ch);
62static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout); 62static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout);
63static void ircomm_tty_hangup(struct tty_struct *tty); 63static void ircomm_tty_hangup(struct tty_struct *tty);
64static void ircomm_tty_do_softint(void *private_); 64static void ircomm_tty_do_softint(struct work_struct *work);
65static void ircomm_tty_shutdown(struct ircomm_tty_cb *self); 65static void ircomm_tty_shutdown(struct ircomm_tty_cb *self);
66static void ircomm_tty_stop(struct tty_struct *tty); 66static void ircomm_tty_stop(struct tty_struct *tty);
67 67
@@ -389,7 +389,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
389 self->flow = FLOW_STOP; 389 self->flow = FLOW_STOP;
390 390
391 self->line = line; 391 self->line = line;
392 INIT_WORK(&self->tqueue, ircomm_tty_do_softint, self); 392 INIT_WORK(&self->tqueue, ircomm_tty_do_softint);
393 self->max_header_size = IRCOMM_TTY_HDR_UNINITIALISED; 393 self->max_header_size = IRCOMM_TTY_HDR_UNINITIALISED;
394 self->max_data_size = IRCOMM_TTY_DATA_UNINITIALISED; 394 self->max_data_size = IRCOMM_TTY_DATA_UNINITIALISED;
395 self->close_delay = 5*HZ/10; 395 self->close_delay = 5*HZ/10;
@@ -594,15 +594,16 @@ static void ircomm_tty_flush_buffer(struct tty_struct *tty)
594} 594}
595 595
596/* 596/*
597 * Function ircomm_tty_do_softint (private_) 597 * Function ircomm_tty_do_softint (work)
598 * 598 *
599 * We use this routine to give the write wakeup to the user at at a 599 * We use this routine to give the write wakeup to the user at at a
600 * safe time (as fast as possible after write have completed). This 600 * safe time (as fast as possible after write have completed). This
601 * can be compared to the Tx interrupt. 601 * can be compared to the Tx interrupt.
602 */ 602 */
603static void ircomm_tty_do_softint(void *private_) 603static void ircomm_tty_do_softint(struct work_struct *work)
604{ 604{
605 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) private_; 605 struct ircomm_tty_cb *self =
606 container_of(work, struct ircomm_tty_cb, tqueue);
606 struct tty_struct *tty; 607 struct tty_struct *tty;
607 unsigned long flags; 608 unsigned long flags;
608 struct sk_buff *skb, *ctrl_skb; 609 struct sk_buff *skb, *ctrl_skb;
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index eaa0f8a1adb6..a9638ff52a72 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -108,7 +108,7 @@ static struct {
108 size_t size; 108 size_t size;
109 109
110 /* slab cache pointer */ 110 /* slab cache pointer */
111 kmem_cache_t *cachep; 111 struct kmem_cache *cachep;
112 112
113 /* allocated slab cache + modules which uses this slab cache */ 113 /* allocated slab cache + modules which uses this slab cache */
114 int use; 114 int use;
@@ -147,7 +147,7 @@ int nf_conntrack_register_cache(u_int32_t features, const char *name,
147{ 147{
148 int ret = 0; 148 int ret = 0;
149 char *cache_name; 149 char *cache_name;
150 kmem_cache_t *cachep; 150 struct kmem_cache *cachep;
151 151
152 DEBUGP("nf_conntrack_register_cache: features=0x%x, name=%s, size=%d\n", 152 DEBUGP("nf_conntrack_register_cache: features=0x%x, name=%s, size=%d\n",
153 features, name, size); 153 features, name, size);
@@ -226,7 +226,7 @@ EXPORT_SYMBOL_GPL(nf_conntrack_register_cache);
226/* FIXME: In the current, only nf_conntrack_cleanup() can call this function. */ 226/* FIXME: In the current, only nf_conntrack_cleanup() can call this function. */
227void nf_conntrack_unregister_cache(u_int32_t features) 227void nf_conntrack_unregister_cache(u_int32_t features)
228{ 228{
229 kmem_cache_t *cachep; 229 struct kmem_cache *cachep;
230 char *name; 230 char *name;
231 231
232 /* 232 /*
diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c
index 588d37937046..c20f901fa177 100644
--- a/net/netfilter/nf_conntrack_expect.c
+++ b/net/netfilter/nf_conntrack_expect.c
@@ -29,7 +29,7 @@
29LIST_HEAD(nf_conntrack_expect_list); 29LIST_HEAD(nf_conntrack_expect_list);
30EXPORT_SYMBOL_GPL(nf_conntrack_expect_list); 30EXPORT_SYMBOL_GPL(nf_conntrack_expect_list);
31 31
32kmem_cache_t *nf_conntrack_expect_cachep __read_mostly; 32struct kmem_cache *nf_conntrack_expect_cachep __read_mostly;
33static unsigned int nf_conntrack_expect_next_id; 33static unsigned int nf_conntrack_expect_next_id;
34 34
35/* nf_conntrack_expect helper functions */ 35/* nf_conntrack_expect helper functions */
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index a98de0b54d65..a5a6e192ac2d 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -92,7 +92,7 @@ struct xt_hashlimit_htable {
92static DEFINE_SPINLOCK(hashlimit_lock); /* protects htables list */ 92static DEFINE_SPINLOCK(hashlimit_lock); /* protects htables list */
93static DEFINE_MUTEX(hlimit_mutex); /* additional checkentry protection */ 93static DEFINE_MUTEX(hlimit_mutex); /* additional checkentry protection */
94static HLIST_HEAD(hashlimit_htables); 94static HLIST_HEAD(hashlimit_htables);
95static kmem_cache_t *hashlimit_cachep __read_mostly; 95static struct kmem_cache *hashlimit_cachep __read_mostly;
96 96
97static inline int dst_cmp(const struct dsthash_ent *ent, struct dsthash_dst *b) 97static inline int dst_cmp(const struct dsthash_ent *ent, struct dsthash_dst *b)
98{ 98{
diff --git a/net/rxrpc/krxiod.c b/net/rxrpc/krxiod.c
index dada34a77b21..49effd92144e 100644
--- a/net/rxrpc/krxiod.c
+++ b/net/rxrpc/krxiod.c
@@ -13,6 +13,7 @@
13#include <linux/completion.h> 13#include <linux/completion.h>
14#include <linux/spinlock.h> 14#include <linux/spinlock.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/freezer.h>
16#include <rxrpc/krxiod.h> 17#include <rxrpc/krxiod.h>
17#include <rxrpc/transport.h> 18#include <rxrpc/transport.h>
18#include <rxrpc/peer.h> 19#include <rxrpc/peer.h>
diff --git a/net/rxrpc/krxsecd.c b/net/rxrpc/krxsecd.c
index cea4eb5e2497..3ab0f77409f4 100644
--- a/net/rxrpc/krxsecd.c
+++ b/net/rxrpc/krxsecd.c
@@ -27,6 +27,7 @@
27#include <rxrpc/call.h> 27#include <rxrpc/call.h>
28#include <linux/udp.h> 28#include <linux/udp.h>
29#include <linux/ip.h> 29#include <linux/ip.h>
30#include <linux/freezer.h>
30#include <net/sock.h> 31#include <net/sock.h>
31#include "internal.h" 32#include "internal.h"
32 33
diff --git a/net/rxrpc/krxtimod.c b/net/rxrpc/krxtimod.c
index 3e7466900bd4..9a9b6132dba4 100644
--- a/net/rxrpc/krxtimod.c
+++ b/net/rxrpc/krxtimod.c
@@ -13,6 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/completion.h> 15#include <linux/completion.h>
16#include <linux/freezer.h>
16#include <rxrpc/rxrpc.h> 17#include <rxrpc/rxrpc.h>
17#include <rxrpc/krxtimod.h> 18#include <rxrpc/krxtimod.h>
18#include <asm/errno.h> 19#include <asm/errno.h>
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 39471d3b31b9..ad0057db0f91 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -61,7 +61,7 @@
61#include <net/sctp/sm.h> 61#include <net/sctp/sm.h>
62 62
63/* Forward declarations for internal functions. */ 63/* Forward declarations for internal functions. */
64static void sctp_assoc_bh_rcv(struct sctp_association *asoc); 64static void sctp_assoc_bh_rcv(struct work_struct *work);
65 65
66 66
67/* 1st Level Abstractions. */ 67/* 1st Level Abstractions. */
@@ -269,9 +269,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
269 269
270 /* Create an input queue. */ 270 /* Create an input queue. */
271 sctp_inq_init(&asoc->base.inqueue); 271 sctp_inq_init(&asoc->base.inqueue);
272 sctp_inq_set_th_handler(&asoc->base.inqueue, 272 sctp_inq_set_th_handler(&asoc->base.inqueue, sctp_assoc_bh_rcv);
273 (void (*)(void *))sctp_assoc_bh_rcv,
274 asoc);
275 273
276 /* Create an output queue. */ 274 /* Create an output queue. */
277 sctp_outq_init(asoc, &asoc->outqueue); 275 sctp_outq_init(asoc, &asoc->outqueue);
@@ -946,8 +944,11 @@ out:
946} 944}
947 945
948/* Do delayed input processing. This is scheduled by sctp_rcv(). */ 946/* Do delayed input processing. This is scheduled by sctp_rcv(). */
949static void sctp_assoc_bh_rcv(struct sctp_association *asoc) 947static void sctp_assoc_bh_rcv(struct work_struct *work)
950{ 948{
949 struct sctp_association *asoc =
950 container_of(work, struct sctp_association,
951 base.inqueue.immediate);
951 struct sctp_endpoint *ep; 952 struct sctp_endpoint *ep;
952 struct sctp_chunk *chunk; 953 struct sctp_chunk *chunk;
953 struct sock *sk; 954 struct sock *sk;
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index 33a42e90c32f..129756908da4 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -61,7 +61,7 @@
61#include <net/sctp/sm.h> 61#include <net/sctp/sm.h>
62 62
63/* Forward declarations for internal helpers. */ 63/* Forward declarations for internal helpers. */
64static void sctp_endpoint_bh_rcv(struct sctp_endpoint *ep); 64static void sctp_endpoint_bh_rcv(struct work_struct *work);
65 65
66/* 66/*
67 * Initialize the base fields of the endpoint structure. 67 * Initialize the base fields of the endpoint structure.
@@ -89,8 +89,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
89 sctp_inq_init(&ep->base.inqueue); 89 sctp_inq_init(&ep->base.inqueue);
90 90
91 /* Set its top-half handler */ 91 /* Set its top-half handler */
92 sctp_inq_set_th_handler(&ep->base.inqueue, 92 sctp_inq_set_th_handler(&ep->base.inqueue, sctp_endpoint_bh_rcv);
93 (void (*)(void *))sctp_endpoint_bh_rcv, ep);
94 93
95 /* Initialize the bind addr area */ 94 /* Initialize the bind addr area */
96 sctp_bind_addr_init(&ep->base.bind_addr, 0); 95 sctp_bind_addr_init(&ep->base.bind_addr, 0);
@@ -318,8 +317,11 @@ int sctp_endpoint_is_peeled_off(struct sctp_endpoint *ep,
318/* Do delayed input processing. This is scheduled by sctp_rcv(). 317/* Do delayed input processing. This is scheduled by sctp_rcv().
319 * This may be called on BH or task time. 318 * This may be called on BH or task time.
320 */ 319 */
321static void sctp_endpoint_bh_rcv(struct sctp_endpoint *ep) 320static void sctp_endpoint_bh_rcv(struct work_struct *work)
322{ 321{
322 struct sctp_endpoint *ep =
323 container_of(work, struct sctp_endpoint,
324 base.inqueue.immediate);
323 struct sctp_association *asoc; 325 struct sctp_association *asoc;
324 struct sock *sk; 326 struct sock *sk;
325 struct sctp_transport *transport; 327 struct sctp_transport *transport;
diff --git a/net/sctp/inqueue.c b/net/sctp/inqueue.c
index cf6deed7e849..71b07466e880 100644
--- a/net/sctp/inqueue.c
+++ b/net/sctp/inqueue.c
@@ -54,7 +54,7 @@ void sctp_inq_init(struct sctp_inq *queue)
54 queue->in_progress = NULL; 54 queue->in_progress = NULL;
55 55
56 /* Create a task for delivering data. */ 56 /* Create a task for delivering data. */
57 INIT_WORK(&queue->immediate, NULL, NULL); 57 INIT_WORK(&queue->immediate, NULL);
58 58
59 queue->malloced = 0; 59 queue->malloced = 0;
60} 60}
@@ -97,7 +97,7 @@ void sctp_inq_push(struct sctp_inq *q, struct sctp_chunk *chunk)
97 * on the BH related data structures. 97 * on the BH related data structures.
98 */ 98 */
99 list_add_tail(&chunk->list, &q->in_chunk_list); 99 list_add_tail(&chunk->list, &q->in_chunk_list);
100 q->immediate.func(q->immediate.data); 100 q->immediate.func(&q->immediate);
101} 101}
102 102
103/* Extract a chunk from an SCTP inqueue. 103/* Extract a chunk from an SCTP inqueue.
@@ -205,9 +205,8 @@ struct sctp_chunk *sctp_inq_pop(struct sctp_inq *queue)
205 * The intent is that this routine will pull stuff out of the 205 * The intent is that this routine will pull stuff out of the
206 * inqueue and process it. 206 * inqueue and process it.
207 */ 207 */
208void sctp_inq_set_th_handler(struct sctp_inq *q, 208void sctp_inq_set_th_handler(struct sctp_inq *q, work_func_t callback)
209 void (*callback)(void *), void *arg)
210{ 209{
211 INIT_WORK(&q->immediate, callback, arg); 210 INIT_WORK(&q->immediate, callback);
212} 211}
213 212
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 11f3b549f4a4..f2ba8615895b 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -79,8 +79,8 @@ static struct sctp_pf *sctp_pf_inet_specific;
79static struct sctp_af *sctp_af_v4_specific; 79static struct sctp_af *sctp_af_v4_specific;
80static struct sctp_af *sctp_af_v6_specific; 80static struct sctp_af *sctp_af_v6_specific;
81 81
82kmem_cache_t *sctp_chunk_cachep __read_mostly; 82struct kmem_cache *sctp_chunk_cachep __read_mostly;
83kmem_cache_t *sctp_bucket_cachep __read_mostly; 83struct kmem_cache *sctp_bucket_cachep __read_mostly;
84 84
85/* Return the address of the control sock. */ 85/* Return the address of the control sock. */
86struct sock *sctp_get_ctl_sock(void) 86struct sock *sctp_get_ctl_sock(void)
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 04954e5f6846..30927d3a597f 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -65,7 +65,7 @@
65#include <net/sctp/sctp.h> 65#include <net/sctp/sctp.h>
66#include <net/sctp/sm.h> 66#include <net/sctp/sm.h>
67 67
68extern kmem_cache_t *sctp_chunk_cachep; 68extern struct kmem_cache *sctp_chunk_cachep;
69 69
70SCTP_STATIC 70SCTP_STATIC
71struct sctp_chunk *sctp_make_chunk(const struct sctp_association *asoc, 71struct sctp_chunk *sctp_make_chunk(const struct sctp_association *asoc,
@@ -979,7 +979,7 @@ struct sctp_chunk *sctp_chunkify(struct sk_buff *skb,
979{ 979{
980 struct sctp_chunk *retval; 980 struct sctp_chunk *retval;
981 981
982 retval = kmem_cache_alloc(sctp_chunk_cachep, SLAB_ATOMIC); 982 retval = kmem_cache_alloc(sctp_chunk_cachep, GFP_ATOMIC);
983 983
984 if (!retval) 984 if (!retval)
985 goto nodata; 985 goto nodata;
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 02b27145b279..1e8132b8c4d9 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -107,7 +107,7 @@ static void sctp_sock_migrate(struct sock *, struct sock *,
107 struct sctp_association *, sctp_socket_type_t); 107 struct sctp_association *, sctp_socket_type_t);
108static char *sctp_hmac_alg = SCTP_COOKIE_HMAC_ALG; 108static char *sctp_hmac_alg = SCTP_COOKIE_HMAC_ALG;
109 109
110extern kmem_cache_t *sctp_bucket_cachep; 110extern struct kmem_cache *sctp_bucket_cachep;
111 111
112/* Get the sndbuf space available at the time on the association. */ 112/* Get the sndbuf space available at the time on the association. */
113static inline int sctp_wspace(struct sctp_association *asoc) 113static inline int sctp_wspace(struct sctp_association *asoc)
@@ -4989,7 +4989,7 @@ static struct sctp_bind_bucket *sctp_bucket_create(
4989{ 4989{
4990 struct sctp_bind_bucket *pp; 4990 struct sctp_bind_bucket *pp;
4991 4991
4992 pp = kmem_cache_alloc(sctp_bucket_cachep, SLAB_ATOMIC); 4992 pp = kmem_cache_alloc(sctp_bucket_cachep, GFP_ATOMIC);
4993 SCTP_DBG_OBJCNT_INC(bind_bucket); 4993 SCTP_DBG_OBJCNT_INC(bind_bucket);
4994 if (pp) { 4994 if (pp) {
4995 pp->port = snum; 4995 pp->port = snum;
diff --git a/net/socket.c b/net/socket.c
index e8db54702a69..29ea1de43ecb 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -230,13 +230,13 @@ int move_addr_to_user(void *kaddr, int klen, void __user *uaddr,
230 230
231#define SOCKFS_MAGIC 0x534F434B 231#define SOCKFS_MAGIC 0x534F434B
232 232
233static kmem_cache_t *sock_inode_cachep __read_mostly; 233static struct kmem_cache *sock_inode_cachep __read_mostly;
234 234
235static struct inode *sock_alloc_inode(struct super_block *sb) 235static struct inode *sock_alloc_inode(struct super_block *sb)
236{ 236{
237 struct socket_alloc *ei; 237 struct socket_alloc *ei;
238 238
239 ei = kmem_cache_alloc(sock_inode_cachep, SLAB_KERNEL); 239 ei = kmem_cache_alloc(sock_inode_cachep, GFP_KERNEL);
240 if (!ei) 240 if (!ei)
241 return NULL; 241 return NULL;
242 init_waitqueue_head(&ei->socket.wait); 242 init_waitqueue_head(&ei->socket.wait);
@@ -257,7 +257,7 @@ static void sock_destroy_inode(struct inode *inode)
257 container_of(inode, struct socket_alloc, vfs_inode)); 257 container_of(inode, struct socket_alloc, vfs_inode));
258} 258}
259 259
260static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags) 260static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
261{ 261{
262 struct socket_alloc *ei = (struct socket_alloc *)foo; 262 struct socket_alloc *ei = (struct socket_alloc *)foo;
263 263
@@ -305,7 +305,14 @@ static struct file_system_type sock_fs_type = {
305 305
306static int sockfs_delete_dentry(struct dentry *dentry) 306static int sockfs_delete_dentry(struct dentry *dentry)
307{ 307{
308 return 1; 308 /*
309 * At creation time, we pretended this dentry was hashed
310 * (by clearing DCACHE_UNHASHED bit in d_flags)
311 * At delete time, we restore the truth : not hashed.
312 * (so that dput() can proceed correctly)
313 */
314 dentry->d_flags |= DCACHE_UNHASHED;
315 return 0;
309} 316}
310static struct dentry_operations sockfs_dentry_operations = { 317static struct dentry_operations sockfs_dentry_operations = {
311 .d_delete = sockfs_delete_dentry, 318 .d_delete = sockfs_delete_dentry,
@@ -353,14 +360,20 @@ static int sock_attach_fd(struct socket *sock, struct file *file)
353 360
354 this.len = sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino); 361 this.len = sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino);
355 this.name = name; 362 this.name = name;
356 this.hash = SOCK_INODE(sock)->i_ino; 363 this.hash = 0;
357 364
358 file->f_dentry = d_alloc(sock_mnt->mnt_sb->s_root, &this); 365 file->f_dentry = d_alloc(sock_mnt->mnt_sb->s_root, &this);
359 if (unlikely(!file->f_dentry)) 366 if (unlikely(!file->f_dentry))
360 return -ENOMEM; 367 return -ENOMEM;
361 368
362 file->f_dentry->d_op = &sockfs_dentry_operations; 369 file->f_dentry->d_op = &sockfs_dentry_operations;
363 d_add(file->f_dentry, SOCK_INODE(sock)); 370 /*
371 * We dont want to push this dentry into global dentry hash table.
372 * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED
373 * This permits a working /proc/$pid/fd/XXX on sockets
374 */
375 file->f_dentry->d_flags &= ~DCACHE_UNHASHED;
376 d_instantiate(file->f_dentry, SOCK_INODE(sock));
364 file->f_vfsmnt = mntget(sock_mnt); 377 file->f_vfsmnt = mntget(sock_mnt);
365 file->f_mapping = file->f_dentry->d_inode->i_mapping; 378 file->f_mapping = file->f_dentry->d_inode->i_mapping;
366 379
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 00cb388ece03..d96fd466a9a4 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -284,8 +284,8 @@ static struct file_operations cache_file_operations;
284static struct file_operations content_file_operations; 284static struct file_operations content_file_operations;
285static struct file_operations cache_flush_operations; 285static struct file_operations cache_flush_operations;
286 286
287static void do_cache_clean(void *data); 287static void do_cache_clean(struct work_struct *work);
288static DECLARE_WORK(cache_cleaner, do_cache_clean, NULL); 288static DECLARE_DELAYED_WORK(cache_cleaner, do_cache_clean);
289 289
290void cache_register(struct cache_detail *cd) 290void cache_register(struct cache_detail *cd)
291{ 291{
@@ -337,7 +337,7 @@ void cache_register(struct cache_detail *cd)
337 spin_unlock(&cache_list_lock); 337 spin_unlock(&cache_list_lock);
338 338
339 /* start the cleaning process */ 339 /* start the cleaning process */
340 schedule_work(&cache_cleaner); 340 schedule_delayed_work(&cache_cleaner, 0);
341} 341}
342 342
343int cache_unregister(struct cache_detail *cd) 343int cache_unregister(struct cache_detail *cd)
@@ -461,7 +461,7 @@ static int cache_clean(void)
461/* 461/*
462 * We want to regularly clean the cache, so we need to schedule some work ... 462 * We want to regularly clean the cache, so we need to schedule some work ...
463 */ 463 */
464static void do_cache_clean(void *data) 464static void do_cache_clean(struct work_struct *work)
465{ 465{
466 int delay = 5; 466 int delay = 5;
467 if (cache_clean() == -1) 467 if (cache_clean() == -1)
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 9a0b41a97f90..19703aa9659e 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -33,7 +33,7 @@ static int rpc_mount_count;
33static struct file_system_type rpc_pipe_fs_type; 33static struct file_system_type rpc_pipe_fs_type;
34 34
35 35
36static kmem_cache_t *rpc_inode_cachep __read_mostly; 36static struct kmem_cache *rpc_inode_cachep __read_mostly;
37 37
38#define RPC_UPCALL_TIMEOUT (30*HZ) 38#define RPC_UPCALL_TIMEOUT (30*HZ)
39 39
@@ -54,10 +54,11 @@ static void rpc_purge_list(struct rpc_inode *rpci, struct list_head *head,
54} 54}
55 55
56static void 56static void
57rpc_timeout_upcall_queue(void *data) 57rpc_timeout_upcall_queue(struct work_struct *work)
58{ 58{
59 LIST_HEAD(free_list); 59 LIST_HEAD(free_list);
60 struct rpc_inode *rpci = (struct rpc_inode *)data; 60 struct rpc_inode *rpci =
61 container_of(work, struct rpc_inode, queue_timeout.work);
61 struct inode *inode = &rpci->vfs_inode; 62 struct inode *inode = &rpci->vfs_inode;
62 void (*destroy_msg)(struct rpc_pipe_msg *); 63 void (*destroy_msg)(struct rpc_pipe_msg *);
63 64
@@ -142,7 +143,7 @@ static struct inode *
142rpc_alloc_inode(struct super_block *sb) 143rpc_alloc_inode(struct super_block *sb)
143{ 144{
144 struct rpc_inode *rpci; 145 struct rpc_inode *rpci;
145 rpci = (struct rpc_inode *)kmem_cache_alloc(rpc_inode_cachep, SLAB_KERNEL); 146 rpci = (struct rpc_inode *)kmem_cache_alloc(rpc_inode_cachep, GFP_KERNEL);
146 if (!rpci) 147 if (!rpci)
147 return NULL; 148 return NULL;
148 return &rpci->vfs_inode; 149 return &rpci->vfs_inode;
@@ -823,7 +824,7 @@ static struct file_system_type rpc_pipe_fs_type = {
823}; 824};
824 825
825static void 826static void
826init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 827init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
827{ 828{
828 struct rpc_inode *rpci = (struct rpc_inode *) foo; 829 struct rpc_inode *rpci = (struct rpc_inode *) foo;
829 830
@@ -837,7 +838,8 @@ init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
837 INIT_LIST_HEAD(&rpci->pipe); 838 INIT_LIST_HEAD(&rpci->pipe);
838 rpci->pipelen = 0; 839 rpci->pipelen = 0;
839 init_waitqueue_head(&rpci->waitq); 840 init_waitqueue_head(&rpci->waitq);
840 INIT_WORK(&rpci->queue_timeout, rpc_timeout_upcall_queue, rpci); 841 INIT_DELAYED_WORK(&rpci->queue_timeout,
842 rpc_timeout_upcall_queue);
841 rpci->ops = NULL; 843 rpci->ops = NULL;
842 } 844 }
843} 845}
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index a1ab4eed41f4..225e6510b523 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -34,14 +34,14 @@ static int rpc_task_id;
34#define RPC_BUFFER_MAXSIZE (2048) 34#define RPC_BUFFER_MAXSIZE (2048)
35#define RPC_BUFFER_POOLSIZE (8) 35#define RPC_BUFFER_POOLSIZE (8)
36#define RPC_TASK_POOLSIZE (8) 36#define RPC_TASK_POOLSIZE (8)
37static kmem_cache_t *rpc_task_slabp __read_mostly; 37static struct kmem_cache *rpc_task_slabp __read_mostly;
38static kmem_cache_t *rpc_buffer_slabp __read_mostly; 38static struct kmem_cache *rpc_buffer_slabp __read_mostly;
39static mempool_t *rpc_task_mempool __read_mostly; 39static mempool_t *rpc_task_mempool __read_mostly;
40static mempool_t *rpc_buffer_mempool __read_mostly; 40static mempool_t *rpc_buffer_mempool __read_mostly;
41 41
42static void __rpc_default_timer(struct rpc_task *task); 42static void __rpc_default_timer(struct rpc_task *task);
43static void rpciod_killall(void); 43static void rpciod_killall(void);
44static void rpc_async_schedule(void *); 44static void rpc_async_schedule(struct work_struct *);
45 45
46/* 46/*
47 * RPC tasks sit here while waiting for conditions to improve. 47 * RPC tasks sit here while waiting for conditions to improve.
@@ -305,7 +305,7 @@ static void rpc_make_runnable(struct rpc_task *task)
305 if (RPC_IS_ASYNC(task)) { 305 if (RPC_IS_ASYNC(task)) {
306 int status; 306 int status;
307 307
308 INIT_WORK(&task->u.tk_work, rpc_async_schedule, (void *)task); 308 INIT_WORK(&task->u.tk_work, rpc_async_schedule);
309 status = queue_work(task->tk_workqueue, &task->u.tk_work); 309 status = queue_work(task->tk_workqueue, &task->u.tk_work);
310 if (status < 0) { 310 if (status < 0) {
311 printk(KERN_WARNING "RPC: failed to add task to queue: error: %d!\n", status); 311 printk(KERN_WARNING "RPC: failed to add task to queue: error: %d!\n", status);
@@ -695,9 +695,9 @@ rpc_execute(struct rpc_task *task)
695 return __rpc_execute(task); 695 return __rpc_execute(task);
696} 696}
697 697
698static void rpc_async_schedule(void *arg) 698static void rpc_async_schedule(struct work_struct *work)
699{ 699{
700 __rpc_execute((struct rpc_task *)arg); 700 __rpc_execute(container_of(work, struct rpc_task, u.tk_work));
701} 701}
702 702
703/** 703/**
diff --git a/net/sunrpc/svcauth.c b/net/sunrpc/svcauth.c
index ee9bb1522d5e..c7bb5f7f21a5 100644
--- a/net/sunrpc/svcauth.c
+++ b/net/sunrpc/svcauth.c
@@ -119,7 +119,8 @@ EXPORT_SYMBOL(svc_auth_unregister);
119#define DN_HASHMASK (DN_HASHMAX-1) 119#define DN_HASHMASK (DN_HASHMAX-1)
120 120
121static struct hlist_head auth_domain_table[DN_HASHMAX]; 121static struct hlist_head auth_domain_table[DN_HASHMAX];
122static spinlock_t auth_domain_lock = SPIN_LOCK_UNLOCKED; 122static spinlock_t auth_domain_lock =
123 __SPIN_LOCK_UNLOCKED(auth_domain_lock);
123 124
124void auth_domain_put(struct auth_domain *dom) 125void auth_domain_put(struct auth_domain *dom)
125{ 126{
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 64ca1f61dd94..99f54fb6d669 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -32,6 +32,7 @@
32#include <linux/netdevice.h> 32#include <linux/netdevice.h>
33#include <linux/skbuff.h> 33#include <linux/skbuff.h>
34#include <linux/file.h> 34#include <linux/file.h>
35#include <linux/freezer.h>
35#include <net/sock.h> 36#include <net/sock.h>
36#include <net/checksum.h> 37#include <net/checksum.h>
37#include <net/ip.h> 38#include <net/ip.h>
@@ -84,6 +85,35 @@ static struct cache_deferred_req *svc_defer(struct cache_req *req);
84 */ 85 */
85static int svc_conn_age_period = 6*60; 86static int svc_conn_age_period = 6*60;
86 87
88#ifdef CONFIG_DEBUG_LOCK_ALLOC
89static struct lock_class_key svc_key[2];
90static struct lock_class_key svc_slock_key[2];
91
92static inline void svc_reclassify_socket(struct socket *sock)
93{
94 struct sock *sk = sock->sk;
95 BUG_ON(sk->sk_lock.owner != NULL);
96 switch (sk->sk_family) {
97 case AF_INET:
98 sock_lock_init_class_and_name(sk, "slock-AF_INET-NFSD",
99 &svc_slock_key[0], "sk_lock-AF_INET-NFSD", &svc_key[0]);
100 break;
101
102 case AF_INET6:
103 sock_lock_init_class_and_name(sk, "slock-AF_INET6-NFSD",
104 &svc_slock_key[1], "sk_lock-AF_INET6-NFSD", &svc_key[1]);
105 break;
106
107 default:
108 BUG();
109 }
110}
111#else
112static inline void svc_reclassify_socket(struct socket *sock)
113{
114}
115#endif
116
87/* 117/*
88 * Queue up an idle server thread. Must have pool->sp_lock held. 118 * Queue up an idle server thread. Must have pool->sp_lock held.
89 * Note: this is really a stack rather than a queue, so that we only 119 * Note: this is really a stack rather than a queue, so that we only
@@ -1556,6 +1586,8 @@ svc_create_socket(struct svc_serv *serv, int protocol, struct sockaddr_in *sin)
1556 if ((error = sock_create_kern(PF_INET, type, protocol, &sock)) < 0) 1586 if ((error = sock_create_kern(PF_INET, type, protocol, &sock)) < 0)
1557 return error; 1587 return error;
1558 1588
1589 svc_reclassify_socket(sock);
1590
1559 if (type == SOCK_STREAM) 1591 if (type == SOCK_STREAM)
1560 sock->sk->sk_reuse = 1; /* allow address reuse */ 1592 sock->sk->sk_reuse = 1; /* allow address reuse */
1561 error = kernel_bind(sock, (struct sockaddr *) sin, 1593 error = kernel_bind(sock, (struct sockaddr *) sin,
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 80857470dc11..4f9a5d9791fb 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -479,9 +479,10 @@ int xprt_adjust_timeout(struct rpc_rqst *req)
479 return status; 479 return status;
480} 480}
481 481
482static void xprt_autoclose(void *args) 482static void xprt_autoclose(struct work_struct *work)
483{ 483{
484 struct rpc_xprt *xprt = (struct rpc_xprt *)args; 484 struct rpc_xprt *xprt =
485 container_of(work, struct rpc_xprt, task_cleanup);
485 486
486 xprt_disconnect(xprt); 487 xprt_disconnect(xprt);
487 xprt->ops->close(xprt); 488 xprt->ops->close(xprt);
@@ -932,7 +933,7 @@ struct rpc_xprt *xprt_create_transport(int proto, struct sockaddr *ap, size_t si
932 933
933 INIT_LIST_HEAD(&xprt->free); 934 INIT_LIST_HEAD(&xprt->free);
934 INIT_LIST_HEAD(&xprt->recv); 935 INIT_LIST_HEAD(&xprt->recv);
935 INIT_WORK(&xprt->task_cleanup, xprt_autoclose, xprt); 936 INIT_WORK(&xprt->task_cleanup, xprt_autoclose);
936 init_timer(&xprt->timer); 937 init_timer(&xprt->timer);
937 xprt->timer.function = xprt_init_autodisconnect; 938 xprt->timer.function = xprt_init_autodisconnect;
938 xprt->timer.data = (unsigned long) xprt; 939 xprt->timer.data = (unsigned long) xprt;
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 757fc91ef25d..2fc4a3123261 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1058,15 +1058,45 @@ static int xs_bindresvport(struct rpc_xprt *xprt, struct socket *sock)
1058 return err; 1058 return err;
1059} 1059}
1060 1060
1061#ifdef CONFIG_DEBUG_LOCK_ALLOC
1062static struct lock_class_key xs_key[2];
1063static struct lock_class_key xs_slock_key[2];
1064
1065static inline void xs_reclassify_socket(struct socket *sock)
1066{
1067 struct sock *sk = sock->sk;
1068 BUG_ON(sk->sk_lock.owner != NULL);
1069 switch (sk->sk_family) {
1070 case AF_INET:
1071 sock_lock_init_class_and_name(sk, "slock-AF_INET-NFS",
1072 &xs_slock_key[0], "sk_lock-AF_INET-NFS", &xs_key[0]);
1073 break;
1074
1075 case AF_INET6:
1076 sock_lock_init_class_and_name(sk, "slock-AF_INET6-NFS",
1077 &xs_slock_key[1], "sk_lock-AF_INET6-NFS", &xs_key[1]);
1078 break;
1079
1080 default:
1081 BUG();
1082 }
1083}
1084#else
1085static inline void xs_reclassify_socket(struct socket *sock)
1086{
1087}
1088#endif
1089
1061/** 1090/**
1062 * xs_udp_connect_worker - set up a UDP socket 1091 * xs_udp_connect_worker - set up a UDP socket
1063 * @args: RPC transport to connect 1092 * @work: RPC transport to connect
1064 * 1093 *
1065 * Invoked by a work queue tasklet. 1094 * Invoked by a work queue tasklet.
1066 */ 1095 */
1067static void xs_udp_connect_worker(void *args) 1096static void xs_udp_connect_worker(struct work_struct *work)
1068{ 1097{
1069 struct rpc_xprt *xprt = (struct rpc_xprt *) args; 1098 struct rpc_xprt *xprt =
1099 container_of(work, struct rpc_xprt, connect_worker.work);
1070 struct socket *sock = xprt->sock; 1100 struct socket *sock = xprt->sock;
1071 int err, status = -EIO; 1101 int err, status = -EIO;
1072 1102
@@ -1080,6 +1110,7 @@ static void xs_udp_connect_worker(void *args)
1080 dprintk("RPC: can't create UDP transport socket (%d).\n", -err); 1110 dprintk("RPC: can't create UDP transport socket (%d).\n", -err);
1081 goto out; 1111 goto out;
1082 } 1112 }
1113 xs_reclassify_socket(sock);
1083 1114
1084 if (xprt->resvport && xs_bindresvport(xprt, sock) < 0) { 1115 if (xprt->resvport && xs_bindresvport(xprt, sock) < 0) {
1085 sock_release(sock); 1116 sock_release(sock);
@@ -1144,13 +1175,14 @@ static void xs_tcp_reuse_connection(struct rpc_xprt *xprt)
1144 1175
1145/** 1176/**
1146 * xs_tcp_connect_worker - connect a TCP socket to a remote endpoint 1177 * xs_tcp_connect_worker - connect a TCP socket to a remote endpoint
1147 * @args: RPC transport to connect 1178 * @work: RPC transport to connect
1148 * 1179 *
1149 * Invoked by a work queue tasklet. 1180 * Invoked by a work queue tasklet.
1150 */ 1181 */
1151static void xs_tcp_connect_worker(void *args) 1182static void xs_tcp_connect_worker(struct work_struct *work)
1152{ 1183{
1153 struct rpc_xprt *xprt = (struct rpc_xprt *)args; 1184 struct rpc_xprt *xprt =
1185 container_of(work, struct rpc_xprt, connect_worker.work);
1154 struct socket *sock = xprt->sock; 1186 struct socket *sock = xprt->sock;
1155 int err, status = -EIO; 1187 int err, status = -EIO;
1156 1188
@@ -1163,6 +1195,7 @@ static void xs_tcp_connect_worker(void *args)
1163 dprintk("RPC: can't create TCP transport socket (%d).\n", -err); 1195 dprintk("RPC: can't create TCP transport socket (%d).\n", -err);
1164 goto out; 1196 goto out;
1165 } 1197 }
1198 xs_reclassify_socket(sock);
1166 1199
1167 if (xprt->resvport && xs_bindresvport(xprt, sock) < 0) { 1200 if (xprt->resvport && xs_bindresvport(xprt, sock) < 0) {
1168 sock_release(sock); 1201 sock_release(sock);
@@ -1262,7 +1295,7 @@ static void xs_connect(struct rpc_task *task)
1262 xprt->reestablish_timeout = XS_TCP_MAX_REEST_TO; 1295 xprt->reestablish_timeout = XS_TCP_MAX_REEST_TO;
1263 } else { 1296 } else {
1264 dprintk("RPC: xs_connect scheduled xprt %p\n", xprt); 1297 dprintk("RPC: xs_connect scheduled xprt %p\n", xprt);
1265 schedule_work(&xprt->connect_worker); 1298 schedule_delayed_work(&xprt->connect_worker, 0);
1266 1299
1267 /* flush_scheduled_work can sleep... */ 1300 /* flush_scheduled_work can sleep... */
1268 if (!RPC_IS_ASYNC(task)) 1301 if (!RPC_IS_ASYNC(task))
@@ -1375,7 +1408,7 @@ int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to)
1375 /* XXX: header size can vary due to auth type, IPv6, etc. */ 1408 /* XXX: header size can vary due to auth type, IPv6, etc. */
1376 xprt->max_payload = (1U << 16) - (MAX_HEADER << 3); 1409 xprt->max_payload = (1U << 16) - (MAX_HEADER << 3);
1377 1410
1378 INIT_WORK(&xprt->connect_worker, xs_udp_connect_worker, xprt); 1411 INIT_DELAYED_WORK(&xprt->connect_worker, xs_udp_connect_worker);
1379 xprt->bind_timeout = XS_BIND_TO; 1412 xprt->bind_timeout = XS_BIND_TO;
1380 xprt->connect_timeout = XS_UDP_CONN_TO; 1413 xprt->connect_timeout = XS_UDP_CONN_TO;
1381 xprt->reestablish_timeout = XS_UDP_REEST_TO; 1414 xprt->reestablish_timeout = XS_UDP_REEST_TO;
@@ -1420,7 +1453,7 @@ int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to)
1420 xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32); 1453 xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32);
1421 xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; 1454 xprt->max_payload = RPC_MAX_FRAGMENT_SIZE;
1422 1455
1423 INIT_WORK(&xprt->connect_worker, xs_tcp_connect_worker, xprt); 1456 INIT_DELAYED_WORK(&xprt->connect_worker, xs_tcp_connect_worker);
1424 xprt->bind_timeout = XS_BIND_TO; 1457 xprt->bind_timeout = XS_BIND_TO;
1425 xprt->connect_timeout = XS_TCP_CONN_TO; 1458 xprt->connect_timeout = XS_TCP_CONN_TO;
1426 xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO; 1459 xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO;
diff --git a/net/tipc/handler.c b/net/tipc/handler.c
index ae6ddf00a1aa..eb80778d6d9c 100644
--- a/net/tipc/handler.c
+++ b/net/tipc/handler.c
@@ -42,7 +42,7 @@ struct queue_item {
42 unsigned long data; 42 unsigned long data;
43}; 43};
44 44
45static kmem_cache_t *tipc_queue_item_cache; 45static struct kmem_cache *tipc_queue_item_cache;
46static struct list_head signal_queue_head; 46static struct list_head signal_queue_head;
47static DEFINE_SPINLOCK(qitem_lock); 47static DEFINE_SPINLOCK(qitem_lock);
48static int handler_enabled = 0; 48static int handler_enabled = 0;
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index e8198a2c785d..414f89070380 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -12,7 +12,7 @@
12#include <net/ip.h> 12#include <net/ip.h>
13#include <net/xfrm.h> 13#include <net/xfrm.h>
14 14
15static kmem_cache_t *secpath_cachep __read_mostly; 15static struct kmem_cache *secpath_cachep __read_mostly;
16 16
17void __secpath_destroy(struct sec_path *sp) 17void __secpath_destroy(struct sec_path *sp)
18{ 18{
@@ -27,7 +27,7 @@ struct sec_path *secpath_dup(struct sec_path *src)
27{ 27{
28 struct sec_path *sp; 28 struct sec_path *sp;
29 29
30 sp = kmem_cache_alloc(secpath_cachep, SLAB_ATOMIC); 30 sp = kmem_cache_alloc(secpath_cachep, GFP_ATOMIC);
31 if (!sp) 31 if (!sp)
32 return NULL; 32 return NULL;
33 33
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 64d3938f74c4..3f3f563eb4ab 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -39,7 +39,7 @@ EXPORT_SYMBOL(xfrm_policy_count);
39static DEFINE_RWLOCK(xfrm_policy_afinfo_lock); 39static DEFINE_RWLOCK(xfrm_policy_afinfo_lock);
40static struct xfrm_policy_afinfo *xfrm_policy_afinfo[NPROTO]; 40static struct xfrm_policy_afinfo *xfrm_policy_afinfo[NPROTO];
41 41
42static kmem_cache_t *xfrm_dst_cache __read_mostly; 42static struct kmem_cache *xfrm_dst_cache __read_mostly;
43 43
44static struct work_struct xfrm_policy_gc_work; 44static struct work_struct xfrm_policy_gc_work;
45static HLIST_HEAD(xfrm_policy_gc_list); 45static HLIST_HEAD(xfrm_policy_gc_list);
@@ -392,7 +392,7 @@ static void xfrm_policy_gc_kill(struct xfrm_policy *policy)
392 xfrm_pol_put(policy); 392 xfrm_pol_put(policy);
393} 393}
394 394
395static void xfrm_policy_gc_task(void *data) 395static void xfrm_policy_gc_task(struct work_struct *work)
396{ 396{
397 struct xfrm_policy *policy; 397 struct xfrm_policy *policy;
398 struct hlist_node *entry, *tmp; 398 struct hlist_node *entry, *tmp;
@@ -580,7 +580,7 @@ static inline int xfrm_byidx_should_resize(int total)
580 580
581static DEFINE_MUTEX(hash_resize_mutex); 581static DEFINE_MUTEX(hash_resize_mutex);
582 582
583static void xfrm_hash_resize(void *__unused) 583static void xfrm_hash_resize(struct work_struct *__unused)
584{ 584{
585 int dir, total; 585 int dir, total;
586 586
@@ -597,7 +597,7 @@ static void xfrm_hash_resize(void *__unused)
597 mutex_unlock(&hash_resize_mutex); 597 mutex_unlock(&hash_resize_mutex);
598} 598}
599 599
600static DECLARE_WORK(xfrm_hash_work, xfrm_hash_resize, NULL); 600static DECLARE_WORK(xfrm_hash_work, xfrm_hash_resize);
601 601
602/* Generate new index... KAME seems to generate them ordered by cost 602/* Generate new index... KAME seems to generate them ordered by cost
603 * of an absolute inpredictability of ordering of rules. This will not pass. */ 603 * of an absolute inpredictability of ordering of rules. This will not pass. */
@@ -2116,7 +2116,7 @@ static void __init xfrm_policy_init(void)
2116 panic("XFRM: failed to allocate bydst hash\n"); 2116 panic("XFRM: failed to allocate bydst hash\n");
2117 } 2117 }
2118 2118
2119 INIT_WORK(&xfrm_policy_gc_work, xfrm_policy_gc_task, NULL); 2119 INIT_WORK(&xfrm_policy_gc_work, xfrm_policy_gc_task);
2120 register_netdevice_notifier(&xfrm_dev_notifier); 2120 register_netdevice_notifier(&xfrm_dev_notifier);
2121} 2121}
2122 2122
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 864962bbda90..da54a64ccfa3 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -115,7 +115,7 @@ static unsigned long xfrm_hash_new_size(void)
115 115
116static DEFINE_MUTEX(hash_resize_mutex); 116static DEFINE_MUTEX(hash_resize_mutex);
117 117
118static void xfrm_hash_resize(void *__unused) 118static void xfrm_hash_resize(struct work_struct *__unused)
119{ 119{
120 struct hlist_head *ndst, *nsrc, *nspi, *odst, *osrc, *ospi; 120 struct hlist_head *ndst, *nsrc, *nspi, *odst, *osrc, *ospi;
121 unsigned long nsize, osize; 121 unsigned long nsize, osize;
@@ -168,7 +168,7 @@ out_unlock:
168 mutex_unlock(&hash_resize_mutex); 168 mutex_unlock(&hash_resize_mutex);
169} 169}
170 170
171static DECLARE_WORK(xfrm_hash_work, xfrm_hash_resize, NULL); 171static DECLARE_WORK(xfrm_hash_work, xfrm_hash_resize);
172 172
173DECLARE_WAIT_QUEUE_HEAD(km_waitq); 173DECLARE_WAIT_QUEUE_HEAD(km_waitq);
174EXPORT_SYMBOL(km_waitq); 174EXPORT_SYMBOL(km_waitq);
@@ -207,7 +207,7 @@ static void xfrm_state_gc_destroy(struct xfrm_state *x)
207 kfree(x); 207 kfree(x);
208} 208}
209 209
210static void xfrm_state_gc_task(void *data) 210static void xfrm_state_gc_task(struct work_struct *data)
211{ 211{
212 struct xfrm_state *x; 212 struct xfrm_state *x;
213 struct hlist_node *entry, *tmp; 213 struct hlist_node *entry, *tmp;
@@ -1568,6 +1568,6 @@ void __init xfrm_state_init(void)
1568 panic("XFRM: Cannot allocate bydst/bysrc/byspi hashes."); 1568 panic("XFRM: Cannot allocate bydst/bysrc/byspi hashes.");
1569 xfrm_state_hmask = ((sz / sizeof(struct hlist_head)) - 1); 1569 xfrm_state_hmask = ((sz / sizeof(struct hlist_head)) - 1);
1570 1570
1571 INIT_WORK(&xfrm_state_gc_work, xfrm_state_gc_task, NULL); 1571 INIT_WORK(&xfrm_state_gc_work, xfrm_state_gc_task);
1572} 1572}
1573 1573
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 338bdea96541..f5628c57640b 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -798,7 +798,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
798 QAction *action; 798 QAction *action;
799 799
800 headerPopup = new QPopupMenu(this); 800 headerPopup = new QPopupMenu(this);
801 action = new QAction("Show Name", 0, this); 801 action = new QAction(NULL, "Show Name", 0, this);
802 action->setToggleAction(TRUE); 802 action->setToggleAction(TRUE);
803 connect(action, SIGNAL(toggled(bool)), 803 connect(action, SIGNAL(toggled(bool)),
804 parent(), SLOT(setShowName(bool))); 804 parent(), SLOT(setShowName(bool)));
@@ -806,7 +806,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
806 action, SLOT(setOn(bool))); 806 action, SLOT(setOn(bool)));
807 action->setOn(showName); 807 action->setOn(showName);
808 action->addTo(headerPopup); 808 action->addTo(headerPopup);
809 action = new QAction("Show Range", 0, this); 809 action = new QAction(NULL, "Show Range", 0, this);
810 action->setToggleAction(TRUE); 810 action->setToggleAction(TRUE);
811 connect(action, SIGNAL(toggled(bool)), 811 connect(action, SIGNAL(toggled(bool)),
812 parent(), SLOT(setShowRange(bool))); 812 parent(), SLOT(setShowRange(bool)));
@@ -814,7 +814,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
814 action, SLOT(setOn(bool))); 814 action, SLOT(setOn(bool)));
815 action->setOn(showRange); 815 action->setOn(showRange);
816 action->addTo(headerPopup); 816 action->addTo(headerPopup);
817 action = new QAction("Show Data", 0, this); 817 action = new QAction(NULL, "Show Data", 0, this);
818 action->setToggleAction(TRUE); 818 action->setToggleAction(TRUE);
819 connect(action, SIGNAL(toggled(bool)), 819 connect(action, SIGNAL(toggled(bool)),
820 parent(), SLOT(setShowData(bool))); 820 parent(), SLOT(setShowData(bool)));
@@ -1161,7 +1161,7 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char
1161QPopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos) 1161QPopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos)
1162{ 1162{
1163 QPopupMenu* popup = Parent::createPopupMenu(pos); 1163 QPopupMenu* popup = Parent::createPopupMenu(pos);
1164 QAction* action = new QAction("Show Debug Info", 0, popup); 1164 QAction* action = new QAction(NULL,"Show Debug Info", 0, popup);
1165 action->setToggleAction(TRUE); 1165 action->setToggleAction(TRUE);
1166 connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); 1166 connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
1167 connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool))); 1167 connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool)));
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 187f5de4612c..df3b272f7ce6 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1430,7 +1430,7 @@ sub create_parameterlist($$$) {
1430 # corresponding data structures "correctly". Catch it later in 1430 # corresponding data structures "correctly". Catch it later in
1431 # output_* subs. 1431 # output_* subs.
1432 push_parameter($arg, "", $file); 1432 push_parameter($arg, "", $file);
1433 } elsif ($arg =~ m/\(/) { 1433 } elsif ($arg =~ m/\(.*\*/) {
1434 # pointer-to-function 1434 # pointer-to-function
1435 $arg =~ tr/#/,/; 1435 $arg =~ tr/#/,/;
1436 $arg =~ m/[^\(]+\(\*([^\)]+)\)/; 1436 $arg =~ m/[^\(]+\(\*([^\)]+)\)/;
diff --git a/scripts/ver_linux b/scripts/ver_linux
index 84999f69773d..72876dfadc8a 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -48,6 +48,8 @@ fsck.reiser4 -V 2>&1 | grep ^fsck.reiser4 | awk \
48xfs_db -V 2>&1 | grep version | awk \ 48xfs_db -V 2>&1 | grep version | awk \
49'NR==1{print "xfsprogs ", $3}' 49'NR==1{print "xfsprogs ", $3}'
50 50
51pccardctl -V 2>&1| grep pcmciautils | awk '{print "pcmciautils ", $2}'
52
51cardmgr -V 2>&1| grep version | awk \ 53cardmgr -V 2>&1| grep version | awk \
52'NR==1{print "pcmcia-cs ", $3}' 54'NR==1{print "pcmcia-cs ", $3}'
53 55
@@ -87,10 +89,16 @@ loadkeys -h 2>&1 | awk \
87loadkeys -V 2>&1 | awk \ 89loadkeys -V 2>&1 | awk \
88'(NR==1 && ($2 ~ /console-tools/)) {print "Console-tools ", $3}' 90'(NR==1 && ($2 ~ /console-tools/)) {print "Console-tools ", $3}'
89 91
92oprofiled --version 2>&1 | awk \
93'(NR==1 && ($2 == "oprofile")) {print "oprofile ", $3}'
94
90expr --v 2>&1 | awk 'NR==1{print "Sh-utils ", $NF}' 95expr --v 2>&1 | awk 'NR==1{print "Sh-utils ", $NF}'
91 96
92udevinfo -V 2>&1 | grep version | awk '{print "udev ", $3}' 97udevinfo -V 2>&1 | grep version | awk '{print "udev ", $3}'
93 98
99iwconfig --version 2>&1 | awk \
100'(NR==1 && ($3 == "version")) {print "wireless-tools ",$4}'
101
94if [ -e /proc/modules ]; then 102if [ -e /proc/modules ]; then
95 X=`cat /proc/modules | sed -e "s/ .*$//"` 103 X=`cat /proc/modules | sed -e "s/ .*$//"`
96 echo "Modules Loaded "$X 104 echo "Modules Loaded "$X
diff --git a/security/keys/key.c b/security/keys/key.c
index 80de8c3e9cc3..ac9326c5f1da 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -20,7 +20,7 @@
20#include <linux/err.h> 20#include <linux/err.h>
21#include "internal.h" 21#include "internal.h"
22 22
23static kmem_cache_t *key_jar; 23static struct kmem_cache *key_jar;
24struct rb_root key_serial_tree; /* tree of keys indexed by serial */ 24struct rb_root key_serial_tree; /* tree of keys indexed by serial */
25DEFINE_SPINLOCK(key_serial_lock); 25DEFINE_SPINLOCK(key_serial_lock);
26 26
@@ -30,8 +30,8 @@ DEFINE_SPINLOCK(key_user_lock);
30static LIST_HEAD(key_types_list); 30static LIST_HEAD(key_types_list);
31static DECLARE_RWSEM(key_types_sem); 31static DECLARE_RWSEM(key_types_sem);
32 32
33static void key_cleanup(void *data); 33static void key_cleanup(struct work_struct *work);
34static DECLARE_WORK(key_cleanup_task, key_cleanup, NULL); 34static DECLARE_WORK(key_cleanup_task, key_cleanup);
35 35
36/* we serialise key instantiation and link */ 36/* we serialise key instantiation and link */
37DECLARE_RWSEM(key_construction_sem); 37DECLARE_RWSEM(key_construction_sem);
@@ -285,16 +285,14 @@ struct key *key_alloc(struct key_type *type, const char *desc,
285 } 285 }
286 286
287 /* allocate and initialise the key and its description */ 287 /* allocate and initialise the key and its description */
288 key = kmem_cache_alloc(key_jar, SLAB_KERNEL); 288 key = kmem_cache_alloc(key_jar, GFP_KERNEL);
289 if (!key) 289 if (!key)
290 goto no_memory_2; 290 goto no_memory_2;
291 291
292 if (desc) { 292 if (desc) {
293 key->description = kmalloc(desclen, GFP_KERNEL); 293 key->description = kmemdup(desc, desclen, GFP_KERNEL);
294 if (!key->description) 294 if (!key->description)
295 goto no_memory_3; 295 goto no_memory_3;
296
297 memcpy(key->description, desc, desclen);
298 } 296 }
299 297
300 atomic_set(&key->usage, 1); 298 atomic_set(&key->usage, 1);
@@ -552,7 +550,7 @@ EXPORT_SYMBOL(key_negate_and_link);
552 * do cleaning up in process context so that we don't have to disable 550 * do cleaning up in process context so that we don't have to disable
553 * interrupts all over the place 551 * interrupts all over the place
554 */ 552 */
555static void key_cleanup(void *data) 553static void key_cleanup(struct work_struct *work)
556{ 554{
557 struct rb_node *_n; 555 struct rb_node *_n;
558 struct key *key; 556 struct key *key;
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index e8d02acc51e7..ad45ce73964b 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -706,12 +706,10 @@ int __key_link(struct key *keyring, struct key *key)
706 BUG_ON(size > PAGE_SIZE); 706 BUG_ON(size > PAGE_SIZE);
707 707
708 ret = -ENOMEM; 708 ret = -ENOMEM;
709 nklist = kmalloc(size, GFP_KERNEL); 709 nklist = kmemdup(klist, size, GFP_KERNEL);
710 if (!nklist) 710 if (!nklist)
711 goto error2; 711 goto error2;
712 712
713 memcpy(nklist, klist, size);
714
715 /* replace matched key */ 713 /* replace matched key */
716 atomic_inc(&key->usage); 714 atomic_inc(&key->usage);
717 nklist->keys[loop] = key; 715 nklist->keys[loop] = key;
diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c
index 32150cf7c37f..b6f86808475a 100644
--- a/security/keys/process_keys.c
+++ b/security/keys/process_keys.c
@@ -27,7 +27,7 @@ static DEFINE_MUTEX(key_session_mutex);
27struct key_user root_key_user = { 27struct key_user root_key_user = {
28 .usage = ATOMIC_INIT(3), 28 .usage = ATOMIC_INIT(3),
29 .consq = LIST_HEAD_INIT(root_key_user.consq), 29 .consq = LIST_HEAD_INIT(root_key_user.consq),
30 .lock = SPIN_LOCK_UNLOCKED, 30 .lock = __SPIN_LOCK_UNLOCKED(root_key_user.lock),
31 .nkeys = ATOMIC_INIT(2), 31 .nkeys = ATOMIC_INIT(2),
32 .nikeys = ATOMIC_INIT(2), 32 .nikeys = ATOMIC_INIT(2),
33 .uid = 0, 33 .uid = 0,
diff --git a/security/selinux/avc.c b/security/selinux/avc.c
index e73ac1ab7cfd..e7c0b5e2066b 100644
--- a/security/selinux/avc.c
+++ b/security/selinux/avc.c
@@ -124,7 +124,7 @@ DEFINE_PER_CPU(struct avc_cache_stats, avc_cache_stats) = { 0 };
124 124
125static struct avc_cache avc_cache; 125static struct avc_cache avc_cache;
126static struct avc_callback_node *avc_callbacks; 126static struct avc_callback_node *avc_callbacks;
127static kmem_cache_t *avc_node_cachep; 127static struct kmem_cache *avc_node_cachep;
128 128
129static inline int avc_hash(u32 ssid, u32 tsid, u16 tclass) 129static inline int avc_hash(u32 ssid, u32 tsid, u16 tclass)
130{ 130{
@@ -332,7 +332,7 @@ static struct avc_node *avc_alloc_node(void)
332{ 332{
333 struct avc_node *node; 333 struct avc_node *node;
334 334
335 node = kmem_cache_alloc(avc_node_cachep, SLAB_ATOMIC); 335 node = kmem_cache_alloc(avc_node_cachep, GFP_ATOMIC);
336 if (!node) 336 if (!node)
337 goto out; 337 goto out;
338 338
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 78f98fe084eb..44e9cd470543 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -124,7 +124,7 @@ static struct security_operations *secondary_ops = NULL;
124static LIST_HEAD(superblock_security_head); 124static LIST_HEAD(superblock_security_head);
125static DEFINE_SPINLOCK(sb_security_lock); 125static DEFINE_SPINLOCK(sb_security_lock);
126 126
127static kmem_cache_t *sel_inode_cache; 127static struct kmem_cache *sel_inode_cache;
128 128
129/* Return security context for a given sid or just the context 129/* Return security context for a given sid or just the context
130 length if the buffer is null or length is 0 */ 130 length if the buffer is null or length is 0 */
@@ -181,7 +181,7 @@ static int inode_alloc_security(struct inode *inode)
181 struct task_security_struct *tsec = current->security; 181 struct task_security_struct *tsec = current->security;
182 struct inode_security_struct *isec; 182 struct inode_security_struct *isec;
183 183
184 isec = kmem_cache_alloc(sel_inode_cache, SLAB_KERNEL); 184 isec = kmem_cache_alloc(sel_inode_cache, GFP_KERNEL);
185 if (!isec) 185 if (!isec)
186 return -ENOMEM; 186 return -ENOMEM;
187 187
diff --git a/security/selinux/ss/avtab.c b/security/selinux/ss/avtab.c
index d049c7acbc8b..ebb993c5c244 100644
--- a/security/selinux/ss/avtab.c
+++ b/security/selinux/ss/avtab.c
@@ -28,7 +28,7 @@
28 (keyp->source_type << 9)) & \ 28 (keyp->source_type << 9)) & \
29 AVTAB_HASH_MASK) 29 AVTAB_HASH_MASK)
30 30
31static kmem_cache_t *avtab_node_cachep; 31static struct kmem_cache *avtab_node_cachep;
32 32
33static struct avtab_node* 33static struct avtab_node*
34avtab_insert_node(struct avtab *h, int hvalue, 34avtab_insert_node(struct avtab *h, int hvalue,
@@ -36,7 +36,7 @@ avtab_insert_node(struct avtab *h, int hvalue,
36 struct avtab_key *key, struct avtab_datum *datum) 36 struct avtab_key *key, struct avtab_datum *datum)
37{ 37{
38 struct avtab_node * newnode; 38 struct avtab_node * newnode;
39 newnode = kmem_cache_alloc(avtab_node_cachep, SLAB_KERNEL); 39 newnode = kmem_cache_alloc(avtab_node_cachep, GFP_KERNEL);
40 if (newnode == NULL) 40 if (newnode == NULL)
41 return NULL; 41 return NULL;
42 memset(newnode, 0, sizeof(struct avtab_node)); 42 memset(newnode, 0, sizeof(struct avtab_node));
diff --git a/sound/aoa/aoa-gpio.h b/sound/aoa/aoa-gpio.h
index 3a61f3115573..ee64f5de8966 100644
--- a/sound/aoa/aoa-gpio.h
+++ b/sound/aoa/aoa-gpio.h
@@ -59,10 +59,10 @@ struct gpio_methods {
59}; 59};
60 60
61struct gpio_notification { 61struct gpio_notification {
62 struct delayed_work work;
62 notify_func_t notify; 63 notify_func_t notify;
63 void *data; 64 void *data;
64 void *gpio_private; 65 void *gpio_private;
65 struct work_struct work;
66 struct mutex mutex; 66 struct mutex mutex;
67}; 67};
68 68
diff --git a/sound/aoa/core/snd-aoa-gpio-feature.c b/sound/aoa/core/snd-aoa-gpio-feature.c
index 40eb47eccf9a..2b03bc798bcb 100644
--- a/sound/aoa/core/snd-aoa-gpio-feature.c
+++ b/sound/aoa/core/snd-aoa-gpio-feature.c
@@ -195,9 +195,10 @@ static void ftr_gpio_all_amps_restore(struct gpio_runtime *rt)
195 ftr_gpio_set_lineout(rt, (s>>2)&1); 195 ftr_gpio_set_lineout(rt, (s>>2)&1);
196} 196}
197 197
198static void ftr_handle_notify(void *data) 198static void ftr_handle_notify(struct work_struct *work)
199{ 199{
200 struct gpio_notification *notif = data; 200 struct gpio_notification *notif =
201 container_of(work, struct gpio_notification, work.work);
201 202
202 mutex_lock(&notif->mutex); 203 mutex_lock(&notif->mutex);
203 if (notif->notify) 204 if (notif->notify)
@@ -253,12 +254,9 @@ static void ftr_gpio_init(struct gpio_runtime *rt)
253 254
254 ftr_gpio_all_amps_off(rt); 255 ftr_gpio_all_amps_off(rt);
255 rt->implementation_private = 0; 256 rt->implementation_private = 0;
256 INIT_WORK(&rt->headphone_notify.work, ftr_handle_notify, 257 INIT_DELAYED_WORK(&rt->headphone_notify.work, ftr_handle_notify);
257 &rt->headphone_notify); 258 INIT_DELAYED_WORK(&rt->line_in_notify.work, ftr_handle_notify);
258 INIT_WORK(&rt->line_in_notify.work, ftr_handle_notify, 259 INIT_DELAYED_WORK(&rt->line_out_notify.work, ftr_handle_notify);
259 &rt->line_in_notify);
260 INIT_WORK(&rt->line_out_notify.work, ftr_handle_notify,
261 &rt->line_out_notify);
262 mutex_init(&rt->headphone_notify.mutex); 260 mutex_init(&rt->headphone_notify.mutex);
263 mutex_init(&rt->line_in_notify.mutex); 261 mutex_init(&rt->line_in_notify.mutex);
264 mutex_init(&rt->line_out_notify.mutex); 262 mutex_init(&rt->line_out_notify.mutex);
@@ -287,7 +285,7 @@ static irqreturn_t ftr_handle_notify_irq(int xx, void *data)
287{ 285{
288 struct gpio_notification *notif = data; 286 struct gpio_notification *notif = data;
289 287
290 schedule_work(&notif->work); 288 schedule_delayed_work(&notif->work, 0);
291 289
292 return IRQ_HANDLED; 290 return IRQ_HANDLED;
293} 291}
diff --git a/sound/aoa/core/snd-aoa-gpio-pmf.c b/sound/aoa/core/snd-aoa-gpio-pmf.c
index 2836c3218391..5ca2220eac7d 100644
--- a/sound/aoa/core/snd-aoa-gpio-pmf.c
+++ b/sound/aoa/core/snd-aoa-gpio-pmf.c
@@ -69,9 +69,10 @@ static void pmf_gpio_all_amps_restore(struct gpio_runtime *rt)
69 pmf_gpio_set_lineout(rt, (s>>2)&1); 69 pmf_gpio_set_lineout(rt, (s>>2)&1);
70} 70}
71 71
72static void pmf_handle_notify(void *data) 72static void pmf_handle_notify(struct work_struct *work)
73{ 73{
74 struct gpio_notification *notif = data; 74 struct gpio_notification *notif =
75 container_of(work, struct gpio_notification, work.work);
75 76
76 mutex_lock(&notif->mutex); 77 mutex_lock(&notif->mutex);
77 if (notif->notify) 78 if (notif->notify)
@@ -83,12 +84,9 @@ static void pmf_gpio_init(struct gpio_runtime *rt)
83{ 84{
84 pmf_gpio_all_amps_off(rt); 85 pmf_gpio_all_amps_off(rt);
85 rt->implementation_private = 0; 86 rt->implementation_private = 0;
86 INIT_WORK(&rt->headphone_notify.work, pmf_handle_notify, 87 INIT_DELAYED_WORK(&rt->headphone_notify.work, pmf_handle_notify);
87 &rt->headphone_notify); 88 INIT_DELAYED_WORK(&rt->line_in_notify.work, pmf_handle_notify);
88 INIT_WORK(&rt->line_in_notify.work, pmf_handle_notify, 89 INIT_DELAYED_WORK(&rt->line_out_notify.work, pmf_handle_notify);
89 &rt->line_in_notify);
90 INIT_WORK(&rt->line_out_notify.work, pmf_handle_notify,
91 &rt->line_out_notify);
92 mutex_init(&rt->headphone_notify.mutex); 90 mutex_init(&rt->headphone_notify.mutex);
93 mutex_init(&rt->line_in_notify.mutex); 91 mutex_init(&rt->line_in_notify.mutex);
94 mutex_init(&rt->line_out_notify.mutex); 92 mutex_init(&rt->line_out_notify.mutex);
@@ -129,7 +127,7 @@ static void pmf_handle_notify_irq(void *data)
129{ 127{
130 struct gpio_notification *notif = data; 128 struct gpio_notification *notif = data;
131 129
132 schedule_work(&notif->work); 130 schedule_delayed_work(&notif->work, 0);
133} 131}
134 132
135static int pmf_set_notify(struct gpio_runtime *rt, 133static int pmf_set_notify(struct gpio_runtime *rt,
diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c
index c79a9afd0955..c7e1b2646193 100644
--- a/sound/arm/sa11xx-uda1341.c
+++ b/sound/arm/sa11xx-uda1341.c
@@ -125,7 +125,7 @@ struct audio_stream {
125#else 125#else
126 dma_regs_t *dma_regs; /* points to our DMA registers */ 126 dma_regs_t *dma_regs; /* points to our DMA registers */
127#endif 127#endif
128 int active:1; /* we are using this stream for transfer now */ 128 unsigned int active:1; /* we are using this stream for transfer now */
129 int period; /* current transfer period */ 129 int period; /* current transfer period */
130 int periods; /* current count of periods registerd in the DMA engine */ 130 int periods; /* current count of periods registerd in the DMA engine */
131 int tx_spin; /* are we recoding - flag used to do DMA trans. for sync */ 131 int tx_spin; /* are we recoding - flag used to do DMA trans. for sync */
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 66e24b5da469..6ea67b16c676 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3027,7 +3027,7 @@ static struct page * snd_pcm_mmap_status_nopage(struct vm_area_struct *area,
3027 struct page * page; 3027 struct page * page;
3028 3028
3029 if (substream == NULL) 3029 if (substream == NULL)
3030 return NOPAGE_OOM; 3030 return NOPAGE_SIGBUS;
3031 runtime = substream->runtime; 3031 runtime = substream->runtime;
3032 page = virt_to_page(runtime->status); 3032 page = virt_to_page(runtime->status);
3033 get_page(page); 3033 get_page(page);
@@ -3070,7 +3070,7 @@ static struct page * snd_pcm_mmap_control_nopage(struct vm_area_struct *area,
3070 struct page * page; 3070 struct page * page;
3071 3071
3072 if (substream == NULL) 3072 if (substream == NULL)
3073 return NOPAGE_OOM; 3073 return NOPAGE_SIGBUS;
3074 runtime = substream->runtime; 3074 runtime = substream->runtime;
3075 page = virt_to_page(runtime->control); 3075 page = virt_to_page(runtime->control);
3076 get_page(page); 3076 get_page(page);
@@ -3131,18 +3131,18 @@ static struct page *snd_pcm_mmap_data_nopage(struct vm_area_struct *area,
3131 size_t dma_bytes; 3131 size_t dma_bytes;
3132 3132
3133 if (substream == NULL) 3133 if (substream == NULL)
3134 return NOPAGE_OOM; 3134 return NOPAGE_SIGBUS;
3135 runtime = substream->runtime; 3135 runtime = substream->runtime;
3136 offset = area->vm_pgoff << PAGE_SHIFT; 3136 offset = area->vm_pgoff << PAGE_SHIFT;
3137 offset += address - area->vm_start; 3137 offset += address - area->vm_start;
3138 snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM); 3138 snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_SIGBUS);
3139 dma_bytes = PAGE_ALIGN(runtime->dma_bytes); 3139 dma_bytes = PAGE_ALIGN(runtime->dma_bytes);
3140 if (offset > dma_bytes - PAGE_SIZE) 3140 if (offset > dma_bytes - PAGE_SIZE)
3141 return NOPAGE_SIGBUS; 3141 return NOPAGE_SIGBUS;
3142 if (substream->ops->page) { 3142 if (substream->ops->page) {
3143 page = substream->ops->page(substream, offset); 3143 page = substream->ops->page(substream, offset);
3144 if (! page) 3144 if (! page)
3145 return NOPAGE_OOM; 3145 return NOPAGE_OOM; /* XXX: is this really due to OOM? */
3146 } else { 3146 } else {
3147 vaddr = runtime->dma_area + offset; 3147 vaddr = runtime->dma_area + offset;
3148 page = virt_to_page(vaddr); 3148 page = virt_to_page(vaddr);
diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c
index 12ffffc9e814..d2f2c5078e65 100644
--- a/sound/i2c/other/ak4114.c
+++ b/sound/i2c/other/ak4114.c
@@ -35,7 +35,7 @@ MODULE_LICENSE("GPL");
35 35
36#define AK4114_ADDR 0x00 /* fixed address */ 36#define AK4114_ADDR 0x00 /* fixed address */
37 37
38static void ak4114_stats(void *); 38static void ak4114_stats(struct work_struct *work);
39 39
40static void reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char val) 40static void reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char val)
41{ 41{
@@ -158,7 +158,7 @@ void snd_ak4114_reinit(struct ak4114 *chip)
158 reg_write(chip, AK4114_REG_PWRDN, old | AK4114_RST | AK4114_PWN); 158 reg_write(chip, AK4114_REG_PWRDN, old | AK4114_RST | AK4114_PWN);
159 /* bring up statistics / event queing */ 159 /* bring up statistics / event queing */
160 chip->init = 0; 160 chip->init = 0;
161 INIT_WORK(&chip->work, ak4114_stats, chip); 161 INIT_DELAYED_WORK(&chip->work, ak4114_stats);
162 queue_delayed_work(chip->workqueue, &chip->work, HZ / 10); 162 queue_delayed_work(chip->workqueue, &chip->work, HZ / 10);
163} 163}
164 164
@@ -561,9 +561,9 @@ int snd_ak4114_check_rate_and_errors(struct ak4114 *ak4114, unsigned int flags)
561 return res; 561 return res;
562} 562}
563 563
564static void ak4114_stats(void *data) 564static void ak4114_stats(struct work_struct *work)
565{ 565{
566 struct ak4114 *chip = (struct ak4114 *)data; 566 struct ak4114 *chip = container_of(work, struct ak4114, work.work);
567 567
568 if (chip->init) 568 if (chip->init)
569 return; 569 return;
diff --git a/sound/oss/Kconfig b/sound/oss/Kconfig
index cc2b9ab7f4e5..a0588c21324a 100644
--- a/sound/oss/Kconfig
+++ b/sound/oss/Kconfig
@@ -5,20 +5,6 @@
5# 5#
6# Prompt user for primary drivers. 6# Prompt user for primary drivers.
7 7
8config OSS_OBSOLETE_DRIVER
9 bool "Obsolete OSS drivers"
10 depends on SOUND_PRIME
11 help
12 This option enables support for obsolete OSS drivers that
13 are scheduled for removal in the near future since there
14 are ALSA drivers for the same hardware.
15
16 Please contact Adrian Bunk <bunk@stusta.de> if you had to
17 say Y here because your soundcard is not properly supported
18 by ALSA.
19
20 If unsure, say N.
21
22config SOUND_BT878 8config SOUND_BT878
23 tristate "BT878 audio dma" 9 tristate "BT878 audio dma"
24 depends on SOUND_PRIME && PCI 10 depends on SOUND_PRIME && PCI
@@ -35,40 +21,6 @@ config SOUND_BT878
35 To compile this driver as a module, choose M here: the module will 21 To compile this driver as a module, choose M here: the module will
36 be called btaudio. 22 be called btaudio.
37 23
38config SOUND_EMU10K1
39 tristate "Creative SBLive! (EMU10K1)"
40 depends on SOUND_PRIME && PCI && OSS_OBSOLETE_DRIVER
41 ---help---
42 Say Y or M if you have a PCI sound card using the EMU10K1 chipset,
43 such as the Creative SBLive!, SB PCI512 or Emu-APS.
44
45 For more information on this driver and the degree of support for
46 the different card models please check:
47
48 <http://sourceforge.net/projects/emu10k1/>
49
50 It is now possible to load dsp microcode patches into the EMU10K1
51 chip. These patches are used to implement real time sound
52 processing effects which include for example: signal routing,
53 bass/treble control, AC3 passthrough, ...
54 Userspace tools to create new patches and load/unload them can be
55 found in the emu-tools package at the above URL.
56
57config MIDI_EMU10K1
58 bool "Creative SBLive! MIDI (EXPERIMENTAL)"
59 depends on SOUND_EMU10K1 && EXPERIMENTAL && ISA_DMA_API
60 help
61 Say Y if you want to be able to use the OSS /dev/sequencer
62 interface. This code is still experimental.
63
64config SOUND_FUSION
65 tristate "Crystal SoundFusion (CS4280/461x)"
66 depends on SOUND_PRIME && PCI && OSS_OBSOLETE_DRIVER
67 help
68 This module drives the Crystal SoundFusion devices (CS4280/46xx
69 series) when wired as native sound drivers with AC97 codecs. If
70 this driver does not work try the CS4232 driver.
71
72config SOUND_BCM_CS4297A 24config SOUND_BCM_CS4297A
73 tristate "Crystal Sound CS4297a (for Swarm)" 25 tristate "Crystal Sound CS4297a (for Swarm)"
74 depends on SOUND_PRIME && SIBYTE_SWARM 26 depends on SOUND_PRIME && SIBYTE_SWARM
@@ -448,47 +400,6 @@ config SOUND_DMAP
448 400
449 Say Y unless you have 16MB or more RAM or a PCI sound card. 401 Say Y unless you have 16MB or more RAM or a PCI sound card.
450 402
451config SOUND_AD1816
452 tristate "AD1816(A) based cards (EXPERIMENTAL)"
453 depends on EXPERIMENTAL && SOUND_OSS && OSS_OBSOLETE_DRIVER
454 help
455 Say M here if you have a sound card based on the Analog Devices
456 AD1816(A) chip.
457
458 If you compile the driver into the kernel, you have to add
459 "ad1816=<io>,<irq>,<dma>,<dma2>" to the kernel command line.
460
461config SOUND_AD1889
462 tristate "AD1889 based cards (AD1819 codec) (EXPERIMENTAL)"
463 depends on EXPERIMENTAL && SOUND_OSS && PCI && OSS_OBSOLETE_DRIVER
464 help
465 Say M here if you have a sound card based on the Analog Devices
466 AD1889 chip.
467
468config SOUND_ADLIB
469 tristate "Adlib Cards"
470 depends on SOUND_OSS && OSS_OBSOLETE_DRIVER
471 help
472 Includes ASB 64 4D. Information on programming AdLib cards is
473 available at <http://www.itsnet.com/home/ldragon/Specs/adlib.html>.
474
475config SOUND_ACI_MIXER
476 tristate "ACI mixer (miroSOUND PCM1-pro/PCM12/PCM20)"
477 depends on SOUND_OSS && OSS_OBSOLETE_DRIVER
478 ---help---
479 ACI (Audio Command Interface) is a protocol used to communicate with
480 the microcontroller on some sound cards produced by miro and
481 Cardinal Technologies. The main function of the ACI is to control
482 the mixer and to get a product identification.
483
484 This VoxWare ACI driver currently supports the ACI functions on the
485 miroSOUND PCM1-pro, PCM12 and PCM20 radio. On the PCM20 radio, ACI
486 also controls the radio tuner. This is supported in the video4linux
487 miropcm20 driver (say M or Y here and go back to "Multimedia
488 devices" -> "Radio Adapters").
489
490 This driver is also available as a module and will be called aci.
491
492config SOUND_CS4232 403config SOUND_CS4232
493 tristate "Crystal CS4232 based (PnP) cards" 404 tristate "Crystal CS4232 based (PnP) cards"
494 depends on SOUND_OSS 405 depends on SOUND_OSS
@@ -594,18 +505,6 @@ config SOUND_MPU401
594 If you compile the driver into the kernel, you have to add 505 If you compile the driver into the kernel, you have to add
595 "mpu401=<io>,<irq>" to the kernel command line. 506 "mpu401=<io>,<irq>" to the kernel command line.
596 507
597config SOUND_NM256
598 tristate "NM256AV/NM256ZX audio support"
599 depends on SOUND_OSS && OSS_OBSOLETE_DRIVER
600 help
601 Say M here to include audio support for the NeoMagic 256AV/256ZX
602 chipsets. These are the audio chipsets found in the Sony
603 Z505S/SX/DX, some Sony F-series, and the Dell Latitude CPi and CPt
604 laptops. It includes support for an AC97-compatible mixer and an
605 apparently proprietary sound engine.
606
607 See <file:Documentation/sound/oss/NM256> for further information.
608
609config SOUND_PAS 508config SOUND_PAS
610 tristate "ProAudioSpectrum 16 support" 509 tristate "ProAudioSpectrum 16 support"
611 depends on SOUND_OSS 510 depends on SOUND_OSS
@@ -714,20 +613,6 @@ config SOUND_YM3812
714 613
715 If unsure, say Y. 614 If unsure, say Y.
716 615
717config SOUND_OPL3SA2
718 tristate "Yamaha OPL3-SA2 and SA3 based PnP cards"
719 depends on SOUND_OSS && OSS_OBSOLETE_DRIVER
720 help
721 Say Y or M if you have a card based on one of these Yamaha sound
722 chipsets or the "SAx", which is actually a SA3. Read
723 <file:Documentation/sound/oss/OPL3-SA2> for more information on
724 configuring these cards.
725
726 If you compile the driver into the kernel and do not also
727 configure in the optional ISA PnP support, you will have to add
728 "opl3sa2=<io>,<irq>,<dma>,<dma2>,<mssio>,<mpuio>" to the kernel
729 command line.
730
731config SOUND_UART6850 616config SOUND_UART6850
732 tristate "6850 UART support" 617 tristate "6850 UART support"
733 depends on SOUND_OSS 618 depends on SOUND_OSS
diff --git a/sound/oss/btaudio.c b/sound/oss/btaudio.c
index 6ad384114239..ad7210a00dc0 100644
--- a/sound/oss/btaudio.c
+++ b/sound/oss/btaudio.c
@@ -1020,6 +1020,7 @@ static int __devinit btaudio_probe(struct pci_dev *pci_dev,
1020 fail2: 1020 fail2:
1021 free_irq(bta->irq,bta); 1021 free_irq(bta->irq,bta);
1022 fail1: 1022 fail1:
1023 iounmap(bta->mmio);
1023 kfree(bta); 1024 kfree(bta);
1024 fail0: 1025 fail0:
1025 release_mem_region(pci_resource_start(pci_dev,0), 1026 release_mem_region(pci_resource_start(pci_dev,0),
@@ -1051,6 +1052,7 @@ static void __devexit btaudio_remove(struct pci_dev *pci_dev)
1051 free_irq(bta->irq,bta); 1052 free_irq(bta->irq,bta);
1052 release_mem_region(pci_resource_start(pci_dev,0), 1053 release_mem_region(pci_resource_start(pci_dev,0),
1053 pci_resource_len(pci_dev,0)); 1054 pci_resource_len(pci_dev,0));
1055 iounmap(bta->mmio);
1054 1056
1055 /* remove from linked list */ 1057 /* remove from linked list */
1056 if (bta == btaudios) { 1058 if (bta == btaudios) {
diff --git a/sound/oss/emu10k1/audio.c b/sound/oss/emu10k1/audio.c
index 86dd23974e05..49f902f35c28 100644
--- a/sound/oss/emu10k1/audio.c
+++ b/sound/oss/emu10k1/audio.c
@@ -111,9 +111,15 @@ static ssize_t emu10k1_audio_read(struct file *file, char __user *buffer, size_t
111 111
112 if ((bytestocopy >= wiinst->buffer.fragment_size) 112 if ((bytestocopy >= wiinst->buffer.fragment_size)
113 || (bytestocopy >= count)) { 113 || (bytestocopy >= count)) {
114 int rc;
115
114 bytestocopy = min_t(u32, bytestocopy, count); 116 bytestocopy = min_t(u32, bytestocopy, count);
115 117
116 emu10k1_wavein_xferdata(wiinst, (u8 __user *)buffer, &bytestocopy); 118 rc = emu10k1_wavein_xferdata(wiinst,
119 (u8 __user *)buffer,
120 &bytestocopy);
121 if (rc)
122 return rc;
117 123
118 count -= bytestocopy; 124 count -= bytestocopy;
119 buffer += bytestocopy; 125 buffer += bytestocopy;
diff --git a/sound/oss/emu10k1/cardwi.c b/sound/oss/emu10k1/cardwi.c
index 8bbf44b881b4..060d1be94d33 100644
--- a/sound/oss/emu10k1/cardwi.c
+++ b/sound/oss/emu10k1/cardwi.c
@@ -304,11 +304,12 @@ void emu10k1_wavein_getxfersize(struct wiinst *wiinst, u32 * size)
304 } 304 }
305} 305}
306 306
307static void copy_block(u8 __user *dst, u8 * src, u32 str, u32 len, u8 cov) 307static int copy_block(u8 __user *dst, u8 * src, u32 str, u32 len, u8 cov)
308{ 308{
309 if (cov == 1) 309 if (cov == 1) {
310 __copy_to_user(dst, src + str, len); 310 if (__copy_to_user(dst, src + str, len))
311 else { 311 return -EFAULT;
312 } else {
312 u8 byte; 313 u8 byte;
313 u32 i; 314 u32 i;
314 315
@@ -316,22 +317,26 @@ static void copy_block(u8 __user *dst, u8 * src, u32 str, u32 len, u8 cov)
316 317
317 for (i = 0; i < len; i++) { 318 for (i = 0; i < len; i++) {
318 byte = src[2 * i] ^ 0x80; 319 byte = src[2 * i] ^ 0x80;
319 __copy_to_user(dst + i, &byte, 1); 320 if (__copy_to_user(dst + i, &byte, 1))
321 return -EFAULT;
320 } 322 }
321 } 323 }
324
325 return 0;
322} 326}
323 327
324void emu10k1_wavein_xferdata(struct wiinst *wiinst, u8 __user *data, u32 * size) 328int emu10k1_wavein_xferdata(struct wiinst *wiinst, u8 __user *data, u32 * size)
325{ 329{
326 struct wavein_buffer *buffer = &wiinst->buffer; 330 struct wavein_buffer *buffer = &wiinst->buffer;
327 u32 sizetocopy, sizetocopy_now, start; 331 u32 sizetocopy, sizetocopy_now, start;
328 unsigned long flags; 332 unsigned long flags;
333 int ret;
329 334
330 sizetocopy = min_t(u32, buffer->size, *size); 335 sizetocopy = min_t(u32, buffer->size, *size);
331 *size = sizetocopy; 336 *size = sizetocopy;
332 337
333 if (!sizetocopy) 338 if (!sizetocopy)
334 return; 339 return 0;
335 340
336 spin_lock_irqsave(&wiinst->lock, flags); 341 spin_lock_irqsave(&wiinst->lock, flags);
337 start = buffer->pos; 342 start = buffer->pos;
@@ -345,11 +350,17 @@ void emu10k1_wavein_xferdata(struct wiinst *wiinst, u8 __user *data, u32 * size)
345 if (sizetocopy > sizetocopy_now) { 350 if (sizetocopy > sizetocopy_now) {
346 sizetocopy -= sizetocopy_now; 351 sizetocopy -= sizetocopy_now;
347 352
348 copy_block(data, buffer->addr, start, sizetocopy_now, buffer->cov); 353 ret = copy_block(data, buffer->addr, start, sizetocopy_now,
349 copy_block(data + sizetocopy_now, buffer->addr, 0, sizetocopy, buffer->cov); 354 buffer->cov);
355 if (ret == 0)
356 ret = copy_block(data + sizetocopy_now, buffer->addr, 0,
357 sizetocopy, buffer->cov);
350 } else { 358 } else {
351 copy_block(data, buffer->addr, start, sizetocopy, buffer->cov); 359 ret = copy_block(data, buffer->addr, start, sizetocopy,
360 buffer->cov);
352 } 361 }
362
363 return ret;
353} 364}
354 365
355void emu10k1_wavein_update(struct emu10k1_card *card, struct wiinst *wiinst) 366void emu10k1_wavein_update(struct emu10k1_card *card, struct wiinst *wiinst)
diff --git a/sound/oss/emu10k1/cardwi.h b/sound/oss/emu10k1/cardwi.h
index 15cfb9b35596..e82029b46ad1 100644
--- a/sound/oss/emu10k1/cardwi.h
+++ b/sound/oss/emu10k1/cardwi.h
@@ -83,7 +83,7 @@ void emu10k1_wavein_close(struct emu10k1_wavedevice *);
83void emu10k1_wavein_start(struct emu10k1_wavedevice *); 83void emu10k1_wavein_start(struct emu10k1_wavedevice *);
84void emu10k1_wavein_stop(struct emu10k1_wavedevice *); 84void emu10k1_wavein_stop(struct emu10k1_wavedevice *);
85void emu10k1_wavein_getxfersize(struct wiinst *, u32 *); 85void emu10k1_wavein_getxfersize(struct wiinst *, u32 *);
86void emu10k1_wavein_xferdata(struct wiinst *, u8 __user *, u32 *); 86int emu10k1_wavein_xferdata(struct wiinst *, u8 __user *, u32 *);
87int emu10k1_wavein_setformat(struct emu10k1_wavedevice *, struct wave_format *); 87int emu10k1_wavein_setformat(struct emu10k1_wavedevice *, struct wave_format *);
88void emu10k1_wavein_update(struct emu10k1_card *, struct wiinst *); 88void emu10k1_wavein_update(struct emu10k1_card *, struct wiinst *);
89 89
diff --git a/sound/oss/emu10k1/passthrough.c b/sound/oss/emu10k1/passthrough.c
index 4e3baca7d41f..6d21d4368dec 100644
--- a/sound/oss/emu10k1/passthrough.c
+++ b/sound/oss/emu10k1/passthrough.c
@@ -162,12 +162,15 @@ ssize_t emu10k1_pt_write(struct file *file, const char __user *buffer, size_t co
162 162
163 DPD(3, "prepend size %d, prepending %d bytes\n", pt->prepend_size, needed); 163 DPD(3, "prepend size %d, prepending %d bytes\n", pt->prepend_size, needed);
164 if (count < needed) { 164 if (count < needed) {
165 copy_from_user(pt->buf + pt->prepend_size, buffer, count); 165 if (copy_from_user(pt->buf + pt->prepend_size,
166 buffer, count))
167 return -EFAULT;
166 pt->prepend_size += count; 168 pt->prepend_size += count;
167 DPD(3, "prepend size now %d\n", pt->prepend_size); 169 DPD(3, "prepend size now %d\n", pt->prepend_size);
168 return count; 170 return count;
169 } 171 }
170 copy_from_user(pt->buf + pt->prepend_size, buffer, needed); 172 if (copy_from_user(pt->buf + pt->prepend_size, buffer, needed))
173 return -EFAULT;
171 r = pt_putblock(wave_dev, (u16 *) pt->buf, nonblock); 174 r = pt_putblock(wave_dev, (u16 *) pt->buf, nonblock);
172 if (r) 175 if (r)
173 return r; 176 return r;
@@ -178,7 +181,8 @@ ssize_t emu10k1_pt_write(struct file *file, const char __user *buffer, size_t co
178 blocks_copied = 0; 181 blocks_copied = 0;
179 while (blocks > 0) { 182 while (blocks > 0) {
180 u16 __user *bufptr = (u16 __user *) buffer + (bytes_copied/2); 183 u16 __user *bufptr = (u16 __user *) buffer + (bytes_copied/2);
181 copy_from_user(pt->buf, bufptr, PT_BLOCKSIZE); 184 if (copy_from_user(pt->buf, bufptr, PT_BLOCKSIZE))
185 return -EFAULT;
182 r = pt_putblock(wave_dev, (u16 *)pt->buf, nonblock); 186 r = pt_putblock(wave_dev, (u16 *)pt->buf, nonblock);
183 if (r) { 187 if (r) {
184 if (bytes_copied) 188 if (bytes_copied)
@@ -193,7 +197,8 @@ ssize_t emu10k1_pt_write(struct file *file, const char __user *buffer, size_t co
193 i = count - bytes_copied; 197 i = count - bytes_copied;
194 if (i) { 198 if (i) {
195 pt->prepend_size = i; 199 pt->prepend_size = i;
196 copy_from_user(pt->buf, buffer + bytes_copied, i); 200 if (copy_from_user(pt->buf, buffer + bytes_copied, i))
201 return -EFAULT;
197 bytes_copied += i; 202 bytes_copied += i;
198 DPD(3, "filling prepend buffer with %d bytes", i); 203 DPD(3, "filling prepend buffer with %d bytes", i);
199 } 204 }
diff --git a/sound/oss/via82cxxx_audio.c b/sound/oss/via82cxxx_audio.c
index 17837d4b5ed3..c96cc8c68b3b 100644
--- a/sound/oss/via82cxxx_audio.c
+++ b/sound/oss/via82cxxx_audio.c
@@ -2120,8 +2120,8 @@ static struct page * via_mm_nopage (struct vm_area_struct * vma,
2120 return NOPAGE_SIGBUS; /* Disallow mremap */ 2120 return NOPAGE_SIGBUS; /* Disallow mremap */
2121 } 2121 }
2122 if (!card) { 2122 if (!card) {
2123 DPRINTK ("EXIT, returning NOPAGE_OOM\n"); 2123 DPRINTK ("EXIT, returning NOPAGE_SIGBUS\n");
2124 return NOPAGE_OOM; /* Nothing allocated */ 2124 return NOPAGE_SIGBUS; /* Nothing allocated */
2125 } 2125 }
2126 2126
2127 pgoff = vma->vm_pgoff + ((address - vma->vm_start) >> PAGE_SHIFT); 2127 pgoff = vma->vm_pgoff + ((address - vma->vm_start) >> PAGE_SHIFT);
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index 6577b2325357..7abcb10b2754 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -1927,9 +1927,10 @@ static int snd_ac97_dev_disconnect(struct snd_device *device)
1927static struct snd_ac97_build_ops null_build_ops; 1927static struct snd_ac97_build_ops null_build_ops;
1928 1928
1929#ifdef CONFIG_SND_AC97_POWER_SAVE 1929#ifdef CONFIG_SND_AC97_POWER_SAVE
1930static void do_update_power(void *data) 1930static void do_update_power(struct work_struct *work)
1931{ 1931{
1932 update_power_regs(data); 1932 update_power_regs(
1933 container_of(work, struct snd_ac97, power_work.work));
1933} 1934}
1934#endif 1935#endif
1935 1936
@@ -1989,7 +1990,7 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
1989 mutex_init(&ac97->page_mutex); 1990 mutex_init(&ac97->page_mutex);
1990#ifdef CONFIG_SND_AC97_POWER_SAVE 1991#ifdef CONFIG_SND_AC97_POWER_SAVE
1991 ac97->power_workq = create_workqueue("ac97"); 1992 ac97->power_workq = create_workqueue("ac97");
1992 INIT_WORK(&ac97->power_work, do_update_power, ac97); 1993 INIT_DELAYED_WORK(&ac97->power_work, do_update_power);
1993#endif 1994#endif
1994 1995
1995#ifdef CONFIG_PCI 1996#ifdef CONFIG_PCI
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 9c3d7ac08068..71482c15a852 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -272,10 +272,11 @@ EXPORT_SYMBOL(snd_hda_queue_unsol_event);
272/* 272/*
273 * process queueud unsolicited events 273 * process queueud unsolicited events
274 */ 274 */
275static void process_unsol_events(void *data) 275static void process_unsol_events(struct work_struct *work)
276{ 276{
277 struct hda_bus *bus = data; 277 struct hda_bus_unsolicited *unsol =
278 struct hda_bus_unsolicited *unsol = bus->unsol; 278 container_of(work, struct hda_bus_unsolicited, work);
279 struct hda_bus *bus = unsol->bus;
279 struct hda_codec *codec; 280 struct hda_codec *codec;
280 unsigned int rp, caddr, res; 281 unsigned int rp, caddr, res;
281 282
@@ -314,7 +315,8 @@ static int init_unsol_queue(struct hda_bus *bus)
314 kfree(unsol); 315 kfree(unsol);
315 return -ENOMEM; 316 return -ENOMEM;
316 } 317 }
317 INIT_WORK(&unsol->work, process_unsol_events, bus); 318 INIT_WORK(&unsol->work, process_unsol_events);
319 unsol->bus = bus;
318 bus->unsol = unsol; 320 bus->unsol = unsol;
319 return 0; 321 return 0;
320} 322}
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index f9416c36396e..9ca1baf860bd 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -206,6 +206,7 @@ struct hda_bus_unsolicited {
206 /* workqueue */ 206 /* workqueue */
207 struct workqueue_struct *workq; 207 struct workqueue_struct *workq;
208 struct work_struct work; 208 struct work_struct work;
209 struct hda_bus *bus;
209}; 210};
210 211
211/* 212/*
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c
index 2fbe1d183fce..8f074c7936e6 100644
--- a/sound/ppc/tumbler.c
+++ b/sound/ppc/tumbler.c
@@ -942,10 +942,11 @@ static void check_mute(struct snd_pmac *chip, struct pmac_gpio *gp, int val, int
942} 942}
943 943
944static struct work_struct device_change; 944static struct work_struct device_change;
945static struct snd_pmac *device_change_chip;
945 946
946static void device_change_handler(void *self) 947static void device_change_handler(struct work_struct *work)
947{ 948{
948 struct snd_pmac *chip = self; 949 struct snd_pmac *chip = device_change_chip;
949 struct pmac_tumbler *mix; 950 struct pmac_tumbler *mix;
950 int headphone, lineout; 951 int headphone, lineout;
951 952
@@ -1417,7 +1418,8 @@ int __init snd_pmac_tumbler_init(struct snd_pmac *chip)
1417 chip->resume = tumbler_resume; 1418 chip->resume = tumbler_resume;
1418#endif 1419#endif
1419 1420
1420 INIT_WORK(&device_change, device_change_handler, (void *)chip); 1421 INIT_WORK(&device_change, device_change_handler);
1422 device_change_chip = chip;
1421 1423
1422#ifdef PMAC_SUPPORT_AUTOMUTE 1424#ifdef PMAC_SUPPORT_AUTOMUTE
1423 if ((mix->headphone_irq >=0 || mix->lineout_irq >= 0) 1425 if ((mix->headphone_irq >=0 || mix->lineout_irq >= 0)
diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c
index 4b52d18dcd53..b76b3dd9df25 100644
--- a/sound/usb/usx2y/usX2Yhwdep.c
+++ b/sound/usb/usx2y/usX2Yhwdep.c
@@ -48,7 +48,7 @@ static struct page * snd_us428ctls_vm_nopage(struct vm_area_struct *area, unsign
48 48
49 offset = area->vm_pgoff << PAGE_SHIFT; 49 offset = area->vm_pgoff << PAGE_SHIFT;
50 offset += address - area->vm_start; 50 offset += address - area->vm_start;
51 snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM); 51 snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_SIGBUS);
52 vaddr = (char*)((struct usX2Ydev *)area->vm_private_data)->us428ctls_sharedmem + offset; 52 vaddr = (char*)((struct usX2Ydev *)area->vm_private_data)->us428ctls_sharedmem + offset;
53 page = virt_to_page(vaddr); 53 page = virt_to_page(vaddr);
54 get_page(page); 54 get_page(page);