aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Documentation/filesystems/vfs.txt3
-rw-r--r--Documentation/kbuild/makefiles.txt10
-rw-r--r--Documentation/kernel-parameters.txt38
-rw-r--r--Documentation/lguest/.gitignore1
-rw-r--r--Documentation/lguest/lguest.txt11
-rw-r--r--Documentation/spi/spi-summary6
-rw-r--r--MAINTAINERS30
-rw-r--r--Makefile2
-rw-r--r--arch/arm/kernel/sys_oabi-compat.c19
-rw-r--r--arch/arm/mach-at91/at91rm9200_time.c2
-rw-r--r--arch/arm/mach-at91/at91sam926x_time.c2
-rw-r--r--arch/arm/mach-davinci/time.c2
-rw-r--r--arch/arm/mach-imx/time.c2
-rw-r--r--arch/arm/mach-ixp4xx/common.c2
-rw-r--r--arch/arm/mach-msm/timer.c4
-rw-r--r--arch/arm/mach-netx/time.c2
-rw-r--r--arch/arm/mach-ns9xxx/time-ns9360.c2
-rw-r--r--arch/arm/mach-omap1/time.c2
-rw-r--r--arch/arm/mach-omap2/timer-gp.c2
-rw-r--r--arch/arm/mach-pxa/time.c2
-rw-r--r--arch/arm/mach-realview/core.c2
-rw-r--r--arch/arm/mach-versatile/core.c2
-rw-r--r--arch/arm/plat-mxc/time.c2
-rw-r--r--arch/arm/plat-omap/common.c4
-rw-r--r--arch/arm/plat-orion/time.c2
-rw-r--r--arch/avr32/kernel/time.c2
-rw-r--r--arch/blackfin/kernel/time-ts.c12
-rw-r--r--arch/frv/kernel/setup.c1
-rw-r--r--arch/frv/mb93090-mb00/pci-vdk.c63
-rw-r--r--arch/ia64/include/asm/paravirt_privop.h2
-rw-r--r--arch/ia64/kernel/cyclone.c2
-rw-r--r--arch/ia64/kernel/smp.c14
-rw-r--r--arch/ia64/kernel/time.c4
-rw-r--r--arch/ia64/sn/kernel/sn2/timer.c2
-rw-r--r--arch/m68knommu/platform/68328/timers.c2
-rw-r--r--arch/m68knommu/platform/coldfire/dma_timer.c2
-rw-r--r--arch/m68knommu/platform/coldfire/pit.c2
-rw-r--r--arch/m68knommu/platform/coldfire/timers.c2
-rw-r--r--arch/mips/kernel/cevt-txx9.c2
-rw-r--r--arch/mips/kernel/csrc-bcm1480.c2
-rw-r--r--arch/mips/kernel/csrc-ioasic.c6
-rw-r--r--arch/mips/kernel/csrc-r4k.c2
-rw-r--r--arch/mips/kernel/csrc-sb1250.c2
-rw-r--r--arch/mips/kernel/i8253.c2
-rw-r--r--arch/mips/nxp/pnx8550/common/time.c2
-rw-r--r--arch/mips/sgi-ip27/ip27-timer.c2
-rw-r--r--arch/powerpc/kernel/time.c8
-rw-r--r--arch/s390/kernel/compat_linux.c18
-rw-r--r--arch/s390/kernel/time.c2
-rw-r--r--arch/sh/kernel/sys_sh.c9
-rw-r--r--arch/sh/kernel/time_32.c2
-rw-r--r--arch/sh/kernel/timers/timer-tmu.c2
-rw-r--r--arch/sparc/kernel/sys_sparc32.c19
-rw-r--r--arch/sparc/kernel/time_64.c7
-rw-r--r--arch/um/Kconfig.rest2
-rw-r--r--arch/um/kernel/time.c2
-rw-r--r--arch/x86/ia32/sys_ia32.c19
-rw-r--r--arch/x86/include/asm/lguest_hcall.h2
-rw-r--r--arch/x86/kernel/hpet.c6
-rw-r--r--arch/x86/kernel/i8253.c2
-rw-r--r--arch/x86/kernel/kvmclock.c7
-rw-r--r--arch/x86/kernel/tsc.c2
-rw-r--r--arch/x86/kernel/vmiclock_32.c2
-rw-r--r--arch/x86/lguest/boot.c18
-rw-r--r--arch/x86/xen/time.c7
-rw-r--r--drivers/acpi/sleep.c8
-rw-r--r--drivers/base/core.c3
-rw-r--r--drivers/char/agp/generic.c4
-rw-r--r--drivers/char/hpet.c2
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c211
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c150
-rw-r--r--drivers/char/vt.c2
-rw-r--r--drivers/clocksource/acpi_pm.c12
-rw-r--r--drivers/clocksource/cyclone.c2
-rw-r--r--drivers/clocksource/scx200_hrt.c2
-rw-r--r--drivers/clocksource/tcb_clksrc.c2
-rw-r--r--drivers/edac/mpc85xx_edac.c2
-rw-r--r--drivers/gpu/drm/drm_stub.c11
-rw-r--r--drivers/gpu/drm/drm_sysfs.c1
-rw-r--r--drivers/gpu/drm/via/via_dma.c12
-rw-r--r--drivers/ide/cs5536.c1
-rw-r--r--drivers/ide/hpt366.c14
-rw-r--r--drivers/ide/ide-io.c11
-rw-r--r--drivers/ide/pmac.c2
-rw-r--r--drivers/input/serio/hp_sdc.c24
-rw-r--r--drivers/lguest/lg.h3
-rw-r--r--drivers/lguest/segments.c13
-rw-r--r--drivers/lguest/x86/core.c9
-rw-r--r--drivers/md/bitmap.c7
-rw-r--r--drivers/md/md.c41
-rw-r--r--drivers/md/md.h21
-rw-r--r--drivers/md/raid5.c7
-rw-r--r--drivers/message/fusion/mptbase.c2
-rw-r--r--drivers/misc/sgi-gru/grufile.c2
-rw-r--r--drivers/misc/sgi-xp/xp_main.c12
-rw-r--r--drivers/rtc/rtc-cmos.c20
-rw-r--r--drivers/serial/bfin_5xx.c6
-rw-r--r--drivers/spi/pxa2xx_spi.c13
-rw-r--r--drivers/staging/go7007/go7007-driver.c11
-rw-r--r--drivers/staging/go7007/go7007-i2c.c83
-rw-r--r--drivers/staging/go7007/go7007-priv.h1
-rw-r--r--drivers/staging/go7007/go7007-usb.c14
-rw-r--r--drivers/staging/go7007/s2250-board.c71
-rw-r--r--drivers/staging/go7007/wis-i2c.h9
-rw-r--r--drivers/staging/go7007/wis-ov7640.c56
-rw-r--r--drivers/staging/go7007/wis-saa7113.c60
-rw-r--r--drivers/staging/go7007/wis-saa7115.c60
-rw-r--r--drivers/staging/go7007/wis-sony-tuner.c60
-rw-r--r--drivers/staging/go7007/wis-tw2804.c57
-rw-r--r--drivers/staging/go7007/wis-tw9903.c60
-rw-r--r--drivers/staging/go7007/wis-uda1342.c52
-rw-r--r--drivers/video/asiliantfb.c1
-rw-r--r--drivers/video/pxafb.c16
-rw-r--r--drivers/virtio/virtio_balloon.c3
-rw-r--r--fs/autofs/dirhash.c34
-rw-r--r--fs/autofs4/dev-ioctl.c12
-rw-r--r--fs/btrfs/async-thread.c60
-rw-r--r--fs/btrfs/async-thread.h2
-rw-r--r--fs/btrfs/ctree.c17
-rw-r--r--fs/btrfs/disk-io.c9
-rw-r--r--fs/btrfs/extent_io.c86
-rw-r--r--fs/btrfs/file.c6
-rw-r--r--fs/btrfs/inode.c36
-rw-r--r--fs/btrfs/ioctl.c49
-rw-r--r--fs/btrfs/ordered-data.c2
-rw-r--r--fs/btrfs/super.c13
-rw-r--r--fs/btrfs/volumes.c124
-rw-r--r--fs/btrfs/volumes.h13
-rw-r--r--fs/cifs/CHANGES3
-rw-r--r--fs/cifs/cifs_spnego.c2
-rw-r--r--fs/cifs/cifsfs.c48
-rw-r--r--fs/cifs/cifsglob.h3
-rw-r--r--fs/cifs/cifspdu.h8
-rw-r--r--fs/cifs/cifssmb.c6
-rw-r--r--fs/cifs/connect.c205
-rw-r--r--fs/cifs/dir.c145
-rw-r--r--fs/cifs/dns_resolve.c2
-rw-r--r--fs/cifs/file.c127
-rw-r--r--fs/cifs/inode.c77
-rw-r--r--fs/cifs/readdir.c6
-rw-r--r--fs/cifs/sess.c47
-rw-r--r--fs/compat.c37
-rw-r--r--fs/compat_ioctl.c7
-rw-r--r--fs/dcache.c1
-rw-r--r--fs/ecryptfs/miscdev.c15
-rw-r--r--fs/filesystems.c2
-rw-r--r--fs/gfs2/glops.c6
-rw-r--r--fs/gfs2/ops_file.c4
-rw-r--r--fs/hugetlbfs/inode.c3
-rw-r--r--fs/namei.c2
-rw-r--r--fs/namespace.c7
-rw-r--r--fs/ncpfs/ioctl.c21
-rw-r--r--fs/nfs/nfs3xdr.c3
-rw-r--r--fs/nfsd/nfs4recover.c46
-rw-r--r--fs/nfsd/vfs.c34
-rw-r--r--fs/stat.c137
-rw-r--r--fs/sysfs/bin.c13
-rw-r--r--fs/xattr.c10
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl.c23
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl32.c12
-rw-r--r--include/linux/clocksource.h37
-rw-r--r--include/linux/fs.h5
-rw-r--r--include/linux/ipmi.h2
-rw-r--r--include/linux/ipmi_msgdefs.h8
-rw-r--r--include/linux/memcontrol.h2
-rw-r--r--include/linux/reiserfs_fs_sb.h2
-rw-r--r--include/linux/seccomp.h2
-rw-r--r--include/linux/spi/spi.h7
-rw-r--r--include/linux/suspend.h36
-rw-r--r--include/linux/syscalls.h2
-rw-r--r--kernel/audit_tree.c3
-rw-r--r--kernel/power/main.c24
-rw-r--r--kernel/resource.c46
-rw-r--r--kernel/time/clocksource.c8
-rw-r--r--kernel/time/jiffies.c2
-rw-r--r--kernel/time/timekeeping.c12
-rw-r--r--lib/kobject.c3
-rw-r--r--mm/vmscan.c17
-rw-r--r--scripts/Makefile.build3
-rw-r--r--scripts/Makefile.lib9
-rw-r--r--security/smack/smack_lsm.c11
-rw-r--r--sound/pci/emu10k1/io.c2
-rw-r--r--sound/pci/hda/hda_codec.c8
-rw-r--r--sound/pci/hda/hda_intel.c2
-rw-r--r--sound/pci/hda/patch_analog.c8
-rw-r--r--sound/pci/hda/patch_sigmatel.c10
-rw-r--r--sound/pci/intel8x0.c12
-rw-r--r--sound/soc/omap/omap-mcbsp.c7
-rw-r--r--sound/soc/omap/osk5912.c4
-rw-r--r--sound/soc/pxa/pxa-ssp.c1
-rw-r--r--sound/soc/s3c24xx/jive_wm8750.c12
-rw-r--r--sound/soc/s3c24xx/s3c-i2s-v2.c18
-rw-r--r--sound/soc/s3c24xx/s3c2412-i2s.c2
194 files changed, 2013 insertions, 1508 deletions
diff --git a/.gitignore b/.gitignore
index 869e1a3b64b6..51bd99d6a260 100644
--- a/.gitignore
+++ b/.gitignore
@@ -49,6 +49,7 @@ include/linux/compile.h
49include/linux/version.h 49include/linux/version.h
50include/linux/utsrelease.h 50include/linux/utsrelease.h
51include/linux/bounds.h 51include/linux/bounds.h
52include/generated
52 53
53# stgit generated dirs 54# stgit generated dirs
54patches-* 55patches-*
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index deeeed0faa8f..f49eecf2e573 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -277,8 +277,7 @@ or bottom half).
277 unfreeze_fs: called when VFS is unlocking a filesystem and making it writable 277 unfreeze_fs: called when VFS is unlocking a filesystem and making it writable
278 again. 278 again.
279 279
280 statfs: called when the VFS needs to get filesystem statistics. This 280 statfs: called when the VFS needs to get filesystem statistics.
281 is called with the kernel lock held
282 281
283 remount_fs: called when the filesystem is remounted. This is called 282 remount_fs: called when the filesystem is remounted. This is called
284 with the kernel lock held 283 with the kernel lock held
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index d4b05672f9f7..d76cfd8712e1 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -316,6 +316,16 @@ more details, with real examples.
316 #arch/m68k/fpsp040/Makefile 316 #arch/m68k/fpsp040/Makefile
317 ldflags-y := -x 317 ldflags-y := -x
318 318
319 subdir-ccflags-y, subdir-asflags-y
320 The two flags listed above are similar to ccflags-y and as-falgs-y.
321 The difference is that the subdir- variants has effect for the kbuild
322 file where tey are present and all subdirectories.
323 Options specified using subdir-* are added to the commandline before
324 the options specified using the non-subdir variants.
325
326 Example:
327 subdir-ccflags-y := -Werror
328
319 CFLAGS_$@, AFLAGS_$@ 329 CFLAGS_$@, AFLAGS_$@
320 330
321 CFLAGS_$@ and AFLAGS_$@ only apply to commands in current 331 CFLAGS_$@ and AFLAGS_$@ only apply to commands in current
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index a19f021f081a..600cdd72900c 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -231,6 +231,35 @@ and is between 256 and 4096 characters. It is defined in the file
231 power state again in power transition. 231 power state again in power transition.
232 1 : disable the power state check 232 1 : disable the power state check
233 233
234 acpi_sci= [HW,ACPI] ACPI System Control Interrupt trigger mode
235 Format: { level | edge | high | low }
236
237 acpi_serialize [HW,ACPI] force serialization of AML methods
238
239 acpi_skip_timer_override [HW,ACPI]
240 Recognize and ignore IRQ0/pin2 Interrupt Override.
241 For broken nForce2 BIOS resulting in XT-PIC timer.
242
243 acpi_sleep= [HW,ACPI] Sleep options
244 Format: { s3_bios, s3_mode, s3_beep, s4_nohwsig,
245 old_ordering, s4_nonvs }
246 See Documentation/power/video.txt for information on
247 s3_bios and s3_mode.
248 s3_beep is for debugging; it makes the PC's speaker beep
249 as soon as the kernel's real-mode entry point is called.
250 s4_nohwsig prevents ACPI hardware signature from being
251 used during resume from hibernation.
252 old_ordering causes the ACPI 1.0 ordering of the _PTS
253 control method, with respect to putting devices into
254 low power states, to be enforced (the ACPI 2.0 ordering
255 of _PTS is used by default).
256 s4_nonvs prevents the kernel from saving/restoring the
257 ACPI NVS memory during hibernation.
258
259 acpi_use_timer_override [HW,ACPI]
260 Use timer override. For some broken Nvidia NF5 boards
261 that require a timer override, but don't have HPET
262
234 acpi_enforce_resources= [ACPI] 263 acpi_enforce_resources= [ACPI]
235 { strict | lax | no } 264 { strict | lax | no }
236 Check for resource conflicts between native drivers 265 Check for resource conflicts between native drivers
@@ -250,6 +279,9 @@ and is between 256 and 4096 characters. It is defined in the file
250 ad1848= [HW,OSS] 279 ad1848= [HW,OSS]
251 Format: <io>,<irq>,<dma>,<dma2>,<type> 280 Format: <io>,<irq>,<dma>,<dma2>,<type>
252 281
282 add_efi_memmap [EFI; X86] Include EFI memory map in
283 kernel's map of available physical RAM.
284
253 advansys= [HW,SCSI] 285 advansys= [HW,SCSI]
254 See header of drivers/scsi/advansys.c. 286 See header of drivers/scsi/advansys.c.
255 287
@@ -1838,6 +1870,12 @@ and is between 256 and 4096 characters. It is defined in the file
1838 autoconfiguration. 1870 autoconfiguration.
1839 Ranges are in pairs (memory base and size). 1871 Ranges are in pairs (memory base and size).
1840 1872
1873 ports= [IP_VS_FTP] IPVS ftp helper module
1874 Default is 21.
1875 Up to 8 (IP_VS_APP_MAX_PORTS) ports
1876 may be specified.
1877 Format: <port>,<port>....
1878
1841 print-fatal-signals= 1879 print-fatal-signals=
1842 [KNL] debug: print fatal signals 1880 [KNL] debug: print fatal signals
1843 print-fatal-signals=1: print segfault info to 1881 print-fatal-signals=1: print segfault info to
diff --git a/Documentation/lguest/.gitignore b/Documentation/lguest/.gitignore
new file mode 100644
index 000000000000..115587fd5f65
--- /dev/null
+++ b/Documentation/lguest/.gitignore
@@ -0,0 +1 @@
lguest
diff --git a/Documentation/lguest/lguest.txt b/Documentation/lguest/lguest.txt
index 29510dc51510..28c747362f95 100644
--- a/Documentation/lguest/lguest.txt
+++ b/Documentation/lguest/lguest.txt
@@ -3,11 +3,11 @@
3 /, /` - or, A Young Coder's Illustrated Hypervisor 3 /, /` - or, A Young Coder's Illustrated Hypervisor
4 \\"--\\ http://lguest.ozlabs.org 4 \\"--\\ http://lguest.ozlabs.org
5 5
6Lguest is designed to be a minimal hypervisor for the Linux kernel, for 6Lguest is designed to be a minimal 32-bit x86 hypervisor for the Linux kernel,
7Linux developers and users to experiment with virtualization with the 7for Linux developers and users to experiment with virtualization with the
8minimum of complexity. Nonetheless, it should have sufficient 8minimum of complexity. Nonetheless, it should have sufficient features to
9features to make it useful for specific tasks, and, of course, you are 9make it useful for specific tasks, and, of course, you are encouraged to fork
10encouraged to fork and enhance it (see drivers/lguest/README). 10and enhance it (see drivers/lguest/README).
11 11
12Features: 12Features:
13 13
@@ -37,6 +37,7 @@ Running Lguest:
37 "Paravirtualized guest support" = Y 37 "Paravirtualized guest support" = Y
38 "Lguest guest support" = Y 38 "Lguest guest support" = Y
39 "High Memory Support" = off/4GB 39 "High Memory Support" = off/4GB
40 "PAE (Physical Address Extension) Support" = N
40 "Alignment value to which kernel should be aligned" = 0x100000 41 "Alignment value to which kernel should be aligned" = 0x100000
41 (CONFIG_PARAVIRT=y, CONFIG_LGUEST_GUEST=y, CONFIG_HIGHMEM64G=n and 42 (CONFIG_PARAVIRT=y, CONFIG_LGUEST_GUEST=y, CONFIG_HIGHMEM64G=n and
42 CONFIG_PHYSICAL_ALIGN=0x100000) 43 CONFIG_PHYSICAL_ALIGN=0x100000)
diff --git a/Documentation/spi/spi-summary b/Documentation/spi/spi-summary
index 0f5122eb282b..4a02d2508bc8 100644
--- a/Documentation/spi/spi-summary
+++ b/Documentation/spi/spi-summary
@@ -511,10 +511,16 @@ SPI MASTER METHODS
511 This sets up the device clock rate, SPI mode, and word sizes. 511 This sets up the device clock rate, SPI mode, and word sizes.
512 Drivers may change the defaults provided by board_info, and then 512 Drivers may change the defaults provided by board_info, and then
513 call spi_setup(spi) to invoke this routine. It may sleep. 513 call spi_setup(spi) to invoke this routine. It may sleep.
514
514 Unless each SPI slave has its own configuration registers, don't 515 Unless each SPI slave has its own configuration registers, don't
515 change them right away ... otherwise drivers could corrupt I/O 516 change them right away ... otherwise drivers could corrupt I/O
516 that's in progress for other SPI devices. 517 that's in progress for other SPI devices.
517 518
519 ** BUG ALERT: for some reason the first version of
520 ** many spi_master drivers seems to get this wrong.
521 ** When you code setup(), ASSUME that the controller
522 ** is actively processing transfers for another device.
523
518 master->transfer(struct spi_device *spi, struct spi_message *message) 524 master->transfer(struct spi_device *spi, struct spi_message *message)
519 This must not sleep. Its responsibility is arrange that the 525 This must not sleep. Its responsibility is arrange that the
520 transfer happens and its complete() callback is issued. The two 526 transfer happens and its complete() callback is issued. The two
diff --git a/MAINTAINERS b/MAINTAINERS
index 0beac8a7f8f2..cb9571042f21 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1287,6 +1287,14 @@ S: Maintained
1287F: Documentation/video4linux/bttv/ 1287F: Documentation/video4linux/bttv/
1288F: drivers/media/video/bt8xx/bttv* 1288F: drivers/media/video/bt8xx/bttv*
1289 1289
1290CACHEFILES: FS-CACHE BACKEND FOR CACHING ON MOUNTED FILESYSTEMS
1291P: David Howells
1292M: dhowells@redhat.com
1293L: linux-cachefs@redhat.com
1294S: Supported
1295F: Documentation/filesystems/caching/cachefiles.txt
1296F: fs/cachefiles/
1297
1290CAFE CMOS INTEGRATED CAMERA CONTROLLER DRIVER 1298CAFE CMOS INTEGRATED CAMERA CONTROLLER DRIVER
1291P: Jonathan Corbet 1299P: Jonathan Corbet
1292M: corbet@lwn.net 1300M: corbet@lwn.net
@@ -2057,6 +2065,8 @@ F: drivers/infiniband/hw/ehca/
2057EMBEDDED LINUX 2065EMBEDDED LINUX
2058P: Paul Gortmaker 2066P: Paul Gortmaker
2059M: paul.gortmaker@windriver.com 2067M: paul.gortmaker@windriver.com
2068P: Matt Mackall
2069M: mpm@selenic.com
2060P: David Woodhouse 2070P: David Woodhouse
2061M: dwmw2@infradead.org 2071M: dwmw2@infradead.org
2062L: linux-embedded@vger.kernel.org 2072L: linux-embedded@vger.kernel.org
@@ -2325,6 +2335,15 @@ F: Documentation/power/freezing-of-tasks.txt
2325F: include/linux/freezer.h 2335F: include/linux/freezer.h
2326F: kernel/freezer.c 2336F: kernel/freezer.c
2327 2337
2338FS-CACHE: LOCAL CACHING FOR NETWORK FILESYSTEMS
2339P: David Howells
2340M: dhowells@redhat.com
2341L: linux-cachefs@redhat.com
2342S: Supported
2343F: Documentation/filesystems/caching/
2344F: fs/fscache/
2345F: include/linux/fscache*.h
2346
2328FTRACE 2347FTRACE
2329P: Steven Rostedt 2348P: Steven Rostedt
2330M: rostedt@goodmis.org 2349M: rostedt@goodmis.org
@@ -2545,7 +2564,6 @@ F: kernel/power/
2545F: include/linux/suspend.h 2564F: include/linux/suspend.h
2546F: include/linux/freezer.h 2565F: include/linux/freezer.h
2547F: include/linux/pm.h 2566F: include/linux/pm.h
2548F: include/asm-*/suspend*.h
2549F: arch/*/include/asm/suspend*.h 2567F: arch/*/include/asm/suspend*.h
2550 2568
2551HID CORE LAYER 2569HID CORE LAYER
@@ -3323,7 +3341,7 @@ P: Eduard - Gabriel Munteanu
3323M: eduard.munteanu@linux360.ro 3341M: eduard.munteanu@linux360.ro
3324L: linux-kernel@vger.kernel.org 3342L: linux-kernel@vger.kernel.org
3325S: Maintained 3343S: Maintained
3326F: Documentation/vm/kmemtrace.txt 3344F: Documentation/trace/kmemtrace.txt
3327F: include/trace/kmemtrace.h 3345F: include/trace/kmemtrace.h
3328F: kernel/trace/kmemtrace.c 3346F: kernel/trace/kmemtrace.c
3329 3347
@@ -5235,7 +5253,12 @@ M: perex@perex.cz
5235P: Takashi Iwai 5253P: Takashi Iwai
5236M: tiwai@suse.de 5254M: tiwai@suse.de
5237L: alsa-devel@alsa-project.org (subscribers-only) 5255L: alsa-devel@alsa-project.org (subscribers-only)
5256W: http://www.alsa-project.org/
5257T: git git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git
5258T: git git://git.alsa-project.org/alsa-kernel.git
5238S: Maintained 5259S: Maintained
5260F: Documentation/sound/
5261F: include/sound/
5239F: sound/ 5262F: sound/
5240 5263
5241SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEMENT (ASoC) 5264SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEMENT (ASoC)
@@ -5382,7 +5405,6 @@ F: kernel/power/
5382F: include/linux/suspend.h 5405F: include/linux/suspend.h
5383F: include/linux/freezer.h 5406F: include/linux/freezer.h
5384F: include/linux/pm.h 5407F: include/linux/pm.h
5385F: include/asm-*/suspend.h
5386 5408
5387SVGA HANDLING 5409SVGA HANDLING
5388P: Martin Mares 5410P: Martin Mares
@@ -5616,7 +5638,7 @@ L: uclinux-dev@uclinux.org (subscribers-only)
5616S: Maintained 5638S: Maintained
5617F: arch/m68knommu/ 5639F: arch/m68knommu/
5618 5640
5619UCLINUX FOR RENESAS H8/300 5641UCLINUX FOR RENESAS H8/300 (H8300)
5620P: Yoshinori Sato 5642P: Yoshinori Sato
5621M: ysato@users.sourceforge.jp 5643M: ysato@users.sourceforge.jp
5622W: http://uclinux-h8.sourceforge.jp/ 5644W: http://uclinux-h8.sourceforge.jp/
diff --git a/Makefile b/Makefile
index bfdef56add34..6f4208ff2d10 100644
--- a/Makefile
+++ b/Makefile
@@ -1200,7 +1200,7 @@ CLEAN_FILES += vmlinux System.map \
1200 .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map 1200 .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
1201 1201
1202# Directories & files removed with 'make mrproper' 1202# Directories & files removed with 'make mrproper'
1203MRPROPER_DIRS += include/config include2 usr/include 1203MRPROPER_DIRS += include/config include2 usr/include include/generated
1204MRPROPER_FILES += .config .config.old include/asm .version .old_version \ 1204MRPROPER_FILES += .config .config.old include/asm .version .old_version \
1205 include/linux/autoconf.h include/linux/version.h \ 1205 include/linux/autoconf.h include/linux/version.h \
1206 include/linux/utsrelease.h \ 1206 include/linux/utsrelease.h \
diff --git a/arch/arm/kernel/sys_oabi-compat.c b/arch/arm/kernel/sys_oabi-compat.c
index e04173c7e621..d59a0cd537f0 100644
--- a/arch/arm/kernel/sys_oabi-compat.c
+++ b/arch/arm/kernel/sys_oabi-compat.c
@@ -177,21 +177,12 @@ asmlinkage long sys_oabi_fstatat64(int dfd,
177 int flag) 177 int flag)
178{ 178{
179 struct kstat stat; 179 struct kstat stat;
180 int error = -EINVAL; 180 int error;
181 181
182 if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0) 182 error = vfs_fstatat(dfd, filename, &stat, flag);
183 goto out; 183 if (error)
184 184 return error;
185 if (flag & AT_SYMLINK_NOFOLLOW) 185 return cp_oldabi_stat64(&stat, statbuf);
186 error = vfs_lstat_fd(dfd, filename, &stat);
187 else
188 error = vfs_stat_fd(dfd, filename, &stat);
189
190 if (!error)
191 error = cp_oldabi_stat64(&stat, statbuf);
192
193out:
194 return error;
195} 186}
196 187
197struct oabi_flock64 { 188struct oabi_flock64 {
diff --git a/arch/arm/mach-at91/at91rm9200_time.c b/arch/arm/mach-at91/at91rm9200_time.c
index 1ff1bda0a894..309f3511aa20 100644
--- a/arch/arm/mach-at91/at91rm9200_time.c
+++ b/arch/arm/mach-at91/at91rm9200_time.c
@@ -85,7 +85,7 @@ static struct irqaction at91rm9200_timer_irq = {
85 .handler = at91rm9200_timer_interrupt 85 .handler = at91rm9200_timer_interrupt
86}; 86};
87 87
88static cycle_t read_clk32k(void) 88static cycle_t read_clk32k(struct clocksource *cs)
89{ 89{
90 return read_CRTR(); 90 return read_CRTR();
91} 91}
diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c
index b63e1d5f1bad..4bd56aee4370 100644
--- a/arch/arm/mach-at91/at91sam926x_time.c
+++ b/arch/arm/mach-at91/at91sam926x_time.c
@@ -31,7 +31,7 @@ static u32 pit_cnt; /* access only w/system irq blocked */
31 * Clocksource: just a monotonic counter of MCK/16 cycles. 31 * Clocksource: just a monotonic counter of MCK/16 cycles.
32 * We don't care whether or not PIT irqs are enabled. 32 * We don't care whether or not PIT irqs are enabled.
33 */ 33 */
34static cycle_t read_pit_clk(void) 34static cycle_t read_pit_clk(struct clocksource *cs)
35{ 35{
36 unsigned long flags; 36 unsigned long flags;
37 u32 elapsed; 37 u32 elapsed;
diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c
index f8bcd29d17a6..6c227d4ba998 100644
--- a/arch/arm/mach-davinci/time.c
+++ b/arch/arm/mach-davinci/time.c
@@ -238,7 +238,7 @@ static void __init timer_init(void)
238/* 238/*
239 * clocksource 239 * clocksource
240 */ 240 */
241static cycle_t read_cycles(void) 241static cycle_t read_cycles(struct clocksource *cs)
242{ 242{
243 struct timer_s *t = &timers[TID_CLOCKSOURCE]; 243 struct timer_s *t = &timers[TID_CLOCKSOURCE];
244 244
diff --git a/arch/arm/mach-imx/time.c b/arch/arm/mach-imx/time.c
index aff0ebcfa847..5aef18b599e5 100644
--- a/arch/arm/mach-imx/time.c
+++ b/arch/arm/mach-imx/time.c
@@ -73,7 +73,7 @@ static void __init imx_timer_hardware_init(void)
73 IMX_TCTL(TIMER_BASE) = TCTL_FRR | TCTL_CLK_PCLK1 | TCTL_TEN; 73 IMX_TCTL(TIMER_BASE) = TCTL_FRR | TCTL_CLK_PCLK1 | TCTL_TEN;
74} 74}
75 75
76cycle_t imx_get_cycles(void) 76cycle_t imx_get_cycles(struct clocksource *cs)
77{ 77{
78 return IMX_TCN(TIMER_BASE); 78 return IMX_TCN(TIMER_BASE);
79} 79}
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index f4656d2ac8a8..1e93dfee7543 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -401,7 +401,7 @@ void __init ixp4xx_sys_init(void)
401/* 401/*
402 * clocksource 402 * clocksource
403 */ 403 */
404cycle_t ixp4xx_get_cycles(void) 404cycle_t ixp4xx_get_cycles(struct clocksource *cs)
405{ 405{
406 return *IXP4XX_OSTS; 406 return *IXP4XX_OSTS;
407} 407}
diff --git a/arch/arm/mach-msm/timer.c b/arch/arm/mach-msm/timer.c
index 444d9c0f5ca6..4855b8ca5101 100644
--- a/arch/arm/mach-msm/timer.c
+++ b/arch/arm/mach-msm/timer.c
@@ -57,12 +57,12 @@ static irqreturn_t msm_timer_interrupt(int irq, void *dev_id)
57 return IRQ_HANDLED; 57 return IRQ_HANDLED;
58} 58}
59 59
60static cycle_t msm_gpt_read(void) 60static cycle_t msm_gpt_read(struct clocksource *cs)
61{ 61{
62 return readl(MSM_GPT_BASE + TIMER_COUNT_VAL); 62 return readl(MSM_GPT_BASE + TIMER_COUNT_VAL);
63} 63}
64 64
65static cycle_t msm_dgt_read(void) 65static cycle_t msm_dgt_read(struct clocksource *cs)
66{ 66{
67 return readl(MSM_DGT_BASE + TIMER_COUNT_VAL) >> MSM_DGT_SHIFT; 67 return readl(MSM_DGT_BASE + TIMER_COUNT_VAL) >> MSM_DGT_SHIFT;
68} 68}
diff --git a/arch/arm/mach-netx/time.c b/arch/arm/mach-netx/time.c
index f201fddb594f..82801dbf0579 100644
--- a/arch/arm/mach-netx/time.c
+++ b/arch/arm/mach-netx/time.c
@@ -104,7 +104,7 @@ static struct irqaction netx_timer_irq = {
104 .handler = netx_timer_interrupt, 104 .handler = netx_timer_interrupt,
105}; 105};
106 106
107cycle_t netx_get_cycles(void) 107cycle_t netx_get_cycles(struct clocksource *cs)
108{ 108{
109 return readl(NETX_GPIO_COUNTER_CURRENT(TIMER_CLOCKSOURCE)); 109 return readl(NETX_GPIO_COUNTER_CURRENT(TIMER_CLOCKSOURCE));
110} 110}
diff --git a/arch/arm/mach-ns9xxx/time-ns9360.c b/arch/arm/mach-ns9xxx/time-ns9360.c
index 41df69721769..77281260358a 100644
--- a/arch/arm/mach-ns9xxx/time-ns9360.c
+++ b/arch/arm/mach-ns9xxx/time-ns9360.c
@@ -25,7 +25,7 @@
25#define TIMER_CLOCKEVENT 1 25#define TIMER_CLOCKEVENT 1
26static u32 latch; 26static u32 latch;
27 27
28static cycle_t ns9360_clocksource_read(void) 28static cycle_t ns9360_clocksource_read(struct clocksource *cs)
29{ 29{
30 return __raw_readl(SYS_TR(TIMER_CLOCKSOURCE)); 30 return __raw_readl(SYS_TR(TIMER_CLOCKSOURCE));
31} 31}
diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c
index 495a32c287b4..4d56408d3cff 100644
--- a/arch/arm/mach-omap1/time.c
+++ b/arch/arm/mach-omap1/time.c
@@ -198,7 +198,7 @@ static struct irqaction omap_mpu_timer2_irq = {
198 .handler = omap_mpu_timer2_interrupt, 198 .handler = omap_mpu_timer2_interrupt,
199}; 199};
200 200
201static cycle_t mpu_read(void) 201static cycle_t mpu_read(struct clocksource *cs)
202{ 202{
203 return ~omap_mpu_timer_read(1); 203 return ~omap_mpu_timer_read(1);
204} 204}
diff --git a/arch/arm/mach-omap2/timer-gp.c b/arch/arm/mach-omap2/timer-gp.c
index 9fc13a2cc3f4..1cb2c0909c2b 100644
--- a/arch/arm/mach-omap2/timer-gp.c
+++ b/arch/arm/mach-omap2/timer-gp.c
@@ -138,7 +138,7 @@ static inline void __init omap2_gp_clocksource_init(void) {}
138 * clocksource 138 * clocksource
139 */ 139 */
140static struct omap_dm_timer *gpt_clocksource; 140static struct omap_dm_timer *gpt_clocksource;
141static cycle_t clocksource_read_cycles(void) 141static cycle_t clocksource_read_cycles(struct clocksource *cs)
142{ 142{
143 return (cycle_t)omap_dm_timer_read_counter(gpt_clocksource); 143 return (cycle_t)omap_dm_timer_read_counter(gpt_clocksource);
144} 144}
diff --git a/arch/arm/mach-pxa/time.c b/arch/arm/mach-pxa/time.c
index 8eb3830fbb0b..750c448db672 100644
--- a/arch/arm/mach-pxa/time.c
+++ b/arch/arm/mach-pxa/time.c
@@ -125,7 +125,7 @@ static struct clock_event_device ckevt_pxa_osmr0 = {
125 .set_mode = pxa_osmr0_set_mode, 125 .set_mode = pxa_osmr0_set_mode,
126}; 126};
127 127
128static cycle_t pxa_read_oscr(void) 128static cycle_t pxa_read_oscr(struct clocksource *cs)
129{ 129{
130 return OSCR; 130 return OSCR;
131} 131}
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index 9ab947c14f26..942e1a7eb9b2 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -715,7 +715,7 @@ static struct irqaction realview_timer_irq = {
715 .handler = realview_timer_interrupt, 715 .handler = realview_timer_interrupt,
716}; 716};
717 717
718static cycle_t realview_get_cycles(void) 718static cycle_t realview_get_cycles(struct clocksource *cs)
719{ 719{
720 return ~readl(timer3_va_base + TIMER_VALUE); 720 return ~readl(timer3_va_base + TIMER_VALUE);
721} 721}
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index 565776680d8c..1f929c391af7 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -948,7 +948,7 @@ static struct irqaction versatile_timer_irq = {
948 .handler = versatile_timer_interrupt, 948 .handler = versatile_timer_interrupt,
949}; 949};
950 950
951static cycle_t versatile_get_cycles(void) 951static cycle_t versatile_get_cycles(struct clocksource *cs)
952{ 952{
953 return ~readl(TIMER3_VA_BASE + TIMER_VALUE); 953 return ~readl(TIMER3_VA_BASE + TIMER_VALUE);
954} 954}
diff --git a/arch/arm/plat-mxc/time.c b/arch/arm/plat-mxc/time.c
index ef1b3cd85bd3..dab3357196fb 100644
--- a/arch/arm/plat-mxc/time.c
+++ b/arch/arm/plat-mxc/time.c
@@ -36,7 +36,7 @@ static enum clock_event_mode clockevent_mode = CLOCK_EVT_MODE_UNUSED;
36 36
37/* clock source */ 37/* clock source */
38 38
39static cycle_t mxc_get_cycles(void) 39static cycle_t mxc_get_cycles(struct clocksource *cs)
40{ 40{
41 return __raw_readl(TIMER_BASE + MXC_TCN); 41 return __raw_readl(TIMER_BASE + MXC_TCN);
42} 42}
diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index d1797147732f..433021f3d7cc 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -185,7 +185,7 @@ console_initcall(omap_add_serial_console);
185 185
186#include <linux/clocksource.h> 186#include <linux/clocksource.h>
187 187
188static cycle_t omap_32k_read(void) 188static cycle_t omap_32k_read(struct clocksource *cs)
189{ 189{
190 return omap_readl(TIMER_32K_SYNCHRONIZED); 190 return omap_readl(TIMER_32K_SYNCHRONIZED);
191} 191}
@@ -207,7 +207,7 @@ unsigned long long sched_clock(void)
207{ 207{
208 unsigned long long ret; 208 unsigned long long ret;
209 209
210 ret = (unsigned long long)omap_32k_read(); 210 ret = (unsigned long long)omap_32k_read(&clocksource_32k);
211 ret = (ret * clocksource_32k.mult_orig) >> clocksource_32k.shift; 211 ret = (ret * clocksource_32k.mult_orig) >> clocksource_32k.shift;
212 return ret; 212 return ret;
213} 213}
diff --git a/arch/arm/plat-orion/time.c b/arch/arm/plat-orion/time.c
index 6fa2923e6dca..2faf9dba4ef7 100644
--- a/arch/arm/plat-orion/time.c
+++ b/arch/arm/plat-orion/time.c
@@ -41,7 +41,7 @@ static u32 ticks_per_jiffy;
41/* 41/*
42 * Clocksource handling. 42 * Clocksource handling.
43 */ 43 */
44static cycle_t orion_clksrc_read(void) 44static cycle_t orion_clksrc_read(struct clocksource *cs)
45{ 45{
46 return 0xffffffff - readl(TIMER0_VAL); 46 return 0xffffffff - readl(TIMER0_VAL);
47} 47}
diff --git a/arch/avr32/kernel/time.c b/arch/avr32/kernel/time.c
index 0ff46bf873b0..f27aa3b259fa 100644
--- a/arch/avr32/kernel/time.c
+++ b/arch/avr32/kernel/time.c
@@ -18,7 +18,7 @@
18#include <mach/pm.h> 18#include <mach/pm.h>
19 19
20 20
21static cycle_t read_cycle_count(void) 21static cycle_t read_cycle_count(struct clocksource *cs)
22{ 22{
23 return (cycle_t)sysreg_read(COUNT); 23 return (cycle_t)sysreg_read(COUNT);
24} 24}
diff --git a/arch/blackfin/kernel/time-ts.c b/arch/blackfin/kernel/time-ts.c
index 0ed2badfd746..27646121280a 100644
--- a/arch/blackfin/kernel/time-ts.c
+++ b/arch/blackfin/kernel/time-ts.c
@@ -58,16 +58,11 @@ static inline unsigned long long cycles_2_ns(cycle_t cyc)
58 return (cyc * cyc2ns_scale) >> CYC2NS_SCALE_FACTOR; 58 return (cyc * cyc2ns_scale) >> CYC2NS_SCALE_FACTOR;
59} 59}
60 60
61static cycle_t read_cycles(void) 61static cycle_t read_cycles(struct clocksource *cs)
62{ 62{
63 return __bfin_cycles_off + (get_cycles() << __bfin_cycles_mod); 63 return __bfin_cycles_off + (get_cycles() << __bfin_cycles_mod);
64} 64}
65 65
66unsigned long long sched_clock(void)
67{
68 return cycles_2_ns(read_cycles());
69}
70
71static struct clocksource clocksource_bfin = { 66static struct clocksource clocksource_bfin = {
72 .name = "bfin_cycles", 67 .name = "bfin_cycles",
73 .rating = 350, 68 .rating = 350,
@@ -77,6 +72,11 @@ static struct clocksource clocksource_bfin = {
77 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 72 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
78}; 73};
79 74
75unsigned long long sched_clock(void)
76{
77 return cycles_2_ns(read_cycles(&clocksource_bfin));
78}
79
80static int __init bfin_clocksource_init(void) 80static int __init bfin_clocksource_init(void)
81{ 81{
82 set_cyc2ns_scale(get_cclk() / 1000); 82 set_cyc2ns_scale(get_cclk() / 1000);
diff --git a/arch/frv/kernel/setup.c b/arch/frv/kernel/setup.c
index 0669e1382383..55e4fab7c0bc 100644
--- a/arch/frv/kernel/setup.c
+++ b/arch/frv/kernel/setup.c
@@ -46,7 +46,6 @@
46#include <asm/io.h> 46#include <asm/io.h>
47 47
48#ifdef CONFIG_BLK_DEV_INITRD 48#ifdef CONFIG_BLK_DEV_INITRD
49#include <linux/blk.h>
50#include <asm/pgtable.h> 49#include <asm/pgtable.h>
51#endif 50#endif
52 51
diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c
index 0f41c3a72da5..c0dcec65c6b7 100644
--- a/arch/frv/mb93090-mb00/pci-vdk.c
+++ b/arch/frv/mb93090-mb00/pci-vdk.c
@@ -31,6 +31,29 @@ struct pci_bus *__nongpreldata pci_root_bus;
31struct pci_ops *__nongpreldata pci_root_ops; 31struct pci_ops *__nongpreldata pci_root_ops;
32 32
33/* 33/*
34 * The accessible PCI window does not cover the entire CPU address space, but
35 * there are devices we want to access outside of that window, so we need to
36 * insert specific PCI bus resources instead of using the platform-level bus
37 * resources directly for the PCI root bus.
38 *
39 * These are configured and inserted by pcibios_init() and are attached to the
40 * root bus by pcibios_fixup_bus().
41 */
42static struct resource pci_ioport_resource = {
43 .name = "PCI IO",
44 .start = 0,
45 .end = IO_SPACE_LIMIT,
46 .flags = IORESOURCE_IO,
47};
48
49static struct resource pci_iomem_resource = {
50 .name = "PCI mem",
51 .start = 0,
52 .end = -1,
53 .flags = IORESOURCE_MEM,
54};
55
56/*
34 * Functions for accessing PCI configuration space 57 * Functions for accessing PCI configuration space
35 */ 58 */
36 59
@@ -304,6 +327,12 @@ void __init pcibios_fixup_bus(struct pci_bus *bus)
304#if 0 327#if 0
305 printk("### PCIBIOS_FIXUP_BUS(%d)\n",bus->number); 328 printk("### PCIBIOS_FIXUP_BUS(%d)\n",bus->number);
306#endif 329#endif
330
331 if (bus->number == 0) {
332 bus->resource[0] = &pci_ioport_resource;
333 bus->resource[1] = &pci_iomem_resource;
334 }
335
307 pci_read_bridge_bases(bus); 336 pci_read_bridge_bases(bus);
308 337
309 if (bus->number == 0) { 338 if (bus->number == 0) {
@@ -350,28 +379,36 @@ int __init pcibios_init(void)
350 /* enable PCI arbitration */ 379 /* enable PCI arbitration */
351 __reg_MB86943_pci_arbiter = MB86943_PCIARB_EN; 380 __reg_MB86943_pci_arbiter = MB86943_PCIARB_EN;
352 381
353 ioport_resource.start = (__reg_MB86943_sl_pci_io_base << 9) & 0xfffffc00; 382 pci_ioport_resource.start = (__reg_MB86943_sl_pci_io_base << 9) & 0xfffffc00;
354 ioport_resource.end = (__reg_MB86943_sl_pci_io_range << 9) | 0x3ff; 383 pci_ioport_resource.end = (__reg_MB86943_sl_pci_io_range << 9) | 0x3ff;
355 ioport_resource.end += ioport_resource.start; 384 pci_ioport_resource.end += pci_ioport_resource.start;
356 385
357 printk("PCI IO window: %08llx-%08llx\n", 386 printk("PCI IO window: %08llx-%08llx\n",
358 (unsigned long long) ioport_resource.start, 387 (unsigned long long) pci_ioport_resource.start,
359 (unsigned long long) ioport_resource.end); 388 (unsigned long long) pci_ioport_resource.end);
360 389
361 iomem_resource.start = (__reg_MB86943_sl_pci_mem_base << 9) & 0xfffffc00; 390 pci_iomem_resource.start = (__reg_MB86943_sl_pci_mem_base << 9) & 0xfffffc00;
391 pci_iomem_resource.end = (__reg_MB86943_sl_pci_mem_range << 9) | 0x3ff;
392 pci_iomem_resource.end += pci_iomem_resource.start;
362 393
363 /* Reserve somewhere to write to flush posted writes. */ 394 /* Reserve somewhere to write to flush posted writes. This is used by
364 iomem_resource.start += 0x400; 395 * __flush_PCI_writes() from asm/io.h to force the write FIFO in the
365 396 * CPU-PCI bridge to flush as this doesn't happen automatically when a
366 iomem_resource.end = (__reg_MB86943_sl_pci_mem_range << 9) | 0x3ff; 397 * read is performed on the MB93090 development kit motherboard.
367 iomem_resource.end += iomem_resource.start; 398 */
399 pci_iomem_resource.start += 0x400;
368 400
369 printk("PCI MEM window: %08llx-%08llx\n", 401 printk("PCI MEM window: %08llx-%08llx\n",
370 (unsigned long long) iomem_resource.start, 402 (unsigned long long) pci_iomem_resource.start,
371 (unsigned long long) iomem_resource.end); 403 (unsigned long long) pci_iomem_resource.end);
372 printk("PCI DMA memory: %08lx-%08lx\n", 404 printk("PCI DMA memory: %08lx-%08lx\n",
373 dma_coherent_mem_start, dma_coherent_mem_end); 405 dma_coherent_mem_start, dma_coherent_mem_end);
374 406
407 if (insert_resource(&iomem_resource, &pci_iomem_resource) < 0)
408 panic("Unable to insert PCI IOMEM resource\n");
409 if (insert_resource(&ioport_resource, &pci_ioport_resource) < 0)
410 panic("Unable to insert PCI IOPORT resource\n");
411
375 if (!pci_probe) 412 if (!pci_probe)
376 return -ENXIO; 413 return -ENXIO;
377 414
diff --git a/arch/ia64/include/asm/paravirt_privop.h b/arch/ia64/include/asm/paravirt_privop.h
index 3d2951130b5f..8f6cb11c9fae 100644
--- a/arch/ia64/include/asm/paravirt_privop.h
+++ b/arch/ia64/include/asm/paravirt_privop.h
@@ -445,7 +445,6 @@ paravirt_set_rr0_to_rr4(unsigned long val0, unsigned long val1,
445 register unsigned long ia64_intri_res asm ("r8"); \ 445 register unsigned long ia64_intri_res asm ("r8"); \
446 register unsigned long __reg asm ("r8") = (reg); \ 446 register unsigned long __reg asm ("r8") = (reg); \
447 \ 447 \
448 BUILD_BUG_ON(!__builtin_constant_p(reg)); \
449 asm volatile (paravirt_alt_bundle(__PARAVIRT_BR, \ 448 asm volatile (paravirt_alt_bundle(__PARAVIRT_BR, \
450 PARAVIRT_TYPE(GETREG) \ 449 PARAVIRT_TYPE(GETREG) \
451 + (reg)) \ 450 + (reg)) \
@@ -464,7 +463,6 @@ paravirt_set_rr0_to_rr4(unsigned long val0, unsigned long val1,
464 register unsigned long ia64_clobber1 asm ("r8"); \ 463 register unsigned long ia64_clobber1 asm ("r8"); \
465 register unsigned long ia64_clobber2 asm ("r9"); \ 464 register unsigned long ia64_clobber2 asm ("r9"); \
466 \ 465 \
467 BUILD_BUG_ON(!__builtin_constant_p(reg)); \
468 asm volatile (paravirt_alt_bundle(__PARAVIRT_BR, \ 466 asm volatile (paravirt_alt_bundle(__PARAVIRT_BR, \
469 PARAVIRT_TYPE(SETREG) \ 467 PARAVIRT_TYPE(SETREG) \
470 + (reg)) \ 468 + (reg)) \
diff --git a/arch/ia64/kernel/cyclone.c b/arch/ia64/kernel/cyclone.c
index 790ef0d87e12..71e35864d2e2 100644
--- a/arch/ia64/kernel/cyclone.c
+++ b/arch/ia64/kernel/cyclone.c
@@ -21,7 +21,7 @@ void __init cyclone_setup(void)
21 21
22static void __iomem *cyclone_mc; 22static void __iomem *cyclone_mc;
23 23
24static cycle_t read_cyclone(void) 24static cycle_t read_cyclone(struct clocksource *cs)
25{ 25{
26 return (cycle_t)readq((void __iomem *)cyclone_mc); 26 return (cycle_t)readq((void __iomem *)cyclone_mc);
27} 27}
diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c
index 2ea4199d9c57..5230eaafd83f 100644
--- a/arch/ia64/kernel/smp.c
+++ b/arch/ia64/kernel/smp.c
@@ -225,6 +225,7 @@ smp_send_reschedule (int cpu)
225{ 225{
226 platform_send_ipi(cpu, IA64_IPI_RESCHEDULE, IA64_IPI_DM_INT, 0); 226 platform_send_ipi(cpu, IA64_IPI_RESCHEDULE, IA64_IPI_DM_INT, 0);
227} 227}
228EXPORT_SYMBOL_GPL(smp_send_reschedule);
228 229
229/* 230/*
230 * Called with preemption disabled. 231 * Called with preemption disabled.
@@ -300,15 +301,12 @@ smp_flush_tlb_mm (struct mm_struct *mm)
300 return; 301 return;
301 } 302 }
302 303
304 smp_call_function_mask(mm->cpu_vm_mask,
305 (void (*)(void *))local_finish_flush_tlb_mm, mm, 1);
306 local_irq_disable();
307 local_finish_flush_tlb_mm(mm);
308 local_irq_enable();
303 preempt_enable(); 309 preempt_enable();
304 /*
305 * We could optimize this further by using mm->cpu_vm_mask to track which CPUs
306 * have been running in the address space. It's not clear that this is worth the
307 * trouble though: to avoid races, we have to raise the IPI on the target CPU
308 * anyhow, and once a CPU is interrupted, the cost of local_flush_tlb_all() is
309 * rather trivial.
310 */
311 on_each_cpu((void (*)(void *))local_finish_flush_tlb_mm, mm, 1);
312} 310}
313 311
314void arch_send_call_function_single_ipi(int cpu) 312void arch_send_call_function_single_ipi(int cpu)
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c
index 641c8b61c4f1..604c1a35db33 100644
--- a/arch/ia64/kernel/time.c
+++ b/arch/ia64/kernel/time.c
@@ -33,7 +33,7 @@
33 33
34#include "fsyscall_gtod_data.h" 34#include "fsyscall_gtod_data.h"
35 35
36static cycle_t itc_get_cycles(void); 36static cycle_t itc_get_cycles(struct clocksource *cs);
37 37
38struct fsyscall_gtod_data_t fsyscall_gtod_data = { 38struct fsyscall_gtod_data_t fsyscall_gtod_data = {
39 .lock = SEQLOCK_UNLOCKED, 39 .lock = SEQLOCK_UNLOCKED,
@@ -383,7 +383,7 @@ ia64_init_itm (void)
383 } 383 }
384} 384}
385 385
386static cycle_t itc_get_cycles(void) 386static cycle_t itc_get_cycles(struct clocksource *cs)
387{ 387{
388 u64 lcycle, now, ret; 388 u64 lcycle, now, ret;
389 389
diff --git a/arch/ia64/sn/kernel/sn2/timer.c b/arch/ia64/sn/kernel/sn2/timer.c
index cf67fc562054..21d6f09e3447 100644
--- a/arch/ia64/sn/kernel/sn2/timer.c
+++ b/arch/ia64/sn/kernel/sn2/timer.c
@@ -23,7 +23,7 @@
23 23
24extern unsigned long sn_rtc_cycles_per_second; 24extern unsigned long sn_rtc_cycles_per_second;
25 25
26static cycle_t read_sn2(void) 26static cycle_t read_sn2(struct clocksource *cs)
27{ 27{
28 return (cycle_t)readq(RTC_COUNTER_ADDR); 28 return (cycle_t)readq(RTC_COUNTER_ADDR);
29} 29}
diff --git a/arch/m68knommu/platform/68328/timers.c b/arch/m68knommu/platform/68328/timers.c
index 6bafefa546e5..309f725995bf 100644
--- a/arch/m68knommu/platform/68328/timers.c
+++ b/arch/m68knommu/platform/68328/timers.c
@@ -75,7 +75,7 @@ static struct irqaction m68328_timer_irq = {
75 75
76/***************************************************************************/ 76/***************************************************************************/
77 77
78static cycle_t m68328_read_clk(void) 78static cycle_t m68328_read_clk(struct clocksource *cs)
79{ 79{
80 unsigned long flags; 80 unsigned long flags;
81 u32 cycles; 81 u32 cycles;
diff --git a/arch/m68knommu/platform/coldfire/dma_timer.c b/arch/m68knommu/platform/coldfire/dma_timer.c
index 772578b1084f..a5f562823d7a 100644
--- a/arch/m68knommu/platform/coldfire/dma_timer.c
+++ b/arch/m68knommu/platform/coldfire/dma_timer.c
@@ -34,7 +34,7 @@
34#define DMA_DTMR_CLK_DIV_16 (2 << 1) 34#define DMA_DTMR_CLK_DIV_16 (2 << 1)
35#define DMA_DTMR_ENABLE (1 << 0) 35#define DMA_DTMR_ENABLE (1 << 0)
36 36
37static cycle_t cf_dt_get_cycles(void) 37static cycle_t cf_dt_get_cycles(struct clocksource *cs)
38{ 38{
39 return __raw_readl(DTCN0); 39 return __raw_readl(DTCN0);
40} 40}
diff --git a/arch/m68knommu/platform/coldfire/pit.c b/arch/m68knommu/platform/coldfire/pit.c
index 2a12e7fa9748..61b96211f8ff 100644
--- a/arch/m68knommu/platform/coldfire/pit.c
+++ b/arch/m68knommu/platform/coldfire/pit.c
@@ -125,7 +125,7 @@ static struct irqaction pit_irq = {
125 125
126/***************************************************************************/ 126/***************************************************************************/
127 127
128static cycle_t pit_read_clk(void) 128static cycle_t pit_read_clk(struct clocksource *cs)
129{ 129{
130 unsigned long flags; 130 unsigned long flags;
131 u32 cycles; 131 u32 cycles;
diff --git a/arch/m68knommu/platform/coldfire/timers.c b/arch/m68knommu/platform/coldfire/timers.c
index 454f25493491..1ba8a3731653 100644
--- a/arch/m68knommu/platform/coldfire/timers.c
+++ b/arch/m68knommu/platform/coldfire/timers.c
@@ -78,7 +78,7 @@ static struct irqaction mcftmr_timer_irq = {
78 78
79/***************************************************************************/ 79/***************************************************************************/
80 80
81static cycle_t mcftmr_read_clk(void) 81static cycle_t mcftmr_read_clk(struct clocksource *cs)
82{ 82{
83 unsigned long flags; 83 unsigned long flags;
84 u32 cycles; 84 u32 cycles;
diff --git a/arch/mips/kernel/cevt-txx9.c b/arch/mips/kernel/cevt-txx9.c
index eccf7d6096bd..2e911e3da8d3 100644
--- a/arch/mips/kernel/cevt-txx9.c
+++ b/arch/mips/kernel/cevt-txx9.c
@@ -22,7 +22,7 @@
22 22
23static struct txx9_tmr_reg __iomem *txx9_cs_tmrptr; 23static struct txx9_tmr_reg __iomem *txx9_cs_tmrptr;
24 24
25static cycle_t txx9_cs_read(void) 25static cycle_t txx9_cs_read(struct clocksource *cs)
26{ 26{
27 return __raw_readl(&txx9_cs_tmrptr->trr); 27 return __raw_readl(&txx9_cs_tmrptr->trr);
28} 28}
diff --git a/arch/mips/kernel/csrc-bcm1480.c b/arch/mips/kernel/csrc-bcm1480.c
index 868745e7184b..51489f8a825e 100644
--- a/arch/mips/kernel/csrc-bcm1480.c
+++ b/arch/mips/kernel/csrc-bcm1480.c
@@ -28,7 +28,7 @@
28 28
29#include <asm/sibyte/sb1250.h> 29#include <asm/sibyte/sb1250.h>
30 30
31static cycle_t bcm1480_hpt_read(void) 31static cycle_t bcm1480_hpt_read(struct clocksource *cs)
32{ 32{
33 return (cycle_t) __raw_readq(IOADDR(A_SCD_ZBBUS_CYCLE_COUNT)); 33 return (cycle_t) __raw_readq(IOADDR(A_SCD_ZBBUS_CYCLE_COUNT));
34} 34}
diff --git a/arch/mips/kernel/csrc-ioasic.c b/arch/mips/kernel/csrc-ioasic.c
index 1d5f63cf8997..b551f48d3a07 100644
--- a/arch/mips/kernel/csrc-ioasic.c
+++ b/arch/mips/kernel/csrc-ioasic.c
@@ -25,7 +25,7 @@
25#include <asm/dec/ioasic.h> 25#include <asm/dec/ioasic.h>
26#include <asm/dec/ioasic_addrs.h> 26#include <asm/dec/ioasic_addrs.h>
27 27
28static cycle_t dec_ioasic_hpt_read(void) 28static cycle_t dec_ioasic_hpt_read(struct clocksource *cs)
29{ 29{
30 return ioasic_read(IO_REG_FCTR); 30 return ioasic_read(IO_REG_FCTR);
31} 31}
@@ -47,13 +47,13 @@ void __init dec_ioasic_clocksource_init(void)
47 while (!ds1287_timer_state()) 47 while (!ds1287_timer_state())
48 ; 48 ;
49 49
50 start = dec_ioasic_hpt_read(); 50 start = dec_ioasic_hpt_read(&clocksource_dec);
51 51
52 while (i--) 52 while (i--)
53 while (!ds1287_timer_state()) 53 while (!ds1287_timer_state())
54 ; 54 ;
55 55
56 end = dec_ioasic_hpt_read(); 56 end = dec_ioasic_hpt_read(&clocksource_dec);
57 57
58 freq = (end - start) * 10; 58 freq = (end - start) * 10;
59 printk(KERN_INFO "I/O ASIC clock frequency %dHz\n", freq); 59 printk(KERN_INFO "I/O ASIC clock frequency %dHz\n", freq);
diff --git a/arch/mips/kernel/csrc-r4k.c b/arch/mips/kernel/csrc-r4k.c
index f1a2893931ed..e95a3cd48eea 100644
--- a/arch/mips/kernel/csrc-r4k.c
+++ b/arch/mips/kernel/csrc-r4k.c
@@ -10,7 +10,7 @@
10 10
11#include <asm/time.h> 11#include <asm/time.h>
12 12
13static cycle_t c0_hpt_read(void) 13static cycle_t c0_hpt_read(struct clocksource *cs)
14{ 14{
15 return read_c0_count(); 15 return read_c0_count();
16} 16}
diff --git a/arch/mips/kernel/csrc-sb1250.c b/arch/mips/kernel/csrc-sb1250.c
index 92212bbb8e45..d14d3d1907fa 100644
--- a/arch/mips/kernel/csrc-sb1250.c
+++ b/arch/mips/kernel/csrc-sb1250.c
@@ -33,7 +33,7 @@
33 * The HPT is free running from SB1250_HPT_VALUE down to 0 then starts over 33 * The HPT is free running from SB1250_HPT_VALUE down to 0 then starts over
34 * again. 34 * again.
35 */ 35 */
36static cycle_t sb1250_hpt_read(void) 36static cycle_t sb1250_hpt_read(struct clocksource *cs)
37{ 37{
38 unsigned int count; 38 unsigned int count;
39 39
diff --git a/arch/mips/kernel/i8253.c b/arch/mips/kernel/i8253.c
index 689719e34f08..ed20e7fe65e3 100644
--- a/arch/mips/kernel/i8253.c
+++ b/arch/mips/kernel/i8253.c
@@ -128,7 +128,7 @@ void __init setup_pit_timer(void)
128 * to just read by itself. So use jiffies to emulate a free 128 * to just read by itself. So use jiffies to emulate a free
129 * running counter: 129 * running counter:
130 */ 130 */
131static cycle_t pit_read(void) 131static cycle_t pit_read(struct clocksource *cs)
132{ 132{
133 unsigned long flags; 133 unsigned long flags;
134 int count; 134 int count;
diff --git a/arch/mips/nxp/pnx8550/common/time.c b/arch/mips/nxp/pnx8550/common/time.c
index cf293b279098..8df43e9e4d90 100644
--- a/arch/mips/nxp/pnx8550/common/time.c
+++ b/arch/mips/nxp/pnx8550/common/time.c
@@ -35,7 +35,7 @@
35 35
36static unsigned long cpj; 36static unsigned long cpj;
37 37
38static cycle_t hpt_read(void) 38static cycle_t hpt_read(struct clocksource *cs)
39{ 39{
40 return read_c0_count2(); 40 return read_c0_count2();
41} 41}
diff --git a/arch/mips/sgi-ip27/ip27-timer.c b/arch/mips/sgi-ip27/ip27-timer.c
index f024057a35f8..f10a7cd64f7e 100644
--- a/arch/mips/sgi-ip27/ip27-timer.c
+++ b/arch/mips/sgi-ip27/ip27-timer.c
@@ -159,7 +159,7 @@ static void __init hub_rt_clock_event_global_init(void)
159 setup_irq(irq, &hub_rt_irqaction); 159 setup_irq(irq, &hub_rt_irqaction);
160} 160}
161 161
162static cycle_t hub_rt_read(void) 162static cycle_t hub_rt_read(struct clocksource *cs)
163{ 163{
164 return REMOTE_HUB_L(cputonasid(0), PI_RT_COUNT); 164 return REMOTE_HUB_L(cputonasid(0), PI_RT_COUNT);
165} 165}
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 926ea864e34f..48571ac56fb7 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -77,7 +77,7 @@
77#include <linux/clockchips.h> 77#include <linux/clockchips.h>
78#include <linux/clocksource.h> 78#include <linux/clocksource.h>
79 79
80static cycle_t rtc_read(void); 80static cycle_t rtc_read(struct clocksource *);
81static struct clocksource clocksource_rtc = { 81static struct clocksource clocksource_rtc = {
82 .name = "rtc", 82 .name = "rtc",
83 .rating = 400, 83 .rating = 400,
@@ -88,7 +88,7 @@ static struct clocksource clocksource_rtc = {
88 .read = rtc_read, 88 .read = rtc_read,
89}; 89};
90 90
91static cycle_t timebase_read(void); 91static cycle_t timebase_read(struct clocksource *);
92static struct clocksource clocksource_timebase = { 92static struct clocksource clocksource_timebase = {
93 .name = "timebase", 93 .name = "timebase",
94 .rating = 400, 94 .rating = 400,
@@ -766,12 +766,12 @@ unsigned long read_persistent_clock(void)
766} 766}
767 767
768/* clocksource code */ 768/* clocksource code */
769static cycle_t rtc_read(void) 769static cycle_t rtc_read(struct clocksource *cs)
770{ 770{
771 return (cycle_t)get_rtc(); 771 return (cycle_t)get_rtc();
772} 772}
773 773
774static cycle_t timebase_read(void) 774static cycle_t timebase_read(struct clocksource *cs)
775{ 775{
776 return (cycle_t)get_tb(); 776 return (cycle_t)get_tb();
777} 777}
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
index 6cc87d8c8682..002c70d3cb75 100644
--- a/arch/s390/kernel/compat_linux.c
+++ b/arch/s390/kernel/compat_linux.c
@@ -702,20 +702,12 @@ asmlinkage long sys32_fstatat64(unsigned int dfd, char __user *filename,
702 struct stat64_emu31 __user* statbuf, int flag) 702 struct stat64_emu31 __user* statbuf, int flag)
703{ 703{
704 struct kstat stat; 704 struct kstat stat;
705 int error = -EINVAL; 705 int error;
706
707 if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
708 goto out;
709
710 if (flag & AT_SYMLINK_NOFOLLOW)
711 error = vfs_lstat_fd(dfd, filename, &stat);
712 else
713 error = vfs_stat_fd(dfd, filename, &stat);
714 706
715 if (!error) 707 error = vfs_fstatat(dfd, filename, &stat, flag);
716 error = cp_stat64(statbuf, &stat); 708 if (error)
717out: 709 return error;
718 return error; 710 return cp_stat64(statbuf, &stat);
719} 711}
720 712
721/* 713/*
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
index 6ded50dfa75a..ef596d020573 100644
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -201,7 +201,7 @@ unsigned long read_persistent_clock(void)
201 return ts.tv_sec; 201 return ts.tv_sec;
202} 202}
203 203
204static cycle_t read_tod_clock(void) 204static cycle_t read_tod_clock(struct clocksource *cs)
205{ 205{
206 return get_clock(); 206 return get_clock();
207} 207}
diff --git a/arch/sh/kernel/sys_sh.c b/arch/sh/kernel/sys_sh.c
index 58dfc02c7af1..e3a7e36639ef 100644
--- a/arch/sh/kernel/sys_sh.c
+++ b/arch/sh/kernel/sys_sh.c
@@ -63,6 +63,15 @@ asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
63 unsigned long prot, unsigned long flags, 63 unsigned long prot, unsigned long flags,
64 unsigned long fd, unsigned long pgoff) 64 unsigned long fd, unsigned long pgoff)
65{ 65{
66 /*
67 * The shift for mmap2 is constant, regardless of PAGE_SIZE
68 * setting.
69 */
70 if (pgoff & ((1 << (PAGE_SHIFT - 12)) - 1))
71 return -EINVAL;
72
73 pgoff >>= PAGE_SHIFT - 12;
74
66 return do_mmap2(addr, len, prot, flags, fd, pgoff); 75 return do_mmap2(addr, len, prot, flags, fd, pgoff);
67} 76}
68 77
diff --git a/arch/sh/kernel/time_32.c b/arch/sh/kernel/time_32.c
index 04b8c6ab1667..c770413c3213 100644
--- a/arch/sh/kernel/time_32.c
+++ b/arch/sh/kernel/time_32.c
@@ -209,7 +209,7 @@ unsigned long long sched_clock(void)
209 if (!clocksource_sh.rating) 209 if (!clocksource_sh.rating)
210 return (unsigned long long)jiffies * (NSEC_PER_SEC / HZ); 210 return (unsigned long long)jiffies * (NSEC_PER_SEC / HZ);
211 211
212 cycles = clocksource_sh.read(); 212 cycles = clocksource_sh.read(&clocksource_sh);
213 return cyc2ns(&clocksource_sh, cycles); 213 return cyc2ns(&clocksource_sh, cycles);
214} 214}
215#endif 215#endif
diff --git a/arch/sh/kernel/timers/timer-tmu.c b/arch/sh/kernel/timers/timer-tmu.c
index c5d3396f5960..fe8d8930ccb6 100644
--- a/arch/sh/kernel/timers/timer-tmu.c
+++ b/arch/sh/kernel/timers/timer-tmu.c
@@ -81,7 +81,7 @@ static int tmu_timer_stop(void)
81 */ 81 */
82static int tmus_are_scaled; 82static int tmus_are_scaled;
83 83
84static cycle_t tmu_timer_read(void) 84static cycle_t tmu_timer_read(struct clocksource *cs)
85{ 85{
86 return ((cycle_t)(~_tmu_read(TMU1)))<<tmus_are_scaled; 86 return ((cycle_t)(~_tmu_read(TMU1)))<<tmus_are_scaled;
87} 87}
diff --git a/arch/sparc/kernel/sys_sparc32.c b/arch/sparc/kernel/sys_sparc32.c
index e800503879e4..f5000a460c05 100644
--- a/arch/sparc/kernel/sys_sparc32.c
+++ b/arch/sparc/kernel/sys_sparc32.c
@@ -206,21 +206,12 @@ asmlinkage long compat_sys_fstatat64(unsigned int dfd, char __user *filename,
206 struct compat_stat64 __user * statbuf, int flag) 206 struct compat_stat64 __user * statbuf, int flag)
207{ 207{
208 struct kstat stat; 208 struct kstat stat;
209 int error = -EINVAL; 209 int error;
210
211 if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
212 goto out;
213
214 if (flag & AT_SYMLINK_NOFOLLOW)
215 error = vfs_lstat_fd(dfd, filename, &stat);
216 else
217 error = vfs_stat_fd(dfd, filename, &stat);
218
219 if (!error)
220 error = cp_compat_stat64(&stat, statbuf);
221 210
222out: 211 error = vfs_fstatat(dfd, filename, &stat, flag);
223 return error; 212 if (error)
213 return error;
214 return cp_compat_stat64(&stat, statbuf);
224} 215}
225 216
226asmlinkage long compat_sys_sysfs(int option, u32 arg1, u32 arg2) 217asmlinkage long compat_sys_sysfs(int option, u32 arg1, u32 arg2)
diff --git a/arch/sparc/kernel/time_64.c b/arch/sparc/kernel/time_64.c
index db310aa00183..5c12e79b4bdf 100644
--- a/arch/sparc/kernel/time_64.c
+++ b/arch/sparc/kernel/time_64.c
@@ -814,6 +814,11 @@ void udelay(unsigned long usecs)
814} 814}
815EXPORT_SYMBOL(udelay); 815EXPORT_SYMBOL(udelay);
816 816
817static cycle_t clocksource_tick_read(struct clocksource *cs)
818{
819 return tick_ops->get_tick();
820}
821
817void __init time_init(void) 822void __init time_init(void)
818{ 823{
819 unsigned long freq = sparc64_init_timers(); 824 unsigned long freq = sparc64_init_timers();
@@ -827,7 +832,7 @@ void __init time_init(void)
827 clocksource_tick.mult = 832 clocksource_tick.mult =
828 clocksource_hz2mult(freq, 833 clocksource_hz2mult(freq,
829 clocksource_tick.shift); 834 clocksource_tick.shift);
830 clocksource_tick.read = tick_ops->get_tick; 835 clocksource_tick.read = clocksource_tick_read;
831 836
832 printk("clocksource: mult[%x] shift[%d]\n", 837 printk("clocksource: mult[%x] shift[%d]\n",
833 clocksource_tick.mult, clocksource_tick.shift); 838 clocksource_tick.mult, clocksource_tick.shift);
diff --git a/arch/um/Kconfig.rest b/arch/um/Kconfig.rest
index 7b5cea75a6c4..0ccad0ff6d6e 100644
--- a/arch/um/Kconfig.rest
+++ b/arch/um/Kconfig.rest
@@ -36,7 +36,7 @@ source "drivers/leds/Kconfig"
36 36
37#This is just to shut up some Kconfig warnings, so no prompt. 37#This is just to shut up some Kconfig warnings, so no prompt.
38config INPUT 38config INPUT
39 bool 39 tristate
40 default n 40 default n
41 41
42source "arch/um/Kconfig.debug" 42source "arch/um/Kconfig.debug"
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c
index b13a87a3ec95..c8b9c469fcd7 100644
--- a/arch/um/kernel/time.c
+++ b/arch/um/kernel/time.c
@@ -65,7 +65,7 @@ static irqreturn_t um_timer(int irq, void *dev)
65 return IRQ_HANDLED; 65 return IRQ_HANDLED;
66} 66}
67 67
68static cycle_t itimer_read(void) 68static cycle_t itimer_read(struct clocksource *cs)
69{ 69{
70 return os_nsecs() / 1000; 70 return os_nsecs() / 1000;
71} 71}
diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
index efac92fd1efb..085a8c35f149 100644
--- a/arch/x86/ia32/sys_ia32.c
+++ b/arch/x86/ia32/sys_ia32.c
@@ -129,21 +129,12 @@ asmlinkage long sys32_fstatat(unsigned int dfd, char __user *filename,
129 struct stat64 __user *statbuf, int flag) 129 struct stat64 __user *statbuf, int flag)
130{ 130{
131 struct kstat stat; 131 struct kstat stat;
132 int error = -EINVAL; 132 int error;
133 133
134 if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0) 134 error = vfs_fstatat(dfd, filename, &stat, flag);
135 goto out; 135 if (error)
136 136 return error;
137 if (flag & AT_SYMLINK_NOFOLLOW) 137 return cp_stat64(statbuf, &stat);
138 error = vfs_lstat_fd(dfd, filename, &stat);
139 else
140 error = vfs_stat_fd(dfd, filename, &stat);
141
142 if (!error)
143 error = cp_stat64(statbuf, &stat);
144
145out:
146 return error;
147} 138}
148 139
149/* 140/*
diff --git a/arch/x86/include/asm/lguest_hcall.h b/arch/x86/include/asm/lguest_hcall.h
index 0f4ee7148afe..faae1996487b 100644
--- a/arch/x86/include/asm/lguest_hcall.h
+++ b/arch/x86/include/asm/lguest_hcall.h
@@ -5,7 +5,6 @@
5#define LHCALL_FLUSH_ASYNC 0 5#define LHCALL_FLUSH_ASYNC 0
6#define LHCALL_LGUEST_INIT 1 6#define LHCALL_LGUEST_INIT 1
7#define LHCALL_SHUTDOWN 2 7#define LHCALL_SHUTDOWN 2
8#define LHCALL_LOAD_GDT 3
9#define LHCALL_NEW_PGTABLE 4 8#define LHCALL_NEW_PGTABLE 4
10#define LHCALL_FLUSH_TLB 5 9#define LHCALL_FLUSH_TLB 5
11#define LHCALL_LOAD_IDT_ENTRY 6 10#define LHCALL_LOAD_IDT_ENTRY 6
@@ -17,6 +16,7 @@
17#define LHCALL_SET_PMD 15 16#define LHCALL_SET_PMD 15
18#define LHCALL_LOAD_TLS 16 17#define LHCALL_LOAD_TLS 16
19#define LHCALL_NOTIFY 17 18#define LHCALL_NOTIFY 17
19#define LHCALL_LOAD_GDT_ENTRY 18
20 20
21#define LGUEST_TRAP_ENTRY 0x1F 21#define LGUEST_TRAP_ENTRY 0x1F
22 22
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 648b3a2a3a44..3f0019e0a229 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -722,7 +722,7 @@ static int hpet_cpuhp_notify(struct notifier_block *n,
722/* 722/*
723 * Clock source related code 723 * Clock source related code
724 */ 724 */
725static cycle_t read_hpet(void) 725static cycle_t read_hpet(struct clocksource *cs)
726{ 726{
727 return (cycle_t)hpet_readl(HPET_COUNTER); 727 return (cycle_t)hpet_readl(HPET_COUNTER);
728} 728}
@@ -756,7 +756,7 @@ static int hpet_clocksource_register(void)
756 hpet_restart_counter(); 756 hpet_restart_counter();
757 757
758 /* Verify whether hpet counter works */ 758 /* Verify whether hpet counter works */
759 t1 = read_hpet(); 759 t1 = hpet_readl(HPET_COUNTER);
760 rdtscll(start); 760 rdtscll(start);
761 761
762 /* 762 /*
@@ -770,7 +770,7 @@ static int hpet_clocksource_register(void)
770 rdtscll(now); 770 rdtscll(now);
771 } while ((now - start) < 200000UL); 771 } while ((now - start) < 200000UL);
772 772
773 if (t1 == read_hpet()) { 773 if (t1 == hpet_readl(HPET_COUNTER)) {
774 printk(KERN_WARNING 774 printk(KERN_WARNING
775 "HPET counter not counting. HPET disabled\n"); 775 "HPET counter not counting. HPET disabled\n");
776 return -ENODEV; 776 return -ENODEV;
diff --git a/arch/x86/kernel/i8253.c b/arch/x86/kernel/i8253.c
index 3475440baa54..c2e0bb0890d4 100644
--- a/arch/x86/kernel/i8253.c
+++ b/arch/x86/kernel/i8253.c
@@ -129,7 +129,7 @@ void __init setup_pit_timer(void)
129 * to just read by itself. So use jiffies to emulate a free 129 * to just read by itself. So use jiffies to emulate a free
130 * running counter: 130 * running counter:
131 */ 131 */
132static cycle_t pit_read(void) 132static cycle_t pit_read(struct clocksource *cs)
133{ 133{
134 static int old_count; 134 static int old_count;
135 static u32 old_jifs; 135 static u32 old_jifs;
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index 137f2e8132df..223af43f1526 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -77,6 +77,11 @@ static cycle_t kvm_clock_read(void)
77 return ret; 77 return ret;
78} 78}
79 79
80static cycle_t kvm_clock_get_cycles(struct clocksource *cs)
81{
82 return kvm_clock_read();
83}
84
80/* 85/*
81 * If we don't do that, there is the possibility that the guest 86 * If we don't do that, there is the possibility that the guest
82 * will calibrate under heavy load - thus, getting a lower lpj - 87 * will calibrate under heavy load - thus, getting a lower lpj -
@@ -107,7 +112,7 @@ static void kvm_get_preset_lpj(void)
107 112
108static struct clocksource kvm_clock = { 113static struct clocksource kvm_clock = {
109 .name = "kvm-clock", 114 .name = "kvm-clock",
110 .read = kvm_clock_read, 115 .read = kvm_clock_get_cycles,
111 .rating = 400, 116 .rating = 400,
112 .mask = CLOCKSOURCE_MASK(64), 117 .mask = CLOCKSOURCE_MASK(64),
113 .mult = 1 << KVM_SCALE, 118 .mult = 1 << KVM_SCALE,
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 7a567ebe6361..d57de05dc430 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -699,7 +699,7 @@ static struct clocksource clocksource_tsc;
699 * code, which is necessary to support wrapping clocksources like pm 699 * code, which is necessary to support wrapping clocksources like pm
700 * timer. 700 * timer.
701 */ 701 */
702static cycle_t read_tsc(void) 702static cycle_t read_tsc(struct clocksource *cs)
703{ 703{
704 cycle_t ret = (cycle_t)get_cycles(); 704 cycle_t ret = (cycle_t)get_cycles();
705 705
diff --git a/arch/x86/kernel/vmiclock_32.c b/arch/x86/kernel/vmiclock_32.c
index d303369a7bad..2b3eb82efeeb 100644
--- a/arch/x86/kernel/vmiclock_32.c
+++ b/arch/x86/kernel/vmiclock_32.c
@@ -283,7 +283,7 @@ void __devinit vmi_time_ap_init(void)
283/** vmi clocksource */ 283/** vmi clocksource */
284static struct clocksource clocksource_vmi; 284static struct clocksource clocksource_vmi;
285 285
286static cycle_t read_real_cycles(void) 286static cycle_t read_real_cycles(struct clocksource *cs)
287{ 287{
288 cycle_t ret = (cycle_t)vmi_timer_ops.get_cycle_counter(VMI_CYCLES_REAL); 288 cycle_t ret = (cycle_t)vmi_timer_ops.get_cycle_counter(VMI_CYCLES_REAL);
289 return max(ret, clocksource_vmi.cycle_last); 289 return max(ret, clocksource_vmi.cycle_last);
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index e94a11e42f98..ca7ec44bafc3 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -273,15 +273,15 @@ static void lguest_load_idt(const struct desc_ptr *desc)
273 * controls the entire thing and the Guest asks it to make changes using the 273 * controls the entire thing and the Guest asks it to make changes using the
274 * LOAD_GDT hypercall. 274 * LOAD_GDT hypercall.
275 * 275 *
276 * This is the opposite of the IDT code where we have a LOAD_IDT_ENTRY 276 * This is the exactly like the IDT code.
277 * hypercall and use that repeatedly to load a new IDT. I don't think it
278 * really matters, but wouldn't it be nice if they were the same? Wouldn't
279 * it be even better if you were the one to send the patch to fix it?
280 */ 277 */
281static void lguest_load_gdt(const struct desc_ptr *desc) 278static void lguest_load_gdt(const struct desc_ptr *desc)
282{ 279{
283 BUG_ON((desc->size + 1) / 8 != GDT_ENTRIES); 280 unsigned int i;
284 kvm_hypercall2(LHCALL_LOAD_GDT, __pa(desc->address), GDT_ENTRIES); 281 struct desc_struct *gdt = (void *)desc->address;
282
283 for (i = 0; i < (desc->size+1)/8; i++)
284 kvm_hypercall3(LHCALL_LOAD_GDT_ENTRY, i, gdt[i].a, gdt[i].b);
285} 285}
286 286
287/* For a single GDT entry which changes, we do the lazy thing: alter our GDT, 287/* For a single GDT entry which changes, we do the lazy thing: alter our GDT,
@@ -291,7 +291,9 @@ static void lguest_write_gdt_entry(struct desc_struct *dt, int entrynum,
291 const void *desc, int type) 291 const void *desc, int type)
292{ 292{
293 native_write_gdt_entry(dt, entrynum, desc, type); 293 native_write_gdt_entry(dt, entrynum, desc, type);
294 kvm_hypercall2(LHCALL_LOAD_GDT, __pa(dt), GDT_ENTRIES); 294 /* Tell Host about this new entry. */
295 kvm_hypercall3(LHCALL_LOAD_GDT_ENTRY, entrynum,
296 dt[entrynum].a, dt[entrynum].b);
295} 297}
296 298
297/* OK, I lied. There are three "thread local storage" GDT entries which change 299/* OK, I lied. There are three "thread local storage" GDT entries which change
@@ -661,7 +663,7 @@ static unsigned long lguest_tsc_khz(void)
661 663
662/* If we can't use the TSC, the kernel falls back to our lower-priority 664/* If we can't use the TSC, the kernel falls back to our lower-priority
663 * "lguest_clock", where we read the time value given to us by the Host. */ 665 * "lguest_clock", where we read the time value given to us by the Host. */
664static cycle_t lguest_clock_read(void) 666static cycle_t lguest_clock_read(struct clocksource *cs)
665{ 667{
666 unsigned long sec, nsec; 668 unsigned long sec, nsec;
667 669
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 14f240623497..0a5aa44299a5 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -213,6 +213,11 @@ cycle_t xen_clocksource_read(void)
213 return ret; 213 return ret;
214} 214}
215 215
216static cycle_t xen_clocksource_get_cycles(struct clocksource *cs)
217{
218 return xen_clocksource_read();
219}
220
216static void xen_read_wallclock(struct timespec *ts) 221static void xen_read_wallclock(struct timespec *ts)
217{ 222{
218 struct shared_info *s = HYPERVISOR_shared_info; 223 struct shared_info *s = HYPERVISOR_shared_info;
@@ -241,7 +246,7 @@ int xen_set_wallclock(unsigned long now)
241static struct clocksource xen_clocksource __read_mostly = { 246static struct clocksource xen_clocksource __read_mostly = {
242 .name = "xen", 247 .name = "xen",
243 .rating = 400, 248 .rating = 400,
244 .read = xen_clocksource_read, 249 .read = xen_clocksource_get_cycles,
245 .mask = ~0, 250 .mask = ~0,
246 .mult = 1<<XEN_SHIFT, /* time directly in nanoseconds */ 251 .mult = 1<<XEN_SHIFT, /* time directly in nanoseconds */
247 .shift = XEN_SHIFT, 252 .shift = XEN_SHIFT,
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 779e4e500df4..d060e6fd7fd5 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -300,9 +300,9 @@ static int acpi_suspend_state_valid(suspend_state_t pm_state)
300static struct platform_suspend_ops acpi_suspend_ops = { 300static struct platform_suspend_ops acpi_suspend_ops = {
301 .valid = acpi_suspend_state_valid, 301 .valid = acpi_suspend_state_valid,
302 .begin = acpi_suspend_begin, 302 .begin = acpi_suspend_begin,
303 .prepare = acpi_pm_prepare, 303 .prepare_late = acpi_pm_prepare,
304 .enter = acpi_suspend_enter, 304 .enter = acpi_suspend_enter,
305 .finish = acpi_pm_finish, 305 .wake = acpi_pm_finish,
306 .end = acpi_pm_end, 306 .end = acpi_pm_end,
307}; 307};
308 308
@@ -328,9 +328,9 @@ static int acpi_suspend_begin_old(suspend_state_t pm_state)
328static struct platform_suspend_ops acpi_suspend_ops_old = { 328static struct platform_suspend_ops acpi_suspend_ops_old = {
329 .valid = acpi_suspend_state_valid, 329 .valid = acpi_suspend_state_valid,
330 .begin = acpi_suspend_begin_old, 330 .begin = acpi_suspend_begin_old,
331 .prepare = acpi_pm_disable_gpes, 331 .prepare_late = acpi_pm_disable_gpes,
332 .enter = acpi_suspend_enter, 332 .enter = acpi_suspend_enter,
333 .finish = acpi_pm_finish, 333 .wake = acpi_pm_finish,
334 .end = acpi_pm_end, 334 .end = acpi_pm_end,
335 .recover = acpi_pm_finish, 335 .recover = acpi_pm_finish,
336}; 336};
diff --git a/drivers/base/core.c b/drivers/base/core.c
index d230ff4b3eec..4aa527b8a913 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -891,7 +891,8 @@ int device_add(struct device *dev)
891 set_dev_node(dev, dev_to_node(parent)); 891 set_dev_node(dev, dev_to_node(parent));
892 892
893 /* first, register with generic layer. */ 893 /* first, register with generic layer. */
894 error = kobject_add(&dev->kobj, dev->kobj.parent, "%s", dev_name(dev)); 894 /* we require the name to be set before, and pass NULL */
895 error = kobject_add(&dev->kobj, dev->kobj.parent, NULL);
895 if (error) 896 if (error)
896 goto Error; 897 goto Error;
897 898
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index 10d6cbd7c05e..2224b762b7fb 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -1226,7 +1226,7 @@ int agp_generic_alloc_pages(struct agp_bridge_data *bridge, struct agp_memory *m
1226 int i, ret = -ENOMEM; 1226 int i, ret = -ENOMEM;
1227 1227
1228 for (i = 0; i < num_pages; i++) { 1228 for (i = 0; i < num_pages; i++) {
1229 page = alloc_page(GFP_KERNEL | GFP_DMA32); 1229 page = alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO);
1230 /* agp_free_memory() needs gart address */ 1230 /* agp_free_memory() needs gart address */
1231 if (page == NULL) 1231 if (page == NULL)
1232 goto out; 1232 goto out;
@@ -1257,7 +1257,7 @@ void *agp_generic_alloc_page(struct agp_bridge_data *bridge)
1257{ 1257{
1258 struct page * page; 1258 struct page * page;
1259 1259
1260 page = alloc_page(GFP_KERNEL | GFP_DMA32); 1260 page = alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO);
1261 if (page == NULL) 1261 if (page == NULL)
1262 return NULL; 1262 return NULL;
1263 1263
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 50dfa3bc71ce..340ba4f9dc54 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -72,7 +72,7 @@ static u32 hpet_nhpet, hpet_max_freq = HPET_USER_FREQ;
72#ifdef CONFIG_IA64 72#ifdef CONFIG_IA64
73static void __iomem *hpet_mctr; 73static void __iomem *hpet_mctr;
74 74
75static cycle_t read_hpet(void) 75static cycle_t read_hpet(struct clocksource *cs)
76{ 76{
77 return (cycle_t)read_counter((void __iomem *)hpet_mctr); 77 return (cycle_t)read_counter((void __iomem *)hpet_mctr);
78} 78}
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index e93fc8d22fb2..aa83a0865ec1 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -285,6 +285,11 @@ enum ipmi_stat_indexes {
285 /* Events that were received with the proper format. */ 285 /* Events that were received with the proper format. */
286 IPMI_STAT_events, 286 IPMI_STAT_events,
287 287
288 /* Retransmissions on IPMB that failed. */
289 IPMI_STAT_dropped_rexmit_ipmb_commands,
290
291 /* Retransmissions on LAN that failed. */
292 IPMI_STAT_dropped_rexmit_lan_commands,
288 293
289 /* This *must* remain last, add new values above this. */ 294 /* This *must* remain last, add new values above this. */
290 IPMI_NUM_STATS 295 IPMI_NUM_STATS
@@ -445,6 +450,20 @@ static DEFINE_MUTEX(smi_watchers_mutex);
445#define ipmi_get_stat(intf, stat) \ 450#define ipmi_get_stat(intf, stat) \
446 ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat])) 451 ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
447 452
453static int is_lan_addr(struct ipmi_addr *addr)
454{
455 return addr->addr_type == IPMI_LAN_ADDR_TYPE;
456}
457
458static int is_ipmb_addr(struct ipmi_addr *addr)
459{
460 return addr->addr_type == IPMI_IPMB_ADDR_TYPE;
461}
462
463static int is_ipmb_bcast_addr(struct ipmi_addr *addr)
464{
465 return addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE;
466}
448 467
449static void free_recv_msg_list(struct list_head *q) 468static void free_recv_msg_list(struct list_head *q)
450{ 469{
@@ -601,8 +620,7 @@ ipmi_addr_equal(struct ipmi_addr *addr1, struct ipmi_addr *addr2)
601 return (smi_addr1->lun == smi_addr2->lun); 620 return (smi_addr1->lun == smi_addr2->lun);
602 } 621 }
603 622
604 if ((addr1->addr_type == IPMI_IPMB_ADDR_TYPE) 623 if (is_ipmb_addr(addr1) || is_ipmb_bcast_addr(addr1)) {
605 || (addr1->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) {
606 struct ipmi_ipmb_addr *ipmb_addr1 624 struct ipmi_ipmb_addr *ipmb_addr1
607 = (struct ipmi_ipmb_addr *) addr1; 625 = (struct ipmi_ipmb_addr *) addr1;
608 struct ipmi_ipmb_addr *ipmb_addr2 626 struct ipmi_ipmb_addr *ipmb_addr2
@@ -612,7 +630,7 @@ ipmi_addr_equal(struct ipmi_addr *addr1, struct ipmi_addr *addr2)
612 && (ipmb_addr1->lun == ipmb_addr2->lun)); 630 && (ipmb_addr1->lun == ipmb_addr2->lun));
613 } 631 }
614 632
615 if (addr1->addr_type == IPMI_LAN_ADDR_TYPE) { 633 if (is_lan_addr(addr1)) {
616 struct ipmi_lan_addr *lan_addr1 634 struct ipmi_lan_addr *lan_addr1
617 = (struct ipmi_lan_addr *) addr1; 635 = (struct ipmi_lan_addr *) addr1;
618 struct ipmi_lan_addr *lan_addr2 636 struct ipmi_lan_addr *lan_addr2
@@ -644,14 +662,13 @@ int ipmi_validate_addr(struct ipmi_addr *addr, int len)
644 || (addr->channel < 0)) 662 || (addr->channel < 0))
645 return -EINVAL; 663 return -EINVAL;
646 664
647 if ((addr->addr_type == IPMI_IPMB_ADDR_TYPE) 665 if (is_ipmb_addr(addr) || is_ipmb_bcast_addr(addr)) {
648 || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) {
649 if (len < sizeof(struct ipmi_ipmb_addr)) 666 if (len < sizeof(struct ipmi_ipmb_addr))
650 return -EINVAL; 667 return -EINVAL;
651 return 0; 668 return 0;
652 } 669 }
653 670
654 if (addr->addr_type == IPMI_LAN_ADDR_TYPE) { 671 if (is_lan_addr(addr)) {
655 if (len < sizeof(struct ipmi_lan_addr)) 672 if (len < sizeof(struct ipmi_lan_addr))
656 return -EINVAL; 673 return -EINVAL;
657 return 0; 674 return 0;
@@ -1503,8 +1520,7 @@ static int i_ipmi_request(ipmi_user_t user,
1503 memcpy(&(smi_msg->data[2]), msg->data, msg->data_len); 1520 memcpy(&(smi_msg->data[2]), msg->data, msg->data_len);
1504 smi_msg->data_size = msg->data_len + 2; 1521 smi_msg->data_size = msg->data_len + 2;
1505 ipmi_inc_stat(intf, sent_local_commands); 1522 ipmi_inc_stat(intf, sent_local_commands);
1506 } else if ((addr->addr_type == IPMI_IPMB_ADDR_TYPE) 1523 } else if (is_ipmb_addr(addr) || is_ipmb_bcast_addr(addr)) {
1507 || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) {
1508 struct ipmi_ipmb_addr *ipmb_addr; 1524 struct ipmi_ipmb_addr *ipmb_addr;
1509 unsigned char ipmb_seq; 1525 unsigned char ipmb_seq;
1510 long seqid; 1526 long seqid;
@@ -1583,8 +1599,6 @@ static int i_ipmi_request(ipmi_user_t user,
1583 1599
1584 spin_lock_irqsave(&(intf->seq_lock), flags); 1600 spin_lock_irqsave(&(intf->seq_lock), flags);
1585 1601
1586 ipmi_inc_stat(intf, sent_ipmb_commands);
1587
1588 /* 1602 /*
1589 * Create a sequence number with a 1 second 1603 * Create a sequence number with a 1 second
1590 * timeout and 4 retries. 1604 * timeout and 4 retries.
@@ -1606,6 +1620,8 @@ static int i_ipmi_request(ipmi_user_t user,
1606 goto out_err; 1620 goto out_err;
1607 } 1621 }
1608 1622
1623 ipmi_inc_stat(intf, sent_ipmb_commands);
1624
1609 /* 1625 /*
1610 * Store the sequence number in the message, 1626 * Store the sequence number in the message,
1611 * so that when the send message response 1627 * so that when the send message response
@@ -1635,7 +1651,7 @@ static int i_ipmi_request(ipmi_user_t user,
1635 */ 1651 */
1636 spin_unlock_irqrestore(&(intf->seq_lock), flags); 1652 spin_unlock_irqrestore(&(intf->seq_lock), flags);
1637 } 1653 }
1638 } else if (addr->addr_type == IPMI_LAN_ADDR_TYPE) { 1654 } else if (is_lan_addr(addr)) {
1639 struct ipmi_lan_addr *lan_addr; 1655 struct ipmi_lan_addr *lan_addr;
1640 unsigned char ipmb_seq; 1656 unsigned char ipmb_seq;
1641 long seqid; 1657 long seqid;
@@ -1696,8 +1712,6 @@ static int i_ipmi_request(ipmi_user_t user,
1696 1712
1697 spin_lock_irqsave(&(intf->seq_lock), flags); 1713 spin_lock_irqsave(&(intf->seq_lock), flags);
1698 1714
1699 ipmi_inc_stat(intf, sent_lan_commands);
1700
1701 /* 1715 /*
1702 * Create a sequence number with a 1 second 1716 * Create a sequence number with a 1 second
1703 * timeout and 4 retries. 1717 * timeout and 4 retries.
@@ -1719,6 +1733,8 @@ static int i_ipmi_request(ipmi_user_t user,
1719 goto out_err; 1733 goto out_err;
1720 } 1734 }
1721 1735
1736 ipmi_inc_stat(intf, sent_lan_commands);
1737
1722 /* 1738 /*
1723 * Store the sequence number in the message, 1739 * Store the sequence number in the message,
1724 * so that when the send message response 1740 * so that when the send message response
@@ -1937,6 +1953,10 @@ static int stat_file_read_proc(char *page, char **start, off_t off,
1937 ipmi_get_stat(intf, invalid_events)); 1953 ipmi_get_stat(intf, invalid_events));
1938 out += sprintf(out, "events: %u\n", 1954 out += sprintf(out, "events: %u\n",
1939 ipmi_get_stat(intf, events)); 1955 ipmi_get_stat(intf, events));
1956 out += sprintf(out, "failed rexmit LAN msgs: %u\n",
1957 ipmi_get_stat(intf, dropped_rexmit_lan_commands));
1958 out += sprintf(out, "failed rexmit IPMB msgs: %u\n",
1959 ipmi_get_stat(intf, dropped_rexmit_ipmb_commands));
1940 1960
1941 return (out - ((char *) page)); 1961 return (out - ((char *) page));
1942} 1962}
@@ -3264,6 +3284,114 @@ static int handle_lan_get_msg_cmd(ipmi_smi_t intf,
3264 return rv; 3284 return rv;
3265} 3285}
3266 3286
3287/*
3288 * This routine will handle "Get Message" command responses with
3289 * channels that use an OEM Medium. The message format belongs to
3290 * the OEM. See IPMI 2.0 specification, Chapter 6 and
3291 * Chapter 22, sections 22.6 and 22.24 for more details.
3292 */
3293static int handle_oem_get_msg_cmd(ipmi_smi_t intf,
3294 struct ipmi_smi_msg *msg)
3295{
3296 struct cmd_rcvr *rcvr;
3297 int rv = 0;
3298 unsigned char netfn;
3299 unsigned char cmd;
3300 unsigned char chan;
3301 ipmi_user_t user = NULL;
3302 struct ipmi_system_interface_addr *smi_addr;
3303 struct ipmi_recv_msg *recv_msg;
3304
3305 /*
3306 * We expect the OEM SW to perform error checking
3307 * so we just do some basic sanity checks
3308 */
3309 if (msg->rsp_size < 4) {
3310 /* Message not big enough, just ignore it. */
3311 ipmi_inc_stat(intf, invalid_commands);
3312 return 0;
3313 }
3314
3315 if (msg->rsp[2] != 0) {
3316 /* An error getting the response, just ignore it. */
3317 return 0;
3318 }
3319
3320 /*
3321 * This is an OEM Message so the OEM needs to know how
3322 * handle the message. We do no interpretation.
3323 */
3324 netfn = msg->rsp[0] >> 2;
3325 cmd = msg->rsp[1];
3326 chan = msg->rsp[3] & 0xf;
3327
3328 rcu_read_lock();
3329 rcvr = find_cmd_rcvr(intf, netfn, cmd, chan);
3330 if (rcvr) {
3331 user = rcvr->user;
3332 kref_get(&user->refcount);
3333 } else
3334 user = NULL;
3335 rcu_read_unlock();
3336
3337 if (user == NULL) {
3338 /* We didn't find a user, just give up. */
3339 ipmi_inc_stat(intf, unhandled_commands);
3340
3341 /*
3342 * Don't do anything with these messages, just allow
3343 * them to be freed.
3344 */
3345
3346 rv = 0;
3347 } else {
3348 /* Deliver the message to the user. */
3349 ipmi_inc_stat(intf, handled_commands);
3350
3351 recv_msg = ipmi_alloc_recv_msg();
3352 if (!recv_msg) {
3353 /*
3354 * We couldn't allocate memory for the
3355 * message, so requeue it for handling
3356 * later.
3357 */
3358 rv = 1;
3359 kref_put(&user->refcount, free_user);
3360 } else {
3361 /*
3362 * OEM Messages are expected to be delivered via
3363 * the system interface to SMS software. We might
3364 * need to visit this again depending on OEM
3365 * requirements
3366 */
3367 smi_addr = ((struct ipmi_system_interface_addr *)
3368 &(recv_msg->addr));
3369 smi_addr->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
3370 smi_addr->channel = IPMI_BMC_CHANNEL;
3371 smi_addr->lun = msg->rsp[0] & 3;
3372
3373 recv_msg->user = user;
3374 recv_msg->user_msg_data = NULL;
3375 recv_msg->recv_type = IPMI_OEM_RECV_TYPE;
3376 recv_msg->msg.netfn = msg->rsp[0] >> 2;
3377 recv_msg->msg.cmd = msg->rsp[1];
3378 recv_msg->msg.data = recv_msg->msg_data;
3379
3380 /*
3381 * The message starts at byte 4 which follows the
3382 * the Channel Byte in the "GET MESSAGE" command
3383 */
3384 recv_msg->msg.data_len = msg->rsp_size - 4;
3385 memcpy(recv_msg->msg_data,
3386 &(msg->rsp[4]),
3387 msg->rsp_size - 4);
3388 deliver_response(recv_msg);
3389 }
3390 }
3391
3392 return rv;
3393}
3394
3267static void copy_event_into_recv_msg(struct ipmi_recv_msg *recv_msg, 3395static void copy_event_into_recv_msg(struct ipmi_recv_msg *recv_msg,
3268 struct ipmi_smi_msg *msg) 3396 struct ipmi_smi_msg *msg)
3269{ 3397{
@@ -3519,6 +3647,17 @@ static int handle_new_recv_msg(ipmi_smi_t intf,
3519 goto out; 3647 goto out;
3520 } 3648 }
3521 3649
3650 /*
3651 ** We need to make sure the channels have been initialized.
3652 ** The channel_handler routine will set the "curr_channel"
3653 ** equal to or greater than IPMI_MAX_CHANNELS when all the
3654 ** channels for this interface have been initialized.
3655 */
3656 if (intf->curr_channel < IPMI_MAX_CHANNELS) {
3657 requeue = 1; /* Just put the message back for now */
3658 goto out;
3659 }
3660
3522 switch (intf->channels[chan].medium) { 3661 switch (intf->channels[chan].medium) {
3523 case IPMI_CHANNEL_MEDIUM_IPMB: 3662 case IPMI_CHANNEL_MEDIUM_IPMB:
3524 if (msg->rsp[4] & 0x04) { 3663 if (msg->rsp[4] & 0x04) {
@@ -3554,11 +3693,20 @@ static int handle_new_recv_msg(ipmi_smi_t intf,
3554 break; 3693 break;
3555 3694
3556 default: 3695 default:
3557 /* 3696 /* Check for OEM Channels. Clients had better
3558 * We don't handle the channel type, so just 3697 register for these commands. */
3559 * free the message. 3698 if ((intf->channels[chan].medium
3560 */ 3699 >= IPMI_CHANNEL_MEDIUM_OEM_MIN)
3561 requeue = 0; 3700 && (intf->channels[chan].medium
3701 <= IPMI_CHANNEL_MEDIUM_OEM_MAX)) {
3702 requeue = handle_oem_get_msg_cmd(intf, msg);
3703 } else {
3704 /*
3705 * We don't handle the channel type, so just
3706 * free the message.
3707 */
3708 requeue = 0;
3709 }
3562 } 3710 }
3563 3711
3564 } else if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2)) 3712 } else if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2))
@@ -3730,7 +3878,7 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent,
3730 list_add_tail(&msg->link, timeouts); 3878 list_add_tail(&msg->link, timeouts);
3731 if (ent->broadcast) 3879 if (ent->broadcast)
3732 ipmi_inc_stat(intf, timed_out_ipmb_broadcasts); 3880 ipmi_inc_stat(intf, timed_out_ipmb_broadcasts);
3733 else if (ent->recv_msg->addr.addr_type == IPMI_LAN_ADDR_TYPE) 3881 else if (is_lan_addr(&ent->recv_msg->addr))
3734 ipmi_inc_stat(intf, timed_out_lan_commands); 3882 ipmi_inc_stat(intf, timed_out_lan_commands);
3735 else 3883 else
3736 ipmi_inc_stat(intf, timed_out_ipmb_commands); 3884 ipmi_inc_stat(intf, timed_out_ipmb_commands);
@@ -3744,15 +3892,17 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent,
3744 */ 3892 */
3745 ent->timeout = MAX_MSG_TIMEOUT; 3893 ent->timeout = MAX_MSG_TIMEOUT;
3746 ent->retries_left--; 3894 ent->retries_left--;
3747 if (ent->recv_msg->addr.addr_type == IPMI_LAN_ADDR_TYPE)
3748 ipmi_inc_stat(intf, retransmitted_lan_commands);
3749 else
3750 ipmi_inc_stat(intf, retransmitted_ipmb_commands);
3751
3752 smi_msg = smi_from_recv_msg(intf, ent->recv_msg, slot, 3895 smi_msg = smi_from_recv_msg(intf, ent->recv_msg, slot,
3753 ent->seqid); 3896 ent->seqid);
3754 if (!smi_msg) 3897 if (!smi_msg) {
3898 if (is_lan_addr(&ent->recv_msg->addr))
3899 ipmi_inc_stat(intf,
3900 dropped_rexmit_lan_commands);
3901 else
3902 ipmi_inc_stat(intf,
3903 dropped_rexmit_ipmb_commands);
3755 return; 3904 return;
3905 }
3756 3906
3757 spin_unlock_irqrestore(&intf->seq_lock, *flags); 3907 spin_unlock_irqrestore(&intf->seq_lock, *flags);
3758 3908
@@ -3764,10 +3914,17 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent,
3764 * resent. 3914 * resent.
3765 */ 3915 */
3766 handlers = intf->handlers; 3916 handlers = intf->handlers;
3767 if (handlers) 3917 if (handlers) {
3918 if (is_lan_addr(&ent->recv_msg->addr))
3919 ipmi_inc_stat(intf,
3920 retransmitted_lan_commands);
3921 else
3922 ipmi_inc_stat(intf,
3923 retransmitted_ipmb_commands);
3924
3768 intf->handlers->sender(intf->send_info, 3925 intf->handlers->sender(intf->send_info,
3769 smi_msg, 0); 3926 smi_msg, 0);
3770 else 3927 } else
3771 ipmi_free_smi_msg(smi_msg); 3928 ipmi_free_smi_msg(smi_msg);
3772 3929
3773 spin_lock_irqsave(&intf->seq_lock, *flags); 3930 spin_lock_irqsave(&intf->seq_lock, *flags);
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index e58ea4cd55ce..259644646b82 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -82,12 +82,6 @@
82#define SI_SHORT_TIMEOUT_USEC 250 /* .25ms when the SM request a 82#define SI_SHORT_TIMEOUT_USEC 250 /* .25ms when the SM request a
83 short timeout */ 83 short timeout */
84 84
85/* Bit for BMC global enables. */
86#define IPMI_BMC_RCV_MSG_INTR 0x01
87#define IPMI_BMC_EVT_MSG_INTR 0x02
88#define IPMI_BMC_EVT_MSG_BUFF 0x04
89#define IPMI_BMC_SYS_LOG 0x08
90
91enum si_intf_state { 85enum si_intf_state {
92 SI_NORMAL, 86 SI_NORMAL,
93 SI_GETTING_FLAGS, 87 SI_GETTING_FLAGS,
@@ -220,6 +214,9 @@ struct smi_info {
220 OEM2_DATA_AVAIL) 214 OEM2_DATA_AVAIL)
221 unsigned char msg_flags; 215 unsigned char msg_flags;
222 216
217 /* Does the BMC have an event buffer? */
218 char has_event_buffer;
219
223 /* 220 /*
224 * If set to true, this will request events the next time the 221 * If set to true, this will request events the next time the
225 * state machine is idle. 222 * state machine is idle.
@@ -968,7 +965,8 @@ static void request_events(void *send_info)
968{ 965{
969 struct smi_info *smi_info = send_info; 966 struct smi_info *smi_info = send_info;
970 967
971 if (atomic_read(&smi_info->stop_operation)) 968 if (atomic_read(&smi_info->stop_operation) ||
969 !smi_info->has_event_buffer)
972 return; 970 return;
973 971
974 atomic_set(&smi_info->req_events, 1); 972 atomic_set(&smi_info->req_events, 1);
@@ -2407,26 +2405,9 @@ static struct of_platform_driver ipmi_of_platform_driver = {
2407}; 2405};
2408#endif /* CONFIG_PPC_OF */ 2406#endif /* CONFIG_PPC_OF */
2409 2407
2410 2408static int wait_for_msg_done(struct smi_info *smi_info)
2411static int try_get_dev_id(struct smi_info *smi_info)
2412{ 2409{
2413 unsigned char msg[2];
2414 unsigned char *resp;
2415 unsigned long resp_len;
2416 enum si_sm_result smi_result; 2410 enum si_sm_result smi_result;
2417 int rv = 0;
2418
2419 resp = kmalloc(IPMI_MAX_MSG_LENGTH, GFP_KERNEL);
2420 if (!resp)
2421 return -ENOMEM;
2422
2423 /*
2424 * Do a Get Device ID command, since it comes back with some
2425 * useful info.
2426 */
2427 msg[0] = IPMI_NETFN_APP_REQUEST << 2;
2428 msg[1] = IPMI_GET_DEVICE_ID_CMD;
2429 smi_info->handlers->start_transaction(smi_info->si_sm, msg, 2);
2430 2411
2431 smi_result = smi_info->handlers->event(smi_info->si_sm, 0); 2412 smi_result = smi_info->handlers->event(smi_info->si_sm, 0);
2432 for (;;) { 2413 for (;;) {
@@ -2441,16 +2422,39 @@ static int try_get_dev_id(struct smi_info *smi_info)
2441 } else 2422 } else
2442 break; 2423 break;
2443 } 2424 }
2444 if (smi_result == SI_SM_HOSED) { 2425 if (smi_result == SI_SM_HOSED)
2445 /* 2426 /*
2446 * We couldn't get the state machine to run, so whatever's at 2427 * We couldn't get the state machine to run, so whatever's at
2447 * the port is probably not an IPMI SMI interface. 2428 * the port is probably not an IPMI SMI interface.
2448 */ 2429 */
2449 rv = -ENODEV; 2430 return -ENODEV;
2431
2432 return 0;
2433}
2434
2435static int try_get_dev_id(struct smi_info *smi_info)
2436{
2437 unsigned char msg[2];
2438 unsigned char *resp;
2439 unsigned long resp_len;
2440 int rv = 0;
2441
2442 resp = kmalloc(IPMI_MAX_MSG_LENGTH, GFP_KERNEL);
2443 if (!resp)
2444 return -ENOMEM;
2445
2446 /*
2447 * Do a Get Device ID command, since it comes back with some
2448 * useful info.
2449 */
2450 msg[0] = IPMI_NETFN_APP_REQUEST << 2;
2451 msg[1] = IPMI_GET_DEVICE_ID_CMD;
2452 smi_info->handlers->start_transaction(smi_info->si_sm, msg, 2);
2453
2454 rv = wait_for_msg_done(smi_info);
2455 if (rv)
2450 goto out; 2456 goto out;
2451 }
2452 2457
2453 /* Otherwise, we got some data. */
2454 resp_len = smi_info->handlers->get_result(smi_info->si_sm, 2458 resp_len = smi_info->handlers->get_result(smi_info->si_sm,
2455 resp, IPMI_MAX_MSG_LENGTH); 2459 resp, IPMI_MAX_MSG_LENGTH);
2456 2460
@@ -2462,6 +2466,88 @@ static int try_get_dev_id(struct smi_info *smi_info)
2462 return rv; 2466 return rv;
2463} 2467}
2464 2468
2469static int try_enable_event_buffer(struct smi_info *smi_info)
2470{
2471 unsigned char msg[3];
2472 unsigned char *resp;
2473 unsigned long resp_len;
2474 int rv = 0;
2475
2476 resp = kmalloc(IPMI_MAX_MSG_LENGTH, GFP_KERNEL);
2477 if (!resp)
2478 return -ENOMEM;
2479
2480 msg[0] = IPMI_NETFN_APP_REQUEST << 2;
2481 msg[1] = IPMI_GET_BMC_GLOBAL_ENABLES_CMD;
2482 smi_info->handlers->start_transaction(smi_info->si_sm, msg, 2);
2483
2484 rv = wait_for_msg_done(smi_info);
2485 if (rv) {
2486 printk(KERN_WARNING
2487 "ipmi_si: Error getting response from get global,"
2488 " enables command, the event buffer is not"
2489 " enabled.\n");
2490 goto out;
2491 }
2492
2493 resp_len = smi_info->handlers->get_result(smi_info->si_sm,
2494 resp, IPMI_MAX_MSG_LENGTH);
2495
2496 if (resp_len < 4 ||
2497 resp[0] != (IPMI_NETFN_APP_REQUEST | 1) << 2 ||
2498 resp[1] != IPMI_GET_BMC_GLOBAL_ENABLES_CMD ||
2499 resp[2] != 0) {
2500 printk(KERN_WARNING
2501 "ipmi_si: Invalid return from get global"
2502 " enables command, cannot enable the event"
2503 " buffer.\n");
2504 rv = -EINVAL;
2505 goto out;
2506 }
2507
2508 if (resp[3] & IPMI_BMC_EVT_MSG_BUFF)
2509 /* buffer is already enabled, nothing to do. */
2510 goto out;
2511
2512 msg[0] = IPMI_NETFN_APP_REQUEST << 2;
2513 msg[1] = IPMI_SET_BMC_GLOBAL_ENABLES_CMD;
2514 msg[2] = resp[3] | IPMI_BMC_EVT_MSG_BUFF;
2515 smi_info->handlers->start_transaction(smi_info->si_sm, msg, 3);
2516
2517 rv = wait_for_msg_done(smi_info);
2518 if (rv) {
2519 printk(KERN_WARNING
2520 "ipmi_si: Error getting response from set global,"
2521 " enables command, the event buffer is not"
2522 " enabled.\n");
2523 goto out;
2524 }
2525
2526 resp_len = smi_info->handlers->get_result(smi_info->si_sm,
2527 resp, IPMI_MAX_MSG_LENGTH);
2528
2529 if (resp_len < 3 ||
2530 resp[0] != (IPMI_NETFN_APP_REQUEST | 1) << 2 ||
2531 resp[1] != IPMI_SET_BMC_GLOBAL_ENABLES_CMD) {
2532 printk(KERN_WARNING
2533 "ipmi_si: Invalid return from get global,"
2534 "enables command, not enable the event"
2535 " buffer.\n");
2536 rv = -EINVAL;
2537 goto out;
2538 }
2539
2540 if (resp[2] != 0)
2541 /*
2542 * An error when setting the event buffer bit means
2543 * that the event buffer is not supported.
2544 */
2545 rv = -ENOENT;
2546 out:
2547 kfree(resp);
2548 return rv;
2549}
2550
2465static int type_file_read_proc(char *page, char **start, off_t off, 2551static int type_file_read_proc(char *page, char **start, off_t off,
2466 int count, int *eof, void *data) 2552 int count, int *eof, void *data)
2467{ 2553{
@@ -2847,6 +2933,10 @@ static int try_smi_init(struct smi_info *new_smi)
2847 new_smi->intf_num = smi_num; 2933 new_smi->intf_num = smi_num;
2848 smi_num++; 2934 smi_num++;
2849 2935
2936 rv = try_enable_event_buffer(new_smi);
2937 if (rv == 0)
2938 new_smi->has_event_buffer = 1;
2939
2850 /* 2940 /*
2851 * Start clearing the flags before we enable interrupts or the 2941 * Start clearing the flags before we enable interrupts or the
2852 * timer to avoid racing with the timer. 2942 * timer to avoid racing with the timer.
@@ -2863,7 +2953,7 @@ static int try_smi_init(struct smi_info *new_smi)
2863 */ 2953 */
2864 new_smi->pdev = platform_device_alloc("ipmi_si", 2954 new_smi->pdev = platform_device_alloc("ipmi_si",
2865 new_smi->intf_num); 2955 new_smi->intf_num);
2866 if (rv) { 2956 if (!new_smi->pdev) {
2867 printk(KERN_ERR 2957 printk(KERN_ERR
2868 "ipmi_si_intf:" 2958 "ipmi_si_intf:"
2869 " Unable to allocate platform device\n"); 2959 " Unable to allocate platform device\n");
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 2c1d133819b5..08151d4de489 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -2274,7 +2274,7 @@ rescan_last_byte:
2274 continue; /* nothing to display */ 2274 continue; /* nothing to display */
2275 } 2275 }
2276 /* Glyph not found */ 2276 /* Glyph not found */
2277 if ((!(vc->vc_utf && !vc->vc_disp_ctrl) && c < 128) && !(c & ~charmask)) { 2277 if ((!(vc->vc_utf && !vc->vc_disp_ctrl) || c < 128) && !(c & ~charmask)) {
2278 /* In legacy mode use the glyph we get by a 1:1 mapping. 2278 /* In legacy mode use the glyph we get by a 1:1 mapping.
2279 This would make absolutely no sense with Unicode in mind, 2279 This would make absolutely no sense with Unicode in mind,
2280 but do this for ASCII characters since a font may lack 2280 but do this for ASCII characters since a font may lack
diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
index ee19b6e8fcb4..40bd8c61c7d7 100644
--- a/drivers/clocksource/acpi_pm.c
+++ b/drivers/clocksource/acpi_pm.c
@@ -57,7 +57,7 @@ u32 acpi_pm_read_verified(void)
57 return v2; 57 return v2;
58} 58}
59 59
60static cycle_t acpi_pm_read(void) 60static cycle_t acpi_pm_read(struct clocksource *cs)
61{ 61{
62 return (cycle_t)read_pmtmr(); 62 return (cycle_t)read_pmtmr();
63} 63}
@@ -83,7 +83,7 @@ static int __init acpi_pm_good_setup(char *__str)
83} 83}
84__setup("acpi_pm_good", acpi_pm_good_setup); 84__setup("acpi_pm_good", acpi_pm_good_setup);
85 85
86static cycle_t acpi_pm_read_slow(void) 86static cycle_t acpi_pm_read_slow(struct clocksource *cs)
87{ 87{
88 return (cycle_t)acpi_pm_read_verified(); 88 return (cycle_t)acpi_pm_read_verified();
89} 89}
@@ -156,9 +156,9 @@ static int verify_pmtmr_rate(void)
156 unsigned long count, delta; 156 unsigned long count, delta;
157 157
158 mach_prepare_counter(); 158 mach_prepare_counter();
159 value1 = clocksource_acpi_pm.read(); 159 value1 = clocksource_acpi_pm.read(&clocksource_acpi_pm);
160 mach_countup(&count); 160 mach_countup(&count);
161 value2 = clocksource_acpi_pm.read(); 161 value2 = clocksource_acpi_pm.read(&clocksource_acpi_pm);
162 delta = (value2 - value1) & ACPI_PM_MASK; 162 delta = (value2 - value1) & ACPI_PM_MASK;
163 163
164 /* Check that the PMTMR delta is within 5% of what we expect */ 164 /* Check that the PMTMR delta is within 5% of what we expect */
@@ -195,9 +195,9 @@ static int __init init_acpi_pm_clocksource(void)
195 /* "verify" this timing source: */ 195 /* "verify" this timing source: */
196 for (j = 0; j < ACPI_PM_MONOTONICITY_CHECKS; j++) { 196 for (j = 0; j < ACPI_PM_MONOTONICITY_CHECKS; j++) {
197 udelay(100 * j); 197 udelay(100 * j);
198 value1 = clocksource_acpi_pm.read(); 198 value1 = clocksource_acpi_pm.read(&clocksource_acpi_pm);
199 for (i = 0; i < ACPI_PM_READ_CHECKS; i++) { 199 for (i = 0; i < ACPI_PM_READ_CHECKS; i++) {
200 value2 = clocksource_acpi_pm.read(); 200 value2 = clocksource_acpi_pm.read(&clocksource_acpi_pm);
201 if (value2 == value1) 201 if (value2 == value1)
202 continue; 202 continue;
203 if (value2 > value1) 203 if (value2 > value1)
diff --git a/drivers/clocksource/cyclone.c b/drivers/clocksource/cyclone.c
index 8615059a8729..64e528e8bfa6 100644
--- a/drivers/clocksource/cyclone.c
+++ b/drivers/clocksource/cyclone.c
@@ -19,7 +19,7 @@
19int use_cyclone = 0; 19int use_cyclone = 0;
20static void __iomem *cyclone_ptr; 20static void __iomem *cyclone_ptr;
21 21
22static cycle_t read_cyclone(void) 22static cycle_t read_cyclone(struct clocksource *cs)
23{ 23{
24 return (cycle_t)readl(cyclone_ptr); 24 return (cycle_t)readl(cyclone_ptr);
25} 25}
diff --git a/drivers/clocksource/scx200_hrt.c b/drivers/clocksource/scx200_hrt.c
index b92da677aa5d..27f4d9637b62 100644
--- a/drivers/clocksource/scx200_hrt.c
+++ b/drivers/clocksource/scx200_hrt.c
@@ -43,7 +43,7 @@ MODULE_PARM_DESC(ppm, "+-adjust to actual XO freq (ppm)");
43/* The base timer frequency, * 27 if selected */ 43/* The base timer frequency, * 27 if selected */
44#define HRT_FREQ 1000000 44#define HRT_FREQ 1000000
45 45
46static cycle_t read_hrt(void) 46static cycle_t read_hrt(struct clocksource *cs)
47{ 47{
48 /* Read the timer value */ 48 /* Read the timer value */
49 return (cycle_t) inl(scx200_cb_base + SCx200_TIMER_OFFSET); 49 return (cycle_t) inl(scx200_cb_base + SCx200_TIMER_OFFSET);
diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c
index 254f1064d973..01b886e68822 100644
--- a/drivers/clocksource/tcb_clksrc.c
+++ b/drivers/clocksource/tcb_clksrc.c
@@ -39,7 +39,7 @@
39 39
40static void __iomem *tcaddr; 40static void __iomem *tcaddr;
41 41
42static cycle_t tc_get_cycles(void) 42static cycle_t tc_get_cycles(struct clocksource *cs)
43{ 43{
44 unsigned long flags; 44 unsigned long flags;
45 u32 lower, upper; 45 u32 lower, upper;
diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
index 4637a4a757df..7c8c2d72916f 100644
--- a/drivers/edac/mpc85xx_edac.c
+++ b/drivers/edac/mpc85xx_edac.c
@@ -674,7 +674,7 @@ static void mpc85xx_mc_check(struct mem_ctl_info *mci)
674 int row_index; 674 int row_index;
675 675
676 err_detect = in_be32(pdata->mc_vbase + MPC85XX_MC_ERR_DETECT); 676 err_detect = in_be32(pdata->mc_vbase + MPC85XX_MC_ERR_DETECT);
677 if (err_detect) 677 if (!err_detect)
678 return; 678 return;
679 679
680 mpc85xx_mc_printk(mci, KERN_ERR, "Err Detect Register: %#8.8x\n", 680 mpc85xx_mc_printk(mci, KERN_ERR, "Err Detect Register: %#8.8x\n",
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index d009661781bc..ef878615c49f 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -159,6 +159,9 @@ void drm_master_put(struct drm_master **master)
159int drm_setmaster_ioctl(struct drm_device *dev, void *data, 159int drm_setmaster_ioctl(struct drm_device *dev, void *data,
160 struct drm_file *file_priv) 160 struct drm_file *file_priv)
161{ 161{
162 if (file_priv->is_master)
163 return 0;
164
162 if (file_priv->minor->master && file_priv->minor->master != file_priv->master) 165 if (file_priv->minor->master && file_priv->minor->master != file_priv->master)
163 return -EINVAL; 166 return -EINVAL;
164 167
@@ -169,6 +172,7 @@ int drm_setmaster_ioctl(struct drm_device *dev, void *data,
169 file_priv->minor->master != file_priv->master) { 172 file_priv->minor->master != file_priv->master) {
170 mutex_lock(&dev->struct_mutex); 173 mutex_lock(&dev->struct_mutex);
171 file_priv->minor->master = drm_master_get(file_priv->master); 174 file_priv->minor->master = drm_master_get(file_priv->master);
175 file_priv->is_master = 1;
172 mutex_unlock(&dev->struct_mutex); 176 mutex_unlock(&dev->struct_mutex);
173 } 177 }
174 178
@@ -178,10 +182,15 @@ int drm_setmaster_ioctl(struct drm_device *dev, void *data,
178int drm_dropmaster_ioctl(struct drm_device *dev, void *data, 182int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
179 struct drm_file *file_priv) 183 struct drm_file *file_priv)
180{ 184{
181 if (!file_priv->master) 185 if (!file_priv->is_master)
182 return -EINVAL; 186 return -EINVAL;
187
188 if (!file_priv->minor->master)
189 return -EINVAL;
190
183 mutex_lock(&dev->struct_mutex); 191 mutex_lock(&dev->struct_mutex);
184 drm_master_put(&file_priv->minor->master); 192 drm_master_put(&file_priv->minor->master);
193 file_priv->is_master = 0;
185 mutex_unlock(&dev->struct_mutex); 194 mutex_unlock(&dev->struct_mutex);
186 return 0; 195 return 0;
187} 196}
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index bc0c6849360c..022876ae34f0 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -132,6 +132,7 @@ void drm_sysfs_destroy(void)
132 */ 132 */
133static void drm_sysfs_device_release(struct device *dev) 133static void drm_sysfs_device_release(struct device *dev)
134{ 134{
135 memset(dev, 0, sizeof(struct device));
135 return; 136 return;
136} 137}
137 138
diff --git a/drivers/gpu/drm/via/via_dma.c b/drivers/gpu/drm/via/via_dma.c
index 7a339dba6a69..bfb92d283260 100644
--- a/drivers/gpu/drm/via/via_dma.c
+++ b/drivers/gpu/drm/via/via_dma.c
@@ -481,11 +481,13 @@ static int via_wait_idle(drm_via_private_t * dev_priv)
481{ 481{
482 int count = 10000000; 482 int count = 10000000;
483 483
484 while (!(VIA_READ(VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY) && count--); 484 while (!(VIA_READ(VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY) && --count)
485 ;
485 486
486 while (count-- && (VIA_READ(VIA_REG_STATUS) & 487 while (count && (VIA_READ(VIA_REG_STATUS) &
487 (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY | 488 (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY |
488 VIA_3D_ENG_BUSY))) ; 489 VIA_3D_ENG_BUSY)))
490 --count;
489 return count; 491 return count;
490} 492}
491 493
@@ -705,7 +707,7 @@ static int via_cmdbuf_size(struct drm_device *dev, void *data, struct drm_file *
705 switch (d_siz->func) { 707 switch (d_siz->func) {
706 case VIA_CMDBUF_SPACE: 708 case VIA_CMDBUF_SPACE:
707 while (((tmp_size = via_cmdbuf_space(dev_priv)) < d_siz->size) 709 while (((tmp_size = via_cmdbuf_space(dev_priv)) < d_siz->size)
708 && count--) { 710 && --count) {
709 if (!d_siz->wait) { 711 if (!d_siz->wait) {
710 break; 712 break;
711 } 713 }
@@ -717,7 +719,7 @@ static int via_cmdbuf_size(struct drm_device *dev, void *data, struct drm_file *
717 break; 719 break;
718 case VIA_CMDBUF_LAG: 720 case VIA_CMDBUF_LAG:
719 while (((tmp_size = via_cmdbuf_lag(dev_priv)) > d_siz->size) 721 while (((tmp_size = via_cmdbuf_lag(dev_priv)) > d_siz->size)
720 && count--) { 722 && --count) {
721 if (!d_siz->wait) { 723 if (!d_siz->wait) {
722 break; 724 break;
723 } 725 }
diff --git a/drivers/ide/cs5536.c b/drivers/ide/cs5536.c
index 353a35bbba63..0332a95eefd4 100644
--- a/drivers/ide/cs5536.c
+++ b/drivers/ide/cs5536.c
@@ -236,6 +236,7 @@ static const struct ide_dma_ops cs5536_dma_ops = {
236 .dma_test_irq = ide_dma_test_irq, 236 .dma_test_irq = ide_dma_test_irq,
237 .dma_lost_irq = ide_dma_lost_irq, 237 .dma_lost_irq = ide_dma_lost_irq,
238 .dma_timer_expiry = ide_dma_sff_timer_expiry, 238 .dma_timer_expiry = ide_dma_sff_timer_expiry,
239 .dma_sff_read_status = ide_dma_sff_read_status,
239}; 240};
240 241
241static const struct ide_port_info cs5536_info = { 242static const struct ide_port_info cs5536_info = {
diff --git a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c
index a0eb87f59134..0feb66c720e1 100644
--- a/drivers/ide/hpt366.c
+++ b/drivers/ide/hpt366.c
@@ -3,7 +3,7 @@
3 * Portions Copyright (C) 2001 Sun Microsystems, Inc. 3 * Portions Copyright (C) 2001 Sun Microsystems, Inc.
4 * Portions Copyright (C) 2003 Red Hat Inc 4 * Portions Copyright (C) 2003 Red Hat Inc
5 * Portions Copyright (C) 2007 Bartlomiej Zolnierkiewicz 5 * Portions Copyright (C) 2007 Bartlomiej Zolnierkiewicz
6 * Portions Copyright (C) 2005-2008 MontaVista Software, Inc. 6 * Portions Copyright (C) 2005-2009 MontaVista Software, Inc.
7 * 7 *
8 * Thanks to HighPoint Technologies for their assistance, and hardware. 8 * Thanks to HighPoint Technologies for their assistance, and hardware.
9 * Special Thanks to Jon Burchmore in SanDiego for the deep pockets, his 9 * Special Thanks to Jon Burchmore in SanDiego for the deep pockets, his
@@ -114,6 +114,8 @@
114 * the register setting lists into the table indexed by the clock selected 114 * the register setting lists into the table indexed by the clock selected
115 * - set the correct hwif->ultra_mask for each individual chip 115 * - set the correct hwif->ultra_mask for each individual chip
116 * - add Ultra and MW DMA mode filtering for the HPT37[24] based SATA cards 116 * - add Ultra and MW DMA mode filtering for the HPT37[24] based SATA cards
117 * - stop resetting HPT370's state machine before each DMA transfer as that has
118 * caused more harm than good
117 * Sergei Shtylyov, <sshtylyov@ru.mvista.com> or <source@mvista.com> 119 * Sergei Shtylyov, <sshtylyov@ru.mvista.com> or <source@mvista.com>
118 */ 120 */
119 121
@@ -133,7 +135,7 @@
133#define DRV_NAME "hpt366" 135#define DRV_NAME "hpt366"
134 136
135/* various tuning parameters */ 137/* various tuning parameters */
136#define HPT_RESET_STATE_ENGINE 138#undef HPT_RESET_STATE_ENGINE
137#undef HPT_DELAY_INTERRUPT 139#undef HPT_DELAY_INTERRUPT
138 140
139static const char *quirk_drives[] = { 141static const char *quirk_drives[] = {
@@ -808,7 +810,7 @@ static void hpt370_irq_timeout(ide_drive_t *drive)
808 /* get DMA command mode */ 810 /* get DMA command mode */
809 dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); 811 dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD);
810 /* stop DMA */ 812 /* stop DMA */
811 outb(dma_cmd & ~0x1, hwif->dma_base + ATA_DMA_CMD); 813 outb(dma_cmd & ~ATA_DMA_START, hwif->dma_base + ATA_DMA_CMD);
812 hpt370_clear_engine(drive); 814 hpt370_clear_engine(drive);
813} 815}
814 816
@@ -825,11 +827,11 @@ static int hpt370_dma_end(ide_drive_t *drive)
825 ide_hwif_t *hwif = drive->hwif; 827 ide_hwif_t *hwif = drive->hwif;
826 u8 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); 828 u8 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS);
827 829
828 if (dma_stat & 0x01) { 830 if (dma_stat & ATA_DMA_ACTIVE) {
829 /* wait a little */ 831 /* wait a little */
830 udelay(20); 832 udelay(20);
831 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); 833 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS);
832 if (dma_stat & 0x01) 834 if (dma_stat & ATA_DMA_ACTIVE)
833 hpt370_irq_timeout(drive); 835 hpt370_irq_timeout(drive);
834 } 836 }
835 return ide_dma_end(drive); 837 return ide_dma_end(drive);
@@ -851,7 +853,7 @@ static int hpt374_dma_test_irq(ide_drive_t *drive)
851 853
852 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); 854 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS);
853 /* return 1 if INTR asserted */ 855 /* return 1 if INTR asserted */
854 if (dma_stat & 4) 856 if (dma_stat & ATA_DMA_INTR)
855 return 1; 857 return 1;
856 858
857 return 0; 859 return 0;
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 2ae02b8d7f8e..35dc38d3b2c5 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -102,11 +102,14 @@ void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err)
102 drive->dev_flags |= IDE_DFLAG_PARKED; 102 drive->dev_flags |= IDE_DFLAG_PARKED;
103 } 103 }
104 104
105 if (rq && rq->cmd_type == REQ_TYPE_ATA_TASKFILE) 105 if (rq && rq->cmd_type == REQ_TYPE_ATA_TASKFILE) {
106 memcpy(rq->special, cmd, sizeof(*cmd)); 106 struct ide_cmd *orig_cmd = rq->special;
107 107
108 if (cmd->tf_flags & IDE_TFLAG_DYN) 108 if (cmd->tf_flags & IDE_TFLAG_DYN)
109 kfree(cmd); 109 kfree(orig_cmd);
110 else
111 memcpy(orig_cmd, cmd, sizeof(*cmd));
112 }
110} 113}
111 114
112/* obsolete, blk_rq_bytes() should be used instead */ 115/* obsolete, blk_rq_bytes() should be used instead */
diff --git a/drivers/ide/pmac.c b/drivers/ide/pmac.c
index 052b9bf1f8fb..f76e4e6b408f 100644
--- a/drivers/ide/pmac.c
+++ b/drivers/ide/pmac.c
@@ -1682,7 +1682,7 @@ static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif,
1682 * The +2 is +1 for the stop command and +1 to allow for 1682 * The +2 is +1 for the stop command and +1 to allow for
1683 * aligning the start address to a multiple of 16 bytes. 1683 * aligning the start address to a multiple of 16 bytes.
1684 */ 1684 */
1685 pmif->dma_table_cpu = (struct dbdma_cmd*)pci_alloc_consistent( 1685 pmif->dma_table_cpu = pci_alloc_consistent(
1686 dev, 1686 dev,
1687 (MAX_DCMDS + 2) * sizeof(struct dbdma_cmd), 1687 (MAX_DCMDS + 2) * sizeof(struct dbdma_cmd),
1688 &hwif->dmatable_dma); 1688 &hwif->dmatable_dma);
diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c
index bfe49243f38b..1c9410d1822c 100644
--- a/drivers/input/serio/hp_sdc.c
+++ b/drivers/input/serio/hp_sdc.c
@@ -819,6 +819,7 @@ static const struct parisc_device_id hp_sdc_tbl[] = {
819MODULE_DEVICE_TABLE(parisc, hp_sdc_tbl); 819MODULE_DEVICE_TABLE(parisc, hp_sdc_tbl);
820 820
821static int __init hp_sdc_init_hppa(struct parisc_device *d); 821static int __init hp_sdc_init_hppa(struct parisc_device *d);
822static struct delayed_work moduleloader_work;
822 823
823static struct parisc_driver hp_sdc_driver = { 824static struct parisc_driver hp_sdc_driver = {
824 .name = "hp_sdc", 825 .name = "hp_sdc",
@@ -930,8 +931,15 @@ static int __init hp_sdc_init(void)
930 931
931#if defined(__hppa__) 932#if defined(__hppa__)
932 933
934static void request_module_delayed(struct work_struct *work)
935{
936 request_module("hp_sdc_mlc");
937}
938
933static int __init hp_sdc_init_hppa(struct parisc_device *d) 939static int __init hp_sdc_init_hppa(struct parisc_device *d)
934{ 940{
941 int ret;
942
935 if (!d) 943 if (!d)
936 return 1; 944 return 1;
937 if (hp_sdc.dev != NULL) 945 if (hp_sdc.dev != NULL)
@@ -944,13 +952,26 @@ static int __init hp_sdc_init_hppa(struct parisc_device *d)
944 hp_sdc.data_io = d->hpa.start + 0x800; 952 hp_sdc.data_io = d->hpa.start + 0x800;
945 hp_sdc.status_io = d->hpa.start + 0x801; 953 hp_sdc.status_io = d->hpa.start + 0x801;
946 954
947 return hp_sdc_init(); 955 INIT_DELAYED_WORK(&moduleloader_work, request_module_delayed);
956
957 ret = hp_sdc_init();
958 /* after sucessfull initialization give SDC some time to settle
959 * and then load the hp_sdc_mlc upper layer driver */
960 if (!ret)
961 schedule_delayed_work(&moduleloader_work,
962 msecs_to_jiffies(2000));
963
964 return ret;
948} 965}
949 966
950#endif /* __hppa__ */ 967#endif /* __hppa__ */
951 968
952static void hp_sdc_exit(void) 969static void hp_sdc_exit(void)
953{ 970{
971 /* do nothing if we don't have a SDC */
972 if (!hp_sdc.dev)
973 return;
974
954 write_lock_irq(&hp_sdc.lock); 975 write_lock_irq(&hp_sdc.lock);
955 976
956 /* Turn off all maskable "sub-function" irq's. */ 977 /* Turn off all maskable "sub-function" irq's. */
@@ -969,6 +990,7 @@ static void hp_sdc_exit(void)
969 tasklet_kill(&hp_sdc.task); 990 tasklet_kill(&hp_sdc.task);
970 991
971#if defined(__hppa__) 992#if defined(__hppa__)
993 cancel_delayed_work_sync(&moduleloader_work);
972 if (unregister_parisc_driver(&hp_sdc_driver)) 994 if (unregister_parisc_driver(&hp_sdc_driver))
973 printk(KERN_WARNING PREFIX "Error unregistering HP SDC"); 995 printk(KERN_WARNING PREFIX "Error unregistering HP SDC");
974#endif 996#endif
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h
index ac8a4a3741b8..af92a176697f 100644
--- a/drivers/lguest/lg.h
+++ b/drivers/lguest/lg.h
@@ -158,7 +158,8 @@ void free_interrupts(void);
158/* segments.c: */ 158/* segments.c: */
159void setup_default_gdt_entries(struct lguest_ro_state *state); 159void setup_default_gdt_entries(struct lguest_ro_state *state);
160void setup_guest_gdt(struct lg_cpu *cpu); 160void setup_guest_gdt(struct lg_cpu *cpu);
161void load_guest_gdt(struct lg_cpu *cpu, unsigned long table, u32 num); 161void load_guest_gdt_entry(struct lg_cpu *cpu, unsigned int i,
162 u32 low, u32 hi);
162void guest_load_tls(struct lg_cpu *cpu, unsigned long tls_array); 163void guest_load_tls(struct lg_cpu *cpu, unsigned long tls_array);
163void copy_gdt(const struct lg_cpu *cpu, struct desc_struct *gdt); 164void copy_gdt(const struct lg_cpu *cpu, struct desc_struct *gdt);
164void copy_gdt_tls(const struct lg_cpu *cpu, struct desc_struct *gdt); 165void copy_gdt_tls(const struct lg_cpu *cpu, struct desc_struct *gdt);
diff --git a/drivers/lguest/segments.c b/drivers/lguest/segments.c
index 4f15439b7f12..7ede64ffeef9 100644
--- a/drivers/lguest/segments.c
+++ b/drivers/lguest/segments.c
@@ -144,18 +144,19 @@ void copy_gdt(const struct lg_cpu *cpu, struct desc_struct *gdt)
144 gdt[i] = cpu->arch.gdt[i]; 144 gdt[i] = cpu->arch.gdt[i];
145} 145}
146 146
147/*H:620 This is where the Guest asks us to load a new GDT (LHCALL_LOAD_GDT). 147/*H:620 This is where the Guest asks us to load a new GDT entry
148 * We copy it from the Guest and tweak the entries. */ 148 * (LHCALL_LOAD_GDT_ENTRY). We tweak the entry and copy it in. */
149void load_guest_gdt(struct lg_cpu *cpu, unsigned long table, u32 num) 149void load_guest_gdt_entry(struct lg_cpu *cpu, u32 num, u32 lo, u32 hi)
150{ 150{
151 /* We assume the Guest has the same number of GDT entries as the 151 /* We assume the Guest has the same number of GDT entries as the
152 * Host, otherwise we'd have to dynamically allocate the Guest GDT. */ 152 * Host, otherwise we'd have to dynamically allocate the Guest GDT. */
153 if (num > ARRAY_SIZE(cpu->arch.gdt)) 153 if (num > ARRAY_SIZE(cpu->arch.gdt))
154 kill_guest(cpu, "too many gdt entries %i", num); 154 kill_guest(cpu, "too many gdt entries %i", num);
155 155
156 /* We read the whole thing in, then fix it up. */ 156 /* Set it up, then fix it. */
157 __lgread(cpu, cpu->arch.gdt, table, num * sizeof(cpu->arch.gdt[0])); 157 cpu->arch.gdt[num].a = lo;
158 fixup_gdt_table(cpu, 0, ARRAY_SIZE(cpu->arch.gdt)); 158 cpu->arch.gdt[num].b = hi;
159 fixup_gdt_table(cpu, num, num+1);
159 /* Mark that the GDT changed so the core knows it has to copy it again, 160 /* Mark that the GDT changed so the core knows it has to copy it again,
160 * even if the Guest is run on the same CPU. */ 161 * even if the Guest is run on the same CPU. */
161 cpu->changed |= CHANGED_GDT; 162 cpu->changed |= CHANGED_GDT;
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
index a6b717644be0..1a83910f674f 100644
--- a/drivers/lguest/x86/core.c
+++ b/drivers/lguest/x86/core.c
@@ -324,6 +324,11 @@ static void rewrite_hypercall(struct lg_cpu *cpu)
324 u8 insn[3] = {0xcd, 0x1f, 0x90}; 324 u8 insn[3] = {0xcd, 0x1f, 0x90};
325 325
326 __lgwrite(cpu, guest_pa(cpu, cpu->regs->eip), insn, sizeof(insn)); 326 __lgwrite(cpu, guest_pa(cpu, cpu->regs->eip), insn, sizeof(insn));
327 /* The above write might have caused a copy of that page to be made
328 * (if it was read-only). We need to make sure the Guest has
329 * up-to-date pagetables. As this doesn't happen often, we can just
330 * drop them all. */
331 guest_pagetable_clear_all(cpu);
327} 332}
328 333
329static bool is_hypercall(struct lg_cpu *cpu) 334static bool is_hypercall(struct lg_cpu *cpu)
@@ -563,8 +568,8 @@ void __exit lguest_arch_host_fini(void)
563int lguest_arch_do_hcall(struct lg_cpu *cpu, struct hcall_args *args) 568int lguest_arch_do_hcall(struct lg_cpu *cpu, struct hcall_args *args)
564{ 569{
565 switch (args->arg0) { 570 switch (args->arg0) {
566 case LHCALL_LOAD_GDT: 571 case LHCALL_LOAD_GDT_ENTRY:
567 load_guest_gdt(cpu, args->arg1, args->arg2); 572 load_guest_gdt_entry(cpu, args->arg1, args->arg2, args->arg3);
568 break; 573 break;
569 case LHCALL_LOAD_IDT_ENTRY: 574 case LHCALL_LOAD_IDT_ENTRY:
570 load_guest_idt_entry(cpu, args->arg1, args->arg2, args->arg3); 575 load_guest_idt_entry(cpu, args->arg1, args->arg2, args->arg3);
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index f8a9f7ab2cb8..1fb91edc7de2 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1479,6 +1479,7 @@ void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector)
1479 s += blocks; 1479 s += blocks;
1480 } 1480 }
1481 bitmap->last_end_sync = jiffies; 1481 bitmap->last_end_sync = jiffies;
1482 sysfs_notify(&bitmap->mddev->kobj, NULL, "sync_completed");
1482} 1483}
1483 1484
1484static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed) 1485static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed)
@@ -1589,7 +1590,7 @@ void bitmap_destroy(mddev_t *mddev)
1589int bitmap_create(mddev_t *mddev) 1590int bitmap_create(mddev_t *mddev)
1590{ 1591{
1591 struct bitmap *bitmap; 1592 struct bitmap *bitmap;
1592 unsigned long blocks = mddev->resync_max_sectors; 1593 sector_t blocks = mddev->resync_max_sectors;
1593 unsigned long chunks; 1594 unsigned long chunks;
1594 unsigned long pages; 1595 unsigned long pages;
1595 struct file *file = mddev->bitmap_file; 1596 struct file *file = mddev->bitmap_file;
@@ -1631,8 +1632,8 @@ int bitmap_create(mddev_t *mddev)
1631 bitmap->chunkshift = ffz(~bitmap->chunksize); 1632 bitmap->chunkshift = ffz(~bitmap->chunksize);
1632 1633
1633 /* now that chunksize and chunkshift are set, we can use these macros */ 1634 /* now that chunksize and chunkshift are set, we can use these macros */
1634 chunks = (blocks + CHUNK_BLOCK_RATIO(bitmap) - 1) / 1635 chunks = (blocks + CHUNK_BLOCK_RATIO(bitmap) - 1) >>
1635 CHUNK_BLOCK_RATIO(bitmap); 1636 CHUNK_BLOCK_SHIFT(bitmap);
1636 pages = (chunks + PAGE_COUNTER_RATIO - 1) / PAGE_COUNTER_RATIO; 1637 pages = (chunks + PAGE_COUNTER_RATIO - 1) / PAGE_COUNTER_RATIO;
1637 1638
1638 BUG_ON(!pages); 1639 BUG_ON(!pages);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index ed5727c089a9..612343fdde94 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2017,6 +2017,8 @@ repeat:
2017 clear_bit(MD_CHANGE_PENDING, &mddev->flags); 2017 clear_bit(MD_CHANGE_PENDING, &mddev->flags);
2018 spin_unlock_irq(&mddev->write_lock); 2018 spin_unlock_irq(&mddev->write_lock);
2019 wake_up(&mddev->sb_wait); 2019 wake_up(&mddev->sb_wait);
2020 if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))
2021 sysfs_notify(&mddev->kobj, NULL, "sync_completed");
2020 2022
2021} 2023}
2022 2024
@@ -2086,6 +2088,7 @@ state_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2086 * -writemostly - clears write_mostly 2088 * -writemostly - clears write_mostly
2087 * blocked - sets the Blocked flag 2089 * blocked - sets the Blocked flag
2088 * -blocked - clears the Blocked flag 2090 * -blocked - clears the Blocked flag
2091 * insync - sets Insync providing device isn't active
2089 */ 2092 */
2090 int err = -EINVAL; 2093 int err = -EINVAL;
2091 if (cmd_match(buf, "faulty") && rdev->mddev->pers) { 2094 if (cmd_match(buf, "faulty") && rdev->mddev->pers) {
@@ -2118,6 +2121,9 @@ state_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2118 md_wakeup_thread(rdev->mddev->thread); 2121 md_wakeup_thread(rdev->mddev->thread);
2119 2122
2120 err = 0; 2123 err = 0;
2124 } else if (cmd_match(buf, "insync") && rdev->raid_disk == -1) {
2125 set_bit(In_sync, &rdev->flags);
2126 err = 0;
2121 } 2127 }
2122 if (!err && rdev->sysfs_state) 2128 if (!err && rdev->sysfs_state)
2123 sysfs_notify_dirent(rdev->sysfs_state); 2129 sysfs_notify_dirent(rdev->sysfs_state);
@@ -2190,7 +2196,7 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2190 } else if (rdev->mddev->pers) { 2196 } else if (rdev->mddev->pers) {
2191 mdk_rdev_t *rdev2; 2197 mdk_rdev_t *rdev2;
2192 /* Activating a spare .. or possibly reactivating 2198 /* Activating a spare .. or possibly reactivating
2193 * if we every get bitmaps working here. 2199 * if we ever get bitmaps working here.
2194 */ 2200 */
2195 2201
2196 if (rdev->raid_disk != -1) 2202 if (rdev->raid_disk != -1)
@@ -3482,12 +3488,15 @@ sync_completed_show(mddev_t *mddev, char *page)
3482{ 3488{
3483 unsigned long max_sectors, resync; 3489 unsigned long max_sectors, resync;
3484 3490
3491 if (!test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))
3492 return sprintf(page, "none\n");
3493
3485 if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) 3494 if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery))
3486 max_sectors = mddev->resync_max_sectors; 3495 max_sectors = mddev->resync_max_sectors;
3487 else 3496 else
3488 max_sectors = mddev->dev_sectors; 3497 max_sectors = mddev->dev_sectors;
3489 3498
3490 resync = (mddev->curr_resync - atomic_read(&mddev->recovery_active)); 3499 resync = mddev->curr_resync_completed;
3491 return sprintf(page, "%lu / %lu\n", resync, max_sectors); 3500 return sprintf(page, "%lu / %lu\n", resync, max_sectors);
3492} 3501}
3493 3502
@@ -6334,18 +6343,13 @@ void md_do_sync(mddev_t *mddev)
6334 sector_t sectors; 6343 sector_t sectors;
6335 6344
6336 skipped = 0; 6345 skipped = 0;
6337 if (j >= mddev->resync_max) {
6338 sysfs_notify(&mddev->kobj, NULL, "sync_completed");
6339 wait_event(mddev->recovery_wait,
6340 mddev->resync_max > j
6341 || kthread_should_stop());
6342 }
6343 if (kthread_should_stop())
6344 goto interrupted;
6345 6346
6346 if (mddev->curr_resync > mddev->curr_resync_completed && 6347 if ((mddev->curr_resync > mddev->curr_resync_completed &&
6347 (mddev->curr_resync - mddev->curr_resync_completed) 6348 (mddev->curr_resync - mddev->curr_resync_completed)
6348 > (max_sectors >> 4)) { 6349 > (max_sectors >> 4)) ||
6350 (j - mddev->curr_resync_completed)*2
6351 >= mddev->resync_max - mddev->curr_resync_completed
6352 ) {
6349 /* time to update curr_resync_completed */ 6353 /* time to update curr_resync_completed */
6350 blk_unplug(mddev->queue); 6354 blk_unplug(mddev->queue);
6351 wait_event(mddev->recovery_wait, 6355 wait_event(mddev->recovery_wait,
@@ -6353,7 +6357,17 @@ void md_do_sync(mddev_t *mddev)
6353 mddev->curr_resync_completed = 6357 mddev->curr_resync_completed =
6354 mddev->curr_resync; 6358 mddev->curr_resync;
6355 set_bit(MD_CHANGE_CLEAN, &mddev->flags); 6359 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
6360 sysfs_notify(&mddev->kobj, NULL, "sync_completed");
6356 } 6361 }
6362
6363 if (j >= mddev->resync_max)
6364 wait_event(mddev->recovery_wait,
6365 mddev->resync_max > j
6366 || kthread_should_stop());
6367
6368 if (kthread_should_stop())
6369 goto interrupted;
6370
6357 sectors = mddev->pers->sync_request(mddev, j, &skipped, 6371 sectors = mddev->pers->sync_request(mddev, j, &skipped,
6358 currspeed < speed_min(mddev)); 6372 currspeed < speed_min(mddev));
6359 if (sectors == 0) { 6373 if (sectors == 0) {
@@ -6461,6 +6475,7 @@ void md_do_sync(mddev_t *mddev)
6461 6475
6462 skip: 6476 skip:
6463 mddev->curr_resync = 0; 6477 mddev->curr_resync = 0;
6478 mddev->curr_resync_completed = 0;
6464 mddev->resync_min = 0; 6479 mddev->resync_min = 0;
6465 mddev->resync_max = MaxSector; 6480 mddev->resync_max = MaxSector;
6466 sysfs_notify(&mddev->kobj, NULL, "sync_completed"); 6481 sysfs_notify(&mddev->kobj, NULL, "sync_completed");
diff --git a/drivers/md/md.h b/drivers/md/md.h
index e9b7f54c24d6..8227ab909d44 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -12,10 +12,17 @@
12 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 12 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
13*/ 13*/
14 14
15#ifndef _MD_K_H 15#ifndef _MD_MD_H
16#define _MD_K_H 16#define _MD_MD_H
17 17
18#ifdef CONFIG_BLOCK 18#include <linux/blkdev.h>
19#include <linux/kobject.h>
20#include <linux/list.h>
21#include <linux/mm.h>
22#include <linux/mutex.h>
23#include <linux/timer.h>
24#include <linux/wait.h>
25#include <linux/workqueue.h>
19 26
20#define MaxSector (~(sector_t)0) 27#define MaxSector (~(sector_t)0)
21 28
@@ -408,10 +415,6 @@ static inline void safe_put_page(struct page *p)
408 if (p) put_page(p); 415 if (p) put_page(p);
409} 416}
410 417
411#endif /* CONFIG_BLOCK */
412#endif
413
414
415extern int register_md_personality(struct mdk_personality *p); 418extern int register_md_personality(struct mdk_personality *p);
416extern int unregister_md_personality(struct mdk_personality *p); 419extern int unregister_md_personality(struct mdk_personality *p);
417extern mdk_thread_t * md_register_thread(void (*run) (mddev_t *mddev), 420extern mdk_thread_t * md_register_thread(void (*run) (mddev_t *mddev),
@@ -434,3 +437,5 @@ extern void md_new_event(mddev_t *mddev);
434extern int md_allow_write(mddev_t *mddev); 437extern int md_allow_write(mddev_t *mddev);
435extern void md_wait_for_blocked_rdev(mdk_rdev_t *rdev, mddev_t *mddev); 438extern void md_wait_for_blocked_rdev(mdk_rdev_t *rdev, mddev_t *mddev);
436extern void md_set_array_sectors(mddev_t *mddev, sector_t array_sectors); 439extern void md_set_array_sectors(mddev_t *mddev, sector_t array_sectors);
440
441#endif /* _MD_MD_H */
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 3bbc6d647044..4616bc3a6e71 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3845,6 +3845,7 @@ static sector_t reshape_request(mddev_t *mddev, sector_t sector_nr, int *skipped
3845 wait_event(conf->wait_for_overlap, 3845 wait_event(conf->wait_for_overlap,
3846 atomic_read(&conf->reshape_stripes)==0); 3846 atomic_read(&conf->reshape_stripes)==0);
3847 mddev->reshape_position = conf->reshape_progress; 3847 mddev->reshape_position = conf->reshape_progress;
3848 mddev->curr_resync_completed = mddev->curr_resync;
3848 conf->reshape_checkpoint = jiffies; 3849 conf->reshape_checkpoint = jiffies;
3849 set_bit(MD_CHANGE_DEVS, &mddev->flags); 3850 set_bit(MD_CHANGE_DEVS, &mddev->flags);
3850 md_wakeup_thread(mddev->thread); 3851 md_wakeup_thread(mddev->thread);
@@ -3854,6 +3855,7 @@ static sector_t reshape_request(mddev_t *mddev, sector_t sector_nr, int *skipped
3854 conf->reshape_safe = mddev->reshape_position; 3855 conf->reshape_safe = mddev->reshape_position;
3855 spin_unlock_irq(&conf->device_lock); 3856 spin_unlock_irq(&conf->device_lock);
3856 wake_up(&conf->wait_for_overlap); 3857 wake_up(&conf->wait_for_overlap);
3858 sysfs_notify(&mddev->kobj, NULL, "sync_completed");
3857 } 3859 }
3858 3860
3859 if (mddev->delta_disks < 0) { 3861 if (mddev->delta_disks < 0) {
@@ -3938,11 +3940,13 @@ static sector_t reshape_request(mddev_t *mddev, sector_t sector_nr, int *skipped
3938 * then we need to write out the superblock. 3940 * then we need to write out the superblock.
3939 */ 3941 */
3940 sector_nr += reshape_sectors; 3942 sector_nr += reshape_sectors;
3941 if (sector_nr >= mddev->resync_max) { 3943 if ((sector_nr - mddev->curr_resync_completed) * 2
3944 >= mddev->resync_max - mddev->curr_resync_completed) {
3942 /* Cannot proceed until we've updated the superblock... */ 3945 /* Cannot proceed until we've updated the superblock... */
3943 wait_event(conf->wait_for_overlap, 3946 wait_event(conf->wait_for_overlap,
3944 atomic_read(&conf->reshape_stripes) == 0); 3947 atomic_read(&conf->reshape_stripes) == 0);
3945 mddev->reshape_position = conf->reshape_progress; 3948 mddev->reshape_position = conf->reshape_progress;
3949 mddev->curr_resync_completed = mddev->curr_resync;
3946 conf->reshape_checkpoint = jiffies; 3950 conf->reshape_checkpoint = jiffies;
3947 set_bit(MD_CHANGE_DEVS, &mddev->flags); 3951 set_bit(MD_CHANGE_DEVS, &mddev->flags);
3948 md_wakeup_thread(mddev->thread); 3952 md_wakeup_thread(mddev->thread);
@@ -3953,6 +3957,7 @@ static sector_t reshape_request(mddev_t *mddev, sector_t sector_nr, int *skipped
3953 conf->reshape_safe = mddev->reshape_position; 3957 conf->reshape_safe = mddev->reshape_position;
3954 spin_unlock_irq(&conf->device_lock); 3958 spin_unlock_irq(&conf->device_lock);
3955 wake_up(&conf->wait_for_overlap); 3959 wake_up(&conf->wait_for_overlap);
3960 sysfs_notify(&mddev->kobj, NULL, "sync_completed");
3956 } 3961 }
3957 return reshape_sectors; 3962 return reshape_sectors;
3958} 3963}
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index d0d126c69354..5d496a99e034 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -5934,7 +5934,7 @@ mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *pCfg)
5934 5934
5935 /* Initalize the timer 5935 /* Initalize the timer
5936 */ 5936 */
5937 init_timer(&pCfg->timer); 5937 init_timer_on_stack(&pCfg->timer);
5938 pCfg->timer.data = (unsigned long) ioc; 5938 pCfg->timer.data = (unsigned long) ioc;
5939 pCfg->timer.function = mpt_timer_expired; 5939 pCfg->timer.function = mpt_timer_expired;
5940 pCfg->wait_done = 0; 5940 pCfg->wait_done = 0;
diff --git a/drivers/misc/sgi-gru/grufile.c b/drivers/misc/sgi-gru/grufile.c
index 3e6e42d2f01b..bbefe77c67a9 100644
--- a/drivers/misc/sgi-gru/grufile.c
+++ b/drivers/misc/sgi-gru/grufile.c
@@ -375,7 +375,7 @@ static int __init gru_init(void)
375 void *gru_start_vaddr; 375 void *gru_start_vaddr;
376 376
377 if (!is_uv_system()) 377 if (!is_uv_system())
378 return -ENODEV; 378 return 0;
379 379
380#if defined CONFIG_IA64 380#if defined CONFIG_IA64
381 gru_start_paddr = 0xd000000000UL; /* ZZZZZZZZZZZZZZZZZZZ fixme */ 381 gru_start_paddr = 0xd000000000UL; /* ZZZZZZZZZZZZZZZZZZZ fixme */
diff --git a/drivers/misc/sgi-xp/xp_main.c b/drivers/misc/sgi-xp/xp_main.c
index 16f8dcab2da4..7896849b16dc 100644
--- a/drivers/misc/sgi-xp/xp_main.c
+++ b/drivers/misc/sgi-xp/xp_main.c
@@ -248,19 +248,19 @@ xp_init(void)
248 enum xp_retval ret; 248 enum xp_retval ret;
249 int ch_number; 249 int ch_number;
250 250
251 /* initialize the connection registration mutex */
252 for (ch_number = 0; ch_number < XPC_MAX_NCHANNELS; ch_number++)
253 mutex_init(&xpc_registrations[ch_number].mutex);
254
251 if (is_shub()) 255 if (is_shub())
252 ret = xp_init_sn2(); 256 ret = xp_init_sn2();
253 else if (is_uv()) 257 else if (is_uv())
254 ret = xp_init_uv(); 258 ret = xp_init_uv();
255 else 259 else
256 ret = xpUnsupported; 260 ret = 0;
257 261
258 if (ret != xpSuccess) 262 if (ret != xpSuccess)
259 return -ENODEV; 263 return ret;
260
261 /* initialize the connection registration mutex */
262 for (ch_number = 0; ch_number < XPC_MAX_NCHANNELS; ch_number++)
263 mutex_init(&xpc_registrations[ch_number].mutex);
264 264
265 return 0; 265 return 0;
266} 266}
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index b6d35f50e404..23e10b6263d6 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -797,17 +797,15 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
797 goto cleanup2; 797 goto cleanup2;
798 } 798 }
799 799
800 pr_info("%s: alarms up to one %s%s, %zd bytes nvram%s\n", 800 pr_info("%s: %s%s, %zd bytes nvram%s\n",
801 dev_name(&cmos_rtc.rtc->dev), 801 dev_name(&cmos_rtc.rtc->dev),
802 is_valid_irq(rtc_irq) 802 !is_valid_irq(rtc_irq) ? "no alarms" :
803 ? (cmos_rtc.mon_alrm 803 cmos_rtc.mon_alrm ? "alarms up to one year" :
804 ? "year" 804 cmos_rtc.day_alrm ? "alarms up to one month" :
805 : (cmos_rtc.day_alrm 805 "alarms up to one day",
806 ? "month" : "day")) 806 cmos_rtc.century ? ", y3k" : "",
807 : "no", 807 nvram.size,
808 cmos_rtc.century ? ", y3k" : "", 808 is_hpet_enabled() ? ", hpet irqs" : "");
809 nvram.size,
810 is_hpet_enabled() ? ", hpet irqs" : "");
811 809
812 return 0; 810 return 0;
813 811
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index 18ba812a4f84..d86123e03391 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -166,7 +166,7 @@ static void bfin_serial_start_tx(struct uart_port *port)
166 struct tty_struct *tty = uart->port.info->port.tty; 166 struct tty_struct *tty = uart->port.info->port.tty;
167 167
168#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS 168#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
169 if (uart->scts && (!bfin_serial_get_mctrl(&uart->port)&TIOCM_CTS)) { 169 if (uart->scts && !(bfin_serial_get_mctrl(&uart->port) & TIOCM_CTS)) {
170 uart->scts = 0; 170 uart->scts = 0;
171 uart_handle_cts_change(&uart->port, uart->scts); 171 uart_handle_cts_change(&uart->port, uart->scts);
172 } 172 }
@@ -368,7 +368,7 @@ static irqreturn_t bfin_serial_tx_int(int irq, void *dev_id)
368 struct bfin_serial_port *uart = dev_id; 368 struct bfin_serial_port *uart = dev_id;
369 369
370#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS 370#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
371 if (uart->scts && (!bfin_serial_get_mctrl(&uart->port)&TIOCM_CTS)) { 371 if (uart->scts && !(bfin_serial_get_mctrl(&uart->port) & TIOCM_CTS)) {
372 uart->scts = 0; 372 uart->scts = 0;
373 uart_handle_cts_change(&uart->port, uart->scts); 373 uart_handle_cts_change(&uart->port, uart->scts);
374 } 374 }
@@ -504,7 +504,7 @@ static irqreturn_t bfin_serial_dma_tx_int(int irq, void *dev_id)
504 struct circ_buf *xmit = &uart->port.info->xmit; 504 struct circ_buf *xmit = &uart->port.info->xmit;
505 505
506#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS 506#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
507 if (uart->scts && (!bfin_serial_get_mctrl(&uart->port)&TIOCM_CTS)) { 507 if (uart->scts && !(bfin_serial_get_mctrl(&uart->port)&TIOCM_CTS)) {
508 uart->scts = 0; 508 uart->scts = 0;
509 uart_handle_cts_change(&uart->port, uart->scts); 509 uart_handle_cts_change(&uart->port, uart->scts);
510 } 510 }
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index c76feea5fe25..885194a07418 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -213,7 +213,7 @@ static int flush(struct driver_data *drv_data)
213 while (read_SSSR(reg) & SSSR_RNE) { 213 while (read_SSSR(reg) & SSSR_RNE) {
214 read_SSDR(reg); 214 read_SSDR(reg);
215 } 215 }
216 } while ((read_SSSR(reg) & SSSR_BSY) && limit--); 216 } while ((read_SSSR(reg) & SSSR_BSY) && --limit);
217 write_SSSR(SSSR_ROR, reg); 217 write_SSSR(SSSR_ROR, reg);
218 218
219 return limit; 219 return limit;
@@ -484,7 +484,7 @@ static int wait_ssp_rx_stall(void const __iomem *ioaddr)
484{ 484{
485 unsigned long limit = loops_per_jiffy << 1; 485 unsigned long limit = loops_per_jiffy << 1;
486 486
487 while ((read_SSSR(ioaddr) & SSSR_BSY) && limit--) 487 while ((read_SSSR(ioaddr) & SSSR_BSY) && --limit)
488 cpu_relax(); 488 cpu_relax();
489 489
490 return limit; 490 return limit;
@@ -494,7 +494,7 @@ static int wait_dma_channel_stop(int channel)
494{ 494{
495 unsigned long limit = loops_per_jiffy << 1; 495 unsigned long limit = loops_per_jiffy << 1;
496 496
497 while (!(DCSR(channel) & DCSR_STOPSTATE) && limit--) 497 while (!(DCSR(channel) & DCSR_STOPSTATE) && --limit)
498 cpu_relax(); 498 cpu_relax();
499 499
500 return limit; 500 return limit;
@@ -1700,6 +1700,13 @@ static int pxa2xx_spi_resume(struct platform_device *pdev)
1700 struct ssp_device *ssp = drv_data->ssp; 1700 struct ssp_device *ssp = drv_data->ssp;
1701 int status = 0; 1701 int status = 0;
1702 1702
1703 if (drv_data->rx_channel != -1)
1704 DRCMR(drv_data->ssp->drcmr_rx) =
1705 DRCMR_MAPVLD | drv_data->rx_channel;
1706 if (drv_data->tx_channel != -1)
1707 DRCMR(drv_data->ssp->drcmr_tx) =
1708 DRCMR_MAPVLD | drv_data->tx_channel;
1709
1703 /* Enable the SSP clock */ 1710 /* Enable the SSP clock */
1704 clk_enable(ssp->clk); 1711 clk_enable(ssp->clk);
1705 1712
diff --git a/drivers/staging/go7007/go7007-driver.c b/drivers/staging/go7007/go7007-driver.c
index f47c0ce2849a..77b1e769ac92 100644
--- a/drivers/staging/go7007/go7007-driver.c
+++ b/drivers/staging/go7007/go7007-driver.c
@@ -191,8 +191,10 @@ int go7007_reset_encoder(struct go7007 *go)
191/* 191/*
192 * Attempt to instantiate an I2C client by ID, probably loading a module. 192 * Attempt to instantiate an I2C client by ID, probably loading a module.
193 */ 193 */
194static int init_i2c_module(struct i2c_adapter *adapter, int id, int addr) 194static int init_i2c_module(struct i2c_adapter *adapter, const char *type,
195 int id, int addr)
195{ 196{
197 struct i2c_board_info info;
196 char *modname; 198 char *modname;
197 199
198 switch (id) { 200 switch (id) {
@@ -226,7 +228,11 @@ static int init_i2c_module(struct i2c_adapter *adapter, int id, int addr)
226 } 228 }
227 if (modname != NULL) 229 if (modname != NULL)
228 request_module(modname); 230 request_module(modname);
229 if (wis_i2c_probe_device(adapter, id, addr) == 1) 231
232 memset(&info, 0, sizeof(struct i2c_board_info));
233 info.addr = addr;
234 strlcpy(info.type, type, I2C_NAME_SIZE);
235 if (!i2c_new_device(adapter, &info))
230 return 0; 236 return 0;
231 if (modname != NULL) 237 if (modname != NULL)
232 printk(KERN_INFO 238 printk(KERN_INFO
@@ -266,6 +272,7 @@ int go7007_register_encoder(struct go7007 *go)
266 if (go->i2c_adapter_online) { 272 if (go->i2c_adapter_online) {
267 for (i = 0; i < go->board_info->num_i2c_devs; ++i) 273 for (i = 0; i < go->board_info->num_i2c_devs; ++i)
268 init_i2c_module(&go->i2c_adapter, 274 init_i2c_module(&go->i2c_adapter,
275 go->board_info->i2c_devs[i].type,
269 go->board_info->i2c_devs[i].id, 276 go->board_info->i2c_devs[i].id,
270 go->board_info->i2c_devs[i].addr); 277 go->board_info->i2c_devs[i].addr);
271 if (go->board_id == GO7007_BOARDID_ADLINK_MPG24) 278 if (go->board_id == GO7007_BOARDID_ADLINK_MPG24)
diff --git a/drivers/staging/go7007/go7007-i2c.c b/drivers/staging/go7007/go7007-i2c.c
index cd55b76eabc7..c82867fdd28d 100644
--- a/drivers/staging/go7007/go7007-i2c.c
+++ b/drivers/staging/go7007/go7007-i2c.c
@@ -31,87 +31,6 @@
31#include "go7007-priv.h" 31#include "go7007-priv.h"
32#include "wis-i2c.h" 32#include "wis-i2c.h"
33 33
34/************** Registration interface for I2C client drivers **************/
35
36/* Since there's no way to auto-probe the I2C devices connected to the I2C
37 * bus on the go7007, we have this silly little registration system that
38 * client drivers can use to register their I2C driver ID and their
39 * detect_client function (the one that's normally passed to i2c_probe).
40 *
41 * When a new go7007 device is connected, we can look up in a board info
42 * table by the USB or PCI vendor/product/revision ID to determine
43 * which I2C client module to load. The client driver module will register
44 * itself here, and then we can call the registered detect_client function
45 * to force-load a new client at the address listed in the board info table.
46 *
47 * Really the I2C subsystem should have a way to force-load I2C client
48 * drivers when we have a priori knowledge of what's on the bus, especially
49 * since the existing I2C auto-probe mechanism is so hokey, but we'll use
50 * our own mechanism for the time being. */
51
52struct wis_i2c_client_driver {
53 unsigned int id;
54 found_proc found_proc;
55 struct list_head list;
56};
57
58static LIST_HEAD(i2c_client_drivers);
59static DECLARE_MUTEX(i2c_client_driver_list_lock);
60
61/* Client drivers register here by their I2C driver ID */
62int wis_i2c_add_driver(unsigned int id, found_proc found_proc)
63{
64 struct wis_i2c_client_driver *driver;
65
66 driver = kmalloc(sizeof(struct wis_i2c_client_driver), GFP_KERNEL);
67 if (driver == NULL)
68 return -ENOMEM;
69 driver->id = id;
70 driver->found_proc = found_proc;
71
72 down(&i2c_client_driver_list_lock);
73 list_add_tail(&driver->list, &i2c_client_drivers);
74 up(&i2c_client_driver_list_lock);
75
76 return 0;
77}
78EXPORT_SYMBOL(wis_i2c_add_driver);
79
80void wis_i2c_del_driver(found_proc found_proc)
81{
82 struct wis_i2c_client_driver *driver, *next;
83
84 down(&i2c_client_driver_list_lock);
85 list_for_each_entry_safe(driver, next, &i2c_client_drivers, list)
86 if (driver->found_proc == found_proc) {
87 list_del(&driver->list);
88 kfree(driver);
89 }
90 up(&i2c_client_driver_list_lock);
91}
92EXPORT_SYMBOL(wis_i2c_del_driver);
93
94/* The main go7007 driver calls this to instantiate a client by driver
95 * ID and bus address, which are both stored in the board info table */
96int wis_i2c_probe_device(struct i2c_adapter *adapter,
97 unsigned int id, int addr)
98{
99 struct wis_i2c_client_driver *driver;
100 int found = 0;
101
102 if (addr < 0 || addr > 0x7f)
103 return -1;
104 down(&i2c_client_driver_list_lock);
105 list_for_each_entry(driver, &i2c_client_drivers, list)
106 if (driver->id == id) {
107 if (driver->found_proc(adapter, addr, 0) == 0)
108 found = 1;
109 break;
110 }
111 up(&i2c_client_driver_list_lock);
112 return found;
113}
114
115/********************* Driver for on-board I2C adapter *********************/ 34/********************* Driver for on-board I2C adapter *********************/
116 35
117/* #define GO7007_I2C_DEBUG */ 36/* #define GO7007_I2C_DEBUG */
@@ -287,9 +206,7 @@ static struct i2c_algorithm go7007_algo = {
287 206
288static struct i2c_adapter go7007_adap_templ = { 207static struct i2c_adapter go7007_adap_templ = {
289 .owner = THIS_MODULE, 208 .owner = THIS_MODULE,
290 .class = I2C_CLASS_TV_ANALOG,
291 .name = "WIS GO7007SB", 209 .name = "WIS GO7007SB",
292 .id = I2C_ALGO_GO7007,
293 .algo = &go7007_algo, 210 .algo = &go7007_algo,
294}; 211};
295 212
diff --git a/drivers/staging/go7007/go7007-priv.h b/drivers/staging/go7007/go7007-priv.h
index 372f1f1c09b2..178d18119faa 100644
--- a/drivers/staging/go7007/go7007-priv.h
+++ b/drivers/staging/go7007/go7007-priv.h
@@ -87,6 +87,7 @@ struct go7007_board_info {
87 int audio_main_div; 87 int audio_main_div;
88 int num_i2c_devs; 88 int num_i2c_devs;
89 struct { 89 struct {
90 const char *type;
90 int id; 91 int id;
91 int addr; 92 int addr;
92 } i2c_devs[4]; 93 } i2c_devs[4];
diff --git a/drivers/staging/go7007/go7007-usb.c b/drivers/staging/go7007/go7007-usb.c
index 83eec920c7d3..aa4a9e0b9954 100644
--- a/drivers/staging/go7007/go7007-usb.c
+++ b/drivers/staging/go7007/go7007-usb.c
@@ -91,6 +91,7 @@ static struct go7007_usb_board board_matrix_ii = {
91 .num_i2c_devs = 1, 91 .num_i2c_devs = 1,
92 .i2c_devs = { 92 .i2c_devs = {
93 { 93 {
94 .type = "wis_saa7115",
94 .id = I2C_DRIVERID_WIS_SAA7115, 95 .id = I2C_DRIVERID_WIS_SAA7115,
95 .addr = 0x20, 96 .addr = 0x20,
96 }, 97 },
@@ -127,6 +128,7 @@ static struct go7007_usb_board board_matrix_reload = {
127 .num_i2c_devs = 1, 128 .num_i2c_devs = 1,
128 .i2c_devs = { 129 .i2c_devs = {
129 { 130 {
131 .type = "wis_saa7113",
130 .id = I2C_DRIVERID_WIS_SAA7113, 132 .id = I2C_DRIVERID_WIS_SAA7113,
131 .addr = 0x25, 133 .addr = 0x25,
132 }, 134 },
@@ -164,6 +166,7 @@ static struct go7007_usb_board board_star_trek = {
164 .num_i2c_devs = 1, 166 .num_i2c_devs = 1,
165 .i2c_devs = { 167 .i2c_devs = {
166 { 168 {
169 .type = "wis_saa7115",
167 .id = I2C_DRIVERID_WIS_SAA7115, 170 .id = I2C_DRIVERID_WIS_SAA7115,
168 .addr = 0x20, 171 .addr = 0x20,
169 }, 172 },
@@ -209,14 +212,17 @@ static struct go7007_usb_board board_px_tv402u = {
209 .num_i2c_devs = 3, 212 .num_i2c_devs = 3,
210 .i2c_devs = { 213 .i2c_devs = {
211 { 214 {
215 .type = "wis_saa7115",
212 .id = I2C_DRIVERID_WIS_SAA7115, 216 .id = I2C_DRIVERID_WIS_SAA7115,
213 .addr = 0x20, 217 .addr = 0x20,
214 }, 218 },
215 { 219 {
220 .type = "wis_uda1342",
216 .id = I2C_DRIVERID_WIS_UDA1342, 221 .id = I2C_DRIVERID_WIS_UDA1342,
217 .addr = 0x1a, 222 .addr = 0x1a,
218 }, 223 },
219 { 224 {
225 .type = "wis_sony_tuner",
220 .id = I2C_DRIVERID_WIS_SONY_TUNER, 226 .id = I2C_DRIVERID_WIS_SONY_TUNER,
221 .addr = 0x60, 227 .addr = 0x60,
222 }, 228 },
@@ -264,6 +270,7 @@ static struct go7007_usb_board board_xmen = {
264 .num_i2c_devs = 1, 270 .num_i2c_devs = 1,
265 .i2c_devs = { 271 .i2c_devs = {
266 { 272 {
273 .type = "wis_ov7640",
267 .id = I2C_DRIVERID_WIS_OV7640, 274 .id = I2C_DRIVERID_WIS_OV7640,
268 .addr = 0x21, 275 .addr = 0x21,
269 }, 276 },
@@ -296,6 +303,7 @@ static struct go7007_usb_board board_matrix_revolution = {
296 .num_i2c_devs = 1, 303 .num_i2c_devs = 1,
297 .i2c_devs = { 304 .i2c_devs = {
298 { 305 {
306 .type = "wis_tw9903",
299 .id = I2C_DRIVERID_WIS_TW9903, 307 .id = I2C_DRIVERID_WIS_TW9903,
300 .addr = 0x44, 308 .addr = 0x44,
301 }, 309 },
@@ -385,6 +393,7 @@ static struct go7007_usb_board board_adlink_mpg24 = {
385 .num_i2c_devs = 1, 393 .num_i2c_devs = 1,
386 .i2c_devs = { 394 .i2c_devs = {
387 { 395 {
396 .type = "wis_twTW2804",
388 .id = I2C_DRIVERID_WIS_TW2804, 397 .id = I2C_DRIVERID_WIS_TW2804,
389 .addr = 0x00, /* yes, really */ 398 .addr = 0x00, /* yes, really */
390 }, 399 },
@@ -415,8 +424,9 @@ static struct go7007_usb_board board_sensoray_2250 = {
415 .num_i2c_devs = 1, 424 .num_i2c_devs = 1,
416 .i2c_devs = { 425 .i2c_devs = {
417 { 426 {
427 .type = "s2250_board",
418 .id = I2C_DRIVERID_S2250, 428 .id = I2C_DRIVERID_S2250,
419 .addr = 0x34, 429 .addr = 0x43,
420 }, 430 },
421 }, 431 },
422 .num_inputs = 2, 432 .num_inputs = 2,
@@ -943,9 +953,7 @@ static struct i2c_algorithm go7007_usb_algo = {
943 953
944static struct i2c_adapter go7007_usb_adap_templ = { 954static struct i2c_adapter go7007_usb_adap_templ = {
945 .owner = THIS_MODULE, 955 .owner = THIS_MODULE,
946 .class = I2C_CLASS_TV_ANALOG,
947 .name = "WIS GO7007SB EZ-USB", 956 .name = "WIS GO7007SB EZ-USB",
948 .id = I2C_ALGO_GO7007_USB,
949 .algo = &go7007_usb_algo, 957 .algo = &go7007_usb_algo,
950}; 958};
951 959
diff --git a/drivers/staging/go7007/s2250-board.c b/drivers/staging/go7007/s2250-board.c
index d333ea2cd774..1706fbf06847 100644
--- a/drivers/staging/go7007/s2250-board.c
+++ b/drivers/staging/go7007/s2250-board.c
@@ -28,7 +28,6 @@ extern int s2250loader_init(void);
28extern void s2250loader_cleanup(void); 28extern void s2250loader_cleanup(void);
29 29
30#define TLV320_ADDRESS 0x34 30#define TLV320_ADDRESS 0x34
31#define S2250_VIDDEC 0x86
32#define VPX322_ADDR_ANALOGCONTROL1 0x02 31#define VPX322_ADDR_ANALOGCONTROL1 0x02
33#define VPX322_ADDR_BRIGHTNESS0 0x0127 32#define VPX322_ADDR_BRIGHTNESS0 0x0127
34#define VPX322_ADDR_BRIGHTNESS1 0x0131 33#define VPX322_ADDR_BRIGHTNESS1 0x0131
@@ -123,6 +122,7 @@ struct s2250 {
123 int hue; 122 int hue;
124 int reg12b_val; 123 int reg12b_val;
125 int audio_input; 124 int audio_input;
125 struct i2c_client *audio;
126}; 126};
127 127
128/* from go7007-usb.c which is Copyright (C) 2005-2006 Micronas USA Inc.*/ 128/* from go7007-usb.c which is Copyright (C) 2005-2006 Micronas USA Inc.*/
@@ -452,16 +452,15 @@ static int s2250_command(struct i2c_client *client,
452 { 452 {
453 struct v4l2_audio *audio = arg; 453 struct v4l2_audio *audio = arg;
454 454
455 client->addr = TLV320_ADDRESS;
456 switch (audio->index) { 455 switch (audio->index) {
457 case 0: 456 case 0:
458 write_reg(client, 0x08, 0x02); /* Line In */ 457 write_reg(dec->audio, 0x08, 0x02); /* Line In */
459 break; 458 break;
460 case 1: 459 case 1:
461 write_reg(client, 0x08, 0x04); /* Mic */ 460 write_reg(dec->audio, 0x08, 0x04); /* Mic */
462 break; 461 break;
463 case 2: 462 case 2:
464 write_reg(client, 0x08, 0x05); /* Mic Boost */ 463 write_reg(dec->audio, 0x08, 0x05); /* Mic Boost */
465 break; 464 break;
466 default: 465 default:
467 return -EINVAL; 466 return -EINVAL;
@@ -477,31 +476,23 @@ static int s2250_command(struct i2c_client *client,
477 return 0; 476 return 0;
478} 477}
479 478
480static struct i2c_driver s2250_driver; 479static int s2250_probe(struct i2c_client *client,
481 480 const struct i2c_device_id *id)
482static struct i2c_client s2250_client_templ = {
483 .name = "Sensoray 2250",
484 .driver = &s2250_driver,
485};
486
487static int s2250_detect(struct i2c_adapter *adapter, int addr, int kind)
488{ 481{
489 struct i2c_client *client; 482 struct i2c_client *audio;
483 struct i2c_adapter *adapter = client->adapter;
490 struct s2250 *dec; 484 struct s2250 *dec;
491 u8 *data; 485 u8 *data;
492 struct go7007 *go = i2c_get_adapdata(adapter); 486 struct go7007 *go = i2c_get_adapdata(adapter);
493 struct go7007_usb *usb = go->hpi_context; 487 struct go7007_usb *usb = go->hpi_context;
494 488
495 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 489 audio = i2c_new_dummy(adapter, TLV320_ADDRESS >> 1);
496 if (client == NULL) 490 if (audio == NULL)
497 return -ENOMEM; 491 return -ENOMEM;
498 memcpy(client, &s2250_client_templ,
499 sizeof(s2250_client_templ));
500 client->adapter = adapter;
501 492
502 dec = kmalloc(sizeof(struct s2250), GFP_KERNEL); 493 dec = kmalloc(sizeof(struct s2250), GFP_KERNEL);
503 if (dec == NULL) { 494 if (dec == NULL) {
504 kfree(client); 495 i2c_unregister_device(audio);
505 return -ENOMEM; 496 return -ENOMEM;
506 } 497 }
507 498
@@ -510,7 +501,7 @@ static int s2250_detect(struct i2c_adapter *adapter, int addr, int kind)
510 dec->contrast = 50; 501 dec->contrast = 50;
511 dec->saturation = 50; 502 dec->saturation = 50;
512 dec->hue = 0; 503 dec->hue = 0;
513 client->addr = TLV320_ADDRESS; 504 dec->audio = audio;
514 i2c_set_clientdata(client, dec); 505 i2c_set_clientdata(client, dec);
515 506
516 printk(KERN_DEBUG 507 printk(KERN_DEBUG
@@ -518,28 +509,25 @@ static int s2250_detect(struct i2c_adapter *adapter, int addr, int kind)
518 adapter->name); 509 adapter->name);
519 510
520 /* initialize the audio */ 511 /* initialize the audio */
521 client->addr = TLV320_ADDRESS; 512 if (write_regs(audio, aud_regs) < 0) {
522 if (write_regs(client, aud_regs) < 0) {
523 printk(KERN_ERR 513 printk(KERN_ERR
524 "s2250: error initializing audio\n"); 514 "s2250: error initializing audio\n");
525 kfree(client); 515 i2c_unregister_device(audio);
526 kfree(dec); 516 kfree(dec);
527 return 0; 517 return 0;
528 } 518 }
529 client->addr = S2250_VIDDEC;
530 i2c_set_clientdata(client, dec);
531 519
532 if (write_regs(client, vid_regs) < 0) { 520 if (write_regs(client, vid_regs) < 0) {
533 printk(KERN_ERR 521 printk(KERN_ERR
534 "s2250: error initializing decoder\n"); 522 "s2250: error initializing decoder\n");
535 kfree(client); 523 i2c_unregister_device(audio);
536 kfree(dec); 524 kfree(dec);
537 return 0; 525 return 0;
538 } 526 }
539 if (write_regs_fp(client, vid_regs_fp) < 0) { 527 if (write_regs_fp(client, vid_regs_fp) < 0) {
540 printk(KERN_ERR 528 printk(KERN_ERR
541 "s2250: error initializing decoder\n"); 529 "s2250: error initializing decoder\n");
542 kfree(client); 530 i2c_unregister_device(audio);
543 kfree(dec); 531 kfree(dec);
544 return 0; 532 return 0;
545 } 533 }
@@ -575,32 +563,33 @@ static int s2250_detect(struct i2c_adapter *adapter, int addr, int kind)
575 up(&usb->i2c_lock); 563 up(&usb->i2c_lock);
576 } 564 }
577 565
578 i2c_attach_client(client);
579 printk("s2250: initialized successfully\n"); 566 printk("s2250: initialized successfully\n");
580 return 0; 567 return 0;
581} 568}
582 569
583static int s2250_detach(struct i2c_client *client) 570static int s2250_remove(struct i2c_client *client)
584{ 571{
585 struct s2250 *dec = i2c_get_clientdata(client); 572 struct s2250 *dec = i2c_get_clientdata(client);
586 int r;
587
588 r = i2c_detach_client(client);
589 if (r < 0)
590 return r;
591 573
592 kfree(client); 574 i2c_set_clientdata(client, NULL);
575 i2c_unregister_device(dec->audio);
593 kfree(dec); 576 kfree(dec);
594 return 0; 577 return 0;
595} 578}
596 579
580static struct i2c_device_id s2250_id[] = {
581 { "s2250_board", 0 },
582 { }
583};
584
597static struct i2c_driver s2250_driver = { 585static struct i2c_driver s2250_driver = {
598 .driver = { 586 .driver = {
599 .name = "Sensoray 2250 board driver", 587 .name = "Sensoray 2250 board driver",
600 }, 588 },
601 .id = I2C_DRIVERID_S2250, 589 .probe = s2250_probe,
602 .detach_client = s2250_detach, 590 .remove = s2250_remove,
603 .command = s2250_command, 591 .command = s2250_command,
592 .id_table = s2250_id,
604}; 593};
605 594
606static int __init s2250_init(void) 595static int __init s2250_init(void)
@@ -613,13 +602,13 @@ static int __init s2250_init(void)
613 602
614 r = i2c_add_driver(&s2250_driver); 603 r = i2c_add_driver(&s2250_driver);
615 if (r < 0) 604 if (r < 0)
616 return r; 605 s2250loader_cleanup();
617 return wis_i2c_add_driver(s2250_driver.id, s2250_detect); 606
607 return r;
618} 608}
619 609
620static void __exit s2250_cleanup(void) 610static void __exit s2250_cleanup(void)
621{ 611{
622 wis_i2c_del_driver(s2250_detect);
623 i2c_del_driver(&s2250_driver); 612 i2c_del_driver(&s2250_driver);
624 613
625 s2250loader_cleanup(); 614 s2250loader_cleanup();
diff --git a/drivers/staging/go7007/wis-i2c.h b/drivers/staging/go7007/wis-i2c.h
index 431f41dd3966..3c2b9be455df 100644
--- a/drivers/staging/go7007/wis-i2c.h
+++ b/drivers/staging/go7007/wis-i2c.h
@@ -24,21 +24,12 @@
24#define I2C_DRIVERID_WIS_OV7640 0xf0f5 24#define I2C_DRIVERID_WIS_OV7640 0xf0f5
25#define I2C_DRIVERID_WIS_TW2804 0xf0f6 25#define I2C_DRIVERID_WIS_TW2804 0xf0f6
26#define I2C_DRIVERID_S2250 0xf0f7 26#define I2C_DRIVERID_S2250 0xf0f7
27#define I2C_ALGO_GO7007 0xf00000
28#define I2C_ALGO_GO7007_USB 0xf10000
29 27
30/* Flag to indicate that the client needs to be accessed with SCCB semantics */ 28/* Flag to indicate that the client needs to be accessed with SCCB semantics */
31/* We re-use the I2C_M_TEN value so the flag passes through the masks in the 29/* We re-use the I2C_M_TEN value so the flag passes through the masks in the
32 * core I2C code. Major kludge, but the I2C layer ain't exactly flexible. */ 30 * core I2C code. Major kludge, but the I2C layer ain't exactly flexible. */
33#define I2C_CLIENT_SCCB 0x10 31#define I2C_CLIENT_SCCB 0x10
34 32
35typedef int (*found_proc) (struct i2c_adapter *, int, int);
36int wis_i2c_add_driver(unsigned int id, found_proc found_proc);
37void wis_i2c_del_driver(found_proc found_proc);
38
39int wis_i2c_probe_device(struct i2c_adapter *adapter,
40 unsigned int id, int addr);
41
42/* Definitions for new video decoder commands */ 33/* Definitions for new video decoder commands */
43 34
44struct video_decoder_resolution { 35struct video_decoder_resolution {
diff --git a/drivers/staging/go7007/wis-ov7640.c b/drivers/staging/go7007/wis-ov7640.c
index 2f9efca04606..04d6d3a498a3 100644
--- a/drivers/staging/go7007/wis-ov7640.c
+++ b/drivers/staging/go7007/wis-ov7640.c
@@ -50,76 +50,54 @@ static int write_regs(struct i2c_client *client, u8 *regs)
50 return 0; 50 return 0;
51} 51}
52 52
53static struct i2c_driver wis_ov7640_driver; 53static int wis_ov7640_probe(struct i2c_client *client,
54 54 const struct i2c_device_id *id)
55static struct i2c_client wis_ov7640_client_templ = {
56 .name = "OV7640 (WIS)",
57 .driver = &wis_ov7640_driver,
58};
59
60static int wis_ov7640_detect(struct i2c_adapter *adapter, int addr, int kind)
61{ 55{
62 struct i2c_client *client; 56 struct i2c_adapter *adapter = client->adapter;
63 57
64 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 58 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
65 return 0; 59 return -ENODEV;
66 60
67 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
68 if (client == NULL)
69 return -ENOMEM;
70 memcpy(client, &wis_ov7640_client_templ,
71 sizeof(wis_ov7640_client_templ));
72 client->adapter = adapter;
73 client->addr = addr;
74 client->flags = I2C_CLIENT_SCCB; 61 client->flags = I2C_CLIENT_SCCB;
75 62
76 printk(KERN_DEBUG 63 printk(KERN_DEBUG
77 "wis-ov7640: initializing OV7640 at address %d on %s\n", 64 "wis-ov7640: initializing OV7640 at address %d on %s\n",
78 addr, adapter->name); 65 client->addr, adapter->name);
79 66
80 if (write_regs(client, initial_registers) < 0) { 67 if (write_regs(client, initial_registers) < 0) {
81 printk(KERN_ERR "wis-ov7640: error initializing OV7640\n"); 68 printk(KERN_ERR "wis-ov7640: error initializing OV7640\n");
82 kfree(client); 69 return -ENODEV;
83 return 0;
84 } 70 }
85 71
86 i2c_attach_client(client);
87 return 0; 72 return 0;
88} 73}
89 74
90static int wis_ov7640_detach(struct i2c_client *client) 75static int wis_ov7640_remove(struct i2c_client *client)
91{ 76{
92 int r;
93
94 r = i2c_detach_client(client);
95 if (r < 0)
96 return r;
97
98 kfree(client);
99 return 0; 77 return 0;
100} 78}
101 79
80static struct i2c_device_id wis_ov7640_id[] = {
81 { "wis_ov7640", 0 },
82 { }
83};
84
102static struct i2c_driver wis_ov7640_driver = { 85static struct i2c_driver wis_ov7640_driver = {
103 .driver = { 86 .driver = {
104 .name = "WIS OV7640 I2C driver", 87 .name = "WIS OV7640 I2C driver",
105 }, 88 },
106 .id = I2C_DRIVERID_WIS_OV7640, 89 .probe = wis_ov7640_probe,
107 .detach_client = wis_ov7640_detach, 90 .remove = wis_ov7640_remove,
91 .id_table = wis_ov7640_id,
108}; 92};
109 93
110static int __init wis_ov7640_init(void) 94static int __init wis_ov7640_init(void)
111{ 95{
112 int r; 96 return i2c_add_driver(&wis_ov7640_driver);
113
114 r = i2c_add_driver(&wis_ov7640_driver);
115 if (r < 0)
116 return r;
117 return wis_i2c_add_driver(wis_ov7640_driver.id, wis_ov7640_detect);
118} 97}
119 98
120static void __exit wis_ov7640_cleanup(void) 99static void __exit wis_ov7640_cleanup(void)
121{ 100{
122 wis_i2c_del_driver(wis_ov7640_detect);
123 i2c_del_driver(&wis_ov7640_driver); 101 i2c_del_driver(&wis_ov7640_driver);
124} 102}
125 103
diff --git a/drivers/staging/go7007/wis-saa7113.c b/drivers/staging/go7007/wis-saa7113.c
index 11689723945e..9ab893bd204e 100644
--- a/drivers/staging/go7007/wis-saa7113.c
+++ b/drivers/staging/go7007/wis-saa7113.c
@@ -261,34 +261,19 @@ static int wis_saa7113_command(struct i2c_client *client,
261 return 0; 261 return 0;
262} 262}
263 263
264static struct i2c_driver wis_saa7113_driver; 264static int wis_saa7113_probe(struct i2c_client *client,
265 265 const struct i2c_device_id *id)
266static struct i2c_client wis_saa7113_client_templ = {
267 .name = "SAA7113 (WIS)",
268 .driver = &wis_saa7113_driver,
269};
270
271static int wis_saa7113_detect(struct i2c_adapter *adapter, int addr, int kind)
272{ 266{
273 struct i2c_client *client; 267 struct i2c_adapter *adapter = client->adapter;
274 struct wis_saa7113 *dec; 268 struct wis_saa7113 *dec;
275 269
276 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 270 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
277 return 0; 271 return -ENODEV;
278
279 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
280 if (client == NULL)
281 return -ENOMEM;
282 memcpy(client, &wis_saa7113_client_templ,
283 sizeof(wis_saa7113_client_templ));
284 client->adapter = adapter;
285 client->addr = addr;
286 272
287 dec = kmalloc(sizeof(struct wis_saa7113), GFP_KERNEL); 273 dec = kmalloc(sizeof(struct wis_saa7113), GFP_KERNEL);
288 if (dec == NULL) { 274 if (dec == NULL)
289 kfree(client);
290 return -ENOMEM; 275 return -ENOMEM;
291 } 276
292 dec->norm = V4L2_STD_NTSC; 277 dec->norm = V4L2_STD_NTSC;
293 dec->brightness = 128; 278 dec->brightness = 128;
294 dec->contrast = 71; 279 dec->contrast = 71;
@@ -298,56 +283,49 @@ static int wis_saa7113_detect(struct i2c_adapter *adapter, int addr, int kind)
298 283
299 printk(KERN_DEBUG 284 printk(KERN_DEBUG
300 "wis-saa7113: initializing SAA7113 at address %d on %s\n", 285 "wis-saa7113: initializing SAA7113 at address %d on %s\n",
301 addr, adapter->name); 286 client->addr, adapter->name);
302 287
303 if (write_regs(client, initial_registers) < 0) { 288 if (write_regs(client, initial_registers) < 0) {
304 printk(KERN_ERR 289 printk(KERN_ERR
305 "wis-saa7113: error initializing SAA7113\n"); 290 "wis-saa7113: error initializing SAA7113\n");
306 kfree(client);
307 kfree(dec); 291 kfree(dec);
308 return 0; 292 return -ENODEV;
309 } 293 }
310 294
311 i2c_attach_client(client);
312 return 0; 295 return 0;
313} 296}
314 297
315static int wis_saa7113_detach(struct i2c_client *client) 298static int wis_saa7113_remove(struct i2c_client *client)
316{ 299{
317 struct wis_saa7113 *dec = i2c_get_clientdata(client); 300 struct wis_saa7113 *dec = i2c_get_clientdata(client);
318 int r;
319
320 r = i2c_detach_client(client);
321 if (r < 0)
322 return r;
323 301
324 kfree(client); 302 i2c_set_clientdata(client, NULL);
325 kfree(dec); 303 kfree(dec);
326 return 0; 304 return 0;
327} 305}
328 306
307static struct i2c_device_id wis_saa7113_id[] = {
308 { "wis_saa7113", 0 },
309 { }
310};
311
329static struct i2c_driver wis_saa7113_driver = { 312static struct i2c_driver wis_saa7113_driver = {
330 .driver = { 313 .driver = {
331 .name = "WIS SAA7113 I2C driver", 314 .name = "WIS SAA7113 I2C driver",
332 }, 315 },
333 .id = I2C_DRIVERID_WIS_SAA7113, 316 .probe = wis_saa7113_probe,
334 .detach_client = wis_saa7113_detach, 317 .remove = wis_saa7113_remove,
335 .command = wis_saa7113_command, 318 .command = wis_saa7113_command,
319 .id_table = wis_saa7113_id,
336}; 320};
337 321
338static int __init wis_saa7113_init(void) 322static int __init wis_saa7113_init(void)
339{ 323{
340 int r; 324 return i2c_add_driver(&wis_saa7113_driver);
341
342 r = i2c_add_driver(&wis_saa7113_driver);
343 if (r < 0)
344 return r;
345 return wis_i2c_add_driver(wis_saa7113_driver.id, wis_saa7113_detect);
346} 325}
347 326
348static void __exit wis_saa7113_cleanup(void) 327static void __exit wis_saa7113_cleanup(void)
349{ 328{
350 wis_i2c_del_driver(wis_saa7113_detect);
351 i2c_del_driver(&wis_saa7113_driver); 329 i2c_del_driver(&wis_saa7113_driver);
352} 330}
353 331
diff --git a/drivers/staging/go7007/wis-saa7115.c b/drivers/staging/go7007/wis-saa7115.c
index 59417a7174d7..8687ad2de761 100644
--- a/drivers/staging/go7007/wis-saa7115.c
+++ b/drivers/staging/go7007/wis-saa7115.c
@@ -394,34 +394,19 @@ static int wis_saa7115_command(struct i2c_client *client,
394 return 0; 394 return 0;
395} 395}
396 396
397static struct i2c_driver wis_saa7115_driver; 397static int wis_saa7115_probe(struct i2c_client *client,
398 398 const struct i2c_device_id *id)
399static struct i2c_client wis_saa7115_client_templ = {
400 .name = "SAA7115 (WIS)",
401 .driver = &wis_saa7115_driver,
402};
403
404static int wis_saa7115_detect(struct i2c_adapter *adapter, int addr, int kind)
405{ 399{
406 struct i2c_client *client; 400 struct i2c_adapter *adapter = client->adapter;
407 struct wis_saa7115 *dec; 401 struct wis_saa7115 *dec;
408 402
409 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 403 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
410 return 0; 404 return -ENODEV;
411
412 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
413 if (client == NULL)
414 return -ENOMEM;
415 memcpy(client, &wis_saa7115_client_templ,
416 sizeof(wis_saa7115_client_templ));
417 client->adapter = adapter;
418 client->addr = addr;
419 405
420 dec = kmalloc(sizeof(struct wis_saa7115), GFP_KERNEL); 406 dec = kmalloc(sizeof(struct wis_saa7115), GFP_KERNEL);
421 if (dec == NULL) { 407 if (dec == NULL)
422 kfree(client);
423 return -ENOMEM; 408 return -ENOMEM;
424 } 409
425 dec->norm = V4L2_STD_NTSC; 410 dec->norm = V4L2_STD_NTSC;
426 dec->brightness = 128; 411 dec->brightness = 128;
427 dec->contrast = 64; 412 dec->contrast = 64;
@@ -431,56 +416,49 @@ static int wis_saa7115_detect(struct i2c_adapter *adapter, int addr, int kind)
431 416
432 printk(KERN_DEBUG 417 printk(KERN_DEBUG
433 "wis-saa7115: initializing SAA7115 at address %d on %s\n", 418 "wis-saa7115: initializing SAA7115 at address %d on %s\n",
434 addr, adapter->name); 419 client->addr, adapter->name);
435 420
436 if (write_regs(client, initial_registers) < 0) { 421 if (write_regs(client, initial_registers) < 0) {
437 printk(KERN_ERR 422 printk(KERN_ERR
438 "wis-saa7115: error initializing SAA7115\n"); 423 "wis-saa7115: error initializing SAA7115\n");
439 kfree(client);
440 kfree(dec); 424 kfree(dec);
441 return 0; 425 return -ENODEV;
442 } 426 }
443 427
444 i2c_attach_client(client);
445 return 0; 428 return 0;
446} 429}
447 430
448static int wis_saa7115_detach(struct i2c_client *client) 431static int wis_saa7115_remove(struct i2c_client *client)
449{ 432{
450 struct wis_saa7115 *dec = i2c_get_clientdata(client); 433 struct wis_saa7115 *dec = i2c_get_clientdata(client);
451 int r;
452
453 r = i2c_detach_client(client);
454 if (r < 0)
455 return r;
456 434
457 kfree(client); 435 i2c_set_clientdata(client, NULL);
458 kfree(dec); 436 kfree(dec);
459 return 0; 437 return 0;
460} 438}
461 439
440static struct i2c_device_id wis_saa7115_id[] = {
441 { "wis_saa7115", 0 },
442 { }
443};
444
462static struct i2c_driver wis_saa7115_driver = { 445static struct i2c_driver wis_saa7115_driver = {
463 .driver = { 446 .driver = {
464 .name = "WIS SAA7115 I2C driver", 447 .name = "WIS SAA7115 I2C driver",
465 }, 448 },
466 .id = I2C_DRIVERID_WIS_SAA7115, 449 .probe = wis_saa7115_probe,
467 .detach_client = wis_saa7115_detach, 450 .remove = wis_saa7115_remove,
468 .command = wis_saa7115_command, 451 .command = wis_saa7115_command,
452 .id_table = wis_saa7115_id,
469}; 453};
470 454
471static int __init wis_saa7115_init(void) 455static int __init wis_saa7115_init(void)
472{ 456{
473 int r; 457 return i2c_add_driver(&wis_saa7115_driver);
474
475 r = i2c_add_driver(&wis_saa7115_driver);
476 if (r < 0)
477 return r;
478 return wis_i2c_add_driver(wis_saa7115_driver.id, wis_saa7115_detect);
479} 458}
480 459
481static void __exit wis_saa7115_cleanup(void) 460static void __exit wis_saa7115_cleanup(void)
482{ 461{
483 wis_i2c_del_driver(wis_saa7115_detect);
484 i2c_del_driver(&wis_saa7115_driver); 462 i2c_del_driver(&wis_saa7115_driver);
485} 463}
486 464
diff --git a/drivers/staging/go7007/wis-sony-tuner.c b/drivers/staging/go7007/wis-sony-tuner.c
index 0a7eeef7c008..c965c601ac90 100644
--- a/drivers/staging/go7007/wis-sony-tuner.c
+++ b/drivers/staging/go7007/wis-sony-tuner.c
@@ -653,35 +653,19 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
653 return 0; 653 return 0;
654} 654}
655 655
656static struct i2c_driver wis_sony_tuner_driver; 656static int wis_sony_tuner_probe(struct i2c_client *client,
657 657 const struct i2c_device_id *id)
658static struct i2c_client wis_sony_tuner_client_templ = {
659 .name = "Sony TV Tuner (WIS)",
660 .driver = &wis_sony_tuner_driver,
661};
662
663static int wis_sony_tuner_detect(struct i2c_adapter *adapter,
664 int addr, int kind)
665{ 658{
666 struct i2c_client *client; 659 struct i2c_adapter *adapter = client->adapter;
667 struct wis_sony_tuner *t; 660 struct wis_sony_tuner *t;
668 661
669 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) 662 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
670 return 0; 663 return -ENODEV;
671
672 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
673 if (client == NULL)
674 return -ENOMEM;
675 memcpy(client, &wis_sony_tuner_client_templ,
676 sizeof(wis_sony_tuner_client_templ));
677 client->adapter = adapter;
678 client->addr = addr;
679 664
680 t = kmalloc(sizeof(struct wis_sony_tuner), GFP_KERNEL); 665 t = kmalloc(sizeof(struct wis_sony_tuner), GFP_KERNEL);
681 if (t == NULL) { 666 if (t == NULL)
682 kfree(client);
683 return -ENOMEM; 667 return -ENOMEM;
684 } 668
685 t->type = -1; 669 t->type = -1;
686 t->freq = 0; 670 t->freq = 0;
687 t->mpxmode = 0; 671 t->mpxmode = 0;
@@ -690,50 +674,42 @@ static int wis_sony_tuner_detect(struct i2c_adapter *adapter,
690 674
691 printk(KERN_DEBUG 675 printk(KERN_DEBUG
692 "wis-sony-tuner: initializing tuner at address %d on %s\n", 676 "wis-sony-tuner: initializing tuner at address %d on %s\n",
693 addr, adapter->name); 677 client->addr, adapter->name);
694
695 i2c_attach_client(client);
696 678
697 return 0; 679 return 0;
698} 680}
699 681
700static int wis_sony_tuner_detach(struct i2c_client *client) 682static int wis_sony_tuner_remove(struct i2c_client *client)
701{ 683{
702 struct wis_sony_tuner *t = i2c_get_clientdata(client); 684 struct wis_sony_tuner *t = i2c_get_clientdata(client);
703 int r;
704
705 r = i2c_detach_client(client);
706 if (r < 0)
707 return r;
708 685
686 i2c_set_clientdata(client, NULL);
709 kfree(t); 687 kfree(t);
710 kfree(client);
711 return 0; 688 return 0;
712} 689}
713 690
691static struct i2c_device_id wis_sony_tuner_id[] = {
692 { "wis_sony_tuner", 0 },
693 { }
694};
695
714static struct i2c_driver wis_sony_tuner_driver = { 696static struct i2c_driver wis_sony_tuner_driver = {
715 .driver = { 697 .driver = {
716 .name = "WIS Sony TV Tuner I2C driver", 698 .name = "WIS Sony TV Tuner I2C driver",
717 }, 699 },
718 .id = I2C_DRIVERID_WIS_SONY_TUNER, 700 .probe = wis_sony_tuner_probe,
719 .detach_client = wis_sony_tuner_detach, 701 .remove = wis_sony_tuner_remove,
720 .command = tuner_command, 702 .command = tuner_command,
703 .id_table = wis_sony_tuner_id,
721}; 704};
722 705
723static int __init wis_sony_tuner_init(void) 706static int __init wis_sony_tuner_init(void)
724{ 707{
725 int r; 708 return i2c_add_driver(&wis_sony_tuner_driver);
726
727 r = i2c_add_driver(&wis_sony_tuner_driver);
728 if (r < 0)
729 return r;
730 return wis_i2c_add_driver(wis_sony_tuner_driver.id,
731 wis_sony_tuner_detect);
732} 709}
733 710
734static void __exit wis_sony_tuner_cleanup(void) 711static void __exit wis_sony_tuner_cleanup(void)
735{ 712{
736 wis_i2c_del_driver(wis_sony_tuner_detect);
737 i2c_del_driver(&wis_sony_tuner_driver); 713 i2c_del_driver(&wis_sony_tuner_driver);
738} 714}
739 715
diff --git a/drivers/staging/go7007/wis-tw2804.c b/drivers/staging/go7007/wis-tw2804.c
index 57b8f2b1caa3..e15794a2a0ae 100644
--- a/drivers/staging/go7007/wis-tw2804.c
+++ b/drivers/staging/go7007/wis-tw2804.c
@@ -291,34 +291,19 @@ static int wis_tw2804_command(struct i2c_client *client,
291 return 0; 291 return 0;
292} 292}
293 293
294static struct i2c_driver wis_tw2804_driver; 294static int wis_tw2804_probe(struct i2c_client *client,
295 295 const struct i2c_device_id *id)
296static struct i2c_client wis_tw2804_client_templ = {
297 .name = "TW2804 (WIS)",
298 .driver = &wis_tw2804_driver,
299};
300
301static int wis_tw2804_detect(struct i2c_adapter *adapter, int addr, int kind)
302{ 296{
303 struct i2c_client *client; 297 struct i2c_adapter *adapter = client->adapter;
304 struct wis_tw2804 *dec; 298 struct wis_tw2804 *dec;
305 299
306 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 300 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
307 return 0; 301 return -ENODEV;
308
309 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
310 if (client == NULL)
311 return -ENOMEM;
312 memcpy(client, &wis_tw2804_client_templ,
313 sizeof(wis_tw2804_client_templ));
314 client->adapter = adapter;
315 client->addr = addr;
316 302
317 dec = kmalloc(sizeof(struct wis_tw2804), GFP_KERNEL); 303 dec = kmalloc(sizeof(struct wis_tw2804), GFP_KERNEL);
318 if (dec == NULL) { 304 if (dec == NULL)
319 kfree(client);
320 return -ENOMEM; 305 return -ENOMEM;
321 } 306
322 dec->channel = -1; 307 dec->channel = -1;
323 dec->norm = V4L2_STD_NTSC; 308 dec->norm = V4L2_STD_NTSC;
324 dec->brightness = 128; 309 dec->brightness = 128;
@@ -328,48 +313,42 @@ static int wis_tw2804_detect(struct i2c_adapter *adapter, int addr, int kind)
328 i2c_set_clientdata(client, dec); 313 i2c_set_clientdata(client, dec);
329 314
330 printk(KERN_DEBUG "wis-tw2804: creating TW2804 at address %d on %s\n", 315 printk(KERN_DEBUG "wis-tw2804: creating TW2804 at address %d on %s\n",
331 addr, adapter->name); 316 client->addr, adapter->name);
332 317
333 i2c_attach_client(client);
334 return 0; 318 return 0;
335} 319}
336 320
337static int wis_tw2804_detach(struct i2c_client *client) 321static int wis_tw2804_remove(struct i2c_client *client)
338{ 322{
339 struct wis_tw2804 *dec = i2c_get_clientdata(client); 323 struct wis_tw2804 *dec = i2c_get_clientdata(client);
340 int r;
341
342 r = i2c_detach_client(client);
343 if (r < 0)
344 return r;
345 324
346 kfree(client); 325 i2c_set_clientdata(client, NULL);
347 kfree(dec); 326 kfree(dec);
348 return 0; 327 return 0;
349} 328}
350 329
330static struct i2c_device_id wis_tw2804_id[] = {
331 { "wis_tw2804", 0 },
332 { }
333};
334
351static struct i2c_driver wis_tw2804_driver = { 335static struct i2c_driver wis_tw2804_driver = {
352 .driver = { 336 .driver = {
353 .name = "WIS TW2804 I2C driver", 337 .name = "WIS TW2804 I2C driver",
354 }, 338 },
355 .id = I2C_DRIVERID_WIS_TW2804, 339 .probe = wis_tw2804_probe,
356 .detach_client = wis_tw2804_detach, 340 .remove = wis_tw2804_remove,
357 .command = wis_tw2804_command, 341 .command = wis_tw2804_command,
342 .id_table = wis_tw2804_id,
358}; 343};
359 344
360static int __init wis_tw2804_init(void) 345static int __init wis_tw2804_init(void)
361{ 346{
362 int r; 347 return i2c_add_driver(&wis_tw2804_driver);
363
364 r = i2c_add_driver(&wis_tw2804_driver);
365 if (r < 0)
366 return r;
367 return wis_i2c_add_driver(wis_tw2804_driver.id, wis_tw2804_detect);
368} 348}
369 349
370static void __exit wis_tw2804_cleanup(void) 350static void __exit wis_tw2804_cleanup(void)
371{ 351{
372 wis_i2c_del_driver(wis_tw2804_detect);
373 i2c_del_driver(&wis_tw2804_driver); 352 i2c_del_driver(&wis_tw2804_driver);
374} 353}
375 354
diff --git a/drivers/staging/go7007/wis-tw9903.c b/drivers/staging/go7007/wis-tw9903.c
index 40627b282cb4..6c3427bb6f4c 100644
--- a/drivers/staging/go7007/wis-tw9903.c
+++ b/drivers/staging/go7007/wis-tw9903.c
@@ -267,34 +267,19 @@ static int wis_tw9903_command(struct i2c_client *client,
267 return 0; 267 return 0;
268} 268}
269 269
270static struct i2c_driver wis_tw9903_driver; 270static int wis_tw9903_probe(struct i2c_client *client,
271 271 const struct i2c_device_id *id)
272static struct i2c_client wis_tw9903_client_templ = {
273 .name = "TW9903 (WIS)",
274 .driver = &wis_tw9903_driver,
275};
276
277static int wis_tw9903_detect(struct i2c_adapter *adapter, int addr, int kind)
278{ 272{
279 struct i2c_client *client; 273 struct i2c_adapter *adapter = client->adapter;
280 struct wis_tw9903 *dec; 274 struct wis_tw9903 *dec;
281 275
282 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 276 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
283 return 0; 277 return -ENODEV;
284
285 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
286 if (client == NULL)
287 return -ENOMEM;
288 memcpy(client, &wis_tw9903_client_templ,
289 sizeof(wis_tw9903_client_templ));
290 client->adapter = adapter;
291 client->addr = addr;
292 278
293 dec = kmalloc(sizeof(struct wis_tw9903), GFP_KERNEL); 279 dec = kmalloc(sizeof(struct wis_tw9903), GFP_KERNEL);
294 if (dec == NULL) { 280 if (dec == NULL)
295 kfree(client);
296 return -ENOMEM; 281 return -ENOMEM;
297 } 282
298 dec->norm = V4L2_STD_NTSC; 283 dec->norm = V4L2_STD_NTSC;
299 dec->brightness = 0; 284 dec->brightness = 0;
300 dec->contrast = 0x60; 285 dec->contrast = 0x60;
@@ -303,55 +288,48 @@ static int wis_tw9903_detect(struct i2c_adapter *adapter, int addr, int kind)
303 288
304 printk(KERN_DEBUG 289 printk(KERN_DEBUG
305 "wis-tw9903: initializing TW9903 at address %d on %s\n", 290 "wis-tw9903: initializing TW9903 at address %d on %s\n",
306 addr, adapter->name); 291 client->addr, adapter->name);
307 292
308 if (write_regs(client, initial_registers) < 0) { 293 if (write_regs(client, initial_registers) < 0) {
309 printk(KERN_ERR "wis-tw9903: error initializing TW9903\n"); 294 printk(KERN_ERR "wis-tw9903: error initializing TW9903\n");
310 kfree(client);
311 kfree(dec); 295 kfree(dec);
312 return 0; 296 return -ENODEV;
313 } 297 }
314 298
315 i2c_attach_client(client);
316 return 0; 299 return 0;
317} 300}
318 301
319static int wis_tw9903_detach(struct i2c_client *client) 302static int wis_tw9903_remove(struct i2c_client *client)
320{ 303{
321 struct wis_tw9903 *dec = i2c_get_clientdata(client); 304 struct wis_tw9903 *dec = i2c_get_clientdata(client);
322 int r;
323
324 r = i2c_detach_client(client);
325 if (r < 0)
326 return r;
327 305
328 kfree(client); 306 i2c_set_clientdata(client, NULL);
329 kfree(dec); 307 kfree(dec);
330 return 0; 308 return 0;
331} 309}
332 310
311static struct i2c_device_id wis_tw9903_id[] = {
312 { "wis_tw9903", 0 },
313 { }
314};
315
333static struct i2c_driver wis_tw9903_driver = { 316static struct i2c_driver wis_tw9903_driver = {
334 .driver = { 317 .driver = {
335 .name = "WIS TW9903 I2C driver", 318 .name = "WIS TW9903 I2C driver",
336 }, 319 },
337 .id = I2C_DRIVERID_WIS_TW9903, 320 .probe = wis_tw9903_probe,
338 .detach_client = wis_tw9903_detach, 321 .remove = wis_tw9903_remove,
339 .command = wis_tw9903_command, 322 .command = wis_tw9903_command,
323 .id_table = wis_tw9903_id,
340}; 324};
341 325
342static int __init wis_tw9903_init(void) 326static int __init wis_tw9903_init(void)
343{ 327{
344 int r; 328 return i2c_add_driver(&wis_tw9903_driver);
345
346 r = i2c_add_driver(&wis_tw9903_driver);
347 if (r < 0)
348 return r;
349 return wis_i2c_add_driver(wis_tw9903_driver.id, wis_tw9903_detect);
350} 329}
351 330
352static void __exit wis_tw9903_cleanup(void) 331static void __exit wis_tw9903_cleanup(void)
353{ 332{
354 wis_i2c_del_driver(wis_tw9903_detect);
355 i2c_del_driver(&wis_tw9903_driver); 333 i2c_del_driver(&wis_tw9903_driver);
356} 334}
357 335
diff --git a/drivers/staging/go7007/wis-uda1342.c b/drivers/staging/go7007/wis-uda1342.c
index 555645c0cc1a..739c7ae8913f 100644
--- a/drivers/staging/go7007/wis-uda1342.c
+++ b/drivers/staging/go7007/wis-uda1342.c
@@ -59,73 +59,51 @@ static int wis_uda1342_command(struct i2c_client *client,
59 return 0; 59 return 0;
60} 60}
61 61
62static struct i2c_driver wis_uda1342_driver; 62static int wis_uda1342_probe(struct i2c_client *client,
63 63 const struct i2c_device_id *id)
64static struct i2c_client wis_uda1342_client_templ = {
65 .name = "UDA1342 (WIS)",
66 .driver = &wis_uda1342_driver,
67};
68
69static int wis_uda1342_detect(struct i2c_adapter *adapter, int addr, int kind)
70{ 64{
71 struct i2c_client *client; 65 struct i2c_adapter *adapter = client->adapter;
72 66
73 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) 67 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA))
74 return 0; 68 return -ENODEV;
75
76 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
77 if (client == NULL)
78 return -ENOMEM;
79 memcpy(client, &wis_uda1342_client_templ,
80 sizeof(wis_uda1342_client_templ));
81 client->adapter = adapter;
82 client->addr = addr;
83 69
84 printk(KERN_DEBUG 70 printk(KERN_DEBUG
85 "wis-uda1342: initializing UDA1342 at address %d on %s\n", 71 "wis-uda1342: initializing UDA1342 at address %d on %s\n",
86 addr, adapter->name); 72 client->addr, adapter->name);
87 73
88 write_reg(client, 0x00, 0x8000); /* reset registers */ 74 write_reg(client, 0x00, 0x8000); /* reset registers */
89 write_reg(client, 0x00, 0x1241); /* select input 1 */ 75 write_reg(client, 0x00, 0x1241); /* select input 1 */
90 76
91 i2c_attach_client(client);
92 return 0; 77 return 0;
93} 78}
94 79
95static int wis_uda1342_detach(struct i2c_client *client) 80static int wis_uda1342_remove(struct i2c_client *client)
96{ 81{
97 int r;
98
99 r = i2c_detach_client(client);
100 if (r < 0)
101 return r;
102
103 kfree(client);
104 return 0; 82 return 0;
105} 83}
106 84
85static struct i2c_device_id wis_uda1342_id[] = {
86 { "wis_uda1342", 0 },
87 { }
88};
89
107static struct i2c_driver wis_uda1342_driver = { 90static struct i2c_driver wis_uda1342_driver = {
108 .driver = { 91 .driver = {
109 .name = "WIS UDA1342 I2C driver", 92 .name = "WIS UDA1342 I2C driver",
110 }, 93 },
111 .id = I2C_DRIVERID_WIS_UDA1342, 94 .probe = wis_uda1342_probe,
112 .detach_client = wis_uda1342_detach, 95 .remove = wis_uda1342_remove,
113 .command = wis_uda1342_command, 96 .command = wis_uda1342_command,
97 .id_table = wis_uda1342_id,
114}; 98};
115 99
116static int __init wis_uda1342_init(void) 100static int __init wis_uda1342_init(void)
117{ 101{
118 int r; 102 return i2c_add_driver(&wis_uda1342_driver);
119
120 r = i2c_add_driver(&wis_uda1342_driver);
121 if (r < 0)
122 return r;
123 return wis_i2c_add_driver(wis_uda1342_driver.id, wis_uda1342_detect);
124} 103}
125 104
126static void __exit wis_uda1342_cleanup(void) 105static void __exit wis_uda1342_cleanup(void)
127{ 106{
128 wis_i2c_del_driver(wis_uda1342_detect);
129 i2c_del_driver(&wis_uda1342_driver); 107 i2c_del_driver(&wis_uda1342_driver);
130} 108}
131 109
diff --git a/drivers/video/asiliantfb.c b/drivers/video/asiliantfb.c
index 1a1f946d8fef..9fe90ce928fb 100644
--- a/drivers/video/asiliantfb.c
+++ b/drivers/video/asiliantfb.c
@@ -533,6 +533,7 @@ static int __devinit init_asiliant(struct fb_info *p, unsigned long addr)
533 533
534 writeb(0xff, mmio_base + 0x78c); 534 writeb(0xff, mmio_base + 0x78c);
535 chips_hw_init(p); 535 chips_hw_init(p);
536 return 0;
536} 537}
537 538
538static int __devinit 539static int __devinit
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 84f63205c46d..0889d50c3288 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -1439,7 +1439,7 @@ static void pxafb_disable_controller(struct pxafb_info *fbi)
1439static irqreturn_t pxafb_handle_irq(int irq, void *dev_id) 1439static irqreturn_t pxafb_handle_irq(int irq, void *dev_id)
1440{ 1440{
1441 struct pxafb_info *fbi = dev_id; 1441 struct pxafb_info *fbi = dev_id;
1442 unsigned int lccr0, lcsr, lcsr1; 1442 unsigned int lccr0, lcsr;
1443 1443
1444 lcsr = lcd_readl(fbi, LCSR); 1444 lcsr = lcd_readl(fbi, LCSR);
1445 if (lcsr & LCSR_LDD) { 1445 if (lcsr & LCSR_LDD) {
@@ -1455,14 +1455,16 @@ static irqreturn_t pxafb_handle_irq(int irq, void *dev_id)
1455 lcd_writel(fbi, LCSR, lcsr); 1455 lcd_writel(fbi, LCSR, lcsr);
1456 1456
1457#ifdef CONFIG_FB_PXA_OVERLAY 1457#ifdef CONFIG_FB_PXA_OVERLAY
1458 lcsr1 = lcd_readl(fbi, LCSR1); 1458 {
1459 if (lcsr1 & LCSR1_BS(1)) 1459 unsigned int lcsr1 = lcd_readl(fbi, LCSR1);
1460 complete(&fbi->overlay[0].branch_done); 1460 if (lcsr1 & LCSR1_BS(1))
1461 complete(&fbi->overlay[0].branch_done);
1461 1462
1462 if (lcsr1 & LCSR1_BS(2)) 1463 if (lcsr1 & LCSR1_BS(2))
1463 complete(&fbi->overlay[1].branch_done); 1464 complete(&fbi->overlay[1].branch_done);
1464 1465
1465 lcd_writel(fbi, LCSR1, lcsr1); 1466 lcd_writel(fbi, LCSR1, lcsr1);
1467 }
1466#endif 1468#endif
1467 return IRQ_HANDLED; 1469 return IRQ_HANDLED;
1468} 1470}
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 59268266b79a..9c76a061a04d 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -190,7 +190,8 @@ static int balloon(void *_vballoon)
190 try_to_freeze(); 190 try_to_freeze();
191 wait_event_interruptible(vb->config_change, 191 wait_event_interruptible(vb->config_change,
192 (diff = towards_target(vb)) != 0 192 (diff = towards_target(vb)) != 0
193 || kthread_should_stop()); 193 || kthread_should_stop()
194 || freezing(current));
194 if (diff > 0) 195 if (diff > 0)
195 fill_balloon(vb, diff); 196 fill_balloon(vb, diff);
196 else if (diff < 0) 197 else if (diff < 0)
diff --git a/fs/autofs/dirhash.c b/fs/autofs/dirhash.c
index bf8c8af98004..4eb4d8dfb2f1 100644
--- a/fs/autofs/dirhash.c
+++ b/fs/autofs/dirhash.c
@@ -39,10 +39,12 @@ struct autofs_dir_ent *autofs_expire(struct super_block *sb,
39{ 39{
40 struct autofs_dirhash *dh = &sbi->dirhash; 40 struct autofs_dirhash *dh = &sbi->dirhash;
41 struct autofs_dir_ent *ent; 41 struct autofs_dir_ent *ent;
42 struct dentry *dentry;
43 unsigned long timeout = sbi->exp_timeout; 42 unsigned long timeout = sbi->exp_timeout;
44 43
45 while (1) { 44 while (1) {
45 struct path path;
46 int umount_ok;
47
46 if ( list_empty(&dh->expiry_head) || sbi->catatonic ) 48 if ( list_empty(&dh->expiry_head) || sbi->catatonic )
47 return NULL; /* No entries */ 49 return NULL; /* No entries */
48 /* We keep the list sorted by last_usage and want old stuff */ 50 /* We keep the list sorted by last_usage and want old stuff */
@@ -57,17 +59,17 @@ struct autofs_dir_ent *autofs_expire(struct super_block *sb,
57 return ent; /* Symlinks are always expirable */ 59 return ent; /* Symlinks are always expirable */
58 60
59 /* Get the dentry for the autofs subdirectory */ 61 /* Get the dentry for the autofs subdirectory */
60 dentry = ent->dentry; 62 path.dentry = ent->dentry;
61 63
62 if ( !dentry ) { 64 if (!path.dentry) {
63 /* Should only happen in catatonic mode */ 65 /* Should only happen in catatonic mode */
64 printk("autofs: dentry == NULL but inode range is directory, entry %s\n", ent->name); 66 printk("autofs: dentry == NULL but inode range is directory, entry %s\n", ent->name);
65 autofs_delete_usage(ent); 67 autofs_delete_usage(ent);
66 continue; 68 continue;
67 } 69 }
68 70
69 if ( !dentry->d_inode ) { 71 if (!path.dentry->d_inode) {
70 dput(dentry); 72 dput(path.dentry);
71 printk("autofs: negative dentry on expiry queue: %s\n", 73 printk("autofs: negative dentry on expiry queue: %s\n",
72 ent->name); 74 ent->name);
73 autofs_delete_usage(ent); 75 autofs_delete_usage(ent);
@@ -76,29 +78,29 @@ struct autofs_dir_ent *autofs_expire(struct super_block *sb,
76 78
77 /* Make sure entry is mounted and unused; note that dentry will 79 /* Make sure entry is mounted and unused; note that dentry will
78 point to the mounted-on-top root. */ 80 point to the mounted-on-top root. */
79 if (!S_ISDIR(dentry->d_inode->i_mode)||!d_mountpoint(dentry)) { 81 if (!S_ISDIR(path.dentry->d_inode->i_mode) ||
82 !d_mountpoint(path.dentry)) {
80 DPRINTK(("autofs: not expirable (not a mounted directory): %s\n", ent->name)); 83 DPRINTK(("autofs: not expirable (not a mounted directory): %s\n", ent->name));
81 continue; 84 continue;
82 } 85 }
83 mntget(mnt); 86 path.mnt = mnt;
84 dget(dentry); 87 path_get(&path);
85 if (!follow_down(&mnt, &dentry)) { 88 if (!follow_down(&path.mnt, &path.dentry)) {
86 dput(dentry); 89 path_put(&path);
87 mntput(mnt);
88 DPRINTK(("autofs: not expirable (not a mounted directory): %s\n", ent->name)); 90 DPRINTK(("autofs: not expirable (not a mounted directory): %s\n", ent->name));
89 continue; 91 continue;
90 } 92 }
91 while (d_mountpoint(dentry) && follow_down(&mnt, &dentry)) 93 while (d_mountpoint(path.dentry) &&
94 follow_down(&path.mnt, &path.dentry))
92 ; 95 ;
93 dput(dentry); 96 umount_ok = may_umount(path.mnt);
97 path_put(&path);
94 98
95 if ( may_umount(mnt) ) { 99 if (umount_ok) {
96 mntput(mnt);
97 DPRINTK(("autofs: signaling expire on %s\n", ent->name)); 100 DPRINTK(("autofs: signaling expire on %s\n", ent->name));
98 return ent; /* Expirable! */ 101 return ent; /* Expirable! */
99 } 102 }
100 DPRINTK(("autofs: didn't expire due to may_umount: %s\n", ent->name)); 103 DPRINTK(("autofs: didn't expire due to may_umount: %s\n", ent->name));
101 mntput(mnt);
102 } 104 }
103 return NULL; /* No expirable entries */ 105 return NULL; /* No expirable entries */
104} 106}
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index 9e5ae8a4f5c8..84168c0dcc2d 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -54,11 +54,10 @@ static int check_name(const char *name)
54 * Check a string doesn't overrun the chunk of 54 * Check a string doesn't overrun the chunk of
55 * memory we copied from user land. 55 * memory we copied from user land.
56 */ 56 */
57static int invalid_str(char *str, void *end) 57static int invalid_str(char *str, size_t size)
58{ 58{
59 while ((void *) str <= end) 59 if (memchr(str, 0, size))
60 if (!*str++) 60 return 0;
61 return 0;
62 return -EINVAL; 61 return -EINVAL;
63} 62}
64 63
@@ -138,8 +137,7 @@ static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param)
138 } 137 }
139 138
140 if (param->size > sizeof(*param)) { 139 if (param->size > sizeof(*param)) {
141 err = invalid_str(param->path, 140 err = invalid_str(param->path, param->size - sizeof(*param));
142 (void *) ((size_t) param + param->size));
143 if (err) { 141 if (err) {
144 AUTOFS_WARN( 142 AUTOFS_WARN(
145 "path string terminator missing for cmd(0x%08x)", 143 "path string terminator missing for cmd(0x%08x)",
@@ -488,7 +486,7 @@ static int autofs_dev_ioctl_requester(struct file *fp,
488 } 486 }
489 487
490 path = param->path; 488 path = param->path;
491 devid = sbi->sb->s_dev; 489 devid = new_encode_dev(sbi->sb->s_dev);
492 490
493 param->requester.uid = param->requester.gid = -1; 491 param->requester.uid = param->requester.gid = -1;
494 492
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index 51bfdfc8fcda..502c3d61de62 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -25,6 +25,7 @@
25#define WORK_QUEUED_BIT 0 25#define WORK_QUEUED_BIT 0
26#define WORK_DONE_BIT 1 26#define WORK_DONE_BIT 1
27#define WORK_ORDER_DONE_BIT 2 27#define WORK_ORDER_DONE_BIT 2
28#define WORK_HIGH_PRIO_BIT 3
28 29
29/* 30/*
30 * container for the kthread task pointer and the list of pending work 31 * container for the kthread task pointer and the list of pending work
@@ -36,6 +37,7 @@ struct btrfs_worker_thread {
36 37
37 /* list of struct btrfs_work that are waiting for service */ 38 /* list of struct btrfs_work that are waiting for service */
38 struct list_head pending; 39 struct list_head pending;
40 struct list_head prio_pending;
39 41
40 /* list of worker threads from struct btrfs_workers */ 42 /* list of worker threads from struct btrfs_workers */
41 struct list_head worker_list; 43 struct list_head worker_list;
@@ -103,10 +105,16 @@ static noinline int run_ordered_completions(struct btrfs_workers *workers,
103 105
104 spin_lock_irqsave(&workers->lock, flags); 106 spin_lock_irqsave(&workers->lock, flags);
105 107
106 while (!list_empty(&workers->order_list)) { 108 while (1) {
107 work = list_entry(workers->order_list.next, 109 if (!list_empty(&workers->prio_order_list)) {
108 struct btrfs_work, order_list); 110 work = list_entry(workers->prio_order_list.next,
109 111 struct btrfs_work, order_list);
112 } else if (!list_empty(&workers->order_list)) {
113 work = list_entry(workers->order_list.next,
114 struct btrfs_work, order_list);
115 } else {
116 break;
117 }
110 if (!test_bit(WORK_DONE_BIT, &work->flags)) 118 if (!test_bit(WORK_DONE_BIT, &work->flags))
111 break; 119 break;
112 120
@@ -143,8 +151,14 @@ static int worker_loop(void *arg)
143 do { 151 do {
144 spin_lock_irq(&worker->lock); 152 spin_lock_irq(&worker->lock);
145again_locked: 153again_locked:
146 while (!list_empty(&worker->pending)) { 154 while (1) {
147 cur = worker->pending.next; 155 if (!list_empty(&worker->prio_pending))
156 cur = worker->prio_pending.next;
157 else if (!list_empty(&worker->pending))
158 cur = worker->pending.next;
159 else
160 break;
161
148 work = list_entry(cur, struct btrfs_work, list); 162 work = list_entry(cur, struct btrfs_work, list);
149 list_del(&work->list); 163 list_del(&work->list);
150 clear_bit(WORK_QUEUED_BIT, &work->flags); 164 clear_bit(WORK_QUEUED_BIT, &work->flags);
@@ -163,7 +177,6 @@ again_locked:
163 177
164 spin_lock_irq(&worker->lock); 178 spin_lock_irq(&worker->lock);
165 check_idle_worker(worker); 179 check_idle_worker(worker);
166
167 } 180 }
168 if (freezing(current)) { 181 if (freezing(current)) {
169 worker->working = 0; 182 worker->working = 0;
@@ -178,7 +191,8 @@ again_locked:
178 * jump_in? 191 * jump_in?
179 */ 192 */
180 smp_mb(); 193 smp_mb();
181 if (!list_empty(&worker->pending)) 194 if (!list_empty(&worker->pending) ||
195 !list_empty(&worker->prio_pending))
182 continue; 196 continue;
183 197
184 /* 198 /*
@@ -191,7 +205,8 @@ again_locked:
191 */ 205 */
192 schedule_timeout(1); 206 schedule_timeout(1);
193 smp_mb(); 207 smp_mb();
194 if (!list_empty(&worker->pending)) 208 if (!list_empty(&worker->pending) ||
209 !list_empty(&worker->prio_pending))
195 continue; 210 continue;
196 211
197 if (kthread_should_stop()) 212 if (kthread_should_stop())
@@ -200,7 +215,8 @@ again_locked:
200 /* still no more work?, sleep for real */ 215 /* still no more work?, sleep for real */
201 spin_lock_irq(&worker->lock); 216 spin_lock_irq(&worker->lock);
202 set_current_state(TASK_INTERRUPTIBLE); 217 set_current_state(TASK_INTERRUPTIBLE);
203 if (!list_empty(&worker->pending)) 218 if (!list_empty(&worker->pending) ||
219 !list_empty(&worker->prio_pending))
204 goto again_locked; 220 goto again_locked;
205 221
206 /* 222 /*
@@ -248,6 +264,7 @@ void btrfs_init_workers(struct btrfs_workers *workers, char *name, int max)
248 INIT_LIST_HEAD(&workers->worker_list); 264 INIT_LIST_HEAD(&workers->worker_list);
249 INIT_LIST_HEAD(&workers->idle_list); 265 INIT_LIST_HEAD(&workers->idle_list);
250 INIT_LIST_HEAD(&workers->order_list); 266 INIT_LIST_HEAD(&workers->order_list);
267 INIT_LIST_HEAD(&workers->prio_order_list);
251 spin_lock_init(&workers->lock); 268 spin_lock_init(&workers->lock);
252 workers->max_workers = max; 269 workers->max_workers = max;
253 workers->idle_thresh = 32; 270 workers->idle_thresh = 32;
@@ -273,6 +290,7 @@ int btrfs_start_workers(struct btrfs_workers *workers, int num_workers)
273 } 290 }
274 291
275 INIT_LIST_HEAD(&worker->pending); 292 INIT_LIST_HEAD(&worker->pending);
293 INIT_LIST_HEAD(&worker->prio_pending);
276 INIT_LIST_HEAD(&worker->worker_list); 294 INIT_LIST_HEAD(&worker->worker_list);
277 spin_lock_init(&worker->lock); 295 spin_lock_init(&worker->lock);
278 atomic_set(&worker->num_pending, 0); 296 atomic_set(&worker->num_pending, 0);
@@ -396,7 +414,10 @@ int btrfs_requeue_work(struct btrfs_work *work)
396 goto out; 414 goto out;
397 415
398 spin_lock_irqsave(&worker->lock, flags); 416 spin_lock_irqsave(&worker->lock, flags);
399 list_add_tail(&work->list, &worker->pending); 417 if (test_bit(WORK_HIGH_PRIO_BIT, &work->flags))
418 list_add_tail(&work->list, &worker->prio_pending);
419 else
420 list_add_tail(&work->list, &worker->pending);
400 atomic_inc(&worker->num_pending); 421 atomic_inc(&worker->num_pending);
401 422
402 /* by definition we're busy, take ourselves off the idle 423 /* by definition we're busy, take ourselves off the idle
@@ -422,6 +443,11 @@ out:
422 return 0; 443 return 0;
423} 444}
424 445
446void btrfs_set_work_high_prio(struct btrfs_work *work)
447{
448 set_bit(WORK_HIGH_PRIO_BIT, &work->flags);
449}
450
425/* 451/*
426 * places a struct btrfs_work into the pending queue of one of the kthreads 452 * places a struct btrfs_work into the pending queue of one of the kthreads
427 */ 453 */
@@ -438,7 +464,12 @@ int btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work)
438 worker = find_worker(workers); 464 worker = find_worker(workers);
439 if (workers->ordered) { 465 if (workers->ordered) {
440 spin_lock_irqsave(&workers->lock, flags); 466 spin_lock_irqsave(&workers->lock, flags);
441 list_add_tail(&work->order_list, &workers->order_list); 467 if (test_bit(WORK_HIGH_PRIO_BIT, &work->flags)) {
468 list_add_tail(&work->order_list,
469 &workers->prio_order_list);
470 } else {
471 list_add_tail(&work->order_list, &workers->order_list);
472 }
442 spin_unlock_irqrestore(&workers->lock, flags); 473 spin_unlock_irqrestore(&workers->lock, flags);
443 } else { 474 } else {
444 INIT_LIST_HEAD(&work->order_list); 475 INIT_LIST_HEAD(&work->order_list);
@@ -446,7 +477,10 @@ int btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work)
446 477
447 spin_lock_irqsave(&worker->lock, flags); 478 spin_lock_irqsave(&worker->lock, flags);
448 479
449 list_add_tail(&work->list, &worker->pending); 480 if (test_bit(WORK_HIGH_PRIO_BIT, &work->flags))
481 list_add_tail(&work->list, &worker->prio_pending);
482 else
483 list_add_tail(&work->list, &worker->pending);
450 atomic_inc(&worker->num_pending); 484 atomic_inc(&worker->num_pending);
451 check_busy_worker(worker); 485 check_busy_worker(worker);
452 486
diff --git a/fs/btrfs/async-thread.h b/fs/btrfs/async-thread.h
index 31be4ed8b63e..1b511c109db6 100644
--- a/fs/btrfs/async-thread.h
+++ b/fs/btrfs/async-thread.h
@@ -85,6 +85,7 @@ struct btrfs_workers {
85 * of work items waiting for completion 85 * of work items waiting for completion
86 */ 86 */
87 struct list_head order_list; 87 struct list_head order_list;
88 struct list_head prio_order_list;
88 89
89 /* lock for finding the next worker thread to queue on */ 90 /* lock for finding the next worker thread to queue on */
90 spinlock_t lock; 91 spinlock_t lock;
@@ -98,4 +99,5 @@ int btrfs_start_workers(struct btrfs_workers *workers, int num_workers);
98int btrfs_stop_workers(struct btrfs_workers *workers); 99int btrfs_stop_workers(struct btrfs_workers *workers);
99void btrfs_init_workers(struct btrfs_workers *workers, char *name, int max); 100void btrfs_init_workers(struct btrfs_workers *workers, char *name, int max);
100int btrfs_requeue_work(struct btrfs_work *work); 101int btrfs_requeue_work(struct btrfs_work *work);
102void btrfs_set_work_high_prio(struct btrfs_work *work);
101#endif 103#endif
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index e5b2533b691a..a99f1c2a710d 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1325,12 +1325,12 @@ static noinline int reada_for_balance(struct btrfs_root *root,
1325 int ret = 0; 1325 int ret = 0;
1326 int blocksize; 1326 int blocksize;
1327 1327
1328 parent = path->nodes[level - 1]; 1328 parent = path->nodes[level + 1];
1329 if (!parent) 1329 if (!parent)
1330 return 0; 1330 return 0;
1331 1331
1332 nritems = btrfs_header_nritems(parent); 1332 nritems = btrfs_header_nritems(parent);
1333 slot = path->slots[level]; 1333 slot = path->slots[level + 1];
1334 blocksize = btrfs_level_size(root, level); 1334 blocksize = btrfs_level_size(root, level);
1335 1335
1336 if (slot > 0) { 1336 if (slot > 0) {
@@ -1341,7 +1341,7 @@ static noinline int reada_for_balance(struct btrfs_root *root,
1341 block1 = 0; 1341 block1 = 0;
1342 free_extent_buffer(eb); 1342 free_extent_buffer(eb);
1343 } 1343 }
1344 if (slot < nritems) { 1344 if (slot + 1 < nritems) {
1345 block2 = btrfs_node_blockptr(parent, slot + 1); 1345 block2 = btrfs_node_blockptr(parent, slot + 1);
1346 gen = btrfs_node_ptr_generation(parent, slot + 1); 1346 gen = btrfs_node_ptr_generation(parent, slot + 1);
1347 eb = btrfs_find_tree_block(root, block2, blocksize); 1347 eb = btrfs_find_tree_block(root, block2, blocksize);
@@ -1351,7 +1351,11 @@ static noinline int reada_for_balance(struct btrfs_root *root,
1351 } 1351 }
1352 if (block1 || block2) { 1352 if (block1 || block2) {
1353 ret = -EAGAIN; 1353 ret = -EAGAIN;
1354
1355 /* release the whole path */
1354 btrfs_release_path(root, path); 1356 btrfs_release_path(root, path);
1357
1358 /* read the blocks */
1355 if (block1) 1359 if (block1)
1356 readahead_tree_block(root, block1, blocksize, 0); 1360 readahead_tree_block(root, block1, blocksize, 0);
1357 if (block2) 1361 if (block2)
@@ -1361,7 +1365,7 @@ static noinline int reada_for_balance(struct btrfs_root *root,
1361 eb = read_tree_block(root, block1, blocksize, 0); 1365 eb = read_tree_block(root, block1, blocksize, 0);
1362 free_extent_buffer(eb); 1366 free_extent_buffer(eb);
1363 } 1367 }
1364 if (block1) { 1368 if (block2) {
1365 eb = read_tree_block(root, block2, blocksize, 0); 1369 eb = read_tree_block(root, block2, blocksize, 0);
1366 free_extent_buffer(eb); 1370 free_extent_buffer(eb);
1367 } 1371 }
@@ -1481,12 +1485,15 @@ read_block_for_search(struct btrfs_trans_handle *trans,
1481 * of the btree by dropping locks before 1485 * of the btree by dropping locks before
1482 * we read. 1486 * we read.
1483 */ 1487 */
1484 btrfs_release_path(NULL, p); 1488 btrfs_unlock_up_safe(p, level + 1);
1489 btrfs_set_path_blocking(p);
1490
1485 if (tmp) 1491 if (tmp)
1486 free_extent_buffer(tmp); 1492 free_extent_buffer(tmp);
1487 if (p->reada) 1493 if (p->reada)
1488 reada_for_search(root, p, level, slot, key->objectid); 1494 reada_for_search(root, p, level, slot, key->objectid);
1489 1495
1496 btrfs_release_path(NULL, p);
1490 tmp = read_tree_block(root, blocknr, blocksize, gen); 1497 tmp = read_tree_block(root, blocknr, blocksize, gen);
1491 if (tmp) 1498 if (tmp)
1492 free_extent_buffer(tmp); 1499 free_extent_buffer(tmp);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 92caa8035f36..a6b83744b05d 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -579,6 +579,10 @@ int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode,
579 async->bio_flags = bio_flags; 579 async->bio_flags = bio_flags;
580 580
581 atomic_inc(&fs_info->nr_async_submits); 581 atomic_inc(&fs_info->nr_async_submits);
582
583 if (rw & (1 << BIO_RW_SYNCIO))
584 btrfs_set_work_high_prio(&async->work);
585
582 btrfs_queue_worker(&fs_info->workers, &async->work); 586 btrfs_queue_worker(&fs_info->workers, &async->work);
583#if 0 587#if 0
584 int limit = btrfs_async_submit_limit(fs_info); 588 int limit = btrfs_async_submit_limit(fs_info);
@@ -656,6 +660,7 @@ static int btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
656 return btrfs_map_bio(BTRFS_I(inode)->root, rw, bio, 660 return btrfs_map_bio(BTRFS_I(inode)->root, rw, bio,
657 mirror_num, 0); 661 mirror_num, 0);
658 } 662 }
663
659 /* 664 /*
660 * kthread helpers are used to submit writes so that checksumming 665 * kthread helpers are used to submit writes so that checksumming
661 * can happen in parallel across all CPUs 666 * can happen in parallel across all CPUs
@@ -2095,10 +2100,10 @@ static int write_dev_supers(struct btrfs_device *device,
2095 device->barriers = 0; 2100 device->barriers = 0;
2096 get_bh(bh); 2101 get_bh(bh);
2097 lock_buffer(bh); 2102 lock_buffer(bh);
2098 ret = submit_bh(WRITE, bh); 2103 ret = submit_bh(WRITE_SYNC, bh);
2099 } 2104 }
2100 } else { 2105 } else {
2101 ret = submit_bh(WRITE, bh); 2106 ret = submit_bh(WRITE_SYNC, bh);
2102 } 2107 }
2103 2108
2104 if (!ret && wait) { 2109 if (!ret && wait) {
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index eb2bee8b7fbf..05a1c42e25bf 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -50,7 +50,10 @@ struct extent_page_data {
50 /* tells writepage not to lock the state bits for this range 50 /* tells writepage not to lock the state bits for this range
51 * it still does the unlocking 51 * it still does the unlocking
52 */ 52 */
53 int extent_locked; 53 unsigned int extent_locked:1;
54
55 /* tells the submit_bio code to use a WRITE_SYNC */
56 unsigned int sync_io:1;
54}; 57};
55 58
56int __init extent_io_init(void) 59int __init extent_io_init(void)
@@ -2101,6 +2104,16 @@ int extent_read_full_page(struct extent_io_tree *tree, struct page *page,
2101 return ret; 2104 return ret;
2102} 2105}
2103 2106
2107static noinline void update_nr_written(struct page *page,
2108 struct writeback_control *wbc,
2109 unsigned long nr_written)
2110{
2111 wbc->nr_to_write -= nr_written;
2112 if (wbc->range_cyclic || (wbc->nr_to_write > 0 &&
2113 wbc->range_start == 0 && wbc->range_end == LLONG_MAX))
2114 page->mapping->writeback_index = page->index + nr_written;
2115}
2116
2104/* 2117/*
2105 * the writepage semantics are similar to regular writepage. extent 2118 * the writepage semantics are similar to regular writepage. extent
2106 * records are inserted to lock ranges in the tree, and as dirty areas 2119 * records are inserted to lock ranges in the tree, and as dirty areas
@@ -2136,8 +2149,14 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
2136 u64 delalloc_end; 2149 u64 delalloc_end;
2137 int page_started; 2150 int page_started;
2138 int compressed; 2151 int compressed;
2152 int write_flags;
2139 unsigned long nr_written = 0; 2153 unsigned long nr_written = 0;
2140 2154
2155 if (wbc->sync_mode == WB_SYNC_ALL)
2156 write_flags = WRITE_SYNC_PLUG;
2157 else
2158 write_flags = WRITE;
2159
2141 WARN_ON(!PageLocked(page)); 2160 WARN_ON(!PageLocked(page));
2142 pg_offset = i_size & (PAGE_CACHE_SIZE - 1); 2161 pg_offset = i_size & (PAGE_CACHE_SIZE - 1);
2143 if (page->index > end_index || 2162 if (page->index > end_index ||
@@ -2164,6 +2183,12 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
2164 delalloc_end = 0; 2183 delalloc_end = 0;
2165 page_started = 0; 2184 page_started = 0;
2166 if (!epd->extent_locked) { 2185 if (!epd->extent_locked) {
2186 /*
2187 * make sure the wbc mapping index is at least updated
2188 * to this page.
2189 */
2190 update_nr_written(page, wbc, 0);
2191
2167 while (delalloc_end < page_end) { 2192 while (delalloc_end < page_end) {
2168 nr_delalloc = find_lock_delalloc_range(inode, tree, 2193 nr_delalloc = find_lock_delalloc_range(inode, tree,
2169 page, 2194 page,
@@ -2185,7 +2210,13 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
2185 */ 2210 */
2186 if (page_started) { 2211 if (page_started) {
2187 ret = 0; 2212 ret = 0;
2188 goto update_nr_written; 2213 /*
2214 * we've unlocked the page, so we can't update
2215 * the mapping's writeback index, just update
2216 * nr_to_write.
2217 */
2218 wbc->nr_to_write -= nr_written;
2219 goto done_unlocked;
2189 } 2220 }
2190 } 2221 }
2191 lock_extent(tree, start, page_end, GFP_NOFS); 2222 lock_extent(tree, start, page_end, GFP_NOFS);
@@ -2198,13 +2229,18 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
2198 if (ret == -EAGAIN) { 2229 if (ret == -EAGAIN) {
2199 unlock_extent(tree, start, page_end, GFP_NOFS); 2230 unlock_extent(tree, start, page_end, GFP_NOFS);
2200 redirty_page_for_writepage(wbc, page); 2231 redirty_page_for_writepage(wbc, page);
2232 update_nr_written(page, wbc, nr_written);
2201 unlock_page(page); 2233 unlock_page(page);
2202 ret = 0; 2234 ret = 0;
2203 goto update_nr_written; 2235 goto done_unlocked;
2204 } 2236 }
2205 } 2237 }
2206 2238
2207 nr_written++; 2239 /*
2240 * we don't want to touch the inode after unlocking the page,
2241 * so we update the mapping writeback index now
2242 */
2243 update_nr_written(page, wbc, nr_written + 1);
2208 2244
2209 end = page_end; 2245 end = page_end;
2210 if (test_range_bit(tree, start, page_end, EXTENT_DELALLOC, 0)) 2246 if (test_range_bit(tree, start, page_end, EXTENT_DELALLOC, 0))
@@ -2314,9 +2350,9 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
2314 (unsigned long long)end); 2350 (unsigned long long)end);
2315 } 2351 }
2316 2352
2317 ret = submit_extent_page(WRITE, tree, page, sector, 2353 ret = submit_extent_page(write_flags, tree, page,
2318 iosize, pg_offset, bdev, 2354 sector, iosize, pg_offset,
2319 &epd->bio, max_nr, 2355 bdev, &epd->bio, max_nr,
2320 end_bio_extent_writepage, 2356 end_bio_extent_writepage,
2321 0, 0, 0); 2357 0, 0, 0);
2322 if (ret) 2358 if (ret)
@@ -2336,11 +2372,8 @@ done:
2336 unlock_extent(tree, unlock_start, page_end, GFP_NOFS); 2372 unlock_extent(tree, unlock_start, page_end, GFP_NOFS);
2337 unlock_page(page); 2373 unlock_page(page);
2338 2374
2339update_nr_written: 2375done_unlocked:
2340 wbc->nr_to_write -= nr_written; 2376
2341 if (wbc->range_cyclic || (wbc->nr_to_write > 0 &&
2342 wbc->range_start == 0 && wbc->range_end == LLONG_MAX))
2343 page->mapping->writeback_index = page->index + nr_written;
2344 return 0; 2377 return 0;
2345} 2378}
2346 2379
@@ -2460,15 +2493,23 @@ retry:
2460 return ret; 2493 return ret;
2461} 2494}
2462 2495
2463static noinline void flush_write_bio(void *data) 2496static void flush_epd_write_bio(struct extent_page_data *epd)
2464{ 2497{
2465 struct extent_page_data *epd = data;
2466 if (epd->bio) { 2498 if (epd->bio) {
2467 submit_one_bio(WRITE, epd->bio, 0, 0); 2499 if (epd->sync_io)
2500 submit_one_bio(WRITE_SYNC, epd->bio, 0, 0);
2501 else
2502 submit_one_bio(WRITE, epd->bio, 0, 0);
2468 epd->bio = NULL; 2503 epd->bio = NULL;
2469 } 2504 }
2470} 2505}
2471 2506
2507static noinline void flush_write_bio(void *data)
2508{
2509 struct extent_page_data *epd = data;
2510 flush_epd_write_bio(epd);
2511}
2512
2472int extent_write_full_page(struct extent_io_tree *tree, struct page *page, 2513int extent_write_full_page(struct extent_io_tree *tree, struct page *page,
2473 get_extent_t *get_extent, 2514 get_extent_t *get_extent,
2474 struct writeback_control *wbc) 2515 struct writeback_control *wbc)
@@ -2480,23 +2521,22 @@ int extent_write_full_page(struct extent_io_tree *tree, struct page *page,
2480 .tree = tree, 2521 .tree = tree,
2481 .get_extent = get_extent, 2522 .get_extent = get_extent,
2482 .extent_locked = 0, 2523 .extent_locked = 0,
2524 .sync_io = wbc->sync_mode == WB_SYNC_ALL,
2483 }; 2525 };
2484 struct writeback_control wbc_writepages = { 2526 struct writeback_control wbc_writepages = {
2485 .bdi = wbc->bdi, 2527 .bdi = wbc->bdi,
2486 .sync_mode = WB_SYNC_NONE, 2528 .sync_mode = wbc->sync_mode,
2487 .older_than_this = NULL, 2529 .older_than_this = NULL,
2488 .nr_to_write = 64, 2530 .nr_to_write = 64,
2489 .range_start = page_offset(page) + PAGE_CACHE_SIZE, 2531 .range_start = page_offset(page) + PAGE_CACHE_SIZE,
2490 .range_end = (loff_t)-1, 2532 .range_end = (loff_t)-1,
2491 }; 2533 };
2492 2534
2493
2494 ret = __extent_writepage(page, wbc, &epd); 2535 ret = __extent_writepage(page, wbc, &epd);
2495 2536
2496 extent_write_cache_pages(tree, mapping, &wbc_writepages, 2537 extent_write_cache_pages(tree, mapping, &wbc_writepages,
2497 __extent_writepage, &epd, flush_write_bio); 2538 __extent_writepage, &epd, flush_write_bio);
2498 if (epd.bio) 2539 flush_epd_write_bio(&epd);
2499 submit_one_bio(WRITE, epd.bio, 0, 0);
2500 return ret; 2540 return ret;
2501} 2541}
2502 2542
@@ -2515,6 +2555,7 @@ int extent_write_locked_range(struct extent_io_tree *tree, struct inode *inode,
2515 .tree = tree, 2555 .tree = tree,
2516 .get_extent = get_extent, 2556 .get_extent = get_extent,
2517 .extent_locked = 1, 2557 .extent_locked = 1,
2558 .sync_io = mode == WB_SYNC_ALL,
2518 }; 2559 };
2519 struct writeback_control wbc_writepages = { 2560 struct writeback_control wbc_writepages = {
2520 .bdi = inode->i_mapping->backing_dev_info, 2561 .bdi = inode->i_mapping->backing_dev_info,
@@ -2540,8 +2581,7 @@ int extent_write_locked_range(struct extent_io_tree *tree, struct inode *inode,
2540 start += PAGE_CACHE_SIZE; 2581 start += PAGE_CACHE_SIZE;
2541 } 2582 }
2542 2583
2543 if (epd.bio) 2584 flush_epd_write_bio(&epd);
2544 submit_one_bio(WRITE, epd.bio, 0, 0);
2545 return ret; 2585 return ret;
2546} 2586}
2547 2587
@@ -2556,13 +2596,13 @@ int extent_writepages(struct extent_io_tree *tree,
2556 .tree = tree, 2596 .tree = tree,
2557 .get_extent = get_extent, 2597 .get_extent = get_extent,
2558 .extent_locked = 0, 2598 .extent_locked = 0,
2599 .sync_io = wbc->sync_mode == WB_SYNC_ALL,
2559 }; 2600 };
2560 2601
2561 ret = extent_write_cache_pages(tree, mapping, wbc, 2602 ret = extent_write_cache_pages(tree, mapping, wbc,
2562 __extent_writepage, &epd, 2603 __extent_writepage, &epd,
2563 flush_write_bio); 2604 flush_write_bio);
2564 if (epd.bio) 2605 flush_epd_write_bio(&epd);
2565 submit_one_bio(WRITE, epd.bio, 0, 0);
2566 return ret; 2606 return ret;
2567} 2607}
2568 2608
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 9c9fb46ccd08..482f8db2cfd0 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -830,7 +830,7 @@ again:
830 830
831 ret = btrfs_del_items(trans, root, path, del_slot, del_nr); 831 ret = btrfs_del_items(trans, root, path, del_slot, del_nr);
832 BUG_ON(ret); 832 BUG_ON(ret);
833 goto done; 833 goto release;
834 } else if (split == start) { 834 } else if (split == start) {
835 if (locked_end < extent_end) { 835 if (locked_end < extent_end) {
836 ret = try_lock_extent(&BTRFS_I(inode)->io_tree, 836 ret = try_lock_extent(&BTRFS_I(inode)->io_tree,
@@ -926,6 +926,8 @@ again:
926 } 926 }
927done: 927done:
928 btrfs_mark_buffer_dirty(leaf); 928 btrfs_mark_buffer_dirty(leaf);
929
930release:
929 btrfs_release_path(root, path); 931 btrfs_release_path(root, path);
930 if (split_end && split == start) { 932 if (split_end && split == start) {
931 split = end; 933 split = end;
@@ -1131,7 +1133,7 @@ static ssize_t btrfs_file_write(struct file *file, const char __user *buf,
1131 if (will_write) { 1133 if (will_write) {
1132 btrfs_fdatawrite_range(inode->i_mapping, pos, 1134 btrfs_fdatawrite_range(inode->i_mapping, pos,
1133 pos + write_bytes - 1, 1135 pos + write_bytes - 1,
1134 WB_SYNC_NONE); 1136 WB_SYNC_ALL);
1135 } else { 1137 } else {
1136 balance_dirty_pages_ratelimited_nr(inode->i_mapping, 1138 balance_dirty_pages_ratelimited_nr(inode->i_mapping,
1137 num_pages); 1139 num_pages);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index a0d1dd492a58..65219f6a16a1 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4970,10 +4970,10 @@ out_fail:
4970 return err; 4970 return err;
4971} 4971}
4972 4972
4973static int prealloc_file_range(struct inode *inode, u64 start, u64 end, 4973static int prealloc_file_range(struct btrfs_trans_handle *trans,
4974 struct inode *inode, u64 start, u64 end,
4974 u64 alloc_hint, int mode) 4975 u64 alloc_hint, int mode)
4975{ 4976{
4976 struct btrfs_trans_handle *trans;
4977 struct btrfs_root *root = BTRFS_I(inode)->root; 4977 struct btrfs_root *root = BTRFS_I(inode)->root;
4978 struct btrfs_key ins; 4978 struct btrfs_key ins;
4979 u64 alloc_size; 4979 u64 alloc_size;
@@ -4981,10 +4981,6 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
4981 u64 num_bytes = end - start; 4981 u64 num_bytes = end - start;
4982 int ret = 0; 4982 int ret = 0;
4983 4983
4984 trans = btrfs_join_transaction(root, 1);
4985 BUG_ON(!trans);
4986 btrfs_set_trans_block_group(trans, inode);
4987
4988 while (num_bytes > 0) { 4984 while (num_bytes > 0) {
4989 alloc_size = min(num_bytes, root->fs_info->max_extent); 4985 alloc_size = min(num_bytes, root->fs_info->max_extent);
4990 ret = btrfs_reserve_extent(trans, root, alloc_size, 4986 ret = btrfs_reserve_extent(trans, root, alloc_size,
@@ -5015,7 +5011,6 @@ out:
5015 BUG_ON(ret); 5011 BUG_ON(ret);
5016 } 5012 }
5017 5013
5018 btrfs_end_transaction(trans, root);
5019 return ret; 5014 return ret;
5020} 5015}
5021 5016
@@ -5029,11 +5024,18 @@ static long btrfs_fallocate(struct inode *inode, int mode,
5029 u64 alloc_hint = 0; 5024 u64 alloc_hint = 0;
5030 u64 mask = BTRFS_I(inode)->root->sectorsize - 1; 5025 u64 mask = BTRFS_I(inode)->root->sectorsize - 1;
5031 struct extent_map *em; 5026 struct extent_map *em;
5027 struct btrfs_trans_handle *trans;
5032 int ret; 5028 int ret;
5033 5029
5034 alloc_start = offset & ~mask; 5030 alloc_start = offset & ~mask;
5035 alloc_end = (offset + len + mask) & ~mask; 5031 alloc_end = (offset + len + mask) & ~mask;
5036 5032
5033 /*
5034 * wait for ordered IO before we have any locks. We'll loop again
5035 * below with the locks held.
5036 */
5037 btrfs_wait_ordered_range(inode, alloc_start, alloc_end - alloc_start);
5038
5037 mutex_lock(&inode->i_mutex); 5039 mutex_lock(&inode->i_mutex);
5038 if (alloc_start > inode->i_size) { 5040 if (alloc_start > inode->i_size) {
5039 ret = btrfs_cont_expand(inode, alloc_start); 5041 ret = btrfs_cont_expand(inode, alloc_start);
@@ -5043,6 +5045,16 @@ static long btrfs_fallocate(struct inode *inode, int mode,
5043 5045
5044 while (1) { 5046 while (1) {
5045 struct btrfs_ordered_extent *ordered; 5047 struct btrfs_ordered_extent *ordered;
5048
5049 trans = btrfs_start_transaction(BTRFS_I(inode)->root, 1);
5050 if (!trans) {
5051 ret = -EIO;
5052 goto out;
5053 }
5054
5055 /* the extent lock is ordered inside the running
5056 * transaction
5057 */
5046 lock_extent(&BTRFS_I(inode)->io_tree, alloc_start, 5058 lock_extent(&BTRFS_I(inode)->io_tree, alloc_start,
5047 alloc_end - 1, GFP_NOFS); 5059 alloc_end - 1, GFP_NOFS);
5048 ordered = btrfs_lookup_first_ordered_extent(inode, 5060 ordered = btrfs_lookup_first_ordered_extent(inode,
@@ -5053,6 +5065,12 @@ static long btrfs_fallocate(struct inode *inode, int mode,
5053 btrfs_put_ordered_extent(ordered); 5065 btrfs_put_ordered_extent(ordered);
5054 unlock_extent(&BTRFS_I(inode)->io_tree, 5066 unlock_extent(&BTRFS_I(inode)->io_tree,
5055 alloc_start, alloc_end - 1, GFP_NOFS); 5067 alloc_start, alloc_end - 1, GFP_NOFS);
5068 btrfs_end_transaction(trans, BTRFS_I(inode)->root);
5069
5070 /*
5071 * we can't wait on the range with the transaction
5072 * running or with the extent lock held
5073 */
5056 btrfs_wait_ordered_range(inode, alloc_start, 5074 btrfs_wait_ordered_range(inode, alloc_start,
5057 alloc_end - alloc_start); 5075 alloc_end - alloc_start);
5058 } else { 5076 } else {
@@ -5070,7 +5088,7 @@ static long btrfs_fallocate(struct inode *inode, int mode,
5070 last_byte = min(extent_map_end(em), alloc_end); 5088 last_byte = min(extent_map_end(em), alloc_end);
5071 last_byte = (last_byte + mask) & ~mask; 5089 last_byte = (last_byte + mask) & ~mask;
5072 if (em->block_start == EXTENT_MAP_HOLE) { 5090 if (em->block_start == EXTENT_MAP_HOLE) {
5073 ret = prealloc_file_range(inode, cur_offset, 5091 ret = prealloc_file_range(trans, inode, cur_offset,
5074 last_byte, alloc_hint, mode); 5092 last_byte, alloc_hint, mode);
5075 if (ret < 0) { 5093 if (ret < 0) {
5076 free_extent_map(em); 5094 free_extent_map(em);
@@ -5089,6 +5107,8 @@ static long btrfs_fallocate(struct inode *inode, int mode,
5089 } 5107 }
5090 unlock_extent(&BTRFS_I(inode)->io_tree, alloc_start, alloc_end - 1, 5108 unlock_extent(&BTRFS_I(inode)->io_tree, alloc_start, alloc_end - 1,
5091 GFP_NOFS); 5109 GFP_NOFS);
5110
5111 btrfs_end_transaction(trans, BTRFS_I(inode)->root);
5092out: 5112out:
5093 mutex_unlock(&inode->i_mutex); 5113 mutex_unlock(&inode->i_mutex);
5094 return ret; 5114 return ret;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 7594bec1be10..9f135e878507 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -461,15 +461,9 @@ static int btrfs_ioctl_resize(struct btrfs_root *root, void __user *arg)
461 if (!capable(CAP_SYS_ADMIN)) 461 if (!capable(CAP_SYS_ADMIN))
462 return -EPERM; 462 return -EPERM;
463 463
464 vol_args = kmalloc(sizeof(*vol_args), GFP_NOFS); 464 vol_args = memdup_user(arg, sizeof(*vol_args));
465 465 if (IS_ERR(vol_args))
466 if (!vol_args) 466 return PTR_ERR(vol_args);
467 return -ENOMEM;
468
469 if (copy_from_user(vol_args, arg, sizeof(*vol_args))) {
470 ret = -EFAULT;
471 goto out;
472 }
473 467
474 vol_args->name[BTRFS_PATH_NAME_MAX] = '\0'; 468 vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';
475 namelen = strlen(vol_args->name); 469 namelen = strlen(vol_args->name);
@@ -545,7 +539,6 @@ static int btrfs_ioctl_resize(struct btrfs_root *root, void __user *arg)
545 539
546out_unlock: 540out_unlock:
547 mutex_unlock(&root->fs_info->volume_mutex); 541 mutex_unlock(&root->fs_info->volume_mutex);
548out:
549 kfree(vol_args); 542 kfree(vol_args);
550 return ret; 543 return ret;
551} 544}
@@ -565,15 +558,9 @@ static noinline int btrfs_ioctl_snap_create(struct file *file,
565 if (root->fs_info->sb->s_flags & MS_RDONLY) 558 if (root->fs_info->sb->s_flags & MS_RDONLY)
566 return -EROFS; 559 return -EROFS;
567 560
568 vol_args = kmalloc(sizeof(*vol_args), GFP_NOFS); 561 vol_args = memdup_user(arg, sizeof(*vol_args));
569 562 if (IS_ERR(vol_args))
570 if (!vol_args) 563 return PTR_ERR(vol_args);
571 return -ENOMEM;
572
573 if (copy_from_user(vol_args, arg, sizeof(*vol_args))) {
574 ret = -EFAULT;
575 goto out;
576 }
577 564
578 vol_args->name[BTRFS_PATH_NAME_MAX] = '\0'; 565 vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';
579 namelen = strlen(vol_args->name); 566 namelen = strlen(vol_args->name);
@@ -675,19 +662,13 @@ static long btrfs_ioctl_add_dev(struct btrfs_root *root, void __user *arg)
675 if (!capable(CAP_SYS_ADMIN)) 662 if (!capable(CAP_SYS_ADMIN))
676 return -EPERM; 663 return -EPERM;
677 664
678 vol_args = kmalloc(sizeof(*vol_args), GFP_NOFS); 665 vol_args = memdup_user(arg, sizeof(*vol_args));
666 if (IS_ERR(vol_args))
667 return PTR_ERR(vol_args);
679 668
680 if (!vol_args)
681 return -ENOMEM;
682
683 if (copy_from_user(vol_args, arg, sizeof(*vol_args))) {
684 ret = -EFAULT;
685 goto out;
686 }
687 vol_args->name[BTRFS_PATH_NAME_MAX] = '\0'; 669 vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';
688 ret = btrfs_init_new_device(root, vol_args->name); 670 ret = btrfs_init_new_device(root, vol_args->name);
689 671
690out:
691 kfree(vol_args); 672 kfree(vol_args);
692 return ret; 673 return ret;
693} 674}
@@ -703,19 +684,13 @@ static long btrfs_ioctl_rm_dev(struct btrfs_root *root, void __user *arg)
703 if (root->fs_info->sb->s_flags & MS_RDONLY) 684 if (root->fs_info->sb->s_flags & MS_RDONLY)
704 return -EROFS; 685 return -EROFS;
705 686
706 vol_args = kmalloc(sizeof(*vol_args), GFP_NOFS); 687 vol_args = memdup_user(arg, sizeof(*vol_args));
688 if (IS_ERR(vol_args))
689 return PTR_ERR(vol_args);
707 690
708 if (!vol_args)
709 return -ENOMEM;
710
711 if (copy_from_user(vol_args, arg, sizeof(*vol_args))) {
712 ret = -EFAULT;
713 goto out;
714 }
715 vol_args->name[BTRFS_PATH_NAME_MAX] = '\0'; 691 vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';
716 ret = btrfs_rm_device(root, vol_args->name); 692 ret = btrfs_rm_device(root, vol_args->name);
717 693
718out:
719 kfree(vol_args); 694 kfree(vol_args);
720 return ret; 695 return ret;
721} 696}
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 53c87b197d70..d6f0806c682f 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -489,7 +489,7 @@ again:
489 /* start IO across the range first to instantiate any delalloc 489 /* start IO across the range first to instantiate any delalloc
490 * extents 490 * extents
491 */ 491 */
492 btrfs_fdatawrite_range(inode->i_mapping, start, orig_end, WB_SYNC_NONE); 492 btrfs_fdatawrite_range(inode->i_mapping, start, orig_end, WB_SYNC_ALL);
493 493
494 /* The compression code will leave pages locked but return from 494 /* The compression code will leave pages locked but return from
495 * writepage without setting the page writeback. Starting again 495 * writepage without setting the page writeback. Starting again
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 9744af9d71e9..a7acfe639a44 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -635,14 +635,9 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
635 if (!capable(CAP_SYS_ADMIN)) 635 if (!capable(CAP_SYS_ADMIN))
636 return -EPERM; 636 return -EPERM;
637 637
638 vol = kmalloc(sizeof(*vol), GFP_KERNEL); 638 vol = memdup_user((void __user *)arg, sizeof(*vol));
639 if (!vol) 639 if (IS_ERR(vol))
640 return -ENOMEM; 640 return PTR_ERR(vol);
641
642 if (copy_from_user(vol, (void __user *)arg, sizeof(*vol))) {
643 ret = -EFAULT;
644 goto out;
645 }
646 641
647 switch (cmd) { 642 switch (cmd) {
648 case BTRFS_IOC_SCAN_DEV: 643 case BTRFS_IOC_SCAN_DEV:
@@ -650,7 +645,7 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
650 &btrfs_fs_type, &fs_devices); 645 &btrfs_fs_type, &fs_devices);
651 break; 646 break;
652 } 647 }
653out: 648
654 kfree(vol); 649 kfree(vol);
655 return ret; 650 return ret;
656} 651}
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index e0913e469728..e53835b88594 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -125,6 +125,20 @@ static noinline struct btrfs_fs_devices *find_fsid(u8 *fsid)
125 return NULL; 125 return NULL;
126} 126}
127 127
128static void requeue_list(struct btrfs_pending_bios *pending_bios,
129 struct bio *head, struct bio *tail)
130{
131
132 struct bio *old_head;
133
134 old_head = pending_bios->head;
135 pending_bios->head = head;
136 if (pending_bios->tail)
137 tail->bi_next = old_head;
138 else
139 pending_bios->tail = tail;
140}
141
128/* 142/*
129 * we try to collect pending bios for a device so we don't get a large 143 * we try to collect pending bios for a device so we don't get a large
130 * number of procs sending bios down to the same device. This greatly 144 * number of procs sending bios down to the same device. This greatly
@@ -141,10 +155,12 @@ static noinline int run_scheduled_bios(struct btrfs_device *device)
141 struct bio *pending; 155 struct bio *pending;
142 struct backing_dev_info *bdi; 156 struct backing_dev_info *bdi;
143 struct btrfs_fs_info *fs_info; 157 struct btrfs_fs_info *fs_info;
158 struct btrfs_pending_bios *pending_bios;
144 struct bio *tail; 159 struct bio *tail;
145 struct bio *cur; 160 struct bio *cur;
146 int again = 0; 161 int again = 0;
147 unsigned long num_run = 0; 162 unsigned long num_run;
163 unsigned long num_sync_run;
148 unsigned long limit; 164 unsigned long limit;
149 unsigned long last_waited = 0; 165 unsigned long last_waited = 0;
150 166
@@ -153,20 +169,30 @@ static noinline int run_scheduled_bios(struct btrfs_device *device)
153 limit = btrfs_async_submit_limit(fs_info); 169 limit = btrfs_async_submit_limit(fs_info);
154 limit = limit * 2 / 3; 170 limit = limit * 2 / 3;
155 171
172 /* we want to make sure that every time we switch from the sync
173 * list to the normal list, we unplug
174 */
175 num_sync_run = 0;
176
156loop: 177loop:
157 spin_lock(&device->io_lock); 178 spin_lock(&device->io_lock);
179 num_run = 0;
158 180
159loop_lock: 181loop_lock:
182
160 /* take all the bios off the list at once and process them 183 /* take all the bios off the list at once and process them
161 * later on (without the lock held). But, remember the 184 * later on (without the lock held). But, remember the
162 * tail and other pointers so the bios can be properly reinserted 185 * tail and other pointers so the bios can be properly reinserted
163 * into the list if we hit congestion 186 * into the list if we hit congestion
164 */ 187 */
165 pending = device->pending_bios; 188 if (device->pending_sync_bios.head)
166 tail = device->pending_bio_tail; 189 pending_bios = &device->pending_sync_bios;
190 else
191 pending_bios = &device->pending_bios;
192
193 pending = pending_bios->head;
194 tail = pending_bios->tail;
167 WARN_ON(pending && !tail); 195 WARN_ON(pending && !tail);
168 device->pending_bios = NULL;
169 device->pending_bio_tail = NULL;
170 196
171 /* 197 /*
172 * if pending was null this time around, no bios need processing 198 * if pending was null this time around, no bios need processing
@@ -176,16 +202,41 @@ loop_lock:
176 * device->running_pending is used to synchronize with the 202 * device->running_pending is used to synchronize with the
177 * schedule_bio code. 203 * schedule_bio code.
178 */ 204 */
179 if (pending) { 205 if (device->pending_sync_bios.head == NULL &&
180 again = 1; 206 device->pending_bios.head == NULL) {
181 device->running_pending = 1;
182 } else {
183 again = 0; 207 again = 0;
184 device->running_pending = 0; 208 device->running_pending = 0;
209 } else {
210 again = 1;
211 device->running_pending = 1;
185 } 212 }
213
214 pending_bios->head = NULL;
215 pending_bios->tail = NULL;
216
186 spin_unlock(&device->io_lock); 217 spin_unlock(&device->io_lock);
187 218
219 /*
220 * if we're doing the regular priority list, make sure we unplug
221 * for any high prio bios we've sent down
222 */
223 if (pending_bios == &device->pending_bios && num_sync_run > 0) {
224 num_sync_run = 0;
225 blk_run_backing_dev(bdi, NULL);
226 }
227
188 while (pending) { 228 while (pending) {
229
230 rmb();
231 if (pending_bios != &device->pending_sync_bios &&
232 device->pending_sync_bios.head &&
233 num_run > 16) {
234 cond_resched();
235 spin_lock(&device->io_lock);
236 requeue_list(pending_bios, pending, tail);
237 goto loop_lock;
238 }
239
189 cur = pending; 240 cur = pending;
190 pending = pending->bi_next; 241 pending = pending->bi_next;
191 cur->bi_next = NULL; 242 cur->bi_next = NULL;
@@ -196,10 +247,18 @@ loop_lock:
196 wake_up(&fs_info->async_submit_wait); 247 wake_up(&fs_info->async_submit_wait);
197 248
198 BUG_ON(atomic_read(&cur->bi_cnt) == 0); 249 BUG_ON(atomic_read(&cur->bi_cnt) == 0);
199 bio_get(cur);
200 submit_bio(cur->bi_rw, cur); 250 submit_bio(cur->bi_rw, cur);
201 bio_put(cur);
202 num_run++; 251 num_run++;
252 if (bio_sync(cur))
253 num_sync_run++;
254
255 if (need_resched()) {
256 if (num_sync_run) {
257 blk_run_backing_dev(bdi, NULL);
258 num_sync_run = 0;
259 }
260 cond_resched();
261 }
203 262
204 /* 263 /*
205 * we made progress, there is more work to do and the bdi 264 * we made progress, there is more work to do and the bdi
@@ -208,7 +267,6 @@ loop_lock:
208 */ 267 */
209 if (pending && bdi_write_congested(bdi) && num_run > 16 && 268 if (pending && bdi_write_congested(bdi) && num_run > 16 &&
210 fs_info->fs_devices->open_devices > 1) { 269 fs_info->fs_devices->open_devices > 1) {
211 struct bio *old_head;
212 struct io_context *ioc; 270 struct io_context *ioc;
213 271
214 ioc = current->io_context; 272 ioc = current->io_context;
@@ -233,17 +291,17 @@ loop_lock:
233 * against it before looping 291 * against it before looping
234 */ 292 */
235 last_waited = ioc->last_waited; 293 last_waited = ioc->last_waited;
294 if (need_resched()) {
295 if (num_sync_run) {
296 blk_run_backing_dev(bdi, NULL);
297 num_sync_run = 0;
298 }
299 cond_resched();
300 }
236 continue; 301 continue;
237 } 302 }
238 spin_lock(&device->io_lock); 303 spin_lock(&device->io_lock);
239 304 requeue_list(pending_bios, pending, tail);
240 old_head = device->pending_bios;
241 device->pending_bios = pending;
242 if (device->pending_bio_tail)
243 tail->bi_next = old_head;
244 else
245 device->pending_bio_tail = tail;
246
247 device->running_pending = 1; 305 device->running_pending = 1;
248 306
249 spin_unlock(&device->io_lock); 307 spin_unlock(&device->io_lock);
@@ -251,11 +309,18 @@ loop_lock:
251 goto done; 309 goto done;
252 } 310 }
253 } 311 }
312
313 if (num_sync_run) {
314 num_sync_run = 0;
315 blk_run_backing_dev(bdi, NULL);
316 }
317
318 cond_resched();
254 if (again) 319 if (again)
255 goto loop; 320 goto loop;
256 321
257 spin_lock(&device->io_lock); 322 spin_lock(&device->io_lock);
258 if (device->pending_bios) 323 if (device->pending_bios.head || device->pending_sync_bios.head)
259 goto loop_lock; 324 goto loop_lock;
260 spin_unlock(&device->io_lock); 325 spin_unlock(&device->io_lock);
261 326
@@ -2497,7 +2562,7 @@ again:
2497 max_errors = 1; 2562 max_errors = 1;
2498 } 2563 }
2499 } 2564 }
2500 if (multi_ret && rw == WRITE && 2565 if (multi_ret && (rw & (1 << BIO_RW)) &&
2501 stripes_allocated < stripes_required) { 2566 stripes_allocated < stripes_required) {
2502 stripes_allocated = map->num_stripes; 2567 stripes_allocated = map->num_stripes;
2503 free_extent_map(em); 2568 free_extent_map(em);
@@ -2762,6 +2827,7 @@ static noinline int schedule_bio(struct btrfs_root *root,
2762 int rw, struct bio *bio) 2827 int rw, struct bio *bio)
2763{ 2828{
2764 int should_queue = 1; 2829 int should_queue = 1;
2830 struct btrfs_pending_bios *pending_bios;
2765 2831
2766 /* don't bother with additional async steps for reads, right now */ 2832 /* don't bother with additional async steps for reads, right now */
2767 if (!(rw & (1 << BIO_RW))) { 2833 if (!(rw & (1 << BIO_RW))) {
@@ -2783,13 +2849,17 @@ static noinline int schedule_bio(struct btrfs_root *root,
2783 bio->bi_rw |= rw; 2849 bio->bi_rw |= rw;
2784 2850
2785 spin_lock(&device->io_lock); 2851 spin_lock(&device->io_lock);
2852 if (bio_sync(bio))
2853 pending_bios = &device->pending_sync_bios;
2854 else
2855 pending_bios = &device->pending_bios;
2786 2856
2787 if (device->pending_bio_tail) 2857 if (pending_bios->tail)
2788 device->pending_bio_tail->bi_next = bio; 2858 pending_bios->tail->bi_next = bio;
2789 2859
2790 device->pending_bio_tail = bio; 2860 pending_bios->tail = bio;
2791 if (!device->pending_bios) 2861 if (!pending_bios->head)
2792 device->pending_bios = bio; 2862 pending_bios->head = bio;
2793 if (device->running_pending) 2863 if (device->running_pending)
2794 should_queue = 0; 2864 should_queue = 0;
2795 2865
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 2185de72ff7d..5836327ba5dd 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -23,13 +23,22 @@
23#include "async-thread.h" 23#include "async-thread.h"
24 24
25struct buffer_head; 25struct buffer_head;
26struct btrfs_pending_bios {
27 struct bio *head;
28 struct bio *tail;
29};
30
26struct btrfs_device { 31struct btrfs_device {
27 struct list_head dev_list; 32 struct list_head dev_list;
28 struct list_head dev_alloc_list; 33 struct list_head dev_alloc_list;
29 struct btrfs_fs_devices *fs_devices; 34 struct btrfs_fs_devices *fs_devices;
30 struct btrfs_root *dev_root; 35 struct btrfs_root *dev_root;
31 struct bio *pending_bios; 36
32 struct bio *pending_bio_tail; 37 /* regular prio bios */
38 struct btrfs_pending_bios pending_bios;
39 /* WRITE_SYNC bios */
40 struct btrfs_pending_bios pending_sync_bios;
41
33 int running_pending; 42 int running_pending;
34 u64 generation; 43 u64 generation;
35 44
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES
index 65984006192c..9d1fb6ec8a5a 100644
--- a/fs/cifs/CHANGES
+++ b/fs/cifs/CHANGES
@@ -15,7 +15,8 @@ Posix file open support added (turned off after one attempt if server
15fails to support it properly, as with Samba server versions prior to 3.3.2) 15fails to support it properly, as with Samba server versions prior to 3.3.2)
16Fix "redzone overwritten" bug in cifs_put_tcon (CIFSTcon may allocate too 16Fix "redzone overwritten" bug in cifs_put_tcon (CIFSTcon may allocate too
17little memory for the "nativeFileSystem" field returned by the server 17little memory for the "nativeFileSystem" field returned by the server
18during mount). 18during mount). Endian convert inode numbers if necessary (makes it easier
19to compare inode numbers on network files from big endian systems).
19 20
20Version 1.56 21Version 1.56
21------------ 22------------
diff --git a/fs/cifs/cifs_spnego.c b/fs/cifs/cifs_spnego.c
index 3fd3a9df043a..67bf93a40d2e 100644
--- a/fs/cifs/cifs_spnego.c
+++ b/fs/cifs/cifs_spnego.c
@@ -41,7 +41,7 @@ cifs_spnego_key_instantiate(struct key *key, const void *data, size_t datalen)
41 41
42 /* attach the data */ 42 /* attach the data */
43 memcpy(payload, data, datalen); 43 memcpy(payload, data, datalen);
44 rcu_assign_pointer(key->payload.data, payload); 44 key->payload.data = payload;
45 ret = 0; 45 ret = 0;
46 46
47error: 47error:
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 38491fd3871d..0d6d8b573652 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -66,9 +66,6 @@ unsigned int sign_CIFS_PDUs = 1;
66extern struct task_struct *oplockThread; /* remove sparse warning */ 66extern struct task_struct *oplockThread; /* remove sparse warning */
67struct task_struct *oplockThread = NULL; 67struct task_struct *oplockThread = NULL;
68/* extern struct task_struct * dnotifyThread; remove sparse warning */ 68/* extern struct task_struct * dnotifyThread; remove sparse warning */
69#ifdef CONFIG_CIFS_EXPERIMENTAL
70static struct task_struct *dnotifyThread = NULL;
71#endif
72static const struct super_operations cifs_super_ops; 69static const struct super_operations cifs_super_ops;
73unsigned int CIFSMaxBufSize = CIFS_MAX_MSGSIZE; 70unsigned int CIFSMaxBufSize = CIFS_MAX_MSGSIZE;
74module_param(CIFSMaxBufSize, int, 0); 71module_param(CIFSMaxBufSize, int, 0);
@@ -316,6 +313,7 @@ cifs_alloc_inode(struct super_block *sb)
316 cifs_inode->clientCanCacheAll = false; 313 cifs_inode->clientCanCacheAll = false;
317 cifs_inode->delete_pending = false; 314 cifs_inode->delete_pending = false;
318 cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */ 315 cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */
316 cifs_inode->server_eof = 0;
319 317
320 /* Can not set i_flags here - they get immediately overwritten 318 /* Can not set i_flags here - they get immediately overwritten
321 to zero by the VFS */ 319 to zero by the VFS */
@@ -1040,34 +1038,6 @@ static int cifs_oplock_thread(void *dummyarg)
1040 return 0; 1038 return 0;
1041} 1039}
1042 1040
1043#ifdef CONFIG_CIFS_EXPERIMENTAL
1044static int cifs_dnotify_thread(void *dummyarg)
1045{
1046 struct list_head *tmp;
1047 struct TCP_Server_Info *server;
1048
1049 do {
1050 if (try_to_freeze())
1051 continue;
1052 set_current_state(TASK_INTERRUPTIBLE);
1053 schedule_timeout(15*HZ);
1054 /* check if any stuck requests that need
1055 to be woken up and wakeq so the
1056 thread can wake up and error out */
1057 read_lock(&cifs_tcp_ses_lock);
1058 list_for_each(tmp, &cifs_tcp_ses_list) {
1059 server = list_entry(tmp, struct TCP_Server_Info,
1060 tcp_ses_list);
1061 if (atomic_read(&server->inFlight))
1062 wake_up_all(&server->response_q);
1063 }
1064 read_unlock(&cifs_tcp_ses_lock);
1065 } while (!kthread_should_stop());
1066
1067 return 0;
1068}
1069#endif
1070
1071static int __init 1041static int __init
1072init_cifs(void) 1042init_cifs(void)
1073{ 1043{
@@ -1144,21 +1114,8 @@ init_cifs(void)
1144 goto out_unregister_dfs_key_type; 1114 goto out_unregister_dfs_key_type;
1145 } 1115 }
1146 1116
1147#ifdef CONFIG_CIFS_EXPERIMENTAL
1148 dnotifyThread = kthread_run(cifs_dnotify_thread, NULL, "cifsdnotifyd");
1149 if (IS_ERR(dnotifyThread)) {
1150 rc = PTR_ERR(dnotifyThread);
1151 cERROR(1, ("error %d create dnotify thread", rc));
1152 goto out_stop_oplock_thread;
1153 }
1154#endif
1155
1156 return 0; 1117 return 0;
1157 1118
1158#ifdef CONFIG_CIFS_EXPERIMENTAL
1159 out_stop_oplock_thread:
1160#endif
1161 kthread_stop(oplockThread);
1162 out_unregister_dfs_key_type: 1119 out_unregister_dfs_key_type:
1163#ifdef CONFIG_CIFS_DFS_UPCALL 1120#ifdef CONFIG_CIFS_DFS_UPCALL
1164 unregister_key_type(&key_type_dns_resolver); 1121 unregister_key_type(&key_type_dns_resolver);
@@ -1196,9 +1153,6 @@ exit_cifs(void)
1196 cifs_destroy_inodecache(); 1153 cifs_destroy_inodecache();
1197 cifs_destroy_mids(); 1154 cifs_destroy_mids();
1198 cifs_destroy_request_bufs(); 1155 cifs_destroy_request_bufs();
1199#ifdef CONFIG_CIFS_EXPERIMENTAL
1200 kthread_stop(dnotifyThread);
1201#endif
1202 kthread_stop(oplockThread); 1156 kthread_stop(oplockThread);
1203} 1157}
1204 1158
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 9fbf4dff5da6..df40ab64cd95 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -350,7 +350,7 @@ struct cifsFileInfo {
350 bool invalidHandle:1; /* file closed via session abend */ 350 bool invalidHandle:1; /* file closed via session abend */
351 bool messageMode:1; /* for pipes: message vs byte mode */ 351 bool messageMode:1; /* for pipes: message vs byte mode */
352 atomic_t wrtPending; /* handle in use - defer close */ 352 atomic_t wrtPending; /* handle in use - defer close */
353 struct semaphore fh_sem; /* prevents reopen race after dead ses*/ 353 struct mutex fh_mutex; /* prevents reopen race after dead ses*/
354 struct cifs_search_info srch_inf; 354 struct cifs_search_info srch_inf;
355}; 355};
356 356
@@ -370,6 +370,7 @@ struct cifsInodeInfo {
370 bool clientCanCacheAll:1; /* read and writebehind oplock */ 370 bool clientCanCacheAll:1; /* read and writebehind oplock */
371 bool oplockPending:1; 371 bool oplockPending:1;
372 bool delete_pending:1; /* DELETE_ON_CLOSE is set */ 372 bool delete_pending:1; /* DELETE_ON_CLOSE is set */
373 u64 server_eof; /* current file size on server */
373 struct inode vfs_inode; 374 struct inode vfs_inode;
374}; 375};
375 376
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h
index b370489c8da5..a785f69dbc9f 100644
--- a/fs/cifs/cifspdu.h
+++ b/fs/cifs/cifspdu.h
@@ -2163,7 +2163,7 @@ typedef struct {
2163 __le32 Type; 2163 __le32 Type;
2164 __le64 DevMajor; 2164 __le64 DevMajor;
2165 __le64 DevMinor; 2165 __le64 DevMinor;
2166 __u64 UniqueId; 2166 __le64 UniqueId;
2167 __le64 Permissions; 2167 __le64 Permissions;
2168 __le64 Nlinks; 2168 __le64 Nlinks;
2169} __attribute__((packed)) FILE_UNIX_BASIC_INFO; /* level 0x200 QPathInfo */ 2169} __attribute__((packed)) FILE_UNIX_BASIC_INFO; /* level 0x200 QPathInfo */
@@ -2308,7 +2308,7 @@ struct unlink_psx_rq { /* level 0x20a SetPathInfo */
2308} __attribute__((packed)); 2308} __attribute__((packed));
2309 2309
2310struct file_internal_info { 2310struct file_internal_info {
2311 __u64 UniqueId; /* inode number */ 2311 __le64 UniqueId; /* inode number */
2312} __attribute__((packed)); /* level 0x3ee */ 2312} __attribute__((packed)); /* level 0x3ee */
2313 2313
2314struct file_mode_info { 2314struct file_mode_info {
@@ -2338,7 +2338,7 @@ typedef struct {
2338 __le32 Type; 2338 __le32 Type;
2339 __le64 DevMajor; 2339 __le64 DevMajor;
2340 __le64 DevMinor; 2340 __le64 DevMinor;
2341 __u64 UniqueId; 2341 __le64 UniqueId;
2342 __le64 Permissions; 2342 __le64 Permissions;
2343 __le64 Nlinks; 2343 __le64 Nlinks;
2344 char FileName[1]; 2344 char FileName[1];
@@ -2386,7 +2386,7 @@ typedef struct {
2386 __le32 FileNameLength; 2386 __le32 FileNameLength;
2387 __le32 EaSize; /* EA size */ 2387 __le32 EaSize; /* EA size */
2388 __le32 Reserved; 2388 __le32 Reserved;
2389 __u64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/ 2389 __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
2390 char FileName[1]; 2390 char FileName[1];
2391} __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */ 2391} __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */
2392 2392
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index bc09c998631f..a0845dc7b8a9 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -1626,6 +1626,8 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1626 int smb_hdr_len; 1626 int smb_hdr_len;
1627 int resp_buf_type = 0; 1627 int resp_buf_type = 0;
1628 1628
1629 *nbytes = 0;
1630
1629 cFYI(1, ("write2 at %lld %d bytes", (long long)offset, count)); 1631 cFYI(1, ("write2 at %lld %d bytes", (long long)offset, count));
1630 1632
1631 if (tcon->ses->capabilities & CAP_LARGE_FILES) { 1633 if (tcon->ses->capabilities & CAP_LARGE_FILES) {
@@ -1682,11 +1684,9 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1682 cifs_stats_inc(&tcon->num_writes); 1684 cifs_stats_inc(&tcon->num_writes);
1683 if (rc) { 1685 if (rc) {
1684 cFYI(1, ("Send error Write2 = %d", rc)); 1686 cFYI(1, ("Send error Write2 = %d", rc));
1685 *nbytes = 0;
1686 } else if (resp_buf_type == 0) { 1687 } else if (resp_buf_type == 0) {
1687 /* presumably this can not happen, but best to be safe */ 1688 /* presumably this can not happen, but best to be safe */
1688 rc = -EIO; 1689 rc = -EIO;
1689 *nbytes = 0;
1690 } else { 1690 } else {
1691 WRITE_RSP *pSMBr = (WRITE_RSP *)iov[0].iov_base; 1691 WRITE_RSP *pSMBr = (WRITE_RSP *)iov[0].iov_base;
1692 *nbytes = le16_to_cpu(pSMBr->CountHigh); 1692 *nbytes = le16_to_cpu(pSMBr->CountHigh);
@@ -3918,7 +3918,7 @@ GetInodeNumberRetry:
3918 } 3918 }
3919 pfinfo = (struct file_internal_info *) 3919 pfinfo = (struct file_internal_info *)
3920 (data_offset + (char *) &pSMBr->hdr.Protocol); 3920 (data_offset + (char *) &pSMBr->hdr.Protocol);
3921 *inode_number = pfinfo->UniqueId; 3921 *inode_number = le64_to_cpu(pfinfo->UniqueId);
3922 } 3922 }
3923 } 3923 }
3924GetInodeNumOut: 3924GetInodeNumOut:
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 0de3b5615a22..bacdef1546b7 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2214,9 +2214,58 @@ is_path_accessible(int xid, struct cifsTconInfo *tcon,
2214 return rc; 2214 return rc;
2215} 2215}
2216 2216
2217static void
2218cleanup_volume_info(struct smb_vol **pvolume_info)
2219{
2220 struct smb_vol *volume_info;
2221
2222 if (!pvolume_info && !*pvolume_info)
2223 return;
2224
2225 volume_info = *pvolume_info;
2226 kzfree(volume_info->password);
2227 kfree(volume_info->UNC);
2228 kfree(volume_info->prepath);
2229 kfree(volume_info);
2230 *pvolume_info = NULL;
2231 return;
2232}
2233
2234#ifdef CONFIG_CIFS_DFS_UPCALL
2235/* build_path_to_root returns full path to root when
2236 * we do not have an exiting connection (tcon) */
2237static char *
2238build_unc_path_to_root(const struct smb_vol *volume_info,
2239 const struct cifs_sb_info *cifs_sb)
2240{
2241 char *full_path;
2242
2243 int unc_len = strnlen(volume_info->UNC, MAX_TREE_SIZE + 1);
2244 full_path = kmalloc(unc_len + cifs_sb->prepathlen + 1, GFP_KERNEL);
2245 if (full_path == NULL)
2246 return ERR_PTR(-ENOMEM);
2247
2248 strncpy(full_path, volume_info->UNC, unc_len);
2249 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) {
2250 int i;
2251 for (i = 0; i < unc_len; i++) {
2252 if (full_path[i] == '\\')
2253 full_path[i] = '/';
2254 }
2255 }
2256
2257 if (cifs_sb->prepathlen)
2258 strncpy(full_path + unc_len, cifs_sb->prepath,
2259 cifs_sb->prepathlen);
2260
2261 full_path[unc_len + cifs_sb->prepathlen] = 0; /* add trailing null */
2262 return full_path;
2263}
2264#endif
2265
2217int 2266int
2218cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, 2267cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2219 char *mount_data, const char *devname) 2268 char *mount_data_global, const char *devname)
2220{ 2269{
2221 int rc = 0; 2270 int rc = 0;
2222 int xid; 2271 int xid;
@@ -2225,6 +2274,13 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2225 struct cifsTconInfo *tcon = NULL; 2274 struct cifsTconInfo *tcon = NULL;
2226 struct TCP_Server_Info *srvTcp = NULL; 2275 struct TCP_Server_Info *srvTcp = NULL;
2227 char *full_path; 2276 char *full_path;
2277 char *mount_data = mount_data_global;
2278#ifdef CONFIG_CIFS_DFS_UPCALL
2279 struct dfs_info3_param *referrals = NULL;
2280 unsigned int num_referrals = 0;
2281try_mount_again:
2282#endif
2283 full_path = NULL;
2228 2284
2229 xid = GetXid(); 2285 xid = GetXid();
2230 2286
@@ -2371,11 +2427,9 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2371 } 2427 }
2372 } 2428 }
2373 2429
2374 /* check for null share name ie connect to dfs root */
2375 if ((strchr(volume_info->UNC + 3, '\\') == NULL) 2430 if ((strchr(volume_info->UNC + 3, '\\') == NULL)
2376 && (strchr(volume_info->UNC + 3, '/') == NULL)) { 2431 && (strchr(volume_info->UNC + 3, '/') == NULL)) {
2377 /* rc = connect_to_dfs_path(...) */ 2432 cERROR(1, ("Missing share name"));
2378 cFYI(1, ("DFS root not supported"));
2379 rc = -ENODEV; 2433 rc = -ENODEV;
2380 goto mount_fail_check; 2434 goto mount_fail_check;
2381 } else { 2435 } else {
@@ -2392,7 +2446,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2392 } 2446 }
2393 } 2447 }
2394 if (rc) 2448 if (rc)
2395 goto mount_fail_check; 2449 goto remote_path_check;
2396 tcon->seal = volume_info->seal; 2450 tcon->seal = volume_info->seal;
2397 write_lock(&cifs_tcp_ses_lock); 2451 write_lock(&cifs_tcp_ses_lock);
2398 list_add(&tcon->tcon_list, &pSesInfo->tcon_list); 2452 list_add(&tcon->tcon_list, &pSesInfo->tcon_list);
@@ -2417,19 +2471,9 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2417 /* BB FIXME fix time_gran to be larger for LANMAN sessions */ 2471 /* BB FIXME fix time_gran to be larger for LANMAN sessions */
2418 sb->s_time_gran = 100; 2472 sb->s_time_gran = 100;
2419 2473
2420mount_fail_check: 2474 if (rc)
2421 /* on error free sesinfo and tcon struct if needed */ 2475 goto remote_path_check;
2422 if (rc) { 2476
2423 /* If find_unc succeeded then rc == 0 so we can not end */
2424 /* up accidently freeing someone elses tcon struct */
2425 if (tcon)
2426 cifs_put_tcon(tcon);
2427 else if (pSesInfo)
2428 cifs_put_smb_ses(pSesInfo);
2429 else
2430 cifs_put_tcp_session(srvTcp);
2431 goto out;
2432 }
2433 cifs_sb->tcon = tcon; 2477 cifs_sb->tcon = tcon;
2434 2478
2435 /* do not care if following two calls succeed - informational */ 2479 /* do not care if following two calls succeed - informational */
@@ -2461,7 +2505,9 @@ mount_fail_check:
2461 cifs_sb->rsize = min(cifs_sb->rsize, 2505 cifs_sb->rsize = min(cifs_sb->rsize,
2462 (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE)); 2506 (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE));
2463 2507
2464 if (!rc && cifs_sb->prepathlen) { 2508remote_path_check:
2509 /* check if a whole path (including prepath) is not remote */
2510 if (!rc && cifs_sb->prepathlen && tcon) {
2465 /* build_path_to_root works only when we have a valid tcon */ 2511 /* build_path_to_root works only when we have a valid tcon */
2466 full_path = cifs_build_path_to_root(cifs_sb); 2512 full_path = cifs_build_path_to_root(cifs_sb);
2467 if (full_path == NULL) { 2513 if (full_path == NULL) {
@@ -2469,31 +2515,79 @@ mount_fail_check:
2469 goto mount_fail_check; 2515 goto mount_fail_check;
2470 } 2516 }
2471 rc = is_path_accessible(xid, tcon, cifs_sb, full_path); 2517 rc = is_path_accessible(xid, tcon, cifs_sb, full_path);
2472 if (rc) { 2518 if (rc != -EREMOTE) {
2473 cERROR(1, ("Path %s in not accessible: %d",
2474 full_path, rc));
2475 kfree(full_path); 2519 kfree(full_path);
2476 goto mount_fail_check; 2520 goto mount_fail_check;
2477 } 2521 }
2478 kfree(full_path); 2522 kfree(full_path);
2479 } 2523 }
2480 2524
2525 /* get referral if needed */
2526 if (rc == -EREMOTE) {
2527#ifdef CONFIG_CIFS_DFS_UPCALL
2528 /* convert forward to back slashes in prepath here if needed */
2529 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) == 0)
2530 convert_delimiter(cifs_sb->prepath,
2531 CIFS_DIR_SEP(cifs_sb));
2532 full_path = build_unc_path_to_root(volume_info, cifs_sb);
2533 if (IS_ERR(full_path)) {
2534 rc = PTR_ERR(full_path);
2535 goto mount_fail_check;
2536 }
2537
2538 cFYI(1, ("Getting referral for: %s", full_path));
2539 rc = get_dfs_path(xid, pSesInfo , full_path + 1,
2540 cifs_sb->local_nls, &num_referrals, &referrals,
2541 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
2542 if (!rc && num_referrals > 0) {
2543 char *fake_devname = NULL;
2544
2545 if (mount_data != mount_data_global)
2546 kfree(mount_data);
2547 mount_data = cifs_compose_mount_options(
2548 cifs_sb->mountdata, full_path + 1,
2549 referrals, &fake_devname);
2550 kfree(fake_devname);
2551 free_dfs_info_array(referrals, num_referrals);
2552
2553 if (tcon)
2554 cifs_put_tcon(tcon);
2555 else if (pSesInfo)
2556 cifs_put_smb_ses(pSesInfo);
2557
2558 cleanup_volume_info(&volume_info);
2559 FreeXid(xid);
2560 kfree(full_path);
2561 goto try_mount_again;
2562 }
2563#else /* No DFS support, return error on mount */
2564 rc = -EOPNOTSUPP;
2565#endif
2566 }
2567
2568mount_fail_check:
2569 /* on error free sesinfo and tcon struct if needed */
2570 if (rc) {
2571 if (mount_data != mount_data_global)
2572 kfree(mount_data);
2573 /* If find_unc succeeded then rc == 0 so we can not end */
2574 /* up accidently freeing someone elses tcon struct */
2575 if (tcon)
2576 cifs_put_tcon(tcon);
2577 else if (pSesInfo)
2578 cifs_put_smb_ses(pSesInfo);
2579 else
2580 cifs_put_tcp_session(srvTcp);
2581 goto out;
2582 }
2583
2481 /* volume_info->password is freed above when existing session found 2584 /* volume_info->password is freed above when existing session found
2482 (in which case it is not needed anymore) but when new sesion is created 2585 (in which case it is not needed anymore) but when new sesion is created
2483 the password ptr is put in the new session structure (in which case the 2586 the password ptr is put in the new session structure (in which case the
2484 password will be freed at unmount time) */ 2587 password will be freed at unmount time) */
2485out: 2588out:
2486 /* zero out password before freeing */ 2589 /* zero out password before freeing */
2487 if (volume_info) { 2590 cleanup_volume_info(&volume_info);
2488 if (volume_info->password != NULL) {
2489 memset(volume_info->password, 0,
2490 strlen(volume_info->password));
2491 kfree(volume_info->password);
2492 }
2493 kfree(volume_info->UNC);
2494 kfree(volume_info->prepath);
2495 kfree(volume_info);
2496 }
2497 FreeXid(xid); 2591 FreeXid(xid);
2498 return rc; 2592 return rc;
2499} 2593}
@@ -2673,8 +2767,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2673/* We look for obvious messed up bcc or strings in response so we do not go off 2767/* We look for obvious messed up bcc or strings in response so we do not go off
2674 the end since (at least) WIN2K and Windows XP have a major bug in not null 2768 the end since (at least) WIN2K and Windows XP have a major bug in not null
2675 terminating last Unicode string in response */ 2769 terminating last Unicode string in response */
2676 if (ses->serverOS) 2770 kfree(ses->serverOS);
2677 kfree(ses->serverOS);
2678 ses->serverOS = kzalloc(2 * (len + 1), 2771 ses->serverOS = kzalloc(2 * (len + 1),
2679 GFP_KERNEL); 2772 GFP_KERNEL);
2680 if (ses->serverOS == NULL) 2773 if (ses->serverOS == NULL)
@@ -2710,8 +2803,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2710 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); 2803 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words);
2711 /* last string is not always null terminated 2804 /* last string is not always null terminated
2712 (for e.g. for Windows XP & 2000) */ 2805 (for e.g. for Windows XP & 2000) */
2713 if (ses->serverDomain) 2806 kfree(ses->serverDomain);
2714 kfree(ses->serverDomain);
2715 ses->serverDomain = 2807 ses->serverDomain =
2716 kzalloc(2*(len+1), 2808 kzalloc(2*(len+1),
2717 GFP_KERNEL); 2809 GFP_KERNEL);
@@ -2725,8 +2817,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2725 ses->serverDomain[1+(2*len)] = 0; 2817 ses->serverDomain[1+(2*len)] = 0;
2726 } else { /* else no more room so create 2818 } else { /* else no more room so create
2727 dummy domain string */ 2819 dummy domain string */
2728 if (ses->serverDomain) 2820 kfree(ses->serverDomain);
2729 kfree(ses->serverDomain);
2730 ses->serverDomain = 2821 ses->serverDomain =
2731 kzalloc(2, GFP_KERNEL); 2822 kzalloc(2, GFP_KERNEL);
2732 } 2823 }
@@ -2772,8 +2863,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2772 bcc_ptr++; 2863 bcc_ptr++;
2773 2864
2774 len = strnlen(bcc_ptr, 1024); 2865 len = strnlen(bcc_ptr, 1024);
2775 if (ses->serverDomain) 2866 kfree(ses->serverDomain);
2776 kfree(ses->serverDomain);
2777 ses->serverDomain = kzalloc(len + 1, 2867 ses->serverDomain = kzalloc(len + 1,
2778 GFP_KERNEL); 2868 GFP_KERNEL);
2779 if (ses->serverDomain == NULL) 2869 if (ses->serverDomain == NULL)
@@ -3013,8 +3103,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
3013/* We look for obvious messed up bcc or strings in response so we do not go off 3103/* We look for obvious messed up bcc or strings in response so we do not go off
3014 the end since (at least) WIN2K and Windows XP have a major bug in not null 3104 the end since (at least) WIN2K and Windows XP have a major bug in not null
3015 terminating last Unicode string in response */ 3105 terminating last Unicode string in response */
3016 if (ses->serverOS) 3106 kfree(ses->serverOS);
3017 kfree(ses->serverOS);
3018 ses->serverOS = 3107 ses->serverOS =
3019 kzalloc(2 * (len + 1), GFP_KERNEL); 3108 kzalloc(2 * (len + 1), GFP_KERNEL);
3020 cifs_strfromUCS_le(ses->serverOS, 3109 cifs_strfromUCS_le(ses->serverOS,
@@ -3086,8 +3175,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
3086 if (((long) bcc_ptr + len) - (long) 3175 if (((long) bcc_ptr + len) - (long)
3087 pByteArea(smb_buffer_response) 3176 pByteArea(smb_buffer_response)
3088 <= BCC(smb_buffer_response)) { 3177 <= BCC(smb_buffer_response)) {
3089 if (ses->serverOS) 3178 kfree(ses->serverOS);
3090 kfree(ses->serverOS);
3091 ses->serverOS = 3179 ses->serverOS =
3092 kzalloc(len + 1, 3180 kzalloc(len + 1,
3093 GFP_KERNEL); 3181 GFP_KERNEL);
@@ -3414,8 +3502,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3414/* We look for obvious messed up bcc or strings in response so we do not go off 3502/* We look for obvious messed up bcc or strings in response so we do not go off
3415 the end since (at least) WIN2K and Windows XP have a major bug in not null 3503 the end since (at least) WIN2K and Windows XP have a major bug in not null
3416 terminating last Unicode string in response */ 3504 terminating last Unicode string in response */
3417 if (ses->serverOS) 3505 kfree(ses->serverOS);
3418 kfree(ses->serverOS);
3419 ses->serverOS = 3506 ses->serverOS =
3420 kzalloc(2 * (len + 1), GFP_KERNEL); 3507 kzalloc(2 * (len + 1), GFP_KERNEL);
3421 cifs_strfromUCS_le(ses->serverOS, 3508 cifs_strfromUCS_le(ses->serverOS,
@@ -3448,8 +3535,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3448 if (remaining_words > 0) { 3535 if (remaining_words > 0) {
3449 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); 3536 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words);
3450 /* last string not always null terminated (e.g. for Windows XP & 2000) */ 3537 /* last string not always null terminated (e.g. for Windows XP & 2000) */
3451 if (ses->serverDomain) 3538 kfree(ses->serverDomain);
3452 kfree(ses->serverDomain);
3453 ses->serverDomain = 3539 ses->serverDomain =
3454 kzalloc(2 * 3540 kzalloc(2 *
3455 (len + 3541 (len +
@@ -3476,13 +3562,11 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3476 = 0; 3562 = 0;
3477 } /* else no more room so create dummy domain string */ 3563 } /* else no more room so create dummy domain string */
3478 else { 3564 else {
3479 if (ses->serverDomain) 3565 kfree(ses->serverDomain);
3480 kfree(ses->serverDomain);
3481 ses->serverDomain = kzalloc(2,GFP_KERNEL); 3566 ses->serverDomain = kzalloc(2,GFP_KERNEL);
3482 } 3567 }
3483 } else { /* no room so create dummy domain and NOS string */ 3568 } else { /* no room so create dummy domain and NOS string */
3484 if (ses->serverDomain) 3569 kfree(ses->serverDomain);
3485 kfree(ses->serverDomain);
3486 ses->serverDomain = kzalloc(2, GFP_KERNEL); 3570 ses->serverDomain = kzalloc(2, GFP_KERNEL);
3487 kfree(ses->serverNOS); 3571 kfree(ses->serverNOS);
3488 ses->serverNOS = kzalloc(2, GFP_KERNEL); 3572 ses->serverNOS = kzalloc(2, GFP_KERNEL);
@@ -3492,8 +3576,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3492 if (((long) bcc_ptr + len) - 3576 if (((long) bcc_ptr + len) -
3493 (long) pByteArea(smb_buffer_response) 3577 (long) pByteArea(smb_buffer_response)
3494 <= BCC(smb_buffer_response)) { 3578 <= BCC(smb_buffer_response)) {
3495 if (ses->serverOS) 3579 kfree(ses->serverOS);
3496 kfree(ses->serverOS);
3497 ses->serverOS = kzalloc(len + 1, GFP_KERNEL); 3580 ses->serverOS = kzalloc(len + 1, GFP_KERNEL);
3498 strncpy(ses->serverOS,bcc_ptr, len); 3581 strncpy(ses->serverOS,bcc_ptr, len);
3499 3582
@@ -3512,8 +3595,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
3512 bcc_ptr++; 3595 bcc_ptr++;
3513 3596
3514 len = strnlen(bcc_ptr, 1024); 3597 len = strnlen(bcc_ptr, 1024);
3515 if (ses->serverDomain) 3598 kfree(ses->serverDomain);
3516 kfree(ses->serverDomain);
3517 ses->serverDomain = 3599 ses->serverDomain =
3518 kzalloc(len+1, 3600 kzalloc(len+1,
3519 GFP_KERNEL); 3601 GFP_KERNEL);
@@ -3674,16 +3756,15 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
3674 BCC(smb_buffer_response)) { 3756 BCC(smb_buffer_response)) {
3675 kfree(tcon->nativeFileSystem); 3757 kfree(tcon->nativeFileSystem);
3676 tcon->nativeFileSystem = 3758 tcon->nativeFileSystem =
3677 kzalloc(2*(length + 1), GFP_KERNEL); 3759 kzalloc((4 * length) + 2, GFP_KERNEL);
3678 if (tcon->nativeFileSystem) 3760 if (tcon->nativeFileSystem) {
3679 cifs_strfromUCS_le( 3761 cifs_strfromUCS_le(
3680 tcon->nativeFileSystem, 3762 tcon->nativeFileSystem,
3681 (__le16 *) bcc_ptr, 3763 (__le16 *) bcc_ptr,
3682 length, nls_codepage); 3764 length, nls_codepage);
3683 bcc_ptr += 2 * length; 3765 cFYI(1, ("nativeFileSystem=%s",
3684 bcc_ptr[0] = 0; /* null terminate the string */ 3766 tcon->nativeFileSystem));
3685 bcc_ptr[1] = 0; 3767 }
3686 bcc_ptr += 2;
3687 } 3768 }
3688 /* else do not bother copying these information fields*/ 3769 /* else do not bother copying these information fields*/
3689 } else { 3770 } else {
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 54dce78fbb73..461750e01364 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -129,12 +129,62 @@ cifs_bp_rename_retry:
129 return full_path; 129 return full_path;
130} 130}
131 131
132static void
133cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle,
134 struct cifsTconInfo *tcon, bool write_only)
135{
136 int oplock = 0;
137 struct cifsFileInfo *pCifsFile;
138 struct cifsInodeInfo *pCifsInode;
139
140 pCifsFile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
141
142 if (pCifsFile == NULL)
143 return;
144
145 if (oplockEnabled)
146 oplock = REQ_OPLOCK;
147
148 pCifsFile->netfid = fileHandle;
149 pCifsFile->pid = current->tgid;
150 pCifsFile->pInode = newinode;
151 pCifsFile->invalidHandle = false;
152 pCifsFile->closePend = false;
153 mutex_init(&pCifsFile->fh_mutex);
154 mutex_init(&pCifsFile->lock_mutex);
155 INIT_LIST_HEAD(&pCifsFile->llist);
156 atomic_set(&pCifsFile->wrtPending, 0);
157
158 /* set the following in open now
159 pCifsFile->pfile = file; */
160 write_lock(&GlobalSMBSeslock);
161 list_add(&pCifsFile->tlist, &tcon->openFileList);
162 pCifsInode = CIFS_I(newinode);
163 if (pCifsInode) {
164 /* if readable file instance put first in list*/
165 if (write_only)
166 list_add_tail(&pCifsFile->flist,
167 &pCifsInode->openFileList);
168 else
169 list_add(&pCifsFile->flist, &pCifsInode->openFileList);
170
171 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
172 pCifsInode->clientCanCacheAll = true;
173 pCifsInode->clientCanCacheRead = true;
174 cFYI(1, ("Exclusive Oplock inode %p", newinode));
175 } else if ((oplock & 0xF) == OPLOCK_READ)
176 pCifsInode->clientCanCacheRead = true;
177 }
178 write_unlock(&GlobalSMBSeslock);
179}
180
132int cifs_posix_open(char *full_path, struct inode **pinode, 181int cifs_posix_open(char *full_path, struct inode **pinode,
133 struct super_block *sb, int mode, int oflags, 182 struct super_block *sb, int mode, int oflags,
134 int *poplock, __u16 *pnetfid, int xid) 183 int *poplock, __u16 *pnetfid, int xid)
135{ 184{
136 int rc; 185 int rc;
137 __u32 oplock; 186 __u32 oplock;
187 bool write_only = false;
138 FILE_UNIX_BASIC_INFO *presp_data; 188 FILE_UNIX_BASIC_INFO *presp_data;
139 __u32 posix_flags = 0; 189 __u32 posix_flags = 0;
140 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 190 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
@@ -172,6 +222,8 @@ int cifs_posix_open(char *full_path, struct inode **pinode,
172 if (oflags & O_DIRECT) 222 if (oflags & O_DIRECT)
173 posix_flags |= SMB_O_DIRECT; 223 posix_flags |= SMB_O_DIRECT;
174 224
225 if (!(oflags & FMODE_READ))
226 write_only = true;
175 227
176 rc = CIFSPOSIXCreate(xid, cifs_sb->tcon, posix_flags, mode, 228 rc = CIFSPOSIXCreate(xid, cifs_sb->tcon, posix_flags, mode,
177 pnetfid, presp_data, &oplock, full_path, 229 pnetfid, presp_data, &oplock, full_path,
@@ -187,8 +239,10 @@ int cifs_posix_open(char *full_path, struct inode **pinode,
187 if (!pinode) 239 if (!pinode)
188 goto posix_open_ret; /* caller does not need info */ 240 goto posix_open_ret; /* caller does not need info */
189 241
190 if (*pinode == NULL) 242 if (*pinode == NULL) {
191 *pinode = cifs_new_inode(sb, &presp_data->UniqueId); 243 __u64 unique_id = le64_to_cpu(presp_data->UniqueId);
244 *pinode = cifs_new_inode(sb, &unique_id);
245 }
192 /* else an inode was passed in. Update its info, don't create one */ 246 /* else an inode was passed in. Update its info, don't create one */
193 247
194 /* We do not need to close the file if new_inode fails since 248 /* We do not need to close the file if new_inode fails since
@@ -198,6 +252,8 @@ int cifs_posix_open(char *full_path, struct inode **pinode,
198 252
199 posix_fill_in_inode(*pinode, presp_data, 1); 253 posix_fill_in_inode(*pinode, presp_data, 1);
200 254
255 cifs_fill_fileinfo(*pinode, *pnetfid, cifs_sb->tcon, write_only);
256
201posix_open_ret: 257posix_open_ret:
202 kfree(presp_data); 258 kfree(presp_data);
203 return rc; 259 return rc;
@@ -239,7 +295,6 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
239 char *full_path = NULL; 295 char *full_path = NULL;
240 FILE_ALL_INFO *buf = NULL; 296 FILE_ALL_INFO *buf = NULL;
241 struct inode *newinode = NULL; 297 struct inode *newinode = NULL;
242 struct cifsInodeInfo *pCifsInode;
243 int disposition = FILE_OVERWRITE_IF; 298 int disposition = FILE_OVERWRITE_IF;
244 bool write_only = false; 299 bool write_only = false;
245 300
@@ -410,44 +465,8 @@ cifs_create_set_dentry:
410 /* mknod case - do not leave file open */ 465 /* mknod case - do not leave file open */
411 CIFSSMBClose(xid, tcon, fileHandle); 466 CIFSSMBClose(xid, tcon, fileHandle);
412 } else if (newinode) { 467 } else if (newinode) {
413 struct cifsFileInfo *pCifsFile = 468 cifs_fill_fileinfo(newinode, fileHandle,
414 kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL); 469 cifs_sb->tcon, write_only);
415
416 if (pCifsFile == NULL)
417 goto cifs_create_out;
418 pCifsFile->netfid = fileHandle;
419 pCifsFile->pid = current->tgid;
420 pCifsFile->pInode = newinode;
421 pCifsFile->invalidHandle = false;
422 pCifsFile->closePend = false;
423 init_MUTEX(&pCifsFile->fh_sem);
424 mutex_init(&pCifsFile->lock_mutex);
425 INIT_LIST_HEAD(&pCifsFile->llist);
426 atomic_set(&pCifsFile->wrtPending, 0);
427
428 /* set the following in open now
429 pCifsFile->pfile = file; */
430 write_lock(&GlobalSMBSeslock);
431 list_add(&pCifsFile->tlist, &tcon->openFileList);
432 pCifsInode = CIFS_I(newinode);
433 if (pCifsInode) {
434 /* if readable file instance put first in list*/
435 if (write_only) {
436 list_add_tail(&pCifsFile->flist,
437 &pCifsInode->openFileList);
438 } else {
439 list_add(&pCifsFile->flist,
440 &pCifsInode->openFileList);
441 }
442 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
443 pCifsInode->clientCanCacheAll = true;
444 pCifsInode->clientCanCacheRead = true;
445 cFYI(1, ("Exclusive Oplock inode %p",
446 newinode));
447 } else if ((oplock & 0xF) == OPLOCK_READ)
448 pCifsInode->clientCanCacheRead = true;
449 }
450 write_unlock(&GlobalSMBSeslock);
451 } 470 }
452cifs_create_out: 471cifs_create_out:
453 kfree(buf); 472 kfree(buf);
@@ -580,17 +599,21 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
580 return rc; 599 return rc;
581} 600}
582 601
583
584struct dentry * 602struct dentry *
585cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, 603cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
586 struct nameidata *nd) 604 struct nameidata *nd)
587{ 605{
588 int xid; 606 int xid;
589 int rc = 0; /* to get around spurious gcc warning, set to zero here */ 607 int rc = 0; /* to get around spurious gcc warning, set to zero here */
608 int oplock = 0;
609 int mode;
610 __u16 fileHandle = 0;
611 bool posix_open = false;
590 struct cifs_sb_info *cifs_sb; 612 struct cifs_sb_info *cifs_sb;
591 struct cifsTconInfo *pTcon; 613 struct cifsTconInfo *pTcon;
592 struct inode *newInode = NULL; 614 struct inode *newInode = NULL;
593 char *full_path = NULL; 615 char *full_path = NULL;
616 struct file *filp;
594 617
595 xid = GetXid(); 618 xid = GetXid();
596 619
@@ -632,12 +655,37 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
632 } 655 }
633 cFYI(1, ("Full path: %s inode = 0x%p", full_path, direntry->d_inode)); 656 cFYI(1, ("Full path: %s inode = 0x%p", full_path, direntry->d_inode));
634 657
635 if (pTcon->unix_ext) 658 if (pTcon->unix_ext) {
636 rc = cifs_get_inode_info_unix(&newInode, full_path, 659 if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY)) &&
637 parent_dir_inode->i_sb, xid); 660 (nd->flags & LOOKUP_OPEN)) {
638 else 661 if (!((nd->intent.open.flags & O_CREAT) &&
662 (nd->intent.open.flags & O_EXCL))) {
663 mode = nd->intent.open.create_mode &
664 ~current_umask();
665 rc = cifs_posix_open(full_path, &newInode,
666 parent_dir_inode->i_sb, mode,
667 nd->intent.open.flags, &oplock,
668 &fileHandle, xid);
669 /*
670 * This code works around a bug in
671 * samba posix open in samba versions 3.3.1
672 * and earlier where create works
673 * but open fails with invalid parameter.
674 * If either of these error codes are
675 * returned, follow the normal lookup.
676 * Otherwise, the error during posix open
677 * is handled.
678 */
679 if ((rc != -EINVAL) && (rc != -EOPNOTSUPP))
680 posix_open = true;
681 }
682 }
683 if (!posix_open)
684 rc = cifs_get_inode_info_unix(&newInode, full_path,
685 parent_dir_inode->i_sb, xid);
686 } else
639 rc = cifs_get_inode_info(&newInode, full_path, NULL, 687 rc = cifs_get_inode_info(&newInode, full_path, NULL,
640 parent_dir_inode->i_sb, xid, NULL); 688 parent_dir_inode->i_sb, xid, NULL);
641 689
642 if ((rc == 0) && (newInode != NULL)) { 690 if ((rc == 0) && (newInode != NULL)) {
643 if (pTcon->nocase) 691 if (pTcon->nocase)
@@ -645,7 +693,8 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
645 else 693 else
646 direntry->d_op = &cifs_dentry_ops; 694 direntry->d_op = &cifs_dentry_ops;
647 d_add(direntry, newInode); 695 d_add(direntry, newInode);
648 696 if (posix_open)
697 filp = lookup_instantiate_filp(nd, direntry, NULL);
649 /* since paths are not looked up by component - the parent 698 /* since paths are not looked up by component - the parent
650 directories are presumed to be good here */ 699 directories are presumed to be good here */
651 renew_parental_timestamps(direntry); 700 renew_parental_timestamps(direntry);
diff --git a/fs/cifs/dns_resolve.c b/fs/cifs/dns_resolve.c
index 1e0c1bd8f2e4..df4a306f697e 100644
--- a/fs/cifs/dns_resolve.c
+++ b/fs/cifs/dns_resolve.c
@@ -78,7 +78,7 @@ dns_resolver_instantiate(struct key *key, const void *data,
78 } 78 }
79 79
80 key->type_data.x[0] = datalen; 80 key->type_data.x[0] = datalen;
81 rcu_assign_pointer(key->payload.data, ip); 81 key->payload.data = ip;
82 82
83 return rc; 83 return rc;
84} 84}
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 81747acca4c4..50ca088d8860 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -46,7 +46,7 @@ static inline struct cifsFileInfo *cifs_init_private(
46 memset(private_data, 0, sizeof(struct cifsFileInfo)); 46 memset(private_data, 0, sizeof(struct cifsFileInfo));
47 private_data->netfid = netfid; 47 private_data->netfid = netfid;
48 private_data->pid = current->tgid; 48 private_data->pid = current->tgid;
49 init_MUTEX(&private_data->fh_sem); 49 mutex_init(&private_data->fh_mutex);
50 mutex_init(&private_data->lock_mutex); 50 mutex_init(&private_data->lock_mutex);
51 INIT_LIST_HEAD(&private_data->llist); 51 INIT_LIST_HEAD(&private_data->llist);
52 private_data->pfile = file; /* needed for writepage */ 52 private_data->pfile = file; /* needed for writepage */
@@ -284,35 +284,32 @@ int cifs_open(struct inode *inode, struct file *file)
284 cifs_sb = CIFS_SB(inode->i_sb); 284 cifs_sb = CIFS_SB(inode->i_sb);
285 tcon = cifs_sb->tcon; 285 tcon = cifs_sb->tcon;
286 286
287 if (file->f_flags & O_CREAT) { 287 /* search inode for this file and fill in file->private_data */
288 /* search inode for this file and fill in file->private_data */ 288 pCifsInode = CIFS_I(file->f_path.dentry->d_inode);
289 pCifsInode = CIFS_I(file->f_path.dentry->d_inode); 289 read_lock(&GlobalSMBSeslock);
290 read_lock(&GlobalSMBSeslock); 290 list_for_each(tmp, &pCifsInode->openFileList) {
291 list_for_each(tmp, &pCifsInode->openFileList) { 291 pCifsFile = list_entry(tmp, struct cifsFileInfo,
292 pCifsFile = list_entry(tmp, struct cifsFileInfo, 292 flist);
293 flist); 293 if ((pCifsFile->pfile == NULL) &&
294 if ((pCifsFile->pfile == NULL) && 294 (pCifsFile->pid == current->tgid)) {
295 (pCifsFile->pid == current->tgid)) { 295 /* mode set in cifs_create */
296 /* mode set in cifs_create */ 296
297 297 /* needed for writepage */
298 /* needed for writepage */ 298 pCifsFile->pfile = file;
299 pCifsFile->pfile = file; 299
300 300 file->private_data = pCifsFile;
301 file->private_data = pCifsFile; 301 break;
302 break;
303 }
304 }
305 read_unlock(&GlobalSMBSeslock);
306 if (file->private_data != NULL) {
307 rc = 0;
308 FreeXid(xid);
309 return rc;
310 } else {
311 if (file->f_flags & O_EXCL)
312 cERROR(1, ("could not find file instance for "
313 "new file %p", file));
314 } 302 }
315 } 303 }
304 read_unlock(&GlobalSMBSeslock);
305
306 if (file->private_data != NULL) {
307 rc = 0;
308 FreeXid(xid);
309 return rc;
310 } else if ((file->f_flags & O_CREAT) && (file->f_flags & O_EXCL))
311 cERROR(1, ("could not find file instance for "
312 "new file %p", file));
316 313
317 full_path = build_path_from_dentry(file->f_path.dentry); 314 full_path = build_path_from_dentry(file->f_path.dentry);
318 if (full_path == NULL) { 315 if (full_path == NULL) {
@@ -500,9 +497,9 @@ static int cifs_reopen_file(struct file *file, bool can_flush)
500 return -EBADF; 497 return -EBADF;
501 498
502 xid = GetXid(); 499 xid = GetXid();
503 down(&pCifsFile->fh_sem); 500 mutex_unlock(&pCifsFile->fh_mutex);
504 if (!pCifsFile->invalidHandle) { 501 if (!pCifsFile->invalidHandle) {
505 up(&pCifsFile->fh_sem); 502 mutex_lock(&pCifsFile->fh_mutex);
506 FreeXid(xid); 503 FreeXid(xid);
507 return 0; 504 return 0;
508 } 505 }
@@ -533,7 +530,7 @@ static int cifs_reopen_file(struct file *file, bool can_flush)
533 if (full_path == NULL) { 530 if (full_path == NULL) {
534 rc = -ENOMEM; 531 rc = -ENOMEM;
535reopen_error_exit: 532reopen_error_exit:
536 up(&pCifsFile->fh_sem); 533 mutex_lock(&pCifsFile->fh_mutex);
537 FreeXid(xid); 534 FreeXid(xid);
538 return rc; 535 return rc;
539 } 536 }
@@ -575,14 +572,14 @@ reopen_error_exit:
575 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & 572 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
576 CIFS_MOUNT_MAP_SPECIAL_CHR); 573 CIFS_MOUNT_MAP_SPECIAL_CHR);
577 if (rc) { 574 if (rc) {
578 up(&pCifsFile->fh_sem); 575 mutex_lock(&pCifsFile->fh_mutex);
579 cFYI(1, ("cifs_open returned 0x%x", rc)); 576 cFYI(1, ("cifs_open returned 0x%x", rc));
580 cFYI(1, ("oplock: %d", oplock)); 577 cFYI(1, ("oplock: %d", oplock));
581 } else { 578 } else {
582reopen_success: 579reopen_success:
583 pCifsFile->netfid = netfid; 580 pCifsFile->netfid = netfid;
584 pCifsFile->invalidHandle = false; 581 pCifsFile->invalidHandle = false;
585 up(&pCifsFile->fh_sem); 582 mutex_lock(&pCifsFile->fh_mutex);
586 pCifsInode = CIFS_I(inode); 583 pCifsInode = CIFS_I(inode);
587 if (pCifsInode) { 584 if (pCifsInode) {
588 if (can_flush) { 585 if (can_flush) {
@@ -971,6 +968,40 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
971 return rc; 968 return rc;
972} 969}
973 970
971/*
972 * Set the timeout on write requests past EOF. For some servers (Windows)
973 * these calls can be very long.
974 *
975 * If we're writing >10M past the EOF we give a 180s timeout. Anything less
976 * than that gets a 45s timeout. Writes not past EOF get 15s timeouts.
977 * The 10M cutoff is totally arbitrary. A better scheme for this would be
978 * welcome if someone wants to suggest one.
979 *
980 * We may be able to do a better job with this if there were some way to
981 * declare that a file should be sparse.
982 */
983static int
984cifs_write_timeout(struct cifsInodeInfo *cifsi, loff_t offset)
985{
986 if (offset <= cifsi->server_eof)
987 return CIFS_STD_OP;
988 else if (offset > (cifsi->server_eof + (10 * 1024 * 1024)))
989 return CIFS_VLONG_OP;
990 else
991 return CIFS_LONG_OP;
992}
993
994/* update the file size (if needed) after a write */
995static void
996cifs_update_eof(struct cifsInodeInfo *cifsi, loff_t offset,
997 unsigned int bytes_written)
998{
999 loff_t end_of_write = offset + bytes_written;
1000
1001 if (end_of_write > cifsi->server_eof)
1002 cifsi->server_eof = end_of_write;
1003}
1004
974ssize_t cifs_user_write(struct file *file, const char __user *write_data, 1005ssize_t cifs_user_write(struct file *file, const char __user *write_data,
975 size_t write_size, loff_t *poffset) 1006 size_t write_size, loff_t *poffset)
976{ 1007{
@@ -981,6 +1012,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
981 struct cifsTconInfo *pTcon; 1012 struct cifsTconInfo *pTcon;
982 int xid, long_op; 1013 int xid, long_op;
983 struct cifsFileInfo *open_file; 1014 struct cifsFileInfo *open_file;
1015 struct cifsInodeInfo *cifsi = CIFS_I(file->f_path.dentry->d_inode);
984 1016
985 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1017 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
986 1018
@@ -1000,11 +1032,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
1000 1032
1001 xid = GetXid(); 1033 xid = GetXid();
1002 1034
1003 if (*poffset > file->f_path.dentry->d_inode->i_size) 1035 long_op = cifs_write_timeout(cifsi, *poffset);
1004 long_op = CIFS_VLONG_OP; /* writes past EOF take long time */
1005 else
1006 long_op = CIFS_LONG_OP;
1007
1008 for (total_written = 0; write_size > total_written; 1036 for (total_written = 0; write_size > total_written;
1009 total_written += bytes_written) { 1037 total_written += bytes_written) {
1010 rc = -EAGAIN; 1038 rc = -EAGAIN;
@@ -1048,8 +1076,10 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
1048 FreeXid(xid); 1076 FreeXid(xid);
1049 return rc; 1077 return rc;
1050 } 1078 }
1051 } else 1079 } else {
1080 cifs_update_eof(cifsi, *poffset, bytes_written);
1052 *poffset += bytes_written; 1081 *poffset += bytes_written;
1082 }
1053 long_op = CIFS_STD_OP; /* subsequent writes fast - 1083 long_op = CIFS_STD_OP; /* subsequent writes fast -
1054 15 seconds is plenty */ 1084 15 seconds is plenty */
1055 } 1085 }
@@ -1085,6 +1115,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
1085 struct cifsTconInfo *pTcon; 1115 struct cifsTconInfo *pTcon;
1086 int xid, long_op; 1116 int xid, long_op;
1087 struct cifsFileInfo *open_file; 1117 struct cifsFileInfo *open_file;
1118 struct cifsInodeInfo *cifsi = CIFS_I(file->f_path.dentry->d_inode);
1088 1119
1089 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1120 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
1090 1121
@@ -1099,11 +1130,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
1099 1130
1100 xid = GetXid(); 1131 xid = GetXid();
1101 1132
1102 if (*poffset > file->f_path.dentry->d_inode->i_size) 1133 long_op = cifs_write_timeout(cifsi, *poffset);
1103 long_op = CIFS_VLONG_OP; /* writes past EOF can be slow */
1104 else
1105 long_op = CIFS_LONG_OP;
1106
1107 for (total_written = 0; write_size > total_written; 1134 for (total_written = 0; write_size > total_written;
1108 total_written += bytes_written) { 1135 total_written += bytes_written) {
1109 rc = -EAGAIN; 1136 rc = -EAGAIN;
@@ -1166,8 +1193,10 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
1166 FreeXid(xid); 1193 FreeXid(xid);
1167 return rc; 1194 return rc;
1168 } 1195 }
1169 } else 1196 } else {
1197 cifs_update_eof(cifsi, *poffset, bytes_written);
1170 *poffset += bytes_written; 1198 *poffset += bytes_written;
1199 }
1171 long_op = CIFS_STD_OP; /* subsequent writes fast - 1200 long_op = CIFS_STD_OP; /* subsequent writes fast -
1172 15 seconds is plenty */ 1201 15 seconds is plenty */
1173 } 1202 }
@@ -1380,11 +1409,12 @@ static int cifs_writepages(struct address_space *mapping,
1380 int nr_pages; 1409 int nr_pages;
1381 __u64 offset = 0; 1410 __u64 offset = 0;
1382 struct cifsFileInfo *open_file; 1411 struct cifsFileInfo *open_file;
1412 struct cifsInodeInfo *cifsi = CIFS_I(mapping->host);
1383 struct page *page; 1413 struct page *page;
1384 struct pagevec pvec; 1414 struct pagevec pvec;
1385 int rc = 0; 1415 int rc = 0;
1386 int scanned = 0; 1416 int scanned = 0;
1387 int xid; 1417 int xid, long_op;
1388 1418
1389 cifs_sb = CIFS_SB(mapping->host->i_sb); 1419 cifs_sb = CIFS_SB(mapping->host->i_sb);
1390 1420
@@ -1528,12 +1558,15 @@ retry:
1528 cERROR(1, ("No writable handles for inode")); 1558 cERROR(1, ("No writable handles for inode"));
1529 rc = -EBADF; 1559 rc = -EBADF;
1530 } else { 1560 } else {
1561 long_op = cifs_write_timeout(cifsi, offset);
1531 rc = CIFSSMBWrite2(xid, cifs_sb->tcon, 1562 rc = CIFSSMBWrite2(xid, cifs_sb->tcon,
1532 open_file->netfid, 1563 open_file->netfid,
1533 bytes_to_write, offset, 1564 bytes_to_write, offset,
1534 &bytes_written, iov, n_iov, 1565 &bytes_written, iov, n_iov,
1535 CIFS_LONG_OP); 1566 long_op);
1536 atomic_dec(&open_file->wrtPending); 1567 atomic_dec(&open_file->wrtPending);
1568 cifs_update_eof(cifsi, offset, bytes_written);
1569
1537 if (rc || bytes_written < bytes_to_write) { 1570 if (rc || bytes_written < bytes_to_write) {
1538 cERROR(1, ("Write2 ret %d, wrote %d", 1571 cERROR(1, ("Write2 ret %d, wrote %d",
1539 rc, bytes_written)); 1572 rc, bytes_written));
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index f121a80fdd6f..f36b4e40e443 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -143,6 +143,7 @@ static void cifs_unix_info_to_inode(struct inode *inode,
143 143
144 inode->i_nlink = le64_to_cpu(info->Nlinks); 144 inode->i_nlink = le64_to_cpu(info->Nlinks);
145 145
146 cifsInfo->server_eof = end_of_file;
146 spin_lock(&inode->i_lock); 147 spin_lock(&inode->i_lock);
147 if (is_size_safe_to_change(cifsInfo, end_of_file)) { 148 if (is_size_safe_to_change(cifsInfo, end_of_file)) {
148 /* 149 /*
@@ -276,7 +277,8 @@ int cifs_get_inode_info_unix(struct inode **pinode,
276 277
277 /* get new inode */ 278 /* get new inode */
278 if (*pinode == NULL) { 279 if (*pinode == NULL) {
279 *pinode = cifs_new_inode(sb, &find_data.UniqueId); 280 __u64 unique_id = le64_to_cpu(find_data.UniqueId);
281 *pinode = cifs_new_inode(sb, &unique_id);
280 if (*pinode == NULL) { 282 if (*pinode == NULL) {
281 rc = -ENOMEM; 283 rc = -ENOMEM;
282 goto cgiiu_exit; 284 goto cgiiu_exit;
@@ -605,12 +607,12 @@ int cifs_get_inode_info(struct inode **pinode,
605 inode->i_mode |= S_IFREG; 607 inode->i_mode |= S_IFREG;
606 } 608 }
607 609
610 cifsInfo->server_eof = le64_to_cpu(pfindData->EndOfFile);
608 spin_lock(&inode->i_lock); 611 spin_lock(&inode->i_lock);
609 if (is_size_safe_to_change(cifsInfo, 612 if (is_size_safe_to_change(cifsInfo, cifsInfo->server_eof)) {
610 le64_to_cpu(pfindData->EndOfFile))) {
611 /* can not safely shrink the file size here if the 613 /* can not safely shrink the file size here if the
612 client is writing to it due to potential races */ 614 client is writing to it due to potential races */
613 i_size_write(inode, le64_to_cpu(pfindData->EndOfFile)); 615 i_size_write(inode, cifsInfo->server_eof);
614 616
615 /* 512 bytes (2**9) is the fake blocksize that must be 617 /* 512 bytes (2**9) is the fake blocksize that must be
616 used for this calculation */ 618 used for this calculation */
@@ -1138,6 +1140,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
1138 cFYI(1, ("posix mkdir returned 0x%x", rc)); 1140 cFYI(1, ("posix mkdir returned 0x%x", rc));
1139 d_drop(direntry); 1141 d_drop(direntry);
1140 } else { 1142 } else {
1143 __u64 unique_id;
1141 if (pInfo->Type == cpu_to_le32(-1)) { 1144 if (pInfo->Type == cpu_to_le32(-1)) {
1142 /* no return info, go query for it */ 1145 /* no return info, go query for it */
1143 kfree(pInfo); 1146 kfree(pInfo);
@@ -1151,8 +1154,8 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
1151 else 1154 else
1152 direntry->d_op = &cifs_dentry_ops; 1155 direntry->d_op = &cifs_dentry_ops;
1153 1156
1154 newinode = cifs_new_inode(inode->i_sb, 1157 unique_id = le64_to_cpu(pInfo->UniqueId);
1155 &pInfo->UniqueId); 1158 newinode = cifs_new_inode(inode->i_sb, &unique_id);
1156 if (newinode == NULL) { 1159 if (newinode == NULL) {
1157 kfree(pInfo); 1160 kfree(pInfo);
1158 goto mkdir_get_info; 1161 goto mkdir_get_info;
@@ -1450,7 +1453,8 @@ int cifs_rename(struct inode *source_dir, struct dentry *source_dentry,
1450 checking the UniqueId via FILE_INTERNAL_INFO */ 1453 checking the UniqueId via FILE_INTERNAL_INFO */
1451 1454
1452unlink_target: 1455unlink_target:
1453 if ((rc == -EACCES) || (rc == -EEXIST)) { 1456 /* Try unlinking the target dentry if it's not negative */
1457 if (target_dentry->d_inode && (rc == -EACCES || rc == -EEXIST)) {
1454 tmprc = cifs_unlink(target_dir, target_dentry); 1458 tmprc = cifs_unlink(target_dir, target_dentry);
1455 if (tmprc) 1459 if (tmprc)
1456 goto cifs_rename_exit; 1460 goto cifs_rename_exit;
@@ -1753,6 +1757,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
1753 } 1757 }
1754 1758
1755 if (rc == 0) { 1759 if (rc == 0) {
1760 cifsInode->server_eof = attrs->ia_size;
1756 rc = cifs_vmtruncate(inode, attrs->ia_size); 1761 rc = cifs_vmtruncate(inode, attrs->ia_size);
1757 cifs_truncate_page(inode->i_mapping, inode->i_size); 1762 cifs_truncate_page(inode->i_mapping, inode->i_size);
1758 } 1763 }
@@ -1792,20 +1797,21 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
1792 goto out; 1797 goto out;
1793 } 1798 }
1794 1799
1795 if ((attrs->ia_valid & ATTR_MTIME) || (attrs->ia_valid & ATTR_SIZE)) { 1800 /*
1796 /* 1801 * Attempt to flush data before changing attributes. We need to do
1797 Flush data before changing file size or changing the last 1802 * this for ATTR_SIZE and ATTR_MTIME for sure, and if we change the
1798 write time of the file on the server. If the 1803 * ownership or mode then we may also need to do this. Here, we take
1799 flush returns error, store it to report later and continue. 1804 * the safe way out and just do the flush on all setattr requests. If
1800 BB: This should be smarter. Why bother flushing pages that 1805 * the flush returns error, store it to report later and continue.
1801 will be truncated anyway? Also, should we error out here if 1806 *
1802 the flush returns error? 1807 * BB: This should be smarter. Why bother flushing pages that
1803 */ 1808 * will be truncated anyway? Also, should we error out here if
1804 rc = filemap_write_and_wait(inode->i_mapping); 1809 * the flush returns error?
1805 if (rc != 0) { 1810 */
1806 cifsInode->write_behind_rc = rc; 1811 rc = filemap_write_and_wait(inode->i_mapping);
1807 rc = 0; 1812 if (rc != 0) {
1808 } 1813 cifsInode->write_behind_rc = rc;
1814 rc = 0;
1809 } 1815 }
1810 1816
1811 if (attrs->ia_valid & ATTR_SIZE) { 1817 if (attrs->ia_valid & ATTR_SIZE) {
@@ -1903,20 +1909,21 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
1903 return -ENOMEM; 1909 return -ENOMEM;
1904 } 1910 }
1905 1911
1906 if ((attrs->ia_valid & ATTR_MTIME) || (attrs->ia_valid & ATTR_SIZE)) { 1912 /*
1907 /* 1913 * Attempt to flush data before changing attributes. We need to do
1908 Flush data before changing file size or changing the last 1914 * this for ATTR_SIZE and ATTR_MTIME for sure, and if we change the
1909 write time of the file on the server. If the 1915 * ownership or mode then we may also need to do this. Here, we take
1910 flush returns error, store it to report later and continue. 1916 * the safe way out and just do the flush on all setattr requests. If
1911 BB: This should be smarter. Why bother flushing pages that 1917 * the flush returns error, store it to report later and continue.
1912 will be truncated anyway? Also, should we error out here if 1918 *
1913 the flush returns error? 1919 * BB: This should be smarter. Why bother flushing pages that
1914 */ 1920 * will be truncated anyway? Also, should we error out here if
1915 rc = filemap_write_and_wait(inode->i_mapping); 1921 * the flush returns error?
1916 if (rc != 0) { 1922 */
1917 cifsInode->write_behind_rc = rc; 1923 rc = filemap_write_and_wait(inode->i_mapping);
1918 rc = 0; 1924 if (rc != 0) {
1919 } 1925 cifsInode->write_behind_rc = rc;
1926 rc = 0;
1920 } 1927 }
1921 1928
1922 if (attrs->ia_valid & ATTR_SIZE) { 1929 if (attrs->ia_valid & ATTR_SIZE) {
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index c2c01ff4c32c..1a8be6228333 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -239,6 +239,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
239 if (atomic_read(&cifsInfo->inUse) == 0) 239 if (atomic_read(&cifsInfo->inUse) == 0)
240 atomic_set(&cifsInfo->inUse, 1); 240 atomic_set(&cifsInfo->inUse, 1);
241 241
242 cifsInfo->server_eof = end_of_file;
242 spin_lock(&tmp_inode->i_lock); 243 spin_lock(&tmp_inode->i_lock);
243 if (is_size_safe_to_change(cifsInfo, end_of_file)) { 244 if (is_size_safe_to_change(cifsInfo, end_of_file)) {
244 /* can not safely change the file size here if the 245 /* can not safely change the file size here if the
@@ -375,6 +376,7 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
375 tmp_inode->i_gid = le64_to_cpu(pfindData->Gid); 376 tmp_inode->i_gid = le64_to_cpu(pfindData->Gid);
376 tmp_inode->i_nlink = le64_to_cpu(pfindData->Nlinks); 377 tmp_inode->i_nlink = le64_to_cpu(pfindData->Nlinks);
377 378
379 cifsInfo->server_eof = end_of_file;
378 spin_lock(&tmp_inode->i_lock); 380 spin_lock(&tmp_inode->i_lock);
379 if (is_size_safe_to_change(cifsInfo, end_of_file)) { 381 if (is_size_safe_to_change(cifsInfo, end_of_file)) {
380 /* can not safely change the file size here if the 382 /* can not safely change the file size here if the
@@ -840,7 +842,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
840 len = strnlen(filename, PATH_MAX); 842 len = strnlen(filename, PATH_MAX);
841 } 843 }
842 844
843 *pinum = pFindData->UniqueId; 845 *pinum = le64_to_cpu(pFindData->UniqueId);
844 } else if (level == SMB_FIND_FILE_DIRECTORY_INFO) { 846 } else if (level == SMB_FIND_FILE_DIRECTORY_INFO) {
845 FILE_DIRECTORY_INFO *pFindData = 847 FILE_DIRECTORY_INFO *pFindData =
846 (FILE_DIRECTORY_INFO *)current_entry; 848 (FILE_DIRECTORY_INFO *)current_entry;
@@ -856,7 +858,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
856 (SEARCH_ID_FULL_DIR_INFO *)current_entry; 858 (SEARCH_ID_FULL_DIR_INFO *)current_entry;
857 filename = &pFindData->FileName[0]; 859 filename = &pFindData->FileName[0];
858 len = le32_to_cpu(pFindData->FileNameLength); 860 len = le32_to_cpu(pFindData->FileNameLength);
859 *pinum = pFindData->UniqueId; 861 *pinum = le64_to_cpu(pFindData->UniqueId);
860 } else if (level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) { 862 } else if (level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
861 FILE_BOTH_DIRECTORY_INFO *pFindData = 863 FILE_BOTH_DIRECTORY_INFO *pFindData =
862 (FILE_BOTH_DIRECTORY_INFO *)current_entry; 864 (FILE_BOTH_DIRECTORY_INFO *)current_entry;
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index 5c68b4282be9..c652c73760dd 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -285,35 +285,36 @@ static int decode_unicode_ssetup(char **pbcc_area, int bleft,
285 int words_left, len; 285 int words_left, len;
286 char *data = *pbcc_area; 286 char *data = *pbcc_area;
287 287
288
289
290 cFYI(1, ("bleft %d", bleft)); 288 cFYI(1, ("bleft %d", bleft));
291 289
292 290 /*
293 /* SMB header is unaligned, so cifs servers word align start of 291 * Windows servers do not always double null terminate their final
294 Unicode strings */ 292 * Unicode string. Check to see if there are an uneven number of bytes
295 data++; 293 * left. If so, then add an extra NULL pad byte to the end of the
296 bleft--; /* Windows servers do not always double null terminate 294 * response.
297 their final Unicode string - in which case we 295 *
298 now will not attempt to decode the byte of junk 296 * See section 2.7.2 in "Implementing CIFS" for details
299 which follows it */ 297 */
298 if (bleft % 2) {
299 data[bleft] = 0;
300 ++bleft;
301 }
300 302
301 words_left = bleft / 2; 303 words_left = bleft / 2;
302 304
303 /* save off server operating system */ 305 /* save off server operating system */
304 len = UniStrnlen((wchar_t *) data, words_left); 306 len = UniStrnlen((wchar_t *) data, words_left);
305 307
306/* We look for obvious messed up bcc or strings in response so we do not go off
307 the end since (at least) WIN2K and Windows XP have a major bug in not null
308 terminating last Unicode string in response */
309 if (len >= words_left) 308 if (len >= words_left)
310 return rc; 309 return rc;
311 310
312 kfree(ses->serverOS); 311 kfree(ses->serverOS);
313 /* UTF-8 string will not grow more than four times as big as UCS-16 */ 312 /* UTF-8 string will not grow more than four times as big as UCS-16 */
314 ses->serverOS = kzalloc((4 * len) + 2 /* trailing null */, GFP_KERNEL); 313 ses->serverOS = kzalloc((4 * len) + 2 /* trailing null */, GFP_KERNEL);
315 if (ses->serverOS != NULL) 314 if (ses->serverOS != NULL) {
316 cifs_strfromUCS_le(ses->serverOS, (__le16 *)data, len, nls_cp); 315 cifs_strfromUCS_le(ses->serverOS, (__le16 *)data, len, nls_cp);
316 cFYI(1, ("serverOS=%s", ses->serverOS));
317 }
317 data += 2 * (len + 1); 318 data += 2 * (len + 1);
318 words_left -= len + 1; 319 words_left -= len + 1;
319 320
@@ -328,6 +329,7 @@ static int decode_unicode_ssetup(char **pbcc_area, int bleft,
328 if (ses->serverNOS != NULL) { 329 if (ses->serverNOS != NULL) {
329 cifs_strfromUCS_le(ses->serverNOS, (__le16 *)data, len, 330 cifs_strfromUCS_le(ses->serverNOS, (__le16 *)data, len,
330 nls_cp); 331 nls_cp);
332 cFYI(1, ("serverNOS=%s", ses->serverNOS));
331 if (strncmp(ses->serverNOS, "NT LAN Manager 4", 16) == 0) { 333 if (strncmp(ses->serverNOS, "NT LAN Manager 4", 16) == 0) {
332 cFYI(1, ("NT4 server")); 334 cFYI(1, ("NT4 server"));
333 ses->flags |= CIFS_SES_NT4; 335 ses->flags |= CIFS_SES_NT4;
@@ -343,12 +345,11 @@ static int decode_unicode_ssetup(char **pbcc_area, int bleft,
343 return rc; 345 return rc;
344 346
345 kfree(ses->serverDomain); 347 kfree(ses->serverDomain);
346 ses->serverDomain = kzalloc(2 * (len + 1), GFP_KERNEL); /* BB FIXME wrong length */ 348 ses->serverDomain = kzalloc((4 * len) + 2, GFP_KERNEL);
347 if (ses->serverDomain != NULL) { 349 if (ses->serverDomain != NULL) {
348 cifs_strfromUCS_le(ses->serverDomain, (__le16 *)data, len, 350 cifs_strfromUCS_le(ses->serverDomain, (__le16 *)data, len,
349 nls_cp); 351 nls_cp);
350 ses->serverDomain[2*len] = 0; 352 cFYI(1, ("serverDomain=%s", ses->serverDomain));
351 ses->serverDomain[(2*len) + 1] = 0;
352 } 353 }
353 data += 2 * (len + 1); 354 data += 2 * (len + 1);
354 words_left -= len + 1; 355 words_left -= len + 1;
@@ -702,12 +703,18 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
702 } 703 }
703 704
704 /* BB check if Unicode and decode strings */ 705 /* BB check if Unicode and decode strings */
705 if (smb_buf->Flags2 & SMBFLG2_UNICODE) 706 if (smb_buf->Flags2 & SMBFLG2_UNICODE) {
707 /* unicode string area must be word-aligned */
708 if (((unsigned long) bcc_ptr - (unsigned long) smb_buf) % 2) {
709 ++bcc_ptr;
710 --bytes_remaining;
711 }
706 rc = decode_unicode_ssetup(&bcc_ptr, bytes_remaining, 712 rc = decode_unicode_ssetup(&bcc_ptr, bytes_remaining,
707 ses, nls_cp); 713 ses, nls_cp);
708 else 714 } else {
709 rc = decode_ascii_ssetup(&bcc_ptr, bytes_remaining, 715 rc = decode_ascii_ssetup(&bcc_ptr, bytes_remaining,
710 ses, nls_cp); 716 ses, nls_cp);
717 }
711 718
712ssetup_exit: 719ssetup_exit:
713 if (spnego_key) { 720 if (spnego_key) {
diff --git a/fs/compat.c b/fs/compat.c
index 3f84d5f15889..379a399bf5c3 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -181,22 +181,24 @@ asmlinkage long compat_sys_newstat(char __user * filename,
181 struct compat_stat __user *statbuf) 181 struct compat_stat __user *statbuf)
182{ 182{
183 struct kstat stat; 183 struct kstat stat;
184 int error = vfs_stat_fd(AT_FDCWD, filename, &stat); 184 int error;
185 185
186 if (!error) 186 error = vfs_stat(filename, &stat);
187 error = cp_compat_stat(&stat, statbuf); 187 if (error)
188 return error; 188 return error;
189 return cp_compat_stat(&stat, statbuf);
189} 190}
190 191
191asmlinkage long compat_sys_newlstat(char __user * filename, 192asmlinkage long compat_sys_newlstat(char __user * filename,
192 struct compat_stat __user *statbuf) 193 struct compat_stat __user *statbuf)
193{ 194{
194 struct kstat stat; 195 struct kstat stat;
195 int error = vfs_lstat_fd(AT_FDCWD, filename, &stat); 196 int error;
196 197
197 if (!error) 198 error = vfs_lstat(filename, &stat);
198 error = cp_compat_stat(&stat, statbuf); 199 if (error)
199 return error; 200 return error;
201 return cp_compat_stat(&stat, statbuf);
200} 202}
201 203
202#ifndef __ARCH_WANT_STAT64 204#ifndef __ARCH_WANT_STAT64
@@ -204,21 +206,12 @@ asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user *filename,
204 struct compat_stat __user *statbuf, int flag) 206 struct compat_stat __user *statbuf, int flag)
205{ 207{
206 struct kstat stat; 208 struct kstat stat;
207 int error = -EINVAL; 209 int error;
208
209 if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
210 goto out;
211
212 if (flag & AT_SYMLINK_NOFOLLOW)
213 error = vfs_lstat_fd(dfd, filename, &stat);
214 else
215 error = vfs_stat_fd(dfd, filename, &stat);
216
217 if (!error)
218 error = cp_compat_stat(&stat, statbuf);
219 210
220out: 211 error = vfs_fstatat(dfd, filename, &stat, flag);
221 return error; 212 if (error)
213 return error;
214 return cp_compat_stat(&stat, statbuf);
222} 215}
223#endif 216#endif
224 217
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 3e87ce443ea2..b83f6bcfa51a 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -58,7 +58,6 @@
58#include <linux/i2c.h> 58#include <linux/i2c.h>
59#include <linux/i2c-dev.h> 59#include <linux/i2c-dev.h>
60#include <linux/atalk.h> 60#include <linux/atalk.h>
61#include <linux/loop.h>
62 61
63#include <net/bluetooth/bluetooth.h> 62#include <net/bluetooth/bluetooth.h>
64#include <net/bluetooth/hci.h> 63#include <net/bluetooth/hci.h>
@@ -68,6 +67,7 @@
68#include <linux/gigaset_dev.h> 67#include <linux/gigaset_dev.h>
69 68
70#ifdef CONFIG_BLOCK 69#ifdef CONFIG_BLOCK
70#include <linux/loop.h>
71#include <scsi/scsi.h> 71#include <scsi/scsi.h>
72#include <scsi/scsi_ioctl.h> 72#include <scsi/scsi_ioctl.h>
73#include <scsi/sg.h> 73#include <scsi/sg.h>
@@ -2660,6 +2660,8 @@ HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl)
2660HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl) 2660HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl)
2661/* block stuff */ 2661/* block stuff */
2662#ifdef CONFIG_BLOCK 2662#ifdef CONFIG_BLOCK
2663/* loop */
2664IGNORE_IOCTL(LOOP_CLR_FD)
2663/* Raw devices */ 2665/* Raw devices */
2664HANDLE_IOCTL(RAW_SETBIND, raw_ioctl) 2666HANDLE_IOCTL(RAW_SETBIND, raw_ioctl)
2665HANDLE_IOCTL(RAW_GETBIND, raw_ioctl) 2667HANDLE_IOCTL(RAW_GETBIND, raw_ioctl)
@@ -2728,9 +2730,6 @@ HANDLE_IOCTL(LPSETTIMEOUT, lp_timeout_trans)
2728IGNORE_IOCTL(VFAT_IOCTL_READDIR_BOTH32) 2730IGNORE_IOCTL(VFAT_IOCTL_READDIR_BOTH32)
2729IGNORE_IOCTL(VFAT_IOCTL_READDIR_SHORT32) 2731IGNORE_IOCTL(VFAT_IOCTL_READDIR_SHORT32)
2730 2732
2731/* loop */
2732IGNORE_IOCTL(LOOP_CLR_FD)
2733
2734#ifdef CONFIG_SPARC 2733#ifdef CONFIG_SPARC
2735/* Sparc framebuffers, handled in sbusfb_compat_ioctl() */ 2734/* Sparc framebuffers, handled in sbusfb_compat_ioctl() */
2736IGNORE_IOCTL(FBIOGTYPE) 2735IGNORE_IOCTL(FBIOGTYPE)
diff --git a/fs/dcache.c b/fs/dcache.c
index 761d30be2683..1fcffebfb44f 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2149,7 +2149,6 @@ int is_subdir(struct dentry *new_dentry, struct dentry *old_dentry)
2149 int result; 2149 int result;
2150 unsigned long seq; 2150 unsigned long seq;
2151 2151
2152 /* FIXME: This is old behavior, needed? Please check callers. */
2153 if (new_dentry == old_dentry) 2152 if (new_dentry == old_dentry)
2154 return 1; 2153 return 1;
2155 2154
diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
index a67fea655f49..dda3c58eefc0 100644
--- a/fs/ecryptfs/miscdev.c
+++ b/fs/ecryptfs/miscdev.c
@@ -418,18 +418,13 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,
418 418
419 if (count == 0) 419 if (count == 0)
420 goto out; 420 goto out;
421 data = kmalloc(count, GFP_KERNEL); 421
422 if (!data) { 422 data = memdup_user(buf, count);
423 printk(KERN_ERR "%s: Out of memory whilst attempting to " 423 if (IS_ERR(data)) {
424 "kmalloc([%zd], GFP_KERNEL)\n", __func__, count); 424 printk(KERN_ERR "%s: memdup_user returned error [%ld]\n",
425 __func__, PTR_ERR(data));
425 goto out; 426 goto out;
426 } 427 }
427 rc = copy_from_user(data, buf, count);
428 if (rc) {
429 printk(KERN_ERR "%s: copy_from_user returned error [%d]\n",
430 __func__, rc);
431 goto out_free;
432 }
433 sz = count; 428 sz = count;
434 i = 0; 429 i = 0;
435 switch (data[i++]) { 430 switch (data[i++]) {
diff --git a/fs/filesystems.c b/fs/filesystems.c
index 1aa70260e6d1..a24c58e181db 100644
--- a/fs/filesystems.c
+++ b/fs/filesystems.c
@@ -199,7 +199,7 @@ SYSCALL_DEFINE3(sysfs, int, option, unsigned long, arg1, unsigned long, arg2)
199 return retval; 199 return retval;
200} 200}
201 201
202int get_filesystem_list(char * buf) 202int __init get_filesystem_list(char *buf)
203{ 203{
204 int len = 0; 204 int len = 0;
205 struct file_system_type * tmp; 205 struct file_system_type * tmp;
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index bf23a62aa925..70f87f43afa2 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -156,6 +156,12 @@ static void inode_go_sync(struct gfs2_glock *gl)
156 error = filemap_fdatawait(metamapping); 156 error = filemap_fdatawait(metamapping);
157 mapping_set_error(metamapping, error); 157 mapping_set_error(metamapping, error);
158 gfs2_ail_empty_gl(gl); 158 gfs2_ail_empty_gl(gl);
159 /*
160 * Writeback of the data mapping may cause the dirty flag to be set
161 * so we have to clear it again here.
162 */
163 smp_mb__before_clear_bit();
164 clear_bit(GLF_DIRTY, &gl->gl_flags);
159} 165}
160 166
161/** 167/**
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c
index 101caf3ee861..5d82e91887e3 100644
--- a/fs/gfs2/ops_file.c
+++ b/fs/gfs2/ops_file.c
@@ -413,7 +413,9 @@ out_unlock:
413 gfs2_glock_dq(&gh); 413 gfs2_glock_dq(&gh);
414out: 414out:
415 gfs2_holder_uninit(&gh); 415 gfs2_holder_uninit(&gh);
416 if (ret) 416 if (ret == -ENOMEM)
417 ret = VM_FAULT_OOM;
418 else if (ret)
417 ret = VM_FAULT_SIGBUS; 419 ret = VM_FAULT_SIGBUS;
418 return ret; 420 return ret;
419} 421}
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 23a3c76711e0..153d9681192b 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -26,7 +26,6 @@
26#include <linux/pagevec.h> 26#include <linux/pagevec.h>
27#include <linux/parser.h> 27#include <linux/parser.h>
28#include <linux/mman.h> 28#include <linux/mman.h>
29#include <linux/quotaops.h>
30#include <linux/slab.h> 29#include <linux/slab.h>
31#include <linux/dnotify.h> 30#include <linux/dnotify.h>
32#include <linux/statfs.h> 31#include <linux/statfs.h>
@@ -842,7 +841,7 @@ hugetlbfs_parse_options(char *options, struct hugetlbfs_config *pconfig)
842bad_val: 841bad_val:
843 printk(KERN_ERR "hugetlbfs: Bad value '%s' for mount option '%s'\n", 842 printk(KERN_ERR "hugetlbfs: Bad value '%s' for mount option '%s'\n",
844 args[0].from, p); 843 args[0].from, p);
845 return 1; 844 return -EINVAL;
846} 845}
847 846
848static int 847static int
diff --git a/fs/namei.c b/fs/namei.c
index b8433ebfae05..78f253cd2d4f 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1248,6 +1248,8 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
1248 int err; 1248 int err;
1249 struct qstr this; 1249 struct qstr this;
1250 1250
1251 WARN_ON_ONCE(!mutex_is_locked(&base->d_inode->i_mutex));
1252
1251 err = __lookup_one_len(name, &this, base, len); 1253 err = __lookup_one_len(name, &this, base, len);
1252 if (err) 1254 if (err)
1253 return ERR_PTR(err); 1255 return ERR_PTR(err);
diff --git a/fs/namespace.c b/fs/namespace.c
index c6f54e4c4290..41196209a906 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1377,7 +1377,7 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt,
1377 if (parent_path) { 1377 if (parent_path) {
1378 detach_mnt(source_mnt, parent_path); 1378 detach_mnt(source_mnt, parent_path);
1379 attach_mnt(source_mnt, path); 1379 attach_mnt(source_mnt, path);
1380 touch_mnt_namespace(current->nsproxy->mnt_ns); 1380 touch_mnt_namespace(parent_path->mnt->mnt_ns);
1381 } else { 1381 } else {
1382 mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt); 1382 mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt);
1383 commit_tree(source_mnt); 1383 commit_tree(source_mnt);
@@ -1920,8 +1920,9 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
1920 if (data_page) 1920 if (data_page)
1921 ((char *)data_page)[PAGE_SIZE - 1] = 0; 1921 ((char *)data_page)[PAGE_SIZE - 1] = 0;
1922 1922
1923 /* Default to relatime */ 1923 /* Default to relatime unless overriden */
1924 mnt_flags |= MNT_RELATIME; 1924 if (!(flags & MS_NOATIME))
1925 mnt_flags |= MNT_RELATIME;
1925 1926
1926 /* Separate the per-mountpoint flags */ 1927 /* Separate the per-mountpoint flags */
1927 if (flags & MS_NOSUID) 1928 if (flags & MS_NOSUID)
diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c
index f54360f50a9c..fa038df63ac8 100644
--- a/fs/ncpfs/ioctl.c
+++ b/fs/ncpfs/ioctl.c
@@ -660,13 +660,10 @@ outrel:
660 if (user.object_name_len > NCP_OBJECT_NAME_MAX_LEN) 660 if (user.object_name_len > NCP_OBJECT_NAME_MAX_LEN)
661 return -ENOMEM; 661 return -ENOMEM;
662 if (user.object_name_len) { 662 if (user.object_name_len) {
663 newname = kmalloc(user.object_name_len, GFP_USER); 663 newname = memdup_user(user.object_name,
664 if (!newname) 664 user.object_name_len);
665 return -ENOMEM; 665 if (IS_ERR(newname))
666 if (copy_from_user(newname, user.object_name, user.object_name_len)) { 666 return PTR_ERR(newname);
667 kfree(newname);
668 return -EFAULT;
669 }
670 } else { 667 } else {
671 newname = NULL; 668 newname = NULL;
672 } 669 }
@@ -760,13 +757,9 @@ outrel:
760 if (user.len > NCP_PRIVATE_DATA_MAX_LEN) 757 if (user.len > NCP_PRIVATE_DATA_MAX_LEN)
761 return -ENOMEM; 758 return -ENOMEM;
762 if (user.len) { 759 if (user.len) {
763 new = kmalloc(user.len, GFP_USER); 760 new = memdup_user(user.data, user.len);
764 if (!new) 761 if (IS_ERR(new))
765 return -ENOMEM; 762 return PTR_ERR(new);
766 if (copy_from_user(new, user.data, user.len)) {
767 kfree(new);
768 return -EFAULT;
769 }
770 } else { 763 } else {
771 new = NULL; 764 new = NULL;
772 } 765 }
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index e6a1932c7110..35869a4921f1 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -713,7 +713,8 @@ nfs3_xdr_setaclargs(struct rpc_rqst *req, __be32 *p,
713 if (args->npages != 0) 713 if (args->npages != 0)
714 xdr_encode_pages(buf, args->pages, 0, args->len); 714 xdr_encode_pages(buf, args->pages, 0, args->len);
715 else 715 else
716 req->rq_slen += args->len; 716 req->rq_slen = xdr_adjust_iovec(req->rq_svec,
717 p + XDR_QUADLEN(args->len));
717 718
718 err = nfsacl_encode(buf, base, args->inode, 719 err = nfsacl_encode(buf, base, args->inode,
719 (args->mask & NFS_ACL) ? 720 (args->mask & NFS_ACL) ?
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index 3444c0052a87..5275097a7565 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -229,21 +229,23 @@ nfsd4_list_rec_dir(struct dentry *dir, recdir_func *f)
229 goto out; 229 goto out;
230 status = vfs_readdir(filp, nfsd4_build_namelist, &names); 230 status = vfs_readdir(filp, nfsd4_build_namelist, &names);
231 fput(filp); 231 fput(filp);
232 mutex_lock(&dir->d_inode->i_mutex);
232 while (!list_empty(&names)) { 233 while (!list_empty(&names)) {
233 entry = list_entry(names.next, struct name_list, list); 234 entry = list_entry(names.next, struct name_list, list);
234 235
235 dentry = lookup_one_len(entry->name, dir, HEXDIR_LEN-1); 236 dentry = lookup_one_len(entry->name, dir, HEXDIR_LEN-1);
236 if (IS_ERR(dentry)) { 237 if (IS_ERR(dentry)) {
237 status = PTR_ERR(dentry); 238 status = PTR_ERR(dentry);
238 goto out; 239 break;
239 } 240 }
240 status = f(dir, dentry); 241 status = f(dir, dentry);
241 dput(dentry); 242 dput(dentry);
242 if (status) 243 if (status)
243 goto out; 244 break;
244 list_del(&entry->list); 245 list_del(&entry->list);
245 kfree(entry); 246 kfree(entry);
246 } 247 }
248 mutex_unlock(&dir->d_inode->i_mutex);
247out: 249out:
248 while (!list_empty(&names)) { 250 while (!list_empty(&names)) {
249 entry = list_entry(names.next, struct name_list, list); 251 entry = list_entry(names.next, struct name_list, list);
@@ -255,36 +257,6 @@ out:
255} 257}
256 258
257static int 259static int
258nfsd4_remove_clid_file(struct dentry *dir, struct dentry *dentry)
259{
260 int status;
261
262 if (!S_ISREG(dir->d_inode->i_mode)) {
263 printk("nfsd4: non-file found in client recovery directory\n");
264 return -EINVAL;
265 }
266 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
267 status = vfs_unlink(dir->d_inode, dentry);
268 mutex_unlock(&dir->d_inode->i_mutex);
269 return status;
270}
271
272static int
273nfsd4_clear_clid_dir(struct dentry *dir, struct dentry *dentry)
274{
275 int status;
276
277 /* For now this directory should already be empty, but we empty it of
278 * any regular files anyway, just in case the directory was created by
279 * a kernel from the future.... */
280 nfsd4_list_rec_dir(dentry, nfsd4_remove_clid_file);
281 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
282 status = vfs_rmdir(dir->d_inode, dentry);
283 mutex_unlock(&dir->d_inode->i_mutex);
284 return status;
285}
286
287static int
288nfsd4_unlink_clid_dir(char *name, int namlen) 260nfsd4_unlink_clid_dir(char *name, int namlen)
289{ 261{
290 struct dentry *dentry; 262 struct dentry *dentry;
@@ -294,18 +266,18 @@ nfsd4_unlink_clid_dir(char *name, int namlen)
294 266
295 mutex_lock(&rec_dir.dentry->d_inode->i_mutex); 267 mutex_lock(&rec_dir.dentry->d_inode->i_mutex);
296 dentry = lookup_one_len(name, rec_dir.dentry, namlen); 268 dentry = lookup_one_len(name, rec_dir.dentry, namlen);
297 mutex_unlock(&rec_dir.dentry->d_inode->i_mutex);
298 if (IS_ERR(dentry)) { 269 if (IS_ERR(dentry)) {
299 status = PTR_ERR(dentry); 270 status = PTR_ERR(dentry);
300 return status; 271 goto out_unlock;
301 } 272 }
302 status = -ENOENT; 273 status = -ENOENT;
303 if (!dentry->d_inode) 274 if (!dentry->d_inode)
304 goto out; 275 goto out;
305 276 status = vfs_rmdir(rec_dir.dentry->d_inode, dentry);
306 status = nfsd4_clear_clid_dir(rec_dir.dentry, dentry);
307out: 277out:
308 dput(dentry); 278 dput(dentry);
279out_unlock:
280 mutex_unlock(&rec_dir.dentry->d_inode->i_mutex);
309 return status; 281 return status;
310} 282}
311 283
@@ -348,7 +320,7 @@ purge_old(struct dentry *parent, struct dentry *child)
348 if (nfs4_has_reclaimed_state(child->d_name.name, false)) 320 if (nfs4_has_reclaimed_state(child->d_name.name, false))
349 return 0; 321 return 0;
350 322
351 status = nfsd4_clear_clid_dir(parent, child); 323 status = vfs_rmdir(parent->d_inode, child);
352 if (status) 324 if (status)
353 printk("failed to remove client recovery directory %s\n", 325 printk("failed to remove client recovery directory %s\n",
354 child->d_name.name); 326 child->d_name.name);
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index ab93fcfef254..6c68ffd6b4bb 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -116,10 +116,15 @@ nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
116 } 116 }
117 if ((exp->ex_flags & NFSEXP_CROSSMOUNT) || EX_NOHIDE(exp2)) { 117 if ((exp->ex_flags & NFSEXP_CROSSMOUNT) || EX_NOHIDE(exp2)) {
118 /* successfully crossed mount point */ 118 /* successfully crossed mount point */
119 exp_put(exp); 119 /*
120 *expp = exp2; 120 * This is subtle: dentry is *not* under mnt at this point.
121 * The only reason we are safe is that original mnt is pinned
122 * down by exp, so we should dput before putting exp.
123 */
121 dput(dentry); 124 dput(dentry);
122 *dpp = mounts; 125 *dpp = mounts;
126 exp_put(exp);
127 *expp = exp2;
123 } else { 128 } else {
124 exp_put(exp2); 129 exp_put(exp2);
125 dput(mounts); 130 dput(mounts);
@@ -1885,8 +1890,8 @@ static int nfsd_buffered_filldir(void *__buf, const char *name, int namlen,
1885 return 0; 1890 return 0;
1886} 1891}
1887 1892
1888static int nfsd_buffered_readdir(struct file *file, filldir_t func, 1893static __be32 nfsd_buffered_readdir(struct file *file, filldir_t func,
1889 struct readdir_cd *cdp, loff_t *offsetp) 1894 struct readdir_cd *cdp, loff_t *offsetp)
1890{ 1895{
1891 struct readdir_data buf; 1896 struct readdir_data buf;
1892 struct buffered_dirent *de; 1897 struct buffered_dirent *de;
@@ -1896,11 +1901,12 @@ static int nfsd_buffered_readdir(struct file *file, filldir_t func,
1896 1901
1897 buf.dirent = (void *)__get_free_page(GFP_KERNEL); 1902 buf.dirent = (void *)__get_free_page(GFP_KERNEL);
1898 if (!buf.dirent) 1903 if (!buf.dirent)
1899 return -ENOMEM; 1904 return nfserrno(-ENOMEM);
1900 1905
1901 offset = *offsetp; 1906 offset = *offsetp;
1902 1907
1903 while (1) { 1908 while (1) {
1909 struct inode *dir_inode = file->f_path.dentry->d_inode;
1904 unsigned int reclen; 1910 unsigned int reclen;
1905 1911
1906 cdp->err = nfserr_eof; /* will be cleared on successful read */ 1912 cdp->err = nfserr_eof; /* will be cleared on successful read */
@@ -1919,26 +1925,38 @@ static int nfsd_buffered_readdir(struct file *file, filldir_t func,
1919 if (!size) 1925 if (!size)
1920 break; 1926 break;
1921 1927
1928 /*
1929 * Various filldir functions may end up calling back into
1930 * lookup_one_len() and the file system's ->lookup() method.
1931 * These expect i_mutex to be held, as it would within readdir.
1932 */
1933 host_err = mutex_lock_killable(&dir_inode->i_mutex);
1934 if (host_err)
1935 break;
1936
1922 de = (struct buffered_dirent *)buf.dirent; 1937 de = (struct buffered_dirent *)buf.dirent;
1923 while (size > 0) { 1938 while (size > 0) {
1924 offset = de->offset; 1939 offset = de->offset;
1925 1940
1926 if (func(cdp, de->name, de->namlen, de->offset, 1941 if (func(cdp, de->name, de->namlen, de->offset,
1927 de->ino, de->d_type)) 1942 de->ino, de->d_type))
1928 goto done; 1943 break;
1929 1944
1930 if (cdp->err != nfs_ok) 1945 if (cdp->err != nfs_ok)
1931 goto done; 1946 break;
1932 1947
1933 reclen = ALIGN(sizeof(*de) + de->namlen, 1948 reclen = ALIGN(sizeof(*de) + de->namlen,
1934 sizeof(u64)); 1949 sizeof(u64));
1935 size -= reclen; 1950 size -= reclen;
1936 de = (struct buffered_dirent *)((char *)de + reclen); 1951 de = (struct buffered_dirent *)((char *)de + reclen);
1937 } 1952 }
1953 mutex_unlock(&dir_inode->i_mutex);
1954 if (size > 0) /* We bailed out early */
1955 break;
1956
1938 offset = vfs_llseek(file, 0, SEEK_CUR); 1957 offset = vfs_llseek(file, 0, SEEK_CUR);
1939 } 1958 }
1940 1959
1941 done:
1942 free_page((unsigned long)(buf.dirent)); 1960 free_page((unsigned long)(buf.dirent));
1943 1961
1944 if (host_err) 1962 if (host_err)
diff --git a/fs/stat.c b/fs/stat.c
index 2db740a0cfb5..075694e31d8b 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -55,59 +55,54 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55 55
56EXPORT_SYMBOL(vfs_getattr); 56EXPORT_SYMBOL(vfs_getattr);
57 57
58int vfs_stat_fd(int dfd, char __user *name, struct kstat *stat) 58int vfs_fstat(unsigned int fd, struct kstat *stat)
59{ 59{
60 struct path path; 60 struct file *f = fget(fd);
61 int error; 61 int error = -EBADF;
62 62
63 error = user_path_at(dfd, name, LOOKUP_FOLLOW, &path); 63 if (f) {
64 if (!error) { 64 error = vfs_getattr(f->f_path.mnt, f->f_path.dentry, stat);
65 error = vfs_getattr(path.mnt, path.dentry, stat); 65 fput(f);
66 path_put(&path);
67 } 66 }
68 return error; 67 return error;
69} 68}
69EXPORT_SYMBOL(vfs_fstat);
70 70
71int vfs_stat(char __user *name, struct kstat *stat) 71int vfs_fstatat(int dfd, char __user *filename, struct kstat *stat, int flag)
72{ 72{
73 return vfs_stat_fd(AT_FDCWD, name, stat); 73 struct path path;
74} 74 int error = -EINVAL;
75 int lookup_flags = 0;
75 76
76EXPORT_SYMBOL(vfs_stat); 77 if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
78 goto out;
77 79
78int vfs_lstat_fd(int dfd, char __user *name, struct kstat *stat) 80 if (!(flag & AT_SYMLINK_NOFOLLOW))
79{ 81 lookup_flags |= LOOKUP_FOLLOW;
80 struct path path;
81 int error;
82 82
83 error = user_path_at(dfd, name, 0, &path); 83 error = user_path_at(dfd, filename, lookup_flags, &path);
84 if (!error) { 84 if (error)
85 error = vfs_getattr(path.mnt, path.dentry, stat); 85 goto out;
86 path_put(&path); 86
87 } 87 error = vfs_getattr(path.mnt, path.dentry, stat);
88 path_put(&path);
89out:
88 return error; 90 return error;
89} 91}
92EXPORT_SYMBOL(vfs_fstatat);
90 93
91int vfs_lstat(char __user *name, struct kstat *stat) 94int vfs_stat(char __user *name, struct kstat *stat)
92{ 95{
93 return vfs_lstat_fd(AT_FDCWD, name, stat); 96 return vfs_fstatat(AT_FDCWD, name, stat, 0);
94} 97}
98EXPORT_SYMBOL(vfs_stat);
95 99
96EXPORT_SYMBOL(vfs_lstat); 100int vfs_lstat(char __user *name, struct kstat *stat)
97
98int vfs_fstat(unsigned int fd, struct kstat *stat)
99{ 101{
100 struct file *f = fget(fd); 102 return vfs_fstatat(AT_FDCWD, name, stat, AT_SYMLINK_NOFOLLOW);
101 int error = -EBADF;
102
103 if (f) {
104 error = vfs_getattr(f->f_path.mnt, f->f_path.dentry, stat);
105 fput(f);
106 }
107 return error;
108} 103}
104EXPORT_SYMBOL(vfs_lstat);
109 105
110EXPORT_SYMBOL(vfs_fstat);
111 106
112#ifdef __ARCH_WANT_OLD_STAT 107#ifdef __ARCH_WANT_OLD_STAT
113 108
@@ -155,23 +150,25 @@ static int cp_old_stat(struct kstat *stat, struct __old_kernel_stat __user * sta
155SYSCALL_DEFINE2(stat, char __user *, filename, struct __old_kernel_stat __user *, statbuf) 150SYSCALL_DEFINE2(stat, char __user *, filename, struct __old_kernel_stat __user *, statbuf)
156{ 151{
157 struct kstat stat; 152 struct kstat stat;
158 int error = vfs_stat_fd(AT_FDCWD, filename, &stat); 153 int error;
159 154
160 if (!error) 155 error = vfs_stat(filename, &stat);
161 error = cp_old_stat(&stat, statbuf); 156 if (error)
157 return error;
162 158
163 return error; 159 return cp_old_stat(&stat, statbuf);
164} 160}
165 161
166SYSCALL_DEFINE2(lstat, char __user *, filename, struct __old_kernel_stat __user *, statbuf) 162SYSCALL_DEFINE2(lstat, char __user *, filename, struct __old_kernel_stat __user *, statbuf)
167{ 163{
168 struct kstat stat; 164 struct kstat stat;
169 int error = vfs_lstat_fd(AT_FDCWD, filename, &stat); 165 int error;
170 166
171 if (!error) 167 error = vfs_lstat(filename, &stat);
172 error = cp_old_stat(&stat, statbuf); 168 if (error)
169 return error;
173 170
174 return error; 171 return cp_old_stat(&stat, statbuf);
175} 172}
176 173
177SYSCALL_DEFINE2(fstat, unsigned int, fd, struct __old_kernel_stat __user *, statbuf) 174SYSCALL_DEFINE2(fstat, unsigned int, fd, struct __old_kernel_stat __user *, statbuf)
@@ -240,23 +237,23 @@ static int cp_new_stat(struct kstat *stat, struct stat __user *statbuf)
240SYSCALL_DEFINE2(newstat, char __user *, filename, struct stat __user *, statbuf) 237SYSCALL_DEFINE2(newstat, char __user *, filename, struct stat __user *, statbuf)
241{ 238{
242 struct kstat stat; 239 struct kstat stat;
243 int error = vfs_stat_fd(AT_FDCWD, filename, &stat); 240 int error = vfs_stat(filename, &stat);
244
245 if (!error)
246 error = cp_new_stat(&stat, statbuf);
247 241
248 return error; 242 if (error)
243 return error;
244 return cp_new_stat(&stat, statbuf);
249} 245}
250 246
251SYSCALL_DEFINE2(newlstat, char __user *, filename, struct stat __user *, statbuf) 247SYSCALL_DEFINE2(newlstat, char __user *, filename, struct stat __user *, statbuf)
252{ 248{
253 struct kstat stat; 249 struct kstat stat;
254 int error = vfs_lstat_fd(AT_FDCWD, filename, &stat); 250 int error;
255 251
256 if (!error) 252 error = vfs_lstat(filename, &stat);
257 error = cp_new_stat(&stat, statbuf); 253 if (error)
254 return error;
258 255
259 return error; 256 return cp_new_stat(&stat, statbuf);
260} 257}
261 258
262#if !defined(__ARCH_WANT_STAT64) || defined(__ARCH_WANT_SYS_NEWFSTATAT) 259#if !defined(__ARCH_WANT_STAT64) || defined(__ARCH_WANT_SYS_NEWFSTATAT)
@@ -264,21 +261,12 @@ SYSCALL_DEFINE4(newfstatat, int, dfd, char __user *, filename,
264 struct stat __user *, statbuf, int, flag) 261 struct stat __user *, statbuf, int, flag)
265{ 262{
266 struct kstat stat; 263 struct kstat stat;
267 int error = -EINVAL; 264 int error;
268
269 if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
270 goto out;
271
272 if (flag & AT_SYMLINK_NOFOLLOW)
273 error = vfs_lstat_fd(dfd, filename, &stat);
274 else
275 error = vfs_stat_fd(dfd, filename, &stat);
276
277 if (!error)
278 error = cp_new_stat(&stat, statbuf);
279 265
280out: 266 error = vfs_fstatat(dfd, filename, &stat, flag);
281 return error; 267 if (error)
268 return error;
269 return cp_new_stat(&stat, statbuf);
282} 270}
283#endif 271#endif
284 272
@@ -404,21 +392,12 @@ SYSCALL_DEFINE4(fstatat64, int, dfd, char __user *, filename,
404 struct stat64 __user *, statbuf, int, flag) 392 struct stat64 __user *, statbuf, int, flag)
405{ 393{
406 struct kstat stat; 394 struct kstat stat;
407 int error = -EINVAL; 395 int error;
408
409 if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
410 goto out;
411
412 if (flag & AT_SYMLINK_NOFOLLOW)
413 error = vfs_lstat_fd(dfd, filename, &stat);
414 else
415 error = vfs_stat_fd(dfd, filename, &stat);
416
417 if (!error)
418 error = cp_new_stat64(&stat, statbuf);
419 396
420out: 397 error = vfs_fstatat(dfd, filename, &stat, flag);
421 return error; 398 if (error)
399 return error;
400 return cp_new_stat64(&stat, statbuf);
422} 401}
423#endif /* __ARCH_WANT_STAT64 */ 402#endif /* __ARCH_WANT_STAT64 */
424 403
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
index 93e0c0281d45..9345806c8853 100644
--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -157,14 +157,9 @@ static ssize_t write(struct file *file, const char __user *userbuf,
157 count = size - offs; 157 count = size - offs;
158 } 158 }
159 159
160 temp = kmalloc(count, GFP_KERNEL); 160 temp = memdup_user(userbuf, count);
161 if (!temp) 161 if (IS_ERR(temp))
162 return -ENOMEM; 162 return PTR_ERR(temp);
163
164 if (copy_from_user(temp, userbuf, count)) {
165 count = -EFAULT;
166 goto out_free;
167 }
168 163
169 mutex_lock(&bb->mutex); 164 mutex_lock(&bb->mutex);
170 165
@@ -176,8 +171,6 @@ static ssize_t write(struct file *file, const char __user *userbuf,
176 if (count > 0) 171 if (count > 0)
177 *off = offs + count; 172 *off = offs + count;
178 173
179out_free:
180 kfree(temp);
181 return count; 174 return count;
182} 175}
183 176
diff --git a/fs/xattr.c b/fs/xattr.c
index 197c4fcac032..d51b8f9db921 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -237,13 +237,9 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
237 if (size) { 237 if (size) {
238 if (size > XATTR_SIZE_MAX) 238 if (size > XATTR_SIZE_MAX)
239 return -E2BIG; 239 return -E2BIG;
240 kvalue = kmalloc(size, GFP_KERNEL); 240 kvalue = memdup_user(value, size);
241 if (!kvalue) 241 if (IS_ERR(kvalue))
242 return -ENOMEM; 242 return PTR_ERR(kvalue);
243 if (copy_from_user(kvalue, value, size)) {
244 kfree(kvalue);
245 return -EFAULT;
246 }
247 } 243 }
248 244
249 error = vfs_setxattr(d, kname, kvalue, size, flags); 245 error = vfs_setxattr(d, kname, kvalue, size, flags);
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index d0b499418a7d..34eaab608e6e 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -489,17 +489,12 @@ xfs_attrmulti_attr_set(
489 if (len > XATTR_SIZE_MAX) 489 if (len > XATTR_SIZE_MAX)
490 return EINVAL; 490 return EINVAL;
491 491
492 kbuf = kmalloc(len, GFP_KERNEL); 492 kbuf = memdup_user(ubuf, len);
493 if (!kbuf) 493 if (IS_ERR(kbuf))
494 return ENOMEM; 494 return PTR_ERR(kbuf);
495
496 if (copy_from_user(kbuf, ubuf, len))
497 goto out_kfree;
498 495
499 error = xfs_attr_set(XFS_I(inode), name, kbuf, len, flags); 496 error = xfs_attr_set(XFS_I(inode), name, kbuf, len, flags);
500 497
501 out_kfree:
502 kfree(kbuf);
503 return error; 498 return error;
504} 499}
505 500
@@ -540,20 +535,16 @@ xfs_attrmulti_by_handle(
540 if (!size || size > 16 * PAGE_SIZE) 535 if (!size || size > 16 * PAGE_SIZE)
541 goto out_dput; 536 goto out_dput;
542 537
543 error = ENOMEM; 538 ops = memdup_user(am_hreq.ops, size);
544 ops = kmalloc(size, GFP_KERNEL); 539 if (IS_ERR(ops)) {
545 if (!ops) 540 error = PTR_ERR(ops);
546 goto out_dput; 541 goto out_dput;
547 542 }
548 error = EFAULT;
549 if (copy_from_user(ops, am_hreq.ops, size))
550 goto out_kfree_ops;
551 543
552 attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL); 544 attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL);
553 if (!attr_name) 545 if (!attr_name)
554 goto out_kfree_ops; 546 goto out_kfree_ops;
555 547
556
557 error = 0; 548 error = 0;
558 for (i = 0; i < am_hreq.opcount; i++) { 549 for (i = 0; i < am_hreq.opcount; i++) {
559 ops[i].am_error = strncpy_from_user(attr_name, 550 ops[i].am_error = strncpy_from_user(attr_name,
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.c b/fs/xfs/linux-2.6/xfs_ioctl32.c
index c70c4e3db790..0882d166239a 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl32.c
@@ -427,20 +427,16 @@ xfs_compat_attrmulti_by_handle(
427 if (!size || size > 16 * PAGE_SIZE) 427 if (!size || size > 16 * PAGE_SIZE)
428 goto out_dput; 428 goto out_dput;
429 429
430 error = ENOMEM; 430 ops = memdup_user(compat_ptr(am_hreq.ops), size);
431 ops = kmalloc(size, GFP_KERNEL); 431 if (IS_ERR(ops)) {
432 if (!ops) 432 error = PTR_ERR(ops);
433 goto out_dput; 433 goto out_dput;
434 434 }
435 error = EFAULT;
436 if (copy_from_user(ops, compat_ptr(am_hreq.ops), size))
437 goto out_kfree_ops;
438 435
439 attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL); 436 attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL);
440 if (!attr_name) 437 if (!attr_name)
441 goto out_kfree_ops; 438 goto out_kfree_ops;
442 439
443
444 error = 0; 440 error = 0;
445 for (i = 0; i < am_hreq.opcount; i++) { 441 for (i = 0; i < am_hreq.opcount; i++) {
446 ops[i].am_error = strncpy_from_user(attr_name, 442 ops[i].am_error = strncpy_from_user(attr_name,
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index 573819ef4cc0..5a40d14daa9f 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -143,7 +143,9 @@ extern u64 timecounter_cyc2time(struct timecounter *tc,
143 * 400-499: Perfect 143 * 400-499: Perfect
144 * The ideal clocksource. A must-use where 144 * The ideal clocksource. A must-use where
145 * available. 145 * available.
146 * @read: returns a cycle value 146 * @read: returns a cycle value, passes clocksource as argument
147 * @enable: optional function to enable the clocksource
148 * @disable: optional function to disable the clocksource
147 * @mask: bitmask for two's complement 149 * @mask: bitmask for two's complement
148 * subtraction of non 64 bit counters 150 * subtraction of non 64 bit counters
149 * @mult: cycle to nanosecond multiplier (adjusted by NTP) 151 * @mult: cycle to nanosecond multiplier (adjusted by NTP)
@@ -162,7 +164,9 @@ struct clocksource {
162 char *name; 164 char *name;
163 struct list_head list; 165 struct list_head list;
164 int rating; 166 int rating;
165 cycle_t (*read)(void); 167 cycle_t (*read)(struct clocksource *cs);
168 int (*enable)(struct clocksource *cs);
169 void (*disable)(struct clocksource *cs);
166 cycle_t mask; 170 cycle_t mask;
167 u32 mult; 171 u32 mult;
168 u32 mult_orig; 172 u32 mult_orig;
@@ -271,7 +275,34 @@ static inline u32 clocksource_hz2mult(u32 hz, u32 shift_constant)
271 */ 275 */
272static inline cycle_t clocksource_read(struct clocksource *cs) 276static inline cycle_t clocksource_read(struct clocksource *cs)
273{ 277{
274 return cs->read(); 278 return cs->read(cs);
279}
280
281/**
282 * clocksource_enable: - enable clocksource
283 * @cs: pointer to clocksource
284 *
285 * Enables the specified clocksource. The clocksource callback
286 * function should start up the hardware and setup mult and field
287 * members of struct clocksource to reflect hardware capabilities.
288 */
289static inline int clocksource_enable(struct clocksource *cs)
290{
291 return cs->enable ? cs->enable(cs) : 0;
292}
293
294/**
295 * clocksource_disable: - disable clocksource
296 * @cs: pointer to clocksource
297 *
298 * Disables the specified clocksource. The clocksource callback
299 * function should power down the now unused hardware block to
300 * save power.
301 */
302static inline void clocksource_disable(struct clocksource *cs)
303{
304 if (cs->disable)
305 cs->disable(cs);
275} 306}
276 307
277/** 308/**
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e766be0d4329..5bed436f4353 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2299,9 +2299,8 @@ extern int vfs_readdir(struct file *, filldir_t, void *);
2299 2299
2300extern int vfs_stat(char __user *, struct kstat *); 2300extern int vfs_stat(char __user *, struct kstat *);
2301extern int vfs_lstat(char __user *, struct kstat *); 2301extern int vfs_lstat(char __user *, struct kstat *);
2302extern int vfs_stat_fd(int dfd, char __user *, struct kstat *);
2303extern int vfs_lstat_fd(int dfd, char __user *, struct kstat *);
2304extern int vfs_fstat(unsigned int, struct kstat *); 2302extern int vfs_fstat(unsigned int, struct kstat *);
2303extern int vfs_fstatat(int , char __user *, struct kstat *, int);
2305 2304
2306extern int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, 2305extern int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
2307 unsigned long arg); 2306 unsigned long arg);
@@ -2449,7 +2448,7 @@ struct ctl_table;
2449int proc_nr_files(struct ctl_table *table, int write, struct file *filp, 2448int proc_nr_files(struct ctl_table *table, int write, struct file *filp,
2450 void __user *buffer, size_t *lenp, loff_t *ppos); 2449 void __user *buffer, size_t *lenp, loff_t *ppos);
2451 2450
2452int get_filesystem_list(char * buf); 2451int __init get_filesystem_list(char *buf);
2453 2452
2454#endif /* __KERNEL__ */ 2453#endif /* __KERNEL__ */
2455#endif /* _LINUX_FS_H */ 2454#endif /* _LINUX_FS_H */
diff --git a/include/linux/ipmi.h b/include/linux/ipmi.h
index 7ebdb4fb4e54..65aae34759de 100644
--- a/include/linux/ipmi.h
+++ b/include/linux/ipmi.h
@@ -198,6 +198,8 @@ struct kernel_ipmi_msg {
198 response. When you send a 198 response. When you send a
199 response message, this will 199 response message, this will
200 be returned. */ 200 be returned. */
201#define IPMI_OEM_RECV_TYPE 5 /* The response for OEM Channels */
202
201/* Note that async events and received commands do not have a completion 203/* Note that async events and received commands do not have a completion
202 code as the first byte of the incoming data, unlike a response. */ 204 code as the first byte of the incoming data, unlike a response. */
203 205
diff --git a/include/linux/ipmi_msgdefs.h b/include/linux/ipmi_msgdefs.h
index b56a158d587a..df97e6e31e87 100644
--- a/include/linux/ipmi_msgdefs.h
+++ b/include/linux/ipmi_msgdefs.h
@@ -58,6 +58,12 @@
58#define IPMI_READ_EVENT_MSG_BUFFER_CMD 0x35 58#define IPMI_READ_EVENT_MSG_BUFFER_CMD 0x35
59#define IPMI_GET_CHANNEL_INFO_CMD 0x42 59#define IPMI_GET_CHANNEL_INFO_CMD 0x42
60 60
61/* Bit for BMC global enables. */
62#define IPMI_BMC_RCV_MSG_INTR 0x01
63#define IPMI_BMC_EVT_MSG_INTR 0x02
64#define IPMI_BMC_EVT_MSG_BUFF 0x04
65#define IPMI_BMC_SYS_LOG 0x08
66
61#define IPMI_NETFN_STORAGE_REQUEST 0x0a 67#define IPMI_NETFN_STORAGE_REQUEST 0x0a
62#define IPMI_NETFN_STORAGE_RESPONSE 0x0b 68#define IPMI_NETFN_STORAGE_RESPONSE 0x0b
63#define IPMI_ADD_SEL_ENTRY_CMD 0x44 69#define IPMI_ADD_SEL_ENTRY_CMD 0x44
@@ -109,5 +115,7 @@
109#define IPMI_CHANNEL_MEDIUM_USB1 10 115#define IPMI_CHANNEL_MEDIUM_USB1 10
110#define IPMI_CHANNEL_MEDIUM_USB2 11 116#define IPMI_CHANNEL_MEDIUM_USB2 11
111#define IPMI_CHANNEL_MEDIUM_SYSINTF 12 117#define IPMI_CHANNEL_MEDIUM_SYSINTF 12
118#define IPMI_CHANNEL_MEDIUM_OEM_MIN 0x60
119#define IPMI_CHANNEL_MEDIUM_OEM_MAX 0x7f
112 120
113#endif /* __LINUX_IPMI_MSGDEFS_H */ 121#endif /* __LINUX_IPMI_MSGDEFS_H */
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 18146c980b68..a9e3b76aa884 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -75,7 +75,7 @@ int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
75{ 75{
76 struct mem_cgroup *mem; 76 struct mem_cgroup *mem;
77 rcu_read_lock(); 77 rcu_read_lock();
78 mem = mem_cgroup_from_task((mm)->owner); 78 mem = mem_cgroup_from_task(rcu_dereference((mm)->owner));
79 rcu_read_unlock(); 79 rcu_read_unlock();
80 return cgroup == mem; 80 return cgroup == mem;
81} 81}
diff --git a/include/linux/reiserfs_fs_sb.h b/include/linux/reiserfs_fs_sb.h
index 5621d87c4479..6b361d23a499 100644
--- a/include/linux/reiserfs_fs_sb.h
+++ b/include/linux/reiserfs_fs_sb.h
@@ -193,7 +193,7 @@ struct reiserfs_journal {
193 atomic_t j_wcount; /* count of writers for current commit */ 193 atomic_t j_wcount; /* count of writers for current commit */
194 unsigned long j_bcount; /* batch count. allows turning X transactions into 1 */ 194 unsigned long j_bcount; /* batch count. allows turning X transactions into 1 */
195 unsigned long j_first_unflushed_offset; /* first unflushed transactions offset */ 195 unsigned long j_first_unflushed_offset; /* first unflushed transactions offset */
196 unsigned long j_last_flush_trans_id; /* last fully flushed journal timestamp */ 196 unsigned j_last_flush_trans_id; /* last fully flushed journal timestamp */
197 struct buffer_head *j_header_bh; 197 struct buffer_head *j_header_bh;
198 198
199 time_t j_trans_start_time; /* time this transaction started */ 199 time_t j_trans_start_time; /* time this transaction started */
diff --git a/include/linux/seccomp.h b/include/linux/seccomp.h
index 262a8dccfa81..167c33361d9c 100644
--- a/include/linux/seccomp.h
+++ b/include/linux/seccomp.h
@@ -21,6 +21,8 @@ extern long prctl_set_seccomp(unsigned long);
21 21
22#else /* CONFIG_SECCOMP */ 22#else /* CONFIG_SECCOMP */
23 23
24#include <linux/errno.h>
25
24typedef struct { } seccomp_t; 26typedef struct { } seccomp_t;
25 27
26#define secure_computing(x) do { } while (0) 28#define secure_computing(x) do { } while (0)
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 2cc43fa380cb..a0faa18f7b1b 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -245,7 +245,12 @@ struct spi_master {
245 */ 245 */
246 u16 dma_alignment; 246 u16 dma_alignment;
247 247
248 /* setup mode and clock, etc (spi driver may call many times) */ 248 /* Setup mode and clock, etc (spi driver may call many times).
249 *
250 * IMPORTANT: this may be called when transfers to another
251 * device are active. DO NOT UPDATE SHARED REGISTERS in ways
252 * which could break those transfers.
253 */
249 int (*setup)(struct spi_device *spi); 254 int (*setup)(struct spi_device *spi);
250 255
251 /* bidirectional bulk transfers 256 /* bidirectional bulk transfers
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 3e3a4364cbff..795032edfc46 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -58,10 +58,17 @@ typedef int __bitwise suspend_state_t;
58 * by @begin(). 58 * by @begin().
59 * @prepare() is called right after devices have been suspended (ie. the 59 * @prepare() is called right after devices have been suspended (ie. the
60 * appropriate .suspend() method has been executed for each device) and 60 * appropriate .suspend() method has been executed for each device) and
61 * before the nonboot CPUs are disabled (it is executed with IRQs enabled). 61 * before device drivers' late suspend callbacks are executed. It returns
62 * This callback is optional. It returns 0 on success or a negative 62 * 0 on success or a negative error code otherwise, in which case the
63 * error code otherwise, in which case the system cannot enter the desired 63 * system cannot enter the desired sleep state (@prepare_late(), @enter(),
64 * sleep state (@enter() and @finish() will not be called in that case). 64 * @wake(), and @finish() will not be called in that case).
65 *
66 * @prepare_late: Finish preparing the platform for entering the system sleep
67 * state indicated by @begin().
68 * @prepare_late is called before disabling nonboot CPUs and after
69 * device drivers' late suspend callbacks have been executed. It returns
70 * 0 on success or a negative error code otherwise, in which case the
71 * system cannot enter the desired sleep state (@enter() and @wake()).
65 * 72 *
66 * @enter: Enter the system sleep state indicated by @begin() or represented by 73 * @enter: Enter the system sleep state indicated by @begin() or represented by
67 * the argument if @begin() is not implemented. 74 * the argument if @begin() is not implemented.
@@ -69,19 +76,26 @@ typedef int __bitwise suspend_state_t;
69 * error code otherwise, in which case the system cannot enter the desired 76 * error code otherwise, in which case the system cannot enter the desired
70 * sleep state. 77 * sleep state.
71 * 78 *
72 * @finish: Called when the system has just left a sleep state, right after 79 * @wake: Called when the system has just left a sleep state, right after
73 * the nonboot CPUs have been enabled and before devices are resumed (it is 80 * the nonboot CPUs have been enabled and before device drivers' early
74 * executed with IRQs enabled). 81 * resume callbacks are executed.
82 * This callback is optional, but should be implemented by the platforms
83 * that implement @prepare_late(). If implemented, it is always called
84 * after @enter(), even if @enter() fails.
85 *
86 * @finish: Finish wake-up of the platform.
87 * @finish is called right prior to calling device drivers' regular suspend
88 * callbacks.
75 * This callback is optional, but should be implemented by the platforms 89 * This callback is optional, but should be implemented by the platforms
76 * that implement @prepare(). If implemented, it is always called after 90 * that implement @prepare(). If implemented, it is always called after
77 * @enter() (even if @enter() fails). 91 * @enter() and @wake(), if implemented, even if any of them fails.
78 * 92 *
79 * @end: Called by the PM core right after resuming devices, to indicate to 93 * @end: Called by the PM core right after resuming devices, to indicate to
80 * the platform that the system has returned to the working state or 94 * the platform that the system has returned to the working state or
81 * the transition to the sleep state has been aborted. 95 * the transition to the sleep state has been aborted.
82 * This callback is optional, but should be implemented by the platforms 96 * This callback is optional, but should be implemented by the platforms
83 * that implement @begin(), but platforms implementing @begin() should 97 * that implement @begin(). Accordingly, platforms implementing @begin()
84 * also provide a @end() which cleans up transitions aborted before 98 * should also provide a @end() which cleans up transitions aborted before
85 * @enter(). 99 * @enter().
86 * 100 *
87 * @recover: Recover the platform from a suspend failure. 101 * @recover: Recover the platform from a suspend failure.
@@ -93,7 +107,9 @@ struct platform_suspend_ops {
93 int (*valid)(suspend_state_t state); 107 int (*valid)(suspend_state_t state);
94 int (*begin)(suspend_state_t state); 108 int (*begin)(suspend_state_t state);
95 int (*prepare)(void); 109 int (*prepare)(void);
110 int (*prepare_late)(void);
96 int (*enter)(suspend_state_t state); 111 int (*enter)(suspend_state_t state);
112 void (*wake)(void);
97 void (*finish)(void); 113 void (*finish)(void);
98 void (*end)(void); 114 void (*end)(void);
99 void (*recover)(void); 115 void (*recover)(void);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index dabe4ad89141..40617c1d8976 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -148,7 +148,7 @@ struct old_linux_dirent;
148 asm ("\t.globl " #alias "\n\t.set " #alias ", " #name "\n" \ 148 asm ("\t.globl " #alias "\n\t.set " #alias ", " #name "\n" \
149 "\t.globl ." #alias "\n\t.set ." #alias ", ." #name) 149 "\t.globl ." #alias "\n\t.set ." #alias ", ." #name)
150#else 150#else
151#ifdef CONFIG_ALPHA 151#if defined(CONFIG_ALPHA) || defined(CONFIG_MIPS)
152#define SYSCALL_ALIAS(alias, name) \ 152#define SYSCALL_ALIAS(alias, name) \
153 asm ( #alias " = " #name "\n\t.globl " #alias) 153 asm ( #alias " = " #name "\n\t.globl " #alias)
154#else 154#else
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index 917ab9525568..6e7351739a82 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -734,9 +734,6 @@ int audit_tag_tree(char *old, char *new)
734 dentry = dget(path.dentry); 734 dentry = dget(path.dentry);
735 path_put(&path); 735 path_put(&path);
736 736
737 if (dentry == tagged->mnt_root && dentry == mnt->mnt_root)
738 follow_up(&mnt, &dentry);
739
740 list_add_tail(&list, &tagged->mnt_list); 737 list_add_tail(&list, &tagged->mnt_list);
741 738
742 mutex_lock(&audit_filter_mutex); 739 mutex_lock(&audit_filter_mutex);
diff --git a/kernel/power/main.c b/kernel/power/main.c
index f172f41858bb..f99ed6a75eac 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -291,20 +291,26 @@ static int suspend_enter(suspend_state_t state)
291 291
292 device_pm_lock(); 292 device_pm_lock();
293 293
294 if (suspend_ops->prepare) {
295 error = suspend_ops->prepare();
296 if (error)
297 goto Done;
298 }
299
294 error = device_power_down(PMSG_SUSPEND); 300 error = device_power_down(PMSG_SUSPEND);
295 if (error) { 301 if (error) {
296 printk(KERN_ERR "PM: Some devices failed to power down\n"); 302 printk(KERN_ERR "PM: Some devices failed to power down\n");
297 goto Done; 303 goto Platfrom_finish;
298 } 304 }
299 305
300 if (suspend_ops->prepare) { 306 if (suspend_ops->prepare_late) {
301 error = suspend_ops->prepare(); 307 error = suspend_ops->prepare_late();
302 if (error) 308 if (error)
303 goto Power_up_devices; 309 goto Power_up_devices;
304 } 310 }
305 311
306 if (suspend_test(TEST_PLATFORM)) 312 if (suspend_test(TEST_PLATFORM))
307 goto Platfrom_finish; 313 goto Platform_wake;
308 314
309 error = disable_nonboot_cpus(); 315 error = disable_nonboot_cpus();
310 if (error || suspend_test(TEST_CPUS)) 316 if (error || suspend_test(TEST_CPUS))
@@ -326,13 +332,17 @@ static int suspend_enter(suspend_state_t state)
326 Enable_cpus: 332 Enable_cpus:
327 enable_nonboot_cpus(); 333 enable_nonboot_cpus();
328 334
329 Platfrom_finish: 335 Platform_wake:
330 if (suspend_ops->finish) 336 if (suspend_ops->wake)
331 suspend_ops->finish(); 337 suspend_ops->wake();
332 338
333 Power_up_devices: 339 Power_up_devices:
334 device_power_up(PMSG_RESUME); 340 device_power_up(PMSG_RESUME);
335 341
342 Platfrom_finish:
343 if (suspend_ops->finish)
344 suspend_ops->finish();
345
336 Done: 346 Done:
337 device_pm_unlock(); 347 device_pm_unlock();
338 348
diff --git a/kernel/resource.c b/kernel/resource.c
index fd5d7d574bb9..ac5f3a36923f 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -533,43 +533,21 @@ static void __init __reserve_region_with_split(struct resource *root,
533 res->end = end; 533 res->end = end;
534 res->flags = IORESOURCE_BUSY; 534 res->flags = IORESOURCE_BUSY;
535 535
536 for (;;) { 536 conflict = __request_resource(parent, res);
537 conflict = __request_resource(parent, res); 537 if (!conflict)
538 if (!conflict) 538 return;
539 break;
540 if (conflict != parent) {
541 parent = conflict;
542 if (!(conflict->flags & IORESOURCE_BUSY))
543 continue;
544 }
545
546 /* Uhhuh, that didn't work out.. */
547 kfree(res);
548 res = NULL;
549 break;
550 }
551
552 if (!res) {
553 /* failed, split and try again */
554
555 /* conflict covered whole area */
556 if (conflict->start <= start && conflict->end >= end)
557 return;
558 539
559 if (conflict->start > start) 540 /* failed, split and try again */
560 __reserve_region_with_split(root, start, conflict->start-1, name); 541 kfree(res);
561 if (!(conflict->flags & IORESOURCE_BUSY)) {
562 resource_size_t common_start, common_end;
563 542
564 common_start = max(conflict->start, start); 543 /* conflict covered whole area */
565 common_end = min(conflict->end, end); 544 if (conflict->start <= start && conflict->end >= end)
566 if (common_start < common_end) 545 return;
567 __reserve_region_with_split(root, common_start, common_end, name);
568 }
569 if (conflict->end < end)
570 __reserve_region_with_split(root, conflict->end+1, end, name);
571 }
572 546
547 if (conflict->start > start)
548 __reserve_region_with_split(root, start, conflict->start-1, name);
549 if (conflict->end < end)
550 __reserve_region_with_split(root, conflict->end+1, end, name);
573} 551}
574 552
575void __init reserve_region_with_split(struct resource *root, 553void __init reserve_region_with_split(struct resource *root,
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index c46c931a7fe7..ecfd7b5187e0 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -181,12 +181,12 @@ static void clocksource_watchdog(unsigned long data)
181 181
182 resumed = test_and_clear_bit(0, &watchdog_resumed); 182 resumed = test_and_clear_bit(0, &watchdog_resumed);
183 183
184 wdnow = watchdog->read(); 184 wdnow = watchdog->read(watchdog);
185 wd_nsec = cyc2ns(watchdog, (wdnow - watchdog_last) & watchdog->mask); 185 wd_nsec = cyc2ns(watchdog, (wdnow - watchdog_last) & watchdog->mask);
186 watchdog_last = wdnow; 186 watchdog_last = wdnow;
187 187
188 list_for_each_entry_safe(cs, tmp, &watchdog_list, wd_list) { 188 list_for_each_entry_safe(cs, tmp, &watchdog_list, wd_list) {
189 csnow = cs->read(); 189 csnow = cs->read(cs);
190 190
191 if (unlikely(resumed)) { 191 if (unlikely(resumed)) {
192 cs->wd_last = csnow; 192 cs->wd_last = csnow;
@@ -247,7 +247,7 @@ static void clocksource_check_watchdog(struct clocksource *cs)
247 247
248 list_add(&cs->wd_list, &watchdog_list); 248 list_add(&cs->wd_list, &watchdog_list);
249 if (!started && watchdog) { 249 if (!started && watchdog) {
250 watchdog_last = watchdog->read(); 250 watchdog_last = watchdog->read(watchdog);
251 watchdog_timer.expires = jiffies + WATCHDOG_INTERVAL; 251 watchdog_timer.expires = jiffies + WATCHDOG_INTERVAL;
252 add_timer_on(&watchdog_timer, 252 add_timer_on(&watchdog_timer,
253 cpumask_first(cpu_online_mask)); 253 cpumask_first(cpu_online_mask));
@@ -268,7 +268,7 @@ static void clocksource_check_watchdog(struct clocksource *cs)
268 cse->flags &= ~CLOCK_SOURCE_WATCHDOG; 268 cse->flags &= ~CLOCK_SOURCE_WATCHDOG;
269 /* Start if list is not empty */ 269 /* Start if list is not empty */
270 if (!list_empty(&watchdog_list)) { 270 if (!list_empty(&watchdog_list)) {
271 watchdog_last = watchdog->read(); 271 watchdog_last = watchdog->read(watchdog);
272 watchdog_timer.expires = 272 watchdog_timer.expires =
273 jiffies + WATCHDOG_INTERVAL; 273 jiffies + WATCHDOG_INTERVAL;
274 add_timer_on(&watchdog_timer, 274 add_timer_on(&watchdog_timer,
diff --git a/kernel/time/jiffies.c b/kernel/time/jiffies.c
index 06f197560f3b..c3f6c30816e3 100644
--- a/kernel/time/jiffies.c
+++ b/kernel/time/jiffies.c
@@ -50,7 +50,7 @@
50 */ 50 */
51#define JIFFIES_SHIFT 8 51#define JIFFIES_SHIFT 8
52 52
53static cycle_t jiffies_read(void) 53static cycle_t jiffies_read(struct clocksource *cs)
54{ 54{
55 return (cycle_t) jiffies; 55 return (cycle_t) jiffies;
56} 56}
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 900f1b6598d1..687dff49f6e7 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -182,7 +182,7 @@ EXPORT_SYMBOL(do_settimeofday);
182 */ 182 */
183static void change_clocksource(void) 183static void change_clocksource(void)
184{ 184{
185 struct clocksource *new; 185 struct clocksource *new, *old;
186 186
187 new = clocksource_get_next(); 187 new = clocksource_get_next();
188 188
@@ -191,11 +191,16 @@ static void change_clocksource(void)
191 191
192 clocksource_forward_now(); 192 clocksource_forward_now();
193 193
194 new->raw_time = clock->raw_time; 194 if (clocksource_enable(new))
195 return;
195 196
197 new->raw_time = clock->raw_time;
198 old = clock;
196 clock = new; 199 clock = new;
200 clocksource_disable(old);
201
197 clock->cycle_last = 0; 202 clock->cycle_last = 0;
198 clock->cycle_last = clocksource_read(new); 203 clock->cycle_last = clocksource_read(clock);
199 clock->error = 0; 204 clock->error = 0;
200 clock->xtime_nsec = 0; 205 clock->xtime_nsec = 0;
201 clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH); 206 clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH);
@@ -292,6 +297,7 @@ void __init timekeeping_init(void)
292 ntp_init(); 297 ntp_init();
293 298
294 clock = clocksource_get_next(); 299 clock = clocksource_get_next();
300 clocksource_enable(clock);
295 clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH); 301 clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH);
296 clock->cycle_last = clocksource_read(clock); 302 clock->cycle_last = clocksource_read(clock);
297 303
diff --git a/lib/kobject.c b/lib/kobject.c
index a6dec32f2ddd..bacf6fe4f7a0 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -218,6 +218,9 @@ int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
218 const char *old_name = kobj->name; 218 const char *old_name = kobj->name;
219 char *s; 219 char *s;
220 220
221 if (kobj->name && !fmt)
222 return 0;
223
221 kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs); 224 kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
222 if (!kobj->name) 225 if (!kobj->name)
223 return -ENOMEM; 226 return -ENOMEM;
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 39fdfb14eeaa..eac9577941f9 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -63,6 +63,9 @@ struct scan_control {
63 /* Can mapped pages be reclaimed? */ 63 /* Can mapped pages be reclaimed? */
64 int may_unmap; 64 int may_unmap;
65 65
66 /* Can pages be swapped as part of reclaim? */
67 int may_swap;
68
66 /* This context's SWAP_CLUSTER_MAX. If freeing memory for 69 /* This context's SWAP_CLUSTER_MAX. If freeing memory for
67 * suspend, we effectively ignore SWAP_CLUSTER_MAX. 70 * suspend, we effectively ignore SWAP_CLUSTER_MAX.
68 * In this context, it doesn't matter that we scan the 71 * In this context, it doesn't matter that we scan the
@@ -1380,7 +1383,7 @@ static void get_scan_ratio(struct zone *zone, struct scan_control *sc,
1380 struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(zone, sc); 1383 struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(zone, sc);
1381 1384
1382 /* If we have no swap space, do not bother scanning anon pages. */ 1385 /* If we have no swap space, do not bother scanning anon pages. */
1383 if (nr_swap_pages <= 0) { 1386 if (!sc->may_swap || (nr_swap_pages <= 0)) {
1384 percent[0] = 0; 1387 percent[0] = 0;
1385 percent[1] = 100; 1388 percent[1] = 100;
1386 return; 1389 return;
@@ -1697,6 +1700,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
1697 .may_writepage = !laptop_mode, 1700 .may_writepage = !laptop_mode,
1698 .swap_cluster_max = SWAP_CLUSTER_MAX, 1701 .swap_cluster_max = SWAP_CLUSTER_MAX,
1699 .may_unmap = 1, 1702 .may_unmap = 1,
1703 .may_swap = 1,
1700 .swappiness = vm_swappiness, 1704 .swappiness = vm_swappiness,
1701 .order = order, 1705 .order = order,
1702 .mem_cgroup = NULL, 1706 .mem_cgroup = NULL,
@@ -1717,6 +1721,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,
1717 struct scan_control sc = { 1721 struct scan_control sc = {
1718 .may_writepage = !laptop_mode, 1722 .may_writepage = !laptop_mode,
1719 .may_unmap = 1, 1723 .may_unmap = 1,
1724 .may_swap = !noswap,
1720 .swap_cluster_max = SWAP_CLUSTER_MAX, 1725 .swap_cluster_max = SWAP_CLUSTER_MAX,
1721 .swappiness = swappiness, 1726 .swappiness = swappiness,
1722 .order = 0, 1727 .order = 0,
@@ -1726,9 +1731,6 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,
1726 }; 1731 };
1727 struct zonelist *zonelist; 1732 struct zonelist *zonelist;
1728 1733
1729 if (noswap)
1730 sc.may_unmap = 0;
1731
1732 sc.gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) | 1734 sc.gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) |
1733 (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK); 1735 (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK);
1734 zonelist = NODE_DATA(numa_node_id())->node_zonelists; 1736 zonelist = NODE_DATA(numa_node_id())->node_zonelists;
@@ -1767,6 +1769,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)
1767 struct scan_control sc = { 1769 struct scan_control sc = {
1768 .gfp_mask = GFP_KERNEL, 1770 .gfp_mask = GFP_KERNEL,
1769 .may_unmap = 1, 1771 .may_unmap = 1,
1772 .may_swap = 1,
1770 .swap_cluster_max = SWAP_CLUSTER_MAX, 1773 .swap_cluster_max = SWAP_CLUSTER_MAX,
1771 .swappiness = vm_swappiness, 1774 .swappiness = vm_swappiness,
1772 .order = order, 1775 .order = order,
@@ -2088,13 +2091,13 @@ static void shrink_all_zones(unsigned long nr_pages, int prio,
2088 nr_reclaimed += shrink_list(l, nr_to_scan, zone, 2091 nr_reclaimed += shrink_list(l, nr_to_scan, zone,
2089 sc, prio); 2092 sc, prio);
2090 if (nr_reclaimed >= nr_pages) { 2093 if (nr_reclaimed >= nr_pages) {
2091 sc->nr_reclaimed = nr_reclaimed; 2094 sc->nr_reclaimed += nr_reclaimed;
2092 return; 2095 return;
2093 } 2096 }
2094 } 2097 }
2095 } 2098 }
2096 } 2099 }
2097 sc->nr_reclaimed = nr_reclaimed; 2100 sc->nr_reclaimed += nr_reclaimed;
2098} 2101}
2099 2102
2100/* 2103/*
@@ -2115,6 +2118,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)
2115 .may_unmap = 0, 2118 .may_unmap = 0,
2116 .may_writepage = 1, 2119 .may_writepage = 1,
2117 .isolate_pages = isolate_pages_global, 2120 .isolate_pages = isolate_pages_global,
2121 .nr_reclaimed = 0,
2118 }; 2122 };
2119 2123
2120 current->reclaim_state = &reclaim_state; 2124 current->reclaim_state = &reclaim_state;
@@ -2297,6 +2301,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
2297 struct scan_control sc = { 2301 struct scan_control sc = {
2298 .may_writepage = !!(zone_reclaim_mode & RECLAIM_WRITE), 2302 .may_writepage = !!(zone_reclaim_mode & RECLAIM_WRITE),
2299 .may_unmap = !!(zone_reclaim_mode & RECLAIM_SWAP), 2303 .may_unmap = !!(zone_reclaim_mode & RECLAIM_SWAP),
2304 .may_swap = 1,
2300 .swap_cluster_max = max_t(unsigned long, nr_pages, 2305 .swap_cluster_max = max_t(unsigned long, nr_pages,
2301 SWAP_CLUSTER_MAX), 2306 SWAP_CLUSTER_MAX),
2302 .gfp_mask = gfp_mask, 2307 .gfp_mask = gfp_mask,
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 39a9642927d3..5c4b7a400c18 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -27,6 +27,9 @@ ccflags-y :=
27cppflags-y := 27cppflags-y :=
28ldflags-y := 28ldflags-y :=
29 29
30subdir-asflags-y :=
31subdir-ccflags-y :=
32
30# Read auto.conf if it exists, otherwise ignore 33# Read auto.conf if it exists, otherwise ignore
31-include include/config/auto.conf 34-include include/config/auto.conf
32 35
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 979619574f70..cba61ca403ca 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -4,6 +4,11 @@ ccflags-y += $(EXTRA_CFLAGS)
4cppflags-y += $(EXTRA_CPPFLAGS) 4cppflags-y += $(EXTRA_CPPFLAGS)
5ldflags-y += $(EXTRA_LDFLAGS) 5ldflags-y += $(EXTRA_LDFLAGS)
6 6
7#
8# flags that take effect in sub directories
9export KBUILD_SUBDIR_ASFLAGS := $(KBUILD_SUBDIR_ASFLAGS) $(subdir-asflags-y)
10export KBUILD_SUBDIR_CCFLAGS := $(KBUILD_SUBDIR_CCFLAGS) $(subdir-ccflags-y)
11
7# Figure out what we need to build from the various variables 12# Figure out what we need to build from the various variables
8# =========================================================================== 13# ===========================================================================
9 14
@@ -104,10 +109,10 @@ else
104debug_flags = 109debug_flags =
105endif 110endif
106 111
107orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ 112orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \
108 $(ccflags-y) $(CFLAGS_$(basetarget).o) 113 $(ccflags-y) $(CFLAGS_$(basetarget).o)
109_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags)) 114_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
110_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \ 115_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \
111 $(asflags-y) $(AFLAGS_$(basetarget).o) 116 $(asflags-y) $(AFLAGS_$(basetarget).o)
112_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F)) 117_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
113 118
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 921514902eca..98b3195347ab 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -609,8 +609,12 @@ static int smack_inode_setxattr(struct dentry *dentry, const char *name,
609 strcmp(name, XATTR_NAME_SMACKIPOUT) == 0) { 609 strcmp(name, XATTR_NAME_SMACKIPOUT) == 0) {
610 if (!capable(CAP_MAC_ADMIN)) 610 if (!capable(CAP_MAC_ADMIN))
611 rc = -EPERM; 611 rc = -EPERM;
612 /* a label cannot be void and cannot begin with '-' */ 612 /*
613 if (size == 0 || (size > 0 && ((char *)value)[0] == '-')) 613 * check label validity here so import wont fail on
614 * post_setxattr
615 */
616 if (size == 0 || size >= SMK_LABELLEN ||
617 smk_import(value, size) == NULL)
614 rc = -EINVAL; 618 rc = -EINVAL;
615 } else 619 } else
616 rc = cap_inode_setxattr(dentry, name, value, size, flags); 620 rc = cap_inode_setxattr(dentry, name, value, size, flags);
@@ -644,9 +648,6 @@ static void smack_inode_post_setxattr(struct dentry *dentry, const char *name,
644 if (strcmp(name, XATTR_NAME_SMACK)) 648 if (strcmp(name, XATTR_NAME_SMACK))
645 return; 649 return;
646 650
647 if (size >= SMK_LABELLEN)
648 return;
649
650 isp = dentry->d_inode->i_security; 651 isp = dentry->d_inode->i_security;
651 652
652 /* 653 /*
diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c
index 4bfc31d1b281..c1a5aa15af8f 100644
--- a/sound/pci/emu10k1/io.c
+++ b/sound/pci/emu10k1/io.c
@@ -490,7 +490,7 @@ void snd_emu10k1_wait(struct snd_emu10k1 *emu, unsigned int wait)
490 if (newtime != curtime) 490 if (newtime != curtime)
491 break; 491 break;
492 } 492 }
493 if (count >= 16384) 493 if (count > 16384)
494 break; 494 break;
495 curtime = newtime; 495 curtime = newtime;
496 } 496 }
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index fd6e6f337d10..8820faf6c9d8 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -642,19 +642,21 @@ static int get_codec_name(struct hda_codec *codec)
642 */ 642 */
643static void /*__devinit*/ setup_fg_nodes(struct hda_codec *codec) 643static void /*__devinit*/ setup_fg_nodes(struct hda_codec *codec)
644{ 644{
645 int i, total_nodes; 645 int i, total_nodes, function_id;
646 hda_nid_t nid; 646 hda_nid_t nid;
647 647
648 total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid); 648 total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid);
649 for (i = 0; i < total_nodes; i++, nid++) { 649 for (i = 0; i < total_nodes; i++, nid++) {
650 codec->function_id = snd_hda_param_read(codec, nid, 650 function_id = snd_hda_param_read(codec, nid,
651 AC_PAR_FUNCTION_TYPE) & 0xff; 651 AC_PAR_FUNCTION_TYPE) & 0xff;
652 switch (codec->function_id) { 652 switch (function_id) {
653 case AC_GRP_AUDIO_FUNCTION: 653 case AC_GRP_AUDIO_FUNCTION:
654 codec->afg = nid; 654 codec->afg = nid;
655 codec->function_id = function_id;
655 break; 656 break;
656 case AC_GRP_MODEM_FUNCTION: 657 case AC_GRP_MODEM_FUNCTION:
657 codec->mfg = nid; 658 codec->mfg = nid;
659 codec->function_id = function_id;
658 break; 660 break;
659 default: 661 default:
660 break; 662 break;
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index bc882f8f163c..21e99cfa8c49 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -312,7 +312,6 @@ struct azx_dev {
312 unsigned int period_bytes; /* size of the period in bytes */ 312 unsigned int period_bytes; /* size of the period in bytes */
313 unsigned int frags; /* number for period in the play buffer */ 313 unsigned int frags; /* number for period in the play buffer */
314 unsigned int fifo_size; /* FIFO size */ 314 unsigned int fifo_size; /* FIFO size */
315 unsigned int start_flag: 1; /* stream full start flag */
316 unsigned long start_jiffies; /* start + minimum jiffies */ 315 unsigned long start_jiffies; /* start + minimum jiffies */
317 unsigned long min_jiffies; /* minimum jiffies before position is valid */ 316 unsigned long min_jiffies; /* minimum jiffies before position is valid */
318 317
@@ -333,6 +332,7 @@ struct azx_dev {
333 unsigned int opened :1; 332 unsigned int opened :1;
334 unsigned int running :1; 333 unsigned int running :1;
335 unsigned int irq_pending :1; 334 unsigned int irq_pending :1;
335 unsigned int start_flag: 1; /* stream full start flag */
336 /* 336 /*
337 * For VIA: 337 * For VIA:
338 * A flag to ensure DMA position is 0 338 * A flag to ensure DMA position is 0
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 38ad3f7b040f..9bcd8ab5a27f 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -3977,6 +3977,14 @@ static int patch_ad1884a(struct hda_codec *codec)
3977 spec->input_mux = &ad1884a_laptop_capture_source; 3977 spec->input_mux = &ad1884a_laptop_capture_source;
3978 codec->patch_ops.unsol_event = ad1884a_hp_unsol_event; 3978 codec->patch_ops.unsol_event = ad1884a_hp_unsol_event;
3979 codec->patch_ops.init = ad1884a_hp_init; 3979 codec->patch_ops.init = ad1884a_hp_init;
3980 /* set the upper-limit for mixer amp to 0dB for avoiding the
3981 * possible damage by overloading
3982 */
3983 snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
3984 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
3985 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
3986 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3987 (1 << AC_AMPCAP_MUTE_SHIFT));
3980 break; 3988 break;
3981 case AD1884A_MOBILE: 3989 case AD1884A_MOBILE:
3982 spec->mixers[0] = ad1884a_mobile_mixers; 3990 spec->mixers[0] = ad1884a_mobile_mixers;
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index ce30b459aee6..917bc5d3ac2c 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -3076,6 +3076,11 @@ static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3076 unsigned int wid_caps; 3076 unsigned int wid_caps;
3077 3077
3078 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) { 3078 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3079 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3080 wid_caps = get_wcaps(codec, pins[i]);
3081 if (wid_caps & AC_WCAP_UNSOL_CAP)
3082 spec->hp_detect = 1;
3083 }
3079 nid = dac_nids[i]; 3084 nid = dac_nids[i];
3080 if (!nid) 3085 if (!nid)
3081 continue; 3086 continue;
@@ -3119,11 +3124,6 @@ static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3119 err = create_controls_idx(codec, name, idx, nid, 3); 3124 err = create_controls_idx(codec, name, idx, nid, 3);
3120 if (err < 0) 3125 if (err < 0)
3121 return err; 3126 return err;
3122 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3123 wid_caps = get_wcaps(codec, pins[i]);
3124 if (wid_caps & AC_WCAP_UNSOL_CAP)
3125 spec->hp_detect = 1;
3126 }
3127 } 3127 }
3128 } 3128 }
3129 return 0; 3129 return 0;
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 5dced5b79387..8042d5398892 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -1854,6 +1854,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1854 }, 1854 },
1855 { 1855 {
1856 .subvendor = 0x1028, 1856 .subvendor = 0x1028,
1857 .subdevice = 0x016a,
1858 .name = "Dell Inspiron 8600", /* STAC9750/51 */
1859 .type = AC97_TUNE_HP_ONLY
1860 },
1861 {
1862 .subvendor = 0x1028,
1857 .subdevice = 0x0186, 1863 .subdevice = 0x0186,
1858 .name = "Dell Latitude D810", /* cf. Malone #41015 */ 1864 .name = "Dell Latitude D810", /* cf. Malone #41015 */
1859 .type = AC97_TUNE_HP_MUTE_LED 1865 .type = AC97_TUNE_HP_MUTE_LED
@@ -1896,12 +1902,6 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1896 }, 1902 },
1897 { 1903 {
1898 .subvendor = 0x103c, 1904 .subvendor = 0x103c,
1899 .subdevice = 0x0934,
1900 .name = "HP nx8220",
1901 .type = AC97_TUNE_MUTE_LED
1902 },
1903 {
1904 .subvendor = 0x103c,
1905 .subdevice = 0x129d, 1905 .subdevice = 0x129d,
1906 .name = "HP xw8000", 1906 .name = "HP xw8000",
1907 .type = AC97_TUNE_HP_ONLY 1907 .type = AC97_TUNE_HP_ONLY
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index 9c09b94f0cf8..90f4df7fd906 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -283,7 +283,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
283 break; 283 break;
284 case SND_SOC_DAIFMT_DSP_B: 284 case SND_SOC_DAIFMT_DSP_B:
285 regs->srgr2 |= FPER(wlen * channels - 1); 285 regs->srgr2 |= FPER(wlen * channels - 1);
286 regs->srgr1 |= FWID(wlen * channels - 2); 286 regs->srgr1 |= FWID(0);
287 break; 287 break;
288 } 288 }
289 289
@@ -302,6 +302,7 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
302{ 302{
303 struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); 303 struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data);
304 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; 304 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
305 unsigned int temp_fmt = fmt;
305 306
306 if (mcbsp_data->configured) 307 if (mcbsp_data->configured)
307 return 0; 308 return 0;
@@ -328,6 +329,8 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
328 /* 0-bit data delay */ 329 /* 0-bit data delay */
329 regs->rcr2 |= RDATDLY(0); 330 regs->rcr2 |= RDATDLY(0);
330 regs->xcr2 |= XDATDLY(0); 331 regs->xcr2 |= XDATDLY(0);
332 /* Invert FS polarity configuration */
333 temp_fmt ^= SND_SOC_DAIFMT_NB_IF;
331 break; 334 break;
332 default: 335 default:
333 /* Unsupported data format */ 336 /* Unsupported data format */
@@ -351,7 +354,7 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
351 } 354 }
352 355
353 /* Set bit clock (CLKX/CLKR) and FS polarities */ 356 /* Set bit clock (CLKX/CLKR) and FS polarities */
354 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 357 switch (temp_fmt & SND_SOC_DAIFMT_INV_MASK) {
355 case SND_SOC_DAIFMT_NB_NF: 358 case SND_SOC_DAIFMT_NB_NF:
356 /* 359 /*
357 * Normal BCLK + FS. 360 * Normal BCLK + FS.
diff --git a/sound/soc/omap/osk5912.c b/sound/soc/omap/osk5912.c
index a952a4eb3361..a4e149b7f0eb 100644
--- a/sound/soc/omap/osk5912.c
+++ b/sound/soc/omap/osk5912.c
@@ -62,7 +62,7 @@ static int osk_hw_params(struct snd_pcm_substream *substream,
62 /* Set codec DAI configuration */ 62 /* Set codec DAI configuration */
63 err = snd_soc_dai_set_fmt(codec_dai, 63 err = snd_soc_dai_set_fmt(codec_dai,
64 SND_SOC_DAIFMT_DSP_B | 64 SND_SOC_DAIFMT_DSP_B |
65 SND_SOC_DAIFMT_NB_IF | 65 SND_SOC_DAIFMT_NB_NF |
66 SND_SOC_DAIFMT_CBM_CFM); 66 SND_SOC_DAIFMT_CBM_CFM);
67 if (err < 0) { 67 if (err < 0) {
68 printk(KERN_ERR "can't set codec DAI configuration\n"); 68 printk(KERN_ERR "can't set codec DAI configuration\n");
@@ -72,7 +72,7 @@ static int osk_hw_params(struct snd_pcm_substream *substream,
72 /* Set cpu DAI configuration */ 72 /* Set cpu DAI configuration */
73 err = snd_soc_dai_set_fmt(cpu_dai, 73 err = snd_soc_dai_set_fmt(cpu_dai,
74 SND_SOC_DAIFMT_DSP_B | 74 SND_SOC_DAIFMT_DSP_B |
75 SND_SOC_DAIFMT_NB_IF | 75 SND_SOC_DAIFMT_NB_NF |
76 SND_SOC_DAIFMT_CBM_CFM); 76 SND_SOC_DAIFMT_CBM_CFM);
77 if (err < 0) { 77 if (err < 0) {
78 printk(KERN_ERR "can't set cpu DAI configuration\n"); 78 printk(KERN_ERR "can't set cpu DAI configuration\n");
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index 308a657928d2..de2254475d52 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -806,6 +806,7 @@ static int pxa_ssp_probe(struct platform_device *pdev,
806 goto err_priv; 806 goto err_priv;
807 } 807 }
808 808
809 priv->dai_fmt = (unsigned int) -1;
809 dai->private_data = priv; 810 dai->private_data = priv;
810 811
811 return 0; 812 return 0;
diff --git a/sound/soc/s3c24xx/jive_wm8750.c b/sound/soc/s3c24xx/jive_wm8750.c
index 32063790d95b..93e6c87b7399 100644
--- a/sound/soc/s3c24xx/jive_wm8750.c
+++ b/sound/soc/s3c24xx/jive_wm8750.c
@@ -69,8 +69,8 @@ static int jive_hw_params(struct snd_pcm_substream *substream,
69 break; 69 break;
70 } 70 }
71 71
72 s3c_i2sv2_calc_rate(&div, NULL, params_rate(params), 72 s3c_i2sv2_iis_calc_rate(&div, NULL, params_rate(params),
73 s3c2412_get_iisclk()); 73 s3c2412_get_iisclk());
74 74
75 /* set codec DAI configuration */ 75 /* set codec DAI configuration */
76 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | 76 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
@@ -145,8 +145,9 @@ static struct snd_soc_dai_link jive_dai = {
145}; 145};
146 146
147/* jive audio machine driver */ 147/* jive audio machine driver */
148static struct snd_soc_machine snd_soc_machine_jive = { 148static struct snd_soc_card snd_soc_machine_jive = {
149 .name = "Jive", 149 .name = "Jive",
150 .platform = &s3c24xx_soc_platform,
150 .dai_link = &jive_dai, 151 .dai_link = &jive_dai,
151 .num_links = 1, 152 .num_links = 1,
152}; 153};
@@ -157,9 +158,8 @@ static struct wm8750_setup_data jive_wm8750_setup = {
157 158
158/* jive audio subsystem */ 159/* jive audio subsystem */
159static struct snd_soc_device jive_snd_devdata = { 160static struct snd_soc_device jive_snd_devdata = {
160 .machine = &snd_soc_machine_jive, 161 .card = &snd_soc_machine_jive,
161 .platform = &s3c24xx_soc_platform, 162 .codec_dev = &soc_codec_dev_wm8750,
162 .codec_dev = &soc_codec_dev_wm8750_spi,
163 .codec_data = &jive_wm8750_setup, 163 .codec_data = &jive_wm8750_setup,
164}; 164};
165 165
diff --git a/sound/soc/s3c24xx/s3c-i2s-v2.c b/sound/soc/s3c24xx/s3c-i2s-v2.c
index 295a4c910262..689ffcd17e1f 100644
--- a/sound/soc/s3c24xx/s3c-i2s-v2.c
+++ b/sound/soc/s3c24xx/s3c-i2s-v2.c
@@ -473,9 +473,9 @@ static int s3c2412_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai,
473/* default table of all avaialable root fs divisors */ 473/* default table of all avaialable root fs divisors */
474static unsigned int iis_fs_tab[] = { 256, 512, 384, 768 }; 474static unsigned int iis_fs_tab[] = { 256, 512, 384, 768 };
475 475
476int s3c2412_iis_calc_rate(struct s3c_i2sv2_rate_calc *info, 476int s3c_i2sv2_iis_calc_rate(struct s3c_i2sv2_rate_calc *info,
477 unsigned int *fstab, 477 unsigned int *fstab,
478 unsigned int rate, struct clk *clk) 478 unsigned int rate, struct clk *clk)
479{ 479{
480 unsigned long clkrate = clk_get_rate(clk); 480 unsigned long clkrate = clk_get_rate(clk);
481 unsigned int div; 481 unsigned int div;
@@ -531,7 +531,7 @@ int s3c2412_iis_calc_rate(struct s3c_i2sv2_rate_calc *info,
531 531
532 return 0; 532 return 0;
533} 533}
534EXPORT_SYMBOL_GPL(s3c2412_iis_calc_rate); 534EXPORT_SYMBOL_GPL(s3c_i2sv2_iis_calc_rate);
535 535
536int s3c_i2sv2_probe(struct platform_device *pdev, 536int s3c_i2sv2_probe(struct platform_device *pdev,
537 struct snd_soc_dai *dai, 537 struct snd_soc_dai *dai,
@@ -624,10 +624,12 @@ static int s3c2412_i2s_resume(struct snd_soc_dai *dai)
624 624
625int s3c_i2sv2_register_dai(struct snd_soc_dai *dai) 625int s3c_i2sv2_register_dai(struct snd_soc_dai *dai)
626{ 626{
627 dai->ops.trigger = s3c2412_i2s_trigger; 627 struct snd_soc_dai_ops *ops = dai->ops;
628 dai->ops.hw_params = s3c2412_i2s_hw_params; 628
629 dai->ops.set_fmt = s3c2412_i2s_set_fmt; 629 ops->trigger = s3c2412_i2s_trigger;
630 dai->ops.set_clkdiv = s3c2412_i2s_set_clkdiv; 630 ops->hw_params = s3c2412_i2s_hw_params;
631 ops->set_fmt = s3c2412_i2s_set_fmt;
632 ops->set_clkdiv = s3c2412_i2s_set_clkdiv;
631 633
632 dai->suspend = s3c2412_i2s_suspend; 634 dai->suspend = s3c2412_i2s_suspend;
633 dai->resume = s3c2412_i2s_resume; 635 dai->resume = s3c2412_i2s_resume;
diff --git a/sound/soc/s3c24xx/s3c2412-i2s.c b/sound/soc/s3c24xx/s3c2412-i2s.c
index 1ca3cdaa8213..b7e0b3f0bfc8 100644
--- a/sound/soc/s3c24xx/s3c2412-i2s.c
+++ b/sound/soc/s3c24xx/s3c2412-i2s.c
@@ -33,8 +33,8 @@
33 33
34#include <plat/regs-s3c2412-iis.h> 34#include <plat/regs-s3c2412-iis.h>
35 35
36#include <plat/regs-gpio.h>
37#include <plat/audio.h> 36#include <plat/audio.h>
37#include <mach/regs-gpio.h>
38#include <mach/dma.h> 38#include <mach/dma.h>
39 39
40#include "s3c24xx-pcm.h" 40#include "s3c24xx-pcm.h"