aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/dvb/get_dvb_firmware8
-rw-r--r--Documentation/firmware_class/README17
-rw-r--r--Documentation/firmware_class/firmware_sample_driver.c11
-rw-r--r--Documentation/serial/driver9
-rw-r--r--Documentation/watchdog/watchdog-api.txt3
-rw-r--r--MAINTAINERS39
-rw-r--r--Makefile4
-rw-r--r--arch/arm/mach-ixp23xx/core.c18
-rw-r--r--arch/arm/mach-pxa/mainstone.c5
-rw-r--r--arch/arm/mach-s3c2410/sleep.S6
-rw-r--r--arch/arm/mm/mm-armv.c4
-rw-r--r--arch/arm/mm/proc-xsc3.S3
-rw-r--r--arch/i386/kernel/acpi/boot.c8
-rw-r--r--arch/i386/kernel/apic.c8
-rw-r--r--arch/i386/kernel/syscall_table.S1
-rw-r--r--arch/i386/kernel/traps.c4
-rw-r--r--arch/i386/mach-generic/probe.c16
-rw-r--r--arch/i386/mm/init.c2
-rw-r--r--arch/i386/power/cpu.c2
-rw-r--r--arch/mips/Kconfig96
-rw-r--r--arch/mips/au1000/common/irq.c1
-rw-r--r--arch/mips/au1000/common/time.c1
-rw-r--r--arch/mips/kernel/asm-offsets.c4
-rw-r--r--arch/mips/kernel/cpu-probe.c13
-rw-r--r--arch/mips/kernel/entry.S2
-rw-r--r--arch/mips/kernel/gdb-low.S8
-rw-r--r--arch/mips/kernel/proc.c2
-rw-r--r--arch/mips/kernel/signal-common.h30
-rw-r--r--arch/mips/kernel/syscall.c24
-rw-r--r--arch/mips/kernel/traps.c1
-rw-r--r--arch/mips/kernel/vmlinux.lds.S20
-rw-r--r--arch/mips/mm/c-r4k.c44
-rw-r--r--arch/mips/mm/pg-r4k.c1
-rw-r--r--arch/mips/mm/tlbex.c2
-rw-r--r--arch/mips/oprofile/common.c1
-rw-r--r--arch/mips/oprofile/op_model_mipsxx.c4
-rw-r--r--arch/powerpc/kernel/prom_init.c48
-rw-r--r--arch/powerpc/kernel/systbl.S2
-rw-r--r--arch/powerpc/platforms/cell/spu_callbacks.c7
-rw-r--r--arch/powerpc/platforms/powermac/low_i2c.c12
-rw-r--r--arch/powerpc/platforms/powermac/setup.c12
-rw-r--r--arch/ppc/kernel/asm-offsets.c2
-rw-r--r--arch/ppc/platforms/mpc8272ads_setup.c10
-rw-r--r--arch/ppc/syslib/pq2_devices.c16
-rw-r--r--arch/ppc/syslib/pq2_sys.c8
-rw-r--r--arch/s390/kernel/time.c2
-rw-r--r--arch/sparc/kernel/systbls.S3
-rw-r--r--arch/sparc64/kernel/head.S30
-rw-r--r--arch/sparc64/kernel/pci_iommu.c4
-rw-r--r--arch/sparc64/kernel/pci_sun4v.c4
-rw-r--r--arch/sparc64/kernel/setup.c23
-rw-r--r--arch/sparc64/kernel/smp.c16
-rw-r--r--arch/sparc64/kernel/systbls.S8
-rw-r--r--arch/x86_64/ia32/ia32_binfmt.c4
-rw-r--r--arch/x86_64/kernel/e820.c2
-rw-r--r--arch/x86_64/kernel/entry.S7
-rw-r--r--arch/x86_64/kernel/kprobes.c6
-rw-r--r--arch/x86_64/kernel/pci-dma.c4
-rw-r--r--arch/x86_64/kernel/pci-gart.c6
-rw-r--r--arch/x86_64/kernel/pmtimer.c2
-rw-r--r--arch/x86_64/kernel/setup.c2
-rw-r--r--arch/x86_64/mm/srat.c4
-rw-r--r--block/cfq-iosched.c77
-rw-r--r--block/ll_rw_blk.c7
-rw-r--r--drivers/base/firmware_class.c39
-rw-r--r--drivers/base/power/suspend.c5
-rw-r--r--drivers/char/agp/Kconfig2
-rw-r--r--drivers/char/agp/amd64-agp.c3
-rw-r--r--drivers/char/agp/via-agp.c7
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c38
-rw-r--r--drivers/char/tpm/tpm_bios.c89
-rw-r--r--drivers/char/tpm/tpm_tis.c4
-rw-r--r--drivers/char/tty_io.c2
-rw-r--r--drivers/char/vt.c8
-rw-r--r--drivers/char/watchdog/i8xx_tco.c16
-rw-r--r--drivers/char/watchdog/s3c2410_wdt.c6
-rw-r--r--drivers/char/watchdog/sc1200wdt.c2
-rw-r--r--drivers/i2c/busses/scx200_acb.c2
-rw-r--r--drivers/ide/pci/sgiioc4.c16
-rw-r--r--drivers/ide/ppc/pmac.c2
-rw-r--r--drivers/infiniband/core/uverbs_mem.c4
-rw-r--r--drivers/infiniband/hw/ipath/ipath_driver.c22
-rw-r--r--drivers/infiniband/hw/ipath/ipath_eeprom.c7
-rw-r--r--drivers/infiniband/hw/ipath/ipath_file_ops.c6
-rw-r--r--drivers/infiniband/hw/ipath/ipath_ht400.c21
-rw-r--r--drivers/infiniband/hw/ipath/ipath_init_chip.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_kernel.h2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_keys.c6
-rw-r--r--drivers/infiniband/hw/ipath/ipath_layer.c12
-rw-r--r--drivers/infiniband/hw/ipath/ipath_pe800.c2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_qp.c64
-rw-r--r--drivers/infiniband/hw/ipath/ipath_rc.c15
-rw-r--r--drivers/infiniband/hw/ipath/ipath_ruc.c2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.c7
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c35
-rw-r--r--drivers/infiniband/hw/mthca/mthca_srq.c41
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c10
-rw-r--r--drivers/input/joystick/sidewinder.c11
-rw-r--r--drivers/input/keyboard/corgikbd.c12
-rw-r--r--drivers/input/keyboard/spitzkbd.c12
-rw-r--r--drivers/input/misc/wistron_btns.c19
-rw-r--r--drivers/input/mouse/alps.c4
-rw-r--r--drivers/input/mouse/lifebook.c24
-rw-r--r--drivers/input/mouse/logips2pp.c6
-rw-r--r--drivers/input/touchscreen/ads7846.c53
-rw-r--r--drivers/isdn/i4l/isdn_tty.c2
-rw-r--r--drivers/md/md.c17
-rw-r--r--drivers/md/raid0.c5
-rw-r--r--drivers/media/Kconfig45
-rw-r--r--drivers/media/common/Kconfig3
-rw-r--r--drivers/media/dvb/Kconfig10
-rw-r--r--drivers/media/dvb/b2c2/Kconfig6
-rw-r--r--drivers/media/dvb/bt8xx/Kconfig3
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.c6
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c5
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c12
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c4
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig2
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c17
-rw-r--r--drivers/media/dvb/frontends/cx24123.c565
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.c4
-rw-r--r--drivers/media/dvb/pluto2/Kconfig3
-rw-r--r--drivers/media/dvb/pluto2/Makefile2
-rw-r--r--drivers/media/dvb/ttpci/Kconfig12
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c6
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c105
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c6
-rw-r--r--drivers/media/radio/Kconfig30
-rw-r--r--drivers/media/video/Kconfig79
-rw-r--r--drivers/media/video/Makefile10
-rw-r--r--drivers/media/video/bt8xx/Kconfig2
-rw-r--r--drivers/media/video/bt8xx/Makefile2
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c4
-rw-r--r--drivers/media/video/bt8xx/bttv-risc.c14
-rw-r--r--drivers/media/video/cx25840/cx25840-firmware.c49
-rw-r--r--drivers/media/video/cx88/cx88-cards.c2
-rw-r--r--drivers/media/video/cx88/cx88-core.c16
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c2
-rw-r--r--drivers/media/video/cx88/cx88-video.c2
-rw-r--r--drivers/media/video/em28xx/Kconfig2
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c10
-rw-r--r--drivers/media/video/et61x251/Kconfig2
-rw-r--r--drivers/media/video/pwc/Kconfig2
-rw-r--r--drivers/media/video/pwc/Makefile17
-rw-r--r--drivers/media/video/saa7127.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c2
-rw-r--r--drivers/media/video/sn9c102/Kconfig2
-rw-r--r--drivers/media/video/tuner-types.c4
-rw-r--r--drivers/media/video/tveeprom.c2
-rw-r--r--drivers/media/video/usbvideo/Kconfig6
-rw-r--r--drivers/media/video/vivi.c5
-rw-r--r--drivers/media/video/zc0301/Kconfig2
-rw-r--r--drivers/mmc/au1xmmc.c6
-rw-r--r--drivers/mmc/imxmmc.c24
-rw-r--r--drivers/mmc/mmc.c1
-rw-r--r--drivers/mmc/mmc_block.c3
-rw-r--r--drivers/mmc/pxamci.c4
-rw-r--r--drivers/mmc/wbsd.c8
-rw-r--r--drivers/net/bnx2.c20
-rw-r--r--drivers/net/e1000/e1000_main.c10
-rw-r--r--drivers/net/forcedeth.c72
-rw-r--r--drivers/net/irda/Kconfig20
-rw-r--r--drivers/net/pcmcia/axnet_cs.c13
-rw-r--r--drivers/net/pcnet32.c2
-rw-r--r--drivers/net/skge.c8
-rw-r--r--drivers/net/sky2.c73
-rw-r--r--drivers/net/sky2.h2
-rw-r--r--drivers/net/tg3.c8
-rw-r--r--drivers/net/tulip/winbond-840.c4
-rw-r--r--drivers/net/via-rhine.c34
-rw-r--r--drivers/net/wireless/arlan-main.c4
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c6
-rw-r--r--drivers/net/wireless/orinoco.c4
-rw-r--r--drivers/net/wireless/wavelan.c2
-rw-r--r--drivers/pci/pci-acpi.c60
-rw-r--r--drivers/pcmcia/pd6729.c2
-rw-r--r--drivers/rtc/rtc-dev.c6
-rw-r--r--drivers/rtc/rtc-sa1100.c2
-rw-r--r--drivers/rtc/rtc-test.c2
-rw-r--r--drivers/rtc/rtc-vr41xx.c2
-rw-r--r--drivers/s390/net/ctcmain.c26
-rw-r--r--drivers/s390/net/ctctty.c10
-rw-r--r--drivers/s390/net/cu3088.c10
-rw-r--r--drivers/s390/net/iucv.c36
-rw-r--r--drivers/s390/net/iucv.h622
-rw-r--r--drivers/s390/net/lcs.c345
-rw-r--r--drivers/s390/net/lcs.h14
-rw-r--r--drivers/s390/net/netiucv.c36
-rw-r--r--drivers/s390/net/qeth.h18
-rw-r--r--drivers/s390/net/qeth_eddp.c18
-rw-r--r--drivers/s390/net/qeth_fs.h2
-rw-r--r--drivers/s390/net/qeth_main.c107
-rw-r--r--drivers/s390/net/qeth_mpc.h4
-rw-r--r--drivers/s390/net/qeth_proc.c8
-rw-r--r--drivers/s390/net/qeth_sys.c6
-rw-r--r--drivers/s390/net/qeth_tso.h4
-rw-r--r--drivers/scsi/libata-core.c12
-rw-r--r--drivers/scsi/sata_mv.c134
-rw-r--r--drivers/scsi/st.c2
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_core.c8
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm2.c2
-rw-r--r--drivers/serial/sunsu.c1
-rw-r--r--drivers/spi/Kconfig26
-rw-r--r--drivers/spi/Makefile3
-rw-r--r--drivers/spi/pxa2xx_spi.c93
-rw-r--r--drivers/spi/spi.c6
-rw-r--r--drivers/spi/spi_butterfly.c1
-rw-r--r--drivers/spi/spi_mpc83xx.c483
-rw-r--r--drivers/spi/spi_s3c24xx.c453
-rw-r--r--drivers/spi/spi_s3c24xx_gpio.c188
-rw-r--r--drivers/usb/input/hiddev.c1
-rw-r--r--drivers/video/au1100fb.c21
-rw-r--r--drivers/video/console/fbcon.c2
-rw-r--r--drivers/video/i810/i810_main.c4
-rw-r--r--drivers/video/matrox/g450_pll.c23
-rw-r--r--drivers/video/matrox/matroxfb_DAC1064.h2
-rw-r--r--drivers/video/matrox/matroxfb_base.h2
-rw-r--r--drivers/video/maxinefb.c4
-rw-r--r--fs/affs/namei.c3
-rw-r--r--fs/binfmt_flat.c30
-rw-r--r--fs/bio.c3
-rw-r--r--fs/cifs/CHANGES7
-rw-r--r--fs/cifs/cifsfs.h2
-rw-r--r--fs/cifs/cifsproto.h2
-rw-r--r--fs/cifs/cifssmb.c40
-rw-r--r--fs/cifs/connect.c97
-rw-r--r--fs/cifs/file.c12
-rw-r--r--fs/compat.c177
-rw-r--r--fs/exportfs/expfs.c2
-rw-r--r--fs/ext3/resize.c1
-rw-r--r--fs/inotify.c9
-rw-r--r--fs/jfs/jfs_metapage.c20
-rw-r--r--fs/nfsd/export.c4
-rw-r--r--fs/nfsd/vfs.c7
-rw-r--r--include/asm-alpha/termbits.h1
-rw-r--r--include/asm-arm/arch-ixp23xx/memory.h2
-rw-r--r--include/asm-arm/arch-pxa/pxa2xx_spi.h3
-rw-r--r--include/asm-arm/arch-s3c2410/spi-gpio.h31
-rw-r--r--include/asm-arm/arch-s3c2410/spi.h29
-rw-r--r--include/asm-arm/spinlock.h6
-rw-r--r--include/asm-arm/system.h6
-rw-r--r--include/asm-generic/pgtable.h11
-rw-r--r--include/asm-mips/cpu.h6
-rw-r--r--include/asm-mips/futex.h141
-rw-r--r--include/asm-mips/inst.h33
-rw-r--r--include/asm-mips/mipsregs.h2
-rw-r--r--include/asm-mips/pgtable.h98
-rw-r--r--include/asm-mips/sigcontext.h10
-rw-r--r--include/asm-powerpc/termbits.h1
-rw-r--r--include/asm-powerpc/unistd.h4
-rw-r--r--include/asm-sparc/unistd.h8
-rw-r--r--include/asm-sparc64/dma-mapping.h141
-rw-r--r--include/asm-sparc64/pci.h4
-rw-r--r--include/asm-sparc64/pgtable.h17
-rw-r--r--include/asm-sparc64/unistd.h8
-rw-r--r--include/asm-x86_64/elf.h2
-rw-r--r--include/linux/firmware.h1
-rw-r--r--include/linux/fs.h7
-rw-r--r--include/linux/fsl_devices.h11
-rw-r--r--include/linux/input.h13
-rw-r--r--include/linux/mmc/mmc.h1
-rw-r--r--include/linux/mmzone.h1
-rw-r--r--include/linux/pci_ids.h1
-rw-r--r--include/linux/syscalls.h6
-rw-r--r--include/linux/videodev2.h5
-rw-r--r--include/linux/vt_kern.h5
-rw-r--r--include/net/compat.h3
-rw-r--r--include/net/irda/irlmp.h2
-rw-r--r--include/net/sctp/command.h1
-rw-r--r--include/net/sctp/sctp.h6
-rw-r--r--kernel/cpuset.c25
-rw-r--r--kernel/hrtimer.c6
-rw-r--r--kernel/sched.c62
-rw-r--r--kernel/timer.c16
-rw-r--r--lib/kobject.c6
-rw-r--r--mm/memory_hotplug.c8
-rw-r--r--mm/page_alloc.c19
-rw-r--r--mm/slab.c27
-rw-r--r--mm/sparse.c7
-rw-r--r--net/bridge/br.c3
-rw-r--r--net/core/dev.c20
-rw-r--r--net/ipv4/ipcomp.c2
-rw-r--r--net/ipv4/netfilter/Kconfig4
-rw-r--r--net/ipv4/netfilter/ip_conntrack_core.c1
-rw-r--r--net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.c36
-rw-r--r--net/ipv4/netfilter/ip_conntrack_helper_pptp.c4
-rw-r--r--net/ipv4/netfilter/ip_nat_snmp_basic.c16
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c1
-rw-r--r--net/ipv4/tcp_highspeed.c3
-rw-r--r--net/ipv4/xfrm4_policy.c2
-rw-r--r--net/ipv6/ipcomp6.c2
-rw-r--r--net/ipv6/route.c16
-rw-r--r--net/irda/iriap.c3
-rw-r--r--net/sctp/input.c144
-rw-r--r--net/sctp/sm_sideeffect.c16
-rw-r--r--net/sctp/sm_statefuns.c81
-rw-r--r--net/sctp/socket.c29
-rw-r--r--net/sunrpc/cache.c1
-rw-r--r--net/xfrm/xfrm_input.c2
-rw-r--r--scripts/mod/modpost.c88
-rw-r--r--scripts/mod/modpost.h23
-rw-r--r--security/selinux/hooks.c2
-rw-r--r--sound/drivers/mpu401/mpu401.c2
-rw-r--r--sound/isa/es18xx.c2
-rw-r--r--sound/oss/ad1848.c10
-rw-r--r--sound/oss/nm256_audio.c6
309 files changed, 4873 insertions, 2511 deletions
diff --git a/Documentation/dvb/get_dvb_firmware b/Documentation/dvb/get_dvb_firmware
index 15fc8fbef67e..4820366b6ae8 100644
--- a/Documentation/dvb/get_dvb_firmware
+++ b/Documentation/dvb/get_dvb_firmware
@@ -259,9 +259,9 @@ sub dibusb {
259} 259}
260 260
261sub nxt2002 { 261sub nxt2002 {
262 my $sourcefile = "Broadband4PC_4_2_11.zip"; 262 my $sourcefile = "Technisat_DVB-PC_4_4_COMPACT.zip";
263 my $url = "http://www.bbti.us/download/windows/$sourcefile"; 263 my $url = "http://www.bbti.us/download/windows/$sourcefile";
264 my $hash = "c6d2ea47a8f456d887ada0cfb718ff2a"; 264 my $hash = "476befae8c7c1bb9648954060b1eec1f";
265 my $outfile = "dvb-fe-nxt2002.fw"; 265 my $outfile = "dvb-fe-nxt2002.fw";
266 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 266 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
267 267
@@ -269,8 +269,8 @@ sub nxt2002 {
269 269
270 wgetfile($sourcefile, $url); 270 wgetfile($sourcefile, $url);
271 unzip($sourcefile, $tmpdir); 271 unzip($sourcefile, $tmpdir);
272 verify("$tmpdir/SkyNETU.sys", $hash); 272 verify("$tmpdir/SkyNET.sys", $hash);
273 extract("$tmpdir/SkyNETU.sys", 375832, 5908, $outfile); 273 extract("$tmpdir/SkyNET.sys", 331624, 5908, $outfile);
274 274
275 $outfile; 275 $outfile;
276} 276}
diff --git a/Documentation/firmware_class/README b/Documentation/firmware_class/README
index 43e836c07ae8..e9cc8bb26f7d 100644
--- a/Documentation/firmware_class/README
+++ b/Documentation/firmware_class/README
@@ -105,20 +105,3 @@
105 on the setup, so I think that the choice on what firmware to make 105 on the setup, so I think that the choice on what firmware to make
106 persistent should be left to userspace. 106 persistent should be left to userspace.
107 107
108 - Why register_firmware()+__init can be useful:
109 - For boot devices needing firmware.
110 - To make the transition easier:
111 The firmware can be declared __init and register_firmware()
112 called on module_init. Then the firmware is warranted to be
113 there even if "firmware hotplug userspace" is not there yet or
114 it doesn't yet provide the needed firmware.
115 Once the firmware is widely available in userspace, it can be
116 removed from the kernel. Or made optional (CONFIG_.*_FIRMWARE).
117
118 In either case, if firmware hotplug support is there, it can move the
119 firmware out of kernel memory into the real filesystem for later
120 usage.
121
122 Note: If persistence is implemented on top of initramfs,
123 register_firmware() may not be appropriate.
124
diff --git a/Documentation/firmware_class/firmware_sample_driver.c b/Documentation/firmware_class/firmware_sample_driver.c
index ad3edaba4533..87feccdb5c9f 100644
--- a/Documentation/firmware_class/firmware_sample_driver.c
+++ b/Documentation/firmware_class/firmware_sample_driver.c
@@ -5,8 +5,6 @@
5 * 5 *
6 * Sample code on how to use request_firmware() from drivers. 6 * Sample code on how to use request_firmware() from drivers.
7 * 7 *
8 * Note that register_firmware() is currently useless.
9 *
10 */ 8 */
11 9
12#include <linux/module.h> 10#include <linux/module.h>
@@ -17,11 +15,6 @@
17 15
18#include "linux/firmware.h" 16#include "linux/firmware.h"
19 17
20#define WE_CAN_NEED_FIRMWARE_BEFORE_USERSPACE_IS_AVAILABLE
21#ifdef WE_CAN_NEED_FIRMWARE_BEFORE_USERSPACE_IS_AVAILABLE
22char __init inkernel_firmware[] = "let's say that this is firmware\n";
23#endif
24
25static struct device ghost_device = { 18static struct device ghost_device = {
26 .bus_id = "ghost0", 19 .bus_id = "ghost0",
27}; 20};
@@ -104,10 +97,6 @@ static void sample_probe_async(void)
104 97
105static int sample_init(void) 98static int sample_init(void)
106{ 99{
107#ifdef WE_CAN_NEED_FIRMWARE_BEFORE_USERSPACE_IS_AVAILABLE
108 register_firmware("sample_driver_fw", inkernel_firmware,
109 sizeof(inkernel_firmware));
110#endif
111 device_initialize(&ghost_device); 100 device_initialize(&ghost_device);
112 /* since there is no real hardware insertion I just call the 101 /* since there is no real hardware insertion I just call the
113 * sample probe functions here */ 102 * sample probe functions here */
diff --git a/Documentation/serial/driver b/Documentation/serial/driver
index df82116a9f26..88ad615dd338 100644
--- a/Documentation/serial/driver
+++ b/Documentation/serial/driver
@@ -214,12 +214,13 @@ hardware.
214 The interaction of the iflag bits is as follows (parity error 214 The interaction of the iflag bits is as follows (parity error
215 given as an example): 215 given as an example):
216 Parity error INPCK IGNPAR 216 Parity error INPCK IGNPAR
217 None n/a n/a character received 217 n/a 0 n/a character received, marked as
218 Yes n/a 0 character discarded
219 Yes 0 1 character received, marked as
220 TTY_NORMAL 218 TTY_NORMAL
221 Yes 1 1 character received, marked as 219 None 1 n/a character received, marked as
220 TTY_NORMAL
221 Yes 1 0 character received, marked as
222 TTY_PARITY 222 TTY_PARITY
223 Yes 1 1 character discarded
223 224
224 Other flags may be used (eg, xon/xoff characters) if your 225 Other flags may be used (eg, xon/xoff characters) if your
225 hardware supports hardware "soft" flow control. 226 hardware supports hardware "soft" flow control.
diff --git a/Documentation/watchdog/watchdog-api.txt b/Documentation/watchdog/watchdog-api.txt
index c5beb548cfc4..21ed51173662 100644
--- a/Documentation/watchdog/watchdog-api.txt
+++ b/Documentation/watchdog/watchdog-api.txt
@@ -36,6 +36,9 @@ timeout or margin. The simplest way to ping the watchdog is to write
36some data to the device. So a very simple watchdog daemon would look 36some data to the device. So a very simple watchdog daemon would look
37like this: 37like this:
38 38
39#include <stdlib.h>
40#include <fcntl.h>
41
39int main(int argc, const char *argv[]) { 42int main(int argc, const char *argv[]) {
40 int fd=open("/dev/watchdog",O_WRONLY); 43 int fd=open("/dev/watchdog",O_WRONLY);
41 if (fd==-1) { 44 if (fd==-1) {
diff --git a/MAINTAINERS b/MAINTAINERS
index 753584cf4e7e..74d71cafb17c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -40,11 +40,20 @@ trivial patch so apply some common sense.
40 PLEASE document known bugs. If it doesn't work for everything 40 PLEASE document known bugs. If it doesn't work for everything
41 or does something very odd once a month document it. 41 or does something very odd once a month document it.
42 42
43 PLEASE remember that submissions must be made under the terms
44 of the OSDL certificate of contribution
45 (http://www.osdl.org/newsroom/press_releases/2004/2004_05_24_dco.html)
46 and should include a Signed-off-by: line.
47
436. Make sure you have the right to send any changes you make. If you 486. Make sure you have the right to send any changes you make. If you
44 do changes at work you may find your employer owns the patch 49 do changes at work you may find your employer owns the patch
45 not you. 50 not you.
46 51
477. Happy hacking. 527. When sending security related changes or reports to a maintainer
53 please Cc: security@kernel.org, especially if the maintainer
54 does not respond.
55
568. Happy hacking.
48 57
49 ----------------------------------- 58 -----------------------------------
50 59
@@ -556,7 +565,7 @@ BROADBAND PROCESSOR ARCHITECTURE
556P: Arnd Bergmann 565P: Arnd Bergmann
557M: arnd@arndb.de 566M: arnd@arndb.de
558L: linuxppc-dev@ozlabs.org 567L: linuxppc-dev@ozlabs.org
559W: http://linuxppc64.org 568W: http://www.penguinppc.org/ppc64/
560S: Supported 569S: Supported
561 570
562BTTV VIDEO4LINUX DRIVER 571BTTV VIDEO4LINUX DRIVER
@@ -969,7 +978,7 @@ S: Maintained
969EXT3 FILE SYSTEM 978EXT3 FILE SYSTEM
970P: Stephen Tweedie, Andrew Morton 979P: Stephen Tweedie, Andrew Morton
971M: sct@redhat.com, akpm@osdl.org, adilger@clusterfs.com 980M: sct@redhat.com, akpm@osdl.org, adilger@clusterfs.com
972L: ext3-users@redhat.com 981L: ext2-devel@lists.sourceforge.net
973S: Maintained 982S: Maintained
974 983
975F71805F HARDWARE MONITORING DRIVER 984F71805F HARDWARE MONITORING DRIVER
@@ -1530,12 +1539,28 @@ W: http://jfs.sourceforge.net/
1530T: git kernel.org:/pub/scm/linux/kernel/git/shaggy/jfs-2.6.git 1539T: git kernel.org:/pub/scm/linux/kernel/git/shaggy/jfs-2.6.git
1531S: Supported 1540S: Supported
1532 1541
1542JOURNALLING LAYER FOR BLOCK DEVICS (JBD)
1543P: Stephen Tweedie, Andrew Morton
1544M: sct@redhat.com, akpm@osdl.org
1545L: ext2-devel@lists.sourceforge.net
1546S: Maintained
1547
1533KCONFIG 1548KCONFIG
1534P: Roman Zippel 1549P: Roman Zippel
1535M: zippel@linux-m68k.org 1550M: zippel@linux-m68k.org
1536L: kbuild-devel@lists.sourceforge.net 1551L: kbuild-devel@lists.sourceforge.net
1537S: Maintained 1552S: Maintained
1538 1553
1554KDUMP
1555P: Vivek Goyal
1556M: vgoyal@in.ibm.com
1557P: Haren Myneni
1558M: hbabu@us.ibm.com
1559L: fastboot@lists.osdl.org
1560L: linux-kernel@vger.kernel.org
1561W: http://lse.sourceforge.net/kdump/
1562S: Maintained
1563
1539KERNEL AUTOMOUNTER (AUTOFS) 1564KERNEL AUTOMOUNTER (AUTOFS)
1540P: H. Peter Anvin 1565P: H. Peter Anvin
1541M: hpa@zytor.com 1566M: hpa@zytor.com
@@ -1691,7 +1716,7 @@ M: paulus@au.ibm.com
1691P: Anton Blanchard 1716P: Anton Blanchard
1692M: anton@samba.org 1717M: anton@samba.org
1693M: anton@au.ibm.com 1718M: anton@au.ibm.com
1694W: http://linuxppc64.org 1719W: http://www.penguinppc.org/ppc64/
1695L: linuxppc-dev@ozlabs.org 1720L: linuxppc-dev@ozlabs.org
1696S: Supported 1721S: Supported
1697 1722
@@ -1874,6 +1899,12 @@ M: James.Bottomley@HansenPartnership.com
1874L: linux-scsi@vger.kernel.org 1899L: linux-scsi@vger.kernel.org
1875S: Maintained 1900S: Maintained
1876 1901
1902NETEM NETWORK EMULATOR
1903P: Stephen Hemminger
1904M: shemminger@osdl.org
1905L: netem@osdl.org
1906S: Maintained
1907
1877NETFILTER/IPTABLES/IPCHAINS 1908NETFILTER/IPTABLES/IPCHAINS
1878P: Rusty Russell 1909P: Rusty Russell
1879P: Marc Boucher 1910P: Marc Boucher
diff --git a/Makefile b/Makefile
index 3494c17c9fb9..435d209f42d8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 17 3SUBLEVEL = 17
4EXTRAVERSION =-rc4 4EXTRAVERSION =-rc5
5NAME=Sliding Snow Leopard 5NAME=Lordi Rules
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
8# To see a list of typical targets execute "make help" 8# To see a list of typical targets execute "make help"
diff --git a/arch/arm/mach-ixp23xx/core.c b/arch/arm/mach-ixp23xx/core.c
index 092ee12ced42..affd1d5d7440 100644
--- a/arch/arm/mach-ixp23xx/core.c
+++ b/arch/arm/mach-ixp23xx/core.c
@@ -178,8 +178,12 @@ static int ixp23xx_irq_set_type(unsigned int irq, unsigned int type)
178 178
179static void ixp23xx_irq_mask(unsigned int irq) 179static void ixp23xx_irq_mask(unsigned int irq)
180{ 180{
181 volatile unsigned long *intr_reg = IXP23XX_INTR_EN1 + (irq / 32); 181 volatile unsigned long *intr_reg;
182 182
183 if (irq >= 56)
184 irq += 8;
185
186 intr_reg = IXP23XX_INTR_EN1 + (irq / 32);
183 *intr_reg &= ~(1 << (irq % 32)); 187 *intr_reg &= ~(1 << (irq % 32));
184} 188}
185 189
@@ -199,17 +203,25 @@ static void ixp23xx_irq_ack(unsigned int irq)
199 */ 203 */
200static void ixp23xx_irq_level_unmask(unsigned int irq) 204static void ixp23xx_irq_level_unmask(unsigned int irq)
201{ 205{
202 volatile unsigned long *intr_reg = IXP23XX_INTR_EN1 + (irq / 32); 206 volatile unsigned long *intr_reg;
203 207
204 ixp23xx_irq_ack(irq); 208 ixp23xx_irq_ack(irq);
205 209
210 if (irq >= 56)
211 irq += 8;
212
213 intr_reg = IXP23XX_INTR_EN1 + (irq / 32);
206 *intr_reg |= (1 << (irq % 32)); 214 *intr_reg |= (1 << (irq % 32));
207} 215}
208 216
209static void ixp23xx_irq_edge_unmask(unsigned int irq) 217static void ixp23xx_irq_edge_unmask(unsigned int irq)
210{ 218{
211 volatile unsigned long *intr_reg = IXP23XX_INTR_EN1 + (irq / 32); 219 volatile unsigned long *intr_reg;
220
221 if (irq >= 56)
222 irq += 8;
212 223
224 intr_reg = IXP23XX_INTR_EN1 + (irq / 32);
213 *intr_reg |= (1 << (irq % 32)); 225 *intr_reg |= (1 << (irq % 32));
214} 226}
215 227
diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index 98356f810007..02e188d98e7d 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -95,7 +95,10 @@ static void __init mainstone_init_irq(void)
95 for(irq = MAINSTONE_IRQ(0); irq <= MAINSTONE_IRQ(15); irq++) { 95 for(irq = MAINSTONE_IRQ(0); irq <= MAINSTONE_IRQ(15); irq++) {
96 set_irq_chip(irq, &mainstone_irq_chip); 96 set_irq_chip(irq, &mainstone_irq_chip);
97 set_irq_handler(irq, do_level_IRQ); 97 set_irq_handler(irq, do_level_IRQ);
98 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); 98 if (irq == MAINSTONE_IRQ(10) || irq == MAINSTONE_IRQ(14))
99 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE | IRQF_NOAUTOEN);
100 else
101 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
99 } 102 }
100 set_irq_flags(MAINSTONE_IRQ(8), 0); 103 set_irq_flags(MAINSTONE_IRQ(8), 0);
101 set_irq_flags(MAINSTONE_IRQ(12), 0); 104 set_irq_flags(MAINSTONE_IRQ(12), 0);
diff --git a/arch/arm/mach-s3c2410/sleep.S b/arch/arm/mach-s3c2410/sleep.S
index 832fb86a03b4..73de2eaca22a 100644
--- a/arch/arm/mach-s3c2410/sleep.S
+++ b/arch/arm/mach-s3c2410/sleep.S
@@ -59,8 +59,7 @@ ENTRY(s3c2410_cpu_suspend)
59 mrc p15, 0, r5, c13, c0, 0 @ PID 59 mrc p15, 0, r5, c13, c0, 0 @ PID
60 mrc p15, 0, r6, c3, c0, 0 @ Domain ID 60 mrc p15, 0, r6, c3, c0, 0 @ Domain ID
61 mrc p15, 0, r7, c2, c0, 0 @ translation table base address 61 mrc p15, 0, r7, c2, c0, 0 @ translation table base address
62 mrc p15, 0, r8, c2, c0, 0 @ auxiliary control register 62 mrc p15, 0, r8, c1, c0, 0 @ control register
63 mrc p15, 0, r9, c1, c0, 0 @ control register
64 63
65 stmia r0, { r4 - r13 } 64 stmia r0, { r4 - r13 }
66 65
@@ -165,7 +164,6 @@ ENTRY(s3c2410_cpu_resume)
165 mcr p15, 0, r5, c13, c0, 0 @ PID 164 mcr p15, 0, r5, c13, c0, 0 @ PID
166 mcr p15, 0, r6, c3, c0, 0 @ Domain ID 165 mcr p15, 0, r6, c3, c0, 0 @ Domain ID
167 mcr p15, 0, r7, c2, c0, 0 @ translation table base 166 mcr p15, 0, r7, c2, c0, 0 @ translation table base
168 mcr p15, 0, r8, c1, c1, 0 @ auxilliary control
169 167
170#ifdef CONFIG_DEBUG_RESUME 168#ifdef CONFIG_DEBUG_RESUME
171 mov r3, #'R' 169 mov r3, #'R'
@@ -173,7 +171,7 @@ ENTRY(s3c2410_cpu_resume)
173#endif 171#endif
174 172
175 ldr r2, =resume_with_mmu 173 ldr r2, =resume_with_mmu
176 mcr p15, 0, r9, c1, c0, 0 @ turn on MMU, etc 174 mcr p15, 0, r8, c1, c0, 0 @ turn on MMU, etc
177 nop @ second-to-last before mmu 175 nop @ second-to-last before mmu
178 mov pc, r2 @ go back to virtual address 176 mov pc, r2 @ go back to virtual address
179 177
diff --git a/arch/arm/mm/mm-armv.c b/arch/arm/mm/mm-armv.c
index f14b2d0f3690..95273de4f772 100644
--- a/arch/arm/mm/mm-armv.c
+++ b/arch/arm/mm/mm-armv.c
@@ -376,7 +376,7 @@ void __init build_mem_type_table(void)
376 ecc_mask = 0; 376 ecc_mask = 0;
377 } 377 }
378 378
379 if (cpu_arch <= CPU_ARCH_ARMv5TEJ) { 379 if (cpu_arch <= CPU_ARCH_ARMv5TEJ && !cpu_is_xscale()) {
380 for (i = 0; i < ARRAY_SIZE(mem_types); i++) { 380 for (i = 0; i < ARRAY_SIZE(mem_types); i++) {
381 if (mem_types[i].prot_l1) 381 if (mem_types[i].prot_l1)
382 mem_types[i].prot_l1 |= PMD_BIT4; 382 mem_types[i].prot_l1 |= PMD_BIT4;
@@ -631,7 +631,7 @@ void setup_mm_for_reboot(char mode)
631 pgd = init_mm.pgd; 631 pgd = init_mm.pgd;
632 632
633 base_pmdval = PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | PMD_TYPE_SECT; 633 base_pmdval = PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | PMD_TYPE_SECT;
634 if (cpu_architecture() <= CPU_ARCH_ARMv5TEJ) 634 if (cpu_architecture() <= CPU_ARCH_ARMv5TEJ && !cpu_is_xscale())
635 base_pmdval |= PMD_BIT4; 635 base_pmdval |= PMD_BIT4;
636 636
637 for (i = 0; i < FIRST_USER_PGD_NR + USER_PTRS_PER_PGD; i++, pgd++) { 637 for (i = 0; i < FIRST_USER_PGD_NR + USER_PTRS_PER_PGD; i++, pgd++) {
diff --git a/arch/arm/mm/proc-xsc3.S b/arch/arm/mm/proc-xsc3.S
index 80873b36c3f7..8d32e21fe151 100644
--- a/arch/arm/mm/proc-xsc3.S
+++ b/arch/arm/mm/proc-xsc3.S
@@ -427,12 +427,13 @@ __xsc3_setup:
427#endif 427#endif
428 mcr p15, 0, r0, c1, c0, 1 @ set auxiliary control reg 428 mcr p15, 0, r0, c1, c0, 1 @ set auxiliary control reg
429 mrc p15, 0, r0, c1, c0, 0 @ get control register 429 mrc p15, 0, r0, c1, c0, 0 @ get control register
430 bic r0, r0, #0x0200 @ .... ..R. .... ....
431 bic r0, r0, #0x0002 @ .... .... .... ..A. 430 bic r0, r0, #0x0002 @ .... .... .... ..A.
432 orr r0, r0, #0x0005 @ .... .... .... .C.M 431 orr r0, r0, #0x0005 @ .... .... .... .C.M
433#if BTB_ENABLE 432#if BTB_ENABLE
433 bic r0, r0, #0x0200 @ .... ..R. .... ....
434 orr r0, r0, #0x3900 @ ..VI Z..S .... .... 434 orr r0, r0, #0x3900 @ ..VI Z..S .... ....
435#else 435#else
436 bic r0, r0, #0x0a00 @ .... Z.R. .... ....
436 orr r0, r0, #0x3100 @ ..VI ...S .... .... 437 orr r0, r0, #0x3100 @ ..VI ...S .... ....
437#endif 438#endif
438#if L2_CACHE_ENABLE 439#if L2_CACHE_ENABLE
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index daee69579b1c..40e5aba3ad3d 100644
--- a/arch/i386/kernel/acpi/boot.c
+++ b/arch/i386/kernel/acpi/boot.c
@@ -1066,14 +1066,6 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
1066 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"), 1066 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
1067 }, 1067 },
1068 }, 1068 },
1069 {
1070 .callback = disable_acpi_pci,
1071 .ident = "HP xw9300",
1072 .matches = {
1073 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1074 DMI_MATCH(DMI_PRODUCT_NAME, "HP xw9300 Workstation"),
1075 },
1076 },
1077 {} 1069 {}
1078}; 1070};
1079 1071
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index 013b85df18c6..3d4b2f3d116a 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -1341,6 +1341,14 @@ int __init APIC_init_uniprocessor (void)
1341 1341
1342 connect_bsp_APIC(); 1342 connect_bsp_APIC();
1343 1343
1344 /*
1345 * Hack: In case of kdump, after a crash, kernel might be booting
1346 * on a cpu with non-zero lapic id. But boot_cpu_physical_apicid
1347 * might be zero if read from MP tables. Get it from LAPIC.
1348 */
1349#ifdef CONFIG_CRASH_DUMP
1350 boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID));
1351#endif
1344 phys_cpu_present_map = physid_mask_of_physid(boot_cpu_physical_apicid); 1352 phys_cpu_present_map = physid_mask_of_physid(boot_cpu_physical_apicid);
1345 1353
1346 setup_local_APIC(); 1354 setup_local_APIC();
diff --git a/arch/i386/kernel/syscall_table.S b/arch/i386/kernel/syscall_table.S
index f48bef15b4f0..af56987f69b0 100644
--- a/arch/i386/kernel/syscall_table.S
+++ b/arch/i386/kernel/syscall_table.S
@@ -315,3 +315,4 @@ ENTRY(sys_call_table)
315 .long sys_splice 315 .long sys_splice
316 .long sys_sync_file_range 316 .long sys_sync_file_range
317 .long sys_tee /* 315 */ 317 .long sys_tee /* 315 */
318 .long sys_vmsplice
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index 2d22f5761b1d..0e498369f35e 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -130,9 +130,8 @@ static inline int print_addr_and_symbol(unsigned long addr, char *log_lvl,
130 print_symbol("%s", addr); 130 print_symbol("%s", addr);
131 131
132 printed = (printed + 1) % CONFIG_STACK_BACKTRACE_COLS; 132 printed = (printed + 1) % CONFIG_STACK_BACKTRACE_COLS;
133
134 if (printed) 133 if (printed)
135 printk(" "); 134 printk(" ");
136 else 135 else
137 printk("\n"); 136 printk("\n");
138 137
@@ -212,7 +211,6 @@ static void show_stack_log_lvl(struct task_struct *task, unsigned long *esp,
212 } 211 }
213 212
214 stack = esp; 213 stack = esp;
215 printk(log_lvl);
216 for(i = 0; i < kstack_depth_to_print; i++) { 214 for(i = 0; i < kstack_depth_to_print; i++) {
217 if (kstack_end(stack)) 215 if (kstack_end(stack))
218 break; 216 break;
diff --git a/arch/i386/mach-generic/probe.c b/arch/i386/mach-generic/probe.c
index cea5b3ce4b57..d55fa7b187ab 100644
--- a/arch/i386/mach-generic/probe.c
+++ b/arch/i386/mach-generic/probe.c
@@ -93,9 +93,11 @@ int __init mps_oem_check(struct mp_config_table *mpc, char *oem, char *productid
93 int i; 93 int i;
94 for (i = 0; apic_probe[i]; ++i) { 94 for (i = 0; apic_probe[i]; ++i) {
95 if (apic_probe[i]->mps_oem_check(mpc,oem,productid)) { 95 if (apic_probe[i]->mps_oem_check(mpc,oem,productid)) {
96 genapic = apic_probe[i]; 96 if (!cmdline_apic) {
97 printk(KERN_INFO "Switched to APIC driver `%s'.\n", 97 genapic = apic_probe[i];
98 genapic->name); 98 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
99 genapic->name);
100 }
99 return 1; 101 return 1;
100 } 102 }
101 } 103 }
@@ -107,9 +109,11 @@ int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
107 int i; 109 int i;
108 for (i = 0; apic_probe[i]; ++i) { 110 for (i = 0; apic_probe[i]; ++i) {
109 if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) { 111 if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
110 genapic = apic_probe[i]; 112 if (!cmdline_apic) {
111 printk(KERN_INFO "Switched to APIC driver `%s'.\n", 113 genapic = apic_probe[i];
112 genapic->name); 114 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
115 genapic->name);
116 }
113 return 1; 117 return 1;
114 } 118 }
115 } 119 }
diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c
index ae6534ad8161..3df1371d4520 100644
--- a/arch/i386/mm/init.c
+++ b/arch/i386/mm/init.c
@@ -651,7 +651,7 @@ void __init mem_init(void)
651 * Specifically, in the case of x86, we will always add 651 * Specifically, in the case of x86, we will always add
652 * memory to the highmem for now. 652 * memory to the highmem for now.
653 */ 653 */
654#ifdef CONFIG_HOTPLUG_MEMORY 654#ifdef CONFIG_MEMORY_HOTPLUG
655#ifndef CONFIG_NEED_MULTIPLE_NODES 655#ifndef CONFIG_NEED_MULTIPLE_NODES
656int add_memory(u64 start, u64 size) 656int add_memory(u64 start, u64 size)
657{ 657{
diff --git a/arch/i386/power/cpu.c b/arch/i386/power/cpu.c
index 50a0bef8c85f..79b2370c7fac 100644
--- a/arch/i386/power/cpu.c
+++ b/arch/i386/power/cpu.c
@@ -92,7 +92,7 @@ void __restore_processor_state(struct saved_context *ctxt)
92 write_cr4(ctxt->cr4); 92 write_cr4(ctxt->cr4);
93 write_cr3(ctxt->cr3); 93 write_cr3(ctxt->cr3);
94 write_cr2(ctxt->cr2); 94 write_cr2(ctxt->cr2);
95 write_cr2(ctxt->cr0); 95 write_cr0(ctxt->cr0);
96 96
97 /* 97 /*
98 * now restore the descriptor tables to their proper values 98 * now restore the descriptor tables to their proper values
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index ee5fbb02b28f..e8ff09fe73d9 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -13,7 +13,7 @@ choice
13 default SGI_IP22 13 default SGI_IP22
14 14
15config MIPS_MTX1 15config MIPS_MTX1
16 bool "Support for 4G Systems MTX-1 board" 16 bool "4G Systems MTX-1 board"
17 select DMA_NONCOHERENT 17 select DMA_NONCOHERENT
18 select HW_HAS_PCI 18 select HW_HAS_PCI
19 select SOC_AU1500 19 select SOC_AU1500
@@ -120,7 +120,7 @@ config MIPS_MIRAGE
120 select SYS_SUPPORTS_LITTLE_ENDIAN 120 select SYS_SUPPORTS_LITTLE_ENDIAN
121 121
122config MIPS_COBALT 122config MIPS_COBALT
123 bool "Support for Cobalt Server" 123 bool "Cobalt Server"
124 select DMA_NONCOHERENT 124 select DMA_NONCOHERENT
125 select HW_HAS_PCI 125 select HW_HAS_PCI
126 select I8259 126 select I8259
@@ -132,7 +132,7 @@ config MIPS_COBALT
132 select SYS_SUPPORTS_LITTLE_ENDIAN 132 select SYS_SUPPORTS_LITTLE_ENDIAN
133 133
134config MACH_DECSTATION 134config MACH_DECSTATION
135 bool "Support for DECstations" 135 bool "DECstations"
136 select BOOT_ELF32 136 select BOOT_ELF32
137 select DMA_NONCOHERENT 137 select DMA_NONCOHERENT
138 select EARLY_PRINTK 138 select EARLY_PRINTK
@@ -158,7 +158,7 @@ config MACH_DECSTATION
158 otherwise choose R3000. 158 otherwise choose R3000.
159 159
160config MIPS_EV64120 160config MIPS_EV64120
161 bool "Support for Galileo EV64120 Evaluation board (EXPERIMENTAL)" 161 bool "Galileo EV64120 Evaluation board (EXPERIMENTAL)"
162 depends on EXPERIMENTAL 162 depends on EXPERIMENTAL
163 select DMA_NONCOHERENT 163 select DMA_NONCOHERENT
164 select HW_HAS_PCI 164 select HW_HAS_PCI
@@ -175,7 +175,7 @@ config MIPS_EV64120
175 kernel for this platform. 175 kernel for this platform.
176 176
177config MIPS_EV96100 177config MIPS_EV96100
178 bool "Support for Galileo EV96100 Evaluation board (EXPERIMENTAL)" 178 bool "Galileo EV96100 Evaluation board (EXPERIMENTAL)"
179 depends on EXPERIMENTAL 179 depends on EXPERIMENTAL
180 select DMA_NONCOHERENT 180 select DMA_NONCOHERENT
181 select HW_HAS_PCI 181 select HW_HAS_PCI
@@ -195,7 +195,7 @@ config MIPS_EV96100
195 here if you wish to build a kernel for this platform. 195 here if you wish to build a kernel for this platform.
196 196
197config MIPS_IVR 197config MIPS_IVR
198 bool "Support for Globespan IVR board" 198 bool "Globespan IVR board"
199 select DMA_NONCOHERENT 199 select DMA_NONCOHERENT
200 select HW_HAS_PCI 200 select HW_HAS_PCI
201 select ITE_BOARD_GEN 201 select ITE_BOARD_GEN
@@ -211,7 +211,7 @@ config MIPS_IVR
211 build a kernel for this platform. 211 build a kernel for this platform.
212 212
213config MIPS_ITE8172 213config MIPS_ITE8172
214 bool "Support for ITE 8172G board" 214 bool "ITE 8172G board"
215 select DMA_NONCOHERENT 215 select DMA_NONCOHERENT
216 select HW_HAS_PCI 216 select HW_HAS_PCI
217 select ITE_BOARD_GEN 217 select ITE_BOARD_GEN
@@ -228,7 +228,7 @@ config MIPS_ITE8172
228 a kernel for this platform. 228 a kernel for this platform.
229 229
230config MACH_JAZZ 230config MACH_JAZZ
231 bool "Support for the Jazz family of machines" 231 bool "Jazz family of machines"
232 select ARC 232 select ARC
233 select ARC32 233 select ARC32
234 select ARCH_MAY_HAVE_PC_FDC 234 select ARCH_MAY_HAVE_PC_FDC
@@ -246,7 +246,7 @@ config MACH_JAZZ
246 Olivetti M700-10 workstations. 246 Olivetti M700-10 workstations.
247 247
248config LASAT 248config LASAT
249 bool "Support for LASAT Networks platforms" 249 bool "LASAT Networks platforms"
250 select DMA_NONCOHERENT 250 select DMA_NONCOHERENT
251 select HW_HAS_PCI 251 select HW_HAS_PCI
252 select MIPS_GT64120 252 select MIPS_GT64120
@@ -258,7 +258,7 @@ config LASAT
258 select SYS_SUPPORTS_LITTLE_ENDIAN 258 select SYS_SUPPORTS_LITTLE_ENDIAN
259 259
260config MIPS_ATLAS 260config MIPS_ATLAS
261 bool "Support for MIPS Atlas board" 261 bool "MIPS Atlas board"
262 select BOOT_ELF32 262 select BOOT_ELF32
263 select DMA_NONCOHERENT 263 select DMA_NONCOHERENT
264 select IRQ_CPU 264 select IRQ_CPU
@@ -283,7 +283,7 @@ config MIPS_ATLAS
283 board. 283 board.
284 284
285config MIPS_MALTA 285config MIPS_MALTA
286 bool "Support for MIPS Malta board" 286 bool "MIPS Malta board"
287 select ARCH_MAY_HAVE_PC_FDC 287 select ARCH_MAY_HAVE_PC_FDC
288 select BOOT_ELF32 288 select BOOT_ELF32
289 select HAVE_STD_PC_SERIAL_PORT 289 select HAVE_STD_PC_SERIAL_PORT
@@ -311,7 +311,7 @@ config MIPS_MALTA
311 board. 311 board.
312 312
313config MIPS_SEAD 313config MIPS_SEAD
314 bool "Support for MIPS SEAD board (EXPERIMENTAL)" 314 bool "MIPS SEAD board (EXPERIMENTAL)"
315 depends on EXPERIMENTAL 315 depends on EXPERIMENTAL
316 select IRQ_CPU 316 select IRQ_CPU
317 select DMA_NONCOHERENT 317 select DMA_NONCOHERENT
@@ -328,7 +328,7 @@ config MIPS_SEAD
328 board. 328 board.
329 329
330config MIPS_SIM 330config MIPS_SIM
331 bool 'Support for MIPS simulator (MIPSsim)' 331 bool 'MIPS simulator (MIPSsim)'
332 select DMA_NONCOHERENT 332 select DMA_NONCOHERENT
333 select IRQ_CPU 333 select IRQ_CPU
334 select SYS_HAS_CPU_MIPS32_R1 334 select SYS_HAS_CPU_MIPS32_R1
@@ -341,7 +341,7 @@ config MIPS_SIM
341 emulator. 341 emulator.
342 342
343config MOMENCO_JAGUAR_ATX 343config MOMENCO_JAGUAR_ATX
344 bool "Support for Momentum Jaguar board" 344 bool "Momentum Jaguar board"
345 select BOOT_ELF32 345 select BOOT_ELF32
346 select DMA_NONCOHERENT 346 select DMA_NONCOHERENT
347 select HW_HAS_PCI 347 select HW_HAS_PCI
@@ -361,7 +361,7 @@ config MOMENCO_JAGUAR_ATX
361 Momentum Computer <http://www.momenco.com/>. 361 Momentum Computer <http://www.momenco.com/>.
362 362
363config MOMENCO_OCELOT 363config MOMENCO_OCELOT
364 bool "Support for Momentum Ocelot board" 364 bool "Momentum Ocelot board"
365 select DMA_NONCOHERENT 365 select DMA_NONCOHERENT
366 select HW_HAS_PCI 366 select HW_HAS_PCI
367 select IRQ_CPU 367 select IRQ_CPU
@@ -378,7 +378,7 @@ config MOMENCO_OCELOT
378 Momentum Computer <http://www.momenco.com/>. 378 Momentum Computer <http://www.momenco.com/>.
379 379
380config MOMENCO_OCELOT_3 380config MOMENCO_OCELOT_3
381 bool "Support for Momentum Ocelot-3 board" 381 bool "Momentum Ocelot-3 board"
382 select BOOT_ELF32 382 select BOOT_ELF32
383 select DMA_NONCOHERENT 383 select DMA_NONCOHERENT
384 select HW_HAS_PCI 384 select HW_HAS_PCI
@@ -397,7 +397,7 @@ config MOMENCO_OCELOT_3
397 PMC-Sierra Rm79000 core. 397 PMC-Sierra Rm79000 core.
398 398
399config MOMENCO_OCELOT_C 399config MOMENCO_OCELOT_C
400 bool "Support for Momentum Ocelot-C board" 400 bool "Momentum Ocelot-C board"
401 select DMA_NONCOHERENT 401 select DMA_NONCOHERENT
402 select HW_HAS_PCI 402 select HW_HAS_PCI
403 select IRQ_CPU 403 select IRQ_CPU
@@ -414,7 +414,7 @@ config MOMENCO_OCELOT_C
414 Momentum Computer <http://www.momenco.com/>. 414 Momentum Computer <http://www.momenco.com/>.
415 415
416config MOMENCO_OCELOT_G 416config MOMENCO_OCELOT_G
417 bool "Support for Momentum Ocelot-G board" 417 bool "Momentum Ocelot-G board"
418 select DMA_NONCOHERENT 418 select DMA_NONCOHERENT
419 select HW_HAS_PCI 419 select HW_HAS_PCI
420 select IRQ_CPU 420 select IRQ_CPU
@@ -431,23 +431,23 @@ config MOMENCO_OCELOT_G
431 Momentum Computer <http://www.momenco.com/>. 431 Momentum Computer <http://www.momenco.com/>.
432 432
433config MIPS_XXS1500 433config MIPS_XXS1500
434 bool "Support for MyCable XXS1500 board" 434 bool "MyCable XXS1500 board"
435 select DMA_NONCOHERENT 435 select DMA_NONCOHERENT
436 select SOC_AU1500 436 select SOC_AU1500
437 select SYS_SUPPORTS_LITTLE_ENDIAN 437 select SYS_SUPPORTS_LITTLE_ENDIAN
438 438
439config PNX8550_V2PCI 439config PNX8550_V2PCI
440 bool "Support for Philips PNX8550 based Viper2-PCI board" 440 bool "Philips PNX8550 based Viper2-PCI board"
441 select PNX8550 441 select PNX8550
442 select SYS_SUPPORTS_LITTLE_ENDIAN 442 select SYS_SUPPORTS_LITTLE_ENDIAN
443 443
444config PNX8550_JBS 444config PNX8550_JBS
445 bool "Support for Philips PNX8550 based JBS board" 445 bool "Philips PNX8550 based JBS board"
446 select PNX8550 446 select PNX8550
447 select SYS_SUPPORTS_LITTLE_ENDIAN 447 select SYS_SUPPORTS_LITTLE_ENDIAN
448 448
449config DDB5074 449config DDB5074
450 bool "Support for NEC DDB Vrc-5074 (EXPERIMENTAL)" 450 bool "NEC DDB Vrc-5074 (EXPERIMENTAL)"
451 depends on EXPERIMENTAL 451 depends on EXPERIMENTAL
452 select DDB5XXX_COMMON 452 select DDB5XXX_COMMON
453 select DMA_NONCOHERENT 453 select DMA_NONCOHERENT
@@ -465,7 +465,7 @@ config DDB5074
465 evaluation board. 465 evaluation board.
466 466
467config DDB5476 467config DDB5476
468 bool "Support for NEC DDB Vrc-5476" 468 bool "NEC DDB Vrc-5476"
469 select DDB5XXX_COMMON 469 select DDB5XXX_COMMON
470 select DMA_NONCOHERENT 470 select DMA_NONCOHERENT
471 select HAVE_STD_PC_SERIAL_PORT 471 select HAVE_STD_PC_SERIAL_PORT
@@ -486,7 +486,7 @@ config DDB5476
486 IDE controller, PS2 keyboard, PS2 mouse, etc. 486 IDE controller, PS2 keyboard, PS2 mouse, etc.
487 487
488config DDB5477 488config DDB5477
489 bool "Support for NEC DDB Vrc-5477" 489 bool "NEC DDB Vrc-5477"
490 select DDB5XXX_COMMON 490 select DDB5XXX_COMMON
491 select DMA_NONCOHERENT 491 select DMA_NONCOHERENT
492 select HW_HAS_PCI 492 select HW_HAS_PCI
@@ -504,13 +504,13 @@ config DDB5477
504 ether port USB, AC97, PCI, etc. 504 ether port USB, AC97, PCI, etc.
505 505
506config MACH_VR41XX 506config MACH_VR41XX
507 bool "Support for NEC VR4100 series based machines" 507 bool "NEC VR41XX-based machines"
508 select SYS_HAS_CPU_VR41XX 508 select SYS_HAS_CPU_VR41XX
509 select SYS_SUPPORTS_32BIT_KERNEL 509 select SYS_SUPPORTS_32BIT_KERNEL
510 select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL 510 select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
511 511
512config PMC_YOSEMITE 512config PMC_YOSEMITE
513 bool "Support for PMC-Sierra Yosemite eval board" 513 bool "PMC-Sierra Yosemite eval board"
514 select DMA_COHERENT 514 select DMA_COHERENT
515 select HW_HAS_PCI 515 select HW_HAS_PCI
516 select IRQ_CPU 516 select IRQ_CPU
@@ -527,7 +527,7 @@ config PMC_YOSEMITE
527 manufactured by PMC-Sierra. 527 manufactured by PMC-Sierra.
528 528
529config QEMU 529config QEMU
530 bool "Support for Qemu" 530 bool "Qemu"
531 select DMA_COHERENT 531 select DMA_COHERENT
532 select GENERIC_ISA_DMA 532 select GENERIC_ISA_DMA
533 select HAVE_STD_PC_SERIAL_PORT 533 select HAVE_STD_PC_SERIAL_PORT
@@ -547,7 +547,7 @@ config QEMU
547 can be found at http://www.linux-mips.org/wiki/Qemu. 547 can be found at http://www.linux-mips.org/wiki/Qemu.
548 548
549config SGI_IP22 549config SGI_IP22
550 bool "Support for SGI IP22 (Indy/Indigo2)" 550 bool "SGI IP22 (Indy/Indigo2)"
551 select ARC 551 select ARC
552 select ARC32 552 select ARC32
553 select BOOT_ELF32 553 select BOOT_ELF32
@@ -567,7 +567,7 @@ config SGI_IP22
567 that runs on these, say Y here. 567 that runs on these, say Y here.
568 568
569config SGI_IP27 569config SGI_IP27
570 bool "Support for SGI IP27 (Origin200/2000)" 570 bool "SGI IP27 (Origin200/2000)"
571 select ARC 571 select ARC
572 select ARC64 572 select ARC64
573 select BOOT_ELF64 573 select BOOT_ELF64
@@ -583,7 +583,7 @@ config SGI_IP27
583 here. 583 here.
584 584
585config SGI_IP32 585config SGI_IP32
586 bool "Support for SGI IP32 (O2) (EXPERIMENTAL)" 586 bool "SGI IP32 (O2) (EXPERIMENTAL)"
587 depends on EXPERIMENTAL 587 depends on EXPERIMENTAL
588 select ARC 588 select ARC
589 select ARC32 589 select ARC32
@@ -604,7 +604,7 @@ config SGI_IP32
604 If you want this kernel to run on SGI O2 workstation, say Y here. 604 If you want this kernel to run on SGI O2 workstation, say Y here.
605 605
606config SIBYTE_BIGSUR 606config SIBYTE_BIGSUR
607 bool "Support for Sibyte BCM91480B-BigSur" 607 bool "Sibyte BCM91480B-BigSur"
608 select BOOT_ELF32 608 select BOOT_ELF32
609 select DMA_COHERENT 609 select DMA_COHERENT
610 select PCI_DOMAINS 610 select PCI_DOMAINS
@@ -615,7 +615,7 @@ config SIBYTE_BIGSUR
615 select SYS_SUPPORTS_LITTLE_ENDIAN 615 select SYS_SUPPORTS_LITTLE_ENDIAN
616 616
617config SIBYTE_SWARM 617config SIBYTE_SWARM
618 bool "Support for Sibyte BCM91250A-SWARM" 618 bool "Sibyte BCM91250A-SWARM"
619 select BOOT_ELF32 619 select BOOT_ELF32
620 select DMA_COHERENT 620 select DMA_COHERENT
621 select SIBYTE_SB1250 621 select SIBYTE_SB1250
@@ -626,7 +626,7 @@ config SIBYTE_SWARM
626 select SYS_SUPPORTS_LITTLE_ENDIAN 626 select SYS_SUPPORTS_LITTLE_ENDIAN
627 627
628config SIBYTE_SENTOSA 628config SIBYTE_SENTOSA
629 bool "Support for Sibyte BCM91250E-Sentosa" 629 bool "Sibyte BCM91250E-Sentosa"
630 depends on EXPERIMENTAL 630 depends on EXPERIMENTAL
631 select BOOT_ELF32 631 select BOOT_ELF32
632 select DMA_COHERENT 632 select DMA_COHERENT
@@ -637,7 +637,7 @@ config SIBYTE_SENTOSA
637 select SYS_SUPPORTS_LITTLE_ENDIAN 637 select SYS_SUPPORTS_LITTLE_ENDIAN
638 638
639config SIBYTE_RHONE 639config SIBYTE_RHONE
640 bool "Support for Sibyte BCM91125E-Rhone" 640 bool "Sibyte BCM91125E-Rhone"
641 depends on EXPERIMENTAL 641 depends on EXPERIMENTAL
642 select BOOT_ELF32 642 select BOOT_ELF32
643 select DMA_COHERENT 643 select DMA_COHERENT
@@ -648,7 +648,7 @@ config SIBYTE_RHONE
648 select SYS_SUPPORTS_LITTLE_ENDIAN 648 select SYS_SUPPORTS_LITTLE_ENDIAN
649 649
650config SIBYTE_CARMEL 650config SIBYTE_CARMEL
651 bool "Support for Sibyte BCM91120x-Carmel" 651 bool "Sibyte BCM91120x-Carmel"
652 depends on EXPERIMENTAL 652 depends on EXPERIMENTAL
653 select BOOT_ELF32 653 select BOOT_ELF32
654 select DMA_COHERENT 654 select DMA_COHERENT
@@ -659,7 +659,7 @@ config SIBYTE_CARMEL
659 select SYS_SUPPORTS_LITTLE_ENDIAN 659 select SYS_SUPPORTS_LITTLE_ENDIAN
660 660
661config SIBYTE_PTSWARM 661config SIBYTE_PTSWARM
662 bool "Support for Sibyte BCM91250PT-PTSWARM" 662 bool "Sibyte BCM91250PT-PTSWARM"
663 depends on EXPERIMENTAL 663 depends on EXPERIMENTAL
664 select BOOT_ELF32 664 select BOOT_ELF32
665 select DMA_COHERENT 665 select DMA_COHERENT
@@ -671,7 +671,7 @@ config SIBYTE_PTSWARM
671 select SYS_SUPPORTS_LITTLE_ENDIAN 671 select SYS_SUPPORTS_LITTLE_ENDIAN
672 672
673config SIBYTE_LITTLESUR 673config SIBYTE_LITTLESUR
674 bool "Support for Sibyte BCM91250C2-LittleSur" 674 bool "Sibyte BCM91250C2-LittleSur"
675 depends on EXPERIMENTAL 675 depends on EXPERIMENTAL
676 select BOOT_ELF32 676 select BOOT_ELF32
677 select DMA_COHERENT 677 select DMA_COHERENT
@@ -683,7 +683,7 @@ config SIBYTE_LITTLESUR
683 select SYS_SUPPORTS_LITTLE_ENDIAN 683 select SYS_SUPPORTS_LITTLE_ENDIAN
684 684
685config SIBYTE_CRHINE 685config SIBYTE_CRHINE
686 bool "Support for Sibyte BCM91120C-CRhine" 686 bool "Sibyte BCM91120C-CRhine"
687 depends on EXPERIMENTAL 687 depends on EXPERIMENTAL
688 select BOOT_ELF32 688 select BOOT_ELF32
689 select DMA_COHERENT 689 select DMA_COHERENT
@@ -694,7 +694,7 @@ config SIBYTE_CRHINE
694 select SYS_SUPPORTS_LITTLE_ENDIAN 694 select SYS_SUPPORTS_LITTLE_ENDIAN
695 695
696config SIBYTE_CRHONE 696config SIBYTE_CRHONE
697 bool "Support for Sibyte BCM91125C-CRhone" 697 bool "Sibyte BCM91125C-CRhone"
698 depends on EXPERIMENTAL 698 depends on EXPERIMENTAL
699 select BOOT_ELF32 699 select BOOT_ELF32
700 select DMA_COHERENT 700 select DMA_COHERENT
@@ -706,7 +706,7 @@ config SIBYTE_CRHONE
706 select SYS_SUPPORTS_LITTLE_ENDIAN 706 select SYS_SUPPORTS_LITTLE_ENDIAN
707 707
708config SNI_RM200_PCI 708config SNI_RM200_PCI
709 bool "Support for SNI RM200 PCI" 709 bool "SNI RM200 PCI"
710 select ARC 710 select ARC
711 select ARC32 711 select ARC32
712 select ARCH_MAY_HAVE_PC_FDC 712 select ARCH_MAY_HAVE_PC_FDC
@@ -732,7 +732,7 @@ config SNI_RM200_PCI
732 support this machine type. 732 support this machine type.
733 733
734config TOSHIBA_JMR3927 734config TOSHIBA_JMR3927
735 bool "Support for Toshiba JMR-TX3927 board" 735 bool "Toshiba JMR-TX3927 board"
736 select DMA_NONCOHERENT 736 select DMA_NONCOHERENT
737 select HW_HAS_PCI 737 select HW_HAS_PCI
738 select MIPS_TX3927 738 select MIPS_TX3927
@@ -743,7 +743,7 @@ config TOSHIBA_JMR3927
743 select TOSHIBA_BOARDS 743 select TOSHIBA_BOARDS
744 744
745config TOSHIBA_RBTX4927 745config TOSHIBA_RBTX4927
746 bool "Support for Toshiba TBTX49[23]7 board" 746 bool "Toshiba TBTX49[23]7 board"
747 select DMA_NONCOHERENT 747 select DMA_NONCOHERENT
748 select HAS_TXX9_SERIAL 748 select HAS_TXX9_SERIAL
749 select HW_HAS_PCI 749 select HW_HAS_PCI
@@ -760,7 +760,7 @@ config TOSHIBA_RBTX4927
760 support this machine type 760 support this machine type
761 761
762config TOSHIBA_RBTX4938 762config TOSHIBA_RBTX4938
763 bool "Support for Toshiba RBTX4938 board" 763 bool "Toshiba RBTX4938 board"
764 select HAVE_STD_PC_SERIAL_PORT 764 select HAVE_STD_PC_SERIAL_PORT
765 select DMA_NONCOHERENT 765 select DMA_NONCOHERENT
766 select GENERIC_ISA_DMA 766 select GENERIC_ISA_DMA
@@ -1411,13 +1411,12 @@ config PAGE_SIZE_8KB
1411 1411
1412config PAGE_SIZE_16KB 1412config PAGE_SIZE_16KB
1413 bool "16kB" 1413 bool "16kB"
1414 depends on EXPERIMENTAL && !CPU_R3000 && !CPU_TX39XX 1414 depends on !CPU_R3000 && !CPU_TX39XX
1415 help 1415 help
1416 Using 16kB page size will result in higher performance kernel at 1416 Using 16kB page size will result in higher performance kernel at
1417 the price of higher memory consumption. This option is available on 1417 the price of higher memory consumption. This option is available on
1418 all non-R3000 family processor. Not that at the time of this 1418 all non-R3000 family processors. Note that you will need a suitable
1419 writing this option is still high experimental; there are also 1419 Linux distribution to support this.
1420 issues with compatibility of user applications.
1421 1420
1422config PAGE_SIZE_64KB 1421config PAGE_SIZE_64KB
1423 bool "64kB" 1422 bool "64kB"
@@ -1426,8 +1425,7 @@ config PAGE_SIZE_64KB
1426 Using 64kB page size will result in higher performance kernel at 1425 Using 64kB page size will result in higher performance kernel at
1427 the price of higher memory consumption. This option is available on 1426 the price of higher memory consumption. This option is available on
1428 all non-R3000 family processor. Not that at the time of this 1427 all non-R3000 family processor. Not that at the time of this
1429 writing this option is still high experimental; there are also 1428 writing this option is still high experimental.
1430 issues with compatibility of user applications.
1431 1429
1432endchoice 1430endchoice
1433 1431
diff --git a/arch/mips/au1000/common/irq.c b/arch/mips/au1000/common/irq.c
index da61de776154..afe05ec12c27 100644
--- a/arch/mips/au1000/common/irq.c
+++ b/arch/mips/au1000/common/irq.c
@@ -68,6 +68,7 @@
68 68
69extern void set_debug_traps(void); 69extern void set_debug_traps(void);
70extern irq_cpustat_t irq_stat [NR_CPUS]; 70extern irq_cpustat_t irq_stat [NR_CPUS];
71extern void mips_timer_interrupt(struct pt_regs *regs);
71 72
72static void setup_local_irq(unsigned int irq, int type, int int_req); 73static void setup_local_irq(unsigned int irq, int type, int int_req);
73static unsigned int startup_irq(unsigned int irq); 74static unsigned int startup_irq(unsigned int irq);
diff --git a/arch/mips/au1000/common/time.c b/arch/mips/au1000/common/time.c
index f85f1524b366..f74d66a58a21 100644
--- a/arch/mips/au1000/common/time.c
+++ b/arch/mips/au1000/common/time.c
@@ -116,6 +116,7 @@ void mips_timer_interrupt(struct pt_regs *regs)
116 116
117null: 117null:
118 ack_r4ktimer(0); 118 ack_r4ktimer(0);
119 irq_exit();
119} 120}
120 121
121#ifdef CONFIG_PM 122#ifdef CONFIG_PM
diff --git a/arch/mips/kernel/asm-offsets.c b/arch/mips/kernel/asm-offsets.c
index 92b28b674d6f..0facfaf4e950 100644
--- a/arch/mips/kernel/asm-offsets.c
+++ b/arch/mips/kernel/asm-offsets.c
@@ -272,8 +272,8 @@ void output_sc_defines(void)
272 text("/* Linux sigcontext offsets. */"); 272 text("/* Linux sigcontext offsets. */");
273 offset("#define SC_REGS ", struct sigcontext, sc_regs); 273 offset("#define SC_REGS ", struct sigcontext, sc_regs);
274 offset("#define SC_FPREGS ", struct sigcontext, sc_fpregs); 274 offset("#define SC_FPREGS ", struct sigcontext, sc_fpregs);
275 offset("#define SC_MDHI ", struct sigcontext, sc_hi); 275 offset("#define SC_MDHI ", struct sigcontext, sc_mdhi);
276 offset("#define SC_MDLO ", struct sigcontext, sc_lo); 276 offset("#define SC_MDLO ", struct sigcontext, sc_mdlo);
277 offset("#define SC_PC ", struct sigcontext, sc_pc); 277 offset("#define SC_PC ", struct sigcontext, sc_pc);
278 offset("#define SC_FPC_CSR ", struct sigcontext, sc_fpc_csr); 278 offset("#define SC_FPC_CSR ", struct sigcontext, sc_fpc_csr);
279 linefeed; 279 linefeed;
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index 58b3b14873cb..bef3e2dc7c52 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -121,6 +121,7 @@ static inline void check_wait(void)
121 case CPU_24K: 121 case CPU_24K:
122 case CPU_25KF: 122 case CPU_25KF:
123 case CPU_34K: 123 case CPU_34K:
124 case CPU_74K:
124 case CPU_PR4450: 125 case CPU_PR4450:
125 cpu_wait = r4k_wait; 126 cpu_wait = r4k_wait;
126 printk(" available.\n"); 127 printk(" available.\n");
@@ -432,6 +433,15 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c)
432 MIPS_CPU_LLSC; 433 MIPS_CPU_LLSC;
433 c->tlbsize = 64; 434 c->tlbsize = 64;
434 break; 435 break;
436 case PRID_IMP_R14000:
437 c->cputype = CPU_R14000;
438 c->isa_level = MIPS_CPU_ISA_IV;
439 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
440 MIPS_CPU_FPU | MIPS_CPU_32FPR |
441 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
442 MIPS_CPU_LLSC;
443 c->tlbsize = 64;
444 break;
435 } 445 }
436} 446}
437 447
@@ -593,6 +603,9 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c)
593 case PRID_IMP_34K: 603 case PRID_IMP_34K:
594 c->cputype = CPU_34K; 604 c->cputype = CPU_34K;
595 break; 605 break;
606 case PRID_IMP_74K:
607 c->cputype = CPU_74K;
608 break;
596 } 609 }
597} 610}
598 611
diff --git a/arch/mips/kernel/entry.S b/arch/mips/kernel/entry.S
index d101d2fb24ca..a9c6de1b9542 100644
--- a/arch/mips/kernel/entry.S
+++ b/arch/mips/kernel/entry.S
@@ -101,7 +101,7 @@ FEXPORT(restore_all) # restore full frame
101 EMT 101 EMT
1021: 1021:
103 mfc0 v1, CP0_TCSTATUS 103 mfc0 v1, CP0_TCSTATUS
104 /* We set IXMT above, XOR should cler it here */ 104 /* We set IXMT above, XOR should clear it here */
105 xori v1, v1, TCSTATUS_IXMT 105 xori v1, v1, TCSTATUS_IXMT
106 or v1, v0, v1 106 or v1, v0, v1
107 mtc0 v1, CP0_TCSTATUS 107 mtc0 v1, CP0_TCSTATUS
diff --git a/arch/mips/kernel/gdb-low.S b/arch/mips/kernel/gdb-low.S
index 10f28fb9f008..5fd7a8af0c62 100644
--- a/arch/mips/kernel/gdb-low.S
+++ b/arch/mips/kernel/gdb-low.S
@@ -54,9 +54,11 @@
54 */ 54 */
55 mfc0 k0, CP0_CAUSE 55 mfc0 k0, CP0_CAUSE
56 andi k0, k0, 0x7c 56 andi k0, k0, 0x7c
57 add k1, k1, k0 57#ifdef CONFIG_64BIT
58 PTR_L k0, saved_vectors(k1) 58 dsll k0, k0, 1
59 jr k0 59#endif
60 PTR_L k1, saved_vectors(k0)
61 jr k1
60 nop 62 nop
611: 631:
62 move k0, sp 64 move k0, sp
diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c
index 84ab959f924a..9def554f335b 100644
--- a/arch/mips/kernel/proc.c
+++ b/arch/mips/kernel/proc.c
@@ -42,6 +42,7 @@ static const char *cpu_name[] = {
42 [CPU_R8000] = "R8000", 42 [CPU_R8000] = "R8000",
43 [CPU_R10000] = "R10000", 43 [CPU_R10000] = "R10000",
44 [CPU_R12000] = "R12000", 44 [CPU_R12000] = "R12000",
45 [CPU_R14000] = "R14000",
45 [CPU_R4300] = "R4300", 46 [CPU_R4300] = "R4300",
46 [CPU_R4650] = "R4650", 47 [CPU_R4650] = "R4650",
47 [CPU_R4700] = "R4700", 48 [CPU_R4700] = "R4700",
@@ -74,6 +75,7 @@ static const char *cpu_name[] = {
74 [CPU_24K] = "MIPS 24K", 75 [CPU_24K] = "MIPS 24K",
75 [CPU_25KF] = "MIPS 25Kf", 76 [CPU_25KF] = "MIPS 25Kf",
76 [CPU_34K] = "MIPS 34K", 77 [CPU_34K] = "MIPS 34K",
78 [CPU_74K] = "MIPS 74K",
77 [CPU_VR4111] = "NEC VR4111", 79 [CPU_VR4111] = "NEC VR4111",
78 [CPU_VR4121] = "NEC VR4121", 80 [CPU_VR4121] = "NEC VR4121",
79 [CPU_VR4122] = "NEC VR4122", 81 [CPU_VR4122] = "NEC VR4122",
diff --git a/arch/mips/kernel/signal-common.h b/arch/mips/kernel/signal-common.h
index 3ca786215d48..ce6cb915c0a7 100644
--- a/arch/mips/kernel/signal-common.h
+++ b/arch/mips/kernel/signal-common.h
@@ -31,7 +31,6 @@ setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
31 save_gp_reg(31); 31 save_gp_reg(31);
32#undef save_gp_reg 32#undef save_gp_reg
33 33
34#ifdef CONFIG_32BIT
35 err |= __put_user(regs->hi, &sc->sc_mdhi); 34 err |= __put_user(regs->hi, &sc->sc_mdhi);
36 err |= __put_user(regs->lo, &sc->sc_mdlo); 35 err |= __put_user(regs->lo, &sc->sc_mdlo);
37 if (cpu_has_dsp) { 36 if (cpu_has_dsp) {
@@ -43,20 +42,6 @@ setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
43 err |= __put_user(mflo3(), &sc->sc_lo3); 42 err |= __put_user(mflo3(), &sc->sc_lo3);
44 err |= __put_user(rddsp(DSP_MASK), &sc->sc_dsp); 43 err |= __put_user(rddsp(DSP_MASK), &sc->sc_dsp);
45 } 44 }
46#endif
47#ifdef CONFIG_64BIT
48 err |= __put_user(regs->hi, &sc->sc_hi[0]);
49 err |= __put_user(regs->lo, &sc->sc_lo[0]);
50 if (cpu_has_dsp) {
51 err |= __put_user(mfhi1(), &sc->sc_hi[1]);
52 err |= __put_user(mflo1(), &sc->sc_lo[1]);
53 err |= __put_user(mfhi2(), &sc->sc_hi[2]);
54 err |= __put_user(mflo2(), &sc->sc_lo[2]);
55 err |= __put_user(mfhi3(), &sc->sc_hi[3]);
56 err |= __put_user(mflo3(), &sc->sc_lo[3]);
57 err |= __put_user(rddsp(DSP_MASK), &sc->sc_dsp);
58 }
59#endif
60 45
61 err |= __put_user(!!used_math(), &sc->sc_used_math); 46 err |= __put_user(!!used_math(), &sc->sc_used_math);
62 47
@@ -92,7 +77,6 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
92 current_thread_info()->restart_block.fn = do_no_restart_syscall; 77 current_thread_info()->restart_block.fn = do_no_restart_syscall;
93 78
94 err |= __get_user(regs->cp0_epc, &sc->sc_pc); 79 err |= __get_user(regs->cp0_epc, &sc->sc_pc);
95#ifdef CONFIG_32BIT
96 err |= __get_user(regs->hi, &sc->sc_mdhi); 80 err |= __get_user(regs->hi, &sc->sc_mdhi);
97 err |= __get_user(regs->lo, &sc->sc_mdlo); 81 err |= __get_user(regs->lo, &sc->sc_mdlo);
98 if (cpu_has_dsp) { 82 if (cpu_has_dsp) {
@@ -104,20 +88,6 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
104 err |= __get_user(treg, &sc->sc_lo3); mtlo3(treg); 88 err |= __get_user(treg, &sc->sc_lo3); mtlo3(treg);
105 err |= __get_user(treg, &sc->sc_dsp); wrdsp(treg, DSP_MASK); 89 err |= __get_user(treg, &sc->sc_dsp); wrdsp(treg, DSP_MASK);
106 } 90 }
107#endif
108#ifdef CONFIG_64BIT
109 err |= __get_user(regs->hi, &sc->sc_hi[0]);
110 err |= __get_user(regs->lo, &sc->sc_lo[0]);
111 if (cpu_has_dsp) {
112 err |= __get_user(treg, &sc->sc_hi[1]); mthi1(treg);
113 err |= __get_user(treg, &sc->sc_lo[1]); mthi1(treg);
114 err |= __get_user(treg, &sc->sc_hi[2]); mthi2(treg);
115 err |= __get_user(treg, &sc->sc_lo[2]); mthi2(treg);
116 err |= __get_user(treg, &sc->sc_hi[3]); mthi3(treg);
117 err |= __get_user(treg, &sc->sc_lo[3]); mthi3(treg);
118 err |= __get_user(treg, &sc->sc_dsp); wrdsp(treg, DSP_MASK);
119 }
120#endif
121 91
122#define restore_gp_reg(i) do { \ 92#define restore_gp_reg(i) do { \
123 err |= __get_user(regs->regs[i], &sc->sc_regs[i]); \ 93 err |= __get_user(regs->regs[i], &sc->sc_regs[i]); \
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index 2aeaa2fd4b32..8f4fdd94dbd0 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -280,27 +280,6 @@ asmlinkage int _sys_sysmips(int cmd, long arg1, int arg2, int arg3)
280 char __user *name; 280 char __user *name;
281 281
282 switch(cmd) { 282 switch(cmd) {
283 case SETNAME: {
284 char nodename[__NEW_UTS_LEN + 1];
285
286 if (!capable(CAP_SYS_ADMIN))
287 return -EPERM;
288
289 name = (char __user *) arg1;
290
291 len = strncpy_from_user(nodename, name, __NEW_UTS_LEN);
292 if (len < 0)
293 return -EFAULT;
294
295 down_write(&uts_sem);
296 strncpy(system_utsname.nodename, nodename, len);
297 nodename[__NEW_UTS_LEN] = '\0';
298 strlcpy(system_utsname.nodename, nodename,
299 sizeof(system_utsname.nodename));
300 up_write(&uts_sem);
301 return 0;
302 }
303
304 case MIPS_ATOMIC_SET: 283 case MIPS_ATOMIC_SET:
305 printk(KERN_CRIT "How did I get here?\n"); 284 printk(KERN_CRIT "How did I get here?\n");
306 return -EINVAL; 285 return -EINVAL;
@@ -313,9 +292,6 @@ asmlinkage int _sys_sysmips(int cmd, long arg1, int arg2, int arg3)
313 case FLUSH_CACHE: 292 case FLUSH_CACHE:
314 __flush_cache_all(); 293 __flush_cache_all();
315 return 0; 294 return 0;
316
317 case MIPS_RDNVRAM:
318 return -EIO;
319 } 295 }
320 296
321 return -EINVAL; 297 return -EINVAL;
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 4901f0a37fca..35cb08da3820 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -902,6 +902,7 @@ static inline void parity_protection_init(void)
902{ 902{
903 switch (current_cpu_data.cputype) { 903 switch (current_cpu_data.cputype) {
904 case CPU_24K: 904 case CPU_24K:
905 case CPU_34K:
905 case CPU_5KC: 906 case CPU_5KC:
906 write_c0_ecc(0x80000000); 907 write_c0_ecc(0x80000000);
907 back_to_back_c0_hazard(); 908 back_to_back_c0_hazard();
diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
index 14fa00e3cdfa..b84d1f9ce28e 100644
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -151,23 +151,13 @@ SECTIONS
151 151
152 /* This is the MIPS specific mdebug section. */ 152 /* This is the MIPS specific mdebug section. */
153 .mdebug : { *(.mdebug) } 153 .mdebug : { *(.mdebug) }
154 /* These are needed for ELF backends which have not yet been 154
155 converted to the new style linker. */ 155 STABS_DEBUG
156 .stab 0 : { *(.stab) } 156
157 .stabstr 0 : { *(.stabstr) } 157 DWARF_DEBUG
158 /* DWARF debug sections. 158
159 Symbols in the .debug DWARF section are relative to the beginning of the
160 section so we begin .debug at 0. It's not clear yet what needs to happen
161 for the others. */
162 .debug 0 : { *(.debug) }
163 .debug_srcinfo 0 : { *(.debug_srcinfo) }
164 .debug_aranges 0 : { *(.debug_aranges) }
165 .debug_pubnames 0 : { *(.debug_pubnames) }
166 .debug_sfnames 0 : { *(.debug_sfnames) }
167 .line 0 : { *(.line) }
168 /* These must appear regardless of . */ 159 /* These must appear regardless of . */
169 .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } 160 .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
170 .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } 161 .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
171 .comment : { *(.comment) }
172 .note : { *(.note) } 162 .note : { *(.note) }
173} 163}
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index 4182e1176fae..6b3541769602 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -29,6 +29,27 @@
29#include <asm/war.h> 29#include <asm/war.h>
30#include <asm/cacheflush.h> /* for run_uncached() */ 30#include <asm/cacheflush.h> /* for run_uncached() */
31 31
32
33/*
34 * Special Variant of smp_call_function for use by cache functions:
35 *
36 * o No return value
37 * o collapses to normal function call on UP kernels
38 * o collapses to normal function call on systems with a single shared
39 * primary cache.
40 */
41static inline void r4k_on_each_cpu(void (*func) (void *info), void *info,
42 int retry, int wait)
43{
44 preempt_disable();
45
46#if !defined(CONFIG_MIPS_MT_SMP) && !defined(CONFIG_MIPS_MT_SMTC)
47 smp_call_function(func, info, retry, wait);
48#endif
49 func(info);
50 preempt_enable();
51}
52
32/* 53/*
33 * Must die. 54 * Must die.
34 */ 55 */
@@ -299,7 +320,7 @@ static void r4k_flush_cache_all(void)
299 if (!cpu_has_dc_aliases) 320 if (!cpu_has_dc_aliases)
300 return; 321 return;
301 322
302 on_each_cpu(local_r4k_flush_cache_all, NULL, 1, 1); 323 r4k_on_each_cpu(local_r4k_flush_cache_all, NULL, 1, 1);
303} 324}
304 325
305static inline void local_r4k___flush_cache_all(void * args) 326static inline void local_r4k___flush_cache_all(void * args)
@@ -314,13 +335,14 @@ static inline void local_r4k___flush_cache_all(void * args)
314 case CPU_R4400MC: 335 case CPU_R4400MC:
315 case CPU_R10000: 336 case CPU_R10000:
316 case CPU_R12000: 337 case CPU_R12000:
338 case CPU_R14000:
317 r4k_blast_scache(); 339 r4k_blast_scache();
318 } 340 }
319} 341}
320 342
321static void r4k___flush_cache_all(void) 343static void r4k___flush_cache_all(void)
322{ 344{
323 on_each_cpu(local_r4k___flush_cache_all, NULL, 1, 1); 345 r4k_on_each_cpu(local_r4k___flush_cache_all, NULL, 1, 1);
324} 346}
325 347
326static inline void local_r4k_flush_cache_range(void * args) 348static inline void local_r4k_flush_cache_range(void * args)
@@ -341,7 +363,7 @@ static inline void local_r4k_flush_cache_range(void * args)
341static void r4k_flush_cache_range(struct vm_area_struct *vma, 363static void r4k_flush_cache_range(struct vm_area_struct *vma,
342 unsigned long start, unsigned long end) 364 unsigned long start, unsigned long end)
343{ 365{
344 on_each_cpu(local_r4k_flush_cache_range, vma, 1, 1); 366 r4k_on_each_cpu(local_r4k_flush_cache_range, vma, 1, 1);
345} 367}
346 368
347static inline void local_r4k_flush_cache_mm(void * args) 369static inline void local_r4k_flush_cache_mm(void * args)
@@ -370,7 +392,7 @@ static void r4k_flush_cache_mm(struct mm_struct *mm)
370 if (!cpu_has_dc_aliases) 392 if (!cpu_has_dc_aliases)
371 return; 393 return;
372 394
373 on_each_cpu(local_r4k_flush_cache_mm, mm, 1, 1); 395 r4k_on_each_cpu(local_r4k_flush_cache_mm, mm, 1, 1);
374} 396}
375 397
376struct flush_cache_page_args { 398struct flush_cache_page_args {
@@ -461,7 +483,7 @@ static void r4k_flush_cache_page(struct vm_area_struct *vma,
461 args.addr = addr; 483 args.addr = addr;
462 args.pfn = pfn; 484 args.pfn = pfn;
463 485
464 on_each_cpu(local_r4k_flush_cache_page, &args, 1, 1); 486 r4k_on_each_cpu(local_r4k_flush_cache_page, &args, 1, 1);
465} 487}
466 488
467static inline void local_r4k_flush_data_cache_page(void * addr) 489static inline void local_r4k_flush_data_cache_page(void * addr)
@@ -471,7 +493,7 @@ static inline void local_r4k_flush_data_cache_page(void * addr)
471 493
472static void r4k_flush_data_cache_page(unsigned long addr) 494static void r4k_flush_data_cache_page(unsigned long addr)
473{ 495{
474 on_each_cpu(local_r4k_flush_data_cache_page, (void *) addr, 1, 1); 496 r4k_on_each_cpu(local_r4k_flush_data_cache_page, (void *) addr, 1, 1);
475} 497}
476 498
477struct flush_icache_range_args { 499struct flush_icache_range_args {
@@ -514,7 +536,7 @@ static void r4k_flush_icache_range(unsigned long start, unsigned long end)
514 args.start = start; 536 args.start = start;
515 args.end = end; 537 args.end = end;
516 538
517 on_each_cpu(local_r4k_flush_icache_range, &args, 1, 1); 539 r4k_on_each_cpu(local_r4k_flush_icache_range, &args, 1, 1);
518 instruction_hazard(); 540 instruction_hazard();
519} 541}
520 542
@@ -590,7 +612,7 @@ static void r4k_flush_icache_page(struct vm_area_struct *vma,
590 args.vma = vma; 612 args.vma = vma;
591 args.page = page; 613 args.page = page;
592 614
593 on_each_cpu(local_r4k_flush_icache_page, &args, 1, 1); 615 r4k_on_each_cpu(local_r4k_flush_icache_page, &args, 1, 1);
594} 616}
595 617
596 618
@@ -689,7 +711,7 @@ static void local_r4k_flush_cache_sigtramp(void * arg)
689 711
690static void r4k_flush_cache_sigtramp(unsigned long addr) 712static void r4k_flush_cache_sigtramp(unsigned long addr)
691{ 713{
692 on_each_cpu(local_r4k_flush_cache_sigtramp, (void *) addr, 1, 1); 714 r4k_on_each_cpu(local_r4k_flush_cache_sigtramp, (void *) addr, 1, 1);
693} 715}
694 716
695static void r4k_flush_icache_all(void) 717static void r4k_flush_icache_all(void)
@@ -812,6 +834,7 @@ static void __init probe_pcache(void)
812 834
813 case CPU_R10000: 835 case CPU_R10000:
814 case CPU_R12000: 836 case CPU_R12000:
837 case CPU_R14000:
815 icache_size = 1 << (12 + ((config & R10K_CONF_IC) >> 29)); 838 icache_size = 1 << (12 + ((config & R10K_CONF_IC) >> 29));
816 c->icache.linesz = 64; 839 c->icache.linesz = 64;
817 c->icache.ways = 2; 840 c->icache.ways = 2;
@@ -965,9 +988,11 @@ static void __init probe_pcache(void)
965 c->dcache.flags |= MIPS_CACHE_PINDEX; 988 c->dcache.flags |= MIPS_CACHE_PINDEX;
966 case CPU_R10000: 989 case CPU_R10000:
967 case CPU_R12000: 990 case CPU_R12000:
991 case CPU_R14000:
968 case CPU_SB1: 992 case CPU_SB1:
969 break; 993 break;
970 case CPU_24K: 994 case CPU_24K:
995 case CPU_34K:
971 if (!(read_c0_config7() & (1 << 16))) 996 if (!(read_c0_config7() & (1 << 16)))
972 default: 997 default:
973 if (c->dcache.waysize > PAGE_SIZE) 998 if (c->dcache.waysize > PAGE_SIZE)
@@ -1091,6 +1116,7 @@ static void __init setup_scache(void)
1091 1116
1092 case CPU_R10000: 1117 case CPU_R10000:
1093 case CPU_R12000: 1118 case CPU_R12000:
1119 case CPU_R14000:
1094 scache_size = 0x80000 << ((config & R10K_CONF_SS) >> 16); 1120 scache_size = 0x80000 << ((config & R10K_CONF_SS) >> 16);
1095 c->scache.linesz = 64 << ((config >> 13) & 1); 1121 c->scache.linesz = 64 << ((config >> 13) & 1);
1096 c->scache.ways = 2; 1122 c->scache.ways = 2;
diff --git a/arch/mips/mm/pg-r4k.c b/arch/mips/mm/pg-r4k.c
index e4390dc3eb48..b7c749232ffe 100644
--- a/arch/mips/mm/pg-r4k.c
+++ b/arch/mips/mm/pg-r4k.c
@@ -357,6 +357,7 @@ void __init build_clear_page(void)
357 357
358 case CPU_R10000: 358 case CPU_R10000:
359 case CPU_R12000: 359 case CPU_R12000:
360 case CPU_R14000:
360 pref_src_mode = Pref_LoadStreamed; 361 pref_src_mode = Pref_LoadStreamed;
361 pref_dst_mode = Pref_StoreStreamed; 362 pref_dst_mode = Pref_StoreStreamed;
362 break; 363 break;
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 053dbacac56b..54507be2ab5b 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -875,6 +875,7 @@ static __init void build_tlb_write_entry(u32 **p, struct label **l,
875 875
876 case CPU_R10000: 876 case CPU_R10000:
877 case CPU_R12000: 877 case CPU_R12000:
878 case CPU_R14000:
878 case CPU_4KC: 879 case CPU_4KC:
879 case CPU_SB1: 880 case CPU_SB1:
880 case CPU_SB1A: 881 case CPU_SB1A:
@@ -906,6 +907,7 @@ static __init void build_tlb_write_entry(u32 **p, struct label **l,
906 case CPU_4KEC: 907 case CPU_4KEC:
907 case CPU_24K: 908 case CPU_24K:
908 case CPU_34K: 909 case CPU_34K:
910 case CPU_74K:
909 i_ehb(p); 911 i_ehb(p);
910 tlbw(p); 912 tlbw(p);
911 break; 913 break;
diff --git a/arch/mips/oprofile/common.c b/arch/mips/oprofile/common.c
index f2b4862aaae5..91b799d2cd88 100644
--- a/arch/mips/oprofile/common.c
+++ b/arch/mips/oprofile/common.c
@@ -80,6 +80,7 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
80 case CPU_24K: 80 case CPU_24K:
81 case CPU_25KF: 81 case CPU_25KF:
82 case CPU_34K: 82 case CPU_34K:
83 case CPU_74K:
83 case CPU_SB1: 84 case CPU_SB1:
84 case CPU_SB1A: 85 case CPU_SB1A:
85 lmodel = &op_model_mipsxx; 86 lmodel = &op_model_mipsxx;
diff --git a/arch/mips/oprofile/op_model_mipsxx.c b/arch/mips/oprofile/op_model_mipsxx.c
index 95d488ca0754..e7ce92391303 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -205,6 +205,10 @@ static int __init mipsxx_init(void)
205 case CPU_34K: 205 case CPU_34K:
206 op_model_mipsxx.cpu_type = "mips/34K"; 206 op_model_mipsxx.cpu_type = "mips/34K";
207 break; 207 break;
208
209 case CPU_74K:
210 op_model_mipsxx.cpu_type = "mips/74K";
211 break;
208#endif 212#endif
209 213
210 case CPU_5KC: 214 case CPU_5KC:
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 2d80653aa2af..41e9ab40cd54 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -2057,10 +2057,45 @@ static void __init flatten_device_tree(void)
2057 2057
2058} 2058}
2059 2059
2060 2060#ifdef CONFIG_PPC_MAPLE
2061static void __init fixup_device_tree(void) 2061/* PIBS Version 1.05.0000 04/26/2005 has an incorrect /ht/isa/ranges property.
2062 * The values are bad, and it doesn't even have the right number of cells. */
2063static void __init fixup_device_tree_maple(void)
2062{ 2064{
2065 phandle isa;
2066 u32 isa_ranges[6];
2067
2068 isa = call_prom("finddevice", 1, 1, ADDR("/ht@0/isa@4"));
2069 if (!PHANDLE_VALID(isa))
2070 return;
2071
2072 if (prom_getprop(isa, "ranges", isa_ranges, sizeof(isa_ranges))
2073 == PROM_ERROR)
2074 return;
2075
2076 if (isa_ranges[0] != 0x1 ||
2077 isa_ranges[1] != 0xf4000000 ||
2078 isa_ranges[2] != 0x00010000)
2079 return;
2080
2081 prom_printf("fixing up bogus ISA range on Maple...\n");
2082
2083 isa_ranges[0] = 0x1;
2084 isa_ranges[1] = 0x0;
2085 isa_ranges[2] = 0x01002000; /* IO space; PCI device = 4 */
2086 isa_ranges[3] = 0x0;
2087 isa_ranges[4] = 0x0;
2088 isa_ranges[5] = 0x00010000;
2089 prom_setprop(isa, "/ht@0/isa@4", "ranges",
2090 isa_ranges, sizeof(isa_ranges));
2091}
2092#else
2093#define fixup_device_tree_maple()
2094#endif
2095
2063#if defined(CONFIG_PPC64) && defined(CONFIG_PPC_PMAC) 2096#if defined(CONFIG_PPC64) && defined(CONFIG_PPC_PMAC)
2097static void __init fixup_device_tree_pmac(void)
2098{
2064 phandle u3, i2c, mpic; 2099 phandle u3, i2c, mpic;
2065 u32 u3_rev; 2100 u32 u3_rev;
2066 u32 interrupts[2]; 2101 u32 interrupts[2];
@@ -2097,9 +2132,16 @@ static void __init fixup_device_tree(void)
2097 parent = (u32)mpic; 2132 parent = (u32)mpic;
2098 prom_setprop(i2c, "/u3@0,f8000000/i2c@f8001000", "interrupt-parent", 2133 prom_setprop(i2c, "/u3@0,f8000000/i2c@f8001000", "interrupt-parent",
2099 &parent, sizeof(parent)); 2134 &parent, sizeof(parent));
2100#endif
2101} 2135}
2136#else
2137#define fixup_device_tree_pmac()
2138#endif
2102 2139
2140static void __init fixup_device_tree(void)
2141{
2142 fixup_device_tree_maple();
2143 fixup_device_tree_pmac();
2144}
2103 2145
2104static void __init prom_find_boot_cpu(void) 2146static void __init prom_find_boot_cpu(void)
2105{ 2147{
diff --git a/arch/powerpc/kernel/systbl.S b/arch/powerpc/kernel/systbl.S
index cf56a1d499ff..26ed1f5ef16e 100644
--- a/arch/powerpc/kernel/systbl.S
+++ b/arch/powerpc/kernel/systbl.S
@@ -338,6 +338,8 @@ SYSCALL(symlinkat)
338SYSCALL(readlinkat) 338SYSCALL(readlinkat)
339SYSCALL(fchmodat) 339SYSCALL(fchmodat)
340SYSCALL(faccessat) 340SYSCALL(faccessat)
341COMPAT_SYS(get_robust_list)
342COMPAT_SYS(set_robust_list)
341 343
342/* 344/*
343 * please add new calls to arch/powerpc/platforms/cell/spu_callbacks.c 345 * please add new calls to arch/powerpc/platforms/cell/spu_callbacks.c
diff --git a/arch/powerpc/platforms/cell/spu_callbacks.c b/arch/powerpc/platforms/cell/spu_callbacks.c
index 95b36430aa0f..b47fcc5ddb78 100644
--- a/arch/powerpc/platforms/cell/spu_callbacks.c
+++ b/arch/powerpc/platforms/cell/spu_callbacks.c
@@ -258,6 +258,7 @@ void *spu_syscall_table[] = {
258 [__NR_futex] sys_futex, 258 [__NR_futex] sys_futex,
259 [__NR_sched_setaffinity] sys_sched_setaffinity, 259 [__NR_sched_setaffinity] sys_sched_setaffinity,
260 [__NR_sched_getaffinity] sys_sched_getaffinity, 260 [__NR_sched_getaffinity] sys_sched_getaffinity,
261 [224] sys_ni_syscall,
261 [__NR_tuxcall] sys_ni_syscall, 262 [__NR_tuxcall] sys_ni_syscall,
262 [226] sys_ni_syscall, 263 [226] sys_ni_syscall,
263 [__NR_io_setup] sys_io_setup, 264 [__NR_io_setup] sys_io_setup,
@@ -332,19 +333,21 @@ void *spu_syscall_table[] = {
332 [__NR_readlinkat] sys_readlinkat, 333 [__NR_readlinkat] sys_readlinkat,
333 [__NR_fchmodat] sys_fchmodat, 334 [__NR_fchmodat] sys_fchmodat,
334 [__NR_faccessat] sys_faccessat, 335 [__NR_faccessat] sys_faccessat,
336 [__NR_get_robust_list] sys_get_robust_list,
337 [__NR_set_robust_list] sys_set_robust_list,
335}; 338};
336 339
337long spu_sys_callback(struct spu_syscall_block *s) 340long spu_sys_callback(struct spu_syscall_block *s)
338{ 341{
339 long (*syscall)(u64 a1, u64 a2, u64 a3, u64 a4, u64 a5, u64 a6); 342 long (*syscall)(u64 a1, u64 a2, u64 a3, u64 a4, u64 a5, u64 a6);
340 343
341 syscall = spu_syscall_table[s->nr_ret];
342
343 if (s->nr_ret >= ARRAY_SIZE(spu_syscall_table)) { 344 if (s->nr_ret >= ARRAY_SIZE(spu_syscall_table)) {
344 pr_debug("%s: invalid syscall #%ld", __FUNCTION__, s->nr_ret); 345 pr_debug("%s: invalid syscall #%ld", __FUNCTION__, s->nr_ret);
345 return -ENOSYS; 346 return -ENOSYS;
346 } 347 }
347 348
349 syscall = spu_syscall_table[s->nr_ret];
350
348#ifdef DEBUG 351#ifdef DEBUG
349 print_symbol(KERN_DEBUG "SPU-syscall %s:", (unsigned long)syscall); 352 print_symbol(KERN_DEBUG "SPU-syscall %s:", (unsigned long)syscall);
350 printk("syscall%ld(%lx, %lx, %lx, %lx, %lx, %lx)\n", 353 printk("syscall%ld(%lx, %lx, %lx, %lx, %lx, %lx)\n",
diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c
index df2343e1956b..c896ce83d412 100644
--- a/arch/powerpc/platforms/powermac/low_i2c.c
+++ b/arch/powerpc/platforms/powermac/low_i2c.c
@@ -1157,6 +1157,7 @@ EXPORT_SYMBOL_GPL(pmac_i2c_xfer);
1157/* some quirks for platform function decoding */ 1157/* some quirks for platform function decoding */
1158enum { 1158enum {
1159 pmac_i2c_quirk_invmask = 0x00000001u, 1159 pmac_i2c_quirk_invmask = 0x00000001u,
1160 pmac_i2c_quirk_skip = 0x00000002u,
1160}; 1161};
1161 1162
1162static void pmac_i2c_devscan(void (*callback)(struct device_node *dev, 1163static void pmac_i2c_devscan(void (*callback)(struct device_node *dev,
@@ -1172,6 +1173,15 @@ static void pmac_i2c_devscan(void (*callback)(struct device_node *dev,
1172 /* XXX Study device-tree's & apple drivers are get the quirks 1173 /* XXX Study device-tree's & apple drivers are get the quirks
1173 * right ! 1174 * right !
1174 */ 1175 */
1176 /* Workaround: It seems that running the clockspreading
1177 * properties on the eMac will cause lockups during boot.
1178 * The machine seems to work fine without that. So for now,
1179 * let's make sure i2c-hwclock doesn't match about "imic"
1180 * clocks and we'll figure out if we really need to do
1181 * something special about those later.
1182 */
1183 { "i2c-hwclock", "imic5002", pmac_i2c_quirk_skip },
1184 { "i2c-hwclock", "imic5003", pmac_i2c_quirk_skip },
1175 { "i2c-hwclock", NULL, pmac_i2c_quirk_invmask }, 1185 { "i2c-hwclock", NULL, pmac_i2c_quirk_invmask },
1176 { "i2c-cpu-voltage", NULL, 0}, 1186 { "i2c-cpu-voltage", NULL, 0},
1177 { "temp-monitor", NULL, 0 }, 1187 { "temp-monitor", NULL, 0 },
@@ -1198,6 +1208,8 @@ static void pmac_i2c_devscan(void (*callback)(struct device_node *dev,
1198 if (p->compatible && 1208 if (p->compatible &&
1199 !device_is_compatible(np, p->compatible)) 1209 !device_is_compatible(np, p->compatible))
1200 continue; 1210 continue;
1211 if (p->quirks & pmac_i2c_quirk_skip)
1212 break;
1201 callback(np, p->quirks); 1213 callback(np, p->quirks);
1202 break; 1214 break;
1203 } 1215 }
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index 4d15e396655c..b9200fb07815 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -463,11 +463,23 @@ static int pmac_pm_finish(suspend_state_t state)
463 return 0; 463 return 0;
464} 464}
465 465
466static int pmac_pm_valid(suspend_state_t state)
467{
468 switch (state) {
469 case PM_SUSPEND_DISK:
470 return 1;
471 /* can't do any other states via generic mechanism yet */
472 default:
473 return 0;
474 }
475}
476
466static struct pm_ops pmac_pm_ops = { 477static struct pm_ops pmac_pm_ops = {
467 .pm_disk_mode = PM_DISK_SHUTDOWN, 478 .pm_disk_mode = PM_DISK_SHUTDOWN,
468 .prepare = pmac_pm_prepare, 479 .prepare = pmac_pm_prepare,
469 .enter = pmac_pm_enter, 480 .enter = pmac_pm_enter,
470 .finish = pmac_pm_finish, 481 .finish = pmac_pm_finish,
482 .valid = pmac_pm_valid,
471}; 483};
472 484
473#endif /* CONFIG_SOFTWARE_SUSPEND */ 485#endif /* CONFIG_SOFTWARE_SUSPEND */
diff --git a/arch/ppc/kernel/asm-offsets.c b/arch/ppc/kernel/asm-offsets.c
index cc7c4aea9397..2f5c5e157617 100644
--- a/arch/ppc/kernel/asm-offsets.c
+++ b/arch/ppc/kernel/asm-offsets.c
@@ -134,7 +134,7 @@ main(void)
134 DEFINE(TI_TASK, offsetof(struct thread_info, task)); 134 DEFINE(TI_TASK, offsetof(struct thread_info, task));
135 DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain)); 135 DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain));
136 DEFINE(TI_FLAGS, offsetof(struct thread_info, flags)); 136 DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
137 DEFINE(TI_LOCAL_FLAGS, offsetof(struct thread_info, flags)); 137 DEFINE(TI_LOCAL_FLAGS, offsetof(struct thread_info, local_flags));
138 DEFINE(TI_CPU, offsetof(struct thread_info, cpu)); 138 DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
139 DEFINE(TI_PREEMPT, offsetof(struct thread_info, preempt_count)); 139 DEFINE(TI_PREEMPT, offsetof(struct thread_info, preempt_count));
140 140
diff --git a/arch/ppc/platforms/mpc8272ads_setup.c b/arch/ppc/platforms/mpc8272ads_setup.c
index e62b75707f7a..abb7154de2c7 100644
--- a/arch/ppc/platforms/mpc8272ads_setup.c
+++ b/arch/ppc/platforms/mpc8272ads_setup.c
@@ -279,11 +279,11 @@ static int mpc8272ads_platform_notify(struct device *dev)
279 static const struct platform_notify_dev_map dev_map[] = { 279 static const struct platform_notify_dev_map dev_map[] = {
280 { 280 {
281 .bus_id = "fsl-cpm-fcc", 281 .bus_id = "fsl-cpm-fcc",
282 .rtn = mpc8272ads_fixup_enet_pdata 282 .rtn = mpc8272ads_fixup_enet_pdata,
283 }, 283 },
284 { 284 {
285 .bus_id = "fsl-cpm-scc:uart", 285 .bus_id = "fsl-cpm-scc:uart",
286 .rtn = mpc 286 .rtn = mpc8272ads_fixup_uart_pdata,
287 }, 287 },
288 { 288 {
289 .bus_id = NULL 289 .bus_id = NULL
@@ -335,15 +335,15 @@ struct platform_device* early_uart_get_pdev(int index)
335 struct platform_device* pdev = NULL; 335 struct platform_device* pdev = NULL;
336 if(index) { /*assume SCC4 here*/ 336 if(index) { /*assume SCC4 here*/
337 pdev = &ppc_sys_platform_devices[MPC82xx_CPM_SCC4]; 337 pdev = &ppc_sys_platform_devices[MPC82xx_CPM_SCC4];
338 pinfo = &mpc8272<F12>_uart_pdata[1]; 338 pinfo = &mpc8272_uart_pdata[fsid_scc4_uart];
339 } else { /*over SCC1*/ 339 } else { /*over SCC1*/
340 pdev = &ppc_sys_platform_devices[MPC82xx_CPM_SCC1]; 340 pdev = &ppc_sys_platform_devices[MPC82xx_CPM_SCC1];
341 pinfo = &mpc8272_uart_pdata[0]; 341 pinfo = &mpc8272_uart_pdata[fsid_scc1_uart];
342 } 342 }
343 343
344 pinfo->uart_clk = bd->bi_intfreq; 344 pinfo->uart_clk = bd->bi_intfreq;
345 pdev->dev.platform_data = pinfo; 345 pdev->dev.platform_data = pinfo;
346 ppc_sys_fixup_mem_resource(pdev, IMAP_ADDR); 346 ppc_sys_fixup_mem_resource(pdev, CPM_MAP_ADDR);
347 return NULL; 347 return NULL;
348} 348}
349 349
diff --git a/arch/ppc/syslib/pq2_devices.c b/arch/ppc/syslib/pq2_devices.c
index 0636aed7b827..8692d00c08c4 100644
--- a/arch/ppc/syslib/pq2_devices.c
+++ b/arch/ppc/syslib/pq2_devices.c
@@ -121,13 +121,13 @@ struct platform_device ppc_sys_platform_devices[] = {
121 .num_resources = 3, 121 .num_resources = 3,
122 .resource = (struct resource[]) { 122 .resource = (struct resource[]) {
123 { 123 {
124 .name = "scc_mem", 124 .name = "regs",
125 .start = 0x11A00, 125 .start = 0x11A00,
126 .end = 0x11A1F, 126 .end = 0x11A1F,
127 .flags = IORESOURCE_MEM, 127 .flags = IORESOURCE_MEM,
128 }, 128 },
129 { 129 {
130 .name = "scc_pram", 130 .name = "pram",
131 .start = 0x8000, 131 .start = 0x8000,
132 .end = 0x80ff, 132 .end = 0x80ff,
133 .flags = IORESOURCE_MEM, 133 .flags = IORESOURCE_MEM,
@@ -145,13 +145,13 @@ struct platform_device ppc_sys_platform_devices[] = {
145 .num_resources = 3, 145 .num_resources = 3,
146 .resource = (struct resource[]) { 146 .resource = (struct resource[]) {
147 { 147 {
148 .name = "scc_mem", 148 .name = "regs",
149 .start = 0x11A20, 149 .start = 0x11A20,
150 .end = 0x11A3F, 150 .end = 0x11A3F,
151 .flags = IORESOURCE_MEM, 151 .flags = IORESOURCE_MEM,
152 }, 152 },
153 { 153 {
154 .name = "scc_pram", 154 .name = "pram",
155 .start = 0x8100, 155 .start = 0x8100,
156 .end = 0x81ff, 156 .end = 0x81ff,
157 .flags = IORESOURCE_MEM, 157 .flags = IORESOURCE_MEM,
@@ -169,13 +169,13 @@ struct platform_device ppc_sys_platform_devices[] = {
169 .num_resources = 3, 169 .num_resources = 3,
170 .resource = (struct resource[]) { 170 .resource = (struct resource[]) {
171 { 171 {
172 .name = "scc_mem", 172 .name = "regs",
173 .start = 0x11A40, 173 .start = 0x11A40,
174 .end = 0x11A5F, 174 .end = 0x11A5F,
175 .flags = IORESOURCE_MEM, 175 .flags = IORESOURCE_MEM,
176 }, 176 },
177 { 177 {
178 .name = "scc_pram", 178 .name = "pram",
179 .start = 0x8200, 179 .start = 0x8200,
180 .end = 0x82ff, 180 .end = 0x82ff,
181 .flags = IORESOURCE_MEM, 181 .flags = IORESOURCE_MEM,
@@ -193,13 +193,13 @@ struct platform_device ppc_sys_platform_devices[] = {
193 .num_resources = 3, 193 .num_resources = 3,
194 .resource = (struct resource[]) { 194 .resource = (struct resource[]) {
195 { 195 {
196 .name = "scc_mem", 196 .name = "regs",
197 .start = 0x11A60, 197 .start = 0x11A60,
198 .end = 0x11A7F, 198 .end = 0x11A7F,
199 .flags = IORESOURCE_MEM, 199 .flags = IORESOURCE_MEM,
200 }, 200 },
201 { 201 {
202 .name = "scc_pram", 202 .name = "pram",
203 .start = 0x8300, 203 .start = 0x8300,
204 .end = 0x83ff, 204 .end = 0x83ff,
205 .flags = IORESOURCE_MEM, 205 .flags = IORESOURCE_MEM,
diff --git a/arch/ppc/syslib/pq2_sys.c b/arch/ppc/syslib/pq2_sys.c
index 433b0fa203e1..fee8948162b9 100644
--- a/arch/ppc/syslib/pq2_sys.c
+++ b/arch/ppc/syslib/pq2_sys.c
@@ -139,13 +139,13 @@ struct ppc_sys_spec ppc_sys_specs[] = {
139 .ppc_sys_name = "8272", 139 .ppc_sys_name = "8272",
140 .mask = 0x0000ff00, 140 .mask = 0x0000ff00,
141 .value = 0x00000c00, 141 .value = 0x00000c00,
142 .num_devices = 11, 142 .num_devices = 12,
143 .device_list = (enum ppc_sys_devices[]) 143 .device_list = (enum ppc_sys_devices[])
144 { 144 {
145 MPC82xx_CPM_FCC1, MPC82xx_CPM_FCC2, MPC82xx_CPM_SCC1, 145 MPC82xx_CPM_FCC1, MPC82xx_CPM_FCC2, MPC82xx_CPM_SCC1,
146 MPC82xx_CPM_SCC2, MPC82xx_CPM_SCC3, MPC82xx_CPM_SMC1, 146 MPC82xx_CPM_SCC2, MPC82xx_CPM_SCC3, MPC82xx_CPM_SCC4,
147 MPC82xx_CPM_SMC2, MPC82xx_CPM_SPI, MPC82xx_CPM_I2C, 147 MPC82xx_CPM_SMC1, MPC82xx_CPM_SMC2, MPC82xx_CPM_SPI,
148 MPC82xx_CPM_USB, MPC82xx_SEC1, 148 MPC82xx_CPM_I2C, MPC82xx_CPM_USB, MPC82xx_SEC1,
149 }, 149 },
150 }, 150 },
151 /* below is a list of the 8280 family of processors */ 151 /* below is a list of the 8280 family of processors */
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
index 029f09901b85..2a6c6efb6865 100644
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -272,7 +272,7 @@ static inline void stop_hz_timer(void)
272 next = next_timer_interrupt(); 272 next = next_timer_interrupt();
273 do { 273 do {
274 seq = read_seqbegin_irqsave(&xtime_lock, flags); 274 seq = read_seqbegin_irqsave(&xtime_lock, flags);
275 timer = (__u64)(next - jiffies) + jiffies_64; 275 timer = ((__u64) next) - ((__u64) jiffies) + jiffies_64;
276 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags)); 276 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
277 todval = -1ULL; 277 todval = -1ULL;
278 /* Be careful about overflows. */ 278 /* Be careful about overflows. */
diff --git a/arch/sparc/kernel/systbls.S b/arch/sparc/kernel/systbls.S
index 6e1135cc03b0..2856551bddf1 100644
--- a/arch/sparc/kernel/systbls.S
+++ b/arch/sparc/kernel/systbls.S
@@ -79,6 +79,7 @@ sys_call_table:
79/*285*/ .long sys_mkdirat, sys_mknodat, sys_fchownat, sys_futimesat, sys_fstatat64 79/*285*/ .long sys_mkdirat, sys_mknodat, sys_fchownat, sys_futimesat, sys_fstatat64
80/*290*/ .long sys_unlinkat, sys_renameat, sys_linkat, sys_symlinkat, sys_readlinkat 80/*290*/ .long sys_unlinkat, sys_renameat, sys_linkat, sys_symlinkat, sys_readlinkat
81/*295*/ .long sys_fchmodat, sys_faccessat, sys_pselect6, sys_ppoll, sys_unshare 81/*295*/ .long sys_fchmodat, sys_faccessat, sys_pselect6, sys_ppoll, sys_unshare
82/*300*/ .long sys_set_robust_list, sys_get_robust_list
82 83
83#ifdef CONFIG_SUNOS_EMUL 84#ifdef CONFIG_SUNOS_EMUL
84 /* Now the SunOS syscall table. */ 85 /* Now the SunOS syscall table. */
@@ -190,6 +191,6 @@ sunos_sys_table:
190/*290*/ .long sunos_nosys, sunos_nosys, sunos_nosys 191/*290*/ .long sunos_nosys, sunos_nosys, sunos_nosys
191 .long sunos_nosys, sunos_nosys, sunos_nosys 192 .long sunos_nosys, sunos_nosys, sunos_nosys
192 .long sunos_nosys, sunos_nosys, sunos_nosys 193 .long sunos_nosys, sunos_nosys, sunos_nosys
193 .long sunos_nosys 194 .long sunos_nosys, sunos_nosys, sunos_nosys
194 195
195#endif 196#endif
diff --git a/arch/sparc64/kernel/head.S b/arch/sparc64/kernel/head.S
index 3eadac5e171e..31c5892f5acc 100644
--- a/arch/sparc64/kernel/head.S
+++ b/arch/sparc64/kernel/head.S
@@ -10,6 +10,7 @@
10#include <linux/config.h> 10#include <linux/config.h>
11#include <linux/version.h> 11#include <linux/version.h>
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/threads.h>
13#include <asm/thread_info.h> 14#include <asm/thread_info.h>
14#include <asm/asi.h> 15#include <asm/asi.h>
15#include <asm/pstate.h> 16#include <asm/pstate.h>
@@ -493,6 +494,35 @@ tlb_fixup_done:
493 call prom_init 494 call prom_init
494 mov %l7, %o0 ! OpenPROM cif handler 495 mov %l7, %o0 ! OpenPROM cif handler
495 496
497 /* Initialize current_thread_info()->cpu as early as possible.
498 * In order to do that accurately we have to patch up the get_cpuid()
499 * assembler sequences. And that, in turn, requires that we know
500 * if we are on a Starfire box or not. While we're here, patch up
501 * the sun4v sequences as well.
502 */
503 call check_if_starfire
504 nop
505 call per_cpu_patch
506 nop
507 call sun4v_patch
508 nop
509
510#ifdef CONFIG_SMP
511 call hard_smp_processor_id
512 nop
513 cmp %o0, NR_CPUS
514 blu,pt %xcc, 1f
515 nop
516 call boot_cpu_id_too_large
517 nop
518 /* Not reached... */
519
5201:
521#else
522 mov 0, %o0
523#endif
524 stb %o0, [%g6 + TI_CPU]
525
496 /* Off we go.... */ 526 /* Off we go.... */
497 call start_kernel 527 call start_kernel
498 nop 528 nop
diff --git a/arch/sparc64/kernel/pci_iommu.c b/arch/sparc64/kernel/pci_iommu.c
index 8efbc139769d..82e5455134c6 100644
--- a/arch/sparc64/kernel/pci_iommu.c
+++ b/arch/sparc64/kernel/pci_iommu.c
@@ -218,7 +218,7 @@ static inline void iommu_free_ctx(struct pci_iommu *iommu, int ctx)
218 * DMA for PCI device PDEV. Return non-NULL cpu-side address if 218 * DMA for PCI device PDEV. Return non-NULL cpu-side address if
219 * successful and set *DMA_ADDRP to the PCI side dma address. 219 * successful and set *DMA_ADDRP to the PCI side dma address.
220 */ 220 */
221static void *pci_4u_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_addrp) 221static void *pci_4u_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_addrp, gfp_t gfp)
222{ 222{
223 struct pcidev_cookie *pcp; 223 struct pcidev_cookie *pcp;
224 struct pci_iommu *iommu; 224 struct pci_iommu *iommu;
@@ -232,7 +232,7 @@ static void *pci_4u_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr
232 if (order >= 10) 232 if (order >= 10)
233 return NULL; 233 return NULL;
234 234
235 first_page = __get_free_pages(GFP_ATOMIC, order); 235 first_page = __get_free_pages(gfp, order);
236 if (first_page == 0UL) 236 if (first_page == 0UL)
237 return NULL; 237 return NULL;
238 memset((char *)first_page, 0, PAGE_SIZE << order); 238 memset((char *)first_page, 0, PAGE_SIZE << order);
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c
index 9e94db2573a2..2b7a1f316a93 100644
--- a/arch/sparc64/kernel/pci_sun4v.c
+++ b/arch/sparc64/kernel/pci_sun4v.c
@@ -154,7 +154,7 @@ static void pci_arena_free(struct pci_iommu_arena *arena, unsigned long base, un
154 __clear_bit(i, arena->map); 154 __clear_bit(i, arena->map);
155} 155}
156 156
157static void *pci_4v_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_addrp) 157static void *pci_4v_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_addrp, gfp_t gfp)
158{ 158{
159 struct pcidev_cookie *pcp; 159 struct pcidev_cookie *pcp;
160 struct pci_iommu *iommu; 160 struct pci_iommu *iommu;
@@ -169,7 +169,7 @@ static void *pci_4v_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr
169 169
170 npages = size >> IO_PAGE_SHIFT; 170 npages = size >> IO_PAGE_SHIFT;
171 171
172 first_page = __get_free_pages(GFP_ATOMIC, order); 172 first_page = __get_free_pages(gfp, order);
173 if (unlikely(first_page == 0UL)) 173 if (unlikely(first_page == 0UL))
174 return NULL; 174 return NULL;
175 175
diff --git a/arch/sparc64/kernel/setup.c b/arch/sparc64/kernel/setup.c
index 005167f82419..9cf1c88cd774 100644
--- a/arch/sparc64/kernel/setup.c
+++ b/arch/sparc64/kernel/setup.c
@@ -220,7 +220,7 @@ char reboot_command[COMMAND_LINE_SIZE];
220 220
221static struct pt_regs fake_swapper_regs = { { 0, }, 0, 0, 0, 0 }; 221static struct pt_regs fake_swapper_regs = { { 0, }, 0, 0, 0, 0 };
222 222
223static void __init per_cpu_patch(void) 223void __init per_cpu_patch(void)
224{ 224{
225 struct cpuid_patch_entry *p; 225 struct cpuid_patch_entry *p;
226 unsigned long ver; 226 unsigned long ver;
@@ -280,7 +280,7 @@ static void __init per_cpu_patch(void)
280 } 280 }
281} 281}
282 282
283static void __init sun4v_patch(void) 283void __init sun4v_patch(void)
284{ 284{
285 struct sun4v_1insn_patch_entry *p1; 285 struct sun4v_1insn_patch_entry *p1;
286 struct sun4v_2insn_patch_entry *p2; 286 struct sun4v_2insn_patch_entry *p2;
@@ -315,6 +315,15 @@ static void __init sun4v_patch(void)
315 } 315 }
316} 316}
317 317
318#ifdef CONFIG_SMP
319void __init boot_cpu_id_too_large(int cpu)
320{
321 prom_printf("Serious problem, boot cpu id (%d) >= NR_CPUS (%d)\n",
322 cpu, NR_CPUS);
323 prom_halt();
324}
325#endif
326
318void __init setup_arch(char **cmdline_p) 327void __init setup_arch(char **cmdline_p)
319{ 328{
320 /* Initialize PROM console and command line. */ 329 /* Initialize PROM console and command line. */
@@ -332,16 +341,6 @@ void __init setup_arch(char **cmdline_p)
332 conswitchp = &prom_con; 341 conswitchp = &prom_con;
333#endif 342#endif
334 343
335 /* Work out if we are starfire early on */
336 check_if_starfire();
337
338 /* Now we know enough to patch the get_cpuid sequences
339 * used by trap code.
340 */
341 per_cpu_patch();
342
343 sun4v_patch();
344
345 boot_flags_init(*cmdline_p); 344 boot_flags_init(*cmdline_p);
346 345
347 idprom_init(); 346 idprom_init();
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index 90eaca3ec9a6..4e8cd79156e0 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -1264,7 +1264,6 @@ void __init smp_tick_init(void)
1264 boot_cpu_id = hard_smp_processor_id(); 1264 boot_cpu_id = hard_smp_processor_id();
1265 current_tick_offset = timer_tick_offset; 1265 current_tick_offset = timer_tick_offset;
1266 1266
1267 cpu_set(boot_cpu_id, cpu_online_map);
1268 prof_counter(boot_cpu_id) = prof_multiplier(boot_cpu_id) = 1; 1267 prof_counter(boot_cpu_id) = prof_multiplier(boot_cpu_id) = 1;
1269} 1268}
1270 1269
@@ -1345,18 +1344,6 @@ void __init smp_setup_cpu_possible_map(void)
1345 1344
1346void __devinit smp_prepare_boot_cpu(void) 1345void __devinit smp_prepare_boot_cpu(void)
1347{ 1346{
1348 int cpu = hard_smp_processor_id();
1349
1350 if (cpu >= NR_CPUS) {
1351 prom_printf("Serious problem, boot cpu id >= NR_CPUS\n");
1352 prom_halt();
1353 }
1354
1355 current_thread_info()->cpu = cpu;
1356 __local_per_cpu_offset = __per_cpu_offset(cpu);
1357
1358 cpu_set(smp_processor_id(), cpu_online_map);
1359 cpu_set(smp_processor_id(), phys_cpu_present_map);
1360} 1347}
1361 1348
1362int __devinit __cpu_up(unsigned int cpu) 1349int __devinit __cpu_up(unsigned int cpu)
@@ -1433,4 +1420,7 @@ void __init setup_per_cpu_areas(void)
1433 1420
1434 for (i = 0; i < NR_CPUS; i++, ptr += size) 1421 for (i = 0; i < NR_CPUS; i++, ptr += size)
1435 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start); 1422 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
1423
1424 /* Setup %g5 for the boot cpu. */
1425 __local_per_cpu_offset = __per_cpu_offset(smp_processor_id());
1436} 1426}
diff --git a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
index d4b39cd30310..1136fc465e37 100644
--- a/arch/sparc64/kernel/systbls.S
+++ b/arch/sparc64/kernel/systbls.S
@@ -78,8 +78,9 @@ sys_call_table32:
78 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid 78 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
79/*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat 79/*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
80 .word sys_mkdirat, sys_mknodat, sys_fchownat, compat_sys_futimesat, compat_sys_fstatat64 80 .word sys_mkdirat, sys_mknodat, sys_fchownat, compat_sys_futimesat, compat_sys_fstatat64
81/*285*/ .word sys_unlinkat, sys_renameat, sys_linkat, sys_symlinkat, sys_readlinkat 81/*290*/ .word sys_unlinkat, sys_renameat, sys_linkat, sys_symlinkat, sys_readlinkat
82 .word sys_fchmodat, sys_faccessat, compat_sys_pselect6, compat_sys_ppoll, sys_unshare 82 .word sys_fchmodat, sys_faccessat, compat_sys_pselect6, compat_sys_ppoll, sys_unshare
83/*300*/ .word compat_sys_set_robust_list, compat_sys_get_robust_list
83 84
84#endif /* CONFIG_COMPAT */ 85#endif /* CONFIG_COMPAT */
85 86
@@ -147,8 +148,9 @@ sys_call_table:
147 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid 148 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
148/*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat 149/*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
149 .word sys_mkdirat, sys_mknodat, sys_fchownat, sys_futimesat, sys_fstatat64 150 .word sys_mkdirat, sys_mknodat, sys_fchownat, sys_futimesat, sys_fstatat64
150/*285*/ .word sys_unlinkat, sys_renameat, sys_linkat, sys_symlinkat, sys_readlinkat 151/*290*/ .word sys_unlinkat, sys_renameat, sys_linkat, sys_symlinkat, sys_readlinkat
151 .word sys_fchmodat, sys_faccessat, sys_pselect6, sys_ppoll, sys_unshare 152 .word sys_fchmodat, sys_faccessat, sys_pselect6, sys_ppoll, sys_unshare
153/*300*/ .word sys_set_robust_list, sys_get_robust_list
152 154
153#if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \ 155#if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
154 defined(CONFIG_SOLARIS_EMUL_MODULE) 156 defined(CONFIG_SOLARIS_EMUL_MODULE)
@@ -261,5 +263,5 @@ sunos_sys_table:
261/*290*/ .word sunos_nosys, sunos_nosys, sunos_nosys 263/*290*/ .word sunos_nosys, sunos_nosys, sunos_nosys
262 .word sunos_nosys, sunos_nosys, sunos_nosys 264 .word sunos_nosys, sunos_nosys, sunos_nosys
263 .word sunos_nosys, sunos_nosys, sunos_nosys 265 .word sunos_nosys, sunos_nosys, sunos_nosys
264 .word sunos_nosys 266 .word sunos_nosys, sunos_nosys, sunos_nosys
265#endif 267#endif
diff --git a/arch/x86_64/ia32/ia32_binfmt.c b/arch/x86_64/ia32/ia32_binfmt.c
index e776139afb20..926c4743d13b 100644
--- a/arch/x86_64/ia32/ia32_binfmt.c
+++ b/arch/x86_64/ia32/ia32_binfmt.c
@@ -339,7 +339,7 @@ int ia32_setup_arg_pages(struct linux_binprm *bprm, unsigned long stack_top,
339 struct mm_struct *mm = current->mm; 339 struct mm_struct *mm = current->mm;
340 int i, ret; 340 int i, ret;
341 341
342 stack_base = IA32_STACK_TOP - MAX_ARG_PAGES * PAGE_SIZE; 342 stack_base = stack_top - MAX_ARG_PAGES * PAGE_SIZE;
343 mm->arg_start = bprm->p + stack_base; 343 mm->arg_start = bprm->p + stack_base;
344 344
345 bprm->p += stack_base; 345 bprm->p += stack_base;
@@ -357,7 +357,7 @@ int ia32_setup_arg_pages(struct linux_binprm *bprm, unsigned long stack_top,
357 { 357 {
358 mpnt->vm_mm = mm; 358 mpnt->vm_mm = mm;
359 mpnt->vm_start = PAGE_MASK & (unsigned long) bprm->p; 359 mpnt->vm_start = PAGE_MASK & (unsigned long) bprm->p;
360 mpnt->vm_end = IA32_STACK_TOP; 360 mpnt->vm_end = stack_top;
361 if (executable_stack == EXSTACK_ENABLE_X) 361 if (executable_stack == EXSTACK_ENABLE_X)
362 mpnt->vm_flags = VM_STACK_FLAGS | VM_EXEC; 362 mpnt->vm_flags = VM_STACK_FLAGS | VM_EXEC;
363 else if (executable_stack == EXSTACK_DISABLE_X) 363 else if (executable_stack == EXSTACK_DISABLE_X)
diff --git a/arch/x86_64/kernel/e820.c b/arch/x86_64/kernel/e820.c
index 222b5b46d2b2..1ef6028f721e 100644
--- a/arch/x86_64/kernel/e820.c
+++ b/arch/x86_64/kernel/e820.c
@@ -149,7 +149,7 @@ unsigned long __init find_e820_area(unsigned long start, unsigned long end, unsi
149 addr = start; 149 addr = start;
150 if (addr > ei->addr + ei->size) 150 if (addr > ei->addr + ei->size)
151 continue; 151 continue;
152 while (bad_addr(&addr, size) && addr+size < ei->addr + ei->size) 152 while (bad_addr(&addr, size) && addr+size <= ei->addr+ei->size)
153 ; 153 ;
154 last = addr + size; 154 last = addr + size;
155 if (last > ei->addr + ei->size) 155 if (last > ei->addr + ei->size)
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
index c946e4fe67a7..586b34c00c48 100644
--- a/arch/x86_64/kernel/entry.S
+++ b/arch/x86_64/kernel/entry.S
@@ -281,12 +281,7 @@ tracesys:
281 ja 1f 281 ja 1f
282 movq %r10,%rcx /* fixup for C */ 282 movq %r10,%rcx /* fixup for C */
283 call *sys_call_table(,%rax,8) 283 call *sys_call_table(,%rax,8)
284 movq %rax,RAX-ARGOFFSET(%rsp) 2841: movq %rax,RAX-ARGOFFSET(%rsp)
2851: SAVE_REST
286 movq %rsp,%rdi
287 call syscall_trace_leave
288 RESTORE_TOP_OF_STACK %rbx
289 RESTORE_REST
290 /* Use IRET because user could have changed frame */ 285 /* Use IRET because user could have changed frame */
291 jmp int_ret_from_sys_call 286 jmp int_ret_from_sys_call
292 CFI_ENDPROC 287 CFI_ENDPROC
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c
index 1eaa5dae6174..fa1d19ca700a 100644
--- a/arch/x86_64/kernel/kprobes.c
+++ b/arch/x86_64/kernel/kprobes.c
@@ -514,13 +514,13 @@ static void __kprobes resume_execution(struct kprobe *p,
514 *tos = orig_rip + (*tos - copy_rip); 514 *tos = orig_rip + (*tos - copy_rip);
515 break; 515 break;
516 case 0xff: 516 case 0xff:
517 if ((*insn & 0x30) == 0x10) { 517 if ((insn[1] & 0x30) == 0x10) {
518 /* call absolute, indirect */ 518 /* call absolute, indirect */
519 /* Fix return addr; rip is correct. */ 519 /* Fix return addr; rip is correct. */
520 next_rip = regs->rip; 520 next_rip = regs->rip;
521 *tos = orig_rip + (*tos - copy_rip); 521 *tos = orig_rip + (*tos - copy_rip);
522 } else if (((*insn & 0x31) == 0x20) || /* jmp near, absolute indirect */ 522 } else if (((insn[1] & 0x31) == 0x20) || /* jmp near, absolute indirect */
523 ((*insn & 0x31) == 0x21)) { /* jmp far, absolute indirect */ 523 ((insn[1] & 0x31) == 0x21)) { /* jmp far, absolute indirect */
524 /* rip is correct. */ 524 /* rip is correct. */
525 next_rip = regs->rip; 525 next_rip = regs->rip;
526 } 526 }
diff --git a/arch/x86_64/kernel/pci-dma.c b/arch/x86_64/kernel/pci-dma.c
index af035ede70cd..a9275c9557cf 100644
--- a/arch/x86_64/kernel/pci-dma.c
+++ b/arch/x86_64/kernel/pci-dma.c
@@ -54,6 +54,10 @@ dma_alloc_pages(struct device *dev, gfp_t gfp, unsigned order)
54 else 54 else
55#endif 55#endif
56 node = numa_node_id(); 56 node = numa_node_id();
57
58 if (node < first_node(node_online_map))
59 node = first_node(node_online_map);
60
57 page = alloc_pages_node(node, gfp, order); 61 page = alloc_pages_node(node, gfp, order);
58 return page ? page_address(page) : NULL; 62 return page ? page_address(page) : NULL;
59} 63}
diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
index 2480d3f08a47..82a7c9bfdfa0 100644
--- a/arch/x86_64/kernel/pci-gart.c
+++ b/arch/x86_64/kernel/pci-gart.c
@@ -631,10 +631,8 @@ static int __init pci_iommu_init(void)
631 printk(KERN_INFO "PCI-DMA: Disabling IOMMU.\n"); 631 printk(KERN_INFO "PCI-DMA: Disabling IOMMU.\n");
632 if (end_pfn > MAX_DMA32_PFN) { 632 if (end_pfn > MAX_DMA32_PFN) {
633 printk(KERN_ERR "WARNING more than 4GB of memory " 633 printk(KERN_ERR "WARNING more than 4GB of memory "
634 "but IOMMU not compiled in.\n" 634 "but IOMMU not available.\n"
635 KERN_ERR "WARNING 32bit PCI may malfunction.\n" 635 KERN_ERR "WARNING 32bit PCI may malfunction.\n");
636 KERN_ERR "You might want to enable "
637 "CONFIG_GART_IOMMU\n");
638 } 636 }
639 return -1; 637 return -1;
640 } 638 }
diff --git a/arch/x86_64/kernel/pmtimer.c b/arch/x86_64/kernel/pmtimer.c
index b0444a415bd6..bf421ed26808 100644
--- a/arch/x86_64/kernel/pmtimer.c
+++ b/arch/x86_64/kernel/pmtimer.c
@@ -68,7 +68,7 @@ int pmtimer_mark_offset(void)
68 offset_delay = delta % (USEC_PER_SEC / HZ); 68 offset_delay = delta % (USEC_PER_SEC / HZ);
69 69
70 rdtscll(tsc); 70 rdtscll(tsc);
71 vxtime.last_tsc = tsc - offset_delay * cpu_khz; 71 vxtime.last_tsc = tsc - offset_delay * (u64)cpu_khz / 1000;
72 72
73 /* don't calculate delay for first run, 73 /* don't calculate delay for first run,
74 or if we've got less then a tick */ 74 or if we've got less then a tick */
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index f0870bef24d1..655b9192eeb3 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -1051,7 +1051,7 @@ static void srat_detect_node(void)
1051 for now. */ 1051 for now. */
1052 node = apicid_to_node[hard_smp_processor_id()]; 1052 node = apicid_to_node[hard_smp_processor_id()];
1053 if (node == NUMA_NO_NODE) 1053 if (node == NUMA_NO_NODE)
1054 node = 0; 1054 node = first_node(node_online_map);
1055 numa_set_node(cpu, node); 1055 numa_set_node(cpu, node);
1056 1056
1057 if (acpi_numa > 0) 1057 if (acpi_numa > 0)
diff --git a/arch/x86_64/mm/srat.c b/arch/x86_64/mm/srat.c
index e1513532df29..474df22c6ed2 100644
--- a/arch/x86_64/mm/srat.c
+++ b/arch/x86_64/mm/srat.c
@@ -399,8 +399,10 @@ int __init acpi_scan_nodes(unsigned long start, unsigned long end)
399 /* First clean up the node list */ 399 /* First clean up the node list */
400 for (i = 0; i < MAX_NUMNODES; i++) { 400 for (i = 0; i < MAX_NUMNODES; i++) {
401 cutoff_node(i, start, end); 401 cutoff_node(i, start, end);
402 if ((nodes[i].end - nodes[i].start) < NODE_MIN_SIZE) 402 if ((nodes[i].end - nodes[i].start) < NODE_MIN_SIZE) {
403 unparse_node(i); 403 unparse_node(i);
404 node_set_offline(i);
405 }
404 } 406 }
405 407
406 if (acpi_numa <= 0) 408 if (acpi_numa <= 0)
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 2540dfaa3e38..8e9d84825e1c 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -33,7 +33,7 @@ static int cfq_slice_idle = HZ / 70;
33 33
34#define CFQ_KEY_ASYNC (0) 34#define CFQ_KEY_ASYNC (0)
35 35
36static DEFINE_RWLOCK(cfq_exit_lock); 36static DEFINE_SPINLOCK(cfq_exit_lock);
37 37
38/* 38/*
39 * for the hash of cfqq inside the cfqd 39 * for the hash of cfqq inside the cfqd
@@ -133,6 +133,7 @@ struct cfq_data {
133 mempool_t *crq_pool; 133 mempool_t *crq_pool;
134 134
135 int rq_in_driver; 135 int rq_in_driver;
136 int hw_tag;
136 137
137 /* 138 /*
138 * schedule slice state info 139 * schedule slice state info
@@ -500,10 +501,13 @@ static void cfq_resort_rr_list(struct cfq_queue *cfqq, int preempted)
500 501
501 /* 502 /*
502 * if queue was preempted, just add to front to be fair. busy_rr 503 * if queue was preempted, just add to front to be fair. busy_rr
503 * isn't sorted. 504 * isn't sorted, but insert at the back for fairness.
504 */ 505 */
505 if (preempted || list == &cfqd->busy_rr) { 506 if (preempted || list == &cfqd->busy_rr) {
506 list_add(&cfqq->cfq_list, list); 507 if (preempted)
508 list = list->prev;
509
510 list_add_tail(&cfqq->cfq_list, list);
507 return; 511 return;
508 } 512 }
509 513
@@ -664,6 +668,15 @@ static void cfq_activate_request(request_queue_t *q, struct request *rq)
664 struct cfq_data *cfqd = q->elevator->elevator_data; 668 struct cfq_data *cfqd = q->elevator->elevator_data;
665 669
666 cfqd->rq_in_driver++; 670 cfqd->rq_in_driver++;
671
672 /*
673 * If the depth is larger 1, it really could be queueing. But lets
674 * make the mark a little higher - idling could still be good for
675 * low queueing, and a low queueing number could also just indicate
676 * a SCSI mid layer like behaviour where limit+1 is often seen.
677 */
678 if (!cfqd->hw_tag && cfqd->rq_in_driver > 4)
679 cfqd->hw_tag = 1;
667} 680}
668 681
669static void cfq_deactivate_request(request_queue_t *q, struct request *rq) 682static void cfq_deactivate_request(request_queue_t *q, struct request *rq)
@@ -879,6 +892,13 @@ static struct cfq_queue *cfq_set_active_queue(struct cfq_data *cfqd)
879 cfqq = list_entry_cfqq(cfqd->cur_rr.next); 892 cfqq = list_entry_cfqq(cfqd->cur_rr.next);
880 893
881 /* 894 /*
895 * If no new queues are available, check if the busy list has some
896 * before falling back to idle io.
897 */
898 if (!cfqq && !list_empty(&cfqd->busy_rr))
899 cfqq = list_entry_cfqq(cfqd->busy_rr.next);
900
901 /*
882 * if we have idle queues and no rt or be queues had pending 902 * if we have idle queues and no rt or be queues had pending
883 * requests, either allow immediate service if the grace period 903 * requests, either allow immediate service if the grace period
884 * has passed or arm the idle grace timer 904 * has passed or arm the idle grace timer
@@ -1284,7 +1304,7 @@ static void cfq_exit_io_context(struct io_context *ioc)
1284 /* 1304 /*
1285 * put the reference this task is holding to the various queues 1305 * put the reference this task is holding to the various queues
1286 */ 1306 */
1287 read_lock_irqsave(&cfq_exit_lock, flags); 1307 spin_lock_irqsave(&cfq_exit_lock, flags);
1288 1308
1289 n = rb_first(&ioc->cic_root); 1309 n = rb_first(&ioc->cic_root);
1290 while (n != NULL) { 1310 while (n != NULL) {
@@ -1294,7 +1314,7 @@ static void cfq_exit_io_context(struct io_context *ioc)
1294 n = rb_next(n); 1314 n = rb_next(n);
1295 } 1315 }
1296 1316
1297 read_unlock_irqrestore(&cfq_exit_lock, flags); 1317 spin_unlock_irqrestore(&cfq_exit_lock, flags);
1298} 1318}
1299 1319
1300static struct cfq_io_context * 1320static struct cfq_io_context *
@@ -1400,17 +1420,17 @@ static int cfq_ioc_set_ioprio(struct io_context *ioc, unsigned int ioprio)
1400 struct cfq_io_context *cic; 1420 struct cfq_io_context *cic;
1401 struct rb_node *n; 1421 struct rb_node *n;
1402 1422
1403 write_lock(&cfq_exit_lock); 1423 spin_lock(&cfq_exit_lock);
1404 1424
1405 n = rb_first(&ioc->cic_root); 1425 n = rb_first(&ioc->cic_root);
1406 while (n != NULL) { 1426 while (n != NULL) {
1407 cic = rb_entry(n, struct cfq_io_context, rb_node); 1427 cic = rb_entry(n, struct cfq_io_context, rb_node);
1408 1428
1409 changed_ioprio(cic); 1429 changed_ioprio(cic);
1410 n = rb_next(n); 1430 n = rb_next(n);
1411 } 1431 }
1412 1432
1413 write_unlock(&cfq_exit_lock); 1433 spin_unlock(&cfq_exit_lock);
1414 1434
1415 return 0; 1435 return 0;
1416} 1436}
@@ -1458,7 +1478,8 @@ retry:
1458 * set ->slice_left to allow preemption for a new process 1478 * set ->slice_left to allow preemption for a new process
1459 */ 1479 */
1460 cfqq->slice_left = 2 * cfqd->cfq_slice_idle; 1480 cfqq->slice_left = 2 * cfqd->cfq_slice_idle;
1461 cfq_mark_cfqq_idle_window(cfqq); 1481 if (!cfqd->hw_tag)
1482 cfq_mark_cfqq_idle_window(cfqq);
1462 cfq_mark_cfqq_prio_changed(cfqq); 1483 cfq_mark_cfqq_prio_changed(cfqq);
1463 cfq_init_prio_data(cfqq); 1484 cfq_init_prio_data(cfqq);
1464 } 1485 }
@@ -1475,9 +1496,10 @@ out:
1475static void 1496static void
1476cfq_drop_dead_cic(struct io_context *ioc, struct cfq_io_context *cic) 1497cfq_drop_dead_cic(struct io_context *ioc, struct cfq_io_context *cic)
1477{ 1498{
1478 read_lock(&cfq_exit_lock); 1499 spin_lock(&cfq_exit_lock);
1479 rb_erase(&cic->rb_node, &ioc->cic_root); 1500 rb_erase(&cic->rb_node, &ioc->cic_root);
1480 read_unlock(&cfq_exit_lock); 1501 list_del_init(&cic->queue_list);
1502 spin_unlock(&cfq_exit_lock);
1481 kmem_cache_free(cfq_ioc_pool, cic); 1503 kmem_cache_free(cfq_ioc_pool, cic);
1482 atomic_dec(&ioc_count); 1504 atomic_dec(&ioc_count);
1483} 1505}
@@ -1545,11 +1567,11 @@ restart:
1545 BUG(); 1567 BUG();
1546 } 1568 }
1547 1569
1548 read_lock(&cfq_exit_lock); 1570 spin_lock(&cfq_exit_lock);
1549 rb_link_node(&cic->rb_node, parent, p); 1571 rb_link_node(&cic->rb_node, parent, p);
1550 rb_insert_color(&cic->rb_node, &ioc->cic_root); 1572 rb_insert_color(&cic->rb_node, &ioc->cic_root);
1551 list_add(&cic->queue_list, &cfqd->cic_list); 1573 list_add(&cic->queue_list, &cfqd->cic_list);
1552 read_unlock(&cfq_exit_lock); 1574 spin_unlock(&cfq_exit_lock);
1553} 1575}
1554 1576
1555/* 1577/*
@@ -1648,7 +1670,7 @@ cfq_update_idle_window(struct cfq_data *cfqd, struct cfq_queue *cfqq,
1648{ 1670{
1649 int enable_idle = cfq_cfqq_idle_window(cfqq); 1671 int enable_idle = cfq_cfqq_idle_window(cfqq);
1650 1672
1651 if (!cic->ioc->task || !cfqd->cfq_slice_idle) 1673 if (!cic->ioc->task || !cfqd->cfq_slice_idle || cfqd->hw_tag)
1652 enable_idle = 0; 1674 enable_idle = 0;
1653 else if (sample_valid(cic->ttime_samples)) { 1675 else if (sample_valid(cic->ttime_samples)) {
1654 if (cic->ttime_mean > cfqd->cfq_slice_idle) 1676 if (cic->ttime_mean > cfqd->cfq_slice_idle)
@@ -1739,14 +1761,24 @@ cfq_crq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq,
1739 1761
1740 cfqq->next_crq = cfq_choose_req(cfqd, cfqq->next_crq, crq); 1762 cfqq->next_crq = cfq_choose_req(cfqd, cfqq->next_crq, crq);
1741 1763
1764 cic = crq->io_context;
1765
1742 /* 1766 /*
1743 * we never wait for an async request and we don't allow preemption 1767 * we never wait for an async request and we don't allow preemption
1744 * of an async request. so just return early 1768 * of an async request. so just return early
1745 */ 1769 */
1746 if (!cfq_crq_is_sync(crq)) 1770 if (!cfq_crq_is_sync(crq)) {
1771 /*
1772 * sync process issued an async request, if it's waiting
1773 * then expire it and kick rq handling.
1774 */
1775 if (cic == cfqd->active_cic &&
1776 del_timer(&cfqd->idle_slice_timer)) {
1777 cfq_slice_expired(cfqd, 0);
1778 cfq_start_queueing(cfqd, cfqq);
1779 }
1747 return; 1780 return;
1748 1781 }
1749 cic = crq->io_context;
1750 1782
1751 cfq_update_io_thinktime(cfqd, cic); 1783 cfq_update_io_thinktime(cfqd, cic);
1752 cfq_update_io_seektime(cfqd, cic, crq); 1784 cfq_update_io_seektime(cfqd, cic, crq);
@@ -2164,10 +2196,9 @@ static void cfq_idle_class_timer(unsigned long data)
2164 * race with a non-idle queue, reset timer 2196 * race with a non-idle queue, reset timer
2165 */ 2197 */
2166 end = cfqd->last_end_request + CFQ_IDLE_GRACE; 2198 end = cfqd->last_end_request + CFQ_IDLE_GRACE;
2167 if (!time_after_eq(jiffies, end)) { 2199 if (!time_after_eq(jiffies, end))
2168 cfqd->idle_class_timer.expires = end; 2200 mod_timer(&cfqd->idle_class_timer, end);
2169 add_timer(&cfqd->idle_class_timer); 2201 else
2170 } else
2171 cfq_schedule_dispatch(cfqd); 2202 cfq_schedule_dispatch(cfqd);
2172 2203
2173 spin_unlock_irqrestore(cfqd->queue->queue_lock, flags); 2204 spin_unlock_irqrestore(cfqd->queue->queue_lock, flags);
@@ -2187,7 +2218,7 @@ static void cfq_exit_queue(elevator_t *e)
2187 2218
2188 cfq_shutdown_timer_wq(cfqd); 2219 cfq_shutdown_timer_wq(cfqd);
2189 2220
2190 write_lock(&cfq_exit_lock); 2221 spin_lock(&cfq_exit_lock);
2191 spin_lock_irq(q->queue_lock); 2222 spin_lock_irq(q->queue_lock);
2192 2223
2193 if (cfqd->active_queue) 2224 if (cfqd->active_queue)
@@ -2210,7 +2241,7 @@ static void cfq_exit_queue(elevator_t *e)
2210 } 2241 }
2211 2242
2212 spin_unlock_irq(q->queue_lock); 2243 spin_unlock_irq(q->queue_lock);
2213 write_unlock(&cfq_exit_lock); 2244 spin_unlock(&cfq_exit_lock);
2214 2245
2215 cfq_shutdown_timer_wq(cfqd); 2246 cfq_shutdown_timer_wq(cfqd);
2216 2247
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index eac48bec1479..7eb36c53f4b7 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -3452,7 +3452,12 @@ void end_that_request_last(struct request *req, int uptodate)
3452 if (unlikely(laptop_mode) && blk_fs_request(req)) 3452 if (unlikely(laptop_mode) && blk_fs_request(req))
3453 laptop_io_completion(); 3453 laptop_io_completion();
3454 3454
3455 if (disk && blk_fs_request(req)) { 3455 /*
3456 * Account IO completion. bar_rq isn't accounted as a normal
3457 * IO on queueing nor completion. Accounting the containing
3458 * request is enough.
3459 */
3460 if (disk && blk_fs_request(req) && req != &req->q->bar_rq) {
3456 unsigned long duration = jiffies - req->start_time; 3461 unsigned long duration = jiffies - req->start_time;
3457 const int rw = rq_data_dir(req); 3462 const int rw = rq_data_dir(req);
3458 3463
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 472318205236..0c99ae6a3407 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -86,18 +86,9 @@ firmware_timeout_store(struct class *class, const char *buf, size_t count)
86static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store); 86static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store);
87 87
88static void fw_class_dev_release(struct class_device *class_dev); 88static void fw_class_dev_release(struct class_device *class_dev);
89int firmware_class_uevent(struct class_device *dev, char **envp,
90 int num_envp, char *buffer, int buffer_size);
91 89
92static struct class firmware_class = { 90static int firmware_class_uevent(struct class_device *class_dev, char **envp,
93 .name = "firmware", 91 int num_envp, char *buffer, int buffer_size)
94 .uevent = firmware_class_uevent,
95 .release = fw_class_dev_release,
96};
97
98int
99firmware_class_uevent(struct class_device *class_dev, char **envp,
100 int num_envp, char *buffer, int buffer_size)
101{ 92{
102 struct firmware_priv *fw_priv = class_get_devdata(class_dev); 93 struct firmware_priv *fw_priv = class_get_devdata(class_dev);
103 int i = 0, len = 0; 94 int i = 0, len = 0;
@@ -116,6 +107,12 @@ firmware_class_uevent(struct class_device *class_dev, char **envp,
116 return 0; 107 return 0;
117} 108}
118 109
110static struct class firmware_class = {
111 .name = "firmware",
112 .uevent = firmware_class_uevent,
113 .release = fw_class_dev_release,
114};
115
119static ssize_t 116static ssize_t
120firmware_loading_show(struct class_device *class_dev, char *buf) 117firmware_loading_show(struct class_device *class_dev, char *buf)
121{ 118{
@@ -493,25 +490,6 @@ release_firmware(const struct firmware *fw)
493 } 490 }
494} 491}
495 492
496/**
497 * register_firmware: - provide a firmware image for later usage
498 * @name: name of firmware image file
499 * @data: buffer pointer for the firmware image
500 * @size: size of the data buffer area
501 *
502 * Make sure that @data will be available by requesting firmware @name.
503 *
504 * Note: This will not be possible until some kind of persistence
505 * is available.
506 **/
507void
508register_firmware(const char *name, const u8 *data, size_t size)
509{
510 /* This is meaningless without firmware caching, so until we
511 * decide if firmware caching is reasonable just leave it as a
512 * noop */
513}
514
515/* Async support */ 493/* Async support */
516struct firmware_work { 494struct firmware_work {
517 struct work_struct work; 495 struct work_struct work;
@@ -630,4 +608,3 @@ module_exit(firmware_class_exit);
630EXPORT_SYMBOL(release_firmware); 608EXPORT_SYMBOL(release_firmware);
631EXPORT_SYMBOL(request_firmware); 609EXPORT_SYMBOL(request_firmware);
632EXPORT_SYMBOL(request_firmware_nowait); 610EXPORT_SYMBOL(request_firmware_nowait);
633EXPORT_SYMBOL(register_firmware);
diff --git a/drivers/base/power/suspend.c b/drivers/base/power/suspend.c
index 662209d3f42d..2a769cc6f5f9 100644
--- a/drivers/base/power/suspend.c
+++ b/drivers/base/power/suspend.c
@@ -8,7 +8,6 @@
8 * 8 *
9 */ 9 */
10 10
11#include <linux/vt_kern.h>
12#include <linux/device.h> 11#include <linux/device.h>
13#include <linux/kallsyms.h> 12#include <linux/kallsyms.h>
14#include <linux/pm.h> 13#include <linux/pm.h>
@@ -66,6 +65,7 @@ int suspend_device(struct device * dev, pm_message_t state)
66 return error; 65 return error;
67} 66}
68 67
68
69/** 69/**
70 * device_suspend - Save state and stop all devices in system. 70 * device_suspend - Save state and stop all devices in system.
71 * @state: Power state to put each device in. 71 * @state: Power state to put each device in.
@@ -85,9 +85,6 @@ int device_suspend(pm_message_t state)
85{ 85{
86 int error = 0; 86 int error = 0;
87 87
88 if (!is_console_suspend_safe())
89 return -EINVAL;
90
91 down(&dpm_sem); 88 down(&dpm_sem);
92 down(&dpm_list_sem); 89 down(&dpm_list_sem);
93 while (!list_empty(&dpm_active) && error == 0) { 90 while (!list_empty(&dpm_active) && error == 0) {
diff --git a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig
index 0b9cf9c59a21..7c88c060a9e6 100644
--- a/drivers/char/agp/Kconfig
+++ b/drivers/char/agp/Kconfig
@@ -86,7 +86,7 @@ config AGP_NVIDIA
86 86
87config AGP_SIS 87config AGP_SIS
88 tristate "SiS chipset support" 88 tristate "SiS chipset support"
89 depends on AGP && X86_32 89 depends on AGP
90 help 90 help
91 This option gives you AGP support for the GLX component of 91 This option gives you AGP support for the GLX component of
92 X on Silicon Integrated Systems [SiS] chipsets. 92 X on Silicon Integrated Systems [SiS] chipsets.
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 36517d4d1ad9..ac3c33a2e37d 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -617,6 +617,9 @@ static int agp_amd64_resume(struct pci_dev *pdev)
617 pci_set_power_state(pdev, PCI_D0); 617 pci_set_power_state(pdev, PCI_D0);
618 pci_restore_state(pdev); 618 pci_restore_state(pdev);
619 619
620 if (pdev->vendor == PCI_VENDOR_ID_NVIDIA)
621 nforce3_agp_init(pdev);
622
620 return amd_8151_configure(); 623 return amd_8151_configure();
621} 624}
622 625
diff --git a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c
index 97b0a890ba7f..b8ec25d17478 100644
--- a/drivers/char/agp/via-agp.c
+++ b/drivers/char/agp/via-agp.c
@@ -345,6 +345,12 @@ static struct agp_device_ids via_agp_device_ids[] __devinitdata =
345 .chipset_name = "PT880", 345 .chipset_name = "PT880",
346 }, 346 },
347 347
348 /* PT880 Ultra */
349 {
350 .device_id = PCI_DEVICE_ID_VIA_PT880ULTRA,
351 .chipset_name = "PT880 Ultra",
352 },
353
348 /* PT890 */ 354 /* PT890 */
349 { 355 {
350 .device_id = PCI_DEVICE_ID_VIA_8783_0, 356 .device_id = PCI_DEVICE_ID_VIA_8783_0,
@@ -511,6 +517,7 @@ static struct pci_device_id agp_via_pci_table[] = {
511 ID(PCI_DEVICE_ID_VIA_8763_0), 517 ID(PCI_DEVICE_ID_VIA_8763_0),
512 ID(PCI_DEVICE_ID_VIA_8378_0), 518 ID(PCI_DEVICE_ID_VIA_8378_0),
513 ID(PCI_DEVICE_ID_VIA_PT880), 519 ID(PCI_DEVICE_ID_VIA_PT880),
520 ID(PCI_DEVICE_ID_VIA_PT880ULTRA),
514 ID(PCI_DEVICE_ID_VIA_8783_0), 521 ID(PCI_DEVICE_ID_VIA_8783_0),
515 ID(PCI_DEVICE_ID_VIA_PX8X0_0), 522 ID(PCI_DEVICE_ID_VIA_PX8X0_0),
516 ID(PCI_DEVICE_ID_VIA_3269_0), 523 ID(PCI_DEVICE_ID_VIA_3269_0),
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index b36eef0e9d19..02a7dd7a8a55 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -1184,20 +1184,20 @@ static void port_outl(struct si_sm_io *io, unsigned int offset,
1184static void port_cleanup(struct smi_info *info) 1184static void port_cleanup(struct smi_info *info)
1185{ 1185{
1186 unsigned int addr = info->io.addr_data; 1186 unsigned int addr = info->io.addr_data;
1187 int mapsize; 1187 int idx;
1188 1188
1189 if (addr) { 1189 if (addr) {
1190 mapsize = ((info->io_size * info->io.regspacing) 1190 for (idx = 0; idx < info->io_size; idx++) {
1191 - (info->io.regspacing - info->io.regsize)); 1191 release_region(addr + idx * info->io.regspacing,
1192 1192 info->io.regsize);
1193 release_region (addr, mapsize); 1193 }
1194 } 1194 }
1195} 1195}
1196 1196
1197static int port_setup(struct smi_info *info) 1197static int port_setup(struct smi_info *info)
1198{ 1198{
1199 unsigned int addr = info->io.addr_data; 1199 unsigned int addr = info->io.addr_data;
1200 int mapsize; 1200 int idx;
1201 1201
1202 if (!addr) 1202 if (!addr)
1203 return -ENODEV; 1203 return -ENODEV;
@@ -1225,16 +1225,22 @@ static int port_setup(struct smi_info *info)
1225 return -EINVAL; 1225 return -EINVAL;
1226 } 1226 }
1227 1227
1228 /* Calculate the total amount of memory to claim. This is an 1228 /* Some BIOSes reserve disjoint I/O regions in their ACPI
1229 * unusual looking calculation, but it avoids claiming any 1229 * tables. This causes problems when trying to register the
1230 * more memory than it has to. It will claim everything 1230 * entire I/O region. Therefore we must register each I/O
1231 * between the first address to the end of the last full 1231 * port separately.
1232 * register. */ 1232 */
1233 mapsize = ((info->io_size * info->io.regspacing) 1233 for (idx = 0; idx < info->io_size; idx++) {
1234 - (info->io.regspacing - info->io.regsize)); 1234 if (request_region(addr + idx * info->io.regspacing,
1235 1235 info->io.regsize, DEVICE_NAME) == NULL) {
1236 if (request_region(addr, mapsize, DEVICE_NAME) == NULL) 1236 /* Undo allocations */
1237 return -EIO; 1237 while (idx--) {
1238 release_region(addr + idx * info->io.regspacing,
1239 info->io.regsize);
1240 }
1241 return -EIO;
1242 }
1243 }
1238 return 0; 1244 return 0;
1239} 1245}
1240 1246
diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c
index e45f0d3d12de..a611972024e6 100644
--- a/drivers/char/tpm/tpm_bios.c
+++ b/drivers/char/tpm/tpm_bios.c
@@ -105,6 +105,12 @@ static const char* tcpa_event_type_strings[] = {
105 "Non-Host Info" 105 "Non-Host Info"
106}; 106};
107 107
108struct tcpa_pc_event {
109 u32 event_id;
110 u32 event_size;
111 u8 event_data[0];
112};
113
108enum tcpa_pc_event_ids { 114enum tcpa_pc_event_ids {
109 SMBIOS = 1, 115 SMBIOS = 1,
110 BIS_CERT, 116 BIS_CERT,
@@ -114,14 +120,15 @@ enum tcpa_pc_event_ids {
114 NVRAM, 120 NVRAM,
115 OPTION_ROM_EXEC, 121 OPTION_ROM_EXEC,
116 OPTION_ROM_CONFIG, 122 OPTION_ROM_CONFIG,
117 OPTION_ROM_MICROCODE, 123 OPTION_ROM_MICROCODE = 10,
118 S_CRTM_VERSION, 124 S_CRTM_VERSION,
119 S_CRTM_CONTENTS, 125 S_CRTM_CONTENTS,
120 POST_CONTENTS, 126 POST_CONTENTS,
127 HOST_TABLE_OF_DEVICES,
121}; 128};
122 129
123static const char* tcpa_pc_event_id_strings[] = { 130static const char* tcpa_pc_event_id_strings[] = {
124 "" 131 "",
125 "SMBIOS", 132 "SMBIOS",
126 "BIS Certificate", 133 "BIS Certificate",
127 "POST BIOS ", 134 "POST BIOS ",
@@ -130,11 +137,12 @@ static const char* tcpa_pc_event_id_strings[] = {
130 "NVRAM", 137 "NVRAM",
131 "Option ROM", 138 "Option ROM",
132 "Option ROM config", 139 "Option ROM config",
133 "Option ROM microcode", 140 "",
141 "Option ROM microcode ",
134 "S-CRTM Version", 142 "S-CRTM Version",
135 "S-CRTM Contents", 143 "S-CRTM Contents ",
136 "S-CRTM POST Contents", 144 "POST Contents ",
137 "POST Contents", 145 "Table of Devices",
138}; 146};
139 147
140/* returns pointer to start of pos. entry of tcg log */ 148/* returns pointer to start of pos. entry of tcg log */
@@ -206,7 +214,7 @@ static int get_event_name(char *dest, struct tcpa_event *event,
206 const char *name = ""; 214 const char *name = "";
207 char data[40] = ""; 215 char data[40] = "";
208 int i, n_len = 0, d_len = 0; 216 int i, n_len = 0, d_len = 0;
209 u32 event_id; 217 struct tcpa_pc_event *pc_event;
210 218
211 switch(event->event_type) { 219 switch(event->event_type) {
212 case PREBOOT: 220 case PREBOOT:
@@ -235,31 +243,32 @@ static int get_event_name(char *dest, struct tcpa_event *event,
235 } 243 }
236 break; 244 break;
237 case EVENT_TAG: 245 case EVENT_TAG:
238 event_id = be32_to_cpu(*((u32 *)event_entry)); 246 pc_event = (struct tcpa_pc_event *)event_entry;
239 247
240 /* ToDo Row data -> Base64 */ 248 /* ToDo Row data -> Base64 */
241 249
242 switch (event_id) { 250 switch (pc_event->event_id) {
243 case SMBIOS: 251 case SMBIOS:
244 case BIS_CERT: 252 case BIS_CERT:
245 case CMOS: 253 case CMOS:
246 case NVRAM: 254 case NVRAM:
247 case OPTION_ROM_EXEC: 255 case OPTION_ROM_EXEC:
248 case OPTION_ROM_CONFIG: 256 case OPTION_ROM_CONFIG:
249 case OPTION_ROM_MICROCODE:
250 case S_CRTM_VERSION: 257 case S_CRTM_VERSION:
251 case S_CRTM_CONTENTS: 258 name = tcpa_pc_event_id_strings[pc_event->event_id];
252 case POST_CONTENTS:
253 name = tcpa_pc_event_id_strings[event_id];
254 n_len = strlen(name); 259 n_len = strlen(name);
255 break; 260 break;
261 /* hash data */
256 case POST_BIOS_ROM: 262 case POST_BIOS_ROM:
257 case ESCD: 263 case ESCD:
258 name = tcpa_pc_event_id_strings[event_id]; 264 case OPTION_ROM_MICROCODE:
265 case S_CRTM_CONTENTS:
266 case POST_CONTENTS:
267 name = tcpa_pc_event_id_strings[pc_event->event_id];
259 n_len = strlen(name); 268 n_len = strlen(name);
260 for (i = 0; i < 20; i++) 269 for (i = 0; i < 20; i++)
261 d_len += sprintf(data, "%02x", 270 d_len += sprintf(&data[2*i], "%02x",
262 event_entry[8 + i]); 271 pc_event->event_data[i]);
263 break; 272 break;
264 default: 273 default:
265 break; 274 break;
@@ -275,53 +284,13 @@ static int get_event_name(char *dest, struct tcpa_event *event,
275 284
276static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v) 285static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
277{ 286{
287 struct tcpa_event *event = v;
288 char *data = v;
289 int i;
278 290
279 char *eventname; 291 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
280 char data[4];
281 u32 help;
282 int i, len;
283 struct tcpa_event *event = (struct tcpa_event *) v;
284 unsigned char *event_entry =
285 (unsigned char *) (v + sizeof(struct tcpa_event));
286
287 eventname = kmalloc(MAX_TEXT_EVENT, GFP_KERNEL);
288 if (!eventname) {
289 printk(KERN_ERR "%s: ERROR - No Memory for event name\n ",
290 __func__);
291 return -ENOMEM;
292 }
293
294 /* 1st: PCR used is in little-endian format (4 bytes) */
295 help = le32_to_cpu(event->pcr_index);
296 memcpy(data, &help, 4);
297 for (i = 0; i < 4; i++)
298 seq_putc(m, data[i]);
299
300 /* 2nd: SHA1 (20 bytes) */
301 for (i = 0; i < 20; i++)
302 seq_putc(m, event->pcr_value[i]);
303
304 /* 3rd: event type identifier (4 bytes) */
305 help = le32_to_cpu(event->event_type);
306 memcpy(data, &help, 4);
307 for (i = 0; i < 4; i++)
308 seq_putc(m, data[i]); 292 seq_putc(m, data[i]);
309 293
310 len = 0;
311
312 len += get_event_name(eventname, event, event_entry);
313
314 /* 4th: filename <= 255 + \'0' delimiter */
315 if (len > TCG_EVENT_NAME_LEN_MAX)
316 len = TCG_EVENT_NAME_LEN_MAX;
317
318 for (i = 0; i < len; i++)
319 seq_putc(m, eventname[i]);
320
321 /* 5th: delimiter */
322 seq_putc(m, '\0');
323
324 kfree(eventname);
325 return 0; 294 return 0;
326} 295}
327 296
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index f621168f38ae..8ea70625f7ea 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -457,10 +457,6 @@ static int __devinit tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
457 } 457 }
458 458
459 vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0)); 459 vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0));
460 if ((vendor & 0xFFFF) == 0xFFFF) {
461 rc = -ENODEV;
462 goto out_err;
463 }
464 460
465 /* Default timeouts */ 461 /* Default timeouts */
466 chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT); 462 chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index f07637a8f88f..a88b94a82b14 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -398,7 +398,7 @@ int tty_insert_flip_string_flags(struct tty_struct *tty,
398 while (unlikely(size > copied)); 398 while (unlikely(size > copied));
399 return copied; 399 return copied;
400} 400}
401EXPORT_SYMBOL_GPL(tty_insert_flip_string_flags); 401EXPORT_SYMBOL(tty_insert_flip_string_flags);
402 402
403void tty_schedule_flip(struct tty_struct *tty) 403void tty_schedule_flip(struct tty_struct *tty)
404{ 404{
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index acc5d47844eb..6c94879e0b99 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -3238,14 +3238,6 @@ void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org)
3238 } 3238 }
3239} 3239}
3240 3240
3241int is_console_suspend_safe(void)
3242{
3243 /* It is unsafe to suspend devices while X has control of the
3244 * hardware. Make sure we are running on a kernel-controlled console.
3245 */
3246 return vc_cons[fg_console].d->vc_mode == KD_TEXT;
3247}
3248
3249/* 3241/*
3250 * Visible symbols for modules 3242 * Visible symbols for modules
3251 */ 3243 */
diff --git a/drivers/char/watchdog/i8xx_tco.c b/drivers/char/watchdog/i8xx_tco.c
index a13395e2c372..fa2ba9ebe42a 100644
--- a/drivers/char/watchdog/i8xx_tco.c
+++ b/drivers/char/watchdog/i8xx_tco.c
@@ -33,11 +33,6 @@
33 * 82801E (C-ICH) : document number 273599-001, 273645-002, 33 * 82801E (C-ICH) : document number 273599-001, 273645-002,
34 * 82801EB (ICH5) : document number 252516-001, 252517-003, 34 * 82801EB (ICH5) : document number 252516-001, 252517-003,
35 * 82801ER (ICH5R) : document number 252516-001, 252517-003, 35 * 82801ER (ICH5R) : document number 252516-001, 252517-003,
36 * 82801FB (ICH6) : document number 301473-002, 301474-007,
37 * 82801FR (ICH6R) : document number 301473-002, 301474-007,
38 * 82801FBM (ICH6-M) : document number 301473-002, 301474-007,
39 * 82801FW (ICH6W) : document number 301473-001, 301474-007,
40 * 82801FRW (ICH6RW) : document number 301473-001, 301474-007
41 * 36 *
42 * 20000710 Nils Faerber 37 * 20000710 Nils Faerber
43 * Initial Version 0.01 38 * Initial Version 0.01
@@ -66,6 +61,10 @@
66 * 20050807 Wim Van Sebroeck <wim@iguana.be> 61 * 20050807 Wim Van Sebroeck <wim@iguana.be>
67 * 0.08 Make sure that the watchdog is only "armed" when started. 62 * 0.08 Make sure that the watchdog is only "armed" when started.
68 * (Kernel Bug 4251) 63 * (Kernel Bug 4251)
64 * 20060416 Wim Van Sebroeck <wim@iguana.be>
65 * 0.09 Remove support for the ICH6, ICH6R, ICH6-M, ICH6W and ICH6RW and
66 * ICH7 chipsets. (See Kernel Bug 6031 - other code will support these
67 * chipsets)
69 */ 68 */
70 69
71/* 70/*
@@ -90,7 +89,7 @@
90#include "i8xx_tco.h" 89#include "i8xx_tco.h"
91 90
92/* Module and version information */ 91/* Module and version information */
93#define TCO_VERSION "0.08" 92#define TCO_VERSION "0.09"
94#define TCO_MODULE_NAME "i8xx TCO timer" 93#define TCO_MODULE_NAME "i8xx TCO timer"
95#define TCO_DRIVER_NAME TCO_MODULE_NAME ", v" TCO_VERSION 94#define TCO_DRIVER_NAME TCO_MODULE_NAME ", v" TCO_VERSION
96#define PFX TCO_MODULE_NAME ": " 95#define PFX TCO_MODULE_NAME ": "
@@ -391,11 +390,6 @@ static struct pci_device_id i8xx_tco_pci_tbl[] = {
391 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, PCI_ANY_ID, PCI_ANY_ID, }, 390 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, PCI_ANY_ID, PCI_ANY_ID, },
392 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801E_0, PCI_ANY_ID, PCI_ANY_ID, }, 391 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801E_0, PCI_ANY_ID, PCI_ANY_ID, },
393 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, PCI_ANY_ID, PCI_ANY_ID, }, 392 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, PCI_ANY_ID, PCI_ANY_ID, },
394 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_0, PCI_ANY_ID, PCI_ANY_ID, },
395 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, PCI_ANY_ID, PCI_ANY_ID, },
396 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_2, PCI_ANY_ID, PCI_ANY_ID, },
397 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0, PCI_ANY_ID, PCI_ANY_ID, },
398 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1, PCI_ANY_ID, PCI_ANY_ID, },
399 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1, PCI_ANY_ID, PCI_ANY_ID, }, 393 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1, PCI_ANY_ID, PCI_ANY_ID, },
400 { 0, }, /* End of list */ 394 { 0, }, /* End of list */
401}; 395};
diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c
index 9dc54736e4eb..1ea04e9b2b0b 100644
--- a/drivers/char/watchdog/s3c2410_wdt.c
+++ b/drivers/char/watchdog/s3c2410_wdt.c
@@ -423,6 +423,12 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
423 if (tmr_atboot && started == 0) { 423 if (tmr_atboot && started == 0) {
424 printk(KERN_INFO PFX "Starting Watchdog Timer\n"); 424 printk(KERN_INFO PFX "Starting Watchdog Timer\n");
425 s3c2410wdt_start(); 425 s3c2410wdt_start();
426 } else if (!tmr_atboot) {
427 /* if we're not enabling the watchdog, then ensure it is
428 * disabled if it has been left running from the bootloader
429 * or other source */
430
431 s3c2410wdt_stop();
426 } 432 }
427 433
428 return 0; 434 return 0;
diff --git a/drivers/char/watchdog/sc1200wdt.c b/drivers/char/watchdog/sc1200wdt.c
index 515ce7572049..20b88f9b7be2 100644
--- a/drivers/char/watchdog/sc1200wdt.c
+++ b/drivers/char/watchdog/sc1200wdt.c
@@ -377,7 +377,7 @@ static int __init sc1200wdt_init(void)
377{ 377{
378 int ret; 378 int ret;
379 379
380 printk(banner); 380 printk("%s\n", banner);
381 381
382 spin_lock_init(&sc1200wdt_lock); 382 spin_lock_init(&sc1200wdt_lock);
383 sema_init(&open_sem, 1); 383 sema_init(&open_sem, 1);
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index a140e4536a4e..766cc969c4d0 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -491,7 +491,7 @@ static struct pci_device_id divil_pci[] = {
491 491
492#define MSR_LBAR_SMB 0x5140000B 492#define MSR_LBAR_SMB 0x5140000B
493 493
494static int scx200_add_cs553x(void) 494static __init int scx200_add_cs553x(void)
495{ 495{
496 u32 low, hi; 496 u32 low, hi;
497 u32 smb_base; 497 u32 smb_base;
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 43b96e298363..27c9eb989a9a 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -345,17 +345,17 @@ sgiioc4_resetproc(ide_drive_t * drive)
345static u8 345static u8
346sgiioc4_INB(unsigned long port) 346sgiioc4_INB(unsigned long port)
347{ 347{
348 u8 reg = (u8) inb(port); 348 u8 reg = (u8) readb((void __iomem *) port);
349 349
350 if ((port & 0xFFF) == 0x11C) { /* Status register of IOC4 */ 350 if ((port & 0xFFF) == 0x11C) { /* Status register of IOC4 */
351 if (reg & 0x51) { /* Not busy...check for interrupt */ 351 if (reg & 0x51) { /* Not busy...check for interrupt */
352 unsigned long other_ir = port - 0x110; 352 unsigned long other_ir = port - 0x110;
353 unsigned int intr_reg = (u32) inl(other_ir); 353 unsigned int intr_reg = (u32) readl((void __iomem *) other_ir);
354 354
355 /* Clear the Interrupt, Error bits on the IOC4 */ 355 /* Clear the Interrupt, Error bits on the IOC4 */
356 if (intr_reg & 0x03) { 356 if (intr_reg & 0x03) {
357 outl(0x03, other_ir); 357 writel(0x03, (void __iomem *) other_ir);
358 intr_reg = (u32) inl(other_ir); 358 intr_reg = (u32) readl((void __iomem *) other_ir);
359 } 359 }
360 } 360 }
361 } 361 }
@@ -606,6 +606,12 @@ ide_init_sgiioc4(ide_hwif_t * hwif)
606 hwif->ide_dma_host_off = &sgiioc4_ide_dma_host_off; 606 hwif->ide_dma_host_off = &sgiioc4_ide_dma_host_off;
607 hwif->ide_dma_lostirq = &sgiioc4_ide_dma_lostirq; 607 hwif->ide_dma_lostirq = &sgiioc4_ide_dma_lostirq;
608 hwif->ide_dma_timeout = &__ide_dma_timeout; 608 hwif->ide_dma_timeout = &__ide_dma_timeout;
609
610 /*
611 * The IOC4 uses MMIO rather than Port IO.
612 * It also needs special workarounds for INB.
613 */
614 default_hwif_mmiops(hwif);
609 hwif->INB = &sgiioc4_INB; 615 hwif->INB = &sgiioc4_INB;
610} 616}
611 617
@@ -743,6 +749,6 @@ ioc4_ide_exit(void)
743module_init(ioc4_ide_init); 749module_init(ioc4_ide_init);
744module_exit(ioc4_ide_exit); 750module_exit(ioc4_ide_exit);
745 751
746MODULE_AUTHOR("Aniket Malatpure - Silicon Graphics Inc. (SGI)"); 752MODULE_AUTHOR("Aniket Malatpure/Jeremy Higdon");
747MODULE_DESCRIPTION("IDE PCI driver module for SGI IOC4 Base-IO Card"); 753MODULE_DESCRIPTION("IDE PCI driver module for SGI IOC4 Base-IO Card");
748MODULE_LICENSE("GPL"); 754MODULE_LICENSE("GPL");
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 78e30f803671..ffca8b63ee79 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -553,6 +553,8 @@ pmac_ide_init_hwif_ports(hw_regs_t *hw,
553 553
554 if (irq != NULL) 554 if (irq != NULL)
555 *irq = pmac_ide[ix].irq; 555 *irq = pmac_ide[ix].irq;
556
557 hw->dev = &pmac_ide[ix].mdev->ofdev.dev;
556} 558}
557 559
558#define PMAC_IDE_REG(x) ((void __iomem *)(IDE_DATA_REG+(x))) 560#define PMAC_IDE_REG(x) ((void __iomem *)(IDE_DATA_REG+(x)))
diff --git a/drivers/infiniband/core/uverbs_mem.c b/drivers/infiniband/core/uverbs_mem.c
index 36a32c315668..efe147dbeb42 100644
--- a/drivers/infiniband/core/uverbs_mem.c
+++ b/drivers/infiniband/core/uverbs_mem.c
@@ -211,8 +211,10 @@ void ib_umem_release_on_close(struct ib_device *dev, struct ib_umem *umem)
211 */ 211 */
212 212
213 work = kmalloc(sizeof *work, GFP_KERNEL); 213 work = kmalloc(sizeof *work, GFP_KERNEL);
214 if (!work) 214 if (!work) {
215 mmput(mm);
215 return; 216 return;
217 }
216 218
217 INIT_WORK(&work->work, ib_umem_account, work); 219 INIT_WORK(&work->work, ib_umem_account, work);
218 work->mm = mm; 220 work->mm = mm;
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c
index 3697edafd6d2..dddcdae736ac 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -1905,19 +1905,19 @@ static void __exit infinipath_cleanup(void)
1905 } else 1905 } else
1906 ipath_dbg("irq is 0, not doing free_irq " 1906 ipath_dbg("irq is 0, not doing free_irq "
1907 "for unit %u\n", dd->ipath_unit); 1907 "for unit %u\n", dd->ipath_unit);
1908 dd->pcidev = NULL;
1909 }
1910 1908
1911 /* 1909 /*
1912 * we check for NULL here, because it's outside the kregbase 1910 * we check for NULL here, because it's outside
1913 * check, and we need to call it after the free_irq. Thus 1911 * the kregbase check, and we need to call it
1914 * it's possible that the function pointers were never 1912 * after the free_irq. Thus it's possible that
1915 * initialized. 1913 * the function pointers were never initialized.
1916 */ 1914 */
1917 if (dd->ipath_f_cleanup) 1915 if (dd->ipath_f_cleanup)
1918 /* clean up chip-specific stuff */ 1916 /* clean up chip-specific stuff */
1919 dd->ipath_f_cleanup(dd); 1917 dd->ipath_f_cleanup(dd);
1920 1918
1919 dd->pcidev = NULL;
1920 }
1921 spin_lock_irqsave(&ipath_devs_lock, flags); 1921 spin_lock_irqsave(&ipath_devs_lock, flags);
1922 } 1922 }
1923 1923
diff --git a/drivers/infiniband/hw/ipath/ipath_eeprom.c b/drivers/infiniband/hw/ipath/ipath_eeprom.c
index f11a900e8cd7..a2f1ceafcca9 100644
--- a/drivers/infiniband/hw/ipath/ipath_eeprom.c
+++ b/drivers/infiniband/hw/ipath/ipath_eeprom.c
@@ -505,11 +505,10 @@ static u8 flash_csum(struct ipath_flash *ifp, int adjust)
505 * ipath_get_guid - get the GUID from the i2c device 505 * ipath_get_guid - get the GUID from the i2c device
506 * @dd: the infinipath device 506 * @dd: the infinipath device
507 * 507 *
508 * When we add the multi-chip support, we will probably have to add 508 * We have the capability to use the ipath_nguid field, and get
509 * the ability to use the number of guids field, and get the guid from 509 * the guid from the first chip's flash, to use for all of them.
510 * the first chip's flash, to use for all of them.
511 */ 510 */
512void ipath_get_guid(struct ipath_devdata *dd) 511void ipath_get_eeprom_info(struct ipath_devdata *dd)
513{ 512{
514 void *buf; 513 void *buf;
515 struct ipath_flash *ifp; 514 struct ipath_flash *ifp;
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index c347191f02bf..ada267e41f6c 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -139,7 +139,7 @@ static int ipath_get_base_info(struct ipath_portdata *pd,
139 kinfo->spi_piosize = dd->ipath_ibmaxlen; 139 kinfo->spi_piosize = dd->ipath_ibmaxlen;
140 kinfo->spi_mtu = dd->ipath_ibmaxlen; /* maxlen, not ibmtu */ 140 kinfo->spi_mtu = dd->ipath_ibmaxlen; /* maxlen, not ibmtu */
141 kinfo->spi_port = pd->port_port; 141 kinfo->spi_port = pd->port_port;
142 kinfo->spi_sw_version = IPATH_USER_SWVERSION; 142 kinfo->spi_sw_version = IPATH_KERN_SWVERSION;
143 kinfo->spi_hw_version = dd->ipath_revision; 143 kinfo->spi_hw_version = dd->ipath_revision;
144 144
145 if (copy_to_user(ubase, kinfo, sizeof(*kinfo))) 145 if (copy_to_user(ubase, kinfo, sizeof(*kinfo)))
@@ -1224,6 +1224,10 @@ static unsigned int ipath_poll(struct file *fp,
1224 1224
1225 if (tail == head) { 1225 if (tail == head) {
1226 set_bit(IPATH_PORT_WAITING_RCV, &pd->port_flag); 1226 set_bit(IPATH_PORT_WAITING_RCV, &pd->port_flag);
1227 if(dd->ipath_rhdrhead_intr_off) /* arm rcv interrupt */
1228 (void)ipath_write_ureg(dd, ur_rcvhdrhead,
1229 dd->ipath_rhdrhead_intr_off
1230 | head, pd->port_port);
1227 poll_wait(fp, &pd->port_wait, pt); 1231 poll_wait(fp, &pd->port_wait, pt);
1228 1232
1229 if (test_bit(IPATH_PORT_WAITING_RCV, &pd->port_flag)) { 1233 if (test_bit(IPATH_PORT_WAITING_RCV, &pd->port_flag)) {
diff --git a/drivers/infiniband/hw/ipath/ipath_ht400.c b/drivers/infiniband/hw/ipath/ipath_ht400.c
index 4652435998f3..fac0a2b74de2 100644
--- a/drivers/infiniband/hw/ipath/ipath_ht400.c
+++ b/drivers/infiniband/hw/ipath/ipath_ht400.c
@@ -607,7 +607,12 @@ static int ipath_ht_boardname(struct ipath_devdata *dd, char *name,
607 case 4: /* Ponderosa is one of the bringup boards */ 607 case 4: /* Ponderosa is one of the bringup boards */
608 n = "Ponderosa"; 608 n = "Ponderosa";
609 break; 609 break;
610 case 5: /* HT-460 original production board */ 610 case 5:
611 /*
612 * HT-460 original production board; two production levels, with
613 * different serial number ranges. See ipath_ht_early_init() for
614 * case where we enable IPATH_GPIO_INTR for later serial # range.
615 */
611 n = "InfiniPath_HT-460"; 616 n = "InfiniPath_HT-460";
612 break; 617 break;
613 case 6: 618 case 6:
@@ -642,7 +647,7 @@ static int ipath_ht_boardname(struct ipath_devdata *dd, char *name,
642 if (n) 647 if (n)
643 snprintf(name, namelen, "%s", n); 648 snprintf(name, namelen, "%s", n);
644 649
645 if (dd->ipath_majrev != 3 || dd->ipath_minrev != 2) { 650 if (dd->ipath_majrev != 3 || (dd->ipath_minrev < 2 || dd->ipath_minrev > 3)) {
646 /* 651 /*
647 * This version of the driver only supports the HT-400 652 * This version of the driver only supports the HT-400
648 * Rev 3.2 653 * Rev 3.2
@@ -1520,6 +1525,18 @@ static int ipath_ht_early_init(struct ipath_devdata *dd)
1520 */ 1525 */
1521 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 1526 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl,
1522 INFINIPATH_S_ABORT); 1527 INFINIPATH_S_ABORT);
1528
1529 ipath_get_eeprom_info(dd);
1530 if(dd->ipath_boardrev == 5 && dd->ipath_serial[0] == '1' &&
1531 dd->ipath_serial[1] == '2' && dd->ipath_serial[2] == '8') {
1532 /*
1533 * Later production HT-460 has same changes as HT-465, so
1534 * can use GPIO interrupts. They have serial #'s starting
1535 * with 128, rather than 112.
1536 */
1537 dd->ipath_flags |= IPATH_GPIO_INTR;
1538 dd->ipath_flags &= ~IPATH_POLL_RX_INTR;
1539 }
1523 return 0; 1540 return 0;
1524} 1541}
1525 1542
diff --git a/drivers/infiniband/hw/ipath/ipath_init_chip.c b/drivers/infiniband/hw/ipath/ipath_init_chip.c
index 16f640e1c16e..dc83250d26a6 100644
--- a/drivers/infiniband/hw/ipath/ipath_init_chip.c
+++ b/drivers/infiniband/hw/ipath/ipath_init_chip.c
@@ -879,7 +879,6 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit)
879 879
880done: 880done:
881 if (!ret) { 881 if (!ret) {
882 ipath_get_guid(dd);
883 *dd->ipath_statusp |= IPATH_STATUS_CHIP_PRESENT; 882 *dd->ipath_statusp |= IPATH_STATUS_CHIP_PRESENT;
884 if (!dd->ipath_f_intrsetup(dd)) { 883 if (!dd->ipath_f_intrsetup(dd)) {
885 /* now we can enable all interrupts from the chip */ 884 /* now we can enable all interrupts from the chip */
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h
index e6507f8115bc..5d92d57b6f54 100644
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -650,7 +650,7 @@ u32 __iomem *ipath_getpiobuf(struct ipath_devdata *, u32 *);
650void ipath_init_pe800_funcs(struct ipath_devdata *); 650void ipath_init_pe800_funcs(struct ipath_devdata *);
651/* init HT-400-specific func */ 651/* init HT-400-specific func */
652void ipath_init_ht400_funcs(struct ipath_devdata *); 652void ipath_init_ht400_funcs(struct ipath_devdata *);
653void ipath_get_guid(struct ipath_devdata *); 653void ipath_get_eeprom_info(struct ipath_devdata *);
654u64 ipath_snap_cntr(struct ipath_devdata *, ipath_creg); 654u64 ipath_snap_cntr(struct ipath_devdata *, ipath_creg);
655 655
656/* 656/*
diff --git a/drivers/infiniband/hw/ipath/ipath_keys.c b/drivers/infiniband/hw/ipath/ipath_keys.c
index aa33b0e9f2f6..5ae8761f9dd2 100644
--- a/drivers/infiniband/hw/ipath/ipath_keys.c
+++ b/drivers/infiniband/hw/ipath/ipath_keys.c
@@ -136,9 +136,7 @@ int ipath_lkey_ok(struct ipath_lkey_table *rkt, struct ipath_sge *isge,
136 ret = 1; 136 ret = 1;
137 goto bail; 137 goto bail;
138 } 138 }
139 spin_lock(&rkt->lock);
140 mr = rkt->table[(sge->lkey >> (32 - ib_ipath_lkey_table_size))]; 139 mr = rkt->table[(sge->lkey >> (32 - ib_ipath_lkey_table_size))];
141 spin_unlock(&rkt->lock);
142 if (unlikely(mr == NULL || mr->lkey != sge->lkey)) { 140 if (unlikely(mr == NULL || mr->lkey != sge->lkey)) {
143 ret = 0; 141 ret = 0;
144 goto bail; 142 goto bail;
@@ -184,8 +182,6 @@ bail:
184 * @acc: access flags 182 * @acc: access flags
185 * 183 *
186 * Return 1 if successful, otherwise 0. 184 * Return 1 if successful, otherwise 0.
187 *
188 * The QP r_rq.lock should be held.
189 */ 185 */
190int ipath_rkey_ok(struct ipath_ibdev *dev, struct ipath_sge_state *ss, 186int ipath_rkey_ok(struct ipath_ibdev *dev, struct ipath_sge_state *ss,
191 u32 len, u64 vaddr, u32 rkey, int acc) 187 u32 len, u64 vaddr, u32 rkey, int acc)
@@ -196,9 +192,7 @@ int ipath_rkey_ok(struct ipath_ibdev *dev, struct ipath_sge_state *ss,
196 size_t off; 192 size_t off;
197 int ret; 193 int ret;
198 194
199 spin_lock(&rkt->lock);
200 mr = rkt->table[(rkey >> (32 - ib_ipath_lkey_table_size))]; 195 mr = rkt->table[(rkey >> (32 - ib_ipath_lkey_table_size))];
201 spin_unlock(&rkt->lock);
202 if (unlikely(mr == NULL || mr->lkey != rkey)) { 196 if (unlikely(mr == NULL || mr->lkey != rkey)) {
203 ret = 0; 197 ret = 0;
204 goto bail; 198 goto bail;
diff --git a/drivers/infiniband/hw/ipath/ipath_layer.c b/drivers/infiniband/hw/ipath/ipath_layer.c
index 9cb5258ffed9..9ec4ac77b87f 100644
--- a/drivers/infiniband/hw/ipath/ipath_layer.c
+++ b/drivers/infiniband/hw/ipath/ipath_layer.c
@@ -872,12 +872,13 @@ static void copy_io(u32 __iomem *piobuf, struct ipath_sge_state *ss,
872 update_sge(ss, len); 872 update_sge(ss, len);
873 length -= len; 873 length -= len;
874 } 874 }
875 /* Update address before sending packet. */
876 update_sge(ss, length);
875 /* must flush early everything before trigger word */ 877 /* must flush early everything before trigger word */
876 ipath_flush_wc(); 878 ipath_flush_wc();
877 __raw_writel(last, piobuf); 879 __raw_writel(last, piobuf);
878 /* be sure trigger word is written */ 880 /* be sure trigger word is written */
879 ipath_flush_wc(); 881 ipath_flush_wc();
880 update_sge(ss, length);
881} 882}
882 883
883/** 884/**
@@ -943,17 +944,18 @@ int ipath_verbs_send(struct ipath_devdata *dd, u32 hdrwords,
943 if (likely(ss->num_sge == 1 && len <= ss->sge.length && 944 if (likely(ss->num_sge == 1 && len <= ss->sge.length &&
944 !((unsigned long)ss->sge.vaddr & (sizeof(u32) - 1)))) { 945 !((unsigned long)ss->sge.vaddr & (sizeof(u32) - 1)))) {
945 u32 w; 946 u32 w;
947 u32 *addr = (u32 *) ss->sge.vaddr;
946 948
949 /* Update address before sending packet. */
950 update_sge(ss, len);
947 /* Need to round up for the last dword in the packet. */ 951 /* Need to round up for the last dword in the packet. */
948 w = (len + 3) >> 2; 952 w = (len + 3) >> 2;
949 __iowrite32_copy(piobuf, ss->sge.vaddr, w - 1); 953 __iowrite32_copy(piobuf, addr, w - 1);
950 /* must flush early everything before trigger word */ 954 /* must flush early everything before trigger word */
951 ipath_flush_wc(); 955 ipath_flush_wc();
952 __raw_writel(((u32 *) ss->sge.vaddr)[w - 1], 956 __raw_writel(addr[w - 1], piobuf + w - 1);
953 piobuf + w - 1);
954 /* be sure trigger word is written */ 957 /* be sure trigger word is written */
955 ipath_flush_wc(); 958 ipath_flush_wc();
956 update_sge(ss, len);
957 ret = 0; 959 ret = 0;
958 goto bail; 960 goto bail;
959 } 961 }
diff --git a/drivers/infiniband/hw/ipath/ipath_pe800.c b/drivers/infiniband/hw/ipath/ipath_pe800.c
index 6318067ab5ec..02e8c75b24f6 100644
--- a/drivers/infiniband/hw/ipath/ipath_pe800.c
+++ b/drivers/infiniband/hw/ipath/ipath_pe800.c
@@ -1180,6 +1180,8 @@ static int ipath_pe_early_init(struct ipath_devdata *dd)
1180 */ 1180 */
1181 dd->ipath_rhdrhead_intr_off = 1ULL<<32; 1181 dd->ipath_rhdrhead_intr_off = 1ULL<<32;
1182 1182
1183 ipath_get_eeprom_info(dd);
1184
1183 return 0; 1185 return 0;
1184} 1186}
1185 1187
diff --git a/drivers/infiniband/hw/ipath/ipath_qp.c b/drivers/infiniband/hw/ipath/ipath_qp.c
index 18890716db1e..9f8855d970c8 100644
--- a/drivers/infiniband/hw/ipath/ipath_qp.c
+++ b/drivers/infiniband/hw/ipath/ipath_qp.c
@@ -375,10 +375,10 @@ static void ipath_error_qp(struct ipath_qp *qp)
375 375
376 spin_lock(&dev->pending_lock); 376 spin_lock(&dev->pending_lock);
377 /* XXX What if its already removed by the timeout code? */ 377 /* XXX What if its already removed by the timeout code? */
378 if (qp->timerwait.next != LIST_POISON1) 378 if (!list_empty(&qp->timerwait))
379 list_del(&qp->timerwait); 379 list_del_init(&qp->timerwait);
380 if (qp->piowait.next != LIST_POISON1) 380 if (!list_empty(&qp->piowait))
381 list_del(&qp->piowait); 381 list_del_init(&qp->piowait);
382 spin_unlock(&dev->pending_lock); 382 spin_unlock(&dev->pending_lock);
383 383
384 wc.status = IB_WC_WR_FLUSH_ERR; 384 wc.status = IB_WC_WR_FLUSH_ERR;
@@ -427,6 +427,7 @@ static void ipath_error_qp(struct ipath_qp *qp)
427int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 427int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
428 int attr_mask) 428 int attr_mask)
429{ 429{
430 struct ipath_ibdev *dev = to_idev(ibqp->device);
430 struct ipath_qp *qp = to_iqp(ibqp); 431 struct ipath_qp *qp = to_iqp(ibqp);
431 enum ib_qp_state cur_state, new_state; 432 enum ib_qp_state cur_state, new_state;
432 unsigned long flags; 433 unsigned long flags;
@@ -443,6 +444,19 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
443 attr_mask)) 444 attr_mask))
444 goto inval; 445 goto inval;
445 446
447 if (attr_mask & IB_QP_AV)
448 if (attr->ah_attr.dlid == 0 ||
449 attr->ah_attr.dlid >= IPS_MULTICAST_LID_BASE)
450 goto inval;
451
452 if (attr_mask & IB_QP_PKEY_INDEX)
453 if (attr->pkey_index >= ipath_layer_get_npkeys(dev->dd))
454 goto inval;
455
456 if (attr_mask & IB_QP_MIN_RNR_TIMER)
457 if (attr->min_rnr_timer > 31)
458 goto inval;
459
446 switch (new_state) { 460 switch (new_state) {
447 case IB_QPS_RESET: 461 case IB_QPS_RESET:
448 ipath_reset_qp(qp); 462 ipath_reset_qp(qp);
@@ -457,13 +471,8 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
457 471
458 } 472 }
459 473
460 if (attr_mask & IB_QP_PKEY_INDEX) { 474 if (attr_mask & IB_QP_PKEY_INDEX)
461 struct ipath_ibdev *dev = to_idev(ibqp->device);
462
463 if (attr->pkey_index >= ipath_layer_get_npkeys(dev->dd))
464 goto inval;
465 qp->s_pkey_index = attr->pkey_index; 475 qp->s_pkey_index = attr->pkey_index;
466 }
467 476
468 if (attr_mask & IB_QP_DEST_QPN) 477 if (attr_mask & IB_QP_DEST_QPN)
469 qp->remote_qpn = attr->dest_qp_num; 478 qp->remote_qpn = attr->dest_qp_num;
@@ -479,12 +488,8 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
479 if (attr_mask & IB_QP_ACCESS_FLAGS) 488 if (attr_mask & IB_QP_ACCESS_FLAGS)
480 qp->qp_access_flags = attr->qp_access_flags; 489 qp->qp_access_flags = attr->qp_access_flags;
481 490
482 if (attr_mask & IB_QP_AV) { 491 if (attr_mask & IB_QP_AV)
483 if (attr->ah_attr.dlid == 0 ||
484 attr->ah_attr.dlid >= IPS_MULTICAST_LID_BASE)
485 goto inval;
486 qp->remote_ah_attr = attr->ah_attr; 492 qp->remote_ah_attr = attr->ah_attr;
487 }
488 493
489 if (attr_mask & IB_QP_PATH_MTU) 494 if (attr_mask & IB_QP_PATH_MTU)
490 qp->path_mtu = attr->path_mtu; 495 qp->path_mtu = attr->path_mtu;
@@ -499,11 +504,8 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
499 qp->s_rnr_retry_cnt = qp->s_rnr_retry; 504 qp->s_rnr_retry_cnt = qp->s_rnr_retry;
500 } 505 }
501 506
502 if (attr_mask & IB_QP_MIN_RNR_TIMER) { 507 if (attr_mask & IB_QP_MIN_RNR_TIMER)
503 if (attr->min_rnr_timer > 31)
504 goto inval;
505 qp->s_min_rnr_timer = attr->min_rnr_timer; 508 qp->s_min_rnr_timer = attr->min_rnr_timer;
506 }
507 509
508 if (attr_mask & IB_QP_QKEY) 510 if (attr_mask & IB_QP_QKEY)
509 qp->qkey = attr->qkey; 511 qp->qkey = attr->qkey;
@@ -710,10 +712,8 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
710 init_attr->qp_type == IB_QPT_RC ? 712 init_attr->qp_type == IB_QPT_RC ?
711 ipath_do_rc_send : ipath_do_uc_send, 713 ipath_do_rc_send : ipath_do_uc_send,
712 (unsigned long)qp); 714 (unsigned long)qp);
713 qp->piowait.next = LIST_POISON1; 715 INIT_LIST_HEAD(&qp->piowait);
714 qp->piowait.prev = LIST_POISON2; 716 INIT_LIST_HEAD(&qp->timerwait);
715 qp->timerwait.next = LIST_POISON1;
716 qp->timerwait.prev = LIST_POISON2;
717 qp->state = IB_QPS_RESET; 717 qp->state = IB_QPS_RESET;
718 qp->s_wq = swq; 718 qp->s_wq = swq;
719 qp->s_size = init_attr->cap.max_send_wr + 1; 719 qp->s_size = init_attr->cap.max_send_wr + 1;
@@ -734,7 +734,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
734 ipath_reset_qp(qp); 734 ipath_reset_qp(qp);
735 735
736 /* Tell the core driver that the kernel SMA is present. */ 736 /* Tell the core driver that the kernel SMA is present. */
737 if (qp->ibqp.qp_type == IB_QPT_SMI) 737 if (init_attr->qp_type == IB_QPT_SMI)
738 ipath_layer_set_verbs_flags(dev->dd, 738 ipath_layer_set_verbs_flags(dev->dd,
739 IPATH_VERBS_KERNEL_SMA); 739 IPATH_VERBS_KERNEL_SMA);
740 break; 740 break;
@@ -783,10 +783,10 @@ int ipath_destroy_qp(struct ib_qp *ibqp)
783 783
784 /* Make sure the QP isn't on the timeout list. */ 784 /* Make sure the QP isn't on the timeout list. */
785 spin_lock_irqsave(&dev->pending_lock, flags); 785 spin_lock_irqsave(&dev->pending_lock, flags);
786 if (qp->timerwait.next != LIST_POISON1) 786 if (!list_empty(&qp->timerwait))
787 list_del(&qp->timerwait); 787 list_del_init(&qp->timerwait);
788 if (qp->piowait.next != LIST_POISON1) 788 if (!list_empty(&qp->piowait))
789 list_del(&qp->piowait); 789 list_del_init(&qp->piowait);
790 spin_unlock_irqrestore(&dev->pending_lock, flags); 790 spin_unlock_irqrestore(&dev->pending_lock, flags);
791 791
792 /* 792 /*
@@ -855,10 +855,10 @@ void ipath_sqerror_qp(struct ipath_qp *qp, struct ib_wc *wc)
855 855
856 spin_lock(&dev->pending_lock); 856 spin_lock(&dev->pending_lock);
857 /* XXX What if its already removed by the timeout code? */ 857 /* XXX What if its already removed by the timeout code? */
858 if (qp->timerwait.next != LIST_POISON1) 858 if (!list_empty(&qp->timerwait))
859 list_del(&qp->timerwait); 859 list_del_init(&qp->timerwait);
860 if (qp->piowait.next != LIST_POISON1) 860 if (!list_empty(&qp->piowait))
861 list_del(&qp->piowait); 861 list_del_init(&qp->piowait);
862 spin_unlock(&dev->pending_lock); 862 spin_unlock(&dev->pending_lock);
863 863
864 ipath_cq_enter(to_icq(qp->ibqp.send_cq), wc, 1); 864 ipath_cq_enter(to_icq(qp->ibqp.send_cq), wc, 1);
diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
index a4055ca00614..493b1821a934 100644
--- a/drivers/infiniband/hw/ipath/ipath_rc.c
+++ b/drivers/infiniband/hw/ipath/ipath_rc.c
@@ -57,7 +57,7 @@ static void ipath_init_restart(struct ipath_qp *qp, struct ipath_swqe *wqe)
57 qp->s_len = wqe->length - len; 57 qp->s_len = wqe->length - len;
58 dev = to_idev(qp->ibqp.device); 58 dev = to_idev(qp->ibqp.device);
59 spin_lock(&dev->pending_lock); 59 spin_lock(&dev->pending_lock);
60 if (qp->timerwait.next == LIST_POISON1) 60 if (list_empty(&qp->timerwait))
61 list_add_tail(&qp->timerwait, 61 list_add_tail(&qp->timerwait,
62 &dev->pending[dev->pending_index]); 62 &dev->pending[dev->pending_index]);
63 spin_unlock(&dev->pending_lock); 63 spin_unlock(&dev->pending_lock);
@@ -356,7 +356,7 @@ static inline int ipath_make_rc_req(struct ipath_qp *qp,
356 if ((int)(qp->s_psn - qp->s_next_psn) > 0) 356 if ((int)(qp->s_psn - qp->s_next_psn) > 0)
357 qp->s_next_psn = qp->s_psn; 357 qp->s_next_psn = qp->s_psn;
358 spin_lock(&dev->pending_lock); 358 spin_lock(&dev->pending_lock);
359 if (qp->timerwait.next == LIST_POISON1) 359 if (list_empty(&qp->timerwait))
360 list_add_tail(&qp->timerwait, 360 list_add_tail(&qp->timerwait,
361 &dev->pending[dev->pending_index]); 361 &dev->pending[dev->pending_index]);
362 spin_unlock(&dev->pending_lock); 362 spin_unlock(&dev->pending_lock);
@@ -726,8 +726,8 @@ void ipath_restart_rc(struct ipath_qp *qp, u32 psn, struct ib_wc *wc)
726 */ 726 */
727 dev = to_idev(qp->ibqp.device); 727 dev = to_idev(qp->ibqp.device);
728 spin_lock(&dev->pending_lock); 728 spin_lock(&dev->pending_lock);
729 if (qp->timerwait.next != LIST_POISON1) 729 if (!list_empty(&qp->timerwait))
730 list_del(&qp->timerwait); 730 list_del_init(&qp->timerwait);
731 spin_unlock(&dev->pending_lock); 731 spin_unlock(&dev->pending_lock);
732 732
733 if (wqe->wr.opcode == IB_WR_RDMA_READ) 733 if (wqe->wr.opcode == IB_WR_RDMA_READ)
@@ -886,8 +886,8 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode)
886 * just won't find anything to restart if we ACK everything. 886 * just won't find anything to restart if we ACK everything.
887 */ 887 */
888 spin_lock(&dev->pending_lock); 888 spin_lock(&dev->pending_lock);
889 if (qp->timerwait.next != LIST_POISON1) 889 if (!list_empty(&qp->timerwait))
890 list_del(&qp->timerwait); 890 list_del_init(&qp->timerwait);
891 spin_unlock(&dev->pending_lock); 891 spin_unlock(&dev->pending_lock);
892 892
893 /* 893 /*
@@ -1194,8 +1194,7 @@ static inline void ipath_rc_rcv_resp(struct ipath_ibdev *dev,
1194 IB_WR_RDMA_READ)) 1194 IB_WR_RDMA_READ))
1195 goto ack_done; 1195 goto ack_done;
1196 spin_lock(&dev->pending_lock); 1196 spin_lock(&dev->pending_lock);
1197 if (qp->s_rnr_timeout == 0 && 1197 if (qp->s_rnr_timeout == 0 && !list_empty(&qp->timerwait))
1198 qp->timerwait.next != LIST_POISON1)
1199 list_move_tail(&qp->timerwait, 1198 list_move_tail(&qp->timerwait,
1200 &dev->pending[dev->pending_index]); 1199 &dev->pending[dev->pending_index]);
1201 spin_unlock(&dev->pending_lock); 1200 spin_unlock(&dev->pending_lock);
diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
index eb81424b3c5b..d38f4f3cfd1d 100644
--- a/drivers/infiniband/hw/ipath/ipath_ruc.c
+++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
@@ -435,7 +435,7 @@ void ipath_no_bufs_available(struct ipath_qp *qp, struct ipath_ibdev *dev)
435 unsigned long flags; 435 unsigned long flags;
436 436
437 spin_lock_irqsave(&dev->pending_lock, flags); 437 spin_lock_irqsave(&dev->pending_lock, flags);
438 if (qp->piowait.next == LIST_POISON1) 438 if (list_empty(&qp->piowait))
439 list_add_tail(&qp->piowait, &dev->piowait); 439 list_add_tail(&qp->piowait, &dev->piowait);
440 spin_unlock_irqrestore(&dev->pending_lock, flags); 440 spin_unlock_irqrestore(&dev->pending_lock, flags);
441 /* 441 /*
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c
index cb9e387c301f..28fdbdaa789d 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c
@@ -464,7 +464,7 @@ static void ipath_ib_timer(void *arg)
464 last = &dev->pending[dev->pending_index]; 464 last = &dev->pending[dev->pending_index];
465 while (!list_empty(last)) { 465 while (!list_empty(last)) {
466 qp = list_entry(last->next, struct ipath_qp, timerwait); 466 qp = list_entry(last->next, struct ipath_qp, timerwait);
467 list_del(&qp->timerwait); 467 list_del_init(&qp->timerwait);
468 qp->timer_next = resend; 468 qp->timer_next = resend;
469 resend = qp; 469 resend = qp;
470 atomic_inc(&qp->refcount); 470 atomic_inc(&qp->refcount);
@@ -474,7 +474,7 @@ static void ipath_ib_timer(void *arg)
474 qp = list_entry(last->next, struct ipath_qp, timerwait); 474 qp = list_entry(last->next, struct ipath_qp, timerwait);
475 if (--qp->s_rnr_timeout == 0) { 475 if (--qp->s_rnr_timeout == 0) {
476 do { 476 do {
477 list_del(&qp->timerwait); 477 list_del_init(&qp->timerwait);
478 tasklet_hi_schedule(&qp->s_task); 478 tasklet_hi_schedule(&qp->s_task);
479 if (list_empty(last)) 479 if (list_empty(last))
480 break; 480 break;
@@ -554,7 +554,7 @@ static int ipath_ib_piobufavail(void *arg)
554 while (!list_empty(&dev->piowait)) { 554 while (!list_empty(&dev->piowait)) {
555 qp = list_entry(dev->piowait.next, struct ipath_qp, 555 qp = list_entry(dev->piowait.next, struct ipath_qp,
556 piowait); 556 piowait);
557 list_del(&qp->piowait); 557 list_del_init(&qp->piowait);
558 tasklet_hi_schedule(&qp->s_task); 558 tasklet_hi_schedule(&qp->s_task);
559 } 559 }
560 spin_unlock_irqrestore(&dev->pending_lock, flags); 560 spin_unlock_irqrestore(&dev->pending_lock, flags);
@@ -951,6 +951,7 @@ static void *ipath_register_ib_device(int unit, struct ipath_devdata *dd)
951 idev->dd = dd; 951 idev->dd = dd;
952 952
953 strlcpy(dev->name, "ipath%d", IB_DEVICE_NAME_MAX); 953 strlcpy(dev->name, "ipath%d", IB_DEVICE_NAME_MAX);
954 dev->owner = THIS_MODULE;
954 dev->node_guid = ipath_layer_get_guid(dd); 955 dev->node_guid = ipath_layer_get_guid(dd);
955 dev->uverbs_abi_ver = IPATH_UVERBS_ABI_VERSION; 956 dev->uverbs_abi_ver = IPATH_UVERBS_ABI_VERSION;
956 dev->uverbs_cmd_mask = 957 dev->uverbs_cmd_mask =
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
index 1985b5dfa481..798e13e14faf 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
@@ -182,7 +182,7 @@ struct mthca_cmd_context {
182 u8 status; 182 u8 status;
183}; 183};
184 184
185static int fw_cmd_doorbell = 1; 185static int fw_cmd_doorbell = 0;
186module_param(fw_cmd_doorbell, int, 0644); 186module_param(fw_cmd_doorbell, int, 0644);
187MODULE_PARM_DESC(fw_cmd_doorbell, "post FW commands through doorbell page if nonzero " 187MODULE_PARM_DESC(fw_cmd_doorbell, "post FW commands through doorbell page if nonzero "
188 "(and supported by FW)"); 188 "(and supported by FW)");
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index 19765f6f8d58..07c13be07a4a 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -1727,23 +1727,7 @@ int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
1727 1727
1728 ind = qp->rq.next_ind; 1728 ind = qp->rq.next_ind;
1729 1729
1730 for (nreq = 0; wr; ++nreq, wr = wr->next) { 1730 for (nreq = 0; wr; wr = wr->next) {
1731 if (unlikely(nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB)) {
1732 nreq = 0;
1733
1734 doorbell[0] = cpu_to_be32((qp->rq.next_ind << qp->rq.wqe_shift) | size0);
1735 doorbell[1] = cpu_to_be32(qp->qpn << 8);
1736
1737 wmb();
1738
1739 mthca_write64(doorbell,
1740 dev->kar + MTHCA_RECEIVE_DOORBELL,
1741 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
1742
1743 qp->rq.head += MTHCA_TAVOR_MAX_WQES_PER_RECV_DB;
1744 size0 = 0;
1745 }
1746
1747 if (mthca_wq_overflow(&qp->rq, nreq, qp->ibqp.recv_cq)) { 1731 if (mthca_wq_overflow(&qp->rq, nreq, qp->ibqp.recv_cq)) {
1748 mthca_err(dev, "RQ %06x full (%u head, %u tail," 1732 mthca_err(dev, "RQ %06x full (%u head, %u tail,"
1749 " %d max, %d nreq)\n", qp->qpn, 1733 " %d max, %d nreq)\n", qp->qpn,
@@ -1797,6 +1781,23 @@ int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
1797 ++ind; 1781 ++ind;
1798 if (unlikely(ind >= qp->rq.max)) 1782 if (unlikely(ind >= qp->rq.max))
1799 ind -= qp->rq.max; 1783 ind -= qp->rq.max;
1784
1785 ++nreq;
1786 if (unlikely(nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB)) {
1787 nreq = 0;
1788
1789 doorbell[0] = cpu_to_be32((qp->rq.next_ind << qp->rq.wqe_shift) | size0);
1790 doorbell[1] = cpu_to_be32(qp->qpn << 8);
1791
1792 wmb();
1793
1794 mthca_write64(doorbell,
1795 dev->kar + MTHCA_RECEIVE_DOORBELL,
1796 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
1797
1798 qp->rq.head += MTHCA_TAVOR_MAX_WQES_PER_RECV_DB;
1799 size0 = 0;
1800 }
1800 } 1801 }
1801 1802
1802out: 1803out:
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c
index 1ea433291fa7..b292fefa3b41 100644
--- a/drivers/infiniband/hw/mthca/mthca_srq.c
+++ b/drivers/infiniband/hw/mthca/mthca_srq.c
@@ -490,26 +490,7 @@ int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
490 490
491 first_ind = srq->first_free; 491 first_ind = srq->first_free;
492 492
493 for (nreq = 0; wr; ++nreq, wr = wr->next) { 493 for (nreq = 0; wr; wr = wr->next) {
494 if (unlikely(nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB)) {
495 nreq = 0;
496
497 doorbell[0] = cpu_to_be32(first_ind << srq->wqe_shift);
498 doorbell[1] = cpu_to_be32(srq->srqn << 8);
499
500 /*
501 * Make sure that descriptors are written
502 * before doorbell is rung.
503 */
504 wmb();
505
506 mthca_write64(doorbell,
507 dev->kar + MTHCA_RECEIVE_DOORBELL,
508 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
509
510 first_ind = srq->first_free;
511 }
512
513 ind = srq->first_free; 494 ind = srq->first_free;
514 495
515 if (ind < 0) { 496 if (ind < 0) {
@@ -569,6 +550,26 @@ int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
569 550
570 srq->wrid[ind] = wr->wr_id; 551 srq->wrid[ind] = wr->wr_id;
571 srq->first_free = next_ind; 552 srq->first_free = next_ind;
553
554 ++nreq;
555 if (unlikely(nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB)) {
556 nreq = 0;
557
558 doorbell[0] = cpu_to_be32(first_ind << srq->wqe_shift);
559 doorbell[1] = cpu_to_be32(srq->srqn << 8);
560
561 /*
562 * Make sure that descriptors are written
563 * before doorbell is rung.
564 */
565 wmb();
566
567 mthca_write64(doorbell,
568 dev->kar + MTHCA_RECEIVE_DOORBELL,
569 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
570
571 first_ind = srq->first_free;
572 }
572 } 573 }
573 574
574 if (likely(nreq)) { 575 if (likely(nreq)) {
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index c32ce4348e1b..9cbdffa08dc2 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -340,7 +340,10 @@ static void srp_disconnect_target(struct srp_target_port *target)
340 /* XXX should send SRP_I_LOGOUT request */ 340 /* XXX should send SRP_I_LOGOUT request */
341 341
342 init_completion(&target->done); 342 init_completion(&target->done);
343 ib_send_cm_dreq(target->cm_id, NULL, 0); 343 if (ib_send_cm_dreq(target->cm_id, NULL, 0)) {
344 printk(KERN_DEBUG PFX "Sending CM DREQ failed\n");
345 return;
346 }
344 wait_for_completion(&target->done); 347 wait_for_completion(&target->done);
345} 348}
346 349
@@ -351,7 +354,6 @@ static void srp_remove_work(void *target_ptr)
351 spin_lock_irq(target->scsi_host->host_lock); 354 spin_lock_irq(target->scsi_host->host_lock);
352 if (target->state != SRP_TARGET_DEAD) { 355 if (target->state != SRP_TARGET_DEAD) {
353 spin_unlock_irq(target->scsi_host->host_lock); 356 spin_unlock_irq(target->scsi_host->host_lock);
354 scsi_host_put(target->scsi_host);
355 return; 357 return;
356 } 358 }
357 target->state = SRP_TARGET_REMOVED; 359 target->state = SRP_TARGET_REMOVED;
@@ -365,8 +367,6 @@ static void srp_remove_work(void *target_ptr)
365 ib_destroy_cm_id(target->cm_id); 367 ib_destroy_cm_id(target->cm_id);
366 srp_free_target_ib(target); 368 srp_free_target_ib(target);
367 scsi_host_put(target->scsi_host); 369 scsi_host_put(target->scsi_host);
368 /* And another put to really free the target port... */
369 scsi_host_put(target->scsi_host);
370} 370}
371 371
372static int srp_connect_target(struct srp_target_port *target) 372static int srp_connect_target(struct srp_target_port *target)
@@ -1241,7 +1241,7 @@ static int srp_reset_device(struct scsi_cmnd *scmnd)
1241 list_for_each_entry_safe(req, tmp, &target->req_queue, list) 1241 list_for_each_entry_safe(req, tmp, &target->req_queue, list)
1242 if (req->scmnd->device == scmnd->device) { 1242 if (req->scmnd->device == scmnd->device) {
1243 req->scmnd->result = DID_RESET << 16; 1243 req->scmnd->result = DID_RESET << 16;
1244 scmnd->scsi_done(scmnd); 1244 req->scmnd->scsi_done(req->scmnd);
1245 srp_remove_req(target, req); 1245 srp_remove_req(target, req);
1246 } 1246 }
1247 1247
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
index 2b2ec1057dee..95c0de7964a0 100644
--- a/drivers/input/joystick/sidewinder.c
+++ b/drivers/input/joystick/sidewinder.c
@@ -589,7 +589,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
589 struct sw *sw; 589 struct sw *sw;
590 struct input_dev *input_dev; 590 struct input_dev *input_dev;
591 int i, j, k, l; 591 int i, j, k, l;
592 int err; 592 int err = 0;
593 unsigned char *buf = NULL; /* [SW_LENGTH] */ 593 unsigned char *buf = NULL; /* [SW_LENGTH] */
594 unsigned char *idbuf = NULL; /* [SW_LENGTH] */ 594 unsigned char *idbuf = NULL; /* [SW_LENGTH] */
595 unsigned char m = 1; 595 unsigned char m = 1;
@@ -776,7 +776,10 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
776 goto fail4; 776 goto fail4;
777 } 777 }
778 778
779 return 0; 779 out: kfree(buf);
780 kfree(idbuf);
781
782 return err;
780 783
781 fail4: input_free_device(sw->dev[i]); 784 fail4: input_free_device(sw->dev[i]);
782 fail3: while (--i >= 0) 785 fail3: while (--i >= 0)
@@ -784,9 +787,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
784 fail2: gameport_close(gameport); 787 fail2: gameport_close(gameport);
785 fail1: gameport_set_drvdata(gameport, NULL); 788 fail1: gameport_set_drvdata(gameport, NULL);
786 kfree(sw); 789 kfree(sw);
787 kfree(buf); 790 goto out;
788 kfree(idbuf);
789 return err;
790} 791}
791 792
792static void sw_disconnect(struct gameport *gameport) 793static void sw_disconnect(struct gameport *gameport)
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c
index 96c6bf77248a..1f0e720267d7 100644
--- a/drivers/input/keyboard/corgikbd.c
+++ b/drivers/input/keyboard/corgikbd.c
@@ -245,9 +245,9 @@ static void corgikbd_hinge_timer(unsigned long data)
245 if (hinge_count >= HINGE_STABLE_COUNT) { 245 if (hinge_count >= HINGE_STABLE_COUNT) {
246 spin_lock_irqsave(&corgikbd_data->lock, flags); 246 spin_lock_irqsave(&corgikbd_data->lock, flags);
247 247
248 input_report_switch(corgikbd_data->input, SW_0, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0)); 248 input_report_switch(corgikbd_data->input, SW_LID, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0));
249 input_report_switch(corgikbd_data->input, SW_1, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0)); 249 input_report_switch(corgikbd_data->input, SW_TABLET_MODE, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0));
250 input_report_switch(corgikbd_data->input, SW_2, (READ_GPIO_BIT(CORGI_GPIO_AK_INT) != 0)); 250 input_report_switch(corgikbd_data->input, SW_HEADPHONE_INSERT, (READ_GPIO_BIT(CORGI_GPIO_AK_INT) != 0));
251 input_sync(corgikbd_data->input); 251 input_sync(corgikbd_data->input);
252 252
253 spin_unlock_irqrestore(&corgikbd_data->lock, flags); 253 spin_unlock_irqrestore(&corgikbd_data->lock, flags);
@@ -340,9 +340,9 @@ static int __init corgikbd_probe(struct platform_device *pdev)
340 for (i = 0; i < ARRAY_SIZE(corgikbd_keycode); i++) 340 for (i = 0; i < ARRAY_SIZE(corgikbd_keycode); i++)
341 set_bit(corgikbd->keycode[i], input_dev->keybit); 341 set_bit(corgikbd->keycode[i], input_dev->keybit);
342 clear_bit(0, input_dev->keybit); 342 clear_bit(0, input_dev->keybit);
343 set_bit(SW_0, input_dev->swbit); 343 set_bit(SW_LID, input_dev->swbit);
344 set_bit(SW_1, input_dev->swbit); 344 set_bit(SW_TABLET_MODE, input_dev->swbit);
345 set_bit(SW_2, input_dev->swbit); 345 set_bit(SW_HEADPHONE_INSERT, input_dev->swbit);
346 346
347 input_register_device(corgikbd->input); 347 input_register_device(corgikbd->input);
348 348
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c
index 1d238a9d52d6..c5d03fb77bcb 100644
--- a/drivers/input/keyboard/spitzkbd.c
+++ b/drivers/input/keyboard/spitzkbd.c
@@ -299,9 +299,9 @@ static void spitzkbd_hinge_timer(unsigned long data)
299 if (hinge_count >= HINGE_STABLE_COUNT) { 299 if (hinge_count >= HINGE_STABLE_COUNT) {
300 spin_lock_irqsave(&spitzkbd_data->lock, flags); 300 spin_lock_irqsave(&spitzkbd_data->lock, flags);
301 301
302 input_report_switch(spitzkbd_data->input, SW_0, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0)); 302 input_report_switch(spitzkbd_data->input, SW_LID, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0));
303 input_report_switch(spitzkbd_data->input, SW_1, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0)); 303 input_report_switch(spitzkbd_data->input, SW_TABLET_MODE, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0));
304 input_report_switch(spitzkbd_data->input, SW_2, ((GPLR(SPITZ_GPIO_AK_INT) & GPIO_bit(SPITZ_GPIO_AK_INT)) != 0)); 304 input_report_switch(spitzkbd_data->input, SW_HEADPHONE_INSERT, ((GPLR(SPITZ_GPIO_AK_INT) & GPIO_bit(SPITZ_GPIO_AK_INT)) != 0));
305 input_sync(spitzkbd_data->input); 305 input_sync(spitzkbd_data->input);
306 306
307 spin_unlock_irqrestore(&spitzkbd_data->lock, flags); 307 spin_unlock_irqrestore(&spitzkbd_data->lock, flags);
@@ -398,9 +398,9 @@ static int __init spitzkbd_probe(struct platform_device *dev)
398 for (i = 0; i < ARRAY_SIZE(spitzkbd_keycode); i++) 398 for (i = 0; i < ARRAY_SIZE(spitzkbd_keycode); i++)
399 set_bit(spitzkbd->keycode[i], input_dev->keybit); 399 set_bit(spitzkbd->keycode[i], input_dev->keybit);
400 clear_bit(0, input_dev->keybit); 400 clear_bit(0, input_dev->keybit);
401 set_bit(SW_0, input_dev->swbit); 401 set_bit(SW_LID, input_dev->swbit);
402 set_bit(SW_1, input_dev->swbit); 402 set_bit(SW_TABLET_MODE, input_dev->swbit);
403 set_bit(SW_2, input_dev->swbit); 403 set_bit(SW_HEADPHONE_INSERT, input_dev->swbit);
404 404
405 input_register_device(input_dev); 405 input_register_device(input_dev);
406 406
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index 36cd2e07fce8..e4e5be111c96 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -318,6 +318,16 @@ static struct key_entry keymap_acer_travelmate_240[] = {
318 { KE_END, 0 } 318 { KE_END, 0 }
319}; 319};
320 320
321static struct key_entry keymap_aopen_1559as[] = {
322 { KE_KEY, 0x01, KEY_HELP },
323 { KE_KEY, 0x06, KEY_PROG3 },
324 { KE_KEY, 0x11, KEY_PROG1 },
325 { KE_KEY, 0x12, KEY_PROG2 },
326 { KE_WIFI, 0x30, 0 },
327 { KE_KEY, 0x31, KEY_MAIL },
328 { KE_KEY, 0x36, KEY_WWW },
329};
330
321/* 331/*
322 * If your machine is not here (which is currently rather likely), please send 332 * If your machine is not here (which is currently rather likely), please send
323 * a list of buttons and their key codes (reported when loading this module 333 * a list of buttons and their key codes (reported when loading this module
@@ -369,6 +379,15 @@ static struct dmi_system_id dmi_ids[] = {
369 }, 379 },
370 .driver_data = keymap_acer_travelmate_240 380 .driver_data = keymap_acer_travelmate_240
371 }, 381 },
382 {
383 .callback = dmi_matched,
384 .ident = "AOpen 1559AS",
385 .matches = {
386 DMI_MATCH(DMI_PRODUCT_NAME, "E2U"),
387 DMI_MATCH(DMI_BOARD_NAME, "E2U"),
388 },
389 .driver_data = keymap_aopen_1559as
390 },
372 { NULL, } 391 { NULL, }
373}; 392};
374 393
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index 2141501e9f2e..a0e2e797c6d5 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -100,8 +100,8 @@ static void alps_process_packet(struct psmouse *psmouse, struct pt_regs *regs)
100 } 100 }
101 101
102 if (priv->i->flags & ALPS_OLDPROTO) { 102 if (priv->i->flags & ALPS_OLDPROTO) {
103 left = packet[2] & 0x08; 103 left = packet[2] & 0x10;
104 right = packet[2] & 0x10; 104 right = packet[2] & 0x08;
105 middle = 0; 105 middle = 0;
106 x = packet[1] | ((packet[0] & 0x07) << 7); 106 x = packet[1] | ((packet[0] & 0x07) << 7);
107 y = packet[4] | ((packet[3] & 0x07) << 7); 107 y = packet[4] | ((packet[3] & 0x07) << 7);
diff --git a/drivers/input/mouse/lifebook.c b/drivers/input/mouse/lifebook.c
index 5ccc3ef3b89e..c14395ba7980 100644
--- a/drivers/input/mouse/lifebook.c
+++ b/drivers/input/mouse/lifebook.c
@@ -22,12 +22,36 @@
22 22
23static struct dmi_system_id lifebook_dmi_table[] = { 23static struct dmi_system_id lifebook_dmi_table[] = {
24 { 24 {
25 .ident = "LifeBook B",
26 .matches = {
27 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B Series"),
28 },
29 },
30 {
25 .ident = "Lifebook B", 31 .ident = "Lifebook B",
26 .matches = { 32 .matches = {
27 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK B Series"), 33 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK B Series"),
28 }, 34 },
29 }, 35 },
30 { 36 {
37 .ident = "Lifebook B213x/B2150",
38 .matches = {
39 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B2131/B2133/B2150"),
40 },
41 },
42 {
43 .ident = "Zephyr",
44 .matches = {
45 DMI_MATCH(DMI_PRODUCT_NAME, "ZEPHYR"),
46 },
47 },
48 {
49 .ident = "CF-18",
50 .matches = {
51 DMI_MATCH(DMI_PRODUCT_NAME, "CF-18"),
52 },
53 },
54 {
31 .ident = "Lifebook B142", 55 .ident = "Lifebook B142",
32 .matches = { 56 .matches = {
33 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B142"), 57 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B142"),
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c
index 40333d61093c..2f0d28840810 100644
--- a/drivers/input/mouse/logips2pp.c
+++ b/drivers/input/mouse/logips2pp.c
@@ -19,6 +19,7 @@
19#define PS2PP_KIND_WHEEL 1 19#define PS2PP_KIND_WHEEL 1
20#define PS2PP_KIND_MX 2 20#define PS2PP_KIND_MX 2
21#define PS2PP_KIND_TP3 3 21#define PS2PP_KIND_TP3 3
22#define PS2PP_KIND_TRACKMAN 4
22 23
23/* Logitech mouse features */ 24/* Logitech mouse features */
24#define PS2PP_WHEEL 0x01 25#define PS2PP_WHEEL 0x01
@@ -223,6 +224,7 @@ static struct ps2pp_info *get_model_info(unsigned char model)
223 { 73, 0, PS2PP_SIDE_BTN }, 224 { 73, 0, PS2PP_SIDE_BTN },
224 { 75, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, 225 { 75, PS2PP_KIND_WHEEL, PS2PP_WHEEL },
225 { 76, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, 226 { 76, PS2PP_KIND_WHEEL, PS2PP_WHEEL },
227 { 79, PS2PP_KIND_TRACKMAN, PS2PP_WHEEL }, /* TrackMan with wheel */
226 { 80, PS2PP_KIND_WHEEL, PS2PP_SIDE_BTN | PS2PP_WHEEL }, 228 { 80, PS2PP_KIND_WHEEL, PS2PP_SIDE_BTN | PS2PP_WHEEL },
227 { 81, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, 229 { 81, PS2PP_KIND_WHEEL, PS2PP_WHEEL },
228 { 83, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, 230 { 83, PS2PP_KIND_WHEEL, PS2PP_WHEEL },
@@ -298,6 +300,10 @@ static void ps2pp_set_model_properties(struct psmouse *psmouse, struct ps2pp_inf
298 psmouse->name = "TouchPad 3"; 300 psmouse->name = "TouchPad 3";
299 break; 301 break;
300 302
303 case PS2PP_KIND_TRACKMAN:
304 psmouse->name = "TrackMan";
305 break;
306
301 default: 307 default:
302 /* 308 /*
303 * Set name to "Mouse" only when using PS2++, 309 * Set name to "Mouse" only when using PS2++,
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 1494175ac6fe..161afddd0f44 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -36,13 +36,10 @@
36 36
37 37
38/* 38/*
39 * This code has been tested on an ads7846 / N770 device. 39 * This code has been heavily tested on a Nokia 770, and lightly
40 * tested on other ads7846 devices (OSK/Mistral, Lubbock).
40 * Support for ads7843 and ads7845 has only been stubbed in. 41 * Support for ads7843 and ads7845 has only been stubbed in.
41 * 42 *
42 * Not yet done: How accurate are the temperature and voltage
43 * readings? (System-specific calibration should support
44 * accuracy of 0.3 degrees C; otherwise it's 2.0 degrees.)
45 *
46 * IRQ handling needs a workaround because of a shortcoming in handling 43 * IRQ handling needs a workaround because of a shortcoming in handling
47 * edge triggered IRQs on some platforms like the OMAP1/2. These 44 * edge triggered IRQs on some platforms like the OMAP1/2. These
48 * platforms don't handle the ARM lazy IRQ disabling properly, thus we 45 * platforms don't handle the ARM lazy IRQ disabling properly, thus we
@@ -248,10 +245,13 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
248 245
249 if (req->msg.status) 246 if (req->msg.status)
250 status = req->msg.status; 247 status = req->msg.status;
248
249 /* on-wire is a must-ignore bit, a BE12 value, then padding */
251 sample = be16_to_cpu(req->sample); 250 sample = be16_to_cpu(req->sample);
252 sample = sample >> 4; 251 sample = sample >> 3;
253 kfree(req); 252 sample &= 0x0fff;
254 253
254 kfree(req);
255 return status ? status : sample; 255 return status ? status : sample;
256} 256}
257 257
@@ -336,13 +336,13 @@ static void ads7846_rx(void *ads)
336 u16 x, y, z1, z2; 336 u16 x, y, z1, z2;
337 unsigned long flags; 337 unsigned long flags;
338 338
339 /* adjust: 12 bit samples (left aligned), built from 339 /* adjust: on-wire is a must-ignore bit, a BE12 value, then padding;
340 * two 8 bit values writen msb-first. 340 * built from two 8 bit values written msb-first.
341 */ 341 */
342 x = be16_to_cpu(ts->tc.x) >> 4; 342 x = (be16_to_cpu(ts->tc.x) >> 3) & 0x0fff;
343 y = be16_to_cpu(ts->tc.y) >> 4; 343 y = (be16_to_cpu(ts->tc.y) >> 3) & 0x0fff;
344 z1 = be16_to_cpu(ts->tc.z1) >> 4; 344 z1 = (be16_to_cpu(ts->tc.z1) >> 3) & 0x0fff;
345 z2 = be16_to_cpu(ts->tc.z2) >> 4; 345 z2 = (be16_to_cpu(ts->tc.z2) >> 3) & 0x0fff;
346 346
347 /* range filtering */ 347 /* range filtering */
348 if (x == MAX_12BIT) 348 if (x == MAX_12BIT)
@@ -420,7 +420,7 @@ static void ads7846_debounce(void *ads)
420 420
421 m = &ts->msg[ts->msg_idx]; 421 m = &ts->msg[ts->msg_idx];
422 t = list_entry(m->transfers.prev, struct spi_transfer, transfer_list); 422 t = list_entry(m->transfers.prev, struct spi_transfer, transfer_list);
423 val = (*(u16 *)t->rx_buf) >> 3; 423 val = (be16_to_cpu(*(__be16 *)t->rx_buf) >> 3) & 0x0fff;
424 if (!ts->read_cnt || (abs(ts->last_read - val) > ts->debounce_tol)) { 424 if (!ts->read_cnt || (abs(ts->last_read - val) > ts->debounce_tol)) {
425 /* Repeat it, if this was the first read or the read 425 /* Repeat it, if this was the first read or the read
426 * wasn't consistent enough. */ 426 * wasn't consistent enough. */
@@ -469,7 +469,7 @@ static void ads7846_timer(unsigned long handle)
469 spin_lock_irq(&ts->lock); 469 spin_lock_irq(&ts->lock);
470 470
471 if (unlikely(ts->msg_idx && !ts->pendown)) { 471 if (unlikely(ts->msg_idx && !ts->pendown)) {
472 /* measurment cycle ended */ 472 /* measurement cycle ended */
473 if (!device_suspended(&ts->spi->dev)) { 473 if (!device_suspended(&ts->spi->dev)) {
474 ts->irq_disabled = 0; 474 ts->irq_disabled = 0;
475 enable_irq(ts->spi->irq); 475 enable_irq(ts->spi->irq);
@@ -495,11 +495,10 @@ static irqreturn_t ads7846_irq(int irq, void *handle, struct pt_regs *regs)
495 spin_lock_irqsave(&ts->lock, flags); 495 spin_lock_irqsave(&ts->lock, flags);
496 if (likely(ts->get_pendown_state())) { 496 if (likely(ts->get_pendown_state())) {
497 if (!ts->irq_disabled) { 497 if (!ts->irq_disabled) {
498 /* REVISIT irq logic for many ARM chips has cloned a 498 /* The ARM do_simple_IRQ() dispatcher doesn't act
499 * bug wherein disabling an irq in its handler won't 499 * like the other dispatchers: it will report IRQs
500 * work;(it's disabled lazily, and too late to work. 500 * even after they've been disabled. We work around
501 * until all their irq logic is fixed, we must shadow 501 * that here. (The "generic irq" framework may help...)
502 * that state here.
503 */ 502 */
504 ts->irq_disabled = 1; 503 ts->irq_disabled = 1;
505 disable_irq(ts->spi->irq); 504 disable_irq(ts->spi->irq);
@@ -609,16 +608,20 @@ static int __devinit ads7846_probe(struct spi_device *spi)
609 return -EINVAL; 608 return -EINVAL;
610 } 609 }
611 610
611 /* REVISIT when the irq can be triggered active-low, or if for some
612 * reason the touchscreen isn't hooked up, we don't need to access
613 * the pendown state.
614 */
612 if (pdata->get_pendown_state == NULL) { 615 if (pdata->get_pendown_state == NULL) {
613 dev_dbg(&spi->dev, "no get_pendown_state function?\n"); 616 dev_dbg(&spi->dev, "no get_pendown_state function?\n");
614 return -EINVAL; 617 return -EINVAL;
615 } 618 }
616 619
617 /* We'd set the wordsize to 12 bits ... except that some controllers 620 /* We'd set TX wordsize 8 bits and RX wordsize to 13 bits ... except
618 * will then treat the 8 bit command words as 12 bits (and drop the 621 * that even if the hardware can do that, the SPI controller driver
619 * four MSBs of the 12 bit result). Result: inputs must be shifted 622 * may not. So we stick to very-portable 8 bit words, both RX and TX.
620 * to discard the four garbage LSBs.
621 */ 623 */
624 spi->bits_per_word = 8;
622 625
623 ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL); 626 ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL);
624 input_dev = input_allocate_device(); 627 input_dev = input_allocate_device();
@@ -772,7 +775,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
772 775
773 if (request_irq(spi->irq, ads7846_irq, 776 if (request_irq(spi->irq, ads7846_irq,
774 SA_SAMPLE_RANDOM | SA_TRIGGER_FALLING, 777 SA_SAMPLE_RANDOM | SA_TRIGGER_FALLING,
775 spi->dev.bus_id, ts)) { 778 spi->dev.driver->name, ts)) {
776 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); 779 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
777 err = -EBUSY; 780 err = -EBUSY;
778 goto err_free_mem; 781 goto err_free_mem;
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index 3585fb1f3344..2ac90242d263 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -2880,7 +2880,7 @@ isdn_tty_cmd_ATand(char **p, modem_info * info)
2880 p[0]++; 2880 p[0]++;
2881 i = 0; 2881 i = 0;
2882 while (*p[0] && (strchr("0123456789,-*[]?;", *p[0])) && 2882 while (*p[0] && (strchr("0123456789,-*[]?;", *p[0])) &&
2883 (i < ISDN_LMSNLEN)) 2883 (i < ISDN_LMSNLEN - 1))
2884 m->lmsn[i++] = *p[0]++; 2884 m->lmsn[i++] = *p[0]++;
2885 m->lmsn[i] = '\0'; 2885 m->lmsn[i] = '\0';
2886 break; 2886 break;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index d7316b829a62..f19b874753a9 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -167,6 +167,15 @@ void md_new_event(mddev_t *mddev)
167} 167}
168EXPORT_SYMBOL_GPL(md_new_event); 168EXPORT_SYMBOL_GPL(md_new_event);
169 169
170/* Alternate version that can be called from interrupts
171 * when calling sysfs_notify isn't needed.
172 */
173void md_new_event_inintr(mddev_t *mddev)
174{
175 atomic_inc(&md_event_count);
176 wake_up(&md_event_waiters);
177}
178
170/* 179/*
171 * Enables to iterate over all existing md arrays 180 * Enables to iterate over all existing md arrays
172 * all_mddevs_lock protects this list. 181 * all_mddevs_lock protects this list.
@@ -2252,7 +2261,7 @@ action_store(mddev_t *mddev, const char *page, size_t len)
2252 } else { 2261 } else {
2253 if (cmd_match(page, "check")) 2262 if (cmd_match(page, "check"))
2254 set_bit(MD_RECOVERY_CHECK, &mddev->recovery); 2263 set_bit(MD_RECOVERY_CHECK, &mddev->recovery);
2255 else if (cmd_match(page, "repair")) 2264 else if (!cmd_match(page, "repair"))
2256 return -EINVAL; 2265 return -EINVAL;
2257 set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery); 2266 set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery);
2258 set_bit(MD_RECOVERY_SYNC, &mddev->recovery); 2267 set_bit(MD_RECOVERY_SYNC, &mddev->recovery);
@@ -4149,7 +4158,7 @@ void md_error(mddev_t *mddev, mdk_rdev_t *rdev)
4149 set_bit(MD_RECOVERY_INTR, &mddev->recovery); 4158 set_bit(MD_RECOVERY_INTR, &mddev->recovery);
4150 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 4159 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
4151 md_wakeup_thread(mddev->thread); 4160 md_wakeup_thread(mddev->thread);
4152 md_new_event(mddev); 4161 md_new_event_inintr(mddev);
4153} 4162}
4154 4163
4155/* seq_file implementation /proc/mdstat */ 4164/* seq_file implementation /proc/mdstat */
@@ -5028,8 +5037,10 @@ static int md_notify_reboot(struct notifier_block *this,
5028 printk(KERN_INFO "md: stopping all md devices.\n"); 5037 printk(KERN_INFO "md: stopping all md devices.\n");
5029 5038
5030 ITERATE_MDDEV(mddev,tmp) 5039 ITERATE_MDDEV(mddev,tmp)
5031 if (mddev_trylock(mddev)) 5040 if (mddev_trylock(mddev)) {
5032 do_md_stop (mddev, 1); 5041 do_md_stop (mddev, 1);
5042 mddev_unlock(mddev);
5043 }
5033 /* 5044 /*
5034 * certain more exotic SCSI devices are known to be 5045 * certain more exotic SCSI devices are known to be
5035 * volatile wrt too early system reboots. While the 5046 * volatile wrt too early system reboots. While the
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 678f4dbbea1d..cb8c6317e4e5 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -331,13 +331,14 @@ static int raid0_run (mddev_t *mddev)
331 goto out_free_conf; 331 goto out_free_conf;
332 size = conf->strip_zone[cur].size; 332 size = conf->strip_zone[cur].size;
333 333
334 for (i=0; i< nb_zone; i++) { 334 conf->hash_table[0] = conf->strip_zone + cur;
335 conf->hash_table[i] = conf->strip_zone + cur; 335 for (i=1; i< nb_zone; i++) {
336 while (size <= conf->hash_spacing) { 336 while (size <= conf->hash_spacing) {
337 cur++; 337 cur++;
338 size += conf->strip_zone[cur].size; 338 size += conf->strip_zone[cur].size;
339 } 339 }
340 size -= conf->hash_spacing; 340 size -= conf->hash_spacing;
341 conf->hash_table[i] = conf->strip_zone + cur;
341 } 342 }
342 if (conf->preshift) { 343 if (conf->preshift) {
343 conf->hash_spacing >>= conf->preshift; 344 conf->hash_spacing >>= conf->preshift;
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index fffc711c260c..344d83aae3ec 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -8,22 +8,54 @@ config VIDEO_DEV
8 tristate "Video For Linux" 8 tristate "Video For Linux"
9 ---help--- 9 ---help---
10 Support for audio/video capture and overlay devices and FM radio 10 Support for audio/video capture and overlay devices and FM radio
11 cards. The exact capabilities of each device vary. User tools for 11 cards. The exact capabilities of each device vary.
12 this are available from
13 <ftp://ftp.uk.linux.org/pub/linux/video4linux/>.
14 12
15 This kernel includes support for the new Video for Linux Two API, 13 This kernel includes support for the new Video for Linux Two API,
16 (V4L2) as well as the original system. Drivers and applications 14 (V4L2) as well as the original system. Drivers and applications
17 need to be rewritten to use V4L2, but drivers for popular cards 15 need to be rewritten to use V4L2, but drivers for popular cards
18 and applications for most video capture functions already exist. 16 and applications for most video capture functions already exist.
19 17
20 Documentation for the original API is included in the file 18 Additional info and docs are available on the web at
21 <file:Documentation/video4linux/API.html>. Documentation for V4L2 is 19 <http://linuxtv.org>
22 available on the web at <http://bytesex.org/v4l/>. 20
21 Documentation for V4L2 is also available on the web at
22 <http://bytesex.org/v4l/>.
23 23
24 To compile this driver as a module, choose M here: the 24 To compile this driver as a module, choose M here: the
25 module will be called videodev. 25 module will be called videodev.
26 26
27config VIDEO_V4L1
28 boolean "Enable Video For Linux API 1 (DEPRECATED)"
29 depends on VIDEO_DEV
30 select VIDEO_V4L1_COMPAT
31 default y
32 ---help---
33 Enables a compatibility API used by most V4L2 devices to allow
34 its usage with legacy applications that supports only V4L1 api.
35
36 If you are unsure as to whether this is required, answer Y.
37
38config VIDEO_V4L1_COMPAT
39 boolean "Enable Video For Linux API 1 compatible Layer"
40 depends on VIDEO_DEV
41 default y
42 ---help---
43 This api were developed to be used at Kernel 2.2 and 2.4, but
44 lacks support for several video standards. There are several
45 drivers at kernel that still depends on it.
46
47 Documentation for the original API is included in the file
48 <Documentation/video4linux/API.html>.
49
50 User tools for this are available from
51 <ftp://ftp.uk.linux.org/pub/linux/video4linux/>.
52
53 If you are unsure as to whether this is required, answer Y.
54
55config VIDEO_V4L2
56 tristate
57 default y
58
27source "drivers/media/video/Kconfig" 59source "drivers/media/video/Kconfig"
28 60
29source "drivers/media/radio/Kconfig" 61source "drivers/media/radio/Kconfig"
@@ -65,4 +97,3 @@ config USB_DABUSB
65 module will be called dabusb. 97 module will be called dabusb.
66 98
67endmenu 99endmenu
68
diff --git a/drivers/media/common/Kconfig b/drivers/media/common/Kconfig
index 6a901a0268e1..1a04db4552da 100644
--- a/drivers/media/common/Kconfig
+++ b/drivers/media/common/Kconfig
@@ -1,9 +1,10 @@
1config VIDEO_SAA7146 1config VIDEO_SAA7146
2 tristate 2 tristate
3 select I2C 3 depends on I2C
4 4
5config VIDEO_SAA7146_VV 5config VIDEO_SAA7146_VV
6 tristate 6 tristate
7 select VIDEO_V4L2
7 select VIDEO_BUF 8 select VIDEO_BUF
8 select VIDEO_VIDEOBUF 9 select VIDEO_VIDEOBUF
9 select VIDEO_SAA7146 10 select VIDEO_SAA7146
diff --git a/drivers/media/dvb/Kconfig b/drivers/media/dvb/Kconfig
index 3f0ec6be03ae..a97c8f5e9a5d 100644
--- a/drivers/media/dvb/Kconfig
+++ b/drivers/media/dvb/Kconfig
@@ -22,26 +22,26 @@ config DVB
22source "drivers/media/dvb/dvb-core/Kconfig" 22source "drivers/media/dvb/dvb-core/Kconfig"
23 23
24comment "Supported SAA7146 based PCI Adapters" 24comment "Supported SAA7146 based PCI Adapters"
25 depends on DVB_CORE && PCI 25 depends on DVB_CORE && PCI && I2C
26source "drivers/media/dvb/ttpci/Kconfig" 26source "drivers/media/dvb/ttpci/Kconfig"
27 27
28comment "Supported USB Adapters" 28comment "Supported USB Adapters"
29 depends on DVB_CORE && USB 29 depends on DVB_CORE && USB && I2C
30source "drivers/media/dvb/dvb-usb/Kconfig" 30source "drivers/media/dvb/dvb-usb/Kconfig"
31source "drivers/media/dvb/ttusb-budget/Kconfig" 31source "drivers/media/dvb/ttusb-budget/Kconfig"
32source "drivers/media/dvb/ttusb-dec/Kconfig" 32source "drivers/media/dvb/ttusb-dec/Kconfig"
33source "drivers/media/dvb/cinergyT2/Kconfig" 33source "drivers/media/dvb/cinergyT2/Kconfig"
34 34
35comment "Supported FlexCopII (B2C2) Adapters" 35comment "Supported FlexCopII (B2C2) Adapters"
36 depends on DVB_CORE && (PCI || USB) 36 depends on DVB_CORE && (PCI || USB) && I2C
37source "drivers/media/dvb/b2c2/Kconfig" 37source "drivers/media/dvb/b2c2/Kconfig"
38 38
39comment "Supported BT878 Adapters" 39comment "Supported BT878 Adapters"
40 depends on DVB_CORE && PCI 40 depends on DVB_CORE && PCI && I2C
41source "drivers/media/dvb/bt8xx/Kconfig" 41source "drivers/media/dvb/bt8xx/Kconfig"
42 42
43comment "Supported Pluto2 Adapters" 43comment "Supported Pluto2 Adapters"
44 depends on DVB_CORE && PCI 44 depends on DVB_CORE && PCI && I2C
45source "drivers/media/dvb/pluto2/Kconfig" 45source "drivers/media/dvb/pluto2/Kconfig"
46 46
47comment "Supported DVB Frontends" 47comment "Supported DVB Frontends"
diff --git a/drivers/media/dvb/b2c2/Kconfig b/drivers/media/dvb/b2c2/Kconfig
index 2963605c0ecc..d7f1fd5b7b02 100644
--- a/drivers/media/dvb/b2c2/Kconfig
+++ b/drivers/media/dvb/b2c2/Kconfig
@@ -1,6 +1,6 @@
1config DVB_B2C2_FLEXCOP 1config DVB_B2C2_FLEXCOP
2 tristate "Technisat/B2C2 FlexCopII(b) and FlexCopIII adapters" 2 tristate "Technisat/B2C2 FlexCopII(b) and FlexCopIII adapters"
3 depends on DVB_CORE 3 depends on DVB_CORE && I2C
4 select DVB_STV0299 4 select DVB_STV0299
5 select DVB_MT352 5 select DVB_MT352
6 select DVB_MT312 6 select DVB_MT312
@@ -16,7 +16,7 @@ config DVB_B2C2_FLEXCOP
16 16
17config DVB_B2C2_FLEXCOP_PCI 17config DVB_B2C2_FLEXCOP_PCI
18 tristate "Technisat/B2C2 Air/Sky/Cable2PC PCI" 18 tristate "Technisat/B2C2 Air/Sky/Cable2PC PCI"
19 depends on DVB_B2C2_FLEXCOP && PCI 19 depends on DVB_B2C2_FLEXCOP && PCI && I2C
20 help 20 help
21 Support for the Air/Sky/CableStar2 PCI card (DVB/ATSC) by Technisat/B2C2. 21 Support for the Air/Sky/CableStar2 PCI card (DVB/ATSC) by Technisat/B2C2.
22 22
@@ -24,7 +24,7 @@ config DVB_B2C2_FLEXCOP_PCI
24 24
25config DVB_B2C2_FLEXCOP_USB 25config DVB_B2C2_FLEXCOP_USB
26 tristate "Technisat/B2C2 Air/Sky/Cable2PC USB" 26 tristate "Technisat/B2C2 Air/Sky/Cable2PC USB"
27 depends on DVB_B2C2_FLEXCOP && USB 27 depends on DVB_B2C2_FLEXCOP && USB && I2C
28 help 28 help
29 Support for the Air/Sky/Cable2PC USB1.1 box (DVB/ATSC) by Technisat/B2C2, 29 Support for the Air/Sky/Cable2PC USB1.1 box (DVB/ATSC) by Technisat/B2C2,
30 30
diff --git a/drivers/media/dvb/bt8xx/Kconfig b/drivers/media/dvb/bt8xx/Kconfig
index 376ca48f1d1d..f394002118f8 100644
--- a/drivers/media/dvb/bt8xx/Kconfig
+++ b/drivers/media/dvb/bt8xx/Kconfig
@@ -1,12 +1,13 @@
1config DVB_BT8XX 1config DVB_BT8XX
2 tristate "BT8xx based PCI cards" 2 tristate "BT8xx based PCI cards"
3 depends on DVB_CORE && PCI && VIDEO_BT848 3 depends on DVB_CORE && PCI && I2C && VIDEO_BT848
4 select DVB_MT352 4 select DVB_MT352
5 select DVB_SP887X 5 select DVB_SP887X
6 select DVB_NXT6000 6 select DVB_NXT6000
7 select DVB_CX24110 7 select DVB_CX24110
8 select DVB_OR51211 8 select DVB_OR51211
9 select DVB_LGDT330X 9 select DVB_LGDT330X
10 select DVB_ZL10353
10 select FW_LOADER 11 select FW_LOADER
11 help 12 help
12 Support for PCI cards based on the Bt8xx PCI bridge. Examples are 13 Support for PCI cards based on the Bt8xx PCI bridge. Examples are
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
index baa8227ef87c..ccc7b2eb4a2d 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -115,7 +115,7 @@ static int is_pci_slot_eq(struct pci_dev* adev, struct pci_dev* bdev)
115 return 0; 115 return 0;
116} 116}
117 117
118static struct bt878 __init *dvb_bt8xx_878_match(unsigned int bttv_nr, struct pci_dev* bttv_pci_dev) 118static struct bt878 __devinit *dvb_bt8xx_878_match(unsigned int bttv_nr, struct pci_dev* bttv_pci_dev)
119{ 119{
120 unsigned int card_nr; 120 unsigned int card_nr;
121 121
@@ -709,7 +709,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
709 } 709 }
710} 710}
711 711
712static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type) 712static int __devinit dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type)
713{ 713{
714 int result; 714 int result;
715 715
@@ -794,7 +794,7 @@ static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type)
794 return 0; 794 return 0;
795} 795}
796 796
797static int dvb_bt8xx_probe(struct bttv_sub_device *sub) 797static int __devinit dvb_bt8xx_probe(struct bttv_sub_device *sub)
798{ 798{
799 struct dvb_bt8xx_card *card; 799 struct dvb_bt8xx_card *card;
800 struct pci_dev* bttv_pci_dev; 800 struct pci_dev* bttv_pci_dev;
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index 71b575dc22bd..9325d039ea65 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -902,7 +902,10 @@ static int cinergyt2_probe (struct usb_interface *intf,
902 return -ENOMEM; 902 return -ENOMEM;
903 } 903 }
904 904
905 dvb_register_adapter(&cinergyt2->adapter, DRIVER_NAME, THIS_MODULE); 905 if ((err = dvb_register_adapter(&cinergyt2->adapter, DRIVER_NAME, THIS_MODULE)) < 0) {
906 kfree(cinergyt2);
907 return err;
908 }
906 909
907 cinergyt2->demux.priv = cinergyt2; 910 cinergyt2->demux.priv = cinergyt2;
908 cinergyt2->demux.filternum = 256; 911 cinergyt2->demux.filternum = 256;
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 4f8f257e6795..a051790161b0 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -106,6 +106,8 @@ struct dvb_frontend_private {
106 unsigned long tune_mode_flags; 106 unsigned long tune_mode_flags;
107 unsigned int delay; 107 unsigned int delay;
108 unsigned int reinitialise; 108 unsigned int reinitialise;
109 int tone;
110 int voltage;
109 111
110 /* swzigzag values */ 112 /* swzigzag values */
111 unsigned int state; 113 unsigned int state;
@@ -537,6 +539,12 @@ static int dvb_frontend_thread(void *data)
537 539
538 if (fepriv->reinitialise) { 540 if (fepriv->reinitialise) {
539 dvb_frontend_init(fe); 541 dvb_frontend_init(fe);
542 if (fepriv->tone != -1) {
543 fe->ops->set_tone(fe, fepriv->tone);
544 }
545 if (fepriv->voltage != -1) {
546 fe->ops->set_voltage(fe, fepriv->voltage);
547 }
540 fepriv->reinitialise = 0; 548 fepriv->reinitialise = 0;
541 } 549 }
542 550
@@ -788,6 +796,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
788 case FE_SET_TONE: 796 case FE_SET_TONE:
789 if (fe->ops->set_tone) { 797 if (fe->ops->set_tone) {
790 err = fe->ops->set_tone(fe, (fe_sec_tone_mode_t) parg); 798 err = fe->ops->set_tone(fe, (fe_sec_tone_mode_t) parg);
799 fepriv->tone = (fe_sec_tone_mode_t) parg;
791 fepriv->state = FESTATE_DISEQC; 800 fepriv->state = FESTATE_DISEQC;
792 fepriv->status = 0; 801 fepriv->status = 0;
793 } 802 }
@@ -796,6 +805,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
796 case FE_SET_VOLTAGE: 805 case FE_SET_VOLTAGE:
797 if (fe->ops->set_voltage) { 806 if (fe->ops->set_voltage) {
798 err = fe->ops->set_voltage(fe, (fe_sec_voltage_t) parg); 807 err = fe->ops->set_voltage(fe, (fe_sec_voltage_t) parg);
808 fepriv->voltage = (fe_sec_voltage_t) parg;
799 fepriv->state = FESTATE_DISEQC; 809 fepriv->state = FESTATE_DISEQC;
800 fepriv->status = 0; 810 fepriv->status = 0;
801 } 811 }
@@ -995,6 +1005,8 @@ static int dvb_frontend_open(struct inode *inode, struct file *file)
995 1005
996 /* normal tune mode when opened R/W */ 1006 /* normal tune mode when opened R/W */
997 fepriv->tune_mode_flags &= ~FE_TUNE_MODE_ONESHOT; 1007 fepriv->tune_mode_flags &= ~FE_TUNE_MODE_ONESHOT;
1008 fepriv->tone = -1;
1009 fepriv->voltage = -1;
998 } 1010 }
999 1011
1000 return ret; 1012 return ret;
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 96fe0ecae250..3852430d0260 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -219,8 +219,6 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
219 return -ENOMEM; 219 return -ENOMEM;
220 } 220 }
221 221
222 mutex_unlock(&dvbdev_register_lock);
223
224 memcpy(dvbdev, template, sizeof(struct dvb_device)); 222 memcpy(dvbdev, template, sizeof(struct dvb_device));
225 dvbdev->type = type; 223 dvbdev->type = type;
226 dvbdev->id = id; 224 dvbdev->id = id;
@@ -231,6 +229,8 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
231 229
232 list_add_tail (&dvbdev->list_head, &adap->device_list); 230 list_add_tail (&dvbdev->list_head, &adap->device_list);
233 231
232 mutex_unlock(&dvbdev_register_lock);
233
234 devfs_mk_cdev(MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)), 234 devfs_mk_cdev(MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
235 S_IFCHR | S_IRUSR | S_IWUSR, 235 S_IFCHR | S_IRUSR | S_IWUSR,
236 "dvb/adapter%d/%s%d", adap->num, dnames[type], id); 236 "dvb/adapter%d/%s%d", adap->num, dnames[type], id);
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index d3df12039b06..e388fb1567d6 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -1,6 +1,6 @@
1config DVB_USB 1config DVB_USB
2 tristate "Support for various USB DVB devices" 2 tristate "Support for various USB DVB devices"
3 depends on DVB_CORE && USB 3 depends on DVB_CORE && USB && I2C
4 select FW_LOADER 4 select FW_LOADER
5 help 5 help
6 By enabling this you will be able to choose the various supported 6 By enabling this you will be able to choose the various supported
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index 7edd6362b9cc..1f0d3e995c8d 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -150,6 +150,15 @@ static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
150 return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0); 150 return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
151} 151}
152 152
153static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
154{
155 u8 b = 0;
156 if (onoff)
157 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
158 else
159 return 0;
160}
161
153static int cxusb_streaming_ctrl(struct dvb_usb_device *d, int onoff) 162static int cxusb_streaming_ctrl(struct dvb_usb_device *d, int onoff)
154{ 163{
155 u8 buf[2] = { 0x03, 0x00 }; 164 u8 buf[2] = { 0x03, 0x00 };
@@ -544,7 +553,7 @@ static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = {
544 .size_of_priv = sizeof(struct cxusb_state), 553 .size_of_priv = sizeof(struct cxusb_state),
545 554
546 .streaming_ctrl = cxusb_streaming_ctrl, 555 .streaming_ctrl = cxusb_streaming_ctrl,
547 .power_ctrl = cxusb_power_ctrl, 556 .power_ctrl = cxusb_bluebird_power_ctrl,
548 .frontend_attach = cxusb_lgdt3303_frontend_attach, 557 .frontend_attach = cxusb_lgdt3303_frontend_attach,
549 .tuner_attach = cxusb_lgh064f_tuner_attach, 558 .tuner_attach = cxusb_lgh064f_tuner_attach,
550 559
@@ -589,7 +598,7 @@ static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = {
589 .size_of_priv = sizeof(struct cxusb_state), 598 .size_of_priv = sizeof(struct cxusb_state),
590 599
591 .streaming_ctrl = cxusb_streaming_ctrl, 600 .streaming_ctrl = cxusb_streaming_ctrl,
592 .power_ctrl = cxusb_power_ctrl, 601 .power_ctrl = cxusb_bluebird_power_ctrl,
593 .frontend_attach = cxusb_dee1601_frontend_attach, 602 .frontend_attach = cxusb_dee1601_frontend_attach,
594 .tuner_attach = cxusb_dee1601_tuner_attach, 603 .tuner_attach = cxusb_dee1601_tuner_attach,
595 604
@@ -638,7 +647,7 @@ static struct dvb_usb_properties cxusb_bluebird_lgz201_properties = {
638 .size_of_priv = sizeof(struct cxusb_state), 647 .size_of_priv = sizeof(struct cxusb_state),
639 648
640 .streaming_ctrl = cxusb_streaming_ctrl, 649 .streaming_ctrl = cxusb_streaming_ctrl,
641 .power_ctrl = cxusb_power_ctrl, 650 .power_ctrl = cxusb_bluebird_power_ctrl,
642 .frontend_attach = cxusb_mt352_frontend_attach, 651 .frontend_attach = cxusb_mt352_frontend_attach,
643 .tuner_attach = cxusb_lgz201_tuner_attach, 652 .tuner_attach = cxusb_lgz201_tuner_attach,
644 653
@@ -683,7 +692,7 @@ static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties = {
683 .size_of_priv = sizeof(struct cxusb_state), 692 .size_of_priv = sizeof(struct cxusb_state),
684 693
685 .streaming_ctrl = cxusb_streaming_ctrl, 694 .streaming_ctrl = cxusb_streaming_ctrl,
686 .power_ctrl = cxusb_power_ctrl, 695 .power_ctrl = cxusb_bluebird_power_ctrl,
687 .frontend_attach = cxusb_mt352_frontend_attach, 696 .frontend_attach = cxusb_mt352_frontend_attach,
688 .tuner_attach = cxusb_dtt7579_tuner_attach, 697 .tuner_attach = cxusb_dtt7579_tuner_attach,
689 698
diff --git a/drivers/media/dvb/frontends/cx24123.c b/drivers/media/dvb/frontends/cx24123.c
index d661c6f9cbe5..691dc840dcc0 100644
--- a/drivers/media/dvb/frontends/cx24123.c
+++ b/drivers/media/dvb/frontends/cx24123.c
@@ -29,6 +29,9 @@
29#include "dvb_frontend.h" 29#include "dvb_frontend.h"
30#include "cx24123.h" 30#include "cx24123.h"
31 31
32#define XTAL 10111000
33
34static int force_band;
32static int debug; 35static int debug;
33#define dprintk(args...) \ 36#define dprintk(args...) \
34 do { \ 37 do { \
@@ -52,6 +55,7 @@ struct cx24123_state
52 u32 VGAarg; 55 u32 VGAarg;
53 u32 bandselectarg; 56 u32 bandselectarg;
54 u32 pllarg; 57 u32 pllarg;
58 u32 FILTune;
55 59
56 /* The Demod/Tuner can't easily provide these, we cache them */ 60 /* The Demod/Tuner can't easily provide these, we cache them */
57 u32 currentfreq; 61 u32 currentfreq;
@@ -63,43 +67,33 @@ static struct
63{ 67{
64 u32 symbolrate_low; 68 u32 symbolrate_low;
65 u32 symbolrate_high; 69 u32 symbolrate_high;
66 u32 VCAslope;
67 u32 VCAoffset;
68 u32 VGA1offset;
69 u32 VGA2offset;
70 u32 VCAprogdata; 70 u32 VCAprogdata;
71 u32 VGAprogdata; 71 u32 VGAprogdata;
72 u32 FILTune;
72} cx24123_AGC_vals[] = 73} cx24123_AGC_vals[] =
73{ 74{
74 { 75 {
75 .symbolrate_low = 1000000, 76 .symbolrate_low = 1000000,
76 .symbolrate_high = 4999999, 77 .symbolrate_high = 4999999,
77 .VCAslope = 0x07, 78 /* the specs recommend other values for VGA offsets,
78 .VCAoffset = 0x0f, 79 but tests show they are wrong */
79 .VGA1offset = 0x1f8, 80 .VGAprogdata = (1 << 19) | (0x180 << 9) | 0x1e0,
80 .VGA2offset = 0x1f8, 81 .VCAprogdata = (2 << 19) | (0x07 << 9) | 0x07,
81 .VGAprogdata = (2 << 18) | (0x1f8 << 9) | 0x1f8, 82 .FILTune = 0x27f /* 0.41 V */
82 .VCAprogdata = (4 << 18) | (0x07 << 9) | 0x07,
83 }, 83 },
84 { 84 {
85 .symbolrate_low = 5000000, 85 .symbolrate_low = 5000000,
86 .symbolrate_high = 14999999, 86 .symbolrate_high = 14999999,
87 .VCAslope = 0x1f, 87 .VGAprogdata = (1 << 19) | (0x180 << 9) | 0x1e0,
88 .VCAoffset = 0x1f, 88 .VCAprogdata = (2 << 19) | (0x07 << 9) | 0x1f,
89 .VGA1offset = 0x1e0, 89 .FILTune = 0x317 /* 0.90 V */
90 .VGA2offset = 0x180,
91 .VGAprogdata = (2 << 18) | (0x180 << 9) | 0x1e0,
92 .VCAprogdata = (4 << 18) | (0x07 << 9) | 0x1f,
93 }, 90 },
94 { 91 {
95 .symbolrate_low = 15000000, 92 .symbolrate_low = 15000000,
96 .symbolrate_high = 45000000, 93 .symbolrate_high = 45000000,
97 .VCAslope = 0x3f, 94 .VGAprogdata = (1 << 19) | (0x100 << 9) | 0x180,
98 .VCAoffset = 0x3f, 95 .VCAprogdata = (2 << 19) | (0x07 << 9) | 0x3f,
99 .VGA1offset = 0x180, 96 .FILTune = 0x145 /* 2.70 V */
100 .VGA2offset = 0x100,
101 .VGAprogdata = (2 << 18) | (0x100 << 9) | 0x180,
102 .VCAprogdata = (4 << 18) | (0x07 << 9) | 0x3f,
103 }, 97 },
104}; 98};
105 99
@@ -112,91 +106,80 @@ static struct
112{ 106{
113 u32 freq_low; 107 u32 freq_low;
114 u32 freq_high; 108 u32 freq_high;
115 u32 bandselect;
116 u32 VCOdivider; 109 u32 VCOdivider;
117 u32 VCOnumber;
118 u32 progdata; 110 u32 progdata;
119} cx24123_bandselect_vals[] = 111} cx24123_bandselect_vals[] =
120{ 112{
113 /* band 1 */
121 { 114 {
122 .freq_low = 950000, 115 .freq_low = 950000,
123 .freq_high = 1018999,
124 .bandselect = 0x40,
125 .VCOdivider = 4,
126 .VCOnumber = 7,
127 .progdata = (0 << 18) | (0 << 9) | 0x40,
128 },
129 {
130 .freq_low = 1019000,
131 .freq_high = 1074999, 116 .freq_high = 1074999,
132 .bandselect = 0x80,
133 .VCOdivider = 4, 117 .VCOdivider = 4,
134 .VCOnumber = 8, 118 .progdata = (0 << 19) | (0 << 9) | 0x40,
135 .progdata = (0 << 18) | (0 << 9) | 0x80,
136 }, 119 },
120
121 /* band 2 */
137 { 122 {
138 .freq_low = 1075000, 123 .freq_low = 1075000,
139 .freq_high = 1227999, 124 .freq_high = 1177999,
140 .bandselect = 0x01, 125 .VCOdivider = 4,
141 .VCOdivider = 2, 126 .progdata = (0 << 19) | (0 << 9) | 0x80,
142 .VCOnumber = 1,
143 .progdata = (0 << 18) | (1 << 9) | 0x01,
144 }, 127 },
128
129 /* band 3 */
145 { 130 {
146 .freq_low = 1228000, 131 .freq_low = 1178000,
147 .freq_high = 1349999, 132 .freq_high = 1295999,
148 .bandselect = 0x02,
149 .VCOdivider = 2, 133 .VCOdivider = 2,
150 .VCOnumber = 2, 134 .progdata = (0 << 19) | (1 << 9) | 0x01,
151 .progdata = (0 << 18) | (1 << 9) | 0x02,
152 }, 135 },
136
137 /* band 4 */
153 { 138 {
154 .freq_low = 1350000, 139 .freq_low = 1296000,
155 .freq_high = 1481999, 140 .freq_high = 1431999,
156 .bandselect = 0x04,
157 .VCOdivider = 2, 141 .VCOdivider = 2,
158 .VCOnumber = 3, 142 .progdata = (0 << 19) | (1 << 9) | 0x02,
159 .progdata = (0 << 18) | (1 << 9) | 0x04,
160 }, 143 },
144
145 /* band 5 */
161 { 146 {
162 .freq_low = 1482000, 147 .freq_low = 1432000,
163 .freq_high = 1595999, 148 .freq_high = 1575999,
164 .bandselect = 0x08,
165 .VCOdivider = 2, 149 .VCOdivider = 2,
166 .VCOnumber = 4, 150 .progdata = (0 << 19) | (1 << 9) | 0x04,
167 .progdata = (0 << 18) | (1 << 9) | 0x08,
168 }, 151 },
152
153 /* band 6 */
169 { 154 {
170 .freq_low = 1596000, 155 .freq_low = 1576000,
171 .freq_high = 1717999, 156 .freq_high = 1717999,
172 .bandselect = 0x10,
173 .VCOdivider = 2, 157 .VCOdivider = 2,
174 .VCOnumber = 5, 158 .progdata = (0 << 19) | (1 << 9) | 0x08,
175 .progdata = (0 << 18) | (1 << 9) | 0x10,
176 }, 159 },
160
161 /* band 7 */
177 { 162 {
178 .freq_low = 1718000, 163 .freq_low = 1718000,
179 .freq_high = 1855999, 164 .freq_high = 1855999,
180 .bandselect = 0x20,
181 .VCOdivider = 2, 165 .VCOdivider = 2,
182 .VCOnumber = 6, 166 .progdata = (0 << 19) | (1 << 9) | 0x10,
183 .progdata = (0 << 18) | (1 << 9) | 0x20,
184 }, 167 },
168
169 /* band 8 */
185 { 170 {
186 .freq_low = 1856000, 171 .freq_low = 1856000,
187 .freq_high = 2035999, 172 .freq_high = 2035999,
188 .bandselect = 0x40,
189 .VCOdivider = 2, 173 .VCOdivider = 2,
190 .VCOnumber = 7, 174 .progdata = (0 << 19) | (1 << 9) | 0x20,
191 .progdata = (0 << 18) | (1 << 9) | 0x40,
192 }, 175 },
176
177 /* band 9 */
193 { 178 {
194 .freq_low = 2036000, 179 .freq_low = 2036000,
195 .freq_high = 2149999, 180 .freq_high = 2150000,
196 .bandselect = 0x80,
197 .VCOdivider = 2, 181 .VCOdivider = 2,
198 .VCOnumber = 8, 182 .progdata = (0 << 19) | (1 << 9) | 0x40,
199 .progdata = (0 << 18) | (1 << 9) | 0x80,
200 }, 183 },
201}; 184};
202 185
@@ -207,49 +190,44 @@ static struct {
207{ 190{
208 {0x00, 0x03}, /* Reset system */ 191 {0x00, 0x03}, /* Reset system */
209 {0x00, 0x00}, /* Clear reset */ 192 {0x00, 0x00}, /* Clear reset */
210 {0x01, 0x3b}, /* Apply sensible defaults, from an i2c sniffer */ 193 {0x03, 0x07}, /* QPSK, DVB, Auto Acquisition (default) */
211 {0x03, 0x07}, 194 {0x04, 0x10}, /* MPEG */
212 {0x04, 0x10}, 195 {0x05, 0x04}, /* MPEG */
213 {0x05, 0x04}, 196 {0x06, 0x31}, /* MPEG (default) */
214 {0x06, 0x31}, 197 {0x0b, 0x00}, /* Freq search start point (default) */
215 {0x0d, 0x02}, 198 {0x0c, 0x00}, /* Demodulator sample gain (default) */
216 {0x0e, 0x03}, 199 {0x0d, 0x02}, /* Frequency search range = Fsymbol / 4 (default) */
217 {0x0f, 0xfe}, 200 {0x0e, 0x03}, /* Default non-inverted, FEC 3/4 (default) */
218 {0x10, 0x01}, 201 {0x0f, 0xfe}, /* FEC search mask (all supported codes) */
219 {0x14, 0x01}, 202 {0x10, 0x01}, /* Default search inversion, no repeat (default) */
220 {0x15, 0x98}, 203 {0x16, 0x00}, /* Enable reading of frequency */
221 {0x16, 0x00}, 204 {0x17, 0x01}, /* Enable EsNO Ready Counter */
222 {0x17, 0x01}, 205 {0x1c, 0x80}, /* Enable error counter */
223 {0x1b, 0x05}, 206 {0x20, 0x00}, /* Tuner burst clock rate = 500KHz */
224 {0x1c, 0x80}, 207 {0x21, 0x15}, /* Tuner burst mode, word length = 0x15 */
225 {0x1d, 0x00}, 208 {0x28, 0x00}, /* Enable FILTERV with positive pol., DiSEqC 2.x off */
226 {0x1e, 0x00}, 209 {0x29, 0x00}, /* DiSEqC LNB_DC off */
227 {0x20, 0x41}, 210 {0x2a, 0xb0}, /* DiSEqC Parameters (default) */
228 {0x21, 0x15}, 211 {0x2b, 0x73}, /* DiSEqC Tone Frequency (default) */
229 {0x27, 0x14}, 212 {0x2c, 0x00}, /* DiSEqC Message (0x2c - 0x31) */
230 {0x28, 0x46},
231 {0x29, 0x00},
232 {0x2a, 0xb0},
233 {0x2b, 0x73},
234 {0x2c, 0x00},
235 {0x2d, 0x00}, 213 {0x2d, 0x00},
236 {0x2e, 0x00}, 214 {0x2e, 0x00},
237 {0x2f, 0x00}, 215 {0x2f, 0x00},
238 {0x30, 0x00}, 216 {0x30, 0x00},
239 {0x31, 0x00}, 217 {0x31, 0x00},
240 {0x32, 0x8c}, 218 {0x32, 0x8c}, /* DiSEqC Parameters (default) */
241 {0x33, 0x00}, 219 {0x33, 0x00}, /* Interrupts off (0x33 - 0x34) */
242 {0x34, 0x00}, 220 {0x34, 0x00},
243 {0x35, 0x03}, 221 {0x35, 0x03}, /* DiSEqC Tone Amplitude (default) */
244 {0x36, 0x02}, 222 {0x36, 0x02}, /* DiSEqC Parameters (default) */
245 {0x37, 0x3a}, 223 {0x37, 0x3a}, /* DiSEqC Parameters (default) */
246 {0x3a, 0x00}, /* Enable AGC accumulator */ 224 {0x3a, 0x00}, /* Enable AGC accumulator (for signal strength) */
247 {0x44, 0x00}, 225 {0x44, 0x00}, /* Constellation (default) */
248 {0x45, 0x00}, 226 {0x45, 0x00}, /* Symbol count (default) */
249 {0x46, 0x05}, 227 {0x46, 0x0d}, /* Symbol rate estimator on (default) */
250 {0x56, 0x41}, 228 {0x56, 0x41}, /* Various (default) */
251 {0x57, 0xff}, 229 {0x57, 0xff}, /* Error Counter Window (default) */
252 {0x67, 0x83}, 230 {0x67, 0x83}, /* Non-DCII symbol clock */
253}; 231};
254 232
255static int cx24123_writereg(struct cx24123_state* state, int reg, int data) 233static int cx24123_writereg(struct cx24123_state* state, int reg, int data)
@@ -258,6 +236,10 @@ static int cx24123_writereg(struct cx24123_state* state, int reg, int data)
258 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; 236 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
259 int err; 237 int err;
260 238
239 if (debug>1)
240 printk("cx24123: %s: write reg 0x%02x, value 0x%02x\n",
241 __FUNCTION__,reg, data);
242
261 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { 243 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
262 printk("%s: writereg error(err == %i, reg == 0x%02x," 244 printk("%s: writereg error(err == %i, reg == 0x%02x,"
263 " data == 0x%02x)\n", __FUNCTION__, err, reg, data); 245 " data == 0x%02x)\n", __FUNCTION__, err, reg, data);
@@ -274,6 +256,10 @@ static int cx24123_writelnbreg(struct cx24123_state* state, int reg, int data)
274 struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = buf, .len = 2 }; 256 struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = buf, .len = 2 };
275 int err; 257 int err;
276 258
259 if (debug>1)
260 printk("cx24123: %s: writeln addr=0x08, reg 0x%02x, value 0x%02x\n",
261 __FUNCTION__,reg, data);
262
277 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { 263 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
278 printk("%s: writelnbreg error (err == %i, reg == 0x%02x," 264 printk("%s: writelnbreg error (err == %i, reg == 0x%02x,"
279 " data == 0x%02x)\n", __FUNCTION__, err, reg, data); 265 " data == 0x%02x)\n", __FUNCTION__, err, reg, data);
@@ -303,6 +289,9 @@ static int cx24123_readreg(struct cx24123_state* state, u8 reg)
303 return ret; 289 return ret;
304 } 290 }
305 291
292 if (debug>1)
293 printk("cx24123: read reg 0x%02x, value 0x%02x\n",reg, ret);
294
306 return b1[0]; 295 return b1[0];
307} 296}
308 297
@@ -313,17 +302,23 @@ static int cx24123_readlnbreg(struct cx24123_state* state, u8 reg)
313 302
314static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_inversion_t inversion) 303static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_inversion_t inversion)
315{ 304{
305 u8 nom_reg = cx24123_readreg(state, 0x0e);
306 u8 auto_reg = cx24123_readreg(state, 0x10);
307
316 switch (inversion) { 308 switch (inversion) {
317 case INVERSION_OFF: 309 case INVERSION_OFF:
318 cx24123_writereg(state, 0x0e, cx24123_readreg(state, 0x0e) & 0x7f); 310 dprintk("%s: inversion off\n",__FUNCTION__);
319 cx24123_writereg(state, 0x10, cx24123_readreg(state, 0x10) | 0x80); 311 cx24123_writereg(state, 0x0e, nom_reg & ~0x80);
312 cx24123_writereg(state, 0x10, auto_reg | 0x80);
320 break; 313 break;
321 case INVERSION_ON: 314 case INVERSION_ON:
322 cx24123_writereg(state, 0x0e, cx24123_readreg(state, 0x0e) | 0x80); 315 dprintk("%s: inversion on\n",__FUNCTION__);
323 cx24123_writereg(state, 0x10, cx24123_readreg(state, 0x10) | 0x80); 316 cx24123_writereg(state, 0x0e, nom_reg | 0x80);
317 cx24123_writereg(state, 0x10, auto_reg | 0x80);
324 break; 318 break;
325 case INVERSION_AUTO: 319 case INVERSION_AUTO:
326 cx24123_writereg(state, 0x10, cx24123_readreg(state, 0x10) & 0x7f); 320 dprintk("%s: inversion auto\n",__FUNCTION__);
321 cx24123_writereg(state, 0x10, auto_reg & ~0x80);
327 break; 322 break;
328 default: 323 default:
329 return -EINVAL; 324 return -EINVAL;
@@ -338,92 +333,191 @@ static int cx24123_get_inversion(struct cx24123_state* state, fe_spectral_invers
338 333
339 val = cx24123_readreg(state, 0x1b) >> 7; 334 val = cx24123_readreg(state, 0x1b) >> 7;
340 335
341 if (val == 0) 336 if (val == 0) {
337 dprintk("%s: read inversion off\n",__FUNCTION__);
342 *inversion = INVERSION_OFF; 338 *inversion = INVERSION_OFF;
343 else 339 } else {
340 dprintk("%s: read inversion on\n",__FUNCTION__);
344 *inversion = INVERSION_ON; 341 *inversion = INVERSION_ON;
342 }
345 343
346 return 0; 344 return 0;
347} 345}
348 346
349static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec) 347static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec)
350{ 348{
349 u8 nom_reg = cx24123_readreg(state, 0x0e) & ~0x07;
350
351 if ( (fec < FEC_NONE) || (fec > FEC_AUTO) ) 351 if ( (fec < FEC_NONE) || (fec > FEC_AUTO) )
352 fec = FEC_AUTO; 352 fec = FEC_AUTO;
353 353
354 /* Hardware has 5/11 and 3/5 but are never unused */
355 switch (fec) { 354 switch (fec) {
356 case FEC_NONE:
357 return cx24123_writereg(state, 0x0f, 0x01);
358 case FEC_1_2: 355 case FEC_1_2:
359 return cx24123_writereg(state, 0x0f, 0x02); 356 dprintk("%s: set FEC to 1/2\n",__FUNCTION__);
357 cx24123_writereg(state, 0x0e, nom_reg | 0x01);
358 cx24123_writereg(state, 0x0f, 0x02);
359 break;
360 case FEC_2_3: 360 case FEC_2_3:
361 return cx24123_writereg(state, 0x0f, 0x04); 361 dprintk("%s: set FEC to 2/3\n",__FUNCTION__);
362 cx24123_writereg(state, 0x0e, nom_reg | 0x02);
363 cx24123_writereg(state, 0x0f, 0x04);
364 break;
362 case FEC_3_4: 365 case FEC_3_4:
363 return cx24123_writereg(state, 0x0f, 0x08); 366 dprintk("%s: set FEC to 3/4\n",__FUNCTION__);
367 cx24123_writereg(state, 0x0e, nom_reg | 0x03);
368 cx24123_writereg(state, 0x0f, 0x08);
369 break;
370 case FEC_4_5:
371 dprintk("%s: set FEC to 4/5\n",__FUNCTION__);
372 cx24123_writereg(state, 0x0e, nom_reg | 0x04);
373 cx24123_writereg(state, 0x0f, 0x10);
374 break;
364 case FEC_5_6: 375 case FEC_5_6:
365 return cx24123_writereg(state, 0x0f, 0x20); 376 dprintk("%s: set FEC to 5/6\n",__FUNCTION__);
377 cx24123_writereg(state, 0x0e, nom_reg | 0x05);
378 cx24123_writereg(state, 0x0f, 0x20);
379 break;
380 case FEC_6_7:
381 dprintk("%s: set FEC to 6/7\n",__FUNCTION__);
382 cx24123_writereg(state, 0x0e, nom_reg | 0x06);
383 cx24123_writereg(state, 0x0f, 0x40);
384 break;
366 case FEC_7_8: 385 case FEC_7_8:
367 return cx24123_writereg(state, 0x0f, 0x80); 386 dprintk("%s: set FEC to 7/8\n",__FUNCTION__);
387 cx24123_writereg(state, 0x0e, nom_reg | 0x07);
388 cx24123_writereg(state, 0x0f, 0x80);
389 break;
368 case FEC_AUTO: 390 case FEC_AUTO:
369 return cx24123_writereg(state, 0x0f, 0xae); 391 dprintk("%s: set FEC to auto\n",__FUNCTION__);
392 cx24123_writereg(state, 0x0f, 0xfe);
393 break;
370 default: 394 default:
371 return -EOPNOTSUPP; 395 return -EOPNOTSUPP;
372 } 396 }
397
398 return 0;
373} 399}
374 400
375static int cx24123_get_fec(struct cx24123_state* state, fe_code_rate_t *fec) 401static int cx24123_get_fec(struct cx24123_state* state, fe_code_rate_t *fec)
376{ 402{
377 int ret; 403 int ret;
378 u8 val;
379 404
380 ret = cx24123_readreg (state, 0x1b); 405 ret = cx24123_readreg (state, 0x1b);
381 if (ret < 0) 406 if (ret < 0)
382 return ret; 407 return ret;
383 val = ret & 0x07; 408 ret = ret & 0x07;
384 switch (val) { 409
410 switch (ret) {
385 case 1: 411 case 1:
386 *fec = FEC_1_2; 412 *fec = FEC_1_2;
387 break; 413 break;
388 case 3: 414 case 2:
389 *fec = FEC_2_3; 415 *fec = FEC_2_3;
390 break; 416 break;
391 case 4: 417 case 3:
392 *fec = FEC_3_4; 418 *fec = FEC_3_4;
393 break; 419 break;
394 case 5: 420 case 4:
395 *fec = FEC_4_5; 421 *fec = FEC_4_5;
396 break; 422 break;
397 case 6: 423 case 5:
398 *fec = FEC_5_6; 424 *fec = FEC_5_6;
399 break; 425 break;
426 case 6:
427 *fec = FEC_6_7;
428 break;
400 case 7: 429 case 7:
401 *fec = FEC_7_8; 430 *fec = FEC_7_8;
402 break; 431 break;
403 case 2: /* *fec = FEC_3_5; break; */
404 case 0: /* *fec = FEC_5_11; break; */
405 *fec = FEC_AUTO;
406 break;
407 default: 432 default:
408 *fec = FEC_NONE; // can't happen 433 /* this can happen when there's no lock */
434 *fec = FEC_NONE;
409 } 435 }
410 436
411 return 0; 437 return 0;
412} 438}
413 439
414/* fixme: Symbol rates < 3MSps may not work because of precision loss */ 440/* Approximation of closest integer of log2(a/b). It actually gives the
441 lowest integer i such that 2^i >= round(a/b) */
442static u32 cx24123_int_log2(u32 a, u32 b)
443{
444 u32 exp, nearest = 0;
445 u32 div = a / b;
446 if(a % b >= b / 2) ++div;
447 if(div < (1 << 31))
448 {
449 for(exp = 1; div > exp; nearest++)
450 exp += exp;
451 }
452 return nearest;
453}
454
415static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate) 455static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate)
416{ 456{
417 u32 val; 457 u32 tmp, sample_rate, ratio, sample_gain;
458 u8 pll_mult;
459
460 /* check if symbol rate is within limits */
461 if ((srate > state->ops.info.symbol_rate_max) ||
462 (srate < state->ops.info.symbol_rate_min))
463 return -EOPNOTSUPP;;
464
465 /* choose the sampling rate high enough for the required operation,
466 while optimizing the power consumed by the demodulator */
467 if (srate < (XTAL*2)/2)
468 pll_mult = 2;
469 else if (srate < (XTAL*3)/2)
470 pll_mult = 3;
471 else if (srate < (XTAL*4)/2)
472 pll_mult = 4;
473 else if (srate < (XTAL*5)/2)
474 pll_mult = 5;
475 else if (srate < (XTAL*6)/2)
476 pll_mult = 6;
477 else if (srate < (XTAL*7)/2)
478 pll_mult = 7;
479 else if (srate < (XTAL*8)/2)
480 pll_mult = 8;
481 else
482 pll_mult = 9;
483
484
485 sample_rate = pll_mult * XTAL;
486
487 /*
488 SYSSymbolRate[21:0] = (srate << 23) / sample_rate
489
490 We have to use 32 bit unsigned arithmetic without precision loss.
491 The maximum srate is 45000000 or 0x02AEA540. This number has
492 only 6 clear bits on top, hence we can shift it left only 6 bits
493 at a time. Borrowed from cx24110.c
494 */
495
496 tmp = srate << 6;
497 ratio = tmp / sample_rate;
498
499 tmp = (tmp % sample_rate) << 6;
500 ratio = (ratio << 6) + (tmp / sample_rate);
501
502 tmp = (tmp % sample_rate) << 6;
503 ratio = (ratio << 6) + (tmp / sample_rate);
504
505 tmp = (tmp % sample_rate) << 5;
506 ratio = (ratio << 5) + (tmp / sample_rate);
507
508
509 cx24123_writereg(state, 0x01, pll_mult * 6);
418 510
419 val = (srate / 1185) * 100; 511 cx24123_writereg(state, 0x08, (ratio >> 16) & 0x3f );
512 cx24123_writereg(state, 0x09, (ratio >> 8) & 0xff );
513 cx24123_writereg(state, 0x0a, (ratio ) & 0xff );
420 514
421 /* Compensate for scaling up, by removing 17 symbols per 1Msps */ 515 /* also set the demodulator sample gain */
422 val = val - (17 * (srate / 1000000)); 516 sample_gain = cx24123_int_log2(sample_rate, srate);
517 tmp = cx24123_readreg(state, 0x0c) & ~0xe0;
518 cx24123_writereg(state, 0x0c, tmp | sample_gain << 5);
423 519
424 cx24123_writereg(state, 0x08, (val >> 16) & 0xff ); 520 dprintk("%s: srate=%d, ratio=0x%08x, sample_rate=%i sample_gain=%d\n", __FUNCTION__, srate, ratio, sample_rate, sample_gain);
425 cx24123_writereg(state, 0x09, (val >> 8) & 0xff );
426 cx24123_writereg(state, 0x0a, (val ) & 0xff );
427 521
428 return 0; 522 return 0;
429} 523}
@@ -437,6 +531,9 @@ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_pa
437 struct cx24123_state *state = fe->demodulator_priv; 531 struct cx24123_state *state = fe->demodulator_priv;
438 u32 ndiv = 0, adiv = 0, vco_div = 0; 532 u32 ndiv = 0, adiv = 0, vco_div = 0;
439 int i = 0; 533 int i = 0;
534 int pump = 2;
535 int band = 0;
536 int num_bands = sizeof(cx24123_bandselect_vals) / sizeof(cx24123_bandselect_vals[0]);
440 537
441 /* Defaults for low freq, low rate */ 538 /* Defaults for low freq, low rate */
442 state->VCAarg = cx24123_AGC_vals[0].VCAprogdata; 539 state->VCAarg = cx24123_AGC_vals[0].VCAprogdata;
@@ -444,38 +541,49 @@ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_pa
444 state->bandselectarg = cx24123_bandselect_vals[0].progdata; 541 state->bandselectarg = cx24123_bandselect_vals[0].progdata;
445 vco_div = cx24123_bandselect_vals[0].VCOdivider; 542 vco_div = cx24123_bandselect_vals[0].VCOdivider;
446 543
447 /* For the given symbolerate, determine the VCA and VGA programming bits */ 544 /* For the given symbol rate, determine the VCA, VGA and FILTUNE programming bits */
448 for (i = 0; i < sizeof(cx24123_AGC_vals) / sizeof(cx24123_AGC_vals[0]); i++) 545 for (i = 0; i < sizeof(cx24123_AGC_vals) / sizeof(cx24123_AGC_vals[0]); i++)
449 { 546 {
450 if ((cx24123_AGC_vals[i].symbolrate_low <= p->u.qpsk.symbol_rate) && 547 if ((cx24123_AGC_vals[i].symbolrate_low <= p->u.qpsk.symbol_rate) &&
451 (cx24123_AGC_vals[i].symbolrate_high >= p->u.qpsk.symbol_rate) ) { 548 (cx24123_AGC_vals[i].symbolrate_high >= p->u.qpsk.symbol_rate) ) {
452 state->VCAarg = cx24123_AGC_vals[i].VCAprogdata; 549 state->VCAarg = cx24123_AGC_vals[i].VCAprogdata;
453 state->VGAarg = cx24123_AGC_vals[i].VGAprogdata; 550 state->VGAarg = cx24123_AGC_vals[i].VGAprogdata;
551 state->FILTune = cx24123_AGC_vals[i].FILTune;
454 } 552 }
455 } 553 }
456 554
457 /* For the given frequency, determine the bandselect programming bits */ 555 /* determine the band to use */
458 for (i = 0; i < sizeof(cx24123_bandselect_vals) / sizeof(cx24123_bandselect_vals[0]); i++) 556 if(force_band < 1 || force_band > num_bands)
459 { 557 {
460 if ((cx24123_bandselect_vals[i].freq_low <= p->frequency) && 558 for (i = 0; i < num_bands; i++)
461 (cx24123_bandselect_vals[i].freq_high >= p->frequency) ) { 559 {
462 state->bandselectarg = cx24123_bandselect_vals[i].progdata; 560 if ((cx24123_bandselect_vals[i].freq_low <= p->frequency) &&
463 vco_div = cx24123_bandselect_vals[i].VCOdivider; 561 (cx24123_bandselect_vals[i].freq_high >= p->frequency) )
562 band = i;
464 } 563 }
465 } 564 }
565 else
566 band = force_band - 1;
567
568 state->bandselectarg = cx24123_bandselect_vals[band].progdata;
569 vco_div = cx24123_bandselect_vals[band].VCOdivider;
570
571 /* determine the charge pump current */
572 if ( p->frequency < (cx24123_bandselect_vals[band].freq_low + cx24123_bandselect_vals[band].freq_high)/2 )
573 pump = 0x01;
574 else
575 pump = 0x02;
466 576
467 /* Determine the N/A dividers for the requested lband freq (in kHz). */ 577 /* Determine the N/A dividers for the requested lband freq (in kHz). */
468 /* Note: 10111 (kHz) is the Crystal Freq and divider of 10. */ 578 /* Note: the reference divider R=10, frequency is in KHz, XTAL is in Hz */
469 ndiv = ( ((p->frequency * vco_div) / (10111 / 10) / 2) / 32) & 0x1ff; 579 ndiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) / 32) & 0x1ff;
470 adiv = ( ((p->frequency * vco_div) / (10111 / 10) / 2) % 32) & 0x1f; 580 adiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) % 32) & 0x1f;
471 581
472 if (adiv == 0) 582 if (adiv == 0)
473 adiv++; 583 ndiv++;
474 584
475 /* determine the correct pll frequency values. */ 585 /* control bits 11, refdiv 11, charge pump polarity 1, charge pump current, ndiv, adiv */
476 /* Command 11, refdiv 11, cpump polarity 1, cpump current 3mA 10. */ 586 state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (pump << 14) | (ndiv << 5) | adiv;
477 state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (2 << 14);
478 state->pllarg |= (ndiv << 5) | adiv;
479 587
480 return 0; 588 return 0;
481} 589}
@@ -489,6 +597,8 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par
489 struct cx24123_state *state = fe->demodulator_priv; 597 struct cx24123_state *state = fe->demodulator_priv;
490 unsigned long timeout; 598 unsigned long timeout;
491 599
600 dprintk("%s: pll writereg called, data=0x%08x\n",__FUNCTION__,data);
601
492 /* align the 21 bytes into to bit23 boundary */ 602 /* align the 21 bytes into to bit23 boundary */
493 data = data << 3; 603 data = data << 3;
494 604
@@ -538,6 +648,9 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par
538static int cx24123_pll_tune(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 648static int cx24123_pll_tune(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
539{ 649{
540 struct cx24123_state *state = fe->demodulator_priv; 650 struct cx24123_state *state = fe->demodulator_priv;
651 u8 val;
652
653 dprintk("frequency=%i\n", p->frequency);
541 654
542 if (cx24123_pll_calculate(fe, p) != 0) { 655 if (cx24123_pll_calculate(fe, p) != 0) {
543 printk("%s: cx24123_pll_calcutate failed\n",__FUNCTION__); 656 printk("%s: cx24123_pll_calcutate failed\n",__FUNCTION__);
@@ -552,6 +665,14 @@ static int cx24123_pll_tune(struct dvb_frontend* fe, struct dvb_frontend_paramet
552 cx24123_pll_writereg(fe, p, state->bandselectarg); 665 cx24123_pll_writereg(fe, p, state->bandselectarg);
553 cx24123_pll_writereg(fe, p, state->pllarg); 666 cx24123_pll_writereg(fe, p, state->pllarg);
554 667
668 /* set the FILTUNE voltage */
669 val = cx24123_readreg(state, 0x28) & ~0x3;
670 cx24123_writereg(state, 0x27, state->FILTune >> 2);
671 cx24123_writereg(state, 0x28, val | (state->FILTune & 0x3));
672
673 dprintk("%s: pll tune VCA=%d, band=%d, pll=%d\n",__FUNCTION__,state->VCAarg,
674 state->bandselectarg,state->pllarg);
675
555 return 0; 676 return 0;
556} 677}
557 678
@@ -560,6 +681,8 @@ static int cx24123_initfe(struct dvb_frontend* fe)
560 struct cx24123_state *state = fe->demodulator_priv; 681 struct cx24123_state *state = fe->demodulator_priv;
561 int i; 682 int i;
562 683
684 dprintk("%s: init frontend\n",__FUNCTION__);
685
563 /* Configure the demod to a good set of defaults */ 686 /* Configure the demod to a good set of defaults */
564 for (i = 0; i < sizeof(cx24123_regdata) / sizeof(cx24123_regdata[0]); i++) 687 for (i = 0; i < sizeof(cx24123_regdata) / sizeof(cx24123_regdata[0]); i++)
565 cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data); 688 cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data);
@@ -587,10 +710,13 @@ static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage
587 710
588 switch (voltage) { 711 switch (voltage) {
589 case SEC_VOLTAGE_13: 712 case SEC_VOLTAGE_13:
713 dprintk("%s: isl6421 voltage = 13V\n",__FUNCTION__);
590 return cx24123_writelnbreg(state, 0x0, val & 0x32); /* V 13v */ 714 return cx24123_writelnbreg(state, 0x0, val & 0x32); /* V 13v */
591 case SEC_VOLTAGE_18: 715 case SEC_VOLTAGE_18:
716 dprintk("%s: isl6421 voltage = 18V\n",__FUNCTION__);
592 return cx24123_writelnbreg(state, 0x0, val | 0x04); /* H 18v */ 717 return cx24123_writelnbreg(state, 0x0, val | 0x04); /* H 18v */
593 case SEC_VOLTAGE_OFF: 718 case SEC_VOLTAGE_OFF:
719 dprintk("%s: isl5421 voltage off\n",__FUNCTION__);
594 return cx24123_writelnbreg(state, 0x0, val & 0x30); 720 return cx24123_writelnbreg(state, 0x0, val & 0x30);
595 default: 721 default:
596 return -EINVAL; 722 return -EINVAL;
@@ -624,13 +750,93 @@ static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage
624 return 0; 750 return 0;
625} 751}
626 752
627static int cx24123_send_diseqc_msg(struct dvb_frontend* fe, 753/* wait for diseqc queue to become ready (or timeout) */
628 struct dvb_diseqc_master_cmd *cmd) 754static void cx24123_wait_for_diseqc(struct cx24123_state *state)
755{
756 unsigned long timeout = jiffies + msecs_to_jiffies(200);
757 while (!(cx24123_readreg(state, 0x29) & 0x40)) {
758 if(time_after(jiffies, timeout)) {
759 printk("%s: diseqc queue not ready, command may be lost.\n", __FUNCTION__);
760 break;
761 }
762 msleep(10);
763 }
764}
765
766static int cx24123_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *cmd)
629{ 767{
630 /* fixme: Implement diseqc */ 768 struct cx24123_state *state = fe->demodulator_priv;
631 printk("%s: No support yet\n",__FUNCTION__); 769 int i, val;
770
771 dprintk("%s:\n",__FUNCTION__);
772
773 /* check if continuous tone has been stopped */
774 if (state->config->use_isl6421)
775 val = cx24123_readlnbreg(state, 0x00) & 0x10;
776 else
777 val = cx24123_readreg(state, 0x29) & 0x10;
632 778
633 return -ENOTSUPP; 779
780 if (val) {
781 printk("%s: ERROR: attempt to send diseqc command before tone is off\n", __FUNCTION__);
782 return -ENOTSUPP;
783 }
784
785 /* wait for diseqc queue ready */
786 cx24123_wait_for_diseqc(state);
787
788 /* select tone mode */
789 cx24123_writereg(state, 0x2a, cx24123_readreg(state, 0x2a) & 0xf8);
790
791 for (i = 0; i < cmd->msg_len; i++)
792 cx24123_writereg(state, 0x2C + i, cmd->msg[i]);
793
794 val = cx24123_readreg(state, 0x29);
795 cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40) | ((cmd->msg_len-3) & 3));
796
797 /* wait for diseqc message to finish sending */
798 cx24123_wait_for_diseqc(state);
799
800 return 0;
801}
802
803static int cx24123_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst)
804{
805 struct cx24123_state *state = fe->demodulator_priv;
806 int val;
807
808 dprintk("%s:\n", __FUNCTION__);
809
810 /* check if continuous tone has been stoped */
811 if (state->config->use_isl6421)
812 val = cx24123_readlnbreg(state, 0x00) & 0x10;
813 else
814 val = cx24123_readreg(state, 0x29) & 0x10;
815
816
817 if (val) {
818 printk("%s: ERROR: attempt to send diseqc command before tone is off\n", __FUNCTION__);
819 return -ENOTSUPP;
820 }
821
822 cx24123_wait_for_diseqc(state);
823
824 /* select tone mode */
825 val = cx24123_readreg(state, 0x2a) & 0xf8;
826 cx24123_writereg(state, 0x2a, val | 0x04);
827
828 val = cx24123_readreg(state, 0x29);
829
830 if (burst == SEC_MINI_A)
831 cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40 | 0x00));
832 else if (burst == SEC_MINI_B)
833 cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40 | 0x08));
834 else
835 return -EINVAL;
836
837 cx24123_wait_for_diseqc(state);
838
839 return 0;
634} 840}
635 841
636static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status) 842static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status)
@@ -642,13 +848,15 @@ static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status)
642 848
643 *status = 0; 849 *status = 0;
644 if (lock & 0x01) 850 if (lock & 0x01)
645 *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL; 851 *status |= FE_HAS_SIGNAL;
852 if (sync & 0x02)
853 *status |= FE_HAS_CARRIER;
646 if (sync & 0x04) 854 if (sync & 0x04)
647 *status |= FE_HAS_VITERBI; 855 *status |= FE_HAS_VITERBI;
648 if (sync & 0x08) 856 if (sync & 0x08)
649 *status |= FE_HAS_CARRIER; 857 *status |= FE_HAS_SYNC;
650 if (sync & 0x80) 858 if (sync & 0x80)
651 *status |= FE_HAS_SYNC | FE_HAS_LOCK; 859 *status |= FE_HAS_LOCK;
652 860
653 return 0; 861 return 0;
654} 862}
@@ -681,6 +889,8 @@ static int cx24123_read_ber(struct dvb_frontend* fe, u32* ber)
681 else 889 else
682 state->snr = 0; 890 state->snr = 0;
683 891
892 dprintk("%s: BER = %d, S/N index = %d\n",__FUNCTION__,state->lastber, state->snr);
893
684 *ber = state->lastber; 894 *ber = state->lastber;
685 895
686 return 0; 896 return 0;
@@ -691,6 +901,8 @@ static int cx24123_read_signal_strength(struct dvb_frontend* fe, u16* signal_str
691 struct cx24123_state *state = fe->demodulator_priv; 901 struct cx24123_state *state = fe->demodulator_priv;
692 *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */ 902 *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */
693 903
904 dprintk("%s: Signal strength = %d\n",__FUNCTION__,*signal_strength);
905
694 return 0; 906 return 0;
695} 907}
696 908
@@ -699,6 +911,8 @@ static int cx24123_read_snr(struct dvb_frontend* fe, u16* snr)
699 struct cx24123_state *state = fe->demodulator_priv; 911 struct cx24123_state *state = fe->demodulator_priv;
700 *snr = state->snr; 912 *snr = state->snr;
701 913
914 dprintk("%s: read S/N index = %d\n",__FUNCTION__,*snr);
915
702 return 0; 916 return 0;
703} 917}
704 918
@@ -707,6 +921,8 @@ static int cx24123_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
707 struct cx24123_state *state = fe->demodulator_priv; 921 struct cx24123_state *state = fe->demodulator_priv;
708 *ucblocks = state->lastber; 922 *ucblocks = state->lastber;
709 923
924 dprintk("%s: ucblocks (ber) = %d\n",__FUNCTION__,*ucblocks);
925
710 return 0; 926 return 0;
711} 927}
712 928
@@ -714,6 +930,8 @@ static int cx24123_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
714{ 930{
715 struct cx24123_state *state = fe->demodulator_priv; 931 struct cx24123_state *state = fe->demodulator_priv;
716 932
933 dprintk("%s: set_frontend\n",__FUNCTION__);
934
717 if (state->config->set_ts_params) 935 if (state->config->set_ts_params)
718 state->config->set_ts_params(fe, 0); 936 state->config->set_ts_params(fe, 0);
719 937
@@ -737,6 +955,8 @@ static int cx24123_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
737{ 955{
738 struct cx24123_state *state = fe->demodulator_priv; 956 struct cx24123_state *state = fe->demodulator_priv;
739 957
958 dprintk("%s: get_frontend\n",__FUNCTION__);
959
740 if (cx24123_get_inversion(state, &p->inversion) != 0) { 960 if (cx24123_get_inversion(state, &p->inversion) != 0) {
741 printk("%s: Failed to get inversion status\n",__FUNCTION__); 961 printk("%s: Failed to get inversion status\n",__FUNCTION__);
742 return -EREMOTEIO; 962 return -EREMOTEIO;
@@ -763,8 +983,10 @@ static int cx24123_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
763 983
764 switch (tone) { 984 switch (tone) {
765 case SEC_TONE_ON: 985 case SEC_TONE_ON:
986 dprintk("%s: isl6421 sec tone on\n",__FUNCTION__);
766 return cx24123_writelnbreg(state, 0x0, val | 0x10); 987 return cx24123_writelnbreg(state, 0x0, val | 0x10);
767 case SEC_TONE_OFF: 988 case SEC_TONE_OFF:
989 dprintk("%s: isl6421 sec tone off\n",__FUNCTION__);
768 return cx24123_writelnbreg(state, 0x0, val & 0x2f); 990 return cx24123_writelnbreg(state, 0x0, val & 0x2f);
769 default: 991 default:
770 printk("%s: CASE reached default with tone=%d\n", __FUNCTION__, tone); 992 printk("%s: CASE reached default with tone=%d\n", __FUNCTION__, tone);
@@ -855,12 +1077,13 @@ static struct dvb_frontend_ops cx24123_ops = {
855 .frequency_min = 950000, 1077 .frequency_min = 950000,
856 .frequency_max = 2150000, 1078 .frequency_max = 2150000,
857 .frequency_stepsize = 1011, /* kHz for QPSK frontends */ 1079 .frequency_stepsize = 1011, /* kHz for QPSK frontends */
858 .frequency_tolerance = 29500, 1080 .frequency_tolerance = 5000,
859 .symbol_rate_min = 1000000, 1081 .symbol_rate_min = 1000000,
860 .symbol_rate_max = 45000000, 1082 .symbol_rate_max = 45000000,
861 .caps = FE_CAN_INVERSION_AUTO | 1083 .caps = FE_CAN_INVERSION_AUTO |
862 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 1084 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
863 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | 1085 FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
1086 FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
864 FE_CAN_QPSK | FE_CAN_RECOVER 1087 FE_CAN_QPSK | FE_CAN_RECOVER
865 }, 1088 },
866 1089
@@ -875,12 +1098,16 @@ static struct dvb_frontend_ops cx24123_ops = {
875 .read_snr = cx24123_read_snr, 1098 .read_snr = cx24123_read_snr,
876 .read_ucblocks = cx24123_read_ucblocks, 1099 .read_ucblocks = cx24123_read_ucblocks,
877 .diseqc_send_master_cmd = cx24123_send_diseqc_msg, 1100 .diseqc_send_master_cmd = cx24123_send_diseqc_msg,
1101 .diseqc_send_burst = cx24123_diseqc_send_burst,
878 .set_tone = cx24123_set_tone, 1102 .set_tone = cx24123_set_tone,
879 .set_voltage = cx24123_set_voltage, 1103 .set_voltage = cx24123_set_voltage,
880}; 1104};
881 1105
882module_param(debug, int, 0644); 1106module_param(debug, int, 0644);
883MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); 1107MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)");
1108
1109module_param(force_band, int, 0644);
1110MODULE_PARM_DESC(force_band, "Force a specific band select (1-9, default:off).");
884 1111
885MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24123/cx24109 hardware"); 1112MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24123/cx24109 hardware");
886MODULE_AUTHOR("Steven Toth"); 1113MODULE_AUTHOR("Steven Toth");
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c
index b6e2c387a04c..791706ec1da3 100644
--- a/drivers/media/dvb/frontends/dvb-pll.c
+++ b/drivers/media/dvb/frontends/dvb-pll.c
@@ -235,8 +235,8 @@ struct dvb_pll_desc dvb_pll_tdvs_tua6034 = {
235 .max = 863000000, 235 .max = 863000000,
236 .count = 3, 236 .count = 3,
237 .entries = { 237 .entries = {
238 { 160000000, 44000000, 62500, 0xce, 0x01 }, 238 { 165000000, 44000000, 62500, 0xce, 0x01 },
239 { 455000000, 44000000, 62500, 0xce, 0x02 }, 239 { 450000000, 44000000, 62500, 0xce, 0x02 },
240 { 999999999, 44000000, 62500, 0xce, 0x04 }, 240 { 999999999, 44000000, 62500, 0xce, 0x04 },
241 }, 241 },
242}; 242};
diff --git a/drivers/media/dvb/pluto2/Kconfig b/drivers/media/dvb/pluto2/Kconfig
index 84f8f9f52869..7d8e6e87bdbb 100644
--- a/drivers/media/dvb/pluto2/Kconfig
+++ b/drivers/media/dvb/pluto2/Kconfig
@@ -1,7 +1,6 @@
1config DVB_PLUTO2 1config DVB_PLUTO2
2 tristate "Pluto2 cards" 2 tristate "Pluto2 cards"
3 depends on DVB_CORE && PCI 3 depends on DVB_CORE && PCI && I2C
4 select I2C
5 select I2C_ALGOBIT 4 select I2C_ALGOBIT
6 select DVB_TDA1004X 5 select DVB_TDA1004X
7 help 6 help
diff --git a/drivers/media/dvb/pluto2/Makefile b/drivers/media/dvb/pluto2/Makefile
index 86ca84b2be6e..ce6a9aaf937e 100644
--- a/drivers/media/dvb/pluto2/Makefile
+++ b/drivers/media/dvb/pluto2/Makefile
@@ -1,3 +1,3 @@
1obj-$(CONFIG_DVB_PLUTO2) = pluto2.o 1obj-$(CONFIG_DVB_PLUTO2) += pluto2.o
2 2
3EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ 3EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
diff --git a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig
index 5b2aadb8385c..b5ac7dfde52f 100644
--- a/drivers/media/dvb/ttpci/Kconfig
+++ b/drivers/media/dvb/ttpci/Kconfig
@@ -1,8 +1,7 @@
1config DVB_AV7110 1config DVB_AV7110
2 tristate "AV7110 cards" 2 tristate "AV7110 cards"
3 depends on DVB_CORE && PCI 3 depends on DVB_CORE && PCI && I2C && VIDEO_V4L1
4 select FW_LOADER 4 select FW_LOADER
5 select VIDEO_DEV
6 select VIDEO_SAA7146_VV 5 select VIDEO_SAA7146_VV
7 select DVB_VES1820 6 select DVB_VES1820
8 select DVB_VES1X93 7 select DVB_VES1X93
@@ -59,7 +58,7 @@ config DVB_AV7110_OSD
59 58
60config DVB_BUDGET 59config DVB_BUDGET
61 tristate "Budget cards" 60 tristate "Budget cards"
62 depends on DVB_CORE && PCI 61 depends on DVB_CORE && PCI && I2C && VIDEO_V4L1
63 select VIDEO_SAA7146 62 select VIDEO_SAA7146
64 select DVB_STV0299 63 select DVB_STV0299
65 select DVB_VES1X93 64 select DVB_VES1X93
@@ -80,7 +79,7 @@ config DVB_BUDGET
80 79
81config DVB_BUDGET_CI 80config DVB_BUDGET_CI
82 tristate "Budget cards with onboard CI connector" 81 tristate "Budget cards with onboard CI connector"
83 depends on DVB_CORE && PCI 82 depends on DVB_CORE && PCI && I2C && VIDEO_V4L1
84 select VIDEO_SAA7146 83 select VIDEO_SAA7146
85 select DVB_STV0297 84 select DVB_STV0297
86 select DVB_STV0299 85 select DVB_STV0299
@@ -100,8 +99,7 @@ config DVB_BUDGET_CI
100 99
101config DVB_BUDGET_AV 100config DVB_BUDGET_AV
102 tristate "Budget cards with analog video inputs" 101 tristate "Budget cards with analog video inputs"
103 depends on DVB_CORE && PCI 102 depends on DVB_CORE && PCI && I2C && VIDEO_V4L1
104 select VIDEO_DEV
105 select VIDEO_SAA7146_VV 103 select VIDEO_SAA7146_VV
106 select DVB_STV0299 104 select DVB_STV0299
107 select DVB_TDA1004X 105 select DVB_TDA1004X
@@ -119,7 +117,7 @@ config DVB_BUDGET_AV
119 117
120config DVB_BUDGET_PATCH 118config DVB_BUDGET_PATCH
121 tristate "AV7110 cards with Budget Patch" 119 tristate "AV7110 cards with Budget Patch"
122 depends on DVB_CORE && DVB_BUDGET 120 depends on DVB_CORE && DVB_BUDGET && VIDEO_V4L1
123 select DVB_AV7110 121 select DVB_AV7110
124 select DVB_STV0299 122 select DVB_STV0299
125 select DVB_VES1X93 123 select DVB_VES1X93
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index 8efe3ce5f66c..8a7cd7d505cf 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -1190,8 +1190,6 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
1190 SAA7146_HPS_SYNC_PORT_A); 1190 SAA7146_HPS_SYNC_PORT_A);
1191 1191
1192 saa7113_setinput(budget_av, 0); 1192 saa7113_setinput(budget_av, 0);
1193 } else {
1194 ciintf_init(budget_av);
1195 } 1193 }
1196 1194
1197 /* fixme: find some sane values here... */ 1195 /* fixme: find some sane values here... */
@@ -1211,6 +1209,10 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
1211 budget_av->budget.dvb_adapter.priv = budget_av; 1209 budget_av->budget.dvb_adapter.priv = budget_av;
1212 frontend_init(budget_av); 1210 frontend_init(budget_av);
1213 1211
1212 if (!budget_av->has_saa7113) {
1213 ciintf_init(budget_av);
1214 }
1215
1214 return 0; 1216 return 0;
1215} 1217}
1216 1218
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index 5f91036f5b87..e64a609cf4ff 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -71,6 +71,7 @@ struct budget_ci {
71 struct tasklet_struct msp430_irq_tasklet; 71 struct tasklet_struct msp430_irq_tasklet;
72 struct tasklet_struct ciintf_irq_tasklet; 72 struct tasklet_struct ciintf_irq_tasklet;
73 int slot_status; 73 int slot_status;
74 int ci_irq;
74 struct dvb_ca_en50221 ca; 75 struct dvb_ca_en50221 ca;
75 char ir_dev_name[50]; 76 char ir_dev_name[50];
76 u8 tuner_pll_address; /* used for philips_tdm1316l configs */ 77 u8 tuner_pll_address; /* used for philips_tdm1316l configs */
@@ -276,8 +277,10 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
276 if (slot != 0) 277 if (slot != 0)
277 return -EINVAL; 278 return -EINVAL;
278 279
279 // trigger on RISING edge during reset so we know when READY is re-asserted 280 if (budget_ci->ci_irq) {
280 saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI); 281 // trigger on RISING edge during reset so we know when READY is re-asserted
282 saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI);
283 }
281 budget_ci->slot_status = SLOTSTATUS_RESET; 284 budget_ci->slot_status = SLOTSTATUS_RESET;
282 ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0); 285 ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0);
283 msleep(1); 286 msleep(1);
@@ -370,11 +373,50 @@ static void ciintf_interrupt(unsigned long data)
370 } 373 }
371} 374}
372 375
376static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open)
377{
378 struct budget_ci *budget_ci = (struct budget_ci *) ca->data;
379 unsigned int flags;
380
381 // ensure we don't get spurious IRQs during initialisation
382 if (!budget_ci->budget.ci_present)
383 return -EINVAL;
384
385 // read the CAM status
386 flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0);
387 if (flags & CICONTROL_CAMDETECT) {
388 // mark it as present if it wasn't before
389 if (budget_ci->slot_status & SLOTSTATUS_NONE) {
390 budget_ci->slot_status = SLOTSTATUS_PRESENT;
391 }
392
393 // during a RESET, we check if we can read from IO memory to see when CAM is ready
394 if (budget_ci->slot_status & SLOTSTATUS_RESET) {
395 if (ciintf_read_attribute_mem(ca, slot, 0) == 0x1d) {
396 budget_ci->slot_status = SLOTSTATUS_READY;
397 }
398 }
399 } else {
400 budget_ci->slot_status = SLOTSTATUS_NONE;
401 }
402
403 if (budget_ci->slot_status != SLOTSTATUS_NONE) {
404 if (budget_ci->slot_status & SLOTSTATUS_READY) {
405 return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY;
406 }
407 return DVB_CA_EN50221_POLL_CAM_PRESENT;
408 }
409
410 return 0;
411}
412
373static int ciintf_init(struct budget_ci *budget_ci) 413static int ciintf_init(struct budget_ci *budget_ci)
374{ 414{
375 struct saa7146_dev *saa = budget_ci->budget.dev; 415 struct saa7146_dev *saa = budget_ci->budget.dev;
376 int flags; 416 int flags;
377 int result; 417 int result;
418 int ci_version;
419 int ca_flags;
378 420
379 memset(&budget_ci->ca, 0, sizeof(struct dvb_ca_en50221)); 421 memset(&budget_ci->ca, 0, sizeof(struct dvb_ca_en50221));
380 422
@@ -382,16 +424,29 @@ static int ciintf_init(struct budget_ci *budget_ci)
382 saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16) | 0x800); 424 saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16) | 0x800);
383 425
384 // test if it is there 426 // test if it is there
385 if ((ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CIVERSION, 1, 1, 0) & 0xa0) != 0xa0) { 427 ci_version = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CIVERSION, 1, 1, 0);
428 if ((ci_version & 0xa0) != 0xa0) {
386 result = -ENODEV; 429 result = -ENODEV;
387 goto error; 430 goto error;
388 } 431 }
432
389 // determine whether a CAM is present or not 433 // determine whether a CAM is present or not
390 flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0); 434 flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0);
391 budget_ci->slot_status = SLOTSTATUS_NONE; 435 budget_ci->slot_status = SLOTSTATUS_NONE;
392 if (flags & CICONTROL_CAMDETECT) 436 if (flags & CICONTROL_CAMDETECT)
393 budget_ci->slot_status = SLOTSTATUS_PRESENT; 437 budget_ci->slot_status = SLOTSTATUS_PRESENT;
394 438
439 // version 0xa2 of the CI firmware doesn't generate interrupts
440 if (ci_version == 0xa2) {
441 ca_flags = 0;
442 budget_ci->ci_irq = 0;
443 } else {
444 ca_flags = DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE |
445 DVB_CA_EN50221_FLAG_IRQ_FR |
446 DVB_CA_EN50221_FLAG_IRQ_DA;
447 budget_ci->ci_irq = 1;
448 }
449
395 // register CI interface 450 // register CI interface
396 budget_ci->ca.owner = THIS_MODULE; 451 budget_ci->ca.owner = THIS_MODULE;
397 budget_ci->ca.read_attribute_mem = ciintf_read_attribute_mem; 452 budget_ci->ca.read_attribute_mem = ciintf_read_attribute_mem;
@@ -401,23 +456,27 @@ static int ciintf_init(struct budget_ci *budget_ci)
401 budget_ci->ca.slot_reset = ciintf_slot_reset; 456 budget_ci->ca.slot_reset = ciintf_slot_reset;
402 budget_ci->ca.slot_shutdown = ciintf_slot_shutdown; 457 budget_ci->ca.slot_shutdown = ciintf_slot_shutdown;
403 budget_ci->ca.slot_ts_enable = ciintf_slot_ts_enable; 458 budget_ci->ca.slot_ts_enable = ciintf_slot_ts_enable;
459 budget_ci->ca.poll_slot_status = ciintf_poll_slot_status;
404 budget_ci->ca.data = budget_ci; 460 budget_ci->ca.data = budget_ci;
405 if ((result = dvb_ca_en50221_init(&budget_ci->budget.dvb_adapter, 461 if ((result = dvb_ca_en50221_init(&budget_ci->budget.dvb_adapter,
406 &budget_ci->ca, 462 &budget_ci->ca,
407 DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE | 463 ca_flags, 1)) != 0) {
408 DVB_CA_EN50221_FLAG_IRQ_FR |
409 DVB_CA_EN50221_FLAG_IRQ_DA, 1)) != 0) {
410 printk("budget_ci: CI interface detected, but initialisation failed.\n"); 464 printk("budget_ci: CI interface detected, but initialisation failed.\n");
411 goto error; 465 goto error;
412 } 466 }
467
413 // Setup CI slot IRQ 468 // Setup CI slot IRQ
414 tasklet_init(&budget_ci->ciintf_irq_tasklet, ciintf_interrupt, (unsigned long) budget_ci); 469 if (budget_ci->ci_irq) {
415 if (budget_ci->slot_status != SLOTSTATUS_NONE) { 470 tasklet_init(&budget_ci->ciintf_irq_tasklet, ciintf_interrupt, (unsigned long) budget_ci);
416 saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQLO); 471 if (budget_ci->slot_status != SLOTSTATUS_NONE) {
417 } else { 472 saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQLO);
418 saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI); 473 } else {
474 saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI);
475 }
476 saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_03);
419 } 477 }
420 saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_03); 478
479 // enable interface
421 ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 480 ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
422 CICONTROL_RESET, 1, 0); 481 CICONTROL_RESET, 1, 0);
423 482
@@ -426,10 +485,12 @@ static int ciintf_init(struct budget_ci *budget_ci)
426 budget_ci->budget.ci_present = 1; 485 budget_ci->budget.ci_present = 1;
427 486
428 // forge a fake CI IRQ so the CAM state is setup correctly 487 // forge a fake CI IRQ so the CAM state is setup correctly
429 flags = DVB_CA_EN50221_CAMCHANGE_REMOVED; 488 if (budget_ci->ci_irq) {
430 if (budget_ci->slot_status != SLOTSTATUS_NONE) 489 flags = DVB_CA_EN50221_CAMCHANGE_REMOVED;
431 flags = DVB_CA_EN50221_CAMCHANGE_INSERTED; 490 if (budget_ci->slot_status != SLOTSTATUS_NONE)
432 dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0, flags); 491 flags = DVB_CA_EN50221_CAMCHANGE_INSERTED;
492 dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0, flags);
493 }
433 494
434 return 0; 495 return 0;
435 496
@@ -443,9 +504,13 @@ static void ciintf_deinit(struct budget_ci *budget_ci)
443 struct saa7146_dev *saa = budget_ci->budget.dev; 504 struct saa7146_dev *saa = budget_ci->budget.dev;
444 505
445 // disable CI interrupts 506 // disable CI interrupts
446 saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_03); 507 if (budget_ci->ci_irq) {
447 saa7146_setgpio(saa, 0, SAA7146_GPIO_INPUT); 508 saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_03);
448 tasklet_kill(&budget_ci->ciintf_irq_tasklet); 509 saa7146_setgpio(saa, 0, SAA7146_GPIO_INPUT);
510 tasklet_kill(&budget_ci->ciintf_irq_tasklet);
511 }
512
513 // reset interface
449 ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0); 514 ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0);
450 msleep(1); 515 msleep(1);
451 ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 516 ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
@@ -473,7 +538,7 @@ static void budget_ci_irq(struct saa7146_dev *dev, u32 * isr)
473 if (*isr & MASK_10) 538 if (*isr & MASK_10)
474 ttpci_budget_irq10_handler(dev, isr); 539 ttpci_budget_irq10_handler(dev, isr);
475 540
476 if ((*isr & MASK_03) && (budget_ci->budget.ci_present)) 541 if ((*isr & MASK_03) && (budget_ci->budget.ci_present) && (budget_ci->ci_irq))
477 tasklet_schedule(&budget_ci->ciintf_irq_tasklet); 542 tasklet_schedule(&budget_ci->ciintf_irq_tasklet);
478} 543}
479 544
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index 248fdc7accfb..6ceae38125c7 100644
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -1507,7 +1507,11 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
1507 1507
1508 mutex_unlock(&ttusb->semi2c); 1508 mutex_unlock(&ttusb->semi2c);
1509 1509
1510 dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE); 1510 if ((result = dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE)) < 0) {
1511 ttusb_free_iso_urbs(ttusb);
1512 kfree(ttusb);
1513 return result;
1514 }
1511 ttusb->adapter.priv = ttusb; 1515 ttusb->adapter.priv = ttusb;
1512 1516
1513 /* i2c */ 1517 /* i2c */
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index d318be383de6..3fff75763693 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -7,7 +7,7 @@ menu "Radio Adapters"
7 7
8config RADIO_CADET 8config RADIO_CADET
9 tristate "ADS Cadet AM/FM Tuner" 9 tristate "ADS Cadet AM/FM Tuner"
10 depends on ISA && VIDEO_DEV 10 depends on ISA && VIDEO_V4L1
11 ---help--- 11 ---help---
12 Choose Y here if you have one of these AM/FM radio cards, and then 12 Choose Y here if you have one of these AM/FM radio cards, and then
13 fill in the port address below. 13 fill in the port address below.
@@ -25,7 +25,7 @@ config RADIO_CADET
25 25
26config RADIO_RTRACK 26config RADIO_RTRACK
27 tristate "AIMSlab RadioTrack (aka RadioReveal) support" 27 tristate "AIMSlab RadioTrack (aka RadioReveal) support"
28 depends on ISA && VIDEO_DEV 28 depends on ISA && VIDEO_V4L1
29 ---help--- 29 ---help---
30 Choose Y here if you have one of these FM radio cards, and then fill 30 Choose Y here if you have one of these FM radio cards, and then fill
31 in the port address below. 31 in the port address below.
@@ -59,7 +59,7 @@ config RADIO_RTRACK_PORT
59 59
60config RADIO_RTRACK2 60config RADIO_RTRACK2
61 tristate "AIMSlab RadioTrack II support" 61 tristate "AIMSlab RadioTrack II support"
62 depends on ISA && VIDEO_DEV 62 depends on ISA && VIDEO_V4L1
63 ---help--- 63 ---help---
64 Choose Y here if you have this FM radio card, and then fill in the 64 Choose Y here if you have this FM radio card, and then fill in the
65 port address below. 65 port address below.
@@ -82,7 +82,7 @@ config RADIO_RTRACK2_PORT
82 82
83config RADIO_AZTECH 83config RADIO_AZTECH
84 tristate "Aztech/Packard Bell Radio" 84 tristate "Aztech/Packard Bell Radio"
85 depends on ISA && VIDEO_DEV 85 depends on ISA && VIDEO_V4L1
86 ---help--- 86 ---help---
87 Choose Y here if you have one of these FM radio cards, and then fill 87 Choose Y here if you have one of these FM radio cards, and then fill
88 in the port address below. 88 in the port address below.
@@ -106,7 +106,7 @@ config RADIO_AZTECH_PORT
106 106
107config RADIO_GEMTEK 107config RADIO_GEMTEK
108 tristate "GemTek Radio Card support" 108 tristate "GemTek Radio Card support"
109 depends on ISA && VIDEO_DEV 109 depends on ISA && VIDEO_V4L1
110 ---help--- 110 ---help---
111 Choose Y here if you have this FM radio card, and then fill in the 111 Choose Y here if you have this FM radio card, and then fill in the
112 port address below. 112 port address below.
@@ -131,7 +131,7 @@ config RADIO_GEMTEK_PORT
131 131
132config RADIO_GEMTEK_PCI 132config RADIO_GEMTEK_PCI
133 tristate "GemTek PCI Radio Card support" 133 tristate "GemTek PCI Radio Card support"
134 depends on VIDEO_DEV && PCI 134 depends on VIDEO_V4L1 && PCI
135 ---help--- 135 ---help---
136 Choose Y here if you have this PCI FM radio card. 136 Choose Y here if you have this PCI FM radio card.
137 137
@@ -145,7 +145,7 @@ config RADIO_GEMTEK_PCI
145 145
146config RADIO_MAXIRADIO 146config RADIO_MAXIRADIO
147 tristate "Guillemot MAXI Radio FM 2000 radio" 147 tristate "Guillemot MAXI Radio FM 2000 radio"
148 depends on VIDEO_DEV && PCI 148 depends on VIDEO_V4L1 && PCI
149 ---help--- 149 ---help---
150 Choose Y here if you have this radio card. This card may also be 150 Choose Y here if you have this radio card. This card may also be
151 found as Gemtek PCI FM. 151 found as Gemtek PCI FM.
@@ -160,7 +160,7 @@ config RADIO_MAXIRADIO
160 160
161config RADIO_MAESTRO 161config RADIO_MAESTRO
162 tristate "Maestro on board radio" 162 tristate "Maestro on board radio"
163 depends on VIDEO_DEV 163 depends on VIDEO_V4L1
164 ---help--- 164 ---help---
165 Say Y here to directly support the on-board radio tuner on the 165 Say Y here to directly support the on-board radio tuner on the
166 Maestro 2 or 2E sound card. 166 Maestro 2 or 2E sound card.
@@ -175,7 +175,7 @@ config RADIO_MAESTRO
175 175
176config RADIO_MIROPCM20 176config RADIO_MIROPCM20
177 tristate "miroSOUND PCM20 radio" 177 tristate "miroSOUND PCM20 radio"
178 depends on ISA && VIDEO_DEV && SOUND_ACI_MIXER 178 depends on ISA && VIDEO_V4L1 && SOUND_ACI_MIXER
179 ---help--- 179 ---help---
180 Choose Y here if you have this FM radio card. You also need to say Y 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") 181 to "ACI mixer (miroSOUND PCM1-pro/PCM12/PCM20 radio)" (in "Sound")
@@ -208,7 +208,7 @@ config RADIO_MIROPCM20_RDS
208 208
209config RADIO_SF16FMI 209config RADIO_SF16FMI
210 tristate "SF16FMI Radio" 210 tristate "SF16FMI Radio"
211 depends on ISA && VIDEO_DEV 211 depends on ISA && VIDEO_V4L1
212 ---help--- 212 ---help---
213 Choose Y here if you have one of these FM radio cards. If you 213 Choose Y here if you have one of these FM radio cards. If you
214 compile the driver into the kernel and your card is not PnP one, you 214 compile the driver into the kernel and your card is not PnP one, you
@@ -225,7 +225,7 @@ config RADIO_SF16FMI
225 225
226config RADIO_SF16FMR2 226config RADIO_SF16FMR2
227 tristate "SF16FMR2 Radio" 227 tristate "SF16FMR2 Radio"
228 depends on ISA && VIDEO_DEV 228 depends on ISA && VIDEO_V4L1
229 ---help--- 229 ---help---
230 Choose Y here if you have one of these FM radio cards. 230 Choose Y here if you have one of these FM radio cards.
231 231
@@ -239,7 +239,7 @@ config RADIO_SF16FMR2
239 239
240config RADIO_TERRATEC 240config RADIO_TERRATEC
241 tristate "TerraTec ActiveRadio ISA Standalone" 241 tristate "TerraTec ActiveRadio ISA Standalone"
242 depends on ISA && VIDEO_DEV 242 depends on ISA && VIDEO_V4L1
243 ---help--- 243 ---help---
244 Choose Y here if you have this FM radio card, and then fill in the 244 Choose Y here if you have this FM radio card, and then fill in the
245 port address below. (TODO) 245 port address below. (TODO)
@@ -268,7 +268,7 @@ config RADIO_TERRATEC_PORT
268 268
269config RADIO_TRUST 269config RADIO_TRUST
270 tristate "Trust FM radio card" 270 tristate "Trust FM radio card"
271 depends on ISA && VIDEO_DEV 271 depends on ISA && VIDEO_V4L1
272 help 272 help
273 This is a driver for the Trust FM radio cards. Say Y if you have 273 This is a driver for the Trust FM radio cards. Say Y if you have
274 such a card and want to use it under Linux. 274 such a card and want to use it under Linux.
@@ -286,7 +286,7 @@ config RADIO_TRUST_PORT
286 286
287config RADIO_TYPHOON 287config RADIO_TYPHOON
288 tristate "Typhoon Radio (a.k.a. EcoRadio)" 288 tristate "Typhoon Radio (a.k.a. EcoRadio)"
289 depends on ISA && VIDEO_DEV 289 depends on ISA && VIDEO_V4L1
290 ---help--- 290 ---help---
291 Choose Y here if you have one of these FM radio cards, and then fill 291 Choose Y here if you have one of these FM radio cards, and then fill
292 in the port address and the frequency used for muting below. 292 in the port address and the frequency used for muting below.
@@ -330,7 +330,7 @@ config RADIO_TYPHOON_MUTEFREQ
330 330
331config RADIO_ZOLTRIX 331config RADIO_ZOLTRIX
332 tristate "Zoltrix Radio" 332 tristate "Zoltrix Radio"
333 depends on ISA && VIDEO_DEV 333 depends on ISA && VIDEO_V4L1
334 ---help--- 334 ---help---
335 Choose Y here if you have one of these FM radio cards, and then fill 335 Choose Y here if you have one of these FM radio cards, and then fill
336 in the port address below. 336 in the port address below.
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 85888a8a93c9..6b4197018561 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -2,10 +2,10 @@
2# Multimedia Video device configuration 2# Multimedia Video device configuration
3# 3#
4 4
5menu "Video For Linux" 5menu "Video Capture Adapters"
6 depends on VIDEO_DEV 6 depends on VIDEO_DEV
7 7
8comment "Video Adapters" 8comment "Video Capture Adapters"
9 9
10config VIDEO_ADV_DEBUG 10config VIDEO_ADV_DEBUG
11 bool "Enable advanced debug functionality" 11 bool "Enable advanced debug functionality"
@@ -16,11 +16,23 @@ config VIDEO_ADV_DEBUG
16 V4L devices. 16 V4L devices.
17 In doubt, say N. 17 In doubt, say N.
18 18
19config VIDEO_VIVI
20 tristate "Virtual Video Driver"
21 depends on VIDEO_V4L2 && !SPARC32 && !SPARC64
22 select VIDEO_BUF
23 default n
24 ---help---
25 Enables a virtual video driver. This device shows a color bar
26 and a timestamp, as a real device would generate by using V4L2
27 api.
28 Say Y here if you want to test video apps or debug V4L devices.
29 In doubt, say N.
30
19source "drivers/media/video/bt8xx/Kconfig" 31source "drivers/media/video/bt8xx/Kconfig"
20 32
21config VIDEO_SAA6588 33config VIDEO_SAA6588
22 tristate "SAA6588 Radio Chip RDS decoder support on BT848 cards" 34 tristate "SAA6588 Radio Chip RDS decoder support on BT848 cards"
23 depends on VIDEO_DEV && I2C && VIDEO_BT848 35 depends on I2C && VIDEO_BT848
24 36
25 help 37 help
26 Support for Radio Data System (RDS) decoder. This allows seeing 38 Support for Radio Data System (RDS) decoder. This allows seeing
@@ -32,7 +44,7 @@ config VIDEO_SAA6588
32 44
33config VIDEO_PMS 45config VIDEO_PMS
34 tristate "Mediavision Pro Movie Studio Video For Linux" 46 tristate "Mediavision Pro Movie Studio Video For Linux"
35 depends on VIDEO_DEV && ISA 47 depends on ISA && VIDEO_V4L1
36 help 48 help
37 Say Y if you have such a thing. 49 Say Y if you have such a thing.
38 50
@@ -41,7 +53,7 @@ config VIDEO_PMS
41 53
42config VIDEO_PLANB 54config VIDEO_PLANB
43 tristate "PlanB Video-In on PowerMac" 55 tristate "PlanB Video-In on PowerMac"
44 depends on PPC_PMAC && VIDEO_DEV && BROKEN 56 depends on PPC_PMAC && VIDEO_V4L1 && BROKEN
45 help 57 help
46 PlanB is the V4L driver for the PowerMac 7x00/8x00 series video 58 PlanB is the V4L driver for the PowerMac 7x00/8x00 series video
47 input hardware. If you want to experiment with this, say Y. 59 input hardware. If you want to experiment with this, say Y.
@@ -52,7 +64,7 @@ config VIDEO_PLANB
52 64
53config VIDEO_BWQCAM 65config VIDEO_BWQCAM
54 tristate "Quickcam BW Video For Linux" 66 tristate "Quickcam BW Video For Linux"
55 depends on VIDEO_DEV && PARPORT 67 depends on PARPORT && VIDEO_V4L1
56 help 68 help
57 Say Y have if you the black and white version of the QuickCam 69 Say Y have if you the black and white version of the QuickCam
58 camera. See the next option for the color version. 70 camera. See the next option for the color version.
@@ -62,7 +74,7 @@ config VIDEO_BWQCAM
62 74
63config VIDEO_CQCAM 75config VIDEO_CQCAM
64 tristate "QuickCam Colour Video For Linux (EXPERIMENTAL)" 76 tristate "QuickCam Colour Video For Linux (EXPERIMENTAL)"
65 depends on EXPERIMENTAL && VIDEO_DEV && PARPORT 77 depends on EXPERIMENTAL && PARPORT && VIDEO_V4L1
66 help 78 help
67 This is the video4linux driver for the colour version of the 79 This is the video4linux driver for the colour version of the
68 Connectix QuickCam. If you have one of these cameras, say Y here, 80 Connectix QuickCam. If you have one of these cameras, say Y here,
@@ -73,7 +85,7 @@ config VIDEO_CQCAM
73 85
74config VIDEO_W9966 86config VIDEO_W9966
75 tristate "W9966CF Webcam (FlyCam Supra and others) Video For Linux" 87 tristate "W9966CF Webcam (FlyCam Supra and others) Video For Linux"
76 depends on PARPORT_1284 && VIDEO_DEV && PARPORT 88 depends on PARPORT_1284 && PARPORT && VIDEO_V4L1
77 help 89 help
78 Video4linux driver for Winbond's w9966 based Webcams. 90 Video4linux driver for Winbond's w9966 based Webcams.
79 Currently tested with the LifeView FlyCam Supra. 91 Currently tested with the LifeView FlyCam Supra.
@@ -86,7 +98,7 @@ config VIDEO_W9966
86 98
87config VIDEO_CPIA 99config VIDEO_CPIA
88 tristate "CPiA Video For Linux" 100 tristate "CPiA Video For Linux"
89 depends on VIDEO_DEV 101 depends on VIDEO_V4L1
90 ---help--- 102 ---help---
91 This is the video4linux driver for cameras based on Vision's CPiA 103 This is the video4linux driver for cameras based on Vision's CPiA
92 (Colour Processor Interface ASIC), such as the Creative Labs Video 104 (Colour Processor Interface ASIC), such as the Creative Labs Video
@@ -123,7 +135,7 @@ source "drivers/media/video/cpia2/Kconfig"
123 135
124config VIDEO_SAA5246A 136config VIDEO_SAA5246A
125 tristate "SAA5246A, SAA5281 Teletext processor" 137 tristate "SAA5246A, SAA5281 Teletext processor"
126 depends on VIDEO_DEV && I2C 138 depends on I2C && VIDEO_V4L1
127 help 139 help
128 Support for I2C bus based teletext using the SAA5246A or SAA5281 140 Support for I2C bus based teletext using the SAA5246A or SAA5281
129 chip. Useful only if you live in Europe. 141 chip. Useful only if you live in Europe.
@@ -150,7 +162,7 @@ config TUNER_3036
150 162
151config VIDEO_VINO 163config VIDEO_VINO
152 tristate "SGI Vino Video For Linux (EXPERIMENTAL)" 164 tristate "SGI Vino Video For Linux (EXPERIMENTAL)"
153 depends on VIDEO_DEV && I2C && SGI_IP22 && EXPERIMENTAL 165 depends on I2C && SGI_IP22 && EXPERIMENTAL && VIDEO_V4L1
154 select I2C_ALGO_SGI 166 select I2C_ALGO_SGI
155 help 167 help
156 Say Y here to build in support for the Vino video input system found 168 Say Y here to build in support for the Vino video input system found
@@ -158,7 +170,7 @@ config VIDEO_VINO
158 170
159config VIDEO_STRADIS 171config VIDEO_STRADIS
160 tristate "Stradis 4:2:2 MPEG-2 video driver (EXPERIMENTAL)" 172 tristate "Stradis 4:2:2 MPEG-2 video driver (EXPERIMENTAL)"
161 depends on EXPERIMENTAL && VIDEO_DEV && PCI 173 depends on EXPERIMENTAL && PCI && VIDEO_V4L1 && !PPC64
162 help 174 help
163 Say Y here to enable support for the Stradis 4:2:2 MPEG-2 video 175 Say Y here to enable support for the Stradis 4:2:2 MPEG-2 video
164 driver for PCI. There is a product page at 176 driver for PCI. There is a product page at
@@ -166,7 +178,7 @@ config VIDEO_STRADIS
166 178
167config VIDEO_ZORAN 179config VIDEO_ZORAN
168 tristate "Zoran ZR36057/36067 Video For Linux" 180 tristate "Zoran ZR36057/36067 Video For Linux"
169 depends on VIDEO_DEV && PCI && I2C_ALGOBIT 181 depends on PCI && I2C_ALGOBIT && VIDEO_V4L1 && !PPC64
170 help 182 help
171 Say Y for support for MJPEG capture cards based on the Zoran 183 Say Y for support for MJPEG capture cards based on the Zoran
172 36057/36067 PCI controller chipset. This includes the Iomega 184 36057/36067 PCI controller chipset. This includes the Iomega
@@ -214,7 +226,7 @@ config VIDEO_ZORAN_LML33R10
214 226
215config VIDEO_ZR36120 227config VIDEO_ZR36120
216 tristate "Zoran ZR36120/36125 Video For Linux" 228 tristate "Zoran ZR36120/36125 Video For Linux"
217 depends on VIDEO_DEV && PCI && I2C && BROKEN 229 depends on PCI && I2C && VIDEO_V4L1 && BROKEN
218 help 230 help
219 Support for ZR36120/ZR36125 based frame grabber/overlay boards. 231 Support for ZR36120/ZR36125 based frame grabber/overlay boards.
220 This includes the Victor II, WaveWatcher, Video Wonder, Maxi-TV, 232 This includes the Victor II, WaveWatcher, Video Wonder, Maxi-TV,
@@ -226,7 +238,7 @@ config VIDEO_ZR36120
226 238
227config VIDEO_MEYE 239config VIDEO_MEYE
228 tristate "Sony Vaio Picturebook Motion Eye Video For Linux" 240 tristate "Sony Vaio Picturebook Motion Eye Video For Linux"
229 depends on VIDEO_DEV && PCI && SONYPI 241 depends on PCI && SONYPI && VIDEO_V4L1
230 ---help--- 242 ---help---
231 This is the video4linux driver for the Motion Eye camera found 243 This is the video4linux driver for the Motion Eye camera found
232 in the Vaio Picturebook laptops. Please read the material in 244 in the Vaio Picturebook laptops. Please read the material in
@@ -242,7 +254,7 @@ source "drivers/media/video/saa7134/Kconfig"
242 254
243config VIDEO_MXB 255config VIDEO_MXB
244 tristate "Siemens-Nixdorf 'Multimedia eXtension Board'" 256 tristate "Siemens-Nixdorf 'Multimedia eXtension Board'"
245 depends on VIDEO_DEV && PCI 257 depends on PCI && VIDEO_V4L1
246 select VIDEO_SAA7146_VV 258 select VIDEO_SAA7146_VV
247 select VIDEO_TUNER 259 select VIDEO_TUNER
248 ---help--- 260 ---help---
@@ -254,8 +266,9 @@ config VIDEO_MXB
254 266
255config VIDEO_DPC 267config VIDEO_DPC
256 tristate "Philips-Semiconductors 'dpc7146 demonstration board'" 268 tristate "Philips-Semiconductors 'dpc7146 demonstration board'"
257 depends on VIDEO_DEV && PCI 269 depends on PCI && VIDEO_V4L1
258 select VIDEO_SAA7146_VV 270 select VIDEO_SAA7146_VV
271 select VIDEO_V4L2
259 ---help--- 272 ---help---
260 This is a video4linux driver for the 'dpc7146 demonstration 273 This is a video4linux driver for the 'dpc7146 demonstration
261 board' by Philips-Semiconductors. It's the reference design 274 board' by Philips-Semiconductors. It's the reference design
@@ -268,8 +281,9 @@ config VIDEO_DPC
268 281
269config VIDEO_HEXIUM_ORION 282config VIDEO_HEXIUM_ORION
270 tristate "Hexium HV-PCI6 and Orion frame grabber" 283 tristate "Hexium HV-PCI6 and Orion frame grabber"
271 depends on VIDEO_DEV && PCI 284 depends on PCI && VIDEO_V4L1
272 select VIDEO_SAA7146_VV 285 select VIDEO_SAA7146_VV
286 select VIDEO_V4L2
273 ---help--- 287 ---help---
274 This is a video4linux driver for the Hexium HV-PCI6 and 288 This is a video4linux driver for the Hexium HV-PCI6 and
275 Orion frame grabber cards by Hexium. 289 Orion frame grabber cards by Hexium.
@@ -279,8 +293,9 @@ config VIDEO_HEXIUM_ORION
279 293
280config VIDEO_HEXIUM_GEMINI 294config VIDEO_HEXIUM_GEMINI
281 tristate "Hexium Gemini frame grabber" 295 tristate "Hexium Gemini frame grabber"
282 depends on VIDEO_DEV && PCI 296 depends on PCI && VIDEO_V4L1
283 select VIDEO_SAA7146_VV 297 select VIDEO_SAA7146_VV
298 select VIDEO_V4L2
284 ---help--- 299 ---help---
285 This is a video4linux driver for the Hexium Gemini frame 300 This is a video4linux driver for the Hexium Gemini frame
286 grabber card by Hexium. Please note that the Gemini Dual 301 grabber card by Hexium. Please note that the Gemini Dual
@@ -293,7 +308,7 @@ source "drivers/media/video/cx88/Kconfig"
293 308
294config VIDEO_OVCAMCHIP 309config VIDEO_OVCAMCHIP
295 tristate "OmniVision Camera Chip support" 310 tristate "OmniVision Camera Chip support"
296 depends on VIDEO_DEV && I2C 311 depends on I2C && VIDEO_V4L1
297 ---help--- 312 ---help---
298 Support for the OmniVision OV6xxx and OV7xxx series of camera chips. 313 Support for the OmniVision OV6xxx and OV7xxx series of camera chips.
299 This driver is intended to be used with the ov511 and w9968cf USB 314 This driver is intended to be used with the ov511 and w9968cf USB
@@ -304,7 +319,7 @@ config VIDEO_OVCAMCHIP
304 319
305config VIDEO_M32R_AR 320config VIDEO_M32R_AR
306 tristate "AR devices" 321 tristate "AR devices"
307 depends on M32R 322 depends on M32R && VIDEO_V4L1
308 ---help--- 323 ---help---
309 This is a video4linux driver for the Renesas AR (Artificial Retina) 324 This is a video4linux driver for the Renesas AR (Artificial Retina)
310 camera module. 325 camera module.
@@ -365,17 +380,17 @@ config VIDEO_WM8739
365source "drivers/media/video/cx25840/Kconfig" 380source "drivers/media/video/cx25840/Kconfig"
366 381
367config VIDEO_SAA711X 382config VIDEO_SAA711X
368 tristate "Philips SAA7113/4/5 video decoders" 383 tristate "Philips SAA7113/4/5 video decoders (OBSOLETED)"
369 depends on VIDEO_DEV && I2C && EXPERIMENTAL 384 depends on VIDEO_V4L1 && I2C && EXPERIMENTAL
370 ---help--- 385 ---help---
371 Support for the Philips SAA7113/4/5 video decoders. 386 Old support for the Philips SAA7113/4 video decoders.
372 387
373 To compile this driver as a module, choose M here: the 388 To compile this driver as a module, choose M here: the
374 module will be called saa7115. 389 module will be called saa7115.
375 390
376config VIDEO_SAA7127 391config VIDEO_SAA7127
377 tristate "Philips SAA7127/9 digital video encoders" 392 tristate "Philips SAA7127/9 digital video encoders"
378 depends on VIDEO_DEV && I2C && EXPERIMENTAL 393 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
379 ---help--- 394 ---help---
380 Support for the Philips SAA7127/9 digital video encoders. 395 Support for the Philips SAA7127/9 digital video encoders.
381 396
@@ -384,7 +399,7 @@ config VIDEO_SAA7127
384 399
385config VIDEO_UPD64031A 400config VIDEO_UPD64031A
386 tristate "NEC Electronics uPD64031A Ghost Reduction" 401 tristate "NEC Electronics uPD64031A Ghost Reduction"
387 depends on VIDEO_DEV && I2C && EXPERIMENTAL 402 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
388 ---help--- 403 ---help---
389 Support for the NEC Electronics uPD64031A Ghost Reduction 404 Support for the NEC Electronics uPD64031A Ghost Reduction
390 video chip. It is most often found in NTSC TV cards made for 405 video chip. It is most often found in NTSC TV cards made for
@@ -396,7 +411,7 @@ config VIDEO_UPD64031A
396 411
397config VIDEO_UPD64083 412config VIDEO_UPD64083
398 tristate "NEC Electronics uPD64083 3-Dimensional Y/C separation" 413 tristate "NEC Electronics uPD64083 3-Dimensional Y/C separation"
399 depends on VIDEO_DEV && I2C && EXPERIMENTAL 414 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
400 ---help--- 415 ---help---
401 Support for the NEC Electronics uPD64083 3-Dimensional Y/C 416 Support for the NEC Electronics uPD64083 3-Dimensional Y/C
402 separation video chip. It is used to improve the quality of 417 separation video chip. It is used to improve the quality of
@@ -418,7 +433,7 @@ source "drivers/media/video/em28xx/Kconfig"
418 433
419config USB_DSBR 434config USB_DSBR
420 tristate "D-Link USB FM radio support (EXPERIMENTAL)" 435 tristate "D-Link USB FM radio support (EXPERIMENTAL)"
421 depends on USB && VIDEO_DEV && EXPERIMENTAL 436 depends on USB && VIDEO_V4L1 && EXPERIMENTAL
422 ---help--- 437 ---help---
423 Say Y here if you want to connect this type of radio to your 438 Say Y here if you want to connect this type of radio to your
424 computer's USB port. Note that the audio is not digital, and 439 computer's USB port. Note that the audio is not digital, and
@@ -434,7 +449,7 @@ source "drivers/media/video/et61x251/Kconfig"
434 449
435config USB_OV511 450config USB_OV511
436 tristate "USB OV511 Camera support" 451 tristate "USB OV511 Camera support"
437 depends on USB && VIDEO_DEV 452 depends on USB && VIDEO_V4L1
438 ---help--- 453 ---help---
439 Say Y here if you want to connect this type of camera to your 454 Say Y here if you want to connect this type of camera to your
440 computer's USB port. See <file:Documentation/video4linux/ov511.txt> 455 computer's USB port. See <file:Documentation/video4linux/ov511.txt>
@@ -445,7 +460,7 @@ config USB_OV511
445 460
446config USB_SE401 461config USB_SE401
447 tristate "USB SE401 Camera support" 462 tristate "USB SE401 Camera support"
448 depends on USB && VIDEO_DEV 463 depends on USB && VIDEO_V4L1
449 ---help--- 464 ---help---
450 Say Y here if you want to connect this type of camera to your 465 Say Y here if you want to connect this type of camera to your
451 computer's USB port. See <file:Documentation/video4linux/se401.txt> 466 computer's USB port. See <file:Documentation/video4linux/se401.txt>
@@ -458,7 +473,7 @@ source "drivers/media/video/sn9c102/Kconfig"
458 473
459config USB_STV680 474config USB_STV680
460 tristate "USB STV680 (Pencam) Camera support" 475 tristate "USB STV680 (Pencam) Camera support"
461 depends on USB && VIDEO_DEV 476 depends on USB && VIDEO_V4L1
462 ---help--- 477 ---help---
463 Say Y here if you want to connect this type of camera to your 478 Say Y here if you want to connect this type of camera to your
464 computer's USB port. This includes the Pencam line of cameras. 479 computer's USB port. This includes the Pencam line of cameras.
@@ -470,7 +485,7 @@ config USB_STV680
470 485
471config USB_W9968CF 486config USB_W9968CF
472 tristate "USB W996[87]CF JPEG Dual Mode Camera support" 487 tristate "USB W996[87]CF JPEG Dual Mode Camera support"
473 depends on USB && VIDEO_DEV && I2C 488 depends on USB && VIDEO_V4L1 && I2C
474 select VIDEO_OVCAMCHIP 489 select VIDEO_OVCAMCHIP
475 ---help--- 490 ---help---
476 Say Y here if you want support for cameras based on OV681 or 491 Say Y here if you want support for cameras based on OV681 or
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index b3ea2d63db9b..e5bf2687b76d 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -10,7 +10,11 @@ tuner-objs := tuner-core.o tuner-types.o tuner-simple.o \
10 10
11msp3400-objs := msp3400-driver.o msp3400-kthreads.o 11msp3400-objs := msp3400-driver.o msp3400-kthreads.o
12 12
13obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-common.o v4l1-compat.o compat_ioctl32.o 13obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-common.o compat_ioctl32.o
14
15ifeq ($(CONFIG_VIDEO_V4L1_COMPAT),y)
16 obj-$(CONFIG_VIDEO_DEV) += v4l1-compat.o
17endif
14 18
15obj-$(CONFIG_VIDEO_BT848) += bt8xx/ 19obj-$(CONFIG_VIDEO_BT848) += bt8xx/
16obj-$(CONFIG_VIDEO_BT848) += tvaudio.o tda7432.o tda9875.o ir-kbd-i2c.o 20obj-$(CONFIG_VIDEO_BT848) += tvaudio.o tda7432.o tda9875.o ir-kbd-i2c.o
@@ -84,4 +88,8 @@ obj-$(CONFIG_USB_IBMCAM) += usbvideo/
84obj-$(CONFIG_USB_KONICAWC) += usbvideo/ 88obj-$(CONFIG_USB_KONICAWC) += usbvideo/
85obj-$(CONFIG_USB_VICAM) += usbvideo/ 89obj-$(CONFIG_USB_VICAM) += usbvideo/
86 90
91obj-$(CONFIG_VIDEO_VIVI) += vivi.o
92
87EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core 93EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core
94extra-cflags-$(CONFIG_VIDEO_V4L1_COMPAT) += -DCONFIG_VIDEO_V4L1_COMPAT
95
diff --git a/drivers/media/video/bt8xx/Kconfig b/drivers/media/video/bt8xx/Kconfig
index 085477c12612..153f6a4a96c9 100644
--- a/drivers/media/video/bt8xx/Kconfig
+++ b/drivers/media/video/bt8xx/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_BT848 1config VIDEO_BT848
2 tristate "BT848 Video For Linux" 2 tristate "BT848 Video For Linux"
3 depends on VIDEO_DEV && PCI && I2C 3 depends on VIDEO_DEV && PCI && I2C && VIDEO_V4L2
4 select I2C_ALGOBIT 4 select I2C_ALGOBIT
5 select FW_LOADER 5 select FW_LOADER
6 select VIDEO_BTCX 6 select VIDEO_BTCX
diff --git a/drivers/media/video/bt8xx/Makefile b/drivers/media/video/bt8xx/Makefile
index db641a36b197..a096a03418aa 100644
--- a/drivers/media/video/bt8xx/Makefile
+++ b/drivers/media/video/bt8xx/Makefile
@@ -8,5 +8,5 @@ bttv-objs := bttv-driver.o bttv-cards.o bttv-if.o \
8 8
9obj-$(CONFIG_VIDEO_BT848) += bttv.o 9obj-$(CONFIG_VIDEO_BT848) += bttv.o
10 10
11EXTRA_CFLAGS += -I$(src)/.. 11EXTRA_CFLAGS += -Idrivers/media/video
12EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core 12EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c
index f209a7492051..2b64aa835b42 100644
--- a/drivers/media/video/bt8xx/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -2991,13 +2991,13 @@ void __devinit bttv_idcard(struct bttv *btv)
2991 2991
2992 if (UNSET != audiomux[0]) { 2992 if (UNSET != audiomux[0]) {
2993 gpiobits = 0; 2993 gpiobits = 0;
2994 for (i = 0; i < 5; i++) { 2994 for (i = 0; i < 4; i++) {
2995 bttv_tvcards[btv->c.type].gpiomux[i] = audiomux[i]; 2995 bttv_tvcards[btv->c.type].gpiomux[i] = audiomux[i];
2996 gpiobits |= audiomux[i]; 2996 gpiobits |= audiomux[i];
2997 } 2997 }
2998 } else { 2998 } else {
2999 gpiobits = audioall; 2999 gpiobits = audioall;
3000 for (i = 0; i < 5; i++) { 3000 for (i = 0; i < 4; i++) {
3001 bttv_tvcards[btv->c.type].gpiomux[i] = audioall; 3001 bttv_tvcards[btv->c.type].gpiomux[i] = audioall;
3002 } 3002 }
3003 } 3003 }
diff --git a/drivers/media/video/bt8xx/bttv-risc.c b/drivers/media/video/bt8xx/bttv-risc.c
index 16323a5d68ac..afcfe71e3792 100644
--- a/drivers/media/video/bt8xx/bttv-risc.c
+++ b/drivers/media/video/bt8xx/bttv-risc.c
@@ -233,7 +233,7 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc,
233 const struct bttv_format *fmt, struct bttv_overlay *ov, 233 const struct bttv_format *fmt, struct bttv_overlay *ov,
234 int skip_even, int skip_odd) 234 int skip_even, int skip_odd)
235{ 235{
236 int instructions,rc,line,maxy,start,end,skip,nskips; 236 int dwords,rc,line,maxy,start,end,skip,nskips;
237 struct btcx_skiplist *skips; 237 struct btcx_skiplist *skips;
238 u32 *rp,ri,ra; 238 u32 *rp,ri,ra;
239 u32 addr; 239 u32 addr;
@@ -242,12 +242,12 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc,
242 if (NULL == (skips = kmalloc(sizeof(*skips) * ov->nclips,GFP_KERNEL))) 242 if (NULL == (skips = kmalloc(sizeof(*skips) * ov->nclips,GFP_KERNEL)))
243 return -ENOMEM; 243 return -ENOMEM;
244 244
245 /* estimate risc mem: worst case is (clip+1) * lines instructions 245 /* estimate risc mem: worst case is (1.5*clip+1) * lines instructions
246 + sync + jump (all 2 dwords) */ 246 + sync + jump (all 2 dwords) */
247 instructions = (ov->nclips + 1) * 247 dwords = (3 * ov->nclips + 2) *
248 ((skip_even || skip_odd) ? ov->w.height>>1 : ov->w.height); 248 ((skip_even || skip_odd) ? (ov->w.height+1)>>1 : ov->w.height);
249 instructions += 2; 249 dwords += 4;
250 if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,instructions*8)) < 0) { 250 if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,dwords*4)) < 0) {
251 kfree(skips); 251 kfree(skips);
252 return rc; 252 return rc;
253 } 253 }
@@ -276,8 +276,6 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc,
276 if (line > maxy) 276 if (line > maxy)
277 btcx_calc_skips(line, ov->w.width, &maxy, 277 btcx_calc_skips(line, ov->w.width, &maxy,
278 skips, &nskips, ov->clips, ov->nclips); 278 skips, &nskips, ov->clips, ov->nclips);
279 else
280 nskips = 0;
281 279
282 /* write out risc code */ 280 /* write out risc code */
283 for (start = 0, skip = 0; start < ov->w.width; start = end) { 281 for (start = 0, skip = 0; start < ov->w.width; start = end) {
diff --git a/drivers/media/video/cx25840/cx25840-firmware.c b/drivers/media/video/cx25840/cx25840-firmware.c
index f59ced181c55..1958d4016ea1 100644
--- a/drivers/media/video/cx25840/cx25840-firmware.c
+++ b/drivers/media/video/cx25840/cx25840-firmware.c
@@ -39,29 +39,12 @@
39 39
40#define FWDEV(x) &((x)->adapter->dev) 40#define FWDEV(x) &((x)->adapter->dev)
41 41
42static int fastfw = 1;
43static char *firmware = FWFILE; 42static char *firmware = FWFILE;
44 43
45module_param(fastfw, bool, 0444);
46module_param(firmware, charp, 0444); 44module_param(firmware, charp, 0444);
47 45
48MODULE_PARM_DESC(fastfw, "Load firmware fast [0=100MHz 1=333MHz (default)]");
49MODULE_PARM_DESC(firmware, "Firmware image [default: " FWFILE "]"); 46MODULE_PARM_DESC(firmware, "Firmware image [default: " FWFILE "]");
50 47
51static void set_i2c_delay(struct i2c_client *client, int delay)
52{
53 struct i2c_algo_bit_data *algod = client->adapter->algo_data;
54
55 /* We aren't guaranteed to be using algo_bit,
56 * so avoid the null pointer dereference
57 * and disable the 'fast firmware load' */
58 if (algod) {
59 algod->udelay = delay;
60 } else {
61 fastfw = 0;
62 }
63}
64
65static void start_fw_load(struct i2c_client *client) 48static void start_fw_load(struct i2c_client *client)
66{ 49{
67 /* DL_ADDR_LB=0 DL_ADDR_HB=0 */ 50 /* DL_ADDR_LB=0 DL_ADDR_HB=0 */
@@ -71,16 +54,10 @@ static void start_fw_load(struct i2c_client *client)
71 cx25840_write(client, 0x803, 0x0b); 54 cx25840_write(client, 0x803, 0x0b);
72 /* AUTO_INC_DIS=1 */ 55 /* AUTO_INC_DIS=1 */
73 cx25840_write(client, 0x000, 0x20); 56 cx25840_write(client, 0x000, 0x20);
74
75 if (fastfw)
76 set_i2c_delay(client, 3);
77} 57}
78 58
79static void end_fw_load(struct i2c_client *client) 59static void end_fw_load(struct i2c_client *client)
80{ 60{
81 if (fastfw)
82 set_i2c_delay(client, 10);
83
84 /* AUTO_INC_DIS=0 */ 61 /* AUTO_INC_DIS=0 */
85 cx25840_write(client, 0x000, 0x00); 62 cx25840_write(client, 0x000, 0x00);
86 /* DL_ENABLE=0 */ 63 /* DL_ENABLE=0 */
@@ -107,30 +84,8 @@ static int fw_write(struct i2c_client *client, u8 * data, int size)
107 int sent; 84 int sent;
108 85
109 if ((sent = i2c_master_send(client, data, size)) < size) { 86 if ((sent = i2c_master_send(client, data, size)) < size) {
110 87 v4l_err(client, "firmware load i2c failure\n");
111 if (fastfw) { 88 return -ENOSYS;
112 v4l_err(client, "333MHz i2c firmware load failed\n");
113 fastfw = 0;
114 set_i2c_delay(client, 10);
115
116 if (sent > 2) {
117 u16 dl_addr = cx25840_read(client, 0x801) << 8;
118 dl_addr |= cx25840_read(client, 0x800);
119 dl_addr -= sent - 2;
120 cx25840_write(client, 0x801, dl_addr >> 8);
121 cx25840_write(client, 0x800, dl_addr & 0xff);
122 }
123
124 if (i2c_master_send(client, data, size) < size) {
125 v4l_err(client, "100MHz i2c firmware load failed\n");
126 return -ENOSYS;
127 }
128
129 } else {
130 v4l_err(client, "firmware load i2c failure\n");
131 return -ENOSYS;
132 }
133
134 } 89 }
135 90
136 return 0; 91 return 0;
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index c7042cf41231..f80154b87d22 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -564,7 +564,7 @@ struct cx88_board cx88_boards[] = {
564 }, 564 },
565 [CX88_BOARD_PCHDTV_HD3000] = { 565 [CX88_BOARD_PCHDTV_HD3000] = {
566 .name = "pcHDTV HD3000 HDTV", 566 .name = "pcHDTV HD3000 HDTV",
567 .tuner_type = TUNER_THOMSON_DTT7610, 567 .tuner_type = TUNER_THOMSON_DTT761X,
568 .radio_type = UNSET, 568 .radio_type = UNSET,
569 .tuner_addr = ADDR_UNSET, 569 .tuner_addr = ADDR_UNSET,
570 .radio_addr = ADDR_UNSET, 570 .radio_addr = ADDR_UNSET,
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 2c3d9f1999be..e1092d5d4628 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -146,9 +146,11 @@ int cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
146 fields++; 146 fields++;
147 147
148 /* estimate risc mem: worst case is one write per page border + 148 /* estimate risc mem: worst case is one write per page border +
149 one write per scan line + syncs + jump (all 2 dwords) */ 149 one write per scan line + syncs + jump (all 2 dwords). Padding
150 instructions = (bpl * lines * fields) / PAGE_SIZE + lines * fields; 150 can cause next bpl to start close to a page border. First DMA
151 instructions += 3 + 4; 151 region may be smaller than PAGE_SIZE */
152 instructions = fields * (1 + ((bpl + padding) * lines) / PAGE_SIZE + lines);
153 instructions += 2;
152 if ((rc = btcx_riscmem_alloc(pci,risc,instructions*8)) < 0) 154 if ((rc = btcx_riscmem_alloc(pci,risc,instructions*8)) < 0)
153 return rc; 155 return rc;
154 156
@@ -176,9 +178,11 @@ int cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc,
176 int rc; 178 int rc;
177 179
178 /* estimate risc mem: worst case is one write per page border + 180 /* estimate risc mem: worst case is one write per page border +
179 one write per scan line + syncs + jump (all 2 dwords) */ 181 one write per scan line + syncs + jump (all 2 dwords). Here
180 instructions = (bpl * lines) / PAGE_SIZE + lines; 182 there is no padding and no sync. First DMA region may be smaller
181 instructions += 3 + 4; 183 than PAGE_SIZE */
184 instructions = 1 + (bpl * lines) / PAGE_SIZE + lines;
185 instructions += 1;
182 if ((rc = btcx_riscmem_alloc(pci,risc,instructions*8)) < 0) 186 if ((rc = btcx_riscmem_alloc(pci,risc,instructions*8)) < 0)
183 return rc; 187 return rc;
184 188
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index f0ea9b5cdbc2..3619a449aefd 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -372,7 +372,7 @@ static int or51132_set_ts_param(struct dvb_frontend* fe,
372static struct or51132_config pchdtv_hd3000 = { 372static struct or51132_config pchdtv_hd3000 = {
373 .demod_address = 0x15, 373 .demod_address = 0x15,
374 .pll_address = 0x61, 374 .pll_address = 0x61,
375 .pll_desc = &dvb_pll_thomson_dtt7610, 375 .pll_desc = &dvb_pll_thomson_dtt761x,
376 .set_ts_params = or51132_set_ts_param, 376 .set_ts_params = or51132_set_ts_param,
377}; 377};
378#endif 378#endif
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 72a417b31745..694d1d80ff3f 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -35,8 +35,10 @@
35#include "cx88.h" 35#include "cx88.h"
36#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
37 37
38#ifdef CONFIG_VIDEO_V4L1_COMPAT
38/* Include V4L1 specific functions. Should be removed soon */ 39/* Include V4L1 specific functions. Should be removed soon */
39#include <linux/videodev.h> 40#include <linux/videodev.h>
41#endif
40 42
41MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards"); 43MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards");
42MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); 44MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
diff --git a/drivers/media/video/em28xx/Kconfig b/drivers/media/video/em28xx/Kconfig
index 5a793ae7cc23..dfb15bfb83dc 100644
--- a/drivers/media/video/em28xx/Kconfig
+++ b/drivers/media/video/em28xx/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_EM28XX 1config VIDEO_EM28XX
2 tristate "Empia EM2800/2820/2840 USB video capture support" 2 tristate "Empia EM2800/2820/2840 USB video capture support"
3 depends on VIDEO_DEV && USB && I2C 3 depends on VIDEO_V4L1 && USB && I2C
4 select VIDEO_BUF 4 select VIDEO_BUF
5 select VIDEO_TUNER 5 select VIDEO_TUNER
6 select VIDEO_TVEEPROM 6 select VIDEO_TVEEPROM
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index ddc92cbb5276..cf7cdf9ef617 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -1576,8 +1576,8 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1576 errCode = em28xx_config(dev); 1576 errCode = em28xx_config(dev);
1577 if (errCode) { 1577 if (errCode) {
1578 em28xx_errdev("error configuring device\n"); 1578 em28xx_errdev("error configuring device\n");
1579 kfree(dev);
1580 em28xx_devused&=~(1<<dev->devno); 1579 em28xx_devused&=~(1<<dev->devno);
1580 kfree(dev);
1581 return -ENOMEM; 1581 return -ENOMEM;
1582 } 1582 }
1583 1583
@@ -1603,8 +1603,8 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1603 dev->vdev = video_device_alloc(); 1603 dev->vdev = video_device_alloc();
1604 if (NULL == dev->vdev) { 1604 if (NULL == dev->vdev) {
1605 em28xx_errdev("cannot allocate video_device.\n"); 1605 em28xx_errdev("cannot allocate video_device.\n");
1606 kfree(dev);
1607 em28xx_devused&=~(1<<dev->devno); 1606 em28xx_devused&=~(1<<dev->devno);
1607 kfree(dev);
1608 return -ENOMEM; 1608 return -ENOMEM;
1609 } 1609 }
1610 1610
@@ -1612,8 +1612,8 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1612 if (NULL == dev->vbi_dev) { 1612 if (NULL == dev->vbi_dev) {
1613 em28xx_errdev("cannot allocate video_device.\n"); 1613 em28xx_errdev("cannot allocate video_device.\n");
1614 kfree(dev->vdev); 1614 kfree(dev->vdev);
1615 kfree(dev);
1616 em28xx_devused&=~(1<<dev->devno); 1615 em28xx_devused&=~(1<<dev->devno);
1616 kfree(dev);
1617 return -ENOMEM; 1617 return -ENOMEM;
1618 } 1618 }
1619 1619
@@ -1650,8 +1650,8 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1650 mutex_unlock(&dev->lock); 1650 mutex_unlock(&dev->lock);
1651 list_del(&dev->devlist); 1651 list_del(&dev->devlist);
1652 video_device_release(dev->vdev); 1652 video_device_release(dev->vdev);
1653 kfree(dev);
1654 em28xx_devused&=~(1<<dev->devno); 1653 em28xx_devused&=~(1<<dev->devno);
1654 kfree(dev);
1655 return -ENODEV; 1655 return -ENODEV;
1656 } 1656 }
1657 1657
@@ -1662,8 +1662,8 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1662 list_del(&dev->devlist); 1662 list_del(&dev->devlist);
1663 video_device_release(dev->vbi_dev); 1663 video_device_release(dev->vbi_dev);
1664 video_device_release(dev->vdev); 1664 video_device_release(dev->vdev);
1665 kfree(dev);
1666 em28xx_devused&=~(1<<dev->devno); 1665 em28xx_devused&=~(1<<dev->devno);
1666 kfree(dev);
1667 return -ENODEV; 1667 return -ENODEV;
1668 } else { 1668 } else {
1669 printk("registered VBI\n"); 1669 printk("registered VBI\n");
diff --git a/drivers/media/video/et61x251/Kconfig b/drivers/media/video/et61x251/Kconfig
index 6c43a90c6569..c6bff705688d 100644
--- a/drivers/media/video/et61x251/Kconfig
+++ b/drivers/media/video/et61x251/Kconfig
@@ -1,6 +1,6 @@
1config USB_ET61X251 1config USB_ET61X251
2 tristate "USB ET61X[12]51 PC Camera Controller support" 2 tristate "USB ET61X[12]51 PC Camera Controller support"
3 depends on USB && VIDEO_DEV 3 depends on USB && VIDEO_V4L1
4 ---help--- 4 ---help---
5 Say Y here if you want support for cameras based on Etoms ET61X151 5 Say Y here if you want support for cameras based on Etoms ET61X151
6 or ET61X251 PC Camera Controllers. 6 or ET61X251 PC Camera Controllers.
diff --git a/drivers/media/video/pwc/Kconfig b/drivers/media/video/pwc/Kconfig
index 86376556f108..53cbc950f95c 100644
--- a/drivers/media/video/pwc/Kconfig
+++ b/drivers/media/video/pwc/Kconfig
@@ -1,6 +1,6 @@
1config USB_PWC 1config USB_PWC
2 tristate "USB Philips Cameras" 2 tristate "USB Philips Cameras"
3 depends on USB && VIDEO_DEV 3 depends on USB && VIDEO_V4L1
4 ---help--- 4 ---help---
5 Say Y or M here if you want to use one of these Philips & OEM 5 Say Y or M here if you want to use one of these Philips & OEM
6 webcams: 6 webcams:
diff --git a/drivers/media/video/pwc/Makefile b/drivers/media/video/pwc/Makefile
index 8326684f49f3..33d60126c024 100644
--- a/drivers/media/video/pwc/Makefile
+++ b/drivers/media/video/pwc/Makefile
@@ -1,20 +1,3 @@
1ifneq ($(KERNELRELEASE),)
2
3pwc-objs := pwc-if.o pwc-misc.o pwc-ctrl.o pwc-uncompress.o pwc-timon.o pwc-kiara.o 1pwc-objs := pwc-if.o pwc-misc.o pwc-ctrl.o pwc-uncompress.o pwc-timon.o pwc-kiara.o
4 2
5obj-$(CONFIG_USB_PWC) += pwc.o 3obj-$(CONFIG_USB_PWC) += pwc.o
6
7else
8
9KDIR := /lib/modules/$(shell uname -r)/build
10PWD := $(shell pwd)
11
12default:
13 $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
14
15endif
16
17clean:
18 rm -f *.[oas] .*.flags *.ko .*.cmd .*.d .*.tmp *.mod.c
19 rm -rf .tmp_versions
20
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c
index 133f9e5252fe..c271e2e14105 100644
--- a/drivers/media/video/saa7127.c
+++ b/drivers/media/video/saa7127.c
@@ -142,6 +142,7 @@ struct i2c_reg_value {
142static const struct i2c_reg_value saa7129_init_config_extra[] = { 142static const struct i2c_reg_value saa7129_init_config_extra[] = {
143 { SAA7127_REG_OUTPUT_PORT_CONTROL, 0x38 }, 143 { SAA7127_REG_OUTPUT_PORT_CONTROL, 0x38 },
144 { SAA7127_REG_VTRIG, 0xfa }, 144 { SAA7127_REG_VTRIG, 0xfa },
145 { 0, 0 }
145}; 146};
146 147
147static const struct i2c_reg_value saa7127_init_config_common[] = { 148static const struct i2c_reg_value saa7127_init_config_common[] = {
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index e666a4465ca4..86eae3528330 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -3504,6 +3504,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
3504 /* power-up tuner chip */ 3504 /* power-up tuner chip */
3505 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x00040000, 0x00040000); 3505 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x00040000, 0x00040000);
3506 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x00040000, 0x00000000); 3506 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x00040000, 0x00000000);
3507 break;
3507 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL: 3508 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
3508 /* this turns the remote control chip off to work around a bug in it */ 3509 /* this turns the remote control chip off to work around a bug in it */
3509 saa_writeb(SAA7134_GPIO_GPMODE1, 0x80); 3510 saa_writeb(SAA7134_GPIO_GPMODE1, 0x80);
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 13de05532e0a..f0c2111f14ad 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -548,6 +548,8 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id, struct pt_regs *regs)
548 if (report & SAA7134_IRQ_REPORT_GPIO16) { 548 if (report & SAA7134_IRQ_REPORT_GPIO16) {
549 switch (dev->has_remote) { 549 switch (dev->has_remote) {
550 case SAA7134_REMOTE_GPIO: 550 case SAA7134_REMOTE_GPIO:
551 if (!dev->remote)
552 break;
551 if (dev->remote->mask_keydown & 0x10000) { 553 if (dev->remote->mask_keydown & 0x10000) {
552 saa7134_input_irq(dev); 554 saa7134_input_irq(dev);
553 } 555 }
@@ -564,6 +566,8 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id, struct pt_regs *regs)
564 if (report & SAA7134_IRQ_REPORT_GPIO18) { 566 if (report & SAA7134_IRQ_REPORT_GPIO18) {
565 switch (dev->has_remote) { 567 switch (dev->has_remote) {
566 case SAA7134_REMOTE_GPIO: 568 case SAA7134_REMOTE_GPIO:
569 if (!dev->remote)
570 break;
567 if ((dev->remote->mask_keydown & 0x40000) || 571 if ((dev->remote->mask_keydown & 0x40000) ||
568 (dev->remote->mask_keyup & 0x40000)) { 572 (dev->remote->mask_keyup & 0x40000)) {
569 saa7134_input_irq(dev); 573 saa7134_input_irq(dev);
@@ -676,7 +680,7 @@ static int saa7134_hwinit2(struct saa7134_dev *dev)
676 SAA7134_IRQ2_INTE_PE | 680 SAA7134_IRQ2_INTE_PE |
677 SAA7134_IRQ2_INTE_AR; 681 SAA7134_IRQ2_INTE_AR;
678 682
679 if (dev->has_remote == SAA7134_REMOTE_GPIO) { 683 if (dev->has_remote == SAA7134_REMOTE_GPIO && dev->remote) {
680 if (dev->remote->mask_keydown & 0x10000) 684 if (dev->remote->mask_keydown & 0x10000)
681 irq2_mask |= SAA7134_IRQ2_INTE_GPIO16; 685 irq2_mask |= SAA7134_IRQ2_INTE_GPIO16;
682 else if (dev->remote->mask_keydown & 0x40000) 686 else if (dev->remote->mask_keydown & 0x40000)
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index aeef80f88a6b..e4156ec9c6d7 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -31,8 +31,10 @@
31#include "saa7134.h" 31#include "saa7134.h"
32#include <media/v4l2-common.h> 32#include <media/v4l2-common.h>
33 33
34#ifdef CONFIG_VIDEO_V4L1_COMPAT
34/* Include V4L1 specific functions. Should be removed soon */ 35/* Include V4L1 specific functions. Should be removed soon */
35#include <linux/videodev.h> 36#include <linux/videodev.h>
37#endif
36 38
37/* ------------------------------------------------------------------ */ 39/* ------------------------------------------------------------------ */
38 40
diff --git a/drivers/media/video/sn9c102/Kconfig b/drivers/media/video/sn9c102/Kconfig
index 55f2bc11964b..cf552e6b8ecf 100644
--- a/drivers/media/video/sn9c102/Kconfig
+++ b/drivers/media/video/sn9c102/Kconfig
@@ -1,6 +1,6 @@
1config USB_SN9C102 1config USB_SN9C102
2 tristate "USB SN9C10x PC Camera Controller support" 2 tristate "USB SN9C10x PC Camera Controller support"
3 depends on USB && VIDEO_DEV 3 depends on USB && VIDEO_V4L1
4 ---help--- 4 ---help---
5 Say Y here if you want support for cameras based on SONiX SN9C101, 5 Say Y here if you want support for cameras based on SONiX SN9C101,
6 SN9C102 or SN9C103 PC Camera Controllers. 6 SN9C102 or SN9C103 PC Camera Controllers.
diff --git a/drivers/media/video/tuner-types.c b/drivers/media/video/tuner-types.c
index 72e0f01db563..a1ae036b44ec 100644
--- a/drivers/media/video/tuner-types.c
+++ b/drivers/media/video/tuner-types.c
@@ -877,8 +877,8 @@ static struct tuner_params tuner_philips_fmd1216me_mk3_params[] = {
877/* ------------ TUNER_LG_TDVS_H062F - INFINEON ATSC ------------ */ 877/* ------------ TUNER_LG_TDVS_H062F - INFINEON ATSC ------------ */
878 878
879static struct tuner_range tuner_tua6034_ntsc_ranges[] = { 879static struct tuner_range tuner_tua6034_ntsc_ranges[] = {
880 { 16 * 160.00 /*MHz*/, 0x8e, 0x01 }, 880 { 16 * 165.00 /*MHz*/, 0x8e, 0x01 },
881 { 16 * 455.00 /*MHz*/, 0x8e, 0x02 }, 881 { 16 * 450.00 /*MHz*/, 0x8e, 0x02 },
882 { 16 * 999.99 , 0x8e, 0x04 }, 882 { 16 * 999.99 , 0x8e, 0x04 },
883}; 883};
884 884
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 431c3e2f6c42..b463e996961a 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -218,7 +218,7 @@ hauppauge_tuner[] =
218 /* 110-119 */ 218 /* 110-119 */
219 { TUNER_ABSENT, "Thompson DTT75105"}, 219 { TUNER_ABSENT, "Thompson DTT75105"},
220 { TUNER_ABSENT, "Conexant_CX24109"}, 220 { TUNER_ABSENT, "Conexant_CX24109"},
221 { TUNER_ABSENT, "TCL M2523_5N_E"}, 221 { TUNER_TCL_2002N, "TCL M2523_5N_E"},
222 { TUNER_ABSENT, "TCL M2523_3DB_E"}, 222 { TUNER_ABSENT, "TCL M2523_3DB_E"},
223 { TUNER_ABSENT, "Philips 8275A"}, 223 { TUNER_ABSENT, "Philips 8275A"},
224 { TUNER_ABSENT, "Microtune MT2060"}, 224 { TUNER_ABSENT, "Microtune MT2060"},
diff --git a/drivers/media/video/usbvideo/Kconfig b/drivers/media/video/usbvideo/Kconfig
index 08a5d20bb2c0..39269a2c5635 100644
--- a/drivers/media/video/usbvideo/Kconfig
+++ b/drivers/media/video/usbvideo/Kconfig
@@ -3,7 +3,7 @@ config VIDEO_USBVIDEO
3 3
4config USB_VICAM 4config USB_VICAM
5 tristate "USB 3com HomeConnect (aka vicam) support (EXPERIMENTAL)" 5 tristate "USB 3com HomeConnect (aka vicam) support (EXPERIMENTAL)"
6 depends on USB && VIDEO_DEV && EXPERIMENTAL 6 depends on USB && VIDEO_V4L1 && EXPERIMENTAL
7 select VIDEO_USBVIDEO 7 select VIDEO_USBVIDEO
8 ---help--- 8 ---help---
9 Say Y here if you have 3com homeconnect camera (vicam). 9 Say Y here if you have 3com homeconnect camera (vicam).
@@ -13,7 +13,7 @@ config USB_VICAM
13 13
14config USB_IBMCAM 14config USB_IBMCAM
15 tristate "USB IBM (Xirlink) C-it Camera support" 15 tristate "USB IBM (Xirlink) C-it Camera support"
16 depends on USB && VIDEO_DEV 16 depends on USB && VIDEO_V4L1
17 select VIDEO_USBVIDEO 17 select VIDEO_USBVIDEO
18 ---help--- 18 ---help---
19 Say Y here if you want to connect a IBM "C-It" camera, also known as 19 Say Y here if you want to connect a IBM "C-It" camera, also known as
@@ -28,7 +28,7 @@ config USB_IBMCAM
28 28
29config USB_KONICAWC 29config USB_KONICAWC
30 tristate "USB Konica Webcam support" 30 tristate "USB Konica Webcam support"
31 depends on USB && VIDEO_DEV 31 depends on USB && VIDEO_V4L1
32 select VIDEO_USBVIDEO 32 select VIDEO_USBVIDEO
33 ---help--- 33 ---help---
34 Say Y here if you want support for webcams based on a Konica 34 Say Y here if you want support for webcams based on a Konica
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 5e813404d068..779db26771c0 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -26,6 +26,11 @@
26#include <linux/random.h> 26#include <linux/random.h>
27#include <linux/version.h> 27#include <linux/version.h>
28#include <linux/videodev2.h> 28#include <linux/videodev2.h>
29#include <linux/dma-mapping.h>
30#ifdef CONFIG_VIDEO_V4L1_COMPAT
31/* Include V4L1 specific functions. Should be removed soon */
32#include <linux/videodev.h>
33#endif
29#include <linux/interrupt.h> 34#include <linux/interrupt.h>
30#include <media/video-buf.h> 35#include <media/video-buf.h>
31#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
diff --git a/drivers/media/video/zc0301/Kconfig b/drivers/media/video/zc0301/Kconfig
index c3bf886b80cd..115833e4f4dd 100644
--- a/drivers/media/video/zc0301/Kconfig
+++ b/drivers/media/video/zc0301/Kconfig
@@ -1,6 +1,6 @@
1config USB_ZC0301 1config USB_ZC0301
2 tristate "USB ZC0301 Image Processor and Control Chip support" 2 tristate "USB ZC0301 Image Processor and Control Chip support"
3 depends on USB && VIDEO_DEV 3 depends on USB && VIDEO_V4L1
4 ---help--- 4 ---help---
5 Say Y here if you want support for cameras based on the ZC0301 5 Say Y here if you want support for cameras based on the ZC0301
6 Image Processor and Control Chip. 6 Image Processor and Control Chip.
diff --git a/drivers/mmc/au1xmmc.c b/drivers/mmc/au1xmmc.c
index 914d62b24064..5dc4bee7abeb 100644
--- a/drivers/mmc/au1xmmc.c
+++ b/drivers/mmc/au1xmmc.c
@@ -310,7 +310,7 @@ static void au1xmmc_data_complete(struct au1xmmc_host *host, u32 status)
310 } 310 }
311 else 311 else
312 data->bytes_xfered = 312 data->bytes_xfered =
313 (data->blocks * (1 << data->blksz_bits)) - 313 (data->blocks * data->blksz) -
314 host->pio.len; 314 host->pio.len;
315 } 315 }
316 316
@@ -575,7 +575,7 @@ static int
575au1xmmc_prepare_data(struct au1xmmc_host *host, struct mmc_data *data) 575au1xmmc_prepare_data(struct au1xmmc_host *host, struct mmc_data *data)
576{ 576{
577 577
578 int datalen = data->blocks * (1 << data->blksz_bits); 578 int datalen = data->blocks * data->blksz;
579 579
580 if (dma != 0) 580 if (dma != 0)
581 host->flags |= HOST_F_DMA; 581 host->flags |= HOST_F_DMA;
@@ -596,7 +596,7 @@ au1xmmc_prepare_data(struct au1xmmc_host *host, struct mmc_data *data)
596 if (host->dma.len == 0) 596 if (host->dma.len == 0)
597 return MMC_ERR_TIMEOUT; 597 return MMC_ERR_TIMEOUT;
598 598
599 au_writel((1 << data->blksz_bits) - 1, HOST_BLKSIZE(host)); 599 au_writel(data->blksz - 1, HOST_BLKSIZE(host));
600 600
601 if (host->flags & HOST_F_DMA) { 601 if (host->flags & HOST_F_DMA) {
602 int i; 602 int i;
diff --git a/drivers/mmc/imxmmc.c b/drivers/mmc/imxmmc.c
index 79358e223f57..a4eb1d0e7a71 100644
--- a/drivers/mmc/imxmmc.c
+++ b/drivers/mmc/imxmmc.c
@@ -218,8 +218,10 @@ static int imxmci_busy_wait_for_status(struct imxmci_host *host,
218 if(!loops) 218 if(!loops)
219 return 0; 219 return 0;
220 220
221 dev_info(mmc_dev(host->mmc), "busy wait for %d usec in %s, STATUS = 0x%x (0x%x)\n", 221 /* The busy-wait is expected there for clock <8MHz due to SDHC hardware flaws */
222 loops, where, *pstat, stat_mask); 222 if(!(stat_mask & STATUS_END_CMD_RESP) || (host->mmc->ios.clock>=8000000))
223 dev_info(mmc_dev(host->mmc), "busy wait for %d usec in %s, STATUS = 0x%x (0x%x)\n",
224 loops, where, *pstat, stat_mask);
223 return loops; 225 return loops;
224} 226}
225 227
@@ -333,6 +335,9 @@ static void imxmci_start_cmd(struct imxmci_host *host, struct mmc_command *cmd,
333 WARN_ON(host->cmd != NULL); 335 WARN_ON(host->cmd != NULL);
334 host->cmd = cmd; 336 host->cmd = cmd;
335 337
338 /* Ensure, that clock are stopped else command programming and start fails */
339 imxmci_stop_clock(host);
340
336 if (cmd->flags & MMC_RSP_BUSY) 341 if (cmd->flags & MMC_RSP_BUSY)
337 cmdat |= CMD_DAT_CONT_BUSY; 342 cmdat |= CMD_DAT_CONT_BUSY;
338 343
@@ -553,7 +558,7 @@ static int imxmci_cpu_driven_data(struct imxmci_host *host, unsigned int *pstat)
553 int trans_done = 0; 558 int trans_done = 0;
554 unsigned int stat = *pstat; 559 unsigned int stat = *pstat;
555 560
556 if(host->actual_bus_width == MMC_BUS_WIDTH_4) 561 if(host->actual_bus_width != MMC_BUS_WIDTH_4)
557 burst_len = 16; 562 burst_len = 16;
558 else 563 else
559 burst_len = 64; 564 burst_len = 64;
@@ -591,8 +596,7 @@ static int imxmci_cpu_driven_data(struct imxmci_host *host, unsigned int *pstat)
591 stat = MMC_STATUS; 596 stat = MMC_STATUS;
592 597
593 /* Flush extra bytes from FIFO */ 598 /* Flush extra bytes from FIFO */
594 while(flush_len >= 2){ 599 while(flush_len && !(stat & STATUS_DATA_TRANS_DONE)){
595 flush_len -= 2;
596 i = MMC_BUFFER_ACCESS; 600 i = MMC_BUFFER_ACCESS;
597 stat = MMC_STATUS; 601 stat = MMC_STATUS;
598 stat &= ~STATUS_CRC_READ_ERR; /* Stupid but required there */ 602 stat &= ~STATUS_CRC_READ_ERR; /* Stupid but required there */
@@ -746,10 +750,6 @@ static void imxmci_tasklet_fnc(unsigned long data)
746 data_dir_mask = STATUS_DATA_TRANS_DONE; 750 data_dir_mask = STATUS_DATA_TRANS_DONE;
747 } 751 }
748 752
749 imxmci_busy_wait_for_status(host, &stat,
750 data_dir_mask,
751 50, "imxmci_tasklet_fnc data");
752
753 if(stat & data_dir_mask) { 753 if(stat & data_dir_mask) {
754 clear_bit(IMXMCI_PEND_DMA_END_b, &host->pending_events); 754 clear_bit(IMXMCI_PEND_DMA_END_b, &host->pending_events);
755 imxmci_data_done(host, stat); 755 imxmci_data_done(host, stat);
@@ -865,7 +865,11 @@ static void imxmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
865 865
866 imxmci_stop_clock(host); 866 imxmci_stop_clock(host);
867 MMC_CLK_RATE = (prescaler<<3) | clk; 867 MMC_CLK_RATE = (prescaler<<3) | clk;
868 imxmci_start_clock(host); 868 /*
869 * Under my understanding, clock should not be started there, because it would
870 * initiate SDHC sequencer and send last or random command into card
871 */
872 /*imxmci_start_clock(host);*/
869 873
870 dev_dbg(mmc_dev(host->mmc), "MMC_CLK_RATE: 0x%08x\n", MMC_CLK_RATE); 874 dev_dbg(mmc_dev(host->mmc), "MMC_CLK_RATE: 0x%08x\n", MMC_CLK_RATE);
871 } else { 875 } else {
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 1ca2c8b9c9b5..6201f3086a02 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -951,6 +951,7 @@ static void mmc_read_scrs(struct mmc_host *host)
951 data.timeout_ns = card->csd.tacc_ns * 10; 951 data.timeout_ns = card->csd.tacc_ns * 10;
952 data.timeout_clks = card->csd.tacc_clks * 10; 952 data.timeout_clks = card->csd.tacc_clks * 10;
953 data.blksz_bits = 3; 953 data.blksz_bits = 3;
954 data.blksz = 1 << 3;
954 data.blocks = 1; 955 data.blocks = 1;
955 data.flags = MMC_DATA_READ; 956 data.flags = MMC_DATA_READ;
956 data.sg = &sg; 957 data.sg = &sg;
diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c
index 06bd1f4cb9b1..587458b370b9 100644
--- a/drivers/mmc/mmc_block.c
+++ b/drivers/mmc/mmc_block.c
@@ -175,6 +175,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
175 brq.data.timeout_ns = card->csd.tacc_ns * 10; 175 brq.data.timeout_ns = card->csd.tacc_ns * 10;
176 brq.data.timeout_clks = card->csd.tacc_clks * 10; 176 brq.data.timeout_clks = card->csd.tacc_clks * 10;
177 brq.data.blksz_bits = md->block_bits; 177 brq.data.blksz_bits = md->block_bits;
178 brq.data.blksz = 1 << md->block_bits;
178 brq.data.blocks = req->nr_sectors >> (md->block_bits - 9); 179 brq.data.blocks = req->nr_sectors >> (md->block_bits - 9);
179 brq.stop.opcode = MMC_STOP_TRANSMISSION; 180 brq.stop.opcode = MMC_STOP_TRANSMISSION;
180 brq.stop.arg = 0; 181 brq.stop.arg = 0;
@@ -352,7 +353,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
352 */ 353 */
353 printk(KERN_ERR "%s: unable to select block size for " 354 printk(KERN_ERR "%s: unable to select block size for "
354 "writing (rb%u wb%u rp%u wp%u)\n", 355 "writing (rb%u wb%u rp%u wp%u)\n",
355 md->disk->disk_name, 356 mmc_card_id(card),
356 1 << card->csd.read_blkbits, 357 1 << card->csd.read_blkbits,
357 1 << card->csd.write_blkbits, 358 1 << card->csd.write_blkbits,
358 card->csd.read_partial, 359 card->csd.read_partial,
diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c
index f97b472085cb..b49368fd96b8 100644
--- a/drivers/mmc/pxamci.c
+++ b/drivers/mmc/pxamci.c
@@ -119,7 +119,7 @@ static void pxamci_setup_data(struct pxamci_host *host, struct mmc_data *data)
119 nob = 0xffff; 119 nob = 0xffff;
120 120
121 writel(nob, host->base + MMC_NOB); 121 writel(nob, host->base + MMC_NOB);
122 writel(1 << data->blksz_bits, host->base + MMC_BLKLEN); 122 writel(data->blksz, host->base + MMC_BLKLEN);
123 123
124 clks = (unsigned long long)data->timeout_ns * CLOCKRATE; 124 clks = (unsigned long long)data->timeout_ns * CLOCKRATE;
125 do_div(clks, 1000000000UL); 125 do_div(clks, 1000000000UL);
@@ -283,7 +283,7 @@ static int pxamci_data_done(struct pxamci_host *host, unsigned int stat)
283 * data blocks as being in error. 283 * data blocks as being in error.
284 */ 284 */
285 if (data->error == MMC_ERR_NONE) 285 if (data->error == MMC_ERR_NONE)
286 data->bytes_xfered = data->blocks << data->blksz_bits; 286 data->bytes_xfered = data->blocks * data->blksz;
287 else 287 else
288 data->bytes_xfered = 0; 288 data->bytes_xfered = 0;
289 289
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c
index 39b3d97f891e..8167332d4013 100644
--- a/drivers/mmc/wbsd.c
+++ b/drivers/mmc/wbsd.c
@@ -662,14 +662,14 @@ static void wbsd_prepare_data(struct wbsd_host *host, struct mmc_data *data)
662 unsigned long dmaflags; 662 unsigned long dmaflags;
663 663
664 DBGF("blksz %04x blks %04x flags %08x\n", 664 DBGF("blksz %04x blks %04x flags %08x\n",
665 1 << data->blksz_bits, data->blocks, data->flags); 665 data->blksz, data->blocks, data->flags);
666 DBGF("tsac %d ms nsac %d clk\n", 666 DBGF("tsac %d ms nsac %d clk\n",
667 data->timeout_ns / 1000000, data->timeout_clks); 667 data->timeout_ns / 1000000, data->timeout_clks);
668 668
669 /* 669 /*
670 * Calculate size. 670 * Calculate size.
671 */ 671 */
672 host->size = data->blocks << data->blksz_bits; 672 host->size = data->blocks * data->blksz;
673 673
674 /* 674 /*
675 * Check timeout values for overflow. 675 * Check timeout values for overflow.
@@ -696,12 +696,12 @@ static void wbsd_prepare_data(struct wbsd_host *host, struct mmc_data *data)
696 * Two bytes are needed for each data line. 696 * Two bytes are needed for each data line.
697 */ 697 */
698 if (host->bus_width == MMC_BUS_WIDTH_1) { 698 if (host->bus_width == MMC_BUS_WIDTH_1) {
699 blksize = (1 << data->blksz_bits) + 2; 699 blksize = data->blksz + 2;
700 700
701 wbsd_write_index(host, WBSD_IDX_PBSMSB, (blksize >> 4) & 0xF0); 701 wbsd_write_index(host, WBSD_IDX_PBSMSB, (blksize >> 4) & 0xF0);
702 wbsd_write_index(host, WBSD_IDX_PBSLSB, blksize & 0xFF); 702 wbsd_write_index(host, WBSD_IDX_PBSLSB, blksize & 0xFF);
703 } else if (host->bus_width == MMC_BUS_WIDTH_4) { 703 } else if (host->bus_width == MMC_BUS_WIDTH_4) {
704 blksize = (1 << data->blksz_bits) + 2 * 4; 704 blksize = data->blksz + 2 * 4;
705 705
706 wbsd_write_index(host, WBSD_IDX_PBSMSB, 706 wbsd_write_index(host, WBSD_IDX_PBSMSB,
707 ((blksize >> 4) & 0xF0) | WBSD_DATA_WIDTH); 707 ((blksize >> 4) & 0xF0) | WBSD_DATA_WIDTH);
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 5ca99e26660a..54161aef3cac 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -55,8 +55,8 @@
55 55
56#define DRV_MODULE_NAME "bnx2" 56#define DRV_MODULE_NAME "bnx2"
57#define PFX DRV_MODULE_NAME ": " 57#define PFX DRV_MODULE_NAME ": "
58#define DRV_MODULE_VERSION "1.4.39" 58#define DRV_MODULE_VERSION "1.4.40"
59#define DRV_MODULE_RELDATE "March 22, 2006" 59#define DRV_MODULE_RELDATE "May 22, 2006"
60 60
61#define RUN_AT(x) (jiffies + (x)) 61#define RUN_AT(x) (jiffies + (x))
62 62
@@ -2945,7 +2945,7 @@ bnx2_nvram_write(struct bnx2 *bp, u32 offset, u8 *data_buf,
2945 int buf_size) 2945 int buf_size)
2946{ 2946{
2947 u32 written, offset32, len32; 2947 u32 written, offset32, len32;
2948 u8 *buf, start[4], end[4]; 2948 u8 *buf, start[4], end[4], *flash_buffer = NULL;
2949 int rc = 0; 2949 int rc = 0;
2950 int align_start, align_end; 2950 int align_start, align_end;
2951 2951
@@ -2985,12 +2985,19 @@ bnx2_nvram_write(struct bnx2 *bp, u32 offset, u8 *data_buf,
2985 memcpy(buf + align_start, data_buf, buf_size); 2985 memcpy(buf + align_start, data_buf, buf_size);
2986 } 2986 }
2987 2987
2988 if (bp->flash_info->buffered == 0) {
2989 flash_buffer = kmalloc(264, GFP_KERNEL);
2990 if (flash_buffer == NULL) {
2991 rc = -ENOMEM;
2992 goto nvram_write_end;
2993 }
2994 }
2995
2988 written = 0; 2996 written = 0;
2989 while ((written < len32) && (rc == 0)) { 2997 while ((written < len32) && (rc == 0)) {
2990 u32 page_start, page_end, data_start, data_end; 2998 u32 page_start, page_end, data_start, data_end;
2991 u32 addr, cmd_flags; 2999 u32 addr, cmd_flags;
2992 int i; 3000 int i;
2993 u8 flash_buffer[264];
2994 3001
2995 /* Find the page_start addr */ 3002 /* Find the page_start addr */
2996 page_start = offset32 + written; 3003 page_start = offset32 + written;
@@ -3061,7 +3068,7 @@ bnx2_nvram_write(struct bnx2 *bp, u32 offset, u8 *data_buf,
3061 } 3068 }
3062 3069
3063 /* Loop to write the new data from data_start to data_end */ 3070 /* Loop to write the new data from data_start to data_end */
3064 for (addr = data_start; addr < data_end; addr += 4, i++) { 3071 for (addr = data_start; addr < data_end; addr += 4, i += 4) {
3065 if ((addr == page_end - 4) || 3072 if ((addr == page_end - 4) ||
3066 ((bp->flash_info->buffered) && 3073 ((bp->flash_info->buffered) &&
3067 (addr == data_end - 4))) { 3074 (addr == data_end - 4))) {
@@ -3109,6 +3116,9 @@ bnx2_nvram_write(struct bnx2 *bp, u32 offset, u8 *data_buf,
3109 } 3116 }
3110 3117
3111nvram_write_end: 3118nvram_write_end:
3119 if (bp->flash_info->buffered == 0)
3120 kfree(flash_buffer);
3121
3112 if (align_start || align_end) 3122 if (align_start || align_end)
3113 kfree(buf); 3123 kfree(buf);
3114 return rc; 3124 return rc;
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index c99e87838f92..ed15fcaedaf9 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -220,6 +220,7 @@ static void e1000_restore_vlan(struct e1000_adapter *adapter);
220static int e1000_suspend(struct pci_dev *pdev, pm_message_t state); 220static int e1000_suspend(struct pci_dev *pdev, pm_message_t state);
221static int e1000_resume(struct pci_dev *pdev); 221static int e1000_resume(struct pci_dev *pdev);
222#endif 222#endif
223static void e1000_shutdown(struct pci_dev *pdev);
223 224
224#ifdef CONFIG_NET_POLL_CONTROLLER 225#ifdef CONFIG_NET_POLL_CONTROLLER
225/* for netdump / net console */ 226/* for netdump / net console */
@@ -235,8 +236,9 @@ static struct pci_driver e1000_driver = {
235 /* Power Managment Hooks */ 236 /* Power Managment Hooks */
236#ifdef CONFIG_PM 237#ifdef CONFIG_PM
237 .suspend = e1000_suspend, 238 .suspend = e1000_suspend,
238 .resume = e1000_resume 239 .resume = e1000_resume,
239#endif 240#endif
241 .shutdown = e1000_shutdown
240}; 242};
241 243
242MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>"); 244MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
@@ -4611,6 +4613,12 @@ e1000_resume(struct pci_dev *pdev)
4611 return 0; 4613 return 0;
4612} 4614}
4613#endif 4615#endif
4616
4617static void e1000_shutdown(struct pci_dev *pdev)
4618{
4619 e1000_suspend(pdev, PMSG_SUSPEND);
4620}
4621
4614#ifdef CONFIG_NET_POLL_CONTROLLER 4622#ifdef CONFIG_NET_POLL_CONTROLLER
4615/* 4623/*
4616 * Polling 'interrupt' - used by things like netconsole to send skbs 4624 * Polling 'interrupt' - used by things like netconsole to send skbs
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index f7235c9bc421..705e1229d89d 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -2891,78 +2891,6 @@ static int nv_open(struct net_device *dev)
2891 goto out_drain; 2891 goto out_drain;
2892 } 2892 }
2893 2893
2894 if (np->msi_flags & NV_MSI_X_CAPABLE) {
2895 for (i = 0; i < (np->msi_flags & NV_MSI_X_VECTORS_MASK); i++) {
2896 np->msi_x_entry[i].entry = i;
2897 }
2898 if ((ret = pci_enable_msix(np->pci_dev, np->msi_x_entry, (np->msi_flags & NV_MSI_X_VECTORS_MASK))) == 0) {
2899 np->msi_flags |= NV_MSI_X_ENABLED;
2900 if (optimization_mode == NV_OPTIMIZATION_MODE_THROUGHPUT) {
2901 /* Request irq for rx handling */
2902 if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector, &nv_nic_irq_rx, SA_SHIRQ, dev->name, dev) != 0) {
2903 printk(KERN_INFO "forcedeth: request_irq failed for rx %d\n", ret);
2904 pci_disable_msix(np->pci_dev);
2905 np->msi_flags &= ~NV_MSI_X_ENABLED;
2906 goto out_drain;
2907 }
2908 /* Request irq for tx handling */
2909 if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector, &nv_nic_irq_tx, SA_SHIRQ, dev->name, dev) != 0) {
2910 printk(KERN_INFO "forcedeth: request_irq failed for tx %d\n", ret);
2911 pci_disable_msix(np->pci_dev);
2912 np->msi_flags &= ~NV_MSI_X_ENABLED;
2913 goto out_drain;
2914 }
2915 /* Request irq for link and timer handling */
2916 if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector, &nv_nic_irq_other, SA_SHIRQ, dev->name, dev) != 0) {
2917 printk(KERN_INFO "forcedeth: request_irq failed for link %d\n", ret);
2918 pci_disable_msix(np->pci_dev);
2919 np->msi_flags &= ~NV_MSI_X_ENABLED;
2920 goto out_drain;
2921 }
2922
2923 /* map interrupts to their respective vector */
2924 writel(0, base + NvRegMSIXMap0);
2925 writel(0, base + NvRegMSIXMap1);
2926 set_msix_vector_map(dev, NV_MSI_X_VECTOR_RX, NVREG_IRQ_RX_ALL);
2927 set_msix_vector_map(dev, NV_MSI_X_VECTOR_TX, NVREG_IRQ_TX_ALL);
2928 set_msix_vector_map(dev, NV_MSI_X_VECTOR_OTHER, NVREG_IRQ_OTHER);
2929 } else {
2930 /* Request irq for all interrupts */
2931 if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector, &nv_nic_irq, SA_SHIRQ, dev->name, dev) != 0) {
2932 printk(KERN_INFO "forcedeth: request_irq failed %d\n", ret);
2933 pci_disable_msix(np->pci_dev);
2934 np->msi_flags &= ~NV_MSI_X_ENABLED;
2935 goto out_drain;
2936 }
2937
2938 /* map interrupts to vector 0 */
2939 writel(0, base + NvRegMSIXMap0);
2940 writel(0, base + NvRegMSIXMap1);
2941 }
2942 }
2943 }
2944 if (ret != 0 && np->msi_flags & NV_MSI_CAPABLE) {
2945 if ((ret = pci_enable_msi(np->pci_dev)) == 0) {
2946 np->msi_flags |= NV_MSI_ENABLED;
2947 if (request_irq(np->pci_dev->irq, &nv_nic_irq, SA_SHIRQ, dev->name, dev) != 0) {
2948 printk(KERN_INFO "forcedeth: request_irq failed %d\n", ret);
2949 pci_disable_msi(np->pci_dev);
2950 np->msi_flags &= ~NV_MSI_ENABLED;
2951 goto out_drain;
2952 }
2953
2954 /* map interrupts to vector 0 */
2955 writel(0, base + NvRegMSIMap0);
2956 writel(0, base + NvRegMSIMap1);
2957 /* enable msi vector 0 */
2958 writel(NVREG_MSI_VECTOR_0_ENABLED, base + NvRegMSIIrqMask);
2959 }
2960 }
2961 if (ret != 0) {
2962 if (request_irq(np->pci_dev->irq, &nv_nic_irq, SA_SHIRQ, dev->name, dev) != 0)
2963 goto out_drain;
2964 }
2965
2966 /* ask for interrupts */ 2894 /* ask for interrupts */
2967 nv_enable_hw_interrupts(dev, np->irqmask); 2895 nv_enable_hw_interrupts(dev, np->irqmask);
2968 2896
diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig
index 5e6d00752990..cff8598aa800 100644
--- a/drivers/net/irda/Kconfig
+++ b/drivers/net/irda/Kconfig
@@ -33,7 +33,7 @@ config DONGLE
33 33
34config ESI_DONGLE 34config ESI_DONGLE
35 tristate "ESI JetEye PC dongle" 35 tristate "ESI JetEye PC dongle"
36 depends on DONGLE && IRDA 36 depends on IRTTY_SIR && DONGLE && IRDA
37 help 37 help
38 Say Y here if you want to build support for the Extended Systems 38 Say Y here if you want to build support for the Extended Systems
39 JetEye PC dongle. To compile it as a module, choose M here. The ESI 39 JetEye PC dongle. To compile it as a module, choose M here. The ESI
@@ -44,7 +44,7 @@ config ESI_DONGLE
44 44
45config ACTISYS_DONGLE 45config ACTISYS_DONGLE
46 tristate "ACTiSYS IR-220L and IR220L+ dongle" 46 tristate "ACTiSYS IR-220L and IR220L+ dongle"
47 depends on DONGLE && IRDA 47 depends on IRTTY_SIR && DONGLE && IRDA
48 help 48 help
49 Say Y here if you want to build support for the ACTiSYS IR-220L and 49 Say Y here if you want to build support for the ACTiSYS IR-220L and
50 IR220L+ dongles. To compile it as a module, choose M here. The 50 IR220L+ dongles. To compile it as a module, choose M here. The
@@ -55,7 +55,7 @@ config ACTISYS_DONGLE
55 55
56config TEKRAM_DONGLE 56config TEKRAM_DONGLE
57 tristate "Tekram IrMate 210B dongle" 57 tristate "Tekram IrMate 210B dongle"
58 depends on DONGLE && IRDA 58 depends on IRTTY_SIR && DONGLE && IRDA
59 help 59 help
60 Say Y here if you want to build support for the Tekram IrMate 210B 60 Say Y here if you want to build support for the Tekram IrMate 210B
61 dongle. To compile it as a module, choose M here. The Tekram dongle 61 dongle. To compile it as a module, choose M here. The Tekram dongle
@@ -66,7 +66,7 @@ config TEKRAM_DONGLE
66 66
67config TOIM3232_DONGLE 67config TOIM3232_DONGLE
68 tristate "TOIM3232 IrDa dongle" 68 tristate "TOIM3232 IrDa dongle"
69 depends on DONGLE && IRDA 69 depends on IRTTY_SIR && DONGLE && IRDA
70 help 70 help
71 Say Y here if you want to build support for the Vishay/Temic 71 Say Y here if you want to build support for the Vishay/Temic
72 TOIM3232 and TOIM4232 based dongles. 72 TOIM3232 and TOIM4232 based dongles.
@@ -74,7 +74,7 @@ config TOIM3232_DONGLE
74 74
75config LITELINK_DONGLE 75config LITELINK_DONGLE
76 tristate "Parallax LiteLink dongle" 76 tristate "Parallax LiteLink dongle"
77 depends on DONGLE && IRDA 77 depends on IRTTY_SIR && DONGLE && IRDA
78 help 78 help
79 Say Y here if you want to build support for the Parallax Litelink 79 Say Y here if you want to build support for the Parallax Litelink
80 dongle. To compile it as a module, choose M here. The Parallax 80 dongle. To compile it as a module, choose M here. The Parallax
@@ -85,7 +85,7 @@ config LITELINK_DONGLE
85 85
86config MA600_DONGLE 86config MA600_DONGLE
87 tristate "Mobile Action MA600 dongle" 87 tristate "Mobile Action MA600 dongle"
88 depends on DONGLE && IRDA && EXPERIMENTAL 88 depends on IRTTY_SIR && DONGLE && IRDA && EXPERIMENTAL
89 help 89 help
90 Say Y here if you want to build support for the Mobile Action MA600 90 Say Y here if you want to build support for the Mobile Action MA600
91 dongle. To compile it as a module, choose M here. The MA600 dongle 91 dongle. To compile it as a module, choose M here. The MA600 dongle
@@ -98,7 +98,7 @@ config MA600_DONGLE
98 98
99config GIRBIL_DONGLE 99config GIRBIL_DONGLE
100 tristate "Greenwich GIrBIL dongle" 100 tristate "Greenwich GIrBIL dongle"
101 depends on DONGLE && IRDA && EXPERIMENTAL 101 depends on IRTTY_SIR && DONGLE && IRDA && EXPERIMENTAL
102 help 102 help
103 Say Y here if you want to build support for the Greenwich GIrBIL 103 Say Y here if you want to build support for the Greenwich GIrBIL
104 dongle. If you want to compile it as a module, choose M here. 104 dongle. If you want to compile it as a module, choose M here.
@@ -109,7 +109,7 @@ config GIRBIL_DONGLE
109 109
110config MCP2120_DONGLE 110config MCP2120_DONGLE
111 tristate "Microchip MCP2120" 111 tristate "Microchip MCP2120"
112 depends on DONGLE && IRDA && EXPERIMENTAL 112 depends on IRTTY_SIR && DONGLE && IRDA && EXPERIMENTAL
113 help 113 help
114 Say Y here if you want to build support for the Microchip MCP2120 114 Say Y here if you want to build support for the Microchip MCP2120
115 dongle. If you want to compile it as a module, choose M here. 115 dongle. If you want to compile it as a module, choose M here.
@@ -123,7 +123,7 @@ config MCP2120_DONGLE
123 123
124config OLD_BELKIN_DONGLE 124config OLD_BELKIN_DONGLE
125 tristate "Old Belkin dongle" 125 tristate "Old Belkin dongle"
126 depends on DONGLE && IRDA && EXPERIMENTAL 126 depends on IRTTY_SIR && DONGLE && IRDA && EXPERIMENTAL
127 help 127 help
128 Say Y here if you want to build support for the Adaptec Airport 1000 128 Say Y here if you want to build support for the Adaptec Airport 1000
129 and 2000 dongles. If you want to compile it as a module, choose 129 and 2000 dongles. If you want to compile it as a module, choose
@@ -132,7 +132,7 @@ config OLD_BELKIN_DONGLE
132 132
133config ACT200L_DONGLE 133config ACT200L_DONGLE
134 tristate "ACTiSYS IR-200L dongle" 134 tristate "ACTiSYS IR-200L dongle"
135 depends on DONGLE && IRDA && EXPERIMENTAL 135 depends on IRTTY_SIR && DONGLE && IRDA && EXPERIMENTAL
136 help 136 help
137 Say Y here if you want to build support for the ACTiSYS IR-200L 137 Say Y here if you want to build support for the ACTiSYS IR-200L
138 dongle. If you want to compile it as a module, choose M here. 138 dongle. If you want to compile it as a module, choose M here.
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 448a09488529..2ea66aca648b 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -1691,17 +1691,6 @@ static void do_set_multicast_list(struct net_device *dev)
1691 memset(ei_local->mcfilter, 0xFF, 8); 1691 memset(ei_local->mcfilter, 0xFF, 8);
1692 } 1692 }
1693 1693
1694 /*
1695 * DP8390 manuals don't specify any magic sequence for altering
1696 * the multicast regs on an already running card. To be safe, we
1697 * ensure multicast mode is off prior to loading up the new hash
1698 * table. If this proves to be not enough, we can always resort
1699 * to stopping the NIC, loading the table and then restarting.
1700 */
1701
1702 if (netif_running(dev))
1703 outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR);
1704
1705 outb_p(E8390_NODMA + E8390_PAGE1, e8390_base + E8390_CMD); 1694 outb_p(E8390_NODMA + E8390_PAGE1, e8390_base + E8390_CMD);
1706 for(i = 0; i < 8; i++) 1695 for(i = 0; i < 8; i++)
1707 { 1696 {
@@ -1715,6 +1704,8 @@ static void do_set_multicast_list(struct net_device *dev)
1715 outb_p(E8390_RXCONFIG | 0x48, e8390_base + EN0_RXCR); 1704 outb_p(E8390_RXCONFIG | 0x48, e8390_base + EN0_RXCR);
1716 else 1705 else
1717 outb_p(E8390_RXCONFIG | 0x40, e8390_base + EN0_RXCR); 1706 outb_p(E8390_RXCONFIG | 0x40, e8390_base + EN0_RXCR);
1707
1708 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, e8390_base+E8390_CMD);
1718} 1709}
1719 1710
1720/* 1711/*
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index 07c31f19c6ba..fc08c4af506c 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -1774,8 +1774,6 @@ static int pcnet32_open(struct net_device *dev)
1774 lp->rx_dma_addr[i] = 0; 1774 lp->rx_dma_addr[i] = 0;
1775 } 1775 }
1776 1776
1777 pcnet32_free_ring(dev);
1778
1779 /* 1777 /*
1780 * Switch back to 16bit mode to avoid problems with dumb 1778 * Switch back to 16bit mode to avoid problems with dumb
1781 * DOS packet driver after a warm reboot 1779 * DOS packet driver after a warm reboot
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index a70c2b0cc104..5ca5a1b546a1 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -78,8 +78,7 @@ static const struct pci_device_id skge_id_table[] = {
78 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_GE) }, 78 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_GE) },
79 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_YU) }, 79 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_YU) },
80 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DLINK_DGE510T), }, 80 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DLINK_DGE510T), },
81 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) }, 81 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b01) }, /* DGE-530T */
82 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b01) },
83 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4320) }, 82 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4320) },
84 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5005) }, /* Belkin */ 83 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5005) }, /* Belkin */
85 { PCI_DEVICE(PCI_VENDOR_ID_CNET, PCI_DEVICE_ID_CNET_GIGACARD) }, 84 { PCI_DEVICE(PCI_VENDOR_ID_CNET, PCI_DEVICE_ID_CNET_GIGACARD) },
@@ -402,7 +401,7 @@ static int skge_set_ring_param(struct net_device *dev,
402 int err; 401 int err;
403 402
404 if (p->rx_pending == 0 || p->rx_pending > MAX_RX_RING_SIZE || 403 if (p->rx_pending == 0 || p->rx_pending > MAX_RX_RING_SIZE ||
405 p->tx_pending == 0 || p->tx_pending > MAX_TX_RING_SIZE) 404 p->tx_pending < MAX_SKB_FRAGS+1 || p->tx_pending > MAX_TX_RING_SIZE)
406 return -EINVAL; 405 return -EINVAL;
407 406
408 skge->rx_ring.count = p->rx_pending; 407 skge->rx_ring.count = p->rx_pending;
@@ -2717,8 +2716,7 @@ static int skge_poll(struct net_device *dev, int *budget)
2717 if (control & BMU_OWN) 2716 if (control & BMU_OWN)
2718 break; 2717 break;
2719 2718
2720 skb = skge_rx_get(skge, e, control, rd->status, 2719 skb = skge_rx_get(skge, e, control, rd->status, rd->csum2);
2721 le16_to_cpu(rd->csum2));
2722 if (likely(skb)) { 2720 if (likely(skb)) {
2723 dev->last_rx = jiffies; 2721 dev->last_rx = jiffies;
2724 netif_receive_skb(skb); 2722 netif_receive_skb(skb);
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 62be6d99d05c..959109609d85 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -51,7 +51,7 @@
51#include "sky2.h" 51#include "sky2.h"
52 52
53#define DRV_NAME "sky2" 53#define DRV_NAME "sky2"
54#define DRV_VERSION "1.3" 54#define DRV_VERSION "1.4"
55#define PFX DRV_NAME " " 55#define PFX DRV_NAME " "
56 56
57/* 57/*
@@ -105,6 +105,7 @@ MODULE_PARM_DESC(idle_timeout, "Idle timeout workaround for lost interrupts (ms)
105static const struct pci_device_id sky2_id_table[] = { 105static const struct pci_device_id sky2_id_table[] = {
106 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, 106 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) },
107 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, 107 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) },
108 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) }, /* DGE-560T */
108 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) }, 109 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) },
109 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) }, 110 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) },
110 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) }, 111 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) },
@@ -235,6 +236,7 @@ static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state)
235 } 236 }
236 237
237 if (hw->chip_id == CHIP_ID_YUKON_EC_U) { 238 if (hw->chip_id == CHIP_ID_YUKON_EC_U) {
239 sky2_write16(hw, B0_CTST, Y2_HW_WOL_ON);
238 sky2_pci_write32(hw, PCI_DEV_REG3, 0); 240 sky2_pci_write32(hw, PCI_DEV_REG3, 0);
239 reg1 = sky2_pci_read32(hw, PCI_DEV_REG4); 241 reg1 = sky2_pci_read32(hw, PCI_DEV_REG4);
240 reg1 &= P_ASPM_CONTROL_MSK; 242 reg1 &= P_ASPM_CONTROL_MSK;
@@ -306,7 +308,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
306 u16 ctrl, ct1000, adv, pg, ledctrl, ledover; 308 u16 ctrl, ct1000, adv, pg, ledctrl, ledover;
307 309
308 if (sky2->autoneg == AUTONEG_ENABLE && 310 if (sky2->autoneg == AUTONEG_ENABLE &&
309 (hw->chip_id != CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U)) { 311 !(hw->chip_id == CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U)) {
310 u16 ectrl = gm_phy_read(hw, port, PHY_MARV_EXT_CTRL); 312 u16 ectrl = gm_phy_read(hw, port, PHY_MARV_EXT_CTRL);
311 313
312 ectrl &= ~(PHY_M_EC_M_DSC_MSK | PHY_M_EC_S_DSC_MSK | 314 ectrl &= ~(PHY_M_EC_M_DSC_MSK | PHY_M_EC_S_DSC_MSK |
@@ -977,6 +979,7 @@ static int sky2_rx_start(struct sky2_port *sky2)
977 struct sky2_hw *hw = sky2->hw; 979 struct sky2_hw *hw = sky2->hw;
978 unsigned rxq = rxqaddr[sky2->port]; 980 unsigned rxq = rxqaddr[sky2->port];
979 int i; 981 int i;
982 unsigned thresh;
980 983
981 sky2->rx_put = sky2->rx_next = 0; 984 sky2->rx_put = sky2->rx_next = 0;
982 sky2_qset(hw, rxq); 985 sky2_qset(hw, rxq);
@@ -1001,9 +1004,21 @@ static int sky2_rx_start(struct sky2_port *sky2)
1001 sky2_rx_add(sky2, re->mapaddr); 1004 sky2_rx_add(sky2, re->mapaddr);
1002 } 1005 }
1003 1006
1004 /* Truncate oversize frames */ 1007
1005 sky2_write16(hw, SK_REG(sky2->port, RX_GMF_TR_THR), sky2->rx_bufsize - 8); 1008 /*
1006 sky2_write32(hw, SK_REG(sky2->port, RX_GMF_CTRL_T), RX_TRUNC_ON); 1009 * The receiver hangs if it receives frames larger than the
1010 * packet buffer. As a workaround, truncate oversize frames, but
1011 * the register is limited to 9 bits, so if you do frames > 2052
1012 * you better get the MTU right!
1013 */
1014 thresh = (sky2->rx_bufsize - 8) / sizeof(u32);
1015 if (thresh > 0x1ff)
1016 sky2_write32(hw, SK_REG(sky2->port, RX_GMF_CTRL_T), RX_TRUNC_OFF);
1017 else {
1018 sky2_write16(hw, SK_REG(sky2->port, RX_GMF_TR_THR), thresh);
1019 sky2_write32(hw, SK_REG(sky2->port, RX_GMF_CTRL_T), RX_TRUNC_ON);
1020 }
1021
1007 1022
1008 /* Tell chip about available buffers */ 1023 /* Tell chip about available buffers */
1009 sky2_write16(hw, Y2_QADDR(rxq, PREF_UNIT_PUT_IDX), sky2->rx_put); 1024 sky2_write16(hw, Y2_QADDR(rxq, PREF_UNIT_PUT_IDX), sky2->rx_put);
@@ -1020,19 +1035,26 @@ static int sky2_up(struct net_device *dev)
1020 struct sky2_hw *hw = sky2->hw; 1035 struct sky2_hw *hw = sky2->hw;
1021 unsigned port = sky2->port; 1036 unsigned port = sky2->port;
1022 u32 ramsize, rxspace, imask; 1037 u32 ramsize, rxspace, imask;
1023 int err; 1038 int cap, err = -ENOMEM;
1024 struct net_device *otherdev = hw->dev[sky2->port^1]; 1039 struct net_device *otherdev = hw->dev[sky2->port^1];
1025 1040
1026 /* Block bringing up both ports at the same time on a dual port card. 1041 /*
1027 * There is an unfixed bug where receiver gets confused and picks up 1042 * On dual port PCI-X card, there is an problem where status
1028 * packets out of order. Until this is fixed, prevent data corruption. 1043 * can be received out of order due to split transactions
1029 */ 1044 */
1030 if (otherdev && netif_running(otherdev)) { 1045 if (otherdev && netif_running(otherdev) &&
1031 printk(KERN_INFO PFX "dual port support is disabled.\n"); 1046 (cap = pci_find_capability(hw->pdev, PCI_CAP_ID_PCIX))) {
1032 return -EBUSY; 1047 struct sky2_port *osky2 = netdev_priv(otherdev);
1033 } 1048 u16 cmd;
1049
1050 cmd = sky2_pci_read16(hw, cap + PCI_X_CMD);
1051 cmd &= ~PCI_X_CMD_MAX_SPLIT;
1052 sky2_pci_write16(hw, cap + PCI_X_CMD, cmd);
1053
1054 sky2->rx_csum = 0;
1055 osky2->rx_csum = 0;
1056 }
1034 1057
1035 err = -ENOMEM;
1036 if (netif_msg_ifup(sky2)) 1058 if (netif_msg_ifup(sky2))
1037 printk(KERN_INFO PFX "%s: enabling interface\n", dev->name); 1059 printk(KERN_INFO PFX "%s: enabling interface\n", dev->name);
1038 1060
@@ -1910,6 +1932,12 @@ static inline void sky2_tx_done(struct net_device *dev, u16 last)
1910 } 1932 }
1911} 1933}
1912 1934
1935/* Is status ring empty or is there more to do? */
1936static inline int sky2_more_work(const struct sky2_hw *hw)
1937{
1938 return (hw->st_idx != sky2_read16(hw, STAT_PUT_IDX));
1939}
1940
1913/* Process status response ring */ 1941/* Process status response ring */
1914static int sky2_status_intr(struct sky2_hw *hw, int to_do) 1942static int sky2_status_intr(struct sky2_hw *hw, int to_do)
1915{ 1943{
@@ -2182,19 +2210,19 @@ static int sky2_poll(struct net_device *dev0, int *budget)
2182 if (status & Y2_IS_CHK_TXA2) 2210 if (status & Y2_IS_CHK_TXA2)
2183 sky2_descriptor_error(hw, 1, "transmit", Y2_IS_CHK_TXA2); 2211 sky2_descriptor_error(hw, 1, "transmit", Y2_IS_CHK_TXA2);
2184 2212
2185 if (status & Y2_IS_STAT_BMU)
2186 sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
2187
2188 work_done = sky2_status_intr(hw, work_limit); 2213 work_done = sky2_status_intr(hw, work_limit);
2189 *budget -= work_done; 2214 *budget -= work_done;
2190 dev0->quota -= work_done; 2215 dev0->quota -= work_done;
2191 2216
2192 if (work_done >= work_limit) 2217 if (status & Y2_IS_STAT_BMU)
2218 sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
2219
2220 if (sky2_more_work(hw))
2193 return 1; 2221 return 1;
2194 2222
2195 netif_rx_complete(dev0); 2223 netif_rx_complete(dev0);
2196 2224
2197 status = sky2_read32(hw, B0_Y2_SP_LISR); 2225 sky2_read32(hw, B0_Y2_SP_LISR);
2198 return 0; 2226 return 0;
2199} 2227}
2200 2228
@@ -3078,12 +3106,7 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
3078 sky2->duplex = -1; 3106 sky2->duplex = -1;
3079 sky2->speed = -1; 3107 sky2->speed = -1;
3080 sky2->advertising = sky2_supported_modes(hw); 3108 sky2->advertising = sky2_supported_modes(hw);
3081 3109 sky2->rx_csum = 1;
3082 /* Receive checksum disabled for Yukon XL
3083 * because of observed problems with incorrect
3084 * values when multiple packets are received in one interrupt
3085 */
3086 sky2->rx_csum = (hw->chip_id != CHIP_ID_YUKON_XL);
3087 3110
3088 spin_lock_init(&sky2->phy_lock); 3111 spin_lock_init(&sky2->phy_lock);
3089 sky2->tx_pending = TX_DEF_PENDING; 3112 sky2->tx_pending = TX_DEF_PENDING;
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index 8012994c9b93..8a0bc5525f0a 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -214,6 +214,8 @@ enum csr_regs {
214enum { 214enum {
215 Y2_VMAIN_AVAIL = 1<<17,/* VMAIN available (YUKON-2 only) */ 215 Y2_VMAIN_AVAIL = 1<<17,/* VMAIN available (YUKON-2 only) */
216 Y2_VAUX_AVAIL = 1<<16,/* VAUX available (YUKON-2 only) */ 216 Y2_VAUX_AVAIL = 1<<16,/* VAUX available (YUKON-2 only) */
217 Y2_HW_WOL_ON = 1<<15,/* HW WOL On (Yukon-EC Ultra A1 only) */
218 Y2_HW_WOL_OFF = 1<<14,/* HW WOL On (Yukon-EC Ultra A1 only) */
217 Y2_ASF_ENABLE = 1<<13,/* ASF Unit Enable (YUKON-2 only) */ 219 Y2_ASF_ENABLE = 1<<13,/* ASF Unit Enable (YUKON-2 only) */
218 Y2_ASF_DISABLE = 1<<12,/* ASF Unit Disable (YUKON-2 only) */ 220 Y2_ASF_DISABLE = 1<<12,/* ASF Unit Disable (YUKON-2 only) */
219 Y2_CLK_RUN_ENA = 1<<11,/* CLK_RUN Enable (YUKON-2 only) */ 221 Y2_CLK_RUN_ENA = 1<<11,/* CLK_RUN Enable (YUKON-2 only) */
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index e1b33a25a25f..49ad60b72657 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -69,8 +69,8 @@
69 69
70#define DRV_MODULE_NAME "tg3" 70#define DRV_MODULE_NAME "tg3"
71#define PFX DRV_MODULE_NAME ": " 71#define PFX DRV_MODULE_NAME ": "
72#define DRV_MODULE_VERSION "3.57" 72#define DRV_MODULE_VERSION "3.58"
73#define DRV_MODULE_RELDATE "Apr 28, 2006" 73#define DRV_MODULE_RELDATE "May 22, 2006"
74 74
75#define TG3_DEF_MAC_MODE 0 75#define TG3_DEF_MAC_MODE 0
76#define TG3_DEF_RX_MODE 0 76#define TG3_DEF_RX_MODE 0
@@ -6488,6 +6488,10 @@ static void tg3_periodic_fetch_stats(struct tg3 *tp)
6488 TG3_STAT_ADD32(&sp->rx_frame_too_long_errors, MAC_RX_STATS_FRAME_TOO_LONG); 6488 TG3_STAT_ADD32(&sp->rx_frame_too_long_errors, MAC_RX_STATS_FRAME_TOO_LONG);
6489 TG3_STAT_ADD32(&sp->rx_jabbers, MAC_RX_STATS_JABBERS); 6489 TG3_STAT_ADD32(&sp->rx_jabbers, MAC_RX_STATS_JABBERS);
6490 TG3_STAT_ADD32(&sp->rx_undersize_packets, MAC_RX_STATS_UNDERSIZE); 6490 TG3_STAT_ADD32(&sp->rx_undersize_packets, MAC_RX_STATS_UNDERSIZE);
6491
6492 TG3_STAT_ADD32(&sp->rxbds_empty, RCVLPC_NO_RCV_BD_CNT);
6493 TG3_STAT_ADD32(&sp->rx_discards, RCVLPC_IN_DISCARDS_CNT);
6494 TG3_STAT_ADD32(&sp->rx_errors, RCVLPC_IN_ERRORS_CNT);
6491} 6495}
6492 6496
6493static void tg3_timer(unsigned long __opaque) 6497static void tg3_timer(unsigned long __opaque)
diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
index ba05dedf29d3..136a70c4d5e4 100644
--- a/drivers/net/tulip/winbond-840.c
+++ b/drivers/net/tulip/winbond-840.c
@@ -850,7 +850,7 @@ static void init_rxtx_rings(struct net_device *dev)
850 break; 850 break;
851 skb->dev = dev; /* Mark as being used by this device. */ 851 skb->dev = dev; /* Mark as being used by this device. */
852 np->rx_addr[i] = pci_map_single(np->pci_dev,skb->data, 852 np->rx_addr[i] = pci_map_single(np->pci_dev,skb->data,
853 skb->len,PCI_DMA_FROMDEVICE); 853 np->rx_buf_sz,PCI_DMA_FROMDEVICE);
854 854
855 np->rx_ring[i].buffer1 = np->rx_addr[i]; 855 np->rx_ring[i].buffer1 = np->rx_addr[i];
856 np->rx_ring[i].status = DescOwn; 856 np->rx_ring[i].status = DescOwn;
@@ -1316,7 +1316,7 @@ static int netdev_rx(struct net_device *dev)
1316 skb->dev = dev; /* Mark as being used by this device. */ 1316 skb->dev = dev; /* Mark as being used by this device. */
1317 np->rx_addr[entry] = pci_map_single(np->pci_dev, 1317 np->rx_addr[entry] = pci_map_single(np->pci_dev,
1318 skb->data, 1318 skb->data,
1319 skb->len, PCI_DMA_FROMDEVICE); 1319 np->rx_buf_sz, PCI_DMA_FROMDEVICE);
1320 np->rx_ring[entry].buffer1 = np->rx_addr[entry]; 1320 np->rx_ring[entry].buffer1 = np->rx_addr[entry];
1321 } 1321 }
1322 wmb(); 1322 wmb();
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
index a6dc53b4250d..fdc21037f6dc 100644
--- a/drivers/net/via-rhine.c
+++ b/drivers/net/via-rhine.c
@@ -491,8 +491,6 @@ struct rhine_private {
491 u8 tx_thresh, rx_thresh; 491 u8 tx_thresh, rx_thresh;
492 492
493 struct mii_if_info mii_if; 493 struct mii_if_info mii_if;
494 struct work_struct tx_timeout_task;
495 struct work_struct check_media_task;
496 void __iomem *base; 494 void __iomem *base;
497}; 495};
498 496
@@ -500,8 +498,6 @@ static int mdio_read(struct net_device *dev, int phy_id, int location);
500static void mdio_write(struct net_device *dev, int phy_id, int location, int value); 498static void mdio_write(struct net_device *dev, int phy_id, int location, int value);
501static int rhine_open(struct net_device *dev); 499static int rhine_open(struct net_device *dev);
502static void rhine_tx_timeout(struct net_device *dev); 500static void rhine_tx_timeout(struct net_device *dev);
503static void rhine_tx_timeout_task(struct net_device *dev);
504static void rhine_check_media_task(struct net_device *dev);
505static int rhine_start_tx(struct sk_buff *skb, struct net_device *dev); 501static int rhine_start_tx(struct sk_buff *skb, struct net_device *dev);
506static irqreturn_t rhine_interrupt(int irq, void *dev_instance, struct pt_regs *regs); 502static irqreturn_t rhine_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
507static void rhine_tx(struct net_device *dev); 503static void rhine_tx(struct net_device *dev);
@@ -856,12 +852,6 @@ static int __devinit rhine_init_one(struct pci_dev *pdev,
856 if (rp->quirks & rqRhineI) 852 if (rp->quirks & rqRhineI)
857 dev->features |= NETIF_F_SG|NETIF_F_HW_CSUM; 853 dev->features |= NETIF_F_SG|NETIF_F_HW_CSUM;
858 854
859 INIT_WORK(&rp->tx_timeout_task,
860 (void (*)(void *))rhine_tx_timeout_task, dev);
861
862 INIT_WORK(&rp->check_media_task,
863 (void (*)(void *))rhine_check_media_task, dev);
864
865 /* dev->name not defined before register_netdev()! */ 855 /* dev->name not defined before register_netdev()! */
866 rc = register_netdev(dev); 856 rc = register_netdev(dev);
867 if (rc) 857 if (rc)
@@ -1108,11 +1098,6 @@ static void rhine_set_carrier(struct mii_if_info *mii)
1108 netif_carrier_ok(mii->dev)); 1098 netif_carrier_ok(mii->dev));
1109} 1099}
1110 1100
1111static void rhine_check_media_task(struct net_device *dev)
1112{
1113 rhine_check_media(dev, 0);
1114}
1115
1116static void init_registers(struct net_device *dev) 1101static void init_registers(struct net_device *dev)
1117{ 1102{
1118 struct rhine_private *rp = netdev_priv(dev); 1103 struct rhine_private *rp = netdev_priv(dev);
@@ -1166,8 +1151,8 @@ static void rhine_disable_linkmon(void __iomem *ioaddr, u32 quirks)
1166 if (quirks & rqRhineI) { 1151 if (quirks & rqRhineI) {
1167 iowrite8(0x01, ioaddr + MIIRegAddr); // MII_BMSR 1152 iowrite8(0x01, ioaddr + MIIRegAddr); // MII_BMSR
1168 1153
1169 /* Do not call from ISR! */ 1154 /* Can be called from ISR. Evil. */
1170 msleep(1); 1155 mdelay(1);
1171 1156
1172 /* 0x80 must be set immediately before turning it off */ 1157 /* 0x80 must be set immediately before turning it off */
1173 iowrite8(0x80, ioaddr + MIICmd); 1158 iowrite8(0x80, ioaddr + MIICmd);
@@ -1257,16 +1242,6 @@ static int rhine_open(struct net_device *dev)
1257static void rhine_tx_timeout(struct net_device *dev) 1242static void rhine_tx_timeout(struct net_device *dev)
1258{ 1243{
1259 struct rhine_private *rp = netdev_priv(dev); 1244 struct rhine_private *rp = netdev_priv(dev);
1260
1261 /*
1262 * Move bulk of work outside of interrupt context
1263 */
1264 schedule_work(&rp->tx_timeout_task);
1265}
1266
1267static void rhine_tx_timeout_task(struct net_device *dev)
1268{
1269 struct rhine_private *rp = netdev_priv(dev);
1270 void __iomem *ioaddr = rp->base; 1245 void __iomem *ioaddr = rp->base;
1271 1246
1272 printk(KERN_WARNING "%s: Transmit timed out, status %4.4x, PHY status " 1247 printk(KERN_WARNING "%s: Transmit timed out, status %4.4x, PHY status "
@@ -1677,7 +1652,7 @@ static void rhine_error(struct net_device *dev, int intr_status)
1677 spin_lock(&rp->lock); 1652 spin_lock(&rp->lock);
1678 1653
1679 if (intr_status & IntrLinkChange) 1654 if (intr_status & IntrLinkChange)
1680 schedule_work(&rp->check_media_task); 1655 rhine_check_media(dev, 0);
1681 if (intr_status & IntrStatsMax) { 1656 if (intr_status & IntrStatsMax) {
1682 rp->stats.rx_crc_errors += ioread16(ioaddr + RxCRCErrs); 1657 rp->stats.rx_crc_errors += ioread16(ioaddr + RxCRCErrs);
1683 rp->stats.rx_missed_errors += ioread16(ioaddr + RxMissed); 1658 rp->stats.rx_missed_errors += ioread16(ioaddr + RxMissed);
@@ -1927,9 +1902,6 @@ static int rhine_close(struct net_device *dev)
1927 spin_unlock_irq(&rp->lock); 1902 spin_unlock_irq(&rp->lock);
1928 1903
1929 free_irq(rp->pdev->irq, dev); 1904 free_irq(rp->pdev->irq, dev);
1930
1931 flush_scheduled_work();
1932
1933 free_rbufs(dev); 1905 free_rbufs(dev);
1934 free_tbufs(dev); 1906 free_tbufs(dev);
1935 free_ring(dev); 1907 free_ring(dev);
diff --git a/drivers/net/wireless/arlan-main.c b/drivers/net/wireless/arlan-main.c
index 0e1ac338cac1..bed6823d9809 100644
--- a/drivers/net/wireless/arlan-main.c
+++ b/drivers/net/wireless/arlan-main.c
@@ -1838,7 +1838,7 @@ struct net_device * __init arlan_probe(int unit)
1838} 1838}
1839 1839
1840#ifdef MODULE 1840#ifdef MODULE
1841int init_module(void) 1841int __init init_module(void)
1842{ 1842{
1843 int i = 0; 1843 int i = 0;
1844 1844
@@ -1860,7 +1860,7 @@ int init_module(void)
1860} 1860}
1861 1861
1862 1862
1863void cleanup_module(void) 1863void __exit cleanup_module(void)
1864{ 1864{
1865 int i = 0; 1865 int i = 0;
1866 struct net_device *dev; 1866 struct net_device *dev;
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index e2982a83ae42..7ed18cad29f7 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -3271,6 +3271,9 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm)
3271 bcm43xx_sysfs_register(bcm); 3271 bcm43xx_sysfs_register(bcm);
3272 //FIXME: check for bcm43xx_sysfs_register failure. This function is a bit messy regarding unwinding, though... 3272 //FIXME: check for bcm43xx_sysfs_register failure. This function is a bit messy regarding unwinding, though...
3273 3273
3274 /*FIXME: This should be handled by softmac instead. */
3275 schedule_work(&bcm->softmac->associnfo.work);
3276
3274 assert(err == 0); 3277 assert(err == 0);
3275out: 3278out:
3276 return err; 3279 return err;
@@ -3946,9 +3949,6 @@ static int bcm43xx_resume(struct pci_dev *pdev)
3946 3949
3947 netif_device_attach(net_dev); 3950 netif_device_attach(net_dev);
3948 3951
3949 /*FIXME: This should be handled by softmac instead. */
3950 schedule_work(&bcm->softmac->associnfo.work);
3951
3952 dprintk(KERN_INFO PFX "Device resumed.\n"); 3952 dprintk(KERN_INFO PFX "Device resumed.\n");
3953 3953
3954 return 0; 3954 return 0;
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index 06523e2a8471..c2d0b09e0418 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -812,7 +812,6 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
812 if (datalen > IEEE80211_DATA_LEN + 12) { 812 if (datalen > IEEE80211_DATA_LEN + 12) {
813 printk(KERN_DEBUG "%s: oversized monitor frame, " 813 printk(KERN_DEBUG "%s: oversized monitor frame, "
814 "data length = %d\n", dev->name, datalen); 814 "data length = %d\n", dev->name, datalen);
815 err = -EIO;
816 stats->rx_length_errors++; 815 stats->rx_length_errors++;
817 goto update_stats; 816 goto update_stats;
818 } 817 }
@@ -821,8 +820,7 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
821 if (!skb) { 820 if (!skb) {
822 printk(KERN_WARNING "%s: Cannot allocate skb for monitor frame\n", 821 printk(KERN_WARNING "%s: Cannot allocate skb for monitor frame\n",
823 dev->name); 822 dev->name);
824 err = -ENOMEM; 823 goto update_stats;
825 goto drop;
826 } 824 }
827 825
828 /* Copy the 802.11 header to the skb */ 826 /* Copy the 802.11 header to the skb */
diff --git a/drivers/net/wireless/wavelan.c b/drivers/net/wireless/wavelan.c
index ff192e96268a..dade4b903579 100644
--- a/drivers/net/wireless/wavelan.c
+++ b/drivers/net/wireless/wavelan.c
@@ -4306,7 +4306,7 @@ out:
4306 * Insertion of the module 4306 * Insertion of the module
4307 * I'm now quite proud of the multi-device support. 4307 * I'm now quite proud of the multi-device support.
4308 */ 4308 */
4309int init_module(void) 4309int __init init_module(void)
4310{ 4310{
4311 int ret = -EIO; /* Return error if no cards found */ 4311 int ret = -EIO; /* Return error if no cards found */
4312 int i; 4312 int i;
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 6917c6cb0912..c2ecae5ff0c1 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -33,13 +33,10 @@ acpi_query_osc (
33 acpi_status status; 33 acpi_status status;
34 struct acpi_object_list input; 34 struct acpi_object_list input;
35 union acpi_object in_params[4]; 35 union acpi_object in_params[4];
36 struct acpi_buffer output; 36 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
37 union acpi_object out_obj; 37 union acpi_object *out_obj;
38 u32 osc_dw0; 38 u32 osc_dw0;
39 39
40 /* Setting up output buffer */
41 output.length = sizeof(out_obj) + 3*sizeof(u32);
42 output.pointer = &out_obj;
43 40
44 /* Setting up input parameters */ 41 /* Setting up input parameters */
45 input.count = 4; 42 input.count = 4;
@@ -61,12 +58,15 @@ acpi_query_osc (
61 "Evaluate _OSC Set fails. Status = 0x%04x\n", status); 58 "Evaluate _OSC Set fails. Status = 0x%04x\n", status);
62 return status; 59 return status;
63 } 60 }
64 if (out_obj.type != ACPI_TYPE_BUFFER) { 61 out_obj = output.pointer;
62
63 if (out_obj->type != ACPI_TYPE_BUFFER) {
65 printk(KERN_DEBUG 64 printk(KERN_DEBUG
66 "Evaluate _OSC returns wrong type\n"); 65 "Evaluate _OSC returns wrong type\n");
67 return AE_TYPE; 66 status = AE_TYPE;
67 goto query_osc_out;
68 } 68 }
69 osc_dw0 = *((u32 *) out_obj.buffer.pointer); 69 osc_dw0 = *((u32 *) out_obj->buffer.pointer);
70 if (osc_dw0) { 70 if (osc_dw0) {
71 if (osc_dw0 & OSC_REQUEST_ERROR) 71 if (osc_dw0 & OSC_REQUEST_ERROR)
72 printk(KERN_DEBUG "_OSC request fails\n"); 72 printk(KERN_DEBUG "_OSC request fails\n");
@@ -76,15 +76,21 @@ acpi_query_osc (
76 printk(KERN_DEBUG "_OSC invalid revision\n"); 76 printk(KERN_DEBUG "_OSC invalid revision\n");
77 if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) { 77 if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) {
78 /* Update Global Control Set */ 78 /* Update Global Control Set */
79 global_ctrlsets = *((u32 *)(out_obj.buffer.pointer+8)); 79 global_ctrlsets = *((u32 *)(out_obj->buffer.pointer+8));
80 return AE_OK; 80 status = AE_OK;
81 goto query_osc_out;
81 } 82 }
82 return AE_ERROR; 83 status = AE_ERROR;
84 goto query_osc_out;
83 } 85 }
84 86
85 /* Update Global Control Set */ 87 /* Update Global Control Set */
86 global_ctrlsets = *((u32 *)(out_obj.buffer.pointer + 8)); 88 global_ctrlsets = *((u32 *)(out_obj->buffer.pointer + 8));
87 return AE_OK; 89 status = AE_OK;
90
91query_osc_out:
92 kfree(output.pointer);
93 return status;
88} 94}
89 95
90 96
@@ -96,14 +102,10 @@ acpi_run_osc (
96 acpi_status status; 102 acpi_status status;
97 struct acpi_object_list input; 103 struct acpi_object_list input;
98 union acpi_object in_params[4]; 104 union acpi_object in_params[4];
99 struct acpi_buffer output; 105 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
100 union acpi_object out_obj; 106 union acpi_object *out_obj;
101 u32 osc_dw0; 107 u32 osc_dw0;
102 108
103 /* Setting up output buffer */
104 output.length = sizeof(out_obj) + 3*sizeof(u32);
105 output.pointer = &out_obj;
106
107 /* Setting up input parameters */ 109 /* Setting up input parameters */
108 input.count = 4; 110 input.count = 4;
109 input.pointer = in_params; 111 input.pointer = in_params;
@@ -124,12 +126,14 @@ acpi_run_osc (
124 "Evaluate _OSC Set fails. Status = 0x%04x\n", status); 126 "Evaluate _OSC Set fails. Status = 0x%04x\n", status);
125 return status; 127 return status;
126 } 128 }
127 if (out_obj.type != ACPI_TYPE_BUFFER) { 129 out_obj = output.pointer;
130 if (out_obj->type != ACPI_TYPE_BUFFER) {
128 printk(KERN_DEBUG 131 printk(KERN_DEBUG
129 "Evaluate _OSC returns wrong type\n"); 132 "Evaluate _OSC returns wrong type\n");
130 return AE_TYPE; 133 status = AE_TYPE;
134 goto run_osc_out;
131 } 135 }
132 osc_dw0 = *((u32 *) out_obj.buffer.pointer); 136 osc_dw0 = *((u32 *) out_obj->buffer.pointer);
133 if (osc_dw0) { 137 if (osc_dw0) {
134 if (osc_dw0 & OSC_REQUEST_ERROR) 138 if (osc_dw0 & OSC_REQUEST_ERROR)
135 printk(KERN_DEBUG "_OSC request fails\n"); 139 printk(KERN_DEBUG "_OSC request fails\n");
@@ -139,11 +143,17 @@ acpi_run_osc (
139 printk(KERN_DEBUG "_OSC invalid revision\n"); 143 printk(KERN_DEBUG "_OSC invalid revision\n");
140 if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) { 144 if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) {
141 printk(KERN_DEBUG "_OSC FW not grant req. control\n"); 145 printk(KERN_DEBUG "_OSC FW not grant req. control\n");
142 return AE_SUPPORT; 146 status = AE_SUPPORT;
147 goto run_osc_out;
143 } 148 }
144 return AE_ERROR; 149 status = AE_ERROR;
150 goto run_osc_out;
145 } 151 }
146 return AE_OK; 152 status = AE_OK;
153
154run_osc_out:
155 kfree(output.pointer);
156 return status;
147} 157}
148 158
149/** 159/**
diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c
index 16d1ea7b0a18..247ab837f841 100644
--- a/drivers/pcmcia/pd6729.c
+++ b/drivers/pcmcia/pd6729.c
@@ -589,7 +589,7 @@ static int pd6729_check_irq(int irq, int flags)
589 return 0; 589 return 0;
590} 590}
591 591
592static u_int __init pd6729_isa_scan(void) 592static u_int __devinit pd6729_isa_scan(void)
593{ 593{
594 u_int mask0, mask = 0; 594 u_int mask0, mask = 0;
595 int i; 595 int i;
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index 6c9ad92747fd..2011567005f9 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -141,13 +141,13 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
141 /* try the driver's ioctl interface */ 141 /* try the driver's ioctl interface */
142 if (ops->ioctl) { 142 if (ops->ioctl) {
143 err = ops->ioctl(class_dev->dev, cmd, arg); 143 err = ops->ioctl(class_dev->dev, cmd, arg);
144 if (err != -EINVAL) 144 if (err != -ENOIOCTLCMD)
145 return err; 145 return err;
146 } 146 }
147 147
148 /* if the driver does not provide the ioctl interface 148 /* if the driver does not provide the ioctl interface
149 * or if that particular ioctl was not implemented 149 * or if that particular ioctl was not implemented
150 * (-EINVAL), we will try to emulate here. 150 * (-ENOIOCTLCMD), we will try to emulate here.
151 */ 151 */
152 152
153 switch (cmd) { 153 switch (cmd) {
@@ -233,7 +233,7 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
233 break; 233 break;
234 234
235 default: 235 default:
236 err = -EINVAL; 236 err = -ENOTTY;
237 break; 237 break;
238 } 238 }
239 239
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index 2bc8aad47219..a997529f8926 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -247,7 +247,7 @@ static int sa1100_rtc_ioctl(struct device *dev, unsigned int cmd,
247 rtc_freq = arg; 247 rtc_freq = arg;
248 return 0; 248 return 0;
249 } 249 }
250 return -EINVAL; 250 return -ENOIOCTLCMD;
251} 251}
252 252
253static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm) 253static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm)
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
index e1f7e8e86daf..e1fa5fe7901f 100644
--- a/drivers/rtc/rtc-test.c
+++ b/drivers/rtc/rtc-test.c
@@ -71,7 +71,7 @@ static int test_rtc_ioctl(struct device *dev, unsigned int cmd,
71 return 0; 71 return 0;
72 72
73 default: 73 default:
74 return -EINVAL; 74 return -ENOIOCTLCMD;
75 } 75 }
76} 76}
77 77
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c
index 4d49fd501198..277596c302e3 100644
--- a/drivers/rtc/rtc-vr41xx.c
+++ b/drivers/rtc/rtc-vr41xx.c
@@ -270,7 +270,7 @@ static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long
270 epoch = arg; 270 epoch = arg;
271 break; 271 break;
272 default: 272 default:
273 return -EINVAL; 273 return -ENOIOCTLCMD;
274 } 274 }
275 275
276 return 0; 276 return 0;
diff --git a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c
index af9f212314b3..fe986af884f8 100644
--- a/drivers/s390/net/ctcmain.c
+++ b/drivers/s390/net/ctcmain.c
@@ -1486,13 +1486,13 @@ ch_action_iofatal(fsm_instance * fi, int event, void *arg)
1486 } 1486 }
1487} 1487}
1488 1488
1489static void 1489static void
1490ch_action_reinit(fsm_instance *fi, int event, void *arg) 1490ch_action_reinit(fsm_instance *fi, int event, void *arg)
1491{ 1491{
1492 struct channel *ch = (struct channel *)arg; 1492 struct channel *ch = (struct channel *)arg;
1493 struct net_device *dev = ch->netdev; 1493 struct net_device *dev = ch->netdev;
1494 struct ctc_priv *privptr = dev->priv; 1494 struct ctc_priv *privptr = dev->priv;
1495 1495
1496 DBF_TEXT(trace, 4, __FUNCTION__); 1496 DBF_TEXT(trace, 4, __FUNCTION__);
1497 ch_action_iofatal(fi, event, arg); 1497 ch_action_iofatal(fi, event, arg);
1498 fsm_addtimer(&privptr->restart_timer, 1000, DEV_EVENT_RESTART, dev); 1498 fsm_addtimer(&privptr->restart_timer, 1000, DEV_EVENT_RESTART, dev);
@@ -1624,7 +1624,7 @@ less_than(char *id1, char *id2)
1624 } 1624 }
1625 dev1 = simple_strtoul(id1, &id1, 16); 1625 dev1 = simple_strtoul(id1, &id1, 16);
1626 dev2 = simple_strtoul(id2, &id2, 16); 1626 dev2 = simple_strtoul(id2, &id2, 16);
1627 1627
1628 return (dev1 < dev2); 1628 return (dev1 < dev2);
1629} 1629}
1630 1630
@@ -1895,7 +1895,7 @@ ctc_irq_handler(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
1895 irb->scsw.dstat); 1895 irb->scsw.dstat);
1896 return; 1896 return;
1897 } 1897 }
1898 1898
1899 priv = ((struct ccwgroup_device *)cdev->dev.driver_data) 1899 priv = ((struct ccwgroup_device *)cdev->dev.driver_data)
1900 ->dev.driver_data; 1900 ->dev.driver_data;
1901 1901
@@ -1909,7 +1909,7 @@ ctc_irq_handler(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
1909 "device %s\n", cdev->dev.bus_id); 1909 "device %s\n", cdev->dev.bus_id);
1910 return; 1910 return;
1911 } 1911 }
1912 1912
1913 dev = (struct net_device *) (ch->netdev); 1913 dev = (struct net_device *) (ch->netdev);
1914 if (dev == NULL) { 1914 if (dev == NULL) {
1915 ctc_pr_crit("ctc: ctc_irq_handler dev=NULL bus_id=%s, ch=0x%p\n", 1915 ctc_pr_crit("ctc: ctc_irq_handler dev=NULL bus_id=%s, ch=0x%p\n",
@@ -2008,12 +2008,12 @@ dev_action_stop(fsm_instance * fi, int event, void *arg)
2008 fsm_event(ch->fsm, CH_EVENT_STOP, ch); 2008 fsm_event(ch->fsm, CH_EVENT_STOP, ch);
2009 } 2009 }
2010} 2010}
2011static void 2011static void
2012dev_action_restart(fsm_instance *fi, int event, void *arg) 2012dev_action_restart(fsm_instance *fi, int event, void *arg)
2013{ 2013{
2014 struct net_device *dev = (struct net_device *)arg; 2014 struct net_device *dev = (struct net_device *)arg;
2015 struct ctc_priv *privptr = dev->priv; 2015 struct ctc_priv *privptr = dev->priv;
2016 2016
2017 DBF_TEXT(trace, 3, __FUNCTION__); 2017 DBF_TEXT(trace, 3, __FUNCTION__);
2018 ctc_pr_debug("%s: Restarting\n", dev->name); 2018 ctc_pr_debug("%s: Restarting\n", dev->name);
2019 dev_action_stop(fi, event, arg); 2019 dev_action_stop(fi, event, arg);
@@ -2193,7 +2193,7 @@ transmit_skb(struct channel *ch, struct sk_buff *skb)
2193 2193
2194 DBF_TEXT(trace, 5, __FUNCTION__); 2194 DBF_TEXT(trace, 5, __FUNCTION__);
2195 /* we need to acquire the lock for testing the state 2195 /* we need to acquire the lock for testing the state
2196 * otherwise we can have an IRQ changing the state to 2196 * otherwise we can have an IRQ changing the state to
2197 * TXIDLE after the test but before acquiring the lock. 2197 * TXIDLE after the test but before acquiring the lock.
2198 */ 2198 */
2199 spin_lock_irqsave(&ch->collect_lock, saveflags); 2199 spin_lock_irqsave(&ch->collect_lock, saveflags);
@@ -2393,7 +2393,7 @@ ctc_tx(struct sk_buff *skb, struct net_device * dev)
2393 2393
2394 /** 2394 /**
2395 * If channels are not running, try to restart them 2395 * If channels are not running, try to restart them
2396 * and throw away packet. 2396 * and throw away packet.
2397 */ 2397 */
2398 if (fsm_getstate(privptr->fsm) != DEV_STATE_RUNNING) { 2398 if (fsm_getstate(privptr->fsm) != DEV_STATE_RUNNING) {
2399 fsm_event(privptr->fsm, DEV_EVENT_START, dev); 2399 fsm_event(privptr->fsm, DEV_EVENT_START, dev);
@@ -2738,7 +2738,7 @@ ctc_remove_files(struct device *dev)
2738/** 2738/**
2739 * Add ctc specific attributes. 2739 * Add ctc specific attributes.
2740 * Add ctc private data. 2740 * Add ctc private data.
2741 * 2741 *
2742 * @param cgdev pointer to ccwgroup_device just added 2742 * @param cgdev pointer to ccwgroup_device just added
2743 * 2743 *
2744 * @returns 0 on success, !0 on failure. 2744 * @returns 0 on success, !0 on failure.
@@ -2869,7 +2869,7 @@ ctc_new_device(struct ccwgroup_device *cgdev)
2869 DBF_TEXT(setup, 3, buffer); 2869 DBF_TEXT(setup, 3, buffer);
2870 2870
2871 type = get_channel_type(&cgdev->cdev[0]->id); 2871 type = get_channel_type(&cgdev->cdev[0]->id);
2872 2872
2873 snprintf(read_id, CTC_ID_SIZE, "ch-%s", cgdev->cdev[0]->dev.bus_id); 2873 snprintf(read_id, CTC_ID_SIZE, "ch-%s", cgdev->cdev[0]->dev.bus_id);
2874 snprintf(write_id, CTC_ID_SIZE, "ch-%s", cgdev->cdev[1]->dev.bus_id); 2874 snprintf(write_id, CTC_ID_SIZE, "ch-%s", cgdev->cdev[1]->dev.bus_id);
2875 2875
@@ -2907,7 +2907,7 @@ ctc_new_device(struct ccwgroup_device *cgdev)
2907 channel_get(type, direction == READ ? read_id : write_id, 2907 channel_get(type, direction == READ ? read_id : write_id,
2908 direction); 2908 direction);
2909 if (privptr->channel[direction] == NULL) { 2909 if (privptr->channel[direction] == NULL) {
2910 if (direction == WRITE) 2910 if (direction == WRITE)
2911 channel_free(privptr->channel[READ]); 2911 channel_free(privptr->channel[READ]);
2912 2912
2913 ctc_free_netdevice(dev, 1); 2913 ctc_free_netdevice(dev, 1);
@@ -2955,7 +2955,7 @@ ctc_shutdown_device(struct ccwgroup_device *cgdev)
2955{ 2955{
2956 struct ctc_priv *priv; 2956 struct ctc_priv *priv;
2957 struct net_device *ndev; 2957 struct net_device *ndev;
2958 2958
2959 DBF_TEXT(setup, 3, __FUNCTION__); 2959 DBF_TEXT(setup, 3, __FUNCTION__);
2960 pr_debug("%s() called\n", __FUNCTION__); 2960 pr_debug("%s() called\n", __FUNCTION__);
2961 2961
diff --git a/drivers/s390/net/ctctty.c b/drivers/s390/net/ctctty.c
index 5cdcdbf92962..af54d1de07bf 100644
--- a/drivers/s390/net/ctctty.c
+++ b/drivers/s390/net/ctctty.c
@@ -130,7 +130,7 @@ ctc_tty_readmodem(ctc_tty_info *info)
130 if ((tty = info->tty)) { 130 if ((tty = info->tty)) {
131 if (info->mcr & UART_MCR_RTS) { 131 if (info->mcr & UART_MCR_RTS) {
132 struct sk_buff *skb; 132 struct sk_buff *skb;
133 133
134 if ((skb = skb_dequeue(&info->rx_queue))) { 134 if ((skb = skb_dequeue(&info->rx_queue))) {
135 int len = skb->len; 135 int len = skb->len;
136 tty_insert_flip_string(tty, skb->data, len); 136 tty_insert_flip_string(tty, skb->data, len);
@@ -328,7 +328,7 @@ ctc_tty_inject(ctc_tty_info *info, char c)
328{ 328{
329 int skb_res; 329 int skb_res;
330 struct sk_buff *skb; 330 struct sk_buff *skb;
331 331
332 DBF_TEXT(trace, 4, __FUNCTION__); 332 DBF_TEXT(trace, 4, __FUNCTION__);
333 if (ctc_tty_shuttingdown) 333 if (ctc_tty_shuttingdown)
334 return; 334 return;
@@ -497,7 +497,7 @@ ctc_tty_write(struct tty_struct *tty, const u_char * buf, int count)
497 c = (count < CTC_TTY_XMIT_SIZE) ? count : CTC_TTY_XMIT_SIZE; 497 c = (count < CTC_TTY_XMIT_SIZE) ? count : CTC_TTY_XMIT_SIZE;
498 if (c <= 0) 498 if (c <= 0)
499 break; 499 break;
500 500
501 skb_res = info->netdev->hard_header_len + sizeof(info->mcr) + 501 skb_res = info->netdev->hard_header_len + sizeof(info->mcr) +
502 + sizeof(__u32); 502 + sizeof(__u32);
503 skb = dev_alloc_skb(skb_res + c); 503 skb = dev_alloc_skb(skb_res + c);
@@ -828,7 +828,7 @@ ctc_tty_block_til_ready(struct tty_struct *tty, struct file *filp, ctc_tty_info
828 if (tty_hung_up_p(filp) || 828 if (tty_hung_up_p(filp) ||
829 (info->flags & CTC_ASYNC_CLOSING)) { 829 (info->flags & CTC_ASYNC_CLOSING)) {
830 if (info->flags & CTC_ASYNC_CLOSING) 830 if (info->flags & CTC_ASYNC_CLOSING)
831 wait_event(info->close_wait, 831 wait_event(info->close_wait,
832 !(info->flags & CTC_ASYNC_CLOSING)); 832 !(info->flags & CTC_ASYNC_CLOSING));
833#ifdef MODEM_DO_RESTART 833#ifdef MODEM_DO_RESTART
834 if (info->flags & CTC_ASYNC_HUP_NOTIFY) 834 if (info->flags & CTC_ASYNC_HUP_NOTIFY)
@@ -1247,7 +1247,7 @@ ctc_tty_unregister_netdev(struct net_device *dev) {
1247void 1247void
1248ctc_tty_cleanup(void) { 1248ctc_tty_cleanup(void) {
1249 unsigned long saveflags; 1249 unsigned long saveflags;
1250 1250
1251 DBF_TEXT(trace, 2, __FUNCTION__); 1251 DBF_TEXT(trace, 2, __FUNCTION__);
1252 spin_lock_irqsave(&ctc_tty_lock, saveflags); 1252 spin_lock_irqsave(&ctc_tty_lock, saveflags);
1253 ctc_tty_shuttingdown = 1; 1253 ctc_tty_shuttingdown = 1;
diff --git a/drivers/s390/net/cu3088.c b/drivers/s390/net/cu3088.c
index b12533104c1f..e965f03a7291 100644
--- a/drivers/s390/net/cu3088.c
+++ b/drivers/s390/net/cu3088.c
@@ -20,7 +20,7 @@
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * 21 *
22 */ 22 */
23 23
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/err.h> 26#include <linux/err.h>
@@ -77,7 +77,7 @@ group_write(struct device_driver *drv, const char *buf, size_t count)
77 int len; 77 int len;
78 78
79 if (!(end = strchr(start, delim[i]))) 79 if (!(end = strchr(start, delim[i])))
80 return count; 80 return -EINVAL;
81 len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start + 1); 81 len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start + 1);
82 strlcpy (bus_ids[i], start, len); 82 strlcpy (bus_ids[i], start, len);
83 argv[i] = bus_ids[i]; 83 argv[i] = bus_ids[i];
@@ -94,7 +94,7 @@ static DRIVER_ATTR(group, 0200, NULL, group_write);
94 94
95/* Register-unregister for ctc&lcs */ 95/* Register-unregister for ctc&lcs */
96int 96int
97register_cu3088_discipline(struct ccwgroup_driver *dcp) 97register_cu3088_discipline(struct ccwgroup_driver *dcp)
98{ 98{
99 int rc; 99 int rc;
100 100
@@ -109,7 +109,7 @@ register_cu3088_discipline(struct ccwgroup_driver *dcp)
109 rc = driver_create_file(&dcp->driver, &driver_attr_group); 109 rc = driver_create_file(&dcp->driver, &driver_attr_group);
110 if (rc) 110 if (rc)
111 ccwgroup_driver_unregister(dcp); 111 ccwgroup_driver_unregister(dcp);
112 112
113 return rc; 113 return rc;
114 114
115} 115}
@@ -137,7 +137,7 @@ static int __init
137cu3088_init (void) 137cu3088_init (void)
138{ 138{
139 int rc; 139 int rc;
140 140
141 cu3088_root_dev = s390_root_dev_register("cu3088"); 141 cu3088_root_dev = s390_root_dev_register("cu3088");
142 if (IS_ERR(cu3088_root_dev)) 142 if (IS_ERR(cu3088_root_dev))
143 return PTR_ERR(cu3088_root_dev); 143 return PTR_ERR(cu3088_root_dev);
diff --git a/drivers/s390/net/iucv.c b/drivers/s390/net/iucv.c
index 6190be9dca99..e0c7deb98831 100644
--- a/drivers/s390/net/iucv.c
+++ b/drivers/s390/net/iucv.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * IUCV network driver 2 * IUCV network driver
3 * 3 *
4 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation 4 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
@@ -28,7 +28,7 @@
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 * 29 *
30 */ 30 */
31 31
32/* #define DEBUG */ 32/* #define DEBUG */
33 33
34#include <linux/module.h> 34#include <linux/module.h>
@@ -81,7 +81,7 @@ iucv_bus_match (struct device *dev, struct device_driver *drv)
81struct bus_type iucv_bus = { 81struct bus_type iucv_bus = {
82 .name = "iucv", 82 .name = "iucv",
83 .match = iucv_bus_match, 83 .match = iucv_bus_match,
84}; 84};
85 85
86struct device *iucv_root; 86struct device *iucv_root;
87 87
@@ -297,7 +297,7 @@ MODULE_LICENSE("GPL");
297/* 297/*
298 * Debugging stuff 298 * Debugging stuff
299 *******************************************************************************/ 299 *******************************************************************************/
300 300
301 301
302#ifdef DEBUG 302#ifdef DEBUG
303static int debuglevel = 0; 303static int debuglevel = 0;
@@ -344,7 +344,7 @@ do { \
344/* 344/*
345 * Internal functions 345 * Internal functions
346 *******************************************************************************/ 346 *******************************************************************************/
347 347
348/** 348/**
349 * print start banner 349 * print start banner
350 */ 350 */
@@ -810,7 +810,7 @@ iucv_register_program (__u8 pgmname[16],
810 sizeof (new_handler->id.userid)); 810 sizeof (new_handler->id.userid));
811 EBC_TOUPPER (new_handler->id.userid, 811 EBC_TOUPPER (new_handler->id.userid,
812 sizeof (new_handler->id.userid)); 812 sizeof (new_handler->id.userid));
813 813
814 if (pgmmask) { 814 if (pgmmask) {
815 memcpy (new_handler->id.mask, pgmmask, 815 memcpy (new_handler->id.mask, pgmmask,
816 sizeof (new_handler->id.mask)); 816 sizeof (new_handler->id.mask));
@@ -1229,7 +1229,7 @@ iucv_purge (__u16 pathid, __u32 msgid, __u32 srccls, __u32 *audit)
1229 /* parm->ipaudit has only 3 bytes */ 1229 /* parm->ipaudit has only 3 bytes */
1230 *audit >>= 8; 1230 *audit >>= 8;
1231 } 1231 }
1232 1232
1233 release_param(parm); 1233 release_param(parm);
1234 1234
1235 iucv_debug(1, "b2f0_result = %ld", b2f0_result); 1235 iucv_debug(1, "b2f0_result = %ld", b2f0_result);
@@ -2330,14 +2330,14 @@ iucv_do_int(iucv_GeneralInterrupt * int_buf)
2330 temp_buff1[j] &= (h->id.mask)[j]; 2330 temp_buff1[j] &= (h->id.mask)[j];
2331 temp_buff2[j] &= (h->id.mask)[j]; 2331 temp_buff2[j] &= (h->id.mask)[j];
2332 } 2332 }
2333 2333
2334 iucv_dumpit("temp_buff1:", 2334 iucv_dumpit("temp_buff1:",
2335 temp_buff1, sizeof(temp_buff1)); 2335 temp_buff1, sizeof(temp_buff1));
2336 iucv_dumpit("temp_buff2", 2336 iucv_dumpit("temp_buff2",
2337 temp_buff2, sizeof(temp_buff2)); 2337 temp_buff2, sizeof(temp_buff2));
2338 2338
2339 if (!memcmp (temp_buff1, temp_buff2, 24)) { 2339 if (!memcmp (temp_buff1, temp_buff2, 24)) {
2340 2340
2341 iucv_debug(2, 2341 iucv_debug(2,
2342 "found a matching handler"); 2342 "found a matching handler");
2343 break; 2343 break;
@@ -2368,7 +2368,7 @@ iucv_do_int(iucv_GeneralInterrupt * int_buf)
2368 } else 2368 } else
2369 iucv_sever(int_buf->ippathid, no_listener); 2369 iucv_sever(int_buf->ippathid, no_listener);
2370 break; 2370 break;
2371 2371
2372 case 0x02: /*connection complete */ 2372 case 0x02: /*connection complete */
2373 if (messagesDisabled) { 2373 if (messagesDisabled) {
2374 iucv_setmask(~0); 2374 iucv_setmask(~0);
@@ -2387,7 +2387,7 @@ iucv_do_int(iucv_GeneralInterrupt * int_buf)
2387 } else 2387 } else
2388 iucv_sever(int_buf->ippathid, no_listener); 2388 iucv_sever(int_buf->ippathid, no_listener);
2389 break; 2389 break;
2390 2390
2391 case 0x03: /* connection severed */ 2391 case 0x03: /* connection severed */
2392 if (messagesDisabled) { 2392 if (messagesDisabled) {
2393 iucv_setmask(~0); 2393 iucv_setmask(~0);
@@ -2398,13 +2398,13 @@ iucv_do_int(iucv_GeneralInterrupt * int_buf)
2398 interrupt->ConnectionSevered( 2398 interrupt->ConnectionSevered(
2399 (iucv_ConnectionSevered *)int_buf, 2399 (iucv_ConnectionSevered *)int_buf,
2400 h->pgm_data); 2400 h->pgm_data);
2401 2401
2402 else 2402 else
2403 iucv_sever (int_buf->ippathid, no_listener); 2403 iucv_sever (int_buf->ippathid, no_listener);
2404 } else 2404 } else
2405 iucv_sever(int_buf->ippathid, no_listener); 2405 iucv_sever(int_buf->ippathid, no_listener);
2406 break; 2406 break;
2407 2407
2408 case 0x04: /* connection quiesced */ 2408 case 0x04: /* connection quiesced */
2409 if (messagesDisabled) { 2409 if (messagesDisabled) {
2410 iucv_setmask(~0); 2410 iucv_setmask(~0);
@@ -2420,7 +2420,7 @@ iucv_do_int(iucv_GeneralInterrupt * int_buf)
2420 "ConnectionQuiesced not called"); 2420 "ConnectionQuiesced not called");
2421 } 2421 }
2422 break; 2422 break;
2423 2423
2424 case 0x05: /* connection resumed */ 2424 case 0x05: /* connection resumed */
2425 if (messagesDisabled) { 2425 if (messagesDisabled) {
2426 iucv_setmask(~0); 2426 iucv_setmask(~0);
@@ -2436,7 +2436,7 @@ iucv_do_int(iucv_GeneralInterrupt * int_buf)
2436 "ConnectionResumed not called"); 2436 "ConnectionResumed not called");
2437 } 2437 }
2438 break; 2438 break;
2439 2439
2440 case 0x06: /* priority message complete */ 2440 case 0x06: /* priority message complete */
2441 case 0x07: /* nonpriority message complete */ 2441 case 0x07: /* nonpriority message complete */
2442 if (h) { 2442 if (h) {
@@ -2449,7 +2449,7 @@ iucv_do_int(iucv_GeneralInterrupt * int_buf)
2449 "MessageComplete not called"); 2449 "MessageComplete not called");
2450 } 2450 }
2451 break; 2451 break;
2452 2452
2453 case 0x08: /* priority message pending */ 2453 case 0x08: /* priority message pending */
2454 case 0x09: /* nonpriority message pending */ 2454 case 0x09: /* nonpriority message pending */
2455 if (h) { 2455 if (h) {
@@ -2467,7 +2467,7 @@ iucv_do_int(iucv_GeneralInterrupt * int_buf)
2467 __FUNCTION__); 2467 __FUNCTION__);
2468 break; 2468 break;
2469 } /* end switch */ 2469 } /* end switch */
2470 2470
2471 iucv_debug(2, "exiting pathid %d, type %02X", 2471 iucv_debug(2, "exiting pathid %d, type %02X",
2472 int_buf->ippathid, int_buf->iptype); 2472 int_buf->ippathid, int_buf->iptype);
2473 2473
diff --git a/drivers/s390/net/iucv.h b/drivers/s390/net/iucv.h
index 0c4644d3d2f3..5b6b1b7241c9 100644
--- a/drivers/s390/net/iucv.h
+++ b/drivers/s390/net/iucv.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * S390 version 5 * S390 version
6 * Copyright (C) 2000 IBM Corporation 6 * Copyright (C) 2000 IBM Corporation
7 * Author(s):Alan Altmark (Alan_Altmark@us.ibm.com) 7 * Author(s):Alan Altmark (Alan_Altmark@us.ibm.com)
8 * Xenia Tkatschow (xenia@us.ibm.com) 8 * Xenia Tkatschow (xenia@us.ibm.com)
9 * 9 *
10 * 10 *
@@ -16,17 +16,17 @@
16 * CP Programming Services book, also available on the web 16 * CP Programming Services book, also available on the web
17 * thru www.ibm.com/s390/vm/pubs, manual # SC24-5760 17 * thru www.ibm.com/s390/vm/pubs, manual # SC24-5760
18 * 18 *
19 * Definition of Return Codes 19 * Definition of Return Codes
20 * -All positive return codes including zero are reflected back 20 * -All positive return codes including zero are reflected back
21 * from CP except for iucv_register_program. The definition of each 21 * from CP except for iucv_register_program. The definition of each
22 * return code can be found in CP Programming Services book. 22 * return code can be found in CP Programming Services book.
23 * Also available on the web thru www.ibm.com/s390/vm/pubs, manual # SC24-5760 23 * Also available on the web thru www.ibm.com/s390/vm/pubs, manual # SC24-5760
24 * - Return Code of: 24 * - Return Code of:
25 * (-EINVAL) Invalid value 25 * (-EINVAL) Invalid value
26 * (-ENOMEM) storage allocation failed 26 * (-ENOMEM) storage allocation failed
27 * pgmask defined in iucv_register_program will be set depending on input 27 * pgmask defined in iucv_register_program will be set depending on input
28 * paramters. 28 * paramters.
29 * 29 *
30 */ 30 */
31 31
32#include <linux/types.h> 32#include <linux/types.h>
@@ -124,13 +124,13 @@ iucv_hex_dump(unsigned char *buf, size_t len)
124#define iucv_handle_t void * 124#define iucv_handle_t void *
125 125
126/* flags1: 126/* flags1:
127 * All flags are defined in the field IPFLAGS1 of each function 127 * All flags are defined in the field IPFLAGS1 of each function
128 * and can be found in CP Programming Services. 128 * and can be found in CP Programming Services.
129 * IPLOCAL - Indicates the connect can only be satisfied on the 129 * IPLOCAL - Indicates the connect can only be satisfied on the
130 * local system 130 * local system
131 * IPPRTY - Indicates a priority message 131 * IPPRTY - Indicates a priority message
132 * IPQUSCE - Indicates you do not want to receive messages on a 132 * IPQUSCE - Indicates you do not want to receive messages on a
133 * path until an iucv_resume is issued 133 * path until an iucv_resume is issued
134 * IPRMDATA - Indicates that the message is in the parameter list 134 * IPRMDATA - Indicates that the message is in the parameter list
135 */ 135 */
136#define IPLOCAL 0x01 136#define IPLOCAL 0x01
@@ -154,14 +154,14 @@ iucv_hex_dump(unsigned char *buf, size_t len)
154#define AllInterrupts 0xf8 154#define AllInterrupts 0xf8
155/* 155/*
156 * Mapping of external interrupt buffers should be used with the corresponding 156 * Mapping of external interrupt buffers should be used with the corresponding
157 * interrupt types. 157 * interrupt types.
158 * Names: iucv_ConnectionPending -> connection pending 158 * Names: iucv_ConnectionPending -> connection pending
159 * iucv_ConnectionComplete -> connection complete 159 * iucv_ConnectionComplete -> connection complete
160 * iucv_ConnectionSevered -> connection severed 160 * iucv_ConnectionSevered -> connection severed
161 * iucv_ConnectionQuiesced -> connection quiesced 161 * iucv_ConnectionQuiesced -> connection quiesced
162 * iucv_ConnectionResumed -> connection resumed 162 * iucv_ConnectionResumed -> connection resumed
163 * iucv_MessagePending -> message pending 163 * iucv_MessagePending -> message pending
164 * iucv_MessageComplete -> message complete 164 * iucv_MessageComplete -> message complete
165 */ 165 */
166typedef struct { 166typedef struct {
167 u16 ippathid; 167 u16 ippathid;
@@ -260,16 +260,16 @@ typedef struct {
260 uchar res2[3]; 260 uchar res2[3];
261} iucv_MessageComplete; 261} iucv_MessageComplete;
262 262
263/* 263/*
264 * iucv_interrupt_ops_t: Is a vector of functions that handle 264 * iucv_interrupt_ops_t: Is a vector of functions that handle
265 * IUCV interrupts. 265 * IUCV interrupts.
266 * Parameter list: 266 * Parameter list:
267 * eib - is a pointer to a 40-byte area described 267 * eib - is a pointer to a 40-byte area described
268 * with one of the structures above. 268 * with one of the structures above.
269 * pgm_data - this data is strictly for the 269 * pgm_data - this data is strictly for the
270 * interrupt handler that is passed by 270 * interrupt handler that is passed by
271 * the application. This may be an address 271 * the application. This may be an address
272 * or token. 272 * or token.
273*/ 273*/
274typedef struct { 274typedef struct {
275 void (*ConnectionPending) (iucv_ConnectionPending * eib, 275 void (*ConnectionPending) (iucv_ConnectionPending * eib,
@@ -287,8 +287,8 @@ typedef struct {
287} iucv_interrupt_ops_t; 287} iucv_interrupt_ops_t;
288 288
289/* 289/*
290 *iucv_array_t : Defines buffer array. 290 *iucv_array_t : Defines buffer array.
291 * Inside the array may be 31- bit addresses and 31-bit lengths. 291 * Inside the array may be 31- bit addresses and 31-bit lengths.
292*/ 292*/
293typedef struct { 293typedef struct {
294 u32 address; 294 u32 address;
@@ -299,19 +299,19 @@ extern struct bus_type iucv_bus;
299extern struct device *iucv_root; 299extern struct device *iucv_root;
300 300
301/* -prototypes- */ 301/* -prototypes- */
302/* 302/*
303 * Name: iucv_register_program 303 * Name: iucv_register_program
304 * Purpose: Registers an application with IUCV 304 * Purpose: Registers an application with IUCV
305 * Input: prmname - user identification 305 * Input: prmname - user identification
306 * userid - machine identification 306 * userid - machine identification
307 * pgmmask - indicates which bits in the prmname and userid combined will be 307 * pgmmask - indicates which bits in the prmname and userid combined will be
308 * used to determine who is given control 308 * used to determine who is given control
309 * ops - address of vector of interrupt handlers 309 * ops - address of vector of interrupt handlers
310 * pgm_data- application data passed to interrupt handlers 310 * pgm_data- application data passed to interrupt handlers
311 * Output: NA 311 * Output: NA
312 * Return: address of handler 312 * Return: address of handler
313 * (0) - Error occurred, registration not completed. 313 * (0) - Error occurred, registration not completed.
314 * NOTE: Exact cause of failure will be recorded in syslog. 314 * NOTE: Exact cause of failure will be recorded in syslog.
315*/ 315*/
316iucv_handle_t iucv_register_program (uchar pgmname[16], 316iucv_handle_t iucv_register_program (uchar pgmname[16],
317 uchar userid[8], 317 uchar userid[8],
@@ -319,13 +319,13 @@ iucv_handle_t iucv_register_program (uchar pgmname[16],
319 iucv_interrupt_ops_t * ops, 319 iucv_interrupt_ops_t * ops,
320 void *pgm_data); 320 void *pgm_data);
321 321
322/* 322/*
323 * Name: iucv_unregister_program 323 * Name: iucv_unregister_program
324 * Purpose: Unregister application with IUCV 324 * Purpose: Unregister application with IUCV
325 * Input: address of handler 325 * Input: address of handler
326 * Output: NA 326 * Output: NA
327 * Return: (0) - Normal return 327 * Return: (0) - Normal return
328 * (-EINVAL) - Internal error, wild pointer 328 * (-EINVAL) - Internal error, wild pointer
329*/ 329*/
330int iucv_unregister_program (iucv_handle_t handle); 330int iucv_unregister_program (iucv_handle_t handle);
331 331
@@ -333,7 +333,7 @@ int iucv_unregister_program (iucv_handle_t handle);
333 * Name: iucv_accept 333 * Name: iucv_accept
334 * Purpose: This function is issued after the user receives a Connection Pending external 334 * Purpose: This function is issued after the user receives a Connection Pending external
335 * interrupt and now wishes to complete the IUCV communication path. 335 * interrupt and now wishes to complete the IUCV communication path.
336 * Input: pathid - u16 , Path identification number 336 * Input: pathid - u16 , Path identification number
337 * msglim_reqstd - u16, The number of outstanding messages requested. 337 * msglim_reqstd - u16, The number of outstanding messages requested.
338 * user_data - uchar[16], Data specified by the iucv_connect function. 338 * user_data - uchar[16], Data specified by the iucv_connect function.
339 * flags1 - int, Contains options for this path. 339 * flags1 - int, Contains options for this path.
@@ -358,34 +358,34 @@ int iucv_accept (u16 pathid,
358 void *pgm_data, int *flags1_out, u16 * msglim); 358 void *pgm_data, int *flags1_out, u16 * msglim);
359 359
360/* 360/*
361 * Name: iucv_connect 361 * Name: iucv_connect
362 * Purpose: This function establishes an IUCV path. Although the connect may complete 362 * Purpose: This function establishes an IUCV path. Although the connect may complete
363 * successfully, you are not able to use the path until you receive an IUCV 363 * successfully, you are not able to use the path until you receive an IUCV
364 * Connection Complete external interrupt. 364 * Connection Complete external interrupt.
365 * Input: pathid - u16 *, Path identification number 365 * Input: pathid - u16 *, Path identification number
366 * msglim_reqstd - u16, Number of outstanding messages requested 366 * msglim_reqstd - u16, Number of outstanding messages requested
367 * user_data - uchar[16], 16-byte user data 367 * user_data - uchar[16], 16-byte user data
368 * userid - uchar[8], User identification 368 * userid - uchar[8], User identification
369 * system_name - uchar[8], 8-byte identifying the system name 369 * system_name - uchar[8], 8-byte identifying the system name
370 * flags1 - int, Contains options for this path. 370 * flags1 - int, Contains options for this path.
371 * -IPPRTY - 0x20, Specifies if you want to send priority message. 371 * -IPPRTY - 0x20, Specifies if you want to send priority message.
372 * -IPRMDATA - 0x80, Specifies whether your program can handle a message 372 * -IPRMDATA - 0x80, Specifies whether your program can handle a message
373 * in the parameter list. 373 * in the parameter list.
374 * -IPQUSCE - 0x40, Specifies whether you want to quiesce the path being 374 * -IPQUSCE - 0x40, Specifies whether you want to quiesce the path being
375 * established. 375 * established.
376 * -IPLOCAL - 0X01, Allows an application to force the partner to be on 376 * -IPLOCAL - 0X01, Allows an application to force the partner to be on
377 * the local system. If local is specified then target class cannot be 377 * the local system. If local is specified then target class cannot be
378 * specified. 378 * specified.
379 * flags1_out - int * Contains information about the path 379 * flags1_out - int * Contains information about the path
380 * - IPPRTY - 0x20, Indicates you may send priority messages. 380 * - IPPRTY - 0x20, Indicates you may send priority messages.
381 * msglim - * u16, Number of outstanding messages 381 * msglim - * u16, Number of outstanding messages
382 * handle - iucv_handle_t, Address of handler 382 * handle - iucv_handle_t, Address of handler
383 * pgm_data - void *, Application data passed to interrupt handlers 383 * pgm_data - void *, Application data passed to interrupt handlers
384 * Output: return code from CP IUCV call 384 * Output: return code from CP IUCV call
385 * rc - return code from iucv_declare_buffer 385 * rc - return code from iucv_declare_buffer
386 * -EINVAL - Invalid handle passed by application 386 * -EINVAL - Invalid handle passed by application
387 * -EINVAL - Pathid address is NULL 387 * -EINVAL - Pathid address is NULL
388 * add_pathid_result - Return code from internal function add_pathid 388 * add_pathid_result - Return code from internal function add_pathid
389*/ 389*/
390int 390int
391 iucv_connect (u16 * pathid, 391 iucv_connect (u16 * pathid,
@@ -397,16 +397,16 @@ int
397 int *flags1_out, 397 int *flags1_out,
398 u16 * msglim, iucv_handle_t handle, void *pgm_data); 398 u16 * msglim, iucv_handle_t handle, void *pgm_data);
399 399
400/* 400/*
401 * Name: iucv_purge 401 * Name: iucv_purge
402 * Purpose: This function cancels a message that you have sent. 402 * Purpose: This function cancels a message that you have sent.
403 * Input: pathid - Path identification number. 403 * Input: pathid - Path identification number.
404 * msgid - Specifies the message ID of the message to be purged. 404 * msgid - Specifies the message ID of the message to be purged.
405 * srccls - Specifies the source message class. 405 * srccls - Specifies the source message class.
406 * Output: audit - Contains information about asynchronous error 406 * Output: audit - Contains information about asynchronous error
407 * that may have affected the normal completion 407 * that may have affected the normal completion
408 * of this message. 408 * of this message.
409 * Return: Return code from CP IUCV call. 409 * Return: Return code from CP IUCV call.
410*/ 410*/
411int iucv_purge (u16 pathid, u32 msgid, u32 srccls, __u32 *audit); 411int iucv_purge (u16 pathid, u32 msgid, u32 srccls, __u32 *audit);
412/* 412/*
@@ -426,38 +426,38 @@ ulong iucv_query_maxconn (void);
426 */ 426 */
427ulong iucv_query_bufsize (void); 427ulong iucv_query_bufsize (void);
428 428
429/* 429/*
430 * Name: iucv_quiesce 430 * Name: iucv_quiesce
431 * Purpose: This function temporarily suspends incoming messages on an 431 * Purpose: This function temporarily suspends incoming messages on an
432 * IUCV path. You can later reactivate the path by invoking 432 * IUCV path. You can later reactivate the path by invoking
433 * the iucv_resume function. 433 * the iucv_resume function.
434 * Input: pathid - Path identification number 434 * Input: pathid - Path identification number
435 * user_data - 16-bytes of user data 435 * user_data - 16-bytes of user data
436 * Output: NA 436 * Output: NA
437 * Return: Return code from CP IUCV call. 437 * Return: Return code from CP IUCV call.
438*/ 438*/
439int iucv_quiesce (u16 pathid, uchar user_data[16]); 439int iucv_quiesce (u16 pathid, uchar user_data[16]);
440 440
441/* 441/*
442 * Name: iucv_receive 442 * Name: iucv_receive
443 * Purpose: This function receives messages that are being sent to you 443 * Purpose: This function receives messages that are being sent to you
444 * over established paths. Data will be returned in buffer for length of 444 * over established paths. Data will be returned in buffer for length of
445 * buflen. 445 * buflen.
446 * Input: 446 * Input:
447 * pathid - Path identification number. 447 * pathid - Path identification number.
448 * buffer - Address of buffer to receive. 448 * buffer - Address of buffer to receive.
449 * buflen - Length of buffer to receive. 449 * buflen - Length of buffer to receive.
450 * msgid - Specifies the message ID. 450 * msgid - Specifies the message ID.
451 * trgcls - Specifies target class. 451 * trgcls - Specifies target class.
452 * Output: 452 * Output:
453 * flags1_out: int *, Contains information about this path. 453 * flags1_out: int *, Contains information about this path.
454 * IPNORPY - 0x10 Specifies this is a one-way message and no reply is 454 * IPNORPY - 0x10 Specifies this is a one-way message and no reply is
455 * expected. 455 * expected.
456 * IPPRTY - 0x20 Specifies if you want to send priority message. 456 * IPPRTY - 0x20 Specifies if you want to send priority message.
457 * IPRMDATA - 0x80 specifies the data is contained in the parameter list 457 * IPRMDATA - 0x80 specifies the data is contained in the parameter list
458 * residual_buffer - address of buffer updated by the number 458 * residual_buffer - address of buffer updated by the number
459 * of bytes you have received. 459 * of bytes you have received.
460 * residual_length - 460 * residual_length -
461 * Contains one of the following values, if the receive buffer is: 461 * Contains one of the following values, if the receive buffer is:
462 * The same length as the message, this field is zero. 462 * The same length as the message, this field is zero.
463 * Longer than the message, this field contains the number of 463 * Longer than the message, this field contains the number of
@@ -466,8 +466,8 @@ int iucv_quiesce (u16 pathid, uchar user_data[16]);
466 * count (that is, the number of bytes remaining in the 466 * count (that is, the number of bytes remaining in the
467 * message that does not fit into the buffer. In this 467 * message that does not fit into the buffer. In this
468 * case b2f0_result = 5. 468 * case b2f0_result = 5.
469 * Return: Return code from CP IUCV call. 469 * Return: Return code from CP IUCV call.
470 * (-EINVAL) - buffer address is pointing to NULL 470 * (-EINVAL) - buffer address is pointing to NULL
471*/ 471*/
472int iucv_receive (u16 pathid, 472int iucv_receive (u16 pathid,
473 u32 msgid, 473 u32 msgid,
@@ -477,16 +477,16 @@ int iucv_receive (u16 pathid,
477 int *flags1_out, 477 int *flags1_out,
478 ulong * residual_buffer, ulong * residual_length); 478 ulong * residual_buffer, ulong * residual_length);
479 479
480 /* 480 /*
481 * Name: iucv_receive_array 481 * Name: iucv_receive_array
482 * Purpose: This function receives messages that are being sent to you 482 * Purpose: This function receives messages that are being sent to you
483 * over established paths. Data will be returned in first buffer for 483 * over established paths. Data will be returned in first buffer for
484 * length of first buffer. 484 * length of first buffer.
485 * Input: pathid - Path identification number. 485 * Input: pathid - Path identification number.
486 * msgid - specifies the message ID. 486 * msgid - specifies the message ID.
487 * trgcls - Specifies target class. 487 * trgcls - Specifies target class.
488 * buffer - Address of array of buffers. 488 * buffer - Address of array of buffers.
489 * buflen - Total length of buffers. 489 * buflen - Total length of buffers.
490 * Output: 490 * Output:
491 * flags1_out: int *, Contains information about this path. 491 * flags1_out: int *, Contains information about this path.
492 * IPNORPY - 0x10 Specifies this is a one-way message and no reply is 492 * IPNORPY - 0x10 Specifies this is a one-way message and no reply is
@@ -504,8 +504,8 @@ int iucv_receive (u16 pathid,
504 * count (that is, the number of bytes remaining in the 504 * count (that is, the number of bytes remaining in the
505 * message that does not fit into the buffer. In this 505 * message that does not fit into the buffer. In this
506 * case b2f0_result = 5. 506 * case b2f0_result = 5.
507 * Return: Return code from CP IUCV call. 507 * Return: Return code from CP IUCV call.
508 * (-EINVAL) - Buffer address is NULL. 508 * (-EINVAL) - Buffer address is NULL.
509 */ 509 */
510int iucv_receive_array (u16 pathid, 510int iucv_receive_array (u16 pathid,
511 u32 msgid, 511 u32 msgid,
@@ -515,44 +515,44 @@ int iucv_receive_array (u16 pathid,
515 int *flags1_out, 515 int *flags1_out,
516 ulong * residual_buffer, ulong * residual_length); 516 ulong * residual_buffer, ulong * residual_length);
517 517
518/* 518/*
519 * Name: iucv_reject 519 * Name: iucv_reject
520 * Purpose: The reject function refuses a specified message. Between the 520 * Purpose: The reject function refuses a specified message. Between the
521 * time you are notified of a message and the time that you 521 * time you are notified of a message and the time that you
522 * complete the message, the message may be rejected. 522 * complete the message, the message may be rejected.
523 * Input: pathid - Path identification number. 523 * Input: pathid - Path identification number.
524 * msgid - Specifies the message ID. 524 * msgid - Specifies the message ID.
525 * trgcls - Specifies target class. 525 * trgcls - Specifies target class.
526 * Output: NA 526 * Output: NA
527 * Return: Return code from CP IUCV call. 527 * Return: Return code from CP IUCV call.
528*/ 528*/
529int iucv_reject (u16 pathid, u32 msgid, u32 trgcls); 529int iucv_reject (u16 pathid, u32 msgid, u32 trgcls);
530 530
531/* 531/*
532 * Name: iucv_reply 532 * Name: iucv_reply
533 * Purpose: This function responds to the two-way messages that you 533 * Purpose: This function responds to the two-way messages that you
534 * receive. You must identify completely the message to 534 * receive. You must identify completely the message to
535 * which you wish to reply. ie, pathid, msgid, and trgcls. 535 * which you wish to reply. ie, pathid, msgid, and trgcls.
536 * Input: pathid - Path identification number. 536 * Input: pathid - Path identification number.
537 * msgid - Specifies the message ID. 537 * msgid - Specifies the message ID.
538 * trgcls - Specifies target class. 538 * trgcls - Specifies target class.
539 * flags1 - Option for path. 539 * flags1 - Option for path.
540 * IPPRTY- 0x20, Specifies if you want to send priority message. 540 * IPPRTY- 0x20, Specifies if you want to send priority message.
541 * buffer - Address of reply buffer. 541 * buffer - Address of reply buffer.
542 * buflen - Length of reply buffer. 542 * buflen - Length of reply buffer.
543 * Output: residual_buffer - Address of buffer updated by the number 543 * Output: residual_buffer - Address of buffer updated by the number
544 * of bytes you have moved. 544 * of bytes you have moved.
545 * residual_length - Contains one of the following values: 545 * residual_length - Contains one of the following values:
546 * If the answer buffer is the same length as the reply, this field 546 * If the answer buffer is the same length as the reply, this field
547 * contains zero. 547 * contains zero.
548 * If the answer buffer is longer than the reply, this field contains 548 * If the answer buffer is longer than the reply, this field contains
549 * the number of bytes remaining in the buffer. 549 * the number of bytes remaining in the buffer.
550 * If the answer buffer is shorter than the reply, this field contains 550 * If the answer buffer is shorter than the reply, this field contains
551 * a residual count (that is, the number of bytes remianing in the 551 * a residual count (that is, the number of bytes remianing in the
552 * reply that does not fit into the buffer. In this 552 * reply that does not fit into the buffer. In this
553 * case b2f0_result = 5. 553 * case b2f0_result = 5.
554 * Return: Return code from CP IUCV call. 554 * Return: Return code from CP IUCV call.
555 * (-EINVAL) - Buffer address is NULL. 555 * (-EINVAL) - Buffer address is NULL.
556*/ 556*/
557int iucv_reply (u16 pathid, 557int iucv_reply (u16 pathid,
558 u32 msgid, 558 u32 msgid,
@@ -561,20 +561,20 @@ int iucv_reply (u16 pathid,
561 void *buffer, ulong buflen, ulong * residual_buffer, 561 void *buffer, ulong buflen, ulong * residual_buffer,
562 ulong * residual_length); 562 ulong * residual_length);
563 563
564/* 564/*
565 * Name: iucv_reply_array 565 * Name: iucv_reply_array
566 * Purpose: This function responds to the two-way messages that you 566 * Purpose: This function responds to the two-way messages that you
567 * receive. You must identify completely the message to 567 * receive. You must identify completely the message to
568 * which you wish to reply. ie, pathid, msgid, and trgcls. 568 * which you wish to reply. ie, pathid, msgid, and trgcls.
569 * The array identifies a list of addresses and lengths of 569 * The array identifies a list of addresses and lengths of
570 * discontiguous buffers that contains the reply data. 570 * discontiguous buffers that contains the reply data.
571 * Input: pathid - Path identification number 571 * Input: pathid - Path identification number
572 * msgid - Specifies the message ID. 572 * msgid - Specifies the message ID.
573 * trgcls - Specifies target class. 573 * trgcls - Specifies target class.
574 * flags1 - Option for path. 574 * flags1 - Option for path.
575 * IPPRTY- 0x20, Specifies if you want to send priority message. 575 * IPPRTY- 0x20, Specifies if you want to send priority message.
576 * buffer - Address of array of reply buffers. 576 * buffer - Address of array of reply buffers.
577 * buflen - Total length of reply buffers. 577 * buflen - Total length of reply buffers.
578 * Output: residual_buffer - Address of buffer which IUCV is currently working on. 578 * Output: residual_buffer - Address of buffer which IUCV is currently working on.
579 * residual_length - Contains one of the following values: 579 * residual_length - Contains one of the following values:
580 * If the answer buffer is the same length as the reply, this field 580 * If the answer buffer is the same length as the reply, this field
@@ -585,8 +585,8 @@ int iucv_reply (u16 pathid,
585 * a residual count (that is, the number of bytes remianing in the 585 * a residual count (that is, the number of bytes remianing in the
586 * reply that does not fit into the buffer. In this 586 * reply that does not fit into the buffer. In this
587 * case b2f0_result = 5. 587 * case b2f0_result = 5.
588 * Return: Return code from CP IUCV call. 588 * Return: Return code from CP IUCV call.
589 * (-EINVAL) - Buffer address is NULL. 589 * (-EINVAL) - Buffer address is NULL.
590*/ 590*/
591int iucv_reply_array (u16 pathid, 591int iucv_reply_array (u16 pathid,
592 u32 msgid, 592 u32 msgid,
@@ -596,77 +596,77 @@ int iucv_reply_array (u16 pathid,
596 ulong buflen, ulong * residual_address, 596 ulong buflen, ulong * residual_address,
597 ulong * residual_length); 597 ulong * residual_length);
598 598
599/* 599/*
600 * Name: iucv_reply_prmmsg 600 * Name: iucv_reply_prmmsg
601 * Purpose: This function responds to the two-way messages that you 601 * Purpose: This function responds to the two-way messages that you
602 * receive. You must identify completely the message to 602 * receive. You must identify completely the message to
603 * which you wish to reply. ie, pathid, msgid, and trgcls. 603 * which you wish to reply. ie, pathid, msgid, and trgcls.
604 * Prmmsg signifies the data is moved into the 604 * Prmmsg signifies the data is moved into the
605 * parameter list. 605 * parameter list.
606 * Input: pathid - Path identification number. 606 * Input: pathid - Path identification number.
607 * msgid - Specifies the message ID. 607 * msgid - Specifies the message ID.
608 * trgcls - Specifies target class. 608 * trgcls - Specifies target class.
609 * flags1 - Option for path. 609 * flags1 - Option for path.
610 * IPPRTY- 0x20 Specifies if you want to send priority message. 610 * IPPRTY- 0x20 Specifies if you want to send priority message.
611 * prmmsg - 8-bytes of data to be placed into the parameter. 611 * prmmsg - 8-bytes of data to be placed into the parameter.
612 * list. 612 * list.
613 * Output: NA 613 * Output: NA
614 * Return: Return code from CP IUCV call. 614 * Return: Return code from CP IUCV call.
615*/ 615*/
616int iucv_reply_prmmsg (u16 pathid, 616int iucv_reply_prmmsg (u16 pathid,
617 u32 msgid, u32 trgcls, int flags1, uchar prmmsg[8]); 617 u32 msgid, u32 trgcls, int flags1, uchar prmmsg[8]);
618 618
619/* 619/*
620 * Name: iucv_resume 620 * Name: iucv_resume
621 * Purpose: This function restores communications over a quiesced path 621 * Purpose: This function restores communications over a quiesced path
622 * Input: pathid - Path identification number. 622 * Input: pathid - Path identification number.
623 * user_data - 16-bytes of user data. 623 * user_data - 16-bytes of user data.
624 * Output: NA 624 * Output: NA
625 * Return: Return code from CP IUCV call. 625 * Return: Return code from CP IUCV call.
626*/ 626*/
627int iucv_resume (u16 pathid, uchar user_data[16]); 627int iucv_resume (u16 pathid, uchar user_data[16]);
628 628
629/* 629/*
630 * Name: iucv_send 630 * Name: iucv_send
631 * Purpose: This function transmits data to another application. 631 * Purpose: This function transmits data to another application.
632 * Data to be transmitted is in a buffer and this is a 632 * Data to be transmitted is in a buffer and this is a
633 * one-way message and the receiver will not reply to the 633 * one-way message and the receiver will not reply to the
634 * message. 634 * message.
635 * Input: pathid - Path identification number. 635 * Input: pathid - Path identification number.
636 * trgcls - Specifies target class. 636 * trgcls - Specifies target class.
637 * srccls - Specifies the source message class. 637 * srccls - Specifies the source message class.
638 * msgtag - Specifies a tag to be associated with the message. 638 * msgtag - Specifies a tag to be associated with the message.
639 * flags1 - Option for path. 639 * flags1 - Option for path.
640 * IPPRTY- 0x20 Specifies if you want to send priority message. 640 * IPPRTY- 0x20 Specifies if you want to send priority message.
641 * buffer - Address of send buffer. 641 * buffer - Address of send buffer.
642 * buflen - Length of send buffer. 642 * buflen - Length of send buffer.
643 * Output: msgid - Specifies the message ID. 643 * Output: msgid - Specifies the message ID.
644 * Return: Return code from CP IUCV call. 644 * Return: Return code from CP IUCV call.
645 * (-EINVAL) - Buffer address is NULL. 645 * (-EINVAL) - Buffer address is NULL.
646*/ 646*/
647int iucv_send (u16 pathid, 647int iucv_send (u16 pathid,
648 u32 * msgid, 648 u32 * msgid,
649 u32 trgcls, 649 u32 trgcls,
650 u32 srccls, u32 msgtag, int flags1, void *buffer, ulong buflen); 650 u32 srccls, u32 msgtag, int flags1, void *buffer, ulong buflen);
651 651
652/* 652/*
653 * Name: iucv_send_array 653 * Name: iucv_send_array
654 * Purpose: This function transmits data to another application. 654 * Purpose: This function transmits data to another application.
655 * The contents of buffer is the address of the array of 655 * The contents of buffer is the address of the array of
656 * addresses and lengths of discontiguous buffers that hold 656 * addresses and lengths of discontiguous buffers that hold
657 * the message text. This is a one-way message and the 657 * the message text. This is a one-way message and the
658 * receiver will not reply to the message. 658 * receiver will not reply to the message.
659 * Input: pathid - Path identification number. 659 * Input: pathid - Path identification number.
660 * trgcls - Specifies target class. 660 * trgcls - Specifies target class.
661 * srccls - Specifies the source message class. 661 * srccls - Specifies the source message class.
662 * msgtag - Specifies a tag to be associated witht the message. 662 * msgtag - Specifies a tag to be associated witht the message.
663 * flags1 - Option for path. 663 * flags1 - Option for path.
664 * IPPRTY- specifies if you want to send priority message. 664 * IPPRTY- specifies if you want to send priority message.
665 * buffer - Address of array of send buffers. 665 * buffer - Address of array of send buffers.
666 * buflen - Total length of send buffers. 666 * buflen - Total length of send buffers.
667 * Output: msgid - Specifies the message ID. 667 * Output: msgid - Specifies the message ID.
668 * Return: Return code from CP IUCV call. 668 * Return: Return code from CP IUCV call.
669 * (-EINVAL) - Buffer address is NULL. 669 * (-EINVAL) - Buffer address is NULL.
670*/ 670*/
671int iucv_send_array (u16 pathid, 671int iucv_send_array (u16 pathid,
672 u32 * msgid, 672 u32 * msgid,
@@ -675,48 +675,48 @@ int iucv_send_array (u16 pathid,
675 u32 msgtag, 675 u32 msgtag,
676 int flags1, iucv_array_t * buffer, ulong buflen); 676 int flags1, iucv_array_t * buffer, ulong buflen);
677 677
678/* 678/*
679 * Name: iucv_send_prmmsg 679 * Name: iucv_send_prmmsg
680 * Purpose: This function transmits data to another application. 680 * Purpose: This function transmits data to another application.
681 * Prmmsg specifies that the 8-bytes of data are to be moved 681 * Prmmsg specifies that the 8-bytes of data are to be moved
682 * into the parameter list. This is a one-way message and the 682 * into the parameter list. This is a one-way message and the
683 * receiver will not reply to the message. 683 * receiver will not reply to the message.
684 * Input: pathid - Path identification number. 684 * Input: pathid - Path identification number.
685 * trgcls - Specifies target class. 685 * trgcls - Specifies target class.
686 * srccls - Specifies the source message class. 686 * srccls - Specifies the source message class.
687 * msgtag - Specifies a tag to be associated with the message. 687 * msgtag - Specifies a tag to be associated with the message.
688 * flags1 - Option for path. 688 * flags1 - Option for path.
689 * IPPRTY- 0x20 specifies if you want to send priority message. 689 * IPPRTY- 0x20 specifies if you want to send priority message.
690 * prmmsg - 8-bytes of data to be placed into parameter list. 690 * prmmsg - 8-bytes of data to be placed into parameter list.
691 * Output: msgid - Specifies the message ID. 691 * Output: msgid - Specifies the message ID.
692 * Return: Return code from CP IUCV call. 692 * Return: Return code from CP IUCV call.
693*/ 693*/
694int iucv_send_prmmsg (u16 pathid, 694int iucv_send_prmmsg (u16 pathid,
695 u32 * msgid, 695 u32 * msgid,
696 u32 trgcls, 696 u32 trgcls,
697 u32 srccls, u32 msgtag, int flags1, uchar prmmsg[8]); 697 u32 srccls, u32 msgtag, int flags1, uchar prmmsg[8]);
698 698
699/* 699/*
700 * Name: iucv_send2way 700 * Name: iucv_send2way
701 * Purpose: This function transmits data to another application. 701 * Purpose: This function transmits data to another application.
702 * Data to be transmitted is in a buffer. The receiver 702 * Data to be transmitted is in a buffer. The receiver
703 * of the send is expected to reply to the message and 703 * of the send is expected to reply to the message and
704 * a buffer is provided into which IUCV moves the reply 704 * a buffer is provided into which IUCV moves the reply
705 * to this message. 705 * to this message.
706 * Input: pathid - Path identification number. 706 * Input: pathid - Path identification number.
707 * trgcls - Specifies target class. 707 * trgcls - Specifies target class.
708 * srccls - Specifies the source message class. 708 * srccls - Specifies the source message class.
709 * msgtag - Specifies a tag associated with the message. 709 * msgtag - Specifies a tag associated with the message.
710 * flags1 - Option for path. 710 * flags1 - Option for path.
711 * IPPRTY- 0x20 Specifies if you want to send priority message. 711 * IPPRTY- 0x20 Specifies if you want to send priority message.
712 * buffer - Address of send buffer. 712 * buffer - Address of send buffer.
713 * buflen - Length of send buffer. 713 * buflen - Length of send buffer.
714 * ansbuf - Address of buffer into which IUCV moves the reply of 714 * ansbuf - Address of buffer into which IUCV moves the reply of
715 * this message. 715 * this message.
716 * anslen - Address of length of buffer. 716 * anslen - Address of length of buffer.
717 * Output: msgid - Specifies the message ID. 717 * Output: msgid - Specifies the message ID.
718 * Return: Return code from CP IUCV call. 718 * Return: Return code from CP IUCV call.
719 * (-EINVAL) - Buffer or ansbuf address is NULL. 719 * (-EINVAL) - Buffer or ansbuf address is NULL.
720*/ 720*/
721int iucv_send2way (u16 pathid, 721int iucv_send2way (u16 pathid,
722 u32 * msgid, 722 u32 * msgid,
@@ -726,28 +726,28 @@ int iucv_send2way (u16 pathid,
726 int flags1, 726 int flags1,
727 void *buffer, ulong buflen, void *ansbuf, ulong anslen); 727 void *buffer, ulong buflen, void *ansbuf, ulong anslen);
728 728
729/* 729/*
730 * Name: iucv_send2way_array 730 * Name: iucv_send2way_array
731 * Purpose: This function transmits data to another application. 731 * Purpose: This function transmits data to another application.
732 * The contents of buffer is the address of the array of 732 * The contents of buffer is the address of the array of
733 * addresses and lengths of discontiguous buffers that hold 733 * addresses and lengths of discontiguous buffers that hold
734 * the message text. The receiver of the send is expected to 734 * the message text. The receiver of the send is expected to
735 * reply to the message and a buffer is provided into which 735 * reply to the message and a buffer is provided into which
736 * IUCV moves the reply to this message. 736 * IUCV moves the reply to this message.
737 * Input: pathid - Path identification number. 737 * Input: pathid - Path identification number.
738 * trgcls - Specifies target class. 738 * trgcls - Specifies target class.
739 * srccls - Specifies the source message class. 739 * srccls - Specifies the source message class.
740 * msgtag - Specifies a tag to be associated with the message. 740 * msgtag - Specifies a tag to be associated with the message.
741 * flags1 - Option for path. 741 * flags1 - Option for path.
742 * IPPRTY- 0x20 Specifies if you want to send priority message. 742 * IPPRTY- 0x20 Specifies if you want to send priority message.
743 * buffer - Sddress of array of send buffers. 743 * buffer - Sddress of array of send buffers.
744 * buflen - Total length of send buffers. 744 * buflen - Total length of send buffers.
745 * ansbuf - Address of array of buffer into which IUCV moves the reply 745 * ansbuf - Address of array of buffer into which IUCV moves the reply
746 * of this message. 746 * of this message.
747 * anslen - Address of length reply buffers. 747 * anslen - Address of length reply buffers.
748 * Output: msgid - Specifies the message ID. 748 * Output: msgid - Specifies the message ID.
749 * Return: Return code from CP IUCV call. 749 * Return: Return code from CP IUCV call.
750 * (-EINVAL) - Buffer address is NULL. 750 * (-EINVAL) - Buffer address is NULL.
751*/ 751*/
752int iucv_send2way_array (u16 pathid, 752int iucv_send2way_array (u16 pathid,
753 u32 * msgid, 753 u32 * msgid,
@@ -758,27 +758,27 @@ int iucv_send2way_array (u16 pathid,
758 iucv_array_t * buffer, 758 iucv_array_t * buffer,
759 ulong buflen, iucv_array_t * ansbuf, ulong anslen); 759 ulong buflen, iucv_array_t * ansbuf, ulong anslen);
760 760
761/* 761/*
762 * Name: iucv_send2way_prmmsg 762 * Name: iucv_send2way_prmmsg
763 * Purpose: This function transmits data to another application. 763 * Purpose: This function transmits data to another application.
764 * Prmmsg specifies that the 8-bytes of data are to be moved 764 * Prmmsg specifies that the 8-bytes of data are to be moved
765 * into the parameter list. This is a two-way message and the 765 * into the parameter list. This is a two-way message and the
766 * receiver of the message is expected to reply. A buffer 766 * receiver of the message is expected to reply. A buffer
767 * is provided into which IUCV moves the reply to this 767 * is provided into which IUCV moves the reply to this
768 * message. 768 * message.
769 * Input: pathid - Rath identification number. 769 * Input: pathid - Rath identification number.
770 * trgcls - Specifies target class. 770 * trgcls - Specifies target class.
771 * srccls - Specifies the source message class. 771 * srccls - Specifies the source message class.
772 * msgtag - Specifies a tag to be associated with the message. 772 * msgtag - Specifies a tag to be associated with the message.
773 * flags1 - Option for path. 773 * flags1 - Option for path.
774 * IPPRTY- 0x20 Specifies if you want to send priority message. 774 * IPPRTY- 0x20 Specifies if you want to send priority message.
775 * prmmsg - 8-bytes of data to be placed in parameter list. 775 * prmmsg - 8-bytes of data to be placed in parameter list.
776 * ansbuf - Address of buffer into which IUCV moves the reply of 776 * ansbuf - Address of buffer into which IUCV moves the reply of
777 * this message. 777 * this message.
778 * anslen - Address of length of buffer. 778 * anslen - Address of length of buffer.
779 * Output: msgid - Specifies the message ID. 779 * Output: msgid - Specifies the message ID.
780 * Return: Return code from CP IUCV call. 780 * Return: Return code from CP IUCV call.
781 * (-EINVAL) - Buffer address is NULL. 781 * (-EINVAL) - Buffer address is NULL.
782*/ 782*/
783int iucv_send2way_prmmsg (u16 pathid, 783int iucv_send2way_prmmsg (u16 pathid,
784 u32 * msgid, 784 u32 * msgid,
@@ -788,29 +788,29 @@ int iucv_send2way_prmmsg (u16 pathid,
788 ulong flags1, 788 ulong flags1,
789 uchar prmmsg[8], void *ansbuf, ulong anslen); 789 uchar prmmsg[8], void *ansbuf, ulong anslen);
790 790
791/* 791/*
792 * Name: iucv_send2way_prmmsg_array 792 * Name: iucv_send2way_prmmsg_array
793 * Purpose: This function transmits data to another application. 793 * Purpose: This function transmits data to another application.
794 * Prmmsg specifies that the 8-bytes of data are to be moved 794 * Prmmsg specifies that the 8-bytes of data are to be moved
795 * into the parameter list. This is a two-way message and the 795 * into the parameter list. This is a two-way message and the
796 * receiver of the message is expected to reply. A buffer 796 * receiver of the message is expected to reply. A buffer
797 * is provided into which IUCV moves the reply to this 797 * is provided into which IUCV moves the reply to this
798 * message. The contents of ansbuf is the address of the 798 * message. The contents of ansbuf is the address of the
799 * array of addresses and lengths of discontiguous buffers 799 * array of addresses and lengths of discontiguous buffers
800 * that contain the reply. 800 * that contain the reply.
801 * Input: pathid - Path identification number. 801 * Input: pathid - Path identification number.
802 * trgcls - Specifies target class. 802 * trgcls - Specifies target class.
803 * srccls - Specifies the source message class. 803 * srccls - Specifies the source message class.
804 * msgtag - Specifies a tag to be associated with the message. 804 * msgtag - Specifies a tag to be associated with the message.
805 * flags1 - Option for path. 805 * flags1 - Option for path.
806 * IPPRTY- 0x20 specifies if you want to send priority message. 806 * IPPRTY- 0x20 specifies if you want to send priority message.
807 * prmmsg - 8-bytes of data to be placed into the parameter list. 807 * prmmsg - 8-bytes of data to be placed into the parameter list.
808 * ansbuf - Address of array of buffer into which IUCV moves the reply 808 * ansbuf - Address of array of buffer into which IUCV moves the reply
809 * of this message. 809 * of this message.
810 * anslen - Address of length of reply buffers. 810 * anslen - Address of length of reply buffers.
811 * Output: msgid - Specifies the message ID. 811 * Output: msgid - Specifies the message ID.
812 * Return: Return code from CP IUCV call. 812 * Return: Return code from CP IUCV call.
813 * (-EINVAL) - Ansbuf address is NULL. 813 * (-EINVAL) - Ansbuf address is NULL.
814*/ 814*/
815int iucv_send2way_prmmsg_array (u16 pathid, 815int iucv_send2way_prmmsg_array (u16 pathid,
816 u32 * msgid, 816 u32 * msgid,
@@ -821,29 +821,29 @@ int iucv_send2way_prmmsg_array (u16 pathid,
821 uchar prmmsg[8], 821 uchar prmmsg[8],
822 iucv_array_t * ansbuf, ulong anslen); 822 iucv_array_t * ansbuf, ulong anslen);
823 823
824/* 824/*
825 * Name: iucv_setmask 825 * Name: iucv_setmask
826 * Purpose: This function enables or disables the following IUCV 826 * Purpose: This function enables or disables the following IUCV
827 * external interruptions: Nonpriority and priority message 827 * external interruptions: Nonpriority and priority message
828 * interrupts, nonpriority and priority reply interrupts. 828 * interrupts, nonpriority and priority reply interrupts.
829 * Input: SetMaskFlag - options for interrupts 829 * Input: SetMaskFlag - options for interrupts
830 * 0x80 - Nonpriority_MessagePendingInterruptsFlag 830 * 0x80 - Nonpriority_MessagePendingInterruptsFlag
831 * 0x40 - Priority_MessagePendingInterruptsFlag 831 * 0x40 - Priority_MessagePendingInterruptsFlag
832 * 0x20 - Nonpriority_MessageCompletionInterruptsFlag 832 * 0x20 - Nonpriority_MessageCompletionInterruptsFlag
833 * 0x10 - Priority_MessageCompletionInterruptsFlag 833 * 0x10 - Priority_MessageCompletionInterruptsFlag
834 * 0x08 - IUCVControlInterruptsFlag 834 * 0x08 - IUCVControlInterruptsFlag
835 * Output: NA 835 * Output: NA
836 * Return: Return code from CP IUCV call. 836 * Return: Return code from CP IUCV call.
837*/ 837*/
838int iucv_setmask (int SetMaskFlag); 838int iucv_setmask (int SetMaskFlag);
839 839
840/* 840/*
841 * Name: iucv_sever 841 * Name: iucv_sever
842 * Purpose: This function terminates an IUCV path. 842 * Purpose: This function terminates an IUCV path.
843 * Input: pathid - Path identification number. 843 * Input: pathid - Path identification number.
844 * user_data - 16-bytes of user data. 844 * user_data - 16-bytes of user data.
845 * Output: NA 845 * Output: NA
846 * Return: Return code from CP IUCV call. 846 * Return: Return code from CP IUCV call.
847 * (-EINVAL) - Interal error, wild pointer. 847 * (-EINVAL) - Interal error, wild pointer.
848*/ 848*/
849int iucv_sever (u16 pathid, uchar user_data[16]); 849int iucv_sever (u16 pathid, uchar user_data[16]);
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index e65da921a827..f94419b334f7 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -68,6 +68,7 @@ static void lcs_tasklet(unsigned long);
68static void lcs_start_kernel_thread(struct lcs_card *card); 68static void lcs_start_kernel_thread(struct lcs_card *card);
69static void lcs_get_frames_cb(struct lcs_channel *, struct lcs_buffer *); 69static void lcs_get_frames_cb(struct lcs_channel *, struct lcs_buffer *);
70static int lcs_send_delipm(struct lcs_card *, struct lcs_ipm_list *); 70static int lcs_send_delipm(struct lcs_card *, struct lcs_ipm_list *);
71static int lcs_recovery(void *ptr);
71 72
72/** 73/**
73 * Debug Facility Stuff 74 * Debug Facility Stuff
@@ -429,12 +430,6 @@ lcs_setup_card(struct lcs_card *card)
429 card->tx_buffer = NULL; 430 card->tx_buffer = NULL;
430 card->tx_emitted = 0; 431 card->tx_emitted = 0;
431 432
432 /* Initialize kernel thread task used for LGW commands. */
433 INIT_WORK(&card->kernel_thread_starter,
434 (void *)lcs_start_kernel_thread,card);
435 card->thread_start_mask = 0;
436 card->thread_allowed_mask = 0;
437 card->thread_running_mask = 0;
438 init_waitqueue_head(&card->wait_q); 433 init_waitqueue_head(&card->wait_q);
439 spin_lock_init(&card->lock); 434 spin_lock_init(&card->lock);
440 spin_lock_init(&card->ipm_lock); 435 spin_lock_init(&card->ipm_lock);
@@ -675,8 +670,9 @@ lcs_ready_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
675 int index, rc; 670 int index, rc;
676 671
677 LCS_DBF_TEXT(5, trace, "rdybuff"); 672 LCS_DBF_TEXT(5, trace, "rdybuff");
678 BUG_ON(buffer->state != BUF_STATE_LOCKED && 673 if (buffer->state != BUF_STATE_LOCKED &&
679 buffer->state != BUF_STATE_PROCESSED); 674 buffer->state != BUF_STATE_PROCESSED)
675 BUG();
680 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); 676 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
681 buffer->state = BUF_STATE_READY; 677 buffer->state = BUF_STATE_READY;
682 index = buffer - channel->iob; 678 index = buffer - channel->iob;
@@ -700,7 +696,8 @@ __lcs_processed_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
700 int index, prev, next; 696 int index, prev, next;
701 697
702 LCS_DBF_TEXT(5, trace, "prcsbuff"); 698 LCS_DBF_TEXT(5, trace, "prcsbuff");
703 BUG_ON(buffer->state != BUF_STATE_READY); 699 if (buffer->state != BUF_STATE_READY)
700 BUG();
704 buffer->state = BUF_STATE_PROCESSED; 701 buffer->state = BUF_STATE_PROCESSED;
705 index = buffer - channel->iob; 702 index = buffer - channel->iob;
706 prev = (index - 1) & (LCS_NUM_BUFFS - 1); 703 prev = (index - 1) & (LCS_NUM_BUFFS - 1);
@@ -732,8 +729,9 @@ lcs_release_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
732 unsigned long flags; 729 unsigned long flags;
733 730
734 LCS_DBF_TEXT(5, trace, "relbuff"); 731 LCS_DBF_TEXT(5, trace, "relbuff");
735 BUG_ON(buffer->state != BUF_STATE_LOCKED && 732 if (buffer->state != BUF_STATE_LOCKED &&
736 buffer->state != BUF_STATE_PROCESSED); 733 buffer->state != BUF_STATE_PROCESSED)
734 BUG();
737 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); 735 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
738 buffer->state = BUF_STATE_EMPTY; 736 buffer->state = BUF_STATE_EMPTY;
739 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags); 737 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
@@ -1147,8 +1145,6 @@ list_modified:
1147 list_add_tail(&ipm->list, &card->ipm_list); 1145 list_add_tail(&ipm->list, &card->ipm_list);
1148 } 1146 }
1149 spin_unlock_irqrestore(&card->ipm_lock, flags); 1147 spin_unlock_irqrestore(&card->ipm_lock, flags);
1150 if (card->state == DEV_STATE_UP)
1151 netif_wake_queue(card->dev);
1152} 1148}
1153 1149
1154/** 1150/**
@@ -1231,17 +1227,17 @@ lcs_set_mc_addresses(struct lcs_card *card, struct in_device *in4_dev)
1231 if (ipm != NULL) 1227 if (ipm != NULL)
1232 continue; /* Address already in list. */ 1228 continue; /* Address already in list. */
1233 ipm = (struct lcs_ipm_list *) 1229 ipm = (struct lcs_ipm_list *)
1234 kmalloc(sizeof(struct lcs_ipm_list), GFP_ATOMIC); 1230 kzalloc(sizeof(struct lcs_ipm_list), GFP_ATOMIC);
1235 if (ipm == NULL) { 1231 if (ipm == NULL) {
1236 PRINT_INFO("Not enough memory to add " 1232 PRINT_INFO("Not enough memory to add "
1237 "new multicast entry!\n"); 1233 "new multicast entry!\n");
1238 break; 1234 break;
1239 } 1235 }
1240 memset(ipm, 0, sizeof(struct lcs_ipm_list));
1241 memcpy(&ipm->ipm.mac_addr, buf, LCS_MAC_LENGTH); 1236 memcpy(&ipm->ipm.mac_addr, buf, LCS_MAC_LENGTH);
1242 ipm->ipm.ip_addr = im4->multiaddr; 1237 ipm->ipm.ip_addr = im4->multiaddr;
1243 ipm->ipm_state = LCS_IPM_STATE_SET_REQUIRED; 1238 ipm->ipm_state = LCS_IPM_STATE_SET_REQUIRED;
1244 spin_lock_irqsave(&card->ipm_lock, flags); 1239 spin_lock_irqsave(&card->ipm_lock, flags);
1240 LCS_DBF_HEX(2,trace,&ipm->ipm.ip_addr,4);
1245 list_add(&ipm->list, &card->ipm_list); 1241 list_add(&ipm->list, &card->ipm_list);
1246 spin_unlock_irqrestore(&card->ipm_lock, flags); 1242 spin_unlock_irqrestore(&card->ipm_lock, flags);
1247 } 1243 }
@@ -1269,7 +1265,15 @@ lcs_register_mc_addresses(void *data)
1269 read_unlock(&in4_dev->mc_list_lock); 1265 read_unlock(&in4_dev->mc_list_lock);
1270 in_dev_put(in4_dev); 1266 in_dev_put(in4_dev);
1271 1267
1268 netif_carrier_off(card->dev);
1269 netif_tx_disable(card->dev);
1270 wait_event(card->write.wait_q,
1271 (card->write.state != CH_STATE_RUNNING));
1272 lcs_fix_multicast_list(card); 1272 lcs_fix_multicast_list(card);
1273 if (card->state == DEV_STATE_UP) {
1274 netif_carrier_on(card->dev);
1275 netif_wake_queue(card->dev);
1276 }
1273out: 1277out:
1274 lcs_clear_thread_running_bit(card, LCS_SET_MC_THREAD); 1278 lcs_clear_thread_running_bit(card, LCS_SET_MC_THREAD);
1275 return 0; 1279 return 0;
@@ -1286,7 +1290,7 @@ lcs_set_multicast_list(struct net_device *dev)
1286 LCS_DBF_TEXT(4, trace, "setmulti"); 1290 LCS_DBF_TEXT(4, trace, "setmulti");
1287 card = (struct lcs_card *) dev->priv; 1291 card = (struct lcs_card *) dev->priv;
1288 1292
1289 if (!lcs_set_thread_start_bit(card, LCS_SET_MC_THREAD)) 1293 if (!lcs_set_thread_start_bit(card, LCS_SET_MC_THREAD))
1290 schedule_work(&card->kernel_thread_starter); 1294 schedule_work(&card->kernel_thread_starter);
1291} 1295}
1292 1296
@@ -1318,6 +1322,53 @@ lcs_check_irb_error(struct ccw_device *cdev, struct irb *irb)
1318 return PTR_ERR(irb); 1322 return PTR_ERR(irb);
1319} 1323}
1320 1324
1325static int
1326lcs_get_problem(struct ccw_device *cdev, struct irb *irb)
1327{
1328 int dstat, cstat;
1329 char *sense;
1330
1331 sense = (char *) irb->ecw;
1332 cstat = irb->scsw.cstat;
1333 dstat = irb->scsw.dstat;
1334
1335 if (cstat & (SCHN_STAT_CHN_CTRL_CHK | SCHN_STAT_INTF_CTRL_CHK |
1336 SCHN_STAT_CHN_DATA_CHK | SCHN_STAT_CHAIN_CHECK |
1337 SCHN_STAT_PROT_CHECK | SCHN_STAT_PROG_CHECK)) {
1338 LCS_DBF_TEXT(2, trace, "CGENCHK");
1339 return 1;
1340 }
1341 if (dstat & DEV_STAT_UNIT_CHECK) {
1342 if (sense[LCS_SENSE_BYTE_1] &
1343 LCS_SENSE_RESETTING_EVENT) {
1344 LCS_DBF_TEXT(2, trace, "REVIND");
1345 return 1;
1346 }
1347 if (sense[LCS_SENSE_BYTE_0] &
1348 LCS_SENSE_CMD_REJECT) {
1349 LCS_DBF_TEXT(2, trace, "CMDREJ");
1350 return 0;
1351 }
1352 if ((!sense[LCS_SENSE_BYTE_0]) &&
1353 (!sense[LCS_SENSE_BYTE_1]) &&
1354 (!sense[LCS_SENSE_BYTE_2]) &&
1355 (!sense[LCS_SENSE_BYTE_3])) {
1356 LCS_DBF_TEXT(2, trace, "ZEROSEN");
1357 return 0;
1358 }
1359 LCS_DBF_TEXT(2, trace, "DGENCHK");
1360 return 1;
1361 }
1362 return 0;
1363}
1364
1365void
1366lcs_schedule_recovery(struct lcs_card *card)
1367{
1368 LCS_DBF_TEXT(2, trace, "startrec");
1369 if (!lcs_set_thread_start_bit(card, LCS_RECOVERY_THREAD))
1370 schedule_work(&card->kernel_thread_starter);
1371}
1321 1372
1322/** 1373/**
1323 * IRQ Handler for LCS channels 1374 * IRQ Handler for LCS channels
@@ -1327,7 +1378,8 @@ lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
1327{ 1378{
1328 struct lcs_card *card; 1379 struct lcs_card *card;
1329 struct lcs_channel *channel; 1380 struct lcs_channel *channel;
1330 int index; 1381 int rc, index;
1382 int cstat, dstat;
1331 1383
1332 if (lcs_check_irb_error(cdev, irb)) 1384 if (lcs_check_irb_error(cdev, irb))
1333 return; 1385 return;
@@ -1338,14 +1390,27 @@ lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
1338 else 1390 else
1339 channel = &card->write; 1391 channel = &card->write;
1340 1392
1393 cstat = irb->scsw.cstat;
1394 dstat = irb->scsw.dstat;
1341 LCS_DBF_TEXT_(5, trace, "Rint%s",cdev->dev.bus_id); 1395 LCS_DBF_TEXT_(5, trace, "Rint%s",cdev->dev.bus_id);
1342 LCS_DBF_TEXT_(5, trace, "%4x%4x",irb->scsw.cstat, irb->scsw.dstat); 1396 LCS_DBF_TEXT_(5, trace, "%4x%4x",irb->scsw.cstat, irb->scsw.dstat);
1343 LCS_DBF_TEXT_(5, trace, "%4x%4x",irb->scsw.fctl, irb->scsw.actl); 1397 LCS_DBF_TEXT_(5, trace, "%4x%4x",irb->scsw.fctl, irb->scsw.actl);
1344 1398
1399 /* Check for channel and device errors presented */
1400 rc = lcs_get_problem(cdev, irb);
1401 if (rc || (dstat & DEV_STAT_UNIT_EXCEP)) {
1402 PRINT_WARN("check on device %s, dstat=0x%X, cstat=0x%X \n",
1403 cdev->dev.bus_id, dstat, cstat);
1404 if (rc) {
1405 lcs_schedule_recovery(card);
1406 wake_up(&card->wait_q);
1407 return;
1408 }
1409 }
1345 /* How far in the ccw chain have we processed? */ 1410 /* How far in the ccw chain have we processed? */
1346 if ((channel->state != CH_STATE_INIT) && 1411 if ((channel->state != CH_STATE_INIT) &&
1347 (irb->scsw.fctl & SCSW_FCTL_START_FUNC)) { 1412 (irb->scsw.fctl & SCSW_FCTL_START_FUNC)) {
1348 index = (struct ccw1 *) __va((addr_t) irb->scsw.cpa) 1413 index = (struct ccw1 *) __va((addr_t) irb->scsw.cpa)
1349 - channel->ccws; 1414 - channel->ccws;
1350 if ((irb->scsw.actl & SCSW_ACTL_SUSPENDED) || 1415 if ((irb->scsw.actl & SCSW_ACTL_SUSPENDED) ||
1351 (irb->scsw.cstat & SCHN_STAT_PCI)) 1416 (irb->scsw.cstat & SCHN_STAT_PCI))
@@ -1367,7 +1432,6 @@ lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
1367 else if (irb->scsw.actl & SCSW_ACTL_SUSPENDED) 1432 else if (irb->scsw.actl & SCSW_ACTL_SUSPENDED)
1368 /* CCW execution stopped on a suspend bit. */ 1433 /* CCW execution stopped on a suspend bit. */
1369 channel->state = CH_STATE_SUSPENDED; 1434 channel->state = CH_STATE_SUSPENDED;
1370
1371 if (irb->scsw.fctl & SCSW_FCTL_HALT_FUNC) { 1435 if (irb->scsw.fctl & SCSW_FCTL_HALT_FUNC) {
1372 if (irb->scsw.cc != 0) { 1436 if (irb->scsw.cc != 0) {
1373 ccw_device_halt(channel->ccwdev, (addr_t) channel); 1437 ccw_device_halt(channel->ccwdev, (addr_t) channel);
@@ -1376,7 +1440,6 @@ lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
1376 /* The channel has been stopped by halt_IO. */ 1440 /* The channel has been stopped by halt_IO. */
1377 channel->state = CH_STATE_HALTED; 1441 channel->state = CH_STATE_HALTED;
1378 } 1442 }
1379
1380 if (irb->scsw.fctl & SCSW_FCTL_CLEAR_FUNC) { 1443 if (irb->scsw.fctl & SCSW_FCTL_CLEAR_FUNC) {
1381 channel->state = CH_STATE_CLEARED; 1444 channel->state = CH_STATE_CLEARED;
1382 } 1445 }
@@ -1452,7 +1515,7 @@ lcs_txbuffer_cb(struct lcs_channel *channel, struct lcs_buffer *buffer)
1452 lcs_release_buffer(channel, buffer); 1515 lcs_release_buffer(channel, buffer);
1453 card = (struct lcs_card *) 1516 card = (struct lcs_card *)
1454 ((char *) channel - offsetof(struct lcs_card, write)); 1517 ((char *) channel - offsetof(struct lcs_card, write));
1455 if (netif_queue_stopped(card->dev)) 1518 if (netif_queue_stopped(card->dev) && netif_carrier_ok(card->dev))
1456 netif_wake_queue(card->dev); 1519 netif_wake_queue(card->dev);
1457 spin_lock(&card->lock); 1520 spin_lock(&card->lock);
1458 card->tx_emitted--; 1521 card->tx_emitted--;
@@ -1488,6 +1551,10 @@ __lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb,
1488 card->stats.tx_carrier_errors++; 1551 card->stats.tx_carrier_errors++;
1489 return 0; 1552 return 0;
1490 } 1553 }
1554 if (skb->protocol == htons(ETH_P_IPV6)) {
1555 dev_kfree_skb(skb);
1556 return 0;
1557 }
1491 netif_stop_queue(card->dev); 1558 netif_stop_queue(card->dev);
1492 spin_lock(&card->lock); 1559 spin_lock(&card->lock);
1493 if (card->tx_buffer != NULL && 1560 if (card->tx_buffer != NULL &&
@@ -1633,30 +1700,6 @@ lcs_detect(struct lcs_card *card)
1633} 1700}
1634 1701
1635/** 1702/**
1636 * reset card
1637 */
1638static int
1639lcs_resetcard(struct lcs_card *card)
1640{
1641 int retries;
1642
1643 LCS_DBF_TEXT(2, trace, "rescard");
1644 for (retries = 0; retries < 10; retries++) {
1645 if (lcs_detect(card) == 0) {
1646 netif_wake_queue(card->dev);
1647 card->state = DEV_STATE_UP;
1648 PRINT_INFO("LCS device %s successfully restarted!\n",
1649 card->dev->name);
1650 return 0;
1651 }
1652 msleep(3000);
1653 }
1654 PRINT_ERR("Error in Reseting LCS card!\n");
1655 return -EIO;
1656}
1657
1658
1659/**
1660 * LCS Stop card 1703 * LCS Stop card
1661 */ 1704 */
1662static int 1705static int
@@ -1680,126 +1723,18 @@ lcs_stopcard(struct lcs_card *card)
1680} 1723}
1681 1724
1682/** 1725/**
1683 * LGW initiated commands
1684 */
1685static int
1686lcs_lgw_startlan_thread(void *data)
1687{
1688 struct lcs_card *card;
1689
1690 card = (struct lcs_card *) data;
1691 daemonize("lgwstpln");
1692
1693 if (!lcs_do_run_thread(card, LCS_STARTLAN_THREAD))
1694 return 0;
1695 LCS_DBF_TEXT(4, trace, "lgwstpln");
1696 if (card->dev)
1697 netif_stop_queue(card->dev);
1698 if (lcs_startlan(card) == 0) {
1699 netif_wake_queue(card->dev);
1700 card->state = DEV_STATE_UP;
1701 PRINT_INFO("LCS Startlan for device %s succeeded!\n",
1702 card->dev->name);
1703
1704 } else
1705 PRINT_ERR("LCS Startlan for device %s failed!\n",
1706 card->dev->name);
1707 lcs_clear_thread_running_bit(card, LCS_STARTLAN_THREAD);
1708 return 0;
1709}
1710
1711/**
1712 * Send startup command initiated by Lan Gateway
1713 */
1714static int
1715lcs_lgw_startup_thread(void *data)
1716{
1717 int rc;
1718
1719 struct lcs_card *card;
1720
1721 card = (struct lcs_card *) data;
1722 daemonize("lgwstaln");
1723
1724 if (!lcs_do_run_thread(card, LCS_STARTUP_THREAD))
1725 return 0;
1726 LCS_DBF_TEXT(4, trace, "lgwstaln");
1727 if (card->dev)
1728 netif_stop_queue(card->dev);
1729 rc = lcs_send_startup(card, LCS_INITIATOR_LGW);
1730 if (rc != 0) {
1731 PRINT_ERR("Startup for LCS device %s initiated " \
1732 "by LGW failed!\nReseting card ...\n",
1733 card->dev->name);
1734 /* do a card reset */
1735 rc = lcs_resetcard(card);
1736 if (rc == 0)
1737 goto Done;
1738 }
1739 rc = lcs_startlan(card);
1740 if (rc == 0) {
1741 netif_wake_queue(card->dev);
1742 card->state = DEV_STATE_UP;
1743 }
1744Done:
1745 if (rc == 0)
1746 PRINT_INFO("LCS Startup for device %s succeeded!\n",
1747 card->dev->name);
1748 else
1749 PRINT_ERR("LCS Startup for device %s failed!\n",
1750 card->dev->name);
1751 lcs_clear_thread_running_bit(card, LCS_STARTUP_THREAD);
1752 return 0;
1753}
1754
1755
1756/**
1757 * send stoplan command initiated by Lan Gateway
1758 */
1759static int
1760lcs_lgw_stoplan_thread(void *data)
1761{
1762 struct lcs_card *card;
1763 int rc;
1764
1765 card = (struct lcs_card *) data;
1766 daemonize("lgwstop");
1767
1768 if (!lcs_do_run_thread(card, LCS_STOPLAN_THREAD))
1769 return 0;
1770 LCS_DBF_TEXT(4, trace, "lgwstop");
1771 if (card->dev)
1772 netif_stop_queue(card->dev);
1773 if (lcs_send_stoplan(card, LCS_INITIATOR_LGW) == 0)
1774 PRINT_INFO("Stoplan for %s initiated by LGW succeeded!\n",
1775 card->dev->name);
1776 else
1777 PRINT_ERR("Stoplan %s initiated by LGW failed!\n",
1778 card->dev->name);
1779 /*Try to reset the card, stop it on failure */
1780 rc = lcs_resetcard(card);
1781 if (rc != 0)
1782 rc = lcs_stopcard(card);
1783 lcs_clear_thread_running_bit(card, LCS_STOPLAN_THREAD);
1784 return rc;
1785}
1786
1787/**
1788 * Kernel Thread helper functions for LGW initiated commands 1726 * Kernel Thread helper functions for LGW initiated commands
1789 */ 1727 */
1790static void 1728static void
1791lcs_start_kernel_thread(struct lcs_card *card) 1729lcs_start_kernel_thread(struct lcs_card *card)
1792{ 1730{
1793 LCS_DBF_TEXT(5, trace, "krnthrd"); 1731 LCS_DBF_TEXT(5, trace, "krnthrd");
1794 if (lcs_do_start_thread(card, LCS_STARTUP_THREAD)) 1732 if (lcs_do_start_thread(card, LCS_RECOVERY_THREAD))
1795 kernel_thread(lcs_lgw_startup_thread, (void *) card, SIGCHLD); 1733 kernel_thread(lcs_recovery, (void *) card, SIGCHLD);
1796 if (lcs_do_start_thread(card, LCS_STARTLAN_THREAD))
1797 kernel_thread(lcs_lgw_startlan_thread, (void *) card, SIGCHLD);
1798 if (lcs_do_start_thread(card, LCS_STOPLAN_THREAD))
1799 kernel_thread(lcs_lgw_stoplan_thread, (void *) card, SIGCHLD);
1800#ifdef CONFIG_IP_MULTICAST 1734#ifdef CONFIG_IP_MULTICAST
1801 if (lcs_do_start_thread(card, LCS_SET_MC_THREAD)) 1735 if (lcs_do_start_thread(card, LCS_SET_MC_THREAD))
1802 kernel_thread(lcs_register_mc_addresses, (void *) card, SIGCHLD); 1736 kernel_thread(lcs_register_mc_addresses,
1737 (void *) card, SIGCHLD);
1803#endif 1738#endif
1804} 1739}
1805 1740
@@ -1813,19 +1748,14 @@ lcs_get_control(struct lcs_card *card, struct lcs_cmd *cmd)
1813 if (cmd->initiator == LCS_INITIATOR_LGW) { 1748 if (cmd->initiator == LCS_INITIATOR_LGW) {
1814 switch(cmd->cmd_code) { 1749 switch(cmd->cmd_code) {
1815 case LCS_CMD_STARTUP: 1750 case LCS_CMD_STARTUP:
1816 if (!lcs_set_thread_start_bit(card,
1817 LCS_STARTUP_THREAD))
1818 schedule_work(&card->kernel_thread_starter);
1819 break;
1820 case LCS_CMD_STARTLAN: 1751 case LCS_CMD_STARTLAN:
1821 if (!lcs_set_thread_start_bit(card, 1752 lcs_schedule_recovery(card);
1822 LCS_STARTLAN_THREAD))
1823 schedule_work(&card->kernel_thread_starter);
1824 break; 1753 break;
1825 case LCS_CMD_STOPLAN: 1754 case LCS_CMD_STOPLAN:
1826 if (!lcs_set_thread_start_bit(card, 1755 PRINT_WARN("Stoplan for %s initiated by LGW.\n",
1827 LCS_STOPLAN_THREAD)) 1756 card->dev->name);
1828 schedule_work(&card->kernel_thread_starter); 1757 if (card->dev)
1758 netif_carrier_off(card->dev);
1829 break; 1759 break;
1830 default: 1760 default:
1831 PRINT_INFO("UNRECOGNIZED LGW COMMAND\n"); 1761 PRINT_INFO("UNRECOGNIZED LGW COMMAND\n");
@@ -1941,8 +1871,11 @@ lcs_stop_device(struct net_device *dev)
1941 1871
1942 LCS_DBF_TEXT(2, trace, "stopdev"); 1872 LCS_DBF_TEXT(2, trace, "stopdev");
1943 card = (struct lcs_card *) dev->priv; 1873 card = (struct lcs_card *) dev->priv;
1944 netif_stop_queue(dev); 1874 netif_carrier_off(dev);
1875 netif_tx_disable(dev);
1945 dev->flags &= ~IFF_UP; 1876 dev->flags &= ~IFF_UP;
1877 wait_event(card->write.wait_q,
1878 (card->write.state != CH_STATE_RUNNING));
1946 rc = lcs_stopcard(card); 1879 rc = lcs_stopcard(card);
1947 if (rc) 1880 if (rc)
1948 PRINT_ERR("Try it again!\n "); 1881 PRINT_ERR("Try it again!\n ");
@@ -1968,6 +1901,7 @@ lcs_open_device(struct net_device *dev)
1968 1901
1969 } else { 1902 } else {
1970 dev->flags |= IFF_UP; 1903 dev->flags |= IFF_UP;
1904 netif_carrier_on(dev);
1971 netif_wake_queue(dev); 1905 netif_wake_queue(dev);
1972 card->state = DEV_STATE_UP; 1906 card->state = DEV_STATE_UP;
1973 } 1907 }
@@ -2059,10 +1993,31 @@ lcs_timeout_store (struct device *dev, struct device_attribute *attr, const char
2059 1993
2060DEVICE_ATTR(lancmd_timeout, 0644, lcs_timeout_show, lcs_timeout_store); 1994DEVICE_ATTR(lancmd_timeout, 0644, lcs_timeout_show, lcs_timeout_store);
2061 1995
1996static ssize_t
1997lcs_dev_recover_store(struct device *dev, struct device_attribute *attr,
1998 const char *buf, size_t count)
1999{
2000 struct lcs_card *card = dev->driver_data;
2001 char *tmp;
2002 int i;
2003
2004 if (!card)
2005 return -EINVAL;
2006 if (card->state != DEV_STATE_UP)
2007 return -EPERM;
2008 i = simple_strtoul(buf, &tmp, 16);
2009 if (i == 1)
2010 lcs_schedule_recovery(card);
2011 return count;
2012}
2013
2014static DEVICE_ATTR(recover, 0200, NULL, lcs_dev_recover_store);
2015
2062static struct attribute * lcs_attrs[] = { 2016static struct attribute * lcs_attrs[] = {
2063 &dev_attr_portno.attr, 2017 &dev_attr_portno.attr,
2064 &dev_attr_type.attr, 2018 &dev_attr_type.attr,
2065 &dev_attr_lancmd_timeout.attr, 2019 &dev_attr_lancmd_timeout.attr,
2020 &dev_attr_recover.attr,
2066 NULL, 2021 NULL,
2067}; 2022};
2068 2023
@@ -2099,6 +2054,12 @@ lcs_probe_device(struct ccwgroup_device *ccwgdev)
2099 ccwgdev->dev.driver_data = card; 2054 ccwgdev->dev.driver_data = card;
2100 ccwgdev->cdev[0]->handler = lcs_irq; 2055 ccwgdev->cdev[0]->handler = lcs_irq;
2101 ccwgdev->cdev[1]->handler = lcs_irq; 2056 ccwgdev->cdev[1]->handler = lcs_irq;
2057 card->gdev = ccwgdev;
2058 INIT_WORK(&card->kernel_thread_starter,
2059 (void *) lcs_start_kernel_thread, card);
2060 card->thread_start_mask = 0;
2061 card->thread_allowed_mask = 0;
2062 card->thread_running_mask = 0;
2102 return 0; 2063 return 0;
2103} 2064}
2104 2065
@@ -2200,6 +2161,7 @@ netdev_out:
2200 if (recover_state == DEV_STATE_RECOVER) { 2161 if (recover_state == DEV_STATE_RECOVER) {
2201 lcs_set_multicast_list(card->dev); 2162 lcs_set_multicast_list(card->dev);
2202 card->dev->flags |= IFF_UP; 2163 card->dev->flags |= IFF_UP;
2164 netif_carrier_on(card->dev);
2203 netif_wake_queue(card->dev); 2165 netif_wake_queue(card->dev);
2204 card->state = DEV_STATE_UP; 2166 card->state = DEV_STATE_UP;
2205 } else { 2167 } else {
@@ -2229,7 +2191,7 @@ out:
2229 * lcs_shutdown_device, called when setting the group device offline. 2191 * lcs_shutdown_device, called when setting the group device offline.
2230 */ 2192 */
2231static int 2193static int
2232lcs_shutdown_device(struct ccwgroup_device *ccwgdev) 2194__lcs_shutdown_device(struct ccwgroup_device *ccwgdev, int recovery_mode)
2233{ 2195{
2234 struct lcs_card *card; 2196 struct lcs_card *card;
2235 enum lcs_dev_states recover_state; 2197 enum lcs_dev_states recover_state;
@@ -2239,9 +2201,11 @@ lcs_shutdown_device(struct ccwgroup_device *ccwgdev)
2239 card = (struct lcs_card *)ccwgdev->dev.driver_data; 2201 card = (struct lcs_card *)ccwgdev->dev.driver_data;
2240 if (!card) 2202 if (!card)
2241 return -ENODEV; 2203 return -ENODEV;
2242 lcs_set_allowed_threads(card, 0); 2204 if (recovery_mode == 0) {
2243 if (lcs_wait_for_threads(card, LCS_SET_MC_THREAD)) 2205 lcs_set_allowed_threads(card, 0);
2244 return -ERESTARTSYS; 2206 if (lcs_wait_for_threads(card, LCS_SET_MC_THREAD))
2207 return -ERESTARTSYS;
2208 }
2245 LCS_DBF_HEX(3, setup, &card, sizeof(void*)); 2209 LCS_DBF_HEX(3, setup, &card, sizeof(void*));
2246 recover_state = card->state; 2210 recover_state = card->state;
2247 2211
@@ -2256,6 +2220,43 @@ lcs_shutdown_device(struct ccwgroup_device *ccwgdev)
2256 return 0; 2220 return 0;
2257} 2221}
2258 2222
2223static int
2224lcs_shutdown_device(struct ccwgroup_device *ccwgdev)
2225{
2226 return __lcs_shutdown_device(ccwgdev, 0);
2227}
2228
2229/**
2230 * drive lcs recovery after startup and startlan initiated by Lan Gateway
2231 */
2232static int
2233lcs_recovery(void *ptr)
2234{
2235 struct lcs_card *card;
2236 struct ccwgroup_device *gdev;
2237 int rc;
2238
2239 card = (struct lcs_card *) ptr;
2240 daemonize("lcs_recover");
2241
2242 LCS_DBF_TEXT(4, trace, "recover1");
2243 if (!lcs_do_run_thread(card, LCS_RECOVERY_THREAD))
2244 return 0;
2245 LCS_DBF_TEXT(4, trace, "recover2");
2246 gdev = card->gdev;
2247 PRINT_WARN("Recovery of device %s started...\n", gdev->dev.bus_id);
2248 rc = __lcs_shutdown_device(gdev, 1);
2249 rc = lcs_new_device(gdev);
2250 if (!rc)
2251 PRINT_INFO("Device %s successfully recovered!\n",
2252 card->dev->name);
2253 else
2254 PRINT_INFO("Device %s could not be recovered!\n",
2255 card->dev->name);
2256 lcs_clear_thread_running_bit(card, LCS_RECOVERY_THREAD);
2257 return 0;
2258}
2259
2259/** 2260/**
2260 * lcs_remove_device, free buffers and card 2261 * lcs_remove_device, free buffers and card
2261 */ 2262 */
diff --git a/drivers/s390/net/lcs.h b/drivers/s390/net/lcs.h
index 2fad5e40c2e4..93143932983b 100644
--- a/drivers/s390/net/lcs.h
+++ b/drivers/s390/net/lcs.h
@@ -73,13 +73,17 @@ do { \
73/** 73/**
74 * LCS sense byte definitions 74 * LCS sense byte definitions
75 */ 75 */
76#define LCS_SENSE_BYTE_0 0
77#define LCS_SENSE_BYTE_1 1
78#define LCS_SENSE_BYTE_2 2
79#define LCS_SENSE_BYTE_3 3
76#define LCS_SENSE_INTERFACE_DISCONNECT 0x01 80#define LCS_SENSE_INTERFACE_DISCONNECT 0x01
77#define LCS_SENSE_EQUIPMENT_CHECK 0x10 81#define LCS_SENSE_EQUIPMENT_CHECK 0x10
78#define LCS_SENSE_BUS_OUT_CHECK 0x20 82#define LCS_SENSE_BUS_OUT_CHECK 0x20
79#define LCS_SENSE_INTERVENTION_REQUIRED 0x40 83#define LCS_SENSE_INTERVENTION_REQUIRED 0x40
80#define LCS_SENSE_CMD_REJECT 0x80 84#define LCS_SENSE_CMD_REJECT 0x80
81#define LCS_SENSE_RESETTING_EVENT 0x0080 85#define LCS_SENSE_RESETTING_EVENT 0x80
82#define LCS_SENSE_DEVICE_ONLINE 0x0020 86#define LCS_SENSE_DEVICE_ONLINE 0x20
83 87
84/** 88/**
85 * LCS packet type definitions 89 * LCS packet type definitions
@@ -152,10 +156,9 @@ enum lcs_dev_states {
152 156
153enum lcs_threads { 157enum lcs_threads {
154 LCS_SET_MC_THREAD = 1, 158 LCS_SET_MC_THREAD = 1,
155 LCS_STARTLAN_THREAD = 2, 159 LCS_RECOVERY_THREAD = 2,
156 LCS_STOPLAN_THREAD = 4,
157 LCS_STARTUP_THREAD = 8,
158}; 160};
161
159/** 162/**
160 * LCS struct declarations 163 * LCS struct declarations
161 */ 164 */
@@ -286,6 +289,7 @@ struct lcs_card {
286 struct net_device_stats stats; 289 struct net_device_stats stats;
287 unsigned short (*lan_type_trans)(struct sk_buff *skb, 290 unsigned short (*lan_type_trans)(struct sk_buff *skb,
288 struct net_device *dev); 291 struct net_device *dev);
292 struct ccwgroup_device *gdev;
289 struct lcs_channel read; 293 struct lcs_channel read;
290 struct lcs_channel write; 294 struct lcs_channel write;
291 struct lcs_buffer *tx_buffer; 295 struct lcs_buffer *tx_buffer;
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index 260a93c8c442..b452cc1afd55 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -30,7 +30,7 @@
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 * 31 *
32 */ 32 */
33 33
34#undef DEBUG 34#undef DEBUG
35 35
36#include <linux/module.h> 36#include <linux/module.h>
@@ -65,7 +65,7 @@ MODULE_AUTHOR
65 ("(C) 2001 IBM Corporation by Fritz Elfert (felfert@millenux.com)"); 65 ("(C) 2001 IBM Corporation by Fritz Elfert (felfert@millenux.com)");
66MODULE_DESCRIPTION ("Linux for S/390 IUCV network driver"); 66MODULE_DESCRIPTION ("Linux for S/390 IUCV network driver");
67 67
68 68
69#define PRINTK_HEADER " iucv: " /* for debugging */ 69#define PRINTK_HEADER " iucv: " /* for debugging */
70 70
71static struct device_driver netiucv_driver = { 71static struct device_driver netiucv_driver = {
@@ -202,7 +202,7 @@ netiucv_printname(char *name)
202 *p = '\0'; 202 *p = '\0';
203 return tmp; 203 return tmp;
204} 204}
205 205
206/** 206/**
207 * States of the interface statemachine. 207 * States of the interface statemachine.
208 */ 208 */
@@ -244,7 +244,7 @@ static const char *dev_event_names[] = {
244 "Connection up", 244 "Connection up",
245 "Connection down", 245 "Connection down",
246}; 246};
247 247
248/** 248/**
249 * Events of the connection statemachine 249 * Events of the connection statemachine
250 */ 250 */
@@ -364,7 +364,7 @@ static const char *conn_state_names[] = {
364 "Connect error", 364 "Connect error",
365}; 365};
366 366
367 367
368/** 368/**
369 * Debug Facility Stuff 369 * Debug Facility Stuff
370 */ 370 */
@@ -516,7 +516,7 @@ static void
516fsm_action_nop(fsm_instance *fi, int event, void *arg) 516fsm_action_nop(fsm_instance *fi, int event, void *arg)
517{ 517{
518} 518}
519 519
520/** 520/**
521 * Actions of the connection statemachine 521 * Actions of the connection statemachine
522 *****************************************************************************/ 522 *****************************************************************************/
@@ -993,7 +993,7 @@ static const fsm_node conn_fsm[] = {
993 993
994static const int CONN_FSM_LEN = sizeof(conn_fsm) / sizeof(fsm_node); 994static const int CONN_FSM_LEN = sizeof(conn_fsm) / sizeof(fsm_node);
995 995
996 996
997/** 997/**
998 * Actions for interface - statemachine. 998 * Actions for interface - statemachine.
999 *****************************************************************************/ 999 *****************************************************************************/
@@ -1182,7 +1182,7 @@ netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) {
1182 1182
1183 fsm_newstate(conn->fsm, CONN_STATE_TX); 1183 fsm_newstate(conn->fsm, CONN_STATE_TX);
1184 conn->prof.send_stamp = xtime; 1184 conn->prof.send_stamp = xtime;
1185 1185
1186 rc = iucv_send(conn->pathid, NULL, 0, 0, 1 /* single_flag */, 1186 rc = iucv_send(conn->pathid, NULL, 0, 0, 1 /* single_flag */,
1187 0, nskb->data, nskb->len); 1187 0, nskb->data, nskb->len);
1188 /* Shut up, gcc! nskb is always below 2G. */ 1188 /* Shut up, gcc! nskb is always below 2G. */
@@ -1220,7 +1220,7 @@ netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) {
1220 1220
1221 return rc; 1221 return rc;
1222} 1222}
1223 1223
1224/** 1224/**
1225 * Interface API for upper network layers 1225 * Interface API for upper network layers
1226 *****************************************************************************/ 1226 *****************************************************************************/
@@ -1291,7 +1291,7 @@ static int netiucv_tx(struct sk_buff *skb, struct net_device *dev)
1291 1291
1292 /** 1292 /**
1293 * If connection is not running, try to restart it 1293 * If connection is not running, try to restart it
1294 * and throw away packet. 1294 * and throw away packet.
1295 */ 1295 */
1296 if (fsm_getstate(privptr->fsm) != DEV_STATE_RUNNING) { 1296 if (fsm_getstate(privptr->fsm) != DEV_STATE_RUNNING) {
1297 fsm_event(privptr->fsm, DEV_EVENT_START, dev); 1297 fsm_event(privptr->fsm, DEV_EVENT_START, dev);
@@ -1538,7 +1538,7 @@ static ssize_t
1538maxcq_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1538maxcq_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1539{ 1539{
1540 struct netiucv_priv *priv = dev->driver_data; 1540 struct netiucv_priv *priv = dev->driver_data;
1541 1541
1542 IUCV_DBF_TEXT(trace, 4, __FUNCTION__); 1542 IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
1543 priv->conn->prof.maxcqueue = 0; 1543 priv->conn->prof.maxcqueue = 0;
1544 return count; 1544 return count;
@@ -1559,7 +1559,7 @@ static ssize_t
1559sdoio_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1559sdoio_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1560{ 1560{
1561 struct netiucv_priv *priv = dev->driver_data; 1561 struct netiucv_priv *priv = dev->driver_data;
1562 1562
1563 IUCV_DBF_TEXT(trace, 4, __FUNCTION__); 1563 IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
1564 priv->conn->prof.doios_single = 0; 1564 priv->conn->prof.doios_single = 0;
1565 return count; 1565 return count;
@@ -1580,7 +1580,7 @@ static ssize_t
1580mdoio_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1580mdoio_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1581{ 1581{
1582 struct netiucv_priv *priv = dev->driver_data; 1582 struct netiucv_priv *priv = dev->driver_data;
1583 1583
1584 IUCV_DBF_TEXT(trace, 5, __FUNCTION__); 1584 IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
1585 priv->conn->prof.doios_multi = 0; 1585 priv->conn->prof.doios_multi = 0;
1586 return count; 1586 return count;
@@ -1601,7 +1601,7 @@ static ssize_t
1601txlen_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1601txlen_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1602{ 1602{
1603 struct netiucv_priv *priv = dev->driver_data; 1603 struct netiucv_priv *priv = dev->driver_data;
1604 1604
1605 IUCV_DBF_TEXT(trace, 4, __FUNCTION__); 1605 IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
1606 priv->conn->prof.txlen = 0; 1606 priv->conn->prof.txlen = 0;
1607 return count; 1607 return count;
@@ -1622,7 +1622,7 @@ static ssize_t
1622txtime_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1622txtime_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1623{ 1623{
1624 struct netiucv_priv *priv = dev->driver_data; 1624 struct netiucv_priv *priv = dev->driver_data;
1625 1625
1626 IUCV_DBF_TEXT(trace, 4, __FUNCTION__); 1626 IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
1627 priv->conn->prof.tx_time = 0; 1627 priv->conn->prof.tx_time = 0;
1628 return count; 1628 return count;
@@ -2000,7 +2000,7 @@ conn_write(struct device_driver *drv, const char *buf, size_t count)
2000 } 2000 }
2001 2001
2002 PRINT_INFO("%s: '%s'\n", dev->name, netiucv_printname(username)); 2002 PRINT_INFO("%s: '%s'\n", dev->name, netiucv_printname(username));
2003 2003
2004 return count; 2004 return count;
2005 2005
2006out_free_ndev: 2006out_free_ndev:
@@ -2099,7 +2099,7 @@ static int __init
2099netiucv_init(void) 2099netiucv_init(void)
2100{ 2100{
2101 int ret; 2101 int ret;
2102 2102
2103 ret = iucv_register_dbf_views(); 2103 ret = iucv_register_dbf_views();
2104 if (ret) { 2104 if (ret) {
2105 PRINT_WARN("netiucv_init failed, " 2105 PRINT_WARN("netiucv_init failed, "
@@ -2128,7 +2128,7 @@ netiucv_init(void)
2128 } 2128 }
2129 return ret; 2129 return ret;
2130} 2130}
2131 2131
2132module_init(netiucv_init); 2132module_init(netiucv_init);
2133module_exit(netiucv_exit); 2133module_exit(netiucv_exit);
2134MODULE_LICENSE("GPL"); 2134MODULE_LICENSE("GPL");
diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h
index 4df0fcd7b10b..619f4a0c7160 100644
--- a/drivers/s390/net/qeth.h
+++ b/drivers/s390/net/qeth.h
@@ -376,7 +376,7 @@ struct qeth_hdr_osn {
376 __u8 reserved3[18]; 376 __u8 reserved3[18];
377 __u32 ccid; 377 __u32 ccid;
378} __attribute__ ((packed)); 378} __attribute__ ((packed));
379 379
380struct qeth_hdr { 380struct qeth_hdr {
381 union { 381 union {
382 struct qeth_hdr_layer2 l2; 382 struct qeth_hdr_layer2 l2;
@@ -825,7 +825,7 @@ struct qeth_card {
825 int use_hard_stop; 825 int use_hard_stop;
826 int (*orig_hard_header)(struct sk_buff *,struct net_device *, 826 int (*orig_hard_header)(struct sk_buff *,struct net_device *,
827 unsigned short,void *,void *,unsigned); 827 unsigned short,void *,void *,unsigned);
828 struct qeth_osn_info osn_info; 828 struct qeth_osn_info osn_info;
829}; 829};
830 830
831struct qeth_card_list_struct { 831struct qeth_card_list_struct {
@@ -944,7 +944,7 @@ qeth_get_netdev_flags(struct qeth_card *card)
944 return 0; 944 return 0;
945 switch (card->info.type) { 945 switch (card->info.type) {
946 case QETH_CARD_TYPE_IQD: 946 case QETH_CARD_TYPE_IQD:
947 case QETH_CARD_TYPE_OSN: 947 case QETH_CARD_TYPE_OSN:
948 return IFF_NOARP; 948 return IFF_NOARP;
949#ifdef CONFIG_QETH_IPV6 949#ifdef CONFIG_QETH_IPV6
950 default: 950 default:
@@ -981,7 +981,7 @@ static inline int
981qeth_get_max_mtu_for_card(int cardtype) 981qeth_get_max_mtu_for_card(int cardtype)
982{ 982{
983 switch (cardtype) { 983 switch (cardtype) {
984 984
985 case QETH_CARD_TYPE_UNKNOWN: 985 case QETH_CARD_TYPE_UNKNOWN:
986 case QETH_CARD_TYPE_OSAE: 986 case QETH_CARD_TYPE_OSAE:
987 case QETH_CARD_TYPE_OSN: 987 case QETH_CARD_TYPE_OSN:
@@ -1097,9 +1097,9 @@ qeth_string_to_ipaddr4(const char *buf, __u8 *addr)
1097 int count = 0, rc = 0; 1097 int count = 0, rc = 0;
1098 int in[4]; 1098 int in[4];
1099 1099
1100 rc = sscanf(buf, "%d.%d.%d.%d%n", 1100 rc = sscanf(buf, "%d.%d.%d.%d%n",
1101 &in[0], &in[1], &in[2], &in[3], &count); 1101 &in[0], &in[1], &in[2], &in[3], &count);
1102 if (rc != 4 || count) 1102 if (rc != 4 || count<=0)
1103 return -EINVAL; 1103 return -EINVAL;
1104 for (count = 0; count < 4; count++) { 1104 for (count = 0; count < 4; count++) {
1105 if (in[count] > 255) 1105 if (in[count] > 255)
@@ -1131,7 +1131,7 @@ qeth_string_to_ipaddr6(const char *buf, __u8 *addr)
1131 1131
1132 cnt = out = found = save_cnt = num2 = 0; 1132 cnt = out = found = save_cnt = num2 = 0;
1133 end = start = (char *) buf; 1133 end = start = (char *) buf;
1134 in = (__u16 *) addr; 1134 in = (__u16 *) addr;
1135 memset(in, 0, 16); 1135 memset(in, 0, 16);
1136 while (end) { 1136 while (end) {
1137 end = strchr(end,':'); 1137 end = strchr(end,':');
@@ -1139,7 +1139,7 @@ qeth_string_to_ipaddr6(const char *buf, __u8 *addr)
1139 end = (char *)buf + (strlen(buf)); 1139 end = (char *)buf + (strlen(buf));
1140 out = 1; 1140 out = 1;
1141 } 1141 }
1142 if ((end - start)) { 1142 if ((end - start)) {
1143 memset(num, 0, 5); 1143 memset(num, 0, 5);
1144 memcpy(num, start, end - start); 1144 memcpy(num, start, end - start);
1145 if (!qeth_isxdigit(num)) 1145 if (!qeth_isxdigit(num))
@@ -1241,5 +1241,5 @@ qeth_osn_register(unsigned char *read_dev_no,
1241 1241
1242extern void 1242extern void
1243qeth_osn_deregister(struct net_device *); 1243qeth_osn_deregister(struct net_device *);
1244 1244
1245#endif /* __QETH_H__ */ 1245#endif /* __QETH_H__ */
diff --git a/drivers/s390/net/qeth_eddp.c b/drivers/s390/net/qeth_eddp.c
index 44e226f211e7..0bab60a20309 100644
--- a/drivers/s390/net/qeth_eddp.c
+++ b/drivers/s390/net/qeth_eddp.c
@@ -81,7 +81,7 @@ void
81qeth_eddp_buf_release_contexts(struct qeth_qdio_out_buffer *buf) 81qeth_eddp_buf_release_contexts(struct qeth_qdio_out_buffer *buf)
82{ 82{
83 struct qeth_eddp_context_reference *ref; 83 struct qeth_eddp_context_reference *ref;
84 84
85 QETH_DBF_TEXT(trace, 6, "eddprctx"); 85 QETH_DBF_TEXT(trace, 6, "eddprctx");
86 while (!list_empty(&buf->ctx_list)){ 86 while (!list_empty(&buf->ctx_list)){
87 ref = list_entry(buf->ctx_list.next, 87 ref = list_entry(buf->ctx_list.next,
@@ -135,7 +135,7 @@ qeth_eddp_fill_buffer(struct qeth_qdio_out_q *queue,
135 "buffer!\n"); 135 "buffer!\n");
136 goto out; 136 goto out;
137 } 137 }
138 } 138 }
139 /* check if the whole next skb fits into current buffer */ 139 /* check if the whole next skb fits into current buffer */
140 if ((QETH_MAX_BUFFER_ELEMENTS(queue->card) - 140 if ((QETH_MAX_BUFFER_ELEMENTS(queue->card) -
141 buf->next_element_to_fill) 141 buf->next_element_to_fill)
@@ -148,7 +148,7 @@ qeth_eddp_fill_buffer(struct qeth_qdio_out_q *queue,
148 * and increment ctx's refcnt */ 148 * and increment ctx's refcnt */
149 must_refcnt = 1; 149 must_refcnt = 1;
150 continue; 150 continue;
151 } 151 }
152 if (must_refcnt){ 152 if (must_refcnt){
153 must_refcnt = 0; 153 must_refcnt = 0;
154 if (qeth_eddp_buf_ref_context(buf, ctx)){ 154 if (qeth_eddp_buf_ref_context(buf, ctx)){
@@ -266,7 +266,7 @@ qeth_eddp_copy_data_tcp(char *dst, struct qeth_eddp_data *eddp, int len,
266 int left_in_frag; 266 int left_in_frag;
267 int copy_len; 267 int copy_len;
268 u8 *src; 268 u8 *src;
269 269
270 QETH_DBF_TEXT(trace, 5, "eddpcdtc"); 270 QETH_DBF_TEXT(trace, 5, "eddpcdtc");
271 if (skb_shinfo(eddp->skb)->nr_frags == 0) { 271 if (skb_shinfo(eddp->skb)->nr_frags == 0) {
272 memcpy(dst, eddp->skb->data + eddp->skb_offset, len); 272 memcpy(dst, eddp->skb->data + eddp->skb_offset, len);
@@ -408,7 +408,7 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
408 struct tcphdr *tcph; 408 struct tcphdr *tcph;
409 int data_len; 409 int data_len;
410 u32 hcsum; 410 u32 hcsum;
411 411
412 QETH_DBF_TEXT(trace, 5, "eddpftcp"); 412 QETH_DBF_TEXT(trace, 5, "eddpftcp");
413 eddp->skb_offset = sizeof(struct qeth_hdr) + eddp->nhl + eddp->thl; 413 eddp->skb_offset = sizeof(struct qeth_hdr) + eddp->nhl + eddp->thl;
414 if (eddp->qh.hdr.l2.id == QETH_HEADER_TYPE_LAYER2) { 414 if (eddp->qh.hdr.l2.id == QETH_HEADER_TYPE_LAYER2) {
@@ -465,13 +465,13 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
465 eddp->th.tcp.h.seq += data_len; 465 eddp->th.tcp.h.seq += data_len;
466 } 466 }
467} 467}
468 468
469static inline int 469static inline int
470qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx, 470qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
471 struct sk_buff *skb, struct qeth_hdr *qhdr) 471 struct sk_buff *skb, struct qeth_hdr *qhdr)
472{ 472{
473 struct qeth_eddp_data *eddp = NULL; 473 struct qeth_eddp_data *eddp = NULL;
474 474
475 QETH_DBF_TEXT(trace, 5, "eddpficx"); 475 QETH_DBF_TEXT(trace, 5, "eddpficx");
476 /* create our segmentation headers and copy original headers */ 476 /* create our segmentation headers and copy original headers */
477 if (skb->protocol == ETH_P_IP) 477 if (skb->protocol == ETH_P_IP)
@@ -512,7 +512,7 @@ qeth_eddp_calc_num_pages(struct qeth_eddp_context *ctx, struct sk_buff *skb,
512 int hdr_len) 512 int hdr_len)
513{ 513{
514 int skbs_per_page; 514 int skbs_per_page;
515 515
516 QETH_DBF_TEXT(trace, 5, "eddpcanp"); 516 QETH_DBF_TEXT(trace, 5, "eddpcanp");
517 /* can we put multiple skbs in one page? */ 517 /* can we put multiple skbs in one page? */
518 skbs_per_page = PAGE_SIZE / (skb_shinfo(skb)->tso_size + hdr_len); 518 skbs_per_page = PAGE_SIZE / (skb_shinfo(skb)->tso_size + hdr_len);
@@ -588,7 +588,7 @@ qeth_eddp_create_context_tcp(struct qeth_card *card, struct sk_buff *skb,
588 struct qeth_hdr *qhdr) 588 struct qeth_hdr *qhdr)
589{ 589{
590 struct qeth_eddp_context *ctx = NULL; 590 struct qeth_eddp_context *ctx = NULL;
591 591
592 QETH_DBF_TEXT(trace, 5, "creddpct"); 592 QETH_DBF_TEXT(trace, 5, "creddpct");
593 if (skb->protocol == ETH_P_IP) 593 if (skb->protocol == ETH_P_IP)
594 ctx = qeth_eddp_create_context_generic(card, skb, 594 ctx = qeth_eddp_create_context_generic(card, skb,
diff --git a/drivers/s390/net/qeth_fs.h b/drivers/s390/net/qeth_fs.h
index e422b41c656e..61faf05517d6 100644
--- a/drivers/s390/net/qeth_fs.h
+++ b/drivers/s390/net/qeth_fs.h
@@ -42,7 +42,7 @@ qeth_create_device_attributes_osn(struct device *dev);
42 42
43extern void 43extern void
44qeth_remove_device_attributes_osn(struct device *dev); 44qeth_remove_device_attributes_osn(struct device *dev);
45 45
46extern int 46extern int
47qeth_create_driver_attributes(void); 47qeth_create_driver_attributes(void);
48 48
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index cb14642d97aa..9e671a48cd2f 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -513,7 +513,7 @@ __qeth_set_offline(struct ccwgroup_device *cgdev, int recovery_mode)
513 513
514 QETH_DBF_TEXT(setup, 3, "setoffl"); 514 QETH_DBF_TEXT(setup, 3, "setoffl");
515 QETH_DBF_HEX(setup, 3, &card, sizeof(void *)); 515 QETH_DBF_HEX(setup, 3, &card, sizeof(void *));
516 516
517 if (card->dev && netif_carrier_ok(card->dev)) 517 if (card->dev && netif_carrier_ok(card->dev))
518 netif_carrier_off(card->dev); 518 netif_carrier_off(card->dev);
519 recover_flag = card->state; 519 recover_flag = card->state;
@@ -604,13 +604,13 @@ __qeth_ref_ip_on_card(struct qeth_card *card, struct qeth_ipaddr *todo,
604 list_for_each_entry(addr, &card->ip_list, entry) { 604 list_for_each_entry(addr, &card->ip_list, entry) {
605 if (card->options.layer2) { 605 if (card->options.layer2) {
606 if ((addr->type == todo->type) && 606 if ((addr->type == todo->type) &&
607 (memcmp(&addr->mac, &todo->mac, 607 (memcmp(&addr->mac, &todo->mac,
608 OSA_ADDR_LEN) == 0)) { 608 OSA_ADDR_LEN) == 0)) {
609 found = 1; 609 found = 1;
610 break; 610 break;
611 } 611 }
612 continue; 612 continue;
613 } 613 }
614 if ((addr->proto == QETH_PROT_IPV4) && 614 if ((addr->proto == QETH_PROT_IPV4) &&
615 (todo->proto == QETH_PROT_IPV4) && 615 (todo->proto == QETH_PROT_IPV4) &&
616 (addr->type == todo->type) && 616 (addr->type == todo->type) &&
@@ -694,13 +694,13 @@ __qeth_insert_ip_todo(struct qeth_card *card, struct qeth_ipaddr *addr, int add)
694 if (card->options.layer2) { 694 if (card->options.layer2) {
695 if ((tmp->type == addr->type) && 695 if ((tmp->type == addr->type) &&
696 (tmp->is_multicast == addr->is_multicast) && 696 (tmp->is_multicast == addr->is_multicast) &&
697 (memcmp(&tmp->mac, &addr->mac, 697 (memcmp(&tmp->mac, &addr->mac,
698 OSA_ADDR_LEN) == 0)) { 698 OSA_ADDR_LEN) == 0)) {
699 found = 1; 699 found = 1;
700 break; 700 break;
701 } 701 }
702 continue; 702 continue;
703 } 703 }
704 if ((tmp->proto == QETH_PROT_IPV4) && 704 if ((tmp->proto == QETH_PROT_IPV4) &&
705 (addr->proto == QETH_PROT_IPV4) && 705 (addr->proto == QETH_PROT_IPV4) &&
706 (tmp->type == addr->type) && 706 (tmp->type == addr->type) &&
@@ -1173,7 +1173,7 @@ qeth_determine_card_type(struct qeth_card *card)
1173 "due to hardware limitations!\n"); 1173 "due to hardware limitations!\n");
1174 card->qdio.no_out_queues = 1; 1174 card->qdio.no_out_queues = 1;
1175 card->qdio.default_out_queue = 0; 1175 card->qdio.default_out_queue = 0;
1176 } 1176 }
1177 return 0; 1177 return 0;
1178 } 1178 }
1179 i++; 1179 i++;
@@ -1198,7 +1198,7 @@ qeth_probe_device(struct ccwgroup_device *gdev)
1198 return -ENODEV; 1198 return -ENODEV;
1199 1199
1200 QETH_DBF_TEXT_(setup, 2, "%s", gdev->dev.bus_id); 1200 QETH_DBF_TEXT_(setup, 2, "%s", gdev->dev.bus_id);
1201 1201
1202 card = qeth_alloc_card(); 1202 card = qeth_alloc_card();
1203 if (!card) { 1203 if (!card) {
1204 put_device(dev); 1204 put_device(dev);
@@ -1220,7 +1220,7 @@ qeth_probe_device(struct ccwgroup_device *gdev)
1220 put_device(dev); 1220 put_device(dev);
1221 qeth_free_card(card); 1221 qeth_free_card(card);
1222 return rc; 1222 return rc;
1223 } 1223 }
1224 if ((rc = qeth_setup_card(card))){ 1224 if ((rc = qeth_setup_card(card))){
1225 QETH_DBF_TEXT_(setup, 2, "2err%d", rc); 1225 QETH_DBF_TEXT_(setup, 2, "2err%d", rc);
1226 put_device(dev); 1226 put_device(dev);
@@ -1843,7 +1843,7 @@ struct qeth_cmd_buffer *iob)
1843 &card->seqno.pdu_hdr_ack, QETH_SEQ_NO_LENGTH); 1843 &card->seqno.pdu_hdr_ack, QETH_SEQ_NO_LENGTH);
1844 QETH_DBF_HEX(control, 2, iob->data, QETH_DBF_CONTROL_LEN); 1844 QETH_DBF_HEX(control, 2, iob->data, QETH_DBF_CONTROL_LEN);
1845} 1845}
1846 1846
1847static int 1847static int
1848qeth_send_control_data(struct qeth_card *card, int len, 1848qeth_send_control_data(struct qeth_card *card, int len,
1849 struct qeth_cmd_buffer *iob, 1849 struct qeth_cmd_buffer *iob,
@@ -1937,7 +1937,7 @@ qeth_osn_send_control_data(struct qeth_card *card, int len,
1937 wake_up(&card->wait_q); 1937 wake_up(&card->wait_q);
1938 } 1938 }
1939 return rc; 1939 return rc;
1940} 1940}
1941 1941
1942static inline void 1942static inline void
1943qeth_prepare_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob, 1943qeth_prepare_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
@@ -1966,7 +1966,7 @@ qeth_osn_send_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
1966 memcpy(QETH_IPA_PDU_LEN_PDU3(iob->data), &s2, 2); 1966 memcpy(QETH_IPA_PDU_LEN_PDU3(iob->data), &s2, 2);
1967 return qeth_osn_send_control_data(card, s1, iob); 1967 return qeth_osn_send_control_data(card, s1, iob);
1968} 1968}
1969 1969
1970static int 1970static int
1971qeth_send_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob, 1971qeth_send_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
1972 int (*reply_cb) 1972 int (*reply_cb)
@@ -2579,7 +2579,7 @@ qeth_process_inbound_buffer(struct qeth_card *card,
2579 skb->dev = card->dev; 2579 skb->dev = card->dev;
2580 if (hdr->hdr.l2.id == QETH_HEADER_TYPE_LAYER2) 2580 if (hdr->hdr.l2.id == QETH_HEADER_TYPE_LAYER2)
2581 vlan_tag = qeth_layer2_rebuild_skb(card, skb, hdr); 2581 vlan_tag = qeth_layer2_rebuild_skb(card, skb, hdr);
2582 else if (hdr->hdr.l3.id == QETH_HEADER_TYPE_LAYER3) 2582 else if (hdr->hdr.l3.id == QETH_HEADER_TYPE_LAYER3)
2583 qeth_rebuild_skb(card, skb, hdr); 2583 qeth_rebuild_skb(card, skb, hdr);
2584 else { /*in case of OSN*/ 2584 else { /*in case of OSN*/
2585 skb_push(skb, sizeof(struct qeth_hdr)); 2585 skb_push(skb, sizeof(struct qeth_hdr));
@@ -2763,7 +2763,7 @@ qeth_qdio_input_handler(struct ccw_device * ccwdev, unsigned int status,
2763 index = i % QDIO_MAX_BUFFERS_PER_Q; 2763 index = i % QDIO_MAX_BUFFERS_PER_Q;
2764 buffer = &card->qdio.in_q->bufs[index]; 2764 buffer = &card->qdio.in_q->bufs[index];
2765 if (!((status & QDIO_STATUS_LOOK_FOR_ERROR) && 2765 if (!((status & QDIO_STATUS_LOOK_FOR_ERROR) &&
2766 qeth_check_qdio_errors(buffer->buffer, 2766 qeth_check_qdio_errors(buffer->buffer,
2767 qdio_err, siga_err,"qinerr"))) 2767 qdio_err, siga_err,"qinerr")))
2768 qeth_process_inbound_buffer(card, buffer, index); 2768 qeth_process_inbound_buffer(card, buffer, index);
2769 /* clear buffer and give back to hardware */ 2769 /* clear buffer and give back to hardware */
@@ -3187,7 +3187,7 @@ qeth_alloc_qdio_buffers(struct qeth_card *card)
3187 if (card->qdio.state == QETH_QDIO_ALLOCATED) 3187 if (card->qdio.state == QETH_QDIO_ALLOCATED)
3188 return 0; 3188 return 0;
3189 3189
3190 card->qdio.in_q = kmalloc(sizeof(struct qeth_qdio_q), 3190 card->qdio.in_q = kmalloc(sizeof(struct qeth_qdio_q),
3191 GFP_KERNEL|GFP_DMA); 3191 GFP_KERNEL|GFP_DMA);
3192 if (!card->qdio.in_q) 3192 if (!card->qdio.in_q)
3193 return - ENOMEM; 3193 return - ENOMEM;
@@ -3476,7 +3476,7 @@ qeth_halt_channels(struct qeth_card *card)
3476 rc3 = qeth_halt_channel(&card->data); 3476 rc3 = qeth_halt_channel(&card->data);
3477 if (rc1) 3477 if (rc1)
3478 return rc1; 3478 return rc1;
3479 if (rc2) 3479 if (rc2)
3480 return rc2; 3480 return rc2;
3481 return rc3; 3481 return rc3;
3482} 3482}
@@ -3491,7 +3491,7 @@ qeth_clear_channels(struct qeth_card *card)
3491 rc3 = qeth_clear_channel(&card->data); 3491 rc3 = qeth_clear_channel(&card->data);
3492 if (rc1) 3492 if (rc1)
3493 return rc1; 3493 return rc1;
3494 if (rc2) 3494 if (rc2)
3495 return rc2; 3495 return rc2;
3496 return rc3; 3496 return rc3;
3497} 3497}
@@ -3798,10 +3798,10 @@ qeth_open(struct net_device *dev)
3798 QETH_DBF_TEXT(trace,4,"nomacadr"); 3798 QETH_DBF_TEXT(trace,4,"nomacadr");
3799 return -EPERM; 3799 return -EPERM;
3800 } 3800 }
3801 card->dev->flags |= IFF_UP;
3802 netif_start_queue(dev);
3803 card->data.state = CH_STATE_UP; 3801 card->data.state = CH_STATE_UP;
3804 card->state = CARD_STATE_UP; 3802 card->state = CARD_STATE_UP;
3803 card->dev->flags |= IFF_UP;
3804 netif_start_queue(dev);
3805 3805
3806 if (!card->lan_online && netif_carrier_ok(dev)) 3806 if (!card->lan_online && netif_carrier_ok(dev))
3807 netif_carrier_off(dev); 3807 netif_carrier_off(dev);
@@ -3817,7 +3817,7 @@ qeth_stop(struct net_device *dev)
3817 3817
3818 card = (struct qeth_card *) dev->priv; 3818 card = (struct qeth_card *) dev->priv;
3819 3819
3820 netif_stop_queue(dev); 3820 netif_tx_disable(dev);
3821 card->dev->flags &= ~IFF_UP; 3821 card->dev->flags &= ~IFF_UP;
3822 if (card->state == CARD_STATE_UP) 3822 if (card->state == CARD_STATE_UP)
3823 card->state = CARD_STATE_SOFTSETUP; 3823 card->state = CARD_STATE_SOFTSETUP;
@@ -3958,7 +3958,7 @@ qeth_prepare_skb(struct qeth_card *card, struct sk_buff **skb,
3958#endif 3958#endif
3959 *hdr = (struct qeth_hdr *) 3959 *hdr = (struct qeth_hdr *)
3960 qeth_push_skb(card, skb, sizeof(struct qeth_hdr)); 3960 qeth_push_skb(card, skb, sizeof(struct qeth_hdr));
3961 if (hdr == NULL) 3961 if (*hdr == NULL)
3962 return -EINVAL; 3962 return -EINVAL;
3963 return 0; 3963 return 0;
3964} 3964}
@@ -4098,7 +4098,7 @@ qeth_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
4098 } 4098 }
4099 } else { /* passthrough */ 4099 } else { /* passthrough */
4100 if((skb->dev->type == ARPHRD_IEEE802_TR) && 4100 if((skb->dev->type == ARPHRD_IEEE802_TR) &&
4101 !memcmp(skb->data + sizeof(struct qeth_hdr) + 4101 !memcmp(skb->data + sizeof(struct qeth_hdr) +
4102 sizeof(__u16), skb->dev->broadcast, 6)) { 4102 sizeof(__u16), skb->dev->broadcast, 6)) {
4103 hdr->hdr.l3.flags = QETH_CAST_BROADCAST | 4103 hdr->hdr.l3.flags = QETH_CAST_BROADCAST |
4104 QETH_HDR_PASSTHRU; 4104 QETH_HDR_PASSTHRU;
@@ -4385,7 +4385,7 @@ out:
4385} 4385}
4386 4386
4387static inline int 4387static inline int
4388qeth_get_elements_no(struct qeth_card *card, void *hdr, 4388qeth_get_elements_no(struct qeth_card *card, void *hdr,
4389 struct sk_buff *skb, int elems) 4389 struct sk_buff *skb, int elems)
4390{ 4390{
4391 int elements_needed = 0; 4391 int elements_needed = 0;
@@ -4416,6 +4416,8 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
4416 enum qeth_large_send_types large_send = QETH_LARGE_SEND_NO; 4416 enum qeth_large_send_types large_send = QETH_LARGE_SEND_NO;
4417 struct qeth_eddp_context *ctx = NULL; 4417 struct qeth_eddp_context *ctx = NULL;
4418 int tx_bytes = skb->len; 4418 int tx_bytes = skb->len;
4419 unsigned short nr_frags = skb_shinfo(skb)->nr_frags;
4420 unsigned short tso_size = skb_shinfo(skb)->tso_size;
4419 int rc; 4421 int rc;
4420 4422
4421 QETH_DBF_TEXT(trace, 6, "sendpkt"); 4423 QETH_DBF_TEXT(trace, 6, "sendpkt");
@@ -4441,7 +4443,7 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
4441 return 0; 4443 return 0;
4442 } 4444 }
4443 cast_type = qeth_get_cast_type(card, skb); 4445 cast_type = qeth_get_cast_type(card, skb);
4444 if ((cast_type == RTN_BROADCAST) && 4446 if ((cast_type == RTN_BROADCAST) &&
4445 (card->info.broadcast_capable == 0)){ 4447 (card->info.broadcast_capable == 0)){
4446 card->stats.tx_dropped++; 4448 card->stats.tx_dropped++;
4447 card->stats.tx_errors++; 4449 card->stats.tx_errors++;
@@ -4463,7 +4465,7 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
4463 card->stats.tx_errors++; 4465 card->stats.tx_errors++;
4464 dev_kfree_skb_any(skb); 4466 dev_kfree_skb_any(skb);
4465 return NETDEV_TX_OK; 4467 return NETDEV_TX_OK;
4466 } 4468 }
4467 elements_needed++; 4469 elements_needed++;
4468 } else { 4470 } else {
4469 if ((rc = qeth_prepare_skb(card, &skb, &hdr, ipv))) { 4471 if ((rc = qeth_prepare_skb(card, &skb, &hdr, ipv))) {
@@ -4498,16 +4500,16 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
4498 card->stats.tx_packets++; 4500 card->stats.tx_packets++;
4499 card->stats.tx_bytes += tx_bytes; 4501 card->stats.tx_bytes += tx_bytes;
4500#ifdef CONFIG_QETH_PERF_STATS 4502#ifdef CONFIG_QETH_PERF_STATS
4501 if (skb_shinfo(skb)->tso_size && 4503 if (tso_size &&
4502 !(large_send == QETH_LARGE_SEND_NO)) { 4504 !(large_send == QETH_LARGE_SEND_NO)) {
4503 card->perf_stats.large_send_bytes += skb->len; 4505 card->perf_stats.large_send_bytes += tx_bytes;
4504 card->perf_stats.large_send_cnt++; 4506 card->perf_stats.large_send_cnt++;
4505 } 4507 }
4506 if (skb_shinfo(skb)->nr_frags > 0){ 4508 if (nr_frags > 0){
4507 card->perf_stats.sg_skbs_sent++; 4509 card->perf_stats.sg_skbs_sent++;
4508 /* nr_frags + skb->data */ 4510 /* nr_frags + skb->data */
4509 card->perf_stats.sg_frags_sent += 4511 card->perf_stats.sg_frags_sent +=
4510 skb_shinfo(skb)->nr_frags + 1; 4512 nr_frags + 1;
4511 } 4513 }
4512#endif /* CONFIG_QETH_PERF_STATS */ 4514#endif /* CONFIG_QETH_PERF_STATS */
4513 } 4515 }
@@ -5373,7 +5375,7 @@ qeth_layer2_send_setdelvlan_cb(struct qeth_card *card,
5373 cmd = (struct qeth_ipa_cmd *) data; 5375 cmd = (struct qeth_ipa_cmd *) data;
5374 if (cmd->hdr.return_code) { 5376 if (cmd->hdr.return_code) {
5375 PRINT_ERR("Error in processing VLAN %i on %s: 0x%x. " 5377 PRINT_ERR("Error in processing VLAN %i on %s: 0x%x. "
5376 "Continuing\n",cmd->data.setdelvlan.vlan_id, 5378 "Continuing\n",cmd->data.setdelvlan.vlan_id,
5377 QETH_CARD_IFNAME(card), cmd->hdr.return_code); 5379 QETH_CARD_IFNAME(card), cmd->hdr.return_code);
5378 QETH_DBF_TEXT_(trace, 2, "L2VL%4x", cmd->hdr.command); 5380 QETH_DBF_TEXT_(trace, 2, "L2VL%4x", cmd->hdr.command);
5379 QETH_DBF_TEXT_(trace, 2, "L2%s", CARD_BUS_ID(card)); 5381 QETH_DBF_TEXT_(trace, 2, "L2%s", CARD_BUS_ID(card));
@@ -5393,7 +5395,7 @@ qeth_layer2_send_setdelvlan(struct qeth_card *card, __u16 i,
5393 iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4); 5395 iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4);
5394 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); 5396 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
5395 cmd->data.setdelvlan.vlan_id = i; 5397 cmd->data.setdelvlan.vlan_id = i;
5396 return qeth_send_ipa_cmd(card, iob, 5398 return qeth_send_ipa_cmd(card, iob,
5397 qeth_layer2_send_setdelvlan_cb, NULL); 5399 qeth_layer2_send_setdelvlan_cb, NULL);
5398} 5400}
5399 5401
@@ -5457,7 +5459,7 @@ qeth_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
5457 * Examine hardware response to SET_PROMISC_MODE 5459 * Examine hardware response to SET_PROMISC_MODE
5458 */ 5460 */
5459static int 5461static int
5460qeth_setadp_promisc_mode_cb(struct qeth_card *card, 5462qeth_setadp_promisc_mode_cb(struct qeth_card *card,
5461 struct qeth_reply *reply, 5463 struct qeth_reply *reply,
5462 unsigned long data) 5464 unsigned long data)
5463{ 5465{
@@ -5468,10 +5470,10 @@ qeth_setadp_promisc_mode_cb(struct qeth_card *card,
5468 5470
5469 cmd = (struct qeth_ipa_cmd *) data; 5471 cmd = (struct qeth_ipa_cmd *) data;
5470 setparms = &(cmd->data.setadapterparms); 5472 setparms = &(cmd->data.setadapterparms);
5471 5473
5472 qeth_default_setadapterparms_cb(card, reply, (unsigned long)cmd); 5474 qeth_default_setadapterparms_cb(card, reply, (unsigned long)cmd);
5473 if (cmd->hdr.return_code) { 5475 if (cmd->hdr.return_code) {
5474 QETH_DBF_TEXT_(trace,4,"prmrc%2.2x",cmd->hdr.return_code); 5476 QETH_DBF_TEXT_(trace,4,"prmrc%2.2x",cmd->hdr.return_code);
5475 setparms->data.mode = SET_PROMISC_MODE_OFF; 5477 setparms->data.mode = SET_PROMISC_MODE_OFF;
5476 } 5478 }
5477 card->info.promisc_mode = setparms->data.mode; 5479 card->info.promisc_mode = setparms->data.mode;
@@ -5517,7 +5519,7 @@ qeth_set_multicast_list(struct net_device *dev)
5517 5519
5518 if (card->info.type == QETH_CARD_TYPE_OSN) 5520 if (card->info.type == QETH_CARD_TYPE_OSN)
5519 return ; 5521 return ;
5520 5522
5521 QETH_DBF_TEXT(trace, 3, "setmulti"); 5523 QETH_DBF_TEXT(trace, 3, "setmulti");
5522 qeth_delete_mc_addresses(card); 5524 qeth_delete_mc_addresses(card);
5523 if (card->options.layer2) { 5525 if (card->options.layer2) {
@@ -5575,7 +5577,7 @@ qeth_osn_assist(struct net_device *dev,
5575 struct qeth_cmd_buffer *iob; 5577 struct qeth_cmd_buffer *iob;
5576 struct qeth_card *card; 5578 struct qeth_card *card;
5577 int rc; 5579 int rc;
5578 5580
5579 QETH_DBF_TEXT(trace, 2, "osnsdmc"); 5581 QETH_DBF_TEXT(trace, 2, "osnsdmc");
5580 if (!dev) 5582 if (!dev)
5581 return -ENODEV; 5583 return -ENODEV;
@@ -5654,7 +5656,7 @@ qeth_osn_deregister(struct net_device * dev)
5654 card->osn_info.data_cb = NULL; 5656 card->osn_info.data_cb = NULL;
5655 return; 5657 return;
5656} 5658}
5657 5659
5658static void 5660static void
5659qeth_delete_mc_addresses(struct qeth_card *card) 5661qeth_delete_mc_addresses(struct qeth_card *card)
5660{ 5662{
@@ -5818,7 +5820,7 @@ qeth_add_multicast_ipv6(struct qeth_card *card)
5818 struct inet6_dev *in6_dev; 5820 struct inet6_dev *in6_dev;
5819 5821
5820 QETH_DBF_TEXT(trace,4,"chkmcv6"); 5822 QETH_DBF_TEXT(trace,4,"chkmcv6");
5821 if (!qeth_is_supported(card, IPA_IPV6)) 5823 if (!qeth_is_supported(card, IPA_IPV6))
5822 return ; 5824 return ;
5823 in6_dev = in6_dev_get(card->dev); 5825 in6_dev = in6_dev_get(card->dev);
5824 if (in6_dev == NULL) 5826 if (in6_dev == NULL)
@@ -6359,12 +6361,9 @@ qeth_netdev_init(struct net_device *dev)
6359 dev->vlan_rx_kill_vid = qeth_vlan_rx_kill_vid; 6361 dev->vlan_rx_kill_vid = qeth_vlan_rx_kill_vid;
6360 dev->vlan_rx_add_vid = qeth_vlan_rx_add_vid; 6362 dev->vlan_rx_add_vid = qeth_vlan_rx_add_vid;
6361#endif 6363#endif
6362 dev->hard_header = card->orig_hard_header;
6363 if (qeth_get_netdev_flags(card) & IFF_NOARP) { 6364 if (qeth_get_netdev_flags(card) & IFF_NOARP) {
6364 dev->rebuild_header = NULL; 6365 dev->rebuild_header = NULL;
6365 dev->hard_header = NULL; 6366 dev->hard_header = NULL;
6366 if (card->options.fake_ll)
6367 dev->hard_header = qeth_fake_header;
6368 dev->header_cache_update = NULL; 6367 dev->header_cache_update = NULL;
6369 dev->hard_header_cache = NULL; 6368 dev->hard_header_cache = NULL;
6370 } 6369 }
@@ -6373,6 +6372,9 @@ qeth_netdev_init(struct net_device *dev)
6373 if (!(card->info.unique_id & UNIQUE_ID_NOT_BY_CARD)) 6372 if (!(card->info.unique_id & UNIQUE_ID_NOT_BY_CARD))
6374 card->dev->dev_id = card->info.unique_id & 0xffff; 6373 card->dev->dev_id = card->info.unique_id & 0xffff;
6375#endif 6374#endif
6375 if (card->options.fake_ll &&
6376 (qeth_get_netdev_flags(card) & IFF_NOARP))
6377 dev->hard_header = qeth_fake_header;
6376 dev->hard_header_parse = NULL; 6378 dev->hard_header_parse = NULL;
6377 dev->set_mac_address = qeth_layer2_set_mac_address; 6379 dev->set_mac_address = qeth_layer2_set_mac_address;
6378 dev->flags |= qeth_get_netdev_flags(card); 6380 dev->flags |= qeth_get_netdev_flags(card);
@@ -6477,6 +6479,9 @@ retry:
6477 /*network device will be recovered*/ 6479 /*network device will be recovered*/
6478 if (card->dev) { 6480 if (card->dev) {
6479 card->dev->hard_header = card->orig_hard_header; 6481 card->dev->hard_header = card->orig_hard_header;
6482 if (card->options.fake_ll &&
6483 (qeth_get_netdev_flags(card) & IFF_NOARP))
6484 card->dev->hard_header = qeth_fake_header;
6480 return 0; 6485 return 0;
6481 } 6486 }
6482 /* at first set_online allocate netdev */ 6487 /* at first set_online allocate netdev */
@@ -6584,7 +6589,7 @@ qeth_setadpparms_change_macaddr_cb(struct qeth_card *card,
6584 6589
6585 cmd = (struct qeth_ipa_cmd *) data; 6590 cmd = (struct qeth_ipa_cmd *) data;
6586 if (!card->options.layer2 || card->info.guestlan || 6591 if (!card->options.layer2 || card->info.guestlan ||
6587 !(card->info.mac_bits & QETH_LAYER2_MAC_READ)) { 6592 !(card->info.mac_bits & QETH_LAYER2_MAC_READ)) {
6588 memcpy(card->dev->dev_addr, 6593 memcpy(card->dev->dev_addr,
6589 &cmd->data.setadapterparms.data.change_addr.addr, 6594 &cmd->data.setadapterparms.data.change_addr.addr,
6590 OSA_ADDR_LEN); 6595 OSA_ADDR_LEN);
@@ -7031,14 +7036,12 @@ qeth_softsetup_ipv6(struct qeth_card *card)
7031 7036
7032 QETH_DBF_TEXT(trace,3,"softipv6"); 7037 QETH_DBF_TEXT(trace,3,"softipv6");
7033 7038
7034 netif_stop_queue(card->dev);
7035 rc = qeth_send_startlan(card, QETH_PROT_IPV6); 7039 rc = qeth_send_startlan(card, QETH_PROT_IPV6);
7036 if (rc) { 7040 if (rc) {
7037 PRINT_ERR("IPv6 startlan failed on %s\n", 7041 PRINT_ERR("IPv6 startlan failed on %s\n",
7038 QETH_CARD_IFNAME(card)); 7042 QETH_CARD_IFNAME(card));
7039 return rc; 7043 return rc;
7040 } 7044 }
7041 netif_wake_queue(card->dev);
7042 rc = qeth_query_ipassists(card,QETH_PROT_IPV6); 7045 rc = qeth_query_ipassists(card,QETH_PROT_IPV6);
7043 if (rc) { 7046 if (rc) {
7044 PRINT_ERR("IPv6 query ipassist failed on %s\n", 7047 PRINT_ERR("IPv6 query ipassist failed on %s\n",
@@ -7352,7 +7355,8 @@ qeth_set_large_send(struct qeth_card *card, enum qeth_large_send_types type)
7352 card->options.large_send = type; 7355 card->options.large_send = type;
7353 return 0; 7356 return 0;
7354 } 7357 }
7355 netif_stop_queue(card->dev); 7358 if (card->state == CARD_STATE_UP)
7359 netif_tx_disable(card->dev);
7356 card->options.large_send = type; 7360 card->options.large_send = type;
7357 switch (card->options.large_send) { 7361 switch (card->options.large_send) {
7358 case QETH_LARGE_SEND_EDDP: 7362 case QETH_LARGE_SEND_EDDP:
@@ -7374,7 +7378,8 @@ qeth_set_large_send(struct qeth_card *card, enum qeth_large_send_types type)
7374 card->dev->features &= ~(NETIF_F_TSO | NETIF_F_SG); 7378 card->dev->features &= ~(NETIF_F_TSO | NETIF_F_SG);
7375 break; 7379 break;
7376 } 7380 }
7377 netif_wake_queue(card->dev); 7381 if (card->state == CARD_STATE_UP)
7382 netif_wake_queue(card->dev);
7378 return rc; 7383 return rc;
7379} 7384}
7380 7385
@@ -7427,7 +7432,7 @@ qeth_softsetup_card(struct qeth_card *card)
7427 if ((rc = qeth_setrouting_v6(card))) 7432 if ((rc = qeth_setrouting_v6(card)))
7428 QETH_DBF_TEXT_(setup, 2, "5err%d", rc); 7433 QETH_DBF_TEXT_(setup, 2, "5err%d", rc);
7429out: 7434out:
7430 netif_stop_queue(card->dev); 7435 netif_tx_disable(card->dev);
7431 return 0; 7436 return 0;
7432} 7437}
7433 7438
@@ -7567,7 +7572,7 @@ qeth_stop_card(struct qeth_card *card, int recovery_mode)
7567 if (card->read.state == CH_STATE_UP && 7572 if (card->read.state == CH_STATE_UP &&
7568 card->write.state == CH_STATE_UP && 7573 card->write.state == CH_STATE_UP &&
7569 (card->state == CARD_STATE_UP)) { 7574 (card->state == CARD_STATE_UP)) {
7570 if (recovery_mode && 7575 if (recovery_mode &&
7571 card->info.type != QETH_CARD_TYPE_OSN) { 7576 card->info.type != QETH_CARD_TYPE_OSN) {
7572 qeth_stop(card->dev); 7577 qeth_stop(card->dev);
7573 } else { 7578 } else {
@@ -7736,10 +7741,8 @@ static int
7736qeth_register_netdev(struct qeth_card *card) 7741qeth_register_netdev(struct qeth_card *card)
7737{ 7742{
7738 QETH_DBF_TEXT(setup, 3, "regnetd"); 7743 QETH_DBF_TEXT(setup, 3, "regnetd");
7739 if (card->dev->reg_state != NETREG_UNINITIALIZED) { 7744 if (card->dev->reg_state != NETREG_UNINITIALIZED)
7740 qeth_netdev_init(card->dev);
7741 return 0; 7745 return 0;
7742 }
7743 /* sysfs magic */ 7746 /* sysfs magic */
7744 SET_NETDEV_DEV(card->dev, &card->gdev->dev); 7747 SET_NETDEV_DEV(card->dev, &card->gdev->dev);
7745 return register_netdev(card->dev); 7748 return register_netdev(card->dev);
@@ -7750,7 +7753,7 @@ qeth_start_again(struct qeth_card *card, int recovery_mode)
7750{ 7753{
7751 QETH_DBF_TEXT(setup ,2, "startag"); 7754 QETH_DBF_TEXT(setup ,2, "startag");
7752 7755
7753 if (recovery_mode && 7756 if (recovery_mode &&
7754 card->info.type != QETH_CARD_TYPE_OSN) { 7757 card->info.type != QETH_CARD_TYPE_OSN) {
7755 qeth_open(card->dev); 7758 qeth_open(card->dev);
7756 } else { 7759 } else {
diff --git a/drivers/s390/net/qeth_mpc.h b/drivers/s390/net/qeth_mpc.h
index 011c41041029..0477c47471c5 100644
--- a/drivers/s390/net/qeth_mpc.h
+++ b/drivers/s390/net/qeth_mpc.h
@@ -445,7 +445,7 @@ enum qeth_ipa_arp_return_codes {
445/* Helper functions */ 445/* Helper functions */
446#define IS_IPA_REPLY(cmd) ((cmd->hdr.initiator == IPA_CMD_INITIATOR_HOST) || \ 446#define IS_IPA_REPLY(cmd) ((cmd->hdr.initiator == IPA_CMD_INITIATOR_HOST) || \
447 (cmd->hdr.initiator == IPA_CMD_INITIATOR_OSA_REPLY)) 447 (cmd->hdr.initiator == IPA_CMD_INITIATOR_OSA_REPLY))
448 448
449/*****************************************************************************/ 449/*****************************************************************************/
450/* END OF IP Assist related definitions */ 450/* END OF IP Assist related definitions */
451/*****************************************************************************/ 451/*****************************************************************************/
@@ -490,7 +490,7 @@ extern unsigned char ULP_ENABLE[];
490/* Layer 2 defintions */ 490/* Layer 2 defintions */
491#define QETH_PROT_LAYER2 0x08 491#define QETH_PROT_LAYER2 0x08
492#define QETH_PROT_TCPIP 0x03 492#define QETH_PROT_TCPIP 0x03
493#define QETH_PROT_OSN2 0x0a 493#define QETH_PROT_OSN2 0x0a
494#define QETH_ULP_ENABLE_PROT_TYPE(buffer) (buffer+0x50) 494#define QETH_ULP_ENABLE_PROT_TYPE(buffer) (buffer+0x50)
495#define QETH_IPA_CMD_PROT_TYPE(buffer) (buffer+0x19) 495#define QETH_IPA_CMD_PROT_TYPE(buffer) (buffer+0x19)
496 496
diff --git a/drivers/s390/net/qeth_proc.c b/drivers/s390/net/qeth_proc.c
index 360d782c7ada..66f2da14e6e3 100644
--- a/drivers/s390/net/qeth_proc.c
+++ b/drivers/s390/net/qeth_proc.c
@@ -36,7 +36,7 @@ qeth_procfile_seq_start(struct seq_file *s, loff_t *offset)
36{ 36{
37 struct device *dev = NULL; 37 struct device *dev = NULL;
38 loff_t nr = 0; 38 loff_t nr = 0;
39 39
40 down_read(&qeth_ccwgroup_driver.driver.bus->subsys.rwsem); 40 down_read(&qeth_ccwgroup_driver.driver.bus->subsys.rwsem);
41 if (*offset == 0) 41 if (*offset == 0)
42 return SEQ_START_TOKEN; 42 return SEQ_START_TOKEN;
@@ -60,8 +60,8 @@ static void *
60qeth_procfile_seq_next(struct seq_file *s, void *it, loff_t *offset) 60qeth_procfile_seq_next(struct seq_file *s, void *it, loff_t *offset)
61{ 61{
62 struct device *prev, *next; 62 struct device *prev, *next;
63 63
64 if (it == SEQ_START_TOKEN) 64 if (it == SEQ_START_TOKEN)
65 prev = NULL; 65 prev = NULL;
66 else 66 else
67 prev = (struct device *) it; 67 prev = (struct device *) it;
@@ -180,7 +180,7 @@ qeth_perf_procfile_seq_show(struct seq_file *s, void *it)
180 struct device *device; 180 struct device *device;
181 struct qeth_card *card; 181 struct qeth_card *card;
182 182
183 183
184 if (it == SEQ_START_TOKEN) 184 if (it == SEQ_START_TOKEN)
185 return 0; 185 return 0;
186 186
diff --git a/drivers/s390/net/qeth_sys.c b/drivers/s390/net/qeth_sys.c
index 882d419e4160..185a9cfbcbdc 100644
--- a/drivers/s390/net/qeth_sys.c
+++ b/drivers/s390/net/qeth_sys.c
@@ -785,7 +785,7 @@ qeth_dev_large_send_store(struct device *dev, struct device_attribute *attr, con
785 } 785 }
786 if (card->options.large_send == type) 786 if (card->options.large_send == type)
787 return count; 787 return count;
788 if ((rc = qeth_set_large_send(card, type))) 788 if ((rc = qeth_set_large_send(card, type)))
789 return rc; 789 return rc;
790 return count; 790 return count;
791} 791}
@@ -1682,7 +1682,7 @@ qeth_create_device_attributes(struct device *dev)
1682 if (card->info.type == QETH_CARD_TYPE_OSN) 1682 if (card->info.type == QETH_CARD_TYPE_OSN)
1683 return sysfs_create_group(&dev->kobj, 1683 return sysfs_create_group(&dev->kobj,
1684 &qeth_osn_device_attr_group); 1684 &qeth_osn_device_attr_group);
1685 1685
1686 if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_attr_group))) 1686 if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_attr_group)))
1687 return ret; 1687 return ret;
1688 if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_ipato_group))){ 1688 if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_ipato_group))){
@@ -1713,7 +1713,7 @@ qeth_remove_device_attributes(struct device *dev)
1713 if (card->info.type == QETH_CARD_TYPE_OSN) 1713 if (card->info.type == QETH_CARD_TYPE_OSN)
1714 return sysfs_remove_group(&dev->kobj, 1714 return sysfs_remove_group(&dev->kobj,
1715 &qeth_osn_device_attr_group); 1715 &qeth_osn_device_attr_group);
1716 1716
1717 sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); 1717 sysfs_remove_group(&dev->kobj, &qeth_device_attr_group);
1718 sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group); 1718 sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group);
1719 sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group); 1719 sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group);
diff --git a/drivers/s390/net/qeth_tso.h b/drivers/s390/net/qeth_tso.h
index 1286ddea450b..24ef40ca9562 100644
--- a/drivers/s390/net/qeth_tso.h
+++ b/drivers/s390/net/qeth_tso.h
@@ -117,11 +117,11 @@ __qeth_fill_buffer_frag(struct sk_buff *skb, struct qdio_buffer *buffer,
117 int fragno; 117 int fragno;
118 unsigned long addr; 118 unsigned long addr;
119 int element, cnt, dlen; 119 int element, cnt, dlen;
120 120
121 fragno = skb_shinfo(skb)->nr_frags; 121 fragno = skb_shinfo(skb)->nr_frags;
122 element = *next_element_to_fill; 122 element = *next_element_to_fill;
123 dlen = 0; 123 dlen = 0;
124 124
125 if (is_tso) 125 if (is_tso)
126 buffer->element[element].flags = 126 buffer->element[element].flags =
127 SBAL_FLAGS_MIDDLE_FRAG; 127 SBAL_FLAGS_MIDDLE_FRAG;
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index bd147207f25d..b046ffa22101 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -864,6 +864,9 @@ static unsigned int ata_id_xfermask(const u16 *id)
864/** 864/**
865 * ata_port_queue_task - Queue port_task 865 * ata_port_queue_task - Queue port_task
866 * @ap: The ata_port to queue port_task for 866 * @ap: The ata_port to queue port_task for
867 * @fn: workqueue function to be scheduled
868 * @data: data value to pass to workqueue function
869 * @delay: delay time for workqueue function
867 * 870 *
868 * Schedule @fn(@data) for execution after @delay jiffies using 871 * Schedule @fn(@data) for execution after @delay jiffies using
869 * port_task. There is one port_task per port and it's the 872 * port_task. There is one port_task per port and it's the
@@ -2739,6 +2742,8 @@ static unsigned int ata_dev_set_xfermode(struct ata_port *ap,
2739 * ata_dev_init_params - Issue INIT DEV PARAMS command 2742 * ata_dev_init_params - Issue INIT DEV PARAMS command
2740 * @ap: Port associated with device @dev 2743 * @ap: Port associated with device @dev
2741 * @dev: Device to which command will be sent 2744 * @dev: Device to which command will be sent
2745 * @heads: Number of heads (taskfile parameter)
2746 * @sectors: Number of sectors (taskfile parameter)
2742 * 2747 *
2743 * LOCKING: 2748 * LOCKING:
2744 * Kernel thread context (may sleep) 2749 * Kernel thread context (may sleep)
@@ -3638,6 +3643,8 @@ static void ata_pio_block(struct ata_port *ap)
3638 3643
3639 ata_pio_sector(qc); 3644 ata_pio_sector(qc);
3640 } 3645 }
3646
3647 ata_altstatus(ap); /* flush */
3641} 3648}
3642 3649
3643static void ata_pio_error(struct ata_port *ap) 3650static void ata_pio_error(struct ata_port *ap)
@@ -3754,11 +3761,14 @@ static void atapi_packet_task(void *_data)
3754 spin_lock_irqsave(&ap->host_set->lock, flags); 3761 spin_lock_irqsave(&ap->host_set->lock, flags);
3755 ap->flags &= ~ATA_FLAG_NOINTR; 3762 ap->flags &= ~ATA_FLAG_NOINTR;
3756 ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1); 3763 ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1);
3764 ata_altstatus(ap); /* flush */
3765
3757 if (qc->tf.protocol == ATA_PROT_ATAPI_DMA) 3766 if (qc->tf.protocol == ATA_PROT_ATAPI_DMA)
3758 ap->ops->bmdma_start(qc); /* initiate bmdma */ 3767 ap->ops->bmdma_start(qc); /* initiate bmdma */
3759 spin_unlock_irqrestore(&ap->host_set->lock, flags); 3768 spin_unlock_irqrestore(&ap->host_set->lock, flags);
3760 } else { 3769 } else {
3761 ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1); 3770 ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1);
3771 ata_altstatus(ap); /* flush */
3762 3772
3763 /* PIO commands are handled by polling */ 3773 /* PIO commands are handled by polling */
3764 ap->hsm_task_state = HSM_ST; 3774 ap->hsm_task_state = HSM_ST;
@@ -4287,6 +4297,7 @@ static int ata_start_drive(struct ata_port *ap, struct ata_device *dev)
4287int ata_device_resume(struct ata_port *ap, struct ata_device *dev) 4297int ata_device_resume(struct ata_port *ap, struct ata_device *dev)
4288{ 4298{
4289 if (ap->flags & ATA_FLAG_SUSPENDED) { 4299 if (ap->flags & ATA_FLAG_SUSPENDED) {
4300 ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 200000);
4290 ap->flags &= ~ATA_FLAG_SUSPENDED; 4301 ap->flags &= ~ATA_FLAG_SUSPENDED;
4291 ata_set_mode(ap); 4302 ata_set_mode(ap);
4292 } 4303 }
@@ -4302,6 +4313,7 @@ int ata_device_resume(struct ata_port *ap, struct ata_device *dev)
4302 * ata_device_suspend - prepare a device for suspend 4313 * ata_device_suspend - prepare a device for suspend
4303 * @ap: port the device is connected to 4314 * @ap: port the device is connected to
4304 * @dev: the device to suspend 4315 * @dev: the device to suspend
4316 * @state: target power management state
4305 * 4317 *
4306 * Flush the cache on the drive, if appropriate, then issue a 4318 * Flush the cache on the drive, if appropriate, then issue a
4307 * standbynow command. 4319 * standbynow command.
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index d5fdcb9a8842..9b8bca1ac1f0 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -37,7 +37,7 @@
37#include <asm/io.h> 37#include <asm/io.h>
38 38
39#define DRV_NAME "sata_mv" 39#define DRV_NAME "sata_mv"
40#define DRV_VERSION "0.6" 40#define DRV_VERSION "0.7"
41 41
42enum { 42enum {
43 /* BAR's are enumerated in terms of pci_resource_start() terms */ 43 /* BAR's are enumerated in terms of pci_resource_start() terms */
@@ -50,6 +50,12 @@ enum {
50 50
51 MV_PCI_REG_BASE = 0, 51 MV_PCI_REG_BASE = 0,
52 MV_IRQ_COAL_REG_BASE = 0x18000, /* 6xxx part only */ 52 MV_IRQ_COAL_REG_BASE = 0x18000, /* 6xxx part only */
53 MV_IRQ_COAL_CAUSE = (MV_IRQ_COAL_REG_BASE + 0x08),
54 MV_IRQ_COAL_CAUSE_LO = (MV_IRQ_COAL_REG_BASE + 0x88),
55 MV_IRQ_COAL_CAUSE_HI = (MV_IRQ_COAL_REG_BASE + 0x8c),
56 MV_IRQ_COAL_THRESHOLD = (MV_IRQ_COAL_REG_BASE + 0xcc),
57 MV_IRQ_COAL_TIME_THRESHOLD = (MV_IRQ_COAL_REG_BASE + 0xd0),
58
53 MV_SATAHC0_REG_BASE = 0x20000, 59 MV_SATAHC0_REG_BASE = 0x20000,
54 MV_FLASH_CTL = 0x1046c, 60 MV_FLASH_CTL = 0x1046c,
55 MV_GPIO_PORT_CTL = 0x104f0, 61 MV_GPIO_PORT_CTL = 0x104f0,
@@ -302,9 +308,6 @@ struct mv_port_priv {
302 dma_addr_t crpb_dma; 308 dma_addr_t crpb_dma;
303 struct mv_sg *sg_tbl; 309 struct mv_sg *sg_tbl;
304 dma_addr_t sg_tbl_dma; 310 dma_addr_t sg_tbl_dma;
305
306 unsigned req_producer; /* cp of req_in_ptr */
307 unsigned rsp_consumer; /* cp of rsp_out_ptr */
308 u32 pp_flags; 311 u32 pp_flags;
309}; 312};
310 313
@@ -937,8 +940,6 @@ static int mv_port_start(struct ata_port *ap)
937 writelfl(pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK, 940 writelfl(pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK,
938 port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); 941 port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
939 942
940 pp->req_producer = pp->rsp_consumer = 0;
941
942 /* Don't turn on EDMA here...do it before DMA commands only. Else 943 /* Don't turn on EDMA here...do it before DMA commands only. Else
943 * we'll be unable to send non-data, PIO, etc due to restricted access 944 * we'll be unable to send non-data, PIO, etc due to restricted access
944 * to shadow regs. 945 * to shadow regs.
@@ -1022,16 +1023,16 @@ static void mv_fill_sg(struct ata_queued_cmd *qc)
1022 } 1023 }
1023} 1024}
1024 1025
1025static inline unsigned mv_inc_q_index(unsigned *index) 1026static inline unsigned mv_inc_q_index(unsigned index)
1026{ 1027{
1027 *index = (*index + 1) & MV_MAX_Q_DEPTH_MASK; 1028 return (index + 1) & MV_MAX_Q_DEPTH_MASK;
1028 return *index;
1029} 1029}
1030 1030
1031static inline void mv_crqb_pack_cmd(u16 *cmdw, u8 data, u8 addr, unsigned last) 1031static inline void mv_crqb_pack_cmd(u16 *cmdw, u8 data, u8 addr, unsigned last)
1032{ 1032{
1033 *cmdw = data | (addr << CRQB_CMD_ADDR_SHIFT) | CRQB_CMD_CS | 1033 u16 tmp = data | (addr << CRQB_CMD_ADDR_SHIFT) | CRQB_CMD_CS |
1034 (last ? CRQB_CMD_LAST : 0); 1034 (last ? CRQB_CMD_LAST : 0);
1035 *cmdw = cpu_to_le16(tmp);
1035} 1036}
1036 1037
1037/** 1038/**
@@ -1053,15 +1054,11 @@ static void mv_qc_prep(struct ata_queued_cmd *qc)
1053 u16 *cw; 1054 u16 *cw;
1054 struct ata_taskfile *tf; 1055 struct ata_taskfile *tf;
1055 u16 flags = 0; 1056 u16 flags = 0;
1057 unsigned in_index;
1056 1058
1057 if (ATA_PROT_DMA != qc->tf.protocol) 1059 if (ATA_PROT_DMA != qc->tf.protocol)
1058 return; 1060 return;
1059 1061
1060 /* the req producer index should be the same as we remember it */
1061 WARN_ON(((readl(mv_ap_base(qc->ap) + EDMA_REQ_Q_IN_PTR_OFS) >>
1062 EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) !=
1063 pp->req_producer);
1064
1065 /* Fill in command request block 1062 /* Fill in command request block
1066 */ 1063 */
1067 if (!(qc->tf.flags & ATA_TFLAG_WRITE)) 1064 if (!(qc->tf.flags & ATA_TFLAG_WRITE))
@@ -1069,13 +1066,17 @@ static void mv_qc_prep(struct ata_queued_cmd *qc)
1069 WARN_ON(MV_MAX_Q_DEPTH <= qc->tag); 1066 WARN_ON(MV_MAX_Q_DEPTH <= qc->tag);
1070 flags |= qc->tag << CRQB_TAG_SHIFT; 1067 flags |= qc->tag << CRQB_TAG_SHIFT;
1071 1068
1072 pp->crqb[pp->req_producer].sg_addr = 1069 /* get current queue index from hardware */
1070 in_index = (readl(mv_ap_base(ap) + EDMA_REQ_Q_IN_PTR_OFS)
1071 >> EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK;
1072
1073 pp->crqb[in_index].sg_addr =
1073 cpu_to_le32(pp->sg_tbl_dma & 0xffffffff); 1074 cpu_to_le32(pp->sg_tbl_dma & 0xffffffff);
1074 pp->crqb[pp->req_producer].sg_addr_hi = 1075 pp->crqb[in_index].sg_addr_hi =
1075 cpu_to_le32((pp->sg_tbl_dma >> 16) >> 16); 1076 cpu_to_le32((pp->sg_tbl_dma >> 16) >> 16);
1076 pp->crqb[pp->req_producer].ctrl_flags = cpu_to_le16(flags); 1077 pp->crqb[in_index].ctrl_flags = cpu_to_le16(flags);
1077 1078
1078 cw = &pp->crqb[pp->req_producer].ata_cmd[0]; 1079 cw = &pp->crqb[in_index].ata_cmd[0];
1079 tf = &qc->tf; 1080 tf = &qc->tf;
1080 1081
1081 /* Sadly, the CRQB cannot accomodate all registers--there are 1082 /* Sadly, the CRQB cannot accomodate all registers--there are
@@ -1144,16 +1145,12 @@ static void mv_qc_prep_iie(struct ata_queued_cmd *qc)
1144 struct mv_port_priv *pp = ap->private_data; 1145 struct mv_port_priv *pp = ap->private_data;
1145 struct mv_crqb_iie *crqb; 1146 struct mv_crqb_iie *crqb;
1146 struct ata_taskfile *tf; 1147 struct ata_taskfile *tf;
1148 unsigned in_index;
1147 u32 flags = 0; 1149 u32 flags = 0;
1148 1150
1149 if (ATA_PROT_DMA != qc->tf.protocol) 1151 if (ATA_PROT_DMA != qc->tf.protocol)
1150 return; 1152 return;
1151 1153
1152 /* the req producer index should be the same as we remember it */
1153 WARN_ON(((readl(mv_ap_base(qc->ap) + EDMA_REQ_Q_IN_PTR_OFS) >>
1154 EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) !=
1155 pp->req_producer);
1156
1157 /* Fill in Gen IIE command request block 1154 /* Fill in Gen IIE command request block
1158 */ 1155 */
1159 if (!(qc->tf.flags & ATA_TFLAG_WRITE)) 1156 if (!(qc->tf.flags & ATA_TFLAG_WRITE))
@@ -1162,7 +1159,11 @@ static void mv_qc_prep_iie(struct ata_queued_cmd *qc)
1162 WARN_ON(MV_MAX_Q_DEPTH <= qc->tag); 1159 WARN_ON(MV_MAX_Q_DEPTH <= qc->tag);
1163 flags |= qc->tag << CRQB_TAG_SHIFT; 1160 flags |= qc->tag << CRQB_TAG_SHIFT;
1164 1161
1165 crqb = (struct mv_crqb_iie *) &pp->crqb[pp->req_producer]; 1162 /* get current queue index from hardware */
1163 in_index = (readl(mv_ap_base(ap) + EDMA_REQ_Q_IN_PTR_OFS)
1164 >> EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK;
1165
1166 crqb = (struct mv_crqb_iie *) &pp->crqb[in_index];
1166 crqb->addr = cpu_to_le32(pp->sg_tbl_dma & 0xffffffff); 1167 crqb->addr = cpu_to_le32(pp->sg_tbl_dma & 0xffffffff);
1167 crqb->addr_hi = cpu_to_le32((pp->sg_tbl_dma >> 16) >> 16); 1168 crqb->addr_hi = cpu_to_le32((pp->sg_tbl_dma >> 16) >> 16);
1168 crqb->flags = cpu_to_le32(flags); 1169 crqb->flags = cpu_to_le32(flags);
@@ -1210,6 +1211,7 @@ static unsigned int mv_qc_issue(struct ata_queued_cmd *qc)
1210{ 1211{
1211 void __iomem *port_mmio = mv_ap_base(qc->ap); 1212 void __iomem *port_mmio = mv_ap_base(qc->ap);
1212 struct mv_port_priv *pp = qc->ap->private_data; 1213 struct mv_port_priv *pp = qc->ap->private_data;
1214 unsigned in_index;
1213 u32 in_ptr; 1215 u32 in_ptr;
1214 1216
1215 if (ATA_PROT_DMA != qc->tf.protocol) { 1217 if (ATA_PROT_DMA != qc->tf.protocol) {
@@ -1221,23 +1223,20 @@ static unsigned int mv_qc_issue(struct ata_queued_cmd *qc)
1221 return ata_qc_issue_prot(qc); 1223 return ata_qc_issue_prot(qc);
1222 } 1224 }
1223 1225
1224 in_ptr = readl(port_mmio + EDMA_REQ_Q_IN_PTR_OFS); 1226 in_ptr = readl(port_mmio + EDMA_REQ_Q_IN_PTR_OFS);
1227 in_index = (in_ptr >> EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK;
1225 1228
1226 /* the req producer index should be the same as we remember it */
1227 WARN_ON(((in_ptr >> EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) !=
1228 pp->req_producer);
1229 /* until we do queuing, the queue should be empty at this point */ 1229 /* until we do queuing, the queue should be empty at this point */
1230 WARN_ON(((in_ptr >> EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) != 1230 WARN_ON(in_index != ((readl(port_mmio + EDMA_REQ_Q_OUT_PTR_OFS)
1231 ((readl(port_mmio + EDMA_REQ_Q_OUT_PTR_OFS) >> 1231 >> EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK));
1232 EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK));
1233 1232
1234 mv_inc_q_index(&pp->req_producer); /* now incr producer index */ 1233 in_index = mv_inc_q_index(in_index); /* now incr producer index */
1235 1234
1236 mv_start_dma(port_mmio, pp); 1235 mv_start_dma(port_mmio, pp);
1237 1236
1238 /* and write the request in pointer to kick the EDMA to life */ 1237 /* and write the request in pointer to kick the EDMA to life */
1239 in_ptr &= EDMA_REQ_Q_BASE_LO_MASK; 1238 in_ptr &= EDMA_REQ_Q_BASE_LO_MASK;
1240 in_ptr |= pp->req_producer << EDMA_REQ_Q_PTR_SHIFT; 1239 in_ptr |= in_index << EDMA_REQ_Q_PTR_SHIFT;
1241 writelfl(in_ptr, port_mmio + EDMA_REQ_Q_IN_PTR_OFS); 1240 writelfl(in_ptr, port_mmio + EDMA_REQ_Q_IN_PTR_OFS);
1242 1241
1243 return 0; 1242 return 0;
@@ -1260,28 +1259,26 @@ static u8 mv_get_crpb_status(struct ata_port *ap)
1260{ 1259{
1261 void __iomem *port_mmio = mv_ap_base(ap); 1260 void __iomem *port_mmio = mv_ap_base(ap);
1262 struct mv_port_priv *pp = ap->private_data; 1261 struct mv_port_priv *pp = ap->private_data;
1262 unsigned out_index;
1263 u32 out_ptr; 1263 u32 out_ptr;
1264 u8 ata_status; 1264 u8 ata_status;
1265 1265
1266 out_ptr = readl(port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); 1266 out_ptr = readl(port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
1267 out_index = (out_ptr >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK;
1267 1268
1268 /* the response consumer index should be the same as we remember it */ 1269 ata_status = le16_to_cpu(pp->crpb[out_index].flags)
1269 WARN_ON(((out_ptr >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) != 1270 >> CRPB_FLAG_STATUS_SHIFT;
1270 pp->rsp_consumer);
1271
1272 ata_status = pp->crpb[pp->rsp_consumer].flags >> CRPB_FLAG_STATUS_SHIFT;
1273 1271
1274 /* increment our consumer index... */ 1272 /* increment our consumer index... */
1275 pp->rsp_consumer = mv_inc_q_index(&pp->rsp_consumer); 1273 out_index = mv_inc_q_index(out_index);
1276 1274
1277 /* and, until we do NCQ, there should only be 1 CRPB waiting */ 1275 /* and, until we do NCQ, there should only be 1 CRPB waiting */
1278 WARN_ON(((readl(port_mmio + EDMA_RSP_Q_IN_PTR_OFS) >> 1276 WARN_ON(out_index != ((readl(port_mmio + EDMA_RSP_Q_IN_PTR_OFS)
1279 EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) != 1277 >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK));
1280 pp->rsp_consumer);
1281 1278
1282 /* write out our inc'd consumer index so EDMA knows we're caught up */ 1279 /* write out our inc'd consumer index so EDMA knows we're caught up */
1283 out_ptr &= EDMA_RSP_Q_BASE_LO_MASK; 1280 out_ptr &= EDMA_RSP_Q_BASE_LO_MASK;
1284 out_ptr |= pp->rsp_consumer << EDMA_RSP_Q_PTR_SHIFT; 1281 out_ptr |= out_index << EDMA_RSP_Q_PTR_SHIFT;
1285 writelfl(out_ptr, port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); 1282 writelfl(out_ptr, port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
1286 1283
1287 /* Return ATA status register for completed CRPB */ 1284 /* Return ATA status register for completed CRPB */
@@ -1291,6 +1288,7 @@ static u8 mv_get_crpb_status(struct ata_port *ap)
1291/** 1288/**
1292 * mv_err_intr - Handle error interrupts on the port 1289 * mv_err_intr - Handle error interrupts on the port
1293 * @ap: ATA channel to manipulate 1290 * @ap: ATA channel to manipulate
1291 * @reset_allowed: bool: 0 == don't trigger from reset here
1294 * 1292 *
1295 * In most cases, just clear the interrupt and move on. However, 1293 * In most cases, just clear the interrupt and move on. However,
1296 * some cases require an eDMA reset, which is done right before 1294 * some cases require an eDMA reset, which is done right before
@@ -1301,7 +1299,7 @@ static u8 mv_get_crpb_status(struct ata_port *ap)
1301 * LOCKING: 1299 * LOCKING:
1302 * Inherited from caller. 1300 * Inherited from caller.
1303 */ 1301 */
1304static void mv_err_intr(struct ata_port *ap) 1302static void mv_err_intr(struct ata_port *ap, int reset_allowed)
1305{ 1303{
1306 void __iomem *port_mmio = mv_ap_base(ap); 1304 void __iomem *port_mmio = mv_ap_base(ap);
1307 u32 edma_err_cause, serr = 0; 1305 u32 edma_err_cause, serr = 0;
@@ -1323,9 +1321,8 @@ static void mv_err_intr(struct ata_port *ap)
1323 writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); 1321 writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS);
1324 1322
1325 /* check for fatal here and recover if needed */ 1323 /* check for fatal here and recover if needed */
1326 if (EDMA_ERR_FATAL & edma_err_cause) { 1324 if (reset_allowed && (EDMA_ERR_FATAL & edma_err_cause))
1327 mv_stop_and_reset(ap); 1325 mv_stop_and_reset(ap);
1328 }
1329} 1326}
1330 1327
1331/** 1328/**
@@ -1374,12 +1371,12 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1374 struct ata_port *ap = host_set->ports[port]; 1371 struct ata_port *ap = host_set->ports[port];
1375 struct mv_port_priv *pp = ap->private_data; 1372 struct mv_port_priv *pp = ap->private_data;
1376 1373
1377 hard_port = port & MV_PORT_MASK; /* range 0-3 */ 1374 hard_port = mv_hardport_from_port(port); /* range 0..3 */
1378 handled = 0; /* ensure ata_status is set if handled++ */ 1375 handled = 0; /* ensure ata_status is set if handled++ */
1379 1376
1380 /* Note that DEV_IRQ might happen spuriously during EDMA, 1377 /* Note that DEV_IRQ might happen spuriously during EDMA,
1381 * and should be ignored in such cases. We could mask it, 1378 * and should be ignored in such cases.
1382 * but it's pretty rare and may not be worth the overhead. 1379 * The cause of this is still under investigation.
1383 */ 1380 */
1384 if (pp->pp_flags & MV_PP_FLAG_EDMA_EN) { 1381 if (pp->pp_flags & MV_PP_FLAG_EDMA_EN) {
1385 /* EDMA: check for response queue interrupt */ 1382 /* EDMA: check for response queue interrupt */
@@ -1393,6 +1390,11 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1393 ata_status = readb((void __iomem *) 1390 ata_status = readb((void __iomem *)
1394 ap->ioaddr.status_addr); 1391 ap->ioaddr.status_addr);
1395 handled = 1; 1392 handled = 1;
1393 /* ignore spurious intr if drive still BUSY */
1394 if (ata_status & ATA_BUSY) {
1395 ata_status = 0;
1396 handled = 0;
1397 }
1396 } 1398 }
1397 } 1399 }
1398 1400
@@ -1406,7 +1408,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1406 shift++; /* skip bit 8 in the HC Main IRQ reg */ 1408 shift++; /* skip bit 8 in the HC Main IRQ reg */
1407 } 1409 }
1408 if ((PORT0_ERR << shift) & relevant) { 1410 if ((PORT0_ERR << shift) & relevant) {
1409 mv_err_intr(ap); 1411 mv_err_intr(ap, 1);
1410 err_mask |= AC_ERR_OTHER; 1412 err_mask |= AC_ERR_OTHER;
1411 handled = 1; 1413 handled = 1;
1412 } 1414 }
@@ -1448,6 +1450,7 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance,
1448 struct ata_host_set *host_set = dev_instance; 1450 struct ata_host_set *host_set = dev_instance;
1449 unsigned int hc, handled = 0, n_hcs; 1451 unsigned int hc, handled = 0, n_hcs;
1450 void __iomem *mmio = host_set->mmio_base; 1452 void __iomem *mmio = host_set->mmio_base;
1453 struct mv_host_priv *hpriv;
1451 u32 irq_stat; 1454 u32 irq_stat;
1452 1455
1453 irq_stat = readl(mmio + HC_MAIN_IRQ_CAUSE_OFS); 1456 irq_stat = readl(mmio + HC_MAIN_IRQ_CAUSE_OFS);
@@ -1469,6 +1472,17 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance,
1469 handled++; 1472 handled++;
1470 } 1473 }
1471 } 1474 }
1475
1476 hpriv = host_set->private_data;
1477 if (IS_60XX(hpriv)) {
1478 /* deal with the interrupt coalescing bits */
1479 if (irq_stat & (TRAN_LO_DONE | TRAN_HI_DONE | PORTS_0_7_COAL_DONE)) {
1480 writelfl(0, mmio + MV_IRQ_COAL_CAUSE_LO);
1481 writelfl(0, mmio + MV_IRQ_COAL_CAUSE_HI);
1482 writelfl(0, mmio + MV_IRQ_COAL_CAUSE);
1483 }
1484 }
1485
1472 if (PCI_ERR & irq_stat) { 1486 if (PCI_ERR & irq_stat) {
1473 printk(KERN_ERR DRV_NAME ": PCI ERROR; PCI IRQ cause=0x%08x\n", 1487 printk(KERN_ERR DRV_NAME ": PCI ERROR; PCI IRQ cause=0x%08x\n",
1474 readl(mmio + PCI_IRQ_CAUSE_OFS)); 1488 readl(mmio + PCI_IRQ_CAUSE_OFS));
@@ -1867,7 +1881,8 @@ static void mv_channel_reset(struct mv_host_priv *hpriv, void __iomem *mmio,
1867 1881
1868 if (IS_60XX(hpriv)) { 1882 if (IS_60XX(hpriv)) {
1869 u32 ifctl = readl(port_mmio + SATA_INTERFACE_CTL); 1883 u32 ifctl = readl(port_mmio + SATA_INTERFACE_CTL);
1870 ifctl |= (1 << 12) | (1 << 7); 1884 ifctl |= (1 << 7); /* enable gen2i speed */
1885 ifctl = (ifctl & 0xfff) | 0x9b1000; /* from chip spec */
1871 writelfl(ifctl, port_mmio + SATA_INTERFACE_CTL); 1886 writelfl(ifctl, port_mmio + SATA_INTERFACE_CTL);
1872 } 1887 }
1873 1888
@@ -2031,11 +2046,14 @@ static void mv_eng_timeout(struct ata_port *ap)
2031 ap->host_set->mmio_base, ap, qc, qc->scsicmd, 2046 ap->host_set->mmio_base, ap, qc, qc->scsicmd,
2032 &qc->scsicmd->cmnd); 2047 &qc->scsicmd->cmnd);
2033 2048
2034 mv_err_intr(ap); 2049 mv_err_intr(ap, 0);
2035 mv_stop_and_reset(ap); 2050 mv_stop_and_reset(ap);
2036 2051
2037 qc->err_mask |= AC_ERR_TIMEOUT; 2052 WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE));
2038 ata_eh_qc_complete(qc); 2053 if (qc->flags & ATA_QCFLAG_ACTIVE) {
2054 qc->err_mask |= AC_ERR_TIMEOUT;
2055 ata_eh_qc_complete(qc);
2056 }
2039} 2057}
2040 2058
2041/** 2059/**
@@ -2229,7 +2247,8 @@ static int mv_init_host(struct pci_dev *pdev, struct ata_probe_ent *probe_ent,
2229 void __iomem *port_mmio = mv_port_base(mmio, port); 2247 void __iomem *port_mmio = mv_port_base(mmio, port);
2230 2248
2231 u32 ifctl = readl(port_mmio + SATA_INTERFACE_CTL); 2249 u32 ifctl = readl(port_mmio + SATA_INTERFACE_CTL);
2232 ifctl |= (1 << 12); 2250 ifctl |= (1 << 7); /* enable gen2i speed */
2251 ifctl = (ifctl & 0xfff) | 0x9b1000; /* from chip spec */
2233 writelfl(ifctl, port_mmio + SATA_INTERFACE_CTL); 2252 writelfl(ifctl, port_mmio + SATA_INTERFACE_CTL);
2234 } 2253 }
2235 2254
@@ -2330,6 +2349,7 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2330 if (rc) { 2349 if (rc) {
2331 return rc; 2350 return rc;
2332 } 2351 }
2352 pci_set_master(pdev);
2333 2353
2334 rc = pci_request_regions(pdev, DRV_NAME); 2354 rc = pci_request_regions(pdev, DRV_NAME);
2335 if (rc) { 2355 if (rc) {
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index d40e7c871c36..56cb49006116 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4054,7 +4054,7 @@ static int st_probe(struct device *dev)
4054 } 4054 }
4055 4055
4056 sdev_printk(KERN_WARNING, SDp, 4056 sdev_printk(KERN_WARNING, SDp,
4057 "Attached scsi tape %s", tape_name(tpnt)); 4057 "Attached scsi tape %s\n", tape_name(tpnt));
4058 printk(KERN_WARNING "%s: try direct i/o: %s (alignment %d B)\n", 4058 printk(KERN_WARNING "%s: try direct i/o: %s (alignment %d B)\n",
4059 tape_name(tpnt), tpnt->try_dio ? "yes" : "no", 4059 tape_name(tpnt), tpnt->try_dio ? "yes" : "no",
4060 queue_dma_alignment(SDp->request_queue) + 1); 4060 queue_dma_alignment(SDp->request_queue) + 1);
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
index 969f94900431..5cba59ad7dc5 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -1164,14 +1164,16 @@ static int __init cpm_uart_console_setup(struct console *co, char *options)
1164 struct fs_uart_platform_info *pdata; 1164 struct fs_uart_platform_info *pdata;
1165 struct platform_device* pdev = early_uart_get_pdev(co->index); 1165 struct platform_device* pdev = early_uart_get_pdev(co->index);
1166 1166
1167 port =
1168 (struct uart_port *)&cpm_uart_ports[cpm_uart_port_map[co->index]];
1169 pinfo = (struct uart_cpm_port *)port;
1170 if (!pdev) { 1167 if (!pdev) {
1171 pr_info("cpm_uart: console: compat mode\n"); 1168 pr_info("cpm_uart: console: compat mode\n");
1172 /* compatibility - will be cleaned up */ 1169 /* compatibility - will be cleaned up */
1173 cpm_uart_init_portdesc(); 1170 cpm_uart_init_portdesc();
1171 }
1174 1172
1173 port =
1174 (struct uart_port *)&cpm_uart_ports[cpm_uart_port_map[co->index]];
1175 pinfo = (struct uart_cpm_port *)port;
1176 if (!pdev) {
1175 if (pinfo->set_lineif) 1177 if (pinfo->set_lineif)
1176 pinfo->set_lineif(pinfo); 1178 pinfo->set_lineif(pinfo);
1177 } else { 1179 } else {
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c
index 4b2de08f46d0..cdba128250a9 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.c
@@ -213,7 +213,7 @@ int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con)
213 L1_CACHE_ALIGN(pinfo->tx_nrfifos * pinfo->tx_fifosize); 213 L1_CACHE_ALIGN(pinfo->tx_nrfifos * pinfo->tx_fifosize);
214 if (is_con) { 214 if (is_con) {
215 mem_addr = alloc_bootmem(memsz); 215 mem_addr = alloc_bootmem(memsz);
216 dma_addr = mem_addr; 216 dma_addr = virt_to_bus(mem_addr);
217 } 217 }
218 else 218 else
219 mem_addr = dma_alloc_coherent(NULL, memsz, &dma_addr, 219 mem_addr = dma_alloc_coherent(NULL, memsz, &dma_addr,
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
index 1c4396c2962d..2b4f96541b8e 100644
--- a/drivers/serial/sunsu.c
+++ b/drivers/serial/sunsu.c
@@ -1730,3 +1730,4 @@ static void __exit sunsu_exit(void)
1730 1730
1731module_init(sunsu_probe); 1731module_init(sunsu_probe);
1732module_exit(sunsu_exit); 1732module_exit(sunsu_exit);
1733MODULE_LICENSE("GPL");
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 9ce1d01469b1..23334c8bc4c7 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -75,6 +75,18 @@ config SPI_BUTTERFLY
75 inexpensive battery powered microcontroller evaluation board. 75 inexpensive battery powered microcontroller evaluation board.
76 This same cable can be used to flash new firmware. 76 This same cable can be used to flash new firmware.
77 77
78config SPI_MPC83xx
79 tristate "Freescale MPC83xx SPI controller"
80 depends on SPI_MASTER && PPC_83xx && EXPERIMENTAL
81 select SPI_BITBANG
82 help
83 This enables using the Freescale MPC83xx SPI controller in master
84 mode.
85
86 Note, this driver uniquely supports the SPI controller on the MPC83xx
87 family of PowerPC processors. The MPC83xx uses a simple set of shift
88 registers for data (opposed to the CPM based descriptor model).
89
78config SPI_PXA2XX 90config SPI_PXA2XX
79 tristate "PXA2xx SSP SPI master" 91 tristate "PXA2xx SSP SPI master"
80 depends on SPI_MASTER && ARCH_PXA && EXPERIMENTAL 92 depends on SPI_MASTER && ARCH_PXA && EXPERIMENTAL
@@ -83,11 +95,25 @@ config SPI_PXA2XX
83 The driver can be configured to use any SSP port and additional 95 The driver can be configured to use any SSP port and additional
84 documentation can be found a Documentation/spi/pxa2xx. 96 documentation can be found a Documentation/spi/pxa2xx.
85 97
98config SPI_S3C24XX_GPIO
99 tristate "Samsung S3C24XX series SPI by GPIO"
100 depends on SPI_MASTER && ARCH_S3C2410 && SPI_BITBANG && EXPERIMENTAL
101 help
102 SPI driver for Samsung S3C24XX series ARM SoCs using
103 GPIO lines to provide the SPI bus. This can be used where
104 the inbuilt hardware cannot provide the transfer mode, or
105 where the board is using non hardware connected pins.
86# 106#
87# Add new SPI master controllers in alphabetical order above this line 107# Add new SPI master controllers in alphabetical order above this line
88# 108#
89 109
90 110
111config SPI_S3C24XX
112 tristate "Samsung S3C24XX series SPI"
113 depends on SPI_MASTER && ARCH_S3C2410 && EXPERIMENTAL
114 help
115 SPI driver for Samsung S3C24XX series ARM SoCs
116
91# 117#
92# There are lots of SPI device types, with sensors and memory 118# There are lots of SPI device types, with sensors and memory
93# being probably the most widely used ones. 119# being probably the most widely used ones.
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 1bca5f95de25..8f4cb67997b3 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -14,6 +14,9 @@ obj-$(CONFIG_SPI_MASTER) += spi.o
14obj-$(CONFIG_SPI_BITBANG) += spi_bitbang.o 14obj-$(CONFIG_SPI_BITBANG) += spi_bitbang.o
15obj-$(CONFIG_SPI_BUTTERFLY) += spi_butterfly.o 15obj-$(CONFIG_SPI_BUTTERFLY) += spi_butterfly.o
16obj-$(CONFIG_SPI_PXA2XX) += pxa2xx_spi.o 16obj-$(CONFIG_SPI_PXA2XX) += pxa2xx_spi.o
17obj-$(CONFIG_SPI_MPC83xx) += spi_mpc83xx.o
18obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o
19obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx.o
17# ... add above this line ... 20# ... add above this line ...
18 21
19# SPI protocol drivers (device/link on bus) 22# SPI protocol drivers (device/link on bus)
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index 596bf820b70c..29aec77f98be 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -363,25 +363,30 @@ static void unmap_dma_buffers(struct driver_data *drv_data)
363} 363}
364 364
365/* caller already set message->status; dma and pio irqs are blocked */ 365/* caller already set message->status; dma and pio irqs are blocked */
366static void giveback(struct spi_message *message, struct driver_data *drv_data) 366static void giveback(struct driver_data *drv_data)
367{ 367{
368 struct spi_transfer* last_transfer; 368 struct spi_transfer* last_transfer;
369 unsigned long flags;
370 struct spi_message *msg;
369 371
370 last_transfer = list_entry(message->transfers.prev, 372 spin_lock_irqsave(&drv_data->lock, flags);
373 msg = drv_data->cur_msg;
374 drv_data->cur_msg = NULL;
375 drv_data->cur_transfer = NULL;
376 drv_data->cur_chip = NULL;
377 queue_work(drv_data->workqueue, &drv_data->pump_messages);
378 spin_unlock_irqrestore(&drv_data->lock, flags);
379
380 last_transfer = list_entry(msg->transfers.prev,
371 struct spi_transfer, 381 struct spi_transfer,
372 transfer_list); 382 transfer_list);
373 383
374 if (!last_transfer->cs_change) 384 if (!last_transfer->cs_change)
375 drv_data->cs_control(PXA2XX_CS_DEASSERT); 385 drv_data->cs_control(PXA2XX_CS_DEASSERT);
376 386
377 message->state = NULL; 387 msg->state = NULL;
378 if (message->complete) 388 if (msg->complete)
379 message->complete(message->context); 389 msg->complete(msg->context);
380
381 drv_data->cur_msg = NULL;
382 drv_data->cur_transfer = NULL;
383 drv_data->cur_chip = NULL;
384 queue_work(drv_data->workqueue, &drv_data->pump_messages);
385} 390}
386 391
387static int wait_ssp_rx_stall(void *ioaddr) 392static int wait_ssp_rx_stall(void *ioaddr)
@@ -415,10 +420,11 @@ static void dma_handler(int channel, void *data, struct pt_regs *regs)
415 if (irq_status & DCSR_BUSERR) { 420 if (irq_status & DCSR_BUSERR) {
416 421
417 /* Disable interrupts, clear status and reset DMA */ 422 /* Disable interrupts, clear status and reset DMA */
423 write_SSCR0(read_SSCR0(reg) & ~SSCR0_SSE, reg);
424 write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg);
418 if (drv_data->ssp_type != PXA25x_SSP) 425 if (drv_data->ssp_type != PXA25x_SSP)
419 write_SSTO(0, reg); 426 write_SSTO(0, reg);
420 write_SSSR(drv_data->clear_sr, reg); 427 write_SSSR(drv_data->clear_sr, reg);
421 write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg);
422 DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL; 428 DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL;
423 DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL; 429 DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL;
424 430
@@ -454,8 +460,8 @@ static void dma_handler(int channel, void *data, struct pt_regs *regs)
454 "dma_handler: ssp rx stall failed\n"); 460 "dma_handler: ssp rx stall failed\n");
455 461
456 /* Clear and disable interrupts on SSP and DMA channels*/ 462 /* Clear and disable interrupts on SSP and DMA channels*/
457 write_SSSR(drv_data->clear_sr, reg);
458 write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg); 463 write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg);
464 write_SSSR(drv_data->clear_sr, reg);
459 DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL; 465 DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL;
460 DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL; 466 DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL;
461 if (wait_dma_channel_stop(drv_data->rx_channel) == 0) 467 if (wait_dma_channel_stop(drv_data->rx_channel) == 0)
@@ -497,10 +503,11 @@ static irqreturn_t dma_transfer(struct driver_data *drv_data)
497 irq_status = read_SSSR(reg) & drv_data->mask_sr; 503 irq_status = read_SSSR(reg) & drv_data->mask_sr;
498 if (irq_status & SSSR_ROR) { 504 if (irq_status & SSSR_ROR) {
499 /* Clear and disable interrupts on SSP and DMA channels*/ 505 /* Clear and disable interrupts on SSP and DMA channels*/
506 write_SSCR0(read_SSCR0(reg) & ~SSCR0_SSE, reg);
507 write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg);
500 if (drv_data->ssp_type != PXA25x_SSP) 508 if (drv_data->ssp_type != PXA25x_SSP)
501 write_SSTO(0, reg); 509 write_SSTO(0, reg);
502 write_SSSR(drv_data->clear_sr, reg); 510 write_SSSR(drv_data->clear_sr, reg);
503 write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg);
504 DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL; 511 DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL;
505 DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL; 512 DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL;
506 unmap_dma_buffers(drv_data); 513 unmap_dma_buffers(drv_data);
@@ -526,10 +533,10 @@ static irqreturn_t dma_transfer(struct driver_data *drv_data)
526 if (irq_status & SSSR_TINT || drv_data->rx == drv_data->rx_end) { 533 if (irq_status & SSSR_TINT || drv_data->rx == drv_data->rx_end) {
527 534
528 /* Clear and disable interrupts on SSP and DMA channels*/ 535 /* Clear and disable interrupts on SSP and DMA channels*/
536 write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg);
529 if (drv_data->ssp_type != PXA25x_SSP) 537 if (drv_data->ssp_type != PXA25x_SSP)
530 write_SSTO(0, reg); 538 write_SSTO(0, reg);
531 write_SSSR(drv_data->clear_sr, reg); 539 write_SSSR(drv_data->clear_sr, reg);
532 write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg);
533 DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL; 540 DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL;
534 DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL; 541 DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL;
535 542
@@ -572,26 +579,30 @@ static irqreturn_t dma_transfer(struct driver_data *drv_data)
572 579
573static irqreturn_t interrupt_transfer(struct driver_data *drv_data) 580static irqreturn_t interrupt_transfer(struct driver_data *drv_data)
574{ 581{
575 u32 irq_status;
576 struct spi_message *msg = drv_data->cur_msg; 582 struct spi_message *msg = drv_data->cur_msg;
577 void *reg = drv_data->ioaddr; 583 void *reg = drv_data->ioaddr;
578 irqreturn_t handled = IRQ_NONE;
579 unsigned long limit = loops_per_jiffy << 1; 584 unsigned long limit = loops_per_jiffy << 1;
585 u32 irq_status;
586 u32 irq_mask = (read_SSCR1(reg) & SSCR1_TIE) ?
587 drv_data->mask_sr : drv_data->mask_sr & ~SSSR_TFS;
580 588
581 while ((irq_status = (read_SSSR(reg) & drv_data->mask_sr))) { 589 while ((irq_status = read_SSSR(reg) & irq_mask)) {
582 590
583 if (irq_status & SSSR_ROR) { 591 if (irq_status & SSSR_ROR) {
584 592
585 /* Clear and disable interrupts */ 593 /* Clear and disable interrupts */
594 write_SSCR0(read_SSCR0(reg) & ~SSCR0_SSE, reg);
595 write_SSCR1(read_SSCR1(reg) & ~drv_data->int_cr1, reg);
586 if (drv_data->ssp_type != PXA25x_SSP) 596 if (drv_data->ssp_type != PXA25x_SSP)
587 write_SSTO(0, reg); 597 write_SSTO(0, reg);
588 write_SSSR(drv_data->clear_sr, reg); 598 write_SSSR(drv_data->clear_sr, reg);
589 write_SSCR1(read_SSCR1(reg) & ~drv_data->int_cr1, reg);
590 599
591 if (flush(drv_data) == 0) 600 if (flush(drv_data) == 0)
592 dev_err(&drv_data->pdev->dev, 601 dev_err(&drv_data->pdev->dev,
593 "interrupt_transfer: flush fail\n"); 602 "interrupt_transfer: flush fail\n");
594 603
604 /* Stop the SSP */
605
595 dev_warn(&drv_data->pdev->dev, 606 dev_warn(&drv_data->pdev->dev,
596 "interrupt_transfer: fifo overun\n"); 607 "interrupt_transfer: fifo overun\n");
597 608
@@ -613,6 +624,7 @@ static irqreturn_t interrupt_transfer(struct driver_data *drv_data)
613 if (drv_data->tx == drv_data->tx_end) { 624 if (drv_data->tx == drv_data->tx_end) {
614 /* Disable tx interrupt */ 625 /* Disable tx interrupt */
615 write_SSCR1(read_SSCR1(reg) & ~SSCR1_TIE, reg); 626 write_SSCR1(read_SSCR1(reg) & ~SSCR1_TIE, reg);
627 irq_mask = drv_data->mask_sr & ~SSSR_TFS;
616 628
617 /* PXA25x_SSP has no timeout, read trailing bytes */ 629 /* PXA25x_SSP has no timeout, read trailing bytes */
618 if (drv_data->ssp_type == PXA25x_SSP) { 630 if (drv_data->ssp_type == PXA25x_SSP) {
@@ -630,10 +642,10 @@ static irqreturn_t interrupt_transfer(struct driver_data *drv_data)
630 || (drv_data->rx == drv_data->rx_end)) { 642 || (drv_data->rx == drv_data->rx_end)) {
631 643
632 /* Clear timeout */ 644 /* Clear timeout */
645 write_SSCR1(read_SSCR1(reg) & ~drv_data->int_cr1, reg);
633 if (drv_data->ssp_type != PXA25x_SSP) 646 if (drv_data->ssp_type != PXA25x_SSP)
634 write_SSTO(0, reg); 647 write_SSTO(0, reg);
635 write_SSSR(drv_data->clear_sr, reg); 648 write_SSSR(drv_data->clear_sr, reg);
636 write_SSCR1(read_SSCR1(reg) & ~drv_data->int_cr1, reg);
637 649
638 /* Update total byte transfered */ 650 /* Update total byte transfered */
639 msg->actual_length += drv_data->len; 651 msg->actual_length += drv_data->len;
@@ -648,24 +660,29 @@ static irqreturn_t interrupt_transfer(struct driver_data *drv_data)
648 660
649 /* Schedule transfer tasklet */ 661 /* Schedule transfer tasklet */
650 tasklet_schedule(&drv_data->pump_transfers); 662 tasklet_schedule(&drv_data->pump_transfers);
651
652 return IRQ_HANDLED;
653 } 663 }
654
655 /* We did something */
656 handled = IRQ_HANDLED;
657 } 664 }
658 665
659 return handled; 666 /* We did something */
667 return IRQ_HANDLED;
660} 668}
661 669
662static irqreturn_t ssp_int(int irq, void *dev_id, struct pt_regs *regs) 670static irqreturn_t ssp_int(int irq, void *dev_id, struct pt_regs *regs)
663{ 671{
664 struct driver_data *drv_data = (struct driver_data *)dev_id; 672 struct driver_data *drv_data = (struct driver_data *)dev_id;
673 void *reg = drv_data->ioaddr;
665 674
666 if (!drv_data->cur_msg) { 675 if (!drv_data->cur_msg) {
676
677 write_SSCR0(read_SSCR0(reg) & ~SSCR0_SSE, reg);
678 write_SSCR1(read_SSCR1(reg) & ~drv_data->int_cr1, reg);
679 if (drv_data->ssp_type != PXA25x_SSP)
680 write_SSTO(0, reg);
681 write_SSSR(drv_data->clear_sr, reg);
682
667 dev_err(&drv_data->pdev->dev, "bad message state " 683 dev_err(&drv_data->pdev->dev, "bad message state "
668 "in interrupt handler\n"); 684 "in interrupt handler");
685
669 /* Never fail */ 686 /* Never fail */
670 return IRQ_HANDLED; 687 return IRQ_HANDLED;
671 } 688 }
@@ -694,14 +711,14 @@ static void pump_transfers(unsigned long data)
694 /* Handle for abort */ 711 /* Handle for abort */
695 if (message->state == ERROR_STATE) { 712 if (message->state == ERROR_STATE) {
696 message->status = -EIO; 713 message->status = -EIO;
697 giveback(message, drv_data); 714 giveback(drv_data);
698 return; 715 return;
699 } 716 }
700 717
701 /* Handle end of message */ 718 /* Handle end of message */
702 if (message->state == DONE_STATE) { 719 if (message->state == DONE_STATE) {
703 message->status = 0; 720 message->status = 0;
704 giveback(message, drv_data); 721 giveback(drv_data);
705 return; 722 return;
706 } 723 }
707 724
@@ -718,7 +735,7 @@ static void pump_transfers(unsigned long data)
718 if (flush(drv_data) == 0) { 735 if (flush(drv_data) == 0) {
719 dev_err(&drv_data->pdev->dev, "pump_transfers: flush failed\n"); 736 dev_err(&drv_data->pdev->dev, "pump_transfers: flush failed\n");
720 message->status = -EIO; 737 message->status = -EIO;
721 giveback(message, drv_data); 738 giveback(drv_data);
722 return; 739 return;
723 } 740 }
724 drv_data->n_bytes = chip->n_bytes; 741 drv_data->n_bytes = chip->n_bytes;
@@ -782,7 +799,7 @@ static void pump_transfers(unsigned long data)
782 799
783 cr0 = clk_div 800 cr0 = clk_div
784 | SSCR0_Motorola 801 | SSCR0_Motorola
785 | SSCR0_DataSize(bits & 0x0f) 802 | SSCR0_DataSize(bits > 16 ? bits - 16 : bits)
786 | SSCR0_SSE 803 | SSCR0_SSE
787 | (bits > 16 ? SSCR0_EDSS : 0); 804 | (bits > 16 ? SSCR0_EDSS : 0);
788 805
@@ -890,8 +907,6 @@ static void pump_messages(void *data)
890 drv_data->cur_msg = list_entry(drv_data->queue.next, 907 drv_data->cur_msg = list_entry(drv_data->queue.next,
891 struct spi_message, queue); 908 struct spi_message, queue);
892 list_del_init(&drv_data->cur_msg->queue); 909 list_del_init(&drv_data->cur_msg->queue);
893 drv_data->busy = 1;
894 spin_unlock_irqrestore(&drv_data->lock, flags);
895 910
896 /* Initial message state*/ 911 /* Initial message state*/
897 drv_data->cur_msg->state = START_STATE; 912 drv_data->cur_msg->state = START_STATE;
@@ -905,6 +920,9 @@ static void pump_messages(void *data)
905 920
906 /* Mark as busy and launch transfers */ 921 /* Mark as busy and launch transfers */
907 tasklet_schedule(&drv_data->pump_transfers); 922 tasklet_schedule(&drv_data->pump_transfers);
923
924 drv_data->busy = 1;
925 spin_unlock_irqrestore(&drv_data->lock, flags);
908} 926}
909 927
910static int transfer(struct spi_device *spi, struct spi_message *msg) 928static int transfer(struct spi_device *spi, struct spi_message *msg)
@@ -958,7 +976,7 @@ static int setup(struct spi_device *spi)
958 976
959 chip->cs_control = null_cs_control; 977 chip->cs_control = null_cs_control;
960 chip->enable_dma = 0; 978 chip->enable_dma = 0;
961 chip->timeout = 5; 979 chip->timeout = SSP_TIMEOUT(1000);
962 chip->threshold = SSCR1_RxTresh(1) | SSCR1_TxTresh(1); 980 chip->threshold = SSCR1_RxTresh(1) | SSCR1_TxTresh(1);
963 chip->dma_burst_size = drv_data->master_info->enable_dma ? 981 chip->dma_burst_size = drv_data->master_info->enable_dma ?
964 DCMD_BURST8 : 0; 982 DCMD_BURST8 : 0;
@@ -971,7 +989,7 @@ static int setup(struct spi_device *spi)
971 if (chip_info->cs_control) 989 if (chip_info->cs_control)
972 chip->cs_control = chip_info->cs_control; 990 chip->cs_control = chip_info->cs_control;
973 991
974 chip->timeout = (chip_info->timeout_microsecs * 10000) / 2712; 992 chip->timeout = SSP_TIMEOUT(chip_info->timeout_microsecs);
975 993
976 chip->threshold = SSCR1_RxTresh(chip_info->rx_threshold) 994 chip->threshold = SSCR1_RxTresh(chip_info->rx_threshold)
977 | SSCR1_TxTresh(chip_info->tx_threshold); 995 | SSCR1_TxTresh(chip_info->tx_threshold);
@@ -1013,7 +1031,8 @@ static int setup(struct spi_device *spi)
1013 1031
1014 chip->cr0 = clk_div 1032 chip->cr0 = clk_div
1015 | SSCR0_Motorola 1033 | SSCR0_Motorola
1016 | SSCR0_DataSize(spi->bits_per_word & 0x0f) 1034 | SSCR0_DataSize(spi->bits_per_word > 16 ?
1035 spi->bits_per_word - 16 : spi->bits_per_word)
1017 | SSCR0_SSE 1036 | SSCR0_SSE
1018 | (spi->bits_per_word > 16 ? SSCR0_EDSS : 0); 1037 | (spi->bits_per_word > 16 ? SSCR0_EDSS : 0);
1019 chip->cr1 |= (((spi->mode & SPI_CPHA) != 0) << 4) 1038 chip->cr1 |= (((spi->mode & SPI_CPHA) != 0) << 4)
@@ -1196,7 +1215,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
1196 goto out_error_master_alloc; 1215 goto out_error_master_alloc;
1197 } 1216 }
1198 1217
1199 drv_data->ioaddr = (void *)io_p2v(memory_resource->start); 1218 drv_data->ioaddr = (void *)io_p2v((unsigned long)(memory_resource->start));
1200 drv_data->ssdr_physical = memory_resource->start + 0x00000010; 1219 drv_data->ssdr_physical = memory_resource->start + 0x00000010;
1201 if (platform_info->ssp_type == PXA25x_SSP) { 1220 if (platform_info->ssp_type == PXA25x_SSP) {
1202 drv_data->int_cr1 = SSCR1_TIE | SSCR1_RIE; 1221 drv_data->int_cr1 = SSCR1_TIE | SSCR1_RIE;
@@ -1218,7 +1237,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
1218 goto out_error_master_alloc; 1237 goto out_error_master_alloc;
1219 } 1238 }
1220 1239
1221 status = request_irq(irq, ssp_int, SA_INTERRUPT, dev->bus_id, drv_data); 1240 status = request_irq(irq, ssp_int, 0, dev->bus_id, drv_data);
1222 if (status < 0) { 1241 if (status < 0) {
1223 dev_err(&pdev->dev, "can not get IRQ\n"); 1242 dev_err(&pdev->dev, "can not get IRQ\n");
1224 goto out_error_master_alloc; 1243 goto out_error_master_alloc;
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 7a3f733051e9..1cea4a6799fe 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -338,18 +338,18 @@ static struct class spi_master_class = {
338 * spi_alloc_master - allocate SPI master controller 338 * spi_alloc_master - allocate SPI master controller
339 * @dev: the controller, possibly using the platform_bus 339 * @dev: the controller, possibly using the platform_bus
340 * @size: how much driver-private data to preallocate; the pointer to this 340 * @size: how much driver-private data to preallocate; the pointer to this
341 * memory is in the class_data field of the returned class_device, 341 * memory is in the class_data field of the returned class_device,
342 * accessible with spi_master_get_devdata(). 342 * accessible with spi_master_get_devdata().
343 * 343 *
344 * This call is used only by SPI master controller drivers, which are the 344 * This call is used only by SPI master controller drivers, which are the
345 * only ones directly touching chip registers. It's how they allocate 345 * only ones directly touching chip registers. It's how they allocate
346 * an spi_master structure, prior to calling spi_add_master(). 346 * an spi_master structure, prior to calling spi_register_master().
347 * 347 *
348 * This must be called from context that can sleep. It returns the SPI 348 * This must be called from context that can sleep. It returns the SPI
349 * master structure on success, else NULL. 349 * master structure on success, else NULL.
350 * 350 *
351 * The caller is responsible for assigning the bus number and initializing 351 * The caller is responsible for assigning the bus number and initializing
352 * the master's methods before calling spi_add_master(); and (after errors 352 * the master's methods before calling spi_register_master(); and (after errors
353 * adding the device) calling spi_master_put() to prevent a memory leak. 353 * adding the device) calling spi_master_put() to prevent a memory leak.
354 */ 354 */
355struct spi_master * __init_or_module 355struct spi_master * __init_or_module
diff --git a/drivers/spi/spi_butterfly.c b/drivers/spi/spi_butterfly.c
index ff9e5faa4dc9..a006a1ee27ac 100644
--- a/drivers/spi/spi_butterfly.c
+++ b/drivers/spi/spi_butterfly.c
@@ -321,6 +321,7 @@ static void butterfly_attach(struct parport *p)
321 * (firmware resets at45, acts as spi slave) or neither (we ignore 321 * (firmware resets at45, acts as spi slave) or neither (we ignore
322 * both, AVR uses AT45). Here we expect firmware for the first option. 322 * both, AVR uses AT45). Here we expect firmware for the first option.
323 */ 323 */
324
324 pp->info[0].max_speed_hz = 15 * 1000 * 1000; 325 pp->info[0].max_speed_hz = 15 * 1000 * 1000;
325 strcpy(pp->info[0].modalias, "mtd_dataflash"); 326 strcpy(pp->info[0].modalias, "mtd_dataflash");
326 pp->info[0].platform_data = &flash; 327 pp->info[0].platform_data = &flash;
diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c
new file mode 100644
index 000000000000..5d92a7e5cb41
--- /dev/null
+++ b/drivers/spi/spi_mpc83xx.c
@@ -0,0 +1,483 @@
1/*
2 * MPC83xx SPI controller driver.
3 *
4 * Maintainer: Kumar Gala
5 *
6 * Copyright (C) 2006 Polycom, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/types.h>
16#include <linux/kernel.h>
17#include <linux/completion.h>
18#include <linux/interrupt.h>
19#include <linux/delay.h>
20#include <linux/irq.h>
21#include <linux/device.h>
22#include <linux/spi/spi.h>
23#include <linux/spi/spi_bitbang.h>
24#include <linux/platform_device.h>
25#include <linux/fsl_devices.h>
26
27#include <asm/irq.h>
28#include <asm/io.h>
29
30/* SPI Controller registers */
31struct mpc83xx_spi_reg {
32 u8 res1[0x20];
33 __be32 mode;
34 __be32 event;
35 __be32 mask;
36 __be32 command;
37 __be32 transmit;
38 __be32 receive;
39};
40
41/* SPI Controller mode register definitions */
42#define SPMODE_CI_INACTIVEHIGH (1 << 29)
43#define SPMODE_CP_BEGIN_EDGECLK (1 << 28)
44#define SPMODE_DIV16 (1 << 27)
45#define SPMODE_REV (1 << 26)
46#define SPMODE_MS (1 << 25)
47#define SPMODE_ENABLE (1 << 24)
48#define SPMODE_LEN(x) ((x) << 20)
49#define SPMODE_PM(x) ((x) << 16)
50
51/*
52 * Default for SPI Mode:
53 * SPI MODE 0 (inactive low, phase middle, MSB, 8-bit length, slow clk
54 */
55#define SPMODE_INIT_VAL (SPMODE_CI_INACTIVEHIGH | SPMODE_DIV16 | SPMODE_REV | \
56 SPMODE_MS | SPMODE_LEN(7) | SPMODE_PM(0xf))
57
58/* SPIE register values */
59#define SPIE_NE 0x00000200 /* Not empty */
60#define SPIE_NF 0x00000100 /* Not full */
61
62/* SPIM register values */
63#define SPIM_NE 0x00000200 /* Not empty */
64#define SPIM_NF 0x00000100 /* Not full */
65
66/* SPI Controller driver's private data. */
67struct mpc83xx_spi {
68 /* bitbang has to be first */
69 struct spi_bitbang bitbang;
70 struct completion done;
71
72 struct mpc83xx_spi_reg __iomem *base;
73
74 /* rx & tx bufs from the spi_transfer */
75 const void *tx;
76 void *rx;
77
78 /* functions to deal with different sized buffers */
79 void (*get_rx) (u32 rx_data, struct mpc83xx_spi *);
80 u32(*get_tx) (struct mpc83xx_spi *);
81
82 unsigned int count;
83 u32 irq;
84
85 unsigned nsecs; /* (clock cycle time)/2 */
86
87 u32 sysclk;
88 void (*activate_cs) (u8 cs, u8 polarity);
89 void (*deactivate_cs) (u8 cs, u8 polarity);
90};
91
92static inline void mpc83xx_spi_write_reg(__be32 __iomem * reg, u32 val)
93{
94 out_be32(reg, val);
95}
96
97static inline u32 mpc83xx_spi_read_reg(__be32 __iomem * reg)
98{
99 return in_be32(reg);
100}
101
102#define MPC83XX_SPI_RX_BUF(type) \
103void mpc83xx_spi_rx_buf_##type(u32 data, struct mpc83xx_spi *mpc83xx_spi) \
104{ \
105 type * rx = mpc83xx_spi->rx; \
106 *rx++ = (type)data; \
107 mpc83xx_spi->rx = rx; \
108}
109
110#define MPC83XX_SPI_TX_BUF(type) \
111u32 mpc83xx_spi_tx_buf_##type(struct mpc83xx_spi *mpc83xx_spi) \
112{ \
113 u32 data; \
114 const type * tx = mpc83xx_spi->tx; \
115 data = *tx++; \
116 mpc83xx_spi->tx = tx; \
117 return data; \
118}
119
120MPC83XX_SPI_RX_BUF(u8)
121MPC83XX_SPI_RX_BUF(u16)
122MPC83XX_SPI_RX_BUF(u32)
123MPC83XX_SPI_TX_BUF(u8)
124MPC83XX_SPI_TX_BUF(u16)
125MPC83XX_SPI_TX_BUF(u32)
126
127static void mpc83xx_spi_chipselect(struct spi_device *spi, int value)
128{
129 struct mpc83xx_spi *mpc83xx_spi;
130 u8 pol = spi->mode & SPI_CS_HIGH ? 1 : 0;
131
132 mpc83xx_spi = spi_master_get_devdata(spi->master);
133
134 if (value == BITBANG_CS_INACTIVE) {
135 if (mpc83xx_spi->deactivate_cs)
136 mpc83xx_spi->deactivate_cs(spi->chip_select, pol);
137 }
138
139 if (value == BITBANG_CS_ACTIVE) {
140 u32 regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode);
141 u32 len = spi->bits_per_word;
142 if (len == 32)
143 len = 0;
144 else
145 len = len - 1;
146
147 /* mask out bits we are going to set */
148 regval &= ~0x38ff0000;
149
150 if (spi->mode & SPI_CPHA)
151 regval |= SPMODE_CP_BEGIN_EDGECLK;
152 if (spi->mode & SPI_CPOL)
153 regval |= SPMODE_CI_INACTIVEHIGH;
154
155 regval |= SPMODE_LEN(len);
156
157 if ((mpc83xx_spi->sysclk / spi->max_speed_hz) >= 64) {
158 u8 pm = mpc83xx_spi->sysclk / (spi->max_speed_hz * 64);
159 regval |= SPMODE_PM(pm) | SPMODE_DIV16;
160 } else {
161 u8 pm = mpc83xx_spi->sysclk / (spi->max_speed_hz * 4);
162 regval |= SPMODE_PM(pm);
163 }
164
165 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval);
166 if (mpc83xx_spi->activate_cs)
167 mpc83xx_spi->activate_cs(spi->chip_select, pol);
168 }
169}
170
171static
172int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
173{
174 struct mpc83xx_spi *mpc83xx_spi;
175 u32 regval;
176 u8 bits_per_word;
177 u32 hz;
178
179 mpc83xx_spi = spi_master_get_devdata(spi->master);
180
181 if (t) {
182 bits_per_word = t->bits_per_word;
183 hz = t->speed_hz;
184 } else {
185 bits_per_word = 0;
186 hz = 0;
187 }
188
189 /* spi_transfer level calls that work per-word */
190 if (!bits_per_word)
191 bits_per_word = spi->bits_per_word;
192
193 /* Make sure its a bit width we support [4..16, 32] */
194 if ((bits_per_word < 4)
195 || ((bits_per_word > 16) && (bits_per_word != 32)))
196 return -EINVAL;
197
198 if (bits_per_word <= 8) {
199 mpc83xx_spi->get_rx = mpc83xx_spi_rx_buf_u8;
200 mpc83xx_spi->get_tx = mpc83xx_spi_tx_buf_u8;
201 } else if (bits_per_word <= 16) {
202 mpc83xx_spi->get_rx = mpc83xx_spi_rx_buf_u16;
203 mpc83xx_spi->get_tx = mpc83xx_spi_tx_buf_u16;
204 } else if (bits_per_word <= 32) {
205 mpc83xx_spi->get_rx = mpc83xx_spi_rx_buf_u32;
206 mpc83xx_spi->get_tx = mpc83xx_spi_tx_buf_u32;
207 } else
208 return -EINVAL;
209
210 /* nsecs = (clock period)/2 */
211 if (!hz)
212 hz = spi->max_speed_hz;
213 mpc83xx_spi->nsecs = (1000000000 / 2) / hz;
214 if (mpc83xx_spi->nsecs > MAX_UDELAY_MS * 1000)
215 return -EINVAL;
216
217 if (bits_per_word == 32)
218 bits_per_word = 0;
219 else
220 bits_per_word = bits_per_word - 1;
221
222 regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode);
223
224 /* Mask out bits_per_wordgth */
225 regval &= 0xff0fffff;
226 regval |= SPMODE_LEN(bits_per_word);
227
228 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval);
229
230 return 0;
231}
232
233static int mpc83xx_spi_setup(struct spi_device *spi)
234{
235 struct spi_bitbang *bitbang;
236 struct mpc83xx_spi *mpc83xx_spi;
237 int retval;
238
239 if (!spi->max_speed_hz)
240 return -EINVAL;
241
242 bitbang = spi_master_get_devdata(spi->master);
243 mpc83xx_spi = spi_master_get_devdata(spi->master);
244
245 if (!spi->bits_per_word)
246 spi->bits_per_word = 8;
247
248 retval = mpc83xx_spi_setup_transfer(spi, NULL);
249 if (retval < 0)
250 return retval;
251
252 dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u nsec\n",
253 __FUNCTION__, spi->mode & (SPI_CPOL | SPI_CPHA),
254 spi->bits_per_word, 2 * mpc83xx_spi->nsecs);
255
256 /* NOTE we _need_ to call chipselect() early, ideally with adapter
257 * setup, unless the hardware defaults cooperate to avoid confusion
258 * between normal (active low) and inverted chipselects.
259 */
260
261 /* deselect chip (low or high) */
262 spin_lock(&bitbang->lock);
263 if (!bitbang->busy) {
264 bitbang->chipselect(spi, BITBANG_CS_INACTIVE);
265 ndelay(mpc83xx_spi->nsecs);
266 }
267 spin_unlock(&bitbang->lock);
268
269 return 0;
270}
271
272static int mpc83xx_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
273{
274 struct mpc83xx_spi *mpc83xx_spi;
275 u32 word;
276
277 mpc83xx_spi = spi_master_get_devdata(spi->master);
278
279 mpc83xx_spi->tx = t->tx_buf;
280 mpc83xx_spi->rx = t->rx_buf;
281 mpc83xx_spi->count = t->len;
282 INIT_COMPLETION(mpc83xx_spi->done);
283
284 /* enable rx ints */
285 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mask, SPIM_NE);
286
287 /* transmit word */
288 word = mpc83xx_spi->get_tx(mpc83xx_spi);
289 mpc83xx_spi_write_reg(&mpc83xx_spi->base->transmit, word);
290
291 wait_for_completion(&mpc83xx_spi->done);
292
293 /* disable rx ints */
294 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mask, 0);
295
296 return t->len - mpc83xx_spi->count;
297}
298
299irqreturn_t mpc83xx_spi_irq(s32 irq, void *context_data,
300 struct pt_regs * ptregs)
301{
302 struct mpc83xx_spi *mpc83xx_spi = context_data;
303 u32 event;
304 irqreturn_t ret = IRQ_NONE;
305
306 /* Get interrupt events(tx/rx) */
307 event = mpc83xx_spi_read_reg(&mpc83xx_spi->base->event);
308
309 /* We need handle RX first */
310 if (event & SPIE_NE) {
311 u32 rx_data = mpc83xx_spi_read_reg(&mpc83xx_spi->base->receive);
312
313 if (mpc83xx_spi->rx)
314 mpc83xx_spi->get_rx(rx_data, mpc83xx_spi);
315
316 ret = IRQ_HANDLED;
317 }
318
319 if ((event & SPIE_NF) == 0)
320 /* spin until TX is done */
321 while (((event =
322 mpc83xx_spi_read_reg(&mpc83xx_spi->base->event)) &
323 SPIE_NF) == 0)
324 cpu_relax();
325
326 mpc83xx_spi->count -= 1;
327 if (mpc83xx_spi->count) {
328 if (mpc83xx_spi->tx) {
329 u32 word = mpc83xx_spi->get_tx(mpc83xx_spi);
330 mpc83xx_spi_write_reg(&mpc83xx_spi->base->transmit,
331 word);
332 }
333 } else {
334 complete(&mpc83xx_spi->done);
335 }
336
337 /* Clear the events */
338 mpc83xx_spi_write_reg(&mpc83xx_spi->base->event, event);
339
340 return ret;
341}
342
343static int __init mpc83xx_spi_probe(struct platform_device *dev)
344{
345 struct spi_master *master;
346 struct mpc83xx_spi *mpc83xx_spi;
347 struct fsl_spi_platform_data *pdata;
348 struct resource *r;
349 u32 regval;
350 int ret = 0;
351
352 /* Get resources(memory, IRQ) associated with the device */
353 master = spi_alloc_master(&dev->dev, sizeof(struct mpc83xx_spi));
354
355 if (master == NULL) {
356 ret = -ENOMEM;
357 goto err;
358 }
359
360 platform_set_drvdata(dev, master);
361 pdata = dev->dev.platform_data;
362
363 if (pdata == NULL) {
364 ret = -ENODEV;
365 goto free_master;
366 }
367
368 r = platform_get_resource(dev, IORESOURCE_MEM, 0);
369 if (r == NULL) {
370 ret = -ENODEV;
371 goto free_master;
372 }
373
374 mpc83xx_spi = spi_master_get_devdata(master);
375 mpc83xx_spi->bitbang.master = spi_master_get(master);
376 mpc83xx_spi->bitbang.chipselect = mpc83xx_spi_chipselect;
377 mpc83xx_spi->bitbang.setup_transfer = mpc83xx_spi_setup_transfer;
378 mpc83xx_spi->bitbang.txrx_bufs = mpc83xx_spi_bufs;
379 mpc83xx_spi->sysclk = pdata->sysclk;
380 mpc83xx_spi->activate_cs = pdata->activate_cs;
381 mpc83xx_spi->deactivate_cs = pdata->deactivate_cs;
382 mpc83xx_spi->get_rx = mpc83xx_spi_rx_buf_u8;
383 mpc83xx_spi->get_tx = mpc83xx_spi_tx_buf_u8;
384
385 mpc83xx_spi->bitbang.master->setup = mpc83xx_spi_setup;
386 init_completion(&mpc83xx_spi->done);
387
388 mpc83xx_spi->base = ioremap(r->start, r->end - r->start + 1);
389 if (mpc83xx_spi->base == NULL) {
390 ret = -ENOMEM;
391 goto put_master;
392 }
393
394 mpc83xx_spi->irq = platform_get_irq(dev, 0);
395
396 if (mpc83xx_spi->irq < 0) {
397 ret = -ENXIO;
398 goto unmap_io;
399 }
400
401 /* Register for SPI Interrupt */
402 ret = request_irq(mpc83xx_spi->irq, mpc83xx_spi_irq,
403 0, "mpc83xx_spi", mpc83xx_spi);
404
405 if (ret != 0)
406 goto unmap_io;
407
408 master->bus_num = pdata->bus_num;
409 master->num_chipselect = pdata->max_chipselect;
410
411 /* SPI controller initializations */
412 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, 0);
413 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mask, 0);
414 mpc83xx_spi_write_reg(&mpc83xx_spi->base->command, 0);
415 mpc83xx_spi_write_reg(&mpc83xx_spi->base->event, 0xffffffff);
416
417 /* Enable SPI interface */
418 regval = pdata->initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE;
419 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval);
420
421 ret = spi_bitbang_start(&mpc83xx_spi->bitbang);
422
423 if (ret != 0)
424 goto free_irq;
425
426 printk(KERN_INFO
427 "%s: MPC83xx SPI Controller driver at 0x%p (irq = %d)\n",
428 dev->dev.bus_id, mpc83xx_spi->base, mpc83xx_spi->irq);
429
430 return ret;
431
432free_irq:
433 free_irq(mpc83xx_spi->irq, mpc83xx_spi);
434unmap_io:
435 iounmap(mpc83xx_spi->base);
436put_master:
437 spi_master_put(master);
438free_master:
439 kfree(master);
440err:
441 return ret;
442}
443
444static int __devexit mpc83xx_spi_remove(struct platform_device *dev)
445{
446 struct mpc83xx_spi *mpc83xx_spi;
447 struct spi_master *master;
448
449 master = platform_get_drvdata(dev);
450 mpc83xx_spi = spi_master_get_devdata(master);
451
452 spi_bitbang_stop(&mpc83xx_spi->bitbang);
453 free_irq(mpc83xx_spi->irq, mpc83xx_spi);
454 iounmap(mpc83xx_spi->base);
455 spi_master_put(mpc83xx_spi->bitbang.master);
456
457 return 0;
458}
459
460static struct platform_driver mpc83xx_spi_driver = {
461 .probe = mpc83xx_spi_probe,
462 .remove = __devexit_p(mpc83xx_spi_remove),
463 .driver = {
464 .name = "mpc83xx_spi",
465 },
466};
467
468static int __init mpc83xx_spi_init(void)
469{
470 return platform_driver_register(&mpc83xx_spi_driver);
471}
472
473static void __exit mpc83xx_spi_exit(void)
474{
475 platform_driver_unregister(&mpc83xx_spi_driver);
476}
477
478module_init(mpc83xx_spi_init);
479module_exit(mpc83xx_spi_exit);
480
481MODULE_AUTHOR("Kumar Gala");
482MODULE_DESCRIPTION("Simple MPC83xx SPI Driver");
483MODULE_LICENSE("GPL");
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c
new file mode 100644
index 000000000000..5fc14563ee3a
--- /dev/null
+++ b/drivers/spi/spi_s3c24xx.c
@@ -0,0 +1,453 @@
1/* linux/drivers/spi/spi_s3c24xx.c
2 *
3 * Copyright (c) 2006 Ben Dooks
4 * Copyright (c) 2006 Simtec Electronics
5 * Ben Dooks <ben@simtec.co.uk>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11*/
12
13
14//#define DEBUG
15
16#include <linux/config.h>
17#include <linux/init.h>
18#include <linux/spinlock.h>
19#include <linux/workqueue.h>
20#include <linux/interrupt.h>
21#include <linux/delay.h>
22#include <linux/errno.h>
23#include <linux/err.h>
24#include <linux/clk.h>
25#include <linux/platform_device.h>
26
27#include <linux/spi/spi.h>
28#include <linux/spi/spi_bitbang.h>
29
30#include <asm/io.h>
31#include <asm/dma.h>
32#include <asm/hardware.h>
33
34#include <asm/arch/regs-gpio.h>
35#include <asm/arch/regs-spi.h>
36#include <asm/arch/spi.h>
37
38struct s3c24xx_spi {
39 /* bitbang has to be first */
40 struct spi_bitbang bitbang;
41 struct completion done;
42
43 void __iomem *regs;
44 int irq;
45 int len;
46 int count;
47
48 /* data buffers */
49 const unsigned char *tx;
50 unsigned char *rx;
51
52 struct clk *clk;
53 struct resource *ioarea;
54 struct spi_master *master;
55 struct spi_device *curdev;
56 struct device *dev;
57 struct s3c2410_spi_info *pdata;
58};
59
60#define SPCON_DEFAULT (S3C2410_SPCON_MSTR | S3C2410_SPCON_SMOD_INT)
61#define SPPIN_DEFAULT (S3C2410_SPPIN_KEEP)
62
63static inline struct s3c24xx_spi *to_hw(struct spi_device *sdev)
64{
65 return spi_master_get_devdata(sdev->master);
66}
67
68static void s3c24xx_spi_chipsel(struct spi_device *spi, int value)
69{
70 struct s3c24xx_spi *hw = to_hw(spi);
71 unsigned int cspol = spi->mode & SPI_CS_HIGH ? 1 : 0;
72 unsigned int spcon;
73
74 switch (value) {
75 case BITBANG_CS_INACTIVE:
76 if (hw->pdata->set_cs)
77 hw->pdata->set_cs(hw->pdata, value, cspol);
78 else
79 s3c2410_gpio_setpin(hw->pdata->pin_cs, cspol ^ 1);
80 break;
81
82 case BITBANG_CS_ACTIVE:
83 spcon = readb(hw->regs + S3C2410_SPCON);
84
85 if (spi->mode & SPI_CPHA)
86 spcon |= S3C2410_SPCON_CPHA_FMTB;
87 else
88 spcon &= ~S3C2410_SPCON_CPHA_FMTB;
89
90 if (spi->mode & SPI_CPOL)
91 spcon |= S3C2410_SPCON_CPOL_HIGH;
92 else
93 spcon &= ~S3C2410_SPCON_CPOL_HIGH;
94
95 spcon |= S3C2410_SPCON_ENSCK;
96
97 /* write new configration */
98
99 writeb(spcon, hw->regs + S3C2410_SPCON);
100
101 if (hw->pdata->set_cs)
102 hw->pdata->set_cs(hw->pdata, value, cspol);
103 else
104 s3c2410_gpio_setpin(hw->pdata->pin_cs, cspol);
105
106 break;
107
108 }
109}
110
111static int s3c24xx_spi_setupxfer(struct spi_device *spi,
112 struct spi_transfer *t)
113{
114 struct s3c24xx_spi *hw = to_hw(spi);
115 unsigned int bpw;
116 unsigned int hz;
117 unsigned int div;
118
119 bpw = t ? t->bits_per_word : spi->bits_per_word;
120 hz = t ? t->speed_hz : spi->max_speed_hz;
121
122 if (bpw != 8) {
123 dev_err(&spi->dev, "invalid bits-per-word (%d)\n", bpw);
124 return -EINVAL;
125 }
126
127 div = clk_get_rate(hw->clk) / hz;
128
129 /* is clk = pclk / (2 * (pre+1)), or is it
130 * clk = (pclk * 2) / ( pre + 1) */
131
132 div = (div / 2) - 1;
133
134 if (div < 0)
135 div = 1;
136
137 if (div > 255)
138 div = 255;
139
140 dev_dbg(&spi->dev, "setting pre-scaler to %d (hz %d)\n", div, hz);
141 writeb(div, hw->regs + S3C2410_SPPRE);
142
143 spin_lock(&hw->bitbang.lock);
144 if (!hw->bitbang.busy) {
145 hw->bitbang.chipselect(spi, BITBANG_CS_INACTIVE);
146 /* need to ndelay for 0.5 clocktick ? */
147 }
148 spin_unlock(&hw->bitbang.lock);
149
150 return 0;
151}
152
153static int s3c24xx_spi_setup(struct spi_device *spi)
154{
155 int ret;
156
157 if (!spi->bits_per_word)
158 spi->bits_per_word = 8;
159
160 if ((spi->mode & SPI_LSB_FIRST) != 0)
161 return -EINVAL;
162
163 ret = s3c24xx_spi_setupxfer(spi, NULL);
164 if (ret < 0) {
165 dev_err(&spi->dev, "setupxfer returned %d\n", ret);
166 return ret;
167 }
168
169 dev_dbg(&spi->dev, "%s: mode %d, %u bpw, %d hz\n",
170 __FUNCTION__, spi->mode, spi->bits_per_word,
171 spi->max_speed_hz);
172
173 return 0;
174}
175
176static inline unsigned int hw_txbyte(struct s3c24xx_spi *hw, int count)
177{
178 return hw->tx ? hw->tx[count] : 0xff;
179}
180
181static int s3c24xx_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
182{
183 struct s3c24xx_spi *hw = to_hw(spi);
184
185 dev_dbg(&spi->dev, "txrx: tx %p, rx %p, len %d\n",
186 t->tx_buf, t->rx_buf, t->len);
187
188 hw->tx = t->tx_buf;
189 hw->rx = t->rx_buf;
190 hw->len = t->len;
191 hw->count = 0;
192
193 /* send the first byte */
194 writeb(hw_txbyte(hw, 0), hw->regs + S3C2410_SPTDAT);
195 wait_for_completion(&hw->done);
196
197 return hw->count;
198}
199
200static irqreturn_t s3c24xx_spi_irq(int irq, void *dev, struct pt_regs *regs)
201{
202 struct s3c24xx_spi *hw = dev;
203 unsigned int spsta = readb(hw->regs + S3C2410_SPSTA);
204 unsigned int count = hw->count;
205
206 if (spsta & S3C2410_SPSTA_DCOL) {
207 dev_dbg(hw->dev, "data-collision\n");
208 complete(&hw->done);
209 goto irq_done;
210 }
211
212 if (!(spsta & S3C2410_SPSTA_READY)) {
213 dev_dbg(hw->dev, "spi not ready for tx?\n");
214 complete(&hw->done);
215 goto irq_done;
216 }
217
218 hw->count++;
219
220 if (hw->rx)
221 hw->rx[count] = readb(hw->regs + S3C2410_SPRDAT);
222
223 count++;
224
225 if (count < hw->len)
226 writeb(hw_txbyte(hw, count), hw->regs + S3C2410_SPTDAT);
227 else
228 complete(&hw->done);
229
230 irq_done:
231 return IRQ_HANDLED;
232}
233
234static int s3c24xx_spi_probe(struct platform_device *pdev)
235{
236 struct s3c24xx_spi *hw;
237 struct spi_master *master;
238 struct spi_board_info *bi;
239 struct resource *res;
240 int err = 0;
241 int i;
242
243 master = spi_alloc_master(&pdev->dev, sizeof(struct s3c24xx_spi));
244 if (master == NULL) {
245 dev_err(&pdev->dev, "No memory for spi_master\n");
246 err = -ENOMEM;
247 goto err_nomem;
248 }
249
250 hw = spi_master_get_devdata(master);
251 memset(hw, 0, sizeof(struct s3c24xx_spi));
252
253 hw->master = spi_master_get(master);
254 hw->pdata = pdev->dev.platform_data;
255 hw->dev = &pdev->dev;
256
257 if (hw->pdata == NULL) {
258 dev_err(&pdev->dev, "No platform data supplied\n");
259 err = -ENOENT;
260 goto err_no_pdata;
261 }
262
263 platform_set_drvdata(pdev, hw);
264 init_completion(&hw->done);
265
266 /* setup the state for the bitbang driver */
267
268 hw->bitbang.master = hw->master;
269 hw->bitbang.setup_transfer = s3c24xx_spi_setupxfer;
270 hw->bitbang.chipselect = s3c24xx_spi_chipsel;
271 hw->bitbang.txrx_bufs = s3c24xx_spi_txrx;
272 hw->bitbang.master->setup = s3c24xx_spi_setup;
273
274 dev_dbg(hw->dev, "bitbang at %p\n", &hw->bitbang);
275
276 /* find and map our resources */
277
278 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
279 if (res == NULL) {
280 dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n");
281 err = -ENOENT;
282 goto err_no_iores;
283 }
284
285 hw->ioarea = request_mem_region(res->start, (res->end - res->start)+1,
286 pdev->name);
287
288 if (hw->ioarea == NULL) {
289 dev_err(&pdev->dev, "Cannot reserve region\n");
290 err = -ENXIO;
291 goto err_no_iores;
292 }
293
294 hw->regs = ioremap(res->start, (res->end - res->start)+1);
295 if (hw->regs == NULL) {
296 dev_err(&pdev->dev, "Cannot map IO\n");
297 err = -ENXIO;
298 goto err_no_iomap;
299 }
300
301 hw->irq = platform_get_irq(pdev, 0);
302 if (hw->irq < 0) {
303 dev_err(&pdev->dev, "No IRQ specified\n");
304 err = -ENOENT;
305 goto err_no_irq;
306 }
307
308 err = request_irq(hw->irq, s3c24xx_spi_irq, 0, pdev->name, hw);
309 if (err) {
310 dev_err(&pdev->dev, "Cannot claim IRQ\n");
311 goto err_no_irq;
312 }
313
314 hw->clk = clk_get(&pdev->dev, "spi");
315 if (IS_ERR(hw->clk)) {
316 dev_err(&pdev->dev, "No clock for device\n");
317 err = PTR_ERR(hw->clk);
318 goto err_no_clk;
319 }
320
321 /* for the moment, permanently enable the clock */
322
323 clk_enable(hw->clk);
324
325 /* program defaults into the registers */
326
327 writeb(0xff, hw->regs + S3C2410_SPPRE);
328 writeb(SPPIN_DEFAULT, hw->regs + S3C2410_SPPIN);
329 writeb(SPCON_DEFAULT, hw->regs + S3C2410_SPCON);
330
331 /* setup any gpio we can */
332
333 if (!hw->pdata->set_cs) {
334 s3c2410_gpio_setpin(hw->pdata->pin_cs, 1);
335 s3c2410_gpio_cfgpin(hw->pdata->pin_cs, S3C2410_GPIO_OUTPUT);
336 }
337
338 /* register our spi controller */
339
340 err = spi_bitbang_start(&hw->bitbang);
341 if (err) {
342 dev_err(&pdev->dev, "Failed to register SPI master\n");
343 goto err_register;
344 }
345
346 dev_dbg(hw->dev, "shutdown=%d\n", hw->bitbang.shutdown);
347
348 /* register all the devices associated */
349
350 bi = &hw->pdata->board_info[0];
351 for (i = 0; i < hw->pdata->board_size; i++, bi++) {
352 dev_info(hw->dev, "registering %s\n", bi->modalias);
353
354 bi->controller_data = hw;
355 spi_new_device(master, bi);
356 }
357
358 return 0;
359
360 err_register:
361 clk_disable(hw->clk);
362 clk_put(hw->clk);
363
364 err_no_clk:
365 free_irq(hw->irq, hw);
366
367 err_no_irq:
368 iounmap(hw->regs);
369
370 err_no_iomap:
371 release_resource(hw->ioarea);
372 kfree(hw->ioarea);
373
374 err_no_iores:
375 err_no_pdata:
376 spi_master_put(hw->master);;
377
378 err_nomem:
379 return err;
380}
381
382static int s3c24xx_spi_remove(struct platform_device *dev)
383{
384 struct s3c24xx_spi *hw = platform_get_drvdata(dev);
385
386 platform_set_drvdata(dev, NULL);
387
388 spi_unregister_master(hw->master);
389
390 clk_disable(hw->clk);
391 clk_put(hw->clk);
392
393 free_irq(hw->irq, hw);
394 iounmap(hw->regs);
395
396 release_resource(hw->ioarea);
397 kfree(hw->ioarea);
398
399 spi_master_put(hw->master);
400 return 0;
401}
402
403
404#ifdef CONFIG_PM
405
406static int s3c24xx_spi_suspend(struct platform_device *pdev, pm_message_t msg)
407{
408 struct s3c24xx_spi *hw = platform_get_drvdata(pdev);
409
410 clk_disable(hw->clk);
411 return 0;
412}
413
414static int s3c24xx_spi_resume(struct platform_device *pdev)
415{
416 struct s3c24xx_spi *hw = platform_get_drvdata(pdev);
417
418 clk_enable(hw->clk);
419 return 0;
420}
421
422#else
423#define s3c24xx_spi_suspend NULL
424#define s3c24xx_spi_resume NULL
425#endif
426
427static struct platform_driver s3c24xx_spidrv = {
428 .probe = s3c24xx_spi_probe,
429 .remove = s3c24xx_spi_remove,
430 .suspend = s3c24xx_spi_suspend,
431 .resume = s3c24xx_spi_resume,
432 .driver = {
433 .name = "s3c2410-spi",
434 .owner = THIS_MODULE,
435 },
436};
437
438static int __init s3c24xx_spi_init(void)
439{
440 return platform_driver_register(&s3c24xx_spidrv);
441}
442
443static void __exit s3c24xx_spi_exit(void)
444{
445 platform_driver_unregister(&s3c24xx_spidrv);
446}
447
448module_init(s3c24xx_spi_init);
449module_exit(s3c24xx_spi_exit);
450
451MODULE_DESCRIPTION("S3C24XX SPI Driver");
452MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");
453MODULE_LICENSE("GPL");
diff --git a/drivers/spi/spi_s3c24xx_gpio.c b/drivers/spi/spi_s3c24xx_gpio.c
new file mode 100644
index 000000000000..aacdceb8f44b
--- /dev/null
+++ b/drivers/spi/spi_s3c24xx_gpio.c
@@ -0,0 +1,188 @@
1/* linux/drivers/spi/spi_s3c24xx_gpio.c
2 *
3 * Copyright (c) 2006 Ben Dooks
4 * Copyright (c) 2006 Simtec Electronics
5 *
6 * S3C24XX GPIO based SPI driver
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
14#include <linux/config.h>
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/delay.h>
18#include <linux/spinlock.h>
19#include <linux/platform_device.h>
20
21#include <linux/spi/spi.h>
22#include <linux/spi/spi_bitbang.h>
23
24#include <asm/arch/regs-gpio.h>
25#include <asm/arch/spi-gpio.h>
26#include <asm/arch/hardware.h>
27
28struct s3c2410_spigpio {
29 struct spi_bitbang bitbang;
30
31 struct s3c2410_spigpio_info *info;
32 struct platform_device *dev;
33};
34
35static inline struct s3c2410_spigpio *spidev_to_sg(struct spi_device *spi)
36{
37 return spi->controller_data;
38}
39
40static inline void setsck(struct spi_device *dev, int on)
41{
42 struct s3c2410_spigpio *sg = spidev_to_sg(dev);
43 s3c2410_gpio_setpin(sg->info->pin_clk, on ? 1 : 0);
44}
45
46static inline void setmosi(struct spi_device *dev, int on)
47{
48 struct s3c2410_spigpio *sg = spidev_to_sg(dev);
49 s3c2410_gpio_setpin(sg->info->pin_mosi, on ? 1 : 0);
50}
51
52static inline u32 getmiso(struct spi_device *dev)
53{
54 struct s3c2410_spigpio *sg = spidev_to_sg(dev);
55 return s3c2410_gpio_getpin(sg->info->pin_miso) ? 1 : 0;
56}
57
58#define spidelay(x) ndelay(x)
59
60#define EXPAND_BITBANG_TXRX
61#include <linux/spi/spi_bitbang.h>
62
63
64static u32 s3c2410_spigpio_txrx_mode0(struct spi_device *spi,
65 unsigned nsecs, u32 word, u8 bits)
66{
67 return bitbang_txrx_be_cpha0(spi, nsecs, 0, word, bits);
68}
69
70static u32 s3c2410_spigpio_txrx_mode1(struct spi_device *spi,
71 unsigned nsecs, u32 word, u8 bits)
72{
73 return bitbang_txrx_be_cpha1(spi, nsecs, 0, word, bits);
74}
75
76static void s3c2410_spigpio_chipselect(struct spi_device *dev, int value)
77{
78 struct s3c2410_spigpio *sg = spidev_to_sg(dev);
79
80 if (sg->info && sg->info->chip_select)
81 (sg->info->chip_select)(sg->info, value);
82}
83
84static int s3c2410_spigpio_probe(struct platform_device *dev)
85{
86 struct spi_master *master;
87 struct s3c2410_spigpio *sp;
88 int ret;
89 int i;
90
91 master = spi_alloc_master(&dev->dev, sizeof(struct s3c2410_spigpio));
92 if (master == NULL) {
93 dev_err(&dev->dev, "failed to allocate spi master\n");
94 ret = -ENOMEM;
95 goto err;
96 }
97
98 sp = spi_master_get_devdata(master);
99
100 platform_set_drvdata(dev, sp);
101
102 /* copy in the plkatform data */
103 sp->info = dev->dev.platform_data;
104
105 /* setup spi bitbang adaptor */
106 sp->bitbang.master = spi_master_get(master);
107 sp->bitbang.chipselect = s3c2410_spigpio_chipselect;
108
109 sp->bitbang.txrx_word[SPI_MODE_0] = s3c2410_spigpio_txrx_mode0;
110 sp->bitbang.txrx_word[SPI_MODE_1] = s3c2410_spigpio_txrx_mode1;
111
112 /* set state of spi pins */
113 s3c2410_gpio_setpin(sp->info->pin_clk, 0);
114 s3c2410_gpio_setpin(sp->info->pin_mosi, 0);
115
116 s3c2410_gpio_cfgpin(sp->info->pin_clk, S3C2410_GPIO_OUTPUT);
117 s3c2410_gpio_cfgpin(sp->info->pin_mosi, S3C2410_GPIO_OUTPUT);
118 s3c2410_gpio_cfgpin(sp->info->pin_miso, S3C2410_GPIO_INPUT);
119
120 ret = spi_bitbang_start(&sp->bitbang);
121 if (ret)
122 goto err_no_bitbang;
123
124 /* register the chips to go with the board */
125
126 for (i = 0; i < sp->info->board_size; i++) {
127 dev_info(&dev->dev, "registering %p: %s\n",
128 &sp->info->board_info[i],
129 sp->info->board_info[i].modalias);
130
131 sp->info->board_info[i].controller_data = sp;
132 spi_new_device(master, sp->info->board_info + i);
133 }
134
135 return 0;
136
137 err_no_bitbang:
138 spi_master_put(sp->bitbang.master);
139 err:
140 return ret;
141
142}
143
144static int s3c2410_spigpio_remove(struct platform_device *dev)
145{
146 struct s3c2410_spigpio *sp = platform_get_drvdata(dev);
147
148 spi_bitbang_stop(&sp->bitbang);
149 spi_master_put(sp->bitbang.master);
150
151 return 0;
152}
153
154/* all gpio should be held over suspend/resume, so we should
155 * not need to deal with this
156*/
157
158#define s3c2410_spigpio_suspend NULL
159#define s3c2410_spigpio_resume NULL
160
161
162static struct platform_driver s3c2410_spigpio_drv = {
163 .probe = s3c2410_spigpio_probe,
164 .remove = s3c2410_spigpio_remove,
165 .suspend = s3c2410_spigpio_suspend,
166 .resume = s3c2410_spigpio_resume,
167 .driver = {
168 .name = "s3c24xx-spi-gpio",
169 .owner = THIS_MODULE,
170 },
171};
172
173static int __init s3c2410_spigpio_init(void)
174{
175 return platform_driver_register(&s3c2410_spigpio_drv);
176}
177
178static void __exit s3c2410_spigpio_exit(void)
179{
180 platform_driver_unregister(&s3c2410_spigpio_drv);
181}
182
183module_init(s3c2410_spigpio_init);
184module_exit(s3c2410_spigpio_exit);
185
186MODULE_DESCRIPTION("S3C24XX SPI Driver");
187MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");
188MODULE_LICENSE("GPL");
diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c
index 6dd666696178..c4670e1d4654 100644
--- a/drivers/usb/input/hiddev.c
+++ b/drivers/usb/input/hiddev.c
@@ -317,6 +317,7 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
317 } 317 }
318 318
319 schedule(); 319 schedule();
320 set_current_state(TASK_INTERRUPTIBLE);
320 } 321 }
321 322
322 set_current_state(TASK_RUNNING); 323 set_current_state(TASK_RUNNING);
diff --git a/drivers/video/au1100fb.c b/drivers/video/au1100fb.c
index 3d04b2def0f1..789450bb0bc9 100644
--- a/drivers/video/au1100fb.c
+++ b/drivers/video/au1100fb.c
@@ -214,10 +214,13 @@ int au1100fb_setmode(struct au1100fb_device *fbdev)
214 */ 214 */
215int au1100fb_fb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *fbi) 215int au1100fb_fb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *fbi)
216{ 216{
217 struct au1100fb_device *fbdev = to_au1100fb_device(fbi); 217 struct au1100fb_device *fbdev;
218 u32 *palette = fbdev->regs->lcd_pallettebase; 218 u32 *palette;
219 u32 value; 219 u32 value;
220 220
221 fbdev = to_au1100fb_device(fbi);
222 palette = fbdev->regs->lcd_pallettebase;
223
221 if (regno > (AU1100_LCD_NBR_PALETTE_ENTRIES - 1)) 224 if (regno > (AU1100_LCD_NBR_PALETTE_ENTRIES - 1))
222 return -EINVAL; 225 return -EINVAL;
223 226
@@ -316,9 +319,11 @@ int au1100fb_fb_blank(int blank_mode, struct fb_info *fbi)
316 */ 319 */
317int au1100fb_fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *fbi) 320int au1100fb_fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *fbi)
318{ 321{
319 struct au1100fb_device *fbdev = to_au1100fb_device(fbi); 322 struct au1100fb_device *fbdev;
320 int dy; 323 int dy;
321 324
325 fbdev = to_au1100fb_device(fbi);
326
322 print_dbg("fb_pan_display %p %p", var, fbi); 327 print_dbg("fb_pan_display %p %p", var, fbi);
323 328
324 if (!var || !fbdev) { 329 if (!var || !fbdev) {
@@ -382,10 +387,12 @@ void au1100fb_fb_rotate(struct fb_info *fbi, int angle)
382 */ 387 */
383int au1100fb_fb_mmap(struct fb_info *fbi, struct vm_area_struct *vma) 388int au1100fb_fb_mmap(struct fb_info *fbi, struct vm_area_struct *vma)
384{ 389{
385 struct au1100fb_device *fbdev = to_au1100fb_device(fbi); 390 struct au1100fb_device *fbdev;
386 unsigned int len; 391 unsigned int len;
387 unsigned long start=0, off; 392 unsigned long start=0, off;
388 393
394 fbdev = to_au1100fb_device(fbi);
395
389 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) { 396 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) {
390 return -EINVAL; 397 return -EINVAL;
391 } 398 }
@@ -467,7 +474,7 @@ int au1100fb_drv_probe(struct device *dev)
467 474
468 if (!request_mem_region(au1100fb_fix.mmio_start, au1100fb_fix.mmio_len, 475 if (!request_mem_region(au1100fb_fix.mmio_start, au1100fb_fix.mmio_len,
469 DRIVER_NAME)) { 476 DRIVER_NAME)) {
470 print_err("fail to lock memory region at 0x%08x", 477 print_err("fail to lock memory region at 0x%08lx",
471 au1100fb_fix.mmio_start); 478 au1100fb_fix.mmio_start);
472 return -EBUSY; 479 return -EBUSY;
473 } 480 }
@@ -595,13 +602,13 @@ int au1100fb_drv_remove(struct device *dev)
595 return 0; 602 return 0;
596} 603}
597 604
598int au1100fb_drv_suspend(struct device *dev, u32 state, u32 level) 605int au1100fb_drv_suspend(struct device *dev, pm_message_t state)
599{ 606{
600 /* TODO */ 607 /* TODO */
601 return 0; 608 return 0;
602} 609}
603 610
604int au1100fb_drv_resume(struct device *dev, u32 level) 611int au1100fb_drv_resume(struct device *dev)
605{ 612{
606 /* TODO */ 613 /* TODO */
607 return 0; 614 return 0;
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index ca020719d20b..953eb8c171d6 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -2631,7 +2631,7 @@ static int fbcon_scrolldelta(struct vc_data *vc, int lines)
2631 scr_memcpyw((u16 *) q, (u16 *) p, 2631 scr_memcpyw((u16 *) q, (u16 *) p,
2632 vc->vc_size_row); 2632 vc->vc_size_row);
2633 } 2633 }
2634 softback_in = p; 2634 softback_in = softback_curr = p;
2635 update_region(vc, vc->vc_origin, 2635 update_region(vc, vc->vc_origin,
2636 logo_lines * vc->vc_cols); 2636 logo_lines * vc->vc_cols);
2637 } 2637 }
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index 788297e9d59e..44aa2ffff973 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -76,8 +76,8 @@
76 * 76 *
77 * Experiment with v_offset to find out which works best for you. 77 * Experiment with v_offset to find out which works best for you.
78 */ 78 */
79static u32 v_offset_default __initdata; /* For 32 MiB Aper size, 8 should be the default */ 79static u32 v_offset_default __devinitdata; /* For 32 MiB Aper size, 8 should be the default */
80static u32 voffset __initdata = 0; 80static u32 voffset __devinitdata;
81 81
82static int i810fb_cursor(struct fb_info *info, struct fb_cursor *cursor); 82static int i810fb_cursor(struct fb_info *info, struct fb_cursor *cursor);
83static int __devinit i810fb_init_pci (struct pci_dev *dev, 83static int __devinit i810fb_init_pci (struct pci_dev *dev,
diff --git a/drivers/video/matrox/g450_pll.c b/drivers/video/matrox/g450_pll.c
index 8073a73f6f35..440272ad10e7 100644
--- a/drivers/video/matrox/g450_pll.c
+++ b/drivers/video/matrox/g450_pll.c
@@ -316,14 +316,24 @@ static int __g450_setclk(WPMINFO unsigned int fout, unsigned int pll,
316 case M_PIXEL_PLL_B: 316 case M_PIXEL_PLL_B:
317 case M_PIXEL_PLL_C: 317 case M_PIXEL_PLL_C:
318 { 318 {
319 u_int8_t tmp; 319 u_int8_t tmp, xpwrctrl;
320 unsigned long flags; 320 unsigned long flags;
321 321
322 matroxfb_DAC_lock_irqsave(flags); 322 matroxfb_DAC_lock_irqsave(flags);
323
324 xpwrctrl = matroxfb_DAC_in(PMINFO M1064_XPWRCTRL);
325 matroxfb_DAC_out(PMINFO M1064_XPWRCTRL, xpwrctrl & ~M1064_XPWRCTRL_PANELPDN);
326 mga_outb(M_SEQ_INDEX, M_SEQ1);
327 mga_outb(M_SEQ_DATA, mga_inb(M_SEQ_DATA) | M_SEQ1_SCROFF);
323 tmp = matroxfb_DAC_in(PMINFO M1064_XPIXCLKCTRL); 328 tmp = matroxfb_DAC_in(PMINFO M1064_XPIXCLKCTRL);
329 tmp |= M1064_XPIXCLKCTRL_DIS;
324 if (!(tmp & M1064_XPIXCLKCTRL_PLL_UP)) { 330 if (!(tmp & M1064_XPIXCLKCTRL_PLL_UP)) {
325 matroxfb_DAC_out(PMINFO M1064_XPIXCLKCTRL, tmp | M1064_XPIXCLKCTRL_PLL_UP); 331 tmp |= M1064_XPIXCLKCTRL_PLL_UP;
326 } 332 }
333 matroxfb_DAC_out(PMINFO M1064_XPIXCLKCTRL, tmp);
334 matroxfb_DAC_out(PMINFO M1064_XDVICLKCTRL, 0);
335 matroxfb_DAC_out(PMINFO M1064_XPWRCTRL, xpwrctrl);
336
327 matroxfb_DAC_unlock_irqrestore(flags); 337 matroxfb_DAC_unlock_irqrestore(flags);
328 } 338 }
329 { 339 {
@@ -418,6 +428,15 @@ static int __g450_setclk(WPMINFO unsigned int fout, unsigned int pll,
418 frequency to higher - with <= lowest wins, while 428 frequency to higher - with <= lowest wins, while
419 with < highest one wins */ 429 with < highest one wins */
420 if (delta <= deltaarray[idx-1]) { 430 if (delta <= deltaarray[idx-1]) {
431 /* all else being equal except VCO,
432 * choose VCO not near (within 1/16th or so) VCOmin
433 * (freqs near VCOmin aren't as stable)
434 */
435 if (delta == deltaarray[idx-1]
436 && vco != g450_mnp2vco(PMINFO mnparray[idx-1])
437 && vco < (pi->vcomin * 17 / 16)) {
438 break;
439 }
421 mnparray[idx] = mnparray[idx-1]; 440 mnparray[idx] = mnparray[idx-1];
422 deltaarray[idx] = deltaarray[idx-1]; 441 deltaarray[idx] = deltaarray[idx-1];
423 } else { 442 } else {
diff --git a/drivers/video/matrox/matroxfb_DAC1064.h b/drivers/video/matrox/matroxfb_DAC1064.h
index 2e7238aa2432..56513a5d220b 100644
--- a/drivers/video/matrox/matroxfb_DAC1064.h
+++ b/drivers/video/matrox/matroxfb_DAC1064.h
@@ -40,6 +40,7 @@ void DAC1064_global_restore(WPMINFO2);
40#define M1064_XCURCOL1RED 0x0C 40#define M1064_XCURCOL1RED 0x0C
41#define M1064_XCURCOL1GREEN 0x0D 41#define M1064_XCURCOL1GREEN 0x0D
42#define M1064_XCURCOL1BLUE 0x0E 42#define M1064_XCURCOL1BLUE 0x0E
43#define M1064_XDVICLKCTRL 0x0F
43#define M1064_XCURCOL2RED 0x10 44#define M1064_XCURCOL2RED 0x10
44#define M1064_XCURCOL2GREEN 0x11 45#define M1064_XCURCOL2GREEN 0x11
45#define M1064_XCURCOL2BLUE 0x12 46#define M1064_XCURCOL2BLUE 0x12
@@ -144,6 +145,7 @@ void DAC1064_global_restore(WPMINFO2);
144#define M1064_XVIDPLLN 0x8F 145#define M1064_XVIDPLLN 0x8F
145 146
146#define M1064_XPWRCTRL 0xA0 147#define M1064_XPWRCTRL 0xA0
148#define M1064_XPWRCTRL_PANELPDN 0x04
147 149
148#define M1064_XPANMODE 0xA2 150#define M1064_XPANMODE 0xA2
149 151
diff --git a/drivers/video/matrox/matroxfb_base.h b/drivers/video/matrox/matroxfb_base.h
index 3a3e1804c56a..b71737178d0d 100644
--- a/drivers/video/matrox/matroxfb_base.h
+++ b/drivers/video/matrox/matroxfb_base.h
@@ -672,6 +672,8 @@ void matroxfb_unregister_driver(struct matroxfb_driver* drv);
672 672
673#define M_SEQ_INDEX 0x1FC4 673#define M_SEQ_INDEX 0x1FC4
674#define M_SEQ_DATA 0x1FC5 674#define M_SEQ_DATA 0x1FC5
675#define M_SEQ1 0x01
676#define M_SEQ1_SCROFF 0x20
675 677
676#define M_MISC_REG_READ 0x1FCC 678#define M_MISC_REG_READ 0x1FCC
677 679
diff --git a/drivers/video/maxinefb.c b/drivers/video/maxinefb.c
index 743e7ad26acc..f85421bf7cb5 100644
--- a/drivers/video/maxinefb.c
+++ b/drivers/video/maxinefb.c
@@ -55,7 +55,7 @@ static struct fb_var_screeninfo maxinefb_defined = {
55}; 55};
56 56
57static struct fb_fix_screeninfo maxinefb_fix = { 57static struct fb_fix_screeninfo maxinefb_fix = {
58 .id = "Maxine onboard graphics 1024x768x8", 58 .id = "Maxine",
59 .smem_len = (1024*768), 59 .smem_len = (1024*768),
60 .type = FB_TYPE_PACKED_PIXELS, 60 .type = FB_TYPE_PACKED_PIXELS,
61 .visual = FB_VISUAL_PSEUDOCOLOR, 61 .visual = FB_VISUAL_PSEUDOCOLOR,
@@ -107,8 +107,6 @@ static int maxinefb_setcolreg(unsigned regno, unsigned red, unsigned green,
107 107
108static struct fb_ops maxinefb_ops = { 108static struct fb_ops maxinefb_ops = {
109 .owner = THIS_MODULE, 109 .owner = THIS_MODULE,
110 .fb_get_fix = gen_get_fix,
111 .fb_get_var = gen_get_var,
112 .fb_setcolreg = maxinefb_setcolreg, 110 .fb_setcolreg = maxinefb_setcolreg,
113 .fb_fillrect = cfb_fillrect, 111 .fb_fillrect = cfb_fillrect,
114 .fb_copyarea = cfb_copyarea, 112 .fb_copyarea = cfb_copyarea,
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index d4c2d636c479..a42143ca0169 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -416,10 +416,9 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry,
416 return retval; 416 return retval;
417 } 417 }
418 418
419 retval = -EIO;
420 bh = affs_bread(sb, old_dentry->d_inode->i_ino); 419 bh = affs_bread(sb, old_dentry->d_inode->i_ino);
421 if (!bh) 420 if (!bh)
422 goto done; 421 return -EIO;
423 422
424 /* Remove header from its parent directory. */ 423 /* Remove header from its parent directory. */
425 affs_lock_dir(old_dir); 424 affs_lock_dir(old_dir);
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 69f44dcdb0b4..b1c902e319c1 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -428,7 +428,6 @@ static int load_flat_file(struct linux_binprm * bprm,
428 loff_t fpos; 428 loff_t fpos;
429 unsigned long start_code, end_code; 429 unsigned long start_code, end_code;
430 int ret; 430 int ret;
431 int exec_fileno;
432 431
433 hdr = ((struct flat_hdr *) bprm->buf); /* exec-header */ 432 hdr = ((struct flat_hdr *) bprm->buf); /* exec-header */
434 inode = bprm->file->f_dentry->d_inode; 433 inode = bprm->file->f_dentry->d_inode;
@@ -502,21 +501,12 @@ static int load_flat_file(struct linux_binprm * bprm,
502 goto err; 501 goto err;
503 } 502 }
504 503
505 /* check file descriptor */
506 exec_fileno = get_unused_fd();
507 if (exec_fileno < 0) {
508 ret = -EMFILE;
509 goto err;
510 }
511 get_file(bprm->file);
512 fd_install(exec_fileno, bprm->file);
513
514 /* Flush all traces of the currently running executable */ 504 /* Flush all traces of the currently running executable */
515 if (id == 0) { 505 if (id == 0) {
516 result = flush_old_exec(bprm); 506 result = flush_old_exec(bprm);
517 if (result) { 507 if (result) {
518 ret = result; 508 ret = result;
519 goto err_close; 509 goto err;
520 } 510 }
521 511
522 /* OK, This is the point of no return */ 512 /* OK, This is the point of no return */
@@ -548,7 +538,7 @@ static int load_flat_file(struct linux_binprm * bprm,
548 textpos = (unsigned long) -ENOMEM; 538 textpos = (unsigned long) -ENOMEM;
549 printk("Unable to mmap process text, errno %d\n", (int)-textpos); 539 printk("Unable to mmap process text, errno %d\n", (int)-textpos);
550 ret = textpos; 540 ret = textpos;
551 goto err_close; 541 goto err;
552 } 542 }
553 543
554 down_write(&current->mm->mmap_sem); 544 down_write(&current->mm->mmap_sem);
@@ -564,7 +554,7 @@ static int load_flat_file(struct linux_binprm * bprm,
564 (int)-datapos); 554 (int)-datapos);
565 do_munmap(current->mm, textpos, text_len); 555 do_munmap(current->mm, textpos, text_len);
566 ret = realdatastart; 556 ret = realdatastart;
567 goto err_close; 557 goto err;
568 } 558 }
569 datapos = realdatastart + MAX_SHARED_LIBS * sizeof(unsigned long); 559 datapos = realdatastart + MAX_SHARED_LIBS * sizeof(unsigned long);
570 560
@@ -587,7 +577,7 @@ static int load_flat_file(struct linux_binprm * bprm,
587 do_munmap(current->mm, textpos, text_len); 577 do_munmap(current->mm, textpos, text_len);
588 do_munmap(current->mm, realdatastart, data_len + extra); 578 do_munmap(current->mm, realdatastart, data_len + extra);
589 ret = result; 579 ret = result;
590 goto err_close; 580 goto err;
591 } 581 }
592 582
593 reloc = (unsigned long *) (datapos+(ntohl(hdr->reloc_start)-text_len)); 583 reloc = (unsigned long *) (datapos+(ntohl(hdr->reloc_start)-text_len));
@@ -606,7 +596,7 @@ static int load_flat_file(struct linux_binprm * bprm,
606 printk("Unable to allocate RAM for process text/data, errno %d\n", 596 printk("Unable to allocate RAM for process text/data, errno %d\n",
607 (int)-textpos); 597 (int)-textpos);
608 ret = textpos; 598 ret = textpos;
609 goto err_close; 599 goto err;
610 } 600 }
611 601
612 realdatastart = textpos + ntohl(hdr->data_start); 602 realdatastart = textpos + ntohl(hdr->data_start);
@@ -652,7 +642,7 @@ static int load_flat_file(struct linux_binprm * bprm,
652 do_munmap(current->mm, textpos, text_len + data_len + extra + 642 do_munmap(current->mm, textpos, text_len + data_len + extra +
653 MAX_SHARED_LIBS * sizeof(unsigned long)); 643 MAX_SHARED_LIBS * sizeof(unsigned long));
654 ret = result; 644 ret = result;
655 goto err_close; 645 goto err;
656 } 646 }
657 } 647 }
658 648
@@ -717,7 +707,7 @@ static int load_flat_file(struct linux_binprm * bprm,
717 addr = calc_reloc(*rp, libinfo, id, 0); 707 addr = calc_reloc(*rp, libinfo, id, 0);
718 if (addr == RELOC_FAILED) { 708 if (addr == RELOC_FAILED) {
719 ret = -ENOEXEC; 709 ret = -ENOEXEC;
720 goto err_close; 710 goto err;
721 } 711 }
722 *rp = addr; 712 *rp = addr;
723 } 713 }
@@ -747,7 +737,7 @@ static int load_flat_file(struct linux_binprm * bprm,
747 rp = (unsigned long *) calc_reloc(addr, libinfo, id, 1); 737 rp = (unsigned long *) calc_reloc(addr, libinfo, id, 1);
748 if (rp == (unsigned long *)RELOC_FAILED) { 738 if (rp == (unsigned long *)RELOC_FAILED) {
749 ret = -ENOEXEC; 739 ret = -ENOEXEC;
750 goto err_close; 740 goto err;
751 } 741 }
752 742
753 /* Get the pointer's value. */ 743 /* Get the pointer's value. */
@@ -762,7 +752,7 @@ static int load_flat_file(struct linux_binprm * bprm,
762 addr = calc_reloc(addr, libinfo, id, 0); 752 addr = calc_reloc(addr, libinfo, id, 0);
763 if (addr == RELOC_FAILED) { 753 if (addr == RELOC_FAILED) {
764 ret = -ENOEXEC; 754 ret = -ENOEXEC;
765 goto err_close; 755 goto err;
766 } 756 }
767 757
768 /* Write back the relocated pointer. */ 758 /* Write back the relocated pointer. */
@@ -783,8 +773,6 @@ static int load_flat_file(struct linux_binprm * bprm,
783 stack_len); 773 stack_len);
784 774
785 return 0; 775 return 0;
786err_close:
787 sys_close(exec_fileno);
788err: 776err:
789 return ret; 777 return ret;
790} 778}
diff --git a/fs/bio.c b/fs/bio.c
index eb8fbc53f2cd..098c12b2d60a 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -1116,6 +1116,9 @@ struct bio_pair *bio_split(struct bio *bi, mempool_t *pool, int first_sectors)
1116 bp->bio1.bi_io_vec = &bp->bv1; 1116 bp->bio1.bi_io_vec = &bp->bv1;
1117 bp->bio2.bi_io_vec = &bp->bv2; 1117 bp->bio2.bi_io_vec = &bp->bv2;
1118 1118
1119 bp->bio1.bi_max_vecs = 1;
1120 bp->bio2.bi_max_vecs = 1;
1121
1119 bp->bio1.bi_end_io = bio_pair_end_1; 1122 bp->bio1.bi_end_io = bio_pair_end_1;
1120 bp->bio2.bi_end_io = bio_pair_end_2; 1123 bp->bio2.bi_end_io = bio_pair_end_2;
1121 1124
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES
index 1a27ecb46c9a..7271bb0257f6 100644
--- a/fs/cifs/CHANGES
+++ b/fs/cifs/CHANGES
@@ -1,3 +1,10 @@
1Version 1.43
2------------
3POSIX locking to servers which support CIFS POSIX Extensions
4(disabled by default controlled by proc/fs/cifs/Experimental).
5Handle conversion of long share names (especially Asian languages)
6to Unicode during mount.
7
1Version 1.42 8Version 1.42
2------------ 9------------
3Fix slow oplock break when mounted to different servers at the same time and 10Fix slow oplock break when mounted to different servers at the same time and
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index 4e829dc672a6..c98755dca868 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -99,5 +99,5 @@ extern ssize_t cifs_getxattr(struct dentry *, const char *, void *, size_t);
99extern ssize_t cifs_listxattr(struct dentry *, char *, size_t); 99extern ssize_t cifs_listxattr(struct dentry *, char *, size_t);
100extern int cifs_ioctl (struct inode * inode, struct file * filep, 100extern int cifs_ioctl (struct inode * inode, struct file * filep,
101 unsigned int command, unsigned long arg); 101 unsigned int command, unsigned long arg);
102#define CIFS_VERSION "1.42" 102#define CIFS_VERSION "1.43"
103#endif /* _CIFSFS_H */ 103#endif /* _CIFSFS_H */
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 2879ba343ca7..310ea2f0e0bf 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -267,7 +267,7 @@ extern int CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
267 const int waitFlag); 267 const int waitFlag);
268extern int CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon, 268extern int CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
269 const __u16 smb_file_id, const int get_flag, 269 const __u16 smb_file_id, const int get_flag,
270 const __u64 len, const __u64 offset, 270 const __u64 len, struct file_lock *,
271 const __u16 lock_type, const int waitFlag); 271 const __u16 lock_type, const int waitFlag);
272extern int CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon); 272extern int CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon);
273extern int CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses); 273extern int CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses);
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index fd36892eda55..925881e00ff2 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -1355,7 +1355,8 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1355int 1355int
1356CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon, 1356CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1357 const __u16 smb_file_id, const int get_flag, const __u64 len, 1357 const __u16 smb_file_id, const int get_flag, const __u64 len,
1358 const __u64 lkoffset, const __u16 lock_type, const int waitFlag) 1358 struct file_lock *pLockData, const __u16 lock_type,
1359 const int waitFlag)
1359{ 1360{
1360 struct smb_com_transaction2_sfi_req *pSMB = NULL; 1361 struct smb_com_transaction2_sfi_req *pSMB = NULL;
1361 struct smb_com_transaction2_sfi_rsp *pSMBr = NULL; 1362 struct smb_com_transaction2_sfi_rsp *pSMBr = NULL;
@@ -1366,6 +1367,10 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1366 __u16 params, param_offset, offset, byte_count, count; 1367 __u16 params, param_offset, offset, byte_count, count;
1367 1368
1368 cFYI(1, ("Posix Lock")); 1369 cFYI(1, ("Posix Lock"));
1370
1371 if(pLockData == NULL)
1372 return EINVAL;
1373
1369 rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB); 1374 rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB);
1370 1375
1371 if (rc) 1376 if (rc)
@@ -1404,10 +1409,10 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1404 1409
1405 parm_data->lock_type = cpu_to_le16(lock_type); 1410 parm_data->lock_type = cpu_to_le16(lock_type);
1406 if(waitFlag) 1411 if(waitFlag)
1407 parm_data->lock_flags = 1; 1412 parm_data->lock_flags = cpu_to_le16(1);
1408 parm_data->pid = cpu_to_le32(current->tgid); 1413 parm_data->pid = cpu_to_le32(current->tgid);
1409 parm_data->start = lkoffset; 1414 parm_data->start = cpu_to_le64(pLockData->fl_start);
1410 parm_data->length = len; /* normalize negative numbers */ 1415 parm_data->length = cpu_to_le64(len); /* normalize negative numbers */
1411 1416
1412 pSMB->DataOffset = cpu_to_le16(offset); 1417 pSMB->DataOffset = cpu_to_le16(offset);
1413 pSMB->Fid = smb_file_id; 1418 pSMB->Fid = smb_file_id;
@@ -1419,8 +1424,33 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1419 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 1424 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
1420 if (rc) { 1425 if (rc) {
1421 cFYI(1, ("Send error in Posix Lock = %d", rc)); 1426 cFYI(1, ("Send error in Posix Lock = %d", rc));
1422 } 1427 } else if (get_flag) {
1428 /* lock structure can be returned on get */
1429 __u16 data_offset;
1430 __u16 data_count;
1431 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
1423 1432
1433 if (rc || (pSMBr->ByteCount < sizeof(struct cifs_posix_lock))) {
1434 rc = -EIO; /* bad smb */
1435 goto plk_err_exit;
1436 }
1437 if(pLockData == NULL) {
1438 rc = -EINVAL;
1439 goto plk_err_exit;
1440 }
1441 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
1442 data_count = le16_to_cpu(pSMBr->t2.DataCount);
1443 if(data_count < sizeof(struct cifs_posix_lock)) {
1444 rc = -EIO;
1445 goto plk_err_exit;
1446 }
1447 parm_data = (struct cifs_posix_lock *)
1448 ((char *)&pSMBr->hdr.Protocol + data_offset);
1449 if(parm_data->lock_type == cpu_to_le16(CIFS_UNLCK))
1450 pLockData->fl_type = F_UNLCK;
1451 }
1452
1453plk_err_exit:
1424 if (pSMB) 1454 if (pSMB)
1425 cifs_small_buf_release(pSMB); 1455 cifs_small_buf_release(pSMB);
1426 1456
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index d2ec806a4f32..bae1479318d1 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2148,6 +2148,8 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2148/* We look for obvious messed up bcc or strings in response so we do not go off 2148/* We look for obvious messed up bcc or strings in response so we do not go off
2149 the end since (at least) WIN2K and Windows XP have a major bug in not null 2149 the end since (at least) WIN2K and Windows XP have a major bug in not null
2150 terminating last Unicode string in response */ 2150 terminating last Unicode string in response */
2151 if(ses->serverOS)
2152 kfree(ses->serverOS);
2151 ses->serverOS = kzalloc(2 * (len + 1), GFP_KERNEL); 2153 ses->serverOS = kzalloc(2 * (len + 1), GFP_KERNEL);
2152 if(ses->serverOS == NULL) 2154 if(ses->serverOS == NULL)
2153 goto sesssetup_nomem; 2155 goto sesssetup_nomem;
@@ -2160,6 +2162,8 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2160 if (remaining_words > 0) { 2162 if (remaining_words > 0) {
2161 len = UniStrnlen((wchar_t *)bcc_ptr, 2163 len = UniStrnlen((wchar_t *)bcc_ptr,
2162 remaining_words-1); 2164 remaining_words-1);
2165 if(ses->serverNOS)
2166 kfree(ses->serverNOS);
2163 ses->serverNOS = kzalloc(2 * (len + 1),GFP_KERNEL); 2167 ses->serverNOS = kzalloc(2 * (len + 1),GFP_KERNEL);
2164 if(ses->serverNOS == NULL) 2168 if(ses->serverNOS == NULL)
2165 goto sesssetup_nomem; 2169 goto sesssetup_nomem;
@@ -2177,6 +2181,8 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2177 if (remaining_words > 0) { 2181 if (remaining_words > 0) {
2178 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); 2182 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words);
2179 /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ 2183 /* last string is not always null terminated (for e.g. for Windows XP & 2000) */
2184 if(ses->serverDomain)
2185 kfree(ses->serverDomain);
2180 ses->serverDomain = 2186 ses->serverDomain =
2181 kzalloc(2*(len+1),GFP_KERNEL); 2187 kzalloc(2*(len+1),GFP_KERNEL);
2182 if(ses->serverDomain == NULL) 2188 if(ses->serverDomain == NULL)
@@ -2187,15 +2193,22 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2187 ses->serverDomain[2*len] = 0; 2193 ses->serverDomain[2*len] = 0;
2188 ses->serverDomain[1+(2*len)] = 0; 2194 ses->serverDomain[1+(2*len)] = 0;
2189 } /* else no more room so create dummy domain string */ 2195 } /* else no more room so create dummy domain string */
2190 else 2196 else {
2197 if(ses->serverDomain)
2198 kfree(ses->serverDomain);
2191 ses->serverDomain = 2199 ses->serverDomain =
2192 kzalloc(2, GFP_KERNEL); 2200 kzalloc(2, GFP_KERNEL);
2201 }
2193 } else { /* no room so create dummy domain and NOS string */ 2202 } else { /* no room so create dummy domain and NOS string */
2194 /* if these kcallocs fail not much we 2203 /* if these kcallocs fail not much we
2195 can do, but better to not fail the 2204 can do, but better to not fail the
2196 sesssetup itself */ 2205 sesssetup itself */
2206 if(ses->serverDomain)
2207 kfree(ses->serverDomain);
2197 ses->serverDomain = 2208 ses->serverDomain =
2198 kzalloc(2, GFP_KERNEL); 2209 kzalloc(2, GFP_KERNEL);
2210 if(ses->serverNOS)
2211 kfree(ses->serverNOS);
2199 ses->serverNOS = 2212 ses->serverNOS =
2200 kzalloc(2, GFP_KERNEL); 2213 kzalloc(2, GFP_KERNEL);
2201 } 2214 }
@@ -2204,6 +2217,8 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2204 if (((long) bcc_ptr + len) - (long) 2217 if (((long) bcc_ptr + len) - (long)
2205 pByteArea(smb_buffer_response) 2218 pByteArea(smb_buffer_response)
2206 <= BCC(smb_buffer_response)) { 2219 <= BCC(smb_buffer_response)) {
2220 if(ses->serverOS)
2221 kfree(ses->serverOS);
2207 ses->serverOS = kzalloc(len + 1,GFP_KERNEL); 2222 ses->serverOS = kzalloc(len + 1,GFP_KERNEL);
2208 if(ses->serverOS == NULL) 2223 if(ses->serverOS == NULL)
2209 goto sesssetup_nomem; 2224 goto sesssetup_nomem;
@@ -2214,6 +2229,8 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2214 bcc_ptr++; 2229 bcc_ptr++;
2215 2230
2216 len = strnlen(bcc_ptr, 1024); 2231 len = strnlen(bcc_ptr, 1024);
2232 if(ses->serverNOS)
2233 kfree(ses->serverNOS);
2217 ses->serverNOS = kzalloc(len + 1,GFP_KERNEL); 2234 ses->serverNOS = kzalloc(len + 1,GFP_KERNEL);
2218 if(ses->serverNOS == NULL) 2235 if(ses->serverNOS == NULL)
2219 goto sesssetup_nomem; 2236 goto sesssetup_nomem;
@@ -2223,6 +2240,8 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2223 bcc_ptr++; 2240 bcc_ptr++;
2224 2241
2225 len = strnlen(bcc_ptr, 1024); 2242 len = strnlen(bcc_ptr, 1024);
2243 if(ses->serverDomain)
2244 kfree(ses->serverDomain);
2226 ses->serverDomain = kzalloc(len + 1,GFP_KERNEL); 2245 ses->serverDomain = kzalloc(len + 1,GFP_KERNEL);
2227 if(ses->serverDomain == NULL) 2246 if(ses->serverDomain == NULL)
2228 goto sesssetup_nomem; 2247 goto sesssetup_nomem;
@@ -2427,6 +2446,8 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2427/* We look for obvious messed up bcc or strings in response so we do not go off 2446/* We look for obvious messed up bcc or strings in response so we do not go off
2428 the end since (at least) WIN2K and Windows XP have a major bug in not null 2447 the end since (at least) WIN2K and Windows XP have a major bug in not null
2429 terminating last Unicode string in response */ 2448 terminating last Unicode string in response */
2449 if(ses->serverOS)
2450 kfree(ses->serverOS);
2430 ses->serverOS = 2451 ses->serverOS =
2431 kzalloc(2 * (len + 1), GFP_KERNEL); 2452 kzalloc(2 * (len + 1), GFP_KERNEL);
2432 cifs_strfromUCS_le(ses->serverOS, 2453 cifs_strfromUCS_le(ses->serverOS,
@@ -2441,6 +2462,8 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2441 len = UniStrnlen((wchar_t *)bcc_ptr, 2462 len = UniStrnlen((wchar_t *)bcc_ptr,
2442 remaining_words 2463 remaining_words
2443 - 1); 2464 - 1);
2465 if(ses->serverNOS)
2466 kfree(ses->serverNOS);
2444 ses->serverNOS = 2467 ses->serverNOS =
2445 kzalloc(2 * (len + 1), 2468 kzalloc(2 * (len + 1),
2446 GFP_KERNEL); 2469 GFP_KERNEL);
@@ -2454,7 +2477,9 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2454 remaining_words -= len + 1; 2477 remaining_words -= len + 1;
2455 if (remaining_words > 0) { 2478 if (remaining_words > 0) {
2456 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); 2479 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words);
2457 /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ 2480 /* last string not null terminated (e.g.Windows XP/2000) */
2481 if(ses->serverDomain)
2482 kfree(ses->serverDomain);
2458 ses->serverDomain = kzalloc(2*(len+1),GFP_KERNEL); 2483 ses->serverDomain = kzalloc(2*(len+1),GFP_KERNEL);
2459 cifs_strfromUCS_le(ses->serverDomain, 2484 cifs_strfromUCS_le(ses->serverDomain,
2460 (__le16 *)bcc_ptr, 2485 (__le16 *)bcc_ptr,
@@ -2463,11 +2488,18 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2463 ses->serverDomain[2*len] = 0; 2488 ses->serverDomain[2*len] = 0;
2464 ses->serverDomain[1+(2*len)] = 0; 2489 ses->serverDomain[1+(2*len)] = 0;
2465 } /* else no more room so create dummy domain string */ 2490 } /* else no more room so create dummy domain string */
2466 else 2491 else {
2492 if(ses->serverDomain)
2493 kfree(ses->serverDomain);
2467 ses->serverDomain = 2494 ses->serverDomain =
2468 kzalloc(2,GFP_KERNEL); 2495 kzalloc(2,GFP_KERNEL);
2469 } else { /* no room so create dummy domain and NOS string */ 2496 }
2497 } else {/* no room use dummy domain&NOS */
2498 if(ses->serverDomain)
2499 kfree(ses->serverDomain);
2470 ses->serverDomain = kzalloc(2, GFP_KERNEL); 2500 ses->serverDomain = kzalloc(2, GFP_KERNEL);
2501 if(ses->serverNOS)
2502 kfree(ses->serverNOS);
2471 ses->serverNOS = kzalloc(2, GFP_KERNEL); 2503 ses->serverNOS = kzalloc(2, GFP_KERNEL);
2472 } 2504 }
2473 } else { /* ASCII */ 2505 } else { /* ASCII */
@@ -2476,6 +2508,8 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2476 if (((long) bcc_ptr + len) - (long) 2508 if (((long) bcc_ptr + len) - (long)
2477 pByteArea(smb_buffer_response) 2509 pByteArea(smb_buffer_response)
2478 <= BCC(smb_buffer_response)) { 2510 <= BCC(smb_buffer_response)) {
2511 if(ses->serverOS)
2512 kfree(ses->serverOS);
2479 ses->serverOS = kzalloc(len + 1, GFP_KERNEL); 2513 ses->serverOS = kzalloc(len + 1, GFP_KERNEL);
2480 strncpy(ses->serverOS, bcc_ptr, len); 2514 strncpy(ses->serverOS, bcc_ptr, len);
2481 2515
@@ -2484,6 +2518,8 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2484 bcc_ptr++; 2518 bcc_ptr++;
2485 2519
2486 len = strnlen(bcc_ptr, 1024); 2520 len = strnlen(bcc_ptr, 1024);
2521 if(ses->serverNOS)
2522 kfree(ses->serverNOS);
2487 ses->serverNOS = kzalloc(len + 1,GFP_KERNEL); 2523 ses->serverNOS = kzalloc(len + 1,GFP_KERNEL);
2488 strncpy(ses->serverNOS, bcc_ptr, len); 2524 strncpy(ses->serverNOS, bcc_ptr, len);
2489 bcc_ptr += len; 2525 bcc_ptr += len;
@@ -2491,6 +2527,8 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2491 bcc_ptr++; 2527 bcc_ptr++;
2492 2528
2493 len = strnlen(bcc_ptr, 1024); 2529 len = strnlen(bcc_ptr, 1024);
2530 if(ses->serverDomain)
2531 kfree(ses->serverDomain);
2494 ses->serverDomain = kzalloc(len + 1, GFP_KERNEL); 2532 ses->serverDomain = kzalloc(len + 1, GFP_KERNEL);
2495 strncpy(ses->serverDomain, bcc_ptr, len); 2533 strncpy(ses->serverDomain, bcc_ptr, len);
2496 bcc_ptr += len; 2534 bcc_ptr += len;
@@ -2728,6 +2766,8 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2728/* We look for obvious messed up bcc or strings in response so we do not go off 2766/* We look for obvious messed up bcc or strings in response so we do not go off
2729 the end since (at least) WIN2K and Windows XP have a major bug in not null 2767 the end since (at least) WIN2K and Windows XP have a major bug in not null
2730 terminating last Unicode string in response */ 2768 terminating last Unicode string in response */
2769 if(ses->serverOS)
2770 kfree(ses->serverOS);
2731 ses->serverOS = 2771 ses->serverOS =
2732 kzalloc(2 * (len + 1), GFP_KERNEL); 2772 kzalloc(2 * (len + 1), GFP_KERNEL);
2733 cifs_strfromUCS_le(ses->serverOS, 2773 cifs_strfromUCS_le(ses->serverOS,
@@ -2743,6 +2783,8 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2743 bcc_ptr, 2783 bcc_ptr,
2744 remaining_words 2784 remaining_words
2745 - 1); 2785 - 1);
2786 if(ses->serverNOS)
2787 kfree(ses->serverNOS);
2746 ses->serverNOS = 2788 ses->serverNOS =
2747 kzalloc(2 * (len + 1), 2789 kzalloc(2 * (len + 1),
2748 GFP_KERNEL); 2790 GFP_KERNEL);
@@ -2760,6 +2802,8 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2760 if (remaining_words > 0) { 2802 if (remaining_words > 0) {
2761 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); 2803 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words);
2762 /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ 2804 /* last string is not always null terminated (for e.g. for Windows XP & 2000) */
2805 if(ses->serverDomain)
2806 kfree(ses->serverDomain);
2763 ses->serverDomain = 2807 ses->serverDomain =
2764 kzalloc(2 * 2808 kzalloc(2 *
2765 (len + 2809 (len +
@@ -2777,13 +2821,20 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2777 [1 + (2 * len)] 2821 [1 + (2 * len)]
2778 = 0; 2822 = 0;
2779 } /* else no more room so create dummy domain string */ 2823 } /* else no more room so create dummy domain string */
2780 else 2824 else {
2825 if(ses->serverDomain)
2826 kfree(ses->serverDomain);
2781 ses->serverDomain = 2827 ses->serverDomain =
2782 kzalloc(2, 2828 kzalloc(2,
2783 GFP_KERNEL); 2829 GFP_KERNEL);
2830 }
2784 } else { /* no room so create dummy domain and NOS string */ 2831 } else { /* no room so create dummy domain and NOS string */
2832 if(ses->serverDomain);
2833 kfree(ses->serverDomain);
2785 ses->serverDomain = 2834 ses->serverDomain =
2786 kzalloc(2, GFP_KERNEL); 2835 kzalloc(2, GFP_KERNEL);
2836 if(ses->serverNOS)
2837 kfree(ses->serverNOS);
2787 ses->serverNOS = 2838 ses->serverNOS =
2788 kzalloc(2, GFP_KERNEL); 2839 kzalloc(2, GFP_KERNEL);
2789 } 2840 }
@@ -2792,6 +2843,8 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2792 if (((long) bcc_ptr + len) - (long) 2843 if (((long) bcc_ptr + len) - (long)
2793 pByteArea(smb_buffer_response) 2844 pByteArea(smb_buffer_response)
2794 <= BCC(smb_buffer_response)) { 2845 <= BCC(smb_buffer_response)) {
2846 if(ses->serverOS)
2847 kfree(ses->serverOS);
2795 ses->serverOS = 2848 ses->serverOS =
2796 kzalloc(len + 1, 2849 kzalloc(len + 1,
2797 GFP_KERNEL); 2850 GFP_KERNEL);
@@ -2803,6 +2856,8 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2803 bcc_ptr++; 2856 bcc_ptr++;
2804 2857
2805 len = strnlen(bcc_ptr, 1024); 2858 len = strnlen(bcc_ptr, 1024);
2859 if(ses->serverNOS)
2860 kfree(ses->serverNOS);
2806 ses->serverNOS = 2861 ses->serverNOS =
2807 kzalloc(len + 1, 2862 kzalloc(len + 1,
2808 GFP_KERNEL); 2863 GFP_KERNEL);
@@ -2812,6 +2867,8 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2812 bcc_ptr++; 2867 bcc_ptr++;
2813 2868
2814 len = strnlen(bcc_ptr, 1024); 2869 len = strnlen(bcc_ptr, 1024);
2870 if(ses->serverDomain)
2871 kfree(ses->serverDomain);
2815 ses->serverDomain = 2872 ses->serverDomain =
2816 kzalloc(len + 1, 2873 kzalloc(len + 1,
2817 GFP_KERNEL); 2874 GFP_KERNEL);
@@ -3116,6 +3173,8 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3116/* We look for obvious messed up bcc or strings in response so we do not go off 3173/* We look for obvious messed up bcc or strings in response so we do not go off
3117 the end since (at least) WIN2K and Windows XP have a major bug in not null 3174 the end since (at least) WIN2K and Windows XP have a major bug in not null
3118 terminating last Unicode string in response */ 3175 terminating last Unicode string in response */
3176 if(ses->serverOS)
3177 kfree(ses->serverOS);
3119 ses->serverOS = 3178 ses->serverOS =
3120 kzalloc(2 * (len + 1), GFP_KERNEL); 3179 kzalloc(2 * (len + 1), GFP_KERNEL);
3121 cifs_strfromUCS_le(ses->serverOS, 3180 cifs_strfromUCS_le(ses->serverOS,
@@ -3131,6 +3190,8 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3131 bcc_ptr, 3190 bcc_ptr,
3132 remaining_words 3191 remaining_words
3133 - 1); 3192 - 1);
3193 if(ses->serverNOS)
3194 kfree(ses->serverNOS);
3134 ses->serverNOS = 3195 ses->serverNOS =
3135 kzalloc(2 * (len + 1), 3196 kzalloc(2 * (len + 1),
3136 GFP_KERNEL); 3197 GFP_KERNEL);
@@ -3147,6 +3208,8 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3147 if (remaining_words > 0) { 3208 if (remaining_words > 0) {
3148 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); 3209 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words);
3149 /* last string not always null terminated (e.g. for Windows XP & 2000) */ 3210 /* last string not always null terminated (e.g. for Windows XP & 2000) */
3211 if(ses->serverDomain)
3212 kfree(ses->serverDomain);
3150 ses->serverDomain = 3213 ses->serverDomain =
3151 kzalloc(2 * 3214 kzalloc(2 *
3152 (len + 3215 (len +
@@ -3172,10 +3235,17 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3172 len)] 3235 len)]
3173 = 0; 3236 = 0;
3174 } /* else no more room so create dummy domain string */ 3237 } /* else no more room so create dummy domain string */
3175 else 3238 else {
3239 if(ses->serverDomain)
3240 kfree(ses->serverDomain);
3176 ses->serverDomain = kzalloc(2,GFP_KERNEL); 3241 ses->serverDomain = kzalloc(2,GFP_KERNEL);
3242 }
3177 } else { /* no room so create dummy domain and NOS string */ 3243 } else { /* no room so create dummy domain and NOS string */
3244 if(ses->serverDomain)
3245 kfree(ses->serverDomain);
3178 ses->serverDomain = kzalloc(2, GFP_KERNEL); 3246 ses->serverDomain = kzalloc(2, GFP_KERNEL);
3247 if(ses->serverNOS)
3248 kfree(ses->serverNOS);
3179 ses->serverNOS = kzalloc(2, GFP_KERNEL); 3249 ses->serverNOS = kzalloc(2, GFP_KERNEL);
3180 } 3250 }
3181 } else { /* ASCII */ 3251 } else { /* ASCII */
@@ -3183,6 +3253,8 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3183 if (((long) bcc_ptr + len) - 3253 if (((long) bcc_ptr + len) -
3184 (long) pByteArea(smb_buffer_response) 3254 (long) pByteArea(smb_buffer_response)
3185 <= BCC(smb_buffer_response)) { 3255 <= BCC(smb_buffer_response)) {
3256 if(ses->serverOS)
3257 kfree(ses->serverOS);
3186 ses->serverOS = kzalloc(len + 1,GFP_KERNEL); 3258 ses->serverOS = kzalloc(len + 1,GFP_KERNEL);
3187 strncpy(ses->serverOS,bcc_ptr, len); 3259 strncpy(ses->serverOS,bcc_ptr, len);
3188 3260
@@ -3191,6 +3263,8 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3191 bcc_ptr++; 3263 bcc_ptr++;
3192 3264
3193 len = strnlen(bcc_ptr, 1024); 3265 len = strnlen(bcc_ptr, 1024);
3266 if(ses->serverNOS)
3267 kfree(ses->serverNOS);
3194 ses->serverNOS = kzalloc(len+1,GFP_KERNEL); 3268 ses->serverNOS = kzalloc(len+1,GFP_KERNEL);
3195 strncpy(ses->serverNOS, bcc_ptr, len); 3269 strncpy(ses->serverNOS, bcc_ptr, len);
3196 bcc_ptr += len; 3270 bcc_ptr += len;
@@ -3198,6 +3272,8 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3198 bcc_ptr++; 3272 bcc_ptr++;
3199 3273
3200 len = strnlen(bcc_ptr, 1024); 3274 len = strnlen(bcc_ptr, 1024);
3275 if(ses->serverDomain)
3276 kfree(ses->serverDomain);
3201 ses->serverDomain = kzalloc(len+1,GFP_KERNEL); 3277 ses->serverDomain = kzalloc(len+1,GFP_KERNEL);
3202 strncpy(ses->serverDomain, bcc_ptr, len); 3278 strncpy(ses->serverDomain, bcc_ptr, len);
3203 bcc_ptr += len; 3279 bcc_ptr += len;
@@ -3282,7 +3358,8 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
3282 bcc_ptr++; /* align */ 3358 bcc_ptr++; /* align */
3283 } 3359 }
3284 3360
3285 if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 3361 if(ses->server->secMode &
3362 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
3286 smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; 3363 smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
3287 3364
3288 if (ses->capabilities & CAP_STATUS32) { 3365 if (ses->capabilities & CAP_STATUS32) {
@@ -3294,8 +3371,10 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
3294 if (ses->capabilities & CAP_UNICODE) { 3371 if (ses->capabilities & CAP_UNICODE) {
3295 smb_buffer->Flags2 |= SMBFLG2_UNICODE; 3372 smb_buffer->Flags2 |= SMBFLG2_UNICODE;
3296 length = 3373 length =
3297 cifs_strtoUCS((__le16 *) bcc_ptr, tree, 100, nls_codepage); 3374 cifs_strtoUCS((__le16 *) bcc_ptr, tree,
3298 bcc_ptr += 2 * length; /* convert num of 16 bit words to bytes */ 3375 6 /* max utf8 char length in bytes */ *
3376 (/* server len*/ + 256 /* share len */), nls_codepage);
3377 bcc_ptr += 2 * length; /* convert num 16 bit words to bytes */
3299 bcc_ptr += 2; /* skip trailing null */ 3378 bcc_ptr += 2; /* skip trailing null */
3300 } else { /* ASCII */ 3379 } else { /* ASCII */
3301 strcpy(bcc_ptr, tree); 3380 strcpy(bcc_ptr, tree);
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index e152bf6afa60..e2b4ce1dad66 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -84,6 +84,8 @@ static inline int cifs_get_disposition(unsigned int flags)
84 return FILE_OVERWRITE_IF; 84 return FILE_OVERWRITE_IF;
85 else if ((flags & O_CREAT) == O_CREAT) 85 else if ((flags & O_CREAT) == O_CREAT)
86 return FILE_OPEN_IF; 86 return FILE_OPEN_IF;
87 else if ((flags & O_TRUNC) == O_TRUNC)
88 return FILE_OVERWRITE;
87 else 89 else
88 return FILE_OPEN; 90 return FILE_OPEN;
89} 91}
@@ -656,7 +658,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
656 else 658 else
657 posix_lock_type = CIFS_WRLCK; 659 posix_lock_type = CIFS_WRLCK;
658 rc = CIFSSMBPosixLock(xid, pTcon, netfid, 1 /* get */, 660 rc = CIFSSMBPosixLock(xid, pTcon, netfid, 1 /* get */,
659 length, pfLock->fl_start, 661 length, pfLock,
660 posix_lock_type, wait_flag); 662 posix_lock_type, wait_flag);
661 FreeXid(xid); 663 FreeXid(xid);
662 return rc; 664 return rc;
@@ -704,7 +706,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
704 return -EOPNOTSUPP; 706 return -EOPNOTSUPP;
705 } 707 }
706 rc = CIFSSMBPosixLock(xid, pTcon, netfid, 0 /* set */, 708 rc = CIFSSMBPosixLock(xid, pTcon, netfid, 0 /* set */,
707 length, pfLock->fl_start, 709 length, pfLock,
708 posix_lock_type, wait_flag); 710 posix_lock_type, wait_flag);
709 } else 711 } else
710 rc = CIFSSMBLock(xid, pTcon, netfid, length, pfLock->fl_start, 712 rc = CIFSSMBLock(xid, pTcon, netfid, length, pfLock->fl_start,
@@ -904,8 +906,10 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
904 if (rc != 0) 906 if (rc != 0)
905 break; 907 break;
906 } 908 }
907 if(experimEnabled || (pTcon->ses->server->secMode & 909 if(experimEnabled || (pTcon->ses->server &&
908 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) == 0) { 910 ((pTcon->ses->server->secMode &
911 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
912 == 0))) {
909 struct kvec iov[2]; 913 struct kvec iov[2];
910 unsigned int len; 914 unsigned int len;
911 915
diff --git a/fs/compat.c b/fs/compat.c
index 01f39f87f372..b1f64786a613 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -2030,109 +2030,115 @@ union compat_nfsctl_res {
2030 struct knfsd_fh cr32_getfs; 2030 struct knfsd_fh cr32_getfs;
2031}; 2031};
2032 2032
2033static int compat_nfs_svc_trans(struct nfsctl_arg *karg, struct compat_nfsctl_arg __user *arg) 2033static int compat_nfs_svc_trans(struct nfsctl_arg *karg,
2034{ 2034 struct compat_nfsctl_arg __user *arg)
2035 int err; 2035{
2036 2036 if (!access_ok(VERIFY_READ, &arg->ca32_svc, sizeof(arg->ca32_svc)) ||
2037 err = access_ok(VERIFY_READ, &arg->ca32_svc, sizeof(arg->ca32_svc)); 2037 get_user(karg->ca_version, &arg->ca32_version) ||
2038 err |= get_user(karg->ca_version, &arg->ca32_version); 2038 __get_user(karg->ca_svc.svc_port, &arg->ca32_svc.svc32_port) ||
2039 err |= __get_user(karg->ca_svc.svc_port, &arg->ca32_svc.svc32_port); 2039 __get_user(karg->ca_svc.svc_nthreads,
2040 err |= __get_user(karg->ca_svc.svc_nthreads, &arg->ca32_svc.svc32_nthreads); 2040 &arg->ca32_svc.svc32_nthreads))
2041 return (err) ? -EFAULT : 0; 2041 return -EFAULT;
2042 return 0;
2042} 2043}
2043 2044
2044static int compat_nfs_clnt_trans(struct nfsctl_arg *karg, struct compat_nfsctl_arg __user *arg) 2045static int compat_nfs_clnt_trans(struct nfsctl_arg *karg,
2045{ 2046 struct compat_nfsctl_arg __user *arg)
2046 int err; 2047{
2047 2048 if (!access_ok(VERIFY_READ, &arg->ca32_client,
2048 err = access_ok(VERIFY_READ, &arg->ca32_client, sizeof(arg->ca32_client)); 2049 sizeof(arg->ca32_client)) ||
2049 err |= get_user(karg->ca_version, &arg->ca32_version); 2050 get_user(karg->ca_version, &arg->ca32_version) ||
2050 err |= __copy_from_user(&karg->ca_client.cl_ident[0], 2051 __copy_from_user(&karg->ca_client.cl_ident[0],
2051 &arg->ca32_client.cl32_ident[0], 2052 &arg->ca32_client.cl32_ident[0],
2052 NFSCLNT_IDMAX); 2053 NFSCLNT_IDMAX) ||
2053 err |= __get_user(karg->ca_client.cl_naddr, &arg->ca32_client.cl32_naddr); 2054 __get_user(karg->ca_client.cl_naddr,
2054 err |= __copy_from_user(&karg->ca_client.cl_addrlist[0], 2055 &arg->ca32_client.cl32_naddr) ||
2055 &arg->ca32_client.cl32_addrlist[0], 2056 __copy_from_user(&karg->ca_client.cl_addrlist[0],
2056 (sizeof(struct in_addr) * NFSCLNT_ADDRMAX)); 2057 &arg->ca32_client.cl32_addrlist[0],
2057 err |= __get_user(karg->ca_client.cl_fhkeytype, 2058 (sizeof(struct in_addr) * NFSCLNT_ADDRMAX)) ||
2058 &arg->ca32_client.cl32_fhkeytype); 2059 __get_user(karg->ca_client.cl_fhkeytype,
2059 err |= __get_user(karg->ca_client.cl_fhkeylen, 2060 &arg->ca32_client.cl32_fhkeytype) ||
2060 &arg->ca32_client.cl32_fhkeylen); 2061 __get_user(karg->ca_client.cl_fhkeylen,
2061 err |= __copy_from_user(&karg->ca_client.cl_fhkey[0], 2062 &arg->ca32_client.cl32_fhkeylen) ||
2062 &arg->ca32_client.cl32_fhkey[0], 2063 __copy_from_user(&karg->ca_client.cl_fhkey[0],
2063 NFSCLNT_KEYMAX); 2064 &arg->ca32_client.cl32_fhkey[0],
2065 NFSCLNT_KEYMAX))
2066 return -EFAULT;
2064 2067
2065 return (err) ? -EFAULT : 0; 2068 return 0;
2066} 2069}
2067 2070
2068static int compat_nfs_exp_trans(struct nfsctl_arg *karg, struct compat_nfsctl_arg __user *arg) 2071static int compat_nfs_exp_trans(struct nfsctl_arg *karg,
2069{ 2072 struct compat_nfsctl_arg __user *arg)
2070 int err; 2073{
2071 2074 if (!access_ok(VERIFY_READ, &arg->ca32_export,
2072 err = access_ok(VERIFY_READ, &arg->ca32_export, sizeof(arg->ca32_export)); 2075 sizeof(arg->ca32_export)) ||
2073 err |= get_user(karg->ca_version, &arg->ca32_version); 2076 get_user(karg->ca_version, &arg->ca32_version) ||
2074 err |= __copy_from_user(&karg->ca_export.ex_client[0], 2077 __copy_from_user(&karg->ca_export.ex_client[0],
2075 &arg->ca32_export.ex32_client[0], 2078 &arg->ca32_export.ex32_client[0],
2076 NFSCLNT_IDMAX); 2079 NFSCLNT_IDMAX) ||
2077 err |= __copy_from_user(&karg->ca_export.ex_path[0], 2080 __copy_from_user(&karg->ca_export.ex_path[0],
2078 &arg->ca32_export.ex32_path[0], 2081 &arg->ca32_export.ex32_path[0],
2079 NFS_MAXPATHLEN); 2082 NFS_MAXPATHLEN) ||
2080 err |= __get_user(karg->ca_export.ex_dev, 2083 __get_user(karg->ca_export.ex_dev,
2081 &arg->ca32_export.ex32_dev); 2084 &arg->ca32_export.ex32_dev) ||
2082 err |= __get_user(karg->ca_export.ex_ino, 2085 __get_user(karg->ca_export.ex_ino,
2083 &arg->ca32_export.ex32_ino); 2086 &arg->ca32_export.ex32_ino) ||
2084 err |= __get_user(karg->ca_export.ex_flags, 2087 __get_user(karg->ca_export.ex_flags,
2085 &arg->ca32_export.ex32_flags); 2088 &arg->ca32_export.ex32_flags) ||
2086 err |= __get_user(karg->ca_export.ex_anon_uid, 2089 __get_user(karg->ca_export.ex_anon_uid,
2087 &arg->ca32_export.ex32_anon_uid); 2090 &arg->ca32_export.ex32_anon_uid) ||
2088 err |= __get_user(karg->ca_export.ex_anon_gid, 2091 __get_user(karg->ca_export.ex_anon_gid,
2089 &arg->ca32_export.ex32_anon_gid); 2092 &arg->ca32_export.ex32_anon_gid))
2093 return -EFAULT;
2090 SET_UID(karg->ca_export.ex_anon_uid, karg->ca_export.ex_anon_uid); 2094 SET_UID(karg->ca_export.ex_anon_uid, karg->ca_export.ex_anon_uid);
2091 SET_GID(karg->ca_export.ex_anon_gid, karg->ca_export.ex_anon_gid); 2095 SET_GID(karg->ca_export.ex_anon_gid, karg->ca_export.ex_anon_gid);
2092 2096
2093 return (err) ? -EFAULT : 0; 2097 return 0;
2094} 2098}
2095 2099
2096static int compat_nfs_getfd_trans(struct nfsctl_arg *karg, struct compat_nfsctl_arg __user *arg) 2100static int compat_nfs_getfd_trans(struct nfsctl_arg *karg,
2097{ 2101 struct compat_nfsctl_arg __user *arg)
2098 int err; 2102{
2099 2103 if (!access_ok(VERIFY_READ, &arg->ca32_getfd,
2100 err = access_ok(VERIFY_READ, &arg->ca32_getfd, sizeof(arg->ca32_getfd)); 2104 sizeof(arg->ca32_getfd)) ||
2101 err |= get_user(karg->ca_version, &arg->ca32_version); 2105 get_user(karg->ca_version, &arg->ca32_version) ||
2102 err |= __copy_from_user(&karg->ca_getfd.gd_addr, 2106 __copy_from_user(&karg->ca_getfd.gd_addr,
2103 &arg->ca32_getfd.gd32_addr, 2107 &arg->ca32_getfd.gd32_addr,
2104 (sizeof(struct sockaddr))); 2108 (sizeof(struct sockaddr))) ||
2105 err |= __copy_from_user(&karg->ca_getfd.gd_path, 2109 __copy_from_user(&karg->ca_getfd.gd_path,
2106 &arg->ca32_getfd.gd32_path, 2110 &arg->ca32_getfd.gd32_path,
2107 (NFS_MAXPATHLEN+1)); 2111 (NFS_MAXPATHLEN+1)) ||
2108 err |= __get_user(karg->ca_getfd.gd_version, 2112 __get_user(karg->ca_getfd.gd_version,
2109 &arg->ca32_getfd.gd32_version); 2113 &arg->ca32_getfd.gd32_version))
2114 return -EFAULT;
2110 2115
2111 return (err) ? -EFAULT : 0; 2116 return 0;
2112} 2117}
2113 2118
2114static int compat_nfs_getfs_trans(struct nfsctl_arg *karg, struct compat_nfsctl_arg __user *arg) 2119static int compat_nfs_getfs_trans(struct nfsctl_arg *karg,
2120 struct compat_nfsctl_arg __user *arg)
2115{ 2121{
2116 int err; 2122 if (!access_ok(VERIFY_READ,&arg->ca32_getfs,sizeof(arg->ca32_getfs)) ||
2117 2123 get_user(karg->ca_version, &arg->ca32_version) ||
2118 err = access_ok(VERIFY_READ, &arg->ca32_getfs, sizeof(arg->ca32_getfs)); 2124 __copy_from_user(&karg->ca_getfs.gd_addr,
2119 err |= get_user(karg->ca_version, &arg->ca32_version); 2125 &arg->ca32_getfs.gd32_addr,
2120 err |= __copy_from_user(&karg->ca_getfs.gd_addr, 2126 (sizeof(struct sockaddr))) ||
2121 &arg->ca32_getfs.gd32_addr, 2127 __copy_from_user(&karg->ca_getfs.gd_path,
2122 (sizeof(struct sockaddr))); 2128 &arg->ca32_getfs.gd32_path,
2123 err |= __copy_from_user(&karg->ca_getfs.gd_path, 2129 (NFS_MAXPATHLEN+1)) ||
2124 &arg->ca32_getfs.gd32_path, 2130 __get_user(karg->ca_getfs.gd_maxlen,
2125 (NFS_MAXPATHLEN+1)); 2131 &arg->ca32_getfs.gd32_maxlen))
2126 err |= __get_user(karg->ca_getfs.gd_maxlen, 2132 return -EFAULT;
2127 &arg->ca32_getfs.gd32_maxlen);
2128 2133
2129 return (err) ? -EFAULT : 0; 2134 return 0;
2130} 2135}
2131 2136
2132/* This really doesn't need translations, we are only passing 2137/* This really doesn't need translations, we are only passing
2133 * back a union which contains opaque nfs file handle data. 2138 * back a union which contains opaque nfs file handle data.
2134 */ 2139 */
2135static int compat_nfs_getfh_res_trans(union nfsctl_res *kres, union compat_nfsctl_res __user *res) 2140static int compat_nfs_getfh_res_trans(union nfsctl_res *kres,
2141 union compat_nfsctl_res __user *res)
2136{ 2142{
2137 int err; 2143 int err;
2138 2144
@@ -2141,8 +2147,9 @@ static int compat_nfs_getfh_res_trans(union nfsctl_res *kres, union compat_nfsct
2141 return (err) ? -EFAULT : 0; 2147 return (err) ? -EFAULT : 0;
2142} 2148}
2143 2149
2144asmlinkage long compat_sys_nfsservctl(int cmd, struct compat_nfsctl_arg __user *arg, 2150asmlinkage long compat_sys_nfsservctl(int cmd,
2145 union compat_nfsctl_res __user *res) 2151 struct compat_nfsctl_arg __user *arg,
2152 union compat_nfsctl_res __user *res)
2146{ 2153{
2147 struct nfsctl_arg *karg; 2154 struct nfsctl_arg *karg;
2148 union nfsctl_res *kres; 2155 union nfsctl_res *kres;
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
index b06b54f1bbbb..4c39009350f3 100644
--- a/fs/exportfs/expfs.c
+++ b/fs/exportfs/expfs.c
@@ -102,7 +102,7 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent,
102 if (acceptable(context, result)) 102 if (acceptable(context, result))
103 return result; 103 return result;
104 if (S_ISDIR(result->d_inode->i_mode)) { 104 if (S_ISDIR(result->d_inode->i_mode)) {
105 /* there is no other dentry, so fail */ 105 err = -EACCES;
106 goto err_result; 106 goto err_result;
107 } 107 }
108 108
diff --git a/fs/ext3/resize.c b/fs/ext3/resize.c
index 8aac5334680d..34b39e9a1e5a 100644
--- a/fs/ext3/resize.c
+++ b/fs/ext3/resize.c
@@ -767,7 +767,6 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
767 if (input->group != sbi->s_groups_count) { 767 if (input->group != sbi->s_groups_count) {
768 ext3_warning(sb, __FUNCTION__, 768 ext3_warning(sb, __FUNCTION__,
769 "multiple resizers run on filesystem!"); 769 "multiple resizers run on filesystem!");
770 unlock_super(sb);
771 err = -EBUSY; 770 err = -EBUSY;
772 goto exit_journal; 771 goto exit_journal;
773 } 772 }
diff --git a/fs/inotify.c b/fs/inotify.c
index 1f50302849c5..732ec4bd5774 100644
--- a/fs/inotify.c
+++ b/fs/inotify.c
@@ -848,7 +848,11 @@ static int inotify_release(struct inode *ignored, struct file *file)
848 inode = watch->inode; 848 inode = watch->inode;
849 mutex_lock(&inode->inotify_mutex); 849 mutex_lock(&inode->inotify_mutex);
850 mutex_lock(&dev->mutex); 850 mutex_lock(&dev->mutex);
851 remove_watch_no_event(watch, dev); 851
852 /* make sure we didn't race with another list removal */
853 if (likely(idr_find(&dev->idr, watch->wd)))
854 remove_watch_no_event(watch, dev);
855
852 mutex_unlock(&dev->mutex); 856 mutex_unlock(&dev->mutex);
853 mutex_unlock(&inode->inotify_mutex); 857 mutex_unlock(&inode->inotify_mutex);
854 put_inotify_watch(watch); 858 put_inotify_watch(watch);
@@ -890,8 +894,7 @@ static int inotify_ignore(struct inotify_device *dev, s32 wd)
890 mutex_lock(&dev->mutex); 894 mutex_lock(&dev->mutex);
891 895
892 /* make sure that we did not race */ 896 /* make sure that we did not race */
893 watch = idr_find(&dev->idr, wd); 897 if (likely(idr_find(&dev->idr, wd) == watch))
894 if (likely(watch))
895 remove_watch(watch, dev); 898 remove_watch(watch, dev);
896 899
897 mutex_unlock(&dev->mutex); 900 mutex_unlock(&dev->mutex);
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index f28696f235c4..2b220dd6b4e7 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -542,7 +542,7 @@ add_failed:
542static int metapage_releasepage(struct page *page, gfp_t gfp_mask) 542static int metapage_releasepage(struct page *page, gfp_t gfp_mask)
543{ 543{
544 struct metapage *mp; 544 struct metapage *mp;
545 int busy = 0; 545 int ret = 1;
546 unsigned int offset; 546 unsigned int offset;
547 547
548 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) { 548 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
@@ -552,30 +552,20 @@ static int metapage_releasepage(struct page *page, gfp_t gfp_mask)
552 continue; 552 continue;
553 553
554 jfs_info("metapage_releasepage: mp = 0x%p", mp); 554 jfs_info("metapage_releasepage: mp = 0x%p", mp);
555 if (mp->count || mp->nohomeok) { 555 if (mp->count || mp->nohomeok ||
556 test_bit(META_dirty, &mp->flag)) {
556 jfs_info("count = %ld, nohomeok = %d", mp->count, 557 jfs_info("count = %ld, nohomeok = %d", mp->count,
557 mp->nohomeok); 558 mp->nohomeok);
558 busy = 1; 559 ret = 0;
559 continue; 560 continue;
560 } 561 }
561 wait_on_page_writeback(page);
562 //WARN_ON(test_bit(META_dirty, &mp->flag));
563 if (test_bit(META_dirty, &mp->flag)) {
564 dump_mem("dirty mp in metapage_releasepage", mp,
565 sizeof(struct metapage));
566 dump_mem("page", page, sizeof(struct page));
567 dump_stack();
568 }
569 if (mp->lsn) 562 if (mp->lsn)
570 remove_from_logsync(mp); 563 remove_from_logsync(mp);
571 remove_metapage(page, mp); 564 remove_metapage(page, mp);
572 INCREMENT(mpStat.pagefree); 565 INCREMENT(mpStat.pagefree);
573 free_metapage(mp); 566 free_metapage(mp);
574 } 567 }
575 if (busy) 568 return ret;
576 return -1;
577
578 return 0;
579} 569}
580 570
581static void metapage_invalidatepage(struct page *page, unsigned long offset) 571static void metapage_invalidatepage(struct page *page, unsigned long offset)
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 4e0578121d9a..3eec30000f3f 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -1066,9 +1066,11 @@ exp_pseudoroot(struct auth_domain *clp, struct svc_fh *fhp,
1066 rv = nfserr_perm; 1066 rv = nfserr_perm;
1067 else if (IS_ERR(exp)) 1067 else if (IS_ERR(exp))
1068 rv = nfserrno(PTR_ERR(exp)); 1068 rv = nfserrno(PTR_ERR(exp));
1069 else 1069 else {
1070 rv = fh_compose(fhp, exp, 1070 rv = fh_compose(fhp, exp,
1071 fsid_key->ek_dentry, NULL); 1071 fsid_key->ek_dentry, NULL);
1072 exp_put(exp);
1073 }
1072 cache_put(&fsid_key->h, &svc_expkey_cache); 1074 cache_put(&fsid_key->h, &svc_expkey_cache);
1073 return rv; 1075 return rv;
1074} 1076}
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 6aa92d0e6876..1d65f13f458c 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1922,11 +1922,10 @@ nfsd_set_posix_acl(struct svc_fh *fhp, int type, struct posix_acl *acl)
1922 value = kmalloc(size, GFP_KERNEL); 1922 value = kmalloc(size, GFP_KERNEL);
1923 if (!value) 1923 if (!value)
1924 return -ENOMEM; 1924 return -ENOMEM;
1925 size = posix_acl_to_xattr(acl, value, size); 1925 error = posix_acl_to_xattr(acl, value, size);
1926 if (size < 0) { 1926 if (error < 0)
1927 error = size;
1928 goto getout; 1927 goto getout;
1929 } 1928 size = error;
1930 } else 1929 } else
1931 size = 0; 1930 size = 0;
1932 1931
diff --git a/include/asm-alpha/termbits.h b/include/asm-alpha/termbits.h
index f4837fa29420..5541101b58ae 100644
--- a/include/asm-alpha/termbits.h
+++ b/include/asm-alpha/termbits.h
@@ -148,6 +148,7 @@ struct termios {
148#define HUPCL 00040000 148#define HUPCL 00040000
149 149
150#define CLOCAL 00100000 150#define CLOCAL 00100000
151#define CMSPAR 010000000000 /* mark or space (stick) parity */
151#define CRTSCTS 020000000000 /* flow control */ 152#define CRTSCTS 020000000000 /* flow control */
152 153
153/* c_lflag bits */ 154/* c_lflag bits */
diff --git a/include/asm-arm/arch-ixp23xx/memory.h b/include/asm-arm/arch-ixp23xx/memory.h
index 6e19f46d54d1..c85fc06a043c 100644
--- a/include/asm-arm/arch-ixp23xx/memory.h
+++ b/include/asm-arm/arch-ixp23xx/memory.h
@@ -49,7 +49,7 @@ static inline int __ixp23xx_arch_is_coherent(void)
49{ 49{
50 extern unsigned int processor_id; 50 extern unsigned int processor_id;
51 51
52 if (((processor_id & 15) >= 2) || machine_is_roadrunner()) 52 if (((processor_id & 15) >= 4) || machine_is_roadrunner())
53 return 1; 53 return 1;
54 54
55 return 0; 55 return 0;
diff --git a/include/asm-arm/arch-pxa/pxa2xx_spi.h b/include/asm-arm/arch-pxa/pxa2xx_spi.h
index 1e70908b816f..915590c391c8 100644
--- a/include/asm-arm/arch-pxa/pxa2xx_spi.h
+++ b/include/asm-arm/arch-pxa/pxa2xx_spi.h
@@ -27,13 +27,16 @@
27#define SSP1_SerClkDiv(x) (((CLOCK_SPEED_HZ/2/(x+1))<<8)&0x0000ff00) 27#define SSP1_SerClkDiv(x) (((CLOCK_SPEED_HZ/2/(x+1))<<8)&0x0000ff00)
28#define SSP2_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00) 28#define SSP2_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
29#define SSP3_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00) 29#define SSP3_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
30#define SSP_TIMEOUT_SCALE (2712)
30#elif defined(CONFIG_PXA27x) 31#elif defined(CONFIG_PXA27x)
31#define CLOCK_SPEED_HZ 13000000 32#define CLOCK_SPEED_HZ 13000000
32#define SSP1_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00) 33#define SSP1_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
33#define SSP2_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00) 34#define SSP2_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
34#define SSP3_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00) 35#define SSP3_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
36#define SSP_TIMEOUT_SCALE (769)
35#endif 37#endif
36 38
39#define SSP_TIMEOUT(x) ((x*10000)/SSP_TIMEOUT_SCALE)
37#define SSP1_VIRT ((void *)(io_p2v(__PREG(SSCR0_P(1))))) 40#define SSP1_VIRT ((void *)(io_p2v(__PREG(SSCR0_P(1)))))
38#define SSP2_VIRT ((void *)(io_p2v(__PREG(SSCR0_P(2))))) 41#define SSP2_VIRT ((void *)(io_p2v(__PREG(SSCR0_P(2)))))
39#define SSP3_VIRT ((void *)(io_p2v(__PREG(SSCR0_P(3))))) 42#define SSP3_VIRT ((void *)(io_p2v(__PREG(SSCR0_P(3)))))
diff --git a/include/asm-arm/arch-s3c2410/spi-gpio.h b/include/asm-arm/arch-s3c2410/spi-gpio.h
new file mode 100644
index 000000000000..258c00bca270
--- /dev/null
+++ b/include/asm-arm/arch-s3c2410/spi-gpio.h
@@ -0,0 +1,31 @@
1/* linux/include/asm-arm/arch-s3c2410/spi.h
2 *
3 * Copyright (c) 2006 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * S3C2410 - SPI Controller platfrom_device info
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#ifndef __ASM_ARCH_SPIGPIO_H
14#define __ASM_ARCH_SPIGPIO_H __FILE__
15
16struct s3c2410_spigpio_info;
17struct spi_board_info;
18
19struct s3c2410_spigpio_info {
20 unsigned long pin_clk;
21 unsigned long pin_mosi;
22 unsigned long pin_miso;
23
24 unsigned long board_size;
25 struct spi_board_info *board_info;
26
27 void (*chip_select)(struct s3c2410_spigpio_info *spi, int cs);
28};
29
30
31#endif /* __ASM_ARCH_SPIGPIO_H */
diff --git a/include/asm-arm/arch-s3c2410/spi.h b/include/asm-arm/arch-s3c2410/spi.h
new file mode 100644
index 000000000000..4029a1a1ab40
--- /dev/null
+++ b/include/asm-arm/arch-s3c2410/spi.h
@@ -0,0 +1,29 @@
1/* linux/include/asm-arm/arch-s3c2410/spi.h
2 *
3 * Copyright (c) 2006 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * S3C2410 - SPI Controller platform_device info
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#ifndef __ASM_ARCH_SPI_H
14#define __ASM_ARCH_SPI_H __FILE__
15
16struct s3c2410_spi_info;
17struct spi_board_info;
18
19struct s3c2410_spi_info {
20 unsigned long pin_cs; /* simple gpio cs */
21
22 unsigned long board_size;
23 struct spi_board_info *board_info;
24
25 void (*set_cs)(struct s3c2410_spi_info *spi, int cs, int pol);
26};
27
28
29#endif /* __ASM_ARCH_SPI_H */
diff --git a/include/asm-arm/spinlock.h b/include/asm-arm/spinlock.h
index 43ad4e55878c..406ca97a8ab2 100644
--- a/include/asm-arm/spinlock.h
+++ b/include/asm-arm/spinlock.h
@@ -142,6 +142,9 @@ static inline void __raw_write_unlock(raw_rwlock_t *rw)
142 : "cc"); 142 : "cc");
143} 143}
144 144
145/* write_can_lock - would write_trylock() succeed? */
146#define __raw_write_can_lock(x) ((x)->lock == 0x80000000)
147
145/* 148/*
146 * Read locks are a bit more hairy: 149 * Read locks are a bit more hairy:
147 * - Exclusively load the lock value. 150 * - Exclusively load the lock value.
@@ -198,4 +201,7 @@ static inline void __raw_read_unlock(raw_rwlock_t *rw)
198 201
199#define __raw_read_trylock(lock) generic__raw_read_trylock(lock) 202#define __raw_read_trylock(lock) generic__raw_read_trylock(lock)
200 203
204/* read_can_lock - would read_trylock() succeed? */
205#define __raw_read_can_lock(x) ((x)->lock < 0x80000000)
206
201#endif /* __ASM_SPINLOCK_H */ 207#endif /* __ASM_SPINLOCK_H */
diff --git a/include/asm-arm/system.h b/include/asm-arm/system.h
index 95b3abf4851b..7c9568d30307 100644
--- a/include/asm-arm/system.h
+++ b/include/asm-arm/system.h
@@ -127,6 +127,12 @@ static inline int cpu_is_xsc3(void)
127} 127}
128#endif 128#endif
129 129
130#if !defined(CONFIG_CPU_XSCALE) && !defined(CONFIG_CPU_XSC3)
131#define cpu_is_xscale() 0
132#else
133#define cpu_is_xscale() 1
134#endif
135
130#define set_cr(x) \ 136#define set_cr(x) \
131 __asm__ __volatile__( \ 137 __asm__ __volatile__( \
132 "mcr p15, 0, %0, c1, c0, 0 @ set CR" \ 138 "mcr p15, 0, %0, c1, c0, 0 @ set CR" \
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index 358e4d309ceb..c2059a3a0621 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -159,17 +159,8 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres
159#define lazy_mmu_prot_update(pte) do { } while (0) 159#define lazy_mmu_prot_update(pte) do { } while (0)
160#endif 160#endif
161 161
162#ifndef __HAVE_ARCH_MULTIPLE_ZERO_PAGE 162#ifndef __HAVE_ARCH_MOVE_PTE
163#define move_pte(pte, prot, old_addr, new_addr) (pte) 163#define move_pte(pte, prot, old_addr, new_addr) (pte)
164#else
165#define move_pte(pte, prot, old_addr, new_addr) \
166({ \
167 pte_t newpte = (pte); \
168 if (pte_present(pte) && pfn_valid(pte_pfn(pte)) && \
169 pte_page(pte) == ZERO_PAGE(old_addr)) \
170 newpte = mk_pte(ZERO_PAGE(new_addr), (prot)); \
171 newpte; \
172})
173#endif 164#endif
174 165
175/* 166/*
diff --git a/include/asm-mips/cpu.h b/include/asm-mips/cpu.h
index 818b9a97e214..dff2a0a52f8f 100644
--- a/include/asm-mips/cpu.h
+++ b/include/asm-mips/cpu.h
@@ -51,6 +51,7 @@
51#define PRID_IMP_R4300 0x0b00 51#define PRID_IMP_R4300 0x0b00
52#define PRID_IMP_VR41XX 0x0c00 52#define PRID_IMP_VR41XX 0x0c00
53#define PRID_IMP_R12000 0x0e00 53#define PRID_IMP_R12000 0x0e00
54#define PRID_IMP_R14000 0x0f00
54#define PRID_IMP_R8000 0x1000 55#define PRID_IMP_R8000 0x1000
55#define PRID_IMP_PR4450 0x1200 56#define PRID_IMP_PR4450 0x1200
56#define PRID_IMP_R4600 0x2000 57#define PRID_IMP_R4600 0x2000
@@ -87,6 +88,7 @@
87#define PRID_IMP_24K 0x9300 88#define PRID_IMP_24K 0x9300
88#define PRID_IMP_34K 0x9500 89#define PRID_IMP_34K 0x9500
89#define PRID_IMP_24KE 0x9600 90#define PRID_IMP_24KE 0x9600
91#define PRID_IMP_74K 0x9700
90 92
91/* 93/*
92 * These are the PRID's for when 23:16 == PRID_COMP_SIBYTE 94 * These are the PRID's for when 23:16 == PRID_COMP_SIBYTE
@@ -196,7 +198,9 @@
196#define CPU_34K 60 198#define CPU_34K 60
197#define CPU_PR4450 61 199#define CPU_PR4450 61
198#define CPU_SB1A 62 200#define CPU_SB1A 62
199#define CPU_LAST 62 201#define CPU_74K 63
202#define CPU_R14000 64
203#define CPU_LAST 64
200 204
201/* 205/*
202 * ISA Level encodings 206 * ISA Level encodings
diff --git a/include/asm-mips/futex.h b/include/asm-mips/futex.h
index a554089991f2..12d118f1bc9c 100644
--- a/include/asm-mips/futex.h
+++ b/include/asm-mips/futex.h
@@ -7,6 +7,7 @@
7#include <linux/futex.h> 7#include <linux/futex.h>
8#include <asm/errno.h> 8#include <asm/errno.h>
9#include <asm/uaccess.h> 9#include <asm/uaccess.h>
10#include <asm/war.h>
10 11
11#ifdef CONFIG_SMP 12#ifdef CONFIG_SMP
12#define __FUTEX_SMP_SYNC " sync \n" 13#define __FUTEX_SMP_SYNC " sync \n"
@@ -16,30 +17,58 @@
16 17
17#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \ 18#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
18{ \ 19{ \
19 __asm__ __volatile__( \ 20 if (cpu_has_llsc && R10000_LLSC_WAR) { \
20 " .set push \n" \ 21 __asm__ __volatile__( \
21 " .set noat \n" \ 22 " .set push \n" \
22 " .set mips3 \n" \ 23 " .set noat \n" \
23 "1: ll %1, (%3) # __futex_atomic_op1 \n" \ 24 " .set mips3 \n" \
24 " .set mips0 \n" \ 25 "1: ll %1, (%3) # __futex_atomic_op \n" \
25 " " insn " \n" \ 26 " .set mips0 \n" \
26 " .set mips3 \n" \ 27 " " insn " \n" \
27 "2: sc $1, (%3) \n" \ 28 " .set mips3 \n" \
28 " beqzl $1, 1b \n" \ 29 "2: sc $1, (%3) \n" \
29 __FUTEX_SMP_SYNC \ 30 " beqzl $1, 1b \n" \
30 "3: \n" \ 31 __FUTEX_SMP_SYNC \
31 " .set pop \n" \ 32 "3: \n" \
32 " .set mips0 \n" \ 33 " .set pop \n" \
33 " .section .fixup,\"ax\" \n" \ 34 " .set mips0 \n" \
34 "4: li %0, %5 \n" \ 35 " .section .fixup,\"ax\" \n" \
35 " j 2b \n" \ 36 "4: li %0, %5 \n" \
36 " .previous \n" \ 37 " j 2b \n" \
37 " .section __ex_table,\"a\" \n" \ 38 " .previous \n" \
38 " "__UA_ADDR "\t1b, 4b \n" \ 39 " .section __ex_table,\"a\" \n" \
39 " "__UA_ADDR "\t2b, 4b \n" \ 40 " "__UA_ADDR "\t1b, 4b \n" \
40 " .previous \n" \ 41 " "__UA_ADDR "\t2b, 4b \n" \
41 : "=r" (ret), "=r" (oldval) \ 42 " .previous \n" \
42 : "0" (0), "r" (uaddr), "Jr" (oparg), "i" (-EFAULT)); \ 43 : "=r" (ret), "=r" (oldval) \
44 : "0" (0), "r" (uaddr), "Jr" (oparg), "i" (-EFAULT)); \
45 } else if (cpu_has_llsc) { \
46 __asm__ __volatile__( \
47 " .set push \n" \
48 " .set noat \n" \
49 " .set mips3 \n" \
50 "1: ll %1, (%3) # __futex_atomic_op \n" \
51 " .set mips0 \n" \
52 " " insn " \n" \
53 " .set mips3 \n" \
54 "2: sc $1, (%3) \n" \
55 " beqz $1, 1b \n" \
56 __FUTEX_SMP_SYNC \
57 "3: \n" \
58 " .set pop \n" \
59 " .set mips0 \n" \
60 " .section .fixup,\"ax\" \n" \
61 "4: li %0, %5 \n" \
62 " j 2b \n" \
63 " .previous \n" \
64 " .section __ex_table,\"a\" \n" \
65 " "__UA_ADDR "\t1b, 4b \n" \
66 " "__UA_ADDR "\t2b, 4b \n" \
67 " .previous \n" \
68 : "=r" (ret), "=r" (oldval) \
69 : "0" (0), "r" (uaddr), "Jr" (oparg), "i" (-EFAULT)); \
70 } else \
71 ret = -ENOSYS; \
43} 72}
44 73
45static inline int 74static inline int
@@ -102,7 +131,69 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
102static inline int 131static inline int
103futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) 132futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
104{ 133{
105 return -ENOSYS; 134 int retval;
135
136 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
137 return -EFAULT;
138
139 if (cpu_has_llsc && R10000_LLSC_WAR) {
140 __asm__ __volatile__(
141 "# futex_atomic_cmpxchg_inatomic \n"
142 " .set push \n"
143 " .set noat \n"
144 " .set mips3 \n"
145 "1: ll %0, %2 \n"
146 " bne %0, %z3, 3f \n"
147 " .set mips0 \n"
148 " move $1, %z4 \n"
149 " .set mips3 \n"
150 "2: sc $1, %1 \n"
151 " beqzl $1, 1b \n"
152 __FUTEX_SMP_SYNC
153 "3: \n"
154 " .set pop \n"
155 " .section .fixup,\"ax\" \n"
156 "4: li %0, %5 \n"
157 " j 3b \n"
158 " .previous \n"
159 " .section __ex_table,\"a\" \n"
160 " "__UA_ADDR "\t1b, 4b \n"
161 " "__UA_ADDR "\t2b, 4b \n"
162 " .previous \n"
163 : "=&r" (retval), "=R" (*uaddr)
164 : "R" (*uaddr), "Jr" (oldval), "Jr" (newval), "i" (-EFAULT)
165 : "memory");
166 } else if (cpu_has_llsc) {
167 __asm__ __volatile__(
168 "# futex_atomic_cmpxchg_inatomic \n"
169 " .set push \n"
170 " .set noat \n"
171 " .set mips3 \n"
172 "1: ll %0, %2 \n"
173 " bne %0, %z3, 3f \n"
174 " .set mips0 \n"
175 " move $1, %z4 \n"
176 " .set mips3 \n"
177 "2: sc $1, %1 \n"
178 " beqz $1, 1b \n"
179 __FUTEX_SMP_SYNC
180 "3: \n"
181 " .set pop \n"
182 " .section .fixup,\"ax\" \n"
183 "4: li %0, %5 \n"
184 " j 3b \n"
185 " .previous \n"
186 " .section __ex_table,\"a\" \n"
187 " "__UA_ADDR "\t1b, 4b \n"
188 " "__UA_ADDR "\t2b, 4b \n"
189 " .previous \n"
190 : "=&r" (retval), "=R" (*uaddr)
191 : "R" (*uaddr), "Jr" (oldval), "Jr" (newval), "i" (-EFAULT)
192 : "memory");
193 } else
194 return -ENOSYS;
195
196 return retval;
106} 197}
107 198
108#endif 199#endif
diff --git a/include/asm-mips/inst.h b/include/asm-mips/inst.h
index e0745f4ff624..1ed8d0f62577 100644
--- a/include/asm-mips/inst.h
+++ b/include/asm-mips/inst.h
@@ -6,6 +6,7 @@
6 * for more details. 6 * for more details.
7 * 7 *
8 * Copyright (C) 1996, 2000 by Ralf Baechle 8 * Copyright (C) 1996, 2000 by Ralf Baechle
9 * Copyright (C) 2006 by Thiemo Seufer
9 */ 10 */
10#ifndef _ASM_INST_H 11#ifndef _ASM_INST_H
11#define _ASM_INST_H 12#define _ASM_INST_H
@@ -21,14 +22,14 @@ enum major_op {
21 cop0_op, cop1_op, cop2_op, cop1x_op, 22 cop0_op, cop1_op, cop2_op, cop1x_op,
22 beql_op, bnel_op, blezl_op, bgtzl_op, 23 beql_op, bnel_op, blezl_op, bgtzl_op,
23 daddi_op, daddiu_op, ldl_op, ldr_op, 24 daddi_op, daddiu_op, ldl_op, ldr_op,
24 major_1c_op, jalx_op, major_1e_op, major_1f_op, 25 spec2_op, jalx_op, mdmx_op, spec3_op,
25 lb_op, lh_op, lwl_op, lw_op, 26 lb_op, lh_op, lwl_op, lw_op,
26 lbu_op, lhu_op, lwr_op, lwu_op, 27 lbu_op, lhu_op, lwr_op, lwu_op,
27 sb_op, sh_op, swl_op, sw_op, 28 sb_op, sh_op, swl_op, sw_op,
28 sdl_op, sdr_op, swr_op, cache_op, 29 sdl_op, sdr_op, swr_op, cache_op,
29 ll_op, lwc1_op, lwc2_op, pref_op, 30 ll_op, lwc1_op, lwc2_op, pref_op,
30 lld_op, ldc1_op, ldc2_op, ld_op, 31 lld_op, ldc1_op, ldc2_op, ld_op,
31 sc_op, swc1_op, swc2_op, rdhwr_op, 32 sc_op, swc1_op, swc2_op, major_3b_op,
32 scd_op, sdc1_op, sdc2_op, sd_op 33 scd_op, sdc1_op, sdc2_op, sd_op
33}; 34};
34 35
@@ -37,7 +38,7 @@ enum major_op {
37 */ 38 */
38enum spec_op { 39enum spec_op {
39 sll_op, movc_op, srl_op, sra_op, 40 sll_op, movc_op, srl_op, sra_op,
40 sllv_op, srlv_op, srav_op, spec1_unused_op, /* Opcode 0x07 is unused */ 41 sllv_op, pmon_op, srlv_op, srav_op,
41 jr_op, jalr_op, movz_op, movn_op, 42 jr_op, jalr_op, movz_op, movn_op,
42 syscall_op, break_op, spim_op, sync_op, 43 syscall_op, break_op, spim_op, sync_op,
43 mfhi_op, mthi_op, mflo_op, mtlo_op, 44 mfhi_op, mthi_op, mflo_op, mtlo_op,
@@ -55,6 +56,28 @@ enum spec_op {
55}; 56};
56 57
57/* 58/*
59 * func field of spec2 opcode.
60 */
61enum spec2_op {
62 madd_op, maddu_op, mul_op, spec2_3_unused_op,
63 msub_op, msubu_op, /* more unused ops */
64 clz_op = 0x20, clo_op,
65 dclz_op = 0x24, dclo_op,
66 sdbpp_op = 0x3f
67};
68
69/*
70 * func field of spec3 opcode.
71 */
72enum spec3_op {
73 ext_op, dextm_op, dextu_op, dext_op,
74 ins_op, dinsm_op, dinsu_op, dins_op,
75 bshfl_op = 0x20,
76 dbshfl_op = 0x24,
77 rdhwr_op = 0x3f
78};
79
80/*
58 * rt field of bcond opcodes. 81 * rt field of bcond opcodes.
59 */ 82 */
60enum rt_op { 83enum rt_op {
@@ -151,8 +174,8 @@ enum cop1x_func {
151 * func field for mad opcodes (MIPS IV). 174 * func field for mad opcodes (MIPS IV).
152 */ 175 */
153enum mad_func { 176enum mad_func {
154 madd_op = 0x08, msub_op = 0x0a, 177 madd_fp_op = 0x08, msub_fp_op = 0x0a,
155 nmadd_op = 0x0c, nmsub_op = 0x0e 178 nmadd_fp_op = 0x0c, nmsub_fp_op = 0x0e
156}; 179};
157 180
158/* 181/*
diff --git a/include/asm-mips/mipsregs.h b/include/asm-mips/mipsregs.h
index a2ef579f6b1a..5af7517fce8a 100644
--- a/include/asm-mips/mipsregs.h
+++ b/include/asm-mips/mipsregs.h
@@ -291,7 +291,7 @@
291#define ST0_DL (_ULCAST_(1) << 24) 291#define ST0_DL (_ULCAST_(1) << 24)
292 292
293/* 293/*
294 * Enable the MIPS DSP ASE 294 * Enable the MIPS MDMX and DSP ASEs
295 */ 295 */
296#define ST0_MX 0x01000000 296#define ST0_MX 0x01000000
297 297
diff --git a/include/asm-mips/pgtable.h b/include/asm-mips/pgtable.h
index 702a28fa7a34..f80fe75c7800 100644
--- a/include/asm-mips/pgtable.h
+++ b/include/asm-mips/pgtable.h
@@ -70,7 +70,15 @@ extern unsigned long zero_page_mask;
70#define ZERO_PAGE(vaddr) \ 70#define ZERO_PAGE(vaddr) \
71 (virt_to_page(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask))) 71 (virt_to_page(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask)))
72 72
73#define __HAVE_ARCH_MULTIPLE_ZERO_PAGE 73#define __HAVE_ARCH_MOVE_PTE
74#define move_pte(pte, prot, old_addr, new_addr) \
75({ \
76 pte_t newpte = (pte); \
77 if (pte_present(pte) && pfn_valid(pte_pfn(pte)) && \
78 pte_page(pte) == ZERO_PAGE(old_addr)) \
79 newpte = mk_pte(ZERO_PAGE(new_addr), (prot)); \
80 newpte; \
81})
74 82
75extern void paging_init(void); 83extern void paging_init(void);
76 84
@@ -82,10 +90,11 @@ extern void paging_init(void);
82#define pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT)) 90#define pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
83#define pmd_page_kernel(pmd) pmd_val(pmd) 91#define pmd_page_kernel(pmd) pmd_val(pmd)
84 92
85#define pte_none(pte) (!(pte_val(pte) & ~_PAGE_GLOBAL))
86#define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT)
87
88#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32_R1) 93#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32_R1)
94
95#define pte_none(pte) (!(((pte).pte_low | (pte).pte_high) & ~_PAGE_GLOBAL))
96#define pte_present(pte) ((pte).pte_low & _PAGE_PRESENT)
97
89static inline void set_pte(pte_t *ptep, pte_t pte) 98static inline void set_pte(pte_t *ptep, pte_t pte)
90{ 99{
91 ptep->pte_high = pte.pte_high; 100 ptep->pte_high = pte.pte_high;
@@ -93,27 +102,35 @@ static inline void set_pte(pte_t *ptep, pte_t pte)
93 ptep->pte_low = pte.pte_low; 102 ptep->pte_low = pte.pte_low;
94 //printk("pte_high %x pte_low %x\n", ptep->pte_high, ptep->pte_low); 103 //printk("pte_high %x pte_low %x\n", ptep->pte_high, ptep->pte_low);
95 104
96 if (pte_val(pte) & _PAGE_GLOBAL) { 105 if (pte.pte_low & _PAGE_GLOBAL) {
97 pte_t *buddy = ptep_buddy(ptep); 106 pte_t *buddy = ptep_buddy(ptep);
98 /* 107 /*
99 * Make sure the buddy is global too (if it's !none, 108 * Make sure the buddy is global too (if it's !none,
100 * it better already be global) 109 * it better already be global)
101 */ 110 */
102 if (pte_none(*buddy)) 111 if (pte_none(*buddy)) {
103 buddy->pte_low |= _PAGE_GLOBAL; 112 buddy->pte_low |= _PAGE_GLOBAL;
113 buddy->pte_high |= _PAGE_GLOBAL;
114 }
104 } 115 }
105} 116}
106#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) 117#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
107 118
108static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) 119static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
109{ 120{
121 pte_t null = __pte(0);
122
110 /* Preserve global status for the pair */ 123 /* Preserve global status for the pair */
111 if (pte_val(*ptep_buddy(ptep)) & _PAGE_GLOBAL) 124 if (ptep_buddy(ptep)->pte_low & _PAGE_GLOBAL)
112 set_pte_at(mm, addr, ptep, __pte(_PAGE_GLOBAL)); 125 null.pte_low = null.pte_high = _PAGE_GLOBAL;
113 else 126
114 set_pte_at(mm, addr, ptep, __pte(0)); 127 set_pte_at(mm, addr, ptep, null);
115} 128}
116#else 129#else
130
131#define pte_none(pte) (!(pte_val(pte) & ~_PAGE_GLOBAL))
132#define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT)
133
117/* 134/*
118 * Certain architectures need to do special things when pte's 135 * Certain architectures need to do special things when pte's
119 * within a page table are directly modified. Thus, the following 136 * within a page table are directly modified. Thus, the following
@@ -174,75 +191,76 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
174 */ 191 */
175static inline int pte_user(pte_t pte) { BUG(); return 0; } 192static inline int pte_user(pte_t pte) { BUG(); return 0; }
176#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32_R1) 193#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32_R1)
177static inline int pte_read(pte_t pte) { return (pte).pte_low & _PAGE_READ; } 194static inline int pte_read(pte_t pte) { return pte.pte_low & _PAGE_READ; }
178static inline int pte_write(pte_t pte) { return (pte).pte_low & _PAGE_WRITE; } 195static inline int pte_write(pte_t pte) { return pte.pte_low & _PAGE_WRITE; }
179static inline int pte_dirty(pte_t pte) { return (pte).pte_low & _PAGE_MODIFIED; } 196static inline int pte_dirty(pte_t pte) { return pte.pte_low & _PAGE_MODIFIED; }
180static inline int pte_young(pte_t pte) { return (pte).pte_low & _PAGE_ACCESSED; } 197static inline int pte_young(pte_t pte) { return pte.pte_low & _PAGE_ACCESSED; }
181static inline int pte_file(pte_t pte) { return (pte).pte_low & _PAGE_FILE; } 198static inline int pte_file(pte_t pte) { return pte.pte_low & _PAGE_FILE; }
199
182static inline pte_t pte_wrprotect(pte_t pte) 200static inline pte_t pte_wrprotect(pte_t pte)
183{ 201{
184 (pte).pte_low &= ~(_PAGE_WRITE | _PAGE_SILENT_WRITE); 202 pte.pte_low &= ~(_PAGE_WRITE | _PAGE_SILENT_WRITE);
185 (pte).pte_high &= ~_PAGE_SILENT_WRITE; 203 pte.pte_high &= ~_PAGE_SILENT_WRITE;
186 return pte; 204 return pte;
187} 205}
188 206
189static inline pte_t pte_rdprotect(pte_t pte) 207static inline pte_t pte_rdprotect(pte_t pte)
190{ 208{
191 (pte).pte_low &= ~(_PAGE_READ | _PAGE_SILENT_READ); 209 pte.pte_low &= ~(_PAGE_READ | _PAGE_SILENT_READ);
192 (pte).pte_high &= ~_PAGE_SILENT_READ; 210 pte.pte_high &= ~_PAGE_SILENT_READ;
193 return pte; 211 return pte;
194} 212}
195 213
196static inline pte_t pte_mkclean(pte_t pte) 214static inline pte_t pte_mkclean(pte_t pte)
197{ 215{
198 (pte).pte_low &= ~(_PAGE_MODIFIED|_PAGE_SILENT_WRITE); 216 pte.pte_low &= ~(_PAGE_MODIFIED | _PAGE_SILENT_WRITE);
199 (pte).pte_high &= ~_PAGE_SILENT_WRITE; 217 pte.pte_high &= ~_PAGE_SILENT_WRITE;
200 return pte; 218 return pte;
201} 219}
202 220
203static inline pte_t pte_mkold(pte_t pte) 221static inline pte_t pte_mkold(pte_t pte)
204{ 222{
205 (pte).pte_low &= ~(_PAGE_ACCESSED|_PAGE_SILENT_READ); 223 pte.pte_low &= ~(_PAGE_ACCESSED | _PAGE_SILENT_READ);
206 (pte).pte_high &= ~_PAGE_SILENT_READ; 224 pte.pte_high &= ~_PAGE_SILENT_READ;
207 return pte; 225 return pte;
208} 226}
209 227
210static inline pte_t pte_mkwrite(pte_t pte) 228static inline pte_t pte_mkwrite(pte_t pte)
211{ 229{
212 (pte).pte_low |= _PAGE_WRITE; 230 pte.pte_low |= _PAGE_WRITE;
213 if ((pte).pte_low & _PAGE_MODIFIED) { 231 if (pte.pte_low & _PAGE_MODIFIED) {
214 (pte).pte_low |= _PAGE_SILENT_WRITE; 232 pte.pte_low |= _PAGE_SILENT_WRITE;
215 (pte).pte_high |= _PAGE_SILENT_WRITE; 233 pte.pte_high |= _PAGE_SILENT_WRITE;
216 } 234 }
217 return pte; 235 return pte;
218} 236}
219 237
220static inline pte_t pte_mkread(pte_t pte) 238static inline pte_t pte_mkread(pte_t pte)
221{ 239{
222 (pte).pte_low |= _PAGE_READ; 240 pte.pte_low |= _PAGE_READ;
223 if ((pte).pte_low & _PAGE_ACCESSED) { 241 if (pte.pte_low & _PAGE_ACCESSED) {
224 (pte).pte_low |= _PAGE_SILENT_READ; 242 pte.pte_low |= _PAGE_SILENT_READ;
225 (pte).pte_high |= _PAGE_SILENT_READ; 243 pte.pte_high |= _PAGE_SILENT_READ;
226 } 244 }
227 return pte; 245 return pte;
228} 246}
229 247
230static inline pte_t pte_mkdirty(pte_t pte) 248static inline pte_t pte_mkdirty(pte_t pte)
231{ 249{
232 (pte).pte_low |= _PAGE_MODIFIED; 250 pte.pte_low |= _PAGE_MODIFIED;
233 if ((pte).pte_low & _PAGE_WRITE) { 251 if (pte.pte_low & _PAGE_WRITE) {
234 (pte).pte_low |= _PAGE_SILENT_WRITE; 252 pte.pte_low |= _PAGE_SILENT_WRITE;
235 (pte).pte_high |= _PAGE_SILENT_WRITE; 253 pte.pte_high |= _PAGE_SILENT_WRITE;
236 } 254 }
237 return pte; 255 return pte;
238} 256}
239 257
240static inline pte_t pte_mkyoung(pte_t pte) 258static inline pte_t pte_mkyoung(pte_t pte)
241{ 259{
242 (pte).pte_low |= _PAGE_ACCESSED; 260 pte.pte_low |= _PAGE_ACCESSED;
243 if ((pte).pte_low & _PAGE_READ) 261 if (pte.pte_low & _PAGE_READ)
244 (pte).pte_low |= _PAGE_SILENT_READ; 262 pte.pte_low |= _PAGE_SILENT_READ;
245 (pte).pte_high |= _PAGE_SILENT_READ; 263 pte.pte_high |= _PAGE_SILENT_READ;
246 return pte; 264 return pte;
247} 265}
248#else 266#else
diff --git a/include/asm-mips/sigcontext.h b/include/asm-mips/sigcontext.h
index 8edabb0be23f..cefa657dd04a 100644
--- a/include/asm-mips/sigcontext.h
+++ b/include/asm-mips/sigcontext.h
@@ -55,8 +55,14 @@ struct sigcontext {
55struct sigcontext { 55struct sigcontext {
56 unsigned long sc_regs[32]; 56 unsigned long sc_regs[32];
57 unsigned long sc_fpregs[32]; 57 unsigned long sc_fpregs[32];
58 unsigned long sc_hi[4]; 58 unsigned long sc_mdhi;
59 unsigned long sc_lo[4]; 59 unsigned long sc_hi1;
60 unsigned long sc_hi2;
61 unsigned long sc_hi3;
62 unsigned long sc_mdlo;
63 unsigned long sc_lo1;
64 unsigned long sc_lo2;
65 unsigned long sc_lo3;
60 unsigned long sc_pc; 66 unsigned long sc_pc;
61 unsigned int sc_fpc_csr; 67 unsigned int sc_fpc_csr;
62 unsigned int sc_used_math; 68 unsigned int sc_used_math;
diff --git a/include/asm-powerpc/termbits.h b/include/asm-powerpc/termbits.h
index ebf6055481dc..6d533b07aaf5 100644
--- a/include/asm-powerpc/termbits.h
+++ b/include/asm-powerpc/termbits.h
@@ -153,6 +153,7 @@ struct termios {
153#define HUPCL 00040000 153#define HUPCL 00040000
154 154
155#define CLOCAL 00100000 155#define CLOCAL 00100000
156#define CMSPAR 010000000000 /* mark or space (stick) parity */
156#define CRTSCTS 020000000000 /* flow control */ 157#define CRTSCTS 020000000000 /* flow control */
157 158
158/* c_lflag bits */ 159/* c_lflag bits */
diff --git a/include/asm-powerpc/unistd.h b/include/asm-powerpc/unistd.h
index 908acb44cb8a..edde2462bf52 100644
--- a/include/asm-powerpc/unistd.h
+++ b/include/asm-powerpc/unistd.h
@@ -321,8 +321,10 @@
321#define __NR_readlinkat 296 321#define __NR_readlinkat 296
322#define __NR_fchmodat 297 322#define __NR_fchmodat 297
323#define __NR_faccessat 298 323#define __NR_faccessat 298
324#define __NR_get_robust_list 299
325#define __NR_set_robust_list 300
324 326
325#define __NR_syscalls 299 327#define __NR_syscalls 301
326 328
327#ifdef __KERNEL__ 329#ifdef __KERNEL__
328#define __NR__exit __NR_exit 330#define __NR__exit __NR_exit
diff --git a/include/asm-sparc/unistd.h b/include/asm-sparc/unistd.h
index f5611a721fbd..45a576507785 100644
--- a/include/asm-sparc/unistd.h
+++ b/include/asm-sparc/unistd.h
@@ -316,11 +316,13 @@
316#define __NR_pselect6 297 316#define __NR_pselect6 297
317#define __NR_ppoll 298 317#define __NR_ppoll 298
318#define __NR_unshare 299 318#define __NR_unshare 299
319#define __NR_set_robust_list 300
320#define __NR_get_robust_list 301
319 321
320/* WARNING: You MAY NOT add syscall numbers larger than 299, since 322/* WARNING: You MAY NOT add syscall numbers larger than 301, since
321 * all of the syscall tables in the Sparc kernel are 323 * all of the syscall tables in the Sparc kernel are
322 * sized to have 299 entries (starting at zero). Therefore 324 * sized to have 301 entries (starting at zero). Therefore
323 * find a free slot in the 0-299 range. 325 * find a free slot in the 0-301 range.
324 */ 326 */
325 327
326#define _syscall0(type,name) \ 328#define _syscall0(type,name) \
diff --git a/include/asm-sparc64/dma-mapping.h b/include/asm-sparc64/dma-mapping.h
index c7d5804ba76d..a8d39f23d43b 100644
--- a/include/asm-sparc64/dma-mapping.h
+++ b/include/asm-sparc64/dma-mapping.h
@@ -4,7 +4,146 @@
4#include <linux/config.h> 4#include <linux/config.h>
5 5
6#ifdef CONFIG_PCI 6#ifdef CONFIG_PCI
7#include <asm-generic/dma-mapping.h> 7
8/* we implement the API below in terms of the existing PCI one,
9 * so include it */
10#include <linux/pci.h>
11/* need struct page definitions */
12#include <linux/mm.h>
13
14static inline int
15dma_supported(struct device *dev, u64 mask)
16{
17 BUG_ON(dev->bus != &pci_bus_type);
18
19 return pci_dma_supported(to_pci_dev(dev), mask);
20}
21
22static inline int
23dma_set_mask(struct device *dev, u64 dma_mask)
24{
25 BUG_ON(dev->bus != &pci_bus_type);
26
27 return pci_set_dma_mask(to_pci_dev(dev), dma_mask);
28}
29
30static inline void *
31dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
32 gfp_t flag)
33{
34 BUG_ON(dev->bus != &pci_bus_type);
35
36 return pci_iommu_ops->alloc_consistent(to_pci_dev(dev), size, dma_handle, flag);
37}
38
39static inline void
40dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
41 dma_addr_t dma_handle)
42{
43 BUG_ON(dev->bus != &pci_bus_type);
44
45 pci_free_consistent(to_pci_dev(dev), size, cpu_addr, dma_handle);
46}
47
48static inline dma_addr_t
49dma_map_single(struct device *dev, void *cpu_addr, size_t size,
50 enum dma_data_direction direction)
51{
52 BUG_ON(dev->bus != &pci_bus_type);
53
54 return pci_map_single(to_pci_dev(dev), cpu_addr, size, (int)direction);
55}
56
57static inline void
58dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
59 enum dma_data_direction direction)
60{
61 BUG_ON(dev->bus != &pci_bus_type);
62
63 pci_unmap_single(to_pci_dev(dev), dma_addr, size, (int)direction);
64}
65
66static inline dma_addr_t
67dma_map_page(struct device *dev, struct page *page,
68 unsigned long offset, size_t size,
69 enum dma_data_direction direction)
70{
71 BUG_ON(dev->bus != &pci_bus_type);
72
73 return pci_map_page(to_pci_dev(dev), page, offset, size, (int)direction);
74}
75
76static inline void
77dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
78 enum dma_data_direction direction)
79{
80 BUG_ON(dev->bus != &pci_bus_type);
81
82 pci_unmap_page(to_pci_dev(dev), dma_address, size, (int)direction);
83}
84
85static inline int
86dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
87 enum dma_data_direction direction)
88{
89 BUG_ON(dev->bus != &pci_bus_type);
90
91 return pci_map_sg(to_pci_dev(dev), sg, nents, (int)direction);
92}
93
94static inline void
95dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
96 enum dma_data_direction direction)
97{
98 BUG_ON(dev->bus != &pci_bus_type);
99
100 pci_unmap_sg(to_pci_dev(dev), sg, nhwentries, (int)direction);
101}
102
103static inline void
104dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
105 enum dma_data_direction direction)
106{
107 BUG_ON(dev->bus != &pci_bus_type);
108
109 pci_dma_sync_single_for_cpu(to_pci_dev(dev), dma_handle,
110 size, (int)direction);
111}
112
113static inline void
114dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
115 enum dma_data_direction direction)
116{
117 BUG_ON(dev->bus != &pci_bus_type);
118
119 pci_dma_sync_single_for_device(to_pci_dev(dev), dma_handle,
120 size, (int)direction);
121}
122
123static inline void
124dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
125 enum dma_data_direction direction)
126{
127 BUG_ON(dev->bus != &pci_bus_type);
128
129 pci_dma_sync_sg_for_cpu(to_pci_dev(dev), sg, nelems, (int)direction);
130}
131
132static inline void
133dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
134 enum dma_data_direction direction)
135{
136 BUG_ON(dev->bus != &pci_bus_type);
137
138 pci_dma_sync_sg_for_device(to_pci_dev(dev), sg, nelems, (int)direction);
139}
140
141static inline int
142dma_mapping_error(dma_addr_t dma_addr)
143{
144 return pci_dma_mapping_error(dma_addr);
145}
146
8#else 147#else
9 148
10struct device; 149struct device;
diff --git a/include/asm-sparc64/pci.h b/include/asm-sparc64/pci.h
index 7c5a589ea437..e1ea67bc32f2 100644
--- a/include/asm-sparc64/pci.h
+++ b/include/asm-sparc64/pci.h
@@ -42,7 +42,7 @@ static inline void pcibios_penalize_isa_irq(int irq, int active)
42struct pci_dev; 42struct pci_dev;
43 43
44struct pci_iommu_ops { 44struct pci_iommu_ops {
45 void *(*alloc_consistent)(struct pci_dev *, size_t, dma_addr_t *); 45 void *(*alloc_consistent)(struct pci_dev *, size_t, dma_addr_t *, gfp_t);
46 void (*free_consistent)(struct pci_dev *, size_t, void *, dma_addr_t); 46 void (*free_consistent)(struct pci_dev *, size_t, void *, dma_addr_t);
47 dma_addr_t (*map_single)(struct pci_dev *, void *, size_t, int); 47 dma_addr_t (*map_single)(struct pci_dev *, void *, size_t, int);
48 void (*unmap_single)(struct pci_dev *, dma_addr_t, size_t, int); 48 void (*unmap_single)(struct pci_dev *, dma_addr_t, size_t, int);
@@ -59,7 +59,7 @@ extern struct pci_iommu_ops *pci_iommu_ops;
59 */ 59 */
60static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *dma_handle) 60static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *dma_handle)
61{ 61{
62 return pci_iommu_ops->alloc_consistent(hwdev, size, dma_handle); 62 return pci_iommu_ops->alloc_consistent(hwdev, size, dma_handle, GFP_ATOMIC);
63} 63}
64 64
65/* Free and unmap a consistent DMA buffer. 65/* Free and unmap a consistent DMA buffer.
diff --git a/include/asm-sparc64/pgtable.h b/include/asm-sparc64/pgtable.h
index c44e7466534e..cd464f469a2c 100644
--- a/include/asm-sparc64/pgtable.h
+++ b/include/asm-sparc64/pgtable.h
@@ -689,6 +689,23 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *p
689#define pte_clear(mm,addr,ptep) \ 689#define pte_clear(mm,addr,ptep) \
690 set_pte_at((mm), (addr), (ptep), __pte(0UL)) 690 set_pte_at((mm), (addr), (ptep), __pte(0UL))
691 691
692#ifdef DCACHE_ALIASING_POSSIBLE
693#define __HAVE_ARCH_MOVE_PTE
694#define move_pte(pte, prot, old_addr, new_addr) \
695({ \
696 pte_t newpte = (pte); \
697 if (tlb_type != hypervisor && pte_present(pte)) { \
698 unsigned long this_pfn = pte_pfn(pte); \
699 \
700 if (pfn_valid(this_pfn) && \
701 (((old_addr) ^ (new_addr)) & (1 << 13))) \
702 flush_dcache_page_all(current->mm, \
703 pfn_to_page(this_pfn)); \
704 } \
705 newpte; \
706})
707#endif
708
692extern pgd_t swapper_pg_dir[2048]; 709extern pgd_t swapper_pg_dir[2048];
693extern pmd_t swapper_low_pmd_dir[2048]; 710extern pmd_t swapper_low_pmd_dir[2048];
694 711
diff --git a/include/asm-sparc64/unistd.h b/include/asm-sparc64/unistd.h
index 68705748bec0..998ef4ab0e06 100644
--- a/include/asm-sparc64/unistd.h
+++ b/include/asm-sparc64/unistd.h
@@ -318,11 +318,13 @@
318#define __NR_pselect6 297 318#define __NR_pselect6 297
319#define __NR_ppoll 298 319#define __NR_ppoll 298
320#define __NR_unshare 299 320#define __NR_unshare 299
321#define __NR_set_robust_list 300
322#define __NR_get_robust_list 301
321 323
322/* WARNING: You MAY NOT add syscall numbers larger than 299, since 324/* WARNING: You MAY NOT add syscall numbers larger than 301, since
323 * all of the syscall tables in the Sparc kernel are 325 * all of the syscall tables in the Sparc kernel are
324 * sized to have 299 entries (starting at zero). Therefore 326 * sized to have 301 entries (starting at zero). Therefore
325 * find a free slot in the 0-299 range. 327 * find a free slot in the 0-301 range.
326 */ 328 */
327 329
328#define _syscall0(type,name) \ 330#define _syscall0(type,name) \
diff --git a/include/asm-x86_64/elf.h b/include/asm-x86_64/elf.h
index c98633af07d2..b4f8f4a41a6e 100644
--- a/include/asm-x86_64/elf.h
+++ b/include/asm-x86_64/elf.h
@@ -159,7 +159,7 @@ extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *);
159#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs) 159#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
160 160
161/* 1GB for 64bit, 8MB for 32bit */ 161/* 1GB for 64bit, 8MB for 32bit */
162#define STACK_RND_MASK (is_compat_task() ? 0x7ff : 0x3fffff) 162#define STACK_RND_MASK (test_thread_flag(TIF_IA32) ? 0x7ff : 0x3fffff)
163 163
164#endif 164#endif
165 165
diff --git a/include/linux/firmware.h b/include/linux/firmware.h
index 2d716080be4a..33d8f2087b6e 100644
--- a/include/linux/firmware.h
+++ b/include/linux/firmware.h
@@ -19,5 +19,4 @@ int request_firmware_nowait(
19 void (*cont)(const struct firmware *fw, void *context)); 19 void (*cont)(const struct firmware *fw, void *context));
20 20
21void release_firmware(const struct firmware *fw); 21void release_firmware(const struct firmware *fw);
22void register_firmware(const char *name, const u8 *data, size_t size);
23#endif 22#endif
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 3de2bfb2410f..f813bc8266aa 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -213,6 +213,10 @@ extern int dir_notify_enable;
213#define FIBMAP _IO(0x00,1) /* bmap access */ 213#define FIBMAP _IO(0x00,1) /* bmap access */
214#define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */ 214#define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
215 215
216#define SYNC_FILE_RANGE_WAIT_BEFORE 1
217#define SYNC_FILE_RANGE_WRITE 2
218#define SYNC_FILE_RANGE_WAIT_AFTER 4
219
216#ifdef __KERNEL__ 220#ifdef __KERNEL__
217 221
218#include <linux/linkage.h> 222#include <linux/linkage.h>
@@ -758,9 +762,6 @@ extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
758extern int fcntl_getlease(struct file *filp); 762extern int fcntl_getlease(struct file *filp);
759 763
760/* fs/sync.c */ 764/* fs/sync.c */
761#define SYNC_FILE_RANGE_WAIT_BEFORE 1
762#define SYNC_FILE_RANGE_WRITE 2
763#define SYNC_FILE_RANGE_WAIT_AFTER 4
764extern int do_sync_file_range(struct file *file, loff_t offset, loff_t endbyte, 765extern int do_sync_file_range(struct file *file, loff_t offset, loff_t endbyte,
765 unsigned int flags); 766 unsigned int flags);
766 767
diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index a3a0e078f79d..16fbe59edeb1 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -110,5 +110,16 @@ struct fsl_usb2_platform_data {
110#define FSL_USB2_PORT0_ENABLED 0x00000001 110#define FSL_USB2_PORT0_ENABLED 0x00000001
111#define FSL_USB2_PORT1_ENABLED 0x00000002 111#define FSL_USB2_PORT1_ENABLED 0x00000002
112 112
113struct fsl_spi_platform_data {
114 u32 initial_spmode; /* initial SPMODE value */
115 u16 bus_num;
116
117 /* board specific information */
118 u16 max_chipselect;
119 void (*activate_cs)(u8 cs, u8 polarity);
120 void (*deactivate_cs)(u8 cs, u8 polarity);
121 u32 sysclk;
122};
123
113#endif /* _FSL_DEVICE_H_ */ 124#endif /* _FSL_DEVICE_H_ */
114#endif /* __KERNEL__ */ 125#endif /* __KERNEL__ */
diff --git a/include/linux/input.h b/include/linux/input.h
index 50e338d2ffda..ce1a756c4c30 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -345,6 +345,8 @@ struct input_absinfo {
345#define KEY_SAVE 234 345#define KEY_SAVE 234
346#define KEY_DOCUMENTS 235 346#define KEY_DOCUMENTS 235
347 347
348#define KEY_BATTERY 236
349
348#define KEY_UNKNOWN 240 350#define KEY_UNKNOWN 240
349 351
350#define BTN_MISC 0x100 352#define BTN_MISC 0x100
@@ -577,14 +579,9 @@ struct input_absinfo {
577 * Switch events 579 * Switch events
578 */ 580 */
579 581
580#define SW_0 0x00 582#define SW_LID 0x00 /* set = lid shut */
581#define SW_1 0x01 583#define SW_TABLET_MODE 0x01 /* set = tablet mode */
582#define SW_2 0x02 584#define SW_HEADPHONE_INSERT 0x02 /* set = inserted */
583#define SW_3 0x03
584#define SW_4 0x04
585#define SW_5 0x05
586#define SW_6 0x06
587#define SW_7 0x07
588#define SW_MAX 0x0f 585#define SW_MAX 0x0f
589 586
590/* 587/*
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index bdc556d88498..03a14a30c46a 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -69,6 +69,7 @@ struct mmc_data {
69 unsigned int timeout_ns; /* data timeout (in ns, max 80ms) */ 69 unsigned int timeout_ns; /* data timeout (in ns, max 80ms) */
70 unsigned int timeout_clks; /* data timeout (in clocks) */ 70 unsigned int timeout_clks; /* data timeout (in clocks) */
71 unsigned int blksz_bits; /* data block size */ 71 unsigned int blksz_bits; /* data block size */
72 unsigned int blksz; /* data block size */
72 unsigned int blocks; /* number of blocks */ 73 unsigned int blocks; /* number of blocks */
73 unsigned int error; /* data error */ 74 unsigned int error; /* data error */
74 unsigned int flags; 75 unsigned int flags;
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index b5c21122c299..36740354d4db 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -22,6 +22,7 @@
22#else 22#else
23#define MAX_ORDER CONFIG_FORCE_MAX_ZONEORDER 23#define MAX_ORDER CONFIG_FORCE_MAX_ZONEORDER
24#endif 24#endif
25#define MAX_ORDER_NR_PAGES (1 << (MAX_ORDER - 1))
25 26
26struct free_area { 27struct free_area {
27 struct list_head free_list; 28 struct list_head free_list;
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index d6fe048376ab..590dc6dca315 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1231,6 +1231,7 @@
1231#define PCI_DEVICE_ID_VIA_8380_0 0x0204 1231#define PCI_DEVICE_ID_VIA_8380_0 0x0204
1232#define PCI_DEVICE_ID_VIA_3238_0 0x0238 1232#define PCI_DEVICE_ID_VIA_3238_0 0x0238
1233#define PCI_DEVICE_ID_VIA_PT880 0x0258 1233#define PCI_DEVICE_ID_VIA_PT880 0x0258
1234#define PCI_DEVICE_ID_VIA_PT880ULTRA 0x0308
1234#define PCI_DEVICE_ID_VIA_PX8X0_0 0x0259 1235#define PCI_DEVICE_ID_VIA_PX8X0_0 0x0259
1235#define PCI_DEVICE_ID_VIA_3269_0 0x0269 1236#define PCI_DEVICE_ID_VIA_3269_0 0x0269
1236#define PCI_DEVICE_ID_VIA_K8T800PRO_0 0x0282 1237#define PCI_DEVICE_ID_VIA_K8T800PRO_0 0x0282
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 3996960fc565..60d49e5456e7 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -52,6 +52,7 @@ struct utimbuf;
52struct mq_attr; 52struct mq_attr;
53struct compat_stat; 53struct compat_stat;
54struct compat_timeval; 54struct compat_timeval;
55struct robust_list_head;
55 56
56#include <linux/config.h> 57#include <linux/config.h>
57#include <linux/types.h> 58#include <linux/types.h>
@@ -581,5 +582,10 @@ asmlinkage long sys_tee(int fdin, int fdout, size_t len, unsigned int flags);
581 582
582asmlinkage long sys_sync_file_range(int fd, loff_t offset, loff_t nbytes, 583asmlinkage long sys_sync_file_range(int fd, loff_t offset, loff_t nbytes,
583 unsigned int flags); 584 unsigned int flags);
585asmlinkage long sys_get_robust_list(int pid,
586 struct robust_list_head __user **head_ptr,
587 size_t __user *len_ptr);
588asmlinkage long sys_set_robust_list(struct robust_list_head __user *head,
589 size_t len);
584 590
585#endif 591#endif
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index d7670ec1ec1e..ad7fa9c86c10 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1141,8 +1141,13 @@ extern char *v4l2_type_names[];
1141/* Compatibility layer interface -- v4l1-compat module */ 1141/* Compatibility layer interface -- v4l1-compat module */
1142typedef int (*v4l2_kioctl)(struct inode *inode, struct file *file, 1142typedef int (*v4l2_kioctl)(struct inode *inode, struct file *file,
1143 unsigned int cmd, void *arg); 1143 unsigned int cmd, void *arg);
1144
1145#ifdef CONFIG_VIDEO_V4L1_COMPAT
1144int v4l_compat_translate_ioctl(struct inode *inode, struct file *file, 1146int v4l_compat_translate_ioctl(struct inode *inode, struct file *file,
1145 int cmd, void *arg, v4l2_kioctl driver_ioctl); 1147 int cmd, void *arg, v4l2_kioctl driver_ioctl);
1148#else
1149#define v4l_compat_translate_ioctl(inode,file,cmd,arg,ioctl) -EINVAL
1150#endif
1146 1151
1147/* 32 Bits compatibility layer for 64 bits processors */ 1152/* 32 Bits compatibility layer for 64 bits processors */
1148extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd, 1153extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd,
diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h
index 530ae3f4248c..fab5aed8ca31 100644
--- a/include/linux/vt_kern.h
+++ b/include/linux/vt_kern.h
@@ -73,11 +73,6 @@ int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc);
73int vt_waitactive(int vt); 73int vt_waitactive(int vt);
74void change_console(struct vc_data *new_vc); 74void change_console(struct vc_data *new_vc);
75void reset_vc(struct vc_data *vc); 75void reset_vc(struct vc_data *vc);
76#ifdef CONFIG_VT
77int is_console_suspend_safe(void);
78#else
79static inline int is_console_suspend_safe(void) { return 1; }
80#endif
81 76
82/* 77/*
83 * vc_screen.c shares this temporary buffer with the console write code so that 78 * vc_screen.c shares this temporary buffer with the console write code so that
diff --git a/include/net/compat.h b/include/net/compat.h
index 8662b8f43df5..e65cbedb6abc 100644
--- a/include/net/compat.h
+++ b/include/net/compat.h
@@ -3,6 +3,8 @@
3 3
4#include <linux/config.h> 4#include <linux/config.h>
5 5
6struct sock;
7
6#if defined(CONFIG_COMPAT) 8#if defined(CONFIG_COMPAT)
7 9
8#include <linux/compat.h> 10#include <linux/compat.h>
@@ -23,7 +25,6 @@ struct compat_cmsghdr {
23 compat_int_t cmsg_type; 25 compat_int_t cmsg_type;
24}; 26};
25 27
26struct sock;
27extern int compat_sock_get_timestamp(struct sock *, struct timeval __user *); 28extern int compat_sock_get_timestamp(struct sock *, struct timeval __user *);
28 29
29#else /* defined(CONFIG_COMPAT) */ 30#else /* defined(CONFIG_COMPAT) */
diff --git a/include/net/irda/irlmp.h b/include/net/irda/irlmp.h
index 86aefb1fda5e..c0c895d379ba 100644
--- a/include/net/irda/irlmp.h
+++ b/include/net/irda/irlmp.h
@@ -112,7 +112,7 @@ struct lsap_cb {
112 112
113 struct timer_list watchdog_timer; 113 struct timer_list watchdog_timer;
114 114
115 IRLMP_STATE lsap_state; /* Connection state */ 115 LSAP_STATE lsap_state; /* Connection state */
116 notify_t notify; /* Indication/Confirm entry points */ 116 notify_t notify; /* Indication/Confirm entry points */
117 struct qos_info qos; /* QoS for this connection */ 117 struct qos_info qos; /* QoS for this connection */
118 118
diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h
index 34a1a09e5aef..807d6f1ef4b5 100644
--- a/include/net/sctp/command.h
+++ b/include/net/sctp/command.h
@@ -99,6 +99,7 @@ typedef enum {
99 SCTP_CMD_DEL_NON_PRIMARY, /* Removes non-primary peer transports. */ 99 SCTP_CMD_DEL_NON_PRIMARY, /* Removes non-primary peer transports. */
100 SCTP_CMD_T3_RTX_TIMERS_STOP, /* Stops T3-rtx pending timers */ 100 SCTP_CMD_T3_RTX_TIMERS_STOP, /* Stops T3-rtx pending timers */
101 SCTP_CMD_FORCE_PRIM_RETRAN, /* Forces retrans. over primary path. */ 101 SCTP_CMD_FORCE_PRIM_RETRAN, /* Forces retrans. over primary path. */
102 SCTP_CMD_SET_SK_ERR, /* Set sk_err */
102 SCTP_CMD_LAST 103 SCTP_CMD_LAST
103} sctp_verb_t; 104} sctp_verb_t;
104 105
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index e673b2c984e9..aa6033ca7cd8 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -461,12 +461,12 @@ static inline int sctp_frag_point(const struct sctp_sock *sp, int pmtu)
461 * there is room for a param header too. 461 * there is room for a param header too.
462 */ 462 */
463#define sctp_walk_params(pos, chunk, member)\ 463#define sctp_walk_params(pos, chunk, member)\
464_sctp_walk_params((pos), (chunk), WORD_ROUND(ntohs((chunk)->chunk_hdr.length)), member) 464_sctp_walk_params((pos), (chunk), ntohs((chunk)->chunk_hdr.length), member)
465 465
466#define _sctp_walk_params(pos, chunk, end, member)\ 466#define _sctp_walk_params(pos, chunk, end, member)\
467for (pos.v = chunk->member;\ 467for (pos.v = chunk->member;\
468 pos.v <= (void *)chunk + end - sizeof(sctp_paramhdr_t) &&\ 468 pos.v <= (void *)chunk + end - sizeof(sctp_paramhdr_t) &&\
469 pos.v <= (void *)chunk + end - WORD_ROUND(ntohs(pos.p->length)) &&\ 469 pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\
470 ntohs(pos.p->length) >= sizeof(sctp_paramhdr_t);\ 470 ntohs(pos.p->length) >= sizeof(sctp_paramhdr_t);\
471 pos.v += WORD_ROUND(ntohs(pos.p->length))) 471 pos.v += WORD_ROUND(ntohs(pos.p->length)))
472 472
@@ -477,7 +477,7 @@ _sctp_walk_errors((err), (chunk_hdr), ntohs((chunk_hdr)->length))
477for (err = (sctp_errhdr_t *)((void *)chunk_hdr + \ 477for (err = (sctp_errhdr_t *)((void *)chunk_hdr + \
478 sizeof(sctp_chunkhdr_t));\ 478 sizeof(sctp_chunkhdr_t));\
479 (void *)err <= (void *)chunk_hdr + end - sizeof(sctp_errhdr_t) &&\ 479 (void *)err <= (void *)chunk_hdr + end - sizeof(sctp_errhdr_t) &&\
480 (void *)err <= (void *)chunk_hdr + end - WORD_ROUND(ntohs(err->length)) &&\ 480 (void *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\
481 ntohs(err->length) >= sizeof(sctp_errhdr_t); \ 481 ntohs(err->length) >= sizeof(sctp_errhdr_t); \
482 err = (sctp_errhdr_t *)((void *)err + WORD_ROUND(ntohs(err->length)))) 482 err = (sctp_errhdr_t *)((void *)err + WORD_ROUND(ntohs(err->length))))
483 483
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 72248d1b9e3f..ab81fdd4572b 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -2231,19 +2231,25 @@ static const struct cpuset *nearest_exclusive_ancestor(const struct cpuset *cs)
2231 * So only GFP_KERNEL allocations, if all nodes in the cpuset are 2231 * So only GFP_KERNEL allocations, if all nodes in the cpuset are
2232 * short of memory, might require taking the callback_mutex mutex. 2232 * short of memory, might require taking the callback_mutex mutex.
2233 * 2233 *
2234 * The first loop over the zonelist in mm/page_alloc.c:__alloc_pages() 2234 * The first call here from mm/page_alloc:get_page_from_freelist()
2235 * calls here with __GFP_HARDWALL always set in gfp_mask, enforcing 2235 * has __GFP_HARDWALL set in gfp_mask, enforcing hardwall cpusets, so
2236 * hardwall cpusets - no allocation on a node outside the cpuset is 2236 * no allocation on a node outside the cpuset is allowed (unless in
2237 * allowed (unless in interrupt, of course). 2237 * interrupt, of course).
2238 * 2238 *
2239 * The second loop doesn't even call here for GFP_ATOMIC requests 2239 * The second pass through get_page_from_freelist() doesn't even call
2240 * (if the __alloc_pages() local variable 'wait' is set). That check 2240 * here for GFP_ATOMIC calls. For those calls, the __alloc_pages()
2241 * and the checks below have the combined affect in the second loop of 2241 * variable 'wait' is not set, and the bit ALLOC_CPUSET is not set
2242 * the __alloc_pages() routine that: 2242 * in alloc_flags. That logic and the checks below have the combined
2243 * affect that:
2243 * in_interrupt - any node ok (current task context irrelevant) 2244 * in_interrupt - any node ok (current task context irrelevant)
2244 * GFP_ATOMIC - any node ok 2245 * GFP_ATOMIC - any node ok
2245 * GFP_KERNEL - any node in enclosing mem_exclusive cpuset ok 2246 * GFP_KERNEL - any node in enclosing mem_exclusive cpuset ok
2246 * GFP_USER - only nodes in current tasks mems allowed ok. 2247 * GFP_USER - only nodes in current tasks mems allowed ok.
2248 *
2249 * Rule:
2250 * Don't call cpuset_zone_allowed() if you can't sleep, unless you
2251 * pass in the __GFP_HARDWALL flag set in gfp_flag, which disables
2252 * the code that might scan up ancestor cpusets and sleep.
2247 **/ 2253 **/
2248 2254
2249int __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask) 2255int __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
@@ -2255,6 +2261,7 @@ int __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
2255 if (in_interrupt()) 2261 if (in_interrupt())
2256 return 1; 2262 return 1;
2257 node = z->zone_pgdat->node_id; 2263 node = z->zone_pgdat->node_id;
2264 might_sleep_if(!(gfp_mask & __GFP_HARDWALL));
2258 if (node_isset(node, current->mems_allowed)) 2265 if (node_isset(node, current->mems_allowed))
2259 return 1; 2266 return 1;
2260 if (gfp_mask & __GFP_HARDWALL) /* If hardwall request, stop here */ 2267 if (gfp_mask & __GFP_HARDWALL) /* If hardwall request, stop here */
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index b7f0388bd71c..01fa2ae98a85 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -456,6 +456,7 @@ hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode)
456 456
457 return ret; 457 return ret;
458} 458}
459EXPORT_SYMBOL_GPL(hrtimer_start);
459 460
460/** 461/**
461 * hrtimer_try_to_cancel - try to deactivate a timer 462 * hrtimer_try_to_cancel - try to deactivate a timer
@@ -484,6 +485,7 @@ int hrtimer_try_to_cancel(struct hrtimer *timer)
484 return ret; 485 return ret;
485 486
486} 487}
488EXPORT_SYMBOL_GPL(hrtimer_try_to_cancel);
487 489
488/** 490/**
489 * hrtimer_cancel - cancel a timer and wait for the handler to finish. 491 * hrtimer_cancel - cancel a timer and wait for the handler to finish.
@@ -504,6 +506,7 @@ int hrtimer_cancel(struct hrtimer *timer)
504 cpu_relax(); 506 cpu_relax();
505 } 507 }
506} 508}
509EXPORT_SYMBOL_GPL(hrtimer_cancel);
507 510
508/** 511/**
509 * hrtimer_get_remaining - get remaining time for the timer 512 * hrtimer_get_remaining - get remaining time for the timer
@@ -522,6 +525,7 @@ ktime_t hrtimer_get_remaining(const struct hrtimer *timer)
522 525
523 return rem; 526 return rem;
524} 527}
528EXPORT_SYMBOL_GPL(hrtimer_get_remaining);
525 529
526#ifdef CONFIG_NO_IDLE_HZ 530#ifdef CONFIG_NO_IDLE_HZ
527/** 531/**
@@ -580,6 +584,7 @@ void hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
580 timer->base = &bases[clock_id]; 584 timer->base = &bases[clock_id];
581 timer->node.rb_parent = HRTIMER_INACTIVE; 585 timer->node.rb_parent = HRTIMER_INACTIVE;
582} 586}
587EXPORT_SYMBOL_GPL(hrtimer_init);
583 588
584/** 589/**
585 * hrtimer_get_res - get the timer resolution for a clock 590 * hrtimer_get_res - get the timer resolution for a clock
@@ -599,6 +604,7 @@ int hrtimer_get_res(const clockid_t which_clock, struct timespec *tp)
599 604
600 return 0; 605 return 0;
601} 606}
607EXPORT_SYMBOL_GPL(hrtimer_get_res);
602 608
603/* 609/*
604 * Expire the per base hrtimer-queue: 610 * Expire the per base hrtimer-queue:
diff --git a/kernel/sched.c b/kernel/sched.c
index 4c64f85698ae..c13f1bd2df7d 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -665,55 +665,13 @@ static int effective_prio(task_t *p)
665} 665}
666 666
667/* 667/*
668 * We place interactive tasks back into the active array, if possible.
669 *
670 * To guarantee that this does not starve expired tasks we ignore the
671 * interactivity of a task if the first expired task had to wait more
672 * than a 'reasonable' amount of time. This deadline timeout is
673 * load-dependent, as the frequency of array switched decreases with
674 * increasing number of running tasks. We also ignore the interactivity
675 * if a better static_prio task has expired, and switch periodically
676 * regardless, to ensure that highly interactive tasks do not starve
677 * the less fortunate for unreasonably long periods.
678 */
679static inline int expired_starving(runqueue_t *rq)
680{
681 int limit;
682
683 /*
684 * Arrays were recently switched, all is well
685 */
686 if (!rq->expired_timestamp)
687 return 0;
688
689 limit = STARVATION_LIMIT * rq->nr_running;
690
691 /*
692 * It's time to switch arrays
693 */
694 if (jiffies - rq->expired_timestamp >= limit)
695 return 1;
696
697 /*
698 * There's a better selection in the expired array
699 */
700 if (rq->curr->static_prio > rq->best_expired_prio)
701 return 1;
702
703 /*
704 * All is well
705 */
706 return 0;
707}
708
709/*
710 * __activate_task - move a task to the runqueue. 668 * __activate_task - move a task to the runqueue.
711 */ 669 */
712static void __activate_task(task_t *p, runqueue_t *rq) 670static void __activate_task(task_t *p, runqueue_t *rq)
713{ 671{
714 prio_array_t *target = rq->active; 672 prio_array_t *target = rq->active;
715 673
716 if (unlikely(batch_task(p) || (expired_starving(rq) && !rt_task(p)))) 674 if (batch_task(p))
717 target = rq->expired; 675 target = rq->expired;
718 enqueue_task(p, target); 676 enqueue_task(p, target);
719 rq->nr_running++; 677 rq->nr_running++;
@@ -2532,6 +2490,22 @@ unsigned long long current_sched_time(const task_t *tsk)
2532} 2490}
2533 2491
2534/* 2492/*
2493 * We place interactive tasks back into the active array, if possible.
2494 *
2495 * To guarantee that this does not starve expired tasks we ignore the
2496 * interactivity of a task if the first expired task had to wait more
2497 * than a 'reasonable' amount of time. This deadline timeout is
2498 * load-dependent, as the frequency of array switched decreases with
2499 * increasing number of running tasks. We also ignore the interactivity
2500 * if a better static_prio task has expired:
2501 */
2502#define EXPIRED_STARVING(rq) \
2503 ((STARVATION_LIMIT && ((rq)->expired_timestamp && \
2504 (jiffies - (rq)->expired_timestamp >= \
2505 STARVATION_LIMIT * ((rq)->nr_running) + 1))) || \
2506 ((rq)->curr->static_prio > (rq)->best_expired_prio))
2507
2508/*
2535 * Account user cpu time to a process. 2509 * Account user cpu time to a process.
2536 * @p: the process that the cpu time gets accounted to 2510 * @p: the process that the cpu time gets accounted to
2537 * @hardirq_offset: the offset to subtract from hardirq_count() 2511 * @hardirq_offset: the offset to subtract from hardirq_count()
@@ -2666,7 +2640,7 @@ void scheduler_tick(void)
2666 2640
2667 if (!rq->expired_timestamp) 2641 if (!rq->expired_timestamp)
2668 rq->expired_timestamp = jiffies; 2642 rq->expired_timestamp = jiffies;
2669 if (!TASK_INTERACTIVE(p) || expired_starving(rq)) { 2643 if (!TASK_INTERACTIVE(p) || EXPIRED_STARVING(rq)) {
2670 enqueue_task(p, rq->expired); 2644 enqueue_task(p, rq->expired);
2671 if (p->static_prio < rq->best_expired_prio) 2645 if (p->static_prio < rq->best_expired_prio)
2672 rq->best_expired_prio = p->static_prio; 2646 rq->best_expired_prio = p->static_prio;
diff --git a/kernel/timer.c b/kernel/timer.c
index 67eaf0f54096..9e49deed468c 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -541,6 +541,22 @@ found:
541 } 541 }
542 spin_unlock(&base->lock); 542 spin_unlock(&base->lock);
543 543
544 /*
545 * It can happen that other CPUs service timer IRQs and increment
546 * jiffies, but we have not yet got a local timer tick to process
547 * the timer wheels. In that case, the expiry time can be before
548 * jiffies, but since the high-resolution timer here is relative to
549 * jiffies, the default expression when high-resolution timers are
550 * not active,
551 *
552 * time_before(MAX_JIFFY_OFFSET + jiffies, expires)
553 *
554 * would falsely evaluate to true. If that is the case, just
555 * return jiffies so that we can immediately fire the local timer
556 */
557 if (time_before(expires, jiffies))
558 return jiffies;
559
544 if (time_before(hr_expires, expires)) 560 if (time_before(hr_expires, expires))
545 return hr_expires; 561 return hr_expires;
546 562
diff --git a/lib/kobject.c b/lib/kobject.c
index b46350c27837..687ab418d292 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -198,14 +198,14 @@ int kobject_add(struct kobject * kobj)
198 198
199 /* be noisy on error issues */ 199 /* be noisy on error issues */
200 if (error == -EEXIST) 200 if (error == -EEXIST)
201 printk("kobject_add failed for %s with -EEXIST, " 201 pr_debug("kobject_add failed for %s with -EEXIST, "
202 "don't try to register things with the " 202 "don't try to register things with the "
203 "same name in the same directory.\n", 203 "same name in the same directory.\n",
204 kobject_name(kobj)); 204 kobject_name(kobj));
205 else 205 else
206 printk("kobject_add failed for %s (%d)\n", 206 pr_debug("kobject_add failed for %s (%d)\n",
207 kobject_name(kobj), error); 207 kobject_name(kobj), error);
208 dump_stack(); 208 /* dump_stack(); */
209 } 209 }
210 210
211 return error; 211 return error;
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 1ae2b2cc3a54..70df5c0d957e 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -91,8 +91,8 @@ static void grow_zone_span(struct zone *zone,
91 if (start_pfn < zone->zone_start_pfn) 91 if (start_pfn < zone->zone_start_pfn)
92 zone->zone_start_pfn = start_pfn; 92 zone->zone_start_pfn = start_pfn;
93 93
94 if (end_pfn > old_zone_end_pfn) 94 zone->spanned_pages = max(old_zone_end_pfn, end_pfn) -
95 zone->spanned_pages = end_pfn - zone->zone_start_pfn; 95 zone->zone_start_pfn;
96 96
97 zone_span_writeunlock(zone); 97 zone_span_writeunlock(zone);
98} 98}
@@ -106,8 +106,8 @@ static void grow_pgdat_span(struct pglist_data *pgdat,
106 if (start_pfn < pgdat->node_start_pfn) 106 if (start_pfn < pgdat->node_start_pfn)
107 pgdat->node_start_pfn = start_pfn; 107 pgdat->node_start_pfn = start_pfn;
108 108
109 if (end_pfn > old_pgdat_end_pfn) 109 pgdat->node_spanned_pages = max(old_pgdat_end_pfn, end_pfn) -
110 pgdat->node_spanned_pages = end_pfn - pgdat->node_start_pfn; 110 pgdat->node_start_pfn;
111} 111}
112 112
113int online_pages(unsigned long pfn, unsigned long nr_pages) 113int online_pages(unsigned long pfn, unsigned long nr_pages)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 813b4ec1298a..253a450c400d 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -951,7 +951,7 @@ restart:
951 goto got_pg; 951 goto got_pg;
952 952
953 do { 953 do {
954 if (cpuset_zone_allowed(*z, gfp_mask)) 954 if (cpuset_zone_allowed(*z, gfp_mask|__GFP_HARDWALL))
955 wakeup_kswapd(*z, order); 955 wakeup_kswapd(*z, order);
956 } while (*(++z)); 956 } while (*(++z));
957 957
@@ -970,7 +970,8 @@ restart:
970 alloc_flags |= ALLOC_HARDER; 970 alloc_flags |= ALLOC_HARDER;
971 if (gfp_mask & __GFP_HIGH) 971 if (gfp_mask & __GFP_HIGH)
972 alloc_flags |= ALLOC_HIGH; 972 alloc_flags |= ALLOC_HIGH;
973 alloc_flags |= ALLOC_CPUSET; 973 if (wait)
974 alloc_flags |= ALLOC_CPUSET;
974 975
975 /* 976 /*
976 * Go through the zonelist again. Let __GFP_HIGH and allocations 977 * Go through the zonelist again. Let __GFP_HIGH and allocations
@@ -2124,14 +2125,22 @@ static void __init alloc_node_mem_map(struct pglist_data *pgdat)
2124#ifdef CONFIG_FLAT_NODE_MEM_MAP 2125#ifdef CONFIG_FLAT_NODE_MEM_MAP
2125 /* ia64 gets its own node_mem_map, before this, without bootmem */ 2126 /* ia64 gets its own node_mem_map, before this, without bootmem */
2126 if (!pgdat->node_mem_map) { 2127 if (!pgdat->node_mem_map) {
2127 unsigned long size; 2128 unsigned long size, start, end;
2128 struct page *map; 2129 struct page *map;
2129 2130
2130 size = (pgdat->node_spanned_pages + 1) * sizeof(struct page); 2131 /*
2132 * The zone's endpoints aren't required to be MAX_ORDER
2133 * aligned but the node_mem_map endpoints must be in order
2134 * for the buddy allocator to function correctly.
2135 */
2136 start = pgdat->node_start_pfn & ~(MAX_ORDER_NR_PAGES - 1);
2137 end = pgdat->node_start_pfn + pgdat->node_spanned_pages;
2138 end = ALIGN(end, MAX_ORDER_NR_PAGES);
2139 size = (end - start) * sizeof(struct page);
2131 map = alloc_remap(pgdat->node_id, size); 2140 map = alloc_remap(pgdat->node_id, size);
2132 if (!map) 2141 if (!map)
2133 map = alloc_bootmem_node(pgdat, size); 2142 map = alloc_bootmem_node(pgdat, size);
2134 pgdat->node_mem_map = map; 2143 pgdat->node_mem_map = map + (pgdat->node_start_pfn - start);
2135 } 2144 }
2136#ifdef CONFIG_FLATMEM 2145#ifdef CONFIG_FLATMEM
2137 /* 2146 /*
diff --git a/mm/slab.c b/mm/slab.c
index d31a06bfbea5..f1b644eb39d8 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -207,11 +207,6 @@ typedef unsigned int kmem_bufctl_t;
207#define BUFCTL_ACTIVE (((kmem_bufctl_t)(~0U))-2) 207#define BUFCTL_ACTIVE (((kmem_bufctl_t)(~0U))-2)
208#define SLAB_LIMIT (((kmem_bufctl_t)(~0U))-3) 208#define SLAB_LIMIT (((kmem_bufctl_t)(~0U))-3)
209 209
210/* Max number of objs-per-slab for caches which use off-slab slabs.
211 * Needed to avoid a possible looping condition in cache_grow().
212 */
213static unsigned long offslab_limit;
214
215/* 210/*
216 * struct slab 211 * struct slab
217 * 212 *
@@ -1356,12 +1351,6 @@ void __init kmem_cache_init(void)
1356 NULL, NULL); 1351 NULL, NULL);
1357 } 1352 }
1358 1353
1359 /* Inc off-slab bufctl limit until the ceiling is hit. */
1360 if (!(OFF_SLAB(sizes->cs_cachep))) {
1361 offslab_limit = sizes->cs_size - sizeof(struct slab);
1362 offslab_limit /= sizeof(kmem_bufctl_t);
1363 }
1364
1365 sizes->cs_dmacachep = kmem_cache_create(names->name_dma, 1354 sizes->cs_dmacachep = kmem_cache_create(names->name_dma,
1366 sizes->cs_size, 1355 sizes->cs_size,
1367 ARCH_KMALLOC_MINALIGN, 1356 ARCH_KMALLOC_MINALIGN,
@@ -1780,6 +1769,7 @@ static void set_up_list3s(struct kmem_cache *cachep, int index)
1780static size_t calculate_slab_order(struct kmem_cache *cachep, 1769static size_t calculate_slab_order(struct kmem_cache *cachep,
1781 size_t size, size_t align, unsigned long flags) 1770 size_t size, size_t align, unsigned long flags)
1782{ 1771{
1772 unsigned long offslab_limit;
1783 size_t left_over = 0; 1773 size_t left_over = 0;
1784 int gfporder; 1774 int gfporder;
1785 1775
@@ -1791,9 +1781,18 @@ static size_t calculate_slab_order(struct kmem_cache *cachep,
1791 if (!num) 1781 if (!num)
1792 continue; 1782 continue;
1793 1783
1794 /* More than offslab_limit objects will cause problems */ 1784 if (flags & CFLGS_OFF_SLAB) {
1795 if ((flags & CFLGS_OFF_SLAB) && num > offslab_limit) 1785 /*
1796 break; 1786 * Max number of objs-per-slab for caches which
1787 * use off-slab slabs. Needed to avoid a possible
1788 * looping condition in cache_grow().
1789 */
1790 offslab_limit = size - sizeof(struct slab);
1791 offslab_limit /= sizeof(kmem_bufctl_t);
1792
1793 if (num > offslab_limit)
1794 break;
1795 }
1797 1796
1798 /* Found something acceptable - save it away */ 1797 /* Found something acceptable - save it away */
1799 cachep->num = num; 1798 cachep->num = num;
diff --git a/mm/sparse.c b/mm/sparse.c
index c5e89eb9ac8f..100040c0dfb6 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -87,11 +87,8 @@ int __section_nr(struct mem_section* ms)
87 unsigned long root_nr; 87 unsigned long root_nr;
88 struct mem_section* root; 88 struct mem_section* root;
89 89
90 for (root_nr = 0; 90 for (root_nr = 0; root_nr < NR_SECTION_ROOTS; root_nr++) {
91 root_nr < NR_MEM_SECTIONS; 91 root = __nr_to_section(root_nr * SECTIONS_PER_ROOT);
92 root_nr += SECTIONS_PER_ROOT) {
93 root = __nr_to_section(root_nr);
94
95 if (!root) 92 if (!root)
96 continue; 93 continue;
97 94
diff --git a/net/bridge/br.c b/net/bridge/br.c
index 22d806cf40ca..12da21afb9ca 100644
--- a/net/bridge/br.c
+++ b/net/bridge/br.c
@@ -55,7 +55,7 @@ static int __init br_init(void)
55 55
56static void __exit br_deinit(void) 56static void __exit br_deinit(void)
57{ 57{
58 llc_sap_close(br_stp_sap); 58 rcu_assign_pointer(br_stp_sap->rcv_func, NULL);
59 59
60#ifdef CONFIG_BRIDGE_NETFILTER 60#ifdef CONFIG_BRIDGE_NETFILTER
61 br_netfilter_fini(); 61 br_netfilter_fini();
@@ -67,6 +67,7 @@ static void __exit br_deinit(void)
67 67
68 synchronize_net(); 68 synchronize_net();
69 69
70 llc_sap_put(br_stp_sap);
70 br_fdb_get_hook = NULL; 71 br_fdb_get_hook = NULL;
71 br_fdb_put_hook = NULL; 72 br_fdb_put_hook = NULL;
72 73
diff --git a/net/core/dev.c b/net/core/dev.c
index 2dce673a039b..4fba549caf29 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -127,7 +127,7 @@
127 * sure which should go first, but I bet it won't make much 127 * sure which should go first, but I bet it won't make much
128 * difference if we are running VLANs. The good news is that 128 * difference if we are running VLANs. The good news is that
129 * this protocol won't be in the list unless compiled in, so 129 * this protocol won't be in the list unless compiled in, so
130 * the average user (w/out VLANs) will not be adversly affected. 130 * the average user (w/out VLANs) will not be adversely affected.
131 * --BLG 131 * --BLG
132 * 132 *
133 * 0800 IP 133 * 0800 IP
@@ -149,7 +149,7 @@ static struct list_head ptype_base[16]; /* 16 way hashed list */
149static struct list_head ptype_all; /* Taps */ 149static struct list_head ptype_all; /* Taps */
150 150
151/* 151/*
152 * The @dev_base list is protected by @dev_base_lock and the rtln 152 * The @dev_base list is protected by @dev_base_lock and the rtnl
153 * semaphore. 153 * semaphore.
154 * 154 *
155 * Pure readers hold dev_base_lock for reading. 155 * Pure readers hold dev_base_lock for reading.
@@ -641,10 +641,12 @@ int dev_valid_name(const char *name)
641 * @name: name format string 641 * @name: name format string
642 * 642 *
643 * Passed a format string - eg "lt%d" it will try and find a suitable 643 * Passed a format string - eg "lt%d" it will try and find a suitable
644 * id. Not efficient for many devices, not called a lot. The caller 644 * id. It scans list of devices to build up a free map, then chooses
645 * must hold the dev_base or rtnl lock while allocating the name and 645 * the first empty slot. The caller must hold the dev_base or rtnl lock
646 * adding the device in order to avoid duplicates. Returns the number 646 * while allocating the name and adding the device in order to avoid
647 * of the unit assigned or a negative errno code. 647 * duplicates.
648 * Limited to bits_per_byte * page size devices (ie 32K on most platforms).
649 * Returns the number of the unit assigned or a negative errno code.
648 */ 650 */
649 651
650int dev_alloc_name(struct net_device *dev, const char *name) 652int dev_alloc_name(struct net_device *dev, const char *name)
@@ -744,7 +746,7 @@ int dev_change_name(struct net_device *dev, char *newname)
744} 746}
745 747
746/** 748/**
747 * netdev_features_change - device changes fatures 749 * netdev_features_change - device changes features
748 * @dev: device to cause notification 750 * @dev: device to cause notification
749 * 751 *
750 * Called to indicate a device has changed features. 752 * Called to indicate a device has changed features.
@@ -2196,7 +2198,7 @@ int netdev_set_master(struct net_device *slave, struct net_device *master)
2196 * @dev: device 2198 * @dev: device
2197 * @inc: modifier 2199 * @inc: modifier
2198 * 2200 *
2199 * Add or remove promsicuity from a device. While the count in the device 2201 * Add or remove promiscuity from a device. While the count in the device
2200 * remains above zero the interface remains promiscuous. Once it hits zero 2202 * remains above zero the interface remains promiscuous. Once it hits zero
2201 * the device reverts back to normal filtering operation. A negative inc 2203 * the device reverts back to normal filtering operation. A negative inc
2202 * value is used to drop promiscuity on the device. 2204 * value is used to drop promiscuity on the device.
@@ -3122,7 +3124,7 @@ EXPORT_SYMBOL(alloc_netdev);
3122void free_netdev(struct net_device *dev) 3124void free_netdev(struct net_device *dev)
3123{ 3125{
3124#ifdef CONFIG_SYSFS 3126#ifdef CONFIG_SYSFS
3125 /* Compatiablity with error handling in drivers */ 3127 /* Compatibility with error handling in drivers */
3126 if (dev->reg_state == NETREG_UNINITIALIZED) { 3128 if (dev->reg_state == NETREG_UNINITIALIZED) {
3127 kfree((char *)dev - dev->padded); 3129 kfree((char *)dev - dev->padded);
3128 return; 3130 return;
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index cd810f41af1a..95278b22b669 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -210,7 +210,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
210 skb->h.icmph->code != ICMP_FRAG_NEEDED) 210 skb->h.icmph->code != ICMP_FRAG_NEEDED)
211 return; 211 return;
212 212
213 spi = ntohl(ntohs(ipch->cpi)); 213 spi = htonl(ntohs(ipch->cpi));
214 x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, 214 x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr,
215 spi, IPPROTO_COMP, AF_INET); 215 spi, IPPROTO_COMP, AF_INET);
216 if (!x) 216 if (!x)
diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig
index 3d560dec63ab..d4072533da21 100644
--- a/net/ipv4/netfilter/Kconfig
+++ b/net/ipv4/netfilter/Kconfig
@@ -170,8 +170,8 @@ config IP_NF_PPTP
170 Documentation/modules.txt. If unsure, say `N'. 170 Documentation/modules.txt. If unsure, say `N'.
171 171
172config IP_NF_H323 172config IP_NF_H323
173 tristate 'H.323 protocol support' 173 tristate 'H.323 protocol support (EXPERIMENTAL)'
174 depends on IP_NF_CONNTRACK 174 depends on IP_NF_CONNTRACK && EXPERIMENTAL
175 help 175 help
176 H.323 is a VoIP signalling protocol from ITU-T. As one of the most 176 H.323 is a VoIP signalling protocol from ITU-T. As one of the most
177 important VoIP protocols, it is widely used by voice hardware and 177 important VoIP protocols, it is widely used by voice hardware and
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
index 979a2eac6f00..a297da7bbef5 100644
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -1318,6 +1318,7 @@ getorigdst(struct sock *sk, int optval, void __user *user, int *len)
1318 .tuple.dst.u.tcp.port; 1318 .tuple.dst.u.tcp.port;
1319 sin.sin_addr.s_addr = ct->tuplehash[IP_CT_DIR_ORIGINAL] 1319 sin.sin_addr.s_addr = ct->tuplehash[IP_CT_DIR_ORIGINAL]
1320 .tuple.dst.ip; 1320 .tuple.dst.ip;
1321 memset(sin.sin_zero, 0, sizeof(sin.sin_zero));
1321 1322
1322 DEBUGP("SO_ORIGINAL_DST: %u.%u.%u.%u %u\n", 1323 DEBUGP("SO_ORIGINAL_DST: %u.%u.%u.%u %u\n",
1323 NIPQUAD(sin.sin_addr.s_addr), ntohs(sin.sin_port)); 1324 NIPQUAD(sin.sin_addr.s_addr), ntohs(sin.sin_port));
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.c b/net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.c
index 355a53a5b6cd..26dfecadb335 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.c
+++ b/net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.c
@@ -528,14 +528,15 @@ int decode_seq(bitstr_t * bs, field_t * f, char *base, int level)
528 528
529 /* Decode */ 529 /* Decode */
530 if ((err = (Decoders[son->type]) (bs, son, base, 530 if ((err = (Decoders[son->type]) (bs, son, base,
531 level + 1)) > 531 level + 1)) <
532 H323_ERROR_STOP) 532 H323_ERROR_NONE)
533 return err; 533 return err;
534 534
535 bs->cur = beg + len; 535 bs->cur = beg + len;
536 bs->bit = 0; 536 bs->bit = 0;
537 } else if ((err = (Decoders[son->type]) (bs, son, base, 537 } else if ((err = (Decoders[son->type]) (bs, son, base,
538 level + 1))) 538 level + 1)) <
539 H323_ERROR_NONE)
539 return err; 540 return err;
540 } 541 }
541 542
@@ -554,7 +555,7 @@ int decode_seq(bitstr_t * bs, field_t * f, char *base, int level)
554 555
555 /* Decode the extension components */ 556 /* Decode the extension components */
556 for (opt = 0; opt < bmp2_len; opt++, i++, son++) { 557 for (opt = 0; opt < bmp2_len; opt++, i++, son++) {
557 if (son->attr & STOP) { 558 if (i < f->ub && son->attr & STOP) {
558 PRINT("%*.s%s\n", (level + 1) * TAB_SIZE, " ", 559 PRINT("%*.s%s\n", (level + 1) * TAB_SIZE, " ",
559 son->name); 560 son->name);
560 return H323_ERROR_STOP; 561 return H323_ERROR_STOP;
@@ -584,8 +585,8 @@ int decode_seq(bitstr_t * bs, field_t * f, char *base, int level)
584 beg = bs->cur; 585 beg = bs->cur;
585 586
586 if ((err = (Decoders[son->type]) (bs, son, base, 587 if ((err = (Decoders[son->type]) (bs, son, base,
587 level + 1)) > 588 level + 1)) <
588 H323_ERROR_STOP) 589 H323_ERROR_NONE)
589 return err; 590 return err;
590 591
591 bs->cur = beg + len; 592 bs->cur = beg + len;
@@ -660,18 +661,20 @@ int decode_seqof(bitstr_t * bs, field_t * f, char *base, int level)
660 i < 661 i <
661 effective_count ? 662 effective_count ?
662 base : NULL, 663 base : NULL,
663 level + 1)) > 664 level + 1)) <
664 H323_ERROR_STOP) 665 H323_ERROR_NONE)
665 return err; 666 return err;
666 667
667 bs->cur = beg + len; 668 bs->cur = beg + len;
668 bs->bit = 0; 669 bs->bit = 0;
669 } else 670 } else
670 if ((err = (Decoders[son->type]) (bs, son, 671 if ((err = (Decoders[son->type]) (bs, son,
671 i < effective_count ? 672 i <
672 base : NULL, 673 effective_count ?
673 level + 1))) 674 base : NULL,
674 return err; 675 level + 1)) <
676 H323_ERROR_NONE)
677 return err;
675 678
676 if (base) 679 if (base)
677 base += son->offset; 680 base += son->offset;
@@ -735,13 +738,14 @@ int decode_choice(bitstr_t * bs, field_t * f, char *base, int level)
735 } 738 }
736 beg = bs->cur; 739 beg = bs->cur;
737 740
738 if ((err = (Decoders[son->type]) (bs, son, base, level + 1)) > 741 if ((err = (Decoders[son->type]) (bs, son, base, level + 1)) <
739 H323_ERROR_STOP) 742 H323_ERROR_NONE)
740 return err; 743 return err;
741 744
742 bs->cur = beg + len; 745 bs->cur = beg + len;
743 bs->bit = 0; 746 bs->bit = 0;
744 } else if ((err = (Decoders[son->type]) (bs, son, base, level + 1))) 747 } else if ((err = (Decoders[son->type]) (bs, son, base, level + 1)) <
748 H323_ERROR_NONE)
745 return err; 749 return err;
746 750
747 return H323_ERROR_NONE; 751 return H323_ERROR_NONE;
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_pptp.c b/net/ipv4/netfilter/ip_conntrack_helper_pptp.c
index 7d3ba4302e9e..8ccfe17bb253 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_pptp.c
+++ b/net/ipv4/netfilter/ip_conntrack_helper_pptp.c
@@ -469,8 +469,8 @@ pptp_inbound_pkt(struct sk_buff **pskb,
469 DEBUGP("%s but no session\n", pptp_msg_name[msg]); 469 DEBUGP("%s but no session\n", pptp_msg_name[msg]);
470 break; 470 break;
471 } 471 }
472 if (info->sstate != PPTP_CALL_IN_REP 472 if (info->cstate != PPTP_CALL_IN_REP
473 && info->sstate != PPTP_CALL_IN_CONF) { 473 && info->cstate != PPTP_CALL_IN_CONF) {
474 DEBUGP("%s but never sent IN_CALL_REPLY\n", 474 DEBUGP("%s but never sent IN_CALL_REPLY\n",
475 pptp_msg_name[msg]); 475 pptp_msg_name[msg]);
476 break; 476 break;
diff --git a/net/ipv4/netfilter/ip_nat_snmp_basic.c b/net/ipv4/netfilter/ip_nat_snmp_basic.c
index c62253845538..c33244263b90 100644
--- a/net/ipv4/netfilter/ip_nat_snmp_basic.c
+++ b/net/ipv4/netfilter/ip_nat_snmp_basic.c
@@ -768,6 +768,7 @@ static unsigned char snmp_object_decode(struct asn1_ctx *ctx,
768 len *= sizeof(unsigned long); 768 len *= sizeof(unsigned long);
769 *obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC); 769 *obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC);
770 if (*obj == NULL) { 770 if (*obj == NULL) {
771 kfree(lp);
771 kfree(id); 772 kfree(id);
772 if (net_ratelimit()) 773 if (net_ratelimit())
773 printk("OOM in bsalg (%d)\n", __LINE__); 774 printk("OOM in bsalg (%d)\n", __LINE__);
@@ -1003,12 +1004,12 @@ static unsigned char snmp_trap_decode(struct asn1_ctx *ctx,
1003 1004
1004 return 1; 1005 return 1;
1005 1006
1007err_addr_free:
1008 kfree((unsigned long *)trap->ip_address);
1009
1006err_id_free: 1010err_id_free:
1007 kfree(trap->id); 1011 kfree(trap->id);
1008 1012
1009err_addr_free:
1010 kfree((unsigned long *)trap->ip_address);
1011
1012 return 0; 1013 return 0;
1013} 1014}
1014 1015
@@ -1126,11 +1127,10 @@ static int snmp_parse_mangle(unsigned char *msg,
1126 struct snmp_v1_trap trap; 1127 struct snmp_v1_trap trap;
1127 unsigned char ret = snmp_trap_decode(&ctx, &trap, map, check); 1128 unsigned char ret = snmp_trap_decode(&ctx, &trap, map, check);
1128 1129
1129 /* Discard trap allocations regardless */ 1130 if (ret) {
1130 kfree(trap.id); 1131 kfree(trap.id);
1131 kfree((unsigned long *)trap.ip_address); 1132 kfree((unsigned long *)trap.ip_address);
1132 1133 } else
1133 if (!ret)
1134 return ret; 1134 return ret;
1135 1135
1136 } else { 1136 } else {
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index 5bc9f64d7b5b..77d974443c7b 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -348,6 +348,7 @@ getorigdst(struct sock *sk, int optval, void __user *user, int *len)
348 .tuple.dst.u.tcp.port; 348 .tuple.dst.u.tcp.port;
349 sin.sin_addr.s_addr = ct->tuplehash[IP_CT_DIR_ORIGINAL] 349 sin.sin_addr.s_addr = ct->tuplehash[IP_CT_DIR_ORIGINAL]
350 .tuple.dst.u3.ip; 350 .tuple.dst.u3.ip;
351 memset(sin.sin_zero, 0, sizeof(sin.sin_zero));
351 352
352 DEBUGP("SO_ORIGINAL_DST: %u.%u.%u.%u %u\n", 353 DEBUGP("SO_ORIGINAL_DST: %u.%u.%u.%u %u\n",
353 NIPQUAD(sin.sin_addr.s_addr), ntohs(sin.sin_port)); 354 NIPQUAD(sin.sin_addr.s_addr), ntohs(sin.sin_port));
diff --git a/net/ipv4/tcp_highspeed.c b/net/ipv4/tcp_highspeed.c
index b72fa55dfb84..ba7c63ca5bb1 100644
--- a/net/ipv4/tcp_highspeed.c
+++ b/net/ipv4/tcp_highspeed.c
@@ -135,7 +135,8 @@ static void hstcp_cong_avoid(struct sock *sk, u32 adk, u32 rtt,
135 135
136 /* Do additive increase */ 136 /* Do additive increase */
137 if (tp->snd_cwnd < tp->snd_cwnd_clamp) { 137 if (tp->snd_cwnd < tp->snd_cwnd_clamp) {
138 tp->snd_cwnd_cnt += ca->ai; 138 /* cwnd = cwnd + a(w) / cwnd */
139 tp->snd_cwnd_cnt += ca->ai + 1;
139 if (tp->snd_cwnd_cnt >= tp->snd_cwnd) { 140 if (tp->snd_cwnd_cnt >= tp->snd_cwnd) {
140 tp->snd_cwnd_cnt -= tp->snd_cwnd; 141 tp->snd_cwnd_cnt -= tp->snd_cwnd;
141 tp->snd_cwnd++; 142 tp->snd_cwnd++;
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index f285bbf296e2..8604c747bca5 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -221,7 +221,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl)
221 if (pskb_may_pull(skb, xprth + 4 - skb->data)) { 221 if (pskb_may_pull(skb, xprth + 4 - skb->data)) {
222 u16 *ipcomp_hdr = (u16 *)xprth; 222 u16 *ipcomp_hdr = (u16 *)xprth;
223 223
224 fl->fl_ipsec_spi = ntohl(ntohs(ipcomp_hdr[1])); 224 fl->fl_ipsec_spi = htonl(ntohs(ipcomp_hdr[1]));
225 } 225 }
226 break; 226 break;
227 default: 227 default:
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 05eb67def39f..48636436028a 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -208,7 +208,7 @@ static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
208 if (type != ICMPV6_DEST_UNREACH && type != ICMPV6_PKT_TOOBIG) 208 if (type != ICMPV6_DEST_UNREACH && type != ICMPV6_PKT_TOOBIG)
209 return; 209 return;
210 210
211 spi = ntohl(ntohs(ipcomph->cpi)); 211 spi = htonl(ntohs(ipcomph->cpi));
212 x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, spi, IPPROTO_COMP, AF_INET6); 212 x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, spi, IPPROTO_COMP, AF_INET6);
213 if (!x) 213 if (!x)
214 return; 214 return;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 0190e39096b9..8a777932786d 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -280,10 +280,13 @@ static int inline rt6_check_neigh(struct rt6_info *rt)
280{ 280{
281 struct neighbour *neigh = rt->rt6i_nexthop; 281 struct neighbour *neigh = rt->rt6i_nexthop;
282 int m = 0; 282 int m = 0;
283 if (neigh) { 283 if (rt->rt6i_flags & RTF_NONEXTHOP ||
284 !(rt->rt6i_flags & RTF_GATEWAY))
285 m = 1;
286 else if (neigh) {
284 read_lock_bh(&neigh->lock); 287 read_lock_bh(&neigh->lock);
285 if (neigh->nud_state & NUD_VALID) 288 if (neigh->nud_state & NUD_VALID)
286 m = 1; 289 m = 2;
287 read_unlock_bh(&neigh->lock); 290 read_unlock_bh(&neigh->lock);
288 } 291 }
289 return m; 292 return m;
@@ -292,15 +295,18 @@ static int inline rt6_check_neigh(struct rt6_info *rt)
292static int rt6_score_route(struct rt6_info *rt, int oif, 295static int rt6_score_route(struct rt6_info *rt, int oif,
293 int strict) 296 int strict)
294{ 297{
295 int m = rt6_check_dev(rt, oif); 298 int m, n;
299
300 m = rt6_check_dev(rt, oif);
296 if (!m && (strict & RT6_SELECT_F_IFACE)) 301 if (!m && (strict & RT6_SELECT_F_IFACE))
297 return -1; 302 return -1;
298#ifdef CONFIG_IPV6_ROUTER_PREF 303#ifdef CONFIG_IPV6_ROUTER_PREF
299 m |= IPV6_DECODE_PREF(IPV6_EXTRACT_PREF(rt->rt6i_flags)) << 2; 304 m |= IPV6_DECODE_PREF(IPV6_EXTRACT_PREF(rt->rt6i_flags)) << 2;
300#endif 305#endif
301 if (rt6_check_neigh(rt)) 306 n = rt6_check_neigh(rt);
307 if (n > 1)
302 m |= 16; 308 m |= 16;
303 else if (strict & RT6_SELECT_F_REACHABLE) 309 else if (!n && strict & RT6_SELECT_F_REACHABLE)
304 return -1; 310 return -1;
305 return m; 311 return m;
306} 312}
diff --git a/net/irda/iriap.c b/net/irda/iriap.c
index 254f90746900..2d2e2b1919f4 100644
--- a/net/irda/iriap.c
+++ b/net/irda/iriap.c
@@ -544,7 +544,8 @@ static void iriap_getvaluebyclass_response(struct iriap_cb *self,
544{ 544{
545 struct sk_buff *tx_skb; 545 struct sk_buff *tx_skb;
546 int n; 546 int n;
547 __u32 tmp_be32, tmp_be16; 547 __u32 tmp_be32;
548 __be16 tmp_be16;
548 __u8 *fp; 549 __u8 *fp;
549 550
550 IRDA_DEBUG(4, "%s()\n", __FUNCTION__); 551 IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
diff --git a/net/sctp/input.c b/net/sctp/input.c
index d117ebc75cf8..1662f9cc869e 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -73,6 +73,8 @@ static struct sctp_association *__sctp_lookup_association(
73 const union sctp_addr *peer, 73 const union sctp_addr *peer,
74 struct sctp_transport **pt); 74 struct sctp_transport **pt);
75 75
76static void sctp_add_backlog(struct sock *sk, struct sk_buff *skb);
77
76 78
77/* Calculate the SCTP checksum of an SCTP packet. */ 79/* Calculate the SCTP checksum of an SCTP packet. */
78static inline int sctp_rcv_checksum(struct sk_buff *skb) 80static inline int sctp_rcv_checksum(struct sk_buff *skb)
@@ -186,7 +188,6 @@ int sctp_rcv(struct sk_buff *skb)
186 */ 188 */
187 if (sk->sk_bound_dev_if && (sk->sk_bound_dev_if != af->skb_iif(skb))) 189 if (sk->sk_bound_dev_if && (sk->sk_bound_dev_if != af->skb_iif(skb)))
188 { 190 {
189 sock_put(sk);
190 if (asoc) { 191 if (asoc) {
191 sctp_association_put(asoc); 192 sctp_association_put(asoc);
192 asoc = NULL; 193 asoc = NULL;
@@ -197,7 +198,6 @@ int sctp_rcv(struct sk_buff *skb)
197 sk = sctp_get_ctl_sock(); 198 sk = sctp_get_ctl_sock();
198 ep = sctp_sk(sk)->ep; 199 ep = sctp_sk(sk)->ep;
199 sctp_endpoint_hold(ep); 200 sctp_endpoint_hold(ep);
200 sock_hold(sk);
201 rcvr = &ep->base; 201 rcvr = &ep->base;
202 } 202 }
203 203
@@ -253,25 +253,18 @@ int sctp_rcv(struct sk_buff *skb)
253 */ 253 */
254 sctp_bh_lock_sock(sk); 254 sctp_bh_lock_sock(sk);
255 255
256 /* It is possible that the association could have moved to a different
257 * socket if it is peeled off. If so, update the sk.
258 */
259 if (sk != rcvr->sk) {
260 sctp_bh_lock_sock(rcvr->sk);
261 sctp_bh_unlock_sock(sk);
262 sk = rcvr->sk;
263 }
264
265 if (sock_owned_by_user(sk)) 256 if (sock_owned_by_user(sk))
266 sk_add_backlog(sk, skb); 257 sctp_add_backlog(sk, skb);
267 else 258 else
268 sctp_backlog_rcv(sk, skb); 259 sctp_inq_push(&chunk->rcvr->inqueue, chunk);
269 260
270 /* Release the sock and the sock ref we took in the lookup calls.
271 * The asoc/ep ref will be released in sctp_backlog_rcv.
272 */
273 sctp_bh_unlock_sock(sk); 261 sctp_bh_unlock_sock(sk);
274 sock_put(sk); 262
263 /* Release the asoc/ep ref we took in the lookup calls. */
264 if (asoc)
265 sctp_association_put(asoc);
266 else
267 sctp_endpoint_put(ep);
275 268
276 return 0; 269 return 0;
277 270
@@ -280,8 +273,7 @@ discard_it:
280 return 0; 273 return 0;
281 274
282discard_release: 275discard_release:
283 /* Release any structures we may be holding. */ 276 /* Release the asoc/ep ref we took in the lookup calls. */
284 sock_put(sk);
285 if (asoc) 277 if (asoc)
286 sctp_association_put(asoc); 278 sctp_association_put(asoc);
287 else 279 else
@@ -290,56 +282,87 @@ discard_release:
290 goto discard_it; 282 goto discard_it;
291} 283}
292 284
293/* Handle second half of inbound skb processing. If the sock was busy, 285/* Process the backlog queue of the socket. Every skb on
294 * we may have need to delay processing until later when the sock is 286 * the backlog holds a ref on an association or endpoint.
295 * released (on the backlog). If not busy, we call this routine 287 * We hold this ref throughout the state machine to make
296 * directly from the bottom half. 288 * sure that the structure we need is still around.
297 */ 289 */
298int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb) 290int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb)
299{ 291{
300 struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk; 292 struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk;
301 struct sctp_inq *inqueue = NULL; 293 struct sctp_inq *inqueue = &chunk->rcvr->inqueue;
302 struct sctp_ep_common *rcvr = NULL; 294 struct sctp_ep_common *rcvr = NULL;
295 int backloged = 0;
303 296
304 rcvr = chunk->rcvr; 297 rcvr = chunk->rcvr;
305 298
306 BUG_TRAP(rcvr->sk == sk); 299 /* If the rcvr is dead then the association or endpoint
307 300 * has been deleted and we can safely drop the chunk
308 if (rcvr->dead) { 301 * and refs that we are holding.
309 sctp_chunk_free(chunk); 302 */
310 } else { 303 if (rcvr->dead) {
311 inqueue = &chunk->rcvr->inqueue; 304 sctp_chunk_free(chunk);
312 sctp_inq_push(inqueue, chunk); 305 goto done;
313 } 306 }
314 307
315 /* Release the asoc/ep ref we took in the lookup calls in sctp_rcv. */ 308 if (unlikely(rcvr->sk != sk)) {
316 if (SCTP_EP_TYPE_ASSOCIATION == rcvr->type) 309 /* In this case, the association moved from one socket to
317 sctp_association_put(sctp_assoc(rcvr)); 310 * another. We are currently sitting on the backlog of the
318 else 311 * old socket, so we need to move.
319 sctp_endpoint_put(sctp_ep(rcvr)); 312 * However, since we are here in the process context we
320 313 * need to take make sure that the user doesn't own
314 * the new socket when we process the packet.
315 * If the new socket is user-owned, queue the chunk to the
316 * backlog of the new socket without dropping any refs.
317 * Otherwise, we can safely push the chunk on the inqueue.
318 */
319
320 sk = rcvr->sk;
321 sctp_bh_lock_sock(sk);
322
323 if (sock_owned_by_user(sk)) {
324 sk_add_backlog(sk, skb);
325 backloged = 1;
326 } else
327 sctp_inq_push(inqueue, chunk);
328
329 sctp_bh_unlock_sock(sk);
330
331 /* If the chunk was backloged again, don't drop refs */
332 if (backloged)
333 return 0;
334 } else {
335 sctp_inq_push(inqueue, chunk);
336 }
337
338done:
339 /* Release the refs we took in sctp_add_backlog */
340 if (SCTP_EP_TYPE_ASSOCIATION == rcvr->type)
341 sctp_association_put(sctp_assoc(rcvr));
342 else if (SCTP_EP_TYPE_SOCKET == rcvr->type)
343 sctp_endpoint_put(sctp_ep(rcvr));
344 else
345 BUG();
346
321 return 0; 347 return 0;
322} 348}
323 349
324void sctp_backlog_migrate(struct sctp_association *assoc, 350static void sctp_add_backlog(struct sock *sk, struct sk_buff *skb)
325 struct sock *oldsk, struct sock *newsk)
326{ 351{
327 struct sk_buff *skb; 352 struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk;
328 struct sctp_chunk *chunk; 353 struct sctp_ep_common *rcvr = chunk->rcvr;
329 354
330 skb = oldsk->sk_backlog.head; 355 /* Hold the assoc/ep while hanging on the backlog queue.
331 oldsk->sk_backlog.head = oldsk->sk_backlog.tail = NULL; 356 * This way, we know structures we need will not disappear from us
332 while (skb != NULL) { 357 */
333 struct sk_buff *next = skb->next; 358 if (SCTP_EP_TYPE_ASSOCIATION == rcvr->type)
334 359 sctp_association_hold(sctp_assoc(rcvr));
335 chunk = SCTP_INPUT_CB(skb)->chunk; 360 else if (SCTP_EP_TYPE_SOCKET == rcvr->type)
336 skb->next = NULL; 361 sctp_endpoint_hold(sctp_ep(rcvr));
337 if (&assoc->base == chunk->rcvr) 362 else
338 sk_add_backlog(newsk, skb); 363 BUG();
339 else 364
340 sk_add_backlog(oldsk, skb); 365 sk_add_backlog(sk, skb);
341 skb = next;
342 }
343} 366}
344 367
345/* Handle icmp frag needed error. */ 368/* Handle icmp frag needed error. */
@@ -412,7 +435,7 @@ struct sock *sctp_err_lookup(int family, struct sk_buff *skb,
412 union sctp_addr daddr; 435 union sctp_addr daddr;
413 struct sctp_af *af; 436 struct sctp_af *af;
414 struct sock *sk = NULL; 437 struct sock *sk = NULL;
415 struct sctp_association *asoc = NULL; 438 struct sctp_association *asoc;
416 struct sctp_transport *transport = NULL; 439 struct sctp_transport *transport = NULL;
417 440
418 *app = NULL; *tpp = NULL; 441 *app = NULL; *tpp = NULL;
@@ -453,7 +476,6 @@ struct sock *sctp_err_lookup(int family, struct sk_buff *skb,
453 return sk; 476 return sk;
454 477
455out: 478out:
456 sock_put(sk);
457 if (asoc) 479 if (asoc)
458 sctp_association_put(asoc); 480 sctp_association_put(asoc);
459 return NULL; 481 return NULL;
@@ -463,7 +485,6 @@ out:
463void sctp_err_finish(struct sock *sk, struct sctp_association *asoc) 485void sctp_err_finish(struct sock *sk, struct sctp_association *asoc)
464{ 486{
465 sctp_bh_unlock_sock(sk); 487 sctp_bh_unlock_sock(sk);
466 sock_put(sk);
467 if (asoc) 488 if (asoc)
468 sctp_association_put(asoc); 489 sctp_association_put(asoc);
469} 490}
@@ -490,7 +511,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
490 int type = skb->h.icmph->type; 511 int type = skb->h.icmph->type;
491 int code = skb->h.icmph->code; 512 int code = skb->h.icmph->code;
492 struct sock *sk; 513 struct sock *sk;
493 struct sctp_association *asoc; 514 struct sctp_association *asoc = NULL;
494 struct sctp_transport *transport; 515 struct sctp_transport *transport;
495 struct inet_sock *inet; 516 struct inet_sock *inet;
496 char *saveip, *savesctp; 517 char *saveip, *savesctp;
@@ -716,7 +737,6 @@ static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *l
716 737
717hit: 738hit:
718 sctp_endpoint_hold(ep); 739 sctp_endpoint_hold(ep);
719 sock_hold(epb->sk);
720 read_unlock(&head->lock); 740 read_unlock(&head->lock);
721 return ep; 741 return ep;
722} 742}
@@ -818,7 +838,6 @@ static struct sctp_association *__sctp_lookup_association(
818hit: 838hit:
819 *pt = transport; 839 *pt = transport;
820 sctp_association_hold(asoc); 840 sctp_association_hold(asoc);
821 sock_hold(epb->sk);
822 read_unlock(&head->lock); 841 read_unlock(&head->lock);
823 return asoc; 842 return asoc;
824} 843}
@@ -846,7 +865,6 @@ int sctp_has_association(const union sctp_addr *laddr,
846 struct sctp_transport *transport; 865 struct sctp_transport *transport;
847 866
848 if ((asoc = sctp_lookup_association(laddr, paddr, &transport))) { 867 if ((asoc = sctp_lookup_association(laddr, paddr, &transport))) {
849 sock_put(asoc->base.sk);
850 sctp_association_put(asoc); 868 sctp_association_put(asoc);
851 return 1; 869 return 1;
852 } 870 }
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 8d1dc24bab4c..c5beb2ad7ef7 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -498,10 +498,6 @@ static void sctp_cmd_assoc_failed(sctp_cmd_seq_t *commands,
498 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, 498 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
499 SCTP_STATE(SCTP_STATE_CLOSED)); 499 SCTP_STATE(SCTP_STATE_CLOSED));
500 500
501 /* Set sk_err to ECONNRESET on a 1-1 style socket. */
502 if (!sctp_style(asoc->base.sk, UDP))
503 asoc->base.sk->sk_err = ECONNRESET;
504
505 /* SEND_FAILED sent later when cleaning up the association. */ 501 /* SEND_FAILED sent later when cleaning up the association. */
506 asoc->outqueue.error = error; 502 asoc->outqueue.error = error;
507 sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL()); 503 sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL());
@@ -838,6 +834,15 @@ static void sctp_cmd_del_non_primary(struct sctp_association *asoc)
838 return; 834 return;
839} 835}
840 836
837/* Helper function to set sk_err on a 1-1 style socket. */
838static void sctp_cmd_set_sk_err(struct sctp_association *asoc, int error)
839{
840 struct sock *sk = asoc->base.sk;
841
842 if (!sctp_style(sk, UDP))
843 sk->sk_err = error;
844}
845
841/* These three macros allow us to pull the debugging code out of the 846/* These three macros allow us to pull the debugging code out of the
842 * main flow of sctp_do_sm() to keep attention focused on the real 847 * main flow of sctp_do_sm() to keep attention focused on the real
843 * functionality there. 848 * functionality there.
@@ -1458,6 +1463,9 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
1458 local_cork = 0; 1463 local_cork = 0;
1459 asoc->peer.retran_path = t; 1464 asoc->peer.retran_path = t;
1460 break; 1465 break;
1466 case SCTP_CMD_SET_SK_ERR:
1467 sctp_cmd_set_sk_err(asoc, cmd->obj.error);
1468 break;
1461 default: 1469 default:
1462 printk(KERN_WARNING "Impossible command: %u, %p\n", 1470 printk(KERN_WARNING "Impossible command: %u, %p\n",
1463 cmd->verb, cmd->obj.ptr); 1471 cmd->verb, cmd->obj.ptr);
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 8cdba51ec076..8bc279219a72 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -93,7 +93,7 @@ static sctp_disposition_t sctp_sf_shut_8_4_5(const struct sctp_endpoint *ep,
93static struct sctp_sackhdr *sctp_sm_pull_sack(struct sctp_chunk *chunk); 93static struct sctp_sackhdr *sctp_sm_pull_sack(struct sctp_chunk *chunk);
94 94
95static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands, 95static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands,
96 __u16 error, 96 __u16 error, int sk_err,
97 const struct sctp_association *asoc, 97 const struct sctp_association *asoc,
98 struct sctp_transport *transport); 98 struct sctp_transport *transport);
99 99
@@ -448,7 +448,7 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep,
448 __u32 init_tag; 448 __u32 init_tag;
449 struct sctp_chunk *err_chunk; 449 struct sctp_chunk *err_chunk;
450 struct sctp_packet *packet; 450 struct sctp_packet *packet;
451 sctp_disposition_t ret; 451 __u16 error;
452 452
453 if (!sctp_vtag_verify(chunk, asoc)) 453 if (!sctp_vtag_verify(chunk, asoc))
454 return sctp_sf_pdiscard(ep, asoc, type, arg, commands); 454 return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
@@ -480,11 +480,9 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep,
480 goto nomem; 480 goto nomem;
481 481
482 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(reply)); 482 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(reply));
483 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, 483 return sctp_stop_t1_and_abort(commands, SCTP_ERROR_INV_PARAM,
484 SCTP_STATE(SCTP_STATE_CLOSED)); 484 ECONNREFUSED, asoc,
485 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 485 chunk->transport);
486 sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL());
487 return SCTP_DISPOSITION_DELETE_TCB;
488 } 486 }
489 487
490 /* Verify the INIT chunk before processing it. */ 488 /* Verify the INIT chunk before processing it. */
@@ -511,27 +509,16 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep,
511 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, 509 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT,
512 SCTP_PACKET(packet)); 510 SCTP_PACKET(packet));
513 SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); 511 SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS);
514 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, 512 error = SCTP_ERROR_INV_PARAM;
515 SCTP_STATE(SCTP_STATE_CLOSED));
516 sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB,
517 SCTP_NULL());
518 return SCTP_DISPOSITION_CONSUME;
519 } else { 513 } else {
520 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, 514 error = SCTP_ERROR_NO_RESOURCE;
521 SCTP_STATE(SCTP_STATE_CLOSED));
522 sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB,
523 SCTP_NULL());
524 return SCTP_DISPOSITION_NOMEM;
525 } 515 }
526 } else { 516 } else {
527 ret = sctp_sf_tabort_8_4_8(ep, asoc, type, arg, 517 sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands);
528 commands); 518 error = SCTP_ERROR_INV_PARAM;
529 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
530 SCTP_STATE(SCTP_STATE_CLOSED));
531 sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB,
532 SCTP_NULL());
533 return ret;
534 } 519 }
520 return sctp_stop_t1_and_abort(commands, error, ECONNREFUSED,
521 asoc, chunk->transport);
535 } 522 }
536 523
537 /* Tag the variable length parameters. Note that we never 524 /* Tag the variable length parameters. Note that we never
@@ -886,6 +873,8 @@ sctp_disposition_t sctp_sf_sendbeat_8_3(const struct sctp_endpoint *ep,
886 struct sctp_transport *transport = (struct sctp_transport *) arg; 873 struct sctp_transport *transport = (struct sctp_transport *) arg;
887 874
888 if (asoc->overall_error_count >= asoc->max_retrans) { 875 if (asoc->overall_error_count >= asoc->max_retrans) {
876 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
877 SCTP_ERROR(ETIMEDOUT));
889 /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ 878 /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */
890 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 879 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
891 SCTP_U32(SCTP_ERROR_NO_ERROR)); 880 SCTP_U32(SCTP_ERROR_NO_ERROR));
@@ -1030,6 +1019,12 @@ sctp_disposition_t sctp_sf_backbeat_8_3(const struct sctp_endpoint *ep,
1030 commands); 1019 commands);
1031 1020
1032 hbinfo = (sctp_sender_hb_info_t *) chunk->skb->data; 1021 hbinfo = (sctp_sender_hb_info_t *) chunk->skb->data;
1022 /* Make sure that the length of the parameter is what we expect */
1023 if (ntohs(hbinfo->param_hdr.length) !=
1024 sizeof(sctp_sender_hb_info_t)) {
1025 return SCTP_DISPOSITION_DISCARD;
1026 }
1027
1033 from_addr = hbinfo->daddr; 1028 from_addr = hbinfo->daddr;
1034 link = sctp_assoc_lookup_paddr(asoc, &from_addr); 1029 link = sctp_assoc_lookup_paddr(asoc, &from_addr);
1035 1030
@@ -2126,6 +2121,8 @@ static sctp_disposition_t sctp_sf_do_5_2_6_stale(const struct sctp_endpoint *ep,
2126 int attempts = asoc->init_err_counter + 1; 2121 int attempts = asoc->init_err_counter + 1;
2127 2122
2128 if (attempts > asoc->max_init_attempts) { 2123 if (attempts > asoc->max_init_attempts) {
2124 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
2125 SCTP_ERROR(ETIMEDOUT));
2129 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED, 2126 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
2130 SCTP_U32(SCTP_ERROR_STALE_COOKIE)); 2127 SCTP_U32(SCTP_ERROR_STALE_COOKIE));
2131 return SCTP_DISPOSITION_DELETE_TCB; 2128 return SCTP_DISPOSITION_DELETE_TCB;
@@ -2262,6 +2259,7 @@ sctp_disposition_t sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep,
2262 if (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_errhdr)) 2259 if (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_errhdr))
2263 error = ((sctp_errhdr_t *)chunk->skb->data)->cause; 2260 error = ((sctp_errhdr_t *)chunk->skb->data)->cause;
2264 2261
2262 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(ECONNRESET));
2265 /* ASSOC_FAILED will DELETE_TCB. */ 2263 /* ASSOC_FAILED will DELETE_TCB. */
2266 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, SCTP_U32(error)); 2264 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, SCTP_U32(error));
2267 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 2265 SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
@@ -2306,7 +2304,8 @@ sctp_disposition_t sctp_sf_cookie_wait_abort(const struct sctp_endpoint *ep,
2306 if (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_errhdr)) 2304 if (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_errhdr))
2307 error = ((sctp_errhdr_t *)chunk->skb->data)->cause; 2305 error = ((sctp_errhdr_t *)chunk->skb->data)->cause;
2308 2306
2309 return sctp_stop_t1_and_abort(commands, error, asoc, chunk->transport); 2307 return sctp_stop_t1_and_abort(commands, error, ECONNREFUSED, asoc,
2308 chunk->transport);
2310} 2309}
2311 2310
2312/* 2311/*
@@ -2318,7 +2317,8 @@ sctp_disposition_t sctp_sf_cookie_wait_icmp_abort(const struct sctp_endpoint *ep
2318 void *arg, 2317 void *arg,
2319 sctp_cmd_seq_t *commands) 2318 sctp_cmd_seq_t *commands)
2320{ 2319{
2321 return sctp_stop_t1_and_abort(commands, SCTP_ERROR_NO_ERROR, asoc, 2320 return sctp_stop_t1_and_abort(commands, SCTP_ERROR_NO_ERROR,
2321 ENOPROTOOPT, asoc,
2322 (struct sctp_transport *)arg); 2322 (struct sctp_transport *)arg);
2323} 2323}
2324 2324
@@ -2343,7 +2343,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_abort(const struct sctp_endpoint *ep,
2343 * This is common code called by several sctp_sf_*_abort() functions above. 2343 * This is common code called by several sctp_sf_*_abort() functions above.
2344 */ 2344 */
2345static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands, 2345static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands,
2346 __u16 error, 2346 __u16 error, int sk_err,
2347 const struct sctp_association *asoc, 2347 const struct sctp_association *asoc,
2348 struct sctp_transport *transport) 2348 struct sctp_transport *transport)
2349{ 2349{
@@ -2353,6 +2353,7 @@ static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands,
2353 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 2353 SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
2354 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, 2354 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
2355 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT)); 2355 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT));
2356 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(sk_err));
2356 /* CMD_INIT_FAILED will DELETE_TCB. */ 2357 /* CMD_INIT_FAILED will DELETE_TCB. */
2357 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED, 2358 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
2358 SCTP_U32(error)); 2359 SCTP_U32(error));
@@ -3336,6 +3337,8 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep,
3336 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, 3337 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
3337 SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO)); 3338 SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO));
3338 sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET,SCTP_NULL()); 3339 sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET,SCTP_NULL());
3340 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
3341 SCTP_ERROR(ECONNABORTED));
3339 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 3342 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
3340 SCTP_U32(SCTP_ERROR_ASCONF_ACK)); 3343 SCTP_U32(SCTP_ERROR_ASCONF_ACK));
3341 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 3344 SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
@@ -3362,6 +3365,8 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep,
3362 * processing the rest of the chunks in the packet. 3365 * processing the rest of the chunks in the packet.
3363 */ 3366 */
3364 sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET,SCTP_NULL()); 3367 sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET,SCTP_NULL());
3368 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
3369 SCTP_ERROR(ECONNABORTED));
3365 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 3370 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
3366 SCTP_U32(SCTP_ERROR_ASCONF_ACK)); 3371 SCTP_U32(SCTP_ERROR_ASCONF_ACK));
3367 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 3372 SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
@@ -3714,9 +3719,13 @@ static sctp_disposition_t sctp_sf_violation_chunklen(
3714 if (asoc->state <= SCTP_STATE_COOKIE_ECHOED) { 3719 if (asoc->state <= SCTP_STATE_COOKIE_ECHOED) {
3715 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, 3720 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
3716 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT)); 3721 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT));
3722 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
3723 SCTP_ERROR(ECONNREFUSED));
3717 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED, 3724 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
3718 SCTP_U32(SCTP_ERROR_PROTO_VIOLATION)); 3725 SCTP_U32(SCTP_ERROR_PROTO_VIOLATION));
3719 } else { 3726 } else {
3727 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
3728 SCTP_ERROR(ECONNABORTED));
3720 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 3729 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
3721 SCTP_U32(SCTP_ERROR_PROTO_VIOLATION)); 3730 SCTP_U32(SCTP_ERROR_PROTO_VIOLATION));
3722 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 3731 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB);
@@ -4034,6 +4043,8 @@ sctp_disposition_t sctp_sf_do_9_1_prm_abort(
4034 * TCB. This is a departure from our typical NOMEM handling. 4043 * TCB. This is a departure from our typical NOMEM handling.
4035 */ 4044 */
4036 4045
4046 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
4047 SCTP_ERROR(ECONNABORTED));
4037 /* Delete the established association. */ 4048 /* Delete the established association. */
4038 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 4049 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
4039 SCTP_U32(SCTP_ERROR_USER_ABORT)); 4050 SCTP_U32(SCTP_ERROR_USER_ABORT));
@@ -4175,6 +4186,8 @@ sctp_disposition_t sctp_sf_cookie_wait_prm_abort(
4175 * TCB. This is a departure from our typical NOMEM handling. 4186 * TCB. This is a departure from our typical NOMEM handling.
4176 */ 4187 */
4177 4188
4189 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
4190 SCTP_ERROR(ECONNREFUSED));
4178 /* Delete the established association. */ 4191 /* Delete the established association. */
4179 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED, 4192 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
4180 SCTP_U32(SCTP_ERROR_USER_ABORT)); 4193 SCTP_U32(SCTP_ERROR_USER_ABORT));
@@ -4543,6 +4556,8 @@ sctp_disposition_t sctp_sf_do_6_3_3_rtx(const struct sctp_endpoint *ep,
4543 struct sctp_transport *transport = arg; 4556 struct sctp_transport *transport = arg;
4544 4557
4545 if (asoc->overall_error_count >= asoc->max_retrans) { 4558 if (asoc->overall_error_count >= asoc->max_retrans) {
4559 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
4560 SCTP_ERROR(ETIMEDOUT));
4546 /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ 4561 /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */
4547 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 4562 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
4548 SCTP_U32(SCTP_ERROR_NO_ERROR)); 4563 SCTP_U32(SCTP_ERROR_NO_ERROR));
@@ -4662,6 +4677,8 @@ sctp_disposition_t sctp_sf_t1_init_timer_expire(const struct sctp_endpoint *ep,
4662 SCTP_DEBUG_PRINTK("Giving up on INIT, attempts: %d" 4677 SCTP_DEBUG_PRINTK("Giving up on INIT, attempts: %d"
4663 " max_init_attempts: %d\n", 4678 " max_init_attempts: %d\n",
4664 attempts, asoc->max_init_attempts); 4679 attempts, asoc->max_init_attempts);
4680 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
4681 SCTP_ERROR(ETIMEDOUT));
4665 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED, 4682 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
4666 SCTP_U32(SCTP_ERROR_NO_ERROR)); 4683 SCTP_U32(SCTP_ERROR_NO_ERROR));
4667 return SCTP_DISPOSITION_DELETE_TCB; 4684 return SCTP_DISPOSITION_DELETE_TCB;
@@ -4711,6 +4728,8 @@ sctp_disposition_t sctp_sf_t1_cookie_timer_expire(const struct sctp_endpoint *ep
4711 4728
4712 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl)); 4729 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl));
4713 } else { 4730 } else {
4731 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
4732 SCTP_ERROR(ETIMEDOUT));
4714 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED, 4733 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
4715 SCTP_U32(SCTP_ERROR_NO_ERROR)); 4734 SCTP_U32(SCTP_ERROR_NO_ERROR));
4716 return SCTP_DISPOSITION_DELETE_TCB; 4735 return SCTP_DISPOSITION_DELETE_TCB;
@@ -4742,6 +4761,8 @@ sctp_disposition_t sctp_sf_t2_timer_expire(const struct sctp_endpoint *ep,
4742 4761
4743 SCTP_DEBUG_PRINTK("Timer T2 expired.\n"); 4762 SCTP_DEBUG_PRINTK("Timer T2 expired.\n");
4744 if (asoc->overall_error_count >= asoc->max_retrans) { 4763 if (asoc->overall_error_count >= asoc->max_retrans) {
4764 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
4765 SCTP_ERROR(ETIMEDOUT));
4745 /* Note: CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ 4766 /* Note: CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */
4746 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 4767 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
4747 SCTP_U32(SCTP_ERROR_NO_ERROR)); 4768 SCTP_U32(SCTP_ERROR_NO_ERROR));
@@ -4817,6 +4838,8 @@ sctp_disposition_t sctp_sf_t4_timer_expire(
4817 if (asoc->overall_error_count >= asoc->max_retrans) { 4838 if (asoc->overall_error_count >= asoc->max_retrans) {
4818 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, 4839 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
4819 SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO)); 4840 SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO));
4841 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
4842 SCTP_ERROR(ETIMEDOUT));
4820 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 4843 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
4821 SCTP_U32(SCTP_ERROR_NO_ERROR)); 4844 SCTP_U32(SCTP_ERROR_NO_ERROR));
4822 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 4845 SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
@@ -4870,6 +4893,8 @@ sctp_disposition_t sctp_sf_t5_timer_expire(const struct sctp_endpoint *ep,
4870 goto nomem; 4893 goto nomem;
4871 4894
4872 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(reply)); 4895 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(reply));
4896 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
4897 SCTP_ERROR(ETIMEDOUT));
4873 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 4898 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
4874 SCTP_U32(SCTP_ERROR_NO_ERROR)); 4899 SCTP_U32(SCTP_ERROR_NO_ERROR));
4875 4900
@@ -5309,6 +5334,8 @@ static int sctp_eat_data(const struct sctp_association *asoc,
5309 * processing the rest of the chunks in the packet. 5334 * processing the rest of the chunks in the packet.
5310 */ 5335 */
5311 sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET,SCTP_NULL()); 5336 sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET,SCTP_NULL());
5337 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
5338 SCTP_ERROR(ECONNABORTED));
5312 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 5339 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
5313 SCTP_U32(SCTP_ERROR_NO_DATA)); 5340 SCTP_U32(SCTP_ERROR_NO_DATA));
5314 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 5341 SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index b6e4b89539b3..174d4d35e951 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1057,6 +1057,7 @@ static int __sctp_connect(struct sock* sk,
1057 inet_sk(sk)->dport = htons(asoc->peer.port); 1057 inet_sk(sk)->dport = htons(asoc->peer.port);
1058 af = sctp_get_af_specific(to.sa.sa_family); 1058 af = sctp_get_af_specific(to.sa.sa_family);
1059 af->to_sk_daddr(&to, sk); 1059 af->to_sk_daddr(&to, sk);
1060 sk->sk_err = 0;
1060 1061
1061 timeo = sock_sndtimeo(sk, sk->sk_socket->file->f_flags & O_NONBLOCK); 1062 timeo = sock_sndtimeo(sk, sk->sk_socket->file->f_flags & O_NONBLOCK);
1062 err = sctp_wait_for_connect(asoc, &timeo); 1063 err = sctp_wait_for_connect(asoc, &timeo);
@@ -1228,7 +1229,7 @@ SCTP_STATIC void sctp_close(struct sock *sk, long timeout)
1228 1229
1229 ep = sctp_sk(sk)->ep; 1230 ep = sctp_sk(sk)->ep;
1230 1231
1231 /* Walk all associations on a socket, not on an endpoint. */ 1232 /* Walk all associations on an endpoint. */
1232 list_for_each_safe(pos, temp, &ep->asocs) { 1233 list_for_each_safe(pos, temp, &ep->asocs) {
1233 asoc = list_entry(pos, struct sctp_association, asocs); 1234 asoc = list_entry(pos, struct sctp_association, asocs);
1234 1235
@@ -1241,13 +1242,13 @@ SCTP_STATIC void sctp_close(struct sock *sk, long timeout)
1241 if (sctp_state(asoc, CLOSED)) { 1242 if (sctp_state(asoc, CLOSED)) {
1242 sctp_unhash_established(asoc); 1243 sctp_unhash_established(asoc);
1243 sctp_association_free(asoc); 1244 sctp_association_free(asoc);
1245 continue;
1246 }
1247 }
1244 1248
1245 } else if (sock_flag(sk, SOCK_LINGER) && 1249 if (sock_flag(sk, SOCK_LINGER) && !sk->sk_lingertime)
1246 !sk->sk_lingertime) 1250 sctp_primitive_ABORT(asoc, NULL);
1247 sctp_primitive_ABORT(asoc, NULL); 1251 else
1248 else
1249 sctp_primitive_SHUTDOWN(asoc, NULL);
1250 } else
1251 sctp_primitive_SHUTDOWN(asoc, NULL); 1252 sctp_primitive_SHUTDOWN(asoc, NULL);
1252 } 1253 }
1253 1254
@@ -5317,6 +5318,7 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
5317 */ 5318 */
5318 sctp_release_sock(sk); 5319 sctp_release_sock(sk);
5319 current_timeo = schedule_timeout(current_timeo); 5320 current_timeo = schedule_timeout(current_timeo);
5321 BUG_ON(sk != asoc->base.sk);
5320 sctp_lock_sock(sk); 5322 sctp_lock_sock(sk);
5321 5323
5322 *timeo_p = current_timeo; 5324 *timeo_p = current_timeo;
@@ -5604,12 +5606,14 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
5604 */ 5606 */
5605 newsp->type = type; 5607 newsp->type = type;
5606 5608
5607 spin_lock_bh(&oldsk->sk_lock.slock); 5609 /* Mark the new socket "in-use" by the user so that any packets
5608 /* Migrate the backlog from oldsk to newsk. */ 5610 * that may arrive on the association after we've moved it are
5609 sctp_backlog_migrate(assoc, oldsk, newsk); 5611 * queued to the backlog. This prevents a potential race between
5610 /* Migrate the association to the new socket. */ 5612 * backlog processing on the old socket and new-packet processing
5613 * on the new socket.
5614 */
5615 sctp_lock_sock(newsk);
5611 sctp_assoc_migrate(assoc, newsk); 5616 sctp_assoc_migrate(assoc, newsk);
5612 spin_unlock_bh(&oldsk->sk_lock.slock);
5613 5617
5614 /* If the association on the newsk is already closed before accept() 5618 /* If the association on the newsk is already closed before accept()
5615 * is called, set RCV_SHUTDOWN flag. 5619 * is called, set RCV_SHUTDOWN flag.
@@ -5618,6 +5622,7 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
5618 newsk->sk_shutdown |= RCV_SHUTDOWN; 5622 newsk->sk_shutdown |= RCV_SHUTDOWN;
5619 5623
5620 newsk->sk_state = SCTP_SS_ESTABLISHED; 5624 newsk->sk_state = SCTP_SS_ESTABLISHED;
5625 sctp_release_sock(newsk);
5621} 5626}
5622 5627
5623/* This proto struct describes the ULP interface for SCTP. */ 5628/* This proto struct describes the ULP interface for SCTP. */
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 3ac4193a78ed..7026b0866b7b 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -159,6 +159,7 @@ struct cache_head *sunrpc_cache_update(struct cache_detail *detail,
159 detail->update(tmp, new); 159 detail->update(tmp, new);
160 tmp->next = *head; 160 tmp->next = *head;
161 *head = tmp; 161 *head = tmp;
162 detail->entries++;
162 cache_get(tmp); 163 cache_get(tmp);
163 is_new = cache_fresh_locked(tmp, new->expiry_time); 164 is_new = cache_fresh_locked(tmp, new->expiry_time);
164 cache_fresh_locked(old, 0); 165 cache_fresh_locked(old, 0);
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index b54971059f16..891a6090cc09 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -62,7 +62,7 @@ int xfrm_parse_spi(struct sk_buff *skb, u8 nexthdr, u32 *spi, u32 *seq)
62 case IPPROTO_COMP: 62 case IPPROTO_COMP:
63 if (!pskb_may_pull(skb, sizeof(struct ip_comp_hdr))) 63 if (!pskb_may_pull(skb, sizeof(struct ip_comp_hdr)))
64 return -EINVAL; 64 return -EINVAL;
65 *spi = ntohl(ntohs(*(u16*)(skb->h.raw + 2))); 65 *spi = htonl(ntohs(*(u16*)(skb->h.raw + 2)));
66 *seq = 0; 66 *seq = 0;
67 return 0; 67 return 0;
68 default: 68 default:
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 6d04504b2fc1..d0f86ed43f7a 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -697,29 +697,79 @@ static void check_sec_ref(struct module *mod, const char *modname,
697 697
698 /* Walk through all sections */ 698 /* Walk through all sections */
699 for (i = 0; i < hdr->e_shnum; i++) { 699 for (i = 0; i < hdr->e_shnum; i++) {
700 Elf_Rela *rela; 700 const char *name = secstrings + sechdrs[i].sh_name;
701 Elf_Rela *start = (void *)hdr + sechdrs[i].sh_offset; 701 const char *secname;
702 Elf_Rela *stop = (void*)start + sechdrs[i].sh_size; 702 Elf_Rela r;
703 const char *name = secstrings + sechdrs[i].sh_name + 703 unsigned int r_sym;
704 strlen(".rela");
705 /* We want to process only relocation sections and not .init */ 704 /* We want to process only relocation sections and not .init */
706 if (section_ref_ok(name) || (sechdrs[i].sh_type != SHT_RELA)) 705 if (sechdrs[i].sh_type == SHT_RELA) {
707 continue; 706 Elf_Rela *rela;
707 Elf_Rela *start = (void *)hdr + sechdrs[i].sh_offset;
708 Elf_Rela *stop = (void*)start + sechdrs[i].sh_size;
709 name += strlen(".rela");
710 if (section_ref_ok(name))
711 continue;
708 712
709 for (rela = start; rela < stop; rela++) { 713 for (rela = start; rela < stop; rela++) {
710 Elf_Rela r; 714 r.r_offset = TO_NATIVE(rela->r_offset);
711 const char *secname; 715#if KERNEL_ELFCLASS == ELFCLASS64
712 r.r_offset = TO_NATIVE(rela->r_offset); 716 if (hdr->e_machine == EM_MIPS) {
713 r.r_info = TO_NATIVE(rela->r_info); 717 r_sym = ELF64_MIPS_R_SYM(rela->r_info);
714 r.r_addend = TO_NATIVE(rela->r_addend); 718 r_sym = TO_NATIVE(r_sym);
715 sym = elf->symtab_start + ELF_R_SYM(r.r_info); 719 } else {
716 /* Skip special sections */ 720 r.r_info = TO_NATIVE(rela->r_info);
717 if (sym->st_shndx >= SHN_LORESERVE) 721 r_sym = ELF_R_SYM(r.r_info);
722 }
723#else
724 r.r_info = TO_NATIVE(rela->r_info);
725 r_sym = ELF_R_SYM(r.r_info);
726#endif
727 r.r_addend = TO_NATIVE(rela->r_addend);
728 sym = elf->symtab_start + r_sym;
729 /* Skip special sections */
730 if (sym->st_shndx >= SHN_LORESERVE)
731 continue;
732
733 secname = secstrings +
734 sechdrs[sym->st_shndx].sh_name;
735 if (section(secname))
736 warn_sec_mismatch(modname, name,
737 elf, sym, r);
738 }
739 } else if (sechdrs[i].sh_type == SHT_REL) {
740 Elf_Rel *rel;
741 Elf_Rel *start = (void *)hdr + sechdrs[i].sh_offset;
742 Elf_Rel *stop = (void*)start + sechdrs[i].sh_size;
743 name += strlen(".rel");
744 if (section_ref_ok(name))
718 continue; 745 continue;
719 746
720 secname = secstrings + sechdrs[sym->st_shndx].sh_name; 747 for (rel = start; rel < stop; rel++) {
721 if (section(secname)) 748 r.r_offset = TO_NATIVE(rel->r_offset);
722 warn_sec_mismatch(modname, name, elf, sym, r); 749#if KERNEL_ELFCLASS == ELFCLASS64
750 if (hdr->e_machine == EM_MIPS) {
751 r_sym = ELF64_MIPS_R_SYM(rel->r_info);
752 r_sym = TO_NATIVE(r_sym);
753 } else {
754 r.r_info = TO_NATIVE(rel->r_info);
755 r_sym = ELF_R_SYM(r.r_info);
756 }
757#else
758 r.r_info = TO_NATIVE(rel->r_info);
759 r_sym = ELF_R_SYM(r.r_info);
760#endif
761 r.r_addend = 0;
762 sym = elf->symtab_start + r_sym;
763 /* Skip special sections */
764 if (sym->st_shndx >= SHN_LORESERVE)
765 continue;
766
767 secname = secstrings +
768 sechdrs[sym->st_shndx].sh_name;
769 if (section(secname))
770 warn_sec_mismatch(modname, name,
771 elf, sym, r);
772 }
723 } 773 }
724 } 774 }
725} 775}
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index b14255c72a37..861d866fcd83 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -21,6 +21,7 @@
21#define ELF_ST_BIND ELF32_ST_BIND 21#define ELF_ST_BIND ELF32_ST_BIND
22#define ELF_ST_TYPE ELF32_ST_TYPE 22#define ELF_ST_TYPE ELF32_ST_TYPE
23 23
24#define Elf_Rel Elf32_Rel
24#define Elf_Rela Elf32_Rela 25#define Elf_Rela Elf32_Rela
25#define ELF_R_SYM ELF32_R_SYM 26#define ELF_R_SYM ELF32_R_SYM
26#define ELF_R_TYPE ELF32_R_TYPE 27#define ELF_R_TYPE ELF32_R_TYPE
@@ -34,11 +35,31 @@
34#define ELF_ST_BIND ELF64_ST_BIND 35#define ELF_ST_BIND ELF64_ST_BIND
35#define ELF_ST_TYPE ELF64_ST_TYPE 36#define ELF_ST_TYPE ELF64_ST_TYPE
36 37
38#define Elf_Rel Elf64_Rel
37#define Elf_Rela Elf64_Rela 39#define Elf_Rela Elf64_Rela
38#define ELF_R_SYM ELF64_R_SYM 40#define ELF_R_SYM ELF64_R_SYM
39#define ELF_R_TYPE ELF64_R_TYPE 41#define ELF_R_TYPE ELF64_R_TYPE
40#endif 42#endif
41 43
44/* The 64-bit MIPS ELF ABI uses an unusual reloc format. */
45typedef struct
46{
47 Elf32_Word r_sym; /* Symbol index */
48 unsigned char r_ssym; /* Special symbol for 2nd relocation */
49 unsigned char r_type3; /* 3rd relocation type */
50 unsigned char r_type2; /* 2nd relocation type */
51 unsigned char r_type1; /* 1st relocation type */
52} _Elf64_Mips_R_Info;
53
54typedef union
55{
56 Elf64_Xword r_info_number;
57 _Elf64_Mips_R_Info r_info_fields;
58} _Elf64_Mips_R_Info_union;
59
60#define ELF64_MIPS_R_SYM(i) \
61 ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym)
62
42#if KERNEL_ELFDATA != HOST_ELFDATA 63#if KERNEL_ELFDATA != HOST_ELFDATA
43 64
44static inline void __endian(const void *src, void *dest, unsigned int size) 65static inline void __endian(const void *src, void *dest, unsigned int size)
@@ -48,8 +69,6 @@ static inline void __endian(const void *src, void *dest, unsigned int size)
48 ((unsigned char*)dest)[i] = ((unsigned char*)src)[size - i-1]; 69 ((unsigned char*)dest)[i] = ((unsigned char*)src)[size - i-1];
49} 70}
50 71
51
52
53#define TO_NATIVE(x) \ 72#define TO_NATIVE(x) \
54({ \ 73({ \
55 typeof(x) __x; \ 74 typeof(x) __x; \
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index d987048d3f33..21dad415b896 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3231,7 +3231,7 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
3231 goto out; 3231 goto out;
3232 3232
3233 /* Handle mapped IPv4 packets arriving via IPv6 sockets */ 3233 /* Handle mapped IPv4 packets arriving via IPv6 sockets */
3234 if (family == PF_INET6 && skb->protocol == ntohs(ETH_P_IP)) 3234 if (family == PF_INET6 && skb->protocol == htons(ETH_P_IP))
3235 family = PF_INET; 3235 family = PF_INET;
3236 3236
3237 read_lock_bh(&sk->sk_callback_lock); 3237 read_lock_bh(&sk->sk_callback_lock);
diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c
index da7ef26995c3..77b06009735d 100644
--- a/sound/drivers/mpu401/mpu401.c
+++ b/sound/drivers/mpu401/mpu401.c
@@ -151,7 +151,7 @@ static struct pnp_device_id snd_mpu401_pnpids[] = {
151 151
152MODULE_DEVICE_TABLE(pnp, snd_mpu401_pnpids); 152MODULE_DEVICE_TABLE(pnp, snd_mpu401_pnpids);
153 153
154static int __init snd_mpu401_pnp(int dev, struct pnp_dev *device, 154static int __devinit snd_mpu401_pnp(int dev, struct pnp_dev *device,
155 const struct pnp_device_id *id) 155 const struct pnp_device_id *id)
156{ 156{
157 if (!pnp_port_valid(device, 0) || 157 if (!pnp_port_valid(device, 0) ||
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c
index a36ec1daa5cb..e6945db8ed1b 100644
--- a/sound/isa/es18xx.c
+++ b/sound/isa/es18xx.c
@@ -85,6 +85,8 @@
85#include <linux/pnp.h> 85#include <linux/pnp.h>
86#include <linux/isapnp.h> 86#include <linux/isapnp.h>
87#include <linux/moduleparam.h> 87#include <linux/moduleparam.h>
88#include <linux/delay.h>
89
88#include <asm/io.h> 90#include <asm/io.h>
89#include <asm/dma.h> 91#include <asm/dma.h>
90#include <sound/core.h> 92#include <sound/core.h>
diff --git a/sound/oss/ad1848.c b/sound/oss/ad1848.c
index 49796be955f3..e04fa49b0dc8 100644
--- a/sound/oss/ad1848.c
+++ b/sound/oss/ad1848.c
@@ -2026,7 +2026,8 @@ int ad1848_init (char *name, struct resource *ports, int irq, int dma_playback,
2026 if (irq > 0) 2026 if (irq > 0)
2027 { 2027 {
2028 devc->dev_no = my_dev; 2028 devc->dev_no = my_dev;
2029 if (request_irq(devc->irq, adintr, 0, devc->name, (void *)my_dev) < 0) 2029 if (request_irq(devc->irq, adintr, 0, devc->name,
2030 (void *)(long)my_dev) < 0)
2030 { 2031 {
2031 printk(KERN_WARNING "ad1848: Unable to allocate IRQ\n"); 2032 printk(KERN_WARNING "ad1848: Unable to allocate IRQ\n");
2032 /* Don't free it either then.. */ 2033 /* Don't free it either then.. */
@@ -2175,7 +2176,7 @@ void ad1848_unload(int io_base, int irq, int dma_playback, int dma_capture, int
2175 if (!share_dma) 2176 if (!share_dma)
2176 { 2177 {
2177 if (devc->irq > 0) /* There is no point in freeing irq, if it wasn't allocated */ 2178 if (devc->irq > 0) /* There is no point in freeing irq, if it wasn't allocated */
2178 free_irq(devc->irq, (void *)devc->dev_no); 2179 free_irq(devc->irq, (void *)(long)devc->dev_no);
2179 2180
2180 sound_free_dma(dma_playback); 2181 sound_free_dma(dma_playback);
2181 2182
@@ -2204,7 +2205,7 @@ irqreturn_t adintr(int irq, void *dev_id, struct pt_regs *dummy)
2204 unsigned char c930_stat = 0; 2205 unsigned char c930_stat = 0;
2205 int cnt = 0; 2206 int cnt = 0;
2206 2207
2207 dev = (int)dev_id; 2208 dev = (long)dev_id;
2208 devc = (ad1848_info *) audio_devs[dev]->devc; 2209 devc = (ad1848_info *) audio_devs[dev]->devc;
2209 2210
2210interrupt_again: /* Jump back here if int status doesn't reset */ 2211interrupt_again: /* Jump back here if int status doesn't reset */
@@ -2900,7 +2901,8 @@ static struct pnp_dev *activate_dev(char *devname, char *resname, struct pnp_dev
2900 return(dev); 2901 return(dev);
2901} 2902}
2902 2903
2903static struct pnp_dev *ad1848_init_generic(struct pnp_card *bus, struct address_info *hw_config, int slot) 2904static struct pnp_dev __init *ad1848_init_generic(struct pnp_card *bus,
2905 struct address_info *hw_config, int slot)
2904{ 2906{
2905 2907
2906 /* Configure Audio device */ 2908 /* Configure Audio device */
diff --git a/sound/oss/nm256_audio.c b/sound/oss/nm256_audio.c
index 7de079b202f2..6e662ac009ae 100644
--- a/sound/oss/nm256_audio.c
+++ b/sound/oss/nm256_audio.c
@@ -960,7 +960,7 @@ static struct ac97_mixer_value_list mixer_defaults[] = {
960 960
961 961
962/* Installs the AC97 mixer into CARD. */ 962/* Installs the AC97 mixer into CARD. */
963static int __init 963static int __devinit
964nm256_install_mixer (struct nm256_info *card) 964nm256_install_mixer (struct nm256_info *card)
965{ 965{
966 int mixer; 966 int mixer;
@@ -995,7 +995,7 @@ nm256_install_mixer (struct nm256_info *card)
995 * RAM. 995 * RAM.
996 */ 996 */
997 997
998static void __init 998static void __devinit
999nm256_peek_for_sig (struct nm256_info *card) 999nm256_peek_for_sig (struct nm256_info *card)
1000{ 1000{
1001 u32 port1offset 1001 u32 port1offset
@@ -1056,7 +1056,7 @@ nm256_install(struct pci_dev *pcidev, enum nm256rev rev, char *verstr)
1056 card->playing = 0; 1056 card->playing = 0;
1057 card->recording = 0; 1057 card->recording = 0;
1058 card->rev = rev; 1058 card->rev = rev;
1059 spin_lock_init(&card->lock); 1059 spin_lock_init(&card->lock);
1060 1060
1061 /* Init the memory port info. */ 1061 /* Init the memory port info. */
1062 for (x = 0; x < 2; x++) { 1062 for (x = 0; x < 2; x++) {