aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/kernel-parameters.txt8
-rw-r--r--Documentation/sysctl/kernel.txt8
-rw-r--r--Documentation/trace/postprocess/trace-vmscan-postprocess.pl8
-rw-r--r--MAINTAINERS7
-rw-r--r--arch/alpha/include/asm/unistd.h4
-rw-r--r--arch/alpha/kernel/systbls.S2
-rw-r--r--arch/arm/mach-imx/mach-mx27_3ds.c6
-rw-r--r--arch/arm/mach-imx/mach-mx31_3ds.c6
-rw-r--r--arch/cris/arch-v10/kernel/kgdb.c6
-rw-r--r--arch/cris/arch-v32/kernel/kgdb.c14
-rw-r--r--arch/frv/kernel/gdb-stub.c44
-rw-r--r--arch/mn10300/kernel/gdb-stub.c52
-rw-r--r--arch/powerpc/include/asm/systbl.h2
-rw-r--r--arch/powerpc/include/asm/unistd.h4
-rw-r--r--arch/x86/ia32/ia32entry.S2
-rw-r--r--arch/x86/include/asm/unistd_32.h4
-rw-r--r--arch/x86/include/asm/unistd_64.h4
-rw-r--r--arch/x86/kernel/syscall_table_32.S2
-rw-r--r--drivers/hwmon/hwmon.c32
-rw-r--r--drivers/hwmon/ibmaem.c47
-rw-r--r--drivers/infiniband/core/umem.c6
-rw-r--r--drivers/infiniband/hw/ipath/ipath_user_pages.c6
-rw-r--r--drivers/infiniband/hw/qib/qib_user_pages.c4
-rw-r--r--drivers/isdn/hisax/callc.c4
-rw-r--r--drivers/isdn/hisax/hisax.h4
-rw-r--r--drivers/isdn/hisax/isdnl1.h2
-rw-r--r--drivers/isdn/hisax/isdnl3.c2
-rw-r--r--drivers/isdn/hisax/st5481_d.c4
-rw-r--r--drivers/leds/Kconfig12
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/led-class.c7
-rw-r--r--drivers/leds/led-triggers.c5
-rw-r--r--drivers/leds/leds-gpio.c2
-rw-r--r--drivers/leds/leds-lm3530.c3
-rw-r--r--drivers/leds/leds-lp5521.c24
-rw-r--r--drivers/leds/leds-renesas-tpu.c357
-rw-r--r--drivers/misc/ad525x_dpot-i2c.c1
-rw-r--r--drivers/misc/fsa9480.c3
-rw-r--r--drivers/misc/lis3lv02d/lis3lv02d.c389
-rw-r--r--drivers/misc/lis3lv02d/lis3lv02d.h9
-rw-r--r--drivers/misc/lis3lv02d/lis3lv02d_i2c.c45
-rw-r--r--drivers/misc/lis3lv02d/lis3lv02d_spi.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4_en.h3
-rw-r--r--drivers/net/wireless/at76c50x-usb.c2
-rw-r--r--drivers/net/wireless/ath/ath.h5
-rw-r--r--drivers/net/wireless/ath/ath5k/debug.h4
-rw-r--r--drivers/net/wireless/ath/ath6kl/debug.h4
-rw-r--r--drivers/net/wireless/b43/b43.h12
-rw-r--r--drivers/net/wireless/b43legacy/b43legacy.h16
-rw-r--r--drivers/platform/x86/hp_accel.c10
-rw-r--r--drivers/staging/iio/trigger.h3
-rw-r--r--drivers/video/backlight/adp8870_bl.c2
-rw-r--r--drivers/video/backlight/generic_bl.c4
-rw-r--r--drivers/video/backlight/l4f00242t03.c70
-rw-r--r--fs/Kconfig2
-rw-r--r--fs/aio.c4
-rw-r--r--fs/buffer.c5
-rw-r--r--fs/compat.c7
-rw-r--r--fs/ecryptfs/ecryptfs_kernel.h2
-rw-r--r--fs/eventpoll.c25
-rw-r--r--fs/exec.c4
-rw-r--r--fs/ext2/ext2.h8
-rw-r--r--fs/ext4/ext4.h44
-rw-r--r--fs/ext4/inode.c6
-rw-r--r--fs/fat/dir.c4
-rw-r--r--fs/fat/fat.h9
-rw-r--r--fs/gfs2/glock.h2
-rw-r--r--fs/hpfs/hpfs_fn.h4
-rw-r--r--fs/logfs/logfs.h1
-rw-r--r--fs/logfs/super.c22
-rw-r--r--fs/nilfs2/nilfs.h8
-rw-r--r--fs/ntfs/debug.h15
-rw-r--r--fs/ocfs2/super.h14
-rw-r--r--fs/partitions/ldm.c16
-rw-r--r--fs/pipe.c1
-rw-r--r--fs/proc/base.c13
-rw-r--r--fs/proc/task_mmu.c5
-rw-r--r--fs/read_write.c8
-rw-r--r--fs/super.c2
-rw-r--r--fs/udf/udfdecl.h4
-rw-r--r--fs/ufs/ufs.h9
-rw-r--r--fs/xfs/xfs_aops.c8
-rw-r--r--fs/xfs/xfs_message.h42
-rw-r--r--include/asm-generic/bug.h11
-rw-r--r--include/asm-generic/dma-mapping-common.h14
-rw-r--r--include/asm-generic/page.h4
-rw-r--r--include/drm/drmP.h10
-rw-r--r--include/linux/audit.h11
-rw-r--r--include/linux/blktrace_api.h2
-rw-r--r--include/linux/compaction.h8
-rw-r--r--include/linux/compat.h3
-rw-r--r--include/linux/device.h110
-rw-r--r--include/linux/dmar.h2
-rw-r--r--include/linux/dynamic_debug.h19
-rw-r--r--include/linux/ext3_fs.h16
-rw-r--r--include/linux/fs.h11
-rw-r--r--include/linux/fscache-cache.h8
-rw-r--r--include/linux/gameport.h8
-rw-r--r--include/linux/huge_mm.h5
-rw-r--r--include/linux/kallsyms.h5
-rw-r--r--include/linux/kdb.h9
-rw-r--r--include/linux/kernel.h55
-rw-r--r--include/linux/kexec.h4
-rw-r--r--include/linux/kmod.h4
-rw-r--r--include/linux/kobject.h26
-rw-r--r--include/linux/kthread.h4
-rw-r--r--include/linux/libata.h18
-rw-r--r--include/linux/lis3lv02d.h1
-rw-r--r--include/linux/llist.h2
-rw-r--r--include/linux/memblock.h1
-rw-r--r--include/linux/memcontrol.h3
-rw-r--r--include/linux/mm.h3
-rw-r--r--include/linux/mm_types.h14
-rw-r--r--include/linux/mmiotrace.h8
-rw-r--r--include/linux/mmzone.h13
-rw-r--r--include/linux/netdevice.h34
-rw-r--r--include/linux/oom.h1
-rw-r--r--include/linux/platform_data/leds-renesas-tpu.h14
-rw-r--r--include/linux/printk.h12
-rw-r--r--include/linux/quotaops.h2
-rw-r--r--include/linux/seq_file.h3
-rw-r--r--include/linux/shrinker.h1
-rw-r--r--include/linux/spi/l4f00242t03.h2
-rw-r--r--include/linux/string.h1
-rw-r--r--include/linux/swap.h7
-rw-r--r--include/linux/syscalls.h13
-rw-r--r--include/linux/trace_seq.h8
-rw-r--r--include/linux/vmalloc.h1
-rw-r--r--include/net/bluetooth/bluetooth.h2
-rw-r--r--include/net/netfilter/nf_log.h3
-rw-r--r--include/net/sock.h4
-rw-r--r--include/sound/core.h4
-rw-r--r--include/sound/info.h4
-rw-r--r--include/sound/seq_kernel.h4
-rw-r--r--include/trace/events/vmscan.h8
-rw-r--r--include/xen/hvc-console.h4
-rw-r--r--include/xen/xenbus.h12
-rw-r--r--ipc/mqueue.c4
-rw-r--r--kernel/debug/gdbstub.c12
-rw-r--r--kernel/events/core.c6
-rw-r--r--kernel/exit.c2
-rw-r--r--kernel/fork.c10
-rw-r--r--kernel/printk.c10
-rw-r--r--kernel/stop_machine.c22
-rw-r--r--kernel/sys_ni.c4
-rw-r--r--kernel/sysctl.c9
-rw-r--r--kernel/watchdog.c4
-rw-r--r--lib/Kconfig.debug5
-rw-r--r--lib/bitmap.c10
-rw-r--r--lib/idr.c4
-rw-r--r--lib/kstrtox.c75
-rw-r--r--lib/kstrtox.h8
-rw-r--r--lib/percpu_counter.c2
-rw-r--r--lib/radix-tree.c10
-rw-r--r--lib/spinlock_debug.c19
-rw-r--r--lib/string.c57
-rw-r--r--lib/vsprintf.c47
-rw-r--r--mm/Kconfig3
-rw-r--r--mm/Makefile3
-rw-r--r--mm/backing-dev.c5
-rw-r--r--mm/compaction.c26
-rw-r--r--mm/debug-pagealloc.c56
-rw-r--r--mm/highmem.c2
-rw-r--r--mm/huge_memory.c54
-rw-r--r--mm/ksm.c3
-rw-r--r--mm/memblock.c11
-rw-r--r--mm/memcontrol.c3
-rw-r--r--mm/memory-failure.c12
-rw-r--r--mm/mempolicy.c2
-rw-r--r--mm/migrate.c75
-rw-r--r--mm/mlock.c13
-rw-r--r--mm/mmap.c9
-rw-r--r--mm/mremap.c42
-rw-r--r--mm/oom_kill.c53
-rw-r--r--mm/page-writeback.c4
-rw-r--r--mm/page_alloc.c17
-rw-r--r--mm/process_vm_access.c496
-rw-r--r--mm/rmap.c2
-rw-r--r--mm/shmem.c6
-rw-r--r--mm/slub.c47
-rw-r--r--mm/swapfile.c2
-rw-r--r--mm/thrash.c2
-rw-r--r--mm/vmalloc.c80
-rw-r--r--mm/vmscan.c325
-rw-r--r--mm/vmstat.c3
-rw-r--r--net/nfc/nfc.h2
-rw-r--r--net/rds/rds.h8
-rw-r--r--net/sunrpc/svc.c5
-rwxr-xr-xscripts/checkpatch.pl36
-rw-r--r--security/keys/compat.c2
-rw-r--r--security/keys/encrypted-keys/encrypted.c2
-rw-r--r--security/keys/keyctl.c2
-rw-r--r--security/keys/trusted.c2
-rw-r--r--sound/firewire/cmp.c2
194 files changed, 2520 insertions, 1356 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 661efd4dab6b..a0c5c5f4fce6 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -973,6 +973,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
973 ignore_loglevel [KNL] 973 ignore_loglevel [KNL]
974 Ignore loglevel setting - this will print /all/ 974 Ignore loglevel setting - this will print /all/
975 kernel messages to the console. Useful for debugging. 975 kernel messages to the console. Useful for debugging.
976 We also add it as printk module parameter, so users
977 could change it dynamically, usually by
978 /sys/module/printk/parameters/ignore_loglevel.
976 979
977 ihash_entries= [KNL] 980 ihash_entries= [KNL]
978 Set number of hash buckets for inode cache. 981 Set number of hash buckets for inode cache.
@@ -1666,6 +1669,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1666 debugging driver suspend/resume hooks). This may 1669 debugging driver suspend/resume hooks). This may
1667 not work reliably with all consoles, but is known 1670 not work reliably with all consoles, but is known
1668 to work with serial and VGA consoles. 1671 to work with serial and VGA consoles.
1672 To facilitate more flexible debugging, we also add
1673 console_suspend, a printk module parameter to control
1674 it. Users could use console_suspend (usually
1675 /sys/module/printk/parameters/console_suspend) to
1676 turn on/off it dynamically.
1669 1677
1670 noaliencache [MM, NUMA, SLAB] Disables the allocation of alien 1678 noaliencache [MM, NUMA, SLAB] Disables the allocation of alien
1671 caches in the slab allocator. Saves per-node memory, 1679 caches in the slab allocator. Saves per-node memory,
diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
index 704e474a93df..1f2463671a1a 100644
--- a/Documentation/sysctl/kernel.txt
+++ b/Documentation/sysctl/kernel.txt
@@ -24,6 +24,7 @@ show up in /proc/sys/kernel:
24- bootloader_type [ X86 only ] 24- bootloader_type [ X86 only ]
25- bootloader_version [ X86 only ] 25- bootloader_version [ X86 only ]
26- callhome [ S390 only ] 26- callhome [ S390 only ]
27- cap_last_cap
27- core_pattern 28- core_pattern
28- core_pipe_limit 29- core_pipe_limit
29- core_uses_pid 30- core_uses_pid
@@ -155,6 +156,13 @@ on has a service contract with IBM.
155 156
156============================================================== 157==============================================================
157 158
159cap_last_cap
160
161Highest valid capability of the running kernel. Exports
162CAP_LAST_CAP from the kernel.
163
164==============================================================
165
158core_pattern: 166core_pattern:
159 167
160core_pattern is used to specify a core dumpfile pattern name. 168core_pattern is used to specify a core dumpfile pattern name.
diff --git a/Documentation/trace/postprocess/trace-vmscan-postprocess.pl b/Documentation/trace/postprocess/trace-vmscan-postprocess.pl
index 12cecc83cd91..4a37c4759cd2 100644
--- a/Documentation/trace/postprocess/trace-vmscan-postprocess.pl
+++ b/Documentation/trace/postprocess/trace-vmscan-postprocess.pl
@@ -379,10 +379,10 @@ EVENT_PROCESS:
379 379
380 # To closer match vmstat scanning statistics, only count isolate_both 380 # To closer match vmstat scanning statistics, only count isolate_both
381 # and isolate_inactive as scanning. isolate_active is rotation 381 # and isolate_inactive as scanning. isolate_active is rotation
382 # isolate_inactive == 0 382 # isolate_inactive == 1
383 # isolate_active == 1 383 # isolate_active == 2
384 # isolate_both == 2 384 # isolate_both == 3
385 if ($isolate_mode != 1) { 385 if ($isolate_mode != 2) {
386 $perprocesspid{$process_pid}->{HIGH_NR_SCANNED} += $nr_scanned; 386 $perprocesspid{$process_pid}->{HIGH_NR_SCANNED} += $nr_scanned;
387 } 387 }
388 $perprocesspid{$process_pid}->{HIGH_NR_CONTIG_DIRTY} += $nr_contig_dirty; 388 $perprocesspid{$process_pid}->{HIGH_NR_CONTIG_DIRTY} += $nr_contig_dirty;
diff --git a/MAINTAINERS b/MAINTAINERS
index d498c70e394a..4befa126852e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -316,6 +316,10 @@ W: http://wiki.analog.com/AD7879
316S: Supported 316S: Supported
317F: drivers/input/touchscreen/ad7879.c 317F: drivers/input/touchscreen/ad7879.c
318 318
319ADDRESS SPACE LAYOUT RANDOMIZATION (ASLR)
320M: Jiri Kosina <jkosina@suse.cz>
321S: Maintained
322
319ADM1025 HARDWARE MONITOR DRIVER 323ADM1025 HARDWARE MONITOR DRIVER
320M: Jean Delvare <khali@linux-fr.org> 324M: Jean Delvare <khali@linux-fr.org>
321L: lm-sensors@lm-sensors.org 325L: lm-sensors@lm-sensors.org
@@ -4020,6 +4024,7 @@ M: Eric Piel <eric.piel@tremplin-utc.net>
4020S: Maintained 4024S: Maintained
4021F: Documentation/misc-devices/lis3lv02d 4025F: Documentation/misc-devices/lis3lv02d
4022F: drivers/misc/lis3lv02d/ 4026F: drivers/misc/lis3lv02d/
4027F: drivers/platform/x86/hp_accel.c
4023 4028
4024LLC (802.2) 4029LLC (802.2)
4025M: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> 4030M: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
@@ -4974,7 +4979,7 @@ F: include/linux/i2c-algo-pca.h
4974F: include/linux/i2c-pca-platform.h 4979F: include/linux/i2c-pca-platform.h
4975 4980
4976PCI ERROR RECOVERY 4981PCI ERROR RECOVERY
4977M: Linas Vepstas <linas@austin.ibm.com> 4982M: Linas Vepstas <linasvepstas@gmail.com>
4978L: linux-pci@vger.kernel.org 4983L: linux-pci@vger.kernel.org
4979S: Supported 4984S: Supported
4980F: Documentation/PCI/pci-error-recovery.txt 4985F: Documentation/PCI/pci-error-recovery.txt
diff --git a/arch/alpha/include/asm/unistd.h b/arch/alpha/include/asm/unistd.h
index 4ac48a095f3a..2207fc61665d 100644
--- a/arch/alpha/include/asm/unistd.h
+++ b/arch/alpha/include/asm/unistd.h
@@ -457,10 +457,12 @@
457#define __NR_clock_adjtime 499 457#define __NR_clock_adjtime 499
458#define __NR_syncfs 500 458#define __NR_syncfs 500
459#define __NR_setns 501 459#define __NR_setns 501
460#define __NR_accept4 502
461#define __NR_sendmmsg 503
460 462
461#ifdef __KERNEL__ 463#ifdef __KERNEL__
462 464
463#define NR_SYSCALLS 502 465#define NR_SYSCALLS 504
464 466
465#define __ARCH_WANT_IPC_PARSE_VERSION 467#define __ARCH_WANT_IPC_PARSE_VERSION
466#define __ARCH_WANT_OLD_READDIR 468#define __ARCH_WANT_OLD_READDIR
diff --git a/arch/alpha/kernel/systbls.S b/arch/alpha/kernel/systbls.S
index 6acea1f96de3..e534e1c5bc11 100644
--- a/arch/alpha/kernel/systbls.S
+++ b/arch/alpha/kernel/systbls.S
@@ -520,6 +520,8 @@ sys_call_table:
520 .quad sys_clock_adjtime 520 .quad sys_clock_adjtime
521 .quad sys_syncfs /* 500 */ 521 .quad sys_syncfs /* 500 */
522 .quad sys_setns 522 .quad sys_setns
523 .quad sys_accept4
524 .quad sys_sendmmsg
523 525
524 .size sys_call_table, . - sys_call_table 526 .size sys_call_table, . - sys_call_table
525 .type sys_call_table, @object 527 .type sys_call_table, @object
diff --git a/arch/arm/mach-imx/mach-mx27_3ds.c b/arch/arm/mach-imx/mach-mx27_3ds.c
index 2eafbac2c763..377230497dcc 100644
--- a/arch/arm/mach-imx/mach-mx27_3ds.c
+++ b/arch/arm/mach-imx/mach-mx27_3ds.c
@@ -241,7 +241,7 @@ static struct regulator_init_data gpo_init = {
241}; 241};
242 242
243static struct regulator_consumer_supply vmmc1_consumers[] = { 243static struct regulator_consumer_supply vmmc1_consumers[] = {
244 REGULATOR_SUPPLY("lcd_2v8", NULL), 244 REGULATOR_SUPPLY("vcore", "spi0.0"),
245}; 245};
246 246
247static struct regulator_init_data vmmc1_init = { 247static struct regulator_init_data vmmc1_init = {
@@ -257,7 +257,7 @@ static struct regulator_init_data vmmc1_init = {
257}; 257};
258 258
259static struct regulator_consumer_supply vgen_consumers[] = { 259static struct regulator_consumer_supply vgen_consumers[] = {
260 REGULATOR_SUPPLY("vdd_lcdio", NULL), 260 REGULATOR_SUPPLY("vdd", "spi0.0"),
261}; 261};
262 262
263static struct regulator_init_data vgen_init = { 263static struct regulator_init_data vgen_init = {
@@ -348,8 +348,6 @@ static const struct imx_fb_platform_data mx27_3ds_fb_data __initconst = {
348static struct l4f00242t03_pdata mx27_3ds_lcd_pdata = { 348static struct l4f00242t03_pdata mx27_3ds_lcd_pdata = {
349 .reset_gpio = LCD_RESET, 349 .reset_gpio = LCD_RESET,
350 .data_enable_gpio = LCD_ENABLE, 350 .data_enable_gpio = LCD_ENABLE,
351 .core_supply = "lcd_2v8",
352 .io_supply = "vdd_lcdio",
353}; 351};
354 352
355static struct spi_board_info mx27_3ds_spi_devs[] __initdata = { 353static struct spi_board_info mx27_3ds_spi_devs[] __initdata = {
diff --git a/arch/arm/mach-imx/mach-mx31_3ds.c b/arch/arm/mach-imx/mach-mx31_3ds.c
index 589066fb3316..6484db525bd7 100644
--- a/arch/arm/mach-imx/mach-mx31_3ds.c
+++ b/arch/arm/mach-imx/mach-mx31_3ds.c
@@ -285,8 +285,6 @@ static struct mx3fb_platform_data mx3fb_pdata __initdata = {
285static struct l4f00242t03_pdata mx31_3ds_l4f00242t03_pdata = { 285static struct l4f00242t03_pdata mx31_3ds_l4f00242t03_pdata = {
286 .reset_gpio = IOMUX_TO_GPIO(MX31_PIN_LCS1), 286 .reset_gpio = IOMUX_TO_GPIO(MX31_PIN_LCS1),
287 .data_enable_gpio = IOMUX_TO_GPIO(MX31_PIN_SER_RS), 287 .data_enable_gpio = IOMUX_TO_GPIO(MX31_PIN_SER_RS),
288 .core_supply = "lcd_2v8",
289 .io_supply = "vdd_lcdio",
290}; 288};
291 289
292/* 290/*
@@ -411,7 +409,7 @@ static struct regulator_init_data vmmc2_init = {
411}; 409};
412 410
413static struct regulator_consumer_supply vmmc1_consumers[] = { 411static struct regulator_consumer_supply vmmc1_consumers[] = {
414 REGULATOR_SUPPLY("lcd_2v8", NULL), 412 REGULATOR_SUPPLY("vcore", "spi0.0"),
415 REGULATOR_SUPPLY("cmos_2v8", "soc-camera-pdrv.0"), 413 REGULATOR_SUPPLY("cmos_2v8", "soc-camera-pdrv.0"),
416}; 414};
417 415
@@ -428,7 +426,7 @@ static struct regulator_init_data vmmc1_init = {
428}; 426};
429 427
430static struct regulator_consumer_supply vgen_consumers[] = { 428static struct regulator_consumer_supply vgen_consumers[] = {
431 REGULATOR_SUPPLY("vdd_lcdio", NULL), 429 REGULATOR_SUPPLY("vdd", "spi0.0"),
432}; 430};
433 431
434static struct regulator_init_data vgen_init = { 432static struct regulator_init_data vgen_init = {
diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c
index b9f9c8ce2169..b579dd02e098 100644
--- a/arch/cris/arch-v10/kernel/kgdb.c
+++ b/arch/cris/arch-v10/kernel/kgdb.c
@@ -694,7 +694,7 @@ mem2hex(char *buf, unsigned char *mem, int count)
694 /* Valid mem address. */ 694 /* Valid mem address. */
695 for (i = 0; i < count; i++) { 695 for (i = 0; i < count; i++) {
696 ch = *mem++; 696 ch = *mem++;
697 buf = pack_hex_byte(buf, ch); 697 buf = hex_byte_pack(buf, ch);
698 } 698 }
699 } 699 }
700 700
@@ -868,7 +868,7 @@ stub_is_stopped(int sigval)
868 /* Send trap type (converted to signal) */ 868 /* Send trap type (converted to signal) */
869 869
870 *ptr++ = 'T'; 870 *ptr++ = 'T';
871 ptr = pack_hex_byte(ptr, sigval); 871 ptr = hex_byte_pack(ptr, sigval);
872 872
873 /* Send register contents. We probably only need to send the 873 /* Send register contents. We probably only need to send the
874 * PC, frame pointer and stack pointer here. Other registers will be 874 * PC, frame pointer and stack pointer here. Other registers will be
@@ -881,7 +881,7 @@ stub_is_stopped(int sigval)
881 status = read_register (regno, &reg_cont); 881 status = read_register (regno, &reg_cont);
882 882
883 if (status == SUCCESS) { 883 if (status == SUCCESS) {
884 ptr = pack_hex_byte(ptr, regno); 884 ptr = hex_byte_pack(ptr, regno);
885 *ptr++ = ':'; 885 *ptr++ = ':';
886 886
887 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, 887 ptr = mem2hex(ptr, (unsigned char *)&reg_cont,
diff --git a/arch/cris/arch-v32/kernel/kgdb.c b/arch/cris/arch-v32/kernel/kgdb.c
index c0343c3ea7f8..8c1d35cdf00a 100644
--- a/arch/cris/arch-v32/kernel/kgdb.c
+++ b/arch/cris/arch-v32/kernel/kgdb.c
@@ -677,7 +677,7 @@ mem2hex(char *buf, unsigned char *mem, int count)
677 /* Valid mem address. */ 677 /* Valid mem address. */
678 for (i = 0; i < count; i++) { 678 for (i = 0; i < count; i++) {
679 ch = *mem++; 679 ch = *mem++;
680 buf = pack_hex_byte(buf, ch); 680 buf = hex_byte_pack(buf, ch);
681 } 681 }
682 } 682 }
683 /* Terminate properly. */ 683 /* Terminate properly. */
@@ -695,7 +695,7 @@ mem2hex_nbo(char *buf, unsigned char *mem, int count)
695 mem += count - 1; 695 mem += count - 1;
696 for (i = 0; i < count; i++) { 696 for (i = 0; i < count; i++) {
697 ch = *mem--; 697 ch = *mem--;
698 buf = pack_hex_byte(buf, ch); 698 buf = hex_byte_pack(buf, ch);
699 } 699 }
700 700
701 /* Terminate properly. */ 701 /* Terminate properly. */
@@ -880,7 +880,7 @@ stub_is_stopped(int sigval)
880 /* Send trap type (converted to signal) */ 880 /* Send trap type (converted to signal) */
881 881
882 *ptr++ = 'T'; 882 *ptr++ = 'T';
883 ptr = pack_hex_byte(ptr, sigval); 883 ptr = hex_byte_pack(ptr, sigval);
884 884
885 if (((reg.exs & 0xff00) >> 8) == 0xc) { 885 if (((reg.exs & 0xff00) >> 8) == 0xc) {
886 886
@@ -988,26 +988,26 @@ stub_is_stopped(int sigval)
988 } 988 }
989 /* Only send PC, frame and stack pointer. */ 989 /* Only send PC, frame and stack pointer. */
990 read_register(PC, &reg_cont); 990 read_register(PC, &reg_cont);
991 ptr = pack_hex_byte(ptr, PC); 991 ptr = hex_byte_pack(ptr, PC);
992 *ptr++ = ':'; 992 *ptr++ = ':';
993 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[PC]); 993 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[PC]);
994 *ptr++ = ';'; 994 *ptr++ = ';';
995 995
996 read_register(R8, &reg_cont); 996 read_register(R8, &reg_cont);
997 ptr = pack_hex_byte(ptr, R8); 997 ptr = hex_byte_pack(ptr, R8);
998 *ptr++ = ':'; 998 *ptr++ = ':';
999 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[R8]); 999 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[R8]);
1000 *ptr++ = ';'; 1000 *ptr++ = ';';
1001 1001
1002 read_register(SP, &reg_cont); 1002 read_register(SP, &reg_cont);
1003 ptr = pack_hex_byte(ptr, SP); 1003 ptr = hex_byte_pack(ptr, SP);
1004 *ptr++ = ':'; 1004 *ptr++ = ':';
1005 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[SP]); 1005 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[SP]);
1006 *ptr++ = ';'; 1006 *ptr++ = ';';
1007 1007
1008 /* Send ERP as well; this will save us an entire register fetch in some cases. */ 1008 /* Send ERP as well; this will save us an entire register fetch in some cases. */
1009 read_register(ERP, &reg_cont); 1009 read_register(ERP, &reg_cont);
1010 ptr = pack_hex_byte(ptr, ERP); 1010 ptr = hex_byte_pack(ptr, ERP);
1011 *ptr++ = ':'; 1011 *ptr++ = ':';
1012 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[ERP]); 1012 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[ERP]);
1013 *ptr++ = ';'; 1013 *ptr++ = ';';
diff --git a/arch/frv/kernel/gdb-stub.c b/arch/frv/kernel/gdb-stub.c
index a4dba6b20bd0..a6d5381c94fe 100644
--- a/arch/frv/kernel/gdb-stub.c
+++ b/arch/frv/kernel/gdb-stub.c
@@ -672,7 +672,7 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
672 if ((uint32_t)mem&1 && count>=1) { 672 if ((uint32_t)mem&1 && count>=1) {
673 if (!gdbstub_read_byte(mem,ch)) 673 if (!gdbstub_read_byte(mem,ch))
674 return NULL; 674 return NULL;
675 buf = pack_hex_byte(buf, ch[0]); 675 buf = hex_byte_pack(buf, ch[0]);
676 mem++; 676 mem++;
677 count--; 677 count--;
678 } 678 }
@@ -680,8 +680,8 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
680 if ((uint32_t)mem&3 && count>=2) { 680 if ((uint32_t)mem&3 && count>=2) {
681 if (!gdbstub_read_word(mem,(uint16_t *)ch)) 681 if (!gdbstub_read_word(mem,(uint16_t *)ch))
682 return NULL; 682 return NULL;
683 buf = pack_hex_byte(buf, ch[0]); 683 buf = hex_byte_pack(buf, ch[0]);
684 buf = pack_hex_byte(buf, ch[1]); 684 buf = hex_byte_pack(buf, ch[1]);
685 mem += 2; 685 mem += 2;
686 count -= 2; 686 count -= 2;
687 } 687 }
@@ -689,10 +689,10 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
689 while (count>=4) { 689 while (count>=4) {
690 if (!gdbstub_read_dword(mem,(uint32_t *)ch)) 690 if (!gdbstub_read_dword(mem,(uint32_t *)ch))
691 return NULL; 691 return NULL;
692 buf = pack_hex_byte(buf, ch[0]); 692 buf = hex_byte_pack(buf, ch[0]);
693 buf = pack_hex_byte(buf, ch[1]); 693 buf = hex_byte_pack(buf, ch[1]);
694 buf = pack_hex_byte(buf, ch[2]); 694 buf = hex_byte_pack(buf, ch[2]);
695 buf = pack_hex_byte(buf, ch[3]); 695 buf = hex_byte_pack(buf, ch[3]);
696 mem += 4; 696 mem += 4;
697 count -= 4; 697 count -= 4;
698 } 698 }
@@ -700,8 +700,8 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
700 if (count>=2) { 700 if (count>=2) {
701 if (!gdbstub_read_word(mem,(uint16_t *)ch)) 701 if (!gdbstub_read_word(mem,(uint16_t *)ch))
702 return NULL; 702 return NULL;
703 buf = pack_hex_byte(buf, ch[0]); 703 buf = hex_byte_pack(buf, ch[0]);
704 buf = pack_hex_byte(buf, ch[1]); 704 buf = hex_byte_pack(buf, ch[1]);
705 mem += 2; 705 mem += 2;
706 count -= 2; 706 count -= 2;
707 } 707 }
@@ -709,7 +709,7 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
709 if (count>=1) { 709 if (count>=1) {
710 if (!gdbstub_read_byte(mem,ch)) 710 if (!gdbstub_read_byte(mem,ch))
711 return NULL; 711 return NULL;
712 buf = pack_hex_byte(buf, ch[0]); 712 buf = hex_byte_pack(buf, ch[0]);
713 } 713 }
714 714
715 *buf = 0; 715 *buf = 0;
@@ -1498,21 +1498,21 @@ void gdbstub(int sigval)
1498 ptr = mem2hex(title, ptr, sizeof(title) - 1,0); 1498 ptr = mem2hex(title, ptr, sizeof(title) - 1,0);
1499 1499
1500 hx = hex_asc_hi(brr >> 24); 1500 hx = hex_asc_hi(brr >> 24);
1501 ptr = pack_hex_byte(ptr, hx); 1501 ptr = hex_byte_pack(ptr, hx);
1502 hx = hex_asc_lo(brr >> 24); 1502 hx = hex_asc_lo(brr >> 24);
1503 ptr = pack_hex_byte(ptr, hx); 1503 ptr = hex_byte_pack(ptr, hx);
1504 hx = hex_asc_hi(brr >> 16); 1504 hx = hex_asc_hi(brr >> 16);
1505 ptr = pack_hex_byte(ptr, hx); 1505 ptr = hex_byte_pack(ptr, hx);
1506 hx = hex_asc_lo(brr >> 16); 1506 hx = hex_asc_lo(brr >> 16);
1507 ptr = pack_hex_byte(ptr, hx); 1507 ptr = hex_byte_pack(ptr, hx);
1508 hx = hex_asc_hi(brr >> 8); 1508 hx = hex_asc_hi(brr >> 8);
1509 ptr = pack_hex_byte(ptr, hx); 1509 ptr = hex_byte_pack(ptr, hx);
1510 hx = hex_asc_lo(brr >> 8); 1510 hx = hex_asc_lo(brr >> 8);
1511 ptr = pack_hex_byte(ptr, hx); 1511 ptr = hex_byte_pack(ptr, hx);
1512 hx = hex_asc_hi(brr); 1512 hx = hex_asc_hi(brr);
1513 ptr = pack_hex_byte(ptr, hx); 1513 ptr = hex_byte_pack(ptr, hx);
1514 hx = hex_asc_lo(brr); 1514 hx = hex_asc_lo(brr);
1515 ptr = pack_hex_byte(ptr, hx); 1515 ptr = hex_byte_pack(ptr, hx);
1516 1516
1517 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0); 1517 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0);
1518 *ptr = 0; 1518 *ptr = 0;
@@ -1526,10 +1526,10 @@ void gdbstub(int sigval)
1526 1526
1527 /* Send trap type (converted to signal) */ 1527 /* Send trap type (converted to signal) */
1528 *ptr++ = 'T'; 1528 *ptr++ = 'T';
1529 ptr = pack_hex_byte(ptr, sigval); 1529 ptr = hex_byte_pack(ptr, sigval);
1530 1530
1531 /* Send Error PC */ 1531 /* Send Error PC */
1532 ptr = pack_hex_byte(ptr, GDB_REG_PC); 1532 ptr = hex_byte_pack(ptr, GDB_REG_PC);
1533 *ptr++ = ':'; 1533 *ptr++ = ':';
1534 ptr = mem2hex(&__debug_frame->pc, ptr, 4, 0); 1534 ptr = mem2hex(&__debug_frame->pc, ptr, 4, 0);
1535 *ptr++ = ';'; 1535 *ptr++ = ';';
@@ -1537,7 +1537,7 @@ void gdbstub(int sigval)
1537 /* 1537 /*
1538 * Send frame pointer 1538 * Send frame pointer
1539 */ 1539 */
1540 ptr = pack_hex_byte(ptr, GDB_REG_FP); 1540 ptr = hex_byte_pack(ptr, GDB_REG_FP);
1541 *ptr++ = ':'; 1541 *ptr++ = ':';
1542 ptr = mem2hex(&__debug_frame->fp, ptr, 4, 0); 1542 ptr = mem2hex(&__debug_frame->fp, ptr, 4, 0);
1543 *ptr++ = ';'; 1543 *ptr++ = ';';
@@ -1545,7 +1545,7 @@ void gdbstub(int sigval)
1545 /* 1545 /*
1546 * Send stack pointer 1546 * Send stack pointer
1547 */ 1547 */
1548 ptr = pack_hex_byte(ptr, GDB_REG_SP); 1548 ptr = hex_byte_pack(ptr, GDB_REG_SP);
1549 *ptr++ = ':'; 1549 *ptr++ = ':';
1550 ptr = mem2hex(&__debug_frame->sp, ptr, 4, 0); 1550 ptr = mem2hex(&__debug_frame->sp, ptr, 4, 0);
1551 *ptr++ = ';'; 1551 *ptr++ = ';';
diff --git a/arch/mn10300/kernel/gdb-stub.c b/arch/mn10300/kernel/gdb-stub.c
index 538266b2c9bc..522eb8a9b60d 100644
--- a/arch/mn10300/kernel/gdb-stub.c
+++ b/arch/mn10300/kernel/gdb-stub.c
@@ -798,7 +798,7 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
798 if ((u32) mem & 1 && count >= 1) { 798 if ((u32) mem & 1 && count >= 1) {
799 if (gdbstub_read_byte(mem, ch) != 0) 799 if (gdbstub_read_byte(mem, ch) != 0)
800 return 0; 800 return 0;
801 buf = pack_hex_byte(buf, ch[0]); 801 buf = hex_byte_pack(buf, ch[0]);
802 mem++; 802 mem++;
803 count--; 803 count--;
804 } 804 }
@@ -806,8 +806,8 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
806 if ((u32) mem & 3 && count >= 2) { 806 if ((u32) mem & 3 && count >= 2) {
807 if (gdbstub_read_word(mem, ch) != 0) 807 if (gdbstub_read_word(mem, ch) != 0)
808 return 0; 808 return 0;
809 buf = pack_hex_byte(buf, ch[0]); 809 buf = hex_byte_pack(buf, ch[0]);
810 buf = pack_hex_byte(buf, ch[1]); 810 buf = hex_byte_pack(buf, ch[1]);
811 mem += 2; 811 mem += 2;
812 count -= 2; 812 count -= 2;
813 } 813 }
@@ -815,10 +815,10 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
815 while (count >= 4) { 815 while (count >= 4) {
816 if (gdbstub_read_dword(mem, ch) != 0) 816 if (gdbstub_read_dword(mem, ch) != 0)
817 return 0; 817 return 0;
818 buf = pack_hex_byte(buf, ch[0]); 818 buf = hex_byte_pack(buf, ch[0]);
819 buf = pack_hex_byte(buf, ch[1]); 819 buf = hex_byte_pack(buf, ch[1]);
820 buf = pack_hex_byte(buf, ch[2]); 820 buf = hex_byte_pack(buf, ch[2]);
821 buf = pack_hex_byte(buf, ch[3]); 821 buf = hex_byte_pack(buf, ch[3]);
822 mem += 4; 822 mem += 4;
823 count -= 4; 823 count -= 4;
824 } 824 }
@@ -826,8 +826,8 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
826 if (count >= 2) { 826 if (count >= 2) {
827 if (gdbstub_read_word(mem, ch) != 0) 827 if (gdbstub_read_word(mem, ch) != 0)
828 return 0; 828 return 0;
829 buf = pack_hex_byte(buf, ch[0]); 829 buf = hex_byte_pack(buf, ch[0]);
830 buf = pack_hex_byte(buf, ch[1]); 830 buf = hex_byte_pack(buf, ch[1]);
831 mem += 2; 831 mem += 2;
832 count -= 2; 832 count -= 2;
833 } 833 }
@@ -835,7 +835,7 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
835 if (count >= 1) { 835 if (count >= 1) {
836 if (gdbstub_read_byte(mem, ch) != 0) 836 if (gdbstub_read_byte(mem, ch) != 0)
837 return 0; 837 return 0;
838 buf = pack_hex_byte(buf, ch[0]); 838 buf = hex_byte_pack(buf, ch[0]);
839 } 839 }
840 840
841 *buf = 0; 841 *buf = 0;
@@ -1273,13 +1273,13 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
1273 ptr = mem2hex(title, ptr, sizeof(title) - 1, 0); 1273 ptr = mem2hex(title, ptr, sizeof(title) - 1, 0);
1274 1274
1275 hx = hex_asc_hi(excep >> 8); 1275 hx = hex_asc_hi(excep >> 8);
1276 ptr = pack_hex_byte(ptr, hx); 1276 ptr = hex_byte_pack(ptr, hx);
1277 hx = hex_asc_lo(excep >> 8); 1277 hx = hex_asc_lo(excep >> 8);
1278 ptr = pack_hex_byte(ptr, hx); 1278 ptr = hex_byte_pack(ptr, hx);
1279 hx = hex_asc_hi(excep); 1279 hx = hex_asc_hi(excep);
1280 ptr = pack_hex_byte(ptr, hx); 1280 ptr = hex_byte_pack(ptr, hx);
1281 hx = hex_asc_lo(excep); 1281 hx = hex_asc_lo(excep);
1282 ptr = pack_hex_byte(ptr, hx); 1282 ptr = hex_byte_pack(ptr, hx);
1283 1283
1284 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0); 1284 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0);
1285 *ptr = 0; 1285 *ptr = 0;
@@ -1291,21 +1291,21 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
1291 ptr = mem2hex(tbcberr, ptr, sizeof(tbcberr) - 1, 0); 1291 ptr = mem2hex(tbcberr, ptr, sizeof(tbcberr) - 1, 0);
1292 1292
1293 hx = hex_asc_hi(bcberr >> 24); 1293 hx = hex_asc_hi(bcberr >> 24);
1294 ptr = pack_hex_byte(ptr, hx); 1294 ptr = hex_byte_pack(ptr, hx);
1295 hx = hex_asc_lo(bcberr >> 24); 1295 hx = hex_asc_lo(bcberr >> 24);
1296 ptr = pack_hex_byte(ptr, hx); 1296 ptr = hex_byte_pack(ptr, hx);
1297 hx = hex_asc_hi(bcberr >> 16); 1297 hx = hex_asc_hi(bcberr >> 16);
1298 ptr = pack_hex_byte(ptr, hx); 1298 ptr = hex_byte_pack(ptr, hx);
1299 hx = hex_asc_lo(bcberr >> 16); 1299 hx = hex_asc_lo(bcberr >> 16);
1300 ptr = pack_hex_byte(ptr, hx); 1300 ptr = hex_byte_pack(ptr, hx);
1301 hx = hex_asc_hi(bcberr >> 8); 1301 hx = hex_asc_hi(bcberr >> 8);
1302 ptr = pack_hex_byte(ptr, hx); 1302 ptr = hex_byte_pack(ptr, hx);
1303 hx = hex_asc_lo(bcberr >> 8); 1303 hx = hex_asc_lo(bcberr >> 8);
1304 ptr = pack_hex_byte(ptr, hx); 1304 ptr = hex_byte_pack(ptr, hx);
1305 hx = hex_asc_hi(bcberr); 1305 hx = hex_asc_hi(bcberr);
1306 ptr = pack_hex_byte(ptr, hx); 1306 ptr = hex_byte_pack(ptr, hx);
1307 hx = hex_asc_lo(bcberr); 1307 hx = hex_asc_lo(bcberr);
1308 ptr = pack_hex_byte(ptr, hx); 1308 ptr = hex_byte_pack(ptr, hx);
1309 1309
1310 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0); 1310 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0);
1311 *ptr = 0; 1311 *ptr = 0;
@@ -1321,12 +1321,12 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
1321 * Send trap type (converted to signal) 1321 * Send trap type (converted to signal)
1322 */ 1322 */
1323 *ptr++ = 'T'; 1323 *ptr++ = 'T';
1324 ptr = pack_hex_byte(ptr, sigval); 1324 ptr = hex_byte_pack(ptr, sigval);
1325 1325
1326 /* 1326 /*
1327 * Send Error PC 1327 * Send Error PC
1328 */ 1328 */
1329 ptr = pack_hex_byte(ptr, GDB_REGID_PC); 1329 ptr = hex_byte_pack(ptr, GDB_REGID_PC);
1330 *ptr++ = ':'; 1330 *ptr++ = ':';
1331 ptr = mem2hex(&regs->pc, ptr, 4, 0); 1331 ptr = mem2hex(&regs->pc, ptr, 4, 0);
1332 *ptr++ = ';'; 1332 *ptr++ = ';';
@@ -1334,7 +1334,7 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
1334 /* 1334 /*
1335 * Send frame pointer 1335 * Send frame pointer
1336 */ 1336 */
1337 ptr = pack_hex_byte(ptr, GDB_REGID_FP); 1337 ptr = hex_byte_pack(ptr, GDB_REGID_FP);
1338 *ptr++ = ':'; 1338 *ptr++ = ':';
1339 ptr = mem2hex(&regs->a3, ptr, 4, 0); 1339 ptr = mem2hex(&regs->a3, ptr, 4, 0);
1340 *ptr++ = ';'; 1340 *ptr++ = ';';
@@ -1343,7 +1343,7 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
1343 * Send stack pointer 1343 * Send stack pointer
1344 */ 1344 */
1345 ssp = (unsigned long) (regs + 1); 1345 ssp = (unsigned long) (regs + 1);
1346 ptr = pack_hex_byte(ptr, GDB_REGID_SP); 1346 ptr = hex_byte_pack(ptr, GDB_REGID_SP);
1347 *ptr++ = ':'; 1347 *ptr++ = ':';
1348 ptr = mem2hex(&ssp, ptr, 4, 0); 1348 ptr = mem2hex(&ssp, ptr, 4, 0);
1349 *ptr++ = ';'; 1349 *ptr++ = ';';
diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index fa0d27a400de..559ae1ee6706 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -354,3 +354,5 @@ COMPAT_SYS_SPU(clock_adjtime)
354SYSCALL_SPU(syncfs) 354SYSCALL_SPU(syncfs)
355COMPAT_SYS_SPU(sendmmsg) 355COMPAT_SYS_SPU(sendmmsg)
356SYSCALL_SPU(setns) 356SYSCALL_SPU(setns)
357COMPAT_SYS(process_vm_readv)
358COMPAT_SYS(process_vm_writev)
diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h
index b8b3f599362b..d3d1b5efd7eb 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -373,10 +373,12 @@
373#define __NR_syncfs 348 373#define __NR_syncfs 348
374#define __NR_sendmmsg 349 374#define __NR_sendmmsg 349
375#define __NR_setns 350 375#define __NR_setns 350
376#define __NR_process_vm_readv 351
377#define __NR_process_vm_writev 352
376 378
377#ifdef __KERNEL__ 379#ifdef __KERNEL__
378 380
379#define __NR_syscalls 351 381#define __NR_syscalls 353
380 382
381#define __NR__exit __NR_exit 383#define __NR__exit __NR_exit
382#define NR_syscalls __NR_syscalls 384#define NR_syscalls __NR_syscalls
diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index 54edb207ff3a..a6253ec1b284 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -850,4 +850,6 @@ ia32_sys_call_table:
850 .quad sys_syncfs 850 .quad sys_syncfs
851 .quad compat_sys_sendmmsg /* 345 */ 851 .quad compat_sys_sendmmsg /* 345 */
852 .quad sys_setns 852 .quad sys_setns
853 .quad compat_sys_process_vm_readv
854 .quad compat_sys_process_vm_writev
853ia32_syscall_end: 855ia32_syscall_end:
diff --git a/arch/x86/include/asm/unistd_32.h b/arch/x86/include/asm/unistd_32.h
index 593485b38ab3..599c77d38f33 100644
--- a/arch/x86/include/asm/unistd_32.h
+++ b/arch/x86/include/asm/unistd_32.h
@@ -352,10 +352,12 @@
352#define __NR_syncfs 344 352#define __NR_syncfs 344
353#define __NR_sendmmsg 345 353#define __NR_sendmmsg 345
354#define __NR_setns 346 354#define __NR_setns 346
355#define __NR_process_vm_readv 347
356#define __NR_process_vm_writev 348
355 357
356#ifdef __KERNEL__ 358#ifdef __KERNEL__
357 359
358#define NR_syscalls 347 360#define NR_syscalls 349
359 361
360#define __ARCH_WANT_IPC_PARSE_VERSION 362#define __ARCH_WANT_IPC_PARSE_VERSION
361#define __ARCH_WANT_OLD_READDIR 363#define __ARCH_WANT_OLD_READDIR
diff --git a/arch/x86/include/asm/unistd_64.h b/arch/x86/include/asm/unistd_64.h
index 0a6ba337a2eb..0431f193c3f2 100644
--- a/arch/x86/include/asm/unistd_64.h
+++ b/arch/x86/include/asm/unistd_64.h
@@ -682,6 +682,10 @@ __SYSCALL(__NR_sendmmsg, sys_sendmmsg)
682__SYSCALL(__NR_setns, sys_setns) 682__SYSCALL(__NR_setns, sys_setns)
683#define __NR_getcpu 309 683#define __NR_getcpu 309
684__SYSCALL(__NR_getcpu, sys_getcpu) 684__SYSCALL(__NR_getcpu, sys_getcpu)
685#define __NR_process_vm_readv 310
686__SYSCALL(__NR_process_vm_readv, sys_process_vm_readv)
687#define __NR_process_vm_writev 311
688__SYSCALL(__NR_process_vm_writev, sys_process_vm_writev)
685 689
686#ifndef __NO_STUBS 690#ifndef __NO_STUBS
687#define __ARCH_WANT_OLD_READDIR 691#define __ARCH_WANT_OLD_READDIR
diff --git a/arch/x86/kernel/syscall_table_32.S b/arch/x86/kernel/syscall_table_32.S
index bc19be332bc9..9a0e31293920 100644
--- a/arch/x86/kernel/syscall_table_32.S
+++ b/arch/x86/kernel/syscall_table_32.S
@@ -346,3 +346,5 @@ ENTRY(sys_call_table)
346 .long sys_syncfs 346 .long sys_syncfs
347 .long sys_sendmmsg /* 345 */ 347 .long sys_sendmmsg /* 345 */
348 .long sys_setns 348 .long sys_setns
349 .long sys_process_vm_readv
350 .long sys_process_vm_writev
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index a61e7815a2a9..6460487e41b5 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -27,8 +27,7 @@
27 27
28static struct class *hwmon_class; 28static struct class *hwmon_class;
29 29
30static DEFINE_IDR(hwmon_idr); 30static DEFINE_IDA(hwmon_ida);
31static DEFINE_SPINLOCK(idr_lock);
32 31
33/** 32/**
34 * hwmon_device_register - register w/ hwmon 33 * hwmon_device_register - register w/ hwmon
@@ -42,30 +41,17 @@ static DEFINE_SPINLOCK(idr_lock);
42struct device *hwmon_device_register(struct device *dev) 41struct device *hwmon_device_register(struct device *dev)
43{ 42{
44 struct device *hwdev; 43 struct device *hwdev;
45 int id, err; 44 int id;
46
47again:
48 if (unlikely(idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0))
49 return ERR_PTR(-ENOMEM);
50
51 spin_lock(&idr_lock);
52 err = idr_get_new(&hwmon_idr, NULL, &id);
53 spin_unlock(&idr_lock);
54 45
55 if (unlikely(err == -EAGAIN)) 46 id = ida_simple_get(&hwmon_ida, 0, 0, GFP_KERNEL);
56 goto again; 47 if (id < 0)
57 else if (unlikely(err)) 48 return ERR_PTR(id);
58 return ERR_PTR(err);
59 49
60 id = id & MAX_ID_MASK;
61 hwdev = device_create(hwmon_class, dev, MKDEV(0, 0), NULL, 50 hwdev = device_create(hwmon_class, dev, MKDEV(0, 0), NULL,
62 HWMON_ID_FORMAT, id); 51 HWMON_ID_FORMAT, id);
63 52
64 if (IS_ERR(hwdev)) { 53 if (IS_ERR(hwdev))
65 spin_lock(&idr_lock); 54 ida_simple_remove(&hwmon_ida, id);
66 idr_remove(&hwmon_idr, id);
67 spin_unlock(&idr_lock);
68 }
69 55
70 return hwdev; 56 return hwdev;
71} 57}
@@ -81,9 +67,7 @@ void hwmon_device_unregister(struct device *dev)
81 67
82 if (likely(sscanf(dev_name(dev), HWMON_ID_FORMAT, &id) == 1)) { 68 if (likely(sscanf(dev_name(dev), HWMON_ID_FORMAT, &id) == 1)) {
83 device_unregister(dev); 69 device_unregister(dev);
84 spin_lock(&idr_lock); 70 ida_simple_remove(&hwmon_ida, id);
85 idr_remove(&hwmon_idr, id);
86 spin_unlock(&idr_lock);
87 } else 71 } else
88 dev_dbg(dev->parent, 72 dev_dbg(dev->parent,
89 "hwmon_device_unregister() failed: bad class ID!\n"); 73 "hwmon_device_unregister() failed: bad class ID!\n");
diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
index c316294c48b4..783d0c17b762 100644
--- a/drivers/hwmon/ibmaem.c
+++ b/drivers/hwmon/ibmaem.c
@@ -88,8 +88,7 @@
88#define AEM_MIN_POWER_INTERVAL 200 88#define AEM_MIN_POWER_INTERVAL 200
89#define UJ_PER_MJ 1000L 89#define UJ_PER_MJ 1000L
90 90
91static DEFINE_IDR(aem_idr); 91static DEFINE_IDA(aem_ida);
92static DEFINE_SPINLOCK(aem_idr_lock);
93 92
94static struct platform_driver aem_driver = { 93static struct platform_driver aem_driver = {
95 .driver = { 94 .driver = {
@@ -356,38 +355,6 @@ static void aem_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
356 complete(&data->read_complete); 355 complete(&data->read_complete);
357} 356}
358 357
359/* ID functions */
360
361/* Obtain an id */
362static int aem_idr_get(int *id)
363{
364 int i, err;
365
366again:
367 if (unlikely(!idr_pre_get(&aem_idr, GFP_KERNEL)))
368 return -ENOMEM;
369
370 spin_lock(&aem_idr_lock);
371 err = idr_get_new(&aem_idr, NULL, &i);
372 spin_unlock(&aem_idr_lock);
373
374 if (unlikely(err == -EAGAIN))
375 goto again;
376 else if (unlikely(err))
377 return err;
378
379 *id = i & MAX_ID_MASK;
380 return 0;
381}
382
383/* Release an object ID */
384static void aem_idr_put(int id)
385{
386 spin_lock(&aem_idr_lock);
387 idr_remove(&aem_idr, id);
388 spin_unlock(&aem_idr_lock);
389}
390
391/* Sensor support functions */ 358/* Sensor support functions */
392 359
393/* Read a sensor value */ 360/* Read a sensor value */
@@ -530,7 +497,7 @@ static void aem_delete(struct aem_data *data)
530 ipmi_destroy_user(data->ipmi.user); 497 ipmi_destroy_user(data->ipmi.user);
531 platform_set_drvdata(data->pdev, NULL); 498 platform_set_drvdata(data->pdev, NULL);
532 platform_device_unregister(data->pdev); 499 platform_device_unregister(data->pdev);
533 aem_idr_put(data->id); 500 ida_simple_remove(&aem_ida, data->id);
534 kfree(data); 501 kfree(data);
535} 502}
536 503
@@ -587,7 +554,8 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle)
587 data->power_period[i] = AEM_DEFAULT_POWER_INTERVAL; 554 data->power_period[i] = AEM_DEFAULT_POWER_INTERVAL;
588 555
589 /* Create sub-device for this fw instance */ 556 /* Create sub-device for this fw instance */
590 if (aem_idr_get(&data->id)) 557 data->id = ida_simple_get(&aem_ida, 0, 0, GFP_KERNEL);
558 if (data->id < 0)
591 goto id_err; 559 goto id_err;
592 560
593 data->pdev = platform_device_alloc(DRVNAME, data->id); 561 data->pdev = platform_device_alloc(DRVNAME, data->id);
@@ -638,7 +606,7 @@ ipmi_err:
638 platform_set_drvdata(data->pdev, NULL); 606 platform_set_drvdata(data->pdev, NULL);
639 platform_device_unregister(data->pdev); 607 platform_device_unregister(data->pdev);
640dev_err: 608dev_err:
641 aem_idr_put(data->id); 609 ida_simple_remove(&aem_ida, data->id);
642id_err: 610id_err:
643 kfree(data); 611 kfree(data);
644 612
@@ -720,7 +688,8 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe,
720 data->power_period[i] = AEM_DEFAULT_POWER_INTERVAL; 688 data->power_period[i] = AEM_DEFAULT_POWER_INTERVAL;
721 689
722 /* Create sub-device for this fw instance */ 690 /* Create sub-device for this fw instance */
723 if (aem_idr_get(&data->id)) 691 data->id = ida_simple_get(&aem_ida, 0, 0, GFP_KERNEL);
692 if (data->id < 0)
724 goto id_err; 693 goto id_err;
725 694
726 data->pdev = platform_device_alloc(DRVNAME, data->id); 695 data->pdev = platform_device_alloc(DRVNAME, data->id);
@@ -771,7 +740,7 @@ ipmi_err:
771 platform_set_drvdata(data->pdev, NULL); 740 platform_set_drvdata(data->pdev, NULL);
772 platform_device_unregister(data->pdev); 741 platform_device_unregister(data->pdev);
773dev_err: 742dev_err:
774 aem_idr_put(data->id); 743 ida_simple_remove(&aem_ida, data->id);
775id_err: 744id_err:
776 kfree(data); 745 kfree(data);
777 746
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index b645e558876f..9155f91d66bf 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -136,7 +136,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
136 136
137 down_write(&current->mm->mmap_sem); 137 down_write(&current->mm->mmap_sem);
138 138
139 locked = npages + current->mm->locked_vm; 139 locked = npages + current->mm->pinned_vm;
140 lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT; 140 lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
141 141
142 if ((locked > lock_limit) && !capable(CAP_IPC_LOCK)) { 142 if ((locked > lock_limit) && !capable(CAP_IPC_LOCK)) {
@@ -206,7 +206,7 @@ out:
206 __ib_umem_release(context->device, umem, 0); 206 __ib_umem_release(context->device, umem, 0);
207 kfree(umem); 207 kfree(umem);
208 } else 208 } else
209 current->mm->locked_vm = locked; 209 current->mm->pinned_vm = locked;
210 210
211 up_write(&current->mm->mmap_sem); 211 up_write(&current->mm->mmap_sem);
212 if (vma_list) 212 if (vma_list)
@@ -222,7 +222,7 @@ static void ib_umem_account(struct work_struct *work)
222 struct ib_umem *umem = container_of(work, struct ib_umem, work); 222 struct ib_umem *umem = container_of(work, struct ib_umem, work);
223 223
224 down_write(&umem->mm->mmap_sem); 224 down_write(&umem->mm->mmap_sem);
225 umem->mm->locked_vm -= umem->diff; 225 umem->mm->pinned_vm -= umem->diff;
226 up_write(&umem->mm->mmap_sem); 226 up_write(&umem->mm->mmap_sem);
227 mmput(umem->mm); 227 mmput(umem->mm);
228 kfree(umem); 228 kfree(umem);
diff --git a/drivers/infiniband/hw/ipath/ipath_user_pages.c b/drivers/infiniband/hw/ipath/ipath_user_pages.c
index cfed5399f074..dc66c4506916 100644
--- a/drivers/infiniband/hw/ipath/ipath_user_pages.c
+++ b/drivers/infiniband/hw/ipath/ipath_user_pages.c
@@ -79,7 +79,7 @@ static int __ipath_get_user_pages(unsigned long start_page, size_t num_pages,
79 goto bail_release; 79 goto bail_release;
80 } 80 }
81 81
82 current->mm->locked_vm += num_pages; 82 current->mm->pinned_vm += num_pages;
83 83
84 ret = 0; 84 ret = 0;
85 goto bail; 85 goto bail;
@@ -178,7 +178,7 @@ void ipath_release_user_pages(struct page **p, size_t num_pages)
178 178
179 __ipath_release_user_pages(p, num_pages, 1); 179 __ipath_release_user_pages(p, num_pages, 1);
180 180
181 current->mm->locked_vm -= num_pages; 181 current->mm->pinned_vm -= num_pages;
182 182
183 up_write(&current->mm->mmap_sem); 183 up_write(&current->mm->mmap_sem);
184} 184}
@@ -195,7 +195,7 @@ static void user_pages_account(struct work_struct *_work)
195 container_of(_work, struct ipath_user_pages_work, work); 195 container_of(_work, struct ipath_user_pages_work, work);
196 196
197 down_write(&work->mm->mmap_sem); 197 down_write(&work->mm->mmap_sem);
198 work->mm->locked_vm -= work->num_pages; 198 work->mm->pinned_vm -= work->num_pages;
199 up_write(&work->mm->mmap_sem); 199 up_write(&work->mm->mmap_sem);
200 mmput(work->mm); 200 mmput(work->mm);
201 kfree(work); 201 kfree(work);
diff --git a/drivers/infiniband/hw/qib/qib_user_pages.c b/drivers/infiniband/hw/qib/qib_user_pages.c
index 7689e49c13c9..2bc1d2b96298 100644
--- a/drivers/infiniband/hw/qib/qib_user_pages.c
+++ b/drivers/infiniband/hw/qib/qib_user_pages.c
@@ -74,7 +74,7 @@ static int __qib_get_user_pages(unsigned long start_page, size_t num_pages,
74 goto bail_release; 74 goto bail_release;
75 } 75 }
76 76
77 current->mm->locked_vm += num_pages; 77 current->mm->pinned_vm += num_pages;
78 78
79 ret = 0; 79 ret = 0;
80 goto bail; 80 goto bail;
@@ -151,7 +151,7 @@ void qib_release_user_pages(struct page **p, size_t num_pages)
151 __qib_release_user_pages(p, num_pages, 1); 151 __qib_release_user_pages(p, num_pages, 1);
152 152
153 if (current->mm) { 153 if (current->mm) {
154 current->mm->locked_vm -= num_pages; 154 current->mm->pinned_vm -= num_pages;
155 up_write(&current->mm->mmap_sem); 155 up_write(&current->mm->mmap_sem);
156 } 156 }
157} 157}
diff --git a/drivers/isdn/hisax/callc.c b/drivers/isdn/hisax/callc.c
index 37e685eafd24..c4897e1075d8 100644
--- a/drivers/isdn/hisax/callc.c
+++ b/drivers/isdn/hisax/callc.c
@@ -65,7 +65,7 @@ hisax_findcard(int driverid)
65 return (struct IsdnCardState *) 0; 65 return (struct IsdnCardState *) 0;
66} 66}
67 67
68static __attribute__((format(printf, 3, 4))) void 68static __printf(3, 4) void
69link_debug(struct Channel *chanp, int direction, char *fmt, ...) 69link_debug(struct Channel *chanp, int direction, char *fmt, ...)
70{ 70{
71 va_list args; 71 va_list args;
@@ -1068,7 +1068,7 @@ init_d_st(struct Channel *chanp)
1068 return 0; 1068 return 0;
1069} 1069}
1070 1070
1071static __attribute__((format(printf, 2, 3))) void 1071static __printf(2, 3) void
1072callc_debug(struct FsmInst *fi, char *fmt, ...) 1072callc_debug(struct FsmInst *fi, char *fmt, ...)
1073{ 1073{
1074 va_list args; 1074 va_list args;
diff --git a/drivers/isdn/hisax/hisax.h b/drivers/isdn/hisax/hisax.h
index 0a5c42a3f125..aff45a11a92d 100644
--- a/drivers/isdn/hisax/hisax.h
+++ b/drivers/isdn/hisax/hisax.h
@@ -1287,9 +1287,9 @@ int jiftime(char *s, long mark);
1287 1287
1288int HiSax_command(isdn_ctrl * ic); 1288int HiSax_command(isdn_ctrl * ic);
1289int HiSax_writebuf_skb(int id, int chan, int ack, struct sk_buff *skb); 1289int HiSax_writebuf_skb(int id, int chan, int ack, struct sk_buff *skb);
1290__attribute__((format(printf, 3, 4))) 1290__printf(3, 4)
1291void HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...); 1291void HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...);
1292__attribute__((format(printf, 3, 0))) 1292__printf(3, 0)
1293void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, va_list args); 1293void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, va_list args);
1294void HiSax_reportcard(int cardnr, int sel); 1294void HiSax_reportcard(int cardnr, int sel);
1295int QuickHex(char *txt, u_char * p, int cnt); 1295int QuickHex(char *txt, u_char * p, int cnt);
diff --git a/drivers/isdn/hisax/isdnl1.h b/drivers/isdn/hisax/isdnl1.h
index 425d86116f2b..66ddcab19bba 100644
--- a/drivers/isdn/hisax/isdnl1.h
+++ b/drivers/isdn/hisax/isdnl1.h
@@ -21,7 +21,7 @@
21#define B_XMTBUFREADY 1 21#define B_XMTBUFREADY 1
22#define B_ACKPENDING 2 22#define B_ACKPENDING 2
23 23
24__attribute__((format(printf, 2, 3))) 24__printf(2, 3)
25void debugl1(struct IsdnCardState *cs, char *fmt, ...); 25void debugl1(struct IsdnCardState *cs, char *fmt, ...);
26void DChannel_proc_xmt(struct IsdnCardState *cs); 26void DChannel_proc_xmt(struct IsdnCardState *cs);
27void DChannel_proc_rcv(struct IsdnCardState *cs); 27void DChannel_proc_rcv(struct IsdnCardState *cs);
diff --git a/drivers/isdn/hisax/isdnl3.c b/drivers/isdn/hisax/isdnl3.c
index ad291f21b201..1c24e4457b6f 100644
--- a/drivers/isdn/hisax/isdnl3.c
+++ b/drivers/isdn/hisax/isdnl3.c
@@ -66,7 +66,7 @@ static char *strL3Event[] =
66 "EV_TIMEOUT", 66 "EV_TIMEOUT",
67}; 67};
68 68
69static __attribute__((format(printf, 2, 3))) void 69static __printf(2, 3) void
70l3m_debug(struct FsmInst *fi, char *fmt, ...) 70l3m_debug(struct FsmInst *fi, char *fmt, ...)
71{ 71{
72 va_list args; 72 va_list args;
diff --git a/drivers/isdn/hisax/st5481_d.c b/drivers/isdn/hisax/st5481_d.c
index 44082637a09f..db247b79e561 100644
--- a/drivers/isdn/hisax/st5481_d.c
+++ b/drivers/isdn/hisax/st5481_d.c
@@ -167,7 +167,7 @@ static struct FsmNode L1FnList[] __initdata =
167 {ST_L1_F8, EV_IND_RSY, l1_ignore}, 167 {ST_L1_F8, EV_IND_RSY, l1_ignore},
168}; 168};
169 169
170static __attribute__((format(printf, 2, 3))) 170static __printf(2, 3)
171void l1m_debug(struct FsmInst *fi, char *fmt, ...) 171void l1m_debug(struct FsmInst *fi, char *fmt, ...)
172{ 172{
173 va_list args; 173 va_list args;
@@ -270,7 +270,7 @@ static char *strDoutEvent[] =
270 "EV_DOUT_UNDERRUN", 270 "EV_DOUT_UNDERRUN",
271}; 271};
272 272
273static __attribute__((format(printf, 2, 3))) 273static __printf(2, 3)
274void dout_debug(struct FsmInst *fi, char *fmt, ...) 274void dout_debug(struct FsmInst *fi, char *fmt, ...)
275{ 275{
276 va_list args; 276 va_list args;
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index dc7caaddecf4..ff203a421863 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -375,6 +375,18 @@ config LEDS_ASIC3
375 cannot be used. This driver supports hardware blinking with an on+off 375 cannot be used. This driver supports hardware blinking with an on+off
376 period from 62ms to 125s. Say Y to enable LEDs on the HP iPAQ hx4700. 376 period from 62ms to 125s. Say Y to enable LEDs on the HP iPAQ hx4700.
377 377
378config LEDS_RENESAS_TPU
379 bool "LED support for Renesas TPU"
380 depends on LEDS_CLASS && HAVE_CLK && GENERIC_GPIO
381 help
382 This option enables build of the LED TPU platform driver,
383 suitable to drive any TPU channel on newer Renesas SoCs.
384 The driver controls the GPIO pin connected to the LED via
385 the GPIO framework and expects the LED to be connected to
386 a pin that can be driven in both GPIO mode and using TPU
387 pin function. The latter to support brightness control.
388 Brightness control is supported but hardware blinking is not.
389
378config LEDS_TRIGGERS 390config LEDS_TRIGGERS
379 bool "LED Trigger support" 391 bool "LED Trigger support"
380 depends on LEDS_CLASS 392 depends on LEDS_CLASS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index a0a1b89d78a8..e4f6bf568880 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -42,6 +42,7 @@ obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o
42obj-$(CONFIG_LEDS_NS2) += leds-ns2.o 42obj-$(CONFIG_LEDS_NS2) += leds-ns2.o
43obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o 43obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o
44obj-$(CONFIG_LEDS_ASIC3) += leds-asic3.o 44obj-$(CONFIG_LEDS_ASIC3) += leds-asic3.o
45obj-$(CONFIG_LEDS_RENESAS_TPU) += leds-renesas-tpu.o
45 46
46# LED SPI Drivers 47# LED SPI Drivers
47obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o 48obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index dc3d3d83191a..661b692573e7 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -267,9 +267,14 @@ void led_blink_set(struct led_classdev *led_cdev,
267 unsigned long *delay_on, 267 unsigned long *delay_on,
268 unsigned long *delay_off) 268 unsigned long *delay_off)
269{ 269{
270 del_timer_sync(&led_cdev->blink_timer);
271
270 if (led_cdev->blink_set && 272 if (led_cdev->blink_set &&
271 !led_cdev->blink_set(led_cdev, delay_on, delay_off)) 273 !led_cdev->blink_set(led_cdev, delay_on, delay_off)) {
274 led_cdev->blink_delay_on = *delay_on;
275 led_cdev->blink_delay_off = *delay_off;
272 return; 276 return;
277 }
273 278
274 /* blink with 1 Hz as default if nothing specified */ 279 /* blink with 1 Hz as default if nothing specified */
275 if (!*delay_on && !*delay_off) 280 if (!*delay_on && !*delay_off)
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 4bebae733349..6f1ff93d7cec 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -261,9 +261,12 @@ void led_trigger_register_simple(const char *name, struct led_trigger **tp)
261 if (trigger) { 261 if (trigger) {
262 trigger->name = name; 262 trigger->name = name;
263 err = led_trigger_register(trigger); 263 err = led_trigger_register(trigger);
264 if (err < 0) 264 if (err < 0) {
265 kfree(trigger);
266 trigger = NULL;
265 printk(KERN_WARNING "LED trigger %s failed to register" 267 printk(KERN_WARNING "LED trigger %s failed to register"
266 " (%d)\n", name, err); 268 " (%d)\n", name, err);
269 }
267 } else 270 } else
268 printk(KERN_WARNING "LED trigger %s failed to register" 271 printk(KERN_WARNING "LED trigger %s failed to register"
269 " (no memory)\n", name); 272 " (no memory)\n", name);
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 3d8bc327a68d..504cc26c7e4b 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -121,7 +121,7 @@ static int __devinit create_gpio_led(const struct gpio_led *template,
121 } 121 }
122 led_dat->cdev.brightness_set = gpio_led_set; 122 led_dat->cdev.brightness_set = gpio_led_set;
123 if (template->default_state == LEDS_GPIO_DEFSTATE_KEEP) 123 if (template->default_state == LEDS_GPIO_DEFSTATE_KEEP)
124 state = !!gpio_get_value(led_dat->gpio) ^ led_dat->active_low; 124 state = !!gpio_get_value_cansleep(led_dat->gpio) ^ led_dat->active_low;
125 else 125 else
126 state = (template->default_state == LEDS_GPIO_DEFSTATE_ON); 126 state = (template->default_state == LEDS_GPIO_DEFSTATE_ON);
127 led_dat->cdev.brightness = state ? LED_FULL : LED_OFF; 127 led_dat->cdev.brightness = state ? LED_FULL : LED_OFF;
diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c
index 3dd7090a9a9b..4dc510fdfa06 100644
--- a/drivers/leds/leds-lm3530.c
+++ b/drivers/leds/leds-lm3530.c
@@ -421,7 +421,6 @@ err_class_register:
421err_reg_init: 421err_reg_init:
422 regulator_put(drvdata->regulator); 422 regulator_put(drvdata->regulator);
423err_regulator_get: 423err_regulator_get:
424 i2c_set_clientdata(client, NULL);
425 kfree(drvdata); 424 kfree(drvdata);
426err_out: 425err_out:
427 return err; 426 return err;
@@ -449,7 +448,7 @@ MODULE_DEVICE_TABLE(i2c, lm3530_id);
449 448
450static struct i2c_driver lm3530_i2c_driver = { 449static struct i2c_driver lm3530_i2c_driver = {
451 .probe = lm3530_probe, 450 .probe = lm3530_probe,
452 .remove = lm3530_remove, 451 .remove = __devexit_p(lm3530_remove),
453 .id_table = lm3530_id, 452 .id_table = lm3530_id,
454 .driver = { 453 .driver = {
455 .name = LM3530_NAME, 454 .name = LM3530_NAME,
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index 9fc122c81f06..cb641f1b3342 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -97,6 +97,9 @@
97/* Status */ 97/* Status */
98#define LP5521_EXT_CLK_USED 0x08 98#define LP5521_EXT_CLK_USED 0x08
99 99
100/* default R channel current register value */
101#define LP5521_REG_R_CURR_DEFAULT 0xAF
102
100struct lp5521_engine { 103struct lp5521_engine {
101 int id; 104 int id;
102 u8 mode; 105 u8 mode;
@@ -175,14 +178,14 @@ static int lp5521_set_engine_mode(struct lp5521_engine *engine, u8 mode)
175 mode = LP5521_CMD_DIRECT; 178 mode = LP5521_CMD_DIRECT;
176 179
177 ret = lp5521_read(client, LP5521_REG_OP_MODE, &engine_state); 180 ret = lp5521_read(client, LP5521_REG_OP_MODE, &engine_state);
181 if (ret < 0)
182 return ret;
178 183
179 /* set mode only for this engine */ 184 /* set mode only for this engine */
180 engine_state &= ~(engine->engine_mask); 185 engine_state &= ~(engine->engine_mask);
181 mode &= engine->engine_mask; 186 mode &= engine->engine_mask;
182 engine_state |= mode; 187 engine_state |= mode;
183 ret |= lp5521_write(client, LP5521_REG_OP_MODE, engine_state); 188 return lp5521_write(client, LP5521_REG_OP_MODE, engine_state);
184
185 return ret;
186} 189}
187 190
188static int lp5521_load_program(struct lp5521_engine *eng, const u8 *pattern) 191static int lp5521_load_program(struct lp5521_engine *eng, const u8 *pattern)
@@ -643,6 +646,7 @@ static int __devinit lp5521_probe(struct i2c_client *client,
643 struct lp5521_chip *chip; 646 struct lp5521_chip *chip;
644 struct lp5521_platform_data *pdata; 647 struct lp5521_platform_data *pdata;
645 int ret, i, led; 648 int ret, i, led;
649 u8 buf;
646 650
647 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 651 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
648 if (!chip) 652 if (!chip)
@@ -681,6 +685,20 @@ static int __devinit lp5521_probe(struct i2c_client *client,
681 * Exact value is not available. 10 - 20ms 685 * Exact value is not available. 10 - 20ms
682 * appears to be enough for reset. 686 * appears to be enough for reset.
683 */ 687 */
688
689 /*
690 * Make sure that the chip is reset by reading back the r channel
691 * current reg. This is dummy read is required on some platforms -
692 * otherwise further access to the R G B channels in the
693 * LP5521_REG_ENABLE register will not have any effect - strange!
694 */
695 lp5521_read(client, LP5521_REG_R_CURRENT, &buf);
696 if (buf != LP5521_REG_R_CURR_DEFAULT) {
697 dev_err(&client->dev, "error in reseting chip\n");
698 goto fail2;
699 }
700 usleep_range(10000, 20000);
701
684 ret = lp5521_detect(client); 702 ret = lp5521_detect(client);
685 703
686 if (ret) { 704 if (ret) {
diff --git a/drivers/leds/leds-renesas-tpu.c b/drivers/leds/leds-renesas-tpu.c
new file mode 100644
index 000000000000..3ee540eb127e
--- /dev/null
+++ b/drivers/leds/leds-renesas-tpu.c
@@ -0,0 +1,357 @@
1/*
2 * LED control using Renesas TPU
3 *
4 * Copyright (C) 2011 Magnus Damm
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/module.h>
21#include <linux/init.h>
22#include <linux/platform_device.h>
23#include <linux/spinlock.h>
24#include <linux/printk.h>
25#include <linux/ioport.h>
26#include <linux/io.h>
27#include <linux/clk.h>
28#include <linux/leds.h>
29#include <linux/platform_data/leds-renesas-tpu.h>
30#include <linux/gpio.h>
31#include <linux/err.h>
32#include <linux/slab.h>
33#include <linux/pm_runtime.h>
34#include <linux/workqueue.h>
35
36enum r_tpu_pin { R_TPU_PIN_UNUSED, R_TPU_PIN_GPIO, R_TPU_PIN_GPIO_FN };
37enum r_tpu_timer { R_TPU_TIMER_UNUSED, R_TPU_TIMER_ON };
38
39struct r_tpu_priv {
40 struct led_classdev ldev;
41 void __iomem *mapbase;
42 struct clk *clk;
43 struct platform_device *pdev;
44 enum r_tpu_pin pin_state;
45 enum r_tpu_timer timer_state;
46 unsigned long min_rate;
47 unsigned int refresh_rate;
48 struct work_struct work;
49 enum led_brightness new_brightness;
50};
51
52static DEFINE_SPINLOCK(r_tpu_lock);
53
54#define TSTR -1 /* Timer start register (shared register) */
55#define TCR 0 /* Timer control register (+0x00) */
56#define TMDR 1 /* Timer mode register (+0x04) */
57#define TIOR 2 /* Timer I/O control register (+0x08) */
58#define TIER 3 /* Timer interrupt enable register (+0x0c) */
59#define TSR 4 /* Timer status register (+0x10) */
60#define TCNT 5 /* Timer counter (+0x14) */
61#define TGRA 6 /* Timer general register A (+0x18) */
62#define TGRB 7 /* Timer general register B (+0x1c) */
63#define TGRC 8 /* Timer general register C (+0x20) */
64#define TGRD 9 /* Timer general register D (+0x24) */
65
66static inline unsigned short r_tpu_read(struct r_tpu_priv *p, int reg_nr)
67{
68 struct led_renesas_tpu_config *cfg = p->pdev->dev.platform_data;
69 void __iomem *base = p->mapbase;
70 unsigned long offs = reg_nr << 2;
71
72 if (reg_nr == TSTR)
73 return ioread16(base - cfg->channel_offset);
74
75 return ioread16(base + offs);
76}
77
78static inline void r_tpu_write(struct r_tpu_priv *p, int reg_nr,
79 unsigned short value)
80{
81 struct led_renesas_tpu_config *cfg = p->pdev->dev.platform_data;
82 void __iomem *base = p->mapbase;
83 unsigned long offs = reg_nr << 2;
84
85 if (reg_nr == TSTR) {
86 iowrite16(value, base - cfg->channel_offset);
87 return;
88 }
89
90 iowrite16(value, base + offs);
91}
92
93static void r_tpu_start_stop_ch(struct r_tpu_priv *p, int start)
94{
95 struct led_renesas_tpu_config *cfg = p->pdev->dev.platform_data;
96 unsigned long flags, value;
97
98 /* start stop register shared by multiple timer channels */
99 spin_lock_irqsave(&r_tpu_lock, flags);
100 value = r_tpu_read(p, TSTR);
101
102 if (start)
103 value |= 1 << cfg->timer_bit;
104 else
105 value &= ~(1 << cfg->timer_bit);
106
107 r_tpu_write(p, TSTR, value);
108 spin_unlock_irqrestore(&r_tpu_lock, flags);
109}
110
111static int r_tpu_enable(struct r_tpu_priv *p, enum led_brightness brightness)
112{
113 struct led_renesas_tpu_config *cfg = p->pdev->dev.platform_data;
114 int prescaler[] = { 1, 4, 16, 64 };
115 int k, ret;
116 unsigned long rate, tmp;
117
118 if (p->timer_state == R_TPU_TIMER_ON)
119 return 0;
120
121 /* wake up device and enable clock */
122 pm_runtime_get_sync(&p->pdev->dev);
123 ret = clk_enable(p->clk);
124 if (ret) {
125 dev_err(&p->pdev->dev, "cannot enable clock\n");
126 return ret;
127 }
128
129 /* make sure channel is disabled */
130 r_tpu_start_stop_ch(p, 0);
131
132 /* get clock rate after enabling it */
133 rate = clk_get_rate(p->clk);
134
135 /* pick the lowest acceptable rate */
136 for (k = 0; k < ARRAY_SIZE(prescaler); k++)
137 if ((rate / prescaler[k]) < p->min_rate)
138 break;
139
140 if (!k) {
141 dev_err(&p->pdev->dev, "clock rate mismatch\n");
142 goto err0;
143 }
144 dev_dbg(&p->pdev->dev, "rate = %lu, prescaler %u\n",
145 rate, prescaler[k - 1]);
146
147 /* clear TCNT on TGRB match, count on rising edge, set prescaler */
148 r_tpu_write(p, TCR, 0x0040 | (k - 1));
149
150 /* output 0 until TGRA, output 1 until TGRB */
151 r_tpu_write(p, TIOR, 0x0002);
152
153 rate /= prescaler[k - 1] * p->refresh_rate;
154 r_tpu_write(p, TGRB, rate);
155 dev_dbg(&p->pdev->dev, "TRGB = 0x%04lx\n", rate);
156
157 tmp = (cfg->max_brightness - brightness) * rate;
158 r_tpu_write(p, TGRA, tmp / cfg->max_brightness);
159 dev_dbg(&p->pdev->dev, "TRGA = 0x%04lx\n", tmp / cfg->max_brightness);
160
161 /* PWM mode */
162 r_tpu_write(p, TMDR, 0x0002);
163
164 /* enable channel */
165 r_tpu_start_stop_ch(p, 1);
166
167 p->timer_state = R_TPU_TIMER_ON;
168 return 0;
169 err0:
170 clk_disable(p->clk);
171 pm_runtime_put_sync(&p->pdev->dev);
172 return -ENOTSUPP;
173}
174
175static void r_tpu_disable(struct r_tpu_priv *p)
176{
177 if (p->timer_state == R_TPU_TIMER_UNUSED)
178 return;
179
180 /* disable channel */
181 r_tpu_start_stop_ch(p, 0);
182
183 /* stop clock and mark device as idle */
184 clk_disable(p->clk);
185 pm_runtime_put_sync(&p->pdev->dev);
186
187 p->timer_state = R_TPU_TIMER_UNUSED;
188}
189
190static void r_tpu_set_pin(struct r_tpu_priv *p, enum r_tpu_pin new_state,
191 enum led_brightness brightness)
192{
193 struct led_renesas_tpu_config *cfg = p->pdev->dev.platform_data;
194
195 if (p->pin_state == new_state) {
196 if (p->pin_state == R_TPU_PIN_GPIO)
197 gpio_set_value(cfg->pin_gpio, brightness);
198 return;
199 }
200
201 if (p->pin_state == R_TPU_PIN_GPIO)
202 gpio_free(cfg->pin_gpio);
203
204 if (p->pin_state == R_TPU_PIN_GPIO_FN)
205 gpio_free(cfg->pin_gpio_fn);
206
207 if (new_state == R_TPU_PIN_GPIO) {
208 gpio_request(cfg->pin_gpio, cfg->name);
209 gpio_direction_output(cfg->pin_gpio, !!brightness);
210 }
211 if (new_state == R_TPU_PIN_GPIO_FN)
212 gpio_request(cfg->pin_gpio_fn, cfg->name);
213
214 p->pin_state = new_state;
215}
216
217static void r_tpu_work(struct work_struct *work)
218{
219 struct r_tpu_priv *p = container_of(work, struct r_tpu_priv, work);
220 enum led_brightness brightness = p->new_brightness;
221
222 r_tpu_disable(p);
223
224 /* off and maximum are handled as GPIO pins, in between PWM */
225 if ((brightness == 0) || (brightness == p->ldev.max_brightness))
226 r_tpu_set_pin(p, R_TPU_PIN_GPIO, brightness);
227 else {
228 r_tpu_set_pin(p, R_TPU_PIN_GPIO_FN, 0);
229 r_tpu_enable(p, brightness);
230 }
231}
232
233static void r_tpu_set_brightness(struct led_classdev *ldev,
234 enum led_brightness brightness)
235{
236 struct r_tpu_priv *p = container_of(ldev, struct r_tpu_priv, ldev);
237 p->new_brightness = brightness;
238 schedule_work(&p->work);
239}
240
241static int __devinit r_tpu_probe(struct platform_device *pdev)
242{
243 struct led_renesas_tpu_config *cfg = pdev->dev.platform_data;
244 struct r_tpu_priv *p;
245 struct resource *res;
246 int ret = -ENXIO;
247
248 if (!cfg) {
249 dev_err(&pdev->dev, "missing platform data\n");
250 goto err0;
251 }
252
253 p = kzalloc(sizeof(*p), GFP_KERNEL);
254 if (p == NULL) {
255 dev_err(&pdev->dev, "failed to allocate driver data\n");
256 ret = -ENOMEM;
257 goto err0;
258 }
259
260 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
261 if (!res) {
262 dev_err(&pdev->dev, "failed to get I/O memory\n");
263 goto err1;
264 }
265
266 /* map memory, let mapbase point to our channel */
267 p->mapbase = ioremap_nocache(res->start, resource_size(res));
268 if (p->mapbase == NULL) {
269 dev_err(&pdev->dev, "failed to remap I/O memory\n");
270 goto err1;
271 }
272
273 /* get hold of clock */
274 p->clk = clk_get(&pdev->dev, NULL);
275 if (IS_ERR(p->clk)) {
276 dev_err(&pdev->dev, "cannot get clock\n");
277 ret = PTR_ERR(p->clk);
278 goto err2;
279 }
280
281 p->pdev = pdev;
282 p->pin_state = R_TPU_PIN_UNUSED;
283 p->timer_state = R_TPU_TIMER_UNUSED;
284 p->refresh_rate = cfg->refresh_rate ? cfg->refresh_rate : 100;
285 r_tpu_set_pin(p, R_TPU_PIN_GPIO, LED_OFF);
286 platform_set_drvdata(pdev, p);
287
288 INIT_WORK(&p->work, r_tpu_work);
289
290 p->ldev.name = cfg->name;
291 p->ldev.brightness = LED_OFF;
292 p->ldev.max_brightness = cfg->max_brightness;
293 p->ldev.brightness_set = r_tpu_set_brightness;
294 p->ldev.flags |= LED_CORE_SUSPENDRESUME;
295 ret = led_classdev_register(&pdev->dev, &p->ldev);
296 if (ret < 0)
297 goto err3;
298
299 /* max_brightness may be updated by the LED core code */
300 p->min_rate = p->ldev.max_brightness * p->refresh_rate;
301
302 pm_runtime_enable(&pdev->dev);
303 return 0;
304
305 err3:
306 r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF);
307 clk_put(p->clk);
308 err2:
309 iounmap(p->mapbase);
310 err1:
311 kfree(p);
312 err0:
313 return ret;
314}
315
316static int __devexit r_tpu_remove(struct platform_device *pdev)
317{
318 struct r_tpu_priv *p = platform_get_drvdata(pdev);
319
320 r_tpu_set_brightness(&p->ldev, LED_OFF);
321 led_classdev_unregister(&p->ldev);
322 cancel_work_sync(&p->work);
323 r_tpu_disable(p);
324 r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF);
325
326 pm_runtime_disable(&pdev->dev);
327 clk_put(p->clk);
328
329 iounmap(p->mapbase);
330 kfree(p);
331 return 0;
332}
333
334static struct platform_driver r_tpu_device_driver = {
335 .probe = r_tpu_probe,
336 .remove = __devexit_p(r_tpu_remove),
337 .driver = {
338 .name = "leds-renesas-tpu",
339 }
340};
341
342static int __init r_tpu_init(void)
343{
344 return platform_driver_register(&r_tpu_device_driver);
345}
346
347static void __exit r_tpu_exit(void)
348{
349 platform_driver_unregister(&r_tpu_device_driver);
350}
351
352module_init(r_tpu_init);
353module_exit(r_tpu_exit);
354
355MODULE_AUTHOR("Magnus Damm");
356MODULE_DESCRIPTION("Renesas TPU LED Driver");
357MODULE_LICENSE("GPL v2");
diff --git a/drivers/misc/ad525x_dpot-i2c.c b/drivers/misc/ad525x_dpot-i2c.c
index 4ff73c215746..a39e0555df63 100644
--- a/drivers/misc/ad525x_dpot-i2c.c
+++ b/drivers/misc/ad525x_dpot-i2c.c
@@ -98,6 +98,7 @@ static const struct i2c_device_id ad_dpot_id[] = {
98 {"ad5282", AD5282_ID}, 98 {"ad5282", AD5282_ID},
99 {"adn2860", ADN2860_ID}, 99 {"adn2860", ADN2860_ID},
100 {"ad5273", AD5273_ID}, 100 {"ad5273", AD5273_ID},
101 {"ad5161", AD5161_ID},
101 {"ad5171", AD5171_ID}, 102 {"ad5171", AD5171_ID},
102 {"ad5170", AD5170_ID}, 103 {"ad5170", AD5170_ID},
103 {"ad5172", AD5172_ID}, 104 {"ad5172", AD5172_ID},
diff --git a/drivers/misc/fsa9480.c b/drivers/misc/fsa9480.c
index 27dc0d21aafa..f6586d53e1a3 100644
--- a/drivers/misc/fsa9480.c
+++ b/drivers/misc/fsa9480.c
@@ -400,7 +400,8 @@ static int fsa9480_irq_init(struct fsa9480_usbsw *usbsw)
400 return ret; 400 return ret;
401 } 401 }
402 402
403 device_init_wakeup(&client->dev, pdata->wakeup); 403 if (pdata)
404 device_init_wakeup(&client->dev, pdata->wakeup);
404 } 405 }
405 406
406 return 0; 407 return 0;
diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
index 8b51cd62d067..29d12a70eb1b 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d.c
+++ b/drivers/misc/lis3lv02d/lis3lv02d.c
@@ -163,7 +163,7 @@ static void lis3lv02d_get_xyz(struct lis3lv02d *lis3, int *x, int *y, int *z)
163 int i; 163 int i;
164 164
165 if (lis3->blkread) { 165 if (lis3->blkread) {
166 if (lis3_dev.whoami == WAI_12B) { 166 if (lis3->whoami == WAI_12B) {
167 u16 data[3]; 167 u16 data[3];
168 lis3->blkread(lis3, OUTX_L, 6, (u8 *)data); 168 lis3->blkread(lis3, OUTX_L, 6, (u8 *)data);
169 for (i = 0; i < 3; i++) 169 for (i = 0; i < 3; i++)
@@ -195,18 +195,30 @@ static int lis3_8_rates[2] = {100, 400};
195static int lis3_3dc_rates[16] = {0, 1, 10, 25, 50, 100, 200, 400, 1600, 5000}; 195static int lis3_3dc_rates[16] = {0, 1, 10, 25, 50, 100, 200, 400, 1600, 5000};
196 196
197/* ODR is Output Data Rate */ 197/* ODR is Output Data Rate */
198static int lis3lv02d_get_odr(void) 198static int lis3lv02d_get_odr(struct lis3lv02d *lis3)
199{ 199{
200 u8 ctrl; 200 u8 ctrl;
201 int shift; 201 int shift;
202 202
203 lis3_dev.read(&lis3_dev, CTRL_REG1, &ctrl); 203 lis3->read(lis3, CTRL_REG1, &ctrl);
204 ctrl &= lis3_dev.odr_mask; 204 ctrl &= lis3->odr_mask;
205 shift = ffs(lis3_dev.odr_mask) - 1; 205 shift = ffs(lis3->odr_mask) - 1;
206 return lis3_dev.odrs[(ctrl >> shift)]; 206 return lis3->odrs[(ctrl >> shift)];
207} 207}
208 208
209static int lis3lv02d_set_odr(int rate) 209static int lis3lv02d_get_pwron_wait(struct lis3lv02d *lis3)
210{
211 int div = lis3lv02d_get_odr(lis3);
212
213 if (WARN_ONCE(div == 0, "device returned spurious data"))
214 return -ENXIO;
215
216 /* LIS3 power on delay is quite long */
217 msleep(lis3->pwron_delay / div);
218 return 0;
219}
220
221static int lis3lv02d_set_odr(struct lis3lv02d *lis3, int rate)
210{ 222{
211 u8 ctrl; 223 u8 ctrl;
212 int i, len, shift; 224 int i, len, shift;
@@ -214,14 +226,14 @@ static int lis3lv02d_set_odr(int rate)
214 if (!rate) 226 if (!rate)
215 return -EINVAL; 227 return -EINVAL;
216 228
217 lis3_dev.read(&lis3_dev, CTRL_REG1, &ctrl); 229 lis3->read(lis3, CTRL_REG1, &ctrl);
218 ctrl &= ~lis3_dev.odr_mask; 230 ctrl &= ~lis3->odr_mask;
219 len = 1 << hweight_long(lis3_dev.odr_mask); /* # of possible values */ 231 len = 1 << hweight_long(lis3->odr_mask); /* # of possible values */
220 shift = ffs(lis3_dev.odr_mask) - 1; 232 shift = ffs(lis3->odr_mask) - 1;
221 233
222 for (i = 0; i < len; i++) 234 for (i = 0; i < len; i++)
223 if (lis3_dev.odrs[i] == rate) { 235 if (lis3->odrs[i] == rate) {
224 lis3_dev.write(&lis3_dev, CTRL_REG1, 236 lis3->write(lis3, CTRL_REG1,
225 ctrl | (i << shift)); 237 ctrl | (i << shift));
226 return 0; 238 return 0;
227 } 239 }
@@ -240,12 +252,12 @@ static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3])
240 mutex_lock(&lis3->mutex); 252 mutex_lock(&lis3->mutex);
241 253
242 irq_cfg = lis3->irq_cfg; 254 irq_cfg = lis3->irq_cfg;
243 if (lis3_dev.whoami == WAI_8B) { 255 if (lis3->whoami == WAI_8B) {
244 lis3->data_ready_count[IRQ_LINE0] = 0; 256 lis3->data_ready_count[IRQ_LINE0] = 0;
245 lis3->data_ready_count[IRQ_LINE1] = 0; 257 lis3->data_ready_count[IRQ_LINE1] = 0;
246 258
247 /* Change interrupt cfg to data ready for selftest */ 259 /* Change interrupt cfg to data ready for selftest */
248 atomic_inc(&lis3_dev.wake_thread); 260 atomic_inc(&lis3->wake_thread);
249 lis3->irq_cfg = LIS3_IRQ1_DATA_READY | LIS3_IRQ2_DATA_READY; 261 lis3->irq_cfg = LIS3_IRQ1_DATA_READY | LIS3_IRQ2_DATA_READY;
250 lis3->read(lis3, CTRL_REG3, &ctrl_reg_data); 262 lis3->read(lis3, CTRL_REG3, &ctrl_reg_data);
251 lis3->write(lis3, CTRL_REG3, (ctrl_reg_data & 263 lis3->write(lis3, CTRL_REG3, (ctrl_reg_data &
@@ -253,12 +265,12 @@ static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3])
253 (LIS3_IRQ1_DATA_READY | LIS3_IRQ2_DATA_READY)); 265 (LIS3_IRQ1_DATA_READY | LIS3_IRQ2_DATA_READY));
254 } 266 }
255 267
256 if (lis3_dev.whoami == WAI_3DC) { 268 if (lis3->whoami == WAI_3DC) {
257 ctlreg = CTRL_REG4; 269 ctlreg = CTRL_REG4;
258 selftest = CTRL4_ST0; 270 selftest = CTRL4_ST0;
259 } else { 271 } else {
260 ctlreg = CTRL_REG1; 272 ctlreg = CTRL_REG1;
261 if (lis3_dev.whoami == WAI_12B) 273 if (lis3->whoami == WAI_12B)
262 selftest = CTRL1_ST; 274 selftest = CTRL1_ST;
263 else 275 else
264 selftest = CTRL1_STP; 276 selftest = CTRL1_STP;
@@ -266,7 +278,9 @@ static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3])
266 278
267 lis3->read(lis3, ctlreg, &reg); 279 lis3->read(lis3, ctlreg, &reg);
268 lis3->write(lis3, ctlreg, (reg | selftest)); 280 lis3->write(lis3, ctlreg, (reg | selftest));
269 msleep(lis3->pwron_delay / lis3lv02d_get_odr()); 281 ret = lis3lv02d_get_pwron_wait(lis3);
282 if (ret)
283 goto fail;
270 284
271 /* Read directly to avoid axis remap */ 285 /* Read directly to avoid axis remap */
272 x = lis3->read_data(lis3, OUTX); 286 x = lis3->read_data(lis3, OUTX);
@@ -275,7 +289,9 @@ static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3])
275 289
276 /* back to normal settings */ 290 /* back to normal settings */
277 lis3->write(lis3, ctlreg, reg); 291 lis3->write(lis3, ctlreg, reg);
278 msleep(lis3->pwron_delay / lis3lv02d_get_odr()); 292 ret = lis3lv02d_get_pwron_wait(lis3);
293 if (ret)
294 goto fail;
279 295
280 results[0] = x - lis3->read_data(lis3, OUTX); 296 results[0] = x - lis3->read_data(lis3, OUTX);
281 results[1] = y - lis3->read_data(lis3, OUTY); 297 results[1] = y - lis3->read_data(lis3, OUTY);
@@ -283,9 +299,9 @@ static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3])
283 299
284 ret = 0; 300 ret = 0;
285 301
286 if (lis3_dev.whoami == WAI_8B) { 302 if (lis3->whoami == WAI_8B) {
287 /* Restore original interrupt configuration */ 303 /* Restore original interrupt configuration */
288 atomic_dec(&lis3_dev.wake_thread); 304 atomic_dec(&lis3->wake_thread);
289 lis3->write(lis3, CTRL_REG3, ctrl_reg_data); 305 lis3->write(lis3, CTRL_REG3, ctrl_reg_data);
290 lis3->irq_cfg = irq_cfg; 306 lis3->irq_cfg = irq_cfg;
291 307
@@ -363,8 +379,9 @@ void lis3lv02d_poweroff(struct lis3lv02d *lis3)
363} 379}
364EXPORT_SYMBOL_GPL(lis3lv02d_poweroff); 380EXPORT_SYMBOL_GPL(lis3lv02d_poweroff);
365 381
366void lis3lv02d_poweron(struct lis3lv02d *lis3) 382int lis3lv02d_poweron(struct lis3lv02d *lis3)
367{ 383{
384 int err;
368 u8 reg; 385 u8 reg;
369 386
370 lis3->init(lis3); 387 lis3->init(lis3);
@@ -384,35 +401,41 @@ void lis3lv02d_poweron(struct lis3lv02d *lis3)
384 lis3->write(lis3, CTRL_REG2, reg); 401 lis3->write(lis3, CTRL_REG2, reg);
385 } 402 }
386 403
387 /* LIS3 power on delay is quite long */ 404 err = lis3lv02d_get_pwron_wait(lis3);
388 msleep(lis3->pwron_delay / lis3lv02d_get_odr()); 405 if (err)
406 return err;
389 407
390 if (lis3->reg_ctrl) 408 if (lis3->reg_ctrl)
391 lis3_context_restore(lis3); 409 lis3_context_restore(lis3);
410
411 return 0;
392} 412}
393EXPORT_SYMBOL_GPL(lis3lv02d_poweron); 413EXPORT_SYMBOL_GPL(lis3lv02d_poweron);
394 414
395 415
396static void lis3lv02d_joystick_poll(struct input_polled_dev *pidev) 416static void lis3lv02d_joystick_poll(struct input_polled_dev *pidev)
397{ 417{
418 struct lis3lv02d *lis3 = pidev->private;
398 int x, y, z; 419 int x, y, z;
399 420
400 mutex_lock(&lis3_dev.mutex); 421 mutex_lock(&lis3->mutex);
401 lis3lv02d_get_xyz(&lis3_dev, &x, &y, &z); 422 lis3lv02d_get_xyz(lis3, &x, &y, &z);
402 input_report_abs(pidev->input, ABS_X, x); 423 input_report_abs(pidev->input, ABS_X, x);
403 input_report_abs(pidev->input, ABS_Y, y); 424 input_report_abs(pidev->input, ABS_Y, y);
404 input_report_abs(pidev->input, ABS_Z, z); 425 input_report_abs(pidev->input, ABS_Z, z);
405 input_sync(pidev->input); 426 input_sync(pidev->input);
406 mutex_unlock(&lis3_dev.mutex); 427 mutex_unlock(&lis3->mutex);
407} 428}
408 429
409static void lis3lv02d_joystick_open(struct input_polled_dev *pidev) 430static void lis3lv02d_joystick_open(struct input_polled_dev *pidev)
410{ 431{
411 if (lis3_dev.pm_dev) 432 struct lis3lv02d *lis3 = pidev->private;
412 pm_runtime_get_sync(lis3_dev.pm_dev);
413 433
414 if (lis3_dev.pdata && lis3_dev.whoami == WAI_8B && lis3_dev.idev) 434 if (lis3->pm_dev)
415 atomic_set(&lis3_dev.wake_thread, 1); 435 pm_runtime_get_sync(lis3->pm_dev);
436
437 if (lis3->pdata && lis3->whoami == WAI_8B && lis3->idev)
438 atomic_set(&lis3->wake_thread, 1);
416 /* 439 /*
417 * Update coordinates for the case where poll interval is 0 and 440 * Update coordinates for the case where poll interval is 0 and
418 * the chip in running purely under interrupt control 441 * the chip in running purely under interrupt control
@@ -422,14 +445,18 @@ static void lis3lv02d_joystick_open(struct input_polled_dev *pidev)
422 445
423static void lis3lv02d_joystick_close(struct input_polled_dev *pidev) 446static void lis3lv02d_joystick_close(struct input_polled_dev *pidev)
424{ 447{
425 atomic_set(&lis3_dev.wake_thread, 0); 448 struct lis3lv02d *lis3 = pidev->private;
426 if (lis3_dev.pm_dev) 449
427 pm_runtime_put(lis3_dev.pm_dev); 450 atomic_set(&lis3->wake_thread, 0);
451 if (lis3->pm_dev)
452 pm_runtime_put(lis3->pm_dev);
428} 453}
429 454
430static irqreturn_t lis302dl_interrupt(int irq, void *dummy) 455static irqreturn_t lis302dl_interrupt(int irq, void *data)
431{ 456{
432 if (!test_bit(0, &lis3_dev.misc_opened)) 457 struct lis3lv02d *lis3 = data;
458
459 if (!test_bit(0, &lis3->misc_opened))
433 goto out; 460 goto out;
434 461
435 /* 462 /*
@@ -437,12 +464,12 @@ static irqreturn_t lis302dl_interrupt(int irq, void *dummy)
437 * the lid is closed. This leads to interrupts as soon as a little move 464 * the lid is closed. This leads to interrupts as soon as a little move
438 * is done. 465 * is done.
439 */ 466 */
440 atomic_inc(&lis3_dev.count); 467 atomic_inc(&lis3->count);
441 468
442 wake_up_interruptible(&lis3_dev.misc_wait); 469 wake_up_interruptible(&lis3->misc_wait);
443 kill_fasync(&lis3_dev.async_queue, SIGIO, POLL_IN); 470 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
444out: 471out:
445 if (atomic_read(&lis3_dev.wake_thread)) 472 if (atomic_read(&lis3->wake_thread))
446 return IRQ_WAKE_THREAD; 473 return IRQ_WAKE_THREAD;
447 return IRQ_HANDLED; 474 return IRQ_HANDLED;
448} 475}
@@ -514,28 +541,37 @@ static irqreturn_t lis302dl_interrupt_thread2_8b(int irq, void *data)
514 541
515static int lis3lv02d_misc_open(struct inode *inode, struct file *file) 542static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
516{ 543{
517 if (test_and_set_bit(0, &lis3_dev.misc_opened)) 544 struct lis3lv02d *lis3 = container_of(file->private_data,
545 struct lis3lv02d, miscdev);
546
547 if (test_and_set_bit(0, &lis3->misc_opened))
518 return -EBUSY; /* already open */ 548 return -EBUSY; /* already open */
519 549
520 if (lis3_dev.pm_dev) 550 if (lis3->pm_dev)
521 pm_runtime_get_sync(lis3_dev.pm_dev); 551 pm_runtime_get_sync(lis3->pm_dev);
522 552
523 atomic_set(&lis3_dev.count, 0); 553 atomic_set(&lis3->count, 0);
524 return 0; 554 return 0;
525} 555}
526 556
527static int lis3lv02d_misc_release(struct inode *inode, struct file *file) 557static int lis3lv02d_misc_release(struct inode *inode, struct file *file)
528{ 558{
529 fasync_helper(-1, file, 0, &lis3_dev.async_queue); 559 struct lis3lv02d *lis3 = container_of(file->private_data,
530 clear_bit(0, &lis3_dev.misc_opened); /* release the device */ 560 struct lis3lv02d, miscdev);
531 if (lis3_dev.pm_dev) 561
532 pm_runtime_put(lis3_dev.pm_dev); 562 fasync_helper(-1, file, 0, &lis3->async_queue);
563 clear_bit(0, &lis3->misc_opened); /* release the device */
564 if (lis3->pm_dev)
565 pm_runtime_put(lis3->pm_dev);
533 return 0; 566 return 0;
534} 567}
535 568
536static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf, 569static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
537 size_t count, loff_t *pos) 570 size_t count, loff_t *pos)
538{ 571{
572 struct lis3lv02d *lis3 = container_of(file->private_data,
573 struct lis3lv02d, miscdev);
574
539 DECLARE_WAITQUEUE(wait, current); 575 DECLARE_WAITQUEUE(wait, current);
540 u32 data; 576 u32 data;
541 unsigned char byte_data; 577 unsigned char byte_data;
@@ -544,10 +580,10 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
544 if (count < 1) 580 if (count < 1)
545 return -EINVAL; 581 return -EINVAL;
546 582
547 add_wait_queue(&lis3_dev.misc_wait, &wait); 583 add_wait_queue(&lis3->misc_wait, &wait);
548 while (true) { 584 while (true) {
549 set_current_state(TASK_INTERRUPTIBLE); 585 set_current_state(TASK_INTERRUPTIBLE);
550 data = atomic_xchg(&lis3_dev.count, 0); 586 data = atomic_xchg(&lis3->count, 0);
551 if (data) 587 if (data)
552 break; 588 break;
553 589
@@ -577,22 +613,28 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
577 613
578out: 614out:
579 __set_current_state(TASK_RUNNING); 615 __set_current_state(TASK_RUNNING);
580 remove_wait_queue(&lis3_dev.misc_wait, &wait); 616 remove_wait_queue(&lis3->misc_wait, &wait);
581 617
582 return retval; 618 return retval;
583} 619}
584 620
585static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait) 621static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
586{ 622{
587 poll_wait(file, &lis3_dev.misc_wait, wait); 623 struct lis3lv02d *lis3 = container_of(file->private_data,
588 if (atomic_read(&lis3_dev.count)) 624 struct lis3lv02d, miscdev);
625
626 poll_wait(file, &lis3->misc_wait, wait);
627 if (atomic_read(&lis3->count))
589 return POLLIN | POLLRDNORM; 628 return POLLIN | POLLRDNORM;
590 return 0; 629 return 0;
591} 630}
592 631
593static int lis3lv02d_misc_fasync(int fd, struct file *file, int on) 632static int lis3lv02d_misc_fasync(int fd, struct file *file, int on)
594{ 633{
595 return fasync_helper(fd, file, on, &lis3_dev.async_queue); 634 struct lis3lv02d *lis3 = container_of(file->private_data,
635 struct lis3lv02d, miscdev);
636
637 return fasync_helper(fd, file, on, &lis3->async_queue);
596} 638}
597 639
598static const struct file_operations lis3lv02d_misc_fops = { 640static const struct file_operations lis3lv02d_misc_fops = {
@@ -605,85 +647,80 @@ static const struct file_operations lis3lv02d_misc_fops = {
605 .fasync = lis3lv02d_misc_fasync, 647 .fasync = lis3lv02d_misc_fasync,
606}; 648};
607 649
608static struct miscdevice lis3lv02d_misc_device = { 650int lis3lv02d_joystick_enable(struct lis3lv02d *lis3)
609 .minor = MISC_DYNAMIC_MINOR,
610 .name = "freefall",
611 .fops = &lis3lv02d_misc_fops,
612};
613
614int lis3lv02d_joystick_enable(void)
615{ 651{
616 struct input_dev *input_dev; 652 struct input_dev *input_dev;
617 int err; 653 int err;
618 int max_val, fuzz, flat; 654 int max_val, fuzz, flat;
619 int btns[] = {BTN_X, BTN_Y, BTN_Z}; 655 int btns[] = {BTN_X, BTN_Y, BTN_Z};
620 656
621 if (lis3_dev.idev) 657 if (lis3->idev)
622 return -EINVAL; 658 return -EINVAL;
623 659
624 lis3_dev.idev = input_allocate_polled_device(); 660 lis3->idev = input_allocate_polled_device();
625 if (!lis3_dev.idev) 661 if (!lis3->idev)
626 return -ENOMEM; 662 return -ENOMEM;
627 663
628 lis3_dev.idev->poll = lis3lv02d_joystick_poll; 664 lis3->idev->poll = lis3lv02d_joystick_poll;
629 lis3_dev.idev->open = lis3lv02d_joystick_open; 665 lis3->idev->open = lis3lv02d_joystick_open;
630 lis3_dev.idev->close = lis3lv02d_joystick_close; 666 lis3->idev->close = lis3lv02d_joystick_close;
631 lis3_dev.idev->poll_interval = MDPS_POLL_INTERVAL; 667 lis3->idev->poll_interval = MDPS_POLL_INTERVAL;
632 lis3_dev.idev->poll_interval_min = MDPS_POLL_MIN; 668 lis3->idev->poll_interval_min = MDPS_POLL_MIN;
633 lis3_dev.idev->poll_interval_max = MDPS_POLL_MAX; 669 lis3->idev->poll_interval_max = MDPS_POLL_MAX;
634 input_dev = lis3_dev.idev->input; 670 lis3->idev->private = lis3;
671 input_dev = lis3->idev->input;
635 672
636 input_dev->name = "ST LIS3LV02DL Accelerometer"; 673 input_dev->name = "ST LIS3LV02DL Accelerometer";
637 input_dev->phys = DRIVER_NAME "/input0"; 674 input_dev->phys = DRIVER_NAME "/input0";
638 input_dev->id.bustype = BUS_HOST; 675 input_dev->id.bustype = BUS_HOST;
639 input_dev->id.vendor = 0; 676 input_dev->id.vendor = 0;
640 input_dev->dev.parent = &lis3_dev.pdev->dev; 677 input_dev->dev.parent = &lis3->pdev->dev;
641 678
642 set_bit(EV_ABS, input_dev->evbit); 679 set_bit(EV_ABS, input_dev->evbit);
643 max_val = (lis3_dev.mdps_max_val * lis3_dev.scale) / LIS3_ACCURACY; 680 max_val = (lis3->mdps_max_val * lis3->scale) / LIS3_ACCURACY;
644 if (lis3_dev.whoami == WAI_12B) { 681 if (lis3->whoami == WAI_12B) {
645 fuzz = LIS3_DEFAULT_FUZZ_12B; 682 fuzz = LIS3_DEFAULT_FUZZ_12B;
646 flat = LIS3_DEFAULT_FLAT_12B; 683 flat = LIS3_DEFAULT_FLAT_12B;
647 } else { 684 } else {
648 fuzz = LIS3_DEFAULT_FUZZ_8B; 685 fuzz = LIS3_DEFAULT_FUZZ_8B;
649 flat = LIS3_DEFAULT_FLAT_8B; 686 flat = LIS3_DEFAULT_FLAT_8B;
650 } 687 }
651 fuzz = (fuzz * lis3_dev.scale) / LIS3_ACCURACY; 688 fuzz = (fuzz * lis3->scale) / LIS3_ACCURACY;
652 flat = (flat * lis3_dev.scale) / LIS3_ACCURACY; 689 flat = (flat * lis3->scale) / LIS3_ACCURACY;
653 690
654 input_set_abs_params(input_dev, ABS_X, -max_val, max_val, fuzz, flat); 691 input_set_abs_params(input_dev, ABS_X, -max_val, max_val, fuzz, flat);
655 input_set_abs_params(input_dev, ABS_Y, -max_val, max_val, fuzz, flat); 692 input_set_abs_params(input_dev, ABS_Y, -max_val, max_val, fuzz, flat);
656 input_set_abs_params(input_dev, ABS_Z, -max_val, max_val, fuzz, flat); 693 input_set_abs_params(input_dev, ABS_Z, -max_val, max_val, fuzz, flat);
657 694
658 lis3_dev.mapped_btns[0] = lis3lv02d_get_axis(abs(lis3_dev.ac.x), btns); 695 lis3->mapped_btns[0] = lis3lv02d_get_axis(abs(lis3->ac.x), btns);
659 lis3_dev.mapped_btns[1] = lis3lv02d_get_axis(abs(lis3_dev.ac.y), btns); 696 lis3->mapped_btns[1] = lis3lv02d_get_axis(abs(lis3->ac.y), btns);
660 lis3_dev.mapped_btns[2] = lis3lv02d_get_axis(abs(lis3_dev.ac.z), btns); 697 lis3->mapped_btns[2] = lis3lv02d_get_axis(abs(lis3->ac.z), btns);
661 698
662 err = input_register_polled_device(lis3_dev.idev); 699 err = input_register_polled_device(lis3->idev);
663 if (err) { 700 if (err) {
664 input_free_polled_device(lis3_dev.idev); 701 input_free_polled_device(lis3->idev);
665 lis3_dev.idev = NULL; 702 lis3->idev = NULL;
666 } 703 }
667 704
668 return err; 705 return err;
669} 706}
670EXPORT_SYMBOL_GPL(lis3lv02d_joystick_enable); 707EXPORT_SYMBOL_GPL(lis3lv02d_joystick_enable);
671 708
672void lis3lv02d_joystick_disable(void) 709void lis3lv02d_joystick_disable(struct lis3lv02d *lis3)
673{ 710{
674 if (lis3_dev.irq) 711 if (lis3->irq)
675 free_irq(lis3_dev.irq, &lis3_dev); 712 free_irq(lis3->irq, lis3);
676 if (lis3_dev.pdata && lis3_dev.pdata->irq2) 713 if (lis3->pdata && lis3->pdata->irq2)
677 free_irq(lis3_dev.pdata->irq2, &lis3_dev); 714 free_irq(lis3->pdata->irq2, lis3);
678 715
679 if (!lis3_dev.idev) 716 if (!lis3->idev)
680 return; 717 return;
681 718
682 if (lis3_dev.irq) 719 if (lis3->irq)
683 misc_deregister(&lis3lv02d_misc_device); 720 misc_deregister(&lis3->miscdev);
684 input_unregister_polled_device(lis3_dev.idev); 721 input_unregister_polled_device(lis3->idev);
685 input_free_polled_device(lis3_dev.idev); 722 input_free_polled_device(lis3->idev);
686 lis3_dev.idev = NULL; 723 lis3->idev = NULL;
687} 724}
688EXPORT_SYMBOL_GPL(lis3lv02d_joystick_disable); 725EXPORT_SYMBOL_GPL(lis3lv02d_joystick_disable);
689 726
@@ -708,6 +745,7 @@ static void lis3lv02d_sysfs_poweron(struct lis3lv02d *lis3)
708static ssize_t lis3lv02d_selftest_show(struct device *dev, 745static ssize_t lis3lv02d_selftest_show(struct device *dev,
709 struct device_attribute *attr, char *buf) 746 struct device_attribute *attr, char *buf)
710{ 747{
748 struct lis3lv02d *lis3 = dev_get_drvdata(dev);
711 s16 values[3]; 749 s16 values[3];
712 750
713 static const char ok[] = "OK"; 751 static const char ok[] = "OK";
@@ -715,8 +753,8 @@ static ssize_t lis3lv02d_selftest_show(struct device *dev,
715 static const char irq[] = "FAIL_IRQ"; 753 static const char irq[] = "FAIL_IRQ";
716 const char *res; 754 const char *res;
717 755
718 lis3lv02d_sysfs_poweron(&lis3_dev); 756 lis3lv02d_sysfs_poweron(lis3);
719 switch (lis3lv02d_selftest(&lis3_dev, values)) { 757 switch (lis3lv02d_selftest(lis3, values)) {
720 case SELFTEST_FAIL: 758 case SELFTEST_FAIL:
721 res = fail; 759 res = fail;
722 break; 760 break;
@@ -735,33 +773,37 @@ static ssize_t lis3lv02d_selftest_show(struct device *dev,
735static ssize_t lis3lv02d_position_show(struct device *dev, 773static ssize_t lis3lv02d_position_show(struct device *dev,
736 struct device_attribute *attr, char *buf) 774 struct device_attribute *attr, char *buf)
737{ 775{
776 struct lis3lv02d *lis3 = dev_get_drvdata(dev);
738 int x, y, z; 777 int x, y, z;
739 778
740 lis3lv02d_sysfs_poweron(&lis3_dev); 779 lis3lv02d_sysfs_poweron(lis3);
741 mutex_lock(&lis3_dev.mutex); 780 mutex_lock(&lis3->mutex);
742 lis3lv02d_get_xyz(&lis3_dev, &x, &y, &z); 781 lis3lv02d_get_xyz(lis3, &x, &y, &z);
743 mutex_unlock(&lis3_dev.mutex); 782 mutex_unlock(&lis3->mutex);
744 return sprintf(buf, "(%d,%d,%d)\n", x, y, z); 783 return sprintf(buf, "(%d,%d,%d)\n", x, y, z);
745} 784}
746 785
747static ssize_t lis3lv02d_rate_show(struct device *dev, 786static ssize_t lis3lv02d_rate_show(struct device *dev,
748 struct device_attribute *attr, char *buf) 787 struct device_attribute *attr, char *buf)
749{ 788{
750 lis3lv02d_sysfs_poweron(&lis3_dev); 789 struct lis3lv02d *lis3 = dev_get_drvdata(dev);
751 return sprintf(buf, "%d\n", lis3lv02d_get_odr()); 790
791 lis3lv02d_sysfs_poweron(lis3);
792 return sprintf(buf, "%d\n", lis3lv02d_get_odr(lis3));
752} 793}
753 794
754static ssize_t lis3lv02d_rate_set(struct device *dev, 795static ssize_t lis3lv02d_rate_set(struct device *dev,
755 struct device_attribute *attr, const char *buf, 796 struct device_attribute *attr, const char *buf,
756 size_t count) 797 size_t count)
757{ 798{
799 struct lis3lv02d *lis3 = dev_get_drvdata(dev);
758 unsigned long rate; 800 unsigned long rate;
759 801
760 if (strict_strtoul(buf, 0, &rate)) 802 if (strict_strtoul(buf, 0, &rate))
761 return -EINVAL; 803 return -EINVAL;
762 804
763 lis3lv02d_sysfs_poweron(&lis3_dev); 805 lis3lv02d_sysfs_poweron(lis3);
764 if (lis3lv02d_set_odr(rate)) 806 if (lis3lv02d_set_odr(lis3, rate))
765 return -EINVAL; 807 return -EINVAL;
766 808
767 return count; 809 return count;
@@ -790,6 +832,7 @@ static int lis3lv02d_add_fs(struct lis3lv02d *lis3)
790 if (IS_ERR(lis3->pdev)) 832 if (IS_ERR(lis3->pdev))
791 return PTR_ERR(lis3->pdev); 833 return PTR_ERR(lis3->pdev);
792 834
835 platform_set_drvdata(lis3->pdev, lis3);
793 return sysfs_create_group(&lis3->pdev->dev.kobj, &lis3lv02d_attribute_group); 836 return sysfs_create_group(&lis3->pdev->dev.kobj, &lis3lv02d_attribute_group);
794} 837}
795 838
@@ -803,7 +846,7 @@ int lis3lv02d_remove_fs(struct lis3lv02d *lis3)
803 846
804 /* SYSFS may have left chip running. Turn off if necessary */ 847 /* SYSFS may have left chip running. Turn off if necessary */
805 if (!pm_runtime_suspended(lis3->pm_dev)) 848 if (!pm_runtime_suspended(lis3->pm_dev))
806 lis3lv02d_poweroff(&lis3_dev); 849 lis3lv02d_poweroff(lis3);
807 850
808 pm_runtime_disable(lis3->pm_dev); 851 pm_runtime_disable(lis3->pm_dev);
809 pm_runtime_set_suspended(lis3->pm_dev); 852 pm_runtime_set_suspended(lis3->pm_dev);
@@ -813,24 +856,24 @@ int lis3lv02d_remove_fs(struct lis3lv02d *lis3)
813} 856}
814EXPORT_SYMBOL_GPL(lis3lv02d_remove_fs); 857EXPORT_SYMBOL_GPL(lis3lv02d_remove_fs);
815 858
816static void lis3lv02d_8b_configure(struct lis3lv02d *dev, 859static void lis3lv02d_8b_configure(struct lis3lv02d *lis3,
817 struct lis3lv02d_platform_data *p) 860 struct lis3lv02d_platform_data *p)
818{ 861{
819 int err; 862 int err;
820 int ctrl2 = p->hipass_ctrl; 863 int ctrl2 = p->hipass_ctrl;
821 864
822 if (p->click_flags) { 865 if (p->click_flags) {
823 dev->write(dev, CLICK_CFG, p->click_flags); 866 lis3->write(lis3, CLICK_CFG, p->click_flags);
824 dev->write(dev, CLICK_TIMELIMIT, p->click_time_limit); 867 lis3->write(lis3, CLICK_TIMELIMIT, p->click_time_limit);
825 dev->write(dev, CLICK_LATENCY, p->click_latency); 868 lis3->write(lis3, CLICK_LATENCY, p->click_latency);
826 dev->write(dev, CLICK_WINDOW, p->click_window); 869 lis3->write(lis3, CLICK_WINDOW, p->click_window);
827 dev->write(dev, CLICK_THSZ, p->click_thresh_z & 0xf); 870 lis3->write(lis3, CLICK_THSZ, p->click_thresh_z & 0xf);
828 dev->write(dev, CLICK_THSY_X, 871 lis3->write(lis3, CLICK_THSY_X,
829 (p->click_thresh_x & 0xf) | 872 (p->click_thresh_x & 0xf) |
830 (p->click_thresh_y << 4)); 873 (p->click_thresh_y << 4));
831 874
832 if (dev->idev) { 875 if (lis3->idev) {
833 struct input_dev *input_dev = lis3_dev.idev->input; 876 struct input_dev *input_dev = lis3->idev->input;
834 input_set_capability(input_dev, EV_KEY, BTN_X); 877 input_set_capability(input_dev, EV_KEY, BTN_X);
835 input_set_capability(input_dev, EV_KEY, BTN_Y); 878 input_set_capability(input_dev, EV_KEY, BTN_Y);
836 input_set_capability(input_dev, EV_KEY, BTN_Z); 879 input_set_capability(input_dev, EV_KEY, BTN_Z);
@@ -838,22 +881,22 @@ static void lis3lv02d_8b_configure(struct lis3lv02d *dev,
838 } 881 }
839 882
840 if (p->wakeup_flags) { 883 if (p->wakeup_flags) {
841 dev->write(dev, FF_WU_CFG_1, p->wakeup_flags); 884 lis3->write(lis3, FF_WU_CFG_1, p->wakeup_flags);
842 dev->write(dev, FF_WU_THS_1, p->wakeup_thresh & 0x7f); 885 lis3->write(lis3, FF_WU_THS_1, p->wakeup_thresh & 0x7f);
843 /* pdata value + 1 to keep this backward compatible*/ 886 /* pdata value + 1 to keep this backward compatible*/
844 dev->write(dev, FF_WU_DURATION_1, p->duration1 + 1); 887 lis3->write(lis3, FF_WU_DURATION_1, p->duration1 + 1);
845 ctrl2 ^= HP_FF_WU1; /* Xor to keep compatible with old pdata*/ 888 ctrl2 ^= HP_FF_WU1; /* Xor to keep compatible with old pdata*/
846 } 889 }
847 890
848 if (p->wakeup_flags2) { 891 if (p->wakeup_flags2) {
849 dev->write(dev, FF_WU_CFG_2, p->wakeup_flags2); 892 lis3->write(lis3, FF_WU_CFG_2, p->wakeup_flags2);
850 dev->write(dev, FF_WU_THS_2, p->wakeup_thresh2 & 0x7f); 893 lis3->write(lis3, FF_WU_THS_2, p->wakeup_thresh2 & 0x7f);
851 /* pdata value + 1 to keep this backward compatible*/ 894 /* pdata value + 1 to keep this backward compatible*/
852 dev->write(dev, FF_WU_DURATION_2, p->duration2 + 1); 895 lis3->write(lis3, FF_WU_DURATION_2, p->duration2 + 1);
853 ctrl2 ^= HP_FF_WU2; /* Xor to keep compatible with old pdata*/ 896 ctrl2 ^= HP_FF_WU2; /* Xor to keep compatible with old pdata*/
854 } 897 }
855 /* Configure hipass filters */ 898 /* Configure hipass filters */
856 dev->write(dev, CTRL_REG2, ctrl2); 899 lis3->write(lis3, CTRL_REG2, ctrl2);
857 900
858 if (p->irq2) { 901 if (p->irq2) {
859 err = request_threaded_irq(p->irq2, 902 err = request_threaded_irq(p->irq2,
@@ -861,7 +904,7 @@ static void lis3lv02d_8b_configure(struct lis3lv02d *dev,
861 lis302dl_interrupt_thread2_8b, 904 lis302dl_interrupt_thread2_8b,
862 IRQF_TRIGGER_RISING | IRQF_ONESHOT | 905 IRQF_TRIGGER_RISING | IRQF_ONESHOT |
863 (p->irq_flags2 & IRQF_TRIGGER_MASK), 906 (p->irq_flags2 & IRQF_TRIGGER_MASK),
864 DRIVER_NAME, &lis3_dev); 907 DRIVER_NAME, lis3);
865 if (err < 0) 908 if (err < 0)
866 pr_err("No second IRQ. Limited functionality\n"); 909 pr_err("No second IRQ. Limited functionality\n");
867 } 910 }
@@ -871,93 +914,97 @@ static void lis3lv02d_8b_configure(struct lis3lv02d *dev,
871 * Initialise the accelerometer and the various subsystems. 914 * Initialise the accelerometer and the various subsystems.
872 * Should be rather independent of the bus system. 915 * Should be rather independent of the bus system.
873 */ 916 */
874int lis3lv02d_init_device(struct lis3lv02d *dev) 917int lis3lv02d_init_device(struct lis3lv02d *lis3)
875{ 918{
876 int err; 919 int err;
877 irq_handler_t thread_fn; 920 irq_handler_t thread_fn;
878 int irq_flags = 0; 921 int irq_flags = 0;
879 922
880 dev->whoami = lis3lv02d_read_8(dev, WHO_AM_I); 923 lis3->whoami = lis3lv02d_read_8(lis3, WHO_AM_I);
881 924
882 switch (dev->whoami) { 925 switch (lis3->whoami) {
883 case WAI_12B: 926 case WAI_12B:
884 pr_info("12 bits sensor found\n"); 927 pr_info("12 bits sensor found\n");
885 dev->read_data = lis3lv02d_read_12; 928 lis3->read_data = lis3lv02d_read_12;
886 dev->mdps_max_val = 2048; 929 lis3->mdps_max_val = 2048;
887 dev->pwron_delay = LIS3_PWRON_DELAY_WAI_12B; 930 lis3->pwron_delay = LIS3_PWRON_DELAY_WAI_12B;
888 dev->odrs = lis3_12_rates; 931 lis3->odrs = lis3_12_rates;
889 dev->odr_mask = CTRL1_DF0 | CTRL1_DF1; 932 lis3->odr_mask = CTRL1_DF0 | CTRL1_DF1;
890 dev->scale = LIS3_SENSITIVITY_12B; 933 lis3->scale = LIS3_SENSITIVITY_12B;
891 dev->regs = lis3_wai12_regs; 934 lis3->regs = lis3_wai12_regs;
892 dev->regs_size = ARRAY_SIZE(lis3_wai12_regs); 935 lis3->regs_size = ARRAY_SIZE(lis3_wai12_regs);
893 break; 936 break;
894 case WAI_8B: 937 case WAI_8B:
895 pr_info("8 bits sensor found\n"); 938 pr_info("8 bits sensor found\n");
896 dev->read_data = lis3lv02d_read_8; 939 lis3->read_data = lis3lv02d_read_8;
897 dev->mdps_max_val = 128; 940 lis3->mdps_max_val = 128;
898 dev->pwron_delay = LIS3_PWRON_DELAY_WAI_8B; 941 lis3->pwron_delay = LIS3_PWRON_DELAY_WAI_8B;
899 dev->odrs = lis3_8_rates; 942 lis3->odrs = lis3_8_rates;
900 dev->odr_mask = CTRL1_DR; 943 lis3->odr_mask = CTRL1_DR;
901 dev->scale = LIS3_SENSITIVITY_8B; 944 lis3->scale = LIS3_SENSITIVITY_8B;
902 dev->regs = lis3_wai8_regs; 945 lis3->regs = lis3_wai8_regs;
903 dev->regs_size = ARRAY_SIZE(lis3_wai8_regs); 946 lis3->regs_size = ARRAY_SIZE(lis3_wai8_regs);
904 break; 947 break;
905 case WAI_3DC: 948 case WAI_3DC:
906 pr_info("8 bits 3DC sensor found\n"); 949 pr_info("8 bits 3DC sensor found\n");
907 dev->read_data = lis3lv02d_read_8; 950 lis3->read_data = lis3lv02d_read_8;
908 dev->mdps_max_val = 128; 951 lis3->mdps_max_val = 128;
909 dev->pwron_delay = LIS3_PWRON_DELAY_WAI_8B; 952 lis3->pwron_delay = LIS3_PWRON_DELAY_WAI_8B;
910 dev->odrs = lis3_3dc_rates; 953 lis3->odrs = lis3_3dc_rates;
911 dev->odr_mask = CTRL1_ODR0|CTRL1_ODR1|CTRL1_ODR2|CTRL1_ODR3; 954 lis3->odr_mask = CTRL1_ODR0|CTRL1_ODR1|CTRL1_ODR2|CTRL1_ODR3;
912 dev->scale = LIS3_SENSITIVITY_8B; 955 lis3->scale = LIS3_SENSITIVITY_8B;
913 break; 956 break;
914 default: 957 default:
915 pr_err("unknown sensor type 0x%X\n", dev->whoami); 958 pr_err("unknown sensor type 0x%X\n", lis3->whoami);
916 return -EINVAL; 959 return -EINVAL;
917 } 960 }
918 961
919 dev->reg_cache = kzalloc(max(sizeof(lis3_wai8_regs), 962 lis3->reg_cache = kzalloc(max(sizeof(lis3_wai8_regs),
920 sizeof(lis3_wai12_regs)), GFP_KERNEL); 963 sizeof(lis3_wai12_regs)), GFP_KERNEL);
921 964
922 if (dev->reg_cache == NULL) { 965 if (lis3->reg_cache == NULL) {
923 printk(KERN_ERR DRIVER_NAME "out of memory\n"); 966 printk(KERN_ERR DRIVER_NAME "out of memory\n");
924 return -ENOMEM; 967 return -ENOMEM;
925 } 968 }
926 969
927 mutex_init(&dev->mutex); 970 mutex_init(&lis3->mutex);
928 atomic_set(&dev->wake_thread, 0); 971 atomic_set(&lis3->wake_thread, 0);
929 972
930 lis3lv02d_add_fs(dev); 973 lis3lv02d_add_fs(lis3);
931 lis3lv02d_poweron(dev); 974 err = lis3lv02d_poweron(lis3);
975 if (err) {
976 lis3lv02d_remove_fs(lis3);
977 return err;
978 }
932 979
933 if (dev->pm_dev) { 980 if (lis3->pm_dev) {
934 pm_runtime_set_active(dev->pm_dev); 981 pm_runtime_set_active(lis3->pm_dev);
935 pm_runtime_enable(dev->pm_dev); 982 pm_runtime_enable(lis3->pm_dev);
936 } 983 }
937 984
938 if (lis3lv02d_joystick_enable()) 985 if (lis3lv02d_joystick_enable(lis3))
939 pr_err("joystick initialization failed\n"); 986 pr_err("joystick initialization failed\n");
940 987
941 /* passing in platform specific data is purely optional and only 988 /* passing in platform specific data is purely optional and only
942 * used by the SPI transport layer at the moment */ 989 * used by the SPI transport layer at the moment */
943 if (dev->pdata) { 990 if (lis3->pdata) {
944 struct lis3lv02d_platform_data *p = dev->pdata; 991 struct lis3lv02d_platform_data *p = lis3->pdata;
945 992
946 if (dev->whoami == WAI_8B) 993 if (lis3->whoami == WAI_8B)
947 lis3lv02d_8b_configure(dev, p); 994 lis3lv02d_8b_configure(lis3, p);
948 995
949 irq_flags = p->irq_flags1 & IRQF_TRIGGER_MASK; 996 irq_flags = p->irq_flags1 & IRQF_TRIGGER_MASK;
950 997
951 dev->irq_cfg = p->irq_cfg; 998 lis3->irq_cfg = p->irq_cfg;
952 if (p->irq_cfg) 999 if (p->irq_cfg)
953 dev->write(dev, CTRL_REG3, p->irq_cfg); 1000 lis3->write(lis3, CTRL_REG3, p->irq_cfg);
954 1001
955 if (p->default_rate) 1002 if (p->default_rate)
956 lis3lv02d_set_odr(p->default_rate); 1003 lis3lv02d_set_odr(lis3, p->default_rate);
957 } 1004 }
958 1005
959 /* bail if we did not get an IRQ from the bus layer */ 1006 /* bail if we did not get an IRQ from the bus layer */
960 if (!dev->irq) { 1007 if (!lis3->irq) {
961 pr_debug("No IRQ. Disabling /dev/freefall\n"); 1008 pr_debug("No IRQ. Disabling /dev/freefall\n");
962 goto out; 1009 goto out;
963 } 1010 }
@@ -973,23 +1020,27 @@ int lis3lv02d_init_device(struct lis3lv02d *dev)
973 * io-apic is not configurable (and generates a warning) but I keep it 1020 * io-apic is not configurable (and generates a warning) but I keep it
974 * in case of support for other hardware. 1021 * in case of support for other hardware.
975 */ 1022 */
976 if (dev->pdata && dev->whoami == WAI_8B) 1023 if (lis3->pdata && lis3->whoami == WAI_8B)
977 thread_fn = lis302dl_interrupt_thread1_8b; 1024 thread_fn = lis302dl_interrupt_thread1_8b;
978 else 1025 else
979 thread_fn = NULL; 1026 thread_fn = NULL;
980 1027
981 err = request_threaded_irq(dev->irq, lis302dl_interrupt, 1028 err = request_threaded_irq(lis3->irq, lis302dl_interrupt,
982 thread_fn, 1029 thread_fn,
983 IRQF_TRIGGER_RISING | IRQF_ONESHOT | 1030 IRQF_TRIGGER_RISING | IRQF_ONESHOT |
984 irq_flags, 1031 irq_flags,
985 DRIVER_NAME, &lis3_dev); 1032 DRIVER_NAME, lis3);
986 1033
987 if (err < 0) { 1034 if (err < 0) {
988 pr_err("Cannot get IRQ\n"); 1035 pr_err("Cannot get IRQ\n");
989 goto out; 1036 goto out;
990 } 1037 }
991 1038
992 if (misc_register(&lis3lv02d_misc_device)) 1039 lis3->miscdev.minor = MISC_DYNAMIC_MINOR;
1040 lis3->miscdev.name = "freefall";
1041 lis3->miscdev.fops = &lis3lv02d_misc_fops;
1042
1043 if (misc_register(&lis3->miscdev))
993 pr_err("misc_register failed\n"); 1044 pr_err("misc_register failed\n");
994out: 1045out:
995 return 0; 1046 return 0;
diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
index a1939589eb2c..2b1482ad3f16 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d.h
+++ b/drivers/misc/lis3lv02d/lis3lv02d.h
@@ -21,6 +21,7 @@
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/input-polldev.h> 22#include <linux/input-polldev.h>
23#include <linux/regulator/consumer.h> 23#include <linux/regulator/consumer.h>
24#include <linux/miscdevice.h>
24 25
25/* 26/*
26 * This driver tries to support the "digital" accelerometer chips from 27 * This driver tries to support the "digital" accelerometer chips from
@@ -273,6 +274,8 @@ struct lis3lv02d {
273 struct fasync_struct *async_queue; /* queue for the misc device */ 274 struct fasync_struct *async_queue; /* queue for the misc device */
274 wait_queue_head_t misc_wait; /* Wait queue for the misc device */ 275 wait_queue_head_t misc_wait; /* Wait queue for the misc device */
275 unsigned long misc_opened; /* bit0: whether the device is open */ 276 unsigned long misc_opened; /* bit0: whether the device is open */
277 struct miscdevice miscdev;
278
276 int data_ready_count[2]; 279 int data_ready_count[2];
277 atomic_t wake_thread; 280 atomic_t wake_thread;
278 unsigned char irq_cfg; 281 unsigned char irq_cfg;
@@ -282,10 +285,10 @@ struct lis3lv02d {
282}; 285};
283 286
284int lis3lv02d_init_device(struct lis3lv02d *lis3); 287int lis3lv02d_init_device(struct lis3lv02d *lis3);
285int lis3lv02d_joystick_enable(void); 288int lis3lv02d_joystick_enable(struct lis3lv02d *lis3);
286void lis3lv02d_joystick_disable(void); 289void lis3lv02d_joystick_disable(struct lis3lv02d *lis3);
287void lis3lv02d_poweroff(struct lis3lv02d *lis3); 290void lis3lv02d_poweroff(struct lis3lv02d *lis3);
288void lis3lv02d_poweron(struct lis3lv02d *lis3); 291int lis3lv02d_poweron(struct lis3lv02d *lis3);
289int lis3lv02d_remove_fs(struct lis3lv02d *lis3); 292int lis3lv02d_remove_fs(struct lis3lv02d *lis3);
290 293
291extern struct lis3lv02d lis3_dev; 294extern struct lis3lv02d lis3_dev;
diff --git a/drivers/misc/lis3lv02d/lis3lv02d_i2c.c b/drivers/misc/lis3lv02d/lis3lv02d_i2c.c
index b20dfb4522d2..c02fea029dcf 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d_i2c.c
+++ b/drivers/misc/lis3lv02d/lis3lv02d_i2c.c
@@ -79,8 +79,7 @@ static int lis3_i2c_init(struct lis3lv02d *lis3)
79 u8 reg; 79 u8 reg;
80 int ret; 80 int ret;
81 81
82 if (lis3->reg_ctrl) 82 lis3_reg_ctrl(lis3, LIS3_REG_ON);
83 lis3_reg_ctrl(lis3, LIS3_REG_ON);
84 83
85 lis3->read(lis3, WHO_AM_I, &reg); 84 lis3->read(lis3, WHO_AM_I, &reg);
86 if (reg != lis3->whoami) 85 if (reg != lis3->whoami)
@@ -106,10 +105,6 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client,
106 struct lis3lv02d_platform_data *pdata = client->dev.platform_data; 105 struct lis3lv02d_platform_data *pdata = client->dev.platform_data;
107 106
108 if (pdata) { 107 if (pdata) {
109 /* Regulator control is optional */
110 if (pdata->driver_features & LIS3_USE_REGULATOR_CTRL)
111 lis3_dev.reg_ctrl = lis3_reg_ctrl;
112
113 if ((pdata->driver_features & LIS3_USE_BLOCK_READ) && 108 if ((pdata->driver_features & LIS3_USE_BLOCK_READ) &&
114 (i2c_check_functionality(client->adapter, 109 (i2c_check_functionality(client->adapter,
115 I2C_FUNC_SMBUS_I2C_BLOCK))) 110 I2C_FUNC_SMBUS_I2C_BLOCK)))
@@ -131,15 +126,13 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client,
131 goto fail; 126 goto fail;
132 } 127 }
133 128
134 if (lis3_dev.reg_ctrl) { 129 lis3_dev.regulators[0].supply = reg_vdd;
135 lis3_dev.regulators[0].supply = reg_vdd; 130 lis3_dev.regulators[1].supply = reg_vdd_io;
136 lis3_dev.regulators[1].supply = reg_vdd_io; 131 ret = regulator_bulk_get(&client->dev,
137 ret = regulator_bulk_get(&client->dev, 132 ARRAY_SIZE(lis3_dev.regulators),
138 ARRAY_SIZE(lis3_dev.regulators), 133 lis3_dev.regulators);
139 lis3_dev.regulators); 134 if (ret < 0)
140 if (ret < 0) 135 goto fail;
141 goto fail;
142 }
143 136
144 lis3_dev.pdata = pdata; 137 lis3_dev.pdata = pdata;
145 lis3_dev.bus_priv = client; 138 lis3_dev.bus_priv = client;
@@ -153,16 +146,19 @@ static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client,
153 i2c_set_clientdata(client, &lis3_dev); 146 i2c_set_clientdata(client, &lis3_dev);
154 147
155 /* Provide power over the init call */ 148 /* Provide power over the init call */
156 if (lis3_dev.reg_ctrl) 149 lis3_reg_ctrl(&lis3_dev, LIS3_REG_ON);
157 lis3_reg_ctrl(&lis3_dev, LIS3_REG_ON);
158 150
159 ret = lis3lv02d_init_device(&lis3_dev); 151 ret = lis3lv02d_init_device(&lis3_dev);
160 152
161 if (lis3_dev.reg_ctrl) 153 lis3_reg_ctrl(&lis3_dev, LIS3_REG_OFF);
162 lis3_reg_ctrl(&lis3_dev, LIS3_REG_OFF);
163 154
164 if (ret == 0) 155 if (ret)
165 return 0; 156 goto fail2;
157 return 0;
158
159fail2:
160 regulator_bulk_free(ARRAY_SIZE(lis3_dev.regulators),
161 lis3_dev.regulators);
166fail: 162fail:
167 if (pdata && pdata->release_resources) 163 if (pdata && pdata->release_resources)
168 pdata->release_resources(); 164 pdata->release_resources();
@@ -177,12 +173,11 @@ static int __devexit lis3lv02d_i2c_remove(struct i2c_client *client)
177 if (pdata && pdata->release_resources) 173 if (pdata && pdata->release_resources)
178 pdata->release_resources(); 174 pdata->release_resources();
179 175
180 lis3lv02d_joystick_disable(); 176 lis3lv02d_joystick_disable(lis3);
181 lis3lv02d_remove_fs(&lis3_dev); 177 lis3lv02d_remove_fs(&lis3_dev);
182 178
183 if (lis3_dev.reg_ctrl) 179 regulator_bulk_free(ARRAY_SIZE(lis3->regulators),
184 regulator_bulk_free(ARRAY_SIZE(lis3->regulators), 180 lis3_dev.regulators);
185 lis3_dev.regulators);
186 return 0; 181 return 0;
187} 182}
188 183
diff --git a/drivers/misc/lis3lv02d/lis3lv02d_spi.c b/drivers/misc/lis3lv02d/lis3lv02d_spi.c
index c1f8a8fbf694..b2c1be12d16f 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d_spi.c
+++ b/drivers/misc/lis3lv02d/lis3lv02d_spi.c
@@ -83,7 +83,7 @@ static int __devinit lis302dl_spi_probe(struct spi_device *spi)
83static int __devexit lis302dl_spi_remove(struct spi_device *spi) 83static int __devexit lis302dl_spi_remove(struct spi_device *spi)
84{ 84{
85 struct lis3lv02d *lis3 = spi_get_drvdata(spi); 85 struct lis3lv02d *lis3 = spi_get_drvdata(spi);
86 lis3lv02d_joystick_disable(); 86 lis3lv02d_joystick_disable(lis3);
87 lis3lv02d_poweroff(lis3); 87 lis3lv02d_poweroff(lis3);
88 88
89 return lis3lv02d_remove_fs(&lis3_dev); 89 return lis3lv02d_remove_fs(&lis3_dev);
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index fca66165110e..8fda331c65df 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -581,8 +581,9 @@ extern const struct ethtool_ops mlx4_en_ethtool_ops;
581 * printk / logging functions 581 * printk / logging functions
582 */ 582 */
583 583
584__printf(3, 4)
584int en_print(const char *level, const struct mlx4_en_priv *priv, 585int en_print(const char *level, const struct mlx4_en_priv *priv,
585 const char *format, ...) __attribute__ ((format (printf, 3, 4))); 586 const char *format, ...);
586 587
587#define en_dbg(mlevel, priv, format, arg...) \ 588#define en_dbg(mlevel, priv, format, arg...) \
588do { \ 589do { \
diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
index 39322d4121b7..4045e5ab0555 100644
--- a/drivers/net/wireless/at76c50x-usb.c
+++ b/drivers/net/wireless/at76c50x-usb.c
@@ -517,7 +517,7 @@ static char *hex2str(void *buf, size_t len)
517 goto exit; 517 goto exit;
518 518
519 while (len--) { 519 while (len--) {
520 obuf = pack_hex_byte(obuf, *ibuf++); 520 obuf = hex_byte_pack(obuf, *ibuf++);
521 *obuf++ = '-'; 521 *obuf++ = '-';
522 } 522 }
523 obuf--; 523 obuf--;
diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
index 908fdbc3e0ee..0f9ee46cfc97 100644
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -173,8 +173,7 @@ bool ath_hw_keyreset(struct ath_common *common, u16 entry);
173void ath_hw_cycle_counters_update(struct ath_common *common); 173void ath_hw_cycle_counters_update(struct ath_common *common);
174int32_t ath_hw_get_listen_time(struct ath_common *common); 174int32_t ath_hw_get_listen_time(struct ath_common *common);
175 175
176extern __attribute__((format (printf, 2, 3))) 176extern __printf(2, 3) void ath_printk(const char *level, const char *fmt, ...);
177void ath_printk(const char *level, const char *fmt, ...);
178 177
179#define _ath_printk(level, common, fmt, ...) \ 178#define _ath_printk(level, common, fmt, ...) \
180do { \ 179do { \
@@ -258,7 +257,7 @@ do { \
258 257
259#else 258#else
260 259
261static inline __attribute__((format (printf, 3, 4))) 260static inline __attribute__ ((format (printf, 3, 4)))
262void ath_dbg(struct ath_common *common, enum ATH_DEBUG dbg_mask, 261void ath_dbg(struct ath_common *common, enum ATH_DEBUG dbg_mask,
263 const char *fmt, ...) 262 const char *fmt, ...)
264{ 263{
diff --git a/drivers/net/wireless/ath/ath5k/debug.h b/drivers/net/wireless/ath/ath5k/debug.h
index 7f37df3125fd..0a3f916a1ef3 100644
--- a/drivers/net/wireless/ath/ath5k/debug.h
+++ b/drivers/net/wireless/ath/ath5k/debug.h
@@ -141,10 +141,10 @@ ath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf);
141 141
142#include <linux/compiler.h> 142#include <linux/compiler.h>
143 143
144static inline void __attribute__ ((format (printf, 3, 4))) 144static inline __printf(3, 4) void
145ATH5K_DBG(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...) {} 145ATH5K_DBG(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...) {}
146 146
147static inline void __attribute__ ((format (printf, 3, 4))) 147static inline __printf(3, 4) void
148ATH5K_DBG_UNLIMIT(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...) 148ATH5K_DBG_UNLIMIT(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...)
149{} 149{}
150 150
diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h
index 9288a3ce1e39..7b7675f70a10 100644
--- a/drivers/net/wireless/ath/ath6kl/debug.h
+++ b/drivers/net/wireless/ath/ath6kl/debug.h
@@ -44,8 +44,8 @@ enum ATH6K_DEBUG_MASK {
44}; 44};
45 45
46extern unsigned int debug_mask; 46extern unsigned int debug_mask;
47extern int ath6kl_printk(const char *level, const char *fmt, ...) 47extern __printf(2, 3)
48 __attribute__ ((format (printf, 2, 3))); 48int ath6kl_printk(const char *level, const char *fmt, ...);
49 49
50#define ath6kl_info(fmt, ...) \ 50#define ath6kl_info(fmt, ...) \
51 ath6kl_printk(KERN_INFO, fmt, ##__VA_ARGS__) 51 ath6kl_printk(KERN_INFO, fmt, ##__VA_ARGS__)
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
index 447a2307c9d9..37110dfd2c96 100644
--- a/drivers/net/wireless/b43/b43.h
+++ b/drivers/net/wireless/b43/b43.h
@@ -1011,14 +1011,10 @@ static inline bool b43_using_pio_transfers(struct b43_wldev *dev)
1011} 1011}
1012 1012
1013/* Message printing */ 1013/* Message printing */
1014void b43info(struct b43_wl *wl, const char *fmt, ...) 1014__printf(2, 3) void b43info(struct b43_wl *wl, const char *fmt, ...);
1015 __attribute__ ((format(printf, 2, 3))); 1015__printf(2, 3) void b43err(struct b43_wl *wl, const char *fmt, ...);
1016void b43err(struct b43_wl *wl, const char *fmt, ...) 1016__printf(2, 3) void b43warn(struct b43_wl *wl, const char *fmt, ...);
1017 __attribute__ ((format(printf, 2, 3))); 1017__printf(2, 3) void b43dbg(struct b43_wl *wl, const char *fmt, ...);
1018void b43warn(struct b43_wl *wl, const char *fmt, ...)
1019 __attribute__ ((format(printf, 2, 3)));
1020void b43dbg(struct b43_wl *wl, const char *fmt, ...)
1021 __attribute__ ((format(printf, 2, 3)));
1022 1018
1023 1019
1024/* A WARN_ON variant that vanishes when b43 debugging is disabled. 1020/* A WARN_ON variant that vanishes when b43 debugging is disabled.
diff --git a/drivers/net/wireless/b43legacy/b43legacy.h b/drivers/net/wireless/b43legacy/b43legacy.h
index 12b518251581..1d4fc9db7f5e 100644
--- a/drivers/net/wireless/b43legacy/b43legacy.h
+++ b/drivers/net/wireless/b43legacy/b43legacy.h
@@ -810,15 +810,15 @@ struct b43legacy_lopair *b43legacy_get_lopair(struct b43legacy_phy *phy,
810 810
811 811
812/* Message printing */ 812/* Message printing */
813void b43legacyinfo(struct b43legacy_wl *wl, const char *fmt, ...) 813__printf(2, 3)
814 __attribute__((format(printf, 2, 3))); 814void b43legacyinfo(struct b43legacy_wl *wl, const char *fmt, ...);
815void b43legacyerr(struct b43legacy_wl *wl, const char *fmt, ...) 815__printf(2, 3)
816 __attribute__((format(printf, 2, 3))); 816void b43legacyerr(struct b43legacy_wl *wl, const char *fmt, ...);
817void b43legacywarn(struct b43legacy_wl *wl, const char *fmt, ...) 817__printf(2, 3)
818 __attribute__((format(printf, 2, 3))); 818void b43legacywarn(struct b43legacy_wl *wl, const char *fmt, ...);
819#if B43legacy_DEBUG 819#if B43legacy_DEBUG
820void b43legacydbg(struct b43legacy_wl *wl, const char *fmt, ...) 820__printf(2, 3)
821 __attribute__((format(printf, 2, 3))); 821void b43legacydbg(struct b43legacy_wl *wl, const char *fmt, ...);
822#else /* DEBUG */ 822#else /* DEBUG */
823# define b43legacydbg(wl, fmt...) do { /* nothing */ } while (0) 823# define b43legacydbg(wl, fmt...) do { /* nothing */ } while (0)
824#endif /* DEBUG */ 824#endif /* DEBUG */
diff --git a/drivers/platform/x86/hp_accel.c b/drivers/platform/x86/hp_accel.c
index 64b454855f65..22b2dfa73148 100644
--- a/drivers/platform/x86/hp_accel.c
+++ b/drivers/platform/x86/hp_accel.c
@@ -210,6 +210,8 @@ static struct dmi_system_id lis3lv02d_dmi_ids[] = {
210 AXIS_DMI_MATCH("NC6715x", "HP Compaq 6715", y_inverted), 210 AXIS_DMI_MATCH("NC6715x", "HP Compaq 6715", y_inverted),
211 AXIS_DMI_MATCH("NC693xx", "HP EliteBook 693", xy_rotated_right), 211 AXIS_DMI_MATCH("NC693xx", "HP EliteBook 693", xy_rotated_right),
212 AXIS_DMI_MATCH("NC693xx", "HP EliteBook 853", xy_swap), 212 AXIS_DMI_MATCH("NC693xx", "HP EliteBook 853", xy_swap),
213 AXIS_DMI_MATCH("NC854xx", "HP EliteBook 854", y_inverted),
214 AXIS_DMI_MATCH("NC273xx", "HP EliteBook 273", y_inverted),
213 /* Intel-based HP Pavilion dv5 */ 215 /* Intel-based HP Pavilion dv5 */
214 AXIS_DMI_MATCH2("HPDV5_I", 216 AXIS_DMI_MATCH2("HPDV5_I",
215 PRODUCT_NAME, "HP Pavilion dv5", 217 PRODUCT_NAME, "HP Pavilion dv5",
@@ -228,6 +230,7 @@ static struct dmi_system_id lis3lv02d_dmi_ids[] = {
228 AXIS_DMI_MATCH("HPB452x", "HP ProBook 452", y_inverted), 230 AXIS_DMI_MATCH("HPB452x", "HP ProBook 452", y_inverted),
229 AXIS_DMI_MATCH("HPB522x", "HP ProBook 522", xy_swap), 231 AXIS_DMI_MATCH("HPB522x", "HP ProBook 522", xy_swap),
230 AXIS_DMI_MATCH("HPB532x", "HP ProBook 532", y_inverted), 232 AXIS_DMI_MATCH("HPB532x", "HP ProBook 532", y_inverted),
233 AXIS_DMI_MATCH("HPB655x", "HP ProBook 655", xy_swap_inverted),
231 AXIS_DMI_MATCH("Mini510x", "HP Mini 510", xy_rotated_left_usd), 234 AXIS_DMI_MATCH("Mini510x", "HP Mini 510", xy_rotated_left_usd),
232 AXIS_DMI_MATCH("HPB63xx", "HP ProBook 63", xy_swap), 235 AXIS_DMI_MATCH("HPB63xx", "HP ProBook 63", xy_swap),
233 AXIS_DMI_MATCH("HPB64xx", "HP ProBook 64", xy_swap), 236 AXIS_DMI_MATCH("HPB64xx", "HP ProBook 64", xy_swap),
@@ -325,7 +328,7 @@ static int lis3lv02d_add(struct acpi_device *device)
325 INIT_WORK(&hpled_led.work, delayed_set_status_worker); 328 INIT_WORK(&hpled_led.work, delayed_set_status_worker);
326 ret = led_classdev_register(NULL, &hpled_led.led_classdev); 329 ret = led_classdev_register(NULL, &hpled_led.led_classdev);
327 if (ret) { 330 if (ret) {
328 lis3lv02d_joystick_disable(); 331 lis3lv02d_joystick_disable(&lis3_dev);
329 lis3lv02d_poweroff(&lis3_dev); 332 lis3lv02d_poweroff(&lis3_dev);
330 flush_work(&hpled_led.work); 333 flush_work(&hpled_led.work);
331 return ret; 334 return ret;
@@ -339,7 +342,7 @@ static int lis3lv02d_remove(struct acpi_device *device, int type)
339 if (!device) 342 if (!device)
340 return -EINVAL; 343 return -EINVAL;
341 344
342 lis3lv02d_joystick_disable(); 345 lis3lv02d_joystick_disable(&lis3_dev);
343 lis3lv02d_poweroff(&lis3_dev); 346 lis3lv02d_poweroff(&lis3_dev);
344 347
345 led_classdev_unregister(&hpled_led.led_classdev); 348 led_classdev_unregister(&hpled_led.led_classdev);
@@ -359,8 +362,7 @@ static int lis3lv02d_suspend(struct acpi_device *device, pm_message_t state)
359 362
360static int lis3lv02d_resume(struct acpi_device *device) 363static int lis3lv02d_resume(struct acpi_device *device)
361{ 364{
362 lis3lv02d_poweron(&lis3_dev); 365 return lis3lv02d_poweron(&lis3_dev);
363 return 0;
364} 366}
365#else 367#else
366#define lis3lv02d_suspend NULL 368#define lis3lv02d_suspend NULL
diff --git a/drivers/staging/iio/trigger.h b/drivers/staging/iio/trigger.h
index 598fcb3599f9..5cc42a655c88 100644
--- a/drivers/staging/iio/trigger.h
+++ b/drivers/staging/iio/trigger.h
@@ -115,8 +115,7 @@ void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time);
115 115
116irqreturn_t iio_trigger_generic_data_rdy_poll(int irq, void *private); 116irqreturn_t iio_trigger_generic_data_rdy_poll(int irq, void *private);
117 117
118struct iio_trigger *iio_allocate_trigger(const char *fmt, ...) 118__printf(1, 2) struct iio_trigger *iio_allocate_trigger(const char *fmt, ...);
119 __attribute__((format(printf, 1, 2)));
120void iio_free_trigger(struct iio_trigger *trig); 119void iio_free_trigger(struct iio_trigger *trig);
121 120
122#endif /* _IIO_TRIGGER_H_ */ 121#endif /* _IIO_TRIGGER_H_ */
diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c
index 98e0304deeaf..6c68a6899e87 100644
--- a/drivers/video/backlight/adp8870_bl.c
+++ b/drivers/video/backlight/adp8870_bl.c
@@ -931,7 +931,6 @@ out:
931out1: 931out1:
932 backlight_device_unregister(bl); 932 backlight_device_unregister(bl);
933out2: 933out2:
934 i2c_set_clientdata(client, NULL);
935 kfree(data); 934 kfree(data);
936 935
937 return ret; 936 return ret;
@@ -951,7 +950,6 @@ static int __devexit adp8870_remove(struct i2c_client *client)
951 &adp8870_bl_attr_group); 950 &adp8870_bl_attr_group);
952 951
953 backlight_device_unregister(data->bl); 952 backlight_device_unregister(data->bl);
954 i2c_set_clientdata(client, NULL);
955 kfree(data); 953 kfree(data);
956 954
957 return 0; 955 return 0;
diff --git a/drivers/video/backlight/generic_bl.c b/drivers/video/backlight/generic_bl.c
index 8c6befd65a33..adb191466d64 100644
--- a/drivers/video/backlight/generic_bl.c
+++ b/drivers/video/backlight/generic_bl.c
@@ -56,7 +56,7 @@ static int genericbl_get_intensity(struct backlight_device *bd)
56 * Called when the battery is low to limit the backlight intensity. 56 * Called when the battery is low to limit the backlight intensity.
57 * If limit==0 clear any limit, otherwise limit the intensity 57 * If limit==0 clear any limit, otherwise limit the intensity
58 */ 58 */
59void corgibl_limit_intensity(int limit) 59void genericbl_limit_intensity(int limit)
60{ 60{
61 struct backlight_device *bd = generic_backlight_device; 61 struct backlight_device *bd = generic_backlight_device;
62 62
@@ -68,7 +68,7 @@ void corgibl_limit_intensity(int limit)
68 backlight_update_status(generic_backlight_device); 68 backlight_update_status(generic_backlight_device);
69 mutex_unlock(&bd->ops_lock); 69 mutex_unlock(&bd->ops_lock);
70} 70}
71EXPORT_SYMBOL(corgibl_limit_intensity); 71EXPORT_SYMBOL(genericbl_limit_intensity);
72 72
73static const struct backlight_ops genericbl_ops = { 73static const struct backlight_ops genericbl_ops = {
74 .options = BL_CORE_SUSPENDRESUME, 74 .options = BL_CORE_SUSPENDRESUME,
diff --git a/drivers/video/backlight/l4f00242t03.c b/drivers/video/backlight/l4f00242t03.c
index 98ad3e5f7c85..3543f1b7d5f1 100644
--- a/drivers/video/backlight/l4f00242t03.c
+++ b/drivers/video/backlight/l4f00242t03.c
@@ -52,15 +52,11 @@ static void l4f00242t03_lcd_init(struct spi_device *spi)
52 52
53 dev_dbg(&spi->dev, "initializing LCD\n"); 53 dev_dbg(&spi->dev, "initializing LCD\n");
54 54
55 if (priv->io_reg) { 55 regulator_set_voltage(priv->io_reg, 1800000, 1800000);
56 regulator_set_voltage(priv->io_reg, 1800000, 1800000); 56 regulator_enable(priv->io_reg);
57 regulator_enable(priv->io_reg);
58 }
59 57
60 if (priv->core_reg) { 58 regulator_set_voltage(priv->core_reg, 2800000, 2800000);
61 regulator_set_voltage(priv->core_reg, 2800000, 2800000); 59 regulator_enable(priv->core_reg);
62 regulator_enable(priv->core_reg);
63 }
64 60
65 l4f00242t03_reset(pdata->reset_gpio); 61 l4f00242t03_reset(pdata->reset_gpio);
66 62
@@ -78,11 +74,8 @@ static void l4f00242t03_lcd_powerdown(struct spi_device *spi)
78 74
79 gpio_set_value(pdata->data_enable_gpio, 0); 75 gpio_set_value(pdata->data_enable_gpio, 0);
80 76
81 if (priv->io_reg) 77 regulator_disable(priv->io_reg);
82 regulator_disable(priv->io_reg); 78 regulator_disable(priv->core_reg);
83
84 if (priv->core_reg)
85 regulator_disable(priv->core_reg);
86} 79}
87 80
88static int l4f00242t03_lcd_power_get(struct lcd_device *ld) 81static int l4f00242t03_lcd_power_get(struct lcd_device *ld)
@@ -178,47 +171,34 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
178 171
179 priv->spi = spi; 172 priv->spi = spi;
180 173
181 ret = gpio_request(pdata->reset_gpio, "lcd l4f00242t03 reset"); 174 ret = gpio_request_one(pdata->reset_gpio, GPIOF_OUT_INIT_HIGH,
175 "lcd l4f00242t03 reset");
182 if (ret) { 176 if (ret) {
183 dev_err(&spi->dev, 177 dev_err(&spi->dev,
184 "Unable to get the lcd l4f00242t03 reset gpio.\n"); 178 "Unable to get the lcd l4f00242t03 reset gpio.\n");
185 goto err; 179 goto err;
186 } 180 }
187 181
188 ret = gpio_direction_output(pdata->reset_gpio, 1); 182 ret = gpio_request_one(pdata->data_enable_gpio, GPIOF_OUT_INIT_LOW,
189 if (ret) 183 "lcd l4f00242t03 data enable");
190 goto err2;
191
192 ret = gpio_request(pdata->data_enable_gpio,
193 "lcd l4f00242t03 data enable");
194 if (ret) { 184 if (ret) {
195 dev_err(&spi->dev, 185 dev_err(&spi->dev,
196 "Unable to get the lcd l4f00242t03 data en gpio.\n"); 186 "Unable to get the lcd l4f00242t03 data en gpio.\n");
197 goto err2; 187 goto err2;
198 } 188 }
199 189
200 ret = gpio_direction_output(pdata->data_enable_gpio, 0); 190 priv->io_reg = regulator_get(&spi->dev, "vdd");
201 if (ret) 191 if (IS_ERR(priv->io_reg)) {
192 dev_err(&spi->dev, "%s: Unable to get the IO regulator\n",
193 __func__);
202 goto err3; 194 goto err3;
203
204 if (pdata->io_supply) {
205 priv->io_reg = regulator_get(NULL, pdata->io_supply);
206
207 if (IS_ERR(priv->io_reg)) {
208 pr_err("%s: Unable to get the IO regulator\n",
209 __func__);
210 goto err3;
211 }
212 } 195 }
213 196
214 if (pdata->core_supply) { 197 priv->core_reg = regulator_get(&spi->dev, "vcore");
215 priv->core_reg = regulator_get(NULL, pdata->core_supply); 198 if (IS_ERR(priv->core_reg)) {
216 199 dev_err(&spi->dev, "%s: Unable to get the core regulator\n",
217 if (IS_ERR(priv->core_reg)) { 200 __func__);
218 pr_err("%s: Unable to get the core regulator\n", 201 goto err4;
219 __func__);
220 goto err4;
221 }
222 } 202 }
223 203
224 priv->ld = lcd_device_register("l4f00242t03", 204 priv->ld = lcd_device_register("l4f00242t03",
@@ -238,11 +218,9 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
238 return 0; 218 return 0;
239 219
240err5: 220err5:
241 if (priv->core_reg) 221 regulator_put(priv->core_reg);
242 regulator_put(priv->core_reg);
243err4: 222err4:
244 if (priv->io_reg) 223 regulator_put(priv->io_reg);
245 regulator_put(priv->io_reg);
246err3: 224err3:
247 gpio_free(pdata->data_enable_gpio); 225 gpio_free(pdata->data_enable_gpio);
248err2: 226err2:
@@ -266,10 +244,8 @@ static int __devexit l4f00242t03_remove(struct spi_device *spi)
266 gpio_free(pdata->data_enable_gpio); 244 gpio_free(pdata->data_enable_gpio);
267 gpio_free(pdata->reset_gpio); 245 gpio_free(pdata->reset_gpio);
268 246
269 if (priv->io_reg) 247 regulator_put(priv->io_reg);
270 regulator_put(priv->io_reg); 248 regulator_put(priv->core_reg);
271 if (priv->core_reg)
272 regulator_put(priv->core_reg);
273 249
274 kfree(priv); 250 kfree(priv);
275 251
diff --git a/fs/Kconfig b/fs/Kconfig
index 9fe0b349f4cd..5f4c45d4aa10 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -109,7 +109,7 @@ source "fs/proc/Kconfig"
109source "fs/sysfs/Kconfig" 109source "fs/sysfs/Kconfig"
110 110
111config TMPFS 111config TMPFS
112 bool "Virtual memory file system support (former shm fs)" 112 bool "Tmpfs virtual memory file system support (former shm fs)"
113 depends on SHMEM 113 depends on SHMEM
114 help 114 help
115 Tmpfs is a file system which keeps all files in virtual memory. 115 Tmpfs is a file system which keeps all files in virtual memory.
diff --git a/fs/aio.c b/fs/aio.c
index e29ec485af25..632b235f4fbe 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1387,13 +1387,13 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
1387 ret = compat_rw_copy_check_uvector(type, 1387 ret = compat_rw_copy_check_uvector(type,
1388 (struct compat_iovec __user *)kiocb->ki_buf, 1388 (struct compat_iovec __user *)kiocb->ki_buf,
1389 kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec, 1389 kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
1390 &kiocb->ki_iovec); 1390 &kiocb->ki_iovec, 1);
1391 else 1391 else
1392#endif 1392#endif
1393 ret = rw_copy_check_uvector(type, 1393 ret = rw_copy_check_uvector(type,
1394 (struct iovec __user *)kiocb->ki_buf, 1394 (struct iovec __user *)kiocb->ki_buf,
1395 kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec, 1395 kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
1396 &kiocb->ki_iovec); 1396 &kiocb->ki_iovec, 1);
1397 if (ret < 0) 1397 if (ret < 0)
1398 goto out; 1398 goto out;
1399 1399
diff --git a/fs/buffer.c b/fs/buffer.c
index 936d6035f6e2..70a19745cb61 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -213,13 +213,16 @@ __find_get_block_slow(struct block_device *bdev, sector_t block)
213 * elsewhere, don't buffer_error if we had some unmapped buffers 213 * elsewhere, don't buffer_error if we had some unmapped buffers
214 */ 214 */
215 if (all_mapped) { 215 if (all_mapped) {
216 char b[BDEVNAME_SIZE];
217
216 printk("__find_get_block_slow() failed. " 218 printk("__find_get_block_slow() failed. "
217 "block=%llu, b_blocknr=%llu\n", 219 "block=%llu, b_blocknr=%llu\n",
218 (unsigned long long)block, 220 (unsigned long long)block,
219 (unsigned long long)bh->b_blocknr); 221 (unsigned long long)bh->b_blocknr);
220 printk("b_state=0x%08lx, b_size=%zu\n", 222 printk("b_state=0x%08lx, b_size=%zu\n",
221 bh->b_state, bh->b_size); 223 bh->b_state, bh->b_size);
222 printk("device blocksize: %d\n", 1 << bd_inode->i_blkbits); 224 printk("device %s blocksize: %d\n", bdevname(bdev, b),
225 1 << bd_inode->i_blkbits);
223 } 226 }
224out_unlock: 227out_unlock:
225 spin_unlock(&bd_mapping->private_lock); 228 spin_unlock(&bd_mapping->private_lock);
diff --git a/fs/compat.c b/fs/compat.c
index 302e761bd0aa..c98787536bb8 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -546,7 +546,7 @@ out:
546ssize_t compat_rw_copy_check_uvector(int type, 546ssize_t compat_rw_copy_check_uvector(int type,
547 const struct compat_iovec __user *uvector, unsigned long nr_segs, 547 const struct compat_iovec __user *uvector, unsigned long nr_segs,
548 unsigned long fast_segs, struct iovec *fast_pointer, 548 unsigned long fast_segs, struct iovec *fast_pointer,
549 struct iovec **ret_pointer) 549 struct iovec **ret_pointer, int check_access)
550{ 550{
551 compat_ssize_t tot_len; 551 compat_ssize_t tot_len;
552 struct iovec *iov = *ret_pointer = fast_pointer; 552 struct iovec *iov = *ret_pointer = fast_pointer;
@@ -593,7 +593,8 @@ ssize_t compat_rw_copy_check_uvector(int type,
593 } 593 }
594 if (len < 0) /* size_t not fitting in compat_ssize_t .. */ 594 if (len < 0) /* size_t not fitting in compat_ssize_t .. */
595 goto out; 595 goto out;
596 if (!access_ok(vrfy_dir(type), compat_ptr(buf), len)) { 596 if (check_access &&
597 !access_ok(vrfy_dir(type), compat_ptr(buf), len)) {
597 ret = -EFAULT; 598 ret = -EFAULT;
598 goto out; 599 goto out;
599 } 600 }
@@ -1107,7 +1108,7 @@ static ssize_t compat_do_readv_writev(int type, struct file *file,
1107 goto out; 1108 goto out;
1108 1109
1109 tot_len = compat_rw_copy_check_uvector(type, uvector, nr_segs, 1110 tot_len = compat_rw_copy_check_uvector(type, uvector, nr_segs,
1110 UIO_FASTIOV, iovstack, &iov); 1111 UIO_FASTIOV, iovstack, &iov, 1);
1111 if (tot_len == 0) { 1112 if (tot_len == 0) {
1112 ret = 0; 1113 ret = 0;
1113 goto out; 1114 goto out;
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index b36c5572b3f3..54481a3b2c79 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -514,7 +514,7 @@ ecryptfs_set_dentry_lower_mnt(struct dentry *dentry, struct vfsmount *lower_mnt)
514 514
515#define ecryptfs_printk(type, fmt, arg...) \ 515#define ecryptfs_printk(type, fmt, arg...) \
516 __ecryptfs_printk(type "%s: " fmt, __func__, ## arg); 516 __ecryptfs_printk(type "%s: " fmt, __func__, ## arg);
517__attribute__ ((format(printf, 1, 2))) 517__printf(1, 2)
518void __ecryptfs_printk(const char *fmt, ...); 518void __ecryptfs_printk(const char *fmt, ...);
519 519
520extern const struct file_operations ecryptfs_main_fops; 520extern const struct file_operations ecryptfs_main_fops;
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 9026fc91fe3b..828e750af23a 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -70,6 +70,15 @@
70 * simultaneous inserts (A into B and B into A) from racing and 70 * simultaneous inserts (A into B and B into A) from racing and
71 * constructing a cycle without either insert observing that it is 71 * constructing a cycle without either insert observing that it is
72 * going to. 72 * going to.
73 * It is necessary to acquire multiple "ep->mtx"es at once in the
74 * case when one epoll fd is added to another. In this case, we
75 * always acquire the locks in the order of nesting (i.e. after
76 * epoll_ctl(e1, EPOLL_CTL_ADD, e2), e1->mtx will always be acquired
77 * before e2->mtx). Since we disallow cycles of epoll file
78 * descriptors, this ensures that the mutexes are well-ordered. In
79 * order to communicate this nesting to lockdep, when walking a tree
80 * of epoll file descriptors, we use the current recursion depth as
81 * the lockdep subkey.
73 * It is possible to drop the "ep->mtx" and to use the global 82 * It is possible to drop the "ep->mtx" and to use the global
74 * mutex "epmutex" (together with "ep->lock") to have it working, 83 * mutex "epmutex" (together with "ep->lock") to have it working,
75 * but having "ep->mtx" will make the interface more scalable. 84 * but having "ep->mtx" will make the interface more scalable.
@@ -464,13 +473,15 @@ static void ep_unregister_pollwait(struct eventpoll *ep, struct epitem *epi)
464 * @ep: Pointer to the epoll private data structure. 473 * @ep: Pointer to the epoll private data structure.
465 * @sproc: Pointer to the scan callback. 474 * @sproc: Pointer to the scan callback.
466 * @priv: Private opaque data passed to the @sproc callback. 475 * @priv: Private opaque data passed to the @sproc callback.
476 * @depth: The current depth of recursive f_op->poll calls.
467 * 477 *
468 * Returns: The same integer error code returned by the @sproc callback. 478 * Returns: The same integer error code returned by the @sproc callback.
469 */ 479 */
470static int ep_scan_ready_list(struct eventpoll *ep, 480static int ep_scan_ready_list(struct eventpoll *ep,
471 int (*sproc)(struct eventpoll *, 481 int (*sproc)(struct eventpoll *,
472 struct list_head *, void *), 482 struct list_head *, void *),
473 void *priv) 483 void *priv,
484 int depth)
474{ 485{
475 int error, pwake = 0; 486 int error, pwake = 0;
476 unsigned long flags; 487 unsigned long flags;
@@ -481,7 +492,7 @@ static int ep_scan_ready_list(struct eventpoll *ep,
481 * We need to lock this because we could be hit by 492 * We need to lock this because we could be hit by
482 * eventpoll_release_file() and epoll_ctl(). 493 * eventpoll_release_file() and epoll_ctl().
483 */ 494 */
484 mutex_lock(&ep->mtx); 495 mutex_lock_nested(&ep->mtx, depth);
485 496
486 /* 497 /*
487 * Steal the ready list, and re-init the original one to the 498 * Steal the ready list, and re-init the original one to the
@@ -670,7 +681,7 @@ static int ep_read_events_proc(struct eventpoll *ep, struct list_head *head,
670 681
671static int ep_poll_readyevents_proc(void *priv, void *cookie, int call_nests) 682static int ep_poll_readyevents_proc(void *priv, void *cookie, int call_nests)
672{ 683{
673 return ep_scan_ready_list(priv, ep_read_events_proc, NULL); 684 return ep_scan_ready_list(priv, ep_read_events_proc, NULL, call_nests + 1);
674} 685}
675 686
676static unsigned int ep_eventpoll_poll(struct file *file, poll_table *wait) 687static unsigned int ep_eventpoll_poll(struct file *file, poll_table *wait)
@@ -737,7 +748,7 @@ void eventpoll_release_file(struct file *file)
737 748
738 ep = epi->ep; 749 ep = epi->ep;
739 list_del_init(&epi->fllink); 750 list_del_init(&epi->fllink);
740 mutex_lock(&ep->mtx); 751 mutex_lock_nested(&ep->mtx, 0);
741 ep_remove(ep, epi); 752 ep_remove(ep, epi);
742 mutex_unlock(&ep->mtx); 753 mutex_unlock(&ep->mtx);
743 } 754 }
@@ -1134,7 +1145,7 @@ static int ep_send_events(struct eventpoll *ep,
1134 esed.maxevents = maxevents; 1145 esed.maxevents = maxevents;
1135 esed.events = events; 1146 esed.events = events;
1136 1147
1137 return ep_scan_ready_list(ep, ep_send_events_proc, &esed); 1148 return ep_scan_ready_list(ep, ep_send_events_proc, &esed, 0);
1138} 1149}
1139 1150
1140static inline struct timespec ep_set_mstimeout(long ms) 1151static inline struct timespec ep_set_mstimeout(long ms)
@@ -1267,7 +1278,7 @@ static int ep_loop_check_proc(void *priv, void *cookie, int call_nests)
1267 struct rb_node *rbp; 1278 struct rb_node *rbp;
1268 struct epitem *epi; 1279 struct epitem *epi;
1269 1280
1270 mutex_lock(&ep->mtx); 1281 mutex_lock_nested(&ep->mtx, call_nests + 1);
1271 for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) { 1282 for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) {
1272 epi = rb_entry(rbp, struct epitem, rbn); 1283 epi = rb_entry(rbp, struct epitem, rbn);
1273 if (unlikely(is_file_epoll(epi->ffd.file))) { 1284 if (unlikely(is_file_epoll(epi->ffd.file))) {
@@ -1409,7 +1420,7 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd,
1409 } 1420 }
1410 1421
1411 1422
1412 mutex_lock(&ep->mtx); 1423 mutex_lock_nested(&ep->mtx, 0);
1413 1424
1414 /* 1425 /*
1415 * Try to lookup the file inside our RB tree, Since we grabbed "mtx" 1426 * Try to lookup the file inside our RB tree, Since we grabbed "mtx"
diff --git a/fs/exec.c b/fs/exec.c
index 25dcbe5fc356..36254645b7cc 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -841,10 +841,6 @@ static int exec_mmap(struct mm_struct *mm)
841 tsk->mm = mm; 841 tsk->mm = mm;
842 tsk->active_mm = mm; 842 tsk->active_mm = mm;
843 activate_mm(active_mm, mm); 843 activate_mm(active_mm, mm);
844 if (old_mm && tsk->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) {
845 atomic_dec(&old_mm->oom_disable_count);
846 atomic_inc(&tsk->mm->oom_disable_count);
847 }
848 task_unlock(tsk); 844 task_unlock(tsk);
849 arch_pick_mmap_layout(mm); 845 arch_pick_mmap_layout(mm);
850 if (old_mm) { 846 if (old_mm) {
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index af9fc89b1b2d..9a4e5e206d08 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -135,10 +135,10 @@ extern long ext2_compat_ioctl(struct file *, unsigned int, unsigned long);
135struct dentry *ext2_get_parent(struct dentry *child); 135struct dentry *ext2_get_parent(struct dentry *child);
136 136
137/* super.c */ 137/* super.c */
138extern void ext2_error (struct super_block *, const char *, const char *, ...) 138extern __printf(3, 4)
139 __attribute__ ((format (printf, 3, 4))); 139void ext2_error(struct super_block *, const char *, const char *, ...);
140extern void ext2_msg(struct super_block *, const char *, const char *, ...) 140extern __printf(3, 4)
141 __attribute__ ((format (printf, 3, 4))); 141void ext2_msg(struct super_block *, const char *, const char *, ...);
142extern void ext2_update_dynamic_rev (struct super_block *sb); 142extern void ext2_update_dynamic_rev (struct super_block *sb);
143extern void ext2_write_super (struct super_block *); 143extern void ext2_write_super (struct super_block *);
144 144
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index b7d7bd0f066e..cec3145e532c 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1878,40 +1878,40 @@ extern int ext4_group_extend(struct super_block *sb,
1878extern void *ext4_kvmalloc(size_t size, gfp_t flags); 1878extern void *ext4_kvmalloc(size_t size, gfp_t flags);
1879extern void *ext4_kvzalloc(size_t size, gfp_t flags); 1879extern void *ext4_kvzalloc(size_t size, gfp_t flags);
1880extern void ext4_kvfree(void *ptr); 1880extern void ext4_kvfree(void *ptr);
1881extern void __ext4_error(struct super_block *, const char *, unsigned int, 1881extern __printf(4, 5)
1882 const char *, ...) 1882void __ext4_error(struct super_block *, const char *, unsigned int,
1883 __attribute__ ((format (printf, 4, 5))); 1883 const char *, ...);
1884#define ext4_error(sb, message...) __ext4_error(sb, __func__, \ 1884#define ext4_error(sb, message...) __ext4_error(sb, __func__, \
1885 __LINE__, ## message) 1885 __LINE__, ## message)
1886extern void ext4_error_inode(struct inode *, const char *, unsigned int, 1886extern __printf(5, 6)
1887 ext4_fsblk_t, const char *, ...) 1887void ext4_error_inode(struct inode *, const char *, unsigned int, ext4_fsblk_t,
1888 __attribute__ ((format (printf, 5, 6))); 1888 const char *, ...);
1889extern void ext4_error_file(struct file *, const char *, unsigned int, 1889extern __printf(5, 6)
1890 ext4_fsblk_t, const char *, ...) 1890void ext4_error_file(struct file *, const char *, unsigned int, ext4_fsblk_t,
1891 __attribute__ ((format (printf, 5, 6))); 1891 const char *, ...);
1892extern void __ext4_std_error(struct super_block *, const char *, 1892extern void __ext4_std_error(struct super_block *, const char *,
1893 unsigned int, int); 1893 unsigned int, int);
1894extern void __ext4_abort(struct super_block *, const char *, unsigned int, 1894extern __printf(4, 5)
1895 const char *, ...) 1895void __ext4_abort(struct super_block *, const char *, unsigned int,
1896 __attribute__ ((format (printf, 4, 5))); 1896 const char *, ...);
1897#define ext4_abort(sb, message...) __ext4_abort(sb, __func__, \ 1897#define ext4_abort(sb, message...) __ext4_abort(sb, __func__, \
1898 __LINE__, ## message) 1898 __LINE__, ## message)
1899extern void __ext4_warning(struct super_block *, const char *, unsigned int, 1899extern __printf(4, 5)
1900 const char *, ...) 1900void __ext4_warning(struct super_block *, const char *, unsigned int,
1901 __attribute__ ((format (printf, 4, 5))); 1901 const char *, ...);
1902#define ext4_warning(sb, message...) __ext4_warning(sb, __func__, \ 1902#define ext4_warning(sb, message...) __ext4_warning(sb, __func__, \
1903 __LINE__, ## message) 1903 __LINE__, ## message)
1904extern void ext4_msg(struct super_block *, const char *, const char *, ...) 1904extern __printf(3, 4)
1905 __attribute__ ((format (printf, 3, 4))); 1905void ext4_msg(struct super_block *, const char *, const char *, ...);
1906extern void __dump_mmp_msg(struct super_block *, struct mmp_struct *mmp, 1906extern void __dump_mmp_msg(struct super_block *, struct mmp_struct *mmp,
1907 const char *, unsigned int, const char *); 1907 const char *, unsigned int, const char *);
1908#define dump_mmp_msg(sb, mmp, msg) __dump_mmp_msg(sb, mmp, __func__, \ 1908#define dump_mmp_msg(sb, mmp, msg) __dump_mmp_msg(sb, mmp, __func__, \
1909 __LINE__, msg) 1909 __LINE__, msg)
1910extern void __ext4_grp_locked_error(const char *, unsigned int, \ 1910extern __printf(7, 8)
1911 struct super_block *, ext4_group_t, \ 1911void __ext4_grp_locked_error(const char *, unsigned int,
1912 unsigned long, ext4_fsblk_t, \ 1912 struct super_block *, ext4_group_t,
1913 const char *, ...) 1913 unsigned long, ext4_fsblk_t,
1914 __attribute__ ((format (printf, 7, 8))); 1914 const char *, ...);
1915#define ext4_grp_locked_error(sb, grp, message...) \ 1915#define ext4_grp_locked_error(sb, grp, message...) \
1916 __ext4_grp_locked_error(__func__, __LINE__, (sb), (grp), ## message) 1916 __ext4_grp_locked_error(__func__, __LINE__, (sb), (grp), ## message)
1917extern void ext4_update_dynamic_rev(struct super_block *sb); 1917extern void ext4_update_dynamic_rev(struct super_block *sb);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 986e2388f031..0defe0bfe019 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1811,8 +1811,12 @@ static int ext4_writepage(struct page *page,
1811 * We don't want to do block allocation, so redirty 1811 * We don't want to do block allocation, so redirty
1812 * the page and return. We may reach here when we do 1812 * the page and return. We may reach here when we do
1813 * a journal commit via journal_submit_inode_data_buffers. 1813 * a journal commit via journal_submit_inode_data_buffers.
1814 * We can also reach here via shrink_page_list 1814 * We can also reach here via shrink_page_list but it
1815 * should never be for direct reclaim so warn if that
1816 * happens
1815 */ 1817 */
1818 WARN_ON_ONCE((current->flags & (PF_MEMALLOC|PF_KSWAPD)) ==
1819 PF_MEMALLOC);
1816 goto redirty_page; 1820 goto redirty_page;
1817 } 1821 }
1818 if (commit_write) 1822 if (commit_write)
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 5efbd5d7701a..aca191bd5f8f 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -156,8 +156,8 @@ static int uni16_to_x8(struct super_block *sb, unsigned char *ascii,
156 } else { 156 } else {
157 if (uni_xlate == 1) { 157 if (uni_xlate == 1) {
158 *op++ = ':'; 158 *op++ = ':';
159 op = pack_hex_byte(op, ec >> 8); 159 op = hex_byte_pack(op, ec >> 8);
160 op = pack_hex_byte(op, ec); 160 op = hex_byte_pack(op, ec);
161 len -= 5; 161 len -= 5;
162 } else { 162 } else {
163 *op++ = '?'; 163 *op++ = '?';
diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index a5d3853822e0..1510a4d51990 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -326,15 +326,14 @@ extern int fat_fill_super(struct super_block *sb, void *data, int silent,
326extern int fat_flush_inodes(struct super_block *sb, struct inode *i1, 326extern int fat_flush_inodes(struct super_block *sb, struct inode *i1,
327 struct inode *i2); 327 struct inode *i2);
328/* fat/misc.c */ 328/* fat/misc.c */
329extern void 329extern __printf(3, 4) __cold
330__fat_fs_error(struct super_block *sb, int report, const char *fmt, ...) 330void __fat_fs_error(struct super_block *sb, int report, const char *fmt, ...);
331 __attribute__ ((format (printf, 3, 4))) __cold;
332#define fat_fs_error(sb, fmt, args...) \ 331#define fat_fs_error(sb, fmt, args...) \
333 __fat_fs_error(sb, 1, fmt , ## args) 332 __fat_fs_error(sb, 1, fmt , ## args)
334#define fat_fs_error_ratelimit(sb, fmt, args...) \ 333#define fat_fs_error_ratelimit(sb, fmt, args...) \
335 __fat_fs_error(sb, __ratelimit(&MSDOS_SB(sb)->ratelimit), fmt , ## args) 334 __fat_fs_error(sb, __ratelimit(&MSDOS_SB(sb)->ratelimit), fmt , ## args)
336void fat_msg(struct super_block *sb, const char *level, const char *fmt, ...) 335__printf(3, 4) __cold
337 __attribute__ ((format (printf, 3, 4))) __cold; 336void fat_msg(struct super_block *sb, const char *level, const char *fmt, ...);
338extern int fat_clusters_flush(struct super_block *sb); 337extern int fat_clusters_flush(struct super_block *sb);
339extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster); 338extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster);
340extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts, 339extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts,
diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h
index 66707118af25..2553b858a72e 100644
--- a/fs/gfs2/glock.h
+++ b/fs/gfs2/glock.h
@@ -201,7 +201,7 @@ int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs);
201void gfs2_glock_dq_m(unsigned int num_gh, struct gfs2_holder *ghs); 201void gfs2_glock_dq_m(unsigned int num_gh, struct gfs2_holder *ghs);
202void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs); 202void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs);
203 203
204__attribute__ ((format(printf, 2, 3))) 204__printf(2, 3)
205void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...); 205void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...);
206 206
207/** 207/**
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
index 331b5e234ef3..de946170ebb1 100644
--- a/fs/hpfs/hpfs_fn.h
+++ b/fs/hpfs/hpfs_fn.h
@@ -311,8 +311,8 @@ static inline struct hpfs_sb_info *hpfs_sb(struct super_block *sb)
311 311
312/* super.c */ 312/* super.c */
313 313
314void hpfs_error(struct super_block *, const char *, ...) 314__printf(2, 3)
315 __attribute__((format (printf, 2, 3))); 315void hpfs_error(struct super_block *, const char *, ...);
316int hpfs_stop_cycles(struct super_block *, int, int *, int *, char *); 316int hpfs_stop_cycles(struct super_block *, int, int *, int *, char *);
317unsigned hpfs_count_one_bitmap(struct super_block *, secno); 317unsigned hpfs_count_one_bitmap(struct super_block *, secno);
318 318
diff --git a/fs/logfs/logfs.h b/fs/logfs/logfs.h
index f22d108bfa5d..398ecff6e548 100644
--- a/fs/logfs/logfs.h
+++ b/fs/logfs/logfs.h
@@ -618,7 +618,6 @@ static inline int logfs_buf_recover(struct logfs_area *area, u64 ofs,
618struct page *emergency_read_begin(struct address_space *mapping, pgoff_t index); 618struct page *emergency_read_begin(struct address_space *mapping, pgoff_t index);
619void emergency_read_end(struct page *page); 619void emergency_read_end(struct page *page);
620void logfs_crash_dump(struct super_block *sb); 620void logfs_crash_dump(struct super_block *sb);
621void *memchr_inv(const void *s, int c, size_t n);
622int logfs_statfs(struct dentry *dentry, struct kstatfs *stats); 621int logfs_statfs(struct dentry *dentry, struct kstatfs *stats);
623int logfs_check_ds(struct logfs_disk_super *ds); 622int logfs_check_ds(struct logfs_disk_super *ds);
624int logfs_write_sb(struct super_block *sb); 623int logfs_write_sb(struct super_block *sb);
diff --git a/fs/logfs/super.c b/fs/logfs/super.c
index ce03a182c771..f2697e4df109 100644
--- a/fs/logfs/super.c
+++ b/fs/logfs/super.c
@@ -91,28 +91,6 @@ void logfs_crash_dump(struct super_block *sb)
91} 91}
92 92
93/* 93/*
94 * TODO: move to lib/string.c
95 */
96/**
97 * memchr_inv - Find a character in an area of memory.
98 * @s: The memory area
99 * @c: The byte to search for
100 * @n: The size of the area.
101 *
102 * returns the address of the first character other than @c, or %NULL
103 * if the whole buffer contains just @c.
104 */
105void *memchr_inv(const void *s, int c, size_t n)
106{
107 const unsigned char *p = s;
108 while (n-- != 0)
109 if ((unsigned char)c != *p++)
110 return (void *)(p - 1);
111
112 return NULL;
113}
114
115/*
116 * FIXME: There should be a reserve for root, similar to ext2. 94 * FIXME: There should be a reserve for root, similar to ext2.
117 */ 95 */
118int logfs_statfs(struct dentry *dentry, struct kstatfs *stats) 96int logfs_statfs(struct dentry *dentry, struct kstatfs *stats)
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index 255d5e1c03b7..3777d138f895 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -276,10 +276,10 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
276/* super.c */ 276/* super.c */
277extern struct inode *nilfs_alloc_inode(struct super_block *); 277extern struct inode *nilfs_alloc_inode(struct super_block *);
278extern void nilfs_destroy_inode(struct inode *); 278extern void nilfs_destroy_inode(struct inode *);
279extern void nilfs_error(struct super_block *, const char *, const char *, ...) 279extern __printf(3, 4)
280 __attribute__ ((format (printf, 3, 4))); 280void nilfs_error(struct super_block *, const char *, const char *, ...);
281extern void nilfs_warning(struct super_block *, const char *, const char *, ...) 281extern __printf(3, 4)
282 __attribute__ ((format (printf, 3, 4))); 282void nilfs_warning(struct super_block *, const char *, const char *, ...);
283extern struct nilfs_super_block * 283extern struct nilfs_super_block *
284nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **); 284nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **);
285extern int nilfs_store_magic_and_option(struct super_block *, 285extern int nilfs_store_magic_and_option(struct super_block *,
diff --git a/fs/ntfs/debug.h b/fs/ntfs/debug.h
index 2142b1c68b61..53c27eaf2307 100644
--- a/fs/ntfs/debug.h
+++ b/fs/ntfs/debug.h
@@ -30,8 +30,9 @@
30 30
31extern int debug_msgs; 31extern int debug_msgs;
32 32
33extern void __ntfs_debug(const char *file, int line, const char *function, 33extern __printf(4, 5)
34 const char *format, ...) __attribute__ ((format (printf, 4, 5))); 34void __ntfs_debug(const char *file, int line, const char *function,
35 const char *format, ...);
35/** 36/**
36 * ntfs_debug - write a debug level message to syslog 37 * ntfs_debug - write a debug level message to syslog
37 * @f: a printf format string containing the message 38 * @f: a printf format string containing the message
@@ -52,12 +53,14 @@ extern void ntfs_debug_dump_runlist(const runlist_element *rl);
52 53
53#endif /* !DEBUG */ 54#endif /* !DEBUG */
54 55
55extern void __ntfs_warning(const char *function, const struct super_block *sb, 56extern __printf(3, 4)
56 const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); 57void __ntfs_warning(const char *function, const struct super_block *sb,
58 const char *fmt, ...);
57#define ntfs_warning(sb, f, a...) __ntfs_warning(__func__, sb, f, ##a) 59#define ntfs_warning(sb, f, a...) __ntfs_warning(__func__, sb, f, ##a)
58 60
59extern void __ntfs_error(const char *function, const struct super_block *sb, 61extern __printf(3, 4)
60 const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); 62void __ntfs_error(const char *function, const struct super_block *sb,
63 const char *fmt, ...);
61#define ntfs_error(sb, f, a...) __ntfs_error(__func__, sb, f, ##a) 64#define ntfs_error(sb, f, a...) __ntfs_error(__func__, sb, f, ##a)
62 65
63#endif /* _LINUX_NTFS_DEBUG_H */ 66#endif /* _LINUX_NTFS_DEBUG_H */
diff --git a/fs/ocfs2/super.h b/fs/ocfs2/super.h
index 40c7de084c10..74ff74cf78fe 100644
--- a/fs/ocfs2/super.h
+++ b/fs/ocfs2/super.h
@@ -31,17 +31,15 @@ extern struct workqueue_struct *ocfs2_wq;
31int ocfs2_publish_get_mount_state(struct ocfs2_super *osb, 31int ocfs2_publish_get_mount_state(struct ocfs2_super *osb,
32 int node_num); 32 int node_num);
33 33
34void __ocfs2_error(struct super_block *sb, 34__printf(3, 4)
35 const char *function, 35void __ocfs2_error(struct super_block *sb, const char *function,
36 const char *fmt, ...) 36 const char *fmt, ...);
37 __attribute__ ((format (printf, 3, 4)));
38 37
39#define ocfs2_error(sb, fmt, args...) __ocfs2_error(sb, __PRETTY_FUNCTION__, fmt, ##args) 38#define ocfs2_error(sb, fmt, args...) __ocfs2_error(sb, __PRETTY_FUNCTION__, fmt, ##args)
40 39
41void __ocfs2_abort(struct super_block *sb, 40__printf(3, 4)
42 const char *function, 41void __ocfs2_abort(struct super_block *sb, const char *function,
43 const char *fmt, ...) 42 const char *fmt, ...);
44 __attribute__ ((format (printf, 3, 4)));
45 43
46#define ocfs2_abort(sb, fmt, args...) __ocfs2_abort(sb, __PRETTY_FUNCTION__, fmt, ##args) 44#define ocfs2_abort(sb, fmt, args...) __ocfs2_abort(sb, __PRETTY_FUNCTION__, fmt, ##args)
47 45
diff --git a/fs/partitions/ldm.c b/fs/partitions/ldm.c
index af9fdf046769..bd8ae788f689 100644
--- a/fs/partitions/ldm.c
+++ b/fs/partitions/ldm.c
@@ -49,18 +49,20 @@
49#define ldm_error(f, a...) _ldm_printk (KERN_ERR, __func__, f, ##a) 49#define ldm_error(f, a...) _ldm_printk (KERN_ERR, __func__, f, ##a)
50#define ldm_info(f, a...) _ldm_printk (KERN_INFO, __func__, f, ##a) 50#define ldm_info(f, a...) _ldm_printk (KERN_INFO, __func__, f, ##a)
51 51
52__attribute__ ((format (printf, 3, 4))) 52static __printf(3, 4)
53static void _ldm_printk (const char *level, const char *function, 53void _ldm_printk(const char *level, const char *function, const char *fmt, ...)
54 const char *fmt, ...)
55{ 54{
56 static char buf[128]; 55 struct va_format vaf;
57 va_list args; 56 va_list args;
58 57
59 va_start (args, fmt); 58 va_start (args, fmt);
60 vsnprintf (buf, sizeof (buf), fmt, args);
61 va_end (args);
62 59
63 printk ("%s%s(): %s\n", level, function, buf); 60 vaf.fmt = fmt;
61 vaf.va = &args;
62
63 printk("%s%s(): %pV\n", level, function, &vaf);
64
65 va_end(args);
64} 66}
65 67
66/** 68/**
diff --git a/fs/pipe.c b/fs/pipe.c
index 0e0be1dc0f8e..4065f07366b3 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -1254,6 +1254,7 @@ out:
1254 1254
1255static const struct super_operations pipefs_ops = { 1255static const struct super_operations pipefs_ops = {
1256 .destroy_inode = free_inode_nonrcu, 1256 .destroy_inode = free_inode_nonrcu,
1257 .statfs = simple_statfs,
1257}; 1258};
1258 1259
1259/* 1260/*
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 5eb02069e1b8..8f0087e20e16 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1107,13 +1107,6 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
1107 goto err_sighand; 1107 goto err_sighand;
1108 } 1108 }
1109 1109
1110 if (oom_adjust != task->signal->oom_adj) {
1111 if (oom_adjust == OOM_DISABLE)
1112 atomic_inc(&task->mm->oom_disable_count);
1113 if (task->signal->oom_adj == OOM_DISABLE)
1114 atomic_dec(&task->mm->oom_disable_count);
1115 }
1116
1117 /* 1110 /*
1118 * Warn that /proc/pid/oom_adj is deprecated, see 1111 * Warn that /proc/pid/oom_adj is deprecated, see
1119 * Documentation/feature-removal-schedule.txt. 1112 * Documentation/feature-removal-schedule.txt.
@@ -1215,12 +1208,6 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
1215 goto err_sighand; 1208 goto err_sighand;
1216 } 1209 }
1217 1210
1218 if (oom_score_adj != task->signal->oom_score_adj) {
1219 if (oom_score_adj == OOM_SCORE_ADJ_MIN)
1220 atomic_inc(&task->mm->oom_disable_count);
1221 if (task->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
1222 atomic_dec(&task->mm->oom_disable_count);
1223 }
1224 task->signal->oom_score_adj = oom_score_adj; 1211 task->signal->oom_score_adj = oom_score_adj;
1225 if (has_capability_noaudit(current, CAP_SYS_RESOURCE)) 1212 if (has_capability_noaudit(current, CAP_SYS_RESOURCE))
1226 task->signal->oom_score_adj_min = oom_score_adj; 1213 task->signal->oom_score_adj_min = oom_score_adj;
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 5afaa58a8630..e418c5abdb0e 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -44,6 +44,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
44 "VmPeak:\t%8lu kB\n" 44 "VmPeak:\t%8lu kB\n"
45 "VmSize:\t%8lu kB\n" 45 "VmSize:\t%8lu kB\n"
46 "VmLck:\t%8lu kB\n" 46 "VmLck:\t%8lu kB\n"
47 "VmPin:\t%8lu kB\n"
47 "VmHWM:\t%8lu kB\n" 48 "VmHWM:\t%8lu kB\n"
48 "VmRSS:\t%8lu kB\n" 49 "VmRSS:\t%8lu kB\n"
49 "VmData:\t%8lu kB\n" 50 "VmData:\t%8lu kB\n"
@@ -55,6 +56,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55 hiwater_vm << (PAGE_SHIFT-10), 56 hiwater_vm << (PAGE_SHIFT-10),
56 (total_vm - mm->reserved_vm) << (PAGE_SHIFT-10), 57 (total_vm - mm->reserved_vm) << (PAGE_SHIFT-10),
57 mm->locked_vm << (PAGE_SHIFT-10), 58 mm->locked_vm << (PAGE_SHIFT-10),
59 mm->pinned_vm << (PAGE_SHIFT-10),
58 hiwater_rss << (PAGE_SHIFT-10), 60 hiwater_rss << (PAGE_SHIFT-10),
59 total_rss << (PAGE_SHIFT-10), 61 total_rss << (PAGE_SHIFT-10),
60 data << (PAGE_SHIFT-10), 62 data << (PAGE_SHIFT-10),
@@ -1039,6 +1041,9 @@ static int show_numa_map(struct seq_file *m, void *v)
1039 seq_printf(m, " stack"); 1041 seq_printf(m, " stack");
1040 } 1042 }
1041 1043
1044 if (is_vm_hugetlb_page(vma))
1045 seq_printf(m, " huge");
1046
1042 walk_page_range(vma->vm_start, vma->vm_end, &walk); 1047 walk_page_range(vma->vm_start, vma->vm_end, &walk);
1043 1048
1044 if (!md->pages) 1049 if (!md->pages)
diff --git a/fs/read_write.c b/fs/read_write.c
index dfd125798791..5ad4248b0cd8 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -633,7 +633,8 @@ ssize_t do_loop_readv_writev(struct file *filp, struct iovec *iov,
633ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, 633ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
634 unsigned long nr_segs, unsigned long fast_segs, 634 unsigned long nr_segs, unsigned long fast_segs,
635 struct iovec *fast_pointer, 635 struct iovec *fast_pointer,
636 struct iovec **ret_pointer) 636 struct iovec **ret_pointer,
637 int check_access)
637{ 638{
638 unsigned long seg; 639 unsigned long seg;
639 ssize_t ret; 640 ssize_t ret;
@@ -689,7 +690,8 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
689 ret = -EINVAL; 690 ret = -EINVAL;
690 goto out; 691 goto out;
691 } 692 }
692 if (unlikely(!access_ok(vrfy_dir(type), buf, len))) { 693 if (check_access
694 && unlikely(!access_ok(vrfy_dir(type), buf, len))) {
693 ret = -EFAULT; 695 ret = -EFAULT;
694 goto out; 696 goto out;
695 } 697 }
@@ -721,7 +723,7 @@ static ssize_t do_readv_writev(int type, struct file *file,
721 } 723 }
722 724
723 ret = rw_copy_check_uvector(type, uvector, nr_segs, 725 ret = rw_copy_check_uvector(type, uvector, nr_segs,
724 ARRAY_SIZE(iovstack), iovstack, &iov); 726 ARRAY_SIZE(iovstack), iovstack, &iov, 1);
725 if (ret <= 0) 727 if (ret <= 0)
726 goto out; 728 goto out;
727 729
diff --git a/fs/super.c b/fs/super.c
index 3f56a269a4f4..32a81f3467e0 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -61,7 +61,7 @@ static int prune_super(struct shrinker *shrink, struct shrink_control *sc)
61 return -1; 61 return -1;
62 62
63 if (!grab_super_passive(sb)) 63 if (!grab_super_passive(sb))
64 return -1; 64 return !sc->nr_to_scan ? 0 : -1;
65 65
66 if (sb->s_op && sb->s_op->nr_cached_objects) 66 if (sb->s_op && sb->s_op->nr_cached_objects)
67 fs_objects = sb->s_op->nr_cached_objects(sb); 67 fs_objects = sb->s_op->nr_cached_objects(sb);
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index dbd52d4b5eed..dc8a8dcc5ae1 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -112,8 +112,8 @@ struct extent_position {
112 112
113/* super.c */ 113/* super.c */
114 114
115__attribute__((format(printf, 3, 4))) 115extern __printf(3, 4) void udf_warning(struct super_block *, const char *,
116extern void udf_warning(struct super_block *, const char *, const char *, ...); 116 const char *, ...);
117static inline void udf_updated_lvid(struct super_block *sb) 117static inline void udf_updated_lvid(struct super_block *sb)
118{ 118{
119 struct buffer_head *bh = UDF_SB(sb)->s_lvid_bh; 119 struct buffer_head *bh = UDF_SB(sb)->s_lvid_bh;
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h
index 5be2755dd715..c26f2bcec264 100644
--- a/fs/ufs/ufs.h
+++ b/fs/ufs/ufs.h
@@ -117,9 +117,12 @@ extern int ufs_getfrag_block (struct inode *inode, sector_t fragment, struct buf
117extern const struct file_operations ufs_dir_operations; 117extern const struct file_operations ufs_dir_operations;
118 118
119/* super.c */ 119/* super.c */
120extern void ufs_warning (struct super_block *, const char *, const char *, ...) __attribute__ ((format (printf, 3, 4))); 120extern __printf(3, 4)
121extern void ufs_error (struct super_block *, const char *, const char *, ...) __attribute__ ((format (printf, 3, 4))); 121void ufs_warning(struct super_block *, const char *, const char *, ...);
122extern void ufs_panic (struct super_block *, const char *, const char *, ...) __attribute__ ((format (printf, 3, 4))); 122extern __printf(3, 4)
123void ufs_error(struct super_block *, const char *, const char *, ...);
124extern __printf(3, 4)
125void ufs_panic(struct super_block *, const char *, const char *, ...);
123 126
124/* symlink.c */ 127/* symlink.c */
125extern const struct inode_operations ufs_fast_symlink_inode_operations; 128extern const struct inode_operations ufs_fast_symlink_inode_operations;
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 11b2aad982d4..33b13310ee0c 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -902,11 +902,11 @@ xfs_vm_writepage(
902 * random callers for direct reclaim or memcg reclaim. We explicitly 902 * random callers for direct reclaim or memcg reclaim. We explicitly
903 * allow reclaim from kswapd as the stack usage there is relatively low. 903 * allow reclaim from kswapd as the stack usage there is relatively low.
904 * 904 *
905 * This should really be done by the core VM, but until that happens 905 * This should never happen except in the case of a VM regression so
906 * filesystems like XFS, btrfs and ext4 have to take care of this 906 * warn about it.
907 * by themselves.
908 */ 907 */
909 if ((current->flags & (PF_MEMALLOC|PF_KSWAPD)) == PF_MEMALLOC) 908 if (WARN_ON_ONCE((current->flags & (PF_MEMALLOC|PF_KSWAPD)) ==
909 PF_MEMALLOC))
910 goto redirty; 910 goto redirty;
911 911
912 /* 912 /*
diff --git a/fs/xfs/xfs_message.h b/fs/xfs/xfs_message.h
index 7fb7ea007672..56dc0c17f16a 100644
--- a/fs/xfs/xfs_message.h
+++ b/fs/xfs/xfs_message.h
@@ -3,31 +3,29 @@
3 3
4struct xfs_mount; 4struct xfs_mount;
5 5
6extern void xfs_emerg(const struct xfs_mount *mp, const char *fmt, ...) 6extern __printf(2, 3)
7 __attribute__ ((format (printf, 2, 3))); 7void xfs_emerg(const struct xfs_mount *mp, const char *fmt, ...);
8extern void xfs_alert(const struct xfs_mount *mp, const char *fmt, ...) 8extern __printf(2, 3)
9 __attribute__ ((format (printf, 2, 3))); 9void xfs_alert(const struct xfs_mount *mp, const char *fmt, ...);
10extern void xfs_alert_tag(const struct xfs_mount *mp, int tag, 10extern __printf(3, 4)
11 const char *fmt, ...) 11void xfs_alert_tag(const struct xfs_mount *mp, int tag, const char *fmt, ...);
12 __attribute__ ((format (printf, 3, 4))); 12extern __printf(2, 3)
13extern void xfs_crit(const struct xfs_mount *mp, const char *fmt, ...) 13void xfs_crit(const struct xfs_mount *mp, const char *fmt, ...);
14 __attribute__ ((format (printf, 2, 3))); 14extern __printf(2, 3)
15extern void xfs_err(const struct xfs_mount *mp, const char *fmt, ...) 15void xfs_err(const struct xfs_mount *mp, const char *fmt, ...);
16 __attribute__ ((format (printf, 2, 3))); 16extern __printf(2, 3)
17extern void xfs_warn(const struct xfs_mount *mp, const char *fmt, ...) 17void xfs_warn(const struct xfs_mount *mp, const char *fmt, ...);
18 __attribute__ ((format (printf, 2, 3))); 18extern __printf(2, 3)
19extern void xfs_notice(const struct xfs_mount *mp, const char *fmt, ...) 19void xfs_notice(const struct xfs_mount *mp, const char *fmt, ...);
20 __attribute__ ((format (printf, 2, 3))); 20extern __printf(2, 3)
21extern void xfs_info(const struct xfs_mount *mp, const char *fmt, ...) 21void xfs_info(const struct xfs_mount *mp, const char *fmt, ...);
22 __attribute__ ((format (printf, 2, 3)));
23 22
24#ifdef DEBUG 23#ifdef DEBUG
25extern void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...) 24extern __printf(2, 3)
26 __attribute__ ((format (printf, 2, 3))); 25void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...);
27#else 26#else
28static inline void 27static inline __printf(2, 3)
29__attribute__ ((format (printf, 2, 3))) 28void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...)
30xfs_debug(const struct xfs_mount *mp, const char *fmt, ...)
31{ 29{
32} 30}
33#endif 31#endif
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index dfb0ec666c94..84458b0c38d1 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -61,11 +61,12 @@ struct bug_entry {
61 */ 61 */
62#ifndef __WARN_TAINT 62#ifndef __WARN_TAINT
63#ifndef __ASSEMBLY__ 63#ifndef __ASSEMBLY__
64extern void warn_slowpath_fmt(const char *file, const int line, 64extern __printf(3, 4)
65 const char *fmt, ...) __attribute__((format(printf, 3, 4))); 65void warn_slowpath_fmt(const char *file, const int line,
66extern void warn_slowpath_fmt_taint(const char *file, const int line, 66 const char *fmt, ...);
67 unsigned taint, const char *fmt, ...) 67extern __printf(4, 5)
68 __attribute__((format(printf, 4, 5))); 68void warn_slowpath_fmt_taint(const char *file, const int line, unsigned taint,
69 const char *fmt, ...);
69extern void warn_slowpath_null(const char *file, const int line); 70extern void warn_slowpath_null(const char *file, const int line);
70#define WANT_WARN_ON_SLOWPATH 71#define WANT_WARN_ON_SLOWPATH
71#endif 72#endif
diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h
index 0c80bb38773f..9fa3f96e38cf 100644
--- a/include/asm-generic/dma-mapping-common.h
+++ b/include/asm-generic/dma-mapping-common.h
@@ -123,7 +123,12 @@ static inline void dma_sync_single_range_for_cpu(struct device *dev,
123 size_t size, 123 size_t size,
124 enum dma_data_direction dir) 124 enum dma_data_direction dir)
125{ 125{
126 dma_sync_single_for_cpu(dev, addr + offset, size, dir); 126 const struct dma_map_ops *ops = get_dma_ops(dev);
127
128 BUG_ON(!valid_dma_direction(dir));
129 if (ops->sync_single_for_cpu)
130 ops->sync_single_for_cpu(dev, addr + offset, size, dir);
131 debug_dma_sync_single_range_for_cpu(dev, addr, offset, size, dir);
127} 132}
128 133
129static inline void dma_sync_single_range_for_device(struct device *dev, 134static inline void dma_sync_single_range_for_device(struct device *dev,
@@ -132,7 +137,12 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
132 size_t size, 137 size_t size,
133 enum dma_data_direction dir) 138 enum dma_data_direction dir)
134{ 139{
135 dma_sync_single_for_device(dev, addr + offset, size, dir); 140 const struct dma_map_ops *ops = get_dma_ops(dev);
141
142 BUG_ON(!valid_dma_direction(dir));
143 if (ops->sync_single_for_device)
144 ops->sync_single_for_device(dev, addr + offset, size, dir);
145 debug_dma_sync_single_range_for_device(dev, addr, offset, size, dir);
136} 146}
137 147
138static inline void 148static inline void
diff --git a/include/asm-generic/page.h b/include/asm-generic/page.h
index 75fec18cdc59..351889d1de19 100644
--- a/include/asm-generic/page.h
+++ b/include/asm-generic/page.h
@@ -79,8 +79,8 @@ extern unsigned long memory_end;
79#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) 79#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
80#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) 80#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
81 81
82#define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)) 82#define virt_to_page(addr) pfn_to_page(virt_to_pfn(addr))
83#define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET) 83#define page_to_virt(page) pfn_to_virt(page_to_pfn(page))
84 84
85#ifndef page_to_phys 85#ifndef page_to_phys
86#define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) 86#define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 43538b643560..cf3b446139ea 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -122,12 +122,12 @@ struct drm_device;
122 * using the DRM_DEBUG_KMS and DRM_DEBUG. 122 * using the DRM_DEBUG_KMS and DRM_DEBUG.
123 */ 123 */
124 124
125extern __attribute__((format (printf, 4, 5))) 125extern __printf(4, 5)
126void drm_ut_debug_printk(unsigned int request_level, 126void drm_ut_debug_printk(unsigned int request_level,
127 const char *prefix, 127 const char *prefix,
128 const char *function_name, 128 const char *function_name,
129 const char *format, ...); 129 const char *format, ...);
130extern __attribute__((format (printf, 2, 3))) 130extern __printf(2, 3)
131int drm_err(const char *func, const char *format, ...); 131int drm_err(const char *func, const char *format, ...);
132 132
133/***********************************************************************/ 133/***********************************************************************/
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 0c8006129fb2..2f81c6f3b630 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -584,14 +584,13 @@ extern int audit_signals;
584#ifdef CONFIG_AUDIT 584#ifdef CONFIG_AUDIT
585/* These are defined in audit.c */ 585/* These are defined in audit.c */
586 /* Public API */ 586 /* Public API */
587extern void audit_log(struct audit_context *ctx, gfp_t gfp_mask, 587extern __printf(4, 5)
588 int type, const char *fmt, ...) 588void audit_log(struct audit_context *ctx, gfp_t gfp_mask, int type,
589 __attribute__((format(printf,4,5))); 589 const char *fmt, ...);
590 590
591extern struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type); 591extern struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type);
592extern void audit_log_format(struct audit_buffer *ab, 592extern __printf(2, 3)
593 const char *fmt, ...) 593void audit_log_format(struct audit_buffer *ab, const char *fmt, ...);
594 __attribute__((format(printf,2,3)));
595extern void audit_log_end(struct audit_buffer *ab); 594extern void audit_log_end(struct audit_buffer *ab);
596extern int audit_string_contains_control(const char *string, 595extern int audit_string_contains_control(const char *string,
597 size_t len); 596 size_t len);
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index 8e9e4bc6d73b..4d1a0748eaf8 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -170,7 +170,7 @@ extern void blk_trace_shutdown(struct request_queue *);
170extern int do_blk_trace_setup(struct request_queue *q, char *name, 170extern int do_blk_trace_setup(struct request_queue *q, char *name,
171 dev_t dev, struct block_device *bdev, 171 dev_t dev, struct block_device *bdev,
172 struct blk_user_trace_setup *buts); 172 struct blk_user_trace_setup *buts);
173extern __attribute__((format(printf, 2, 3))) 173extern __printf(2, 3)
174void __trace_note_message(struct blk_trace *, const char *fmt, ...); 174void __trace_note_message(struct blk_trace *, const char *fmt, ...);
175 175
176/** 176/**
diff --git a/include/linux/compaction.h b/include/linux/compaction.h
index cc9f7a428649..bb2bbdbe5464 100644
--- a/include/linux/compaction.h
+++ b/include/linux/compaction.h
@@ -24,8 +24,6 @@ extern unsigned long try_to_compact_pages(struct zonelist *zonelist,
24 int order, gfp_t gfp_mask, nodemask_t *mask, 24 int order, gfp_t gfp_mask, nodemask_t *mask,
25 bool sync); 25 bool sync);
26extern unsigned long compaction_suitable(struct zone *zone, int order); 26extern unsigned long compaction_suitable(struct zone *zone, int order);
27extern unsigned long compact_zone_order(struct zone *zone, int order,
28 gfp_t gfp_mask, bool sync);
29 27
30/* Do not skip compaction more than 64 times */ 28/* Do not skip compaction more than 64 times */
31#define COMPACT_MAX_DEFER_SHIFT 6 29#define COMPACT_MAX_DEFER_SHIFT 6
@@ -69,12 +67,6 @@ static inline unsigned long compaction_suitable(struct zone *zone, int order)
69 return COMPACT_SKIPPED; 67 return COMPACT_SKIPPED;
70} 68}
71 69
72static inline unsigned long compact_zone_order(struct zone *zone, int order,
73 gfp_t gfp_mask, bool sync)
74{
75 return COMPACT_CONTINUE;
76}
77
78static inline void defer_compaction(struct zone *zone) 70static inline void defer_compaction(struct zone *zone)
79{ 71{
80} 72}
diff --git a/include/linux/compat.h b/include/linux/compat.h
index c6e7523bf765..154bf5683015 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -547,7 +547,8 @@ extern ssize_t compat_rw_copy_check_uvector(int type,
547 const struct compat_iovec __user *uvector, 547 const struct compat_iovec __user *uvector,
548 unsigned long nr_segs, 548 unsigned long nr_segs,
549 unsigned long fast_segs, struct iovec *fast_pointer, 549 unsigned long fast_segs, struct iovec *fast_pointer,
550 struct iovec **ret_pointer); 550 struct iovec **ret_pointer,
551 int check_access);
551 552
552extern void __user *compat_alloc_user_space(unsigned long len); 553extern void __user *compat_alloc_user_space(unsigned long len);
553 554
diff --git a/include/linux/device.h b/include/linux/device.h
index 85e78fc7d7fd..e88abeecfadf 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -622,8 +622,8 @@ static inline const char *dev_name(const struct device *dev)
622 return kobject_name(&dev->kobj); 622 return kobject_name(&dev->kobj);
623} 623}
624 624
625extern int dev_set_name(struct device *dev, const char *name, ...) 625extern __printf(2, 3)
626 __attribute__((format(printf, 2, 3))); 626int dev_set_name(struct device *dev, const char *name, ...);
627 627
628#ifdef CONFIG_NUMA 628#ifdef CONFIG_NUMA
629static inline int dev_to_node(struct device *dev) 629static inline int dev_to_node(struct device *dev)
@@ -753,10 +753,10 @@ extern struct device *device_create_vargs(struct class *cls,
753 void *drvdata, 753 void *drvdata,
754 const char *fmt, 754 const char *fmt,
755 va_list vargs); 755 va_list vargs);
756extern struct device *device_create(struct class *cls, struct device *parent, 756extern __printf(5, 6)
757 dev_t devt, void *drvdata, 757struct device *device_create(struct class *cls, struct device *parent,
758 const char *fmt, ...) 758 dev_t devt, void *drvdata,
759 __attribute__((format(printf, 5, 6))); 759 const char *fmt, ...);
760extern void device_destroy(struct class *cls, dev_t devt); 760extern void device_destroy(struct class *cls, dev_t devt);
761 761
762/* 762/*
@@ -800,64 +800,56 @@ extern const char *dev_driver_string(const struct device *dev);
800 800
801extern int __dev_printk(const char *level, const struct device *dev, 801extern int __dev_printk(const char *level, const struct device *dev,
802 struct va_format *vaf); 802 struct va_format *vaf);
803extern int dev_printk(const char *level, const struct device *dev, 803extern __printf(3, 4)
804 const char *fmt, ...) 804int dev_printk(const char *level, const struct device *dev,
805 __attribute__ ((format (printf, 3, 4))); 805 const char *fmt, ...)
806extern int dev_emerg(const struct device *dev, const char *fmt, ...) 806 ;
807 __attribute__ ((format (printf, 2, 3))); 807extern __printf(2, 3)
808extern int dev_alert(const struct device *dev, const char *fmt, ...) 808int dev_emerg(const struct device *dev, const char *fmt, ...);
809 __attribute__ ((format (printf, 2, 3))); 809extern __printf(2, 3)
810extern int dev_crit(const struct device *dev, const char *fmt, ...) 810int dev_alert(const struct device *dev, const char *fmt, ...);
811 __attribute__ ((format (printf, 2, 3))); 811extern __printf(2, 3)
812extern int dev_err(const struct device *dev, const char *fmt, ...) 812int dev_crit(const struct device *dev, const char *fmt, ...);
813 __attribute__ ((format (printf, 2, 3))); 813extern __printf(2, 3)
814extern int dev_warn(const struct device *dev, const char *fmt, ...) 814int dev_err(const struct device *dev, const char *fmt, ...);
815 __attribute__ ((format (printf, 2, 3))); 815extern __printf(2, 3)
816extern int dev_notice(const struct device *dev, const char *fmt, ...) 816int dev_warn(const struct device *dev, const char *fmt, ...);
817 __attribute__ ((format (printf, 2, 3))); 817extern __printf(2, 3)
818extern int _dev_info(const struct device *dev, const char *fmt, ...) 818int dev_notice(const struct device *dev, const char *fmt, ...);
819 __attribute__ ((format (printf, 2, 3))); 819extern __printf(2, 3)
820int _dev_info(const struct device *dev, const char *fmt, ...);
820 821
821#else 822#else
822 823
823static inline int __dev_printk(const char *level, const struct device *dev, 824static inline int __dev_printk(const char *level, const struct device *dev,
824 struct va_format *vaf) 825 struct va_format *vaf)
825 { return 0; } 826{ return 0; }
826static inline int dev_printk(const char *level, const struct device *dev, 827static inline __printf(3, 4)
827 const char *fmt, ...) 828int dev_printk(const char *level, const struct device *dev,
828 __attribute__ ((format (printf, 3, 4))); 829 const char *fmt, ...)
829static inline int dev_printk(const char *level, const struct device *dev, 830{ return 0; }
830 const char *fmt, ...) 831
831 { return 0; } 832static inline __printf(2, 3)
832 833int dev_emerg(const struct device *dev, const char *fmt, ...)
833static inline int dev_emerg(const struct device *dev, const char *fmt, ...) 834{ return 0; }
834 __attribute__ ((format (printf, 2, 3))); 835static inline __printf(2, 3)
835static inline int dev_emerg(const struct device *dev, const char *fmt, ...) 836int dev_crit(const struct device *dev, const char *fmt, ...)
836 { return 0; } 837{ return 0; }
837static inline int dev_crit(const struct device *dev, const char *fmt, ...) 838static inline __printf(2, 3)
838 __attribute__ ((format (printf, 2, 3))); 839int dev_alert(const struct device *dev, const char *fmt, ...)
839static inline int dev_crit(const struct device *dev, const char *fmt, ...) 840{ return 0; }
840 { return 0; } 841static inline __printf(2, 3)
841static inline int dev_alert(const struct device *dev, const char *fmt, ...) 842int dev_err(const struct device *dev, const char *fmt, ...)
842 __attribute__ ((format (printf, 2, 3))); 843{ return 0; }
843static inline int dev_alert(const struct device *dev, const char *fmt, ...) 844static inline __printf(2, 3)
844 { return 0; } 845int dev_warn(const struct device *dev, const char *fmt, ...)
845static inline int dev_err(const struct device *dev, const char *fmt, ...) 846{ return 0; }
846 __attribute__ ((format (printf, 2, 3))); 847static inline __printf(2, 3)
847static inline int dev_err(const struct device *dev, const char *fmt, ...) 848int dev_notice(const struct device *dev, const char *fmt, ...)
848 { return 0; } 849{ return 0; }
849static inline int dev_warn(const struct device *dev, const char *fmt, ...) 850static inline __printf(2, 3)
850 __attribute__ ((format (printf, 2, 3))); 851int _dev_info(const struct device *dev, const char *fmt, ...)
851static inline int dev_warn(const struct device *dev, const char *fmt, ...) 852{ return 0; }
852 { return 0; }
853static inline int dev_notice(const struct device *dev, const char *fmt, ...)
854 __attribute__ ((format (printf, 2, 3)));
855static inline int dev_notice(const struct device *dev, const char *fmt, ...)
856 { return 0; }
857static inline int _dev_info(const struct device *dev, const char *fmt, ...)
858 __attribute__ ((format (printf, 2, 3)));
859static inline int _dev_info(const struct device *dev, const char *fmt, ...)
860 { return 0; }
861 853
862#endif 854#endif
863 855
diff --git a/include/linux/dmar.h b/include/linux/dmar.h
index a8b1a847c103..731a60975101 100644
--- a/include/linux/dmar.h
+++ b/include/linux/dmar.h
@@ -26,6 +26,8 @@
26#include <linux/msi.h> 26#include <linux/msi.h>
27#include <linux/irqreturn.h> 27#include <linux/irqreturn.h>
28 28
29struct acpi_dmar_header;
30
29/* DMAR Flags */ 31/* DMAR Flags */
30#define DMAR_INTR_REMAP 0x1 32#define DMAR_INTR_REMAP 0x1
31#define DMAR_X2APIC_OPT_OUT 0x2 33#define DMAR_X2APIC_OPT_OUT 0x2
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index 13aae8087b56..0564e3c39882 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -37,22 +37,21 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
37 37
38#if defined(CONFIG_DYNAMIC_DEBUG) 38#if defined(CONFIG_DYNAMIC_DEBUG)
39extern int ddebug_remove_module(const char *mod_name); 39extern int ddebug_remove_module(const char *mod_name);
40extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) 40extern __printf(2, 3)
41 __attribute__ ((format (printf, 2, 3))); 41int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...);
42 42
43struct device; 43struct device;
44 44
45extern int __dynamic_dev_dbg(struct _ddebug *descriptor, 45extern __printf(3, 4)
46 const struct device *dev, 46int __dynamic_dev_dbg(struct _ddebug *descriptor, const struct device *dev,
47 const char *fmt, ...) 47 const char *fmt, ...);
48 __attribute__ ((format (printf, 3, 4)));
49 48
50struct net_device; 49struct net_device;
51 50
52extern int __dynamic_netdev_dbg(struct _ddebug *descriptor, 51extern __printf(3, 4)
53 const struct net_device *dev, 52int __dynamic_netdev_dbg(struct _ddebug *descriptor,
54 const char *fmt, ...) 53 const struct net_device *dev,
55 __attribute__ ((format (printf, 3, 4))); 54 const char *fmt, ...);
56 55
57#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ 56#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \
58 static struct _ddebug __used __aligned(8) \ 57 static struct _ddebug __used __aligned(8) \
diff --git a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h
index 67a803aee619..81965cce6bfa 100644
--- a/include/linux/ext3_fs.h
+++ b/include/linux/ext3_fs.h
@@ -937,15 +937,15 @@ extern int ext3_group_extend(struct super_block *sb,
937 ext3_fsblk_t n_blocks_count); 937 ext3_fsblk_t n_blocks_count);
938 938
939/* super.c */ 939/* super.c */
940extern void ext3_error (struct super_block *, const char *, const char *, ...) 940extern __printf(3, 4)
941 __attribute__ ((format (printf, 3, 4))); 941void ext3_error(struct super_block *, const char *, const char *, ...);
942extern void __ext3_std_error (struct super_block *, const char *, int); 942extern void __ext3_std_error (struct super_block *, const char *, int);
943extern void ext3_abort (struct super_block *, const char *, const char *, ...) 943extern __printf(3, 4)
944 __attribute__ ((format (printf, 3, 4))); 944void ext3_abort(struct super_block *, const char *, const char *, ...);
945extern void ext3_warning (struct super_block *, const char *, const char *, ...) 945extern __printf(3, 4)
946 __attribute__ ((format (printf, 3, 4))); 946void ext3_warning(struct super_block *, const char *, const char *, ...);
947extern void ext3_msg(struct super_block *, const char *, const char *, ...) 947extern __printf(3, 4)
948 __attribute__ ((format (printf, 3, 4))); 948void ext3_msg(struct super_block *, const char *, const char *, ...);
949extern void ext3_update_dynamic_rev (struct super_block *sb); 949extern void ext3_update_dynamic_rev (struct super_block *sb);
950 950
951#define ext3_std_error(sb, errno) \ 951#define ext3_std_error(sb, errno) \
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 14493a2d5a03..7a049fd2aa4c 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1633,9 +1633,10 @@ struct inode_operations {
1633struct seq_file; 1633struct seq_file;
1634 1634
1635ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, 1635ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
1636 unsigned long nr_segs, unsigned long fast_segs, 1636 unsigned long nr_segs, unsigned long fast_segs,
1637 struct iovec *fast_pointer, 1637 struct iovec *fast_pointer,
1638 struct iovec **ret_pointer); 1638 struct iovec **ret_pointer,
1639 int check_access);
1639 1640
1640extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *); 1641extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
1641extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *); 1642extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *);
@@ -2634,8 +2635,8 @@ static const struct file_operations __fops = { \
2634 .llseek = generic_file_llseek, \ 2635 .llseek = generic_file_llseek, \
2635}; 2636};
2636 2637
2637static inline void __attribute__((format(printf, 1, 2))) 2638static inline __printf(1, 2)
2638__simple_attr_check_format(const char *fmt, ...) 2639void __simple_attr_check_format(const char *fmt, ...)
2639{ 2640{
2640 /* don't do anything, just let the compiler check the arguments; */ 2641 /* don't do anything, just let the compiler check the arguments; */
2641} 2642}
diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
index af095b54502e..ce31408b1e47 100644
--- a/include/linux/fscache-cache.h
+++ b/include/linux/fscache-cache.h
@@ -492,10 +492,10 @@ static inline void fscache_end_io(struct fscache_retrieval *op,
492/* 492/*
493 * out-of-line cache backend functions 493 * out-of-line cache backend functions
494 */ 494 */
495extern void fscache_init_cache(struct fscache_cache *cache, 495extern __printf(3, 4)
496 const struct fscache_cache_ops *ops, 496void fscache_init_cache(struct fscache_cache *cache,
497 const char *idfmt, 497 const struct fscache_cache_ops *ops,
498 ...) __attribute__ ((format (printf, 3, 4))); 498 const char *idfmt, ...);
499 499
500extern int fscache_add_cache(struct fscache_cache *cache, 500extern int fscache_add_cache(struct fscache_cache *cache,
501 struct fscache_object *fsdef, 501 struct fscache_object *fsdef,
diff --git a/include/linux/gameport.h b/include/linux/gameport.h
index b65a6f472775..069ee4139105 100644
--- a/include/linux/gameport.h
+++ b/include/linux/gameport.h
@@ -78,8 +78,8 @@ static inline void gameport_register_port(struct gameport *gameport)
78 78
79void gameport_unregister_port(struct gameport *gameport); 79void gameport_unregister_port(struct gameport *gameport);
80 80
81void gameport_set_phys(struct gameport *gameport, const char *fmt, ...) 81__printf(2, 3)
82 __attribute__ ((format (printf, 2, 3))); 82void gameport_set_phys(struct gameport *gameport, const char *fmt, ...);
83 83
84#else 84#else
85 85
@@ -93,8 +93,8 @@ static inline void gameport_unregister_port(struct gameport *gameport)
93 return; 93 return;
94} 94}
95 95
96static inline void gameport_set_phys(struct gameport *gameport, 96static inline __printf(2, 3)
97 const char *fmt, ...) 97void gameport_set_phys(struct gameport *gameport, const char *fmt, ...)
98{ 98{
99 return; 99 return;
100} 100}
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index 48c32ebf65a7..a9ace9c32507 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -22,6 +22,11 @@ extern int zap_huge_pmd(struct mmu_gather *tlb,
22extern int mincore_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, 22extern int mincore_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
23 unsigned long addr, unsigned long end, 23 unsigned long addr, unsigned long end,
24 unsigned char *vec); 24 unsigned char *vec);
25extern int move_huge_pmd(struct vm_area_struct *vma,
26 struct vm_area_struct *new_vma,
27 unsigned long old_addr,
28 unsigned long new_addr, unsigned long old_end,
29 pmd_t *old_pmd, pmd_t *new_pmd);
25extern int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, 30extern int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
26 unsigned long addr, pgprot_t newprot); 31 unsigned long addr, pgprot_t newprot);
27 32
diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
index 0df513b7a9f8..387571959dd9 100644
--- a/include/linux/kallsyms.h
+++ b/include/linux/kallsyms.h
@@ -101,9 +101,8 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
101#endif /*CONFIG_KALLSYMS*/ 101#endif /*CONFIG_KALLSYMS*/
102 102
103/* This macro allows us to keep printk typechecking */ 103/* This macro allows us to keep printk typechecking */
104static void __check_printsym_format(const char *fmt, ...) 104static __printf(1, 2)
105__attribute__((format(printf,1,2))); 105void __check_printsym_format(const char *fmt, ...)
106static inline void __check_printsym_format(const char *fmt, ...)
107{ 106{
108} 107}
109 108
diff --git a/include/linux/kdb.h b/include/linux/kdb.h
index 529d9a0c75a5..064725854db8 100644
--- a/include/linux/kdb.h
+++ b/include/linux/kdb.h
@@ -114,12 +114,9 @@ typedef enum {
114} kdb_reason_t; 114} kdb_reason_t;
115 115
116extern int kdb_trap_printk; 116extern int kdb_trap_printk;
117extern int vkdb_printf(const char *fmt, va_list args) 117extern __printf(1, 0) int vkdb_printf(const char *fmt, va_list args);
118 __attribute__ ((format (printf, 1, 0))); 118extern __printf(1, 2) int kdb_printf(const char *, ...);
119extern int kdb_printf(const char *, ...) 119typedef __printf(1, 2) int (*kdb_printf_t)(const char *, ...);
120 __attribute__ ((format (printf, 1, 2)));
121typedef int (*kdb_printf_t)(const char *, ...)
122 __attribute__ ((format (printf, 1, 2)));
123 120
124extern void kdb_init(int level); 121extern void kdb_init(int level);
125 122
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 8eefcf7e95eb..4c0d3b2fd5fc 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -287,6 +287,8 @@ static inline int __must_check kstrtos32_from_user(const char __user *s, size_t
287 return kstrtoint_from_user(s, count, base, res); 287 return kstrtoint_from_user(s, count, base, res);
288} 288}
289 289
290/* Obsolete, do not use. Use kstrto<foo> instead */
291
290extern unsigned long simple_strtoul(const char *,char **,unsigned int); 292extern unsigned long simple_strtoul(const char *,char **,unsigned int);
291extern long simple_strtol(const char *,char **,unsigned int); 293extern long simple_strtol(const char *,char **,unsigned int);
292extern unsigned long long simple_strtoull(const char *,char **,unsigned int); 294extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
@@ -296,20 +298,20 @@ extern long long simple_strtoll(const char *,char **,unsigned int);
296#define strict_strtoull kstrtoull 298#define strict_strtoull kstrtoull
297#define strict_strtoll kstrtoll 299#define strict_strtoll kstrtoll
298 300
299extern int sprintf(char * buf, const char * fmt, ...) 301/* lib/printf utilities */
300 __attribute__ ((format (printf, 2, 3))); 302
301extern int vsprintf(char *buf, const char *, va_list) 303extern __printf(2, 3) int sprintf(char *buf, const char * fmt, ...);
302 __attribute__ ((format (printf, 2, 0))); 304extern __printf(2, 0) int vsprintf(char *buf, const char *, va_list);
303extern int snprintf(char * buf, size_t size, const char * fmt, ...) 305extern __printf(3, 4)
304 __attribute__ ((format (printf, 3, 4))); 306int snprintf(char *buf, size_t size, const char *fmt, ...);
305extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) 307extern __printf(3, 0)
306 __attribute__ ((format (printf, 3, 0))); 308int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
307extern int scnprintf(char * buf, size_t size, const char * fmt, ...) 309extern __printf(3, 4)
308 __attribute__ ((format (printf, 3, 4))); 310int scnprintf(char *buf, size_t size, const char *fmt, ...);
309extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args) 311extern __printf(3, 0)
310 __attribute__ ((format (printf, 3, 0))); 312int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
311extern char *kasprintf(gfp_t gfp, const char *fmt, ...) 313extern __printf(2, 3)
312 __attribute__ ((format (printf, 2, 3))); 314char *kasprintf(gfp_t gfp, const char *fmt, ...);
313extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); 315extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args);
314 316
315extern int sscanf(const char *, const char *, ...) 317extern int sscanf(const char *, const char *, ...)
@@ -374,13 +376,18 @@ extern const char hex_asc[];
374#define hex_asc_lo(x) hex_asc[((x) & 0x0f)] 376#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
375#define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] 377#define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4]
376 378
377static inline char *pack_hex_byte(char *buf, u8 byte) 379static inline char *hex_byte_pack(char *buf, u8 byte)
378{ 380{
379 *buf++ = hex_asc_hi(byte); 381 *buf++ = hex_asc_hi(byte);
380 *buf++ = hex_asc_lo(byte); 382 *buf++ = hex_asc_lo(byte);
381 return buf; 383 return buf;
382} 384}
383 385
386static inline char * __deprecated pack_hex_byte(char *buf, u8 byte)
387{
388 return hex_byte_pack(buf, byte);
389}
390
384extern int hex_to_bin(char ch); 391extern int hex_to_bin(char ch);
385extern int __must_check hex2bin(u8 *dst, const char *src, size_t count); 392extern int __must_check hex2bin(u8 *dst, const char *src, size_t count);
386 393
@@ -427,8 +434,8 @@ extern void tracing_start(void);
427extern void tracing_stop(void); 434extern void tracing_stop(void);
428extern void ftrace_off_permanent(void); 435extern void ftrace_off_permanent(void);
429 436
430static inline void __attribute__ ((format (printf, 1, 2))) 437static inline __printf(1, 2)
431____trace_printk_check_format(const char *fmt, ...) 438void ____trace_printk_check_format(const char *fmt, ...)
432{ 439{
433} 440}
434#define __trace_printk_check_format(fmt, args...) \ 441#define __trace_printk_check_format(fmt, args...) \
@@ -467,13 +474,11 @@ do { \
467 __trace_printk(_THIS_IP_, fmt, ##args); \ 474 __trace_printk(_THIS_IP_, fmt, ##args); \
468} while (0) 475} while (0)
469 476
470extern int 477extern __printf(2, 3)
471__trace_bprintk(unsigned long ip, const char *fmt, ...) 478int __trace_bprintk(unsigned long ip, const char *fmt, ...);
472 __attribute__ ((format (printf, 2, 3)));
473 479
474extern int 480extern __printf(2, 3)
475__trace_printk(unsigned long ip, const char *fmt, ...) 481int __trace_printk(unsigned long ip, const char *fmt, ...);
476 __attribute__ ((format (printf, 2, 3)));
477 482
478extern void trace_dump_stack(void); 483extern void trace_dump_stack(void);
479 484
@@ -502,8 +507,8 @@ __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap);
502 507
503extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode); 508extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode);
504#else 509#else
505static inline int 510static inline __printf(1, 2)
506trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); 511int trace_printk(const char *fmt, ...);
507 512
508static inline void tracing_start(void) { } 513static inline void tracing_start(void) { }
509static inline void tracing_stop(void) { } 514static inline void tracing_stop(void) { }
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index fe45136b32cc..2fa0901219d4 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -140,8 +140,8 @@ void crash_save_vmcoreinfo(void);
140void crash_map_reserved_pages(void); 140void crash_map_reserved_pages(void);
141void crash_unmap_reserved_pages(void); 141void crash_unmap_reserved_pages(void);
142void arch_crash_save_vmcoreinfo(void); 142void arch_crash_save_vmcoreinfo(void);
143void vmcoreinfo_append_str(const char *fmt, ...) 143__printf(1, 2)
144 __attribute__ ((format (printf, 1, 2))); 144void vmcoreinfo_append_str(const char *fmt, ...);
145unsigned long paddr_vmcoreinfo_note(void); 145unsigned long paddr_vmcoreinfo_note(void);
146 146
147#define VMCOREINFO_OSRELEASE(value) \ 147#define VMCOREINFO_OSRELEASE(value) \
diff --git a/include/linux/kmod.h b/include/linux/kmod.h
index 0da38cf7db7b..b16f65390734 100644
--- a/include/linux/kmod.h
+++ b/include/linux/kmod.h
@@ -32,8 +32,8 @@
32extern char modprobe_path[]; /* for sysctl */ 32extern char modprobe_path[]; /* for sysctl */
33/* modprobe exit status on success, -ve on error. Return value 33/* modprobe exit status on success, -ve on error. Return value
34 * usually useless though. */ 34 * usually useless though. */
35extern int __request_module(bool wait, const char *name, ...) \ 35extern __printf(2, 3)
36 __attribute__((format(printf, 2, 3))); 36int __request_module(bool wait, const char *name, ...);
37#define request_module(mod...) __request_module(true, mod) 37#define request_module(mod...) __request_module(true, mod)
38#define request_module_nowait(mod...) __request_module(false, mod) 38#define request_module_nowait(mod...) __request_module(false, mod)
39#define try_then_request_module(x, mod...) \ 39#define try_then_request_module(x, mod...) \
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 668729cc0fe9..ad81e1c51487 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -72,8 +72,8 @@ struct kobject {
72 unsigned int uevent_suppress:1; 72 unsigned int uevent_suppress:1;
73}; 73};
74 74
75extern int kobject_set_name(struct kobject *kobj, const char *name, ...) 75extern __printf(2, 3)
76 __attribute__((format(printf, 2, 3))); 76int kobject_set_name(struct kobject *kobj, const char *name, ...);
77extern int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, 77extern int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
78 va_list vargs); 78 va_list vargs);
79 79
@@ -83,15 +83,13 @@ static inline const char *kobject_name(const struct kobject *kobj)
83} 83}
84 84
85extern void kobject_init(struct kobject *kobj, struct kobj_type *ktype); 85extern void kobject_init(struct kobject *kobj, struct kobj_type *ktype);
86extern int __must_check kobject_add(struct kobject *kobj, 86extern __printf(3, 4) __must_check
87 struct kobject *parent, 87int kobject_add(struct kobject *kobj, struct kobject *parent,
88 const char *fmt, ...) 88 const char *fmt, ...);
89 __attribute__((format(printf, 3, 4))); 89extern __printf(4, 5) __must_check
90extern int __must_check kobject_init_and_add(struct kobject *kobj, 90int kobject_init_and_add(struct kobject *kobj,
91 struct kobj_type *ktype, 91 struct kobj_type *ktype, struct kobject *parent,
92 struct kobject *parent, 92 const char *fmt, ...);
93 const char *fmt, ...)
94 __attribute__((format(printf, 4, 5)));
95 93
96extern void kobject_del(struct kobject *kobj); 94extern void kobject_del(struct kobject *kobj);
97 95
@@ -212,8 +210,8 @@ int kobject_uevent(struct kobject *kobj, enum kobject_action action);
212int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, 210int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
213 char *envp[]); 211 char *envp[]);
214 212
215int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...) 213__printf(2, 3)
216 __attribute__((format (printf, 2, 3))); 214int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...);
217 215
218int kobject_action_type(const char *buf, size_t count, 216int kobject_action_type(const char *buf, size_t count,
219 enum kobject_action *type); 217 enum kobject_action *type);
@@ -226,7 +224,7 @@ static inline int kobject_uevent_env(struct kobject *kobj,
226 char *envp[]) 224 char *envp[])
227{ return 0; } 225{ return 0; }
228 226
229static inline __attribute__((format(printf, 2, 3))) 227static inline __printf(2, 3)
230int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...) 228int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...)
231{ return 0; } 229{ return 0; }
232 230
diff --git a/include/linux/kthread.h b/include/linux/kthread.h
index 1e923e5e88e8..5cac19b3a266 100644
--- a/include/linux/kthread.h
+++ b/include/linux/kthread.h
@@ -4,11 +4,11 @@
4#include <linux/err.h> 4#include <linux/err.h>
5#include <linux/sched.h> 5#include <linux/sched.h>
6 6
7__printf(4, 5)
7struct task_struct *kthread_create_on_node(int (*threadfn)(void *data), 8struct task_struct *kthread_create_on_node(int (*threadfn)(void *data),
8 void *data, 9 void *data,
9 int node, 10 int node,
10 const char namefmt[], ...) 11 const char namefmt[], ...);
11 __attribute__((format(printf, 4, 5)));
12 12
13#define kthread_create(threadfn, data, namefmt, arg...) \ 13#define kthread_create(threadfn, data, namefmt, arg...) \
14 kthread_create_on_node(threadfn, data, -1, namefmt, ##arg) 14 kthread_create_on_node(threadfn, data, -1, namefmt, ##arg)
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 23fa829bf7a3..cafc09a64fe4 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1256,13 +1256,13 @@ static inline int sata_srst_pmp(struct ata_link *link)
1256/* 1256/*
1257 * printk helpers 1257 * printk helpers
1258 */ 1258 */
1259__attribute__((format (printf, 3, 4))) 1259__printf(3, 4)
1260int ata_port_printk(const struct ata_port *ap, const char *level, 1260int ata_port_printk(const struct ata_port *ap, const char *level,
1261 const char *fmt, ...); 1261 const char *fmt, ...);
1262__attribute__((format (printf, 3, 4))) 1262__printf(3, 4)
1263int ata_link_printk(const struct ata_link *link, const char *level, 1263int ata_link_printk(const struct ata_link *link, const char *level,
1264 const char *fmt, ...); 1264 const char *fmt, ...);
1265__attribute__((format (printf, 3, 4))) 1265__printf(3, 4)
1266int ata_dev_printk(const struct ata_device *dev, const char *level, 1266int ata_dev_printk(const struct ata_device *dev, const char *level,
1267 const char *fmt, ...); 1267 const char *fmt, ...);
1268 1268
@@ -1304,10 +1304,10 @@ void ata_print_version(const struct device *dev, const char *version);
1304/* 1304/*
1305 * ata_eh_info helpers 1305 * ata_eh_info helpers
1306 */ 1306 */
1307extern void __ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...) 1307extern __printf(2, 3)
1308 __attribute__ ((format (printf, 2, 3))); 1308void __ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...);
1309extern void ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...) 1309extern __printf(2, 3)
1310 __attribute__ ((format (printf, 2, 3))); 1310void ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...);
1311extern void ata_ehi_clear_desc(struct ata_eh_info *ehi); 1311extern void ata_ehi_clear_desc(struct ata_eh_info *ehi);
1312 1312
1313static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi) 1313static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi)
@@ -1321,8 +1321,8 @@ static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi)
1321/* 1321/*
1322 * port description helpers 1322 * port description helpers
1323 */ 1323 */
1324extern void ata_port_desc(struct ata_port *ap, const char *fmt, ...) 1324extern __printf(2, 3)
1325 __attribute__ ((format (printf, 2, 3))); 1325void ata_port_desc(struct ata_port *ap, const char *fmt, ...);
1326#ifdef CONFIG_PCI 1326#ifdef CONFIG_PCI
1327extern void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset, 1327extern void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset,
1328 const char *name); 1328 const char *name);
diff --git a/include/linux/lis3lv02d.h b/include/linux/lis3lv02d.h
index d4292c8431e0..f1664c636af0 100644
--- a/include/linux/lis3lv02d.h
+++ b/include/linux/lis3lv02d.h
@@ -113,7 +113,6 @@ struct lis3lv02d_platform_data {
113 s8 axis_x; 113 s8 axis_x;
114 s8 axis_y; 114 s8 axis_y;
115 s8 axis_z; 115 s8 axis_z;
116#define LIS3_USE_REGULATOR_CTRL 0x01
117#define LIS3_USE_BLOCK_READ 0x02 116#define LIS3_USE_BLOCK_READ 0x02
118 u16 driver_features; 117 u16 driver_features;
119 int default_rate; 118 int default_rate;
diff --git a/include/linux/llist.h b/include/linux/llist.h
index 7287734e08d1..801b44b07aac 100644
--- a/include/linux/llist.h
+++ b/include/linux/llist.h
@@ -148,7 +148,7 @@ static inline struct llist_node *llist_next(struct llist_node *node)
148 * @new: new entry to be added 148 * @new: new entry to be added
149 * @head: the head for your lock-less list 149 * @head: the head for your lock-less list
150 * 150 *
151 * Return whether list is empty before adding. 151 * Returns true if the list was empty prior to adding this entry.
152 */ 152 */
153static inline bool llist_add(struct llist_node *new, struct llist_head *head) 153static inline bool llist_add(struct llist_node *new, struct llist_head *head)
154{ 154{
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 7525e38c434d..e6b843e16e81 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -80,6 +80,7 @@ extern phys_addr_t __memblock_alloc_base(phys_addr_t size,
80 phys_addr_t align, 80 phys_addr_t align,
81 phys_addr_t max_addr); 81 phys_addr_t max_addr);
82extern phys_addr_t memblock_phys_mem_size(void); 82extern phys_addr_t memblock_phys_mem_size(void);
83extern phys_addr_t memblock_start_of_DRAM(void);
83extern phys_addr_t memblock_end_of_DRAM(void); 84extern phys_addr_t memblock_end_of_DRAM(void);
84extern void memblock_enforce_memory_limit(phys_addr_t memory_limit); 85extern void memblock_enforce_memory_limit(phys_addr_t memory_limit);
85extern int memblock_is_memory(phys_addr_t addr); 86extern int memblock_is_memory(phys_addr_t addr);
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 343bd7661f2a..ac797fa03ef8 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -35,7 +35,8 @@ enum mem_cgroup_page_stat_item {
35extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, 35extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
36 struct list_head *dst, 36 struct list_head *dst,
37 unsigned long *scanned, int order, 37 unsigned long *scanned, int order,
38 int mode, struct zone *z, 38 isolate_mode_t mode,
39 struct zone *z,
39 struct mem_cgroup *mem_cont, 40 struct mem_cgroup *mem_cont,
40 int active, int file); 41 int active, int file);
41 42
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 7438071b44aa..3b3e3b8bb706 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1334,7 +1334,8 @@ extern void si_meminfo(struct sysinfo * val);
1334extern void si_meminfo_node(struct sysinfo *val, int nid); 1334extern void si_meminfo_node(struct sysinfo *val, int nid);
1335extern int after_bootmem; 1335extern int after_bootmem;
1336 1336
1337extern void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...); 1337extern __printf(3, 4)
1338void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...);
1338 1339
1339extern void setup_per_cpu_pageset(void); 1340extern void setup_per_cpu_pageset(void);
1340 1341
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index c93d00a6e95d..3e01a19a91e8 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -304,8 +304,15 @@ struct mm_struct {
304 unsigned long hiwater_rss; /* High-watermark of RSS usage */ 304 unsigned long hiwater_rss; /* High-watermark of RSS usage */
305 unsigned long hiwater_vm; /* High-water virtual memory usage */ 305 unsigned long hiwater_vm; /* High-water virtual memory usage */
306 306
307 unsigned long total_vm, locked_vm, shared_vm, exec_vm; 307 unsigned long total_vm; /* Total pages mapped */
308 unsigned long stack_vm, reserved_vm, def_flags, nr_ptes; 308 unsigned long locked_vm; /* Pages that have PG_mlocked set */
309 unsigned long pinned_vm; /* Refcount permanently increased */
310 unsigned long shared_vm; /* Shared pages (files) */
311 unsigned long exec_vm; /* VM_EXEC & ~VM_WRITE */
312 unsigned long stack_vm; /* VM_GROWSUP/DOWN */
313 unsigned long reserved_vm; /* VM_RESERVED|VM_IO pages */
314 unsigned long def_flags;
315 unsigned long nr_ptes; /* Page table pages */
309 unsigned long start_code, end_code, start_data, end_data; 316 unsigned long start_code, end_code, start_data, end_data;
310 unsigned long start_brk, brk, start_stack; 317 unsigned long start_brk, brk, start_stack;
311 unsigned long arg_start, arg_end, env_start, env_end; 318 unsigned long arg_start, arg_end, env_start, env_end;
@@ -336,9 +343,6 @@ struct mm_struct {
336 unsigned int token_priority; 343 unsigned int token_priority;
337 unsigned int last_interval; 344 unsigned int last_interval;
338 345
339 /* How many tasks sharing this mm are OOM_DISABLE */
340 atomic_t oom_disable_count;
341
342 unsigned long flags; /* Must use atomic bitops to access the bits */ 346 unsigned long flags; /* Must use atomic bitops to access the bits */
343 347
344 struct core_state *core_state; /* coredumping support */ 348 struct core_state *core_state; /* coredumping support */
diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
index 97491f78b08c..c5d52780d6a0 100644
--- a/include/linux/mmiotrace.h
+++ b/include/linux/mmiotrace.h
@@ -49,8 +49,7 @@ extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
49extern void mmiotrace_iounmap(volatile void __iomem *addr); 49extern void mmiotrace_iounmap(volatile void __iomem *addr);
50 50
51/* For anyone to insert markers. Remember trailing newline. */ 51/* For anyone to insert markers. Remember trailing newline. */
52extern int mmiotrace_printk(const char *fmt, ...) 52extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
53 __attribute__ ((format (printf, 1, 2)));
54#else /* !CONFIG_MMIOTRACE: */ 53#else /* !CONFIG_MMIOTRACE: */
55static inline int is_kmmio_active(void) 54static inline int is_kmmio_active(void)
56{ 55{
@@ -71,10 +70,7 @@ static inline void mmiotrace_iounmap(volatile void __iomem *addr)
71{ 70{
72} 71}
73 72
74static inline int mmiotrace_printk(const char *fmt, ...) 73static inline __printf(1, 2) int mmiotrace_printk(const char *fmt, ...)
75 __attribute__ ((format (printf, 1, 0)));
76
77static inline int mmiotrace_printk(const char *fmt, ...)
78{ 74{
79 return 0; 75 return 0;
80} 76}
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index be1ac8d7789b..188cb2ffe8db 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -100,6 +100,7 @@ enum zone_stat_item {
100 NR_UNSTABLE_NFS, /* NFS unstable pages */ 100 NR_UNSTABLE_NFS, /* NFS unstable pages */
101 NR_BOUNCE, 101 NR_BOUNCE,
102 NR_VMSCAN_WRITE, 102 NR_VMSCAN_WRITE,
103 NR_VMSCAN_IMMEDIATE, /* Prioritise for reclaim when writeback ends */
103 NR_WRITEBACK_TEMP, /* Writeback using temporary buffers */ 104 NR_WRITEBACK_TEMP, /* Writeback using temporary buffers */
104 NR_ISOLATED_ANON, /* Temporary isolated pages from anon lru */ 105 NR_ISOLATED_ANON, /* Temporary isolated pages from anon lru */
105 NR_ISOLATED_FILE, /* Temporary isolated pages from file lru */ 106 NR_ISOLATED_FILE, /* Temporary isolated pages from file lru */
@@ -164,6 +165,18 @@ static inline int is_unevictable_lru(enum lru_list l)
164#define LRU_ALL_EVICTABLE (LRU_ALL_FILE | LRU_ALL_ANON) 165#define LRU_ALL_EVICTABLE (LRU_ALL_FILE | LRU_ALL_ANON)
165#define LRU_ALL ((1 << NR_LRU_LISTS) - 1) 166#define LRU_ALL ((1 << NR_LRU_LISTS) - 1)
166 167
168/* Isolate inactive pages */
169#define ISOLATE_INACTIVE ((__force isolate_mode_t)0x1)
170/* Isolate active pages */
171#define ISOLATE_ACTIVE ((__force isolate_mode_t)0x2)
172/* Isolate clean file */
173#define ISOLATE_CLEAN ((__force isolate_mode_t)0x4)
174/* Isolate unmapped file */
175#define ISOLATE_UNMAPPED ((__force isolate_mode_t)0x8)
176
177/* LRU Isolation modes. */
178typedef unsigned __bitwise__ isolate_mode_t;
179
167enum zone_watermarks { 180enum zone_watermarks {
168 WMARK_MIN, 181 WMARK_MIN,
169 WMARK_LOW, 182 WMARK_LOW,
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index df1c836e6948..cbeb5867cff7 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2622,23 +2622,23 @@ static inline const char *netdev_name(const struct net_device *dev)
2622extern int __netdev_printk(const char *level, const struct net_device *dev, 2622extern int __netdev_printk(const char *level, const struct net_device *dev,
2623 struct va_format *vaf); 2623 struct va_format *vaf);
2624 2624
2625extern int netdev_printk(const char *level, const struct net_device *dev, 2625extern __printf(3, 4)
2626 const char *format, ...) 2626int netdev_printk(const char *level, const struct net_device *dev,
2627 __attribute__ ((format (printf, 3, 4))); 2627 const char *format, ...);
2628extern int netdev_emerg(const struct net_device *dev, const char *format, ...) 2628extern __printf(2, 3)
2629 __attribute__ ((format (printf, 2, 3))); 2629int netdev_emerg(const struct net_device *dev, const char *format, ...);
2630extern int netdev_alert(const struct net_device *dev, const char *format, ...) 2630extern __printf(2, 3)
2631 __attribute__ ((format (printf, 2, 3))); 2631int netdev_alert(const struct net_device *dev, const char *format, ...);
2632extern int netdev_crit(const struct net_device *dev, const char *format, ...) 2632extern __printf(2, 3)
2633 __attribute__ ((format (printf, 2, 3))); 2633int netdev_crit(const struct net_device *dev, const char *format, ...);
2634extern int netdev_err(const struct net_device *dev, const char *format, ...) 2634extern __printf(2, 3)
2635 __attribute__ ((format (printf, 2, 3))); 2635int netdev_err(const struct net_device *dev, const char *format, ...);
2636extern int netdev_warn(const struct net_device *dev, const char *format, ...) 2636extern __printf(2, 3)
2637 __attribute__ ((format (printf, 2, 3))); 2637int netdev_warn(const struct net_device *dev, const char *format, ...);
2638extern int netdev_notice(const struct net_device *dev, const char *format, ...) 2638extern __printf(2, 3)
2639 __attribute__ ((format (printf, 2, 3))); 2639int netdev_notice(const struct net_device *dev, const char *format, ...);
2640extern int netdev_info(const struct net_device *dev, const char *format, ...) 2640extern __printf(2, 3)
2641 __attribute__ ((format (printf, 2, 3))); 2641int netdev_info(const struct net_device *dev, const char *format, ...);
2642 2642
2643#define MODULE_ALIAS_NETDEV(device) \ 2643#define MODULE_ALIAS_NETDEV(device) \
2644 MODULE_ALIAS("netdev-" device) 2644 MODULE_ALIAS("netdev-" device)
diff --git a/include/linux/oom.h b/include/linux/oom.h
index 13b7b02e599a..6f9d04a85336 100644
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -40,6 +40,7 @@ enum oom_constraint {
40 CONSTRAINT_MEMCG, 40 CONSTRAINT_MEMCG,
41}; 41};
42 42
43extern void compare_swap_oom_score_adj(int old_val, int new_val);
43extern int test_set_oom_score_adj(int new_val); 44extern int test_set_oom_score_adj(int new_val);
44 45
45extern unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *mem, 46extern unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *mem,
diff --git a/include/linux/platform_data/leds-renesas-tpu.h b/include/linux/platform_data/leds-renesas-tpu.h
new file mode 100644
index 000000000000..055387086fc1
--- /dev/null
+++ b/include/linux/platform_data/leds-renesas-tpu.h
@@ -0,0 +1,14 @@
1#ifndef __LEDS_RENESAS_TPU_H__
2#define __LEDS_RENESAS_TPU_H__
3
4struct led_renesas_tpu_config {
5 char *name;
6 unsigned pin_gpio_fn;
7 unsigned pin_gpio;
8 unsigned int channel_offset;
9 unsigned int timer_bit;
10 unsigned int max_brightness;
11 unsigned int refresh_rate;
12};
13
14#endif /* __LEDS_RENESAS_TPU_H__ */
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 0101d55d9651..f0e22f75143f 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -82,22 +82,22 @@ struct va_format {
82 * Dummy printk for disabled debugging statements to use whilst maintaining 82 * Dummy printk for disabled debugging statements to use whilst maintaining
83 * gcc's format and side-effect checking. 83 * gcc's format and side-effect checking.
84 */ 84 */
85static inline __attribute__ ((format (printf, 1, 2))) 85static inline __printf(1, 2)
86int no_printk(const char *fmt, ...) 86int no_printk(const char *fmt, ...)
87{ 87{
88 return 0; 88 return 0;
89} 89}
90 90
91extern asmlinkage __attribute__ ((format (printf, 1, 2))) 91extern asmlinkage __printf(1, 2)
92void early_printk(const char *fmt, ...); 92void early_printk(const char *fmt, ...);
93 93
94extern int printk_needs_cpu(int cpu); 94extern int printk_needs_cpu(int cpu);
95extern void printk_tick(void); 95extern void printk_tick(void);
96 96
97#ifdef CONFIG_PRINTK 97#ifdef CONFIG_PRINTK
98asmlinkage __attribute__ ((format (printf, 1, 0))) 98asmlinkage __printf(1, 0)
99int vprintk(const char *fmt, va_list args); 99int vprintk(const char *fmt, va_list args);
100asmlinkage __attribute__ ((format (printf, 1, 2))) __cold 100asmlinkage __printf(1, 2) __cold
101int printk(const char *fmt, ...); 101int printk(const char *fmt, ...);
102 102
103/* 103/*
@@ -117,12 +117,12 @@ extern int kptr_restrict;
117void log_buf_kexec_setup(void); 117void log_buf_kexec_setup(void);
118void __init setup_log_buf(int early); 118void __init setup_log_buf(int early);
119#else 119#else
120static inline __attribute__ ((format (printf, 1, 0))) 120static inline __printf(1, 0)
121int vprintk(const char *s, va_list args) 121int vprintk(const char *s, va_list args)
122{ 122{
123 return 0; 123 return 0;
124} 124}
125static inline __attribute__ ((format (printf, 1, 2))) __cold 125static inline __printf(1, 2) __cold
126int printk(const char *s, ...) 126int printk(const char *s, ...)
127{ 127{
128 return 0; 128 return 0;
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index 26f9e3612e0f..d93f95e6177c 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -31,7 +31,7 @@ static inline bool is_quota_modification(struct inode *inode, struct iattr *ia)
31#define quota_error(sb, fmt, args...) \ 31#define quota_error(sb, fmt, args...) \
32 __quota_error((sb), __func__, fmt , ## args) 32 __quota_error((sb), __func__, fmt , ## args)
33 33
34extern __attribute__((format (printf, 3, 4))) 34extern __printf(3, 4)
35void __quota_error(struct super_block *sb, const char *func, 35void __quota_error(struct super_block *sb, const char *func,
36 const char *fmt, ...); 36 const char *fmt, ...);
37 37
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index be720cd2038d..0b69a4684216 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -84,8 +84,7 @@ int seq_putc(struct seq_file *m, char c);
84int seq_puts(struct seq_file *m, const char *s); 84int seq_puts(struct seq_file *m, const char *s);
85int seq_write(struct seq_file *seq, const void *data, size_t len); 85int seq_write(struct seq_file *seq, const void *data, size_t len);
86 86
87int seq_printf(struct seq_file *, const char *, ...) 87__printf(2, 3) int seq_printf(struct seq_file *, const char *, ...);
88 __attribute__ ((format (printf,2,3)));
89 88
90int seq_path(struct seq_file *, struct path *, char *); 89int seq_path(struct seq_file *, struct path *, char *);
91int seq_dentry(struct seq_file *, struct dentry *, char *); 90int seq_dentry(struct seq_file *, struct dentry *, char *);
diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h
index 790651b4e5ba..a83833a1f7a2 100644
--- a/include/linux/shrinker.h
+++ b/include/linux/shrinker.h
@@ -20,6 +20,7 @@ struct shrink_control {
20 * 'nr_to_scan' entries and attempt to free them up. It should return 20 * 'nr_to_scan' entries and attempt to free them up. It should return
21 * the number of objects which remain in the cache. If it returns -1, it means 21 * the number of objects which remain in the cache. If it returns -1, it means
22 * it cannot do any scanning at this time (eg. there is a risk of deadlock). 22 * it cannot do any scanning at this time (eg. there is a risk of deadlock).
23 * The callback must not return -1 if nr_to_scan is zero.
23 * 24 *
24 * The 'gfpmask' refers to the allocation we are currently trying to 25 * The 'gfpmask' refers to the allocation we are currently trying to
25 * fulfil. 26 * fulfil.
diff --git a/include/linux/spi/l4f00242t03.h b/include/linux/spi/l4f00242t03.h
index aee1dbda4edc..bc8677c8eba9 100644
--- a/include/linux/spi/l4f00242t03.h
+++ b/include/linux/spi/l4f00242t03.h
@@ -24,8 +24,6 @@
24struct l4f00242t03_pdata { 24struct l4f00242t03_pdata {
25 unsigned int reset_gpio; 25 unsigned int reset_gpio;
26 unsigned int data_enable_gpio; 26 unsigned int data_enable_gpio;
27 const char *io_supply; /* will be set to 1.8 V */
28 const char *core_supply; /* will be set to 2.8 V */
29}; 27};
30 28
31#endif /* _INCLUDE_LINUX_SPI_L4F00242T03_H_ */ 29#endif /* _INCLUDE_LINUX_SPI_L4F00242T03_H_ */
diff --git a/include/linux/string.h b/include/linux/string.h
index a176db2f2c85..e033564f10ba 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -114,6 +114,7 @@ extern int memcmp(const void *,const void *,__kernel_size_t);
114#ifndef __HAVE_ARCH_MEMCHR 114#ifndef __HAVE_ARCH_MEMCHR
115extern void * memchr(const void *,int,__kernel_size_t); 115extern void * memchr(const void *,int,__kernel_size_t);
116#endif 116#endif
117void *memchr_inv(const void *s, int c, size_t n);
117 118
118extern char *kstrdup(const char *s, gfp_t gfp); 119extern char *kstrdup(const char *s, gfp_t gfp);
119extern char *kstrndup(const char *s, size_t len, gfp_t gfp); 120extern char *kstrndup(const char *s, size_t len, gfp_t gfp);
diff --git a/include/linux/swap.h b/include/linux/swap.h
index c71f84bb62ec..1e22e126d2ac 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -243,15 +243,10 @@ static inline void lru_cache_add_file(struct page *page)
243 __lru_cache_add(page, LRU_INACTIVE_FILE); 243 __lru_cache_add(page, LRU_INACTIVE_FILE);
244} 244}
245 245
246/* LRU Isolation modes. */
247#define ISOLATE_INACTIVE 0 /* Isolate inactive pages. */
248#define ISOLATE_ACTIVE 1 /* Isolate active pages. */
249#define ISOLATE_BOTH 2 /* Isolate both active and inactive pages. */
250
251/* linux/mm/vmscan.c */ 246/* linux/mm/vmscan.c */
252extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order, 247extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
253 gfp_t gfp_mask, nodemask_t *mask); 248 gfp_t gfp_mask, nodemask_t *mask);
254extern int __isolate_lru_page(struct page *page, int mode, int file); 249extern int __isolate_lru_page(struct page *page, isolate_mode_t mode, int file);
255extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem, 250extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem,
256 gfp_t gfp_mask, bool noswap); 251 gfp_t gfp_mask, bool noswap);
257extern unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem, 252extern unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 1ff0ec2a5e8d..86a24b1166d1 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -844,4 +844,17 @@ asmlinkage long sys_open_by_handle_at(int mountdirfd,
844 struct file_handle __user *handle, 844 struct file_handle __user *handle,
845 int flags); 845 int flags);
846asmlinkage long sys_setns(int fd, int nstype); 846asmlinkage long sys_setns(int fd, int nstype);
847asmlinkage long sys_process_vm_readv(pid_t pid,
848 const struct iovec __user *lvec,
849 unsigned long liovcnt,
850 const struct iovec __user *rvec,
851 unsigned long riovcnt,
852 unsigned long flags);
853asmlinkage long sys_process_vm_writev(pid_t pid,
854 const struct iovec __user *lvec,
855 unsigned long liovcnt,
856 const struct iovec __user *rvec,
857 unsigned long riovcnt,
858 unsigned long flags);
859
847#endif 860#endif
diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h
index 5cf397ceb726..7dadc3df0c77 100644
--- a/include/linux/trace_seq.h
+++ b/include/linux/trace_seq.h
@@ -29,10 +29,10 @@ trace_seq_init(struct trace_seq *s)
29 * Currently only defined when tracing is enabled. 29 * Currently only defined when tracing is enabled.
30 */ 30 */
31#ifdef CONFIG_TRACING 31#ifdef CONFIG_TRACING
32extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...) 32extern __printf(2, 3)
33 __attribute__ ((format (printf, 2, 3))); 33int trace_seq_printf(struct trace_seq *s, const char *fmt, ...);
34extern int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args) 34extern __printf(2, 0)
35 __attribute__ ((format (printf, 2, 0))); 35int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args);
36extern int 36extern int
37trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary); 37trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary);
38extern int trace_print_seq(struct seq_file *m, struct trace_seq *s); 38extern int trace_print_seq(struct seq_file *m, struct trace_seq *s);
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index 9332e52ea8c2..687fb11e2010 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -13,6 +13,7 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
13#define VM_MAP 0x00000004 /* vmap()ed pages */ 13#define VM_MAP 0x00000004 /* vmap()ed pages */
14#define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */ 14#define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
15#define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */ 15#define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
16#define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
16/* bits [20..32] reserved for arch specific ioremap internals */ 17/* bits [20..32] reserved for arch specific ioremap internals */
17 18
18/* 19/*
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index e727555d4ee9..e86af08293a8 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -77,7 +77,7 @@ struct bt_power {
77#define BT_POWER_FORCE_ACTIVE_OFF 0 77#define BT_POWER_FORCE_ACTIVE_OFF 0
78#define BT_POWER_FORCE_ACTIVE_ON 1 78#define BT_POWER_FORCE_ACTIVE_ON 1
79 79
80__attribute__((format (printf, 2, 3))) 80__printf(2, 3)
81int bt_printk(const char *level, const char *fmt, ...); 81int bt_printk(const char *level, const char *fmt, ...);
82 82
83#define BT_INFO(fmt, arg...) bt_printk(KERN_INFO, pr_fmt(fmt), ##arg) 83#define BT_INFO(fmt, arg...) bt_printk(KERN_INFO, pr_fmt(fmt), ##arg)
diff --git a/include/net/netfilter/nf_log.h b/include/net/netfilter/nf_log.h
index 920997f1aff0..e991bd0a27af 100644
--- a/include/net/netfilter/nf_log.h
+++ b/include/net/netfilter/nf_log.h
@@ -53,12 +53,13 @@ int nf_log_bind_pf(u_int8_t pf, const struct nf_logger *logger);
53void nf_log_unbind_pf(u_int8_t pf); 53void nf_log_unbind_pf(u_int8_t pf);
54 54
55/* Calls the registered backend logging function */ 55/* Calls the registered backend logging function */
56__printf(7, 8)
56void nf_log_packet(u_int8_t pf, 57void nf_log_packet(u_int8_t pf,
57 unsigned int hooknum, 58 unsigned int hooknum,
58 const struct sk_buff *skb, 59 const struct sk_buff *skb,
59 const struct net_device *in, 60 const struct net_device *in,
60 const struct net_device *out, 61 const struct net_device *out,
61 const struct nf_loginfo *li, 62 const struct nf_loginfo *li,
62 const char *fmt, ...) __attribute__ ((format(printf,7,8))); 63 const char *fmt, ...);
63 64
64#endif /* _NF_LOG_H */ 65#endif /* _NF_LOG_H */
diff --git a/include/net/sock.h b/include/net/sock.h
index 5ac682f73d63..c6658bef7f32 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -76,8 +76,8 @@
76 printk(KERN_DEBUG msg); } while (0) 76 printk(KERN_DEBUG msg); } while (0)
77#else 77#else
78/* Validate arguments and do nothing */ 78/* Validate arguments and do nothing */
79static inline void __attribute__ ((format (printf, 2, 3))) 79static inline __printf(2, 3)
80SOCK_DEBUG(struct sock *sk, const char *msg, ...) 80void SOCK_DEBUG(struct sock *sk, const char *msg, ...)
81{ 81{
82} 82}
83#endif 83#endif
diff --git a/include/sound/core.h b/include/sound/core.h
index 1fa2407c966f..91d513879a78 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -326,9 +326,9 @@ void release_and_free_resource(struct resource *res);
326/* --- */ 326/* --- */
327 327
328#if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK) 328#if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK)
329__printf(4, 5)
329void __snd_printk(unsigned int level, const char *file, int line, 330void __snd_printk(unsigned int level, const char *file, int line,
330 const char *format, ...) 331 const char *format, ...);
331 __attribute__ ((format (printf, 4, 5)));
332#else 332#else
333#define __snd_printk(level, file, line, format, args...) \ 333#define __snd_printk(level, file, line, format, args...) \
334 printk(format, ##args) 334 printk(format, ##args)
diff --git a/include/sound/info.h b/include/sound/info.h
index 4e94cf1ff762..5492cc40dc57 100644
--- a/include/sound/info.h
+++ b/include/sound/info.h
@@ -110,8 +110,8 @@ void snd_card_info_read_oss(struct snd_info_buffer *buffer);
110static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {} 110static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {}
111#endif 111#endif
112 112
113int snd_iprintf(struct snd_info_buffer *buffer, const char *fmt, ...) \ 113__printf(2, 3)
114 __attribute__ ((format (printf, 2, 3))); 114int snd_iprintf(struct snd_info_buffer *buffer, const char *fmt, ...);
115int snd_info_init(void); 115int snd_info_init(void);
116int snd_info_done(void); 116int snd_info_done(void);
117 117
diff --git a/include/sound/seq_kernel.h b/include/sound/seq_kernel.h
index 3d9afb6a8c9c..f352a98ce4f4 100644
--- a/include/sound/seq_kernel.h
+++ b/include/sound/seq_kernel.h
@@ -75,9 +75,9 @@ struct snd_seq_port_callback {
75}; 75};
76 76
77/* interface for kernel client */ 77/* interface for kernel client */
78__printf(3, 4)
78int snd_seq_create_kernel_client(struct snd_card *card, int client_index, 79int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
79 const char *name_fmt, ...) 80 const char *name_fmt, ...);
80 __attribute__ ((format (printf, 3, 4)));
81int snd_seq_delete_kernel_client(int client); 81int snd_seq_delete_kernel_client(int client);
82int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, int atomic, int hop); 82int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, int atomic, int hop);
83int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event *ev, int atomic, int hop); 83int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event *ev, int atomic, int hop);
diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
index 36851f7f13da..edc4b3d25a2d 100644
--- a/include/trace/events/vmscan.h
+++ b/include/trace/events/vmscan.h
@@ -266,7 +266,7 @@ DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template,
266 unsigned long nr_lumpy_taken, 266 unsigned long nr_lumpy_taken,
267 unsigned long nr_lumpy_dirty, 267 unsigned long nr_lumpy_dirty,
268 unsigned long nr_lumpy_failed, 268 unsigned long nr_lumpy_failed,
269 int isolate_mode), 269 isolate_mode_t isolate_mode),
270 270
271 TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode), 271 TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode),
272 272
@@ -278,7 +278,7 @@ DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template,
278 __field(unsigned long, nr_lumpy_taken) 278 __field(unsigned long, nr_lumpy_taken)
279 __field(unsigned long, nr_lumpy_dirty) 279 __field(unsigned long, nr_lumpy_dirty)
280 __field(unsigned long, nr_lumpy_failed) 280 __field(unsigned long, nr_lumpy_failed)
281 __field(int, isolate_mode) 281 __field(isolate_mode_t, isolate_mode)
282 ), 282 ),
283 283
284 TP_fast_assign( 284 TP_fast_assign(
@@ -312,7 +312,7 @@ DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_lru_isolate,
312 unsigned long nr_lumpy_taken, 312 unsigned long nr_lumpy_taken,
313 unsigned long nr_lumpy_dirty, 313 unsigned long nr_lumpy_dirty,
314 unsigned long nr_lumpy_failed, 314 unsigned long nr_lumpy_failed,
315 int isolate_mode), 315 isolate_mode_t isolate_mode),
316 316
317 TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode) 317 TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode)
318 318
@@ -327,7 +327,7 @@ DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_memcg_isolate,
327 unsigned long nr_lumpy_taken, 327 unsigned long nr_lumpy_taken,
328 unsigned long nr_lumpy_dirty, 328 unsigned long nr_lumpy_dirty,
329 unsigned long nr_lumpy_failed, 329 unsigned long nr_lumpy_failed,
330 int isolate_mode), 330 isolate_mode_t isolate_mode),
331 331
332 TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode) 332 TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode)
333 333
diff --git a/include/xen/hvc-console.h b/include/xen/hvc-console.h
index 901724dc528d..b62dfef15f61 100644
--- a/include/xen/hvc-console.h
+++ b/include/xen/hvc-console.h
@@ -6,12 +6,12 @@ extern struct console xenboot_console;
6#ifdef CONFIG_HVC_XEN 6#ifdef CONFIG_HVC_XEN
7void xen_console_resume(void); 7void xen_console_resume(void);
8void xen_raw_console_write(const char *str); 8void xen_raw_console_write(const char *str);
9__attribute__((format(printf, 1, 2))) 9__printf(1, 2)
10void xen_raw_printk(const char *fmt, ...); 10void xen_raw_printk(const char *fmt, ...);
11#else 11#else
12static inline void xen_console_resume(void) { } 12static inline void xen_console_resume(void) { }
13static inline void xen_raw_console_write(const char *str) { } 13static inline void xen_raw_console_write(const char *str) { }
14static inline __attribute__((format(printf, 1, 2))) 14static inline __printf(1, 2)
15void xen_raw_printk(const char *fmt, ...) { } 15void xen_raw_printk(const char *fmt, ...) { }
16#endif 16#endif
17 17
diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h
index aceeca799fd7..b9f9fb5af0d8 100644
--- a/include/xen/xenbus.h
+++ b/include/xen/xenbus.h
@@ -156,9 +156,9 @@ int xenbus_scanf(struct xenbus_transaction t,
156 __attribute__((format(scanf, 4, 5))); 156 __attribute__((format(scanf, 4, 5)));
157 157
158/* Single printf and write: returns -errno or 0. */ 158/* Single printf and write: returns -errno or 0. */
159__printf(4, 5)
159int xenbus_printf(struct xenbus_transaction t, 160int xenbus_printf(struct xenbus_transaction t,
160 const char *dir, const char *node, const char *fmt, ...) 161 const char *dir, const char *node, const char *fmt, ...);
161 __attribute__((format(printf, 4, 5)));
162 162
163/* Generic read function: NULL-terminated triples of name, 163/* Generic read function: NULL-terminated triples of name,
164 * sprintf-style type string, and pointer. Returns 0 or errno.*/ 164 * sprintf-style type string, and pointer. Returns 0 or errno.*/
@@ -200,11 +200,11 @@ int xenbus_watch_path(struct xenbus_device *dev, const char *path,
200 struct xenbus_watch *watch, 200 struct xenbus_watch *watch,
201 void (*callback)(struct xenbus_watch *, 201 void (*callback)(struct xenbus_watch *,
202 const char **, unsigned int)); 202 const char **, unsigned int));
203__printf(4, 5)
203int xenbus_watch_pathfmt(struct xenbus_device *dev, struct xenbus_watch *watch, 204int xenbus_watch_pathfmt(struct xenbus_device *dev, struct xenbus_watch *watch,
204 void (*callback)(struct xenbus_watch *, 205 void (*callback)(struct xenbus_watch *,
205 const char **, unsigned int), 206 const char **, unsigned int),
206 const char *pathfmt, ...) 207 const char *pathfmt, ...);
207 __attribute__ ((format (printf, 4, 5)));
208 208
209int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state new_state); 209int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state new_state);
210int xenbus_grant_ring(struct xenbus_device *dev, unsigned long ring_mfn); 210int xenbus_grant_ring(struct xenbus_device *dev, unsigned long ring_mfn);
@@ -223,9 +223,9 @@ int xenbus_free_evtchn(struct xenbus_device *dev, int port);
223 223
224enum xenbus_state xenbus_read_driver_state(const char *path); 224enum xenbus_state xenbus_read_driver_state(const char *path);
225 225
226__attribute__((format(printf, 3, 4))) 226__printf(3, 4)
227void xenbus_dev_error(struct xenbus_device *dev, int err, const char *fmt, ...); 227void xenbus_dev_error(struct xenbus_device *dev, int err, const char *fmt, ...);
228__attribute__((format(printf, 3, 4))) 228__printf(3, 4)
229void xenbus_dev_fatal(struct xenbus_device *dev, int err, const char *fmt, ...); 229void xenbus_dev_fatal(struct xenbus_device *dev, int err, const char *fmt, ...);
230 230
231const char *xenbus_strstate(enum xenbus_state state); 231const char *xenbus_strstate(enum xenbus_state state);
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index ed049ea568f4..2e0ecfcc881d 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -449,8 +449,8 @@ static int wq_sleep(struct mqueue_inode_info *info, int sr,
449 set_current_state(TASK_INTERRUPTIBLE); 449 set_current_state(TASK_INTERRUPTIBLE);
450 450
451 spin_unlock(&info->lock); 451 spin_unlock(&info->lock);
452 time = schedule_hrtimeout_range_clock(timeout, 452 time = schedule_hrtimeout_range_clock(timeout, 0,
453 HRTIMER_MODE_ABS, 0, CLOCK_REALTIME); 453 HRTIMER_MODE_ABS, CLOCK_REALTIME);
454 454
455 while (ewp->state == STATE_PENDING) 455 while (ewp->state == STATE_PENDING)
456 cpu_relax(); 456 cpu_relax();
diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c
index 34872482315e..c22d8c28ad84 100644
--- a/kernel/debug/gdbstub.c
+++ b/kernel/debug/gdbstub.c
@@ -217,7 +217,7 @@ void gdbstub_msg_write(const char *s, int len)
217 217
218 /* Pack in hex chars */ 218 /* Pack in hex chars */
219 for (i = 0; i < wcount; i++) 219 for (i = 0; i < wcount; i++)
220 bufptr = pack_hex_byte(bufptr, s[i]); 220 bufptr = hex_byte_pack(bufptr, s[i]);
221 *bufptr = '\0'; 221 *bufptr = '\0';
222 222
223 /* Move up */ 223 /* Move up */
@@ -249,7 +249,7 @@ char *kgdb_mem2hex(char *mem, char *buf, int count)
249 if (err) 249 if (err)
250 return NULL; 250 return NULL;
251 while (count > 0) { 251 while (count > 0) {
252 buf = pack_hex_byte(buf, *tmp); 252 buf = hex_byte_pack(buf, *tmp);
253 tmp++; 253 tmp++;
254 count--; 254 count--;
255 } 255 }
@@ -411,14 +411,14 @@ static char *pack_threadid(char *pkt, unsigned char *id)
411 limit = id + (BUF_THREAD_ID_SIZE / 2); 411 limit = id + (BUF_THREAD_ID_SIZE / 2);
412 while (id < limit) { 412 while (id < limit) {
413 if (!lzero || *id != 0) { 413 if (!lzero || *id != 0) {
414 pkt = pack_hex_byte(pkt, *id); 414 pkt = hex_byte_pack(pkt, *id);
415 lzero = 0; 415 lzero = 0;
416 } 416 }
417 id++; 417 id++;
418 } 418 }
419 419
420 if (lzero) 420 if (lzero)
421 pkt = pack_hex_byte(pkt, 0); 421 pkt = hex_byte_pack(pkt, 0);
422 422
423 return pkt; 423 return pkt;
424} 424}
@@ -486,7 +486,7 @@ static void gdb_cmd_status(struct kgdb_state *ks)
486 dbg_remove_all_break(); 486 dbg_remove_all_break();
487 487
488 remcom_out_buffer[0] = 'S'; 488 remcom_out_buffer[0] = 'S';
489 pack_hex_byte(&remcom_out_buffer[1], ks->signo); 489 hex_byte_pack(&remcom_out_buffer[1], ks->signo);
490} 490}
491 491
492static void gdb_get_regs_helper(struct kgdb_state *ks) 492static void gdb_get_regs_helper(struct kgdb_state *ks)
@@ -954,7 +954,7 @@ int gdb_serial_stub(struct kgdb_state *ks)
954 /* Reply to host that an exception has occurred */ 954 /* Reply to host that an exception has occurred */
955 ptr = remcom_out_buffer; 955 ptr = remcom_out_buffer;
956 *ptr++ = 'T'; 956 *ptr++ = 'T';
957 ptr = pack_hex_byte(ptr, ks->signo); 957 ptr = hex_byte_pack(ptr, ks->signo);
958 ptr += strlen(strcpy(ptr, "thread:")); 958 ptr += strlen(strcpy(ptr, "thread:"));
959 int_to_threadref(thref, shadow_pid(current->pid)); 959 int_to_threadref(thref, shadow_pid(current->pid));
960 ptr = pack_threadid(ptr, thref); 960 ptr = pack_threadid(ptr, thref);
diff --git a/kernel/events/core.c b/kernel/events/core.c
index d1a1bee35228..12a0287e0358 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3544,7 +3544,7 @@ static void perf_mmap_close(struct vm_area_struct *vma)
3544 struct ring_buffer *rb = event->rb; 3544 struct ring_buffer *rb = event->rb;
3545 3545
3546 atomic_long_sub((size >> PAGE_SHIFT) + 1, &user->locked_vm); 3546 atomic_long_sub((size >> PAGE_SHIFT) + 1, &user->locked_vm);
3547 vma->vm_mm->locked_vm -= event->mmap_locked; 3547 vma->vm_mm->pinned_vm -= event->mmap_locked;
3548 rcu_assign_pointer(event->rb, NULL); 3548 rcu_assign_pointer(event->rb, NULL);
3549 mutex_unlock(&event->mmap_mutex); 3549 mutex_unlock(&event->mmap_mutex);
3550 3550
@@ -3625,7 +3625,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
3625 3625
3626 lock_limit = rlimit(RLIMIT_MEMLOCK); 3626 lock_limit = rlimit(RLIMIT_MEMLOCK);
3627 lock_limit >>= PAGE_SHIFT; 3627 lock_limit >>= PAGE_SHIFT;
3628 locked = vma->vm_mm->locked_vm + extra; 3628 locked = vma->vm_mm->pinned_vm + extra;
3629 3629
3630 if ((locked > lock_limit) && perf_paranoid_tracepoint_raw() && 3630 if ((locked > lock_limit) && perf_paranoid_tracepoint_raw() &&
3631 !capable(CAP_IPC_LOCK)) { 3631 !capable(CAP_IPC_LOCK)) {
@@ -3651,7 +3651,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
3651 atomic_long_add(user_extra, &user->locked_vm); 3651 atomic_long_add(user_extra, &user->locked_vm);
3652 event->mmap_locked = extra; 3652 event->mmap_locked = extra;
3653 event->mmap_user = get_current_user(); 3653 event->mmap_user = get_current_user();
3654 vma->vm_mm->locked_vm += event->mmap_locked; 3654 vma->vm_mm->pinned_vm += event->mmap_locked;
3655 3655
3656unlock: 3656unlock:
3657 if (!ret) 3657 if (!ret)
diff --git a/kernel/exit.c b/kernel/exit.c
index 2913b3509d42..d0b7d988f873 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -681,8 +681,6 @@ static void exit_mm(struct task_struct * tsk)
681 enter_lazy_tlb(mm, current); 681 enter_lazy_tlb(mm, current);
682 /* We don't want this task to be frozen prematurely */ 682 /* We don't want this task to be frozen prematurely */
683 clear_freeze_flag(tsk); 683 clear_freeze_flag(tsk);
684 if (tsk->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
685 atomic_dec(&mm->oom_disable_count);
686 task_unlock(tsk); 684 task_unlock(tsk);
687 mm_update_next_owner(mm); 685 mm_update_next_owner(mm);
688 mmput(mm); 686 mmput(mm);
diff --git a/kernel/fork.c b/kernel/fork.c
index 8e6b6f4fb272..70d76191afb9 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -501,7 +501,6 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p)
501 mm->cached_hole_size = ~0UL; 501 mm->cached_hole_size = ~0UL;
502 mm_init_aio(mm); 502 mm_init_aio(mm);
503 mm_init_owner(mm, p); 503 mm_init_owner(mm, p);
504 atomic_set(&mm->oom_disable_count, 0);
505 504
506 if (likely(!mm_alloc_pgd(mm))) { 505 if (likely(!mm_alloc_pgd(mm))) {
507 mm->def_flags = 0; 506 mm->def_flags = 0;
@@ -816,8 +815,6 @@ good_mm:
816 /* Initializing for Swap token stuff */ 815 /* Initializing for Swap token stuff */
817 mm->token_priority = 0; 816 mm->token_priority = 0;
818 mm->last_interval = 0; 817 mm->last_interval = 0;
819 if (tsk->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
820 atomic_inc(&mm->oom_disable_count);
821 818
822 tsk->mm = mm; 819 tsk->mm = mm;
823 tsk->active_mm = mm; 820 tsk->active_mm = mm;
@@ -1391,13 +1388,8 @@ bad_fork_cleanup_io:
1391bad_fork_cleanup_namespaces: 1388bad_fork_cleanup_namespaces:
1392 exit_task_namespaces(p); 1389 exit_task_namespaces(p);
1393bad_fork_cleanup_mm: 1390bad_fork_cleanup_mm:
1394 if (p->mm) { 1391 if (p->mm)
1395 task_lock(p);
1396 if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
1397 atomic_dec(&p->mm->oom_disable_count);
1398 task_unlock(p);
1399 mmput(p->mm); 1392 mmput(p->mm);
1400 }
1401bad_fork_cleanup_signal: 1393bad_fork_cleanup_signal:
1402 if (!(clone_flags & CLONE_THREAD)) 1394 if (!(clone_flags & CLONE_THREAD))
1403 free_signal_struct(p->signal); 1395 free_signal_struct(p->signal);
diff --git a/kernel/printk.c b/kernel/printk.c
index b7da18391c38..1455a0d4eedd 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -532,6 +532,9 @@ static int __init ignore_loglevel_setup(char *str)
532} 532}
533 533
534early_param("ignore_loglevel", ignore_loglevel_setup); 534early_param("ignore_loglevel", ignore_loglevel_setup);
535module_param_named(ignore_loglevel, ignore_loglevel, bool, S_IRUGO | S_IWUSR);
536MODULE_PARM_DESC(ignore_loglevel, "ignore loglevel setting, to"
537 "print all kernel messages to the console.");
535 538
536/* 539/*
537 * Write out chars from start to end - 1 inclusive 540 * Write out chars from start to end - 1 inclusive
@@ -592,9 +595,6 @@ static size_t log_prefix(const char *p, unsigned int *level, char *special)
592 /* multi digit including the level and facility number */ 595 /* multi digit including the level and facility number */
593 char *endp = NULL; 596 char *endp = NULL;
594 597
595 if (p[1] < '0' && p[1] > '9')
596 return 0;
597
598 lev = (simple_strtoul(&p[1], &endp, 10) & 7); 598 lev = (simple_strtoul(&p[1], &endp, 10) & 7);
599 if (endp == NULL || endp[0] != '>') 599 if (endp == NULL || endp[0] != '>')
600 return 0; 600 return 0;
@@ -1108,6 +1108,10 @@ static int __init console_suspend_disable(char *str)
1108 return 1; 1108 return 1;
1109} 1109}
1110__setup("no_console_suspend", console_suspend_disable); 1110__setup("no_console_suspend", console_suspend_disable);
1111module_param_named(console_suspend, console_suspend_enabled,
1112 bool, S_IRUGO | S_IWUSR);
1113MODULE_PARM_DESC(console_suspend, "suspend console during suspend"
1114 " and hibernate operations");
1111 1115
1112/** 1116/**
1113 * suspend_console - suspend the console subsystem 1117 * suspend_console - suspend the console subsystem
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index ba5070ce5765..5b0951aa0496 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -41,6 +41,7 @@ struct cpu_stopper {
41}; 41};
42 42
43static DEFINE_PER_CPU(struct cpu_stopper, cpu_stopper); 43static DEFINE_PER_CPU(struct cpu_stopper, cpu_stopper);
44static bool stop_machine_initialized = false;
44 45
45static void cpu_stop_init_done(struct cpu_stop_done *done, unsigned int nr_todo) 46static void cpu_stop_init_done(struct cpu_stop_done *done, unsigned int nr_todo)
46{ 47{
@@ -386,6 +387,8 @@ static int __init cpu_stop_init(void)
386 cpu_stop_cpu_callback(&cpu_stop_cpu_notifier, CPU_ONLINE, bcpu); 387 cpu_stop_cpu_callback(&cpu_stop_cpu_notifier, CPU_ONLINE, bcpu);
387 register_cpu_notifier(&cpu_stop_cpu_notifier); 388 register_cpu_notifier(&cpu_stop_cpu_notifier);
388 389
390 stop_machine_initialized = true;
391
389 return 0; 392 return 0;
390} 393}
391early_initcall(cpu_stop_init); 394early_initcall(cpu_stop_init);
@@ -485,6 +488,25 @@ int __stop_machine(int (*fn)(void *), void *data, const struct cpumask *cpus)
485 .num_threads = num_online_cpus(), 488 .num_threads = num_online_cpus(),
486 .active_cpus = cpus }; 489 .active_cpus = cpus };
487 490
491 if (!stop_machine_initialized) {
492 /*
493 * Handle the case where stop_machine() is called
494 * early in boot before stop_machine() has been
495 * initialized.
496 */
497 unsigned long flags;
498 int ret;
499
500 WARN_ON_ONCE(smdata.num_threads != 1);
501
502 local_irq_save(flags);
503 hard_irq_disable();
504 ret = (*fn)(data);
505 local_irq_restore(flags);
506
507 return ret;
508 }
509
488 /* Set the initial state and stop all online cpus. */ 510 /* Set the initial state and stop all online cpus. */
489 set_state(&smdata, STOPMACHINE_PREPARE); 511 set_state(&smdata, STOPMACHINE_PREPARE);
490 return stop_cpus(cpu_online_mask, stop_machine_cpu_stop, &smdata); 512 return stop_cpus(cpu_online_mask, stop_machine_cpu_stop, &smdata);
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index a9a5de07c4f1..47bfa16430d7 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -145,6 +145,10 @@ cond_syscall(sys_io_submit);
145cond_syscall(sys_io_cancel); 145cond_syscall(sys_io_cancel);
146cond_syscall(sys_io_getevents); 146cond_syscall(sys_io_getevents);
147cond_syscall(sys_syslog); 147cond_syscall(sys_syslog);
148cond_syscall(sys_process_vm_readv);
149cond_syscall(sys_process_vm_writev);
150cond_syscall(compat_sys_process_vm_readv);
151cond_syscall(compat_sys_process_vm_writev);
148 152
149/* arch-specific weak syscall entries */ 153/* arch-specific weak syscall entries */
150cond_syscall(sys_pciconfig_read); 154cond_syscall(sys_pciconfig_read);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 2fe2bc2a57ea..ae2719643854 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -57,6 +57,7 @@
57#include <linux/pipe_fs_i.h> 57#include <linux/pipe_fs_i.h>
58#include <linux/oom.h> 58#include <linux/oom.h>
59#include <linux/kmod.h> 59#include <linux/kmod.h>
60#include <linux/capability.h>
60 61
61#include <asm/uaccess.h> 62#include <asm/uaccess.h>
62#include <asm/processor.h> 63#include <asm/processor.h>
@@ -134,6 +135,7 @@ static int minolduid;
134static int min_percpu_pagelist_fract = 8; 135static int min_percpu_pagelist_fract = 8;
135 136
136static int ngroups_max = NGROUPS_MAX; 137static int ngroups_max = NGROUPS_MAX;
138static const int cap_last_cap = CAP_LAST_CAP;
137 139
138#ifdef CONFIG_INOTIFY_USER 140#ifdef CONFIG_INOTIFY_USER
139#include <linux/inotify.h> 141#include <linux/inotify.h>
@@ -732,6 +734,13 @@ static struct ctl_table kern_table[] = {
732 .mode = 0444, 734 .mode = 0444,
733 .proc_handler = proc_dointvec, 735 .proc_handler = proc_dointvec,
734 }, 736 },
737 {
738 .procname = "cap_last_cap",
739 .data = (void *)&cap_last_cap,
740 .maxlen = sizeof(int),
741 .mode = 0444,
742 .proc_handler = proc_dointvec,
743 },
735#if defined(CONFIG_LOCKUP_DETECTOR) 744#if defined(CONFIG_LOCKUP_DETECTOR)
736 { 745 {
737 .procname = "watchdog", 746 .procname = "watchdog",
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index d680381b0e9c..1d7bca7f4f52 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -481,6 +481,8 @@ static void watchdog_disable(int cpu)
481 } 481 }
482} 482}
483 483
484/* sysctl functions */
485#ifdef CONFIG_SYSCTL
484static void watchdog_enable_all_cpus(void) 486static void watchdog_enable_all_cpus(void)
485{ 487{
486 int cpu; 488 int cpu;
@@ -510,8 +512,6 @@ static void watchdog_disable_all_cpus(void)
510} 512}
511 513
512 514
513/* sysctl functions */
514#ifdef CONFIG_SYSCTL
515/* 515/*
516 * proc handler for /proc/sys/kernel/nmi_watchdog,watchdog_thresh 516 * proc handler for /proc/sys/kernel/nmi_watchdog,watchdog_thresh
517 */ 517 */
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index c583a57cddfe..82928f5ea049 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -248,8 +248,9 @@ config DEFAULT_HUNG_TASK_TIMEOUT
248 to determine when a task has become non-responsive and should 248 to determine when a task has become non-responsive and should
249 be considered hung. 249 be considered hung.
250 250
251 It can be adjusted at runtime via the kernel.hung_task_timeout 251 It can be adjusted at runtime via the kernel.hung_task_timeout_secs
252 sysctl or by writing a value to /proc/sys/kernel/hung_task_timeout. 252 sysctl or by writing a value to
253 /proc/sys/kernel/hung_task_timeout_secs.
253 254
254 A timeout of 0 disables the check. The default is two minutes. 255 A timeout of 0 disables the check. The default is two minutes.
255 Keeping the default should be fine in most cases. 256 Keeping the default should be fine in most cases.
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 2f4412e4d071..0d4a127dd9b3 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -419,7 +419,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
419{ 419{
420 int c, old_c, totaldigits, ndigits, nchunks, nbits; 420 int c, old_c, totaldigits, ndigits, nchunks, nbits;
421 u32 chunk; 421 u32 chunk;
422 const char __user *ubuf = buf; 422 const char __user __force *ubuf = (const char __user __force *)buf;
423 423
424 bitmap_zero(maskp, nmaskbits); 424 bitmap_zero(maskp, nmaskbits);
425 425
@@ -504,7 +504,9 @@ int bitmap_parse_user(const char __user *ubuf,
504{ 504{
505 if (!access_ok(VERIFY_READ, ubuf, ulen)) 505 if (!access_ok(VERIFY_READ, ubuf, ulen))
506 return -EFAULT; 506 return -EFAULT;
507 return __bitmap_parse((const char *)ubuf, ulen, 1, maskp, nmaskbits); 507 return __bitmap_parse((const char __force *)ubuf,
508 ulen, 1, maskp, nmaskbits);
509
508} 510}
509EXPORT_SYMBOL(bitmap_parse_user); 511EXPORT_SYMBOL(bitmap_parse_user);
510 512
@@ -594,7 +596,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
594{ 596{
595 unsigned a, b; 597 unsigned a, b;
596 int c, old_c, totaldigits; 598 int c, old_c, totaldigits;
597 const char __user *ubuf = buf; 599 const char __user __force *ubuf = (const char __user __force *)buf;
598 int exp_digit, in_range; 600 int exp_digit, in_range;
599 601
600 totaldigits = c = 0; 602 totaldigits = c = 0;
@@ -694,7 +696,7 @@ int bitmap_parselist_user(const char __user *ubuf,
694{ 696{
695 if (!access_ok(VERIFY_READ, ubuf, ulen)) 697 if (!access_ok(VERIFY_READ, ubuf, ulen))
696 return -EFAULT; 698 return -EFAULT;
697 return __bitmap_parselist((const char *)ubuf, 699 return __bitmap_parselist((const char __force *)ubuf,
698 ulen, 1, maskp, nmaskbits); 700 ulen, 1, maskp, nmaskbits);
699} 701}
700EXPORT_SYMBOL(bitmap_parselist_user); 702EXPORT_SYMBOL(bitmap_parselist_user);
diff --git a/lib/idr.c b/lib/idr.c
index 5acf9bb10968..bbf211aea4eb 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -767,8 +767,8 @@ EXPORT_SYMBOL(ida_pre_get);
767 * @starting_id: id to start search at 767 * @starting_id: id to start search at
768 * @p_id: pointer to the allocated handle 768 * @p_id: pointer to the allocated handle
769 * 769 *
770 * Allocate new ID above or equal to @ida. It should be called with 770 * Allocate new ID above or equal to @starting_id. It should be called
771 * any required locks. 771 * with any required locks.
772 * 772 *
773 * If memory is required, it will return %-EAGAIN, you should unlock 773 * If memory is required, it will return %-EAGAIN, you should unlock
774 * and go back to the ida_pre_get() call. If the ida is full, it will 774 * and go back to the ida_pre_get() call. If the ida is full, it will
diff --git a/lib/kstrtox.c b/lib/kstrtox.c
index 5e066759f551..7a94c8f14e29 100644
--- a/lib/kstrtox.c
+++ b/lib/kstrtox.c
@@ -18,26 +18,40 @@
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/types.h> 19#include <linux/types.h>
20#include <asm/uaccess.h> 20#include <asm/uaccess.h>
21#include "kstrtox.h"
21 22
22static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) 23const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)
23{ 24{
24 unsigned long long acc; 25 if (*base == 0) {
25 int ok;
26
27 if (base == 0) {
28 if (s[0] == '0') { 26 if (s[0] == '0') {
29 if (_tolower(s[1]) == 'x' && isxdigit(s[2])) 27 if (_tolower(s[1]) == 'x' && isxdigit(s[2]))
30 base = 16; 28 *base = 16;
31 else 29 else
32 base = 8; 30 *base = 8;
33 } else 31 } else
34 base = 10; 32 *base = 10;
35 } 33 }
36 if (base == 16 && s[0] == '0' && _tolower(s[1]) == 'x') 34 if (*base == 16 && s[0] == '0' && _tolower(s[1]) == 'x')
37 s += 2; 35 s += 2;
36 return s;
37}
38 38
39 acc = 0; 39/*
40 ok = 0; 40 * Convert non-negative integer string representation in explicitly given radix
41 * to an integer.
42 * Return number of characters consumed maybe or-ed with overflow bit.
43 * If overflow occurs, result integer (incorrect) is still returned.
44 *
45 * Don't you dare use this function.
46 */
47unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *res)
48{
49 unsigned int rv;
50 int overflow;
51
52 *res = 0;
53 rv = 0;
54 overflow = 0;
41 while (*s) { 55 while (*s) {
42 unsigned int val; 56 unsigned int val;
43 57
@@ -45,23 +59,40 @@ static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res)
45 val = *s - '0'; 59 val = *s - '0';
46 else if ('a' <= _tolower(*s) && _tolower(*s) <= 'f') 60 else if ('a' <= _tolower(*s) && _tolower(*s) <= 'f')
47 val = _tolower(*s) - 'a' + 10; 61 val = _tolower(*s) - 'a' + 10;
48 else if (*s == '\n' && *(s + 1) == '\0')
49 break;
50 else 62 else
51 return -EINVAL; 63 break;
52 64
53 if (val >= base) 65 if (val >= base)
54 return -EINVAL; 66 break;
55 if (acc > div_u64(ULLONG_MAX - val, base)) 67 if (*res > div_u64(ULLONG_MAX - val, base))
56 return -ERANGE; 68 overflow = 1;
57 acc = acc * base + val; 69 *res = *res * base + val;
58 ok = 1; 70 rv++;
59
60 s++; 71 s++;
61 } 72 }
62 if (!ok) 73 if (overflow)
74 rv |= KSTRTOX_OVERFLOW;
75 return rv;
76}
77
78static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res)
79{
80 unsigned long long _res;
81 unsigned int rv;
82
83 s = _parse_integer_fixup_radix(s, &base);
84 rv = _parse_integer(s, base, &_res);
85 if (rv & KSTRTOX_OVERFLOW)
86 return -ERANGE;
87 rv &= ~KSTRTOX_OVERFLOW;
88 if (rv == 0)
89 return -EINVAL;
90 s += rv;
91 if (*s == '\n')
92 s++;
93 if (*s)
63 return -EINVAL; 94 return -EINVAL;
64 *res = acc; 95 *res = _res;
65 return 0; 96 return 0;
66} 97}
67 98
diff --git a/lib/kstrtox.h b/lib/kstrtox.h
new file mode 100644
index 000000000000..f13eeeaf441d
--- /dev/null
+++ b/lib/kstrtox.h
@@ -0,0 +1,8 @@
1#ifndef _LIB_KSTRTOX_H
2#define _LIB_KSTRTOX_H
3
4#define KSTRTOX_OVERFLOW (1U << 31)
5const char *_parse_integer_fixup_radix(const char *s, unsigned int *base);
6unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *res);
7
8#endif
diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c
index f087105ed914..f8a3f1a829b8 100644
--- a/lib/percpu_counter.c
+++ b/lib/percpu_counter.c
@@ -10,8 +10,10 @@
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/debugobjects.h> 11#include <linux/debugobjects.h>
12 12
13#ifdef CONFIG_HOTPLUG_CPU
13static LIST_HEAD(percpu_counters); 14static LIST_HEAD(percpu_counters);
14static DEFINE_MUTEX(percpu_counters_lock); 15static DEFINE_MUTEX(percpu_counters_lock);
16#endif
15 17
16#ifdef CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER 18#ifdef CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER
17 19
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index a2f9da59c197..d9df7454519c 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -576,7 +576,6 @@ int radix_tree_tag_get(struct radix_tree_root *root,
576{ 576{
577 unsigned int height, shift; 577 unsigned int height, shift;
578 struct radix_tree_node *node; 578 struct radix_tree_node *node;
579 int saw_unset_tag = 0;
580 579
581 /* check the root's tag bit */ 580 /* check the root's tag bit */
582 if (!root_tag_get(root, tag)) 581 if (!root_tag_get(root, tag))
@@ -603,15 +602,10 @@ int radix_tree_tag_get(struct radix_tree_root *root,
603 return 0; 602 return 0;
604 603
605 offset = (index >> shift) & RADIX_TREE_MAP_MASK; 604 offset = (index >> shift) & RADIX_TREE_MAP_MASK;
606
607 /*
608 * This is just a debug check. Later, we can bale as soon as
609 * we see an unset tag.
610 */
611 if (!tag_get(node, tag, offset)) 605 if (!tag_get(node, tag, offset))
612 saw_unset_tag = 1; 606 return 0;
613 if (height == 1) 607 if (height == 1)
614 return !!tag_get(node, tag, offset); 608 return 1;
615 node = rcu_dereference_raw(node->slots[offset]); 609 node = rcu_dereference_raw(node->slots[offset]);
616 shift -= RADIX_TREE_MAP_SHIFT; 610 shift -= RADIX_TREE_MAP_SHIFT;
617 height--; 611 height--;
diff --git a/lib/spinlock_debug.c b/lib/spinlock_debug.c
index 4755b98b6dfb..5f3eacdd6178 100644
--- a/lib/spinlock_debug.c
+++ b/lib/spinlock_debug.c
@@ -49,13 +49,10 @@ void __rwlock_init(rwlock_t *lock, const char *name,
49 49
50EXPORT_SYMBOL(__rwlock_init); 50EXPORT_SYMBOL(__rwlock_init);
51 51
52static void spin_bug(raw_spinlock_t *lock, const char *msg) 52static void spin_dump(raw_spinlock_t *lock, const char *msg)
53{ 53{
54 struct task_struct *owner = NULL; 54 struct task_struct *owner = NULL;
55 55
56 if (!debug_locks_off())
57 return;
58
59 if (lock->owner && lock->owner != SPINLOCK_OWNER_INIT) 56 if (lock->owner && lock->owner != SPINLOCK_OWNER_INIT)
60 owner = lock->owner; 57 owner = lock->owner;
61 printk(KERN_EMERG "BUG: spinlock %s on CPU#%d, %s/%d\n", 58 printk(KERN_EMERG "BUG: spinlock %s on CPU#%d, %s/%d\n",
@@ -70,6 +67,14 @@ static void spin_bug(raw_spinlock_t *lock, const char *msg)
70 dump_stack(); 67 dump_stack();
71} 68}
72 69
70static void spin_bug(raw_spinlock_t *lock, const char *msg)
71{
72 if (!debug_locks_off())
73 return;
74
75 spin_dump(lock, msg);
76}
77
73#define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg) 78#define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg)
74 79
75static inline void 80static inline void
@@ -113,11 +118,7 @@ static void __spin_lock_debug(raw_spinlock_t *lock)
113 /* lockup suspected: */ 118 /* lockup suspected: */
114 if (print_once) { 119 if (print_once) {
115 print_once = 0; 120 print_once = 0;
116 printk(KERN_EMERG "BUG: spinlock lockup on CPU#%d, " 121 spin_dump(lock, "lockup");
117 "%s/%d, %p\n",
118 raw_smp_processor_id(), current->comm,
119 task_pid_nr(current), lock);
120 dump_stack();
121#ifdef CONFIG_SMP 122#ifdef CONFIG_SMP
122 trigger_all_cpu_backtrace(); 123 trigger_all_cpu_backtrace();
123#endif 124#endif
diff --git a/lib/string.c b/lib/string.c
index 01fad9b203e1..dc4a86341f91 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -360,7 +360,6 @@ char *strim(char *s)
360 size_t size; 360 size_t size;
361 char *end; 361 char *end;
362 362
363 s = skip_spaces(s);
364 size = strlen(s); 363 size = strlen(s);
365 if (!size) 364 if (!size)
366 return s; 365 return s;
@@ -370,7 +369,7 @@ char *strim(char *s)
370 end--; 369 end--;
371 *(end + 1) = '\0'; 370 *(end + 1) = '\0';
372 371
373 return s; 372 return skip_spaces(s);
374} 373}
375EXPORT_SYMBOL(strim); 374EXPORT_SYMBOL(strim);
376 375
@@ -756,3 +755,57 @@ void *memchr(const void *s, int c, size_t n)
756} 755}
757EXPORT_SYMBOL(memchr); 756EXPORT_SYMBOL(memchr);
758#endif 757#endif
758
759static void *check_bytes8(const u8 *start, u8 value, unsigned int bytes)
760{
761 while (bytes) {
762 if (*start != value)
763 return (void *)start;
764 start++;
765 bytes--;
766 }
767 return NULL;
768}
769
770/**
771 * memchr_inv - Find an unmatching character in an area of memory.
772 * @start: The memory area
773 * @c: Find a character other than c
774 * @bytes: The size of the area.
775 *
776 * returns the address of the first character other than @c, or %NULL
777 * if the whole buffer contains just @c.
778 */
779void *memchr_inv(const void *start, int c, size_t bytes)
780{
781 u8 value = c;
782 u64 value64;
783 unsigned int words, prefix;
784
785 if (bytes <= 16)
786 return check_bytes8(start, value, bytes);
787
788 value64 = value | value << 8 | value << 16 | value << 24;
789 value64 = (value64 & 0xffffffff) | value64 << 32;
790 prefix = 8 - ((unsigned long)start) % 8;
791
792 if (prefix) {
793 u8 *r = check_bytes8(start, value, prefix);
794 if (r)
795 return r;
796 start += prefix;
797 bytes -= prefix;
798 }
799
800 words = bytes / 8;
801
802 while (words) {
803 if (*(u64 *)start != value64)
804 return check_bytes8(start, value, 8);
805 start += 8;
806 words--;
807 }
808
809 return check_bytes8(start, value, bytes % 8);
810}
811EXPORT_SYMBOL(memchr_inv);
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index d7222a9c8267..993599e66e5a 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -31,17 +31,7 @@
31#include <asm/div64.h> 31#include <asm/div64.h>
32#include <asm/sections.h> /* for dereference_function_descriptor() */ 32#include <asm/sections.h> /* for dereference_function_descriptor() */
33 33
34static unsigned int simple_guess_base(const char *cp) 34#include "kstrtox.h"
35{
36 if (cp[0] == '0') {
37 if (_tolower(cp[1]) == 'x' && isxdigit(cp[2]))
38 return 16;
39 else
40 return 8;
41 } else {
42 return 10;
43 }
44}
45 35
46/** 36/**
47 * simple_strtoull - convert a string to an unsigned long long 37 * simple_strtoull - convert a string to an unsigned long long
@@ -51,23 +41,14 @@ static unsigned int simple_guess_base(const char *cp)
51 */ 41 */
52unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base) 42unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base)
53{ 43{
54 unsigned long long result = 0; 44 unsigned long long result;
45 unsigned int rv;
55 46
56 if (!base) 47 cp = _parse_integer_fixup_radix(cp, &base);
57 base = simple_guess_base(cp); 48 rv = _parse_integer(cp, base, &result);
49 /* FIXME */
50 cp += (rv & ~KSTRTOX_OVERFLOW);
58 51
59 if (base == 16 && cp[0] == '0' && _tolower(cp[1]) == 'x')
60 cp += 2;
61
62 while (isxdigit(*cp)) {
63 unsigned int value;
64
65 value = isdigit(*cp) ? *cp - '0' : _tolower(*cp) - 'a' + 10;
66 if (value >= base)
67 break;
68 result = result * base + value;
69 cp++;
70 }
71 if (endp) 52 if (endp)
72 *endp = (char *)cp; 53 *endp = (char *)cp;
73 54
@@ -566,7 +547,7 @@ char *mac_address_string(char *buf, char *end, u8 *addr,
566 } 547 }
567 548
568 for (i = 0; i < 6; i++) { 549 for (i = 0; i < 6; i++) {
569 p = pack_hex_byte(p, addr[i]); 550 p = hex_byte_pack(p, addr[i]);
570 if (fmt[0] == 'M' && i != 5) 551 if (fmt[0] == 'M' && i != 5)
571 *p++ = separator; 552 *p++ = separator;
572 } 553 }
@@ -686,13 +667,13 @@ char *ip6_compressed_string(char *p, const char *addr)
686 lo = word & 0xff; 667 lo = word & 0xff;
687 if (hi) { 668 if (hi) {
688 if (hi > 0x0f) 669 if (hi > 0x0f)
689 p = pack_hex_byte(p, hi); 670 p = hex_byte_pack(p, hi);
690 else 671 else
691 *p++ = hex_asc_lo(hi); 672 *p++ = hex_asc_lo(hi);
692 p = pack_hex_byte(p, lo); 673 p = hex_byte_pack(p, lo);
693 } 674 }
694 else if (lo > 0x0f) 675 else if (lo > 0x0f)
695 p = pack_hex_byte(p, lo); 676 p = hex_byte_pack(p, lo);
696 else 677 else
697 *p++ = hex_asc_lo(lo); 678 *p++ = hex_asc_lo(lo);
698 needcolon = true; 679 needcolon = true;
@@ -714,8 +695,8 @@ char *ip6_string(char *p, const char *addr, const char *fmt)
714 int i; 695 int i;
715 696
716 for (i = 0; i < 8; i++) { 697 for (i = 0; i < 8; i++) {
717 p = pack_hex_byte(p, *addr++); 698 p = hex_byte_pack(p, *addr++);
718 p = pack_hex_byte(p, *addr++); 699 p = hex_byte_pack(p, *addr++);
719 if (fmt[0] == 'I' && i != 7) 700 if (fmt[0] == 'I' && i != 7)
720 *p++ = ':'; 701 *p++ = ':';
721 } 702 }
@@ -773,7 +754,7 @@ char *uuid_string(char *buf, char *end, const u8 *addr,
773 } 754 }
774 755
775 for (i = 0; i < 16; i++) { 756 for (i = 0; i < 16; i++) {
776 p = pack_hex_byte(p, addr[index[i]]); 757 p = hex_byte_pack(p, addr[index[i]]);
777 switch (i) { 758 switch (i) {
778 case 3: 759 case 3:
779 case 5: 760 case 5:
diff --git a/mm/Kconfig b/mm/Kconfig
index f2f1ca19ed53..011b110365c8 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -131,6 +131,9 @@ config SPARSEMEM_VMEMMAP
131config HAVE_MEMBLOCK 131config HAVE_MEMBLOCK
132 boolean 132 boolean
133 133
134config NO_BOOTMEM
135 boolean
136
134# eventually, we can have this option just 'select SPARSEMEM' 137# eventually, we can have this option just 'select SPARSEMEM'
135config MEMORY_HOTPLUG 138config MEMORY_HOTPLUG
136 bool "Allow for memory hot-add" 139 bool "Allow for memory hot-add"
diff --git a/mm/Makefile b/mm/Makefile
index 836e4163c1bf..50ec00ef2a0e 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -5,7 +5,8 @@
5mmu-y := nommu.o 5mmu-y := nommu.o
6mmu-$(CONFIG_MMU) := fremap.o highmem.o madvise.o memory.o mincore.o \ 6mmu-$(CONFIG_MMU) := fremap.o highmem.o madvise.o memory.o mincore.o \
7 mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \ 7 mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \
8 vmalloc.o pagewalk.o pgtable-generic.o 8 vmalloc.o pagewalk.o pgtable-generic.o \
9 process_vm_access.o
9 10
10obj-y := filemap.o mempool.o oom_kill.o fadvise.o \ 11obj-y := filemap.o mempool.o oom_kill.o fadvise.o \
11 maccess.o page_alloc.o page-writeback.o \ 12 maccess.o page_alloc.o page-writeback.o \
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index a87da524a4a0..7520ef0bfd47 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -404,9 +404,8 @@ static int bdi_forker_thread(void *ptr)
404 /* 404 /*
405 * In the following loop we are going to check whether we have 405 * In the following loop we are going to check whether we have
406 * some work to do without any synchronization with tasks 406 * some work to do without any synchronization with tasks
407 * waking us up to do work for them. So we have to set task 407 * waking us up to do work for them. Set the task state here
408 * state already here so that we don't miss wakeups coming 408 * so that we don't miss wakeups after verifying conditions.
409 * after we verify some condition.
410 */ 409 */
411 set_current_state(TASK_INTERRUPTIBLE); 410 set_current_state(TASK_INTERRUPTIBLE);
412 411
diff --git a/mm/compaction.c b/mm/compaction.c
index 6cc604bd5649..899d95638586 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -35,10 +35,6 @@ struct compact_control {
35 unsigned long migrate_pfn; /* isolate_migratepages search base */ 35 unsigned long migrate_pfn; /* isolate_migratepages search base */
36 bool sync; /* Synchronous migration */ 36 bool sync; /* Synchronous migration */
37 37
38 /* Account for isolated anon and file pages */
39 unsigned long nr_anon;
40 unsigned long nr_file;
41
42 unsigned int order; /* order a direct compactor needs */ 38 unsigned int order; /* order a direct compactor needs */
43 int migratetype; /* MOVABLE, RECLAIMABLE etc */ 39 int migratetype; /* MOVABLE, RECLAIMABLE etc */
44 struct zone *zone; 40 struct zone *zone;
@@ -223,17 +219,13 @@ static void isolate_freepages(struct zone *zone,
223static void acct_isolated(struct zone *zone, struct compact_control *cc) 219static void acct_isolated(struct zone *zone, struct compact_control *cc)
224{ 220{
225 struct page *page; 221 struct page *page;
226 unsigned int count[NR_LRU_LISTS] = { 0, }; 222 unsigned int count[2] = { 0, };
227 223
228 list_for_each_entry(page, &cc->migratepages, lru) { 224 list_for_each_entry(page, &cc->migratepages, lru)
229 int lru = page_lru_base_type(page); 225 count[!!page_is_file_cache(page)]++;
230 count[lru]++;
231 }
232 226
233 cc->nr_anon = count[LRU_ACTIVE_ANON] + count[LRU_INACTIVE_ANON]; 227 __mod_zone_page_state(zone, NR_ISOLATED_ANON, count[0]);
234 cc->nr_file = count[LRU_ACTIVE_FILE] + count[LRU_INACTIVE_FILE]; 228 __mod_zone_page_state(zone, NR_ISOLATED_FILE, count[1]);
235 __mod_zone_page_state(zone, NR_ISOLATED_ANON, cc->nr_anon);
236 __mod_zone_page_state(zone, NR_ISOLATED_FILE, cc->nr_file);
237} 229}
238 230
239/* Similar to reclaim, but different enough that they don't share logic */ 231/* Similar to reclaim, but different enough that they don't share logic */
@@ -269,6 +261,7 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone,
269 unsigned long last_pageblock_nr = 0, pageblock_nr; 261 unsigned long last_pageblock_nr = 0, pageblock_nr;
270 unsigned long nr_scanned = 0, nr_isolated = 0; 262 unsigned long nr_scanned = 0, nr_isolated = 0;
271 struct list_head *migratelist = &cc->migratepages; 263 struct list_head *migratelist = &cc->migratepages;
264 isolate_mode_t mode = ISOLATE_ACTIVE|ISOLATE_INACTIVE;
272 265
273 /* Do not scan outside zone boundaries */ 266 /* Do not scan outside zone boundaries */
274 low_pfn = max(cc->migrate_pfn, zone->zone_start_pfn); 267 low_pfn = max(cc->migrate_pfn, zone->zone_start_pfn);
@@ -356,8 +349,11 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone,
356 continue; 349 continue;
357 } 350 }
358 351
352 if (!cc->sync)
353 mode |= ISOLATE_CLEAN;
354
359 /* Try isolate the page */ 355 /* Try isolate the page */
360 if (__isolate_lru_page(page, ISOLATE_BOTH, 0) != 0) 356 if (__isolate_lru_page(page, mode, 0) != 0)
361 continue; 357 continue;
362 358
363 VM_BUG_ON(PageTransCompound(page)); 359 VM_BUG_ON(PageTransCompound(page));
@@ -586,7 +582,7 @@ out:
586 return ret; 582 return ret;
587} 583}
588 584
589unsigned long compact_zone_order(struct zone *zone, 585static unsigned long compact_zone_order(struct zone *zone,
590 int order, gfp_t gfp_mask, 586 int order, gfp_t gfp_mask,
591 bool sync) 587 bool sync)
592{ 588{
diff --git a/mm/debug-pagealloc.c b/mm/debug-pagealloc.c
index a1e3324de2b5..7cea557407f4 100644
--- a/mm/debug-pagealloc.c
+++ b/mm/debug-pagealloc.c
@@ -1,7 +1,10 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/string.h>
2#include <linux/mm.h> 3#include <linux/mm.h>
4#include <linux/highmem.h>
3#include <linux/page-debug-flags.h> 5#include <linux/page-debug-flags.h>
4#include <linux/poison.h> 6#include <linux/poison.h>
7#include <linux/ratelimit.h>
5 8
6static inline void set_page_poison(struct page *page) 9static inline void set_page_poison(struct page *page)
7{ 10{
@@ -18,28 +21,13 @@ static inline bool page_poison(struct page *page)
18 return test_bit(PAGE_DEBUG_FLAG_POISON, &page->debug_flags); 21 return test_bit(PAGE_DEBUG_FLAG_POISON, &page->debug_flags);
19} 22}
20 23
21static void poison_highpage(struct page *page)
22{
23 /*
24 * Page poisoning for highmem pages is not implemented.
25 *
26 * This can be called from interrupt contexts.
27 * So we need to create a new kmap_atomic slot for this
28 * application and it will need interrupt protection.
29 */
30}
31
32static void poison_page(struct page *page) 24static void poison_page(struct page *page)
33{ 25{
34 void *addr; 26 void *addr = kmap_atomic(page);
35 27
36 if (PageHighMem(page)) {
37 poison_highpage(page);
38 return;
39 }
40 set_page_poison(page); 28 set_page_poison(page);
41 addr = page_address(page);
42 memset(addr, PAGE_POISON, PAGE_SIZE); 29 memset(addr, PAGE_POISON, PAGE_SIZE);
30 kunmap_atomic(addr);
43} 31}
44 32
45static void poison_pages(struct page *page, int n) 33static void poison_pages(struct page *page, int n)
@@ -59,14 +47,12 @@ static bool single_bit_flip(unsigned char a, unsigned char b)
59 47
60static void check_poison_mem(unsigned char *mem, size_t bytes) 48static void check_poison_mem(unsigned char *mem, size_t bytes)
61{ 49{
50 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 10);
62 unsigned char *start; 51 unsigned char *start;
63 unsigned char *end; 52 unsigned char *end;
64 53
65 for (start = mem; start < mem + bytes; start++) { 54 start = memchr_inv(mem, PAGE_POISON, bytes);
66 if (*start != PAGE_POISON) 55 if (!start)
67 break;
68 }
69 if (start == mem + bytes)
70 return; 56 return;
71 57
72 for (end = mem + bytes - 1; end > start; end--) { 58 for (end = mem + bytes - 1; end > start; end--) {
@@ -74,7 +60,7 @@ static void check_poison_mem(unsigned char *mem, size_t bytes)
74 break; 60 break;
75 } 61 }
76 62
77 if (!printk_ratelimit()) 63 if (!__ratelimit(&ratelimit))
78 return; 64 return;
79 else if (start == end && single_bit_flip(*start, PAGE_POISON)) 65 else if (start == end && single_bit_flip(*start, PAGE_POISON))
80 printk(KERN_ERR "pagealloc: single bit error\n"); 66 printk(KERN_ERR "pagealloc: single bit error\n");
@@ -86,27 +72,17 @@ static void check_poison_mem(unsigned char *mem, size_t bytes)
86 dump_stack(); 72 dump_stack();
87} 73}
88 74
89static void unpoison_highpage(struct page *page)
90{
91 /*
92 * See comment in poison_highpage().
93 * Highmem pages should not be poisoned for now
94 */
95 BUG_ON(page_poison(page));
96}
97
98static void unpoison_page(struct page *page) 75static void unpoison_page(struct page *page)
99{ 76{
100 if (PageHighMem(page)) { 77 void *addr;
101 unpoison_highpage(page); 78
79 if (!page_poison(page))
102 return; 80 return;
103 }
104 if (page_poison(page)) {
105 void *addr = page_address(page);
106 81
107 check_poison_mem(addr, PAGE_SIZE); 82 addr = kmap_atomic(page);
108 clear_page_poison(page); 83 check_poison_mem(addr, PAGE_SIZE);
109 } 84 clear_page_poison(page);
85 kunmap_atomic(addr);
110} 86}
111 87
112static void unpoison_pages(struct page *page, int n) 88static void unpoison_pages(struct page *page, int n)
diff --git a/mm/highmem.c b/mm/highmem.c
index 5ef672c07f75..e159a7b1cc22 100644
--- a/mm/highmem.c
+++ b/mm/highmem.c
@@ -250,7 +250,7 @@ void *kmap_high_get(struct page *page)
250#endif 250#endif
251 251
252/** 252/**
253 * kunmap_high - map a highmem page into memory 253 * kunmap_high - unmap a highmem page into memory
254 * @page: &struct page to unmap 254 * @page: &struct page to unmap
255 * 255 *
256 * If ARCH_NEEDS_KMAP_HIGH_GET is not defined then this may be called 256 * If ARCH_NEEDS_KMAP_HIGH_GET is not defined then this may be called
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index e2d1587be269..860ec211ddd6 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -89,7 +89,8 @@ struct khugepaged_scan {
89 struct list_head mm_head; 89 struct list_head mm_head;
90 struct mm_slot *mm_slot; 90 struct mm_slot *mm_slot;
91 unsigned long address; 91 unsigned long address;
92} khugepaged_scan = { 92};
93static struct khugepaged_scan khugepaged_scan = {
93 .mm_head = LIST_HEAD_INIT(khugepaged_scan.mm_head), 94 .mm_head = LIST_HEAD_INIT(khugepaged_scan.mm_head),
94}; 95};
95 96
@@ -829,7 +830,7 @@ static int do_huge_pmd_wp_page_fallback(struct mm_struct *mm,
829 830
830 for (i = 0; i < HPAGE_PMD_NR; i++) { 831 for (i = 0; i < HPAGE_PMD_NR; i++) {
831 copy_user_highpage(pages[i], page + i, 832 copy_user_highpage(pages[i], page + i,
832 haddr + PAGE_SHIFT*i, vma); 833 haddr + PAGE_SIZE * i, vma);
833 __SetPageUptodate(pages[i]); 834 __SetPageUptodate(pages[i]);
834 cond_resched(); 835 cond_resched();
835 } 836 }
@@ -1052,6 +1053,51 @@ int mincore_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
1052 return ret; 1053 return ret;
1053} 1054}
1054 1055
1056int move_huge_pmd(struct vm_area_struct *vma, struct vm_area_struct *new_vma,
1057 unsigned long old_addr,
1058 unsigned long new_addr, unsigned long old_end,
1059 pmd_t *old_pmd, pmd_t *new_pmd)
1060{
1061 int ret = 0;
1062 pmd_t pmd;
1063
1064 struct mm_struct *mm = vma->vm_mm;
1065
1066 if ((old_addr & ~HPAGE_PMD_MASK) ||
1067 (new_addr & ~HPAGE_PMD_MASK) ||
1068 old_end - old_addr < HPAGE_PMD_SIZE ||
1069 (new_vma->vm_flags & VM_NOHUGEPAGE))
1070 goto out;
1071
1072 /*
1073 * The destination pmd shouldn't be established, free_pgtables()
1074 * should have release it.
1075 */
1076 if (WARN_ON(!pmd_none(*new_pmd))) {
1077 VM_BUG_ON(pmd_trans_huge(*new_pmd));
1078 goto out;
1079 }
1080
1081 spin_lock(&mm->page_table_lock);
1082 if (likely(pmd_trans_huge(*old_pmd))) {
1083 if (pmd_trans_splitting(*old_pmd)) {
1084 spin_unlock(&mm->page_table_lock);
1085 wait_split_huge_page(vma->anon_vma, old_pmd);
1086 ret = -1;
1087 } else {
1088 pmd = pmdp_get_and_clear(mm, old_addr, old_pmd);
1089 VM_BUG_ON(!pmd_none(*new_pmd));
1090 set_pmd_at(mm, new_addr, new_pmd, pmd);
1091 spin_unlock(&mm->page_table_lock);
1092 ret = 1;
1093 }
1094 } else {
1095 spin_unlock(&mm->page_table_lock);
1096 }
1097out:
1098 return ret;
1099}
1100
1055int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, 1101int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
1056 unsigned long addr, pgprot_t newprot) 1102 unsigned long addr, pgprot_t newprot)
1057{ 1103{
@@ -1906,7 +1952,7 @@ static void collapse_huge_page(struct mm_struct *mm,
1906 BUG_ON(!pmd_none(*pmd)); 1952 BUG_ON(!pmd_none(*pmd));
1907 page_add_new_anon_rmap(new_page, vma, address); 1953 page_add_new_anon_rmap(new_page, vma, address);
1908 set_pmd_at(mm, address, pmd, _pmd); 1954 set_pmd_at(mm, address, pmd, _pmd);
1909 update_mmu_cache(vma, address, entry); 1955 update_mmu_cache(vma, address, _pmd);
1910 prepare_pmd_huge_pte(pgtable, mm); 1956 prepare_pmd_huge_pte(pgtable, mm);
1911 mm->nr_ptes--; 1957 mm->nr_ptes--;
1912 spin_unlock(&mm->page_table_lock); 1958 spin_unlock(&mm->page_table_lock);
@@ -2024,6 +2070,8 @@ static void collect_mm_slot(struct mm_slot *mm_slot)
2024 2070
2025static unsigned int khugepaged_scan_mm_slot(unsigned int pages, 2071static unsigned int khugepaged_scan_mm_slot(unsigned int pages,
2026 struct page **hpage) 2072 struct page **hpage)
2073 __releases(&khugepaged_mm_lock)
2074 __acquires(&khugepaged_mm_lock)
2027{ 2075{
2028 struct mm_slot *mm_slot; 2076 struct mm_slot *mm_slot;
2029 struct mm_struct *mm; 2077 struct mm_struct *mm;
diff --git a/mm/ksm.c b/mm/ksm.c
index 9a68b0cf0a1c..310544a379ae 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -1905,7 +1905,8 @@ static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr,
1905 1905
1906 oom_score_adj = test_set_oom_score_adj(OOM_SCORE_ADJ_MAX); 1906 oom_score_adj = test_set_oom_score_adj(OOM_SCORE_ADJ_MAX);
1907 err = unmerge_and_remove_all_rmap_items(); 1907 err = unmerge_and_remove_all_rmap_items();
1908 test_set_oom_score_adj(oom_score_adj); 1908 compare_swap_oom_score_adj(OOM_SCORE_ADJ_MAX,
1909 oom_score_adj);
1909 if (err) { 1910 if (err) {
1910 ksm_run = KSM_RUN_STOP; 1911 ksm_run = KSM_RUN_STOP;
1911 count = err; 1912 count = err;
diff --git a/mm/memblock.c b/mm/memblock.c
index ccbf97339592..84bec4969ed5 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -58,7 +58,8 @@ static unsigned long __init_memblock memblock_addrs_overlap(phys_addr_t base1, p
58 return ((base1 < (base2 + size2)) && (base2 < (base1 + size1))); 58 return ((base1 < (base2 + size2)) && (base2 < (base1 + size1)));
59} 59}
60 60
61long __init_memblock memblock_overlaps_region(struct memblock_type *type, phys_addr_t base, phys_addr_t size) 61static long __init_memblock memblock_overlaps_region(struct memblock_type *type,
62 phys_addr_t base, phys_addr_t size)
62{ 63{
63 unsigned long i; 64 unsigned long i;
64 65
@@ -267,7 +268,7 @@ static int __init_memblock memblock_double_array(struct memblock_type *type)
267 return 0; 268 return 0;
268} 269}
269 270
270extern int __init_memblock __weak memblock_memory_can_coalesce(phys_addr_t addr1, phys_addr_t size1, 271int __init_memblock __weak memblock_memory_can_coalesce(phys_addr_t addr1, phys_addr_t size1,
271 phys_addr_t addr2, phys_addr_t size2) 272 phys_addr_t addr2, phys_addr_t size2)
272{ 273{
273 return 1; 274 return 1;
@@ -626,6 +627,12 @@ phys_addr_t __init memblock_phys_mem_size(void)
626 return memblock.memory_size; 627 return memblock.memory_size;
627} 628}
628 629
630/* lowest address */
631phys_addr_t __init_memblock memblock_start_of_DRAM(void)
632{
633 return memblock.memory.regions[0].base;
634}
635
629phys_addr_t __init_memblock memblock_end_of_DRAM(void) 636phys_addr_t __init_memblock memblock_end_of_DRAM(void)
630{ 637{
631 int idx = memblock.memory.cnt - 1; 638 int idx = memblock.memory.cnt - 1;
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 3508777837c7..2d5755544afe 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1185,7 +1185,8 @@ mem_cgroup_get_reclaim_stat_from_page(struct page *page)
1185unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, 1185unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
1186 struct list_head *dst, 1186 struct list_head *dst,
1187 unsigned long *scanned, int order, 1187 unsigned long *scanned, int order,
1188 int mode, struct zone *z, 1188 isolate_mode_t mode,
1189 struct zone *z,
1189 struct mem_cgroup *mem_cont, 1190 struct mem_cgroup *mem_cont,
1190 int active, int file) 1191 int active, int file)
1191{ 1192{
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 2b43ba051ac9..edc388db730a 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1310,7 +1310,7 @@ int unpoison_memory(unsigned long pfn)
1310 * to the end. 1310 * to the end.
1311 */ 1311 */
1312 if (PageHuge(page)) { 1312 if (PageHuge(page)) {
1313 pr_debug("MCE: Memory failure is now running on free hugepage %#lx\n", pfn); 1313 pr_info("MCE: Memory failure is now running on free hugepage %#lx\n", pfn);
1314 return 0; 1314 return 0;
1315 } 1315 }
1316 if (TestClearPageHWPoison(p)) 1316 if (TestClearPageHWPoison(p))
@@ -1419,7 +1419,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
1419 1419
1420 if (PageHWPoison(hpage)) { 1420 if (PageHWPoison(hpage)) {
1421 put_page(hpage); 1421 put_page(hpage);
1422 pr_debug("soft offline: %#lx hugepage already poisoned\n", pfn); 1422 pr_info("soft offline: %#lx hugepage already poisoned\n", pfn);
1423 return -EBUSY; 1423 return -EBUSY;
1424 } 1424 }
1425 1425
@@ -1433,8 +1433,8 @@ static int soft_offline_huge_page(struct page *page, int flags)
1433 list_for_each_entry_safe(page1, page2, &pagelist, lru) 1433 list_for_each_entry_safe(page1, page2, &pagelist, lru)
1434 put_page(page1); 1434 put_page(page1);
1435 1435
1436 pr_debug("soft offline: %#lx: migration failed %d, type %lx\n", 1436 pr_info("soft offline: %#lx: migration failed %d, type %lx\n",
1437 pfn, ret, page->flags); 1437 pfn, ret, page->flags);
1438 if (ret > 0) 1438 if (ret > 0)
1439 ret = -EIO; 1439 ret = -EIO;
1440 return ret; 1440 return ret;
@@ -1505,7 +1505,7 @@ int soft_offline_page(struct page *page, int flags)
1505 } 1505 }
1506 if (!PageLRU(page)) { 1506 if (!PageLRU(page)) {
1507 pr_info("soft_offline: %#lx: unknown non LRU page type %lx\n", 1507 pr_info("soft_offline: %#lx: unknown non LRU page type %lx\n",
1508 pfn, page->flags); 1508 pfn, page->flags);
1509 return -EIO; 1509 return -EIO;
1510 } 1510 }
1511 1511
@@ -1566,7 +1566,7 @@ int soft_offline_page(struct page *page, int flags)
1566 } 1566 }
1567 } else { 1567 } else {
1568 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n", 1568 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
1569 pfn, ret, page_count(page), page->flags); 1569 pfn, ret, page_count(page), page->flags);
1570 } 1570 }
1571 if (ret) 1571 if (ret)
1572 return ret; 1572 return ret;
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 9c51f9f58cac..cd237f478304 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -111,7 +111,7 @@ enum zone_type policy_zone = 0;
111/* 111/*
112 * run-time system-wide default policy => local allocation 112 * run-time system-wide default policy => local allocation
113 */ 113 */
114struct mempolicy default_policy = { 114static struct mempolicy default_policy = {
115 .refcnt = ATOMIC_INIT(1), /* never free it */ 115 .refcnt = ATOMIC_INIT(1), /* never free it */
116 .mode = MPOL_PREFERRED, 116 .mode = MPOL_PREFERRED,
117 .flags = MPOL_F_LOCAL, 117 .flags = MPOL_F_LOCAL,
diff --git a/mm/migrate.c b/mm/migrate.c
index 14d0a6a632f6..33358f878111 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -621,38 +621,18 @@ static int move_to_new_page(struct page *newpage, struct page *page,
621 return rc; 621 return rc;
622} 622}
623 623
624/* 624static int __unmap_and_move(struct page *page, struct page *newpage,
625 * Obtain the lock on page, remove all ptes and migrate the page 625 int force, bool offlining, bool sync)
626 * to the newly allocated page in newpage.
627 */
628static int unmap_and_move(new_page_t get_new_page, unsigned long private,
629 struct page *page, int force, bool offlining, bool sync)
630{ 626{
631 int rc = 0; 627 int rc = -EAGAIN;
632 int *result = NULL;
633 struct page *newpage = get_new_page(page, private, &result);
634 int remap_swapcache = 1; 628 int remap_swapcache = 1;
635 int charge = 0; 629 int charge = 0;
636 struct mem_cgroup *mem; 630 struct mem_cgroup *mem;
637 struct anon_vma *anon_vma = NULL; 631 struct anon_vma *anon_vma = NULL;
638 632
639 if (!newpage)
640 return -ENOMEM;
641
642 if (page_count(page) == 1) {
643 /* page was freed from under us. So we are done. */
644 goto move_newpage;
645 }
646 if (unlikely(PageTransHuge(page)))
647 if (unlikely(split_huge_page(page)))
648 goto move_newpage;
649
650 /* prepare cgroup just returns 0 or -ENOMEM */
651 rc = -EAGAIN;
652
653 if (!trylock_page(page)) { 633 if (!trylock_page(page)) {
654 if (!force || !sync) 634 if (!force || !sync)
655 goto move_newpage; 635 goto out;
656 636
657 /* 637 /*
658 * It's not safe for direct compaction to call lock_page. 638 * It's not safe for direct compaction to call lock_page.
@@ -668,7 +648,7 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
668 * altogether. 648 * altogether.
669 */ 649 */
670 if (current->flags & PF_MEMALLOC) 650 if (current->flags & PF_MEMALLOC)
671 goto move_newpage; 651 goto out;
672 652
673 lock_page(page); 653 lock_page(page);
674 } 654 }
@@ -785,27 +765,52 @@ uncharge:
785 mem_cgroup_end_migration(mem, page, newpage, rc == 0); 765 mem_cgroup_end_migration(mem, page, newpage, rc == 0);
786unlock: 766unlock:
787 unlock_page(page); 767 unlock_page(page);
768out:
769 return rc;
770}
788 771
789move_newpage: 772/*
773 * Obtain the lock on page, remove all ptes and migrate the page
774 * to the newly allocated page in newpage.
775 */
776static int unmap_and_move(new_page_t get_new_page, unsigned long private,
777 struct page *page, int force, bool offlining, bool sync)
778{
779 int rc = 0;
780 int *result = NULL;
781 struct page *newpage = get_new_page(page, private, &result);
782
783 if (!newpage)
784 return -ENOMEM;
785
786 if (page_count(page) == 1) {
787 /* page was freed from under us. So we are done. */
788 goto out;
789 }
790
791 if (unlikely(PageTransHuge(page)))
792 if (unlikely(split_huge_page(page)))
793 goto out;
794
795 rc = __unmap_and_move(page, newpage, force, offlining, sync);
796out:
790 if (rc != -EAGAIN) { 797 if (rc != -EAGAIN) {
791 /* 798 /*
792 * A page that has been migrated has all references 799 * A page that has been migrated has all references
793 * removed and will be freed. A page that has not been 800 * removed and will be freed. A page that has not been
794 * migrated will have kepts its references and be 801 * migrated will have kepts its references and be
795 * restored. 802 * restored.
796 */ 803 */
797 list_del(&page->lru); 804 list_del(&page->lru);
798 dec_zone_page_state(page, NR_ISOLATED_ANON + 805 dec_zone_page_state(page, NR_ISOLATED_ANON +
799 page_is_file_cache(page)); 806 page_is_file_cache(page));
800 putback_lru_page(page); 807 putback_lru_page(page);
801 } 808 }
802
803 /* 809 /*
804 * Move the new page to the LRU. If migration was not successful 810 * Move the new page to the LRU. If migration was not successful
805 * then this will free the page. 811 * then this will free the page.
806 */ 812 */
807 putback_lru_page(newpage); 813 putback_lru_page(newpage);
808
809 if (result) { 814 if (result) {
810 if (rc) 815 if (rc)
811 *result = rc; 816 *result = rc;
diff --git a/mm/mlock.c b/mm/mlock.c
index 048260c4e02e..bd34b3a10852 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -110,7 +110,15 @@ void munlock_vma_page(struct page *page)
110 if (TestClearPageMlocked(page)) { 110 if (TestClearPageMlocked(page)) {
111 dec_zone_page_state(page, NR_MLOCK); 111 dec_zone_page_state(page, NR_MLOCK);
112 if (!isolate_lru_page(page)) { 112 if (!isolate_lru_page(page)) {
113 int ret = try_to_munlock(page); 113 int ret = SWAP_AGAIN;
114
115 /*
116 * Optimization: if the page was mapped just once,
117 * that's our mapping and we don't need to check all the
118 * other vmas.
119 */
120 if (page_mapcount(page) > 1)
121 ret = try_to_munlock(page);
114 /* 122 /*
115 * did try_to_unlock() succeed or punt? 123 * did try_to_unlock() succeed or punt?
116 */ 124 */
@@ -549,7 +557,8 @@ SYSCALL_DEFINE1(mlockall, int, flags)
549 if (!can_do_mlock()) 557 if (!can_do_mlock())
550 goto out; 558 goto out;
551 559
552 lru_add_drain_all(); /* flush pagevec */ 560 if (flags & MCL_CURRENT)
561 lru_add_drain_all(); /* flush pagevec */
553 562
554 down_write(&current->mm->mmap_sem); 563 down_write(&current->mm->mmap_sem);
555 564
diff --git a/mm/mmap.c b/mm/mmap.c
index a65efd4db3e1..3c0061f744f5 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2558,7 +2558,6 @@ int mm_take_all_locks(struct mm_struct *mm)
2558{ 2558{
2559 struct vm_area_struct *vma; 2559 struct vm_area_struct *vma;
2560 struct anon_vma_chain *avc; 2560 struct anon_vma_chain *avc;
2561 int ret = -EINTR;
2562 2561
2563 BUG_ON(down_read_trylock(&mm->mmap_sem)); 2562 BUG_ON(down_read_trylock(&mm->mmap_sem));
2564 2563
@@ -2579,13 +2578,11 @@ int mm_take_all_locks(struct mm_struct *mm)
2579 vm_lock_anon_vma(mm, avc->anon_vma); 2578 vm_lock_anon_vma(mm, avc->anon_vma);
2580 } 2579 }
2581 2580
2582 ret = 0; 2581 return 0;
2583 2582
2584out_unlock: 2583out_unlock:
2585 if (ret) 2584 mm_drop_all_locks(mm);
2586 mm_drop_all_locks(mm); 2585 return -EINTR;
2587
2588 return ret;
2589} 2586}
2590 2587
2591static void vm_unlock_anon_vma(struct anon_vma *anon_vma) 2588static void vm_unlock_anon_vma(struct anon_vma *anon_vma)
diff --git a/mm/mremap.c b/mm/mremap.c
index 506fa44403df..d6959cb4df58 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -41,8 +41,7 @@ static pmd_t *get_old_pmd(struct mm_struct *mm, unsigned long addr)
41 return NULL; 41 return NULL;
42 42
43 pmd = pmd_offset(pud, addr); 43 pmd = pmd_offset(pud, addr);
44 split_huge_page_pmd(mm, pmd); 44 if (pmd_none(*pmd))
45 if (pmd_none_or_clear_bad(pmd))
46 return NULL; 45 return NULL;
47 46
48 return pmd; 47 return pmd;
@@ -65,8 +64,6 @@ static pmd_t *alloc_new_pmd(struct mm_struct *mm, struct vm_area_struct *vma,
65 return NULL; 64 return NULL;
66 65
67 VM_BUG_ON(pmd_trans_huge(*pmd)); 66 VM_BUG_ON(pmd_trans_huge(*pmd));
68 if (pmd_none(*pmd) && __pte_alloc(mm, vma, pmd, addr))
69 return NULL;
70 67
71 return pmd; 68 return pmd;
72} 69}
@@ -80,11 +77,7 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
80 struct mm_struct *mm = vma->vm_mm; 77 struct mm_struct *mm = vma->vm_mm;
81 pte_t *old_pte, *new_pte, pte; 78 pte_t *old_pte, *new_pte, pte;
82 spinlock_t *old_ptl, *new_ptl; 79 spinlock_t *old_ptl, *new_ptl;
83 unsigned long old_start;
84 80
85 old_start = old_addr;
86 mmu_notifier_invalidate_range_start(vma->vm_mm,
87 old_start, old_end);
88 if (vma->vm_file) { 81 if (vma->vm_file) {
89 /* 82 /*
90 * Subtle point from Rajesh Venkatasubramanian: before 83 * Subtle point from Rajesh Venkatasubramanian: before
@@ -111,7 +104,7 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
111 new_pte++, new_addr += PAGE_SIZE) { 104 new_pte++, new_addr += PAGE_SIZE) {
112 if (pte_none(*old_pte)) 105 if (pte_none(*old_pte))
113 continue; 106 continue;
114 pte = ptep_clear_flush(vma, old_addr, old_pte); 107 pte = ptep_get_and_clear(mm, old_addr, old_pte);
115 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr); 108 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
116 set_pte_at(mm, new_addr, new_pte, pte); 109 set_pte_at(mm, new_addr, new_pte, pte);
117 } 110 }
@@ -123,7 +116,6 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
123 pte_unmap_unlock(old_pte - 1, old_ptl); 116 pte_unmap_unlock(old_pte - 1, old_ptl);
124 if (mapping) 117 if (mapping)
125 mutex_unlock(&mapping->i_mmap_mutex); 118 mutex_unlock(&mapping->i_mmap_mutex);
126 mmu_notifier_invalidate_range_end(vma->vm_mm, old_start, old_end);
127} 119}
128 120
129#define LATENCY_LIMIT (64 * PAGE_SIZE) 121#define LATENCY_LIMIT (64 * PAGE_SIZE)
@@ -134,22 +126,43 @@ unsigned long move_page_tables(struct vm_area_struct *vma,
134{ 126{
135 unsigned long extent, next, old_end; 127 unsigned long extent, next, old_end;
136 pmd_t *old_pmd, *new_pmd; 128 pmd_t *old_pmd, *new_pmd;
129 bool need_flush = false;
137 130
138 old_end = old_addr + len; 131 old_end = old_addr + len;
139 flush_cache_range(vma, old_addr, old_end); 132 flush_cache_range(vma, old_addr, old_end);
140 133
134 mmu_notifier_invalidate_range_start(vma->vm_mm, old_addr, old_end);
135
141 for (; old_addr < old_end; old_addr += extent, new_addr += extent) { 136 for (; old_addr < old_end; old_addr += extent, new_addr += extent) {
142 cond_resched(); 137 cond_resched();
143 next = (old_addr + PMD_SIZE) & PMD_MASK; 138 next = (old_addr + PMD_SIZE) & PMD_MASK;
144 if (next - 1 > old_end) 139 /* even if next overflowed, extent below will be ok */
145 next = old_end;
146 extent = next - old_addr; 140 extent = next - old_addr;
141 if (extent > old_end - old_addr)
142 extent = old_end - old_addr;
147 old_pmd = get_old_pmd(vma->vm_mm, old_addr); 143 old_pmd = get_old_pmd(vma->vm_mm, old_addr);
148 if (!old_pmd) 144 if (!old_pmd)
149 continue; 145 continue;
150 new_pmd = alloc_new_pmd(vma->vm_mm, vma, new_addr); 146 new_pmd = alloc_new_pmd(vma->vm_mm, vma, new_addr);
151 if (!new_pmd) 147 if (!new_pmd)
152 break; 148 break;
149 if (pmd_trans_huge(*old_pmd)) {
150 int err = 0;
151 if (extent == HPAGE_PMD_SIZE)
152 err = move_huge_pmd(vma, new_vma, old_addr,
153 new_addr, old_end,
154 old_pmd, new_pmd);
155 if (err > 0) {
156 need_flush = true;
157 continue;
158 } else if (!err) {
159 split_huge_page_pmd(vma->vm_mm, old_pmd);
160 }
161 VM_BUG_ON(pmd_trans_huge(*old_pmd));
162 }
163 if (pmd_none(*new_pmd) && __pte_alloc(new_vma->vm_mm, new_vma,
164 new_pmd, new_addr))
165 break;
153 next = (new_addr + PMD_SIZE) & PMD_MASK; 166 next = (new_addr + PMD_SIZE) & PMD_MASK;
154 if (extent > next - new_addr) 167 if (extent > next - new_addr)
155 extent = next - new_addr; 168 extent = next - new_addr;
@@ -157,7 +170,12 @@ unsigned long move_page_tables(struct vm_area_struct *vma,
157 extent = LATENCY_LIMIT; 170 extent = LATENCY_LIMIT;
158 move_ptes(vma, old_pmd, old_addr, old_addr + extent, 171 move_ptes(vma, old_pmd, old_addr, old_addr + extent,
159 new_vma, new_pmd, new_addr); 172 new_vma, new_pmd, new_addr);
173 need_flush = true;
160 } 174 }
175 if (likely(need_flush))
176 flush_tlb_range(vma, old_end-len, old_addr);
177
178 mmu_notifier_invalidate_range_end(vma->vm_mm, old_end-len, old_end);
161 179
162 return len + old_addr - old_end; /* how much done */ 180 return len + old_addr - old_end; /* how much done */
163} 181}
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 626303b52f3c..e916168b6e0a 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -32,12 +32,32 @@
32#include <linux/mempolicy.h> 32#include <linux/mempolicy.h>
33#include <linux/security.h> 33#include <linux/security.h>
34#include <linux/ptrace.h> 34#include <linux/ptrace.h>
35#include <linux/freezer.h>
35 36
36int sysctl_panic_on_oom; 37int sysctl_panic_on_oom;
37int sysctl_oom_kill_allocating_task; 38int sysctl_oom_kill_allocating_task;
38int sysctl_oom_dump_tasks = 1; 39int sysctl_oom_dump_tasks = 1;
39static DEFINE_SPINLOCK(zone_scan_lock); 40static DEFINE_SPINLOCK(zone_scan_lock);
40 41
42/*
43 * compare_swap_oom_score_adj() - compare and swap current's oom_score_adj
44 * @old_val: old oom_score_adj for compare
45 * @new_val: new oom_score_adj for swap
46 *
47 * Sets the oom_score_adj value for current to @new_val iff its present value is
48 * @old_val. Usually used to reinstate a previous value to prevent racing with
49 * userspacing tuning the value in the interim.
50 */
51void compare_swap_oom_score_adj(int old_val, int new_val)
52{
53 struct sighand_struct *sighand = current->sighand;
54
55 spin_lock_irq(&sighand->siglock);
56 if (current->signal->oom_score_adj == old_val)
57 current->signal->oom_score_adj = new_val;
58 spin_unlock_irq(&sighand->siglock);
59}
60
41/** 61/**
42 * test_set_oom_score_adj() - set current's oom_score_adj and return old value 62 * test_set_oom_score_adj() - set current's oom_score_adj and return old value
43 * @new_val: new oom_score_adj value 63 * @new_val: new oom_score_adj value
@@ -53,13 +73,7 @@ int test_set_oom_score_adj(int new_val)
53 73
54 spin_lock_irq(&sighand->siglock); 74 spin_lock_irq(&sighand->siglock);
55 old_val = current->signal->oom_score_adj; 75 old_val = current->signal->oom_score_adj;
56 if (new_val != old_val) { 76 current->signal->oom_score_adj = new_val;
57 if (new_val == OOM_SCORE_ADJ_MIN)
58 atomic_inc(&current->mm->oom_disable_count);
59 else if (old_val == OOM_SCORE_ADJ_MIN)
60 atomic_dec(&current->mm->oom_disable_count);
61 current->signal->oom_score_adj = new_val;
62 }
63 spin_unlock_irq(&sighand->siglock); 77 spin_unlock_irq(&sighand->siglock);
64 78
65 return old_val; 79 return old_val;
@@ -172,16 +186,6 @@ unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *mem,
172 return 0; 186 return 0;
173 187
174 /* 188 /*
175 * Shortcut check for a thread sharing p->mm that is OOM_SCORE_ADJ_MIN
176 * so the entire heuristic doesn't need to be executed for something
177 * that cannot be killed.
178 */
179 if (atomic_read(&p->mm->oom_disable_count)) {
180 task_unlock(p);
181 return 0;
182 }
183
184 /*
185 * The memory controller may have a limit of 0 bytes, so avoid a divide 189 * The memory controller may have a limit of 0 bytes, so avoid a divide
186 * by zero, if necessary. 190 * by zero, if necessary.
187 */ 191 */
@@ -317,8 +321,11 @@ static struct task_struct *select_bad_process(unsigned int *ppoints,
317 * blocked waiting for another task which itself is waiting 321 * blocked waiting for another task which itself is waiting
318 * for memory. Is there a better alternative? 322 * for memory. Is there a better alternative?
319 */ 323 */
320 if (test_tsk_thread_flag(p, TIF_MEMDIE)) 324 if (test_tsk_thread_flag(p, TIF_MEMDIE)) {
325 if (unlikely(frozen(p)))
326 thaw_process(p);
321 return ERR_PTR(-1UL); 327 return ERR_PTR(-1UL);
328 }
322 if (!p->mm) 329 if (!p->mm)
323 continue; 330 continue;
324 331
@@ -435,7 +442,7 @@ static int oom_kill_task(struct task_struct *p, struct mem_cgroup *mem)
435 task_unlock(p); 442 task_unlock(p);
436 443
437 /* 444 /*
438 * Kill all processes sharing p->mm in other thread groups, if any. 445 * Kill all user processes sharing p->mm in other thread groups, if any.
439 * They don't get access to memory reserves or a higher scheduler 446 * They don't get access to memory reserves or a higher scheduler
440 * priority, though, to avoid depletion of all memory or task 447 * priority, though, to avoid depletion of all memory or task
441 * starvation. This prevents mm->mmap_sem livelock when an oom killed 448 * starvation. This prevents mm->mmap_sem livelock when an oom killed
@@ -445,7 +452,11 @@ static int oom_kill_task(struct task_struct *p, struct mem_cgroup *mem)
445 * signal. 452 * signal.
446 */ 453 */
447 for_each_process(q) 454 for_each_process(q)
448 if (q->mm == mm && !same_thread_group(q, p)) { 455 if (q->mm == mm && !same_thread_group(q, p) &&
456 !(q->flags & PF_KTHREAD)) {
457 if (q->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
458 continue;
459
449 task_lock(q); /* Protect ->comm from prctl() */ 460 task_lock(q); /* Protect ->comm from prctl() */
450 pr_err("Kill process %d (%s) sharing same memory\n", 461 pr_err("Kill process %d (%s) sharing same memory\n",
451 task_pid_nr(q), q->comm); 462 task_pid_nr(q), q->comm);
@@ -722,7 +733,7 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
722 read_lock(&tasklist_lock); 733 read_lock(&tasklist_lock);
723 if (sysctl_oom_kill_allocating_task && 734 if (sysctl_oom_kill_allocating_task &&
724 !oom_unkillable_task(current, NULL, nodemask) && 735 !oom_unkillable_task(current, NULL, nodemask) &&
725 current->mm && !atomic_read(&current->mm->oom_disable_count)) { 736 current->mm) {
726 /* 737 /*
727 * oom_kill_process() needs tasklist_lock held. If it returns 738 * oom_kill_process() needs tasklist_lock held. If it returns
728 * non-zero, current could not be killed so we must fallback to 739 * non-zero, current could not be killed so we must fallback to
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 0e309cd1b5b9..793e9874de51 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -305,7 +305,9 @@ static unsigned long task_min_dirty_limit(unsigned long bdi_dirty)
305} 305}
306 306
307/* 307/*
308 * 308 * bdi_min_ratio keeps the sum of the minimum dirty shares of all
309 * registered backing devices, which, for obvious reasons, can not
310 * exceed 100%.
309 */ 311 */
310static unsigned int bdi_min_ratio; 312static unsigned int bdi_min_ratio;
311 313
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 6e8ecb6e021c..9dd443d89d8b 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -318,6 +318,7 @@ static void bad_page(struct page *page)
318 current->comm, page_to_pfn(page)); 318 current->comm, page_to_pfn(page));
319 dump_page(page); 319 dump_page(page);
320 320
321 print_modules();
321 dump_stack(); 322 dump_stack();
322out: 323out:
323 /* Leave bad fields for debug, except PageBuddy could make trouble */ 324 /* Leave bad fields for debug, except PageBuddy could make trouble */
@@ -1753,7 +1754,6 @@ static DEFINE_RATELIMIT_STATE(nopage_rs,
1753 1754
1754void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...) 1755void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...)
1755{ 1756{
1756 va_list args;
1757 unsigned int filter = SHOW_MEM_FILTER_NODES; 1757 unsigned int filter = SHOW_MEM_FILTER_NODES;
1758 1758
1759 if ((gfp_mask & __GFP_NOWARN) || !__ratelimit(&nopage_rs)) 1759 if ((gfp_mask & __GFP_NOWARN) || !__ratelimit(&nopage_rs))
@@ -1772,14 +1772,21 @@ void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...)
1772 filter &= ~SHOW_MEM_FILTER_NODES; 1772 filter &= ~SHOW_MEM_FILTER_NODES;
1773 1773
1774 if (fmt) { 1774 if (fmt) {
1775 printk(KERN_WARNING); 1775 struct va_format vaf;
1776 va_list args;
1777
1776 va_start(args, fmt); 1778 va_start(args, fmt);
1777 vprintk(fmt, args); 1779
1780 vaf.fmt = fmt;
1781 vaf.va = &args;
1782
1783 pr_warn("%pV", &vaf);
1784
1778 va_end(args); 1785 va_end(args);
1779 } 1786 }
1780 1787
1781 pr_warning("%s: page allocation failure: order:%d, mode:0x%x\n", 1788 pr_warn("%s: page allocation failure: order:%d, mode:0x%x\n",
1782 current->comm, order, gfp_mask); 1789 current->comm, order, gfp_mask);
1783 1790
1784 dump_stack(); 1791 dump_stack();
1785 if (!should_suppress_show_mem()) 1792 if (!should_suppress_show_mem())
diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
new file mode 100644
index 000000000000..e920aa3ce104
--- /dev/null
+++ b/mm/process_vm_access.c
@@ -0,0 +1,496 @@
1/*
2 * linux/mm/process_vm_access.c
3 *
4 * Copyright (C) 2010-2011 Christopher Yeoh <cyeoh@au1.ibm.com>, IBM Corp.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/mm.h>
13#include <linux/uio.h>
14#include <linux/sched.h>
15#include <linux/highmem.h>
16#include <linux/ptrace.h>
17#include <linux/slab.h>
18#include <linux/syscalls.h>
19
20#ifdef CONFIG_COMPAT
21#include <linux/compat.h>
22#endif
23
24/**
25 * process_vm_rw_pages - read/write pages from task specified
26 * @task: task to read/write from
27 * @mm: mm for task
28 * @process_pages: struct pages area that can store at least
29 * nr_pages_to_copy struct page pointers
30 * @pa: address of page in task to start copying from/to
31 * @start_offset: offset in page to start copying from/to
32 * @len: number of bytes to copy
33 * @lvec: iovec array specifying where to copy to/from
34 * @lvec_cnt: number of elements in iovec array
35 * @lvec_current: index in iovec array we are up to
36 * @lvec_offset: offset in bytes from current iovec iov_base we are up to
37 * @vm_write: 0 means copy from, 1 means copy to
38 * @nr_pages_to_copy: number of pages to copy
39 * @bytes_copied: returns number of bytes successfully copied
40 * Returns 0 on success, error code otherwise
41 */
42static int process_vm_rw_pages(struct task_struct *task,
43 struct mm_struct *mm,
44 struct page **process_pages,
45 unsigned long pa,
46 unsigned long start_offset,
47 unsigned long len,
48 const struct iovec *lvec,
49 unsigned long lvec_cnt,
50 unsigned long *lvec_current,
51 size_t *lvec_offset,
52 int vm_write,
53 unsigned int nr_pages_to_copy,
54 ssize_t *bytes_copied)
55{
56 int pages_pinned;
57 void *target_kaddr;
58 int pgs_copied = 0;
59 int j;
60 int ret;
61 ssize_t bytes_to_copy;
62 ssize_t rc = 0;
63
64 *bytes_copied = 0;
65
66 /* Get the pages we're interested in */
67 down_read(&mm->mmap_sem);
68 pages_pinned = get_user_pages(task, mm, pa,
69 nr_pages_to_copy,
70 vm_write, 0, process_pages, NULL);
71 up_read(&mm->mmap_sem);
72
73 if (pages_pinned != nr_pages_to_copy) {
74 rc = -EFAULT;
75 goto end;
76 }
77
78 /* Do the copy for each page */
79 for (pgs_copied = 0;
80 (pgs_copied < nr_pages_to_copy) && (*lvec_current < lvec_cnt);
81 pgs_copied++) {
82 /* Make sure we have a non zero length iovec */
83 while (*lvec_current < lvec_cnt
84 && lvec[*lvec_current].iov_len == 0)
85 (*lvec_current)++;
86 if (*lvec_current == lvec_cnt)
87 break;
88
89 /*
90 * Will copy smallest of:
91 * - bytes remaining in page
92 * - bytes remaining in destination iovec
93 */
94 bytes_to_copy = min_t(ssize_t, PAGE_SIZE - start_offset,
95 len - *bytes_copied);
96 bytes_to_copy = min_t(ssize_t, bytes_to_copy,
97 lvec[*lvec_current].iov_len
98 - *lvec_offset);
99
100 target_kaddr = kmap(process_pages[pgs_copied]) + start_offset;
101
102 if (vm_write)
103 ret = copy_from_user(target_kaddr,
104 lvec[*lvec_current].iov_base
105 + *lvec_offset,
106 bytes_to_copy);
107 else
108 ret = copy_to_user(lvec[*lvec_current].iov_base
109 + *lvec_offset,
110 target_kaddr, bytes_to_copy);
111 kunmap(process_pages[pgs_copied]);
112 if (ret) {
113 *bytes_copied += bytes_to_copy - ret;
114 pgs_copied++;
115 rc = -EFAULT;
116 goto end;
117 }
118 *bytes_copied += bytes_to_copy;
119 *lvec_offset += bytes_to_copy;
120 if (*lvec_offset == lvec[*lvec_current].iov_len) {
121 /*
122 * Need to copy remaining part of page into the
123 * next iovec if there are any bytes left in page
124 */
125 (*lvec_current)++;
126 *lvec_offset = 0;
127 start_offset = (start_offset + bytes_to_copy)
128 % PAGE_SIZE;
129 if (start_offset)
130 pgs_copied--;
131 } else {
132 start_offset = 0;
133 }
134 }
135
136end:
137 if (vm_write) {
138 for (j = 0; j < pages_pinned; j++) {
139 if (j < pgs_copied)
140 set_page_dirty_lock(process_pages[j]);
141 put_page(process_pages[j]);
142 }
143 } else {
144 for (j = 0; j < pages_pinned; j++)
145 put_page(process_pages[j]);
146 }
147
148 return rc;
149}
150
151/* Maximum number of pages kmalloc'd to hold struct page's during copy */
152#define PVM_MAX_KMALLOC_PAGES (PAGE_SIZE * 2)
153
154/**
155 * process_vm_rw_single_vec - read/write pages from task specified
156 * @addr: start memory address of target process
157 * @len: size of area to copy to/from
158 * @lvec: iovec array specifying where to copy to/from locally
159 * @lvec_cnt: number of elements in iovec array
160 * @lvec_current: index in iovec array we are up to
161 * @lvec_offset: offset in bytes from current iovec iov_base we are up to
162 * @process_pages: struct pages area that can store at least
163 * nr_pages_to_copy struct page pointers
164 * @mm: mm for task
165 * @task: task to read/write from
166 * @vm_write: 0 means copy from, 1 means copy to
167 * @bytes_copied: returns number of bytes successfully copied
168 * Returns 0 on success or on failure error code
169 */
170static int process_vm_rw_single_vec(unsigned long addr,
171 unsigned long len,
172 const struct iovec *lvec,
173 unsigned long lvec_cnt,
174 unsigned long *lvec_current,
175 size_t *lvec_offset,
176 struct page **process_pages,
177 struct mm_struct *mm,
178 struct task_struct *task,
179 int vm_write,
180 ssize_t *bytes_copied)
181{
182 unsigned long pa = addr & PAGE_MASK;
183 unsigned long start_offset = addr - pa;
184 unsigned long nr_pages;
185 ssize_t bytes_copied_loop;
186 ssize_t rc = 0;
187 unsigned long nr_pages_copied = 0;
188 unsigned long nr_pages_to_copy;
189 unsigned long max_pages_per_loop = PVM_MAX_KMALLOC_PAGES
190 / sizeof(struct pages *);
191
192 *bytes_copied = 0;
193
194 /* Work out address and page range required */
195 if (len == 0)
196 return 0;
197 nr_pages = (addr + len - 1) / PAGE_SIZE - addr / PAGE_SIZE + 1;
198
199 while ((nr_pages_copied < nr_pages) && (*lvec_current < lvec_cnt)) {
200 nr_pages_to_copy = min(nr_pages - nr_pages_copied,
201 max_pages_per_loop);
202
203 rc = process_vm_rw_pages(task, mm, process_pages, pa,
204 start_offset, len,
205 lvec, lvec_cnt,
206 lvec_current, lvec_offset,
207 vm_write, nr_pages_to_copy,
208 &bytes_copied_loop);
209 start_offset = 0;
210 *bytes_copied += bytes_copied_loop;
211
212 if (rc < 0) {
213 return rc;
214 } else {
215 len -= bytes_copied_loop;
216 nr_pages_copied += nr_pages_to_copy;
217 pa += nr_pages_to_copy * PAGE_SIZE;
218 }
219 }
220
221 return rc;
222}
223
224/* Maximum number of entries for process pages array
225 which lives on stack */
226#define PVM_MAX_PP_ARRAY_COUNT 16
227
228/**
229 * process_vm_rw_core - core of reading/writing pages from task specified
230 * @pid: PID of process to read/write from/to
231 * @lvec: iovec array specifying where to copy to/from locally
232 * @liovcnt: size of lvec array
233 * @rvec: iovec array specifying where to copy to/from in the other process
234 * @riovcnt: size of rvec array
235 * @flags: currently unused
236 * @vm_write: 0 if reading from other process, 1 if writing to other process
237 * Returns the number of bytes read/written or error code. May
238 * return less bytes than expected if an error occurs during the copying
239 * process.
240 */
241static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
242 unsigned long liovcnt,
243 const struct iovec *rvec,
244 unsigned long riovcnt,
245 unsigned long flags, int vm_write)
246{
247 struct task_struct *task;
248 struct page *pp_stack[PVM_MAX_PP_ARRAY_COUNT];
249 struct page **process_pages = pp_stack;
250 struct mm_struct *mm;
251 unsigned long i;
252 ssize_t rc = 0;
253 ssize_t bytes_copied_loop;
254 ssize_t bytes_copied = 0;
255 unsigned long nr_pages = 0;
256 unsigned long nr_pages_iov;
257 unsigned long iov_l_curr_idx = 0;
258 size_t iov_l_curr_offset = 0;
259 ssize_t iov_len;
260
261 /*
262 * Work out how many pages of struct pages we're going to need
263 * when eventually calling get_user_pages
264 */
265 for (i = 0; i < riovcnt; i++) {
266 iov_len = rvec[i].iov_len;
267 if (iov_len > 0) {
268 nr_pages_iov = ((unsigned long)rvec[i].iov_base
269 + iov_len)
270 / PAGE_SIZE - (unsigned long)rvec[i].iov_base
271 / PAGE_SIZE + 1;
272 nr_pages = max(nr_pages, nr_pages_iov);
273 }
274 }
275
276 if (nr_pages == 0)
277 return 0;
278
279 if (nr_pages > PVM_MAX_PP_ARRAY_COUNT) {
280 /* For reliability don't try to kmalloc more than
281 2 pages worth */
282 process_pages = kmalloc(min_t(size_t, PVM_MAX_KMALLOC_PAGES,
283 sizeof(struct pages *)*nr_pages),
284 GFP_KERNEL);
285
286 if (!process_pages)
287 return -ENOMEM;
288 }
289
290 /* Get process information */
291 rcu_read_lock();
292 task = find_task_by_vpid(pid);
293 if (task)
294 get_task_struct(task);
295 rcu_read_unlock();
296 if (!task) {
297 rc = -ESRCH;
298 goto free_proc_pages;
299 }
300
301 task_lock(task);
302 if (__ptrace_may_access(task, PTRACE_MODE_ATTACH)) {
303 task_unlock(task);
304 rc = -EPERM;
305 goto put_task_struct;
306 }
307 mm = task->mm;
308
309 if (!mm || (task->flags & PF_KTHREAD)) {
310 task_unlock(task);
311 rc = -EINVAL;
312 goto put_task_struct;
313 }
314
315 atomic_inc(&mm->mm_users);
316 task_unlock(task);
317
318 for (i = 0; i < riovcnt && iov_l_curr_idx < liovcnt; i++) {
319 rc = process_vm_rw_single_vec(
320 (unsigned long)rvec[i].iov_base, rvec[i].iov_len,
321 lvec, liovcnt, &iov_l_curr_idx, &iov_l_curr_offset,
322 process_pages, mm, task, vm_write, &bytes_copied_loop);
323 bytes_copied += bytes_copied_loop;
324 if (rc != 0) {
325 /* If we have managed to copy any data at all then
326 we return the number of bytes copied. Otherwise
327 we return the error code */
328 if (bytes_copied)
329 rc = bytes_copied;
330 goto put_mm;
331 }
332 }
333
334 rc = bytes_copied;
335put_mm:
336 mmput(mm);
337
338put_task_struct:
339 put_task_struct(task);
340
341free_proc_pages:
342 if (process_pages != pp_stack)
343 kfree(process_pages);
344 return rc;
345}
346
347/**
348 * process_vm_rw - check iovecs before calling core routine
349 * @pid: PID of process to read/write from/to
350 * @lvec: iovec array specifying where to copy to/from locally
351 * @liovcnt: size of lvec array
352 * @rvec: iovec array specifying where to copy to/from in the other process
353 * @riovcnt: size of rvec array
354 * @flags: currently unused
355 * @vm_write: 0 if reading from other process, 1 if writing to other process
356 * Returns the number of bytes read/written or error code. May
357 * return less bytes than expected if an error occurs during the copying
358 * process.
359 */
360static ssize_t process_vm_rw(pid_t pid,
361 const struct iovec __user *lvec,
362 unsigned long liovcnt,
363 const struct iovec __user *rvec,
364 unsigned long riovcnt,
365 unsigned long flags, int vm_write)
366{
367 struct iovec iovstack_l[UIO_FASTIOV];
368 struct iovec iovstack_r[UIO_FASTIOV];
369 struct iovec *iov_l = iovstack_l;
370 struct iovec *iov_r = iovstack_r;
371 ssize_t rc;
372
373 if (flags != 0)
374 return -EINVAL;
375
376 /* Check iovecs */
377 if (vm_write)
378 rc = rw_copy_check_uvector(WRITE, lvec, liovcnt, UIO_FASTIOV,
379 iovstack_l, &iov_l, 1);
380 else
381 rc = rw_copy_check_uvector(READ, lvec, liovcnt, UIO_FASTIOV,
382 iovstack_l, &iov_l, 1);
383 if (rc <= 0)
384 goto free_iovecs;
385
386 rc = rw_copy_check_uvector(READ, rvec, riovcnt, UIO_FASTIOV,
387 iovstack_r, &iov_r, 0);
388 if (rc <= 0)
389 goto free_iovecs;
390
391 rc = process_vm_rw_core(pid, iov_l, liovcnt, iov_r, riovcnt, flags,
392 vm_write);
393
394free_iovecs:
395 if (iov_r != iovstack_r)
396 kfree(iov_r);
397 if (iov_l != iovstack_l)
398 kfree(iov_l);
399
400 return rc;
401}
402
403SYSCALL_DEFINE6(process_vm_readv, pid_t, pid, const struct iovec __user *, lvec,
404 unsigned long, liovcnt, const struct iovec __user *, rvec,
405 unsigned long, riovcnt, unsigned long, flags)
406{
407 return process_vm_rw(pid, lvec, liovcnt, rvec, riovcnt, flags, 0);
408}
409
410SYSCALL_DEFINE6(process_vm_writev, pid_t, pid,
411 const struct iovec __user *, lvec,
412 unsigned long, liovcnt, const struct iovec __user *, rvec,
413 unsigned long, riovcnt, unsigned long, flags)
414{
415 return process_vm_rw(pid, lvec, liovcnt, rvec, riovcnt, flags, 1);
416}
417
418#ifdef CONFIG_COMPAT
419
420asmlinkage ssize_t
421compat_process_vm_rw(compat_pid_t pid,
422 const struct compat_iovec __user *lvec,
423 unsigned long liovcnt,
424 const struct compat_iovec __user *rvec,
425 unsigned long riovcnt,
426 unsigned long flags, int vm_write)
427{
428 struct iovec iovstack_l[UIO_FASTIOV];
429 struct iovec iovstack_r[UIO_FASTIOV];
430 struct iovec *iov_l = iovstack_l;
431 struct iovec *iov_r = iovstack_r;
432 ssize_t rc = -EFAULT;
433
434 if (flags != 0)
435 return -EINVAL;
436
437 if (!access_ok(VERIFY_READ, lvec, liovcnt * sizeof(*lvec)))
438 goto out;
439
440 if (!access_ok(VERIFY_READ, rvec, riovcnt * sizeof(*rvec)))
441 goto out;
442
443 if (vm_write)
444 rc = compat_rw_copy_check_uvector(WRITE, lvec, liovcnt,
445 UIO_FASTIOV, iovstack_l,
446 &iov_l, 1);
447 else
448 rc = compat_rw_copy_check_uvector(READ, lvec, liovcnt,
449 UIO_FASTIOV, iovstack_l,
450 &iov_l, 1);
451 if (rc <= 0)
452 goto free_iovecs;
453 rc = compat_rw_copy_check_uvector(READ, rvec, riovcnt,
454 UIO_FASTIOV, iovstack_r,
455 &iov_r, 0);
456 if (rc <= 0)
457 goto free_iovecs;
458
459 rc = process_vm_rw_core(pid, iov_l, liovcnt, iov_r, riovcnt, flags,
460 vm_write);
461
462free_iovecs:
463 if (iov_r != iovstack_r)
464 kfree(iov_r);
465 if (iov_l != iovstack_l)
466 kfree(iov_l);
467
468out:
469 return rc;
470}
471
472asmlinkage ssize_t
473compat_sys_process_vm_readv(compat_pid_t pid,
474 const struct compat_iovec __user *lvec,
475 unsigned long liovcnt,
476 const struct compat_iovec __user *rvec,
477 unsigned long riovcnt,
478 unsigned long flags)
479{
480 return compat_process_vm_rw(pid, lvec, liovcnt, rvec,
481 riovcnt, flags, 0);
482}
483
484asmlinkage ssize_t
485compat_sys_process_vm_writev(compat_pid_t pid,
486 const struct compat_iovec __user *lvec,
487 unsigned long liovcnt,
488 const struct compat_iovec __user *rvec,
489 unsigned long riovcnt,
490 unsigned long flags)
491{
492 return compat_process_vm_rw(pid, lvec, liovcnt, rvec,
493 riovcnt, flags, 1);
494}
495
496#endif
diff --git a/mm/rmap.c b/mm/rmap.c
index 8005080fb9e3..6541cf7fd1d3 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1164,7 +1164,7 @@ void page_remove_rmap(struct page *page)
1164 1164
1165/* 1165/*
1166 * Subfunctions of try_to_unmap: try_to_unmap_one called 1166 * Subfunctions of try_to_unmap: try_to_unmap_one called
1167 * repeatedly from either try_to_unmap_anon or try_to_unmap_file. 1167 * repeatedly from try_to_unmap_ksm, try_to_unmap_anon or try_to_unmap_file.
1168 */ 1168 */
1169int try_to_unmap_one(struct page *page, struct vm_area_struct *vma, 1169int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
1170 unsigned long address, enum ttu_flags flags) 1170 unsigned long address, enum ttu_flags flags)
diff --git a/mm/shmem.c b/mm/shmem.c
index 2d3577295298..fa4fa6ce13bc 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1068,6 +1068,12 @@ int shmem_lock(struct file *file, int lock, struct user_struct *user)
1068 user_shm_unlock(inode->i_size, user); 1068 user_shm_unlock(inode->i_size, user);
1069 info->flags &= ~VM_LOCKED; 1069 info->flags &= ~VM_LOCKED;
1070 mapping_clear_unevictable(file->f_mapping); 1070 mapping_clear_unevictable(file->f_mapping);
1071 /*
1072 * Ensure that a racing putback_lru_page() can see
1073 * the pages of this mapping are evictable when we
1074 * skip them due to !PageLRU during the scan.
1075 */
1076 smp_mb__after_clear_bit();
1071 scan_mapping_unevictable_pages(file->f_mapping); 1077 scan_mapping_unevictable_pages(file->f_mapping);
1072 } 1078 }
1073 retval = 0; 1079 retval = 0;
diff --git a/mm/slub.c b/mm/slub.c
index 95215aa6a75e..7d2a996c307e 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -655,49 +655,6 @@ static void init_object(struct kmem_cache *s, void *object, u8 val)
655 memset(p + s->objsize, val, s->inuse - s->objsize); 655 memset(p + s->objsize, val, s->inuse - s->objsize);
656} 656}
657 657
658static u8 *check_bytes8(u8 *start, u8 value, unsigned int bytes)
659{
660 while (bytes) {
661 if (*start != value)
662 return start;
663 start++;
664 bytes--;
665 }
666 return NULL;
667}
668
669static u8 *check_bytes(u8 *start, u8 value, unsigned int bytes)
670{
671 u64 value64;
672 unsigned int words, prefix;
673
674 if (bytes <= 16)
675 return check_bytes8(start, value, bytes);
676
677 value64 = value | value << 8 | value << 16 | value << 24;
678 value64 = (value64 & 0xffffffff) | value64 << 32;
679 prefix = 8 - ((unsigned long)start) % 8;
680
681 if (prefix) {
682 u8 *r = check_bytes8(start, value, prefix);
683 if (r)
684 return r;
685 start += prefix;
686 bytes -= prefix;
687 }
688
689 words = bytes / 8;
690
691 while (words) {
692 if (*(u64 *)start != value64)
693 return check_bytes8(start, value, 8);
694 start += 8;
695 words--;
696 }
697
698 return check_bytes8(start, value, bytes % 8);
699}
700
701static void restore_bytes(struct kmem_cache *s, char *message, u8 data, 658static void restore_bytes(struct kmem_cache *s, char *message, u8 data,
702 void *from, void *to) 659 void *from, void *to)
703{ 660{
@@ -712,7 +669,7 @@ static int check_bytes_and_report(struct kmem_cache *s, struct page *page,
712 u8 *fault; 669 u8 *fault;
713 u8 *end; 670 u8 *end;
714 671
715 fault = check_bytes(start, value, bytes); 672 fault = memchr_inv(start, value, bytes);
716 if (!fault) 673 if (!fault)
717 return 1; 674 return 1;
718 675
@@ -805,7 +762,7 @@ static int slab_pad_check(struct kmem_cache *s, struct page *page)
805 if (!remainder) 762 if (!remainder)
806 return 1; 763 return 1;
807 764
808 fault = check_bytes(end - remainder, POISON_INUSE, remainder); 765 fault = memchr_inv(end - remainder, POISON_INUSE, remainder);
809 if (!fault) 766 if (!fault)
810 return 1; 767 return 1;
811 while (end > fault && end[-1] == POISON_INUSE) 768 while (end > fault && end[-1] == POISON_INUSE)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 17bc224bce68..c9d654009125 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1617,7 +1617,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
1617 1617
1618 oom_score_adj = test_set_oom_score_adj(OOM_SCORE_ADJ_MAX); 1618 oom_score_adj = test_set_oom_score_adj(OOM_SCORE_ADJ_MAX);
1619 err = try_to_unuse(type); 1619 err = try_to_unuse(type);
1620 test_set_oom_score_adj(oom_score_adj); 1620 compare_swap_oom_score_adj(OOM_SCORE_ADJ_MAX, oom_score_adj);
1621 1621
1622 if (err) { 1622 if (err) {
1623 /* 1623 /*
diff --git a/mm/thrash.c b/mm/thrash.c
index e53f7d02c17c..57ad495dbd54 100644
--- a/mm/thrash.c
+++ b/mm/thrash.c
@@ -29,7 +29,7 @@
29 29
30static DEFINE_SPINLOCK(swap_token_lock); 30static DEFINE_SPINLOCK(swap_token_lock);
31struct mm_struct *swap_token_mm; 31struct mm_struct *swap_token_mm;
32struct mem_cgroup *swap_token_memcg; 32static struct mem_cgroup *swap_token_memcg;
33 33
34#ifdef CONFIG_CGROUP_MEM_RES_CTLR 34#ifdef CONFIG_CGROUP_MEM_RES_CTLR
35static struct mem_cgroup *swap_token_memcg_from_mm(struct mm_struct *mm) 35static struct mem_cgroup *swap_token_memcg_from_mm(struct mm_struct *mm)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 5016f19e1661..b669aa6f6caf 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1253,18 +1253,22 @@ EXPORT_SYMBOL_GPL(map_vm_area);
1253DEFINE_RWLOCK(vmlist_lock); 1253DEFINE_RWLOCK(vmlist_lock);
1254struct vm_struct *vmlist; 1254struct vm_struct *vmlist;
1255 1255
1256static void insert_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va, 1256static void setup_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va,
1257 unsigned long flags, void *caller) 1257 unsigned long flags, void *caller)
1258{ 1258{
1259 struct vm_struct *tmp, **p;
1260
1261 vm->flags = flags; 1259 vm->flags = flags;
1262 vm->addr = (void *)va->va_start; 1260 vm->addr = (void *)va->va_start;
1263 vm->size = va->va_end - va->va_start; 1261 vm->size = va->va_end - va->va_start;
1264 vm->caller = caller; 1262 vm->caller = caller;
1265 va->private = vm; 1263 va->private = vm;
1266 va->flags |= VM_VM_AREA; 1264 va->flags |= VM_VM_AREA;
1265}
1267 1266
1267static void insert_vmalloc_vmlist(struct vm_struct *vm)
1268{
1269 struct vm_struct *tmp, **p;
1270
1271 vm->flags &= ~VM_UNLIST;
1268 write_lock(&vmlist_lock); 1272 write_lock(&vmlist_lock);
1269 for (p = &vmlist; (tmp = *p) != NULL; p = &tmp->next) { 1273 for (p = &vmlist; (tmp = *p) != NULL; p = &tmp->next) {
1270 if (tmp->addr >= vm->addr) 1274 if (tmp->addr >= vm->addr)
@@ -1275,6 +1279,13 @@ static void insert_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va,
1275 write_unlock(&vmlist_lock); 1279 write_unlock(&vmlist_lock);
1276} 1280}
1277 1281
1282static void insert_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va,
1283 unsigned long flags, void *caller)
1284{
1285 setup_vmalloc_vm(vm, va, flags, caller);
1286 insert_vmalloc_vmlist(vm);
1287}
1288
1278static struct vm_struct *__get_vm_area_node(unsigned long size, 1289static struct vm_struct *__get_vm_area_node(unsigned long size,
1279 unsigned long align, unsigned long flags, unsigned long start, 1290 unsigned long align, unsigned long flags, unsigned long start,
1280 unsigned long end, int node, gfp_t gfp_mask, void *caller) 1291 unsigned long end, int node, gfp_t gfp_mask, void *caller)
@@ -1313,7 +1324,18 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
1313 return NULL; 1324 return NULL;
1314 } 1325 }
1315 1326
1316 insert_vmalloc_vm(area, va, flags, caller); 1327 /*
1328 * When this function is called from __vmalloc_node_range,
1329 * we do not add vm_struct to vmlist here to avoid
1330 * accessing uninitialized members of vm_struct such as
1331 * pages and nr_pages fields. They will be set later.
1332 * To distinguish it from others, we use a VM_UNLIST flag.
1333 */
1334 if (flags & VM_UNLIST)
1335 setup_vmalloc_vm(area, va, flags, caller);
1336 else
1337 insert_vmalloc_vm(area, va, flags, caller);
1338
1317 return area; 1339 return area;
1318} 1340}
1319 1341
@@ -1381,17 +1403,20 @@ struct vm_struct *remove_vm_area(const void *addr)
1381 va = find_vmap_area((unsigned long)addr); 1403 va = find_vmap_area((unsigned long)addr);
1382 if (va && va->flags & VM_VM_AREA) { 1404 if (va && va->flags & VM_VM_AREA) {
1383 struct vm_struct *vm = va->private; 1405 struct vm_struct *vm = va->private;
1384 struct vm_struct *tmp, **p; 1406
1385 /* 1407 if (!(vm->flags & VM_UNLIST)) {
1386 * remove from list and disallow access to this vm_struct 1408 struct vm_struct *tmp, **p;
1387 * before unmap. (address range confliction is maintained by 1409 /*
1388 * vmap.) 1410 * remove from list and disallow access to
1389 */ 1411 * this vm_struct before unmap. (address range
1390 write_lock(&vmlist_lock); 1412 * confliction is maintained by vmap.)
1391 for (p = &vmlist; (tmp = *p) != vm; p = &tmp->next) 1413 */
1392 ; 1414 write_lock(&vmlist_lock);
1393 *p = tmp->next; 1415 for (p = &vmlist; (tmp = *p) != vm; p = &tmp->next)
1394 write_unlock(&vmlist_lock); 1416 ;
1417 *p = tmp->next;
1418 write_unlock(&vmlist_lock);
1419 }
1395 1420
1396 vmap_debug_free_range(va->va_start, va->va_end); 1421 vmap_debug_free_range(va->va_start, va->va_end);
1397 free_unmap_vmap_area(va); 1422 free_unmap_vmap_area(va);
@@ -1568,8 +1593,8 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
1568 return area->addr; 1593 return area->addr;
1569 1594
1570fail: 1595fail:
1571 warn_alloc_failed(gfp_mask, order, "vmalloc: allocation failure, " 1596 warn_alloc_failed(gfp_mask, order,
1572 "allocated %ld of %ld bytes\n", 1597 "vmalloc: allocation failure, allocated %ld of %ld bytes\n",
1573 (area->nr_pages*PAGE_SIZE), area->size); 1598 (area->nr_pages*PAGE_SIZE), area->size);
1574 vfree(area->addr); 1599 vfree(area->addr);
1575 return NULL; 1600 return NULL;
@@ -1600,17 +1625,22 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
1600 1625
1601 size = PAGE_ALIGN(size); 1626 size = PAGE_ALIGN(size);
1602 if (!size || (size >> PAGE_SHIFT) > totalram_pages) 1627 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
1603 return NULL; 1628 goto fail;
1604
1605 area = __get_vm_area_node(size, align, VM_ALLOC, start, end, node,
1606 gfp_mask, caller);
1607 1629
1630 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
1631 start, end, node, gfp_mask, caller);
1608 if (!area) 1632 if (!area)
1609 return NULL; 1633 goto fail;
1610 1634
1611 addr = __vmalloc_area_node(area, gfp_mask, prot, node, caller); 1635 addr = __vmalloc_area_node(area, gfp_mask, prot, node, caller);
1612 1636
1613 /* 1637 /*
1638 * In this function, newly allocated vm_struct is not added
1639 * to vmlist at __get_vm_area_node(). so, it is added here.
1640 */
1641 insert_vmalloc_vmlist(area);
1642
1643 /*
1614 * A ref_count = 3 is needed because the vm_struct and vmap_area 1644 * A ref_count = 3 is needed because the vm_struct and vmap_area
1615 * structures allocated in the __get_vm_area_node() function contain 1645 * structures allocated in the __get_vm_area_node() function contain
1616 * references to the virtual address of the vmalloc'ed block. 1646 * references to the virtual address of the vmalloc'ed block.
@@ -1618,6 +1648,12 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
1618 kmemleak_alloc(addr, real_size, 3, gfp_mask); 1648 kmemleak_alloc(addr, real_size, 3, gfp_mask);
1619 1649
1620 return addr; 1650 return addr;
1651
1652fail:
1653 warn_alloc_failed(gfp_mask, 0,
1654 "vmalloc: allocation failure: %lu bytes\n",
1655 real_size);
1656 return NULL;
1621} 1657}
1622 1658
1623/** 1659/**
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 9fdfce7ba403..a90c603a8d02 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -495,15 +495,6 @@ static pageout_t pageout(struct page *page, struct address_space *mapping,
495 return PAGE_ACTIVATE; 495 return PAGE_ACTIVATE;
496 } 496 }
497 497
498 /*
499 * Wait on writeback if requested to. This happens when
500 * direct reclaiming a large contiguous area and the
501 * first attempt to free a range of pages fails.
502 */
503 if (PageWriteback(page) &&
504 (sc->reclaim_mode & RECLAIM_MODE_SYNC))
505 wait_on_page_writeback(page);
506
507 if (!PageWriteback(page)) { 498 if (!PageWriteback(page)) {
508 /* synchronous write or broken a_ops? */ 499 /* synchronous write or broken a_ops? */
509 ClearPageReclaim(page); 500 ClearPageReclaim(page);
@@ -642,13 +633,14 @@ redo:
642 lru = LRU_UNEVICTABLE; 633 lru = LRU_UNEVICTABLE;
643 add_page_to_unevictable_list(page); 634 add_page_to_unevictable_list(page);
644 /* 635 /*
645 * When racing with an mlock clearing (page is 636 * When racing with an mlock or AS_UNEVICTABLE clearing
646 * unlocked), make sure that if the other thread does 637 * (page is unlocked) make sure that if the other thread
647 * not observe our setting of PG_lru and fails 638 * does not observe our setting of PG_lru and fails
648 * isolation, we see PG_mlocked cleared below and move 639 * isolation/check_move_unevictable_page,
640 * we see PG_mlocked/AS_UNEVICTABLE cleared below and move
649 * the page back to the evictable list. 641 * the page back to the evictable list.
650 * 642 *
651 * The other side is TestClearPageMlocked(). 643 * The other side is TestClearPageMlocked() or shmem_lock().
652 */ 644 */
653 smp_mb(); 645 smp_mb();
654 } 646 }
@@ -759,7 +751,10 @@ static noinline_for_stack void free_page_list(struct list_head *free_pages)
759 */ 751 */
760static unsigned long shrink_page_list(struct list_head *page_list, 752static unsigned long shrink_page_list(struct list_head *page_list,
761 struct zone *zone, 753 struct zone *zone,
762 struct scan_control *sc) 754 struct scan_control *sc,
755 int priority,
756 unsigned long *ret_nr_dirty,
757 unsigned long *ret_nr_writeback)
763{ 758{
764 LIST_HEAD(ret_pages); 759 LIST_HEAD(ret_pages);
765 LIST_HEAD(free_pages); 760 LIST_HEAD(free_pages);
@@ -767,6 +762,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,
767 unsigned long nr_dirty = 0; 762 unsigned long nr_dirty = 0;
768 unsigned long nr_congested = 0; 763 unsigned long nr_congested = 0;
769 unsigned long nr_reclaimed = 0; 764 unsigned long nr_reclaimed = 0;
765 unsigned long nr_writeback = 0;
770 766
771 cond_resched(); 767 cond_resched();
772 768
@@ -803,13 +799,12 @@ static unsigned long shrink_page_list(struct list_head *page_list,
803 (PageSwapCache(page) && (sc->gfp_mask & __GFP_IO)); 799 (PageSwapCache(page) && (sc->gfp_mask & __GFP_IO));
804 800
805 if (PageWriteback(page)) { 801 if (PageWriteback(page)) {
802 nr_writeback++;
806 /* 803 /*
807 * Synchronous reclaim is performed in two passes, 804 * Synchronous reclaim cannot queue pages for
808 * first an asynchronous pass over the list to 805 * writeback due to the possibility of stack overflow
809 * start parallel writeback, and a second synchronous 806 * but if it encounters a page under writeback, wait
810 * pass to wait for the IO to complete. Wait here 807 * for the IO to complete.
811 * for any page for which writeback has already
812 * started.
813 */ 808 */
814 if ((sc->reclaim_mode & RECLAIM_MODE_SYNC) && 809 if ((sc->reclaim_mode & RECLAIM_MODE_SYNC) &&
815 may_enter_fs) 810 may_enter_fs)
@@ -865,6 +860,25 @@ static unsigned long shrink_page_list(struct list_head *page_list,
865 if (PageDirty(page)) { 860 if (PageDirty(page)) {
866 nr_dirty++; 861 nr_dirty++;
867 862
863 /*
864 * Only kswapd can writeback filesystem pages to
865 * avoid risk of stack overflow but do not writeback
866 * unless under significant pressure.
867 */
868 if (page_is_file_cache(page) &&
869 (!current_is_kswapd() || priority >= DEF_PRIORITY - 2)) {
870 /*
871 * Immediately reclaim when written back.
872 * Similar in principal to deactivate_page()
873 * except we already have the page isolated
874 * and know it's dirty
875 */
876 inc_zone_page_state(page, NR_VMSCAN_IMMEDIATE);
877 SetPageReclaim(page);
878
879 goto keep_locked;
880 }
881
868 if (references == PAGEREF_RECLAIM_CLEAN) 882 if (references == PAGEREF_RECLAIM_CLEAN)
869 goto keep_locked; 883 goto keep_locked;
870 if (!may_enter_fs) 884 if (!may_enter_fs)
@@ -999,6 +1013,8 @@ keep_lumpy:
999 1013
1000 list_splice(&ret_pages, page_list); 1014 list_splice(&ret_pages, page_list);
1001 count_vm_events(PGACTIVATE, pgactivate); 1015 count_vm_events(PGACTIVATE, pgactivate);
1016 *ret_nr_dirty += nr_dirty;
1017 *ret_nr_writeback += nr_writeback;
1002 return nr_reclaimed; 1018 return nr_reclaimed;
1003} 1019}
1004 1020
@@ -1012,23 +1028,27 @@ keep_lumpy:
1012 * 1028 *
1013 * returns 0 on success, -ve errno on failure. 1029 * returns 0 on success, -ve errno on failure.
1014 */ 1030 */
1015int __isolate_lru_page(struct page *page, int mode, int file) 1031int __isolate_lru_page(struct page *page, isolate_mode_t mode, int file)
1016{ 1032{
1033 bool all_lru_mode;
1017 int ret = -EINVAL; 1034 int ret = -EINVAL;
1018 1035
1019 /* Only take pages on the LRU. */ 1036 /* Only take pages on the LRU. */
1020 if (!PageLRU(page)) 1037 if (!PageLRU(page))
1021 return ret; 1038 return ret;
1022 1039
1040 all_lru_mode = (mode & (ISOLATE_ACTIVE|ISOLATE_INACTIVE)) ==
1041 (ISOLATE_ACTIVE|ISOLATE_INACTIVE);
1042
1023 /* 1043 /*
1024 * When checking the active state, we need to be sure we are 1044 * When checking the active state, we need to be sure we are
1025 * dealing with comparible boolean values. Take the logical not 1045 * dealing with comparible boolean values. Take the logical not
1026 * of each. 1046 * of each.
1027 */ 1047 */
1028 if (mode != ISOLATE_BOTH && (!PageActive(page) != !mode)) 1048 if (!all_lru_mode && !PageActive(page) != !(mode & ISOLATE_ACTIVE))
1029 return ret; 1049 return ret;
1030 1050
1031 if (mode != ISOLATE_BOTH && page_is_file_cache(page) != file) 1051 if (!all_lru_mode && !!page_is_file_cache(page) != file)
1032 return ret; 1052 return ret;
1033 1053
1034 /* 1054 /*
@@ -1041,6 +1061,12 @@ int __isolate_lru_page(struct page *page, int mode, int file)
1041 1061
1042 ret = -EBUSY; 1062 ret = -EBUSY;
1043 1063
1064 if ((mode & ISOLATE_CLEAN) && (PageDirty(page) || PageWriteback(page)))
1065 return ret;
1066
1067 if ((mode & ISOLATE_UNMAPPED) && page_mapped(page))
1068 return ret;
1069
1044 if (likely(get_page_unless_zero(page))) { 1070 if (likely(get_page_unless_zero(page))) {
1045 /* 1071 /*
1046 * Be careful not to clear PageLRU until after we're 1072 * Be careful not to clear PageLRU until after we're
@@ -1076,7 +1102,8 @@ int __isolate_lru_page(struct page *page, int mode, int file)
1076 */ 1102 */
1077static unsigned long isolate_lru_pages(unsigned long nr_to_scan, 1103static unsigned long isolate_lru_pages(unsigned long nr_to_scan,
1078 struct list_head *src, struct list_head *dst, 1104 struct list_head *src, struct list_head *dst,
1079 unsigned long *scanned, int order, int mode, int file) 1105 unsigned long *scanned, int order, isolate_mode_t mode,
1106 int file)
1080{ 1107{
1081 unsigned long nr_taken = 0; 1108 unsigned long nr_taken = 0;
1082 unsigned long nr_lumpy_taken = 0; 1109 unsigned long nr_lumpy_taken = 0;
@@ -1201,8 +1228,8 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,
1201static unsigned long isolate_pages_global(unsigned long nr, 1228static unsigned long isolate_pages_global(unsigned long nr,
1202 struct list_head *dst, 1229 struct list_head *dst,
1203 unsigned long *scanned, int order, 1230 unsigned long *scanned, int order,
1204 int mode, struct zone *z, 1231 isolate_mode_t mode,
1205 int active, int file) 1232 struct zone *z, int active, int file)
1206{ 1233{
1207 int lru = LRU_BASE; 1234 int lru = LRU_BASE;
1208 if (active) 1235 if (active)
@@ -1394,7 +1421,7 @@ static noinline_for_stack void update_isolated_counts(struct zone *zone,
1394} 1421}
1395 1422
1396/* 1423/*
1397 * Returns true if the caller should wait to clean dirty/writeback pages. 1424 * Returns true if a direct reclaim should wait on pages under writeback.
1398 * 1425 *
1399 * If we are direct reclaiming for contiguous pages and we do not reclaim 1426 * If we are direct reclaiming for contiguous pages and we do not reclaim
1400 * everything in the list, try again and wait for writeback IO to complete. 1427 * everything in the list, try again and wait for writeback IO to complete.
@@ -1448,6 +1475,9 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone,
1448 unsigned long nr_taken; 1475 unsigned long nr_taken;
1449 unsigned long nr_anon; 1476 unsigned long nr_anon;
1450 unsigned long nr_file; 1477 unsigned long nr_file;
1478 unsigned long nr_dirty = 0;
1479 unsigned long nr_writeback = 0;
1480 isolate_mode_t reclaim_mode = ISOLATE_INACTIVE;
1451 1481
1452 while (unlikely(too_many_isolated(zone, file, sc))) { 1482 while (unlikely(too_many_isolated(zone, file, sc))) {
1453 congestion_wait(BLK_RW_ASYNC, HZ/10); 1483 congestion_wait(BLK_RW_ASYNC, HZ/10);
@@ -1458,15 +1488,21 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone,
1458 } 1488 }
1459 1489
1460 set_reclaim_mode(priority, sc, false); 1490 set_reclaim_mode(priority, sc, false);
1491 if (sc->reclaim_mode & RECLAIM_MODE_LUMPYRECLAIM)
1492 reclaim_mode |= ISOLATE_ACTIVE;
1493
1461 lru_add_drain(); 1494 lru_add_drain();
1495
1496 if (!sc->may_unmap)
1497 reclaim_mode |= ISOLATE_UNMAPPED;
1498 if (!sc->may_writepage)
1499 reclaim_mode |= ISOLATE_CLEAN;
1500
1462 spin_lock_irq(&zone->lru_lock); 1501 spin_lock_irq(&zone->lru_lock);
1463 1502
1464 if (scanning_global_lru(sc)) { 1503 if (scanning_global_lru(sc)) {
1465 nr_taken = isolate_pages_global(nr_to_scan, 1504 nr_taken = isolate_pages_global(nr_to_scan, &page_list,
1466 &page_list, &nr_scanned, sc->order, 1505 &nr_scanned, sc->order, reclaim_mode, zone, 0, file);
1467 sc->reclaim_mode & RECLAIM_MODE_LUMPYRECLAIM ?
1468 ISOLATE_BOTH : ISOLATE_INACTIVE,
1469 zone, 0, file);
1470 zone->pages_scanned += nr_scanned; 1506 zone->pages_scanned += nr_scanned;
1471 if (current_is_kswapd()) 1507 if (current_is_kswapd())
1472 __count_zone_vm_events(PGSCAN_KSWAPD, zone, 1508 __count_zone_vm_events(PGSCAN_KSWAPD, zone,
@@ -1475,12 +1511,9 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone,
1475 __count_zone_vm_events(PGSCAN_DIRECT, zone, 1511 __count_zone_vm_events(PGSCAN_DIRECT, zone,
1476 nr_scanned); 1512 nr_scanned);
1477 } else { 1513 } else {
1478 nr_taken = mem_cgroup_isolate_pages(nr_to_scan, 1514 nr_taken = mem_cgroup_isolate_pages(nr_to_scan, &page_list,
1479 &page_list, &nr_scanned, sc->order, 1515 &nr_scanned, sc->order, reclaim_mode, zone,
1480 sc->reclaim_mode & RECLAIM_MODE_LUMPYRECLAIM ? 1516 sc->mem_cgroup, 0, file);
1481 ISOLATE_BOTH : ISOLATE_INACTIVE,
1482 zone, sc->mem_cgroup,
1483 0, file);
1484 /* 1517 /*
1485 * mem_cgroup_isolate_pages() keeps track of 1518 * mem_cgroup_isolate_pages() keeps track of
1486 * scanned pages on its own. 1519 * scanned pages on its own.
@@ -1496,12 +1529,14 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone,
1496 1529
1497 spin_unlock_irq(&zone->lru_lock); 1530 spin_unlock_irq(&zone->lru_lock);
1498 1531
1499 nr_reclaimed = shrink_page_list(&page_list, zone, sc); 1532 nr_reclaimed = shrink_page_list(&page_list, zone, sc, priority,
1533 &nr_dirty, &nr_writeback);
1500 1534
1501 /* Check if we should syncronously wait for writeback */ 1535 /* Check if we should syncronously wait for writeback */
1502 if (should_reclaim_stall(nr_taken, nr_reclaimed, priority, sc)) { 1536 if (should_reclaim_stall(nr_taken, nr_reclaimed, priority, sc)) {
1503 set_reclaim_mode(priority, sc, true); 1537 set_reclaim_mode(priority, sc, true);
1504 nr_reclaimed += shrink_page_list(&page_list, zone, sc); 1538 nr_reclaimed += shrink_page_list(&page_list, zone, sc,
1539 priority, &nr_dirty, &nr_writeback);
1505 } 1540 }
1506 1541
1507 local_irq_disable(); 1542 local_irq_disable();
@@ -1511,6 +1546,32 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone,
1511 1546
1512 putback_lru_pages(zone, sc, nr_anon, nr_file, &page_list); 1547 putback_lru_pages(zone, sc, nr_anon, nr_file, &page_list);
1513 1548
1549 /*
1550 * If reclaim is isolating dirty pages under writeback, it implies
1551 * that the long-lived page allocation rate is exceeding the page
1552 * laundering rate. Either the global limits are not being effective
1553 * at throttling processes due to the page distribution throughout
1554 * zones or there is heavy usage of a slow backing device. The
1555 * only option is to throttle from reclaim context which is not ideal
1556 * as there is no guarantee the dirtying process is throttled in the
1557 * same way balance_dirty_pages() manages.
1558 *
1559 * This scales the number of dirty pages that must be under writeback
1560 * before throttling depending on priority. It is a simple backoff
1561 * function that has the most effect in the range DEF_PRIORITY to
1562 * DEF_PRIORITY-2 which is the priority reclaim is considered to be
1563 * in trouble and reclaim is considered to be in trouble.
1564 *
1565 * DEF_PRIORITY 100% isolated pages must be PageWriteback to throttle
1566 * DEF_PRIORITY-1 50% must be PageWriteback
1567 * DEF_PRIORITY-2 25% must be PageWriteback, kswapd in trouble
1568 * ...
1569 * DEF_PRIORITY-6 For SWAP_CLUSTER_MAX isolated pages, throttle if any
1570 * isolated page is PageWriteback
1571 */
1572 if (nr_writeback && nr_writeback >= (nr_taken >> (DEF_PRIORITY-priority)))
1573 wait_iff_congested(zone, BLK_RW_ASYNC, HZ/10);
1574
1514 trace_mm_vmscan_lru_shrink_inactive(zone->zone_pgdat->node_id, 1575 trace_mm_vmscan_lru_shrink_inactive(zone->zone_pgdat->node_id,
1515 zone_idx(zone), 1576 zone_idx(zone),
1516 nr_scanned, nr_reclaimed, 1577 nr_scanned, nr_reclaimed,
@@ -1582,19 +1643,26 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone,
1582 struct page *page; 1643 struct page *page;
1583 struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(zone, sc); 1644 struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(zone, sc);
1584 unsigned long nr_rotated = 0; 1645 unsigned long nr_rotated = 0;
1646 isolate_mode_t reclaim_mode = ISOLATE_ACTIVE;
1585 1647
1586 lru_add_drain(); 1648 lru_add_drain();
1649
1650 if (!sc->may_unmap)
1651 reclaim_mode |= ISOLATE_UNMAPPED;
1652 if (!sc->may_writepage)
1653 reclaim_mode |= ISOLATE_CLEAN;
1654
1587 spin_lock_irq(&zone->lru_lock); 1655 spin_lock_irq(&zone->lru_lock);
1588 if (scanning_global_lru(sc)) { 1656 if (scanning_global_lru(sc)) {
1589 nr_taken = isolate_pages_global(nr_pages, &l_hold, 1657 nr_taken = isolate_pages_global(nr_pages, &l_hold,
1590 &pgscanned, sc->order, 1658 &pgscanned, sc->order,
1591 ISOLATE_ACTIVE, zone, 1659 reclaim_mode, zone,
1592 1, file); 1660 1, file);
1593 zone->pages_scanned += pgscanned; 1661 zone->pages_scanned += pgscanned;
1594 } else { 1662 } else {
1595 nr_taken = mem_cgroup_isolate_pages(nr_pages, &l_hold, 1663 nr_taken = mem_cgroup_isolate_pages(nr_pages, &l_hold,
1596 &pgscanned, sc->order, 1664 &pgscanned, sc->order,
1597 ISOLATE_ACTIVE, zone, 1665 reclaim_mode, zone,
1598 sc->mem_cgroup, 1, file); 1666 sc->mem_cgroup, 1, file);
1599 /* 1667 /*
1600 * mem_cgroup_isolate_pages() keeps track of 1668 * mem_cgroup_isolate_pages() keeps track of
@@ -1795,12 +1863,19 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
1795 enum lru_list l; 1863 enum lru_list l;
1796 int noswap = 0; 1864 int noswap = 0;
1797 bool force_scan = false; 1865 bool force_scan = false;
1798 unsigned long nr_force_scan[2];
1799 1866
1800 /* kswapd does zone balancing and needs to scan this zone */ 1867 /*
1868 * If the zone or memcg is small, nr[l] can be 0. This
1869 * results in no scanning on this priority and a potential
1870 * priority drop. Global direct reclaim can go to the next
1871 * zone and tends to have no problems. Global kswapd is for
1872 * zone balancing and it needs to scan a minimum amount. When
1873 * reclaiming for a memcg, a priority drop can cause high
1874 * latencies, so it's better to scan a minimum amount there as
1875 * well.
1876 */
1801 if (scanning_global_lru(sc) && current_is_kswapd()) 1877 if (scanning_global_lru(sc) && current_is_kswapd())
1802 force_scan = true; 1878 force_scan = true;
1803 /* memcg may have small limit and need to avoid priority drop */
1804 if (!scanning_global_lru(sc)) 1879 if (!scanning_global_lru(sc))
1805 force_scan = true; 1880 force_scan = true;
1806 1881
@@ -1810,8 +1885,6 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
1810 fraction[0] = 0; 1885 fraction[0] = 0;
1811 fraction[1] = 1; 1886 fraction[1] = 1;
1812 denominator = 1; 1887 denominator = 1;
1813 nr_force_scan[0] = 0;
1814 nr_force_scan[1] = SWAP_CLUSTER_MAX;
1815 goto out; 1888 goto out;
1816 } 1889 }
1817 1890
@@ -1828,8 +1901,6 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
1828 fraction[0] = 1; 1901 fraction[0] = 1;
1829 fraction[1] = 0; 1902 fraction[1] = 0;
1830 denominator = 1; 1903 denominator = 1;
1831 nr_force_scan[0] = SWAP_CLUSTER_MAX;
1832 nr_force_scan[1] = 0;
1833 goto out; 1904 goto out;
1834 } 1905 }
1835 } 1906 }
@@ -1878,11 +1949,6 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
1878 fraction[0] = ap; 1949 fraction[0] = ap;
1879 fraction[1] = fp; 1950 fraction[1] = fp;
1880 denominator = ap + fp + 1; 1951 denominator = ap + fp + 1;
1881 if (force_scan) {
1882 unsigned long scan = SWAP_CLUSTER_MAX;
1883 nr_force_scan[0] = div64_u64(scan * ap, denominator);
1884 nr_force_scan[1] = div64_u64(scan * fp, denominator);
1885 }
1886out: 1952out:
1887 for_each_evictable_lru(l) { 1953 for_each_evictable_lru(l) {
1888 int file = is_file_lru(l); 1954 int file = is_file_lru(l);
@@ -1891,20 +1957,10 @@ out:
1891 scan = zone_nr_lru_pages(zone, sc, l); 1957 scan = zone_nr_lru_pages(zone, sc, l);
1892 if (priority || noswap) { 1958 if (priority || noswap) {
1893 scan >>= priority; 1959 scan >>= priority;
1960 if (!scan && force_scan)
1961 scan = SWAP_CLUSTER_MAX;
1894 scan = div64_u64(scan * fraction[file], denominator); 1962 scan = div64_u64(scan * fraction[file], denominator);
1895 } 1963 }
1896
1897 /*
1898 * If zone is small or memcg is small, nr[l] can be 0.
1899 * This results no-scan on this priority and priority drop down.
1900 * For global direct reclaim, it can visit next zone and tend
1901 * not to have problems. For global kswapd, it's for zone
1902 * balancing and it need to scan a small amounts. When using
1903 * memcg, priority drop can cause big latency. So, it's better
1904 * to scan small amount. See may_noscan above.
1905 */
1906 if (!scan && force_scan)
1907 scan = nr_force_scan[file];
1908 nr[l] = scan; 1964 nr[l] = scan;
1909 } 1965 }
1910} 1966}
@@ -1983,12 +2039,14 @@ static void shrink_zone(int priority, struct zone *zone,
1983 enum lru_list l; 2039 enum lru_list l;
1984 unsigned long nr_reclaimed, nr_scanned; 2040 unsigned long nr_reclaimed, nr_scanned;
1985 unsigned long nr_to_reclaim = sc->nr_to_reclaim; 2041 unsigned long nr_to_reclaim = sc->nr_to_reclaim;
2042 struct blk_plug plug;
1986 2043
1987restart: 2044restart:
1988 nr_reclaimed = 0; 2045 nr_reclaimed = 0;
1989 nr_scanned = sc->nr_scanned; 2046 nr_scanned = sc->nr_scanned;
1990 get_scan_count(zone, sc, nr, priority); 2047 get_scan_count(zone, sc, nr, priority);
1991 2048
2049 blk_start_plug(&plug);
1992 while (nr[LRU_INACTIVE_ANON] || nr[LRU_ACTIVE_FILE] || 2050 while (nr[LRU_INACTIVE_ANON] || nr[LRU_ACTIVE_FILE] ||
1993 nr[LRU_INACTIVE_FILE]) { 2051 nr[LRU_INACTIVE_FILE]) {
1994 for_each_evictable_lru(l) { 2052 for_each_evictable_lru(l) {
@@ -2012,6 +2070,7 @@ restart:
2012 if (nr_reclaimed >= nr_to_reclaim && priority < DEF_PRIORITY) 2070 if (nr_reclaimed >= nr_to_reclaim && priority < DEF_PRIORITY)
2013 break; 2071 break;
2014 } 2072 }
2073 blk_finish_plug(&plug);
2015 sc->nr_reclaimed += nr_reclaimed; 2074 sc->nr_reclaimed += nr_reclaimed;
2016 2075
2017 /* 2076 /*
@@ -2044,14 +2103,19 @@ restart:
2044 * 2103 *
2045 * If a zone is deemed to be full of pinned pages then just give it a light 2104 * If a zone is deemed to be full of pinned pages then just give it a light
2046 * scan then give up on it. 2105 * scan then give up on it.
2106 *
2107 * This function returns true if a zone is being reclaimed for a costly
2108 * high-order allocation and compaction is either ready to begin or deferred.
2109 * This indicates to the caller that it should retry the allocation or fail.
2047 */ 2110 */
2048static void shrink_zones(int priority, struct zonelist *zonelist, 2111static bool shrink_zones(int priority, struct zonelist *zonelist,
2049 struct scan_control *sc) 2112 struct scan_control *sc)
2050{ 2113{
2051 struct zoneref *z; 2114 struct zoneref *z;
2052 struct zone *zone; 2115 struct zone *zone;
2053 unsigned long nr_soft_reclaimed; 2116 unsigned long nr_soft_reclaimed;
2054 unsigned long nr_soft_scanned; 2117 unsigned long nr_soft_scanned;
2118 bool should_abort_reclaim = false;
2055 2119
2056 for_each_zone_zonelist_nodemask(zone, z, zonelist, 2120 for_each_zone_zonelist_nodemask(zone, z, zonelist,
2057 gfp_zone(sc->gfp_mask), sc->nodemask) { 2121 gfp_zone(sc->gfp_mask), sc->nodemask) {
@@ -2066,6 +2130,23 @@ static void shrink_zones(int priority, struct zonelist *zonelist,
2066 continue; 2130 continue;
2067 if (zone->all_unreclaimable && priority != DEF_PRIORITY) 2131 if (zone->all_unreclaimable && priority != DEF_PRIORITY)
2068 continue; /* Let kswapd poll it */ 2132 continue; /* Let kswapd poll it */
2133 if (COMPACTION_BUILD) {
2134 /*
2135 * If we already have plenty of memory free for
2136 * compaction in this zone, don't free any more.
2137 * Even though compaction is invoked for any
2138 * non-zero order, only frequent costly order
2139 * reclamation is disruptive enough to become a
2140 * noticable problem, like transparent huge page
2141 * allocations.
2142 */
2143 if (sc->order > PAGE_ALLOC_COSTLY_ORDER &&
2144 (compaction_suitable(zone, sc->order) ||
2145 compaction_deferred(zone))) {
2146 should_abort_reclaim = true;
2147 continue;
2148 }
2149 }
2069 /* 2150 /*
2070 * This steals pages from memory cgroups over softlimit 2151 * This steals pages from memory cgroups over softlimit
2071 * and returns the number of reclaimed pages and 2152 * and returns the number of reclaimed pages and
@@ -2083,6 +2164,8 @@ static void shrink_zones(int priority, struct zonelist *zonelist,
2083 2164
2084 shrink_zone(priority, zone, sc); 2165 shrink_zone(priority, zone, sc);
2085 } 2166 }
2167
2168 return should_abort_reclaim;
2086} 2169}
2087 2170
2088static bool zone_reclaimable(struct zone *zone) 2171static bool zone_reclaimable(struct zone *zone)
@@ -2147,7 +2230,9 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
2147 sc->nr_scanned = 0; 2230 sc->nr_scanned = 0;
2148 if (!priority) 2231 if (!priority)
2149 disable_swap_token(sc->mem_cgroup); 2232 disable_swap_token(sc->mem_cgroup);
2150 shrink_zones(priority, zonelist, sc); 2233 if (shrink_zones(priority, zonelist, sc))
2234 break;
2235
2151 /* 2236 /*
2152 * Don't shrink slabs when reclaiming memory from 2237 * Don't shrink slabs when reclaiming memory from
2153 * over limit cgroups 2238 * over limit cgroups
@@ -2690,6 +2775,8 @@ out:
2690 2775
2691 /* If balanced, clear the congested flag */ 2776 /* If balanced, clear the congested flag */
2692 zone_clear_flag(zone, ZONE_CONGESTED); 2777 zone_clear_flag(zone, ZONE_CONGESTED);
2778 if (i <= *classzone_idx)
2779 balanced += zone->present_pages;
2693 } 2780 }
2694 } 2781 }
2695 2782
@@ -2763,7 +2850,9 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int order, int classzone_idx)
2763static int kswapd(void *p) 2850static int kswapd(void *p)
2764{ 2851{
2765 unsigned long order, new_order; 2852 unsigned long order, new_order;
2853 unsigned balanced_order;
2766 int classzone_idx, new_classzone_idx; 2854 int classzone_idx, new_classzone_idx;
2855 int balanced_classzone_idx;
2767 pg_data_t *pgdat = (pg_data_t*)p; 2856 pg_data_t *pgdat = (pg_data_t*)p;
2768 struct task_struct *tsk = current; 2857 struct task_struct *tsk = current;
2769 2858
@@ -2794,7 +2883,9 @@ static int kswapd(void *p)
2794 set_freezable(); 2883 set_freezable();
2795 2884
2796 order = new_order = 0; 2885 order = new_order = 0;
2886 balanced_order = 0;
2797 classzone_idx = new_classzone_idx = pgdat->nr_zones - 1; 2887 classzone_idx = new_classzone_idx = pgdat->nr_zones - 1;
2888 balanced_classzone_idx = classzone_idx;
2798 for ( ; ; ) { 2889 for ( ; ; ) {
2799 int ret; 2890 int ret;
2800 2891
@@ -2803,7 +2894,8 @@ static int kswapd(void *p)
2803 * new request of a similar or harder type will succeed soon 2894 * new request of a similar or harder type will succeed soon
2804 * so consider going to sleep on the basis we reclaimed at 2895 * so consider going to sleep on the basis we reclaimed at
2805 */ 2896 */
2806 if (classzone_idx >= new_classzone_idx && order == new_order) { 2897 if (balanced_classzone_idx >= new_classzone_idx &&
2898 balanced_order == new_order) {
2807 new_order = pgdat->kswapd_max_order; 2899 new_order = pgdat->kswapd_max_order;
2808 new_classzone_idx = pgdat->classzone_idx; 2900 new_classzone_idx = pgdat->classzone_idx;
2809 pgdat->kswapd_max_order = 0; 2901 pgdat->kswapd_max_order = 0;
@@ -2818,9 +2910,12 @@ static int kswapd(void *p)
2818 order = new_order; 2910 order = new_order;
2819 classzone_idx = new_classzone_idx; 2911 classzone_idx = new_classzone_idx;
2820 } else { 2912 } else {
2821 kswapd_try_to_sleep(pgdat, order, classzone_idx); 2913 kswapd_try_to_sleep(pgdat, balanced_order,
2914 balanced_classzone_idx);
2822 order = pgdat->kswapd_max_order; 2915 order = pgdat->kswapd_max_order;
2823 classzone_idx = pgdat->classzone_idx; 2916 classzone_idx = pgdat->classzone_idx;
2917 new_order = order;
2918 new_classzone_idx = classzone_idx;
2824 pgdat->kswapd_max_order = 0; 2919 pgdat->kswapd_max_order = 0;
2825 pgdat->classzone_idx = pgdat->nr_zones - 1; 2920 pgdat->classzone_idx = pgdat->nr_zones - 1;
2826 } 2921 }
@@ -2835,7 +2930,9 @@ static int kswapd(void *p)
2835 */ 2930 */
2836 if (!ret) { 2931 if (!ret) {
2837 trace_mm_vmscan_kswapd_wake(pgdat->node_id, order); 2932 trace_mm_vmscan_kswapd_wake(pgdat->node_id, order);
2838 order = balance_pgdat(pgdat, order, &classzone_idx); 2933 balanced_classzone_idx = classzone_idx;
2934 balanced_order = balance_pgdat(pgdat, order,
2935 &balanced_classzone_idx);
2839 } 2936 }
2840 } 2937 }
2841 return 0; 2938 return 0;
@@ -3347,66 +3444,12 @@ void scan_mapping_unevictable_pages(struct address_space *mapping)
3347 3444
3348} 3445}
3349 3446
3350/** 3447static void warn_scan_unevictable_pages(void)
3351 * scan_zone_unevictable_pages - check unevictable list for evictable pages
3352 * @zone - zone of which to scan the unevictable list
3353 *
3354 * Scan @zone's unevictable LRU lists to check for pages that have become
3355 * evictable. Move those that have to @zone's inactive list where they
3356 * become candidates for reclaim, unless shrink_inactive_zone() decides
3357 * to reactivate them. Pages that are still unevictable are rotated
3358 * back onto @zone's unevictable list.
3359 */
3360#define SCAN_UNEVICTABLE_BATCH_SIZE 16UL /* arbitrary lock hold batch size */
3361static void scan_zone_unevictable_pages(struct zone *zone)
3362{ 3448{
3363 struct list_head *l_unevictable = &zone->lru[LRU_UNEVICTABLE].list; 3449 printk_once(KERN_WARNING
3364 unsigned long scan; 3450 "The scan_unevictable_pages sysctl/node-interface has been "
3365 unsigned long nr_to_scan = zone_page_state(zone, NR_UNEVICTABLE); 3451 "disabled for lack of a legitimate use case. If you have "
3366 3452 "one, please send an email to linux-mm@kvack.org.\n");
3367 while (nr_to_scan > 0) {
3368 unsigned long batch_size = min(nr_to_scan,
3369 SCAN_UNEVICTABLE_BATCH_SIZE);
3370
3371 spin_lock_irq(&zone->lru_lock);
3372 for (scan = 0; scan < batch_size; scan++) {
3373 struct page *page = lru_to_page(l_unevictable);
3374
3375 if (!trylock_page(page))
3376 continue;
3377
3378 prefetchw_prev_lru_page(page, l_unevictable, flags);
3379
3380 if (likely(PageLRU(page) && PageUnevictable(page)))
3381 check_move_unevictable_page(page, zone);
3382
3383 unlock_page(page);
3384 }
3385 spin_unlock_irq(&zone->lru_lock);
3386
3387 nr_to_scan -= batch_size;
3388 }
3389}
3390
3391
3392/**
3393 * scan_all_zones_unevictable_pages - scan all unevictable lists for evictable pages
3394 *
3395 * A really big hammer: scan all zones' unevictable LRU lists to check for
3396 * pages that have become evictable. Move those back to the zones'
3397 * inactive list where they become candidates for reclaim.
3398 * This occurs when, e.g., we have unswappable pages on the unevictable lists,
3399 * and we add swap to the system. As such, it runs in the context of a task
3400 * that has possibly/probably made some previously unevictable pages
3401 * evictable.
3402 */
3403static void scan_all_zones_unevictable_pages(void)
3404{
3405 struct zone *zone;
3406
3407 for_each_zone(zone) {
3408 scan_zone_unevictable_pages(zone);
3409 }
3410} 3453}
3411 3454
3412/* 3455/*
@@ -3419,11 +3462,8 @@ int scan_unevictable_handler(struct ctl_table *table, int write,
3419 void __user *buffer, 3462 void __user *buffer,
3420 size_t *length, loff_t *ppos) 3463 size_t *length, loff_t *ppos)
3421{ 3464{
3465 warn_scan_unevictable_pages();
3422 proc_doulongvec_minmax(table, write, buffer, length, ppos); 3466 proc_doulongvec_minmax(table, write, buffer, length, ppos);
3423
3424 if (write && *(unsigned long *)table->data)
3425 scan_all_zones_unevictable_pages();
3426
3427 scan_unevictable_pages = 0; 3467 scan_unevictable_pages = 0;
3428 return 0; 3468 return 0;
3429} 3469}
@@ -3438,6 +3478,7 @@ static ssize_t read_scan_unevictable_node(struct sys_device *dev,
3438 struct sysdev_attribute *attr, 3478 struct sysdev_attribute *attr,
3439 char *buf) 3479 char *buf)
3440{ 3480{
3481 warn_scan_unevictable_pages();
3441 return sprintf(buf, "0\n"); /* always zero; should fit... */ 3482 return sprintf(buf, "0\n"); /* always zero; should fit... */
3442} 3483}
3443 3484
@@ -3445,19 +3486,7 @@ static ssize_t write_scan_unevictable_node(struct sys_device *dev,
3445 struct sysdev_attribute *attr, 3486 struct sysdev_attribute *attr,
3446 const char *buf, size_t count) 3487 const char *buf, size_t count)
3447{ 3488{
3448 struct zone *node_zones = NODE_DATA(dev->id)->node_zones; 3489 warn_scan_unevictable_pages();
3449 struct zone *zone;
3450 unsigned long res;
3451 unsigned long req = strict_strtoul(buf, 10, &res);
3452
3453 if (!req)
3454 return 1; /* zero is no-op */
3455
3456 for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) {
3457 if (!populated_zone(zone))
3458 continue;
3459 scan_zone_unevictable_pages(zone);
3460 }
3461 return 1; 3490 return 1;
3462} 3491}
3463 3492
diff --git a/mm/vmstat.c b/mm/vmstat.c
index d52b13d28e8f..8fd603b1665e 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
78 * 78 *
79 * vm_stat contains the global counters 79 * vm_stat contains the global counters
80 */ 80 */
81atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS]; 81atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
82EXPORT_SYMBOL(vm_stat); 82EXPORT_SYMBOL(vm_stat);
83 83
84#ifdef CONFIG_SMP 84#ifdef CONFIG_SMP
@@ -702,6 +702,7 @@ const char * const vmstat_text[] = {
702 "nr_unstable", 702 "nr_unstable",
703 "nr_bounce", 703 "nr_bounce",
704 "nr_vmscan_write", 704 "nr_vmscan_write",
705 "nr_vmscan_immediate_reclaim",
705 "nr_writeback_temp", 706 "nr_writeback_temp",
706 "nr_isolated_anon", 707 "nr_isolated_anon",
707 "nr_isolated_file", 708 "nr_isolated_file",
diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h
index b6753f45624e..d86583f4831d 100644
--- a/net/nfc/nfc.h
+++ b/net/nfc/nfc.h
@@ -27,7 +27,7 @@
27#include <net/nfc/nfc.h> 27#include <net/nfc/nfc.h>
28#include <net/sock.h> 28#include <net/sock.h>
29 29
30__attribute__((format (printf, 2, 3))) 30__printf(2, 3)
31int nfc_printk(const char *level, const char *fmt, ...); 31int nfc_printk(const char *level, const char *fmt, ...);
32 32
33#define nfc_info(fmt, arg...) nfc_printk(KERN_INFO, fmt, ##arg) 33#define nfc_info(fmt, arg...) nfc_printk(KERN_INFO, fmt, ##arg)
diff --git a/net/rds/rds.h b/net/rds/rds.h
index da8adac2bf06..7eaba1831f0d 100644
--- a/net/rds/rds.h
+++ b/net/rds/rds.h
@@ -36,8 +36,8 @@
36#define rdsdebug(fmt, args...) pr_debug("%s(): " fmt, __func__ , ##args) 36#define rdsdebug(fmt, args...) pr_debug("%s(): " fmt, __func__ , ##args)
37#else 37#else
38/* sigh, pr_debug() causes unused variable warnings */ 38/* sigh, pr_debug() causes unused variable warnings */
39static inline void __attribute__ ((format (printf, 1, 2))) 39static inline __printf(1, 2)
40rdsdebug(char *fmt, ...) 40void rdsdebug(char *fmt, ...)
41{ 41{
42} 42}
43#endif 43#endif
@@ -625,8 +625,8 @@ void rds_for_each_conn_info(struct socket *sock, unsigned int len,
625 struct rds_info_lengths *lens, 625 struct rds_info_lengths *lens,
626 int (*visitor)(struct rds_connection *, void *), 626 int (*visitor)(struct rds_connection *, void *),
627 size_t item_len); 627 size_t item_len);
628void __rds_conn_error(struct rds_connection *conn, const char *, ...) 628__printf(2, 3)
629 __attribute__ ((format (printf, 2, 3))); 629void __rds_conn_error(struct rds_connection *conn, const char *, ...);
630#define rds_conn_error(conn, fmt...) \ 630#define rds_conn_error(conn, fmt...) \
631 __rds_conn_error(conn, KERN_WARNING "RDS: " fmt) 631 __rds_conn_error(conn, KERN_WARNING "RDS: " fmt)
632 632
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 30d70abb4e2c..dd5cc00ed559 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -971,9 +971,8 @@ static void svc_unregister(const struct svc_serv *serv)
971/* 971/*
972 * Printk the given error with the address of the client that caused it. 972 * Printk the given error with the address of the client that caused it.
973 */ 973 */
974static int 974static __printf(2, 3)
975__attribute__ ((format (printf, 2, 3))) 975int svc_printk(struct svc_rqst *rqstp, const char *fmt, ...)
976svc_printk(struct svc_rqst *rqstp, const char *fmt, ...)
977{ 976{
978 va_list args; 977 va_list args;
979 int r; 978 int r;
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 0b3e35c9ef08..5e93342d22f9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -240,9 +240,8 @@ our $NonptrType;
240our $Type; 240our $Type;
241our $Declare; 241our $Declare;
242 242
243our $UTF8 = qr { 243our $NON_ASCII_UTF8 = qr{
244 [\x09\x0A\x0D\x20-\x7E] # ASCII 244 [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
245 | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
246 | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs 245 | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
247 | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte 246 | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
248 | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates 247 | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
@@ -251,6 +250,11 @@ our $UTF8 = qr {
251 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 250 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
252}x; 251}x;
253 252
253our $UTF8 = qr{
254 [\x09\x0A\x0D\x20-\x7E] # ASCII
255 | $NON_ASCII_UTF8
256}x;
257
254our $typeTypedefs = qr{(?x: 258our $typeTypedefs = qr{(?x:
255 (?:__)?(?:u|s|be|le)(?:8|16|32|64)| 259 (?:__)?(?:u|s|be|le)(?:8|16|32|64)|
256 atomic_t 260 atomic_t
@@ -1330,6 +1334,9 @@ sub process {
1330 my $signoff = 0; 1334 my $signoff = 0;
1331 my $is_patch = 0; 1335 my $is_patch = 0;
1332 1336
1337 my $in_header_lines = 1;
1338 my $in_commit_log = 0; #Scanning lines before patch
1339
1333 our @report = (); 1340 our @report = ();
1334 our $cnt_lines = 0; 1341 our $cnt_lines = 0;
1335 our $cnt_error = 0; 1342 our $cnt_error = 0;
@@ -1497,7 +1504,6 @@ sub process {
1497 if ($line =~ /^diff --git.*?(\S+)$/) { 1504 if ($line =~ /^diff --git.*?(\S+)$/) {
1498 $realfile = $1; 1505 $realfile = $1;
1499 $realfile =~ s@^([^/]*)/@@; 1506 $realfile =~ s@^([^/]*)/@@;
1500
1501 } elsif ($line =~ /^\+\+\+\s+(\S+)/) { 1507 } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
1502 $realfile = $1; 1508 $realfile = $1;
1503 $realfile =~ s@^([^/]*)/@@; 1509 $realfile =~ s@^([^/]*)/@@;
@@ -1536,6 +1542,7 @@ sub process {
1536# Check the patch for a signoff: 1542# Check the patch for a signoff:
1537 if ($line =~ /^\s*signed-off-by:/i) { 1543 if ($line =~ /^\s*signed-off-by:/i) {
1538 $signoff++; 1544 $signoff++;
1545 $in_commit_log = 0;
1539 } 1546 }
1540 1547
1541# Check signature styles 1548# Check signature styles
@@ -1613,6 +1620,21 @@ sub process {
1613 "Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr); 1620 "Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr);
1614 } 1621 }
1615 1622
1623# Check if it's the start of a commit log
1624# (not a header line and we haven't seen the patch filename)
1625 if ($in_header_lines && $realfile =~ /^$/ &&
1626 $rawline !~ /^(commit\b|from\b|\w+:).+$/i) {
1627 $in_header_lines = 0;
1628 $in_commit_log = 1;
1629 }
1630
1631# Still not yet in a patch, check for any UTF-8
1632 if ($in_commit_log && $realfile =~ /^$/ &&
1633 $rawline =~ /$NON_ASCII_UTF8/) {
1634 CHK("UTF8_BEFORE_PATCH",
1635 "8-bit UTF-8 used in possible commit log\n" . $herecurr);
1636 }
1637
1616# ignore non-hunk lines and lines being removed 1638# ignore non-hunk lines and lines being removed
1617 next if (!$hunk_line || $line =~ /^-/); 1639 next if (!$hunk_line || $line =~ /^-/);
1618 1640
@@ -3151,10 +3173,10 @@ sub process {
3151 "consider using a completion\n" . $herecurr); 3173 "consider using a completion\n" . $herecurr);
3152 3174
3153 } 3175 }
3154# recommend kstrto* over simple_strto* 3176# recommend kstrto* over simple_strto* and strict_strto*
3155 if ($line =~ /\bsimple_(strto.*?)\s*\(/) { 3177 if ($line =~ /\b((simple|strict)_(strto(l|ll|ul|ull)))\s*\(/) {
3156 WARN("CONSIDER_KSTRTO", 3178 WARN("CONSIDER_KSTRTO",
3157 "consider using kstrto* in preference to simple_$1\n" . $herecurr); 3179 "$1 is obsolete, use k$3 instead\n" . $herecurr);
3158 } 3180 }
3159# check for __initcall(), use device_initcall() explicitly please 3181# check for __initcall(), use device_initcall() explicitly please
3160 if ($line =~ /^.\s*__initcall\s*\(/) { 3182 if ($line =~ /^.\s*__initcall\s*\(/) {
diff --git a/security/keys/compat.c b/security/keys/compat.c
index 338b510e9027..4c48e13448f8 100644
--- a/security/keys/compat.c
+++ b/security/keys/compat.c
@@ -38,7 +38,7 @@ long compat_keyctl_instantiate_key_iov(
38 38
39 ret = compat_rw_copy_check_uvector(WRITE, _payload_iov, ioc, 39 ret = compat_rw_copy_check_uvector(WRITE, _payload_iov, ioc,
40 ARRAY_SIZE(iovstack), 40 ARRAY_SIZE(iovstack),
41 iovstack, &iov); 41 iovstack, &iov, 1);
42 if (ret < 0) 42 if (ret < 0)
43 return ret; 43 return ret;
44 if (ret == 0) 44 if (ret == 0)
diff --git a/security/keys/encrypted-keys/encrypted.c b/security/keys/encrypted-keys/encrypted.c
index f33804c1b4c8..dcc843cb0f80 100644
--- a/security/keys/encrypted-keys/encrypted.c
+++ b/security/keys/encrypted-keys/encrypted.c
@@ -293,7 +293,7 @@ static char *datablob_format(struct encrypted_key_payload *epayload,
293 /* convert the hex encoded iv, encrypted-data and HMAC to ascii */ 293 /* convert the hex encoded iv, encrypted-data and HMAC to ascii */
294 bufp = &ascii_buf[len]; 294 bufp = &ascii_buf[len];
295 for (i = 0; i < (asciiblob_len - len) / 2; i++) 295 for (i = 0; i < (asciiblob_len - len) / 2; i++)
296 bufp = pack_hex_byte(bufp, iv[i]); 296 bufp = hex_byte_pack(bufp, iv[i]);
297out: 297out:
298 return ascii_buf; 298 return ascii_buf;
299} 299}
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index eca51918c951..0b3f5d72af1c 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -1065,7 +1065,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
1065 goto no_payload; 1065 goto no_payload;
1066 1066
1067 ret = rw_copy_check_uvector(WRITE, _payload_iov, ioc, 1067 ret = rw_copy_check_uvector(WRITE, _payload_iov, ioc,
1068 ARRAY_SIZE(iovstack), iovstack, &iov); 1068 ARRAY_SIZE(iovstack), iovstack, &iov, 1);
1069 if (ret < 0) 1069 if (ret < 0)
1070 return ret; 1070 return ret;
1071 if (ret == 0) 1071 if (ret == 0)
diff --git a/security/keys/trusted.c b/security/keys/trusted.c
index 0964fc236946..0ed5fdf238a2 100644
--- a/security/keys/trusted.c
+++ b/security/keys/trusted.c
@@ -1098,7 +1098,7 @@ static long trusted_read(const struct key *key, char __user *buffer,
1098 1098
1099 bufp = ascii_buf; 1099 bufp = ascii_buf;
1100 for (i = 0; i < p->blob_len; i++) 1100 for (i = 0; i < p->blob_len; i++)
1101 bufp = pack_hex_byte(bufp, p->blob[i]); 1101 bufp = hex_byte_pack(bufp, p->blob[i]);
1102 if ((copy_to_user(buffer, ascii_buf, 2 * p->blob_len)) != 0) { 1102 if ((copy_to_user(buffer, ascii_buf, 2 * p->blob_len)) != 0) {
1103 kfree(ascii_buf); 1103 kfree(ascii_buf);
1104 return -EFAULT; 1104 return -EFAULT;
diff --git a/sound/firewire/cmp.c b/sound/firewire/cmp.c
index 14cacbc655dd..76294f2ae47f 100644
--- a/sound/firewire/cmp.c
+++ b/sound/firewire/cmp.c
@@ -32,7 +32,7 @@ enum bus_reset_handling {
32 SUCCEED_ON_BUS_RESET, 32 SUCCEED_ON_BUS_RESET,
33}; 33};
34 34
35static __attribute__((format(printf, 2, 3))) 35static __printf(2, 3)
36void cmp_error(struct cmp_connection *c, const char *fmt, ...) 36void cmp_error(struct cmp_connection *c, const char *fmt, ...)
37{ 37{
38 va_list va; 38 va_list va;