aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Documentation/00-INDEX2
-rw-r--r--Documentation/ABI/README3
-rw-r--r--Documentation/DocBook/kernel-api.tmpl3
-rw-r--r--Documentation/aoe/aoe.txt4
-rw-r--r--Documentation/backlight/lp855x-driver.txt10
-rw-r--r--Documentation/devicetree/bindings/rtc/imxdi-rtc.txt17
-rw-r--r--Documentation/devicetree/bindings/rtc/rtc-omap.txt17
-rw-r--r--Documentation/filesystems/proc.txt130
-rw-r--r--Documentation/filesystems/vfat.txt9
-rw-r--r--Documentation/kernel-parameters.txt7
-rw-r--r--Documentation/security/00-INDEX2
-rw-r--r--Documentation/sparse.txt18
-rw-r--r--MAINTAINERS18
-rw-r--r--arch/Kconfig1
-rw-r--r--arch/arm/mach-davinci/devices-da8xx.c13
-rw-r--r--arch/arm64/include/asm/unistd.h1
-rw-r--r--arch/arm64/kernel/sys_compat.c15
-rw-r--r--arch/frv/kernel/setup.c12
-rw-r--r--arch/frv/mm/init.c2
-rw-r--r--arch/powerpc/include/asm/machdep.h36
-rw-r--r--arch/powerpc/include/asm/systbl.h2
-rw-r--r--arch/powerpc/include/asm/unistd.h1
-rw-r--r--arch/powerpc/kernel/sys_ppc32.c17
-rw-r--r--arch/sparc/include/asm/unistd.h1
-rw-r--r--arch/sparc/kernel/sys_sparc32.c14
-rw-r--r--arch/tile/include/asm/compat.h2
-rw-r--r--arch/tile/include/asm/unistd.h1
-rw-r--r--arch/tile/kernel/compat.c18
-rw-r--r--arch/x86/include/uapi/asm/hw_breakpoint.h1
-rw-r--r--arch/x86/include/uapi/asm/setup.h1
-rw-r--r--block/Kconfig1
-rw-r--r--drivers/block/aoe/aoe.h57
-rw-r--r--drivers/block/aoe/aoeblk.c104
-rw-r--r--drivers/block/aoe/aoechr.c7
-rw-r--r--drivers/block/aoe/aoecmd.c715
-rw-r--r--drivers/block/aoe/aoedev.c243
-rw-r--r--drivers/block/aoe/aoemain.c2
-rw-r--r--drivers/block/aoe/aoenet.c15
-rw-r--r--drivers/dma/dmatest.c49
-rw-r--r--drivers/mtd/nand/nandsim.c5
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c5
-rw-r--r--drivers/net/wireless/Kconfig6
-rw-r--r--drivers/of/fdt.c10
-rw-r--r--drivers/platform/x86/asus-nb-wmi.c2
-rw-r--r--drivers/platform/x86/asus-wmi.c2
-rw-r--r--drivers/platform/x86/eeepc-wmi.c2
-rw-r--r--drivers/rtc/Kconfig31
-rw-r--r--drivers/rtc/Makefile2
-rw-r--r--drivers/rtc/rtc-da9055.c413
-rw-r--r--drivers/rtc/rtc-davinci.c21
-rw-r--r--drivers/rtc/rtc-dev.c19
-rw-r--r--drivers/rtc/rtc-imxdi.c11
-rw-r--r--drivers/rtc/rtc-omap.c80
-rw-r--r--drivers/rtc/rtc-pcf8523.c326
-rw-r--r--drivers/rtc/rtc-s3c.c52
-rw-r--r--drivers/rtc/rtc-spear.c91
-rw-r--r--drivers/rtc/rtc-test.c14
-rw-r--r--drivers/rtc/rtc-tps65910.c9
-rw-r--r--drivers/rtc/rtc-vt8500.c15
-rw-r--r--drivers/scsi/fcoe/fcoe_ctlr.c4
-rw-r--r--drivers/usb/musb/musb_core.c12
-rw-r--r--drivers/usb/musb/musb_io.h21
-rw-r--r--drivers/usb/musb/tusb6010.c5
-rw-r--r--drivers/video/backlight/88pm860x_bl.c18
-rw-r--r--drivers/video/backlight/atmel-pwm-bl.c7
-rw-r--r--drivers/video/backlight/backlight.c29
-rw-r--r--drivers/video/backlight/corgi_lcd.c20
-rw-r--r--drivers/video/backlight/da903x_bl.c15
-rw-r--r--drivers/video/backlight/da9052_bl.c2
-rw-r--r--drivers/video/backlight/generic_bl.c4
-rw-r--r--drivers/video/backlight/hp680_bl.c4
-rw-r--r--drivers/video/backlight/ili9320.c14
-rw-r--r--drivers/video/backlight/ili9320.h2
-rw-r--r--drivers/video/backlight/jornada720_bl.c31
-rw-r--r--drivers/video/backlight/l4f00242t03.c3
-rw-r--r--drivers/video/backlight/lcd.c8
-rw-r--r--drivers/video/backlight/lm3630_bl.c2
-rw-r--r--drivers/video/backlight/lm3639_bl.c2
-rw-r--r--drivers/video/backlight/lms283gf05.c17
-rw-r--r--drivers/video/backlight/lp855x_bl.c51
-rw-r--r--drivers/video/backlight/max8925_bl.c11
-rw-r--r--drivers/video/backlight/omap1_bl.c4
-rw-r--r--drivers/video/backlight/pandora_bl.c8
-rw-r--r--drivers/video/backlight/pcf50633-backlight.c8
-rw-r--r--drivers/video/backlight/platform_lcd.c2
-rw-r--r--drivers/video/backlight/s6e63m0.c2
-rw-r--r--drivers/video/backlight/tdo24m.c33
-rw-r--r--drivers/video/backlight/tosa_bl.c7
-rw-r--r--drivers/video/backlight/tosa_lcd.c24
-rw-r--r--drivers/video/backlight/vgg2432a4.c10
-rw-r--r--fs/bad_inode.c2
-rw-r--r--fs/binfmt_elf.c4
-rw-r--r--fs/binfmt_em86.c1
-rw-r--r--fs/binfmt_misc.c6
-rw-r--r--fs/binfmt_script.c4
-rw-r--r--fs/block_dev.c4
-rw-r--r--fs/btrfs/file.c16
-rw-r--r--fs/ceph/dir.c4
-rw-r--r--fs/ceph/file.c6
-rw-r--r--fs/cifs/cifsfs.c8
-rw-r--r--fs/configfs/dir.c4
-rw-r--r--fs/eventfd.c20
-rw-r--r--fs/eventpoll.c28
-rw-r--r--fs/exec.c10
-rw-r--r--fs/exportfs/expfs.c19
-rw-r--r--fs/ext3/dir.c6
-rw-r--r--fs/ext4/dir.c6
-rw-r--r--fs/ext4/file.c22
-rw-r--r--fs/fat/fat.h3
-rw-r--r--fs/fat/inode.c55
-rw-r--r--fs/fat/misc.c9
-rw-r--r--fs/fuse/file.c8
-rw-r--r--fs/gfs2/file.c10
-rw-r--r--fs/libfs.c4
-rw-r--r--fs/nfs/dir.c6
-rw-r--r--fs/nfs/file.c10
-rw-r--r--fs/notify/Makefile2
-rw-r--r--fs/notify/fanotify/fanotify_user.c2
-rw-r--r--fs/notify/fdinfo.c179
-rw-r--r--fs/notify/fdinfo.h27
-rw-r--r--fs/notify/inode_mark.c5
-rw-r--r--fs/notify/inotify/inotify_user.c2
-rw-r--r--fs/ocfs2/extent_map.c12
-rw-r--r--fs/ocfs2/file.c6
-rw-r--r--fs/proc/array.c21
-rw-r--r--fs/proc/fd.c2
-rw-r--r--fs/proc/proc_devtree.c6
-rw-r--r--fs/proc/task_mmu.c53
-rw-r--r--fs/pstore/inode.c6
-rw-r--r--fs/read_write.c40
-rw-r--r--fs/seq_file.c4
-rw-r--r--fs/signalfd.c18
-rw-r--r--fs/ubifs/debug.c8
-rw-r--r--fs/ubifs/dir.c4
-rw-r--r--include/asm-generic/io.h12
-rw-r--r--include/linux/backlight.h10
-rw-r--r--include/linux/binfmts.h2
-rw-r--r--include/linux/compat.h3
-rw-r--r--include/linux/compiler.h2
-rw-r--r--include/linux/exportfs.h2
-rw-r--r--include/linux/fs.h16
-rw-r--r--include/linux/ftrace.h4
-rw-r--r--include/linux/init.h40
-rw-r--r--include/linux/kernel.h33
-rw-r--r--include/linux/percpu-rwsem.h91
-rw-r--r--include/linux/platform_data/lp855x.h9
-rw-r--r--include/linux/proc_fs.h3
-rw-r--r--include/linux/ptrace.h2
-rw-r--r--include/linux/random.h19
-rw-r--r--include/linux/sched.h6
-rw-r--r--include/linux/string.h11
-rw-r--r--include/linux/syscalls.h4
-rw-r--r--include/uapi/linux/ptrace.h5
-rw-r--r--kernel/cgroup.c1
-rw-r--r--kernel/compat.c17
-rw-r--r--kernel/module.c3
-rw-r--r--kernel/pid.c15
-rw-r--r--kernel/printk.c40
-rw-r--r--kernel/ptrace.c3
-rw-r--r--kernel/trace/ftrace.c4
-rw-r--r--kernel/trace/trace_uprobe.c8
-rw-r--r--kernel/watchdog.c13
-rw-r--r--lib/Kconfig3
-rw-r--r--lib/Makefile1
-rw-r--r--lib/dynamic_debug.c9
-rw-r--r--lib/interval_tree_test_main.c7
-rw-r--r--lib/kstrtox.c64
-rw-r--r--lib/percpu-rwsem.c165
-rw-r--r--lib/random32.c97
-rw-r--r--lib/rbtree_test.c8
-rw-r--r--lib/scatterlist.c3
-rw-r--r--lib/vsprintf.c109
-rw-r--r--mm/memory.c9
-rw-r--r--mm/shmem.c20
-rwxr-xr-xscripts/checkpatch.pl143
-rw-r--r--sound/Kconfig3
-rw-r--r--sound/sound_core.c3
-rw-r--r--tools/testing/selftests/breakpoints/Makefile2
-rw-r--r--tools/testing/selftests/cpu-hotplug/Makefile2
-rw-r--r--tools/testing/selftests/kcmp/Makefile6
-rw-r--r--tools/testing/selftests/kcmp/kcmp_test.c6
-rw-r--r--tools/testing/selftests/memory-hotplug/Makefile2
-rw-r--r--tools/testing/selftests/mqueue/Makefile4
-rw-r--r--tools/testing/selftests/vm/Makefile2
185 files changed, 3447 insertions, 1339 deletions
diff --git a/.gitignore b/.gitignore
index 92bd0e45dfa1..3b8b9b33be38 100644
--- a/.gitignore
+++ b/.gitignore
@@ -60,7 +60,6 @@ modules.builtin
60# Generated include files 60# Generated include files
61# 61#
62include/config 62include/config
63include/linux/version.h
64include/generated 63include/generated
65arch/*/include/generated 64arch/*/include/generated
66 65
diff --git a/Documentation/00-INDEX b/Documentation/00-INDEX
index ceb1ff735469..8afe64fb2009 100644
--- a/Documentation/00-INDEX
+++ b/Documentation/00-INDEX
@@ -136,8 +136,6 @@ fault-injection/
136 - dir with docs about the fault injection capabilities infrastructure. 136 - dir with docs about the fault injection capabilities infrastructure.
137fb/ 137fb/
138 - directory with info on the frame buffer graphics abstraction layer. 138 - directory with info on the frame buffer graphics abstraction layer.
139feature-removal-schedule.txt
140 - list of files and features that are going to be removed.
141filesystems/ 139filesystems/
142 - info on the vfs and the various filesystems that Linux supports. 140 - info on the vfs and the various filesystems that Linux supports.
143firmware_class/ 141firmware_class/
diff --git a/Documentation/ABI/README b/Documentation/ABI/README
index 9feaf16f1617..10069828568b 100644
--- a/Documentation/ABI/README
+++ b/Documentation/ABI/README
@@ -36,9 +36,6 @@ The different levels of stability are:
36 the kernel, but are marked to be removed at some later point in 36 the kernel, but are marked to be removed at some later point in
37 time. The description of the interface will document the reason 37 time. The description of the interface will document the reason
38 why it is obsolete and when it can be expected to be removed. 38 why it is obsolete and when it can be expected to be removed.
39 The file Documentation/feature-removal-schedule.txt may describe
40 some of these interfaces, giving a schedule for when they will
41 be removed.
42 39
43 removed/ 40 removed/
44 This directory contains a list of the old interfaces that have 41 This directory contains a list of the old interfaces that have
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl
index 00687ee9d363..f75ab4c1b281 100644
--- a/Documentation/DocBook/kernel-api.tmpl
+++ b/Documentation/DocBook/kernel-api.tmpl
@@ -58,6 +58,9 @@
58 58
59 <sect1><title>String Conversions</title> 59 <sect1><title>String Conversions</title>
60!Elib/vsprintf.c 60!Elib/vsprintf.c
61!Finclude/linux/kernel.h kstrtol
62!Finclude/linux/kernel.h kstrtoul
63!Elib/kstrtox.c
61 </sect1> 64 </sect1>
62 <sect1><title>String Manipulation</title> 65 <sect1><title>String Manipulation</title>
63<!-- All functions are exported at now 66<!-- All functions are exported at now
diff --git a/Documentation/aoe/aoe.txt b/Documentation/aoe/aoe.txt
index bfc9cb19abcd..c71487d399d1 100644
--- a/Documentation/aoe/aoe.txt
+++ b/Documentation/aoe/aoe.txt
@@ -125,7 +125,9 @@ DRIVER OPTIONS
125 The aoe_deadsecs module parameter determines the maximum number of 125 The aoe_deadsecs module parameter determines the maximum number of
126 seconds that the driver will wait for an AoE device to provide a 126 seconds that the driver will wait for an AoE device to provide a
127 response to an AoE command. After aoe_deadsecs seconds have 127 response to an AoE command. After aoe_deadsecs seconds have
128 elapsed, the AoE device will be marked as "down". 128 elapsed, the AoE device will be marked as "down". A value of zero
129 is supported for testing purposes and makes the aoe driver keep
130 trying AoE commands forever.
129 131
130 The aoe_maxout module parameter has a default of 128. This is the 132 The aoe_maxout module parameter has a default of 128. This is the
131 maximum number of unresponded packets that will be sent to an AoE 133 maximum number of unresponded packets that will be sent to an AoE
diff --git a/Documentation/backlight/lp855x-driver.txt b/Documentation/backlight/lp855x-driver.txt
index f5e4caafab7d..1529394cfe8b 100644
--- a/Documentation/backlight/lp855x-driver.txt
+++ b/Documentation/backlight/lp855x-driver.txt
@@ -35,11 +35,8 @@ For supporting platform specific data, the lp855x platform data can be used.
35* mode : Brightness control mode. PWM or register based. 35* mode : Brightness control mode. PWM or register based.
36* device_control : Value of DEVICE CONTROL register. 36* device_control : Value of DEVICE CONTROL register.
37* initial_brightness : Initial value of backlight brightness. 37* initial_brightness : Initial value of backlight brightness.
38* pwm_data : Platform specific pwm generation functions. 38* period_ns : Platform specific PWM period value. unit is nano.
39 Only valid when brightness is pwm input mode. 39 Only valid when brightness is pwm input mode.
40 Functions should be implemented by PWM driver.
41 - pwm_set_intensity() : set duty of PWM
42 - pwm_get_intensity() : get current duty of PWM
43* load_new_rom_data : 40* load_new_rom_data :
44 0 : use default configuration data 41 0 : use default configuration data
45 1 : update values of eeprom or eprom registers on loading driver 42 1 : update values of eeprom or eprom registers on loading driver
@@ -71,8 +68,5 @@ static struct lp855x_platform_data lp8556_pdata = {
71 .mode = PWM_BASED, 68 .mode = PWM_BASED,
72 .device_control = PWM_CONFIG(LP8556), 69 .device_control = PWM_CONFIG(LP8556),
73 .initial_brightness = INITIAL_BRT, 70 .initial_brightness = INITIAL_BRT,
74 .pwm_data = { 71 .period_ns = 1000000,
75 .pwm_set_intensity = platform_pwm_set_intensity,
76 .pwm_get_intensity = platform_pwm_get_intensity,
77 },
78}; 72};
diff --git a/Documentation/devicetree/bindings/rtc/imxdi-rtc.txt b/Documentation/devicetree/bindings/rtc/imxdi-rtc.txt
new file mode 100644
index 000000000000..c9d80d7da141
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/imxdi-rtc.txt
@@ -0,0 +1,17 @@
1* i.MX25 Real Time Clock controller
2
3This binding supports the following chips: i.MX25, i.MX53
4
5Required properties:
6- compatible: should be: "fsl,imx25-rtc"
7- reg: physical base address of the controller and length of memory mapped
8 region.
9- interrupts: rtc alarm interrupt
10
11Example:
12
13rtc@80056000 {
14 compatible = "fsl,imx53-rtc", "fsl,imx25-rtc";
15 reg = <0x80056000 2000>;
16 interrupts = <29>;
17};
diff --git a/Documentation/devicetree/bindings/rtc/rtc-omap.txt b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
new file mode 100644
index 000000000000..b47aa415c820
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
@@ -0,0 +1,17 @@
1TI Real Time Clock
2
3Required properties:
4- compatible: "ti,da830-rtc"
5- reg: Address range of rtc register set
6- interrupts: rtc timer, alarm interrupts in order
7- interrupt-parent: phandle for the interrupt controller
8
9Example:
10
11rtc@1c23000 {
12 compatible = "ti,da830-rtc";
13 reg = <0x23000 0x1000>;
14 interrupts = <19
15 19>;
16 interrupt-parent = <&intc>;
17};
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index 3844d21d6ca3..fd8d0d594fc7 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -41,6 +41,7 @@ Table of Contents
41 3.5 /proc/<pid>/mountinfo - Information about mounts 41 3.5 /proc/<pid>/mountinfo - Information about mounts
42 3.6 /proc/<pid>/comm & /proc/<pid>/task/<tid>/comm 42 3.6 /proc/<pid>/comm & /proc/<pid>/task/<tid>/comm
43 3.7 /proc/<pid>/task/<tid>/children - Information about task children 43 3.7 /proc/<pid>/task/<tid>/children - Information about task children
44 3.8 /proc/<pid>/fdinfo/<fd> - Information about opened file
44 45
45 4 Configuring procfs 46 4 Configuring procfs
46 4.1 Mount options 47 4.1 Mount options
@@ -142,7 +143,7 @@ Table 1-1: Process specific entries in /proc
142 pagemap Page table 143 pagemap Page table
143 stack Report full stack trace, enable via CONFIG_STACKTRACE 144 stack Report full stack trace, enable via CONFIG_STACKTRACE
144 smaps a extension based on maps, showing the memory consumption of 145 smaps a extension based on maps, showing the memory consumption of
145 each mapping 146 each mapping and flags associated with it
146.............................................................................. 147..............................................................................
147 148
148For example, to get the status information of a process, all you have to do is 149For example, to get the status information of a process, all you have to do is
@@ -181,6 +182,7 @@ read the file /proc/PID/status:
181 CapPrm: 0000000000000000 182 CapPrm: 0000000000000000
182 CapEff: 0000000000000000 183 CapEff: 0000000000000000
183 CapBnd: ffffffffffffffff 184 CapBnd: ffffffffffffffff
185 Seccomp: 0
184 voluntary_ctxt_switches: 0 186 voluntary_ctxt_switches: 0
185 nonvoluntary_ctxt_switches: 1 187 nonvoluntary_ctxt_switches: 1
186 188
@@ -237,6 +239,7 @@ Table 1-2: Contents of the status files (as of 2.6.30-rc7)
237 CapPrm bitmap of permitted capabilities 239 CapPrm bitmap of permitted capabilities
238 CapEff bitmap of effective capabilities 240 CapEff bitmap of effective capabilities
239 CapBnd bitmap of capabilities bounding set 241 CapBnd bitmap of capabilities bounding set
242 Seccomp seccomp mode, like prctl(PR_GET_SECCOMP, ...)
240 Cpus_allowed mask of CPUs on which this process may run 243 Cpus_allowed mask of CPUs on which this process may run
241 Cpus_allowed_list Same as previous, but in "list format" 244 Cpus_allowed_list Same as previous, but in "list format"
242 Mems_allowed mask of memory nodes allowed to this process 245 Mems_allowed mask of memory nodes allowed to this process
@@ -415,8 +418,9 @@ Swap: 0 kB
415KernelPageSize: 4 kB 418KernelPageSize: 4 kB
416MMUPageSize: 4 kB 419MMUPageSize: 4 kB
417Locked: 374 kB 420Locked: 374 kB
421VmFlags: rd ex mr mw me de
418 422
419The first of these lines shows the same information as is displayed for the 423the first of these lines shows the same information as is displayed for the
420mapping in /proc/PID/maps. The remaining lines show the size of the mapping 424mapping in /proc/PID/maps. The remaining lines show the size of the mapping
421(size), the amount of the mapping that is currently resident in RAM (RSS), the 425(size), the amount of the mapping that is currently resident in RAM (RSS), the
422process' proportional share of this mapping (PSS), the number of clean and 426process' proportional share of this mapping (PSS), the number of clean and
@@ -430,6 +434,41 @@ and a page is modified, the file page is replaced by a private anonymous copy.
430"Swap" shows how much would-be-anonymous memory is also used, but out on 434"Swap" shows how much would-be-anonymous memory is also used, but out on
431swap. 435swap.
432 436
437"VmFlags" field deserves a separate description. This member represents the kernel
438flags associated with the particular virtual memory area in two letter encoded
439manner. The codes are the following:
440 rd - readable
441 wr - writeable
442 ex - executable
443 sh - shared
444 mr - may read
445 mw - may write
446 me - may execute
447 ms - may share
448 gd - stack segment growns down
449 pf - pure PFN range
450 dw - disabled write to the mapped file
451 lo - pages are locked in memory
452 io - memory mapped I/O area
453 sr - sequential read advise provided
454 rr - random read advise provided
455 dc - do not copy area on fork
456 de - do not expand area on remapping
457 ac - area is accountable
458 nr - swap space is not reserved for the area
459 ht - area uses huge tlb pages
460 nl - non-linear mapping
461 ar - architecture specific flag
462 dd - do not include area into core dump
463 mm - mixed map area
464 hg - huge page advise flag
465 nh - no-huge page advise flag
466 mg - mergable advise flag
467
468Note that there is no guarantee that every flag and associated mnemonic will
469be present in all further kernel releases. Things get changed, the flags may
470be vanished or the reverse -- new added.
471
433This file is only present if the CONFIG_MMU kernel configuration option is 472This file is only present if the CONFIG_MMU kernel configuration option is
434enabled. 473enabled.
435 474
@@ -1595,6 +1634,93 @@ pids, so one need to either stop or freeze processes being inspected
1595if precise results are needed. 1634if precise results are needed.
1596 1635
1597 1636
16373.7 /proc/<pid>/fdinfo/<fd> - Information about opened file
1638---------------------------------------------------------------
1639This file provides information associated with an opened file. The regular
1640files have at least two fields -- 'pos' and 'flags'. The 'pos' represents
1641the current offset of the opened file in decimal form [see lseek(2) for
1642details] and 'flags' denotes the octal O_xxx mask the file has been
1643created with [see open(2) for details].
1644
1645A typical output is
1646
1647 pos: 0
1648 flags: 0100002
1649
1650The files such as eventfd, fsnotify, signalfd, epoll among the regular pos/flags
1651pair provide additional information particular to the objects they represent.
1652
1653 Eventfd files
1654 ~~~~~~~~~~~~~
1655 pos: 0
1656 flags: 04002
1657 eventfd-count: 5a
1658
1659 where 'eventfd-count' is hex value of a counter.
1660
1661 Signalfd files
1662 ~~~~~~~~~~~~~~
1663 pos: 0
1664 flags: 04002
1665 sigmask: 0000000000000200
1666
1667 where 'sigmask' is hex value of the signal mask associated
1668 with a file.
1669
1670 Epoll files
1671 ~~~~~~~~~~~
1672 pos: 0
1673 flags: 02
1674 tfd: 5 events: 1d data: ffffffffffffffff
1675
1676 where 'tfd' is a target file descriptor number in decimal form,
1677 'events' is events mask being watched and the 'data' is data
1678 associated with a target [see epoll(7) for more details].
1679
1680 Fsnotify files
1681 ~~~~~~~~~~~~~~
1682 For inotify files the format is the following
1683
1684 pos: 0
1685 flags: 02000000
1686 inotify wd:3 ino:9e7e sdev:800013 mask:800afce ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:7e9e0000640d1b6d
1687
1688 where 'wd' is a watch descriptor in decimal form, ie a target file
1689 descriptor number, 'ino' and 'sdev' are inode and device where the
1690 target file resides and the 'mask' is the mask of events, all in hex
1691 form [see inotify(7) for more details].
1692
1693 If the kernel was built with exportfs support, the path to the target
1694 file is encoded as a file handle. The file handle is provided by three
1695 fields 'fhandle-bytes', 'fhandle-type' and 'f_handle', all in hex
1696 format.
1697
1698 If the kernel is built without exportfs support the file handle won't be
1699 printed out.
1700
1701 If there is no inotify mark attached yet the 'inotify' line will be omitted.
1702
1703 For fanotify files the format is
1704
1705 pos: 0
1706 flags: 02
1707 fanotify flags:10 event-flags:0
1708 fanotify mnt_id:12 mflags:40 mask:38 ignored_mask:40000003
1709 fanotify ino:4f969 sdev:800013 mflags:0 mask:3b ignored_mask:40000000 fhandle-bytes:8 fhandle-type:1 f_handle:69f90400c275b5b4
1710
1711 where fanotify 'flags' and 'event-flags' are values used in fanotify_init
1712 call, 'mnt_id' is the mount point identifier, 'mflags' is the value of
1713 flags associated with mark which are tracked separately from events
1714 mask. 'ino', 'sdev' are target inode and device, 'mask' is the events
1715 mask and 'ignored_mask' is the mask of events which are to be ignored.
1716 All in hex format. Incorporation of 'mflags', 'mask' and 'ignored_mask'
1717 does provide information about flags and mask used in fanotify_mark
1718 call [see fsnotify manpage for details].
1719
1720 While the first three lines are mandatory and always printed, the rest is
1721 optional and may be omitted if no marks created yet.
1722
1723
1598------------------------------------------------------------------------------ 1724------------------------------------------------------------------------------
1599Configuring procfs 1725Configuring procfs
1600------------------------------------------------------------------------------ 1726------------------------------------------------------------------------------
diff --git a/Documentation/filesystems/vfat.txt b/Documentation/filesystems/vfat.txt
index de1e6c4dccff..d230dd9c99b0 100644
--- a/Documentation/filesystems/vfat.txt
+++ b/Documentation/filesystems/vfat.txt
@@ -111,6 +111,15 @@ tz=UTC -- Interpret timestamps as UTC rather than local time.
111 useful when mounting devices (like digital cameras) 111 useful when mounting devices (like digital cameras)
112 that are set to UTC in order to avoid the pitfalls of 112 that are set to UTC in order to avoid the pitfalls of
113 local time. 113 local time.
114time_offset=minutes
115 -- Set offset for conversion of timestamps from local time
116 used by FAT to UTC. I.e. <minutes> minutes will be subtracted
117 from each timestamp to convert it to UTC used internally by
118 Linux. This is useful when time zone set in sys_tz is
119 not the time zone used by the filesystem. Note that this
120 option still does not provide correct time stamps in all
121 cases in presence of DST - time stamps in a different DST
122 setting will be off by one hour.
114 123
115showexec -- If set, the execute permission bits of the file will be 124showexec -- If set, the execute permission bits of the file will be
116 allowed only if the extension part of the name is .EXE, 125 allowed only if the extension part of the name is .EXE,
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index ea8e5b485576..ddd84d627185 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1503,9 +1503,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1503 mem=nn[KMG] [KNL,BOOT] Force usage of a specific amount of memory 1503 mem=nn[KMG] [KNL,BOOT] Force usage of a specific amount of memory
1504 Amount of memory to be used when the kernel is not able 1504 Amount of memory to be used when the kernel is not able
1505 to see the whole system memory or for test. 1505 to see the whole system memory or for test.
1506 [X86-32] Use together with memmap= to avoid physical 1506 [X86] Work as limiting max address. Use together
1507 address space collisions. Without memmap= PCI devices 1507 with memmap= to avoid physical address space collisions.
1508 could be placed at addresses belonging to unused RAM. 1508 Without memmap= PCI devices could be placed at addresses
1509 belonging to unused RAM.
1509 1510
1510 mem=nopentium [BUGS=X86-32] Disable usage of 4MB pages for kernel 1511 mem=nopentium [BUGS=X86-32] Disable usage of 4MB pages for kernel
1511 memory. 1512 memory.
diff --git a/Documentation/security/00-INDEX b/Documentation/security/00-INDEX
index eeed1de546d4..414235c1fcfc 100644
--- a/Documentation/security/00-INDEX
+++ b/Documentation/security/00-INDEX
@@ -12,6 +12,8 @@ apparmor.txt
12 - documentation on the AppArmor security extension. 12 - documentation on the AppArmor security extension.
13credentials.txt 13credentials.txt
14 - documentation about credentials in Linux. 14 - documentation about credentials in Linux.
15keys-ecryptfs.txt
16 - description of the encryption keys for the ecryptfs filesystem.
15keys-request-key.txt 17keys-request-key.txt
16 - description of the kernel key request service. 18 - description of the kernel key request service.
17keys-trusted-encrypted.txt 19keys-trusted-encrypted.txt
diff --git a/Documentation/sparse.txt b/Documentation/sparse.txt
index 4909d4116356..eceab1308a8c 100644
--- a/Documentation/sparse.txt
+++ b/Documentation/sparse.txt
@@ -49,6 +49,24 @@ be generated without __CHECK_ENDIAN__.
49__bitwise - noisy stuff; in particular, __le*/__be* are that. We really 49__bitwise - noisy stuff; in particular, __le*/__be* are that. We really
50don't want to drown in noise unless we'd explicitly asked for it. 50don't want to drown in noise unless we'd explicitly asked for it.
51 51
52Using sparse for lock checking
53~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54
55The following macros are undefined for gcc and defined during a sparse
56run to use the "context" tracking feature of sparse, applied to
57locking. These annotations tell sparse when a lock is held, with
58regard to the annotated function's entry and exit.
59
60__must_hold - The specified lock is held on function entry and exit.
61
62__acquires - The specified lock is held on function exit, but not entry.
63
64__releases - The specified lock is held on function entry, but not exit.
65
66If the function enters and exits without the lock held, acquiring and
67releasing the lock inside the function in a balanced way, no
68annotation is needed. The tree annotations above are for cases where
69sparse would otherwise report a context imbalance.
52 70
53Getting sparse 71Getting sparse
54~~~~~~~~~~~~~~ 72~~~~~~~~~~~~~~
diff --git a/MAINTAINERS b/MAINTAINERS
index 6892b26025ba..4e2a1f67a1fc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1280,7 +1280,7 @@ F: Documentation/hwmon/asc7621
1280F: drivers/hwmon/asc7621.c 1280F: drivers/hwmon/asc7621.c
1281 1281
1282ASUS NOTEBOOKS AND EEEPC ACPI/WMI EXTRAS DRIVERS 1282ASUS NOTEBOOKS AND EEEPC ACPI/WMI EXTRAS DRIVERS
1283M: Corentin Chary <corentincj@iksaif.net> 1283M: Corentin Chary <corentin.chary@gmail.com>
1284L: acpi4asus-user@lists.sourceforge.net 1284L: acpi4asus-user@lists.sourceforge.net
1285L: platform-driver-x86@vger.kernel.org 1285L: platform-driver-x86@vger.kernel.org
1286W: http://acpi4asus.sf.net 1286W: http://acpi4asus.sf.net
@@ -1929,7 +1929,7 @@ F: scripts/checkpatch.pl
1929 1929
1930CHINESE DOCUMENTATION 1930CHINESE DOCUMENTATION
1931M: Harry Wei <harryxiyou@gmail.com> 1931M: Harry Wei <harryxiyou@gmail.com>
1932L: xiyoulinuxkernelgroup@googlegroups.com 1932L: xiyoulinuxkernelgroup@googlegroups.com (subscribers-only)
1933L: linux-kernel@zh-kernel.org (moderated for non-subscribers) 1933L: linux-kernel@zh-kernel.org (moderated for non-subscribers)
1934S: Maintained 1934S: Maintained
1935F: Documentation/zh_CN/ 1935F: Documentation/zh_CN/
@@ -2982,7 +2982,6 @@ L: linux-ext4@vger.kernel.org
2982S: Maintained 2982S: Maintained
2983F: Documentation/filesystems/ext3.txt 2983F: Documentation/filesystems/ext3.txt
2984F: fs/ext3/ 2984F: fs/ext3/
2985F: include/linux/ext3*
2986 2985
2987EXT4 FILE SYSTEM 2986EXT4 FILE SYSTEM
2988M: "Theodore Ts'o" <tytso@mit.edu> 2987M: "Theodore Ts'o" <tytso@mit.edu>
@@ -3129,7 +3128,8 @@ W: http://ieee1394.wiki.kernel.org/
3129T: git git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394.git 3128T: git git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394.git
3130S: Maintained 3129S: Maintained
3131F: drivers/firewire/ 3130F: drivers/firewire/
3132F: include/linux/firewire*.h 3131F: include/linux/firewire.h
3132F: include/uapi/linux/firewire*.h
3133F: tools/firewire/ 3133F: tools/firewire/
3134 3134
3135FIRMWARE LOADER (request_firmware) 3135FIRMWARE LOADER (request_firmware)
@@ -4314,7 +4314,6 @@ M: Jan Kara <jack@suse.cz>
4314L: linux-ext4@vger.kernel.org 4314L: linux-ext4@vger.kernel.org
4315S: Maintained 4315S: Maintained
4316F: fs/jbd/ 4316F: fs/jbd/
4317F: include/linux/ext3_jbd.h
4318F: include/linux/jbd.h 4317F: include/linux/jbd.h
4319 4318
4320JOURNALLING LAYER FOR BLOCK DEVICES (JBD2) 4319JOURNALLING LAYER FOR BLOCK DEVICES (JBD2)
@@ -6492,7 +6491,7 @@ F: drivers/media/pci/saa7146/
6492F: include/media/saa7146* 6491F: include/media/saa7146*
6493 6492
6494SAMSUNG LAPTOP DRIVER 6493SAMSUNG LAPTOP DRIVER
6495M: Corentin Chary <corentincj@iksaif.net> 6494M: Corentin Chary <corentin.chary@gmail.com>
6496L: platform-driver-x86@vger.kernel.org 6495L: platform-driver-x86@vger.kernel.org
6497S: Maintained 6496S: Maintained
6498F: drivers/platform/x86/samsung-laptop.c 6497F: drivers/platform/x86/samsung-laptop.c
@@ -7546,6 +7545,13 @@ S: Maintained
7546F: sound/soc/codecs/lm49453* 7545F: sound/soc/codecs/lm49453*
7547F: sound/soc/codecs/isabelle* 7546F: sound/soc/codecs/isabelle*
7548 7547
7548TI LP855x BACKLIGHT DRIVER
7549M: Milo Kim <milo.kim@ti.com>
7550S: Maintained
7551F: Documentation/backlight/lp855x-driver.txt
7552F: drivers/video/backlight/lp855x_bl.c
7553F: include/linux/platform_data/lp855x.h
7554
7549TI TWL4030 SERIES SOC CODEC DRIVER 7555TI TWL4030 SERIES SOC CODEC DRIVER
7550M: Peter Ujfalusi <peter.ujfalusi@ti.com> 7556M: Peter Ujfalusi <peter.ujfalusi@ti.com>
7551L: alsa-devel@alsa-project.org (moderated for non-subscribers) 7557L: alsa-devel@alsa-project.org (moderated for non-subscribers)
diff --git a/arch/Kconfig b/arch/Kconfig
index 34884faf98cd..54ffd0f9df21 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -80,6 +80,7 @@ config UPROBES
80 bool "Transparent user-space probes (EXPERIMENTAL)" 80 bool "Transparent user-space probes (EXPERIMENTAL)"
81 depends on UPROBE_EVENT && PERF_EVENTS 81 depends on UPROBE_EVENT && PERF_EVENTS
82 default n 82 default n
83 select PERCPU_RWSEM
83 help 84 help
84 Uprobes is the user-space counterpart to kprobes: they 85 Uprobes is the user-space counterpart to kprobes: they
85 enable instrumentation applications (such as 'perf probe') 86 enable instrumentation applications (such as 'perf probe')
diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c
index fcdbe437409e..2d5502d84a22 100644
--- a/arch/arm/mach-davinci/devices-da8xx.c
+++ b/arch/arm/mach-davinci/devices-da8xx.c
@@ -725,7 +725,7 @@ static struct resource da8xx_rtc_resources[] = {
725}; 725};
726 726
727static struct platform_device da8xx_rtc_device = { 727static struct platform_device da8xx_rtc_device = {
728 .name = "omap_rtc", 728 .name = "da830-rtc",
729 .id = -1, 729 .id = -1,
730 .num_resources = ARRAY_SIZE(da8xx_rtc_resources), 730 .num_resources = ARRAY_SIZE(da8xx_rtc_resources),
731 .resource = da8xx_rtc_resources, 731 .resource = da8xx_rtc_resources,
@@ -734,17 +734,6 @@ static struct platform_device da8xx_rtc_device = {
734int da8xx_register_rtc(void) 734int da8xx_register_rtc(void)
735{ 735{
736 int ret; 736 int ret;
737 void __iomem *base;
738
739 base = ioremap(DA8XX_RTC_BASE, SZ_4K);
740 if (WARN_ON(!base))
741 return -ENOMEM;
742
743 /* Unlock the rtc's registers */
744 __raw_writel(0x83e70b13, base + 0x6c);
745 __raw_writel(0x95a4f1e0, base + 0x70);
746
747 iounmap(base);
748 737
749 ret = platform_device_register(&da8xx_rtc_device); 738 ret = platform_device_register(&da8xx_rtc_device);
750 if (!ret) 739 if (!ret)
diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
index d69aeea6da1e..76fb7dd3350a 100644
--- a/arch/arm64/include/asm/unistd.h
+++ b/arch/arm64/include/asm/unistd.h
@@ -20,6 +20,7 @@
20#define __ARCH_WANT_SYS_GETPGRP 20#define __ARCH_WANT_SYS_GETPGRP
21#define __ARCH_WANT_SYS_LLSEEK 21#define __ARCH_WANT_SYS_LLSEEK
22#define __ARCH_WANT_SYS_NICE 22#define __ARCH_WANT_SYS_NICE
23#define __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL
23#define __ARCH_WANT_SYS_SIGPENDING 24#define __ARCH_WANT_SYS_SIGPENDING
24#define __ARCH_WANT_SYS_SIGPROCMASK 25#define __ARCH_WANT_SYS_SIGPROCMASK
25#define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND 26#define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND
diff --git a/arch/arm64/kernel/sys_compat.c b/arch/arm64/kernel/sys_compat.c
index f7b05edf8ce3..26e9c4eeaba8 100644
--- a/arch/arm64/kernel/sys_compat.c
+++ b/arch/arm64/kernel/sys_compat.c
@@ -28,21 +28,6 @@
28#include <asm/cacheflush.h> 28#include <asm/cacheflush.h>
29#include <asm/unistd32.h> 29#include <asm/unistd32.h>
30 30
31asmlinkage int compat_sys_sched_rr_get_interval(compat_pid_t pid,
32 struct compat_timespec __user *interval)
33{
34 struct timespec t;
35 int ret;
36 mm_segment_t old_fs = get_fs();
37
38 set_fs(KERNEL_DS);
39 ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
40 set_fs(old_fs);
41 if (put_compat_timespec(&t, interval))
42 return -EFAULT;
43 return ret;
44}
45
46static inline void 31static inline void
47do_compat_cache_op(unsigned long start, unsigned long end, int flags) 32do_compat_cache_op(unsigned long start, unsigned long end, int flags)
48{ 33{
diff --git a/arch/frv/kernel/setup.c b/arch/frv/kernel/setup.c
index b8993c87d3de..3cb3392f799e 100644
--- a/arch/frv/kernel/setup.c
+++ b/arch/frv/kernel/setup.c
@@ -804,9 +804,9 @@ void __init setup_arch(char **cmdline_p)
804 804
805 BUG_ON(memory_start == memory_end); 805 BUG_ON(memory_start == memory_end);
806 806
807 init_mm.start_code = (unsigned long) &_stext; 807 init_mm.start_code = (unsigned long) _stext;
808 init_mm.end_code = (unsigned long) &_etext; 808 init_mm.end_code = (unsigned long) _etext;
809 init_mm.end_data = (unsigned long) &_edata; 809 init_mm.end_data = (unsigned long) _edata;
810#if 0 /* DAVIDM - don't set brk just incase someone decides to use it */ 810#if 0 /* DAVIDM - don't set brk just incase someone decides to use it */
811 init_mm.brk = (unsigned long) &_end; 811 init_mm.brk = (unsigned long) &_end;
812#else 812#else
@@ -814,10 +814,8 @@ void __init setup_arch(char **cmdline_p)
814#endif 814#endif
815 815
816#ifdef DEBUG 816#ifdef DEBUG
817 printk("KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x BSS=0x%06x-0x%06x\n", 817 printk("KERNEL -> TEXT=0x%p-0x%p DATA=0x%p-0x%p BSS=0x%p-0x%p\n",
818 (int) &_stext, (int) &_etext, 818 _stext, _etext, _sdata, _edata, __bss_start, __bss_stop);
819 (int) &_sdata, (int) &_edata,
820 (int) &_sbss, (int) &_ebss);
821#endif 819#endif
822 820
823#ifdef CONFIG_VT 821#ifdef CONFIG_VT
diff --git a/arch/frv/mm/init.c b/arch/frv/mm/init.c
index a19effcccb34..92e97b0894a6 100644
--- a/arch/frv/mm/init.c
+++ b/arch/frv/mm/init.c
@@ -146,7 +146,7 @@ void __init mem_init(void)
146 146
147#else 147#else
148 codek = (_etext - _stext) >> 10; 148 codek = (_etext - _stext) >> 10;
149 datak = 0; //(_ebss - _sdata) >> 10; 149 datak = 0; //(__bss_stop - _sdata) >> 10;
150#endif 150#endif
151 151
152 tmp = nr_free_pages() << PAGE_SHIFT; 152 tmp = nr_free_pages() << PAGE_SHIFT;
diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index c4231973edd3..3c82daf8be99 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -320,28 +320,28 @@ static inline void log_error(char *buf, unsigned int err_type, int fatal)
320 ppc_md.log_error(buf, err_type, fatal); 320 ppc_md.log_error(buf, err_type, fatal);
321} 321}
322 322
323#define __define_machine_initcall(mach,level,fn,id) \ 323#define __define_machine_initcall(mach, fn, id) \
324 static int __init __machine_initcall_##mach##_##fn(void) { \ 324 static int __init __machine_initcall_##mach##_##fn(void) { \
325 if (machine_is(mach)) return fn(); \ 325 if (machine_is(mach)) return fn(); \
326 return 0; \ 326 return 0; \
327 } \ 327 } \
328 __define_initcall(level,__machine_initcall_##mach##_##fn,id); 328 __define_initcall(__machine_initcall_##mach##_##fn, id);
329 329
330#define machine_core_initcall(mach,fn) __define_machine_initcall(mach,"1",fn,1) 330#define machine_core_initcall(mach, fn) __define_machine_initcall(mach, fn, 1)
331#define machine_core_initcall_sync(mach,fn) __define_machine_initcall(mach,"1s",fn,1s) 331#define machine_core_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 1s)
332#define machine_postcore_initcall(mach,fn) __define_machine_initcall(mach,"2",fn,2) 332#define machine_postcore_initcall(mach, fn) __define_machine_initcall(mach, fn, 2)
333#define machine_postcore_initcall_sync(mach,fn) __define_machine_initcall(mach,"2s",fn,2s) 333#define machine_postcore_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 2s)
334#define machine_arch_initcall(mach,fn) __define_machine_initcall(mach,"3",fn,3) 334#define machine_arch_initcall(mach, fn) __define_machine_initcall(mach, fn, 3)
335#define machine_arch_initcall_sync(mach,fn) __define_machine_initcall(mach,"3s",fn,3s) 335#define machine_arch_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 3s)
336#define machine_subsys_initcall(mach,fn) __define_machine_initcall(mach,"4",fn,4) 336#define machine_subsys_initcall(mach, fn) __define_machine_initcall(mach, fn, 4)
337#define machine_subsys_initcall_sync(mach,fn) __define_machine_initcall(mach,"4s",fn,4s) 337#define machine_subsys_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 4s)
338#define machine_fs_initcall(mach,fn) __define_machine_initcall(mach,"5",fn,5) 338#define machine_fs_initcall(mach, fn) __define_machine_initcall(mach, fn, 5)
339#define machine_fs_initcall_sync(mach,fn) __define_machine_initcall(mach,"5s",fn,5s) 339#define machine_fs_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 5s)
340#define machine_rootfs_initcall(mach,fn) __define_machine_initcall(mach,"rootfs",fn,rootfs) 340#define machine_rootfs_initcall(mach, fn) __define_machine_initcall(mach, fn, rootfs)
341#define machine_device_initcall(mach,fn) __define_machine_initcall(mach,"6",fn,6) 341#define machine_device_initcall(mach, fn) __define_machine_initcall(mach, fn, 6)
342#define machine_device_initcall_sync(mach,fn) __define_machine_initcall(mach,"6s",fn,6s) 342#define machine_device_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 6s)
343#define machine_late_initcall(mach,fn) __define_machine_initcall(mach,"7",fn,7) 343#define machine_late_initcall(mach, fn) __define_machine_initcall(mach, fn, 7)
344#define machine_late_initcall_sync(mach,fn) __define_machine_initcall(mach,"7s",fn,7s) 344#define machine_late_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 7s)
345 345
346#endif /* __KERNEL__ */ 346#endif /* __KERNEL__ */
347#endif /* _ASM_POWERPC_MACHDEP_H */ 347#endif /* _ASM_POWERPC_MACHDEP_H */
diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index 840838769853..cec8aae5cbf8 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -164,7 +164,7 @@ COMPAT_SYS_SPU(sched_getscheduler)
164SYSCALL_SPU(sched_yield) 164SYSCALL_SPU(sched_yield)
165COMPAT_SYS_SPU(sched_get_priority_max) 165COMPAT_SYS_SPU(sched_get_priority_max)
166COMPAT_SYS_SPU(sched_get_priority_min) 166COMPAT_SYS_SPU(sched_get_priority_min)
167COMPAT_SYS_SPU(sched_rr_get_interval) 167SYSX_SPU(sys_sched_rr_get_interval,compat_sys_sched_rr_get_interval_wrapper,sys_sched_rr_get_interval)
168COMPAT_SYS_SPU(nanosleep) 168COMPAT_SYS_SPU(nanosleep)
169SYSCALL_SPU(mremap) 169SYSCALL_SPU(mremap)
170SYSCALL_SPU(setresuid) 170SYSCALL_SPU(setresuid)
diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h
index 76fe846ec40e..bcbbe413c606 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -54,6 +54,7 @@
54#define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND 54#define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND
55#define __ARCH_WANT_SYS_NEWFSTATAT 55#define __ARCH_WANT_SYS_NEWFSTATAT
56#define __ARCH_WANT_COMPAT_SYS_SENDFILE 56#define __ARCH_WANT_COMPAT_SYS_SENDFILE
57#define __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL
57#endif 58#endif
58#define __ARCH_WANT_SYS_EXECVE 59#define __ARCH_WANT_SYS_EXECVE
59#define __ARCH_WANT_SYS_FORK 60#define __ARCH_WANT_SYS_FORK
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index 9c2ed90ece8f..8a93778ed9f5 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -175,19 +175,10 @@ asmlinkage long compat_sys_prctl(u32 option, u32 arg2, u32 arg3, u32 arg4, u32 a
175 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) 175 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
176 * and the register representation of a signed int (msr in 64-bit mode) is performed. 176 * and the register representation of a signed int (msr in 64-bit mode) is performed.
177 */ 177 */
178asmlinkage long compat_sys_sched_rr_get_interval(u32 pid, struct compat_timespec __user *interval) 178asmlinkage long compat_sys_sched_rr_get_interval_wrapper(u32 pid,
179{ 179 struct compat_timespec __user *interval)
180 struct timespec t; 180{
181 int ret; 181 return compat_sys_sched_rr_get_interval((int)pid, interval);
182 mm_segment_t old_fs = get_fs ();
183
184 /* The __user pointer cast is valid because of the set_fs() */
185 set_fs (KERNEL_DS);
186 ret = sys_sched_rr_get_interval((int)pid, (struct timespec __user *) &t);
187 set_fs (old_fs);
188 if (put_compat_timespec(&t, interval))
189 return -EFAULT;
190 return ret;
191} 182}
192 183
193/* Note: it is necessary to treat mode as an unsigned int, 184/* Note: it is necessary to treat mode as an unsigned int,
diff --git a/arch/sparc/include/asm/unistd.h b/arch/sparc/include/asm/unistd.h
index c3e5d8b64171..497386a7ed28 100644
--- a/arch/sparc/include/asm/unistd.h
+++ b/arch/sparc/include/asm/unistd.h
@@ -45,6 +45,7 @@
45#define __ARCH_WANT_COMPAT_SYS_TIME 45#define __ARCH_WANT_COMPAT_SYS_TIME
46#define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND 46#define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND
47#define __ARCH_WANT_COMPAT_SYS_SENDFILE 47#define __ARCH_WANT_COMPAT_SYS_SENDFILE
48#define __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL
48#endif 49#endif
49#define __ARCH_WANT_SYS_EXECVE 50#define __ARCH_WANT_SYS_EXECVE
50 51
diff --git a/arch/sparc/kernel/sys_sparc32.c b/arch/sparc/kernel/sys_sparc32.c
index 03c7e929ec34..4a4cdc633f6b 100644
--- a/arch/sparc/kernel/sys_sparc32.c
+++ b/arch/sparc/kernel/sys_sparc32.c
@@ -211,20 +211,6 @@ asmlinkage long compat_sys_sysfs(int option, u32 arg1, u32 arg2)
211 return sys_sysfs(option, arg1, arg2); 211 return sys_sysfs(option, arg1, arg2);
212} 212}
213 213
214asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec __user *interval)
215{
216 struct timespec t;
217 int ret;
218 mm_segment_t old_fs = get_fs ();
219
220 set_fs (KERNEL_DS);
221 ret = sys_sched_rr_get_interval(pid, (struct timespec __user *) &t);
222 set_fs (old_fs);
223 if (put_compat_timespec(&t, interval))
224 return -EFAULT;
225 return ret;
226}
227
228asmlinkage long compat_sys_rt_sigprocmask(int how, 214asmlinkage long compat_sys_rt_sigprocmask(int how,
229 compat_sigset_t __user *set, 215 compat_sigset_t __user *set,
230 compat_sigset_t __user *oset, 216 compat_sigset_t __user *oset,
diff --git a/arch/tile/include/asm/compat.h b/arch/tile/include/asm/compat.h
index ca61fb4296b3..88f3c227afd9 100644
--- a/arch/tile/include/asm/compat.h
+++ b/arch/tile/include/asm/compat.h
@@ -296,8 +296,6 @@ long compat_sys_sync_file_range2(int fd, unsigned int flags,
296long compat_sys_fallocate(int fd, int mode, 296long compat_sys_fallocate(int fd, int mode,
297 u32 offset_lo, u32 offset_hi, 297 u32 offset_lo, u32 offset_hi,
298 u32 len_lo, u32 len_hi); 298 u32 len_lo, u32 len_hi);
299long compat_sys_sched_rr_get_interval(compat_pid_t pid,
300 struct compat_timespec __user *interval);
301 299
302/* Assembly trampoline to avoid clobbering r0. */ 300/* Assembly trampoline to avoid clobbering r0. */
303long _compat_sys_rt_sigreturn(void); 301long _compat_sys_rt_sigreturn(void);
diff --git a/arch/tile/include/asm/unistd.h b/arch/tile/include/asm/unistd.h
index b51c6ee3cd6c..fe841e7d4963 100644
--- a/arch/tile/include/asm/unistd.h
+++ b/arch/tile/include/asm/unistd.h
@@ -14,6 +14,7 @@
14/* In compat mode, we use sys_llseek() for compat_sys_llseek(). */ 14/* In compat mode, we use sys_llseek() for compat_sys_llseek(). */
15#ifdef CONFIG_COMPAT 15#ifdef CONFIG_COMPAT
16#define __ARCH_WANT_SYS_LLSEEK 16#define __ARCH_WANT_SYS_LLSEEK
17#define __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL
17#endif 18#endif
18#define __ARCH_WANT_SYS_NEWFSTATAT 19#define __ARCH_WANT_SYS_NEWFSTATAT
19#define __ARCH_WANT_SYS_EXECVE 20#define __ARCH_WANT_SYS_EXECVE
diff --git a/arch/tile/kernel/compat.c b/arch/tile/kernel/compat.c
index 9cd7cb6041c0..7f72401b4f45 100644
--- a/arch/tile/kernel/compat.c
+++ b/arch/tile/kernel/compat.c
@@ -76,24 +76,6 @@ long compat_sys_fallocate(int fd, int mode,
76 ((loff_t)len_hi << 32) | len_lo); 76 ((loff_t)len_hi << 32) | len_lo);
77} 77}
78 78
79
80
81long compat_sys_sched_rr_get_interval(compat_pid_t pid,
82 struct compat_timespec __user *interval)
83{
84 struct timespec t;
85 int ret;
86 mm_segment_t old_fs = get_fs();
87
88 set_fs(KERNEL_DS);
89 ret = sys_sched_rr_get_interval(pid,
90 (struct timespec __force __user *)&t);
91 set_fs(old_fs);
92 if (put_compat_timespec(&t, interval))
93 return -EFAULT;
94 return ret;
95}
96
97/* Provide the compat syscall number to call mapping. */ 79/* Provide the compat syscall number to call mapping. */
98#undef __SYSCALL 80#undef __SYSCALL
99#define __SYSCALL(nr, call) [nr] = (call), 81#define __SYSCALL(nr, call) [nr] = (call),
diff --git a/arch/x86/include/uapi/asm/hw_breakpoint.h b/arch/x86/include/uapi/asm/hw_breakpoint.h
index e69de29bb2d1..79a9626b5500 100644
--- a/arch/x86/include/uapi/asm/hw_breakpoint.h
+++ b/arch/x86/include/uapi/asm/hw_breakpoint.h
@@ -0,0 +1 @@
/* */
diff --git a/arch/x86/include/uapi/asm/setup.h b/arch/x86/include/uapi/asm/setup.h
index e69de29bb2d1..79a9626b5500 100644
--- a/arch/x86/include/uapi/asm/setup.h
+++ b/arch/x86/include/uapi/asm/setup.h
@@ -0,0 +1 @@
/* */
diff --git a/block/Kconfig b/block/Kconfig
index a7e40a7c8214..4a85ccf8d4cf 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -4,6 +4,7 @@
4menuconfig BLOCK 4menuconfig BLOCK
5 bool "Enable the block layer" if EXPERT 5 bool "Enable the block layer" if EXPERT
6 default y 6 default y
7 select PERCPU_RWSEM
7 help 8 help
8 Provide block layer support for the kernel. 9 Provide block layer support for the kernel.
9 10
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index d2ed7f18d1ac..175649468c95 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -1,5 +1,5 @@
1/* Copyright (c) 2012 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2012 Coraid, Inc. See COPYING for GPL terms. */
2#define VERSION "50" 2#define VERSION "81"
3#define AOE_MAJOR 152 3#define AOE_MAJOR 152
4#define DEVICE_NAME "aoe" 4#define DEVICE_NAME "aoe"
5 5
@@ -10,7 +10,7 @@
10#define AOE_PARTITIONS (16) 10#define AOE_PARTITIONS (16)
11#endif 11#endif
12 12
13#define WHITESPACE " \t\v\f\n" 13#define WHITESPACE " \t\v\f\n,"
14 14
15enum { 15enum {
16 AOECMD_ATA, 16 AOECMD_ATA,
@@ -73,21 +73,29 @@ enum {
73 DEVFL_TKILL = (1<<1), /* flag for timer to know when to kill self */ 73 DEVFL_TKILL = (1<<1), /* flag for timer to know when to kill self */
74 DEVFL_EXT = (1<<2), /* device accepts lba48 commands */ 74 DEVFL_EXT = (1<<2), /* device accepts lba48 commands */
75 DEVFL_GDALLOC = (1<<3), /* need to alloc gendisk */ 75 DEVFL_GDALLOC = (1<<3), /* need to alloc gendisk */
76 DEVFL_KICKME = (1<<4), /* slow polling network card catch */ 76 DEVFL_GD_NOW = (1<<4), /* allocating gendisk */
77 DEVFL_NEWSIZE = (1<<5), /* need to update dev size in block layer */ 77 DEVFL_KICKME = (1<<5), /* slow polling network card catch */
78 DEVFL_NEWSIZE = (1<<6), /* need to update dev size in block layer */
79 DEVFL_FREEING = (1<<7), /* set when device is being cleaned up */
80 DEVFL_FREED = (1<<8), /* device has been cleaned up */
78}; 81};
79 82
80enum { 83enum {
81 DEFAULTBCNT = 2 * 512, /* 2 sectors */ 84 DEFAULTBCNT = 2 * 512, /* 2 sectors */
82 MIN_BUFS = 16, 85 MIN_BUFS = 16,
83 NTARGETS = 8, 86 NTARGETS = 4,
84 NAOEIFS = 8, 87 NAOEIFS = 8,
85 NSKBPOOLMAX = 256, 88 NSKBPOOLMAX = 256,
86 NFACTIVE = 61, 89 NFACTIVE = 61,
87 90
88 TIMERTICK = HZ / 10, 91 TIMERTICK = HZ / 10,
89 MINTIMER = HZ >> 2, 92 RTTSCALE = 8,
90 MAXTIMER = HZ << 1, 93 RTTDSCALE = 3,
94 RTTAVG_INIT = USEC_PER_SEC / 4 << RTTSCALE,
95 RTTDEV_INIT = RTTAVG_INIT / 4,
96
97 HARD_SCORN_SECS = 10, /* try another remote port after this */
98 MAX_TAINT = 1000, /* cap on aoetgt taint */
91}; 99};
92 100
93struct buf { 101struct buf {
@@ -100,10 +108,17 @@ struct buf {
100 struct request *rq; 108 struct request *rq;
101}; 109};
102 110
111enum frame_flags {
112 FFL_PROBE = 1,
113};
114
103struct frame { 115struct frame {
104 struct list_head head; 116 struct list_head head;
105 u32 tag; 117 u32 tag;
118 struct timeval sent; /* high-res time packet was sent */
119 u32 sent_jiffs; /* low-res jiffies-based sent time */
106 ulong waited; 120 ulong waited;
121 ulong waited_total;
107 struct aoetgt *t; /* parent target I belong to */ 122 struct aoetgt *t; /* parent target I belong to */
108 sector_t lba; 123 sector_t lba;
109 struct sk_buff *skb; /* command skb freed on module exit */ 124 struct sk_buff *skb; /* command skb freed on module exit */
@@ -112,6 +127,7 @@ struct frame {
112 struct bio_vec *bv; 127 struct bio_vec *bv;
113 ulong bcnt; 128 ulong bcnt;
114 ulong bv_off; 129 ulong bv_off;
130 char flags;
115}; 131};
116 132
117struct aoeif { 133struct aoeif {
@@ -122,28 +138,31 @@ struct aoeif {
122 138
123struct aoetgt { 139struct aoetgt {
124 unsigned char addr[6]; 140 unsigned char addr[6];
125 ushort nframes; 141 ushort nframes; /* cap on frames to use */
126 struct aoedev *d; /* parent device I belong to */ 142 struct aoedev *d; /* parent device I belong to */
127 struct list_head ffree; /* list of free frames */ 143 struct list_head ffree; /* list of free frames */
128 struct aoeif ifs[NAOEIFS]; 144 struct aoeif ifs[NAOEIFS];
129 struct aoeif *ifp; /* current aoeif in use */ 145 struct aoeif *ifp; /* current aoeif in use */
130 ushort nout; 146 ushort nout; /* number of AoE commands outstanding */
131 ushort maxout; 147 ushort maxout; /* current value for max outstanding */
132 ulong falloc; 148 ushort next_cwnd; /* incr maxout after decrementing to zero */
133 ulong lastwadj; /* last window adjustment */ 149 ushort ssthresh; /* slow start threshold */
150 ulong falloc; /* number of allocated frames */
151 int taint; /* how much we want to avoid this aoetgt */
134 int minbcnt; 152 int minbcnt;
135 int wpkts, rpkts; 153 int wpkts, rpkts;
154 char nout_probes;
136}; 155};
137 156
138struct aoedev { 157struct aoedev {
139 struct aoedev *next; 158 struct aoedev *next;
140 ulong sysminor; 159 ulong sysminor;
141 ulong aoemajor; 160 ulong aoemajor;
161 u32 rttavg; /* scaled AoE round trip time average */
162 u32 rttdev; /* scaled round trip time mean deviation */
142 u16 aoeminor; 163 u16 aoeminor;
143 u16 flags; 164 u16 flags;
144 u16 nopen; /* (bd_openers isn't available without sleeping) */ 165 u16 nopen; /* (bd_openers isn't available without sleeping) */
145 u16 rttavg; /* round trip average of requests/responses */
146 u16 mintimer;
147 u16 fw_ver; /* version of blade's firmware */ 166 u16 fw_ver; /* version of blade's firmware */
148 u16 lasttag; /* last tag sent */ 167 u16 lasttag; /* last tag sent */
149 u16 useme; 168 u16 useme;
@@ -151,7 +170,7 @@ struct aoedev {
151 struct work_struct work;/* disk create work struct */ 170 struct work_struct work;/* disk create work struct */
152 struct gendisk *gd; 171 struct gendisk *gd;
153 struct request_queue *blkq; 172 struct request_queue *blkq;
154 struct hd_geometry geo; 173 struct hd_geometry geo;
155 sector_t ssize; 174 sector_t ssize;
156 struct timer_list timer; 175 struct timer_list timer;
157 spinlock_t lock; 176 spinlock_t lock;
@@ -164,11 +183,12 @@ struct aoedev {
164 } ip; 183 } ip;
165 ulong maxbcnt; 184 ulong maxbcnt;
166 struct list_head factive[NFACTIVE]; /* hash of active frames */ 185 struct list_head factive[NFACTIVE]; /* hash of active frames */
167 struct aoetgt *targets[NTARGETS]; 186 struct list_head rexmitq; /* deferred retransmissions */
187 struct aoetgt **targets;
188 ulong ntargets; /* number of allocated aoetgt pointers */
168 struct aoetgt **tgt; /* target in use when working */ 189 struct aoetgt **tgt; /* target in use when working */
169 struct aoetgt *htgt; /* target needing rexmit assistance */
170 ulong ntargets;
171 ulong kicked; 190 ulong kicked;
191 char ident[512];
172}; 192};
173 193
174/* kthread tracking */ 194/* kthread tracking */
@@ -195,6 +215,7 @@ void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
195struct sk_buff *aoecmd_ata_rsp(struct sk_buff *); 215struct sk_buff *aoecmd_ata_rsp(struct sk_buff *);
196void aoecmd_cfg_rsp(struct sk_buff *); 216void aoecmd_cfg_rsp(struct sk_buff *);
197void aoecmd_sleepwork(struct work_struct *); 217void aoecmd_sleepwork(struct work_struct *);
218void aoecmd_wreset(struct aoetgt *t);
198void aoecmd_cleanslate(struct aoedev *); 219void aoecmd_cleanslate(struct aoedev *);
199void aoecmd_exit(void); 220void aoecmd_exit(void);
200int aoecmd_init(void); 221int aoecmd_init(void);
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index 00dfc5008ad4..a129f8c8073d 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -16,11 +16,19 @@
16#include <linux/netdevice.h> 16#include <linux/netdevice.h>
17#include <linux/mutex.h> 17#include <linux/mutex.h>
18#include <linux/export.h> 18#include <linux/export.h>
19#include <linux/moduleparam.h>
20#include <scsi/sg.h>
19#include "aoe.h" 21#include "aoe.h"
20 22
21static DEFINE_MUTEX(aoeblk_mutex); 23static DEFINE_MUTEX(aoeblk_mutex);
22static struct kmem_cache *buf_pool_cache; 24static struct kmem_cache *buf_pool_cache;
23 25
26/* GPFS needs a larger value than the default. */
27static int aoe_maxsectors;
28module_param(aoe_maxsectors, int, 0644);
29MODULE_PARM_DESC(aoe_maxsectors,
30 "When nonzero, set the maximum number of sectors per I/O request");
31
24static ssize_t aoedisk_show_state(struct device *dev, 32static ssize_t aoedisk_show_state(struct device *dev,
25 struct device_attribute *attr, char *page) 33 struct device_attribute *attr, char *page)
26{ 34{
@@ -59,7 +67,7 @@ static ssize_t aoedisk_show_netif(struct device *dev,
59 nd = nds; 67 nd = nds;
60 ne = nd + ARRAY_SIZE(nds); 68 ne = nd + ARRAY_SIZE(nds);
61 t = d->targets; 69 t = d->targets;
62 te = t + NTARGETS; 70 te = t + d->ntargets;
63 for (; t < te && *t; t++) { 71 for (; t < te && *t; t++) {
64 ifp = (*t)->ifs; 72 ifp = (*t)->ifs;
65 e = ifp + NAOEIFS; 73 e = ifp + NAOEIFS;
@@ -91,6 +99,14 @@ static ssize_t aoedisk_show_fwver(struct device *dev,
91 99
92 return snprintf(page, PAGE_SIZE, "0x%04x\n", (unsigned int) d->fw_ver); 100 return snprintf(page, PAGE_SIZE, "0x%04x\n", (unsigned int) d->fw_ver);
93} 101}
102static ssize_t aoedisk_show_payload(struct device *dev,
103 struct device_attribute *attr, char *page)
104{
105 struct gendisk *disk = dev_to_disk(dev);
106 struct aoedev *d = disk->private_data;
107
108 return snprintf(page, PAGE_SIZE, "%lu\n", d->maxbcnt);
109}
94 110
95static DEVICE_ATTR(state, S_IRUGO, aoedisk_show_state, NULL); 111static DEVICE_ATTR(state, S_IRUGO, aoedisk_show_state, NULL);
96static DEVICE_ATTR(mac, S_IRUGO, aoedisk_show_mac, NULL); 112static DEVICE_ATTR(mac, S_IRUGO, aoedisk_show_mac, NULL);
@@ -99,12 +115,14 @@ static struct device_attribute dev_attr_firmware_version = {
99 .attr = { .name = "firmware-version", .mode = S_IRUGO }, 115 .attr = { .name = "firmware-version", .mode = S_IRUGO },
100 .show = aoedisk_show_fwver, 116 .show = aoedisk_show_fwver,
101}; 117};
118static DEVICE_ATTR(payload, S_IRUGO, aoedisk_show_payload, NULL);
102 119
103static struct attribute *aoe_attrs[] = { 120static struct attribute *aoe_attrs[] = {
104 &dev_attr_state.attr, 121 &dev_attr_state.attr,
105 &dev_attr_mac.attr, 122 &dev_attr_mac.attr,
106 &dev_attr_netif.attr, 123 &dev_attr_netif.attr,
107 &dev_attr_firmware_version.attr, 124 &dev_attr_firmware_version.attr,
125 &dev_attr_payload.attr,
108 NULL, 126 NULL,
109}; 127};
110 128
@@ -129,9 +147,18 @@ aoeblk_open(struct block_device *bdev, fmode_t mode)
129 struct aoedev *d = bdev->bd_disk->private_data; 147 struct aoedev *d = bdev->bd_disk->private_data;
130 ulong flags; 148 ulong flags;
131 149
150 if (!virt_addr_valid(d)) {
151 pr_crit("aoe: invalid device pointer in %s\n",
152 __func__);
153 WARN_ON(1);
154 return -ENODEV;
155 }
156 if (!(d->flags & DEVFL_UP) || d->flags & DEVFL_TKILL)
157 return -ENODEV;
158
132 mutex_lock(&aoeblk_mutex); 159 mutex_lock(&aoeblk_mutex);
133 spin_lock_irqsave(&d->lock, flags); 160 spin_lock_irqsave(&d->lock, flags);
134 if (d->flags & DEVFL_UP) { 161 if (d->flags & DEVFL_UP && !(d->flags & DEVFL_TKILL)) {
135 d->nopen++; 162 d->nopen++;
136 spin_unlock_irqrestore(&d->lock, flags); 163 spin_unlock_irqrestore(&d->lock, flags);
137 mutex_unlock(&aoeblk_mutex); 164 mutex_unlock(&aoeblk_mutex);
@@ -195,9 +222,38 @@ aoeblk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
195 return 0; 222 return 0;
196} 223}
197 224
225static int
226aoeblk_ioctl(struct block_device *bdev, fmode_t mode, uint cmd, ulong arg)
227{
228 struct aoedev *d;
229
230 if (!arg)
231 return -EINVAL;
232
233 d = bdev->bd_disk->private_data;
234 if ((d->flags & DEVFL_UP) == 0) {
235 pr_err("aoe: disk not up\n");
236 return -ENODEV;
237 }
238
239 if (cmd == HDIO_GET_IDENTITY) {
240 if (!copy_to_user((void __user *) arg, &d->ident,
241 sizeof(d->ident)))
242 return 0;
243 return -EFAULT;
244 }
245
246 /* udev calls scsi_id, which uses SG_IO, resulting in noise */
247 if (cmd != SG_IO)
248 pr_info("aoe: unknown ioctl 0x%x\n", cmd);
249
250 return -ENOTTY;
251}
252
198static const struct block_device_operations aoe_bdops = { 253static const struct block_device_operations aoe_bdops = {
199 .open = aoeblk_open, 254 .open = aoeblk_open,
200 .release = aoeblk_release, 255 .release = aoeblk_release,
256 .ioctl = aoeblk_ioctl,
201 .getgeo = aoeblk_getgeo, 257 .getgeo = aoeblk_getgeo,
202 .owner = THIS_MODULE, 258 .owner = THIS_MODULE,
203}; 259};
@@ -212,6 +268,18 @@ aoeblk_gdalloc(void *vp)
212 struct request_queue *q; 268 struct request_queue *q;
213 enum { KB = 1024, MB = KB * KB, READ_AHEAD = 2 * MB, }; 269 enum { KB = 1024, MB = KB * KB, READ_AHEAD = 2 * MB, };
214 ulong flags; 270 ulong flags;
271 int late = 0;
272
273 spin_lock_irqsave(&d->lock, flags);
274 if (d->flags & DEVFL_GDALLOC
275 && !(d->flags & DEVFL_TKILL)
276 && !(d->flags & DEVFL_GD_NOW))
277 d->flags |= DEVFL_GD_NOW;
278 else
279 late = 1;
280 spin_unlock_irqrestore(&d->lock, flags);
281 if (late)
282 return;
215 283
216 gd = alloc_disk(AOE_PARTITIONS); 284 gd = alloc_disk(AOE_PARTITIONS);
217 if (gd == NULL) { 285 if (gd == NULL) {
@@ -231,23 +299,24 @@ aoeblk_gdalloc(void *vp)
231 if (q == NULL) { 299 if (q == NULL) {
232 pr_err("aoe: cannot allocate block queue for %ld.%d\n", 300 pr_err("aoe: cannot allocate block queue for %ld.%d\n",
233 d->aoemajor, d->aoeminor); 301 d->aoemajor, d->aoeminor);
234 mempool_destroy(mp); 302 goto err_mempool;
235 goto err_disk;
236 } 303 }
237 304
238 d->blkq = blk_alloc_queue(GFP_KERNEL);
239 if (!d->blkq)
240 goto err_mempool;
241 d->blkq->backing_dev_info.name = "aoe";
242 if (bdi_init(&d->blkq->backing_dev_info))
243 goto err_blkq;
244 spin_lock_irqsave(&d->lock, flags); 305 spin_lock_irqsave(&d->lock, flags);
245 blk_queue_max_hw_sectors(d->blkq, BLK_DEF_MAX_SECTORS); 306 WARN_ON(!(d->flags & DEVFL_GD_NOW));
307 WARN_ON(!(d->flags & DEVFL_GDALLOC));
308 WARN_ON(d->flags & DEVFL_TKILL);
309 WARN_ON(d->gd);
310 WARN_ON(d->flags & DEVFL_UP);
311 blk_queue_max_hw_sectors(q, BLK_DEF_MAX_SECTORS);
312 q->backing_dev_info.name = "aoe";
246 q->backing_dev_info.ra_pages = READ_AHEAD / PAGE_CACHE_SIZE; 313 q->backing_dev_info.ra_pages = READ_AHEAD / PAGE_CACHE_SIZE;
247 d->bufpool = mp; 314 d->bufpool = mp;
248 d->blkq = gd->queue = q; 315 d->blkq = gd->queue = q;
249 q->queuedata = d; 316 q->queuedata = d;
250 d->gd = gd; 317 d->gd = gd;
318 if (aoe_maxsectors)
319 blk_queue_max_hw_sectors(q, aoe_maxsectors);
251 gd->major = AOE_MAJOR; 320 gd->major = AOE_MAJOR;
252 gd->first_minor = d->sysminor; 321 gd->first_minor = d->sysminor;
253 gd->fops = &aoe_bdops; 322 gd->fops = &aoe_bdops;
@@ -263,18 +332,21 @@ aoeblk_gdalloc(void *vp)
263 332
264 add_disk(gd); 333 add_disk(gd);
265 aoedisk_add_sysfs(d); 334 aoedisk_add_sysfs(d);
335
336 spin_lock_irqsave(&d->lock, flags);
337 WARN_ON(!(d->flags & DEVFL_GD_NOW));
338 d->flags &= ~DEVFL_GD_NOW;
339 spin_unlock_irqrestore(&d->lock, flags);
266 return; 340 return;
267 341
268err_blkq:
269 blk_cleanup_queue(d->blkq);
270 d->blkq = NULL;
271err_mempool: 342err_mempool:
272 mempool_destroy(d->bufpool); 343 mempool_destroy(mp);
273err_disk: 344err_disk:
274 put_disk(gd); 345 put_disk(gd);
275err: 346err:
276 spin_lock_irqsave(&d->lock, flags); 347 spin_lock_irqsave(&d->lock, flags);
277 d->flags &= ~DEVFL_GDALLOC; 348 d->flags &= ~DEVFL_GD_NOW;
349 schedule_work(&d->work);
278 spin_unlock_irqrestore(&d->lock, flags); 350 spin_unlock_irqrestore(&d->lock, flags);
279} 351}
280 352
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index ed57a890c643..42e67ad6bd20 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -39,6 +39,11 @@ struct ErrMsg {
39}; 39};
40 40
41static DEFINE_MUTEX(aoechr_mutex); 41static DEFINE_MUTEX(aoechr_mutex);
42
43/* A ring buffer of error messages, to be read through
44 * "/dev/etherd/err". When no messages are present,
45 * readers will block waiting for messages to appear.
46 */
42static struct ErrMsg emsgs[NMSG]; 47static struct ErrMsg emsgs[NMSG];
43static int emsgs_head_idx, emsgs_tail_idx; 48static int emsgs_head_idx, emsgs_tail_idx;
44static struct completion emsgs_comp; 49static struct completion emsgs_comp;
@@ -282,7 +287,7 @@ aoechr_init(void)
282 int n, i; 287 int n, i;
283 288
284 n = register_chrdev(AOE_MAJOR, "aoechr", &aoe_fops); 289 n = register_chrdev(AOE_MAJOR, "aoechr", &aoe_fops);
285 if (n < 0) { 290 if (n < 0) {
286 printk(KERN_ERR "aoe: can't register char device\n"); 291 printk(KERN_ERR "aoe: can't register char device\n");
287 return n; 292 return n;
288 } 293 }
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 9fe4f1865558..25ef5c014fca 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -22,6 +22,7 @@
22#define MAXIOC (8192) /* default meant to avoid most soft lockups */ 22#define MAXIOC (8192) /* default meant to avoid most soft lockups */
23 23
24static void ktcomplete(struct frame *, struct sk_buff *); 24static void ktcomplete(struct frame *, struct sk_buff *);
25static int count_targets(struct aoedev *d, int *untainted);
25 26
26static struct buf *nextbuf(struct aoedev *); 27static struct buf *nextbuf(struct aoedev *);
27 28
@@ -29,7 +30,7 @@ static int aoe_deadsecs = 60 * 3;
29module_param(aoe_deadsecs, int, 0644); 30module_param(aoe_deadsecs, int, 0644);
30MODULE_PARM_DESC(aoe_deadsecs, "After aoe_deadsecs seconds, give up and fail dev."); 31MODULE_PARM_DESC(aoe_deadsecs, "After aoe_deadsecs seconds, give up and fail dev.");
31 32
32static int aoe_maxout = 16; 33static int aoe_maxout = 64;
33module_param(aoe_maxout, int, 0644); 34module_param(aoe_maxout, int, 0644);
34MODULE_PARM_DESC(aoe_maxout, 35MODULE_PARM_DESC(aoe_maxout,
35 "Only aoe_maxout outstanding packets for every MAC on eX.Y."); 36 "Only aoe_maxout outstanding packets for every MAC on eX.Y.");
@@ -43,6 +44,8 @@ static struct {
43 spinlock_t lock; 44 spinlock_t lock;
44} iocq; 45} iocq;
45 46
47static struct page *empty_page;
48
46static struct sk_buff * 49static struct sk_buff *
47new_skb(ulong len) 50new_skb(ulong len)
48{ 51{
@@ -59,6 +62,23 @@ new_skb(ulong len)
59} 62}
60 63
61static struct frame * 64static struct frame *
65getframe_deferred(struct aoedev *d, u32 tag)
66{
67 struct list_head *head, *pos, *nx;
68 struct frame *f;
69
70 head = &d->rexmitq;
71 list_for_each_safe(pos, nx, head) {
72 f = list_entry(pos, struct frame, head);
73 if (f->tag == tag) {
74 list_del(pos);
75 return f;
76 }
77 }
78 return NULL;
79}
80
81static struct frame *
62getframe(struct aoedev *d, u32 tag) 82getframe(struct aoedev *d, u32 tag)
63{ 83{
64 struct frame *f; 84 struct frame *f;
@@ -162,8 +182,10 @@ aoe_freetframe(struct frame *f)
162 182
163 t = f->t; 183 t = f->t;
164 f->buf = NULL; 184 f->buf = NULL;
185 f->lba = 0;
165 f->bv = NULL; 186 f->bv = NULL;
166 f->r_skb = NULL; 187 f->r_skb = NULL;
188 f->flags = 0;
167 list_add(&f->head, &t->ffree); 189 list_add(&f->head, &t->ffree);
168} 190}
169 191
@@ -217,20 +239,25 @@ newframe(struct aoedev *d)
217 struct frame *f; 239 struct frame *f;
218 struct aoetgt *t, **tt; 240 struct aoetgt *t, **tt;
219 int totout = 0; 241 int totout = 0;
242 int use_tainted;
243 int has_untainted;
220 244
221 if (d->targets[0] == NULL) { /* shouldn't happen, but I'm paranoid */ 245 if (!d->targets || !d->targets[0]) {
222 printk(KERN_ERR "aoe: NULL TARGETS!\n"); 246 printk(KERN_ERR "aoe: NULL TARGETS!\n");
223 return NULL; 247 return NULL;
224 } 248 }
225 tt = d->tgt; /* last used target */ 249 tt = d->tgt; /* last used target */
226 for (;;) { 250 for (use_tainted = 0, has_untainted = 0;;) {
227 tt++; 251 tt++;
228 if (tt >= &d->targets[NTARGETS] || !*tt) 252 if (tt >= &d->targets[d->ntargets] || !*tt)
229 tt = d->targets; 253 tt = d->targets;
230 t = *tt; 254 t = *tt;
231 totout += t->nout; 255 if (!t->taint) {
256 has_untainted = 1;
257 totout += t->nout;
258 }
232 if (t->nout < t->maxout 259 if (t->nout < t->maxout
233 && t != d->htgt 260 && (use_tainted || !t->taint)
234 && t->ifp->nd) { 261 && t->ifp->nd) {
235 f = newtframe(d, t); 262 f = newtframe(d, t);
236 if (f) { 263 if (f) {
@@ -239,8 +266,12 @@ newframe(struct aoedev *d)
239 return f; 266 return f;
240 } 267 }
241 } 268 }
242 if (tt == d->tgt) /* we've looped and found nada */ 269 if (tt == d->tgt) { /* we've looped and found nada */
243 break; 270 if (!use_tainted && !has_untainted)
271 use_tainted = 1;
272 else
273 break;
274 }
244 } 275 }
245 if (totout == 0) { 276 if (totout == 0) {
246 d->kicked++; 277 d->kicked++;
@@ -277,21 +308,68 @@ fhash(struct frame *f)
277 list_add_tail(&f->head, &d->factive[n]); 308 list_add_tail(&f->head, &d->factive[n]);
278} 309}
279 310
311static void
312ata_rw_frameinit(struct frame *f)
313{
314 struct aoetgt *t;
315 struct aoe_hdr *h;
316 struct aoe_atahdr *ah;
317 struct sk_buff *skb;
318 char writebit, extbit;
319
320 skb = f->skb;
321 h = (struct aoe_hdr *) skb_mac_header(skb);
322 ah = (struct aoe_atahdr *) (h + 1);
323 skb_put(skb, sizeof(*h) + sizeof(*ah));
324 memset(h, 0, skb->len);
325
326 writebit = 0x10;
327 extbit = 0x4;
328
329 t = f->t;
330 f->tag = aoehdr_atainit(t->d, t, h);
331 fhash(f);
332 t->nout++;
333 f->waited = 0;
334 f->waited_total = 0;
335 if (f->buf)
336 f->lba = f->buf->sector;
337
338 /* set up ata header */
339 ah->scnt = f->bcnt >> 9;
340 put_lba(ah, f->lba);
341 if (t->d->flags & DEVFL_EXT) {
342 ah->aflags |= AOEAFL_EXT;
343 } else {
344 extbit = 0;
345 ah->lba3 &= 0x0f;
346 ah->lba3 |= 0xe0; /* LBA bit + obsolete 0xa0 */
347 }
348 if (f->buf && bio_data_dir(f->buf->bio) == WRITE) {
349 skb_fillup(skb, f->bv, f->bv_off, f->bcnt);
350 ah->aflags |= AOEAFL_WRITE;
351 skb->len += f->bcnt;
352 skb->data_len = f->bcnt;
353 skb->truesize += f->bcnt;
354 t->wpkts++;
355 } else {
356 t->rpkts++;
357 writebit = 0;
358 }
359
360 ah->cmdstat = ATA_CMD_PIO_READ | writebit | extbit;
361 skb->dev = t->ifp->nd;
362}
363
280static int 364static int
281aoecmd_ata_rw(struct aoedev *d) 365aoecmd_ata_rw(struct aoedev *d)
282{ 366{
283 struct frame *f; 367 struct frame *f;
284 struct aoe_hdr *h;
285 struct aoe_atahdr *ah;
286 struct buf *buf; 368 struct buf *buf;
287 struct aoetgt *t; 369 struct aoetgt *t;
288 struct sk_buff *skb; 370 struct sk_buff *skb;
289 struct sk_buff_head queue; 371 struct sk_buff_head queue;
290 ulong bcnt, fbcnt; 372 ulong bcnt, fbcnt;
291 char writebit, extbit;
292
293 writebit = 0x10;
294 extbit = 0x4;
295 373
296 buf = nextbuf(d); 374 buf = nextbuf(d);
297 if (buf == NULL) 375 if (buf == NULL)
@@ -326,50 +404,18 @@ aoecmd_ata_rw(struct aoedev *d)
326 } while (fbcnt); 404 } while (fbcnt);
327 405
328 /* initialize the headers & frame */ 406 /* initialize the headers & frame */
329 skb = f->skb;
330 h = (struct aoe_hdr *) skb_mac_header(skb);
331 ah = (struct aoe_atahdr *) (h+1);
332 skb_put(skb, sizeof *h + sizeof *ah);
333 memset(h, 0, skb->len);
334 f->tag = aoehdr_atainit(d, t, h);
335 fhash(f);
336 t->nout++;
337 f->waited = 0;
338 f->buf = buf; 407 f->buf = buf;
339 f->bcnt = bcnt; 408 f->bcnt = bcnt;
340 f->lba = buf->sector; 409 ata_rw_frameinit(f);
341
342 /* set up ata header */
343 ah->scnt = bcnt >> 9;
344 put_lba(ah, buf->sector);
345 if (d->flags & DEVFL_EXT) {
346 ah->aflags |= AOEAFL_EXT;
347 } else {
348 extbit = 0;
349 ah->lba3 &= 0x0f;
350 ah->lba3 |= 0xe0; /* LBA bit + obsolete 0xa0 */
351 }
352 if (bio_data_dir(buf->bio) == WRITE) {
353 skb_fillup(skb, f->bv, f->bv_off, bcnt);
354 ah->aflags |= AOEAFL_WRITE;
355 skb->len += bcnt;
356 skb->data_len = bcnt;
357 skb->truesize += bcnt;
358 t->wpkts++;
359 } else {
360 t->rpkts++;
361 writebit = 0;
362 }
363
364 ah->cmdstat = ATA_CMD_PIO_READ | writebit | extbit;
365 410
366 /* mark all tracking fields and load out */ 411 /* mark all tracking fields and load out */
367 buf->nframesout += 1; 412 buf->nframesout += 1;
368 buf->sector += bcnt >> 9; 413 buf->sector += bcnt >> 9;
369 414
370 skb->dev = t->ifp->nd; 415 skb = skb_clone(f->skb, GFP_ATOMIC);
371 skb = skb_clone(skb, GFP_ATOMIC);
372 if (skb) { 416 if (skb) {
417 do_gettimeofday(&f->sent);
418 f->sent_jiffs = (u32) jiffies;
373 __skb_queue_head_init(&queue); 419 __skb_queue_head_init(&queue);
374 __skb_queue_tail(&queue, skb); 420 __skb_queue_tail(&queue, skb);
375 aoenet_xmit(&queue); 421 aoenet_xmit(&queue);
@@ -442,11 +488,14 @@ resend(struct aoedev *d, struct frame *f)
442 h = (struct aoe_hdr *) skb_mac_header(skb); 488 h = (struct aoe_hdr *) skb_mac_header(skb);
443 ah = (struct aoe_atahdr *) (h+1); 489 ah = (struct aoe_atahdr *) (h+1);
444 490
445 snprintf(buf, sizeof buf, 491 if (!(f->flags & FFL_PROBE)) {
446 "%15s e%ld.%d oldtag=%08x@%08lx newtag=%08x s=%pm d=%pm nout=%d\n", 492 snprintf(buf, sizeof(buf),
447 "retransmit", d->aoemajor, d->aoeminor, f->tag, jiffies, n, 493 "%15s e%ld.%d oldtag=%08x@%08lx newtag=%08x s=%pm d=%pm nout=%d\n",
448 h->src, h->dst, t->nout); 494 "retransmit", d->aoemajor, d->aoeminor,
449 aoechr_error(buf); 495 f->tag, jiffies, n,
496 h->src, h->dst, t->nout);
497 aoechr_error(buf);
498 }
450 499
451 f->tag = n; 500 f->tag = n;
452 fhash(f); 501 fhash(f);
@@ -458,12 +507,46 @@ resend(struct aoedev *d, struct frame *f)
458 skb = skb_clone(skb, GFP_ATOMIC); 507 skb = skb_clone(skb, GFP_ATOMIC);
459 if (skb == NULL) 508 if (skb == NULL)
460 return; 509 return;
510 do_gettimeofday(&f->sent);
511 f->sent_jiffs = (u32) jiffies;
461 __skb_queue_head_init(&queue); 512 __skb_queue_head_init(&queue);
462 __skb_queue_tail(&queue, skb); 513 __skb_queue_tail(&queue, skb);
463 aoenet_xmit(&queue); 514 aoenet_xmit(&queue);
464} 515}
465 516
466static int 517static int
518tsince_hr(struct frame *f)
519{
520 struct timeval now;
521 int n;
522
523 do_gettimeofday(&now);
524 n = now.tv_usec - f->sent.tv_usec;
525 n += (now.tv_sec - f->sent.tv_sec) * USEC_PER_SEC;
526
527 if (n < 0)
528 n = -n;
529
530 /* For relatively long periods, use jiffies to avoid
531 * discrepancies caused by updates to the system time.
532 *
533 * On system with HZ of 1000, 32-bits is over 49 days
534 * worth of jiffies, or over 71 minutes worth of usecs.
535 *
536 * Jiffies overflow is handled by subtraction of unsigned ints:
537 * (gdb) print (unsigned) 2 - (unsigned) 0xfffffffe
538 * $3 = 4
539 * (gdb)
540 */
541 if (n > USEC_PER_SEC / 4) {
542 n = ((u32) jiffies) - f->sent_jiffs;
543 n *= USEC_PER_SEC / HZ;
544 }
545
546 return n;
547}
548
549static int
467tsince(u32 tag) 550tsince(u32 tag)
468{ 551{
469 int n; 552 int n;
@@ -472,7 +555,7 @@ tsince(u32 tag)
472 n -= tag & 0xffff; 555 n -= tag & 0xffff;
473 if (n < 0) 556 if (n < 0)
474 n += 1<<16; 557 n += 1<<16;
475 return n; 558 return jiffies_to_usecs(n + 1);
476} 559}
477 560
478static struct aoeif * 561static struct aoeif *
@@ -503,70 +586,189 @@ ejectif(struct aoetgt *t, struct aoeif *ifp)
503 dev_put(nd); 586 dev_put(nd);
504} 587}
505 588
506static int 589static struct frame *
507sthtith(struct aoedev *d) 590reassign_frame(struct frame *f)
508{ 591{
509 struct frame *f, *nf; 592 struct frame *nf;
510 struct list_head *nx, *pos, *head;
511 struct sk_buff *skb; 593 struct sk_buff *skb;
512 struct aoetgt *ht = d->htgt;
513 int i;
514 594
515 for (i = 0; i < NFACTIVE; i++) { 595 nf = newframe(f->t->d);
516 head = &d->factive[i]; 596 if (!nf)
517 list_for_each_safe(pos, nx, head) { 597 return NULL;
518 f = list_entry(pos, struct frame, head); 598 if (nf->t == f->t) {
519 if (f->t != ht) 599 aoe_freetframe(nf);
520 continue; 600 return NULL;
601 }
521 602
522 nf = newframe(d); 603 skb = nf->skb;
523 if (!nf) 604 nf->skb = f->skb;
524 return 0; 605 nf->buf = f->buf;
606 nf->bcnt = f->bcnt;
607 nf->lba = f->lba;
608 nf->bv = f->bv;
609 nf->bv_off = f->bv_off;
610 nf->waited = 0;
611 nf->waited_total = f->waited_total;
612 nf->sent = f->sent;
613 nf->sent_jiffs = f->sent_jiffs;
614 f->skb = skb;
615
616 return nf;
617}
525 618
526 /* remove frame from active list */ 619static void
527 list_del(pos); 620probe(struct aoetgt *t)
621{
622 struct aoedev *d;
623 struct frame *f;
624 struct sk_buff *skb;
625 struct sk_buff_head queue;
626 size_t n, m;
627 int frag;
528 628
529 /* reassign all pertinent bits to new outbound frame */ 629 d = t->d;
530 skb = nf->skb; 630 f = newtframe(d, t);
531 nf->skb = f->skb; 631 if (!f) {
532 nf->buf = f->buf; 632 pr_err("%s %pm for e%ld.%d: %s\n",
533 nf->bcnt = f->bcnt; 633 "aoe: cannot probe remote address",
534 nf->lba = f->lba; 634 t->addr,
535 nf->bv = f->bv; 635 (long) d->aoemajor, d->aoeminor,
536 nf->bv_off = f->bv_off; 636 "no frame available");
537 nf->waited = 0; 637 return;
538 f->skb = skb; 638 }
639 f->flags |= FFL_PROBE;
640 ifrotate(t);
641 f->bcnt = t->d->maxbcnt ? t->d->maxbcnt : DEFAULTBCNT;
642 ata_rw_frameinit(f);
643 skb = f->skb;
644 for (frag = 0, n = f->bcnt; n > 0; ++frag, n -= m) {
645 if (n < PAGE_SIZE)
646 m = n;
647 else
648 m = PAGE_SIZE;
649 skb_fill_page_desc(skb, frag, empty_page, 0, m);
650 }
651 skb->len += f->bcnt;
652 skb->data_len = f->bcnt;
653 skb->truesize += f->bcnt;
654
655 skb = skb_clone(f->skb, GFP_ATOMIC);
656 if (skb) {
657 do_gettimeofday(&f->sent);
658 f->sent_jiffs = (u32) jiffies;
659 __skb_queue_head_init(&queue);
660 __skb_queue_tail(&queue, skb);
661 aoenet_xmit(&queue);
662 }
663}
664
665static long
666rto(struct aoedev *d)
667{
668 long t;
669
670 t = 2 * d->rttavg >> RTTSCALE;
671 t += 8 * d->rttdev >> RTTDSCALE;
672 if (t == 0)
673 t = 1;
674
675 return t;
676}
677
678static void
679rexmit_deferred(struct aoedev *d)
680{
681 struct aoetgt *t;
682 struct frame *f;
683 struct frame *nf;
684 struct list_head *pos, *nx, *head;
685 int since;
686 int untainted;
687
688 count_targets(d, &untainted);
689
690 head = &d->rexmitq;
691 list_for_each_safe(pos, nx, head) {
692 f = list_entry(pos, struct frame, head);
693 t = f->t;
694 if (t->taint) {
695 if (!(f->flags & FFL_PROBE)) {
696 nf = reassign_frame(f);
697 if (nf) {
698 if (t->nout_probes == 0
699 && untainted > 0) {
700 probe(t);
701 t->nout_probes++;
702 }
703 list_replace(&f->head, &nf->head);
704 pos = &nf->head;
705 aoe_freetframe(f);
706 f = nf;
707 t = f->t;
708 }
709 } else if (untainted < 1) {
710 /* don't probe w/o other untainted aoetgts */
711 goto stop_probe;
712 } else if (tsince_hr(f) < t->taint * rto(d)) {
713 /* reprobe slowly when taint is high */
714 continue;
715 }
716 } else if (f->flags & FFL_PROBE) {
717stop_probe: /* don't probe untainted aoetgts */
718 list_del(pos);
539 aoe_freetframe(f); 719 aoe_freetframe(f);
540 ht->nout--; 720 /* leaving d->kicked, because this is routine */
541 nf->t->nout++; 721 f->t->d->flags |= DEVFL_KICKME;
542 resend(d, nf); 722 continue;
543 } 723 }
724 if (t->nout >= t->maxout)
725 continue;
726 list_del(pos);
727 t->nout++;
728 if (f->flags & FFL_PROBE)
729 t->nout_probes++;
730 since = tsince_hr(f);
731 f->waited += since;
732 f->waited_total += since;
733 resend(d, f);
544 } 734 }
545 /* We've cleaned up the outstanding so take away his
546 * interfaces so he won't be used. We should remove him from
547 * the target array here, but cleaning up a target is
548 * involved. PUNT!
549 */
550 memset(ht->ifs, 0, sizeof ht->ifs);
551 d->htgt = NULL;
552 return 1;
553} 735}
554 736
555static inline unsigned char 737/* An aoetgt accumulates demerits quickly, and successful
556ata_scnt(unsigned char *packet) { 738 * probing redeems the aoetgt slowly.
557 struct aoe_hdr *h; 739 */
558 struct aoe_atahdr *ah; 740static void
741scorn(struct aoetgt *t)
742{
743 int n;
559 744
560 h = (struct aoe_hdr *) packet; 745 n = t->taint++;
561 ah = (struct aoe_atahdr *) (h+1); 746 t->taint += t->taint * 2;
562 return ah->scnt; 747 if (n > t->taint)
748 t->taint = n;
749 if (t->taint > MAX_TAINT)
750 t->taint = MAX_TAINT;
751}
752
753static int
754count_targets(struct aoedev *d, int *untainted)
755{
756 int i, good;
757
758 for (i = good = 0; i < d->ntargets && d->targets[i]; ++i)
759 if (d->targets[i]->taint == 0)
760 good++;
761
762 if (untainted)
763 *untainted = good;
764 return i;
563} 765}
564 766
565static void 767static void
566rexmit_timer(ulong vp) 768rexmit_timer(ulong vp)
567{ 769{
568 struct aoedev *d; 770 struct aoedev *d;
569 struct aoetgt *t, **tt, **te; 771 struct aoetgt *t;
570 struct aoeif *ifp; 772 struct aoeif *ifp;
571 struct frame *f; 773 struct frame *f;
572 struct list_head *head, *pos, *nx; 774 struct list_head *head, *pos, *nx;
@@ -574,15 +776,18 @@ rexmit_timer(ulong vp)
574 register long timeout; 776 register long timeout;
575 ulong flags, n; 777 ulong flags, n;
576 int i; 778 int i;
779 int utgts; /* number of aoetgt descriptors (not slots) */
780 int since;
577 781
578 d = (struct aoedev *) vp; 782 d = (struct aoedev *) vp;
579 783
580 /* timeout is always ~150% of the moving average */
581 timeout = d->rttavg;
582 timeout += timeout >> 1;
583
584 spin_lock_irqsave(&d->lock, flags); 784 spin_lock_irqsave(&d->lock, flags);
585 785
786 /* timeout based on observed timings and variations */
787 timeout = rto(d);
788
789 utgts = count_targets(d, NULL);
790
586 if (d->flags & DEVFL_TKILL) { 791 if (d->flags & DEVFL_TKILL) {
587 spin_unlock_irqrestore(&d->lock, flags); 792 spin_unlock_irqrestore(&d->lock, flags);
588 return; 793 return;
@@ -593,67 +798,61 @@ rexmit_timer(ulong vp)
593 head = &d->factive[i]; 798 head = &d->factive[i];
594 list_for_each_safe(pos, nx, head) { 799 list_for_each_safe(pos, nx, head) {
595 f = list_entry(pos, struct frame, head); 800 f = list_entry(pos, struct frame, head);
596 if (tsince(f->tag) < timeout) 801 if (tsince_hr(f) < timeout)
597 break; /* end of expired frames */ 802 break; /* end of expired frames */
598 /* move to flist for later processing */ 803 /* move to flist for later processing */
599 list_move_tail(pos, &flist); 804 list_move_tail(pos, &flist);
600 } 805 }
601 } 806 }
602 /* window check */
603 tt = d->targets;
604 te = tt + d->ntargets;
605 for (; tt < te && (t = *tt); tt++) {
606 if (t->nout == t->maxout
607 && t->maxout < t->nframes
608 && (jiffies - t->lastwadj)/HZ > 10) {
609 t->maxout++;
610 t->lastwadj = jiffies;
611 }
612 }
613
614 if (!list_empty(&flist)) { /* retransmissions necessary */
615 n = d->rttavg <<= 1;
616 if (n > MAXTIMER)
617 d->rttavg = MAXTIMER;
618 }
619 807
620 /* process expired frames */ 808 /* process expired frames */
621 while (!list_empty(&flist)) { 809 while (!list_empty(&flist)) {
622 pos = flist.next; 810 pos = flist.next;
623 f = list_entry(pos, struct frame, head); 811 f = list_entry(pos, struct frame, head);
624 n = f->waited += timeout; 812 since = tsince_hr(f);
625 n /= HZ; 813 n = f->waited_total + since;
626 if (n > aoe_deadsecs) { 814 n /= USEC_PER_SEC;
815 if (aoe_deadsecs
816 && n > aoe_deadsecs
817 && !(f->flags & FFL_PROBE)) {
627 /* Waited too long. Device failure. 818 /* Waited too long. Device failure.
628 * Hang all frames on first hash bucket for downdev 819 * Hang all frames on first hash bucket for downdev
629 * to clean up. 820 * to clean up.
630 */ 821 */
631 list_splice(&flist, &d->factive[0]); 822 list_splice(&flist, &d->factive[0]);
632 aoedev_downdev(d); 823 aoedev_downdev(d);
633 break; 824 goto out;
634 } 825 }
635 list_del(pos);
636 826
637 t = f->t; 827 t = f->t;
638 if (n > aoe_deadsecs/2) 828 n = f->waited + since;
639 d->htgt = t; /* see if another target can help */ 829 n /= USEC_PER_SEC;
640 830 if (aoe_deadsecs && utgts > 0
641 if (t->nout == t->maxout) { 831 && (n > aoe_deadsecs / utgts || n > HARD_SCORN_SECS))
642 if (t->maxout > 1) 832 scorn(t); /* avoid this target */
643 t->maxout--; 833
644 t->lastwadj = jiffies; 834 if (t->maxout != 1) {
835 t->ssthresh = t->maxout / 2;
836 t->maxout = 1;
645 } 837 }
646 838
647 ifp = getif(t, f->skb->dev); 839 if (f->flags & FFL_PROBE) {
648 if (ifp && ++ifp->lost > (t->nframes << 1) 840 t->nout_probes--;
649 && (ifp != t->ifs || t->ifs[1].nd)) { 841 } else {
650 ejectif(t, ifp); 842 ifp = getif(t, f->skb->dev);
651 ifp = NULL; 843 if (ifp && ++ifp->lost > (t->nframes << 1)
844 && (ifp != t->ifs || t->ifs[1].nd)) {
845 ejectif(t, ifp);
846 ifp = NULL;
847 }
652 } 848 }
653 resend(d, f); 849 list_move_tail(pos, &d->rexmitq);
850 t->nout--;
654 } 851 }
852 rexmit_deferred(d);
655 853
656 if ((d->flags & DEVFL_KICKME || d->htgt) && d->blkq) { 854out:
855 if ((d->flags & DEVFL_KICKME) && d->blkq) {
657 d->flags &= ~DEVFL_KICKME; 856 d->flags &= ~DEVFL_KICKME;
658 d->blkq->request_fn(d->blkq); 857 d->blkq->request_fn(d->blkq);
659 } 858 }
@@ -774,8 +973,7 @@ nextbuf(struct aoedev *d)
774void 973void
775aoecmd_work(struct aoedev *d) 974aoecmd_work(struct aoedev *d)
776{ 975{
777 if (d->htgt && !sthtith(d)) 976 rexmit_deferred(d);
778 return;
779 while (aoecmd_ata_rw(d)) 977 while (aoecmd_ata_rw(d))
780 ; 978 ;
781} 979}
@@ -809,6 +1007,17 @@ aoecmd_sleepwork(struct work_struct *work)
809} 1007}
810 1008
811static void 1009static void
1010ata_ident_fixstring(u16 *id, int ns)
1011{
1012 u16 s;
1013
1014 while (ns-- > 0) {
1015 s = *id;
1016 *id++ = s >> 8 | s << 8;
1017 }
1018}
1019
1020static void
812ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id) 1021ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id)
813{ 1022{
814 u64 ssize; 1023 u64 ssize;
@@ -843,6 +1052,11 @@ ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id)
843 d->geo.sectors = get_unaligned_le16(&id[56 << 1]); 1052 d->geo.sectors = get_unaligned_le16(&id[56 << 1]);
844 } 1053 }
845 1054
1055 ata_ident_fixstring((u16 *) &id[10<<1], 10); /* serial */
1056 ata_ident_fixstring((u16 *) &id[23<<1], 4); /* firmware */
1057 ata_ident_fixstring((u16 *) &id[27<<1], 20); /* model */
1058 memcpy(d->ident, id, sizeof(d->ident));
1059
846 if (d->ssize != ssize) 1060 if (d->ssize != ssize)
847 printk(KERN_INFO 1061 printk(KERN_INFO
848 "aoe: %pm e%ld.%d v%04x has %llu sectors\n", 1062 "aoe: %pm e%ld.%d v%04x has %llu sectors\n",
@@ -862,26 +1076,28 @@ ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id)
862} 1076}
863 1077
864static void 1078static void
865calc_rttavg(struct aoedev *d, int rtt) 1079calc_rttavg(struct aoedev *d, struct aoetgt *t, int rtt)
866{ 1080{
867 register long n; 1081 register long n;
868 1082
869 n = rtt; 1083 n = rtt;
870 if (n < 0) { 1084
871 n = -rtt; 1085 /* cf. Congestion Avoidance and Control, Jacobson & Karels, 1988 */
872 if (n < MINTIMER) 1086 n -= d->rttavg >> RTTSCALE;
873 n = MINTIMER; 1087 d->rttavg += n;
874 else if (n > MAXTIMER) 1088 if (n < 0)
875 n = MAXTIMER; 1089 n = -n;
876 d->mintimer += (n - d->mintimer) >> 1; 1090 n -= d->rttdev >> RTTDSCALE;
877 } else if (n < d->mintimer) 1091 d->rttdev += n;
878 n = d->mintimer; 1092
879 else if (n > MAXTIMER) 1093 if (!t || t->maxout >= t->nframes)
880 n = MAXTIMER; 1094 return;
881 1095 if (t->maxout < t->ssthresh)
882 /* g == .25; cf. Congestion Avoidance and Control, Jacobson & Karels; 1988 */ 1096 t->maxout += 1;
883 n -= d->rttavg; 1097 else if (t->nout == t->maxout && t->next_cwnd-- == 0) {
884 d->rttavg += n >> 2; 1098 t->maxout += 1;
1099 t->next_cwnd = t->maxout;
1100 }
885} 1101}
886 1102
887static struct aoetgt * 1103static struct aoetgt *
@@ -890,7 +1106,7 @@ gettgt(struct aoedev *d, char *addr)
890 struct aoetgt **t, **e; 1106 struct aoetgt **t, **e;
891 1107
892 t = d->targets; 1108 t = d->targets;
893 e = t + NTARGETS; 1109 e = t + d->ntargets;
894 for (; t < e && *t; t++) 1110 for (; t < e && *t; t++)
895 if (memcmp((*t)->addr, addr, sizeof((*t)->addr)) == 0) 1111 if (memcmp((*t)->addr, addr, sizeof((*t)->addr)) == 0)
896 return *t; 1112 return *t;
@@ -966,19 +1182,22 @@ ktiocomplete(struct frame *f)
966 struct aoeif *ifp; 1182 struct aoeif *ifp;
967 struct aoedev *d; 1183 struct aoedev *d;
968 long n; 1184 long n;
1185 int untainted;
969 1186
970 if (f == NULL) 1187 if (f == NULL)
971 return; 1188 return;
972 1189
973 t = f->t; 1190 t = f->t;
974 d = t->d; 1191 d = t->d;
1192 skb = f->r_skb;
1193 buf = f->buf;
1194 if (f->flags & FFL_PROBE)
1195 goto out;
1196 if (!skb) /* just fail the buf. */
1197 goto noskb;
975 1198
976 hout = (struct aoe_hdr *) skb_mac_header(f->skb); 1199 hout = (struct aoe_hdr *) skb_mac_header(f->skb);
977 ahout = (struct aoe_atahdr *) (hout+1); 1200 ahout = (struct aoe_atahdr *) (hout+1);
978 buf = f->buf;
979 skb = f->r_skb;
980 if (skb == NULL)
981 goto noskb; /* just fail the buf. */
982 1201
983 hin = (struct aoe_hdr *) skb->data; 1202 hin = (struct aoe_hdr *) skb->data;
984 skb_pull(skb, sizeof(*hin)); 1203 skb_pull(skb, sizeof(*hin));
@@ -988,9 +1207,9 @@ ktiocomplete(struct frame *f)
988 pr_err("aoe: ata error cmd=%2.2Xh stat=%2.2Xh from e%ld.%d\n", 1207 pr_err("aoe: ata error cmd=%2.2Xh stat=%2.2Xh from e%ld.%d\n",
989 ahout->cmdstat, ahin->cmdstat, 1208 ahout->cmdstat, ahin->cmdstat,
990 d->aoemajor, d->aoeminor); 1209 d->aoemajor, d->aoeminor);
991noskb: if (buf) 1210noskb: if (buf)
992 clear_bit(BIO_UPTODATE, &buf->bio->bi_flags); 1211 clear_bit(BIO_UPTODATE, &buf->bio->bi_flags);
993 goto badrsp; 1212 goto out;
994 } 1213 }
995 1214
996 n = ahout->scnt << 9; 1215 n = ahout->scnt << 9;
@@ -998,8 +1217,10 @@ noskb: if (buf)
998 case ATA_CMD_PIO_READ: 1217 case ATA_CMD_PIO_READ:
999 case ATA_CMD_PIO_READ_EXT: 1218 case ATA_CMD_PIO_READ_EXT:
1000 if (skb->len < n) { 1219 if (skb->len < n) {
1001 pr_err("aoe: runt data size in read. skb->len=%d need=%ld\n", 1220 pr_err("%s e%ld.%d. skb->len=%d need=%ld\n",
1002 skb->len, n); 1221 "aoe: runt data size in read from",
1222 (long) d->aoemajor, d->aoeminor,
1223 skb->len, n);
1003 clear_bit(BIO_UPTODATE, &buf->bio->bi_flags); 1224 clear_bit(BIO_UPTODATE, &buf->bio->bi_flags);
1004 break; 1225 break;
1005 } 1226 }
@@ -1010,13 +1231,13 @@ noskb: if (buf)
1010 ifp = getif(t, skb->dev); 1231 ifp = getif(t, skb->dev);
1011 if (ifp) 1232 if (ifp)
1012 ifp->lost = 0; 1233 ifp->lost = 0;
1013 if (d->htgt == t) /* I'll help myself, thank you. */
1014 d->htgt = NULL;
1015 spin_unlock_irq(&d->lock); 1234 spin_unlock_irq(&d->lock);
1016 break; 1235 break;
1017 case ATA_CMD_ID_ATA: 1236 case ATA_CMD_ID_ATA:
1018 if (skb->len < 512) { 1237 if (skb->len < 512) {
1019 pr_info("aoe: runt data size in ataid. skb->len=%d\n", 1238 pr_info("%s e%ld.%d. skb->len=%d need=512\n",
1239 "aoe: runt data size in ataid from",
1240 (long) d->aoemajor, d->aoeminor,
1020 skb->len); 1241 skb->len);
1021 break; 1242 break;
1022 } 1243 }
@@ -1032,16 +1253,23 @@ noskb: if (buf)
1032 be16_to_cpu(get_unaligned(&hin->major)), 1253 be16_to_cpu(get_unaligned(&hin->major)),
1033 hin->minor); 1254 hin->minor);
1034 } 1255 }
1035badrsp: 1256out:
1036 spin_lock_irq(&d->lock); 1257 spin_lock_irq(&d->lock);
1258 if (t->taint > 0
1259 && --t->taint > 0
1260 && t->nout_probes == 0) {
1261 count_targets(d, &untainted);
1262 if (untainted > 0) {
1263 probe(t);
1264 t->nout_probes++;
1265 }
1266 }
1037 1267
1038 aoe_freetframe(f); 1268 aoe_freetframe(f);
1039 1269
1040 if (buf && --buf->nframesout == 0 && buf->resid == 0) 1270 if (buf && --buf->nframesout == 0 && buf->resid == 0)
1041 aoe_end_buf(d, buf); 1271 aoe_end_buf(d, buf);
1042 1272
1043 aoecmd_work(d);
1044
1045 spin_unlock_irq(&d->lock); 1273 spin_unlock_irq(&d->lock);
1046 aoedev_put(d); 1274 aoedev_put(d);
1047 dev_kfree_skb(skb); 1275 dev_kfree_skb(skb);
@@ -1141,7 +1369,6 @@ aoecmd_ata_rsp(struct sk_buff *skb)
1141 struct aoedev *d; 1369 struct aoedev *d;
1142 struct aoe_hdr *h; 1370 struct aoe_hdr *h;
1143 struct frame *f; 1371 struct frame *f;
1144 struct aoetgt *t;
1145 u32 n; 1372 u32 n;
1146 ulong flags; 1373 ulong flags;
1147 char ebuf[128]; 1374 char ebuf[128];
@@ -1162,23 +1389,32 @@ aoecmd_ata_rsp(struct sk_buff *skb)
1162 1389
1163 n = be32_to_cpu(get_unaligned(&h->tag)); 1390 n = be32_to_cpu(get_unaligned(&h->tag));
1164 f = getframe(d, n); 1391 f = getframe(d, n);
1165 if (f == NULL) { 1392 if (f) {
1166 calc_rttavg(d, -tsince(n)); 1393 calc_rttavg(d, f->t, tsince_hr(f));
1167 spin_unlock_irqrestore(&d->lock, flags); 1394 f->t->nout--;
1168 aoedev_put(d); 1395 if (f->flags & FFL_PROBE)
1169 snprintf(ebuf, sizeof ebuf, 1396 f->t->nout_probes--;
1170 "%15s e%d.%d tag=%08x@%08lx\n", 1397 } else {
1171 "unexpected rsp", 1398 f = getframe_deferred(d, n);
1172 get_unaligned_be16(&h->major), 1399 if (f) {
1173 h->minor, 1400 calc_rttavg(d, NULL, tsince_hr(f));
1174 get_unaligned_be32(&h->tag), 1401 } else {
1175 jiffies); 1402 calc_rttavg(d, NULL, tsince(n));
1176 aoechr_error(ebuf); 1403 spin_unlock_irqrestore(&d->lock, flags);
1177 return skb; 1404 aoedev_put(d);
1405 snprintf(ebuf, sizeof(ebuf),
1406 "%15s e%d.%d tag=%08x@%08lx s=%pm d=%pm\n",
1407 "unexpected rsp",
1408 get_unaligned_be16(&h->major),
1409 h->minor,
1410 get_unaligned_be32(&h->tag),
1411 jiffies,
1412 h->src,
1413 h->dst);
1414 aoechr_error(ebuf);
1415 return skb;
1416 }
1178 } 1417 }
1179 t = f->t;
1180 calc_rttavg(d, tsince(f->tag));
1181 t->nout--;
1182 aoecmd_work(d); 1418 aoecmd_work(d);
1183 1419
1184 spin_unlock_irqrestore(&d->lock, flags); 1420 spin_unlock_irqrestore(&d->lock, flags);
@@ -1201,7 +1437,7 @@ aoecmd_cfg(ushort aoemajor, unsigned char aoeminor)
1201 aoecmd_cfg_pkts(aoemajor, aoeminor, &queue); 1437 aoecmd_cfg_pkts(aoemajor, aoeminor, &queue);
1202 aoenet_xmit(&queue); 1438 aoenet_xmit(&queue);
1203} 1439}
1204 1440
1205struct sk_buff * 1441struct sk_buff *
1206aoecmd_ata_id(struct aoedev *d) 1442aoecmd_ata_id(struct aoedev *d)
1207{ 1443{
@@ -1227,6 +1463,7 @@ aoecmd_ata_id(struct aoedev *d)
1227 fhash(f); 1463 fhash(f);
1228 t->nout++; 1464 t->nout++;
1229 f->waited = 0; 1465 f->waited = 0;
1466 f->waited_total = 0;
1230 1467
1231 /* set up ata header */ 1468 /* set up ata header */
1232 ah->scnt = 1; 1469 ah->scnt = 1;
@@ -1235,41 +1472,69 @@ aoecmd_ata_id(struct aoedev *d)
1235 1472
1236 skb->dev = t->ifp->nd; 1473 skb->dev = t->ifp->nd;
1237 1474
1238 d->rttavg = MAXTIMER; 1475 d->rttavg = RTTAVG_INIT;
1476 d->rttdev = RTTDEV_INIT;
1239 d->timer.function = rexmit_timer; 1477 d->timer.function = rexmit_timer;
1240 1478
1241 return skb_clone(skb, GFP_ATOMIC); 1479 skb = skb_clone(skb, GFP_ATOMIC);
1480 if (skb) {
1481 do_gettimeofday(&f->sent);
1482 f->sent_jiffs = (u32) jiffies;
1483 }
1484
1485 return skb;
1242} 1486}
1243 1487
1488static struct aoetgt **
1489grow_targets(struct aoedev *d)
1490{
1491 ulong oldn, newn;
1492 struct aoetgt **tt;
1493
1494 oldn = d->ntargets;
1495 newn = oldn * 2;
1496 tt = kcalloc(newn, sizeof(*d->targets), GFP_ATOMIC);
1497 if (!tt)
1498 return NULL;
1499 memmove(tt, d->targets, sizeof(*d->targets) * oldn);
1500 d->tgt = tt + (d->tgt - d->targets);
1501 kfree(d->targets);
1502 d->targets = tt;
1503 d->ntargets = newn;
1504
1505 return &d->targets[oldn];
1506}
1507
1244static struct aoetgt * 1508static struct aoetgt *
1245addtgt(struct aoedev *d, char *addr, ulong nframes) 1509addtgt(struct aoedev *d, char *addr, ulong nframes)
1246{ 1510{
1247 struct aoetgt *t, **tt, **te; 1511 struct aoetgt *t, **tt, **te;
1248 1512
1249 tt = d->targets; 1513 tt = d->targets;
1250 te = tt + NTARGETS; 1514 te = tt + d->ntargets;
1251 for (; tt < te && *tt; tt++) 1515 for (; tt < te && *tt; tt++)
1252 ; 1516 ;
1253 1517
1254 if (tt == te) { 1518 if (tt == te) {
1255 printk(KERN_INFO 1519 tt = grow_targets(d);
1256 "aoe: device addtgt failure; too many targets\n"); 1520 if (!tt)
1257 return NULL; 1521 goto nomem;
1258 } 1522 }
1259 t = kzalloc(sizeof(*t), GFP_ATOMIC); 1523 t = kzalloc(sizeof(*t), GFP_ATOMIC);
1260 if (!t) { 1524 if (!t)
1261 printk(KERN_INFO "aoe: cannot allocate memory to add target\n"); 1525 goto nomem;
1262 return NULL;
1263 }
1264
1265 d->ntargets++;
1266 t->nframes = nframes; 1526 t->nframes = nframes;
1267 t->d = d; 1527 t->d = d;
1268 memcpy(t->addr, addr, sizeof t->addr); 1528 memcpy(t->addr, addr, sizeof t->addr);
1269 t->ifp = t->ifs; 1529 t->ifp = t->ifs;
1270 t->maxout = t->nframes; 1530 aoecmd_wreset(t);
1531 t->maxout = t->nframes / 2;
1271 INIT_LIST_HEAD(&t->ffree); 1532 INIT_LIST_HEAD(&t->ffree);
1272 return *tt = t; 1533 return *tt = t;
1534
1535 nomem:
1536 pr_info("aoe: cannot allocate memory to add target\n");
1537 return NULL;
1273} 1538}
1274 1539
1275static void 1540static void
@@ -1279,7 +1544,7 @@ setdbcnt(struct aoedev *d)
1279 int bcnt = 0; 1544 int bcnt = 0;
1280 1545
1281 t = d->targets; 1546 t = d->targets;
1282 e = t + NTARGETS; 1547 e = t + d->ntargets;
1283 for (; t < e && *t; t++) 1548 for (; t < e && *t; t++)
1284 if (bcnt == 0 || bcnt > (*t)->minbcnt) 1549 if (bcnt == 0 || bcnt > (*t)->minbcnt)
1285 bcnt = (*t)->minbcnt; 1550 bcnt = (*t)->minbcnt;
@@ -1373,7 +1638,11 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
1373 spin_lock_irqsave(&d->lock, flags); 1638 spin_lock_irqsave(&d->lock, flags);
1374 1639
1375 t = gettgt(d, h->src); 1640 t = gettgt(d, h->src);
1376 if (!t) { 1641 if (t) {
1642 t->nframes = n;
1643 if (n < t->maxout)
1644 aoecmd_wreset(t);
1645 } else {
1377 t = addtgt(d, h->src, n); 1646 t = addtgt(d, h->src, n);
1378 if (!t) 1647 if (!t)
1379 goto bail; 1648 goto bail;
@@ -1402,17 +1671,26 @@ bail:
1402} 1671}
1403 1672
1404void 1673void
1674aoecmd_wreset(struct aoetgt *t)
1675{
1676 t->maxout = 1;
1677 t->ssthresh = t->nframes / 2;
1678 t->next_cwnd = t->nframes;
1679}
1680
1681void
1405aoecmd_cleanslate(struct aoedev *d) 1682aoecmd_cleanslate(struct aoedev *d)
1406{ 1683{
1407 struct aoetgt **t, **te; 1684 struct aoetgt **t, **te;
1408 1685
1409 d->mintimer = MINTIMER; 1686 d->rttavg = RTTAVG_INIT;
1687 d->rttdev = RTTDEV_INIT;
1410 d->maxbcnt = 0; 1688 d->maxbcnt = 0;
1411 1689
1412 t = d->targets; 1690 t = d->targets;
1413 te = t + NTARGETS; 1691 te = t + d->ntargets;
1414 for (; t < te && *t; t++) 1692 for (; t < te && *t; t++)
1415 (*t)->maxout = (*t)->nframes; 1693 aoecmd_wreset(*t);
1416} 1694}
1417 1695
1418void 1696void
@@ -1460,6 +1738,14 @@ aoe_flush_iocq(void)
1460int __init 1738int __init
1461aoecmd_init(void) 1739aoecmd_init(void)
1462{ 1740{
1741 void *p;
1742
1743 /* get_zeroed_page returns page with ref count 1 */
1744 p = (void *) get_zeroed_page(GFP_KERNEL | __GFP_REPEAT);
1745 if (!p)
1746 return -ENOMEM;
1747 empty_page = virt_to_page(p);
1748
1463 INIT_LIST_HEAD(&iocq.head); 1749 INIT_LIST_HEAD(&iocq.head);
1464 spin_lock_init(&iocq.lock); 1750 spin_lock_init(&iocq.lock);
1465 init_waitqueue_head(&ktiowq); 1751 init_waitqueue_head(&ktiowq);
@@ -1475,4 +1761,7 @@ aoecmd_exit(void)
1475{ 1761{
1476 aoe_ktstop(&kts); 1762 aoe_ktstop(&kts);
1477 aoe_flush_iocq(); 1763 aoe_flush_iocq();
1764
1765 free_page((unsigned long) page_address(empty_page));
1766 empty_page = NULL;
1478} 1767}
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index 90e5b537f94b..98f2965778b9 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -15,7 +15,6 @@
15#include "aoe.h" 15#include "aoe.h"
16 16
17static void dummy_timer(ulong); 17static void dummy_timer(ulong);
18static void aoedev_freedev(struct aoedev *);
19static void freetgt(struct aoedev *d, struct aoetgt *t); 18static void freetgt(struct aoedev *d, struct aoetgt *t);
20static void skbpoolfree(struct aoedev *d); 19static void skbpoolfree(struct aoedev *d);
21 20
@@ -69,25 +68,34 @@ minor_get_static(ulong *sysminor, ulong aoemaj, int aoemin)
69 NPERSHELF = 16, 68 NPERSHELF = 16,
70 }; 69 };
71 70
71 if (aoemin >= NPERSHELF) {
72 pr_err("aoe: %s %d slots per shelf\n",
73 "static minor device numbers support only",
74 NPERSHELF);
75 error = -1;
76 goto out;
77 }
78
72 n = aoemaj * NPERSHELF + aoemin; 79 n = aoemaj * NPERSHELF + aoemin;
73 if (aoemin >= NPERSHELF || n >= N_DEVS) { 80 if (n >= N_DEVS) {
74 pr_err("aoe: %s with e%ld.%d\n", 81 pr_err("aoe: %s with e%ld.%d\n",
75 "cannot use static minor device numbers", 82 "cannot use static minor device numbers",
76 aoemaj, aoemin); 83 aoemaj, aoemin);
77 error = -1; 84 error = -1;
78 } else { 85 goto out;
79 spin_lock_irqsave(&used_minors_lock, flags);
80 if (test_bit(n, used_minors)) {
81 pr_err("aoe: %s %lu\n",
82 "existing device already has static minor number",
83 n);
84 error = -1;
85 } else
86 set_bit(n, used_minors);
87 spin_unlock_irqrestore(&used_minors_lock, flags);
88 } 86 }
89 87
90 *sysminor = n; 88 spin_lock_irqsave(&used_minors_lock, flags);
89 if (test_bit(n, used_minors)) {
90 pr_err("aoe: %s %lu\n",
91 "existing device already has static minor number",
92 n);
93 error = -1;
94 } else
95 set_bit(n, used_minors);
96 spin_unlock_irqrestore(&used_minors_lock, flags);
97 *sysminor = n * AOE_PARTITIONS;
98out:
91 return error; 99 return error;
92} 100}
93 101
@@ -170,41 +178,50 @@ aoe_failip(struct aoedev *d)
170 aoe_end_request(d, rq, 0); 178 aoe_end_request(d, rq, 0);
171} 179}
172 180
181static void
182downdev_frame(struct list_head *pos)
183{
184 struct frame *f;
185
186 f = list_entry(pos, struct frame, head);
187 list_del(pos);
188 if (f->buf) {
189 f->buf->nframesout--;
190 aoe_failbuf(f->t->d, f->buf);
191 }
192 aoe_freetframe(f);
193}
194
173void 195void
174aoedev_downdev(struct aoedev *d) 196aoedev_downdev(struct aoedev *d)
175{ 197{
176 struct aoetgt *t, **tt, **te; 198 struct aoetgt *t, **tt, **te;
177 struct frame *f;
178 struct list_head *head, *pos, *nx; 199 struct list_head *head, *pos, *nx;
179 struct request *rq; 200 struct request *rq;
180 int i; 201 int i;
181 202
182 d->flags &= ~DEVFL_UP; 203 d->flags &= ~DEVFL_UP;
183 204
184 /* clean out active buffers */ 205 /* clean out active and to-be-retransmitted buffers */
185 for (i = 0; i < NFACTIVE; i++) { 206 for (i = 0; i < NFACTIVE; i++) {
186 head = &d->factive[i]; 207 head = &d->factive[i];
187 list_for_each_safe(pos, nx, head) { 208 list_for_each_safe(pos, nx, head)
188 f = list_entry(pos, struct frame, head); 209 downdev_frame(pos);
189 list_del(pos);
190 if (f->buf) {
191 f->buf->nframesout--;
192 aoe_failbuf(d, f->buf);
193 }
194 aoe_freetframe(f);
195 }
196 } 210 }
211 head = &d->rexmitq;
212 list_for_each_safe(pos, nx, head)
213 downdev_frame(pos);
214
197 /* reset window dressings */ 215 /* reset window dressings */
198 tt = d->targets; 216 tt = d->targets;
199 te = tt + NTARGETS; 217 te = tt + d->ntargets;
200 for (; tt < te && (t = *tt); tt++) { 218 for (; tt < te && (t = *tt); tt++) {
201 t->maxout = t->nframes; 219 aoecmd_wreset(t);
202 t->nout = 0; 220 t->nout = 0;
203 } 221 }
204 222
205 /* clean out the in-process request (if any) */ 223 /* clean out the in-process request (if any) */
206 aoe_failip(d); 224 aoe_failip(d);
207 d->htgt = NULL;
208 225
209 /* fast fail all pending I/O */ 226 /* fast fail all pending I/O */
210 if (d->blkq) { 227 if (d->blkq) {
@@ -218,12 +235,48 @@ aoedev_downdev(struct aoedev *d)
218 set_capacity(d->gd, 0); 235 set_capacity(d->gd, 0);
219} 236}
220 237
238/* return whether the user asked for this particular
239 * device to be flushed
240 */
241static int
242user_req(char *s, size_t slen, struct aoedev *d)
243{
244 char *p;
245 size_t lim;
246
247 if (!d->gd)
248 return 0;
249 p = strrchr(d->gd->disk_name, '/');
250 if (!p)
251 p = d->gd->disk_name;
252 else
253 p += 1;
254 lim = sizeof(d->gd->disk_name);
255 lim -= p - d->gd->disk_name;
256 if (slen < lim)
257 lim = slen;
258
259 return !strncmp(s, p, lim);
260}
261
221static void 262static void
222aoedev_freedev(struct aoedev *d) 263freedev(struct aoedev *d)
223{ 264{
224 struct aoetgt **t, **e; 265 struct aoetgt **t, **e;
266 int freeing = 0;
267 unsigned long flags;
268
269 spin_lock_irqsave(&d->lock, flags);
270 if (d->flags & DEVFL_TKILL
271 && !(d->flags & DEVFL_FREEING)) {
272 d->flags |= DEVFL_FREEING;
273 freeing = 1;
274 }
275 spin_unlock_irqrestore(&d->lock, flags);
276 if (!freeing)
277 return;
225 278
226 cancel_work_sync(&d->work); 279 del_timer_sync(&d->timer);
227 if (d->gd) { 280 if (d->gd) {
228 aoedisk_rm_sysfs(d); 281 aoedisk_rm_sysfs(d);
229 del_gendisk(d->gd); 282 del_gendisk(d->gd);
@@ -231,61 +284,113 @@ aoedev_freedev(struct aoedev *d)
231 blk_cleanup_queue(d->blkq); 284 blk_cleanup_queue(d->blkq);
232 } 285 }
233 t = d->targets; 286 t = d->targets;
234 e = t + NTARGETS; 287 e = t + d->ntargets;
235 for (; t < e && *t; t++) 288 for (; t < e && *t; t++)
236 freetgt(d, *t); 289 freetgt(d, *t);
237 if (d->bufpool) 290 if (d->bufpool)
238 mempool_destroy(d->bufpool); 291 mempool_destroy(d->bufpool);
239 skbpoolfree(d); 292 skbpoolfree(d);
240 minor_free(d->sysminor); 293 minor_free(d->sysminor);
241 kfree(d); 294
295 spin_lock_irqsave(&d->lock, flags);
296 d->flags |= DEVFL_FREED;
297 spin_unlock_irqrestore(&d->lock, flags);
242} 298}
243 299
244int 300enum flush_parms {
245aoedev_flush(const char __user *str, size_t cnt) 301 NOT_EXITING = 0,
302 EXITING = 1,
303};
304
305static int
306flush(const char __user *str, size_t cnt, int exiting)
246{ 307{
247 ulong flags; 308 ulong flags;
248 struct aoedev *d, **dd; 309 struct aoedev *d, **dd;
249 struct aoedev *rmd = NULL;
250 char buf[16]; 310 char buf[16];
251 int all = 0; 311 int all = 0;
312 int specified = 0; /* flush a specific device */
313 unsigned int skipflags;
314
315 skipflags = DEVFL_GDALLOC | DEVFL_NEWSIZE | DEVFL_TKILL;
252 316
253 if (cnt >= 3) { 317 if (!exiting && cnt >= 3) {
254 if (cnt > sizeof buf) 318 if (cnt > sizeof buf)
255 cnt = sizeof buf; 319 cnt = sizeof buf;
256 if (copy_from_user(buf, str, cnt)) 320 if (copy_from_user(buf, str, cnt))
257 return -EFAULT; 321 return -EFAULT;
258 all = !strncmp(buf, "all", 3); 322 all = !strncmp(buf, "all", 3);
323 if (!all)
324 specified = 1;
259 } 325 }
260 326
327 flush_scheduled_work();
328 /* pass one: without sleeping, do aoedev_downdev */
261 spin_lock_irqsave(&devlist_lock, flags); 329 spin_lock_irqsave(&devlist_lock, flags);
262 dd = &devlist; 330 for (d = devlist; d; d = d->next) {
263 while ((d = *dd)) {
264 spin_lock(&d->lock); 331 spin_lock(&d->lock);
265 if ((!all && (d->flags & DEVFL_UP)) 332 if (exiting) {
266 || (d->flags & (DEVFL_GDALLOC|DEVFL_NEWSIZE)) 333 /* unconditionally take each device down */
334 } else if (specified) {
335 if (!user_req(buf, cnt, d))
336 goto cont;
337 } else if ((!all && (d->flags & DEVFL_UP))
338 || d->flags & skipflags
267 || d->nopen 339 || d->nopen
268 || d->ref) { 340 || d->ref)
269 spin_unlock(&d->lock); 341 goto cont;
270 dd = &d->next; 342
271 continue;
272 }
273 *dd = d->next;
274 aoedev_downdev(d); 343 aoedev_downdev(d);
275 d->flags |= DEVFL_TKILL; 344 d->flags |= DEVFL_TKILL;
345cont:
276 spin_unlock(&d->lock); 346 spin_unlock(&d->lock);
277 d->next = rmd;
278 rmd = d;
279 } 347 }
280 spin_unlock_irqrestore(&devlist_lock, flags); 348 spin_unlock_irqrestore(&devlist_lock, flags);
281 while ((d = rmd)) { 349
282 rmd = d->next; 350 /* pass two: call freedev, which might sleep,
283 del_timer_sync(&d->timer); 351 * for aoedevs marked with DEVFL_TKILL
284 aoedev_freedev(d); /* must be able to sleep */ 352 */
353restart:
354 spin_lock_irqsave(&devlist_lock, flags);
355 for (d = devlist; d; d = d->next) {
356 spin_lock(&d->lock);
357 if (d->flags & DEVFL_TKILL
358 && !(d->flags & DEVFL_FREEING)) {
359 spin_unlock(&d->lock);
360 spin_unlock_irqrestore(&devlist_lock, flags);
361 freedev(d);
362 goto restart;
363 }
364 spin_unlock(&d->lock);
285 } 365 }
366
367 /* pass three: remove aoedevs marked with DEVFL_FREED */
368 for (dd = &devlist, d = *dd; d; d = *dd) {
369 struct aoedev *doomed = NULL;
370
371 spin_lock(&d->lock);
372 if (d->flags & DEVFL_FREED) {
373 *dd = d->next;
374 doomed = d;
375 } else {
376 dd = &d->next;
377 }
378 spin_unlock(&d->lock);
379 if (doomed)
380 kfree(doomed->targets);
381 kfree(doomed);
382 }
383 spin_unlock_irqrestore(&devlist_lock, flags);
384
286 return 0; 385 return 0;
287} 386}
288 387
388int
389aoedev_flush(const char __user *str, size_t cnt)
390{
391 return flush(str, cnt, NOT_EXITING);
392}
393
289/* This has been confirmed to occur once with Tms=3*1000 due to the 394/* This has been confirmed to occur once with Tms=3*1000 due to the
290 * driver changing link and not processing its transmit ring. The 395 * driver changing link and not processing its transmit ring. The
291 * problem is hard enough to solve by returning an error that I'm 396 * problem is hard enough to solve by returning an error that I'm
@@ -332,13 +437,20 @@ aoedev_by_aoeaddr(ulong maj, int min, int do_alloc)
332 struct aoedev *d; 437 struct aoedev *d;
333 int i; 438 int i;
334 ulong flags; 439 ulong flags;
335 ulong sysminor; 440 ulong sysminor = 0;
336 441
337 spin_lock_irqsave(&devlist_lock, flags); 442 spin_lock_irqsave(&devlist_lock, flags);
338 443
339 for (d=devlist; d; d=d->next) 444 for (d=devlist; d; d=d->next)
340 if (d->aoemajor == maj && d->aoeminor == min) { 445 if (d->aoemajor == maj && d->aoeminor == min) {
446 spin_lock(&d->lock);
447 if (d->flags & DEVFL_TKILL) {
448 spin_unlock(&d->lock);
449 d = NULL;
450 goto out;
451 }
341 d->ref++; 452 d->ref++;
453 spin_unlock(&d->lock);
342 break; 454 break;
343 } 455 }
344 if (d || !do_alloc || minor_get(&sysminor, maj, min) < 0) 456 if (d || !do_alloc || minor_get(&sysminor, maj, min) < 0)
@@ -346,6 +458,13 @@ aoedev_by_aoeaddr(ulong maj, int min, int do_alloc)
346 d = kcalloc(1, sizeof *d, GFP_ATOMIC); 458 d = kcalloc(1, sizeof *d, GFP_ATOMIC);
347 if (!d) 459 if (!d)
348 goto out; 460 goto out;
461 d->targets = kcalloc(NTARGETS, sizeof(*d->targets), GFP_ATOMIC);
462 if (!d->targets) {
463 kfree(d);
464 d = NULL;
465 goto out;
466 }
467 d->ntargets = NTARGETS;
349 INIT_WORK(&d->work, aoecmd_sleepwork); 468 INIT_WORK(&d->work, aoecmd_sleepwork);
350 spin_lock_init(&d->lock); 469 spin_lock_init(&d->lock);
351 skb_queue_head_init(&d->skbpool); 470 skb_queue_head_init(&d->skbpool);
@@ -359,10 +478,12 @@ aoedev_by_aoeaddr(ulong maj, int min, int do_alloc)
359 d->ref = 1; 478 d->ref = 1;
360 for (i = 0; i < NFACTIVE; i++) 479 for (i = 0; i < NFACTIVE; i++)
361 INIT_LIST_HEAD(&d->factive[i]); 480 INIT_LIST_HEAD(&d->factive[i]);
481 INIT_LIST_HEAD(&d->rexmitq);
362 d->sysminor = sysminor; 482 d->sysminor = sysminor;
363 d->aoemajor = maj; 483 d->aoemajor = maj;
364 d->aoeminor = min; 484 d->aoeminor = min;
365 d->mintimer = MINTIMER; 485 d->rttavg = RTTAVG_INIT;
486 d->rttdev = RTTDEV_INIT;
366 d->next = devlist; 487 d->next = devlist;
367 devlist = d; 488 devlist = d;
368 out: 489 out:
@@ -396,21 +517,9 @@ freetgt(struct aoedev *d, struct aoetgt *t)
396void 517void
397aoedev_exit(void) 518aoedev_exit(void)
398{ 519{
399 struct aoedev *d; 520 flush_scheduled_work();
400 ulong flags;
401
402 aoe_flush_iocq(); 521 aoe_flush_iocq();
403 while ((d = devlist)) { 522 flush(NULL, 0, EXITING);
404 devlist = d->next;
405
406 spin_lock_irqsave(&d->lock, flags);
407 aoedev_downdev(d);
408 d->flags |= DEVFL_TKILL;
409 spin_unlock_irqrestore(&d->lock, flags);
410
411 del_timer_sync(&d->timer);
412 aoedev_freedev(d);
413 }
414} 523}
415 524
416int __init 525int __init
diff --git a/drivers/block/aoe/aoemain.c b/drivers/block/aoe/aoemain.c
index 04793c2c701b..4b987c2fefbe 100644
--- a/drivers/block/aoe/aoemain.c
+++ b/drivers/block/aoe/aoemain.c
@@ -105,7 +105,7 @@ aoe_init(void)
105 aoechr_exit(); 105 aoechr_exit();
106 chr_fail: 106 chr_fail:
107 aoedev_exit(); 107 aoedev_exit();
108 108
109 printk(KERN_INFO "aoe: initialisation failure.\n"); 109 printk(KERN_INFO "aoe: initialisation failure.\n");
110 return ret; 110 return ret;
111} 111}
diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c
index 162c6471275c..71d3ea8d3006 100644
--- a/drivers/block/aoe/aoenet.c
+++ b/drivers/block/aoe/aoenet.c
@@ -31,7 +31,7 @@ enum {
31 31
32static char aoe_iflist[IFLISTSZ]; 32static char aoe_iflist[IFLISTSZ];
33module_param_string(aoe_iflist, aoe_iflist, IFLISTSZ, 0600); 33module_param_string(aoe_iflist, aoe_iflist, IFLISTSZ, 0600);
34MODULE_PARM_DESC(aoe_iflist, "aoe_iflist=\"dev1 [dev2 ...]\""); 34MODULE_PARM_DESC(aoe_iflist, "aoe_iflist=dev1[,dev2...]");
35 35
36static wait_queue_head_t txwq; 36static wait_queue_head_t txwq;
37static struct ktstate kts; 37static struct ktstate kts;
@@ -52,13 +52,18 @@ static struct sk_buff_head skbtxq;
52 52
53/* enters with txlock held */ 53/* enters with txlock held */
54static int 54static int
55tx(void) 55tx(void) __must_hold(&txlock)
56{ 56{
57 struct sk_buff *skb; 57 struct sk_buff *skb;
58 struct net_device *ifp;
58 59
59 while ((skb = skb_dequeue(&skbtxq))) { 60 while ((skb = skb_dequeue(&skbtxq))) {
60 spin_unlock_irq(&txlock); 61 spin_unlock_irq(&txlock);
61 dev_queue_xmit(skb); 62 ifp = skb->dev;
63 if (dev_queue_xmit(skb) == NET_XMIT_DROP && net_ratelimit())
64 pr_warn("aoe: packet could not be sent on %s. %s\n",
65 ifp ? ifp->name : "netif",
66 "consider increasing tx_queue_len");
62 spin_lock_irq(&txlock); 67 spin_lock_irq(&txlock);
63 } 68 }
64 return 0; 69 return 0;
@@ -119,8 +124,8 @@ aoenet_xmit(struct sk_buff_head *queue)
119 } 124 }
120} 125}
121 126
122/* 127/*
123 * (1) len doesn't include the header by default. I want this. 128 * (1) len doesn't include the header by default. I want this.
124 */ 129 */
125static int 130static int
126aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt, struct net_device *orig_dev) 131aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt, struct net_device *orig_dev)
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 24225f0fdcd8..64b048d7fba7 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -228,6 +228,20 @@ static void dmatest_callback(void *arg)
228 wake_up_all(done->wait); 228 wake_up_all(done->wait);
229} 229}
230 230
231static inline void unmap_src(struct device *dev, dma_addr_t *addr, size_t len,
232 unsigned int count)
233{
234 while (count--)
235 dma_unmap_single(dev, addr[count], len, DMA_TO_DEVICE);
236}
237
238static inline void unmap_dst(struct device *dev, dma_addr_t *addr, size_t len,
239 unsigned int count)
240{
241 while (count--)
242 dma_unmap_single(dev, addr[count], len, DMA_BIDIRECTIONAL);
243}
244
231/* 245/*
232 * This function repeatedly tests DMA transfers of various lengths and 246 * This function repeatedly tests DMA transfers of various lengths and
233 * offsets for a given operation type until it is told to exit by 247 * offsets for a given operation type until it is told to exit by
@@ -353,15 +367,35 @@ static int dmatest_func(void *data)
353 367
354 dma_srcs[i] = dma_map_single(dev->dev, buf, len, 368 dma_srcs[i] = dma_map_single(dev->dev, buf, len,
355 DMA_TO_DEVICE); 369 DMA_TO_DEVICE);
370 ret = dma_mapping_error(dev->dev, dma_srcs[i]);
371 if (ret) {
372 unmap_src(dev->dev, dma_srcs, len, i);
373 pr_warn("%s: #%u: mapping error %d with "
374 "src_off=0x%x len=0x%x\n",
375 thread_name, total_tests - 1, ret,
376 src_off, len);
377 failed_tests++;
378 continue;
379 }
356 } 380 }
357 /* map with DMA_BIDIRECTIONAL to force writeback/invalidate */ 381 /* map with DMA_BIDIRECTIONAL to force writeback/invalidate */
358 for (i = 0; i < dst_cnt; i++) { 382 for (i = 0; i < dst_cnt; i++) {
359 dma_dsts[i] = dma_map_single(dev->dev, thread->dsts[i], 383 dma_dsts[i] = dma_map_single(dev->dev, thread->dsts[i],
360 test_buf_size, 384 test_buf_size,
361 DMA_BIDIRECTIONAL); 385 DMA_BIDIRECTIONAL);
386 ret = dma_mapping_error(dev->dev, dma_dsts[i]);
387 if (ret) {
388 unmap_src(dev->dev, dma_srcs, len, src_cnt);
389 unmap_dst(dev->dev, dma_dsts, test_buf_size, i);
390 pr_warn("%s: #%u: mapping error %d with "
391 "dst_off=0x%x len=0x%x\n",
392 thread_name, total_tests - 1, ret,
393 dst_off, test_buf_size);
394 failed_tests++;
395 continue;
396 }
362 } 397 }
363 398
364
365 if (thread->type == DMA_MEMCPY) 399 if (thread->type == DMA_MEMCPY)
366 tx = dev->device_prep_dma_memcpy(chan, 400 tx = dev->device_prep_dma_memcpy(chan,
367 dma_dsts[0] + dst_off, 401 dma_dsts[0] + dst_off,
@@ -383,13 +417,8 @@ static int dmatest_func(void *data)
383 } 417 }
384 418
385 if (!tx) { 419 if (!tx) {
386 for (i = 0; i < src_cnt; i++) 420 unmap_src(dev->dev, dma_srcs, len, src_cnt);
387 dma_unmap_single(dev->dev, dma_srcs[i], len, 421 unmap_dst(dev->dev, dma_dsts, test_buf_size, dst_cnt);
388 DMA_TO_DEVICE);
389 for (i = 0; i < dst_cnt; i++)
390 dma_unmap_single(dev->dev, dma_dsts[i],
391 test_buf_size,
392 DMA_BIDIRECTIONAL);
393 pr_warning("%s: #%u: prep error with src_off=0x%x " 422 pr_warning("%s: #%u: prep error with src_off=0x%x "
394 "dst_off=0x%x len=0x%x\n", 423 "dst_off=0x%x len=0x%x\n",
395 thread_name, total_tests - 1, 424 thread_name, total_tests - 1,
@@ -443,9 +472,7 @@ static int dmatest_func(void *data)
443 } 472 }
444 473
445 /* Unmap by myself (see DMA_COMPL_SKIP_DEST_UNMAP above) */ 474 /* Unmap by myself (see DMA_COMPL_SKIP_DEST_UNMAP above) */
446 for (i = 0; i < dst_cnt; i++) 475 unmap_dst(dev->dev, dma_dsts, test_buf_size, dst_cnt);
447 dma_unmap_single(dev->dev, dma_dsts[i], test_buf_size,
448 DMA_BIDIRECTIONAL);
449 476
450 error_count = 0; 477 error_count = 0;
451 478
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index a932c485eb04..c3c13e64a2f0 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -1397,10 +1397,7 @@ int do_read_error(struct nandsim *ns, int num)
1397 unsigned int page_no = ns->regs.row; 1397 unsigned int page_no = ns->regs.row;
1398 1398
1399 if (read_error(page_no)) { 1399 if (read_error(page_no)) {
1400 int i; 1400 prandom_bytes(ns->buf.byte, num);
1401 memset(ns->buf.byte, 0xFF, num);
1402 for (i = 0; i < num; ++i)
1403 ns->buf.byte[i] = random32();
1404 NS_WARN("simulating read error in page %u\n", page_no); 1401 NS_WARN("simulating read error in page %u\n", page_no);
1405 return 1; 1402 return 1;
1406 } 1403 }
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index a2998bea5d4b..01588b66a38c 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -1832,7 +1832,6 @@ int bnx2x_config_rss_pf(struct bnx2x *bp, struct bnx2x_rss_config_obj *rss_obj,
1832 bool config_hash) 1832 bool config_hash)
1833{ 1833{
1834 struct bnx2x_config_rss_params params = {NULL}; 1834 struct bnx2x_config_rss_params params = {NULL};
1835 int i;
1836 1835
1837 /* Although RSS is meaningless when there is a single HW queue we 1836 /* Although RSS is meaningless when there is a single HW queue we
1838 * still need it enabled in order to have HW Rx hash generated. 1837 * still need it enabled in order to have HW Rx hash generated.
@@ -1864,9 +1863,7 @@ int bnx2x_config_rss_pf(struct bnx2x *bp, struct bnx2x_rss_config_obj *rss_obj,
1864 1863
1865 if (config_hash) { 1864 if (config_hash) {
1866 /* RSS keys */ 1865 /* RSS keys */
1867 for (i = 0; i < sizeof(params.rss_key) / 4; i++) 1866 prandom_bytes(params.rss_key, sizeof(params.rss_key));
1868 params.rss_key[i] = random32();
1869
1870 __set_bit(BNX2X_RSS_SET_SRCH, &params.rss_flags); 1867 __set_bit(BNX2X_RSS_SET_SRCH, &params.rss_flags);
1871 } 1868 }
1872 1869
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 6deaae18db57..28aa05f60c26 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -156,11 +156,7 @@ config PRISM54
156 ---help--- 156 ---help---
157 This enables support for FullMAC PCI/Cardbus prism54 devices. This 157 This enables support for FullMAC PCI/Cardbus prism54 devices. This
158 driver is now deprecated in favor for the SoftMAC driver, p54pci. 158 driver is now deprecated in favor for the SoftMAC driver, p54pci.
159 p54pci supports FullMAC PCI/Cardbus devices as well. For details on 159 p54pci supports FullMAC PCI/Cardbus devices as well.
160 the scheduled removal of this driver on the kernel see the feature
161 removal schedule:
162
163 Documentation/feature-removal-schedule.txt
164 160
165 For more information refer to the p54 wiki: 161 For more information refer to the p54 wiki:
166 162
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index a65c39c473bf..808be06bb67e 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -488,14 +488,8 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
488 depth++; 488 depth++;
489 pathp = (char *)p; 489 pathp = (char *)p;
490 p = ALIGN(p + strlen(pathp) + 1, 4); 490 p = ALIGN(p + strlen(pathp) + 1, 4);
491 if ((*pathp) == '/') { 491 if (*pathp == '/')
492 const char *lp, *np; 492 pathp = kbasename(pathp);
493 for (lp = NULL, np = pathp; *np; np++)
494 if ((*np) == '/')
495 lp = np+1;
496 if (lp != NULL)
497 pathp = lp;
498 }
499 rc = it(p, pathp, depth, data); 493 rc = it(p, pathp, depth, data);
500 if (rc != 0) 494 if (rc != 0)
501 break; 495 break;
diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
index 6b0ebdeae916..be790402e0f1 100644
--- a/drivers/platform/x86/asus-nb-wmi.c
+++ b/drivers/platform/x86/asus-nb-wmi.c
@@ -32,7 +32,7 @@
32 32
33#define ASUS_NB_WMI_FILE "asus-nb-wmi" 33#define ASUS_NB_WMI_FILE "asus-nb-wmi"
34 34
35MODULE_AUTHOR("Corentin Chary <corentincj@iksaif.net>"); 35MODULE_AUTHOR("Corentin Chary <corentin.chary@gmail.com>");
36MODULE_DESCRIPTION("Asus Notebooks WMI Hotkey Driver"); 36MODULE_DESCRIPTION("Asus Notebooks WMI Hotkey Driver");
37MODULE_LICENSE("GPL"); 37MODULE_LICENSE("GPL");
38 38
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index c0e9ff489b24..f80ae4d10f68 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -51,7 +51,7 @@
51 51
52#include "asus-wmi.h" 52#include "asus-wmi.h"
53 53
54MODULE_AUTHOR("Corentin Chary <corentincj@iksaif.net>, " 54MODULE_AUTHOR("Corentin Chary <corentin.chary@gmail.com>, "
55 "Yong Wang <yong.y.wang@intel.com>"); 55 "Yong Wang <yong.y.wang@intel.com>");
56MODULE_DESCRIPTION("Asus Generic WMI Driver"); 56MODULE_DESCRIPTION("Asus Generic WMI Driver");
57MODULE_LICENSE("GPL"); 57MODULE_LICENSE("GPL");
diff --git a/drivers/platform/x86/eeepc-wmi.c b/drivers/platform/x86/eeepc-wmi.c
index 5838332ea5bd..60cb76a5b513 100644
--- a/drivers/platform/x86/eeepc-wmi.c
+++ b/drivers/platform/x86/eeepc-wmi.c
@@ -39,7 +39,7 @@
39 39
40#define EEEPC_WMI_FILE "eeepc-wmi" 40#define EEEPC_WMI_FILE "eeepc-wmi"
41 41
42MODULE_AUTHOR("Corentin Chary <corentincj@iksaif.net>"); 42MODULE_AUTHOR("Corentin Chary <corentin.chary@gmail.com>");
43MODULE_DESCRIPTION("Eee PC WMI Hotkey Driver"); 43MODULE_DESCRIPTION("Eee PC WMI Hotkey Driver");
44MODULE_LICENSE("GPL"); 44MODULE_LICENSE("GPL");
45 45
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 19c03ab2bdcb..d0cea02b5dfc 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -269,6 +269,15 @@ config RTC_DRV_X1205
269 This driver can also be built as a module. If so, the module 269 This driver can also be built as a module. If so, the module
270 will be called rtc-x1205. 270 will be called rtc-x1205.
271 271
272config RTC_DRV_PCF8523
273 tristate "NXP PCF8523"
274 help
275 If you say yes here you get support for the NXP PCF8523 RTC
276 chips.
277
278 This driver can also be built as a module. If so, the module
279 will be called rtc-pcf8523.
280
272config RTC_DRV_PCF8563 281config RTC_DRV_PCF8563
273 tristate "Philips PCF8563/Epson RTC8564" 282 tristate "Philips PCF8563/Epson RTC8564"
274 help 283 help
@@ -600,6 +609,16 @@ config RTC_DRV_DA9052
600 Say y here to support the RTC driver for Dialog Semiconductor 609 Say y here to support the RTC driver for Dialog Semiconductor
601 DA9052-BC and DA9053-AA/Bx PMICs. 610 DA9052-BC and DA9053-AA/Bx PMICs.
602 611
612config RTC_DRV_DA9055
613 tristate "Dialog Semiconductor DA9055 RTC"
614 depends on MFD_DA9055
615 help
616 If you say yes here you will get support for the
617 RTC of the Dialog DA9055 PMIC.
618
619 This driver can also be built as a module. If so, the module
620 will be called rtc-da9055
621
603config RTC_DRV_EFI 622config RTC_DRV_EFI
604 tristate "EFI RTC" 623 tristate "EFI RTC"
605 depends on IA64 624 depends on IA64
@@ -768,7 +787,7 @@ config RTC_DRV_DAVINCI
768 787
769config RTC_DRV_IMXDI 788config RTC_DRV_IMXDI
770 tristate "Freescale IMX DryIce Real Time Clock" 789 tristate "Freescale IMX DryIce Real Time Clock"
771 depends on SOC_IMX25 790 depends on ARCH_MXC
772 help 791 help
773 Support for Freescale IMX DryIce RTC 792 Support for Freescale IMX DryIce RTC
774 793
@@ -777,11 +796,13 @@ config RTC_DRV_IMXDI
777 796
778config RTC_DRV_OMAP 797config RTC_DRV_OMAP
779 tristate "TI OMAP1" 798 tristate "TI OMAP1"
780 depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 || ARCH_DAVINCI_DA8XX 799 depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 || ARCH_DAVINCI_DA8XX || SOC_AM33XX
781 help 800 help
782 Say "yes" here to support the real time clock on TI OMAP1 and 801 Say "yes" here to support the on chip real time clock
783 DA8xx/OMAP-L13x chips. This driver can also be built as a 802 present on TI OMAP1, AM33xx and DA8xx/OMAP-L13x.
784 module called rtc-omap. 803
804 This driver can also be built as a module, if so, module
805 will be called rtc-omap.
785 806
786config HAVE_S3C_RTC 807config HAVE_S3C_RTC
787 bool 808 bool
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 56297f0fd388..c3f62c80dc06 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o
29obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o 29obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o
30obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o 30obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o
31obj-$(CONFIG_RTC_DRV_DA9052) += rtc-da9052.o 31obj-$(CONFIG_RTC_DRV_DA9052) += rtc-da9052.o
32obj-$(CONFIG_RTC_DRV_DA9055) += rtc-da9055.o
32obj-$(CONFIG_RTC_DRV_DAVINCI) += rtc-davinci.o 33obj-$(CONFIG_RTC_DRV_DAVINCI) += rtc-davinci.o
33obj-$(CONFIG_RTC_DRV_DM355EVM) += rtc-dm355evm.o 34obj-$(CONFIG_RTC_DRV_DM355EVM) += rtc-dm355evm.o
34obj-$(CONFIG_RTC_DRV_VRTC) += rtc-mrst.o 35obj-$(CONFIG_RTC_DRV_VRTC) += rtc-mrst.o
@@ -76,6 +77,7 @@ obj-$(CONFIG_RTC_DRV_MV) += rtc-mv.o
76obj-$(CONFIG_RTC_DRV_NUC900) += rtc-nuc900.o 77obj-$(CONFIG_RTC_DRV_NUC900) += rtc-nuc900.o
77obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o 78obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o
78obj-$(CONFIG_RTC_DRV_PCAP) += rtc-pcap.o 79obj-$(CONFIG_RTC_DRV_PCAP) += rtc-pcap.o
80obj-$(CONFIG_RTC_DRV_PCF8523) += rtc-pcf8523.o
79obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o 81obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o
80obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o 82obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o
81obj-$(CONFIG_RTC_DRV_PCF2123) += rtc-pcf2123.o 83obj-$(CONFIG_RTC_DRV_PCF2123) += rtc-pcf2123.o
diff --git a/drivers/rtc/rtc-da9055.c b/drivers/rtc/rtc-da9055.c
new file mode 100644
index 000000000000..96bafc5c3bf8
--- /dev/null
+++ b/drivers/rtc/rtc-da9055.c
@@ -0,0 +1,413 @@
1/*
2 * Real time clock driver for DA9055
3 *
4 * Copyright(c) 2012 Dialog Semiconductor Ltd.
5 *
6 * Author: Dajun Dajun Chen <dajun.chen@diasemi.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 */
14
15#include <linux/module.h>
16#include <linux/platform_device.h>
17#include <linux/rtc.h>
18
19#include <linux/mfd/da9055/core.h>
20#include <linux/mfd/da9055/reg.h>
21#include <linux/mfd/da9055/pdata.h>
22
23struct da9055_rtc {
24 struct rtc_device *rtc;
25 struct da9055 *da9055;
26 int alarm_enable;
27};
28
29static int da9055_rtc_enable_alarm(struct da9055_rtc *rtc, bool enable)
30{
31 int ret;
32 if (enable) {
33 ret = da9055_reg_update(rtc->da9055, DA9055_REG_ALARM_Y,
34 DA9055_RTC_ALM_EN,
35 DA9055_RTC_ALM_EN);
36 if (ret != 0)
37 dev_err(rtc->da9055->dev, "Failed to enable ALM: %d\n",
38 ret);
39 rtc->alarm_enable = 1;
40 } else {
41 ret = da9055_reg_update(rtc->da9055, DA9055_REG_ALARM_Y,
42 DA9055_RTC_ALM_EN, 0);
43 if (ret != 0)
44 dev_err(rtc->da9055->dev,
45 "Failed to disable ALM: %d\n", ret);
46 rtc->alarm_enable = 0;
47 }
48 return ret;
49}
50
51static irqreturn_t da9055_rtc_alm_irq(int irq, void *data)
52{
53 struct da9055_rtc *rtc = data;
54
55 da9055_rtc_enable_alarm(rtc, 0);
56 rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_AF);
57
58 return IRQ_HANDLED;
59}
60
61static int da9055_read_alarm(struct da9055 *da9055, struct rtc_time *rtc_tm)
62{
63 int ret;
64 uint8_t v[5];
65
66 ret = da9055_group_read(da9055, DA9055_REG_ALARM_MI, 5, v);
67 if (ret != 0) {
68 dev_err(da9055->dev, "Failed to group read ALM: %d\n", ret);
69 return ret;
70 }
71
72 rtc_tm->tm_year = (v[4] & DA9055_RTC_ALM_YEAR) + 100;
73 rtc_tm->tm_mon = (v[3] & DA9055_RTC_ALM_MONTH) - 1;
74 rtc_tm->tm_mday = v[2] & DA9055_RTC_ALM_DAY;
75 rtc_tm->tm_hour = v[1] & DA9055_RTC_ALM_HOUR;
76 rtc_tm->tm_min = v[0] & DA9055_RTC_ALM_MIN;
77
78 return rtc_valid_tm(rtc_tm);
79}
80
81static int da9055_set_alarm(struct da9055 *da9055, struct rtc_time *rtc_tm)
82{
83 int ret;
84 uint8_t v[2];
85
86 rtc_tm->tm_year -= 100;
87 rtc_tm->tm_mon += 1;
88
89 ret = da9055_reg_update(da9055, DA9055_REG_ALARM_MI,
90 DA9055_RTC_ALM_MIN, rtc_tm->tm_min);
91 if (ret != 0) {
92 dev_err(da9055->dev, "Failed to write ALRM MIN: %d\n", ret);
93 return ret;
94 }
95
96 v[0] = rtc_tm->tm_hour;
97 v[1] = rtc_tm->tm_mday;
98
99 ret = da9055_group_write(da9055, DA9055_REG_ALARM_H, 2, v);
100 if (ret < 0)
101 return ret;
102
103 ret = da9055_reg_update(da9055, DA9055_REG_ALARM_MO,
104 DA9055_RTC_ALM_MONTH, rtc_tm->tm_mon);
105 if (ret < 0)
106 dev_err(da9055->dev, "Failed to write ALM Month:%d\n", ret);
107
108 ret = da9055_reg_update(da9055, DA9055_REG_ALARM_Y,
109 DA9055_RTC_ALM_YEAR, rtc_tm->tm_year);
110 if (ret < 0)
111 dev_err(da9055->dev, "Failed to write ALM Year:%d\n", ret);
112
113 return ret;
114}
115
116static int da9055_rtc_get_alarm_status(struct da9055 *da9055)
117{
118 int ret;
119
120 ret = da9055_reg_read(da9055, DA9055_REG_ALARM_Y);
121 if (ret < 0) {
122 dev_err(da9055->dev, "Failed to read ALM: %d\n", ret);
123 return ret;
124 }
125 ret &= DA9055_RTC_ALM_EN;
126 return (ret > 0) ? 1 : 0;
127}
128
129static int da9055_rtc_read_time(struct device *dev, struct rtc_time *rtc_tm)
130{
131 struct da9055_rtc *rtc = dev_get_drvdata(dev);
132 uint8_t v[6];
133 int ret;
134
135 ret = da9055_reg_read(rtc->da9055, DA9055_REG_COUNT_S);
136 if (ret < 0)
137 return ret;
138
139 /*
140 * Registers are only valid when RTC_READ
141 * status bit is asserted
142 */
143 if (!(ret & DA9055_RTC_READ))
144 return -EBUSY;
145
146 ret = da9055_group_read(rtc->da9055, DA9055_REG_COUNT_S, 6, v);
147 if (ret < 0) {
148 dev_err(rtc->da9055->dev, "Failed to read RTC time : %d\n",
149 ret);
150 return ret;
151 }
152
153 rtc_tm->tm_year = (v[5] & DA9055_RTC_YEAR) + 100;
154 rtc_tm->tm_mon = (v[4] & DA9055_RTC_MONTH) - 1;
155 rtc_tm->tm_mday = v[3] & DA9055_RTC_DAY;
156 rtc_tm->tm_hour = v[2] & DA9055_RTC_HOUR;
157 rtc_tm->tm_min = v[1] & DA9055_RTC_MIN;
158 rtc_tm->tm_sec = v[0] & DA9055_RTC_SEC;
159
160 return rtc_valid_tm(rtc_tm);
161}
162
163static int da9055_rtc_set_time(struct device *dev, struct rtc_time *tm)
164{
165 struct da9055_rtc *rtc;
166 uint8_t v[6];
167
168 rtc = dev_get_drvdata(dev);
169
170 v[0] = tm->tm_sec;
171 v[1] = tm->tm_min;
172 v[2] = tm->tm_hour;
173 v[3] = tm->tm_mday;
174 v[4] = tm->tm_mon + 1;
175 v[5] = tm->tm_year - 100;
176
177 return da9055_group_write(rtc->da9055, DA9055_REG_COUNT_S, 6, v);
178}
179
180static int da9055_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
181{
182 int ret;
183 struct rtc_time *tm = &alrm->time;
184 struct da9055_rtc *rtc = dev_get_drvdata(dev);
185
186 ret = da9055_read_alarm(rtc->da9055, tm);
187
188 if (ret)
189 return ret;
190
191 alrm->enabled = da9055_rtc_get_alarm_status(rtc->da9055);
192
193 return 0;
194}
195
196static int da9055_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
197{
198 int ret;
199 struct rtc_time *tm = &alrm->time;
200 struct da9055_rtc *rtc = dev_get_drvdata(dev);
201
202 ret = da9055_rtc_enable_alarm(rtc, 0);
203 if (ret < 0)
204 return ret;
205
206 ret = da9055_set_alarm(rtc->da9055, tm);
207 if (ret)
208 return ret;
209
210 ret = da9055_rtc_enable_alarm(rtc, 1);
211
212 return ret;
213}
214
215static int da9055_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
216{
217 struct da9055_rtc *rtc = dev_get_drvdata(dev);
218
219 return da9055_rtc_enable_alarm(rtc, enabled);
220}
221
222static const struct rtc_class_ops da9055_rtc_ops = {
223 .read_time = da9055_rtc_read_time,
224 .set_time = da9055_rtc_set_time,
225 .read_alarm = da9055_rtc_read_alarm,
226 .set_alarm = da9055_rtc_set_alarm,
227 .alarm_irq_enable = da9055_rtc_alarm_irq_enable,
228};
229
230static int __init da9055_rtc_device_init(struct da9055 *da9055,
231 struct da9055_pdata *pdata)
232{
233 int ret;
234
235 /* Enable RTC and the internal Crystal */
236 ret = da9055_reg_update(da9055, DA9055_REG_CONTROL_B,
237 DA9055_RTC_EN, DA9055_RTC_EN);
238 if (ret < 0)
239 return ret;
240 ret = da9055_reg_update(da9055, DA9055_REG_EN_32K,
241 DA9055_CRYSTAL_EN, DA9055_CRYSTAL_EN);
242 if (ret < 0)
243 return ret;
244
245 /* Enable RTC in Power Down mode */
246 ret = da9055_reg_update(da9055, DA9055_REG_CONTROL_B,
247 DA9055_RTC_MODE_PD, DA9055_RTC_MODE_PD);
248 if (ret < 0)
249 return ret;
250
251 /* Enable RTC in Reset mode */
252 if (pdata && pdata->reset_enable) {
253 ret = da9055_reg_update(da9055, DA9055_REG_CONTROL_B,
254 DA9055_RTC_MODE_SD,
255 DA9055_RTC_MODE_SD <<
256 DA9055_RTC_MODE_SD_SHIFT);
257 if (ret < 0)
258 return ret;
259 }
260
261 /* Disable the RTC TICK ALM */
262 ret = da9055_reg_update(da9055, DA9055_REG_ALARM_MO,
263 DA9055_RTC_TICK_WAKE_MASK, 0);
264 if (ret < 0)
265 return ret;
266
267 return 0;
268}
269
270static int da9055_rtc_probe(struct platform_device *pdev)
271{
272 struct da9055_rtc *rtc;
273 struct da9055_pdata *pdata = NULL;
274 int ret, alm_irq;
275
276 rtc = devm_kzalloc(&pdev->dev, sizeof(struct da9055_rtc), GFP_KERNEL);
277 if (!rtc)
278 return -ENOMEM;
279
280 rtc->da9055 = dev_get_drvdata(pdev->dev.parent);
281 pdata = rtc->da9055->dev->platform_data;
282 platform_set_drvdata(pdev, rtc);
283
284 ret = da9055_rtc_device_init(rtc->da9055, pdata);
285 if (ret < 0)
286 goto err_rtc;
287
288 ret = da9055_reg_read(rtc->da9055, DA9055_REG_ALARM_Y);
289 if (ret < 0)
290 goto err_rtc;
291
292 if (ret & DA9055_RTC_ALM_EN)
293 rtc->alarm_enable = 1;
294
295 device_init_wakeup(&pdev->dev, 1);
296
297 rtc->rtc = rtc_device_register(pdev->name, &pdev->dev,
298 &da9055_rtc_ops, THIS_MODULE);
299 if (IS_ERR(rtc->rtc)) {
300 ret = PTR_ERR(rtc->rtc);
301 goto err_rtc;
302 }
303
304 alm_irq = platform_get_irq_byname(pdev, "ALM");
305 alm_irq = regmap_irq_get_virq(rtc->da9055->irq_data, alm_irq);
306 ret = devm_request_threaded_irq(&pdev->dev, alm_irq, NULL,
307 da9055_rtc_alm_irq,
308 IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
309 "ALM", rtc);
310 if (ret != 0)
311 dev_err(rtc->da9055->dev, "irq registration failed: %d\n", ret);
312
313err_rtc:
314 return ret;
315
316}
317
318static int da9055_rtc_remove(struct platform_device *pdev)
319{
320 struct da9055_rtc *rtc = pdev->dev.platform_data;
321
322 rtc_device_unregister(rtc->rtc);
323 platform_set_drvdata(pdev, NULL);
324
325 return 0;
326}
327
328#ifdef CONFIG_PM
329/* Turn off the alarm if it should not be a wake source. */
330static int da9055_rtc_suspend(struct device *dev)
331{
332 struct platform_device *pdev = to_platform_device(dev);
333 struct da9055_rtc *rtc = dev_get_drvdata(&pdev->dev);
334 int ret;
335
336 if (!device_may_wakeup(&pdev->dev)) {
337 /* Disable the ALM IRQ */
338 ret = da9055_rtc_enable_alarm(rtc, 0);
339 if (ret < 0)
340 dev_err(&pdev->dev, "Failed to disable RTC ALM\n");
341 }
342
343 return 0;
344}
345
346/* Enable the alarm if it should be enabled (in case it was disabled to
347 * prevent use as a wake source).
348 */
349static int da9055_rtc_resume(struct device *dev)
350{
351 struct platform_device *pdev = to_platform_device(dev);
352 struct da9055_rtc *rtc = dev_get_drvdata(&pdev->dev);
353 int ret;
354
355 if (!device_may_wakeup(&pdev->dev)) {
356 if (rtc->alarm_enable) {
357 ret = da9055_rtc_enable_alarm(rtc, 1);
358 if (ret < 0)
359 dev_err(&pdev->dev,
360 "Failed to restart RTC ALM\n");
361 }
362 }
363
364 return 0;
365}
366
367/* Unconditionally disable the alarm */
368static int da9055_rtc_freeze(struct device *dev)
369{
370 struct platform_device *pdev = to_platform_device(dev);
371 struct da9055_rtc *rtc = dev_get_drvdata(&pdev->dev);
372 int ret;
373
374 ret = da9055_rtc_enable_alarm(rtc, 0);
375 if (ret < 0)
376 dev_err(&pdev->dev, "Failed to freeze RTC ALMs\n");
377
378 return 0;
379
380}
381#else
382#define da9055_rtc_suspend NULL
383#define da9055_rtc_resume NULL
384#define da9055_rtc_freeze NULL
385#endif
386
387static const struct dev_pm_ops da9055_rtc_pm_ops = {
388 .suspend = da9055_rtc_suspend,
389 .resume = da9055_rtc_resume,
390
391 .freeze = da9055_rtc_freeze,
392 .thaw = da9055_rtc_resume,
393 .restore = da9055_rtc_resume,
394
395 .poweroff = da9055_rtc_suspend,
396};
397
398static struct platform_driver da9055_rtc_driver = {
399 .probe = da9055_rtc_probe,
400 .remove = da9055_rtc_remove,
401 .driver = {
402 .name = "da9055-rtc",
403 .owner = THIS_MODULE,
404 .pm = &da9055_rtc_pm_ops,
405 },
406};
407
408module_platform_driver(da9055_rtc_driver);
409
410MODULE_AUTHOR("David Dajun Chen <dchen@diasemi.com>");
411MODULE_DESCRIPTION("RTC driver for Dialog DA9055 PMIC");
412MODULE_LICENSE("GPL");
413MODULE_ALIAS("platform:da9055-rtc");
diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c
index 14c2109dbaa3..07cd03eae606 100644
--- a/drivers/rtc/rtc-davinci.c
+++ b/drivers/rtc/rtc-davinci.c
@@ -485,7 +485,7 @@ static int __init davinci_rtc_probe(struct platform_device *pdev)
485 struct resource *res, *mem; 485 struct resource *res, *mem;
486 int ret = 0; 486 int ret = 0;
487 487
488 davinci_rtc = kzalloc(sizeof(struct davinci_rtc), GFP_KERNEL); 488 davinci_rtc = devm_kzalloc(&pdev->dev, sizeof(struct davinci_rtc), GFP_KERNEL);
489 if (!davinci_rtc) { 489 if (!davinci_rtc) {
490 dev_dbg(dev, "could not allocate memory for private data\n"); 490 dev_dbg(dev, "could not allocate memory for private data\n");
491 return -ENOMEM; 491 return -ENOMEM;
@@ -494,15 +494,13 @@ static int __init davinci_rtc_probe(struct platform_device *pdev)
494 davinci_rtc->irq = platform_get_irq(pdev, 0); 494 davinci_rtc->irq = platform_get_irq(pdev, 0);
495 if (davinci_rtc->irq < 0) { 495 if (davinci_rtc->irq < 0) {
496 dev_err(dev, "no RTC irq\n"); 496 dev_err(dev, "no RTC irq\n");
497 ret = davinci_rtc->irq; 497 return davinci_rtc->irq;
498 goto fail1;
499 } 498 }
500 499
501 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 500 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
502 if (!res) { 501 if (!res) {
503 dev_err(dev, "no mem resource\n"); 502 dev_err(dev, "no mem resource\n");
504 ret = -EINVAL; 503 return -EINVAL;
505 goto fail1;
506 } 504 }
507 505
508 davinci_rtc->pbase = res->start; 506 davinci_rtc->pbase = res->start;
@@ -513,8 +511,7 @@ static int __init davinci_rtc_probe(struct platform_device *pdev)
513 if (!mem) { 511 if (!mem) {
514 dev_err(dev, "RTC registers at %08x are not free\n", 512 dev_err(dev, "RTC registers at %08x are not free\n",
515 davinci_rtc->pbase); 513 davinci_rtc->pbase);
516 ret = -EBUSY; 514 return -EBUSY;
517 goto fail1;
518 } 515 }
519 516
520 davinci_rtc->base = ioremap(davinci_rtc->pbase, davinci_rtc->base_size); 517 davinci_rtc->base = ioremap(davinci_rtc->pbase, davinci_rtc->base_size);
@@ -529,8 +526,9 @@ static int __init davinci_rtc_probe(struct platform_device *pdev)
529 davinci_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, 526 davinci_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev,
530 &davinci_rtc_ops, THIS_MODULE); 527 &davinci_rtc_ops, THIS_MODULE);
531 if (IS_ERR(davinci_rtc->rtc)) { 528 if (IS_ERR(davinci_rtc->rtc)) {
532 dev_err(dev, "unable to register RTC device, err %ld\n", 529 ret = PTR_ERR(davinci_rtc->rtc);
533 PTR_ERR(davinci_rtc->rtc)); 530 dev_err(dev, "unable to register RTC device, err %d\n",
531 ret);
534 goto fail3; 532 goto fail3;
535 } 533 }
536 534
@@ -566,9 +564,6 @@ fail3:
566 iounmap(davinci_rtc->base); 564 iounmap(davinci_rtc->base);
567fail2: 565fail2:
568 release_mem_region(davinci_rtc->pbase, davinci_rtc->base_size); 566 release_mem_region(davinci_rtc->pbase, davinci_rtc->base_size);
569fail1:
570 kfree(davinci_rtc);
571
572 return ret; 567 return ret;
573} 568}
574 569
@@ -589,8 +584,6 @@ static int __devexit davinci_rtc_remove(struct platform_device *pdev)
589 584
590 platform_set_drvdata(pdev, NULL); 585 platform_set_drvdata(pdev, NULL);
591 586
592 kfree(davinci_rtc);
593
594 return 0; 587 return 0;
595} 588}
596 589
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index cace6d3aed9a..9a86b4bd8699 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -379,25 +379,6 @@ static long rtc_dev_ioctl(struct file *file,
379 err = put_user(rtc->irq_freq, (unsigned long __user *)uarg); 379 err = put_user(rtc->irq_freq, (unsigned long __user *)uarg);
380 break; 380 break;
381 381
382#if 0
383 case RTC_EPOCH_SET:
384#ifndef rtc_epoch
385 /*
386 * There were no RTC clocks before 1900.
387 */
388 if (arg < 1900) {
389 err = -EINVAL;
390 break;
391 }
392 rtc_epoch = arg;
393 err = 0;
394#endif
395 break;
396
397 case RTC_EPOCH_READ:
398 err = put_user(rtc_epoch, (unsigned long __user *)uarg);
399 break;
400#endif
401 case RTC_WKALM_SET: 382 case RTC_WKALM_SET:
402 mutex_unlock(&rtc->ops_lock); 383 mutex_unlock(&rtc->ops_lock);
403 if (copy_from_user(&alarm, uarg, sizeof(alarm))) 384 if (copy_from_user(&alarm, uarg, sizeof(alarm)))
diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index 4eed51044c5d..18a4f0dd78a3 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -37,6 +37,7 @@
37#include <linux/rtc.h> 37#include <linux/rtc.h>
38#include <linux/sched.h> 38#include <linux/sched.h>
39#include <linux/workqueue.h> 39#include <linux/workqueue.h>
40#include <linux/of.h>
40 41
41/* DryIce Register Definitions */ 42/* DryIce Register Definitions */
42 43
@@ -495,10 +496,20 @@ static int __devexit dryice_rtc_remove(struct platform_device *pdev)
495 return 0; 496 return 0;
496} 497}
497 498
499#ifdef CONFIG_OF
500static const struct of_device_id dryice_dt_ids[] = {
501 { .compatible = "fsl,imx25-rtc" },
502 { /* sentinel */ }
503};
504
505MODULE_DEVICE_TABLE(of, dryice_dt_ids);
506#endif
507
498static struct platform_driver dryice_rtc_driver = { 508static struct platform_driver dryice_rtc_driver = {
499 .driver = { 509 .driver = {
500 .name = "imxdi_rtc", 510 .name = "imxdi_rtc",
501 .owner = THIS_MODULE, 511 .owner = THIS_MODULE,
512 .of_match_table = of_match_ptr(dryice_dt_ids),
502 }, 513 },
503 .remove = __devexit_p(dryice_rtc_remove), 514 .remove = __devexit_p(dryice_rtc_remove),
504}; 515};
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 0b614e32653d..600971407aac 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -20,6 +20,9 @@
20#include <linux/rtc.h> 20#include <linux/rtc.h>
21#include <linux/bcd.h> 21#include <linux/bcd.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/of.h>
24#include <linux/of_device.h>
25#include <linux/pm_runtime.h>
23 26
24#include <asm/io.h> 27#include <asm/io.h>
25 28
@@ -38,6 +41,8 @@
38 * the SoC). See the BOARD-SPECIFIC CUSTOMIZATION comment. 41 * the SoC). See the BOARD-SPECIFIC CUSTOMIZATION comment.
39 */ 42 */
40 43
44#define DRIVER_NAME "omap_rtc"
45
41#define OMAP_RTC_BASE 0xfffb4800 46#define OMAP_RTC_BASE 0xfffb4800
42 47
43/* RTC registers */ 48/* RTC registers */
@@ -64,6 +69,9 @@
64#define OMAP_RTC_COMP_MSB_REG 0x50 69#define OMAP_RTC_COMP_MSB_REG 0x50
65#define OMAP_RTC_OSC_REG 0x54 70#define OMAP_RTC_OSC_REG 0x54
66 71
72#define OMAP_RTC_KICK0_REG 0x6c
73#define OMAP_RTC_KICK1_REG 0x70
74
67/* OMAP_RTC_CTRL_REG bit fields: */ 75/* OMAP_RTC_CTRL_REG bit fields: */
68#define OMAP_RTC_CTRL_SPLIT (1<<7) 76#define OMAP_RTC_CTRL_SPLIT (1<<7)
69#define OMAP_RTC_CTRL_DISABLE (1<<6) 77#define OMAP_RTC_CTRL_DISABLE (1<<6)
@@ -88,10 +96,18 @@
88#define OMAP_RTC_INTERRUPTS_IT_ALARM (1<<3) 96#define OMAP_RTC_INTERRUPTS_IT_ALARM (1<<3)
89#define OMAP_RTC_INTERRUPTS_IT_TIMER (1<<2) 97#define OMAP_RTC_INTERRUPTS_IT_TIMER (1<<2)
90 98
99/* OMAP_RTC_KICKER values */
100#define KICK0_VALUE 0x83e70b13
101#define KICK1_VALUE 0x95a4f1e0
102
103#define OMAP_RTC_HAS_KICKER 0x1
104
91static void __iomem *rtc_base; 105static void __iomem *rtc_base;
92 106
93#define rtc_read(addr) __raw_readb(rtc_base + (addr)) 107#define rtc_read(addr) readb(rtc_base + (addr))
94#define rtc_write(val, addr) __raw_writeb(val, rtc_base + (addr)) 108#define rtc_write(val, addr) writeb(val, rtc_base + (addr))
109
110#define rtc_writel(val, addr) writel(val, rtc_base + (addr))
95 111
96 112
97/* we rely on the rtc framework to handle locking (rtc->ops_lock), 113/* we rely on the rtc framework to handle locking (rtc->ops_lock),
@@ -285,11 +301,38 @@ static struct rtc_class_ops omap_rtc_ops = {
285static int omap_rtc_alarm; 301static int omap_rtc_alarm;
286static int omap_rtc_timer; 302static int omap_rtc_timer;
287 303
304#define OMAP_RTC_DATA_DA830_IDX 1
305
306static struct platform_device_id omap_rtc_devtype[] = {
307 {
308 .name = DRIVER_NAME,
309 }, {
310 .name = "da830-rtc",
311 .driver_data = OMAP_RTC_HAS_KICKER,
312 },
313 {},
314};
315MODULE_DEVICE_TABLE(platform, omap_rtc_devtype);
316
317static const struct of_device_id omap_rtc_of_match[] = {
318 { .compatible = "ti,da830-rtc",
319 .data = &omap_rtc_devtype[OMAP_RTC_DATA_DA830_IDX],
320 },
321 {},
322};
323MODULE_DEVICE_TABLE(of, omap_rtc_of_match);
324
288static int __init omap_rtc_probe(struct platform_device *pdev) 325static int __init omap_rtc_probe(struct platform_device *pdev)
289{ 326{
290 struct resource *res, *mem; 327 struct resource *res, *mem;
291 struct rtc_device *rtc; 328 struct rtc_device *rtc;
292 u8 reg, new_ctrl; 329 u8 reg, new_ctrl;
330 const struct platform_device_id *id_entry;
331 const struct of_device_id *of_id;
332
333 of_id = of_match_device(omap_rtc_of_match, &pdev->dev);
334 if (of_id)
335 pdev->id_entry = of_id->data;
293 336
294 omap_rtc_timer = platform_get_irq(pdev, 0); 337 omap_rtc_timer = platform_get_irq(pdev, 0);
295 if (omap_rtc_timer <= 0) { 338 if (omap_rtc_timer <= 0) {
@@ -322,6 +365,16 @@ static int __init omap_rtc_probe(struct platform_device *pdev)
322 goto fail; 365 goto fail;
323 } 366 }
324 367
368 /* Enable the clock/module so that we can access the registers */
369 pm_runtime_enable(&pdev->dev);
370 pm_runtime_get_sync(&pdev->dev);
371
372 id_entry = platform_get_device_id(pdev);
373 if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) {
374 rtc_writel(KICK0_VALUE, OMAP_RTC_KICK0_REG);
375 rtc_writel(KICK1_VALUE, OMAP_RTC_KICK1_REG);
376 }
377
325 rtc = rtc_device_register(pdev->name, &pdev->dev, 378 rtc = rtc_device_register(pdev->name, &pdev->dev,
326 &omap_rtc_ops, THIS_MODULE); 379 &omap_rtc_ops, THIS_MODULE);
327 if (IS_ERR(rtc)) { 380 if (IS_ERR(rtc)) {
@@ -398,6 +451,10 @@ fail2:
398fail1: 451fail1:
399 rtc_device_unregister(rtc); 452 rtc_device_unregister(rtc);
400fail0: 453fail0:
454 if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER))
455 rtc_writel(0, OMAP_RTC_KICK0_REG);
456 pm_runtime_put_sync(&pdev->dev);
457 pm_runtime_disable(&pdev->dev);
401 iounmap(rtc_base); 458 iounmap(rtc_base);
402fail: 459fail:
403 release_mem_region(mem->start, resource_size(mem)); 460 release_mem_region(mem->start, resource_size(mem));
@@ -408,6 +465,8 @@ static int __exit omap_rtc_remove(struct platform_device *pdev)
408{ 465{
409 struct rtc_device *rtc = platform_get_drvdata(pdev); 466 struct rtc_device *rtc = platform_get_drvdata(pdev);
410 struct resource *mem = dev_get_drvdata(&rtc->dev); 467 struct resource *mem = dev_get_drvdata(&rtc->dev);
468 const struct platform_device_id *id_entry =
469 platform_get_device_id(pdev);
411 470
412 device_init_wakeup(&pdev->dev, 0); 471 device_init_wakeup(&pdev->dev, 0);
413 472
@@ -420,6 +479,13 @@ static int __exit omap_rtc_remove(struct platform_device *pdev)
420 free_irq(omap_rtc_alarm, rtc); 479 free_irq(omap_rtc_alarm, rtc);
421 480
422 rtc_device_unregister(rtc); 481 rtc_device_unregister(rtc);
482 if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER))
483 rtc_writel(0, OMAP_RTC_KICK0_REG);
484
485 /* Disable the clock/module */
486 pm_runtime_put_sync(&pdev->dev);
487 pm_runtime_disable(&pdev->dev);
488
423 iounmap(rtc_base); 489 iounmap(rtc_base);
424 release_mem_region(mem->start, resource_size(mem)); 490 release_mem_region(mem->start, resource_size(mem));
425 return 0; 491 return 0;
@@ -442,11 +508,17 @@ static int omap_rtc_suspend(struct platform_device *pdev, pm_message_t state)
442 else 508 else
443 rtc_write(0, OMAP_RTC_INTERRUPTS_REG); 509 rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
444 510
511 /* Disable the clock/module */
512 pm_runtime_put_sync(&pdev->dev);
513
445 return 0; 514 return 0;
446} 515}
447 516
448static int omap_rtc_resume(struct platform_device *pdev) 517static int omap_rtc_resume(struct platform_device *pdev)
449{ 518{
519 /* Enable the clock/module so that we can access the registers */
520 pm_runtime_get_sync(&pdev->dev);
521
450 if (device_may_wakeup(&pdev->dev)) 522 if (device_may_wakeup(&pdev->dev))
451 disable_irq_wake(omap_rtc_alarm); 523 disable_irq_wake(omap_rtc_alarm);
452 else 524 else
@@ -471,9 +543,11 @@ static struct platform_driver omap_rtc_driver = {
471 .resume = omap_rtc_resume, 543 .resume = omap_rtc_resume,
472 .shutdown = omap_rtc_shutdown, 544 .shutdown = omap_rtc_shutdown,
473 .driver = { 545 .driver = {
474 .name = "omap_rtc", 546 .name = DRIVER_NAME,
475 .owner = THIS_MODULE, 547 .owner = THIS_MODULE,
548 .of_match_table = of_match_ptr(omap_rtc_of_match),
476 }, 549 },
550 .id_table = omap_rtc_devtype,
477}; 551};
478 552
479static int __init rtc_init(void) 553static int __init rtc_init(void)
diff --git a/drivers/rtc/rtc-pcf8523.c b/drivers/rtc/rtc-pcf8523.c
new file mode 100644
index 000000000000..be05a645f99e
--- /dev/null
+++ b/drivers/rtc/rtc-pcf8523.c
@@ -0,0 +1,326 @@
1/*
2 * Copyright (C) 2012 Avionic Design GmbH
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/bcd.h>
10#include <linux/i2c.h>
11#include <linux/module.h>
12#include <linux/rtc.h>
13#include <linux/of.h>
14
15#define DRIVER_NAME "rtc-pcf8523"
16
17#define REG_CONTROL1 0x00
18#define REG_CONTROL1_CAP_SEL (1 << 7)
19#define REG_CONTROL1_STOP (1 << 5)
20
21#define REG_CONTROL3 0x02
22#define REG_CONTROL3_PM_BLD (1 << 7) /* battery low detection disabled */
23#define REG_CONTROL3_PM_VDD (1 << 6) /* switch-over disabled */
24#define REG_CONTROL3_PM_DSM (1 << 5) /* direct switching mode */
25#define REG_CONTROL3_PM_MASK 0xe0
26
27#define REG_SECONDS 0x03
28#define REG_SECONDS_OS (1 << 7)
29
30#define REG_MINUTES 0x04
31#define REG_HOURS 0x05
32#define REG_DAYS 0x06
33#define REG_WEEKDAYS 0x07
34#define REG_MONTHS 0x08
35#define REG_YEARS 0x09
36
37struct pcf8523 {
38 struct rtc_device *rtc;
39};
40
41static int pcf8523_read(struct i2c_client *client, u8 reg, u8 *valuep)
42{
43 struct i2c_msg msgs[2];
44 u8 value = 0;
45 int err;
46
47 msgs[0].addr = client->addr;
48 msgs[0].flags = 0;
49 msgs[0].len = sizeof(reg);
50 msgs[0].buf = &reg;
51
52 msgs[1].addr = client->addr;
53 msgs[1].flags = I2C_M_RD;
54 msgs[1].len = sizeof(value);
55 msgs[1].buf = &value;
56
57 err = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
58 if (err < 0)
59 return err;
60
61 *valuep = value;
62
63 return 0;
64}
65
66static int pcf8523_write(struct i2c_client *client, u8 reg, u8 value)
67{
68 u8 buffer[2] = { reg, value };
69 struct i2c_msg msg;
70 int err;
71
72 msg.addr = client->addr;
73 msg.flags = 0;
74 msg.len = sizeof(buffer);
75 msg.buf = buffer;
76
77 err = i2c_transfer(client->adapter, &msg, 1);
78 if (err < 0)
79 return err;
80
81 return 0;
82}
83
84static int pcf8523_select_capacitance(struct i2c_client *client, bool high)
85{
86 u8 value;
87 int err;
88
89 err = pcf8523_read(client, REG_CONTROL1, &value);
90 if (err < 0)
91 return err;
92
93 if (!high)
94 value &= ~REG_CONTROL1_CAP_SEL;
95 else
96 value |= REG_CONTROL1_CAP_SEL;
97
98 err = pcf8523_write(client, REG_CONTROL1, value);
99 if (err < 0)
100 return err;
101
102 return err;
103}
104
105static int pcf8523_set_pm(struct i2c_client *client, u8 pm)
106{
107 u8 value;
108 int err;
109
110 err = pcf8523_read(client, REG_CONTROL3, &value);
111 if (err < 0)
112 return err;
113
114 value = (value & ~REG_CONTROL3_PM_MASK) | pm;
115
116 err = pcf8523_write(client, REG_CONTROL3, value);
117 if (err < 0)
118 return err;
119
120 return 0;
121}
122
123static int pcf8523_stop_rtc(struct i2c_client *client)
124{
125 u8 value;
126 int err;
127
128 err = pcf8523_read(client, REG_CONTROL1, &value);
129 if (err < 0)
130 return err;
131
132 value |= REG_CONTROL1_STOP;
133
134 err = pcf8523_write(client, REG_CONTROL1, value);
135 if (err < 0)
136 return err;
137
138 return 0;
139}
140
141static int pcf8523_start_rtc(struct i2c_client *client)
142{
143 u8 value;
144 int err;
145
146 err = pcf8523_read(client, REG_CONTROL1, &value);
147 if (err < 0)
148 return err;
149
150 value &= ~REG_CONTROL1_STOP;
151
152 err = pcf8523_write(client, REG_CONTROL1, value);
153 if (err < 0)
154 return err;
155
156 return 0;
157}
158
159static int pcf8523_rtc_read_time(struct device *dev, struct rtc_time *tm)
160{
161 struct i2c_client *client = to_i2c_client(dev);
162 u8 start = REG_SECONDS, regs[7];
163 struct i2c_msg msgs[2];
164 int err;
165
166 msgs[0].addr = client->addr;
167 msgs[0].flags = 0;
168 msgs[0].len = 1;
169 msgs[0].buf = &start;
170
171 msgs[1].addr = client->addr;
172 msgs[1].flags = I2C_M_RD;
173 msgs[1].len = sizeof(regs);
174 msgs[1].buf = regs;
175
176 err = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
177 if (err < 0)
178 return err;
179
180 if (regs[0] & REG_SECONDS_OS) {
181 /*
182 * If the oscillator was stopped, try to clear the flag. Upon
183 * power-up the flag is always set, but if we cannot clear it
184 * the oscillator isn't running properly for some reason. The
185 * sensible thing therefore is to return an error, signalling
186 * that the clock cannot be assumed to be correct.
187 */
188
189 regs[0] &= ~REG_SECONDS_OS;
190
191 err = pcf8523_write(client, REG_SECONDS, regs[0]);
192 if (err < 0)
193 return err;
194
195 err = pcf8523_read(client, REG_SECONDS, &regs[0]);
196 if (err < 0)
197 return err;
198
199 if (regs[0] & REG_SECONDS_OS)
200 return -EAGAIN;
201 }
202
203 tm->tm_sec = bcd2bin(regs[0] & 0x7f);
204 tm->tm_min = bcd2bin(regs[1] & 0x7f);
205 tm->tm_hour = bcd2bin(regs[2] & 0x3f);
206 tm->tm_mday = bcd2bin(regs[3] & 0x3f);
207 tm->tm_wday = regs[4] & 0x7;
208 tm->tm_mon = bcd2bin(regs[5] & 0x1f);
209 tm->tm_year = bcd2bin(regs[6]) + 100;
210
211 return rtc_valid_tm(tm);
212}
213
214static int pcf8523_rtc_set_time(struct device *dev, struct rtc_time *tm)
215{
216 struct i2c_client *client = to_i2c_client(dev);
217 struct i2c_msg msg;
218 u8 regs[8];
219 int err;
220
221 err = pcf8523_stop_rtc(client);
222 if (err < 0)
223 return err;
224
225 regs[0] = REG_SECONDS;
226 regs[1] = bin2bcd(tm->tm_sec);
227 regs[2] = bin2bcd(tm->tm_min);
228 regs[3] = bin2bcd(tm->tm_hour);
229 regs[4] = bin2bcd(tm->tm_mday);
230 regs[5] = tm->tm_wday;
231 regs[6] = bin2bcd(tm->tm_mon);
232 regs[7] = bin2bcd(tm->tm_year - 100);
233
234 msg.addr = client->addr;
235 msg.flags = 0;
236 msg.len = sizeof(regs);
237 msg.buf = regs;
238
239 err = i2c_transfer(client->adapter, &msg, 1);
240 if (err < 0) {
241 /*
242 * If the time cannot be set, restart the RTC anyway. Note
243 * that errors are ignored if the RTC cannot be started so
244 * that we have a chance to propagate the original error.
245 */
246 pcf8523_start_rtc(client);
247 return err;
248 }
249
250 return pcf8523_start_rtc(client);
251}
252
253static const struct rtc_class_ops pcf8523_rtc_ops = {
254 .read_time = pcf8523_rtc_read_time,
255 .set_time = pcf8523_rtc_set_time,
256};
257
258static int pcf8523_probe(struct i2c_client *client,
259 const struct i2c_device_id *id)
260{
261 struct pcf8523 *pcf;
262 int err;
263
264 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
265 return -ENODEV;
266
267 pcf = devm_kzalloc(&client->dev, sizeof(*pcf), GFP_KERNEL);
268 if (!pcf)
269 return -ENOMEM;
270
271 err = pcf8523_select_capacitance(client, true);
272 if (err < 0)
273 return err;
274
275 err = pcf8523_set_pm(client, 0);
276 if (err < 0)
277 return err;
278
279 pcf->rtc = rtc_device_register(DRIVER_NAME, &client->dev,
280 &pcf8523_rtc_ops, THIS_MODULE);
281 if (IS_ERR(pcf->rtc))
282 return PTR_ERR(pcf->rtc);
283
284 i2c_set_clientdata(client, pcf);
285
286 return 0;
287}
288
289static int pcf8523_remove(struct i2c_client *client)
290{
291 struct pcf8523 *pcf = i2c_get_clientdata(client);
292
293 rtc_device_unregister(pcf->rtc);
294
295 return 0;
296}
297
298static const struct i2c_device_id pcf8523_id[] = {
299 { "pcf8523", 0 },
300 { }
301};
302MODULE_DEVICE_TABLE(i2c, pcf8523_id);
303
304#ifdef CONFIG_OF
305static const struct of_device_id pcf8523_of_match[] = {
306 { .compatible = "nxp,pcf8523" },
307 { }
308};
309MODULE_DEVICE_TABLE(of, pcf8523_of_match);
310#endif
311
312static struct i2c_driver pcf8523_driver = {
313 .driver = {
314 .name = DRIVER_NAME,
315 .owner = THIS_MODULE,
316 .of_match_table = of_match_ptr(pcf8523_of_match),
317 },
318 .probe = pcf8523_probe,
319 .remove = pcf8523_remove,
320 .id_table = pcf8523_id,
321};
322module_i2c_driver(pcf8523_driver);
323
324MODULE_AUTHOR("Thierry Reding <thierry.reding@avionic-design.de>");
325MODULE_DESCRIPTION("NXP PCF8523 RTC driver");
326MODULE_LICENSE("GPL v2");
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index a7a2a998fa91..4bd9414aee65 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -47,8 +47,6 @@ struct s3c_rtc_drv_data {
47/* I have yet to find an S3C implementation with more than one 47/* I have yet to find an S3C implementation with more than one
48 * of these rtc blocks in */ 48 * of these rtc blocks in */
49 49
50static struct resource *s3c_rtc_mem;
51
52static struct clk *rtc_clk; 50static struct clk *rtc_clk;
53static void __iomem *s3c_rtc_base; 51static void __iomem *s3c_rtc_base;
54static int s3c_rtc_alarmno = NO_IRQ; 52static int s3c_rtc_alarmno = NO_IRQ;
@@ -427,21 +425,13 @@ static int __devexit s3c_rtc_remove(struct platform_device *dev)
427{ 425{
428 struct rtc_device *rtc = platform_get_drvdata(dev); 426 struct rtc_device *rtc = platform_get_drvdata(dev);
429 427
430 free_irq(s3c_rtc_alarmno, rtc);
431 free_irq(s3c_rtc_tickno, rtc);
432
433 platform_set_drvdata(dev, NULL); 428 platform_set_drvdata(dev, NULL);
434 rtc_device_unregister(rtc); 429 rtc_device_unregister(rtc);
435 430
436 s3c_rtc_setaie(&dev->dev, 0); 431 s3c_rtc_setaie(&dev->dev, 0);
437 432
438 clk_put(rtc_clk);
439 rtc_clk = NULL; 433 rtc_clk = NULL;
440 434
441 iounmap(s3c_rtc_base);
442 release_resource(s3c_rtc_mem);
443 kfree(s3c_rtc_mem);
444
445 return 0; 435 return 0;
446} 436}
447 437
@@ -496,28 +486,18 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
496 return -ENOENT; 486 return -ENOENT;
497 } 487 }
498 488
499 s3c_rtc_mem = request_mem_region(res->start, resource_size(res), 489 s3c_rtc_base = devm_request_and_ioremap(&pdev->dev, res);
500 pdev->name);
501
502 if (s3c_rtc_mem == NULL) {
503 dev_err(&pdev->dev, "failed to reserve memory region\n");
504 ret = -ENOENT;
505 goto err_nores;
506 }
507
508 s3c_rtc_base = ioremap(res->start, resource_size(res));
509 if (s3c_rtc_base == NULL) { 490 if (s3c_rtc_base == NULL) {
510 dev_err(&pdev->dev, "failed ioremap()\n"); 491 dev_err(&pdev->dev, "failed to ioremap memory region\n");
511 ret = -EINVAL; 492 return -EINVAL;
512 goto err_nomap;
513 } 493 }
514 494
515 rtc_clk = clk_get(&pdev->dev, "rtc"); 495 rtc_clk = devm_clk_get(&pdev->dev, "rtc");
516 if (IS_ERR(rtc_clk)) { 496 if (IS_ERR(rtc_clk)) {
517 dev_err(&pdev->dev, "failed to find rtc clock source\n"); 497 dev_err(&pdev->dev, "failed to find rtc clock source\n");
518 ret = PTR_ERR(rtc_clk); 498 ret = PTR_ERR(rtc_clk);
519 rtc_clk = NULL; 499 rtc_clk = NULL;
520 goto err_clk; 500 return ret;
521 } 501 }
522 502
523 clk_enable(rtc_clk); 503 clk_enable(rtc_clk);
@@ -576,28 +556,24 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
576 556
577 s3c_rtc_setfreq(&pdev->dev, 1); 557 s3c_rtc_setfreq(&pdev->dev, 1);
578 558
579 ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq, 559 ret = devm_request_irq(&pdev->dev, s3c_rtc_alarmno, s3c_rtc_alarmirq,
580 0, "s3c2410-rtc alarm", rtc); 560 0, "s3c2410-rtc alarm", rtc);
581 if (ret) { 561 if (ret) {
582 dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); 562 dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret);
583 goto err_alarm_irq; 563 goto err_alarm_irq;
584 } 564 }
585 565
586 ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq, 566 ret = devm_request_irq(&pdev->dev, s3c_rtc_tickno, s3c_rtc_tickirq,
587 0, "s3c2410-rtc tick", rtc); 567 0, "s3c2410-rtc tick", rtc);
588 if (ret) { 568 if (ret) {
589 dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); 569 dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret);
590 free_irq(s3c_rtc_alarmno, rtc); 570 goto err_alarm_irq;
591 goto err_tick_irq;
592 } 571 }
593 572
594 clk_disable(rtc_clk); 573 clk_disable(rtc_clk);
595 574
596 return 0; 575 return 0;
597 576
598 err_tick_irq:
599 free_irq(s3c_rtc_alarmno, rtc);
600
601 err_alarm_irq: 577 err_alarm_irq:
602 platform_set_drvdata(pdev, NULL); 578 platform_set_drvdata(pdev, NULL);
603 rtc_device_unregister(rtc); 579 rtc_device_unregister(rtc);
@@ -605,15 +581,7 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
605 err_nortc: 581 err_nortc:
606 s3c_rtc_enable(pdev, 0); 582 s3c_rtc_enable(pdev, 0);
607 clk_disable(rtc_clk); 583 clk_disable(rtc_clk);
608 clk_put(rtc_clk);
609 584
610 err_clk:
611 iounmap(s3c_rtc_base);
612
613 err_nomap:
614 release_resource(s3c_rtc_mem);
615
616 err_nores:
617 return ret; 585 return ret;
618} 586}
619 587
@@ -695,8 +663,6 @@ static const struct of_device_id s3c_rtc_dt_match[] = {
695 {}, 663 {},
696}; 664};
697MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match); 665MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match);
698#else
699#define s3c_rtc_dt_match NULL
700#endif 666#endif
701 667
702static struct platform_device_id s3c_rtc_driver_ids[] = { 668static struct platform_device_id s3c_rtc_driver_ids[] = {
@@ -727,7 +693,7 @@ static struct platform_driver s3c_rtc_driver = {
727 .driver = { 693 .driver = {
728 .name = "s3c-rtc", 694 .name = "s3c-rtc",
729 .owner = THIS_MODULE, 695 .owner = THIS_MODULE,
730 .of_match_table = s3c_rtc_dt_match, 696 .of_match_table = of_match_ptr(s3c_rtc_dt_match),
731 }, 697 },
732}; 698};
733 699
diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c
index bb507d23f6ce..141fc945295f 100644
--- a/drivers/rtc/rtc-spear.c
+++ b/drivers/rtc/rtc-spear.c
@@ -363,35 +363,42 @@ static int __devinit spear_rtc_probe(struct platform_device *pdev)
363 dev_err(&pdev->dev, "no resource defined\n"); 363 dev_err(&pdev->dev, "no resource defined\n");
364 return -EBUSY; 364 return -EBUSY;
365 } 365 }
366 if (!request_mem_region(res->start, resource_size(res), pdev->name)) {
367 dev_err(&pdev->dev, "rtc region already claimed\n");
368 return -EBUSY;
369 }
370 366
371 config = kzalloc(sizeof(*config), GFP_KERNEL); 367 config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL);
372 if (!config) { 368 if (!config) {
373 dev_err(&pdev->dev, "out of memory\n"); 369 dev_err(&pdev->dev, "out of memory\n");
374 status = -ENOMEM; 370 return -ENOMEM;
375 goto err_release_region;
376 } 371 }
377 372
378 config->clk = clk_get(&pdev->dev, NULL); 373 /* alarm irqs */
379 if (IS_ERR(config->clk)) { 374 irq = platform_get_irq(pdev, 0);
380 status = PTR_ERR(config->clk); 375 if (irq < 0) {
381 goto err_kfree; 376 dev_err(&pdev->dev, "no update irq?\n");
377 return irq;
382 } 378 }
383 379
384 status = clk_enable(config->clk); 380 status = devm_request_irq(&pdev->dev, irq, spear_rtc_irq, 0, pdev->name,
385 if (status < 0) 381 config);
386 goto err_clk_put; 382 if (status) {
383 dev_err(&pdev->dev, "Alarm interrupt IRQ%d already claimed\n",
384 irq);
385 return status;
386 }
387 387
388 config->ioaddr = ioremap(res->start, resource_size(res)); 388 config->ioaddr = devm_request_and_ioremap(&pdev->dev, res);
389 if (!config->ioaddr) { 389 if (!config->ioaddr) {
390 dev_err(&pdev->dev, "ioremap fail\n"); 390 dev_err(&pdev->dev, "request-ioremap fail\n");
391 status = -ENOMEM; 391 return -ENOMEM;
392 goto err_disable_clock;
393 } 392 }
394 393
394 config->clk = devm_clk_get(&pdev->dev, NULL);
395 if (IS_ERR(config->clk))
396 return PTR_ERR(config->clk);
397
398 status = clk_prepare_enable(config->clk);
399 if (status < 0)
400 return status;
401
395 spin_lock_init(&config->lock); 402 spin_lock_init(&config->lock);
396 platform_set_drvdata(pdev, config); 403 platform_set_drvdata(pdev, config);
397 404
@@ -401,42 +408,19 @@ static int __devinit spear_rtc_probe(struct platform_device *pdev)
401 dev_err(&pdev->dev, "can't register RTC device, err %ld\n", 408 dev_err(&pdev->dev, "can't register RTC device, err %ld\n",
402 PTR_ERR(config->rtc)); 409 PTR_ERR(config->rtc));
403 status = PTR_ERR(config->rtc); 410 status = PTR_ERR(config->rtc);
404 goto err_iounmap; 411 goto err_disable_clock;
405 }
406
407 /* alarm irqs */
408 irq = platform_get_irq(pdev, 0);
409 if (irq < 0) {
410 dev_err(&pdev->dev, "no update irq?\n");
411 status = irq;
412 goto err_clear_platdata;
413 } 412 }
414 413
415 status = request_irq(irq, spear_rtc_irq, 0, pdev->name, config); 414 config->rtc->uie_unsupported = 1;
416 if (status) {
417 dev_err(&pdev->dev, "Alarm interrupt IRQ%d already \
418 claimed\n", irq);
419 goto err_clear_platdata;
420 }
421 415
422 if (!device_can_wakeup(&pdev->dev)) 416 if (!device_can_wakeup(&pdev->dev))
423 device_init_wakeup(&pdev->dev, 1); 417 device_init_wakeup(&pdev->dev, 1);
424 418
425 return 0; 419 return 0;
426 420
427err_clear_platdata:
428 platform_set_drvdata(pdev, NULL);
429 rtc_device_unregister(config->rtc);
430err_iounmap:
431 iounmap(config->ioaddr);
432err_disable_clock: 421err_disable_clock:
433 clk_disable(config->clk); 422 platform_set_drvdata(pdev, NULL);
434err_clk_put: 423 clk_disable_unprepare(config->clk);
435 clk_put(config->clk);
436err_kfree:
437 kfree(config);
438err_release_region:
439 release_mem_region(res->start, resource_size(res));
440 424
441 return status; 425 return status;
442} 426}
@@ -444,24 +428,11 @@ err_release_region:
444static int __devexit spear_rtc_remove(struct platform_device *pdev) 428static int __devexit spear_rtc_remove(struct platform_device *pdev)
445{ 429{
446 struct spear_rtc_config *config = platform_get_drvdata(pdev); 430 struct spear_rtc_config *config = platform_get_drvdata(pdev);
447 int irq;
448 struct resource *res;
449 431
450 /* leave rtc running, but disable irqs */ 432 rtc_device_unregister(config->rtc);
451 spear_rtc_disable_interrupt(config); 433 spear_rtc_disable_interrupt(config);
434 clk_disable_unprepare(config->clk);
452 device_init_wakeup(&pdev->dev, 0); 435 device_init_wakeup(&pdev->dev, 0);
453 irq = platform_get_irq(pdev, 0);
454 if (irq)
455 free_irq(irq, pdev);
456 clk_disable(config->clk);
457 clk_put(config->clk);
458 iounmap(config->ioaddr);
459 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
460 if (res)
461 release_mem_region(res->start, resource_size(res));
462 platform_set_drvdata(pdev, NULL);
463 rtc_device_unregister(config->rtc);
464 kfree(config);
465 436
466 return 0; 437 return 0;
467} 438}
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
index 7e96254bd365..974b9ae252ab 100644
--- a/drivers/rtc/rtc-test.c
+++ b/drivers/rtc/rtc-test.c
@@ -152,24 +152,24 @@ static int __init test_init(void)
152 152
153 if ((test1 = platform_device_alloc("rtc-test", 1)) == NULL) { 153 if ((test1 = platform_device_alloc("rtc-test", 1)) == NULL) {
154 err = -ENOMEM; 154 err = -ENOMEM;
155 goto exit_free_test0; 155 goto exit_put_test0;
156 } 156 }
157 157
158 if ((err = platform_device_add(test0))) 158 if ((err = platform_device_add(test0)))
159 goto exit_free_test1; 159 goto exit_put_test1;
160 160
161 if ((err = platform_device_add(test1))) 161 if ((err = platform_device_add(test1)))
162 goto exit_device_unregister; 162 goto exit_del_test0;
163 163
164 return 0; 164 return 0;
165 165
166exit_device_unregister: 166exit_del_test0:
167 platform_device_unregister(test0); 167 platform_device_del(test0);
168 168
169exit_free_test1: 169exit_put_test1:
170 platform_device_put(test1); 170 platform_device_put(test1);
171 171
172exit_free_test0: 172exit_put_test0:
173 platform_device_put(test0); 173 platform_device_put(test0);
174 174
175exit_driver_unregister: 175exit_driver_unregister:
diff --git a/drivers/rtc/rtc-tps65910.c b/drivers/rtc/rtc-tps65910.c
index 073108dcf9e7..22eb4ebfa1a6 100644
--- a/drivers/rtc/rtc-tps65910.c
+++ b/drivers/rtc/rtc-tps65910.c
@@ -247,6 +247,13 @@ static int __devinit tps65910_rtc_probe(struct platform_device *pdev)
247 return ret; 247 return ret;
248 248
249 dev_dbg(&pdev->dev, "Enabling rtc-tps65910.\n"); 249 dev_dbg(&pdev->dev, "Enabling rtc-tps65910.\n");
250
251 /* Enable RTC digital power domain */
252 ret = regmap_update_bits(tps65910->regmap, TPS65910_DEVCTRL,
253 DEVCTRL_RTC_PWDN_MASK, 0 << DEVCTRL_RTC_PWDN_SHIFT);
254 if (ret < 0)
255 return ret;
256
250 rtc_reg = TPS65910_RTC_CTRL_STOP_RTC; 257 rtc_reg = TPS65910_RTC_CTRL_STOP_RTC;
251 ret = regmap_write(tps65910->regmap, TPS65910_RTC_CTRL, rtc_reg); 258 ret = regmap_write(tps65910->regmap, TPS65910_RTC_CTRL, rtc_reg);
252 if (ret < 0) 259 if (ret < 0)
@@ -261,7 +268,7 @@ static int __devinit tps65910_rtc_probe(struct platform_device *pdev)
261 268
262 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, 269 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
263 tps65910_rtc_interrupt, IRQF_TRIGGER_LOW, 270 tps65910_rtc_interrupt, IRQF_TRIGGER_LOW,
264 "rtc-tps65910", &pdev->dev); 271 dev_name(&pdev->dev), &pdev->dev);
265 if (ret < 0) { 272 if (ret < 0) {
266 dev_err(&pdev->dev, "IRQ is not free.\n"); 273 dev_err(&pdev->dev, "IRQ is not free.\n");
267 return ret; 274 return ret;
diff --git a/drivers/rtc/rtc-vt8500.c b/drivers/rtc/rtc-vt8500.c
index 07bf19364a74..14e2d8cfcc83 100644
--- a/drivers/rtc/rtc-vt8500.c
+++ b/drivers/rtc/rtc-vt8500.c
@@ -210,7 +210,8 @@ static int __devinit vt8500_rtc_probe(struct platform_device *pdev)
210 struct vt8500_rtc *vt8500_rtc; 210 struct vt8500_rtc *vt8500_rtc;
211 int ret; 211 int ret;
212 212
213 vt8500_rtc = kzalloc(sizeof(struct vt8500_rtc), GFP_KERNEL); 213 vt8500_rtc = devm_kzalloc(&pdev->dev,
214 sizeof(struct vt8500_rtc), GFP_KERNEL);
214 if (!vt8500_rtc) 215 if (!vt8500_rtc)
215 return -ENOMEM; 216 return -ENOMEM;
216 217
@@ -220,15 +221,13 @@ static int __devinit vt8500_rtc_probe(struct platform_device *pdev)
220 vt8500_rtc->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 221 vt8500_rtc->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
221 if (!vt8500_rtc->res) { 222 if (!vt8500_rtc->res) {
222 dev_err(&pdev->dev, "No I/O memory resource defined\n"); 223 dev_err(&pdev->dev, "No I/O memory resource defined\n");
223 ret = -ENXIO; 224 return -ENXIO;
224 goto err_free;
225 } 225 }
226 226
227 vt8500_rtc->irq_alarm = platform_get_irq(pdev, 0); 227 vt8500_rtc->irq_alarm = platform_get_irq(pdev, 0);
228 if (vt8500_rtc->irq_alarm < 0) { 228 if (vt8500_rtc->irq_alarm < 0) {
229 dev_err(&pdev->dev, "No alarm IRQ resource defined\n"); 229 dev_err(&pdev->dev, "No alarm IRQ resource defined\n");
230 ret = -ENXIO; 230 return -ENXIO;
231 goto err_free;
232 } 231 }
233 232
234 vt8500_rtc->res = request_mem_region(vt8500_rtc->res->start, 233 vt8500_rtc->res = request_mem_region(vt8500_rtc->res->start,
@@ -236,8 +235,7 @@ static int __devinit vt8500_rtc_probe(struct platform_device *pdev)
236 "vt8500-rtc"); 235 "vt8500-rtc");
237 if (vt8500_rtc->res == NULL) { 236 if (vt8500_rtc->res == NULL) {
238 dev_err(&pdev->dev, "failed to request I/O memory\n"); 237 dev_err(&pdev->dev, "failed to request I/O memory\n");
239 ret = -EBUSY; 238 return -EBUSY;
240 goto err_free;
241 } 239 }
242 240
243 vt8500_rtc->regbase = ioremap(vt8500_rtc->res->start, 241 vt8500_rtc->regbase = ioremap(vt8500_rtc->res->start,
@@ -278,8 +276,6 @@ err_unmap:
278err_release: 276err_release:
279 release_mem_region(vt8500_rtc->res->start, 277 release_mem_region(vt8500_rtc->res->start,
280 resource_size(vt8500_rtc->res)); 278 resource_size(vt8500_rtc->res));
281err_free:
282 kfree(vt8500_rtc);
283 return ret; 279 return ret;
284} 280}
285 281
@@ -297,7 +293,6 @@ static int __devexit vt8500_rtc_remove(struct platform_device *pdev)
297 release_mem_region(vt8500_rtc->res->start, 293 release_mem_region(vt8500_rtc->res->start,
298 resource_size(vt8500_rtc->res)); 294 resource_size(vt8500_rtc->res));
299 295
300 kfree(vt8500_rtc);
301 platform_set_drvdata(pdev, NULL); 296 platform_set_drvdata(pdev, NULL);
302 297
303 return 0; 298 return 0;
diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index 2ebe03a4b51d..4a909d7cfde1 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -2144,7 +2144,7 @@ static void fcoe_ctlr_vn_restart(struct fcoe_ctlr *fip)
2144 */ 2144 */
2145 port_id = fip->port_id; 2145 port_id = fip->port_id;
2146 if (fip->probe_tries) 2146 if (fip->probe_tries)
2147 port_id = prandom32(&fip->rnd_state) & 0xffff; 2147 port_id = prandom_u32_state(&fip->rnd_state) & 0xffff;
2148 else if (!port_id) 2148 else if (!port_id)
2149 port_id = fip->lp->wwpn & 0xffff; 2149 port_id = fip->lp->wwpn & 0xffff;
2150 if (!port_id || port_id == 0xffff) 2150 if (!port_id || port_id == 0xffff)
@@ -2169,7 +2169,7 @@ static void fcoe_ctlr_vn_restart(struct fcoe_ctlr *fip)
2169static void fcoe_ctlr_vn_start(struct fcoe_ctlr *fip) 2169static void fcoe_ctlr_vn_start(struct fcoe_ctlr *fip)
2170{ 2170{
2171 fip->probe_tries = 0; 2171 fip->probe_tries = 0;
2172 prandom32_seed(&fip->rnd_state, fip->lp->wwpn); 2172 prandom_seed_state(&fip->rnd_state, fip->lp->wwpn);
2173 fcoe_ctlr_vn_restart(fip); 2173 fcoe_ctlr_vn_restart(fip);
2174} 2174}
2175 2175
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 57cc9c6eaa9f..f1c6c5470b92 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -251,7 +251,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)
251 /* best case is 32bit-aligned source address */ 251 /* best case is 32bit-aligned source address */
252 if ((0x02 & (unsigned long) src) == 0) { 252 if ((0x02 & (unsigned long) src) == 0) {
253 if (len >= 4) { 253 if (len >= 4) {
254 writesl(fifo, src + index, len >> 2); 254 iowrite32_rep(fifo, src + index, len >> 2);
255 index += len & ~0x03; 255 index += len & ~0x03;
256 } 256 }
257 if (len & 0x02) { 257 if (len & 0x02) {
@@ -260,7 +260,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)
260 } 260 }
261 } else { 261 } else {
262 if (len >= 2) { 262 if (len >= 2) {
263 writesw(fifo, src + index, len >> 1); 263 iowrite16_rep(fifo, src + index, len >> 1);
264 index += len & ~0x01; 264 index += len & ~0x01;
265 } 265 }
266 } 266 }
@@ -268,7 +268,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)
268 musb_writeb(fifo, 0, src[index]); 268 musb_writeb(fifo, 0, src[index]);
269 } else { 269 } else {
270 /* byte aligned */ 270 /* byte aligned */
271 writesb(fifo, src, len); 271 iowrite8_rep(fifo, src, len);
272 } 272 }
273} 273}
274 274
@@ -294,7 +294,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
294 /* best case is 32bit-aligned destination address */ 294 /* best case is 32bit-aligned destination address */
295 if ((0x02 & (unsigned long) dst) == 0) { 295 if ((0x02 & (unsigned long) dst) == 0) {
296 if (len >= 4) { 296 if (len >= 4) {
297 readsl(fifo, dst, len >> 2); 297 ioread32_rep(fifo, dst, len >> 2);
298 index = len & ~0x03; 298 index = len & ~0x03;
299 } 299 }
300 if (len & 0x02) { 300 if (len & 0x02) {
@@ -303,7 +303,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
303 } 303 }
304 } else { 304 } else {
305 if (len >= 2) { 305 if (len >= 2) {
306 readsw(fifo, dst, len >> 1); 306 ioread16_rep(fifo, dst, len >> 1);
307 index = len & ~0x01; 307 index = len & ~0x01;
308 } 308 }
309 } 309 }
@@ -311,7 +311,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
311 dst[index] = musb_readb(fifo, 0); 311 dst[index] = musb_readb(fifo, 0);
312 } else { 312 } else {
313 /* byte aligned */ 313 /* byte aligned */
314 readsb(fifo, dst, len); 314 ioread8_rep(fifo, dst, len);
315 } 315 }
316} 316}
317#endif 317#endif
diff --git a/drivers/usb/musb/musb_io.h b/drivers/usb/musb/musb_io.h
index 565ad1617832..eebeed78edd6 100644
--- a/drivers/usb/musb/musb_io.h
+++ b/drivers/usb/musb/musb_io.h
@@ -37,27 +37,6 @@
37 37
38#include <linux/io.h> 38#include <linux/io.h>
39 39
40#if !defined(CONFIG_ARM) && !defined(CONFIG_SUPERH) \
41 && !defined(CONFIG_AVR32) && !defined(CONFIG_PPC32) \
42 && !defined(CONFIG_PPC64) && !defined(CONFIG_BLACKFIN) \
43 && !defined(CONFIG_MIPS) && !defined(CONFIG_M68K) \
44 && !defined(CONFIG_XTENSA)
45static inline void readsl(const void __iomem *addr, void *buf, int len)
46 { insl((unsigned long)addr, buf, len); }
47static inline void readsw(const void __iomem *addr, void *buf, int len)
48 { insw((unsigned long)addr, buf, len); }
49static inline void readsb(const void __iomem *addr, void *buf, int len)
50 { insb((unsigned long)addr, buf, len); }
51
52static inline void writesl(const void __iomem *addr, const void *buf, int len)
53 { outsl((unsigned long)addr, buf, len); }
54static inline void writesw(const void __iomem *addr, const void *buf, int len)
55 { outsw((unsigned long)addr, buf, len); }
56static inline void writesb(const void __iomem *addr, const void *buf, int len)
57 { outsb((unsigned long)addr, buf, len); }
58
59#endif
60
61#ifndef CONFIG_BLACKFIN 40#ifndef CONFIG_BLACKFIN
62 41
63/* NOTE: these offsets are all in bytes */ 42/* NOTE: these offsets are all in bytes */
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 8bde6fc5eb75..3969813c217d 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -22,6 +22,7 @@
22#include <linux/prefetch.h> 22#include <linux/prefetch.h>
23#include <linux/usb.h> 23#include <linux/usb.h>
24#include <linux/irq.h> 24#include <linux/irq.h>
25#include <linux/io.h>
25#include <linux/platform_device.h> 26#include <linux/platform_device.h>
26#include <linux/dma-mapping.h> 27#include <linux/dma-mapping.h>
27#include <linux/usb/nop-usb-xceiv.h> 28#include <linux/usb/nop-usb-xceiv.h>
@@ -198,7 +199,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *buf)
198 /* Best case is 32bit-aligned destination address */ 199 /* Best case is 32bit-aligned destination address */
199 if ((0x02 & (unsigned long) buf) == 0) { 200 if ((0x02 & (unsigned long) buf) == 0) {
200 if (len >= 4) { 201 if (len >= 4) {
201 writesl(fifo, buf, len >> 2); 202 iowrite32_rep(fifo, buf, len >> 2);
202 buf += (len & ~0x03); 203 buf += (len & ~0x03);
203 len &= 0x03; 204 len &= 0x03;
204 } 205 }
@@ -245,7 +246,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *buf)
245 /* Best case is 32bit-aligned destination address */ 246 /* Best case is 32bit-aligned destination address */
246 if ((0x02 & (unsigned long) buf) == 0) { 247 if ((0x02 & (unsigned long) buf) == 0) {
247 if (len >= 4) { 248 if (len >= 4) {
248 readsl(fifo, buf, len >> 2); 249 ioread32_rep(fifo, buf, len >> 2);
249 buf += (len & ~0x03); 250 buf += (len & ~0x03);
250 len &= 0x03; 251 len &= 0x03;
251 } 252 }
diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c
index b7ec34c57f46..c072ed9aea36 100644
--- a/drivers/video/backlight/88pm860x_bl.c
+++ b/drivers/video/backlight/88pm860x_bl.c
@@ -117,8 +117,8 @@ static int pm860x_backlight_set(struct backlight_device *bl, int brightness)
117 data->current_brightness = value; 117 data->current_brightness = value;
118 return 0; 118 return 0;
119out: 119out:
120 dev_dbg(chip->dev, "set brightness %d failure with return " 120 dev_dbg(chip->dev, "set brightness %d failure with return value: %d\n",
121 "value:%d\n", value, ret); 121 value, ret);
122 return ret; 122 return ret;
123} 123}
124 124
@@ -208,22 +208,19 @@ static int pm860x_backlight_probe(struct platform_device *pdev)
208 res = platform_get_resource_byname(pdev, IORESOURCE_REG, "duty cycle"); 208 res = platform_get_resource_byname(pdev, IORESOURCE_REG, "duty cycle");
209 if (!res) { 209 if (!res) {
210 dev_err(&pdev->dev, "No REG resource for duty cycle\n"); 210 dev_err(&pdev->dev, "No REG resource for duty cycle\n");
211 ret = -ENXIO; 211 return -ENXIO;
212 goto out;
213 } 212 }
214 data->reg_duty_cycle = res->start; 213 data->reg_duty_cycle = res->start;
215 res = platform_get_resource_byname(pdev, IORESOURCE_REG, "always on"); 214 res = platform_get_resource_byname(pdev, IORESOURCE_REG, "always on");
216 if (!res) { 215 if (!res) {
217 dev_err(&pdev->dev, "No REG resorce for always on\n"); 216 dev_err(&pdev->dev, "No REG resorce for always on\n");
218 ret = -ENXIO; 217 return -ENXIO;
219 goto out;
220 } 218 }
221 data->reg_always_on = res->start; 219 data->reg_always_on = res->start;
222 res = platform_get_resource_byname(pdev, IORESOURCE_REG, "current"); 220 res = platform_get_resource_byname(pdev, IORESOURCE_REG, "current");
223 if (!res) { 221 if (!res) {
224 dev_err(&pdev->dev, "No REG resource for current\n"); 222 dev_err(&pdev->dev, "No REG resource for current\n");
225 ret = -ENXIO; 223 return -ENXIO;
226 goto out;
227 } 224 }
228 data->reg_current = res->start; 225 data->reg_current = res->start;
229 226
@@ -231,8 +228,7 @@ static int pm860x_backlight_probe(struct platform_device *pdev)
231 sprintf(name, "backlight-%d", pdev->id); 228 sprintf(name, "backlight-%d", pdev->id);
232 data->port = pdev->id; 229 data->port = pdev->id;
233 data->chip = chip; 230 data->chip = chip;
234 data->i2c = (chip->id == CHIP_PM8606) ? chip->client \ 231 data->i2c = (chip->id == CHIP_PM8606) ? chip->client : chip->companion;
235 : chip->companion;
236 data->current_brightness = MAX_BRIGHTNESS; 232 data->current_brightness = MAX_BRIGHTNESS;
237 if (pm860x_backlight_dt_init(pdev, data, name)) { 233 if (pm860x_backlight_dt_init(pdev, data, name)) {
238 if (pdata) { 234 if (pdata) {
@@ -263,8 +259,6 @@ static int pm860x_backlight_probe(struct platform_device *pdev)
263 return 0; 259 return 0;
264out_brt: 260out_brt:
265 backlight_device_unregister(bl); 261 backlight_device_unregister(bl);
266out:
267 devm_kfree(&pdev->dev, data);
268 return ret; 262 return ret;
269} 263}
270 264
diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c
index df1cbb7ef6ca..de5e5e74e2a7 100644
--- a/drivers/video/backlight/atmel-pwm-bl.c
+++ b/drivers/video/backlight/atmel-pwm-bl.c
@@ -106,10 +106,9 @@ static int atmel_pwm_bl_init_pwm(struct atmel_pwm_bl *pwmbl)
106 pwm_channel_writel(&pwmbl->pwmc, PWM_CPRD, 106 pwm_channel_writel(&pwmbl->pwmc, PWM_CPRD,
107 pwmbl->pdata->pwm_compare_max); 107 pwmbl->pdata->pwm_compare_max);
108 108
109 dev_info(&pwmbl->pdev->dev, "Atmel PWM backlight driver " 109 dev_info(&pwmbl->pdev->dev, "Atmel PWM backlight driver (%lu Hz)\n",
110 "(%lu Hz)\n", pwmbl->pwmc.mck / 110 pwmbl->pwmc.mck / pwmbl->pdata->pwm_compare_max /
111 pwmbl->pdata->pwm_compare_max / 111 (1 << prescale));
112 (1 << prescale));
113 112
114 return pwm_channel_enable(&pwmbl->pwmc); 113 return pwm_channel_enable(&pwmbl->pwmc);
115} 114}
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 297db2fa91f5..345f6660d4b3 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -370,6 +370,35 @@ void backlight_device_unregister(struct backlight_device *bd)
370} 370}
371EXPORT_SYMBOL(backlight_device_unregister); 371EXPORT_SYMBOL(backlight_device_unregister);
372 372
373#ifdef CONFIG_OF
374static int of_parent_match(struct device *dev, void *data)
375{
376 return dev->parent && dev->parent->of_node == data;
377}
378
379/**
380 * of_find_backlight_by_node() - find backlight device by device-tree node
381 * @node: device-tree node of the backlight device
382 *
383 * Returns a pointer to the backlight device corresponding to the given DT
384 * node or NULL if no such backlight device exists or if the device hasn't
385 * been probed yet.
386 *
387 * This function obtains a reference on the backlight device and it is the
388 * caller's responsibility to drop the reference by calling put_device() on
389 * the backlight device's .dev field.
390 */
391struct backlight_device *of_find_backlight_by_node(struct device_node *node)
392{
393 struct device *dev;
394
395 dev = class_find_device(backlight_class, NULL, node, of_parent_match);
396
397 return dev ? to_backlight_device(dev) : NULL;
398}
399EXPORT_SYMBOL(of_find_backlight_by_node);
400#endif
401
373static void __exit backlight_class_exit(void) 402static void __exit backlight_class_exit(void)
374{ 403{
375 class_destroy(backlight_class); 404 class_destroy(backlight_class);
diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c
index eaaebf21993e..e323fcbe884e 100644
--- a/drivers/video/backlight/corgi_lcd.c
+++ b/drivers/video/backlight/corgi_lcd.c
@@ -6,8 +6,8 @@
6 * Based on Sharp's 2.4 Backlight Driver 6 * Based on Sharp's 2.4 Backlight Driver
7 * 7 *
8 * Copyright (c) 2008 Marvell International Ltd. 8 * Copyright (c) 2008 Marvell International Ltd.
9 * Converted to SPI device based LCD/Backlight device driver 9 * Converted to SPI device based LCD/Backlight device driver
10 * by Eric Miao <eric.miao@marvell.com> 10 * by Eric Miao <eric.miao@marvell.com>
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as 13 * it under the terms of the GNU General Public License version 2 as
@@ -192,7 +192,7 @@ static void lcdtg_set_phadadj(struct corgi_lcd *lcd, int mode)
192{ 192{
193 int adj; 193 int adj;
194 194
195 switch(mode) { 195 switch (mode) {
196 case CORGI_LCD_MODE_VGA: 196 case CORGI_LCD_MODE_VGA:
197 /* Setting for VGA */ 197 /* Setting for VGA */
198 adj = sharpsl_param.phadadj; 198 adj = sharpsl_param.phadadj;
@@ -409,10 +409,10 @@ static int corgi_bl_set_intensity(struct corgi_lcd *lcd, int intensity)
409 cont = !!(intensity & 0x20) ^ lcd->gpio_backlight_cont_inverted; 409 cont = !!(intensity & 0x20) ^ lcd->gpio_backlight_cont_inverted;
410 410
411 if (gpio_is_valid(lcd->gpio_backlight_cont)) 411 if (gpio_is_valid(lcd->gpio_backlight_cont))
412 gpio_set_value(lcd->gpio_backlight_cont, cont); 412 gpio_set_value_cansleep(lcd->gpio_backlight_cont, cont);
413 413
414 if (gpio_is_valid(lcd->gpio_backlight_on)) 414 if (gpio_is_valid(lcd->gpio_backlight_on))
415 gpio_set_value(lcd->gpio_backlight_on, intensity); 415 gpio_set_value_cansleep(lcd->gpio_backlight_on, intensity);
416 416
417 if (lcd->kick_battery) 417 if (lcd->kick_battery)
418 lcd->kick_battery(); 418 lcd->kick_battery();
@@ -495,8 +495,9 @@ static int setup_gpio_backlight(struct corgi_lcd *lcd,
495 err = devm_gpio_request(&spi->dev, pdata->gpio_backlight_on, 495 err = devm_gpio_request(&spi->dev, pdata->gpio_backlight_on,
496 "BL_ON"); 496 "BL_ON");
497 if (err) { 497 if (err) {
498 dev_err(&spi->dev, "failed to request GPIO%d for " 498 dev_err(&spi->dev,
499 "backlight_on\n", pdata->gpio_backlight_on); 499 "failed to request GPIO%d for backlight_on\n",
500 pdata->gpio_backlight_on);
500 return err; 501 return err;
501 } 502 }
502 503
@@ -508,8 +509,9 @@ static int setup_gpio_backlight(struct corgi_lcd *lcd,
508 err = devm_gpio_request(&spi->dev, pdata->gpio_backlight_cont, 509 err = devm_gpio_request(&spi->dev, pdata->gpio_backlight_cont,
509 "BL_CONT"); 510 "BL_CONT");
510 if (err) { 511 if (err) {
511 dev_err(&spi->dev, "failed to request GPIO%d for " 512 dev_err(&spi->dev,
512 "backlight_cont\n", pdata->gpio_backlight_cont); 513 "failed to request GPIO%d for backlight_cont\n",
514 pdata->gpio_backlight_cont);
513 return err; 515 return err;
514 } 516 }
515 517
diff --git a/drivers/video/backlight/da903x_bl.c b/drivers/video/backlight/da903x_bl.c
index 573c7ece0fde..8179cef0730f 100644
--- a/drivers/video/backlight/da903x_bl.c
+++ b/drivers/video/backlight/da903x_bl.c
@@ -2,10 +2,10 @@
2 * Backlight driver for Dialog Semiconductor DA9030/DA9034 2 * Backlight driver for Dialog Semiconductor DA9030/DA9034
3 * 3 *
4 * Copyright (C) 2008 Compulab, Ltd. 4 * Copyright (C) 2008 Compulab, Ltd.
5 * Mike Rapoport <mike@compulab.co.il> 5 * Mike Rapoport <mike@compulab.co.il>
6 * 6 *
7 * Copyright (C) 2006-2008 Marvell International Ltd. 7 * Copyright (C) 2006-2008 Marvell International Ltd.
8 * Eric Miao <eric.miao@marvell.com> 8 * Eric Miao <eric.miao@marvell.com>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as 11 * it under the terms of the GNU General Public License version 2 as
@@ -164,15 +164,14 @@ static int da903x_backlight_remove(struct platform_device *pdev)
164#ifdef CONFIG_PM 164#ifdef CONFIG_PM
165static int da903x_backlight_suspend(struct device *dev) 165static int da903x_backlight_suspend(struct device *dev)
166{ 166{
167 struct platform_device *pdev = to_platform_device(dev); 167 struct backlight_device *bl = dev_get_drvdata(dev);
168 struct backlight_device *bl = platform_get_drvdata(pdev); 168
169 return da903x_backlight_set(bl, 0); 169 return da903x_backlight_set(bl, 0);
170} 170}
171 171
172static int da903x_backlight_resume(struct device *dev) 172static int da903x_backlight_resume(struct device *dev)
173{ 173{
174 struct platform_device *pdev = to_platform_device(dev); 174 struct backlight_device *bl = dev_get_drvdata(dev);
175 struct backlight_device *bl = platform_get_drvdata(pdev);
176 175
177 backlight_update_status(bl); 176 backlight_update_status(bl);
178 return 0; 177 return 0;
@@ -199,7 +198,7 @@ static struct platform_driver da903x_backlight_driver = {
199module_platform_driver(da903x_backlight_driver); 198module_platform_driver(da903x_backlight_driver);
200 199
201MODULE_DESCRIPTION("Backlight Driver for Dialog Semiconductor DA9030/DA9034"); 200MODULE_DESCRIPTION("Backlight Driver for Dialog Semiconductor DA9030/DA9034");
202MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>" 201MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>");
203 "Mike Rapoport <mike@compulab.co.il>"); 202MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>");
204MODULE_LICENSE("GPL"); 203MODULE_LICENSE("GPL");
205MODULE_ALIAS("platform:da903x-backlight"); 204MODULE_ALIAS("platform:da903x-backlight");
diff --git a/drivers/video/backlight/da9052_bl.c b/drivers/video/backlight/da9052_bl.c
index ac196181fe45..842da5a3ac4f 100644
--- a/drivers/video/backlight/da9052_bl.c
+++ b/drivers/video/backlight/da9052_bl.c
@@ -34,7 +34,7 @@ enum {
34 DA9052_TYPE_WLED3, 34 DA9052_TYPE_WLED3,
35}; 35};
36 36
37static unsigned char wled_bank[] = { 37static const unsigned char wled_bank[] = {
38 DA9052_LED1_CONF_REG, 38 DA9052_LED1_CONF_REG,
39 DA9052_LED2_CONF_REG, 39 DA9052_LED2_CONF_REG,
40 DA9052_LED3_CONF_REG, 40 DA9052_LED3_CONF_REG,
diff --git a/drivers/video/backlight/generic_bl.c b/drivers/video/backlight/generic_bl.c
index 8c660fcd250d..0ae155be9c89 100644
--- a/drivers/video/backlight/generic_bl.c
+++ b/drivers/video/backlight/generic_bl.c
@@ -97,8 +97,8 @@ static int genericbl_probe(struct platform_device *pdev)
97 props.max_brightness = machinfo->max_intensity; 97 props.max_brightness = machinfo->max_intensity;
98 bd = backlight_device_register(name, &pdev->dev, NULL, &genericbl_ops, 98 bd = backlight_device_register(name, &pdev->dev, NULL, &genericbl_ops,
99 &props); 99 &props);
100 if (IS_ERR (bd)) 100 if (IS_ERR(bd))
101 return PTR_ERR (bd); 101 return PTR_ERR(bd);
102 102
103 platform_set_drvdata(pdev, bd); 103 platform_set_drvdata(pdev, bd);
104 104
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
index c99966342448..5cefd73526f8 100644
--- a/drivers/video/backlight/hp680_bl.c
+++ b/drivers/video/backlight/hp680_bl.c
@@ -26,7 +26,7 @@
26#define HP680_DEFAULT_INTENSITY 10 26#define HP680_DEFAULT_INTENSITY 10
27 27
28static int hp680bl_suspended; 28static int hp680bl_suspended;
29static int current_intensity = 0; 29static int current_intensity;
30static DEFINE_SPINLOCK(bl_lock); 30static DEFINE_SPINLOCK(bl_lock);
31 31
32static void hp680bl_send_intensity(struct backlight_device *bd) 32static void hp680bl_send_intensity(struct backlight_device *bd)
@@ -168,7 +168,7 @@ static int __init hp680bl_init(void)
168static void __exit hp680bl_exit(void) 168static void __exit hp680bl_exit(void)
169{ 169{
170 platform_device_unregister(hp680bl_device); 170 platform_device_unregister(hp680bl_device);
171 platform_driver_unregister(&hp680bl_driver); 171 platform_driver_unregister(&hp680bl_driver);
172} 172}
173 173
174module_init(hp680bl_init); 174module_init(hp680bl_init);
diff --git a/drivers/video/backlight/ili9320.c b/drivers/video/backlight/ili9320.c
index 66cc313185ad..1235bf9defc4 100644
--- a/drivers/video/backlight/ili9320.c
+++ b/drivers/video/backlight/ili9320.c
@@ -45,7 +45,7 @@ static inline int ili9320_write_spi(struct ili9320 *ili,
45 /* second message is the data to transfer */ 45 /* second message is the data to transfer */
46 46
47 data[0] = spi->id | ILI9320_SPI_DATA | ILI9320_SPI_WRITE; 47 data[0] = spi->id | ILI9320_SPI_DATA | ILI9320_SPI_WRITE;
48 data[1] = value >> 8; 48 data[1] = value >> 8;
49 data[2] = value; 49 data[2] = value;
50 50
51 return spi_sync(spi->dev, &spi->message); 51 return spi_sync(spi->dev, &spi->message);
@@ -56,11 +56,10 @@ int ili9320_write(struct ili9320 *ili, unsigned int reg, unsigned int value)
56 dev_dbg(ili->dev, "write: reg=%02x, val=%04x\n", reg, value); 56 dev_dbg(ili->dev, "write: reg=%02x, val=%04x\n", reg, value);
57 return ili->write(ili, reg, value); 57 return ili->write(ili, reg, value);
58} 58}
59
60EXPORT_SYMBOL_GPL(ili9320_write); 59EXPORT_SYMBOL_GPL(ili9320_write);
61 60
62int ili9320_write_regs(struct ili9320 *ili, 61int ili9320_write_regs(struct ili9320 *ili,
63 struct ili9320_reg *values, 62 const struct ili9320_reg *values,
64 int nr_values) 63 int nr_values)
65{ 64{
66 int index; 65 int index;
@@ -74,7 +73,6 @@ int ili9320_write_regs(struct ili9320 *ili,
74 73
75 return 0; 74 return 0;
76} 75}
77
78EXPORT_SYMBOL_GPL(ili9320_write_regs); 76EXPORT_SYMBOL_GPL(ili9320_write_regs);
79 77
80static void ili9320_reset(struct ili9320 *lcd) 78static void ili9320_reset(struct ili9320 *lcd)
@@ -260,7 +258,6 @@ int ili9320_probe_spi(struct spi_device *spi,
260 258
261 return ret; 259 return ret;
262} 260}
263
264EXPORT_SYMBOL_GPL(ili9320_probe_spi); 261EXPORT_SYMBOL_GPL(ili9320_probe_spi);
265 262
266int ili9320_remove(struct ili9320 *ili) 263int ili9320_remove(struct ili9320 *ili)
@@ -271,7 +268,6 @@ int ili9320_remove(struct ili9320 *ili)
271 268
272 return 0; 269 return 0;
273} 270}
274
275EXPORT_SYMBOL_GPL(ili9320_remove); 271EXPORT_SYMBOL_GPL(ili9320_remove);
276 272
277#ifdef CONFIG_PM 273#ifdef CONFIG_PM
@@ -296,20 +292,17 @@ int ili9320_suspend(struct ili9320 *lcd, pm_message_t state)
296 292
297 return 0; 293 return 0;
298} 294}
299
300EXPORT_SYMBOL_GPL(ili9320_suspend); 295EXPORT_SYMBOL_GPL(ili9320_suspend);
301 296
302int ili9320_resume(struct ili9320 *lcd) 297int ili9320_resume(struct ili9320 *lcd)
303{ 298{
304 dev_info(lcd->dev, "resuming from power state %d\n", lcd->power); 299 dev_info(lcd->dev, "resuming from power state %d\n", lcd->power);
305 300
306 if (lcd->platdata->suspend == ILI9320_SUSPEND_DEEP) { 301 if (lcd->platdata->suspend == ILI9320_SUSPEND_DEEP)
307 ili9320_write(lcd, ILI9320_POWER1, 0x00); 302 ili9320_write(lcd, ILI9320_POWER1, 0x00);
308 }
309 303
310 return ili9320_power(lcd, FB_BLANK_UNBLANK); 304 return ili9320_power(lcd, FB_BLANK_UNBLANK);
311} 305}
312
313EXPORT_SYMBOL_GPL(ili9320_resume); 306EXPORT_SYMBOL_GPL(ili9320_resume);
314#endif 307#endif
315 308
@@ -318,7 +311,6 @@ void ili9320_shutdown(struct ili9320 *lcd)
318{ 311{
319 ili9320_power(lcd, FB_BLANK_POWERDOWN); 312 ili9320_power(lcd, FB_BLANK_POWERDOWN);
320} 313}
321
322EXPORT_SYMBOL_GPL(ili9320_shutdown); 314EXPORT_SYMBOL_GPL(ili9320_shutdown);
323 315
324MODULE_AUTHOR("Ben Dooks <ben-linux@fluff.org>"); 316MODULE_AUTHOR("Ben Dooks <ben-linux@fluff.org>");
diff --git a/drivers/video/backlight/ili9320.h b/drivers/video/backlight/ili9320.h
index e388eca7cac5..e0db738f7bb9 100644
--- a/drivers/video/backlight/ili9320.h
+++ b/drivers/video/backlight/ili9320.h
@@ -63,7 +63,7 @@ extern int ili9320_write(struct ili9320 *ili,
63 unsigned int reg, unsigned int value); 63 unsigned int reg, unsigned int value);
64 64
65extern int ili9320_write_regs(struct ili9320 *ili, 65extern int ili9320_write_regs(struct ili9320 *ili,
66 struct ili9320_reg *values, 66 const struct ili9320_reg *values,
67 int nr_values); 67 int nr_values);
68 68
69/* Device probe */ 69/* Device probe */
diff --git a/drivers/video/backlight/jornada720_bl.c b/drivers/video/backlight/jornada720_bl.c
index 16f593b64427..fef6ce4fad71 100644
--- a/drivers/video/backlight/jornada720_bl.c
+++ b/drivers/video/backlight/jornada720_bl.c
@@ -48,7 +48,7 @@ static int jornada_bl_get_brightness(struct backlight_device *bd)
48 48
49 jornada_ssp_end(); 49 jornada_ssp_end();
50 50
51 return (BL_MAX_BRIGHT - ret); 51 return BL_MAX_BRIGHT - ret;
52} 52}
53 53
54static int jornada_bl_update_status(struct backlight_device *bd) 54static int jornada_bl_update_status(struct backlight_device *bd)
@@ -77,18 +77,23 @@ static int jornada_bl_update_status(struct backlight_device *bd)
77 goto out; 77 goto out;
78 } 78 }
79 79
80 /* at this point we expect that the mcu has accepted 80 /*
81 our command and is waiting for our new value 81 * at this point we expect that the mcu has accepted
82 please note that maximum brightness is 255, 82 * our command and is waiting for our new value
83 but due to physical layout it is equal to 0, so we simply 83 * please note that maximum brightness is 255,
84 invert the value (MAX VALUE - NEW VALUE). */ 84 * but due to physical layout it is equal to 0, so we simply
85 if (jornada_ssp_byte(BL_MAX_BRIGHT - bd->props.brightness) != TXDUMMY) { 85 * invert the value (MAX VALUE - NEW VALUE).
86 */
87 if (jornada_ssp_byte(BL_MAX_BRIGHT - bd->props.brightness)
88 != TXDUMMY) {
86 pr_err("set brightness failed\n"); 89 pr_err("set brightness failed\n");
87 ret = -ETIMEDOUT; 90 ret = -ETIMEDOUT;
88 } 91 }
89 92
90 /* If infact we get an TXDUMMY as output we are happy and dont 93 /*
91 make any further comments about it */ 94 * If infact we get an TXDUMMY as output we are happy and dont
95 * make any further comments about it
96 */
92out: 97out:
93 jornada_ssp_end(); 98 jornada_ssp_end();
94 99
@@ -121,9 +126,11 @@ static int jornada_bl_probe(struct platform_device *pdev)
121 126
122 bd->props.power = FB_BLANK_UNBLANK; 127 bd->props.power = FB_BLANK_UNBLANK;
123 bd->props.brightness = BL_DEF_BRIGHT; 128 bd->props.brightness = BL_DEF_BRIGHT;
124 /* note. make sure max brightness is set otherwise 129 /*
125 you will get seemingly non-related errors when 130 * note. make sure max brightness is set otherwise
126 trying to change brightness */ 131 * you will get seemingly non-related errors when
132 * trying to change brightness
133 */
127 jornada_bl_update_status(bd); 134 jornada_bl_update_status(bd);
128 135
129 platform_set_drvdata(pdev, bd); 136 platform_set_drvdata(pdev, bd);
diff --git a/drivers/video/backlight/l4f00242t03.c b/drivers/video/backlight/l4f00242t03.c
index f5aa0a5961d6..9a35196d12d7 100644
--- a/drivers/video/backlight/l4f00242t03.c
+++ b/drivers/video/backlight/l4f00242t03.c
@@ -4,7 +4,7 @@
4 * Copyright 2007-2009 Freescale Semiconductor, Inc. All Rights Reserved. 4 * Copyright 2007-2009 Freescale Semiconductor, Inc. All Rights Reserved.
5 * 5 *
6 * Copyright (c) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com> 6 * Copyright (c) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
7 * Inspired by Marek Vasut work in l4f00242t03.c 7 * Inspired by Marek Vasut work in l4f00242t03.c
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
@@ -33,7 +33,6 @@ struct l4f00242t03_priv {
33 struct regulator *core_reg; 33 struct regulator *core_reg;
34}; 34};
35 35
36
37static void l4f00242t03_reset(unsigned int gpio) 36static void l4f00242t03_reset(unsigned int gpio)
38{ 37{
39 pr_debug("l4f00242t03_reset.\n"); 38 pr_debug("l4f00242t03_reset.\n");
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
index a5d0d024bb92..34fb6bd798c8 100644
--- a/drivers/video/backlight/lcd.c
+++ b/drivers/video/backlight/lcd.c
@@ -108,7 +108,7 @@ static ssize_t lcd_show_power(struct device *dev, struct device_attribute *attr,
108static ssize_t lcd_store_power(struct device *dev, 108static ssize_t lcd_store_power(struct device *dev,
109 struct device_attribute *attr, const char *buf, size_t count) 109 struct device_attribute *attr, const char *buf, size_t count)
110{ 110{
111 int rc = -ENXIO; 111 int rc;
112 struct lcd_device *ld = to_lcd_device(dev); 112 struct lcd_device *ld = to_lcd_device(dev);
113 unsigned long power; 113 unsigned long power;
114 114
@@ -116,6 +116,8 @@ static ssize_t lcd_store_power(struct device *dev,
116 if (rc) 116 if (rc)
117 return rc; 117 return rc;
118 118
119 rc = -ENXIO;
120
119 mutex_lock(&ld->ops_lock); 121 mutex_lock(&ld->ops_lock);
120 if (ld->ops && ld->ops->set_power) { 122 if (ld->ops && ld->ops->set_power) {
121 pr_debug("set power to %lu\n", power); 123 pr_debug("set power to %lu\n", power);
@@ -144,7 +146,7 @@ static ssize_t lcd_show_contrast(struct device *dev,
144static ssize_t lcd_store_contrast(struct device *dev, 146static ssize_t lcd_store_contrast(struct device *dev,
145 struct device_attribute *attr, const char *buf, size_t count) 147 struct device_attribute *attr, const char *buf, size_t count)
146{ 148{
147 int rc = -ENXIO; 149 int rc;
148 struct lcd_device *ld = to_lcd_device(dev); 150 struct lcd_device *ld = to_lcd_device(dev);
149 unsigned long contrast; 151 unsigned long contrast;
150 152
@@ -152,6 +154,8 @@ static ssize_t lcd_store_contrast(struct device *dev,
152 if (rc) 154 if (rc)
153 return rc; 155 return rc;
154 156
157 rc = -ENXIO;
158
155 mutex_lock(&ld->ops_lock); 159 mutex_lock(&ld->ops_lock);
156 if (ld->ops && ld->ops->set_contrast) { 160 if (ld->ops && ld->ops->set_contrast) {
157 pr_debug("set contrast to %lu\n", contrast); 161 pr_debug("set contrast to %lu\n", contrast);
diff --git a/drivers/video/backlight/lm3630_bl.c b/drivers/video/backlight/lm3630_bl.c
index 0207bc0a4407..a6d637b5c68f 100644
--- a/drivers/video/backlight/lm3630_bl.c
+++ b/drivers/video/backlight/lm3630_bl.c
@@ -37,7 +37,7 @@ enum lm3630_leds {
37 BLED_2 37 BLED_2
38}; 38};
39 39
40static const char *bled_name[] = { 40static const char * const bled_name[] = {
41 [BLED_ALL] = "lm3630_bled", /*Bank1 controls all string */ 41 [BLED_ALL] = "lm3630_bled", /*Bank1 controls all string */
42 [BLED_1] = "lm3630_bled1", /*Bank1 controls bled1 */ 42 [BLED_1] = "lm3630_bled1", /*Bank1 controls bled1 */
43 [BLED_2] = "lm3630_bled2", /*Bank1 or 2 controls bled2 */ 43 [BLED_2] = "lm3630_bled2", /*Bank1 or 2 controls bled2 */
diff --git a/drivers/video/backlight/lm3639_bl.c b/drivers/video/backlight/lm3639_bl.c
index b0e1e8ba4d9f..7ab2d2a04e41 100644
--- a/drivers/video/backlight/lm3639_bl.c
+++ b/drivers/video/backlight/lm3639_bl.c
@@ -214,7 +214,7 @@ out_input:
214 214
215} 215}
216 216
217static DEVICE_ATTR(bled_mode, 0666, NULL, lm3639_bled_mode_store); 217static DEVICE_ATTR(bled_mode, S_IWUSR, NULL, lm3639_bled_mode_store);
218 218
219/* torch */ 219/* torch */
220static void lm3639_torch_brightness_set(struct led_classdev *cdev, 220static void lm3639_torch_brightness_set(struct led_classdev *cdev,
diff --git a/drivers/video/backlight/lms283gf05.c b/drivers/video/backlight/lms283gf05.c
index b29c7071c9db..55819b384701 100644
--- a/drivers/video/backlight/lms283gf05.c
+++ b/drivers/video/backlight/lms283gf05.c
@@ -31,7 +31,7 @@ struct lms283gf05_seq {
31}; 31};
32 32
33/* Magic sequences supplied by manufacturer, for details refer to datasheet */ 33/* Magic sequences supplied by manufacturer, for details refer to datasheet */
34static struct lms283gf05_seq disp_initseq[] = { 34static const struct lms283gf05_seq disp_initseq[] = {
35 /* REG, VALUE, DELAY */ 35 /* REG, VALUE, DELAY */
36 { 0x07, 0x0000, 0 }, 36 { 0x07, 0x0000, 0 },
37 { 0x13, 0x0000, 10 }, 37 { 0x13, 0x0000, 10 },
@@ -78,7 +78,7 @@ static struct lms283gf05_seq disp_initseq[] = {
78 { 0x22, 0x0000, 0 } 78 { 0x22, 0x0000, 0 }
79}; 79};
80 80
81static struct lms283gf05_seq disp_pdwnseq[] = { 81static const struct lms283gf05_seq disp_pdwnseq[] = {
82 { 0x07, 0x0016, 30 }, 82 { 0x07, 0x0016, 30 },
83 83
84 { 0x07, 0x0004, 0 }, 84 { 0x07, 0x0004, 0 },
@@ -104,7 +104,7 @@ static void lms283gf05_reset(unsigned long gpio, bool inverted)
104} 104}
105 105
106static void lms283gf05_toggle(struct spi_device *spi, 106static void lms283gf05_toggle(struct spi_device *spi,
107 struct lms283gf05_seq *seq, int sz) 107 const struct lms283gf05_seq *seq, int sz)
108{ 108{
109 char buf[3]; 109 char buf[3];
110 int i; 110 int i;
@@ -158,13 +158,10 @@ static int lms283gf05_probe(struct spi_device *spi)
158 int ret = 0; 158 int ret = 0;
159 159
160 if (pdata != NULL) { 160 if (pdata != NULL) {
161 ret = devm_gpio_request(&spi->dev, pdata->reset_gpio, 161 ret = devm_gpio_request_one(&spi->dev, pdata->reset_gpio,
162 "LMS285GF05 RESET"); 162 GPIOF_DIR_OUT | (!pdata->reset_inverted ?
163 if (ret) 163 GPIOF_INIT_HIGH : GPIOF_INIT_LOW),
164 return ret; 164 "LMS285GF05 RESET");
165
166 ret = gpio_direction_output(pdata->reset_gpio,
167 !pdata->reset_inverted);
168 if (ret) 165 if (ret)
169 return ret; 166 return ret;
170 } 167 }
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index fd985e0681e9..6e4db0c874c8 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -15,6 +15,7 @@
15#include <linux/backlight.h> 15#include <linux/backlight.h>
16#include <linux/err.h> 16#include <linux/err.h>
17#include <linux/platform_data/lp855x.h> 17#include <linux/platform_data/lp855x.h>
18#include <linux/pwm.h>
18 19
19/* Registers */ 20/* Registers */
20#define BRIGHTNESS_CTRL 0x00 21#define BRIGHTNESS_CTRL 0x00
@@ -34,22 +35,19 @@ struct lp855x {
34 struct i2c_client *client; 35 struct i2c_client *client;
35 struct backlight_device *bl; 36 struct backlight_device *bl;
36 struct device *dev; 37 struct device *dev;
37 struct mutex xfer_lock;
38 struct lp855x_platform_data *pdata; 38 struct lp855x_platform_data *pdata;
39 struct pwm_device *pwm;
39}; 40};
40 41
41static int lp855x_read_byte(struct lp855x *lp, u8 reg, u8 *data) 42static int lp855x_read_byte(struct lp855x *lp, u8 reg, u8 *data)
42{ 43{
43 int ret; 44 int ret;
44 45
45 mutex_lock(&lp->xfer_lock);
46 ret = i2c_smbus_read_byte_data(lp->client, reg); 46 ret = i2c_smbus_read_byte_data(lp->client, reg);
47 if (ret < 0) { 47 if (ret < 0) {
48 mutex_unlock(&lp->xfer_lock);
49 dev_err(lp->dev, "failed to read 0x%.2x\n", reg); 48 dev_err(lp->dev, "failed to read 0x%.2x\n", reg);
50 return ret; 49 return ret;
51 } 50 }
52 mutex_unlock(&lp->xfer_lock);
53 51
54 *data = (u8)ret; 52 *data = (u8)ret;
55 return 0; 53 return 0;
@@ -57,13 +55,7 @@ static int lp855x_read_byte(struct lp855x *lp, u8 reg, u8 *data)
57 55
58static int lp855x_write_byte(struct lp855x *lp, u8 reg, u8 data) 56static int lp855x_write_byte(struct lp855x *lp, u8 reg, u8 data)
59{ 57{
60 int ret; 58 return i2c_smbus_write_byte_data(lp->client, reg, data);
61
62 mutex_lock(&lp->xfer_lock);
63 ret = i2c_smbus_write_byte_data(lp->client, reg, data);
64 mutex_unlock(&lp->xfer_lock);
65
66 return ret;
67} 59}
68 60
69static bool lp855x_is_valid_rom_area(struct lp855x *lp, u8 addr) 61static bool lp855x_is_valid_rom_area(struct lp855x *lp, u8 addr)
@@ -121,6 +113,28 @@ static int lp855x_init_registers(struct lp855x *lp)
121 return ret; 113 return ret;
122} 114}
123 115
116static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
117{
118 unsigned int period = lp->pdata->period_ns;
119 unsigned int duty = br * period / max_br;
120 struct pwm_device *pwm;
121
122 /* request pwm device with the consumer name */
123 if (!lp->pwm) {
124 pwm = devm_pwm_get(lp->dev, lp->chipname);
125 if (IS_ERR(pwm))
126 return;
127
128 lp->pwm = pwm;
129 }
130
131 pwm_config(lp->pwm, duty, period);
132 if (duty)
133 pwm_enable(lp->pwm);
134 else
135 pwm_disable(lp->pwm);
136}
137
124static int lp855x_bl_update_status(struct backlight_device *bl) 138static int lp855x_bl_update_status(struct backlight_device *bl)
125{ 139{
126 struct lp855x *lp = bl_get_data(bl); 140 struct lp855x *lp = bl_get_data(bl);
@@ -130,12 +144,10 @@ static int lp855x_bl_update_status(struct backlight_device *bl)
130 bl->props.brightness = 0; 144 bl->props.brightness = 0;
131 145
132 if (mode == PWM_BASED) { 146 if (mode == PWM_BASED) {
133 struct lp855x_pwm_data *pd = &lp->pdata->pwm_data;
134 int br = bl->props.brightness; 147 int br = bl->props.brightness;
135 int max_br = bl->props.max_brightness; 148 int max_br = bl->props.max_brightness;
136 149
137 if (pd->pwm_set_intensity) 150 lp855x_pwm_ctrl(lp, br, max_br);
138 pd->pwm_set_intensity(br, max_br);
139 151
140 } else if (mode == REGISTER_BASED) { 152 } else if (mode == REGISTER_BASED) {
141 u8 val = bl->props.brightness; 153 u8 val = bl->props.brightness;
@@ -150,14 +162,7 @@ static int lp855x_bl_get_brightness(struct backlight_device *bl)
150 struct lp855x *lp = bl_get_data(bl); 162 struct lp855x *lp = bl_get_data(bl);
151 enum lp855x_brightness_ctrl_mode mode = lp->pdata->mode; 163 enum lp855x_brightness_ctrl_mode mode = lp->pdata->mode;
152 164
153 if (mode == PWM_BASED) { 165 if (mode == REGISTER_BASED) {
154 struct lp855x_pwm_data *pd = &lp->pdata->pwm_data;
155 int max_br = bl->props.max_brightness;
156
157 if (pd->pwm_get_intensity)
158 bl->props.brightness = pd->pwm_get_intensity(max_br);
159
160 } else if (mode == REGISTER_BASED) {
161 u8 val = 0; 166 u8 val = 0;
162 167
163 lp855x_read_byte(lp, BRIGHTNESS_CTRL, &val); 168 lp855x_read_byte(lp, BRIGHTNESS_CTRL, &val);
@@ -266,8 +271,6 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
266 lp->chip_id = id->driver_data; 271 lp->chip_id = id->driver_data;
267 i2c_set_clientdata(cl, lp); 272 i2c_set_clientdata(cl, lp);
268 273
269 mutex_init(&lp->xfer_lock);
270
271 ret = lp855x_init_registers(lp); 274 ret = lp855x_init_registers(lp);
272 if (ret) { 275 if (ret) {
273 dev_err(lp->dev, "i2c communication err: %d", ret); 276 dev_err(lp->dev, "i2c communication err: %d", ret);
diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c
index c6bec7aab87b..2c9bce050aa9 100644
--- a/drivers/video/backlight/max8925_bl.c
+++ b/drivers/video/backlight/max8925_bl.c
@@ -120,15 +120,13 @@ static int max8925_backlight_probe(struct platform_device *pdev)
120 res = platform_get_resource(pdev, IORESOURCE_REG, 0); 120 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
121 if (!res) { 121 if (!res) {
122 dev_err(&pdev->dev, "No REG resource for mode control!\n"); 122 dev_err(&pdev->dev, "No REG resource for mode control!\n");
123 ret = -ENXIO; 123 return -ENXIO;
124 goto out;
125 } 124 }
126 data->reg_mode_cntl = res->start; 125 data->reg_mode_cntl = res->start;
127 res = platform_get_resource(pdev, IORESOURCE_REG, 1); 126 res = platform_get_resource(pdev, IORESOURCE_REG, 1);
128 if (!res) { 127 if (!res) {
129 dev_err(&pdev->dev, "No REG resource for control!\n"); 128 dev_err(&pdev->dev, "No REG resource for control!\n");
130 ret = -ENXIO; 129 return -ENXIO;
131 goto out;
132 } 130 }
133 data->reg_cntl = res->start; 131 data->reg_cntl = res->start;
134 132
@@ -142,8 +140,7 @@ static int max8925_backlight_probe(struct platform_device *pdev)
142 &max8925_backlight_ops, &props); 140 &max8925_backlight_ops, &props);
143 if (IS_ERR(bl)) { 141 if (IS_ERR(bl)) {
144 dev_err(&pdev->dev, "failed to register backlight\n"); 142 dev_err(&pdev->dev, "failed to register backlight\n");
145 ret = PTR_ERR(bl); 143 return PTR_ERR(bl);
146 goto out;
147 } 144 }
148 bl->props.brightness = MAX_BRIGHTNESS; 145 bl->props.brightness = MAX_BRIGHTNESS;
149 146
@@ -166,8 +163,6 @@ static int max8925_backlight_probe(struct platform_device *pdev)
166 return 0; 163 return 0;
167out_brt: 164out_brt:
168 backlight_device_unregister(bl); 165 backlight_device_unregister(bl);
169out:
170 devm_kfree(&pdev->dev, data);
171 return ret; 166 return ret;
172} 167}
173 168
diff --git a/drivers/video/backlight/omap1_bl.c b/drivers/video/backlight/omap1_bl.c
index 9a046a4c98f5..af31c269baa6 100644
--- a/drivers/video/backlight/omap1_bl.c
+++ b/drivers/video/backlight/omap1_bl.c
@@ -42,12 +42,12 @@ struct omap_backlight {
42 struct omap_backlight_config *pdata; 42 struct omap_backlight_config *pdata;
43}; 43};
44 44
45static void inline omapbl_send_intensity(int intensity) 45static inline void omapbl_send_intensity(int intensity)
46{ 46{
47 omap_writeb(intensity, OMAP_PWL_ENABLE); 47 omap_writeb(intensity, OMAP_PWL_ENABLE);
48} 48}
49 49
50static void inline omapbl_send_enable(int enable) 50static inline void omapbl_send_enable(int enable)
51{ 51{
52 omap_writeb(enable, OMAP_PWL_CLK_ENABLE); 52 omap_writeb(enable, OMAP_PWL_CLK_ENABLE);
53} 53}
diff --git a/drivers/video/backlight/pandora_bl.c b/drivers/video/backlight/pandora_bl.c
index 4ec30748b447..633b0a22fd64 100644
--- a/drivers/video/backlight/pandora_bl.c
+++ b/drivers/video/backlight/pandora_bl.c
@@ -71,8 +71,7 @@ static int pandora_backlight_update_status(struct backlight_device *bl)
71 * set PWM duty cycle to max. TPS61161 seems to use this 71 * set PWM duty cycle to max. TPS61161 seems to use this
72 * to calibrate it's PWM sensitivity when it starts. 72 * to calibrate it's PWM sensitivity when it starts.
73 */ 73 */
74 twl_i2c_write_u8(TWL4030_MODULE_PWM0, MAX_VALUE, 74 twl_i2c_write_u8(TWL_MODULE_PWM, MAX_VALUE, TWL_PWM0_OFF);
75 TWL_PWM0_OFF);
76 75
77 /* first enable clock, then PWM0 out */ 76 /* first enable clock, then PWM0 out */
78 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &r, TWL_INTBR_GPBR1); 77 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &r, TWL_INTBR_GPBR1);
@@ -90,8 +89,7 @@ static int pandora_backlight_update_status(struct backlight_device *bl)
90 usleep_range(2000, 10000); 89 usleep_range(2000, 10000);
91 } 90 }
92 91
93 twl_i2c_write_u8(TWL4030_MODULE_PWM0, MIN_VALUE + brightness, 92 twl_i2c_write_u8(TWL_MODULE_PWM, MIN_VALUE + brightness, TWL_PWM0_OFF);
94 TWL_PWM0_OFF);
95 93
96done: 94done:
97 if (brightness != 0) 95 if (brightness != 0)
@@ -132,7 +130,7 @@ static int pandora_backlight_probe(struct platform_device *pdev)
132 platform_set_drvdata(pdev, bl); 130 platform_set_drvdata(pdev, bl);
133 131
134 /* 64 cycle period, ON position 0 */ 132 /* 64 cycle period, ON position 0 */
135 twl_i2c_write_u8(TWL4030_MODULE_PWM0, 0x80, TWL_PWM0_ON); 133 twl_i2c_write_u8(TWL_MODULE_PWM, 0x80, TWL_PWM0_ON);
136 134
137 bl->props.state |= PANDORABL_WAS_OFF; 135 bl->props.state |= PANDORABL_WAS_OFF;
138 bl->props.brightness = MAX_USER_VALUE; 136 bl->props.brightness = MAX_USER_VALUE;
diff --git a/drivers/video/backlight/pcf50633-backlight.c b/drivers/video/backlight/pcf50633-backlight.c
index 0087396007e4..e87c7a3394f3 100644
--- a/drivers/video/backlight/pcf50633-backlight.c
+++ b/drivers/video/backlight/pcf50633-backlight.c
@@ -52,7 +52,7 @@ int pcf50633_bl_set_brightness_limit(struct pcf50633 *pcf, unsigned int limit)
52 pcf_bl->brightness_limit = limit & 0x3f; 52 pcf_bl->brightness_limit = limit & 0x3f;
53 backlight_update_status(pcf_bl->bl); 53 backlight_update_status(pcf_bl->bl);
54 54
55 return 0; 55 return 0;
56} 56}
57 57
58static int pcf50633_bl_update_status(struct backlight_device *bl) 58static int pcf50633_bl_update_status(struct backlight_device *bl)
@@ -136,8 +136,10 @@ static int pcf50633_bl_probe(struct platform_device *pdev)
136 136
137 pcf50633_reg_write(pcf_bl->pcf, PCF50633_REG_LEDDIM, pdata->ramp_time); 137 pcf50633_reg_write(pcf_bl->pcf, PCF50633_REG_LEDDIM, pdata->ramp_time);
138 138
139 /* Should be different from bl_props.brightness, so we do not exit 139 /*
140 * update_status early the first time it's called */ 140 * Should be different from bl_props.brightness, so we do not exit
141 * update_status early the first time it's called
142 */
141 pcf_bl->brightness = pcf_bl->bl->props.brightness + 1; 143 pcf_bl->brightness = pcf_bl->bl->props.brightness + 1;
142 144
143 backlight_update_status(pcf_bl->bl); 145 backlight_update_status(pcf_bl->bl);
diff --git a/drivers/video/backlight/platform_lcd.c b/drivers/video/backlight/platform_lcd.c
index 894bfc5ce422..17a6b83f97af 100644
--- a/drivers/video/backlight/platform_lcd.c
+++ b/drivers/video/backlight/platform_lcd.c
@@ -27,7 +27,7 @@ struct platform_lcd {
27 struct plat_lcd_data *pdata; 27 struct plat_lcd_data *pdata;
28 28
29 unsigned int power; 29 unsigned int power;
30 unsigned int suspended : 1; 30 unsigned int suspended:1;
31}; 31};
32 32
33static inline struct platform_lcd *to_our_lcd(struct lcd_device *lcd) 33static inline struct platform_lcd *to_our_lcd(struct lcd_device *lcd)
diff --git a/drivers/video/backlight/s6e63m0.c b/drivers/video/backlight/s6e63m0.c
index 484e10dd1a8e..3e1c1135f6df 100644
--- a/drivers/video/backlight/s6e63m0.c
+++ b/drivers/video/backlight/s6e63m0.c
@@ -757,7 +757,7 @@ static int s6e63m0_probe(struct spi_device *spi)
757 lcd->spi = spi; 757 lcd->spi = spi;
758 lcd->dev = &spi->dev; 758 lcd->dev = &spi->dev;
759 759
760 lcd->lcd_pd = (struct lcd_platform_data *)spi->dev.platform_data; 760 lcd->lcd_pd = spi->dev.platform_data;
761 if (!lcd->lcd_pd) { 761 if (!lcd->lcd_pd) {
762 dev_err(&spi->dev, "platform data is NULL.\n"); 762 dev_err(&spi->dev, "platform data is NULL.\n");
763 return -EFAULT; 763 return -EFAULT;
diff --git a/drivers/video/backlight/tdo24m.c b/drivers/video/backlight/tdo24m.c
index 146ffb9404d1..ad2325f3d652 100644
--- a/drivers/video/backlight/tdo24m.c
+++ b/drivers/video/backlight/tdo24m.c
@@ -2,7 +2,7 @@
2 * tdo24m - SPI-based drivers for Toppoly TDO24M series LCD panels 2 * tdo24m - SPI-based drivers for Toppoly TDO24M series LCD panels
3 * 3 *
4 * Copyright (C) 2008 Marvell International Ltd. 4 * Copyright (C) 2008 Marvell International Ltd.
5 * Eric Miao <eric.miao@marvell.com> 5 * Eric Miao <eric.miao@marvell.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
@@ -47,7 +47,7 @@ struct tdo24m {
47 ((x1) << 9) | 0x100 | (x2)) 47 ((x1) << 9) | 0x100 | (x2))
48#define CMD_NULL (-1) 48#define CMD_NULL (-1)
49 49
50static uint32_t lcd_panel_reset[] = { 50static const uint32_t lcd_panel_reset[] = {
51 CMD0(0x1), /* reset */ 51 CMD0(0x1), /* reset */
52 CMD0(0x0), /* nop */ 52 CMD0(0x0), /* nop */
53 CMD0(0x0), /* nop */ 53 CMD0(0x0), /* nop */
@@ -55,7 +55,7 @@ static uint32_t lcd_panel_reset[] = {
55 CMD_NULL, 55 CMD_NULL,
56}; 56};
57 57
58static uint32_t lcd_panel_on[] = { 58static const uint32_t lcd_panel_on[] = {
59 CMD0(0x29), /* Display ON */ 59 CMD0(0x29), /* Display ON */
60 CMD2(0xB8, 0xFF, 0xF9), /* Output Control */ 60 CMD2(0xB8, 0xFF, 0xF9), /* Output Control */
61 CMD0(0x11), /* Sleep out */ 61 CMD0(0x11), /* Sleep out */
@@ -63,7 +63,7 @@ static uint32_t lcd_panel_on[] = {
63 CMD_NULL, 63 CMD_NULL,
64}; 64};
65 65
66static uint32_t lcd_panel_off[] = { 66static const uint32_t lcd_panel_off[] = {
67 CMD0(0x28), /* Display OFF */ 67 CMD0(0x28), /* Display OFF */
68 CMD2(0xB8, 0x80, 0x02), /* Output Control */ 68 CMD2(0xB8, 0x80, 0x02), /* Output Control */
69 CMD0(0x10), /* Sleep in */ 69 CMD0(0x10), /* Sleep in */
@@ -71,7 +71,7 @@ static uint32_t lcd_panel_off[] = {
71 CMD_NULL, 71 CMD_NULL,
72}; 72};
73 73
74static uint32_t lcd_vga_pass_through_tdo24m[] = { 74static const uint32_t lcd_vga_pass_through_tdo24m[] = {
75 CMD1(0xB0, 0x16), 75 CMD1(0xB0, 0x16),
76 CMD1(0xBC, 0x80), 76 CMD1(0xBC, 0x80),
77 CMD1(0xE1, 0x00), 77 CMD1(0xE1, 0x00),
@@ -80,7 +80,7 @@ static uint32_t lcd_vga_pass_through_tdo24m[] = {
80 CMD_NULL, 80 CMD_NULL,
81}; 81};
82 82
83static uint32_t lcd_qvga_pass_through_tdo24m[] = { 83static const uint32_t lcd_qvga_pass_through_tdo24m[] = {
84 CMD1(0xB0, 0x16), 84 CMD1(0xB0, 0x16),
85 CMD1(0xBC, 0x81), 85 CMD1(0xBC, 0x81),
86 CMD1(0xE1, 0x00), 86 CMD1(0xE1, 0x00),
@@ -89,8 +89,8 @@ static uint32_t lcd_qvga_pass_through_tdo24m[] = {
89 CMD_NULL, 89 CMD_NULL,
90}; 90};
91 91
92static uint32_t lcd_vga_transfer_tdo24m[] = { 92static const uint32_t lcd_vga_transfer_tdo24m[] = {
93 CMD1(0xcf, 0x02), /* Blanking period control (1) */ 93 CMD1(0xcf, 0x02), /* Blanking period control (1) */
94 CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */ 94 CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */
95 CMD1(0xd1, 0x01), /* CKV timing control on/off */ 95 CMD1(0xd1, 0x01), /* CKV timing control on/off */
96 CMD2(0xd2, 0x14, 0x00), /* CKV 1,2 timing control */ 96 CMD2(0xd2, 0x14, 0x00), /* CKV 1,2 timing control */
@@ -102,7 +102,7 @@ static uint32_t lcd_vga_transfer_tdo24m[] = {
102 CMD_NULL, 102 CMD_NULL,
103}; 103};
104 104
105static uint32_t lcd_qvga_transfer[] = { 105static const uint32_t lcd_qvga_transfer[] = {
106 CMD1(0xd6, 0x02), /* Blanking period control (1) */ 106 CMD1(0xd6, 0x02), /* Blanking period control (1) */
107 CMD2(0xd7, 0x08, 0x04), /* Blanking period control (2) */ 107 CMD2(0xd7, 0x08, 0x04), /* Blanking period control (2) */
108 CMD1(0xd8, 0x01), /* CKV timing control on/off */ 108 CMD1(0xd8, 0x01), /* CKV timing control on/off */
@@ -115,7 +115,7 @@ static uint32_t lcd_qvga_transfer[] = {
115 CMD_NULL, 115 CMD_NULL,
116}; 116};
117 117
118static uint32_t lcd_vga_pass_through_tdo35s[] = { 118static const uint32_t lcd_vga_pass_through_tdo35s[] = {
119 CMD1(0xB0, 0x16), 119 CMD1(0xB0, 0x16),
120 CMD1(0xBC, 0x80), 120 CMD1(0xBC, 0x80),
121 CMD1(0xE1, 0x00), 121 CMD1(0xE1, 0x00),
@@ -123,7 +123,7 @@ static uint32_t lcd_vga_pass_through_tdo35s[] = {
123 CMD_NULL, 123 CMD_NULL,
124}; 124};
125 125
126static uint32_t lcd_qvga_pass_through_tdo35s[] = { 126static const uint32_t lcd_qvga_pass_through_tdo35s[] = {
127 CMD1(0xB0, 0x16), 127 CMD1(0xB0, 0x16),
128 CMD1(0xBC, 0x81), 128 CMD1(0xBC, 0x81),
129 CMD1(0xE1, 0x00), 129 CMD1(0xE1, 0x00),
@@ -131,8 +131,8 @@ static uint32_t lcd_qvga_pass_through_tdo35s[] = {
131 CMD_NULL, 131 CMD_NULL,
132}; 132};
133 133
134static uint32_t lcd_vga_transfer_tdo35s[] = { 134static const uint32_t lcd_vga_transfer_tdo35s[] = {
135 CMD1(0xcf, 0x02), /* Blanking period control (1) */ 135 CMD1(0xcf, 0x02), /* Blanking period control (1) */
136 CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */ 136 CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */
137 CMD1(0xd1, 0x01), /* CKV timing control on/off */ 137 CMD1(0xd1, 0x01), /* CKV timing control on/off */
138 CMD2(0xd2, 0x00, 0x1e), /* CKV 1,2 timing control */ 138 CMD2(0xd2, 0x00, 0x1e), /* CKV 1,2 timing control */
@@ -144,7 +144,7 @@ static uint32_t lcd_vga_transfer_tdo35s[] = {
144 CMD_NULL, 144 CMD_NULL,
145}; 145};
146 146
147static uint32_t lcd_panel_config[] = { 147static const uint32_t lcd_panel_config[] = {
148 CMD2(0xb8, 0xff, 0xf9), /* Output control */ 148 CMD2(0xb8, 0xff, 0xf9), /* Output control */
149 CMD0(0x11), /* sleep out */ 149 CMD0(0x11), /* sleep out */
150 CMD1(0xba, 0x01), /* Display mode (1) */ 150 CMD1(0xba, 0x01), /* Display mode (1) */
@@ -175,10 +175,11 @@ static uint32_t lcd_panel_config[] = {
175 CMD_NULL, 175 CMD_NULL,
176}; 176};
177 177
178static int tdo24m_writes(struct tdo24m *lcd, uint32_t *array) 178static int tdo24m_writes(struct tdo24m *lcd, const uint32_t *array)
179{ 179{
180 struct spi_transfer *x = &lcd->xfer; 180 struct spi_transfer *x = &lcd->xfer;
181 uint32_t data, *p = array; 181 const uint32_t *p = array;
182 uint32_t data;
182 int nparams, err = 0; 183 int nparams, err = 0;
183 184
184 for (; *p != CMD_NULL; p++) { 185 for (; *p != CMD_NULL; p++) {
diff --git a/drivers/video/backlight/tosa_bl.c b/drivers/video/backlight/tosa_bl.c
index a0521abdcd8a..588682cc1614 100644
--- a/drivers/video/backlight/tosa_bl.c
+++ b/drivers/video/backlight/tosa_bl.c
@@ -92,14 +92,12 @@ static int tosa_bl_probe(struct i2c_client *client,
92 92
93 data->comadj = sharpsl_param.comadj == -1 ? COMADJ_DEFAULT : sharpsl_param.comadj; 93 data->comadj = sharpsl_param.comadj == -1 ? COMADJ_DEFAULT : sharpsl_param.comadj;
94 94
95 ret = devm_gpio_request(&client->dev, TOSA_GPIO_BL_C20MA, "backlight"); 95 ret = devm_gpio_request_one(&client->dev, TOSA_GPIO_BL_C20MA,
96 GPIOF_OUT_INIT_LOW, "backlight");
96 if (ret) { 97 if (ret) {
97 dev_dbg(&data->bl->dev, "Unable to request gpio!\n"); 98 dev_dbg(&data->bl->dev, "Unable to request gpio!\n");
98 return ret; 99 return ret;
99 } 100 }
100 ret = gpio_direction_output(TOSA_GPIO_BL_C20MA, 0);
101 if (ret)
102 return ret;
103 101
104 i2c_set_clientdata(client, data); 102 i2c_set_clientdata(client, data);
105 data->i2c = client; 103 data->i2c = client;
@@ -163,7 +161,6 @@ static const struct i2c_device_id tosa_bl_id[] = {
163 { }, 161 { },
164}; 162};
165 163
166
167static struct i2c_driver tosa_bl_driver = { 164static struct i2c_driver tosa_bl_driver = {
168 .driver = { 165 .driver = {
169 .name = "tosa-bl", 166 .name = "tosa-bl",
diff --git a/drivers/video/backlight/tosa_lcd.c b/drivers/video/backlight/tosa_lcd.c
index 86fff88c2e4a..96bae941585a 100644
--- a/drivers/video/backlight/tosa_lcd.c
+++ b/drivers/video/backlight/tosa_lcd.c
@@ -63,7 +63,7 @@ static int tosa_tg_send(struct spi_device *spi, int adrs, uint8_t data)
63int tosa_bl_enable(struct spi_device *spi, int enable) 63int tosa_bl_enable(struct spi_device *spi, int enable)
64{ 64{
65 /* bl_enable GP04=1 otherwise GP04=0*/ 65 /* bl_enable GP04=1 otherwise GP04=0*/
66 return tosa_tg_send(spi, TG_GPODR2, enable? 0x01 : 0x00); 66 return tosa_tg_send(spi, TG_GPODR2, enable ? 0x01 : 0x00);
67} 67}
68EXPORT_SYMBOL(tosa_bl_enable); 68EXPORT_SYMBOL(tosa_bl_enable);
69 69
@@ -91,15 +91,17 @@ static void tosa_lcd_tg_on(struct tosa_lcd_data *data)
91 tosa_tg_send(spi, TG_PNLCTL, value); 91 tosa_tg_send(spi, TG_PNLCTL, value);
92 92
93 /* TG LCD pannel power up */ 93 /* TG LCD pannel power up */
94 tosa_tg_send(spi, TG_PINICTL,0x4); 94 tosa_tg_send(spi, TG_PINICTL, 0x4);
95 mdelay(50); 95 mdelay(50);
96 96
97 /* TG LCD GVSS */ 97 /* TG LCD GVSS */
98 tosa_tg_send(spi, TG_PINICTL,0x0); 98 tosa_tg_send(spi, TG_PINICTL, 0x0);
99 99
100 if (!data->i2c) { 100 if (!data->i2c) {
101 /* after the pannel is powered up the first time, we can access the i2c bus */ 101 /*
102 /* so probe for the DAC */ 102 * after the pannel is powered up the first time,
103 * we can access the i2c bus so probe for the DAC
104 */
103 struct i2c_adapter *adap = i2c_get_adapter(0); 105 struct i2c_adapter *adap = i2c_get_adapter(0);
104 struct i2c_board_info info = { 106 struct i2c_board_info info = {
105 .type = "tosa-bl", 107 .type = "tosa-bl",
@@ -115,11 +117,11 @@ static void tosa_lcd_tg_off(struct tosa_lcd_data *data)
115 struct spi_device *spi = data->spi; 117 struct spi_device *spi = data->spi;
116 118
117 /* TG LCD VHSA off */ 119 /* TG LCD VHSA off */
118 tosa_tg_send(spi, TG_PINICTL,0x4); 120 tosa_tg_send(spi, TG_PINICTL, 0x4);
119 mdelay(50); 121 mdelay(50);
120 122
121 /* TG LCD signal off */ 123 /* TG LCD signal off */
122 tosa_tg_send(spi, TG_PINICTL,0x6); 124 tosa_tg_send(spi, TG_PINICTL, 0x6);
123 mdelay(50); 125 mdelay(50);
124 126
125 /* TG Off */ 127 /* TG Off */
@@ -193,17 +195,13 @@ static int tosa_lcd_probe(struct spi_device *spi)
193 data->spi = spi; 195 data->spi = spi;
194 dev_set_drvdata(&spi->dev, data); 196 dev_set_drvdata(&spi->dev, data);
195 197
196 ret = devm_gpio_request(&spi->dev, TOSA_GPIO_TG_ON, "tg #pwr"); 198 ret = devm_gpio_request_one(&spi->dev, TOSA_GPIO_TG_ON,
199 GPIOF_OUT_INIT_LOW, "tg #pwr");
197 if (ret < 0) 200 if (ret < 0)
198 goto err_gpio_tg; 201 goto err_gpio_tg;
199 202
200 mdelay(60); 203 mdelay(60);
201 204
202 ret = gpio_direction_output(TOSA_GPIO_TG_ON, 0);
203 if (ret < 0)
204 goto err_gpio_tg;
205
206 mdelay(60);
207 tosa_lcd_tg_init(data); 205 tosa_lcd_tg_init(data);
208 206
209 tosa_lcd_tg_on(data); 207 tosa_lcd_tg_on(data);
diff --git a/drivers/video/backlight/vgg2432a4.c b/drivers/video/backlight/vgg2432a4.c
index 712b0acfd339..45e81b4cf8b4 100644
--- a/drivers/video/backlight/vgg2432a4.c
+++ b/drivers/video/backlight/vgg2432a4.c
@@ -26,7 +26,7 @@
26 26
27/* Device initialisation sequences */ 27/* Device initialisation sequences */
28 28
29static struct ili9320_reg vgg_init1[] = { 29static const struct ili9320_reg vgg_init1[] = {
30 { 30 {
31 .address = ILI9320_POWER1, 31 .address = ILI9320_POWER1,
32 .value = ILI9320_POWER1_AP(0) | ILI9320_POWER1_BT(0), 32 .value = ILI9320_POWER1_AP(0) | ILI9320_POWER1_BT(0),
@@ -43,7 +43,7 @@ static struct ili9320_reg vgg_init1[] = {
43 }, 43 },
44}; 44};
45 45
46static struct ili9320_reg vgg_init2[] = { 46static const struct ili9320_reg vgg_init2[] = {
47 { 47 {
48 .address = ILI9320_POWER1, 48 .address = ILI9320_POWER1,
49 .value = (ILI9320_POWER1_AP(3) | ILI9320_POWER1_APE | 49 .value = (ILI9320_POWER1_AP(3) | ILI9320_POWER1_APE |
@@ -54,7 +54,7 @@ static struct ili9320_reg vgg_init2[] = {
54 } 54 }
55}; 55};
56 56
57static struct ili9320_reg vgg_gamma[] = { 57static const struct ili9320_reg vgg_gamma[] = {
58 { 58 {
59 .address = ILI9320_GAMMA1, 59 .address = ILI9320_GAMMA1,
60 .value = 0x0000, 60 .value = 0x0000,
@@ -89,7 +89,7 @@ static struct ili9320_reg vgg_gamma[] = {
89 89
90}; 90};
91 91
92static struct ili9320_reg vgg_init0[] = { 92static const struct ili9320_reg vgg_init0[] = {
93 [0] = { 93 [0] = {
94 /* set direction and scan mode gate */ 94 /* set direction and scan mode gate */
95 .address = ILI9320_DRIVER, 95 .address = ILI9320_DRIVER,
@@ -217,7 +217,7 @@ static int vgg2432a4_resume(struct spi_device *spi)
217} 217}
218#else 218#else
219#define vgg2432a4_suspend NULL 219#define vgg2432a4_suspend NULL
220#define vgg2432a4_resume NULL 220#define vgg2432a4_resume NULL
221#endif 221#endif
222 222
223static struct ili9320_client vgg2432a4_client = { 223static struct ili9320_client vgg2432a4_client = {
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index b1342ffb3cf6..922ad460bff9 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -16,7 +16,7 @@
16#include <linux/poll.h> 16#include <linux/poll.h>
17 17
18 18
19static loff_t bad_file_llseek(struct file *file, loff_t offset, int origin) 19static loff_t bad_file_llseek(struct file *file, loff_t offset, int whence)
20{ 20{
21 return -EIO; 21 return -EIO;
22} 22}
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 6d7d1647a68c..0c42cdbabecf 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1601,8 +1601,10 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
1601 info->thread = NULL; 1601 info->thread = NULL;
1602 1602
1603 psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL); 1603 psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL);
1604 if (psinfo == NULL) 1604 if (psinfo == NULL) {
1605 info->psinfo.data = NULL; /* So we don't free this wrongly */
1605 return 0; 1606 return 0;
1607 }
1606 1608
1607 fill_note(&info->psinfo, "CORE", NT_PRPSINFO, sizeof(*psinfo), psinfo); 1609 fill_note(&info->psinfo, "CORE", NT_PRPSINFO, sizeof(*psinfo), psinfo);
1608 1610
diff --git a/fs/binfmt_em86.c b/fs/binfmt_em86.c
index 4e6cce57d113..037a3e2b045b 100644
--- a/fs/binfmt_em86.c
+++ b/fs/binfmt_em86.c
@@ -42,7 +42,6 @@ static int load_em86(struct linux_binprm *bprm)
42 return -ENOEXEC; 42 return -ENOEXEC;
43 } 43 }
44 44
45 bprm->recursion_depth++; /* Well, the bang-shell is implicit... */
46 allow_write_access(bprm->file); 45 allow_write_access(bprm->file);
47 fput(bprm->file); 46 fput(bprm->file);
48 bprm->file = NULL; 47 bprm->file = NULL;
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index b0b70fbea06c..9be335fb8a7c 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -117,10 +117,6 @@ static int load_misc_binary(struct linux_binprm *bprm)
117 if (!enabled) 117 if (!enabled)
118 goto _ret; 118 goto _ret;
119 119
120 retval = -ENOEXEC;
121 if (bprm->recursion_depth > BINPRM_MAX_RECURSION)
122 goto _ret;
123
124 /* to keep locking time low, we copy the interpreter string */ 120 /* to keep locking time low, we copy the interpreter string */
125 read_lock(&entries_lock); 121 read_lock(&entries_lock);
126 fmt = check_file(bprm); 122 fmt = check_file(bprm);
@@ -197,8 +193,6 @@ static int load_misc_binary(struct linux_binprm *bprm)
197 if (retval < 0) 193 if (retval < 0)
198 goto _error; 194 goto _error;
199 195
200 bprm->recursion_depth++;
201
202 retval = search_binary_handler(bprm); 196 retval = search_binary_handler(bprm);
203 if (retval < 0) 197 if (retval < 0)
204 goto _error; 198 goto _error;
diff --git a/fs/binfmt_script.c b/fs/binfmt_script.c
index 8c954997e7f7..1610a91637e5 100644
--- a/fs/binfmt_script.c
+++ b/fs/binfmt_script.c
@@ -22,15 +22,13 @@ static int load_script(struct linux_binprm *bprm)
22 char interp[BINPRM_BUF_SIZE]; 22 char interp[BINPRM_BUF_SIZE];
23 int retval; 23 int retval;
24 24
25 if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!') || 25 if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!'))
26 (bprm->recursion_depth > BINPRM_MAX_RECURSION))
27 return -ENOEXEC; 26 return -ENOEXEC;
28 /* 27 /*
29 * This section does the #! interpretation. 28 * This section does the #! interpretation.
30 * Sorta complicated, but hopefully it will work. -TYT 29 * Sorta complicated, but hopefully it will work. -TYT
31 */ 30 */
32 31
33 bprm->recursion_depth++;
34 allow_write_access(bprm->file); 32 allow_write_access(bprm->file);
35 fput(bprm->file); 33 fput(bprm->file);
36 bprm->file = NULL; 34 bprm->file = NULL;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index ab3a456f6650..172f8491a2bd 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -321,7 +321,7 @@ static int blkdev_write_end(struct file *file, struct address_space *mapping,
321 * for a block special file file->f_path.dentry->d_inode->i_size is zero 321 * for a block special file file->f_path.dentry->d_inode->i_size is zero
322 * so we compute the size by hand (just as in block_read/write above) 322 * so we compute the size by hand (just as in block_read/write above)
323 */ 323 */
324static loff_t block_llseek(struct file *file, loff_t offset, int origin) 324static loff_t block_llseek(struct file *file, loff_t offset, int whence)
325{ 325{
326 struct inode *bd_inode = file->f_mapping->host; 326 struct inode *bd_inode = file->f_mapping->host;
327 loff_t size; 327 loff_t size;
@@ -331,7 +331,7 @@ static loff_t block_llseek(struct file *file, loff_t offset, int origin)
331 size = i_size_read(bd_inode); 331 size = i_size_read(bd_inode);
332 332
333 retval = -EINVAL; 333 retval = -EINVAL;
334 switch (origin) { 334 switch (whence) {
335 case SEEK_END: 335 case SEEK_END:
336 offset += size; 336 offset += size;
337 break; 337 break;
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index a8ee75cb96ee..9c6673a9231f 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2120,7 +2120,7 @@ out:
2120 return ret; 2120 return ret;
2121} 2121}
2122 2122
2123static int find_desired_extent(struct inode *inode, loff_t *offset, int origin) 2123static int find_desired_extent(struct inode *inode, loff_t *offset, int whence)
2124{ 2124{
2125 struct btrfs_root *root = BTRFS_I(inode)->root; 2125 struct btrfs_root *root = BTRFS_I(inode)->root;
2126 struct extent_map *em; 2126 struct extent_map *em;
@@ -2154,7 +2154,7 @@ static int find_desired_extent(struct inode *inode, loff_t *offset, int origin)
2154 * before the position we want in case there is outstanding delalloc 2154 * before the position we want in case there is outstanding delalloc
2155 * going on here. 2155 * going on here.
2156 */ 2156 */
2157 if (origin == SEEK_HOLE && start != 0) { 2157 if (whence == SEEK_HOLE && start != 0) {
2158 if (start <= root->sectorsize) 2158 if (start <= root->sectorsize)
2159 em = btrfs_get_extent_fiemap(inode, NULL, 0, 0, 2159 em = btrfs_get_extent_fiemap(inode, NULL, 0, 0,
2160 root->sectorsize, 0); 2160 root->sectorsize, 0);
@@ -2188,13 +2188,13 @@ static int find_desired_extent(struct inode *inode, loff_t *offset, int origin)
2188 } 2188 }
2189 } 2189 }
2190 2190
2191 if (origin == SEEK_HOLE) { 2191 if (whence == SEEK_HOLE) {
2192 *offset = start; 2192 *offset = start;
2193 free_extent_map(em); 2193 free_extent_map(em);
2194 break; 2194 break;
2195 } 2195 }
2196 } else { 2196 } else {
2197 if (origin == SEEK_DATA) { 2197 if (whence == SEEK_DATA) {
2198 if (em->block_start == EXTENT_MAP_DELALLOC) { 2198 if (em->block_start == EXTENT_MAP_DELALLOC) {
2199 if (start >= inode->i_size) { 2199 if (start >= inode->i_size) {
2200 free_extent_map(em); 2200 free_extent_map(em);
@@ -2231,16 +2231,16 @@ out:
2231 return ret; 2231 return ret;
2232} 2232}
2233 2233
2234static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int origin) 2234static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int whence)
2235{ 2235{
2236 struct inode *inode = file->f_mapping->host; 2236 struct inode *inode = file->f_mapping->host;
2237 int ret; 2237 int ret;
2238 2238
2239 mutex_lock(&inode->i_mutex); 2239 mutex_lock(&inode->i_mutex);
2240 switch (origin) { 2240 switch (whence) {
2241 case SEEK_END: 2241 case SEEK_END:
2242 case SEEK_CUR: 2242 case SEEK_CUR:
2243 offset = generic_file_llseek(file, offset, origin); 2243 offset = generic_file_llseek(file, offset, whence);
2244 goto out; 2244 goto out;
2245 case SEEK_DATA: 2245 case SEEK_DATA:
2246 case SEEK_HOLE: 2246 case SEEK_HOLE:
@@ -2249,7 +2249,7 @@ static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int origin)
2249 return -ENXIO; 2249 return -ENXIO;
2250 } 2250 }
2251 2251
2252 ret = find_desired_extent(inode, &offset, origin); 2252 ret = find_desired_extent(inode, &offset, whence);
2253 if (ret) { 2253 if (ret) {
2254 mutex_unlock(&inode->i_mutex); 2254 mutex_unlock(&inode->i_mutex);
2255 return ret; 2255 return ret;
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index e5b77319c97b..8c1aabe93b67 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -454,7 +454,7 @@ static void reset_readdir(struct ceph_file_info *fi)
454 fi->flags &= ~CEPH_F_ATEND; 454 fi->flags &= ~CEPH_F_ATEND;
455} 455}
456 456
457static loff_t ceph_dir_llseek(struct file *file, loff_t offset, int origin) 457static loff_t ceph_dir_llseek(struct file *file, loff_t offset, int whence)
458{ 458{
459 struct ceph_file_info *fi = file->private_data; 459 struct ceph_file_info *fi = file->private_data;
460 struct inode *inode = file->f_mapping->host; 460 struct inode *inode = file->f_mapping->host;
@@ -463,7 +463,7 @@ static loff_t ceph_dir_llseek(struct file *file, loff_t offset, int origin)
463 463
464 mutex_lock(&inode->i_mutex); 464 mutex_lock(&inode->i_mutex);
465 retval = -EINVAL; 465 retval = -EINVAL;
466 switch (origin) { 466 switch (whence) {
467 case SEEK_END: 467 case SEEK_END:
468 offset += inode->i_size + 2; /* FIXME */ 468 offset += inode->i_size + 2; /* FIXME */
469 break; 469 break;
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 5840d2aaed15..d4dfdcf76d7f 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -797,7 +797,7 @@ out:
797/* 797/*
798 * llseek. be sure to verify file size on SEEK_END. 798 * llseek. be sure to verify file size on SEEK_END.
799 */ 799 */
800static loff_t ceph_llseek(struct file *file, loff_t offset, int origin) 800static loff_t ceph_llseek(struct file *file, loff_t offset, int whence)
801{ 801{
802 struct inode *inode = file->f_mapping->host; 802 struct inode *inode = file->f_mapping->host;
803 int ret; 803 int ret;
@@ -805,7 +805,7 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int origin)
805 mutex_lock(&inode->i_mutex); 805 mutex_lock(&inode->i_mutex);
806 __ceph_do_pending_vmtruncate(inode); 806 __ceph_do_pending_vmtruncate(inode);
807 807
808 if (origin == SEEK_END || origin == SEEK_DATA || origin == SEEK_HOLE) { 808 if (whence == SEEK_END || whence == SEEK_DATA || whence == SEEK_HOLE) {
809 ret = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE); 809 ret = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE);
810 if (ret < 0) { 810 if (ret < 0) {
811 offset = ret; 811 offset = ret;
@@ -813,7 +813,7 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int origin)
813 } 813 }
814 } 814 }
815 815
816 switch (origin) { 816 switch (whence) {
817 case SEEK_END: 817 case SEEK_END:
818 offset += inode->i_size; 818 offset += inode->i_size;
819 break; 819 break;
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 210f0af83fc4..ce9f3c5421bf 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -695,13 +695,13 @@ static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
695 return written; 695 return written;
696} 696}
697 697
698static loff_t cifs_llseek(struct file *file, loff_t offset, int origin) 698static loff_t cifs_llseek(struct file *file, loff_t offset, int whence)
699{ 699{
700 /* 700 /*
701 * origin == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate 701 * whence == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate
702 * the cached file length 702 * the cached file length
703 */ 703 */
704 if (origin != SEEK_SET && origin != SEEK_CUR) { 704 if (whence != SEEK_SET && whence != SEEK_CUR) {
705 int rc; 705 int rc;
706 struct inode *inode = file->f_path.dentry->d_inode; 706 struct inode *inode = file->f_path.dentry->d_inode;
707 707
@@ -728,7 +728,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
728 if (rc < 0) 728 if (rc < 0)
729 return (loff_t)rc; 729 return (loff_t)rc;
730 } 730 }
731 return generic_file_llseek(file, offset, origin); 731 return generic_file_llseek(file, offset, whence);
732} 732}
733 733
734static int cifs_setlease(struct file *file, long arg, struct file_lock **lease) 734static int cifs_setlease(struct file *file, long arg, struct file_lock **lease)
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 7414ae24a79b..712b10f64c70 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -1613,12 +1613,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
1613 return 0; 1613 return 0;
1614} 1614}
1615 1615
1616static loff_t configfs_dir_lseek(struct file * file, loff_t offset, int origin) 1616static loff_t configfs_dir_lseek(struct file *file, loff_t offset, int whence)
1617{ 1617{
1618 struct dentry * dentry = file->f_path.dentry; 1618 struct dentry * dentry = file->f_path.dentry;
1619 1619
1620 mutex_lock(&dentry->d_inode->i_mutex); 1620 mutex_lock(&dentry->d_inode->i_mutex);
1621 switch (origin) { 1621 switch (whence) {
1622 case 1: 1622 case 1:
1623 offset += file->f_pos; 1623 offset += file->f_pos;
1624 case 0: 1624 case 0:
diff --git a/fs/eventfd.c b/fs/eventfd.c
index d81b9f654086..35470d9b96e6 100644
--- a/fs/eventfd.c
+++ b/fs/eventfd.c
@@ -19,6 +19,8 @@
19#include <linux/export.h> 19#include <linux/export.h>
20#include <linux/kref.h> 20#include <linux/kref.h>
21#include <linux/eventfd.h> 21#include <linux/eventfd.h>
22#include <linux/proc_fs.h>
23#include <linux/seq_file.h>
22 24
23struct eventfd_ctx { 25struct eventfd_ctx {
24 struct kref kref; 26 struct kref kref;
@@ -284,7 +286,25 @@ static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t c
284 return res; 286 return res;
285} 287}
286 288
289#ifdef CONFIG_PROC_FS
290static int eventfd_show_fdinfo(struct seq_file *m, struct file *f)
291{
292 struct eventfd_ctx *ctx = f->private_data;
293 int ret;
294
295 spin_lock_irq(&ctx->wqh.lock);
296 ret = seq_printf(m, "eventfd-count: %16llx\n",
297 (unsigned long long)ctx->count);
298 spin_unlock_irq(&ctx->wqh.lock);
299
300 return ret;
301}
302#endif
303
287static const struct file_operations eventfd_fops = { 304static const struct file_operations eventfd_fops = {
305#ifdef CONFIG_PROC_FS
306 .show_fdinfo = eventfd_show_fdinfo,
307#endif
288 .release = eventfd_release, 308 .release = eventfd_release,
289 .poll = eventfd_poll, 309 .poll = eventfd_poll,
290 .read = eventfd_read, 310 .read = eventfd_read,
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index cd96649bfe62..be56b21435f8 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -38,6 +38,8 @@
38#include <asm/io.h> 38#include <asm/io.h>
39#include <asm/mman.h> 39#include <asm/mman.h>
40#include <linux/atomic.h> 40#include <linux/atomic.h>
41#include <linux/proc_fs.h>
42#include <linux/seq_file.h>
41 43
42/* 44/*
43 * LOCKING: 45 * LOCKING:
@@ -783,8 +785,34 @@ static unsigned int ep_eventpoll_poll(struct file *file, poll_table *wait)
783 return pollflags != -1 ? pollflags : 0; 785 return pollflags != -1 ? pollflags : 0;
784} 786}
785 787
788#ifdef CONFIG_PROC_FS
789static int ep_show_fdinfo(struct seq_file *m, struct file *f)
790{
791 struct eventpoll *ep = f->private_data;
792 struct rb_node *rbp;
793 int ret = 0;
794
795 mutex_lock(&ep->mtx);
796 for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) {
797 struct epitem *epi = rb_entry(rbp, struct epitem, rbn);
798
799 ret = seq_printf(m, "tfd: %8d events: %8x data: %16llx\n",
800 epi->ffd.fd, epi->event.events,
801 (long long)epi->event.data);
802 if (ret)
803 break;
804 }
805 mutex_unlock(&ep->mtx);
806
807 return ret;
808}
809#endif
810
786/* File callbacks that implement the eventpoll file behaviour */ 811/* File callbacks that implement the eventpoll file behaviour */
787static const struct file_operations eventpoll_fops = { 812static const struct file_operations eventpoll_fops = {
813#ifdef CONFIG_PROC_FS
814 .show_fdinfo = ep_show_fdinfo,
815#endif
788 .release = ep_eventpoll_release, 816 .release = ep_eventpoll_release,
789 .poll = ep_eventpoll_poll, 817 .poll = ep_eventpoll_poll,
790 .llseek = noop_llseek, 818 .llseek = noop_llseek,
diff --git a/fs/exec.c b/fs/exec.c
index b71b08ce7120..d8e1191cb112 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1353,6 +1353,10 @@ int search_binary_handler(struct linux_binprm *bprm)
1353 struct linux_binfmt *fmt; 1353 struct linux_binfmt *fmt;
1354 pid_t old_pid, old_vpid; 1354 pid_t old_pid, old_vpid;
1355 1355
1356 /* This allows 4 levels of binfmt rewrites before failing hard. */
1357 if (depth > 5)
1358 return -ELOOP;
1359
1356 retval = security_bprm_check(bprm); 1360 retval = security_bprm_check(bprm);
1357 if (retval) 1361 if (retval)
1358 return retval; 1362 return retval;
@@ -1377,12 +1381,8 @@ int search_binary_handler(struct linux_binprm *bprm)
1377 if (!try_module_get(fmt->module)) 1381 if (!try_module_get(fmt->module))
1378 continue; 1382 continue;
1379 read_unlock(&binfmt_lock); 1383 read_unlock(&binfmt_lock);
1384 bprm->recursion_depth = depth + 1;
1380 retval = fn(bprm); 1385 retval = fn(bprm);
1381 /*
1382 * Restore the depth counter to its starting value
1383 * in this call, so we don't have to rely on every
1384 * load_binary function to restore it on return.
1385 */
1386 bprm->recursion_depth = depth; 1386 bprm->recursion_depth = depth;
1387 if (retval >= 0) { 1387 if (retval >= 0) {
1388 if (depth == 0) { 1388 if (depth == 0) {
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
index 29ab099e3e08..606bb074c501 100644
--- a/fs/exportfs/expfs.c
+++ b/fs/exportfs/expfs.c
@@ -341,10 +341,21 @@ static int export_encode_fh(struct inode *inode, struct fid *fid,
341 return type; 341 return type;
342} 342}
343 343
344int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
345 int *max_len, struct inode *parent)
346{
347 const struct export_operations *nop = inode->i_sb->s_export_op;
348
349 if (nop && nop->encode_fh)
350 return nop->encode_fh(inode, fid->raw, max_len, parent);
351
352 return export_encode_fh(inode, fid, max_len, parent);
353}
354EXPORT_SYMBOL_GPL(exportfs_encode_inode_fh);
355
344int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len, 356int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len,
345 int connectable) 357 int connectable)
346{ 358{
347 const struct export_operations *nop = dentry->d_sb->s_export_op;
348 int error; 359 int error;
349 struct dentry *p = NULL; 360 struct dentry *p = NULL;
350 struct inode *inode = dentry->d_inode, *parent = NULL; 361 struct inode *inode = dentry->d_inode, *parent = NULL;
@@ -357,10 +368,8 @@ int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len,
357 */ 368 */
358 parent = p->d_inode; 369 parent = p->d_inode;
359 } 370 }
360 if (nop->encode_fh) 371
361 error = nop->encode_fh(inode, fid->raw, max_len, parent); 372 error = exportfs_encode_inode_fh(inode, fid, max_len, parent);
362 else
363 error = export_encode_fh(inode, fid, max_len, parent);
364 dput(p); 373 dput(p);
365 374
366 return error; 375 return error;
diff --git a/fs/ext3/dir.c b/fs/ext3/dir.c
index c8fff930790d..dd91264ba94f 100644
--- a/fs/ext3/dir.c
+++ b/fs/ext3/dir.c
@@ -296,17 +296,17 @@ static inline loff_t ext3_get_htree_eof(struct file *filp)
296 * NOTE: offsets obtained *before* ext3_set_inode_flag(dir, EXT3_INODE_INDEX) 296 * NOTE: offsets obtained *before* ext3_set_inode_flag(dir, EXT3_INODE_INDEX)
297 * will be invalid once the directory was converted into a dx directory 297 * will be invalid once the directory was converted into a dx directory
298 */ 298 */
299loff_t ext3_dir_llseek(struct file *file, loff_t offset, int origin) 299loff_t ext3_dir_llseek(struct file *file, loff_t offset, int whence)
300{ 300{
301 struct inode *inode = file->f_mapping->host; 301 struct inode *inode = file->f_mapping->host;
302 int dx_dir = is_dx_dir(inode); 302 int dx_dir = is_dx_dir(inode);
303 loff_t htree_max = ext3_get_htree_eof(file); 303 loff_t htree_max = ext3_get_htree_eof(file);
304 304
305 if (likely(dx_dir)) 305 if (likely(dx_dir))
306 return generic_file_llseek_size(file, offset, origin, 306 return generic_file_llseek_size(file, offset, whence,
307 htree_max, htree_max); 307 htree_max, htree_max);
308 else 308 else
309 return generic_file_llseek(file, offset, origin); 309 return generic_file_llseek(file, offset, whence);
310} 310}
311 311
312/* 312/*
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index b8d877f6c1fa..80a28b297279 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -333,17 +333,17 @@ static inline loff_t ext4_get_htree_eof(struct file *filp)
333 * 333 *
334 * For non-htree, ext4_llseek already chooses the proper max offset. 334 * For non-htree, ext4_llseek already chooses the proper max offset.
335 */ 335 */
336loff_t ext4_dir_llseek(struct file *file, loff_t offset, int origin) 336loff_t ext4_dir_llseek(struct file *file, loff_t offset, int whence)
337{ 337{
338 struct inode *inode = file->f_mapping->host; 338 struct inode *inode = file->f_mapping->host;
339 int dx_dir = is_dx_dir(inode); 339 int dx_dir = is_dx_dir(inode);
340 loff_t htree_max = ext4_get_htree_eof(file); 340 loff_t htree_max = ext4_get_htree_eof(file);
341 341
342 if (likely(dx_dir)) 342 if (likely(dx_dir))
343 return generic_file_llseek_size(file, offset, origin, 343 return generic_file_llseek_size(file, offset, whence,
344 htree_max, htree_max); 344 htree_max, htree_max);
345 else 345 else
346 return ext4_llseek(file, offset, origin); 346 return ext4_llseek(file, offset, whence);
347} 347}
348 348
349/* 349/*
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index b64a60bf105a..d07c27ca594a 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -303,7 +303,7 @@ static int ext4_file_open(struct inode * inode, struct file * filp)
303 * page cache has data or not. 303 * page cache has data or not.
304 */ 304 */
305static int ext4_find_unwritten_pgoff(struct inode *inode, 305static int ext4_find_unwritten_pgoff(struct inode *inode,
306 int origin, 306 int whence,
307 struct ext4_map_blocks *map, 307 struct ext4_map_blocks *map,
308 loff_t *offset) 308 loff_t *offset)
309{ 309{
@@ -333,10 +333,10 @@ static int ext4_find_unwritten_pgoff(struct inode *inode,
333 nr_pages = pagevec_lookup(&pvec, inode->i_mapping, index, 333 nr_pages = pagevec_lookup(&pvec, inode->i_mapping, index,
334 (pgoff_t)num); 334 (pgoff_t)num);
335 if (nr_pages == 0) { 335 if (nr_pages == 0) {
336 if (origin == SEEK_DATA) 336 if (whence == SEEK_DATA)
337 break; 337 break;
338 338
339 BUG_ON(origin != SEEK_HOLE); 339 BUG_ON(whence != SEEK_HOLE);
340 /* 340 /*
341 * If this is the first time to go into the loop and 341 * If this is the first time to go into the loop and
342 * offset is not beyond the end offset, it will be a 342 * offset is not beyond the end offset, it will be a
@@ -352,7 +352,7 @@ static int ext4_find_unwritten_pgoff(struct inode *inode,
352 * offset is smaller than the first page offset, it will be a 352 * offset is smaller than the first page offset, it will be a
353 * hole at this offset. 353 * hole at this offset.
354 */ 354 */
355 if (lastoff == startoff && origin == SEEK_HOLE && 355 if (lastoff == startoff && whence == SEEK_HOLE &&
356 lastoff < page_offset(pvec.pages[0])) { 356 lastoff < page_offset(pvec.pages[0])) {
357 found = 1; 357 found = 1;
358 break; 358 break;
@@ -366,7 +366,7 @@ static int ext4_find_unwritten_pgoff(struct inode *inode,
366 * If the current offset is not beyond the end of given 366 * If the current offset is not beyond the end of given
367 * range, it will be a hole. 367 * range, it will be a hole.
368 */ 368 */
369 if (lastoff < endoff && origin == SEEK_HOLE && 369 if (lastoff < endoff && whence == SEEK_HOLE &&
370 page->index > end) { 370 page->index > end) {
371 found = 1; 371 found = 1;
372 *offset = lastoff; 372 *offset = lastoff;
@@ -391,10 +391,10 @@ static int ext4_find_unwritten_pgoff(struct inode *inode,
391 do { 391 do {
392 if (buffer_uptodate(bh) || 392 if (buffer_uptodate(bh) ||
393 buffer_unwritten(bh)) { 393 buffer_unwritten(bh)) {
394 if (origin == SEEK_DATA) 394 if (whence == SEEK_DATA)
395 found = 1; 395 found = 1;
396 } else { 396 } else {
397 if (origin == SEEK_HOLE) 397 if (whence == SEEK_HOLE)
398 found = 1; 398 found = 1;
399 } 399 }
400 if (found) { 400 if (found) {
@@ -416,7 +416,7 @@ static int ext4_find_unwritten_pgoff(struct inode *inode,
416 * The no. of pages is less than our desired, that would be a 416 * The no. of pages is less than our desired, that would be a
417 * hole in there. 417 * hole in there.
418 */ 418 */
419 if (nr_pages < num && origin == SEEK_HOLE) { 419 if (nr_pages < num && whence == SEEK_HOLE) {
420 found = 1; 420 found = 1;
421 *offset = lastoff; 421 *offset = lastoff;
422 break; 422 break;
@@ -609,7 +609,7 @@ static loff_t ext4_seek_hole(struct file *file, loff_t offset, loff_t maxsize)
609 * by calling generic_file_llseek_size() with the appropriate maxbytes 609 * by calling generic_file_llseek_size() with the appropriate maxbytes
610 * value for each. 610 * value for each.
611 */ 611 */
612loff_t ext4_llseek(struct file *file, loff_t offset, int origin) 612loff_t ext4_llseek(struct file *file, loff_t offset, int whence)
613{ 613{
614 struct inode *inode = file->f_mapping->host; 614 struct inode *inode = file->f_mapping->host;
615 loff_t maxbytes; 615 loff_t maxbytes;
@@ -619,11 +619,11 @@ loff_t ext4_llseek(struct file *file, loff_t offset, int origin)
619 else 619 else
620 maxbytes = inode->i_sb->s_maxbytes; 620 maxbytes = inode->i_sb->s_maxbytes;
621 621
622 switch (origin) { 622 switch (whence) {
623 case SEEK_SET: 623 case SEEK_SET:
624 case SEEK_CUR: 624 case SEEK_CUR:
625 case SEEK_END: 625 case SEEK_END:
626 return generic_file_llseek_size(file, offset, origin, 626 return generic_file_llseek_size(file, offset, whence,
627 maxbytes, i_size_read(inode)); 627 maxbytes, i_size_read(inode));
628 case SEEK_DATA: 628 case SEEK_DATA:
629 return ext4_seek_data(file, offset, maxbytes); 629 return ext4_seek_data(file, offset, maxbytes);
diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index 623f36f0423b..12701a567752 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -29,6 +29,7 @@ struct fat_mount_options {
29 unsigned short fs_fmask; 29 unsigned short fs_fmask;
30 unsigned short fs_dmask; 30 unsigned short fs_dmask;
31 unsigned short codepage; /* Codepage for shortname conversions */ 31 unsigned short codepage; /* Codepage for shortname conversions */
32 int time_offset; /* Offset of timestamps from UTC (in minutes) */
32 char *iocharset; /* Charset used for filename input/display */ 33 char *iocharset; /* Charset used for filename input/display */
33 unsigned short shortname; /* flags for shortname display/create rule */ 34 unsigned short shortname; /* flags for shortname display/create rule */
34 unsigned char name_check; /* r = relaxed, n = normal, s = strict */ 35 unsigned char name_check; /* r = relaxed, n = normal, s = strict */
@@ -45,7 +46,7 @@ struct fat_mount_options {
45 flush:1, /* write things quickly */ 46 flush:1, /* write things quickly */
46 nocase:1, /* Does this need case conversion? 0=need case conversion*/ 47 nocase:1, /* Does this need case conversion? 0=need case conversion*/
47 usefree:1, /* Use free_clusters for FAT32 */ 48 usefree:1, /* Use free_clusters for FAT32 */
48 tz_utc:1, /* Filesystem timestamps are in UTC */ 49 tz_set:1, /* Filesystem timestamps' offset set */
49 rodir:1, /* allow ATTR_RO for directory */ 50 rodir:1, /* allow ATTR_RO for directory */
50 discard:1, /* Issue discard requests on deletions */ 51 discard:1, /* Issue discard requests on deletions */
51 nfs:1; /* Do extra work needed for NFS export */ 52 nfs:1; /* Do extra work needed for NFS export */
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 5bafaad00530..35806813ea4e 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -26,6 +26,7 @@
26#include <linux/writeback.h> 26#include <linux/writeback.h>
27#include <linux/log2.h> 27#include <linux/log2.h>
28#include <linux/hash.h> 28#include <linux/hash.h>
29#include <linux/blkdev.h>
29#include <asm/unaligned.h> 30#include <asm/unaligned.h>
30#include "fat.h" 31#include "fat.h"
31 32
@@ -725,7 +726,8 @@ static int fat_show_options(struct seq_file *m, struct dentry *root)
725 if (opts->allow_utime) 726 if (opts->allow_utime)
726 seq_printf(m, ",allow_utime=%04o", opts->allow_utime); 727 seq_printf(m, ",allow_utime=%04o", opts->allow_utime);
727 if (sbi->nls_disk) 728 if (sbi->nls_disk)
728 seq_printf(m, ",codepage=%s", sbi->nls_disk->charset); 729 /* strip "cp" prefix from displayed option */
730 seq_printf(m, ",codepage=%s", &sbi->nls_disk->charset[2]);
729 if (isvfat) { 731 if (isvfat) {
730 if (sbi->nls_io) 732 if (sbi->nls_io)
731 seq_printf(m, ",iocharset=%s", sbi->nls_io->charset); 733 seq_printf(m, ",iocharset=%s", sbi->nls_io->charset);
@@ -777,8 +779,12 @@ static int fat_show_options(struct seq_file *m, struct dentry *root)
777 } 779 }
778 if (opts->flush) 780 if (opts->flush)
779 seq_puts(m, ",flush"); 781 seq_puts(m, ",flush");
780 if (opts->tz_utc) 782 if (opts->tz_set) {
781 seq_puts(m, ",tz=UTC"); 783 if (opts->time_offset)
784 seq_printf(m, ",time_offset=%d", opts->time_offset);
785 else
786 seq_puts(m, ",tz=UTC");
787 }
782 if (opts->errors == FAT_ERRORS_CONT) 788 if (opts->errors == FAT_ERRORS_CONT)
783 seq_puts(m, ",errors=continue"); 789 seq_puts(m, ",errors=continue");
784 else if (opts->errors == FAT_ERRORS_PANIC) 790 else if (opts->errors == FAT_ERRORS_PANIC)
@@ -800,7 +806,8 @@ enum {
800 Opt_shortname_winnt, Opt_shortname_mixed, Opt_utf8_no, Opt_utf8_yes, 806 Opt_shortname_winnt, Opt_shortname_mixed, Opt_utf8_no, Opt_utf8_yes,
801 Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes, 807 Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes,
802 Opt_obsolete, Opt_flush, Opt_tz_utc, Opt_rodir, Opt_err_cont, 808 Opt_obsolete, Opt_flush, Opt_tz_utc, Opt_rodir, Opt_err_cont,
803 Opt_err_panic, Opt_err_ro, Opt_discard, Opt_nfs, Opt_err, 809 Opt_err_panic, Opt_err_ro, Opt_discard, Opt_nfs, Opt_time_offset,
810 Opt_err,
804}; 811};
805 812
806static const match_table_t fat_tokens = { 813static const match_table_t fat_tokens = {
@@ -825,6 +832,7 @@ static const match_table_t fat_tokens = {
825 {Opt_immutable, "sys_immutable"}, 832 {Opt_immutable, "sys_immutable"},
826 {Opt_flush, "flush"}, 833 {Opt_flush, "flush"},
827 {Opt_tz_utc, "tz=UTC"}, 834 {Opt_tz_utc, "tz=UTC"},
835 {Opt_time_offset, "time_offset=%d"},
828 {Opt_err_cont, "errors=continue"}, 836 {Opt_err_cont, "errors=continue"},
829 {Opt_err_panic, "errors=panic"}, 837 {Opt_err_panic, "errors=panic"},
830 {Opt_err_ro, "errors=remount-ro"}, 838 {Opt_err_ro, "errors=remount-ro"},
@@ -909,7 +917,7 @@ static int parse_options(struct super_block *sb, char *options, int is_vfat,
909 opts->utf8 = opts->unicode_xlate = 0; 917 opts->utf8 = opts->unicode_xlate = 0;
910 opts->numtail = 1; 918 opts->numtail = 1;
911 opts->usefree = opts->nocase = 0; 919 opts->usefree = opts->nocase = 0;
912 opts->tz_utc = 0; 920 opts->tz_set = 0;
913 opts->nfs = 0; 921 opts->nfs = 0;
914 opts->errors = FAT_ERRORS_RO; 922 opts->errors = FAT_ERRORS_RO;
915 *debug = 0; 923 *debug = 0;
@@ -965,48 +973,57 @@ static int parse_options(struct super_block *sb, char *options, int is_vfat,
965 break; 973 break;
966 case Opt_uid: 974 case Opt_uid:
967 if (match_int(&args[0], &option)) 975 if (match_int(&args[0], &option))
968 return 0; 976 return -EINVAL;
969 opts->fs_uid = make_kuid(current_user_ns(), option); 977 opts->fs_uid = make_kuid(current_user_ns(), option);
970 if (!uid_valid(opts->fs_uid)) 978 if (!uid_valid(opts->fs_uid))
971 return 0; 979 return -EINVAL;
972 break; 980 break;
973 case Opt_gid: 981 case Opt_gid:
974 if (match_int(&args[0], &option)) 982 if (match_int(&args[0], &option))
975 return 0; 983 return -EINVAL;
976 opts->fs_gid = make_kgid(current_user_ns(), option); 984 opts->fs_gid = make_kgid(current_user_ns(), option);
977 if (!gid_valid(opts->fs_gid)) 985 if (!gid_valid(opts->fs_gid))
978 return 0; 986 return -EINVAL;
979 break; 987 break;
980 case Opt_umask: 988 case Opt_umask:
981 if (match_octal(&args[0], &option)) 989 if (match_octal(&args[0], &option))
982 return 0; 990 return -EINVAL;
983 opts->fs_fmask = opts->fs_dmask = option; 991 opts->fs_fmask = opts->fs_dmask = option;
984 break; 992 break;
985 case Opt_dmask: 993 case Opt_dmask:
986 if (match_octal(&args[0], &option)) 994 if (match_octal(&args[0], &option))
987 return 0; 995 return -EINVAL;
988 opts->fs_dmask = option; 996 opts->fs_dmask = option;
989 break; 997 break;
990 case Opt_fmask: 998 case Opt_fmask:
991 if (match_octal(&args[0], &option)) 999 if (match_octal(&args[0], &option))
992 return 0; 1000 return -EINVAL;
993 opts->fs_fmask = option; 1001 opts->fs_fmask = option;
994 break; 1002 break;
995 case Opt_allow_utime: 1003 case Opt_allow_utime:
996 if (match_octal(&args[0], &option)) 1004 if (match_octal(&args[0], &option))
997 return 0; 1005 return -EINVAL;
998 opts->allow_utime = option & (S_IWGRP | S_IWOTH); 1006 opts->allow_utime = option & (S_IWGRP | S_IWOTH);
999 break; 1007 break;
1000 case Opt_codepage: 1008 case Opt_codepage:
1001 if (match_int(&args[0], &option)) 1009 if (match_int(&args[0], &option))
1002 return 0; 1010 return -EINVAL;
1003 opts->codepage = option; 1011 opts->codepage = option;
1004 break; 1012 break;
1005 case Opt_flush: 1013 case Opt_flush:
1006 opts->flush = 1; 1014 opts->flush = 1;
1007 break; 1015 break;
1016 case Opt_time_offset:
1017 if (match_int(&args[0], &option))
1018 return -EINVAL;
1019 if (option < -12 * 60 || option > 12 * 60)
1020 return -EINVAL;
1021 opts->tz_set = 1;
1022 opts->time_offset = option;
1023 break;
1008 case Opt_tz_utc: 1024 case Opt_tz_utc:
1009 opts->tz_utc = 1; 1025 opts->tz_set = 1;
1026 opts->time_offset = 0;
1010 break; 1027 break;
1011 case Opt_err_cont: 1028 case Opt_err_cont:
1012 opts->errors = FAT_ERRORS_CONT; 1029 opts->errors = FAT_ERRORS_CONT;
@@ -1431,6 +1448,14 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
1431 goto out_fail; 1448 goto out_fail;
1432 } 1449 }
1433 1450
1451 if (sbi->options.discard) {
1452 struct request_queue *q = bdev_get_queue(sb->s_bdev);
1453 if (!blk_queue_discard(q))
1454 fat_msg(sb, KERN_WARNING,
1455 "mounting with \"discard\" option, but "
1456 "the device does not support discard");
1457 }
1458
1434 return 0; 1459 return 0;
1435 1460
1436out_invalid: 1461out_invalid:
diff --git a/fs/fat/misc.c b/fs/fat/misc.c
index 6d93360ca0cc..5eb600dc43a9 100644
--- a/fs/fat/misc.c
+++ b/fs/fat/misc.c
@@ -212,8 +212,10 @@ void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts,
212 + days_in_year[month] + day 212 + days_in_year[month] + day
213 + DAYS_DELTA) * SECS_PER_DAY; 213 + DAYS_DELTA) * SECS_PER_DAY;
214 214
215 if (!sbi->options.tz_utc) 215 if (!sbi->options.tz_set)
216 second += sys_tz.tz_minuteswest * SECS_PER_MIN; 216 second += sys_tz.tz_minuteswest * SECS_PER_MIN;
217 else
218 second -= sbi->options.time_offset * SECS_PER_MIN;
217 219
218 if (time_cs) { 220 if (time_cs) {
219 ts->tv_sec = second + (time_cs / 100); 221 ts->tv_sec = second + (time_cs / 100);
@@ -229,8 +231,9 @@ void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec *ts,
229 __le16 *time, __le16 *date, u8 *time_cs) 231 __le16 *time, __le16 *date, u8 *time_cs)
230{ 232{
231 struct tm tm; 233 struct tm tm;
232 time_to_tm(ts->tv_sec, sbi->options.tz_utc ? 0 : 234 time_to_tm(ts->tv_sec,
233 -sys_tz.tz_minuteswest * 60, &tm); 235 (sbi->options.tz_set ? sbi->options.time_offset :
236 -sys_tz.tz_minuteswest) * SECS_PER_MIN, &tm);
234 237
235 /* FAT can only support year between 1980 to 2107 */ 238 /* FAT can only support year between 1980 to 2107 */
236 if (tm.tm_year < 1980 - 1900) { 239 if (tm.tm_year < 1980 - 1900) {
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 78d2837bc940..e21d4d8f87e3 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1599,19 +1599,19 @@ static sector_t fuse_bmap(struct address_space *mapping, sector_t block)
1599 return err ? 0 : outarg.block; 1599 return err ? 0 : outarg.block;
1600} 1600}
1601 1601
1602static loff_t fuse_file_llseek(struct file *file, loff_t offset, int origin) 1602static loff_t fuse_file_llseek(struct file *file, loff_t offset, int whence)
1603{ 1603{
1604 loff_t retval; 1604 loff_t retval;
1605 struct inode *inode = file->f_path.dentry->d_inode; 1605 struct inode *inode = file->f_path.dentry->d_inode;
1606 1606
1607 /* No i_mutex protection necessary for SEEK_CUR and SEEK_SET */ 1607 /* No i_mutex protection necessary for SEEK_CUR and SEEK_SET */
1608 if (origin == SEEK_CUR || origin == SEEK_SET) 1608 if (whence == SEEK_CUR || whence == SEEK_SET)
1609 return generic_file_llseek(file, offset, origin); 1609 return generic_file_llseek(file, offset, whence);
1610 1610
1611 mutex_lock(&inode->i_mutex); 1611 mutex_lock(&inode->i_mutex);
1612 retval = fuse_update_attributes(inode, NULL, file, NULL); 1612 retval = fuse_update_attributes(inode, NULL, file, NULL);
1613 if (!retval) 1613 if (!retval)
1614 retval = generic_file_llseek(file, offset, origin); 1614 retval = generic_file_llseek(file, offset, whence);
1615 mutex_unlock(&inode->i_mutex); 1615 mutex_unlock(&inode->i_mutex);
1616 1616
1617 return retval; 1617 return retval;
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index dfe2d8cb9b2c..991ab2d484dd 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -44,7 +44,7 @@
44 * gfs2_llseek - seek to a location in a file 44 * gfs2_llseek - seek to a location in a file
45 * @file: the file 45 * @file: the file
46 * @offset: the offset 46 * @offset: the offset
47 * @origin: Where to seek from (SEEK_SET, SEEK_CUR, or SEEK_END) 47 * @whence: Where to seek from (SEEK_SET, SEEK_CUR, or SEEK_END)
48 * 48 *
49 * SEEK_END requires the glock for the file because it references the 49 * SEEK_END requires the glock for the file because it references the
50 * file's size. 50 * file's size.
@@ -52,26 +52,26 @@
52 * Returns: The new offset, or errno 52 * Returns: The new offset, or errno
53 */ 53 */
54 54
55static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin) 55static loff_t gfs2_llseek(struct file *file, loff_t offset, int whence)
56{ 56{
57 struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); 57 struct gfs2_inode *ip = GFS2_I(file->f_mapping->host);
58 struct gfs2_holder i_gh; 58 struct gfs2_holder i_gh;
59 loff_t error; 59 loff_t error;
60 60
61 switch (origin) { 61 switch (whence) {
62 case SEEK_END: /* These reference inode->i_size */ 62 case SEEK_END: /* These reference inode->i_size */
63 case SEEK_DATA: 63 case SEEK_DATA:
64 case SEEK_HOLE: 64 case SEEK_HOLE:
65 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, 65 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
66 &i_gh); 66 &i_gh);
67 if (!error) { 67 if (!error) {
68 error = generic_file_llseek(file, offset, origin); 68 error = generic_file_llseek(file, offset, whence);
69 gfs2_glock_dq_uninit(&i_gh); 69 gfs2_glock_dq_uninit(&i_gh);
70 } 70 }
71 break; 71 break;
72 case SEEK_CUR: 72 case SEEK_CUR:
73 case SEEK_SET: 73 case SEEK_SET:
74 error = generic_file_llseek(file, offset, origin); 74 error = generic_file_llseek(file, offset, whence);
75 break; 75 break;
76 default: 76 default:
77 error = -EINVAL; 77 error = -EINVAL;
diff --git a/fs/libfs.c b/fs/libfs.c
index 7cc37ca19cd8..35fc6e74cd88 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -81,11 +81,11 @@ int dcache_dir_close(struct inode *inode, struct file *file)
81 return 0; 81 return 0;
82} 82}
83 83
84loff_t dcache_dir_lseek(struct file *file, loff_t offset, int origin) 84loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence)
85{ 85{
86 struct dentry *dentry = file->f_path.dentry; 86 struct dentry *dentry = file->f_path.dentry;
87 mutex_lock(&dentry->d_inode->i_mutex); 87 mutex_lock(&dentry->d_inode->i_mutex);
88 switch (origin) { 88 switch (whence) {
89 case 1: 89 case 1:
90 offset += file->f_pos; 90 offset += file->f_pos;
91 case 0: 91 case 0:
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index b9e66b7e0c14..1cc71f60b491 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -871,7 +871,7 @@ out:
871 return res; 871 return res;
872} 872}
873 873
874static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin) 874static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence)
875{ 875{
876 struct dentry *dentry = filp->f_path.dentry; 876 struct dentry *dentry = filp->f_path.dentry;
877 struct inode *inode = dentry->d_inode; 877 struct inode *inode = dentry->d_inode;
@@ -880,10 +880,10 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin)
880 dfprintk(FILE, "NFS: llseek dir(%s/%s, %lld, %d)\n", 880 dfprintk(FILE, "NFS: llseek dir(%s/%s, %lld, %d)\n",
881 dentry->d_parent->d_name.name, 881 dentry->d_parent->d_name.name,
882 dentry->d_name.name, 882 dentry->d_name.name,
883 offset, origin); 883 offset, whence);
884 884
885 mutex_lock(&inode->i_mutex); 885 mutex_lock(&inode->i_mutex);
886 switch (origin) { 886 switch (whence) {
887 case 1: 887 case 1:
888 offset += filp->f_pos; 888 offset += filp->f_pos;
889 case 0: 889 case 0:
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 582bb8866131..3c2b893665ba 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -119,18 +119,18 @@ force_reval:
119 return __nfs_revalidate_inode(server, inode); 119 return __nfs_revalidate_inode(server, inode);
120} 120}
121 121
122loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin) 122loff_t nfs_file_llseek(struct file *filp, loff_t offset, int whence)
123{ 123{
124 dprintk("NFS: llseek file(%s/%s, %lld, %d)\n", 124 dprintk("NFS: llseek file(%s/%s, %lld, %d)\n",
125 filp->f_path.dentry->d_parent->d_name.name, 125 filp->f_path.dentry->d_parent->d_name.name,
126 filp->f_path.dentry->d_name.name, 126 filp->f_path.dentry->d_name.name,
127 offset, origin); 127 offset, whence);
128 128
129 /* 129 /*
130 * origin == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate 130 * whence == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate
131 * the cached file length 131 * the cached file length
132 */ 132 */
133 if (origin != SEEK_SET && origin != SEEK_CUR) { 133 if (whence != SEEK_SET && whence != SEEK_CUR) {
134 struct inode *inode = filp->f_mapping->host; 134 struct inode *inode = filp->f_mapping->host;
135 135
136 int retval = nfs_revalidate_file_size(inode, filp); 136 int retval = nfs_revalidate_file_size(inode, filp);
@@ -138,7 +138,7 @@ loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin)
138 return (loff_t)retval; 138 return (loff_t)retval;
139 } 139 }
140 140
141 return generic_file_llseek(filp, offset, origin); 141 return generic_file_llseek(filp, offset, whence);
142} 142}
143EXPORT_SYMBOL_GPL(nfs_file_llseek); 143EXPORT_SYMBOL_GPL(nfs_file_llseek);
144 144
diff --git a/fs/notify/Makefile b/fs/notify/Makefile
index ae5f33a6d868..96d3420d0242 100644
--- a/fs/notify/Makefile
+++ b/fs/notify/Makefile
@@ -1,5 +1,5 @@
1obj-$(CONFIG_FSNOTIFY) += fsnotify.o notification.o group.o inode_mark.o \ 1obj-$(CONFIG_FSNOTIFY) += fsnotify.o notification.o group.o inode_mark.o \
2 mark.o vfsmount_mark.o 2 mark.o vfsmount_mark.o fdinfo.o
3 3
4obj-y += dnotify/ 4obj-y += dnotify/
5obj-y += inotify/ 5obj-y += inotify/
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 6fcaeb8c902e..a5cd9bba022f 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -17,6 +17,7 @@
17#include <asm/ioctls.h> 17#include <asm/ioctls.h>
18 18
19#include "../../mount.h" 19#include "../../mount.h"
20#include "../fdinfo.h"
20 21
21#define FANOTIFY_DEFAULT_MAX_EVENTS 16384 22#define FANOTIFY_DEFAULT_MAX_EVENTS 16384
22#define FANOTIFY_DEFAULT_MAX_MARKS 8192 23#define FANOTIFY_DEFAULT_MAX_MARKS 8192
@@ -428,6 +429,7 @@ static long fanotify_ioctl(struct file *file, unsigned int cmd, unsigned long ar
428} 429}
429 430
430static const struct file_operations fanotify_fops = { 431static const struct file_operations fanotify_fops = {
432 .show_fdinfo = fanotify_show_fdinfo,
431 .poll = fanotify_poll, 433 .poll = fanotify_poll,
432 .read = fanotify_read, 434 .read = fanotify_read,
433 .write = fanotify_write, 435 .write = fanotify_write,
diff --git a/fs/notify/fdinfo.c b/fs/notify/fdinfo.c
new file mode 100644
index 000000000000..514c4b81483d
--- /dev/null
+++ b/fs/notify/fdinfo.c
@@ -0,0 +1,179 @@
1#include <linux/file.h>
2#include <linux/fs.h>
3#include <linux/fsnotify_backend.h>
4#include <linux/idr.h>
5#include <linux/init.h>
6#include <linux/inotify.h>
7#include <linux/fanotify.h>
8#include <linux/kernel.h>
9#include <linux/namei.h>
10#include <linux/sched.h>
11#include <linux/types.h>
12#include <linux/seq_file.h>
13#include <linux/proc_fs.h>
14#include <linux/exportfs.h>
15
16#include "inotify/inotify.h"
17#include "../fs/mount.h"
18
19#if defined(CONFIG_PROC_FS)
20
21#if defined(CONFIG_INOTIFY_USER) || defined(CONFIG_FANOTIFY)
22
23static int show_fdinfo(struct seq_file *m, struct file *f,
24 int (*show)(struct seq_file *m, struct fsnotify_mark *mark))
25{
26 struct fsnotify_group *group = f->private_data;
27 struct fsnotify_mark *mark;
28 int ret = 0;
29
30 spin_lock(&group->mark_lock);
31 list_for_each_entry(mark, &group->marks_list, g_list) {
32 ret = show(m, mark);
33 if (ret)
34 break;
35 }
36 spin_unlock(&group->mark_lock);
37 return ret;
38}
39
40#if defined(CONFIG_EXPORTFS)
41static int show_mark_fhandle(struct seq_file *m, struct inode *inode)
42{
43 struct {
44 struct file_handle handle;
45 u8 pad[64];
46 } f;
47 int size, ret, i;
48
49 f.handle.handle_bytes = sizeof(f.pad);
50 size = f.handle.handle_bytes >> 2;
51
52 ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0);
53 if ((ret == 255) || (ret == -ENOSPC)) {
54 WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret);
55 return 0;
56 }
57
58 f.handle.handle_type = ret;
59 f.handle.handle_bytes = size * sizeof(u32);
60
61 ret = seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:",
62 f.handle.handle_bytes, f.handle.handle_type);
63
64 for (i = 0; i < f.handle.handle_bytes; i++)
65 ret |= seq_printf(m, "%02x", (int)f.handle.f_handle[i]);
66
67 return ret;
68}
69#else
70static int show_mark_fhandle(struct seq_file *m, struct inode *inode)
71{
72 return 0;
73}
74#endif
75
76#ifdef CONFIG_INOTIFY_USER
77
78static int inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
79{
80 struct inotify_inode_mark *inode_mark;
81 struct inode *inode;
82 int ret = 0;
83
84 if (!(mark->flags & (FSNOTIFY_MARK_FLAG_ALIVE | FSNOTIFY_MARK_FLAG_INODE)))
85 return 0;
86
87 inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark);
88 inode = igrab(mark->i.inode);
89 if (inode) {
90 ret = seq_printf(m, "inotify wd:%x ino:%lx sdev:%x "
91 "mask:%x ignored_mask:%x ",
92 inode_mark->wd, inode->i_ino,
93 inode->i_sb->s_dev,
94 mark->mask, mark->ignored_mask);
95 ret |= show_mark_fhandle(m, inode);
96 ret |= seq_putc(m, '\n');
97 iput(inode);
98 }
99
100 return ret;
101}
102
103int inotify_show_fdinfo(struct seq_file *m, struct file *f)
104{
105 return show_fdinfo(m, f, inotify_fdinfo);
106}
107
108#endif /* CONFIG_INOTIFY_USER */
109
110#ifdef CONFIG_FANOTIFY
111
112static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
113{
114 unsigned int mflags = 0;
115 struct inode *inode;
116 int ret = 0;
117
118 if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE))
119 return 0;
120
121 if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY)
122 mflags |= FAN_MARK_IGNORED_SURV_MODIFY;
123
124 if (mark->flags & FSNOTIFY_MARK_FLAG_INODE) {
125 inode = igrab(mark->i.inode);
126 if (!inode)
127 goto out;
128 ret = seq_printf(m, "fanotify ino:%lx sdev:%x "
129 "mflags:%x mask:%x ignored_mask:%x ",
130 inode->i_ino, inode->i_sb->s_dev,
131 mflags, mark->mask, mark->ignored_mask);
132 ret |= show_mark_fhandle(m, inode);
133 ret |= seq_putc(m, '\n');
134 iput(inode);
135 } else if (mark->flags & FSNOTIFY_MARK_FLAG_VFSMOUNT) {
136 struct mount *mnt = real_mount(mark->m.mnt);
137
138 ret = seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x "
139 "ignored_mask:%x\n", mnt->mnt_id, mflags,
140 mark->mask, mark->ignored_mask);
141 }
142out:
143 return ret;
144}
145
146int fanotify_show_fdinfo(struct seq_file *m, struct file *f)
147{
148 struct fsnotify_group *group = f->private_data;
149 unsigned int flags = 0;
150
151 switch (group->priority) {
152 case FS_PRIO_0:
153 flags |= FAN_CLASS_NOTIF;
154 break;
155 case FS_PRIO_1:
156 flags |= FAN_CLASS_CONTENT;
157 break;
158 case FS_PRIO_2:
159 flags |= FAN_CLASS_PRE_CONTENT;
160 break;
161 }
162
163 if (group->max_events == UINT_MAX)
164 flags |= FAN_UNLIMITED_QUEUE;
165
166 if (group->fanotify_data.max_marks == UINT_MAX)
167 flags |= FAN_UNLIMITED_MARKS;
168
169 seq_printf(m, "fanotify flags:%x event-flags:%x\n",
170 flags, group->fanotify_data.f_flags);
171
172 return show_fdinfo(m, f, fanotify_fdinfo);
173}
174
175#endif /* CONFIG_FANOTIFY */
176
177#endif /* CONFIG_INOTIFY_USER || CONFIG_FANOTIFY */
178
179#endif /* CONFIG_PROC_FS */
diff --git a/fs/notify/fdinfo.h b/fs/notify/fdinfo.h
new file mode 100644
index 000000000000..556afda990e9
--- /dev/null
+++ b/fs/notify/fdinfo.h
@@ -0,0 +1,27 @@
1#ifndef __FSNOTIFY_FDINFO_H__
2#define __FSNOTIFY_FDINFO_H__
3
4#include <linux/errno.h>
5#include <linux/proc_fs.h>
6
7struct seq_file;
8struct file;
9
10#ifdef CONFIG_PROC_FS
11
12#ifdef CONFIG_INOTIFY_USER
13extern int inotify_show_fdinfo(struct seq_file *m, struct file *f);
14#endif
15
16#ifdef CONFIG_FANOTIFY
17extern int fanotify_show_fdinfo(struct seq_file *m, struct file *f);
18#endif
19
20#else /* CONFIG_PROC_FS */
21
22#define inotify_show_fdinfo NULL
23#define fanotify_show_fdinfo NULL
24
25#endif /* CONFIG_PROC_FS */
26
27#endif /* __FSNOTIFY_FDINFO_H__ */
diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c
index b13c00ac48eb..f3035691f528 100644
--- a/fs/notify/inode_mark.c
+++ b/fs/notify/inode_mark.c
@@ -116,8 +116,9 @@ void fsnotify_clear_inode_marks_by_group(struct fsnotify_group *group)
116 * given a group and inode, find the mark associated with that combination. 116 * given a group and inode, find the mark associated with that combination.
117 * if found take a reference to that mark and return it, else return NULL 117 * if found take a reference to that mark and return it, else return NULL
118 */ 118 */
119struct fsnotify_mark *fsnotify_find_inode_mark_locked(struct fsnotify_group *group, 119static struct fsnotify_mark *fsnotify_find_inode_mark_locked(
120 struct inode *inode) 120 struct fsnotify_group *group,
121 struct inode *inode)
121{ 122{
122 struct fsnotify_mark *mark; 123 struct fsnotify_mark *mark;
123 struct hlist_node *pos; 124 struct hlist_node *pos;
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index c311dda054a3..36cb013c7c13 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -40,6 +40,7 @@
40#include <linux/wait.h> 40#include <linux/wait.h>
41 41
42#include "inotify.h" 42#include "inotify.h"
43#include "../fdinfo.h"
43 44
44#include <asm/ioctls.h> 45#include <asm/ioctls.h>
45 46
@@ -335,6 +336,7 @@ static long inotify_ioctl(struct file *file, unsigned int cmd,
335} 336}
336 337
337static const struct file_operations inotify_fops = { 338static const struct file_operations inotify_fops = {
339 .show_fdinfo = inotify_show_fdinfo,
338 .poll = inotify_poll, 340 .poll = inotify_poll,
339 .read = inotify_read, 341 .read = inotify_read,
340 .fasync = inotify_fasync, 342 .fasync = inotify_fasync,
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c
index 70b5863a2d64..f487aa343442 100644
--- a/fs/ocfs2/extent_map.c
+++ b/fs/ocfs2/extent_map.c
@@ -832,7 +832,7 @@ out:
832 return ret; 832 return ret;
833} 833}
834 834
835int ocfs2_seek_data_hole_offset(struct file *file, loff_t *offset, int origin) 835int ocfs2_seek_data_hole_offset(struct file *file, loff_t *offset, int whence)
836{ 836{
837 struct inode *inode = file->f_mapping->host; 837 struct inode *inode = file->f_mapping->host;
838 int ret; 838 int ret;
@@ -843,7 +843,7 @@ int ocfs2_seek_data_hole_offset(struct file *file, loff_t *offset, int origin)
843 struct buffer_head *di_bh = NULL; 843 struct buffer_head *di_bh = NULL;
844 struct ocfs2_extent_rec rec; 844 struct ocfs2_extent_rec rec;
845 845
846 BUG_ON(origin != SEEK_DATA && origin != SEEK_HOLE); 846 BUG_ON(whence != SEEK_DATA && whence != SEEK_HOLE);
847 847
848 ret = ocfs2_inode_lock(inode, &di_bh, 0); 848 ret = ocfs2_inode_lock(inode, &di_bh, 0);
849 if (ret) { 849 if (ret) {
@@ -859,7 +859,7 @@ int ocfs2_seek_data_hole_offset(struct file *file, loff_t *offset, int origin)
859 } 859 }
860 860
861 if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) { 861 if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
862 if (origin == SEEK_HOLE) 862 if (whence == SEEK_HOLE)
863 *offset = inode->i_size; 863 *offset = inode->i_size;
864 goto out_unlock; 864 goto out_unlock;
865 } 865 }
@@ -888,8 +888,8 @@ int ocfs2_seek_data_hole_offset(struct file *file, loff_t *offset, int origin)
888 is_data = (rec.e_flags & OCFS2_EXT_UNWRITTEN) ? 0 : 1; 888 is_data = (rec.e_flags & OCFS2_EXT_UNWRITTEN) ? 0 : 1;
889 } 889 }
890 890
891 if ((!is_data && origin == SEEK_HOLE) || 891 if ((!is_data && whence == SEEK_HOLE) ||
892 (is_data && origin == SEEK_DATA)) { 892 (is_data && whence == SEEK_DATA)) {
893 if (extoff > *offset) 893 if (extoff > *offset)
894 *offset = extoff; 894 *offset = extoff;
895 goto out_unlock; 895 goto out_unlock;
@@ -899,7 +899,7 @@ int ocfs2_seek_data_hole_offset(struct file *file, loff_t *offset, int origin)
899 cpos += clen; 899 cpos += clen;
900 } 900 }
901 901
902 if (origin == SEEK_HOLE) { 902 if (whence == SEEK_HOLE) {
903 extoff = cpos; 903 extoff = cpos;
904 extoff <<= cs_bits; 904 extoff <<= cs_bits;
905 extlen = clen; 905 extlen = clen;
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index dda089804942..fe492e1a3cfc 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2637,14 +2637,14 @@ bail:
2637} 2637}
2638 2638
2639/* Refer generic_file_llseek_unlocked() */ 2639/* Refer generic_file_llseek_unlocked() */
2640static loff_t ocfs2_file_llseek(struct file *file, loff_t offset, int origin) 2640static loff_t ocfs2_file_llseek(struct file *file, loff_t offset, int whence)
2641{ 2641{
2642 struct inode *inode = file->f_mapping->host; 2642 struct inode *inode = file->f_mapping->host;
2643 int ret = 0; 2643 int ret = 0;
2644 2644
2645 mutex_lock(&inode->i_mutex); 2645 mutex_lock(&inode->i_mutex);
2646 2646
2647 switch (origin) { 2647 switch (whence) {
2648 case SEEK_SET: 2648 case SEEK_SET:
2649 break; 2649 break;
2650 case SEEK_END: 2650 case SEEK_END:
@@ -2659,7 +2659,7 @@ static loff_t ocfs2_file_llseek(struct file *file, loff_t offset, int origin)
2659 break; 2659 break;
2660 case SEEK_DATA: 2660 case SEEK_DATA:
2661 case SEEK_HOLE: 2661 case SEEK_HOLE:
2662 ret = ocfs2_seek_data_hole_offset(file, &offset, origin); 2662 ret = ocfs2_seek_data_hole_offset(file, &offset, whence);
2663 if (ret) 2663 if (ret)
2664 goto out; 2664 goto out;
2665 break; 2665 break;
diff --git a/fs/proc/array.c b/fs/proc/array.c
index d66248a1919b..6a91e6ffbcbd 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -212,7 +212,7 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
212 group_info = cred->group_info; 212 group_info = cred->group_info;
213 task_unlock(p); 213 task_unlock(p);
214 214
215 for (g = 0; g < min(group_info->ngroups, NGROUPS_SMALL); g++) 215 for (g = 0; g < group_info->ngroups; g++)
216 seq_printf(m, "%d ", 216 seq_printf(m, "%d ",
217 from_kgid_munged(user_ns, GROUP_AT(group_info, g))); 217 from_kgid_munged(user_ns, GROUP_AT(group_info, g)));
218 put_cred(cred); 218 put_cred(cred);
@@ -220,7 +220,7 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
220 seq_putc(m, '\n'); 220 seq_putc(m, '\n');
221} 221}
222 222
223static void render_sigset_t(struct seq_file *m, const char *header, 223void render_sigset_t(struct seq_file *m, const char *header,
224 sigset_t *set) 224 sigset_t *set)
225{ 225{
226 int i; 226 int i;
@@ -308,6 +308,10 @@ static void render_cap_t(struct seq_file *m, const char *header,
308 seq_putc(m, '\n'); 308 seq_putc(m, '\n');
309} 309}
310 310
311/* Remove non-existent capabilities */
312#define NORM_CAPS(v) (v.cap[CAP_TO_INDEX(CAP_LAST_CAP)] &= \
313 CAP_TO_MASK(CAP_LAST_CAP + 1) - 1)
314
311static inline void task_cap(struct seq_file *m, struct task_struct *p) 315static inline void task_cap(struct seq_file *m, struct task_struct *p)
312{ 316{
313 const struct cred *cred; 317 const struct cred *cred;
@@ -321,12 +325,24 @@ static inline void task_cap(struct seq_file *m, struct task_struct *p)
321 cap_bset = cred->cap_bset; 325 cap_bset = cred->cap_bset;
322 rcu_read_unlock(); 326 rcu_read_unlock();
323 327
328 NORM_CAPS(cap_inheritable);
329 NORM_CAPS(cap_permitted);
330 NORM_CAPS(cap_effective);
331 NORM_CAPS(cap_bset);
332
324 render_cap_t(m, "CapInh:\t", &cap_inheritable); 333 render_cap_t(m, "CapInh:\t", &cap_inheritable);
325 render_cap_t(m, "CapPrm:\t", &cap_permitted); 334 render_cap_t(m, "CapPrm:\t", &cap_permitted);
326 render_cap_t(m, "CapEff:\t", &cap_effective); 335 render_cap_t(m, "CapEff:\t", &cap_effective);
327 render_cap_t(m, "CapBnd:\t", &cap_bset); 336 render_cap_t(m, "CapBnd:\t", &cap_bset);
328} 337}
329 338
339static inline void task_seccomp(struct seq_file *m, struct task_struct *p)
340{
341#ifdef CONFIG_SECCOMP
342 seq_printf(m, "Seccomp:\t%d\n", p->seccomp.mode);
343#endif
344}
345
330static inline void task_context_switch_counts(struct seq_file *m, 346static inline void task_context_switch_counts(struct seq_file *m,
331 struct task_struct *p) 347 struct task_struct *p)
332{ 348{
@@ -360,6 +376,7 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
360 } 376 }
361 task_sig(m, task); 377 task_sig(m, task);
362 task_cap(m, task); 378 task_cap(m, task);
379 task_seccomp(m, task);
363 task_cpus_allowed(m, task); 380 task_cpus_allowed(m, task);
364 cpuset_task_status_allowed(m, task); 381 cpuset_task_status_allowed(m, task);
365 task_context_switch_counts(m, task); 382 task_context_switch_counts(m, task);
diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index f28a875f8779..d7a4a28ef630 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -50,6 +50,8 @@ static int seq_show(struct seq_file *m, void *v)
50 if (!ret) { 50 if (!ret) {
51 seq_printf(m, "pos:\t%lli\nflags:\t0%o\n", 51 seq_printf(m, "pos:\t%lli\nflags:\t0%o\n",
52 (long long)file->f_pos, f_flags); 52 (long long)file->f_pos, f_flags);
53 if (file->f_op->show_fdinfo)
54 ret = file->f_op->show_fdinfo(m, file);
53 fput(file); 55 fput(file);
54 } 56 }
55 57
diff --git a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c
index df7dd08d4391..de20ec480fa0 100644
--- a/fs/proc/proc_devtree.c
+++ b/fs/proc/proc_devtree.c
@@ -195,11 +195,7 @@ void proc_device_tree_add_node(struct device_node *np,
195 set_node_proc_entry(np, de); 195 set_node_proc_entry(np, de);
196 for (child = NULL; (child = of_get_next_child(np, child));) { 196 for (child = NULL; (child = of_get_next_child(np, child));) {
197 /* Use everything after the last slash, or the full name */ 197 /* Use everything after the last slash, or the full name */
198 p = strrchr(child->full_name, '/'); 198 p = kbasename(child->full_name);
199 if (!p)
200 p = child->full_name;
201 else
202 ++p;
203 199
204 if (duplicate_name(de, p)) 200 if (duplicate_name(de, p))
205 p = fixup_name(np, de, p); 201 p = fixup_name(np, de, p);
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 48775628abbf..448455b7fd91 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -526,6 +526,57 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
526 return 0; 526 return 0;
527} 527}
528 528
529static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
530{
531 /*
532 * Don't forget to update Documentation/ on changes.
533 */
534 static const char mnemonics[BITS_PER_LONG][2] = {
535 /*
536 * In case if we meet a flag we don't know about.
537 */
538 [0 ... (BITS_PER_LONG-1)] = "??",
539
540 [ilog2(VM_READ)] = "rd",
541 [ilog2(VM_WRITE)] = "wr",
542 [ilog2(VM_EXEC)] = "ex",
543 [ilog2(VM_SHARED)] = "sh",
544 [ilog2(VM_MAYREAD)] = "mr",
545 [ilog2(VM_MAYWRITE)] = "mw",
546 [ilog2(VM_MAYEXEC)] = "me",
547 [ilog2(VM_MAYSHARE)] = "ms",
548 [ilog2(VM_GROWSDOWN)] = "gd",
549 [ilog2(VM_PFNMAP)] = "pf",
550 [ilog2(VM_DENYWRITE)] = "dw",
551 [ilog2(VM_LOCKED)] = "lo",
552 [ilog2(VM_IO)] = "io",
553 [ilog2(VM_SEQ_READ)] = "sr",
554 [ilog2(VM_RAND_READ)] = "rr",
555 [ilog2(VM_DONTCOPY)] = "dc",
556 [ilog2(VM_DONTEXPAND)] = "de",
557 [ilog2(VM_ACCOUNT)] = "ac",
558 [ilog2(VM_NORESERVE)] = "nr",
559 [ilog2(VM_HUGETLB)] = "ht",
560 [ilog2(VM_NONLINEAR)] = "nl",
561 [ilog2(VM_ARCH_1)] = "ar",
562 [ilog2(VM_DONTDUMP)] = "dd",
563 [ilog2(VM_MIXEDMAP)] = "mm",
564 [ilog2(VM_HUGEPAGE)] = "hg",
565 [ilog2(VM_NOHUGEPAGE)] = "nh",
566 [ilog2(VM_MERGEABLE)] = "mg",
567 };
568 size_t i;
569
570 seq_puts(m, "VmFlags: ");
571 for (i = 0; i < BITS_PER_LONG; i++) {
572 if (vma->vm_flags & (1UL << i)) {
573 seq_printf(m, "%c%c ",
574 mnemonics[i][0], mnemonics[i][1]);
575 }
576 }
577 seq_putc(m, '\n');
578}
579
529static int show_smap(struct seq_file *m, void *v, int is_pid) 580static int show_smap(struct seq_file *m, void *v, int is_pid)
530{ 581{
531 struct proc_maps_private *priv = m->private; 582 struct proc_maps_private *priv = m->private;
@@ -581,6 +632,8 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
581 seq_printf(m, "Nonlinear: %8lu kB\n", 632 seq_printf(m, "Nonlinear: %8lu kB\n",
582 mss.nonlinear >> 10); 633 mss.nonlinear >> 10);
583 634
635 show_smap_vma_flags(m, vma);
636
584 if (m->count < m->size) /* vma is copied successfully */ 637 if (m->count < m->size) /* vma is copied successfully */
585 m->version = (vma != get_gate_vma(task->mm)) 638 m->version = (vma != get_gate_vma(task->mm))
586 ? vma->vm_start : 0; 639 ? vma->vm_start : 0;
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index ed1d8c7212da..67de74ca85f4 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -151,13 +151,13 @@ static int pstore_file_open(struct inode *inode, struct file *file)
151 return 0; 151 return 0;
152} 152}
153 153
154static loff_t pstore_file_llseek(struct file *file, loff_t off, int origin) 154static loff_t pstore_file_llseek(struct file *file, loff_t off, int whence)
155{ 155{
156 struct seq_file *sf = file->private_data; 156 struct seq_file *sf = file->private_data;
157 157
158 if (sf->op) 158 if (sf->op)
159 return seq_lseek(file, off, origin); 159 return seq_lseek(file, off, whence);
160 return default_llseek(file, off, origin); 160 return default_llseek(file, off, whence);
161} 161}
162 162
163static const struct file_operations pstore_file_operations = { 163static const struct file_operations pstore_file_operations = {
diff --git a/fs/read_write.c b/fs/read_write.c
index d06534857e9e..1edaf099ddd7 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -54,7 +54,7 @@ static loff_t lseek_execute(struct file *file, struct inode *inode,
54 * generic_file_llseek_size - generic llseek implementation for regular files 54 * generic_file_llseek_size - generic llseek implementation for regular files
55 * @file: file structure to seek on 55 * @file: file structure to seek on
56 * @offset: file offset to seek to 56 * @offset: file offset to seek to
57 * @origin: type of seek 57 * @whence: type of seek
58 * @size: max size of this file in file system 58 * @size: max size of this file in file system
59 * @eof: offset used for SEEK_END position 59 * @eof: offset used for SEEK_END position
60 * 60 *
@@ -67,12 +67,12 @@ static loff_t lseek_execute(struct file *file, struct inode *inode,
67 * read/writes behave like SEEK_SET against seeks. 67 * read/writes behave like SEEK_SET against seeks.
68 */ 68 */
69loff_t 69loff_t
70generic_file_llseek_size(struct file *file, loff_t offset, int origin, 70generic_file_llseek_size(struct file *file, loff_t offset, int whence,
71 loff_t maxsize, loff_t eof) 71 loff_t maxsize, loff_t eof)
72{ 72{
73 struct inode *inode = file->f_mapping->host; 73 struct inode *inode = file->f_mapping->host;
74 74
75 switch (origin) { 75 switch (whence) {
76 case SEEK_END: 76 case SEEK_END:
77 offset += eof; 77 offset += eof;
78 break; 78 break;
@@ -122,17 +122,17 @@ EXPORT_SYMBOL(generic_file_llseek_size);
122 * generic_file_llseek - generic llseek implementation for regular files 122 * generic_file_llseek - generic llseek implementation for regular files
123 * @file: file structure to seek on 123 * @file: file structure to seek on
124 * @offset: file offset to seek to 124 * @offset: file offset to seek to
125 * @origin: type of seek 125 * @whence: type of seek
126 * 126 *
127 * This is a generic implemenation of ->llseek useable for all normal local 127 * This is a generic implemenation of ->llseek useable for all normal local
128 * filesystems. It just updates the file offset to the value specified by 128 * filesystems. It just updates the file offset to the value specified by
129 * @offset and @origin under i_mutex. 129 * @offset and @whence under i_mutex.
130 */ 130 */
131loff_t generic_file_llseek(struct file *file, loff_t offset, int origin) 131loff_t generic_file_llseek(struct file *file, loff_t offset, int whence)
132{ 132{
133 struct inode *inode = file->f_mapping->host; 133 struct inode *inode = file->f_mapping->host;
134 134
135 return generic_file_llseek_size(file, offset, origin, 135 return generic_file_llseek_size(file, offset, whence,
136 inode->i_sb->s_maxbytes, 136 inode->i_sb->s_maxbytes,
137 i_size_read(inode)); 137 i_size_read(inode));
138} 138}
@@ -142,32 +142,32 @@ EXPORT_SYMBOL(generic_file_llseek);
142 * noop_llseek - No Operation Performed llseek implementation 142 * noop_llseek - No Operation Performed llseek implementation
143 * @file: file structure to seek on 143 * @file: file structure to seek on
144 * @offset: file offset to seek to 144 * @offset: file offset to seek to
145 * @origin: type of seek 145 * @whence: type of seek
146 * 146 *
147 * This is an implementation of ->llseek useable for the rare special case when 147 * This is an implementation of ->llseek useable for the rare special case when
148 * userspace expects the seek to succeed but the (device) file is actually not 148 * userspace expects the seek to succeed but the (device) file is actually not
149 * able to perform the seek. In this case you use noop_llseek() instead of 149 * able to perform the seek. In this case you use noop_llseek() instead of
150 * falling back to the default implementation of ->llseek. 150 * falling back to the default implementation of ->llseek.
151 */ 151 */
152loff_t noop_llseek(struct file *file, loff_t offset, int origin) 152loff_t noop_llseek(struct file *file, loff_t offset, int whence)
153{ 153{
154 return file->f_pos; 154 return file->f_pos;
155} 155}
156EXPORT_SYMBOL(noop_llseek); 156EXPORT_SYMBOL(noop_llseek);
157 157
158loff_t no_llseek(struct file *file, loff_t offset, int origin) 158loff_t no_llseek(struct file *file, loff_t offset, int whence)
159{ 159{
160 return -ESPIPE; 160 return -ESPIPE;
161} 161}
162EXPORT_SYMBOL(no_llseek); 162EXPORT_SYMBOL(no_llseek);
163 163
164loff_t default_llseek(struct file *file, loff_t offset, int origin) 164loff_t default_llseek(struct file *file, loff_t offset, int whence)
165{ 165{
166 struct inode *inode = file->f_path.dentry->d_inode; 166 struct inode *inode = file->f_path.dentry->d_inode;
167 loff_t retval; 167 loff_t retval;
168 168
169 mutex_lock(&inode->i_mutex); 169 mutex_lock(&inode->i_mutex);
170 switch (origin) { 170 switch (whence) {
171 case SEEK_END: 171 case SEEK_END:
172 offset += i_size_read(inode); 172 offset += i_size_read(inode);
173 break; 173 break;
@@ -216,7 +216,7 @@ out:
216} 216}
217EXPORT_SYMBOL(default_llseek); 217EXPORT_SYMBOL(default_llseek);
218 218
219loff_t vfs_llseek(struct file *file, loff_t offset, int origin) 219loff_t vfs_llseek(struct file *file, loff_t offset, int whence)
220{ 220{
221 loff_t (*fn)(struct file *, loff_t, int); 221 loff_t (*fn)(struct file *, loff_t, int);
222 222
@@ -225,11 +225,11 @@ loff_t vfs_llseek(struct file *file, loff_t offset, int origin)
225 if (file->f_op && file->f_op->llseek) 225 if (file->f_op && file->f_op->llseek)
226 fn = file->f_op->llseek; 226 fn = file->f_op->llseek;
227 } 227 }
228 return fn(file, offset, origin); 228 return fn(file, offset, whence);
229} 229}
230EXPORT_SYMBOL(vfs_llseek); 230EXPORT_SYMBOL(vfs_llseek);
231 231
232SYSCALL_DEFINE3(lseek, unsigned int, fd, off_t, offset, unsigned int, origin) 232SYSCALL_DEFINE3(lseek, unsigned int, fd, off_t, offset, unsigned int, whence)
233{ 233{
234 off_t retval; 234 off_t retval;
235 struct fd f = fdget(fd); 235 struct fd f = fdget(fd);
@@ -237,8 +237,8 @@ SYSCALL_DEFINE3(lseek, unsigned int, fd, off_t, offset, unsigned int, origin)
237 return -EBADF; 237 return -EBADF;
238 238
239 retval = -EINVAL; 239 retval = -EINVAL;
240 if (origin <= SEEK_MAX) { 240 if (whence <= SEEK_MAX) {
241 loff_t res = vfs_llseek(f.file, offset, origin); 241 loff_t res = vfs_llseek(f.file, offset, whence);
242 retval = res; 242 retval = res;
243 if (res != (loff_t)retval) 243 if (res != (loff_t)retval)
244 retval = -EOVERFLOW; /* LFS: should only happen on 32 bit platforms */ 244 retval = -EOVERFLOW; /* LFS: should only happen on 32 bit platforms */
@@ -250,7 +250,7 @@ SYSCALL_DEFINE3(lseek, unsigned int, fd, off_t, offset, unsigned int, origin)
250#ifdef __ARCH_WANT_SYS_LLSEEK 250#ifdef __ARCH_WANT_SYS_LLSEEK
251SYSCALL_DEFINE5(llseek, unsigned int, fd, unsigned long, offset_high, 251SYSCALL_DEFINE5(llseek, unsigned int, fd, unsigned long, offset_high,
252 unsigned long, offset_low, loff_t __user *, result, 252 unsigned long, offset_low, loff_t __user *, result,
253 unsigned int, origin) 253 unsigned int, whence)
254{ 254{
255 int retval; 255 int retval;
256 struct fd f = fdget(fd); 256 struct fd f = fdget(fd);
@@ -260,11 +260,11 @@ SYSCALL_DEFINE5(llseek, unsigned int, fd, unsigned long, offset_high,
260 return -EBADF; 260 return -EBADF;
261 261
262 retval = -EINVAL; 262 retval = -EINVAL;
263 if (origin > SEEK_MAX) 263 if (whence > SEEK_MAX)
264 goto out_putf; 264 goto out_putf;
265 265
266 offset = vfs_llseek(f.file, ((loff_t) offset_high << 32) | offset_low, 266 offset = vfs_llseek(f.file, ((loff_t) offset_high << 32) | offset_low,
267 origin); 267 whence);
268 268
269 retval = (int)offset; 269 retval = (int)offset;
270 if (offset >= 0) { 270 if (offset >= 0) {
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 99dffab4c4e4..9d863fb501f9 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -300,14 +300,14 @@ EXPORT_SYMBOL(seq_read);
300 * 300 *
301 * Ready-made ->f_op->llseek() 301 * Ready-made ->f_op->llseek()
302 */ 302 */
303loff_t seq_lseek(struct file *file, loff_t offset, int origin) 303loff_t seq_lseek(struct file *file, loff_t offset, int whence)
304{ 304{
305 struct seq_file *m = file->private_data; 305 struct seq_file *m = file->private_data;
306 loff_t retval = -EINVAL; 306 loff_t retval = -EINVAL;
307 307
308 mutex_lock(&m->lock); 308 mutex_lock(&m->lock);
309 m->version = file->f_version; 309 m->version = file->f_version;
310 switch (origin) { 310 switch (whence) {
311 case 1: 311 case 1:
312 offset += file->f_pos; 312 offset += file->f_pos;
313 case 0: 313 case 0:
diff --git a/fs/signalfd.c b/fs/signalfd.c
index 8bee4e570911..b53486961735 100644
--- a/fs/signalfd.c
+++ b/fs/signalfd.c
@@ -29,6 +29,7 @@
29#include <linux/anon_inodes.h> 29#include <linux/anon_inodes.h>
30#include <linux/signalfd.h> 30#include <linux/signalfd.h>
31#include <linux/syscalls.h> 31#include <linux/syscalls.h>
32#include <linux/proc_fs.h>
32 33
33void signalfd_cleanup(struct sighand_struct *sighand) 34void signalfd_cleanup(struct sighand_struct *sighand)
34{ 35{
@@ -227,7 +228,24 @@ static ssize_t signalfd_read(struct file *file, char __user *buf, size_t count,
227 return total ? total: ret; 228 return total ? total: ret;
228} 229}
229 230
231#ifdef CONFIG_PROC_FS
232static int signalfd_show_fdinfo(struct seq_file *m, struct file *f)
233{
234 struct signalfd_ctx *ctx = f->private_data;
235 sigset_t sigmask;
236
237 sigmask = ctx->sigmask;
238 signotset(&sigmask);
239 render_sigset_t(m, "sigmask:\t", &sigmask);
240
241 return 0;
242}
243#endif
244
230static const struct file_operations signalfd_fops = { 245static const struct file_operations signalfd_fops = {
246#ifdef CONFIG_PROC_FS
247 .show_fdinfo = signalfd_show_fdinfo,
248#endif
231 .release = signalfd_release, 249 .release = signalfd_release,
232 .poll = signalfd_poll, 250 .poll = signalfd_poll,
233 .read = signalfd_read, 251 .read = signalfd_read,
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 62911637e12f..12817ffc7345 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -2560,7 +2560,7 @@ static int power_cut_emulated(struct ubifs_info *c, int lnum, int write)
2560static int corrupt_data(const struct ubifs_info *c, const void *buf, 2560static int corrupt_data(const struct ubifs_info *c, const void *buf,
2561 unsigned int len) 2561 unsigned int len)
2562{ 2562{
2563 unsigned int from, to, i, ffs = chance(1, 2); 2563 unsigned int from, to, ffs = chance(1, 2);
2564 unsigned char *p = (void *)buf; 2564 unsigned char *p = (void *)buf;
2565 2565
2566 from = random32() % (len + 1); 2566 from = random32() % (len + 1);
@@ -2571,11 +2571,9 @@ static int corrupt_data(const struct ubifs_info *c, const void *buf,
2571 ffs ? "0xFFs" : "random data"); 2571 ffs ? "0xFFs" : "random data");
2572 2572
2573 if (ffs) 2573 if (ffs)
2574 for (i = from; i < to; i++) 2574 memset(p + from, 0xFF, to - from);
2575 p[i] = 0xFF;
2576 else 2575 else
2577 for (i = from; i < to; i++) 2576 prandom_bytes(p + from, to - from);
2578 p[i] = random32() % 0x100;
2579 2577
2580 return to; 2578 return to;
2581} 2579}
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index e271fba1651b..8a574776a493 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -453,11 +453,11 @@ out:
453} 453}
454 454
455/* If a directory is seeked, we have to free saved readdir() state */ 455/* If a directory is seeked, we have to free saved readdir() state */
456static loff_t ubifs_dir_llseek(struct file *file, loff_t offset, int origin) 456static loff_t ubifs_dir_llseek(struct file *file, loff_t offset, int whence)
457{ 457{
458 kfree(file->private_data); 458 kfree(file->private_data);
459 file->private_data = NULL; 459 file->private_data = NULL;
460 return generic_file_llseek(file, offset, origin); 460 return generic_file_llseek(file, offset, whence);
461} 461}
462 462
463/* Free saved readdir() state when the directory is closed */ 463/* Free saved readdir() state when the directory is closed */
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 9e0ebe051243..d1e93284d72a 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -154,7 +154,7 @@ static inline void insb(unsigned long addr, void *buffer, int count)
154 if (count) { 154 if (count) {
155 u8 *buf = buffer; 155 u8 *buf = buffer;
156 do { 156 do {
157 u8 x = inb(addr); 157 u8 x = __raw_readb(addr + PCI_IOBASE);
158 *buf++ = x; 158 *buf++ = x;
159 } while (--count); 159 } while (--count);
160 } 160 }
@@ -167,7 +167,7 @@ static inline void insw(unsigned long addr, void *buffer, int count)
167 if (count) { 167 if (count) {
168 u16 *buf = buffer; 168 u16 *buf = buffer;
169 do { 169 do {
170 u16 x = inw(addr); 170 u16 x = __raw_readw(addr + PCI_IOBASE);
171 *buf++ = x; 171 *buf++ = x;
172 } while (--count); 172 } while (--count);
173 } 173 }
@@ -180,7 +180,7 @@ static inline void insl(unsigned long addr, void *buffer, int count)
180 if (count) { 180 if (count) {
181 u32 *buf = buffer; 181 u32 *buf = buffer;
182 do { 182 do {
183 u32 x = inl(addr); 183 u32 x = __raw_readl(addr + PCI_IOBASE);
184 *buf++ = x; 184 *buf++ = x;
185 } while (--count); 185 } while (--count);
186 } 186 }
@@ -193,7 +193,7 @@ static inline void outsb(unsigned long addr, const void *buffer, int count)
193 if (count) { 193 if (count) {
194 const u8 *buf = buffer; 194 const u8 *buf = buffer;
195 do { 195 do {
196 outb(*buf++, addr); 196 __raw_writeb(*buf++, addr + PCI_IOBASE);
197 } while (--count); 197 } while (--count);
198 } 198 }
199} 199}
@@ -205,7 +205,7 @@ static inline void outsw(unsigned long addr, const void *buffer, int count)
205 if (count) { 205 if (count) {
206 const u16 *buf = buffer; 206 const u16 *buf = buffer;
207 do { 207 do {
208 outw(*buf++, addr); 208 __raw_writew(*buf++, addr + PCI_IOBASE);
209 } while (--count); 209 } while (--count);
210 } 210 }
211} 211}
@@ -217,7 +217,7 @@ static inline void outsl(unsigned long addr, const void *buffer, int count)
217 if (count) { 217 if (count) {
218 const u32 *buf = buffer; 218 const u32 *buf = buffer;
219 do { 219 do {
220 outl(*buf++, addr); 220 __raw_writel(*buf++, addr + PCI_IOBASE);
221 } while (--count); 221 } while (--count);
222 } 222 }
223} 223}
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 5ffc6dda4675..da9a0825e007 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -134,4 +134,14 @@ struct generic_bl_info {
134 void (*kick_battery)(void); 134 void (*kick_battery)(void);
135}; 135};
136 136
137#ifdef CONFIG_OF
138struct backlight_device *of_find_backlight_by_node(struct device_node *node);
139#else
140static inline struct backlight_device *
141of_find_backlight_by_node(struct device_node *node)
142{
143 return NULL;
144}
145#endif
146
137#endif 147#endif
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
index 2630c9b41a86..a4c2b565c835 100644
--- a/include/linux/binfmts.h
+++ b/include/linux/binfmts.h
@@ -54,8 +54,6 @@ struct linux_binprm {
54#define BINPRM_FLAGS_EXECFD_BIT 1 54#define BINPRM_FLAGS_EXECFD_BIT 1
55#define BINPRM_FLAGS_EXECFD (1 << BINPRM_FLAGS_EXECFD_BIT) 55#define BINPRM_FLAGS_EXECFD (1 << BINPRM_FLAGS_EXECFD_BIT)
56 56
57#define BINPRM_MAX_RECURSION 4
58
59/* Function parameter for binfmt->coredump */ 57/* Function parameter for binfmt->coredump */
60struct coredump_params { 58struct coredump_params {
61 siginfo_t *siginfo; 59 siginfo_t *siginfo;
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 784ebfe63c48..e4920bd58a47 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -588,6 +588,9 @@ asmlinkage ssize_t compat_sys_process_vm_writev(compat_pid_t pid,
588asmlinkage long compat_sys_sendfile(int out_fd, int in_fd, 588asmlinkage long compat_sys_sendfile(int out_fd, int in_fd,
589 compat_off_t __user *offset, compat_size_t count); 589 compat_off_t __user *offset, compat_size_t count);
590 590
591asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid,
592 struct compat_timespec __user *interval);
593
591#else 594#else
592 595
593#define is_compat_task() (0) 596#define is_compat_task() (0)
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index f430e4162f41..b121554f1fe2 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -10,6 +10,7 @@
10# define __force __attribute__((force)) 10# define __force __attribute__((force))
11# define __nocast __attribute__((nocast)) 11# define __nocast __attribute__((nocast))
12# define __iomem __attribute__((noderef, address_space(2))) 12# define __iomem __attribute__((noderef, address_space(2)))
13# define __must_hold(x) __attribute__((context(x,1,1)))
13# define __acquires(x) __attribute__((context(x,0,1))) 14# define __acquires(x) __attribute__((context(x,0,1)))
14# define __releases(x) __attribute__((context(x,1,0))) 15# define __releases(x) __attribute__((context(x,1,0)))
15# define __acquire(x) __context__(x,1) 16# define __acquire(x) __context__(x,1)
@@ -33,6 +34,7 @@ extern void __chk_io_ptr(const volatile void __iomem *);
33# define __chk_user_ptr(x) (void)0 34# define __chk_user_ptr(x) (void)0
34# define __chk_io_ptr(x) (void)0 35# define __chk_io_ptr(x) (void)0
35# define __builtin_warning(x, y...) (1) 36# define __builtin_warning(x, y...) (1)
37# define __must_hold(x)
36# define __acquires(x) 38# define __acquires(x)
37# define __releases(x) 39# define __releases(x)
38# define __acquire(x) (void)0 40# define __acquire(x) (void)0
diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h
index 12291a7ee275..c7e6b6392ab8 100644
--- a/include/linux/exportfs.h
+++ b/include/linux/exportfs.h
@@ -177,6 +177,8 @@ struct export_operations {
177 int (*commit_metadata)(struct inode *inode); 177 int (*commit_metadata)(struct inode *inode);
178}; 178};
179 179
180extern int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
181 int *max_len, struct inode *parent);
180extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, 182extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid,
181 int *max_len, int connectable); 183 int *max_len, int connectable);
182extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid, 184extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 035521b46528..a823d4be38e7 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -44,6 +44,7 @@ struct vm_area_struct;
44struct vfsmount; 44struct vfsmount;
45struct cred; 45struct cred;
46struct swap_info_struct; 46struct swap_info_struct;
47struct seq_file;
47 48
48extern void __init inode_init(void); 49extern void __init inode_init(void);
49extern void __init inode_init_early(void); 50extern void __init inode_init_early(void);
@@ -1543,6 +1544,7 @@ struct file_operations {
1543 int (*setlease)(struct file *, long, struct file_lock **); 1544 int (*setlease)(struct file *, long, struct file_lock **);
1544 long (*fallocate)(struct file *file, int mode, loff_t offset, 1545 long (*fallocate)(struct file *file, int mode, loff_t offset,
1545 loff_t len); 1546 loff_t len);
1547 int (*show_fdinfo)(struct seq_file *m, struct file *f);
1546}; 1548};
1547 1549
1548struct inode_operations { 1550struct inode_operations {
@@ -1578,8 +1580,6 @@ struct inode_operations {
1578 umode_t create_mode, int *opened); 1580 umode_t create_mode, int *opened);
1579} ____cacheline_aligned; 1581} ____cacheline_aligned;
1580 1582
1581struct seq_file;
1582
1583ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, 1583ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
1584 unsigned long nr_segs, unsigned long fast_segs, 1584 unsigned long nr_segs, unsigned long fast_segs,
1585 struct iovec *fast_pointer, 1585 struct iovec *fast_pointer,
@@ -2288,9 +2288,9 @@ extern ino_t find_inode_number(struct dentry *, struct qstr *);
2288#include <linux/err.h> 2288#include <linux/err.h>
2289 2289
2290/* needed for stackable file system support */ 2290/* needed for stackable file system support */
2291extern loff_t default_llseek(struct file *file, loff_t offset, int origin); 2291extern loff_t default_llseek(struct file *file, loff_t offset, int whence);
2292 2292
2293extern loff_t vfs_llseek(struct file *file, loff_t offset, int origin); 2293extern loff_t vfs_llseek(struct file *file, loff_t offset, int whence);
2294 2294
2295extern int inode_init_always(struct super_block *, struct inode *); 2295extern int inode_init_always(struct super_block *, struct inode *);
2296extern void inode_init_once(struct inode *); 2296extern void inode_init_once(struct inode *);
@@ -2398,11 +2398,11 @@ extern long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
2398 2398
2399extern void 2399extern void
2400file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping); 2400file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);
2401extern loff_t noop_llseek(struct file *file, loff_t offset, int origin); 2401extern loff_t noop_llseek(struct file *file, loff_t offset, int whence);
2402extern loff_t no_llseek(struct file *file, loff_t offset, int origin); 2402extern loff_t no_llseek(struct file *file, loff_t offset, int whence);
2403extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin); 2403extern loff_t generic_file_llseek(struct file *file, loff_t offset, int whence);
2404extern loff_t generic_file_llseek_size(struct file *file, loff_t offset, 2404extern loff_t generic_file_llseek_size(struct file *file, loff_t offset,
2405 int origin, loff_t maxsize, loff_t eof); 2405 int whence, loff_t maxsize, loff_t eof);
2406extern int generic_file_open(struct inode * inode, struct file * filp); 2406extern int generic_file_open(struct inode * inode, struct file * filp);
2407extern int nonseekable_open(struct inode * inode, struct file * filp); 2407extern int nonseekable_open(struct inode * inode, struct file * filp);
2408 2408
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index a52f2f4fe030..92691d85c320 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -394,7 +394,7 @@ ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf,
394 size_t cnt, loff_t *ppos); 394 size_t cnt, loff_t *ppos);
395ssize_t ftrace_notrace_write(struct file *file, const char __user *ubuf, 395ssize_t ftrace_notrace_write(struct file *file, const char __user *ubuf,
396 size_t cnt, loff_t *ppos); 396 size_t cnt, loff_t *ppos);
397loff_t ftrace_regex_lseek(struct file *file, loff_t offset, int origin); 397loff_t ftrace_regex_lseek(struct file *file, loff_t offset, int whence);
398int ftrace_regex_release(struct inode *inode, struct file *file); 398int ftrace_regex_release(struct inode *inode, struct file *file);
399 399
400void __init 400void __init
@@ -559,7 +559,7 @@ static inline ssize_t ftrace_filter_write(struct file *file, const char __user *
559 size_t cnt, loff_t *ppos) { return -ENODEV; } 559 size_t cnt, loff_t *ppos) { return -ENODEV; }
560static inline ssize_t ftrace_notrace_write(struct file *file, const char __user *ubuf, 560static inline ssize_t ftrace_notrace_write(struct file *file, const char __user *ubuf,
561 size_t cnt, loff_t *ppos) { return -ENODEV; } 561 size_t cnt, loff_t *ppos) { return -ENODEV; }
562static inline loff_t ftrace_regex_lseek(struct file *file, loff_t offset, int origin) 562static inline loff_t ftrace_regex_lseek(struct file *file, loff_t offset, int whence)
563{ 563{
564 return -ENODEV; 564 return -ENODEV;
565} 565}
diff --git a/include/linux/init.h b/include/linux/init.h
index f63692d6902e..a799273714ac 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -182,16 +182,16 @@ extern bool initcall_debug;
182 * can point at the same handler without causing duplicate-symbol build errors. 182 * can point at the same handler without causing duplicate-symbol build errors.
183 */ 183 */
184 184
185#define __define_initcall(level,fn,id) \ 185#define __define_initcall(fn, id) \
186 static initcall_t __initcall_##fn##id __used \ 186 static initcall_t __initcall_##fn##id __used \
187 __attribute__((__section__(".initcall" level ".init"))) = fn 187 __attribute__((__section__(".initcall" #id ".init"))) = fn
188 188
189/* 189/*
190 * Early initcalls run before initializing SMP. 190 * Early initcalls run before initializing SMP.
191 * 191 *
192 * Only for built-in code, not modules. 192 * Only for built-in code, not modules.
193 */ 193 */
194#define early_initcall(fn) __define_initcall("early",fn,early) 194#define early_initcall(fn) __define_initcall(fn, early)
195 195
196/* 196/*
197 * A "pure" initcall has no dependencies on anything else, and purely 197 * A "pure" initcall has no dependencies on anything else, and purely
@@ -200,23 +200,23 @@ extern bool initcall_debug;
200 * This only exists for built-in code, not for modules. 200 * This only exists for built-in code, not for modules.
201 * Keep main.c:initcall_level_names[] in sync. 201 * Keep main.c:initcall_level_names[] in sync.
202 */ 202 */
203#define pure_initcall(fn) __define_initcall("0",fn,0) 203#define pure_initcall(fn) __define_initcall(fn, 0)
204 204
205#define core_initcall(fn) __define_initcall("1",fn,1) 205#define core_initcall(fn) __define_initcall(fn, 1)
206#define core_initcall_sync(fn) __define_initcall("1s",fn,1s) 206#define core_initcall_sync(fn) __define_initcall(fn, 1s)
207#define postcore_initcall(fn) __define_initcall("2",fn,2) 207#define postcore_initcall(fn) __define_initcall(fn, 2)
208#define postcore_initcall_sync(fn) __define_initcall("2s",fn,2s) 208#define postcore_initcall_sync(fn) __define_initcall(fn, 2s)
209#define arch_initcall(fn) __define_initcall("3",fn,3) 209#define arch_initcall(fn) __define_initcall(fn, 3)
210#define arch_initcall_sync(fn) __define_initcall("3s",fn,3s) 210#define arch_initcall_sync(fn) __define_initcall(fn, 3s)
211#define subsys_initcall(fn) __define_initcall("4",fn,4) 211#define subsys_initcall(fn) __define_initcall(fn, 4)
212#define subsys_initcall_sync(fn) __define_initcall("4s",fn,4s) 212#define subsys_initcall_sync(fn) __define_initcall(fn, 4s)
213#define fs_initcall(fn) __define_initcall("5",fn,5) 213#define fs_initcall(fn) __define_initcall(fn, 5)
214#define fs_initcall_sync(fn) __define_initcall("5s",fn,5s) 214#define fs_initcall_sync(fn) __define_initcall(fn, 5s)
215#define rootfs_initcall(fn) __define_initcall("rootfs",fn,rootfs) 215#define rootfs_initcall(fn) __define_initcall(fn, rootfs)
216#define device_initcall(fn) __define_initcall("6",fn,6) 216#define device_initcall(fn) __define_initcall(fn, 6)
217#define device_initcall_sync(fn) __define_initcall("6s",fn,6s) 217#define device_initcall_sync(fn) __define_initcall(fn, 6s)
218#define late_initcall(fn) __define_initcall("7",fn,7) 218#define late_initcall(fn) __define_initcall(fn, 7)
219#define late_initcall_sync(fn) __define_initcall("7s",fn,7s) 219#define late_initcall_sync(fn) __define_initcall(fn, 7s)
220 220
221#define __initcall(fn) device_initcall(fn) 221#define __initcall(fn) device_initcall(fn)
222 222
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d97ed5897447..d140e8fb075f 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -220,6 +220,23 @@ int __must_check _kstrtol(const char *s, unsigned int base, long *res);
220 220
221int __must_check kstrtoull(const char *s, unsigned int base, unsigned long long *res); 221int __must_check kstrtoull(const char *s, unsigned int base, unsigned long long *res);
222int __must_check kstrtoll(const char *s, unsigned int base, long long *res); 222int __must_check kstrtoll(const char *s, unsigned int base, long long *res);
223
224/**
225 * kstrtoul - convert a string to an unsigned long
226 * @s: The start of the string. The string must be null-terminated, and may also
227 * include a single newline before its terminating null. The first character
228 * may also be a plus sign, but not a minus sign.
229 * @base: The number base to use. The maximum supported base is 16. If base is
230 * given as 0, then the base of the string is automatically detected with the
231 * conventional semantics - If it begins with 0x the number will be parsed as a
232 * hexadecimal (case insensitive), if it otherwise begins with 0, it will be
233 * parsed as an octal number. Otherwise it will be parsed as a decimal.
234 * @res: Where to write the result of the conversion on success.
235 *
236 * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error.
237 * Used as a replacement for the obsolete simple_strtoull. Return code must
238 * be checked.
239*/
223static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res) 240static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res)
224{ 241{
225 /* 242 /*
@@ -233,6 +250,22 @@ static inline int __must_check kstrtoul(const char *s, unsigned int base, unsign
233 return _kstrtoul(s, base, res); 250 return _kstrtoul(s, base, res);
234} 251}
235 252
253/**
254 * kstrtol - convert a string to a long
255 * @s: The start of the string. The string must be null-terminated, and may also
256 * include a single newline before its terminating null. The first character
257 * may also be a plus sign or a minus sign.
258 * @base: The number base to use. The maximum supported base is 16. If base is
259 * given as 0, then the base of the string is automatically detected with the
260 * conventional semantics - If it begins with 0x the number will be parsed as a
261 * hexadecimal (case insensitive), if it otherwise begins with 0, it will be
262 * parsed as an octal number. Otherwise it will be parsed as a decimal.
263 * @res: Where to write the result of the conversion on success.
264 *
265 * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error.
266 * Used as a replacement for the obsolete simple_strtoull. Return code must
267 * be checked.
268 */
236static inline int __must_check kstrtol(const char *s, unsigned int base, long *res) 269static inline int __must_check kstrtol(const char *s, unsigned int base, long *res)
237{ 270{
238 /* 271 /*
diff --git a/include/linux/percpu-rwsem.h b/include/linux/percpu-rwsem.h
index bd1e86071e57..3e88c9a7d57f 100644
--- a/include/linux/percpu-rwsem.h
+++ b/include/linux/percpu-rwsem.h
@@ -1,83 +1,34 @@
1#ifndef _LINUX_PERCPU_RWSEM_H 1#ifndef _LINUX_PERCPU_RWSEM_H
2#define _LINUX_PERCPU_RWSEM_H 2#define _LINUX_PERCPU_RWSEM_H
3 3
4#include <linux/mutex.h> 4#include <linux/atomic.h>
5#include <linux/rwsem.h>
5#include <linux/percpu.h> 6#include <linux/percpu.h>
6#include <linux/rcupdate.h> 7#include <linux/wait.h>
7#include <linux/delay.h> 8#include <linux/lockdep.h>
8 9
9struct percpu_rw_semaphore { 10struct percpu_rw_semaphore {
10 unsigned __percpu *counters; 11 unsigned int __percpu *fast_read_ctr;
11 bool locked; 12 atomic_t write_ctr;
12 struct mutex mtx; 13 struct rw_semaphore rw_sem;
14 atomic_t slow_read_ctr;
15 wait_queue_head_t write_waitq;
13}; 16};
14 17
15#define light_mb() barrier() 18extern void percpu_down_read(struct percpu_rw_semaphore *);
16#define heavy_mb() synchronize_sched_expedited() 19extern void percpu_up_read(struct percpu_rw_semaphore *);
17 20
18static inline void percpu_down_read(struct percpu_rw_semaphore *p) 21extern void percpu_down_write(struct percpu_rw_semaphore *);
19{ 22extern void percpu_up_write(struct percpu_rw_semaphore *);
20 rcu_read_lock_sched();
21 if (unlikely(p->locked)) {
22 rcu_read_unlock_sched();
23 mutex_lock(&p->mtx);
24 this_cpu_inc(*p->counters);
25 mutex_unlock(&p->mtx);
26 return;
27 }
28 this_cpu_inc(*p->counters);
29 rcu_read_unlock_sched();
30 light_mb(); /* A, between read of p->locked and read of data, paired with D */
31}
32 23
33static inline void percpu_up_read(struct percpu_rw_semaphore *p) 24extern int __percpu_init_rwsem(struct percpu_rw_semaphore *,
34{ 25 const char *, struct lock_class_key *);
35 light_mb(); /* B, between read of the data and write to p->counter, paired with C */ 26extern void percpu_free_rwsem(struct percpu_rw_semaphore *);
36 this_cpu_dec(*p->counters);
37}
38 27
39static inline unsigned __percpu_count(unsigned __percpu *counters) 28#define percpu_init_rwsem(brw) \
40{ 29({ \
41 unsigned total = 0; 30 static struct lock_class_key rwsem_key; \
42 int cpu; 31 __percpu_init_rwsem(brw, #brw, &rwsem_key); \
43 32})
44 for_each_possible_cpu(cpu)
45 total += ACCESS_ONCE(*per_cpu_ptr(counters, cpu));
46
47 return total;
48}
49
50static inline void percpu_down_write(struct percpu_rw_semaphore *p)
51{
52 mutex_lock(&p->mtx);
53 p->locked = true;
54 synchronize_sched_expedited(); /* make sure that all readers exit the rcu_read_lock_sched region */
55 while (__percpu_count(p->counters))
56 msleep(1);
57 heavy_mb(); /* C, between read of p->counter and write to data, paired with B */
58}
59
60static inline void percpu_up_write(struct percpu_rw_semaphore *p)
61{
62 heavy_mb(); /* D, between write to data and write to p->locked, paired with A */
63 p->locked = false;
64 mutex_unlock(&p->mtx);
65}
66
67static inline int percpu_init_rwsem(struct percpu_rw_semaphore *p)
68{
69 p->counters = alloc_percpu(unsigned);
70 if (unlikely(!p->counters))
71 return -ENOMEM;
72 p->locked = false;
73 mutex_init(&p->mtx);
74 return 0;
75}
76
77static inline void percpu_free_rwsem(struct percpu_rw_semaphore *p)
78{
79 free_percpu(p->counters);
80 p->counters = NULL; /* catch use after free bugs */
81}
82 33
83#endif 34#endif
diff --git a/include/linux/platform_data/lp855x.h b/include/linux/platform_data/lp855x.h
index 761f31752367..e81f62d24ee2 100644
--- a/include/linux/platform_data/lp855x.h
+++ b/include/linux/platform_data/lp855x.h
@@ -89,11 +89,6 @@ enum lp8556_brightness_source {
89 LP8556_COMBINED2, /* pwm + i2c after the shaper block */ 89 LP8556_COMBINED2, /* pwm + i2c after the shaper block */
90}; 90};
91 91
92struct lp855x_pwm_data {
93 void (*pwm_set_intensity) (int brightness, int max_brightness);
94 int (*pwm_get_intensity) (int max_brightness);
95};
96
97struct lp855x_rom_data { 92struct lp855x_rom_data {
98 u8 addr; 93 u8 addr;
99 u8 val; 94 u8 val;
@@ -105,7 +100,7 @@ struct lp855x_rom_data {
105 * @mode : brightness control by pwm or lp855x register 100 * @mode : brightness control by pwm or lp855x register
106 * @device_control : value of DEVICE CONTROL register 101 * @device_control : value of DEVICE CONTROL register
107 * @initial_brightness : initial value of backlight brightness 102 * @initial_brightness : initial value of backlight brightness
108 * @pwm_data : platform specific pwm generation functions. 103 * @period_ns : platform specific pwm period value. unit is nano.
109 Only valid when mode is PWM_BASED. 104 Only valid when mode is PWM_BASED.
110 * @load_new_rom_data : 105 * @load_new_rom_data :
111 0 : use default configuration data 106 0 : use default configuration data
@@ -118,7 +113,7 @@ struct lp855x_platform_data {
118 enum lp855x_brightness_ctrl_mode mode; 113 enum lp855x_brightness_ctrl_mode mode;
119 u8 device_control; 114 u8 device_control;
120 int initial_brightness; 115 int initial_brightness;
121 struct lp855x_pwm_data pwm_data; 116 unsigned int period_ns;
122 u8 load_new_rom_data; 117 u8 load_new_rom_data;
123 int size_program; 118 int size_program;
124 struct lp855x_rom_data *rom_data; 119 struct lp855x_rom_data *rom_data;
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 2e24018b7cec..32676b35d2f5 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -314,4 +314,7 @@ static inline struct net *PDE_NET(struct proc_dir_entry *pde)
314 return pde->parent->data; 314 return pde->parent->data;
315} 315}
316 316
317#include <linux/signal.h>
318
319void render_sigset_t(struct seq_file *m, const char *header, sigset_t *set);
317#endif /* _LINUX_PROC_FS_H */ 320#endif /* _LINUX_PROC_FS_H */
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index a89ff04bddd9..addfbe7c180e 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -32,6 +32,8 @@
32#define PT_TRACE_EXIT PT_EVENT_FLAG(PTRACE_EVENT_EXIT) 32#define PT_TRACE_EXIT PT_EVENT_FLAG(PTRACE_EVENT_EXIT)
33#define PT_TRACE_SECCOMP PT_EVENT_FLAG(PTRACE_EVENT_SECCOMP) 33#define PT_TRACE_SECCOMP PT_EVENT_FLAG(PTRACE_EVENT_SECCOMP)
34 34
35#define PT_EXITKILL (PTRACE_O_EXITKILL << PT_OPT_FLAG_SHIFT)
36
35/* single stepping state bits (used on ARM and PA-RISC) */ 37/* single stepping state bits (used on ARM and PA-RISC) */
36#define PT_SINGLESTEP_BIT 31 38#define PT_SINGLESTEP_BIT 31
37#define PT_SINGLESTEP (1<<PT_SINGLESTEP_BIT) 39#define PT_SINGLESTEP (1<<PT_SINGLESTEP_BIT)
diff --git a/include/linux/random.h b/include/linux/random.h
index 6330ed47b38b..d9846088c2c5 100644
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -25,10 +25,19 @@ extern const struct file_operations random_fops, urandom_fops;
25unsigned int get_random_int(void); 25unsigned int get_random_int(void);
26unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len); 26unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len);
27 27
28u32 random32(void); 28u32 prandom_u32(void);
29void srandom32(u32 seed); 29void prandom_bytes(void *buf, int nbytes);
30void prandom_seed(u32 seed);
30 31
31u32 prandom32(struct rnd_state *); 32/*
33 * These macros are preserved for backward compatibility and should be
34 * removed as soon as a transition is finished.
35 */
36#define random32() prandom_u32()
37#define srandom32(seed) prandom_seed(seed)
38
39u32 prandom_u32_state(struct rnd_state *);
40void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
32 41
33/* 42/*
34 * Handle minimum values for seeds 43 * Handle minimum values for seeds
@@ -39,11 +48,11 @@ static inline u32 __seed(u32 x, u32 m)
39} 48}
40 49
41/** 50/**
42 * prandom32_seed - set seed for prandom32(). 51 * prandom_seed_state - set seed for prandom_u32_state().
43 * @state: pointer to state structure to receive the seed. 52 * @state: pointer to state structure to receive the seed.
44 * @seed: arbitrary 64-bit value to use as a seed. 53 * @seed: arbitrary 64-bit value to use as a seed.
45 */ 54 */
46static inline void prandom32_seed(struct rnd_state *state, u64 seed) 55static inline void prandom_seed_state(struct rnd_state *state, u64 seed)
47{ 56{
48 u32 i = (seed >> 32) ^ (seed << 10) ^ seed; 57 u32 i = (seed >> 32) ^ (seed << 10) ^ seed;
49 58
diff --git a/include/linux/sched.h b/include/linux/sched.h
index b089c92c609b..9914c662ed7b 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1778,12 +1778,6 @@ static inline int is_global_init(struct task_struct *tsk)
1778 return tsk->pid == 1; 1778 return tsk->pid == 1;
1779} 1779}
1780 1780
1781/*
1782 * is_container_init:
1783 * check whether in the task is init in its own pid namespace.
1784 */
1785extern int is_container_init(struct task_struct *tsk);
1786
1787extern struct pid *cad_pid; 1781extern struct pid *cad_pid;
1788 1782
1789extern void free_task(struct task_struct *tsk); 1783extern void free_task(struct task_struct *tsk);
diff --git a/include/linux/string.h b/include/linux/string.h
index 630125818ca8..ac889c5ea11b 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -143,4 +143,15 @@ static inline bool strstarts(const char *str, const char *prefix)
143 143
144extern size_t memweight(const void *ptr, size_t bytes); 144extern size_t memweight(const void *ptr, size_t bytes);
145 145
146/**
147 * kbasename - return the last part of a pathname.
148 *
149 * @path: path to extract the filename from.
150 */
151static inline const char *kbasename(const char *path)
152{
153 const char *tail = strrchr(path, '/');
154 return tail ? tail + 1 : path;
155}
156
146#endif /* _LINUX_STRING_H_ */ 157#endif /* _LINUX_STRING_H_ */
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 91835e7f364d..36c3b07c5119 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -560,10 +560,10 @@ asmlinkage long sys_utime(char __user *filename,
560asmlinkage long sys_utimes(char __user *filename, 560asmlinkage long sys_utimes(char __user *filename,
561 struct timeval __user *utimes); 561 struct timeval __user *utimes);
562asmlinkage long sys_lseek(unsigned int fd, off_t offset, 562asmlinkage long sys_lseek(unsigned int fd, off_t offset,
563 unsigned int origin); 563 unsigned int whence);
564asmlinkage long sys_llseek(unsigned int fd, unsigned long offset_high, 564asmlinkage long sys_llseek(unsigned int fd, unsigned long offset_high,
565 unsigned long offset_low, loff_t __user *result, 565 unsigned long offset_low, loff_t __user *result,
566 unsigned int origin); 566 unsigned int whence);
567asmlinkage long sys_read(unsigned int fd, char __user *buf, size_t count); 567asmlinkage long sys_read(unsigned int fd, char __user *buf, size_t count);
568asmlinkage long sys_readahead(int fd, loff_t offset, size_t count); 568asmlinkage long sys_readahead(int fd, loff_t offset, size_t count);
569asmlinkage long sys_readv(unsigned long fd, 569asmlinkage long sys_readv(unsigned long fd,
diff --git a/include/uapi/linux/ptrace.h b/include/uapi/linux/ptrace.h
index 1ef6c056a9e4..022ab186a812 100644
--- a/include/uapi/linux/ptrace.h
+++ b/include/uapi/linux/ptrace.h
@@ -73,7 +73,10 @@
73#define PTRACE_O_TRACEEXIT (1 << PTRACE_EVENT_EXIT) 73#define PTRACE_O_TRACEEXIT (1 << PTRACE_EVENT_EXIT)
74#define PTRACE_O_TRACESECCOMP (1 << PTRACE_EVENT_SECCOMP) 74#define PTRACE_O_TRACESECCOMP (1 << PTRACE_EVENT_SECCOMP)
75 75
76#define PTRACE_O_MASK 0x000000ff 76/* eventless options */
77#define PTRACE_O_EXITKILL (1 << 20)
78
79#define PTRACE_O_MASK (0x000000ff | PTRACE_O_EXITKILL)
77 80
78#include <asm/ptrace.h> 81#include <asm/ptrace.h>
79 82
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 9915ffe01372..4855892798fd 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1333,7 +1333,6 @@ static int cgroup_remount(struct super_block *sb, int *flags, char *data)
1333 if (ret) 1333 if (ret)
1334 goto out_unlock; 1334 goto out_unlock;
1335 1335
1336 /* See feature-removal-schedule.txt */
1337 if (opts.subsys_mask != root->actual_subsys_mask || opts.release_agent) 1336 if (opts.subsys_mask != root->actual_subsys_mask || opts.release_agent)
1338 pr_warning("cgroup: option changes via remount are deprecated (pid=%d comm=%s)\n", 1337 pr_warning("cgroup: option changes via remount are deprecated (pid=%d comm=%s)\n",
1339 task_tgid_nr(current), current->comm); 1338 task_tgid_nr(current), current->comm);
diff --git a/kernel/compat.c b/kernel/compat.c
index c28a306ae05c..f6150e92dfc9 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -1215,6 +1215,23 @@ compat_sys_sysinfo(struct compat_sysinfo __user *info)
1215 return 0; 1215 return 0;
1216} 1216}
1217 1217
1218#ifdef __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL
1219asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid,
1220 struct compat_timespec __user *interval)
1221{
1222 struct timespec t;
1223 int ret;
1224 mm_segment_t old_fs = get_fs();
1225
1226 set_fs(KERNEL_DS);
1227 ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
1228 set_fs(old_fs);
1229 if (put_compat_timespec(&t, interval))
1230 return -EFAULT;
1231 return ret;
1232}
1233#endif /* __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL */
1234
1218/* 1235/*
1219 * Allocate user-space memory for the duration of a single system call, 1236 * Allocate user-space memory for the duration of a single system call,
1220 * in order to marshall parameters inside a compat thunk. 1237 * in order to marshall parameters inside a compat thunk.
diff --git a/kernel/module.c b/kernel/module.c
index 6e48c3a43599..808bd62e1723 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -372,9 +372,6 @@ static bool check_symbol(const struct symsearch *syms,
372 printk(KERN_WARNING "Symbol %s is being used " 372 printk(KERN_WARNING "Symbol %s is being used "
373 "by a non-GPL module, which will not " 373 "by a non-GPL module, which will not "
374 "be allowed in the future\n", fsa->name); 374 "be allowed in the future\n", fsa->name);
375 printk(KERN_WARNING "Please see the file "
376 "Documentation/feature-removal-schedule.txt "
377 "in the kernel source tree for more details.\n");
378 } 375 }
379 } 376 }
380 377
diff --git a/kernel/pid.c b/kernel/pid.c
index 3e2cf8100acc..36aa02ff17d6 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -84,21 +84,6 @@ struct pid_namespace init_pid_ns = {
84}; 84};
85EXPORT_SYMBOL_GPL(init_pid_ns); 85EXPORT_SYMBOL_GPL(init_pid_ns);
86 86
87int is_container_init(struct task_struct *tsk)
88{
89 int ret = 0;
90 struct pid *pid;
91
92 rcu_read_lock();
93 pid = task_pid(tsk);
94 if (pid != NULL && pid->numbers[pid->level].nr == 1)
95 ret = 1;
96 rcu_read_unlock();
97
98 return ret;
99}
100EXPORT_SYMBOL(is_container_init);
101
102/* 87/*
103 * Note: disable interrupts while the pidmap_lock is held as an 88 * Note: disable interrupts while the pidmap_lock is held as an
104 * interrupt might come in and do read_lock(&tasklist_lock). 89 * interrupt might come in and do read_lock(&tasklist_lock).
diff --git a/kernel/printk.c b/kernel/printk.c
index 22e070f3470a..19c0d7bcf24a 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -747,6 +747,21 @@ void __init setup_log_buf(int early)
747 free, (free * 100) / __LOG_BUF_LEN); 747 free, (free * 100) / __LOG_BUF_LEN);
748} 748}
749 749
750static bool __read_mostly ignore_loglevel;
751
752static int __init ignore_loglevel_setup(char *str)
753{
754 ignore_loglevel = 1;
755 printk(KERN_INFO "debug: ignoring loglevel setting.\n");
756
757 return 0;
758}
759
760early_param("ignore_loglevel", ignore_loglevel_setup);
761module_param(ignore_loglevel, bool, S_IRUGO | S_IWUSR);
762MODULE_PARM_DESC(ignore_loglevel, "ignore loglevel setting, to"
763 "print all kernel messages to the console.");
764
750#ifdef CONFIG_BOOT_PRINTK_DELAY 765#ifdef CONFIG_BOOT_PRINTK_DELAY
751 766
752static int boot_delay; /* msecs delay after each printk during bootup */ 767static int boot_delay; /* msecs delay after each printk during bootup */
@@ -770,13 +785,15 @@ static int __init boot_delay_setup(char *str)
770} 785}
771__setup("boot_delay=", boot_delay_setup); 786__setup("boot_delay=", boot_delay_setup);
772 787
773static void boot_delay_msec(void) 788static void boot_delay_msec(int level)
774{ 789{
775 unsigned long long k; 790 unsigned long long k;
776 unsigned long timeout; 791 unsigned long timeout;
777 792
778 if (boot_delay == 0 || system_state != SYSTEM_BOOTING) 793 if ((boot_delay == 0 || system_state != SYSTEM_BOOTING)
794 || (level >= console_loglevel && !ignore_loglevel)) {
779 return; 795 return;
796 }
780 797
781 k = (unsigned long long)loops_per_msec * boot_delay; 798 k = (unsigned long long)loops_per_msec * boot_delay;
782 799
@@ -795,7 +812,7 @@ static void boot_delay_msec(void)
795 } 812 }
796} 813}
797#else 814#else
798static inline void boot_delay_msec(void) 815static inline void boot_delay_msec(int level)
799{ 816{
800} 817}
801#endif 818#endif
@@ -1238,21 +1255,6 @@ SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len)
1238 return do_syslog(type, buf, len, SYSLOG_FROM_CALL); 1255 return do_syslog(type, buf, len, SYSLOG_FROM_CALL);
1239} 1256}
1240 1257
1241static bool __read_mostly ignore_loglevel;
1242
1243static int __init ignore_loglevel_setup(char *str)
1244{
1245 ignore_loglevel = 1;
1246 printk(KERN_INFO "debug: ignoring loglevel setting.\n");
1247
1248 return 0;
1249}
1250
1251early_param("ignore_loglevel", ignore_loglevel_setup);
1252module_param(ignore_loglevel, bool, S_IRUGO | S_IWUSR);
1253MODULE_PARM_DESC(ignore_loglevel, "ignore loglevel setting, to"
1254 "print all kernel messages to the console.");
1255
1256/* 1258/*
1257 * Call the console drivers, asking them to write out 1259 * Call the console drivers, asking them to write out
1258 * log_buf[start] to log_buf[end - 1]. 1260 * log_buf[start] to log_buf[end - 1].
@@ -1498,7 +1500,7 @@ asmlinkage int vprintk_emit(int facility, int level,
1498 int this_cpu; 1500 int this_cpu;
1499 int printed_len = 0; 1501 int printed_len = 0;
1500 1502
1501 boot_delay_msec(); 1503 boot_delay_msec(level);
1502 printk_delay(); 1504 printk_delay();
1503 1505
1504 /* This stops the holder of console_sem just where we want him */ 1506 /* This stops the holder of console_sem just where we want him */
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 7b09b88862cc..1599157336a6 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -463,6 +463,9 @@ void exit_ptrace(struct task_struct *tracer)
463 return; 463 return;
464 464
465 list_for_each_entry_safe(p, n, &tracer->ptraced, ptrace_entry) { 465 list_for_each_entry_safe(p, n, &tracer->ptraced, ptrace_entry) {
466 if (unlikely(p->ptrace & PT_EXITKILL))
467 send_sig_info(SIGKILL, SEND_SIG_FORCED, p);
468
466 if (__ptrace_detach(tracer, p)) 469 if (__ptrace_detach(tracer, p))
467 list_add(&p->ptrace_entry, &ptrace_dead); 470 list_add(&p->ptrace_entry, &ptrace_dead);
468 } 471 }
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index afd092de45b7..3ffe4c5ad3f3 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2675,12 +2675,12 @@ ftrace_notrace_open(struct inode *inode, struct file *file)
2675} 2675}
2676 2676
2677loff_t 2677loff_t
2678ftrace_regex_lseek(struct file *file, loff_t offset, int origin) 2678ftrace_regex_lseek(struct file *file, loff_t offset, int whence)
2679{ 2679{
2680 loff_t ret; 2680 loff_t ret;
2681 2681
2682 if (file->f_mode & FMODE_READ) 2682 if (file->f_mode & FMODE_READ)
2683 ret = seq_lseek(file, offset, origin); 2683 ret = seq_lseek(file, offset, whence);
2684 else 2684 else
2685 file->f_pos = ret = 1; 2685 file->f_pos = ret = 1;
2686 2686
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 9614db8b0f8c..c86e6d4f67fb 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -22,6 +22,7 @@
22#include <linux/uaccess.h> 22#include <linux/uaccess.h>
23#include <linux/uprobes.h> 23#include <linux/uprobes.h>
24#include <linux/namei.h> 24#include <linux/namei.h>
25#include <linux/string.h>
25 26
26#include "trace_probe.h" 27#include "trace_probe.h"
27 28
@@ -263,16 +264,15 @@ static int create_trace_uprobe(int argc, char **argv)
263 264
264 /* setup a probe */ 265 /* setup a probe */
265 if (!event) { 266 if (!event) {
266 char *tail = strrchr(filename, '/'); 267 char *tail;
267 char *ptr; 268 char *ptr;
268 269
269 ptr = kstrdup((tail ? tail + 1 : filename), GFP_KERNEL); 270 tail = kstrdup(kbasename(filename), GFP_KERNEL);
270 if (!ptr) { 271 if (!tail) {
271 ret = -ENOMEM; 272 ret = -ENOMEM;
272 goto fail_address_parse; 273 goto fail_address_parse;
273 } 274 }
274 275
275 tail = ptr;
276 ptr = strpbrk(tail, ".-_"); 276 ptr = strpbrk(tail, ".-_");
277 if (ptr) 277 if (ptr)
278 *ptr = '\0'; 278 *ptr = '\0';
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index c8c21be11ab4..997c6a16ec22 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -31,6 +31,7 @@
31int watchdog_enabled = 1; 31int watchdog_enabled = 1;
32int __read_mostly watchdog_thresh = 10; 32int __read_mostly watchdog_thresh = 10;
33static int __read_mostly watchdog_disabled; 33static int __read_mostly watchdog_disabled;
34static u64 __read_mostly sample_period;
34 35
35static DEFINE_PER_CPU(unsigned long, watchdog_touch_ts); 36static DEFINE_PER_CPU(unsigned long, watchdog_touch_ts);
36static DEFINE_PER_CPU(struct task_struct *, softlockup_watchdog); 37static DEFINE_PER_CPU(struct task_struct *, softlockup_watchdog);
@@ -116,7 +117,7 @@ static unsigned long get_timestamp(int this_cpu)
116 return cpu_clock(this_cpu) >> 30LL; /* 2^30 ~= 10^9 */ 117 return cpu_clock(this_cpu) >> 30LL; /* 2^30 ~= 10^9 */
117} 118}
118 119
119static u64 get_sample_period(void) 120static void set_sample_period(void)
120{ 121{
121 /* 122 /*
122 * convert watchdog_thresh from seconds to ns 123 * convert watchdog_thresh from seconds to ns
@@ -125,7 +126,7 @@ static u64 get_sample_period(void)
125 * and hard thresholds) to increment before the 126 * and hard thresholds) to increment before the
126 * hardlockup detector generates a warning 127 * hardlockup detector generates a warning
127 */ 128 */
128 return get_softlockup_thresh() * ((u64)NSEC_PER_SEC / 5); 129 sample_period = get_softlockup_thresh() * ((u64)NSEC_PER_SEC / 5);
129} 130}
130 131
131/* Commands for resetting the watchdog */ 132/* Commands for resetting the watchdog */
@@ -275,7 +276,7 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
275 wake_up_process(__this_cpu_read(softlockup_watchdog)); 276 wake_up_process(__this_cpu_read(softlockup_watchdog));
276 277
277 /* .. and repeat */ 278 /* .. and repeat */
278 hrtimer_forward_now(hrtimer, ns_to_ktime(get_sample_period())); 279 hrtimer_forward_now(hrtimer, ns_to_ktime(sample_period));
279 280
280 if (touch_ts == 0) { 281 if (touch_ts == 0) {
281 if (unlikely(__this_cpu_read(softlockup_touch_sync))) { 282 if (unlikely(__this_cpu_read(softlockup_touch_sync))) {
@@ -356,7 +357,7 @@ static void watchdog_enable(unsigned int cpu)
356 hrtimer->function = watchdog_timer_fn; 357 hrtimer->function = watchdog_timer_fn;
357 358
358 /* done here because hrtimer_start can only pin to smp_processor_id() */ 359 /* done here because hrtimer_start can only pin to smp_processor_id() */
359 hrtimer_start(hrtimer, ns_to_ktime(get_sample_period()), 360 hrtimer_start(hrtimer, ns_to_ktime(sample_period),
360 HRTIMER_MODE_REL_PINNED); 361 HRTIMER_MODE_REL_PINNED);
361 362
362 /* initialize timestamp */ 363 /* initialize timestamp */
@@ -386,7 +387,7 @@ static int watchdog_should_run(unsigned int cpu)
386/* 387/*
387 * The watchdog thread function - touches the timestamp. 388 * The watchdog thread function - touches the timestamp.
388 * 389 *
389 * It only runs once every get_sample_period() seconds (4 seconds by 390 * It only runs once every sample_period seconds (4 seconds by
390 * default) to reset the softlockup timestamp. If this gets delayed 391 * default) to reset the softlockup timestamp. If this gets delayed
391 * for more than 2*watchdog_thresh seconds then the debug-printout 392 * for more than 2*watchdog_thresh seconds then the debug-printout
392 * triggers in watchdog_timer_fn(). 393 * triggers in watchdog_timer_fn().
@@ -519,6 +520,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
519 if (ret || !write) 520 if (ret || !write)
520 return ret; 521 return ret;
521 522
523 set_sample_period();
522 if (watchdog_enabled && watchdog_thresh) 524 if (watchdog_enabled && watchdog_thresh)
523 watchdog_enable_all_cpus(); 525 watchdog_enable_all_cpus();
524 else 526 else
@@ -540,6 +542,7 @@ static struct smp_hotplug_thread watchdog_threads = {
540 542
541void __init lockup_detector_init(void) 543void __init lockup_detector_init(void)
542{ 544{
545 set_sample_period();
543 if (smpboot_register_percpu_thread(&watchdog_threads)) { 546 if (smpboot_register_percpu_thread(&watchdog_threads)) {
544 pr_err("Failed to create watchdog threads, disabled\n"); 547 pr_err("Failed to create watchdog threads, disabled\n");
545 watchdog_disabled = -ENODEV; 548 watchdog_disabled = -ENODEV;
diff --git a/lib/Kconfig b/lib/Kconfig
index 4b31a46fb307..75cdb77fa49d 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -42,6 +42,9 @@ config GENERIC_IO
42config STMP_DEVICE 42config STMP_DEVICE
43 bool 43 bool
44 44
45config PERCPU_RWSEM
46 boolean
47
45config CRC_CCITT 48config CRC_CCITT
46 tristate "CRC-CCITT functions" 49 tristate "CRC-CCITT functions"
47 help 50 help
diff --git a/lib/Makefile b/lib/Makefile
index e2152fa7ff4d..5558e35170cd 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -40,6 +40,7 @@ obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
40obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock_debug.o 40obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock_debug.o
41lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o 41lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
42lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o 42lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
43lib-$(CONFIG_PERCPU_RWSEM) += percpu-rwsem.o
43 44
44CFLAGS_hweight.o = $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS)) 45CFLAGS_hweight.o = $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
45obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o 46obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index e7f7d993357a..1db1fc660538 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -62,13 +62,6 @@ static LIST_HEAD(ddebug_tables);
62static int verbose = 0; 62static int verbose = 0;
63module_param(verbose, int, 0644); 63module_param(verbose, int, 0644);
64 64
65/* Return the last part of a pathname */
66static inline const char *basename(const char *path)
67{
68 const char *tail = strrchr(path, '/');
69 return tail ? tail+1 : path;
70}
71
72/* Return the path relative to source root */ 65/* Return the path relative to source root */
73static inline const char *trim_prefix(const char *path) 66static inline const char *trim_prefix(const char *path)
74{ 67{
@@ -154,7 +147,7 @@ static int ddebug_change(const struct ddebug_query *query,
154 /* match against the source filename */ 147 /* match against the source filename */
155 if (query->filename && 148 if (query->filename &&
156 strcmp(query->filename, dp->filename) && 149 strcmp(query->filename, dp->filename) &&
157 strcmp(query->filename, basename(dp->filename)) && 150 strcmp(query->filename, kbasename(dp->filename)) &&
158 strcmp(query->filename, trim_prefix(dp->filename))) 151 strcmp(query->filename, trim_prefix(dp->filename)))
159 continue; 152 continue;
160 153
diff --git a/lib/interval_tree_test_main.c b/lib/interval_tree_test_main.c
index b25903987f7a..245900b98c8e 100644
--- a/lib/interval_tree_test_main.c
+++ b/lib/interval_tree_test_main.c
@@ -30,7 +30,8 @@ static void init(void)
30{ 30{
31 int i; 31 int i;
32 for (i = 0; i < NODES; i++) { 32 for (i = 0; i < NODES; i++) {
33 u32 a = prandom32(&rnd), b = prandom32(&rnd); 33 u32 a = prandom_u32_state(&rnd);
34 u32 b = prandom_u32_state(&rnd);
34 if (a <= b) { 35 if (a <= b) {
35 nodes[i].start = a; 36 nodes[i].start = a;
36 nodes[i].last = b; 37 nodes[i].last = b;
@@ -40,7 +41,7 @@ static void init(void)
40 } 41 }
41 } 42 }
42 for (i = 0; i < SEARCHES; i++) 43 for (i = 0; i < SEARCHES; i++)
43 queries[i] = prandom32(&rnd); 44 queries[i] = prandom_u32_state(&rnd);
44} 45}
45 46
46static int interval_tree_test_init(void) 47static int interval_tree_test_init(void)
@@ -51,7 +52,7 @@ static int interval_tree_test_init(void)
51 52
52 printk(KERN_ALERT "interval tree insert/remove"); 53 printk(KERN_ALERT "interval tree insert/remove");
53 54
54 prandom32_seed(&rnd, 3141592653589793238ULL); 55 prandom_seed_state(&rnd, 3141592653589793238ULL);
55 init(); 56 init();
56 57
57 time1 = get_cycles(); 58 time1 = get_cycles();
diff --git a/lib/kstrtox.c b/lib/kstrtox.c
index c3615eab0cc3..f78ae0c0c4e2 100644
--- a/lib/kstrtox.c
+++ b/lib/kstrtox.c
@@ -104,6 +104,22 @@ static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res)
104 return 0; 104 return 0;
105} 105}
106 106
107/**
108 * kstrtoull - convert a string to an unsigned long long
109 * @s: The start of the string. The string must be null-terminated, and may also
110 * include a single newline before its terminating null. The first character
111 * may also be a plus sign, but not a minus sign.
112 * @base: The number base to use. The maximum supported base is 16. If base is
113 * given as 0, then the base of the string is automatically detected with the
114 * conventional semantics - If it begins with 0x the number will be parsed as a
115 * hexadecimal (case insensitive), if it otherwise begins with 0, it will be
116 * parsed as an octal number. Otherwise it will be parsed as a decimal.
117 * @res: Where to write the result of the conversion on success.
118 *
119 * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error.
120 * Used as a replacement for the obsolete simple_strtoull. Return code must
121 * be checked.
122 */
107int kstrtoull(const char *s, unsigned int base, unsigned long long *res) 123int kstrtoull(const char *s, unsigned int base, unsigned long long *res)
108{ 124{
109 if (s[0] == '+') 125 if (s[0] == '+')
@@ -112,6 +128,22 @@ int kstrtoull(const char *s, unsigned int base, unsigned long long *res)
112} 128}
113EXPORT_SYMBOL(kstrtoull); 129EXPORT_SYMBOL(kstrtoull);
114 130
131/**
132 * kstrtoll - convert a string to a long long
133 * @s: The start of the string. The string must be null-terminated, and may also
134 * include a single newline before its terminating null. The first character
135 * may also be a plus sign or a minus sign.
136 * @base: The number base to use. The maximum supported base is 16. If base is
137 * given as 0, then the base of the string is automatically detected with the
138 * conventional semantics - If it begins with 0x the number will be parsed as a
139 * hexadecimal (case insensitive), if it otherwise begins with 0, it will be
140 * parsed as an octal number. Otherwise it will be parsed as a decimal.
141 * @res: Where to write the result of the conversion on success.
142 *
143 * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error.
144 * Used as a replacement for the obsolete simple_strtoull. Return code must
145 * be checked.
146 */
115int kstrtoll(const char *s, unsigned int base, long long *res) 147int kstrtoll(const char *s, unsigned int base, long long *res)
116{ 148{
117 unsigned long long tmp; 149 unsigned long long tmp;
@@ -168,6 +200,22 @@ int _kstrtol(const char *s, unsigned int base, long *res)
168} 200}
169EXPORT_SYMBOL(_kstrtol); 201EXPORT_SYMBOL(_kstrtol);
170 202
203/**
204 * kstrtouint - convert a string to an unsigned int
205 * @s: The start of the string. The string must be null-terminated, and may also
206 * include a single newline before its terminating null. The first character
207 * may also be a plus sign, but not a minus sign.
208 * @base: The number base to use. The maximum supported base is 16. If base is
209 * given as 0, then the base of the string is automatically detected with the
210 * conventional semantics - If it begins with 0x the number will be parsed as a
211 * hexadecimal (case insensitive), if it otherwise begins with 0, it will be
212 * parsed as an octal number. Otherwise it will be parsed as a decimal.
213 * @res: Where to write the result of the conversion on success.
214 *
215 * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error.
216 * Used as a replacement for the obsolete simple_strtoull. Return code must
217 * be checked.
218 */
171int kstrtouint(const char *s, unsigned int base, unsigned int *res) 219int kstrtouint(const char *s, unsigned int base, unsigned int *res)
172{ 220{
173 unsigned long long tmp; 221 unsigned long long tmp;
@@ -183,6 +231,22 @@ int kstrtouint(const char *s, unsigned int base, unsigned int *res)
183} 231}
184EXPORT_SYMBOL(kstrtouint); 232EXPORT_SYMBOL(kstrtouint);
185 233
234/**
235 * kstrtoint - convert a string to an int
236 * @s: The start of the string. The string must be null-terminated, and may also
237 * include a single newline before its terminating null. The first character
238 * may also be a plus sign or a minus sign.
239 * @base: The number base to use. The maximum supported base is 16. If base is
240 * given as 0, then the base of the string is automatically detected with the
241 * conventional semantics - If it begins with 0x the number will be parsed as a
242 * hexadecimal (case insensitive), if it otherwise begins with 0, it will be
243 * parsed as an octal number. Otherwise it will be parsed as a decimal.
244 * @res: Where to write the result of the conversion on success.
245 *
246 * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error.
247 * Used as a replacement for the obsolete simple_strtoull. Return code must
248 * be checked.
249 */
186int kstrtoint(const char *s, unsigned int base, int *res) 250int kstrtoint(const char *s, unsigned int base, int *res)
187{ 251{
188 long long tmp; 252 long long tmp;
diff --git a/lib/percpu-rwsem.c b/lib/percpu-rwsem.c
new file mode 100644
index 000000000000..652a8ee8efe9
--- /dev/null
+++ b/lib/percpu-rwsem.c
@@ -0,0 +1,165 @@
1#include <linux/atomic.h>
2#include <linux/rwsem.h>
3#include <linux/percpu.h>
4#include <linux/wait.h>
5#include <linux/lockdep.h>
6#include <linux/percpu-rwsem.h>
7#include <linux/rcupdate.h>
8#include <linux/sched.h>
9#include <linux/errno.h>
10
11int __percpu_init_rwsem(struct percpu_rw_semaphore *brw,
12 const char *name, struct lock_class_key *rwsem_key)
13{
14 brw->fast_read_ctr = alloc_percpu(int);
15 if (unlikely(!brw->fast_read_ctr))
16 return -ENOMEM;
17
18 /* ->rw_sem represents the whole percpu_rw_semaphore for lockdep */
19 __init_rwsem(&brw->rw_sem, name, rwsem_key);
20 atomic_set(&brw->write_ctr, 0);
21 atomic_set(&brw->slow_read_ctr, 0);
22 init_waitqueue_head(&brw->write_waitq);
23 return 0;
24}
25
26void percpu_free_rwsem(struct percpu_rw_semaphore *brw)
27{
28 free_percpu(brw->fast_read_ctr);
29 brw->fast_read_ctr = NULL; /* catch use after free bugs */
30}
31
32/*
33 * This is the fast-path for down_read/up_read, it only needs to ensure
34 * there is no pending writer (atomic_read(write_ctr) == 0) and inc/dec the
35 * fast per-cpu counter. The writer uses synchronize_sched_expedited() to
36 * serialize with the preempt-disabled section below.
37 *
38 * The nontrivial part is that we should guarantee acquire/release semantics
39 * in case when
40 *
41 * R_W: down_write() comes after up_read(), the writer should see all
42 * changes done by the reader
43 * or
44 * W_R: down_read() comes after up_write(), the reader should see all
45 * changes done by the writer
46 *
47 * If this helper fails the callers rely on the normal rw_semaphore and
48 * atomic_dec_and_test(), so in this case we have the necessary barriers.
49 *
50 * But if it succeeds we do not have any barriers, atomic_read(write_ctr) or
51 * __this_cpu_add() below can be reordered with any LOAD/STORE done by the
52 * reader inside the critical section. See the comments in down_write and
53 * up_write below.
54 */
55static bool update_fast_ctr(struct percpu_rw_semaphore *brw, unsigned int val)
56{
57 bool success = false;
58
59 preempt_disable();
60 if (likely(!atomic_read(&brw->write_ctr))) {
61 __this_cpu_add(*brw->fast_read_ctr, val);
62 success = true;
63 }
64 preempt_enable();
65
66 return success;
67}
68
69/*
70 * Like the normal down_read() this is not recursive, the writer can
71 * come after the first percpu_down_read() and create the deadlock.
72 *
73 * Note: returns with lock_is_held(brw->rw_sem) == T for lockdep,
74 * percpu_up_read() does rwsem_release(). This pairs with the usage
75 * of ->rw_sem in percpu_down/up_write().
76 */
77void percpu_down_read(struct percpu_rw_semaphore *brw)
78{
79 might_sleep();
80 if (likely(update_fast_ctr(brw, +1))) {
81 rwsem_acquire_read(&brw->rw_sem.dep_map, 0, 0, _RET_IP_);
82 return;
83 }
84
85 down_read(&brw->rw_sem);
86 atomic_inc(&brw->slow_read_ctr);
87 /* avoid up_read()->rwsem_release() */
88 __up_read(&brw->rw_sem);
89}
90
91void percpu_up_read(struct percpu_rw_semaphore *brw)
92{
93 rwsem_release(&brw->rw_sem.dep_map, 1, _RET_IP_);
94
95 if (likely(update_fast_ctr(brw, -1)))
96 return;
97
98 /* false-positive is possible but harmless */
99 if (atomic_dec_and_test(&brw->slow_read_ctr))
100 wake_up_all(&brw->write_waitq);
101}
102
103static int clear_fast_ctr(struct percpu_rw_semaphore *brw)
104{
105 unsigned int sum = 0;
106 int cpu;
107
108 for_each_possible_cpu(cpu) {
109 sum += per_cpu(*brw->fast_read_ctr, cpu);
110 per_cpu(*brw->fast_read_ctr, cpu) = 0;
111 }
112
113 return sum;
114}
115
116/*
117 * A writer increments ->write_ctr to force the readers to switch to the
118 * slow mode, note the atomic_read() check in update_fast_ctr().
119 *
120 * After that the readers can only inc/dec the slow ->slow_read_ctr counter,
121 * ->fast_read_ctr is stable. Once the writer moves its sum into the slow
122 * counter it represents the number of active readers.
123 *
124 * Finally the writer takes ->rw_sem for writing and blocks the new readers,
125 * then waits until the slow counter becomes zero.
126 */
127void percpu_down_write(struct percpu_rw_semaphore *brw)
128{
129 /* tell update_fast_ctr() there is a pending writer */
130 atomic_inc(&brw->write_ctr);
131 /*
132 * 1. Ensures that write_ctr != 0 is visible to any down_read/up_read
133 * so that update_fast_ctr() can't succeed.
134 *
135 * 2. Ensures we see the result of every previous this_cpu_add() in
136 * update_fast_ctr().
137 *
138 * 3. Ensures that if any reader has exited its critical section via
139 * fast-path, it executes a full memory barrier before we return.
140 * See R_W case in the comment above update_fast_ctr().
141 */
142 synchronize_sched_expedited();
143
144 /* exclude other writers, and block the new readers completely */
145 down_write(&brw->rw_sem);
146
147 /* nobody can use fast_read_ctr, move its sum into slow_read_ctr */
148 atomic_add(clear_fast_ctr(brw), &brw->slow_read_ctr);
149
150 /* wait for all readers to complete their percpu_up_read() */
151 wait_event(brw->write_waitq, !atomic_read(&brw->slow_read_ctr));
152}
153
154void percpu_up_write(struct percpu_rw_semaphore *brw)
155{
156 /* release the lock, but the readers can't use the fast-path */
157 up_write(&brw->rw_sem);
158 /*
159 * Insert the barrier before the next fast-path in down_read,
160 * see W_R case in the comment above update_fast_ctr().
161 */
162 synchronize_sched_expedited();
163 /* the last writer unblocks update_fast_ctr() */
164 atomic_dec(&brw->write_ctr);
165}
diff --git a/lib/random32.c b/lib/random32.c
index 938bde5876ac..52280d5526be 100644
--- a/lib/random32.c
+++ b/lib/random32.c
@@ -42,13 +42,13 @@
42static DEFINE_PER_CPU(struct rnd_state, net_rand_state); 42static DEFINE_PER_CPU(struct rnd_state, net_rand_state);
43 43
44/** 44/**
45 * prandom32 - seeded pseudo-random number generator. 45 * prandom_u32_state - seeded pseudo-random number generator.
46 * @state: pointer to state structure holding seeded state. 46 * @state: pointer to state structure holding seeded state.
47 * 47 *
48 * This is used for pseudo-randomness with no outside seeding. 48 * This is used for pseudo-randomness with no outside seeding.
49 * For more random results, use random32(). 49 * For more random results, use prandom_u32().
50 */ 50 */
51u32 prandom32(struct rnd_state *state) 51u32 prandom_u32_state(struct rnd_state *state)
52{ 52{
53#define TAUSWORTHE(s,a,b,c,d) ((s&c)<<d) ^ (((s <<a) ^ s)>>b) 53#define TAUSWORTHE(s,a,b,c,d) ((s&c)<<d) ^ (((s <<a) ^ s)>>b)
54 54
@@ -58,32 +58,81 @@ u32 prandom32(struct rnd_state *state)
58 58
59 return (state->s1 ^ state->s2 ^ state->s3); 59 return (state->s1 ^ state->s2 ^ state->s3);
60} 60}
61EXPORT_SYMBOL(prandom32); 61EXPORT_SYMBOL(prandom_u32_state);
62 62
63/** 63/**
64 * random32 - pseudo random number generator 64 * prandom_u32 - pseudo random number generator
65 * 65 *
66 * A 32 bit pseudo-random number is generated using a fast 66 * A 32 bit pseudo-random number is generated using a fast
67 * algorithm suitable for simulation. This algorithm is NOT 67 * algorithm suitable for simulation. This algorithm is NOT
68 * considered safe for cryptographic use. 68 * considered safe for cryptographic use.
69 */ 69 */
70u32 random32(void) 70u32 prandom_u32(void)
71{ 71{
72 unsigned long r; 72 unsigned long r;
73 struct rnd_state *state = &get_cpu_var(net_rand_state); 73 struct rnd_state *state = &get_cpu_var(net_rand_state);
74 r = prandom32(state); 74 r = prandom_u32_state(state);
75 put_cpu_var(state); 75 put_cpu_var(state);
76 return r; 76 return r;
77} 77}
78EXPORT_SYMBOL(random32); 78EXPORT_SYMBOL(prandom_u32);
79
80/*
81 * prandom_bytes_state - get the requested number of pseudo-random bytes
82 *
83 * @state: pointer to state structure holding seeded state.
84 * @buf: where to copy the pseudo-random bytes to
85 * @bytes: the requested number of bytes
86 *
87 * This is used for pseudo-randomness with no outside seeding.
88 * For more random results, use prandom_bytes().
89 */
90void prandom_bytes_state(struct rnd_state *state, void *buf, int bytes)
91{
92 unsigned char *p = buf;
93 int i;
94
95 for (i = 0; i < round_down(bytes, sizeof(u32)); i += sizeof(u32)) {
96 u32 random = prandom_u32_state(state);
97 int j;
98
99 for (j = 0; j < sizeof(u32); j++) {
100 p[i + j] = random;
101 random >>= BITS_PER_BYTE;
102 }
103 }
104 if (i < bytes) {
105 u32 random = prandom_u32_state(state);
106
107 for (; i < bytes; i++) {
108 p[i] = random;
109 random >>= BITS_PER_BYTE;
110 }
111 }
112}
113EXPORT_SYMBOL(prandom_bytes_state);
114
115/**
116 * prandom_bytes - get the requested number of pseudo-random bytes
117 * @buf: where to copy the pseudo-random bytes to
118 * @bytes: the requested number of bytes
119 */
120void prandom_bytes(void *buf, int bytes)
121{
122 struct rnd_state *state = &get_cpu_var(net_rand_state);
123
124 prandom_bytes_state(state, buf, bytes);
125 put_cpu_var(state);
126}
127EXPORT_SYMBOL(prandom_bytes);
79 128
80/** 129/**
81 * srandom32 - add entropy to pseudo random number generator 130 * prandom_seed - add entropy to pseudo random number generator
82 * @seed: seed value 131 * @seed: seed value
83 * 132 *
84 * Add some additional seeding to the random32() pool. 133 * Add some additional seeding to the prandom pool.
85 */ 134 */
86void srandom32(u32 entropy) 135void prandom_seed(u32 entropy)
87{ 136{
88 int i; 137 int i;
89 /* 138 /*
@@ -95,13 +144,13 @@ void srandom32(u32 entropy)
95 state->s1 = __seed(state->s1 ^ entropy, 1); 144 state->s1 = __seed(state->s1 ^ entropy, 1);
96 } 145 }
97} 146}
98EXPORT_SYMBOL(srandom32); 147EXPORT_SYMBOL(prandom_seed);
99 148
100/* 149/*
101 * Generate some initially weak seeding values to allow 150 * Generate some initially weak seeding values to allow
102 * to start the random32() engine. 151 * to start the prandom_u32() engine.
103 */ 152 */
104static int __init random32_init(void) 153static int __init prandom_init(void)
105{ 154{
106 int i; 155 int i;
107 156
@@ -114,22 +163,22 @@ static int __init random32_init(void)
114 state->s3 = __seed(LCG(state->s2), 15); 163 state->s3 = __seed(LCG(state->s2), 15);
115 164
116 /* "warm it up" */ 165 /* "warm it up" */
117 prandom32(state); 166 prandom_u32_state(state);
118 prandom32(state); 167 prandom_u32_state(state);
119 prandom32(state); 168 prandom_u32_state(state);
120 prandom32(state); 169 prandom_u32_state(state);
121 prandom32(state); 170 prandom_u32_state(state);
122 prandom32(state); 171 prandom_u32_state(state);
123 } 172 }
124 return 0; 173 return 0;
125} 174}
126core_initcall(random32_init); 175core_initcall(prandom_init);
127 176
128/* 177/*
129 * Generate better values after random number generator 178 * Generate better values after random number generator
130 * is fully initialized. 179 * is fully initialized.
131 */ 180 */
132static int __init random32_reseed(void) 181static int __init prandom_reseed(void)
133{ 182{
134 int i; 183 int i;
135 184
@@ -143,8 +192,8 @@ static int __init random32_reseed(void)
143 state->s3 = __seed(seeds[2], 15); 192 state->s3 = __seed(seeds[2], 15);
144 193
145 /* mix it in */ 194 /* mix it in */
146 prandom32(state); 195 prandom_u32_state(state);
147 } 196 }
148 return 0; 197 return 0;
149} 198}
150late_initcall(random32_reseed); 199late_initcall(prandom_reseed);
diff --git a/lib/rbtree_test.c b/lib/rbtree_test.c
index 268b23951fec..af38aedbd874 100644
--- a/lib/rbtree_test.c
+++ b/lib/rbtree_test.c
@@ -96,8 +96,8 @@ static void init(void)
96{ 96{
97 int i; 97 int i;
98 for (i = 0; i < NODES; i++) { 98 for (i = 0; i < NODES; i++) {
99 nodes[i].key = prandom32(&rnd); 99 nodes[i].key = prandom_u32_state(&rnd);
100 nodes[i].val = prandom32(&rnd); 100 nodes[i].val = prandom_u32_state(&rnd);
101 } 101 }
102} 102}
103 103
@@ -118,7 +118,7 @@ static void check(int nr_nodes)
118{ 118{
119 struct rb_node *rb; 119 struct rb_node *rb;
120 int count = 0; 120 int count = 0;
121 int blacks; 121 int blacks = 0;
122 u32 prev_key = 0; 122 u32 prev_key = 0;
123 123
124 for (rb = rb_first(&root); rb; rb = rb_next(rb)) { 124 for (rb = rb_first(&root); rb; rb = rb_next(rb)) {
@@ -155,7 +155,7 @@ static int rbtree_test_init(void)
155 155
156 printk(KERN_ALERT "rbtree testing"); 156 printk(KERN_ALERT "rbtree testing");
157 157
158 prandom32_seed(&rnd, 3141592653589793238ULL); 158 prandom_seed_state(&rnd, 3141592653589793238ULL);
159 init(); 159 init();
160 160
161 time1 = get_cycles(); 161 time1 = get_cycles();
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index 3675452b23ca..7874b01e816e 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -248,7 +248,8 @@ int __sg_alloc_table(struct sg_table *table, unsigned int nents,
248 unsigned int left; 248 unsigned int left;
249 249
250#ifndef ARCH_HAS_SG_CHAIN 250#ifndef ARCH_HAS_SG_CHAIN
251 BUG_ON(nents > max_ents); 251 if (WARN_ON_ONCE(nents > max_ents))
252 return -EINVAL;
252#endif 253#endif
253 254
254 memset(table, 0, sizeof(*table)); 255 memset(table, 0, sizeof(*table));
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 39c99fea7c03..fab33a9c5318 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -23,12 +23,12 @@
23#include <linux/ctype.h> 23#include <linux/ctype.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/kallsyms.h> 25#include <linux/kallsyms.h>
26#include <linux/math64.h>
26#include <linux/uaccess.h> 27#include <linux/uaccess.h>
27#include <linux/ioport.h> 28#include <linux/ioport.h>
28#include <net/addrconf.h> 29#include <net/addrconf.h>
29 30
30#include <asm/page.h> /* for PAGE_SIZE */ 31#include <asm/page.h> /* for PAGE_SIZE */
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
34#include "kstrtox.h" 34#include "kstrtox.h"
@@ -38,6 +38,8 @@
38 * @cp: The start of the string 38 * @cp: The start of the string
39 * @endp: A pointer to the end of the parsed string will be placed here 39 * @endp: A pointer to the end of the parsed string will be placed here
40 * @base: The number base to use 40 * @base: The number base to use
41 *
42 * This function is obsolete. Please use kstrtoull instead.
41 */ 43 */
42unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base) 44unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base)
43{ 45{
@@ -61,6 +63,8 @@ EXPORT_SYMBOL(simple_strtoull);
61 * @cp: The start of the string 63 * @cp: The start of the string
62 * @endp: A pointer to the end of the parsed string will be placed here 64 * @endp: A pointer to the end of the parsed string will be placed here
63 * @base: The number base to use 65 * @base: The number base to use
66 *
67 * This function is obsolete. Please use kstrtoul instead.
64 */ 68 */
65unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base) 69unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base)
66{ 70{
@@ -73,6 +77,8 @@ EXPORT_SYMBOL(simple_strtoul);
73 * @cp: The start of the string 77 * @cp: The start of the string
74 * @endp: A pointer to the end of the parsed string will be placed here 78 * @endp: A pointer to the end of the parsed string will be placed here
75 * @base: The number base to use 79 * @base: The number base to use
80 *
81 * This function is obsolete. Please use kstrtol instead.
76 */ 82 */
77long simple_strtol(const char *cp, char **endp, unsigned int base) 83long simple_strtol(const char *cp, char **endp, unsigned int base)
78{ 84{
@@ -88,6 +94,8 @@ EXPORT_SYMBOL(simple_strtol);
88 * @cp: The start of the string 94 * @cp: The start of the string
89 * @endp: A pointer to the end of the parsed string will be placed here 95 * @endp: A pointer to the end of the parsed string will be placed here
90 * @base: The number base to use 96 * @base: The number base to use
97 *
98 * This function is obsolete. Please use kstrtoll instead.
91 */ 99 */
92long long simple_strtoll(const char *cp, char **endp, unsigned int base) 100long long simple_strtoll(const char *cp, char **endp, unsigned int base)
93{ 101{
@@ -1485,7 +1493,10 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
1485 num = va_arg(args, long); 1493 num = va_arg(args, long);
1486 break; 1494 break;
1487 case FORMAT_TYPE_SIZE_T: 1495 case FORMAT_TYPE_SIZE_T:
1488 num = va_arg(args, size_t); 1496 if (spec.flags & SIGN)
1497 num = va_arg(args, ssize_t);
1498 else
1499 num = va_arg(args, size_t);
1489 break; 1500 break;
1490 case FORMAT_TYPE_PTRDIFF: 1501 case FORMAT_TYPE_PTRDIFF:
1491 num = va_arg(args, ptrdiff_t); 1502 num = va_arg(args, ptrdiff_t);
@@ -2013,7 +2024,11 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
2013 char digit; 2024 char digit;
2014 int num = 0; 2025 int num = 0;
2015 u8 qualifier; 2026 u8 qualifier;
2016 u8 base; 2027 unsigned int base;
2028 union {
2029 long long s;
2030 unsigned long long u;
2031 } val;
2017 s16 field_width; 2032 s16 field_width;
2018 bool is_sign; 2033 bool is_sign;
2019 2034
@@ -2053,8 +2068,11 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
2053 2068
2054 /* get field width */ 2069 /* get field width */
2055 field_width = -1; 2070 field_width = -1;
2056 if (isdigit(*fmt)) 2071 if (isdigit(*fmt)) {
2057 field_width = skip_atoi(&fmt); 2072 field_width = skip_atoi(&fmt);
2073 if (field_width <= 0)
2074 break;
2075 }
2058 2076
2059 /* get conversion qualifier */ 2077 /* get conversion qualifier */
2060 qualifier = -1; 2078 qualifier = -1;
@@ -2154,58 +2172,61 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
2154 || (base == 0 && !isdigit(digit))) 2172 || (base == 0 && !isdigit(digit)))
2155 break; 2173 break;
2156 2174
2175 if (is_sign)
2176 val.s = qualifier != 'L' ?
2177 simple_strtol(str, &next, base) :
2178 simple_strtoll(str, &next, base);
2179 else
2180 val.u = qualifier != 'L' ?
2181 simple_strtoul(str, &next, base) :
2182 simple_strtoull(str, &next, base);
2183
2184 if (field_width > 0 && next - str > field_width) {
2185 if (base == 0)
2186 _parse_integer_fixup_radix(str, &base);
2187 while (next - str > field_width) {
2188 if (is_sign)
2189 val.s = div_s64(val.s, base);
2190 else
2191 val.u = div_u64(val.u, base);
2192 --next;
2193 }
2194 }
2195
2157 switch (qualifier) { 2196 switch (qualifier) {
2158 case 'H': /* that's 'hh' in format */ 2197 case 'H': /* that's 'hh' in format */
2159 if (is_sign) { 2198 if (is_sign)
2160 signed char *s = (signed char *)va_arg(args, signed char *); 2199 *va_arg(args, signed char *) = val.s;
2161 *s = (signed char)simple_strtol(str, &next, base); 2200 else
2162 } else { 2201 *va_arg(args, unsigned char *) = val.u;
2163 unsigned char *s = (unsigned char *)va_arg(args, unsigned char *);
2164 *s = (unsigned char)simple_strtoul(str, &next, base);
2165 }
2166 break; 2202 break;
2167 case 'h': 2203 case 'h':
2168 if (is_sign) { 2204 if (is_sign)
2169 short *s = (short *)va_arg(args, short *); 2205 *va_arg(args, short *) = val.s;
2170 *s = (short)simple_strtol(str, &next, base); 2206 else
2171 } else { 2207 *va_arg(args, unsigned short *) = val.u;
2172 unsigned short *s = (unsigned short *)va_arg(args, unsigned short *);
2173 *s = (unsigned short)simple_strtoul(str, &next, base);
2174 }
2175 break; 2208 break;
2176 case 'l': 2209 case 'l':
2177 if (is_sign) { 2210 if (is_sign)
2178 long *l = (long *)va_arg(args, long *); 2211 *va_arg(args, long *) = val.s;
2179 *l = simple_strtol(str, &next, base); 2212 else
2180 } else { 2213 *va_arg(args, unsigned long *) = val.u;
2181 unsigned long *l = (unsigned long *)va_arg(args, unsigned long *);
2182 *l = simple_strtoul(str, &next, base);
2183 }
2184 break; 2214 break;
2185 case 'L': 2215 case 'L':
2186 if (is_sign) { 2216 if (is_sign)
2187 long long *l = (long long *)va_arg(args, long long *); 2217 *va_arg(args, long long *) = val.s;
2188 *l = simple_strtoll(str, &next, base); 2218 else
2189 } else { 2219 *va_arg(args, unsigned long long *) = val.u;
2190 unsigned long long *l = (unsigned long long *)va_arg(args, unsigned long long *);
2191 *l = simple_strtoull(str, &next, base);
2192 }
2193 break; 2220 break;
2194 case 'Z': 2221 case 'Z':
2195 case 'z': 2222 case 'z':
2196 { 2223 *va_arg(args, size_t *) = val.u;
2197 size_t *s = (size_t *)va_arg(args, size_t *); 2224 break;
2198 *s = (size_t)simple_strtoul(str, &next, base);
2199 }
2200 break;
2201 default: 2225 default:
2202 if (is_sign) { 2226 if (is_sign)
2203 int *i = (int *)va_arg(args, int *); 2227 *va_arg(args, int *) = val.s;
2204 *i = (int)simple_strtol(str, &next, base); 2228 else
2205 } else { 2229 *va_arg(args, unsigned int *) = val.u;
2206 unsigned int *i = (unsigned int *)va_arg(args, unsigned int*);
2207 *i = (unsigned int)simple_strtoul(str, &next, base);
2208 }
2209 break; 2230 break;
2210 } 2231 }
2211 num++; 2232 num++;
diff --git a/mm/memory.c b/mm/memory.c
index e6a3b933517e..e0a9b0ce4f10 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -58,6 +58,7 @@
58#include <linux/elf.h> 58#include <linux/elf.h>
59#include <linux/gfp.h> 59#include <linux/gfp.h>
60#include <linux/migrate.h> 60#include <linux/migrate.h>
61#include <linux/string.h>
61 62
62#include <asm/io.h> 63#include <asm/io.h>
63#include <asm/pgalloc.h> 64#include <asm/pgalloc.h>
@@ -3590,6 +3591,7 @@ static int do_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
3590 unsigned long addr, pmd_t *pmdp) 3591 unsigned long addr, pmd_t *pmdp)
3591{ 3592{
3592 BUG(); 3593 BUG();
3594 return 0;
3593} 3595}
3594#endif /* CONFIG_NUMA_BALANCING */ 3596#endif /* CONFIG_NUMA_BALANCING */
3595 3597
@@ -4117,15 +4119,12 @@ void print_vma_addr(char *prefix, unsigned long ip)
4117 struct file *f = vma->vm_file; 4119 struct file *f = vma->vm_file;
4118 char *buf = (char *)__get_free_page(GFP_KERNEL); 4120 char *buf = (char *)__get_free_page(GFP_KERNEL);
4119 if (buf) { 4121 if (buf) {
4120 char *p, *s; 4122 char *p;
4121 4123
4122 p = d_path(&f->f_path, buf, PAGE_SIZE); 4124 p = d_path(&f->f_path, buf, PAGE_SIZE);
4123 if (IS_ERR(p)) 4125 if (IS_ERR(p))
4124 p = "?"; 4126 p = "?";
4125 s = strrchr(p, '/'); 4127 printk("%s%s[%lx+%lx]", prefix, kbasename(p),
4126 if (s)
4127 p = s+1;
4128 printk("%s%s[%lx+%lx]", prefix, p,
4129 vma->vm_start, 4128 vma->vm_start,
4130 vma->vm_end - vma->vm_start); 4129 vma->vm_end - vma->vm_start);
4131 free_page((unsigned long)buf); 4130 free_page((unsigned long)buf);
diff --git a/mm/shmem.c b/mm/shmem.c
index 03f9ba8fb8e5..5c90d84c2b02 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1719,7 +1719,7 @@ static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos,
1719 * llseek SEEK_DATA or SEEK_HOLE through the radix_tree. 1719 * llseek SEEK_DATA or SEEK_HOLE through the radix_tree.
1720 */ 1720 */
1721static pgoff_t shmem_seek_hole_data(struct address_space *mapping, 1721static pgoff_t shmem_seek_hole_data(struct address_space *mapping,
1722 pgoff_t index, pgoff_t end, int origin) 1722 pgoff_t index, pgoff_t end, int whence)
1723{ 1723{
1724 struct page *page; 1724 struct page *page;
1725 struct pagevec pvec; 1725 struct pagevec pvec;
@@ -1733,13 +1733,13 @@ static pgoff_t shmem_seek_hole_data(struct address_space *mapping,
1733 pvec.nr = shmem_find_get_pages_and_swap(mapping, index, 1733 pvec.nr = shmem_find_get_pages_and_swap(mapping, index,
1734 pvec.nr, pvec.pages, indices); 1734 pvec.nr, pvec.pages, indices);
1735 if (!pvec.nr) { 1735 if (!pvec.nr) {
1736 if (origin == SEEK_DATA) 1736 if (whence == SEEK_DATA)
1737 index = end; 1737 index = end;
1738 break; 1738 break;
1739 } 1739 }
1740 for (i = 0; i < pvec.nr; i++, index++) { 1740 for (i = 0; i < pvec.nr; i++, index++) {
1741 if (index < indices[i]) { 1741 if (index < indices[i]) {
1742 if (origin == SEEK_HOLE) { 1742 if (whence == SEEK_HOLE) {
1743 done = true; 1743 done = true;
1744 break; 1744 break;
1745 } 1745 }
@@ -1751,8 +1751,8 @@ static pgoff_t shmem_seek_hole_data(struct address_space *mapping,
1751 page = NULL; 1751 page = NULL;
1752 } 1752 }
1753 if (index >= end || 1753 if (index >= end ||
1754 (page && origin == SEEK_DATA) || 1754 (page && whence == SEEK_DATA) ||
1755 (!page && origin == SEEK_HOLE)) { 1755 (!page && whence == SEEK_HOLE)) {
1756 done = true; 1756 done = true;
1757 break; 1757 break;
1758 } 1758 }
@@ -1765,15 +1765,15 @@ static pgoff_t shmem_seek_hole_data(struct address_space *mapping,
1765 return index; 1765 return index;
1766} 1766}
1767 1767
1768static loff_t shmem_file_llseek(struct file *file, loff_t offset, int origin) 1768static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence)
1769{ 1769{
1770 struct address_space *mapping = file->f_mapping; 1770 struct address_space *mapping = file->f_mapping;
1771 struct inode *inode = mapping->host; 1771 struct inode *inode = mapping->host;
1772 pgoff_t start, end; 1772 pgoff_t start, end;
1773 loff_t new_offset; 1773 loff_t new_offset;
1774 1774
1775 if (origin != SEEK_DATA && origin != SEEK_HOLE) 1775 if (whence != SEEK_DATA && whence != SEEK_HOLE)
1776 return generic_file_llseek_size(file, offset, origin, 1776 return generic_file_llseek_size(file, offset, whence,
1777 MAX_LFS_FILESIZE, i_size_read(inode)); 1777 MAX_LFS_FILESIZE, i_size_read(inode));
1778 mutex_lock(&inode->i_mutex); 1778 mutex_lock(&inode->i_mutex);
1779 /* We're holding i_mutex so we can access i_size directly */ 1779 /* We're holding i_mutex so we can access i_size directly */
@@ -1785,12 +1785,12 @@ static loff_t shmem_file_llseek(struct file *file, loff_t offset, int origin)
1785 else { 1785 else {
1786 start = offset >> PAGE_CACHE_SHIFT; 1786 start = offset >> PAGE_CACHE_SHIFT;
1787 end = (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 1787 end = (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
1788 new_offset = shmem_seek_hole_data(mapping, start, end, origin); 1788 new_offset = shmem_seek_hole_data(mapping, start, end, whence);
1789 new_offset <<= PAGE_CACHE_SHIFT; 1789 new_offset <<= PAGE_CACHE_SHIFT;
1790 if (new_offset > offset) { 1790 if (new_offset > offset) {
1791 if (new_offset < inode->i_size) 1791 if (new_offset < inode->i_size)
1792 offset = new_offset; 1792 offset = new_offset;
1793 else if (origin == SEEK_DATA) 1793 else if (whence == SEEK_DATA)
1794 offset = -ENXIO; 1794 offset = -ENXIO;
1795 else 1795 else
1796 offset = inode->i_size; 1796 offset = inode->i_size;
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f18750e3bd6c..1d6e4c541370 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -33,6 +33,7 @@ my %ignore_type = ();
33my @ignore = (); 33my @ignore = ();
34my $help = 0; 34my $help = 0;
35my $configuration_file = ".checkpatch.conf"; 35my $configuration_file = ".checkpatch.conf";
36my $max_line_length = 80;
36 37
37sub help { 38sub help {
38 my ($exitcode) = @_; 39 my ($exitcode) = @_;
@@ -51,6 +52,7 @@ Options:
51 -f, --file treat FILE as regular source file 52 -f, --file treat FILE as regular source file
52 --subjective, --strict enable more subjective tests 53 --subjective, --strict enable more subjective tests
53 --ignore TYPE(,TYPE2...) ignore various comma separated message types 54 --ignore TYPE(,TYPE2...) ignore various comma separated message types
55 --max-line-length=n set the maximum line length, if exceeded, warn
54 --show-types show the message "types" in the output 56 --show-types show the message "types" in the output
55 --root=PATH PATH to the kernel tree root 57 --root=PATH PATH to the kernel tree root
56 --no-summary suppress the per-file summary 58 --no-summary suppress the per-file summary
@@ -107,6 +109,7 @@ GetOptions(
107 'strict!' => \$check, 109 'strict!' => \$check,
108 'ignore=s' => \@ignore, 110 'ignore=s' => \@ignore,
109 'show-types!' => \$show_types, 111 'show-types!' => \$show_types,
112 'max-line-length=i' => \$max_line_length,
110 'root=s' => \$root, 113 'root=s' => \$root,
111 'summary!' => \$summary, 114 'summary!' => \$summary,
112 'mailback!' => \$mailback, 115 'mailback!' => \$mailback,
@@ -227,7 +230,11 @@ our $Inline = qr{inline|__always_inline|noinline};
227our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]}; 230our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]};
228our $Lval = qr{$Ident(?:$Member)*}; 231our $Lval = qr{$Ident(?:$Member)*};
229 232
230our $Constant = qr{(?i:(?:[0-9]+|0x[0-9a-f]+)[ul]*)}; 233our $Float_hex = qr{(?i:0x[0-9a-f]+p-?[0-9]+[fl]?)};
234our $Float_dec = qr{(?i:((?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?))};
235our $Float_int = qr{(?i:[0-9]+e-?[0-9]+[fl]?)};
236our $Float = qr{$Float_hex|$Float_dec|$Float_int};
237our $Constant = qr{(?:$Float|(?i:(?:0x[0-9a-f]+|[0-9]+)[ul]*))};
231our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)}; 238our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)};
232our $Compare = qr{<=|>=|==|!=|<|>}; 239our $Compare = qr{<=|>=|==|!=|<|>};
233our $Operators = qr{ 240our $Operators = qr{
@@ -352,27 +359,6 @@ sub deparenthesize {
352 359
353$chk_signoff = 0 if ($file); 360$chk_signoff = 0 if ($file);
354 361
355my @dep_includes = ();
356my @dep_functions = ();
357my $removal = "Documentation/feature-removal-schedule.txt";
358if ($tree && -f "$root/$removal") {
359 open(my $REMOVE, '<', "$root/$removal") ||
360 die "$P: $removal: open failed - $!\n";
361 while (<$REMOVE>) {
362 if (/^Check:\s+(.*\S)/) {
363 for my $entry (split(/[, ]+/, $1)) {
364 if ($entry =~ m@include/(.*)@) {
365 push(@dep_includes, $1);
366
367 } elsif ($entry !~ m@/@) {
368 push(@dep_functions, $entry);
369 }
370 }
371 }
372 }
373 close($REMOVE);
374}
375
376my @rawlines = (); 362my @rawlines = ();
377my @lines = (); 363my @lines = ();
378my $vname; 364my $vname;
@@ -1412,6 +1398,8 @@ sub process {
1412 my %suppress_export; 1398 my %suppress_export;
1413 my $suppress_statement = 0; 1399 my $suppress_statement = 0;
1414 1400
1401 my %camelcase = ();
1402
1415 # Pre-scan the patch sanitizing the lines. 1403 # Pre-scan the patch sanitizing the lines.
1416 # Pre-scan the patch looking for any __setup documentation. 1404 # Pre-scan the patch looking for any __setup documentation.
1417 # 1405 #
@@ -1757,6 +1745,13 @@ sub process {
1757 #print "is_start<$is_start> is_end<$is_end> length<$length>\n"; 1745 #print "is_start<$is_start> is_end<$is_end> length<$length>\n";
1758 } 1746 }
1759 1747
1748# discourage the addition of CONFIG_EXPERIMENTAL in Kconfig.
1749 if ($realfile =~ /Kconfig/ &&
1750 $line =~ /.\s*depends on\s+.*\bEXPERIMENTAL\b/) {
1751 WARN("CONFIG_EXPERIMENTAL",
1752 "Use of CONFIG_EXPERIMENTAL is deprecated. For alternatives, see https://lkml.org/lkml/2012/10/23/580\n");
1753 }
1754
1760 if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) && 1755 if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) &&
1761 ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) { 1756 ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
1762 my $flag = $1; 1757 my $flag = $1;
@@ -1774,15 +1769,15 @@ sub process {
1774# check we are in a valid source file if not then ignore this hunk 1769# check we are in a valid source file if not then ignore this hunk
1775 next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/); 1770 next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
1776 1771
1777#80 column limit 1772#line length limit
1778 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && 1773 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
1779 $rawline !~ /^.\s*\*\s*\@$Ident\s/ && 1774 $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
1780 !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ || 1775 !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ ||
1781 $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && 1776 $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
1782 $length > 80) 1777 $length > $max_line_length)
1783 { 1778 {
1784 WARN("LONG_LINE", 1779 WARN("LONG_LINE",
1785 "line over 80 characters\n" . $herecurr); 1780 "line over $max_line_length characters\n" . $herecurr);
1786 } 1781 }
1787 1782
1788# Check for user-visible strings broken across lines, which breaks the ability 1783# Check for user-visible strings broken across lines, which breaks the ability
@@ -1912,6 +1907,12 @@ sub process {
1912# check we are in a valid C source file if not then ignore this hunk 1907# check we are in a valid C source file if not then ignore this hunk
1913 next if ($realfile !~ /\.(h|c)$/); 1908 next if ($realfile !~ /\.(h|c)$/);
1914 1909
1910# discourage the addition of CONFIG_EXPERIMENTAL in #if(def).
1911 if ($line =~ /^\+\s*\#\s*if.*\bCONFIG_EXPERIMENTAL\b/) {
1912 WARN("CONFIG_EXPERIMENTAL",
1913 "Use of CONFIG_EXPERIMENTAL is deprecated. For alternatives, see https://lkml.org/lkml/2012/10/23/580\n");
1914 }
1915
1915# check for RCS/CVS revision markers 1916# check for RCS/CVS revision markers
1916 if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) { 1917 if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) {
1917 WARN("CVS_KEYWORD", 1918 WARN("CVS_KEYWORD",
@@ -2906,12 +2907,17 @@ sub process {
2906 } 2907 }
2907 } 2908 }
2908 2909
2909#studly caps, commented out until figure out how to distinguish between use of existing and adding new 2910#CamelCase
2910# if (($line=~/[\w_][a-z\d]+[A-Z]/) and !($line=~/print/)) { 2911 while ($line =~ m{($Constant|$Lval)}g) {
2911# print "No studly caps, use _\n"; 2912 my $var = $1;
2912# print "$herecurr"; 2913 if ($var !~ /$Constant/ &&
2913# $clean = 0; 2914 $var =~ /[A-Z]\w*[a-z]|[a-z]\w*[A-Z]/ &&
2914# } 2915 !defined $camelcase{$var}) {
2916 $camelcase{$var} = 1;
2917 WARN("CAMELCASE",
2918 "Avoid CamelCase: <$var>\n" . $herecurr);
2919 }
2920 }
2915 2921
2916#no spaces allowed after \ in define 2922#no spaces allowed after \ in define
2917 if ($line=~/\#\s*define.*\\\s$/) { 2923 if ($line=~/\#\s*define.*\\\s$/) {
@@ -3013,6 +3019,17 @@ sub process {
3013 "Macros with complex values should be enclosed in parenthesis\n" . "$herectx"); 3019 "Macros with complex values should be enclosed in parenthesis\n" . "$herectx");
3014 } 3020 }
3015 } 3021 }
3022
3023# check for line continuations outside of #defines, preprocessor #, and asm
3024
3025 } else {
3026 if ($prevline !~ /^..*\\$/ &&
3027 $line !~ /^\+\s*\#.*\\$/ && # preprocessor
3028 $line !~ /^\+.*\b(__asm__|asm)\b.*\\$/ && # asm
3029 $line =~ /^\+.*\\$/) {
3030 WARN("LINE_CONTINUATIONS",
3031 "Avoid unnecessary line continuations\n" . $herecurr);
3032 }
3016 } 3033 }
3017 3034
3018# do {} while (0) macro tests: 3035# do {} while (0) macro tests:
@@ -3183,20 +3200,14 @@ sub process {
3183 } 3200 }
3184 } 3201 }
3185 3202
3186# don't include deprecated include files (uses RAW line) 3203# check for unnecessary blank lines around braces
3187 for my $inc (@dep_includes) { 3204 if (($line =~ /^..*}\s*$/ && $prevline =~ /^.\s*$/)) {
3188 if ($rawline =~ m@^.\s*\#\s*include\s*\<$inc>@) { 3205 CHK("BRACES",
3189 ERROR("DEPRECATED_INCLUDE", 3206 "Blank lines aren't necessary before a close brace '}'\n" . $hereprev);
3190 "Don't use <$inc>: see Documentation/feature-removal-schedule.txt\n" . $herecurr);
3191 }
3192 } 3207 }
3193 3208 if (($line =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) {
3194# don't use deprecated functions 3209 CHK("BRACES",
3195 for my $func (@dep_functions) { 3210 "Blank lines aren't necessary after an open brace '{'\n" . $hereprev);
3196 if ($line =~ /\b$func\b/) {
3197 ERROR("DEPRECATED_FUNCTION",
3198 "Don't use $func(): see Documentation/feature-removal-schedule.txt\n" . $herecurr);
3199 }
3200 } 3211 }
3201 3212
3202# no volatiles please 3213# no volatiles please
@@ -3213,20 +3224,12 @@ sub process {
3213 $herecurr); 3224 $herecurr);
3214 } 3225 }
3215 3226
3216# check for needless kfree() checks 3227# check for needless "if (<foo>) fn(<foo>)" uses
3217 if ($prevline =~ /\bif\s*\(([^\)]*)\)/) { 3228 if ($prevline =~ /\bif\s*\(\s*($Lval)\s*\)/) {
3218 my $expr = $1; 3229 my $expr = '\s*\(\s*' . quotemeta($1) . '\s*\)\s*;';
3219 if ($line =~ /\bkfree\(\Q$expr\E\);/) { 3230 if ($line =~ /\b(kfree|usb_free_urb|debugfs_remove(?:_recursive)?)$expr/) {
3220 WARN("NEEDLESS_KFREE", 3231 WARN('NEEDLESS_IF',
3221 "kfree(NULL) is safe this check is probably not required\n" . $hereprev); 3232 "$1(NULL) is safe this check is probably not required\n" . $hereprev);
3222 }
3223 }
3224# check for needless usb_free_urb() checks
3225 if ($prevline =~ /\bif\s*\(([^\)]*)\)/) {
3226 my $expr = $1;
3227 if ($line =~ /\busb_free_urb\(\Q$expr\E\);/) {
3228 WARN("NEEDLESS_USB_FREE_URB",
3229 "usb_free_urb(NULL) is safe this check is probably not required\n" . $hereprev);
3230 } 3233 }
3231 } 3234 }
3232 3235
@@ -3344,6 +3347,12 @@ sub process {
3344 "Avoid line continuations in quoted strings\n" . $herecurr); 3347 "Avoid line continuations in quoted strings\n" . $herecurr);
3345 } 3348 }
3346 3349
3350# check for struct spinlock declarations
3351 if ($line =~ /^.\s*\bstruct\s+spinlock\s+\w+\s*;/) {
3352 WARN("USE_SPINLOCK_T",
3353 "struct spinlock should be spinlock_t\n" . $herecurr);
3354 }
3355
3347# Check for misused memsets 3356# Check for misused memsets
3348 if ($^V && $^V ge 5.10.0 && 3357 if ($^V && $^V ge 5.10.0 &&
3349 defined $stat && 3358 defined $stat &&
@@ -3450,8 +3459,22 @@ sub process {
3450 3459
3451# check for multiple semicolons 3460# check for multiple semicolons
3452 if ($line =~ /;\s*;\s*$/) { 3461 if ($line =~ /;\s*;\s*$/) {
3453 WARN("ONE_SEMICOLON", 3462 WARN("ONE_SEMICOLON",
3454 "Statements terminations use 1 semicolon\n" . $herecurr); 3463 "Statements terminations use 1 semicolon\n" . $herecurr);
3464 }
3465
3466# check for switch/default statements without a break;
3467 if ($^V && $^V ge 5.10.0 &&
3468 defined $stat &&
3469 $stat =~ /^\+[$;\s]*(?:case[$;\s]+\w+[$;\s]*:[$;\s]*|)*[$;\s]*\bdefault[$;\s]*:[$;\s]*;/g) {
3470 my $ctx = '';
3471 my $herectx = $here . "\n";
3472 my $cnt = statement_rawlines($stat);
3473 for (my $n = 0; $n < $cnt; $n++) {
3474 $herectx .= raw_line($linenr, $n) . "\n";
3475 }
3476 WARN("DEFAULT_NO_BREAK",
3477 "switch default: should use break\n" . $herectx);
3455 } 3478 }
3456 3479
3457# check for gcc specific __FUNCTION__ 3480# check for gcc specific __FUNCTION__
diff --git a/sound/Kconfig b/sound/Kconfig
index 261a03c8a209..c710ce2c5c37 100644
--- a/sound/Kconfig
+++ b/sound/Kconfig
@@ -52,9 +52,6 @@ config SOUND_OSS_CORE_PRECLAIM
52 52
53 Disabling this allows alternative OSS implementations. 53 Disabling this allows alternative OSS implementations.
54 54
55 Please read Documentation/feature-removal-schedule.txt for
56 details.
57
58 If unsure, say Y. 55 If unsure, say Y.
59 56
60source "sound/oss/dmasound/Kconfig" 57source "sound/oss/dmasound/Kconfig"
diff --git a/sound/sound_core.c b/sound/sound_core.c
index fb9255cca214..bb23009edc8d 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -146,8 +146,7 @@ extern int msnd_pinnacle_init(void);
146 * devices only the standard chrdev aliases are requested. 146 * devices only the standard chrdev aliases are requested.
147 * 147 *
148 * All these clutters are scheduled to be removed along with 148 * All these clutters are scheduled to be removed along with
149 * sound-slot/service-* module aliases. Please take a look at 149 * sound-slot/service-* module aliases.
150 * feature-removal-schedule.txt for details.
151 */ 150 */
152#ifdef CONFIG_SOUND_OSS_CORE_PRECLAIM 151#ifdef CONFIG_SOUND_OSS_CORE_PRECLAIM
153static int preclaim_oss = 1; 152static int preclaim_oss = 1;
diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile
index 931278035f5c..e18b42b254af 100644
--- a/tools/testing/selftests/breakpoints/Makefile
+++ b/tools/testing/selftests/breakpoints/Makefile
@@ -17,7 +17,7 @@ else
17endif 17endif
18 18
19run_tests: 19run_tests:
20 ./breakpoint_test 20 @./breakpoint_test || echo "breakpoints selftests: [FAIL]"
21 21
22clean: 22clean:
23 rm -fr breakpoint_test 23 rm -fr breakpoint_test
diff --git a/tools/testing/selftests/cpu-hotplug/Makefile b/tools/testing/selftests/cpu-hotplug/Makefile
index 7c9c20ff578a..12657a5e4bf9 100644
--- a/tools/testing/selftests/cpu-hotplug/Makefile
+++ b/tools/testing/selftests/cpu-hotplug/Makefile
@@ -1,6 +1,6 @@
1all: 1all:
2 2
3run_tests: 3run_tests:
4 ./on-off-test.sh 4 @./on-off-test.sh || echo "cpu-hotplug selftests: [FAIL]"
5 5
6clean: 6clean:
diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
index dc79b86ea65c..56eb5523dbb8 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -16,13 +16,13 @@ CFLAGS += -I../../../../arch/x86/include/
16 16
17all: 17all:
18ifeq ($(ARCH),X86) 18ifeq ($(ARCH),X86)
19 gcc $(CFLAGS) kcmp_test.c -o run_test 19 gcc $(CFLAGS) kcmp_test.c -o kcmp_test
20else 20else
21 echo "Not an x86 target, can't build kcmp selftest" 21 echo "Not an x86 target, can't build kcmp selftest"
22endif 22endif
23 23
24run-tests: all 24run_tests: all
25 ./kcmp_test 25 @./kcmp_test || echo "kcmp_test: [FAIL]"
26 26
27clean: 27clean:
28 rm -fr ./run_test 28 rm -fr ./run_test
diff --git a/tools/testing/selftests/kcmp/kcmp_test.c b/tools/testing/selftests/kcmp/kcmp_test.c
index 358cc6bfa35d..fa4f1b37e045 100644
--- a/tools/testing/selftests/kcmp/kcmp_test.c
+++ b/tools/testing/selftests/kcmp/kcmp_test.c
@@ -72,7 +72,8 @@ int main(int argc, char **argv)
72 /* This one should return same fd */ 72 /* This one should return same fd */
73 ret = sys_kcmp(pid1, pid2, KCMP_FILE, fd1, fd1); 73 ret = sys_kcmp(pid1, pid2, KCMP_FILE, fd1, fd1);
74 if (ret) { 74 if (ret) {
75 printf("FAIL: 0 expected but %d returned\n", ret); 75 printf("FAIL: 0 expected but %d returned (%s)\n",
76 ret, strerror(errno));
76 ret = -1; 77 ret = -1;
77 } else 78 } else
78 printf("PASS: 0 returned as expected\n"); 79 printf("PASS: 0 returned as expected\n");
@@ -80,7 +81,8 @@ int main(int argc, char **argv)
80 /* Compare with self */ 81 /* Compare with self */
81 ret = sys_kcmp(pid1, pid1, KCMP_VM, 0, 0); 82 ret = sys_kcmp(pid1, pid1, KCMP_VM, 0, 0);
82 if (ret) { 83 if (ret) {
83 printf("FAIL: 0 expected but %li returned\n", ret); 84 printf("FAIL: 0 expected but %li returned (%s)\n",
85 ret, strerror(errno));
84 ret = -1; 86 ret = -1;
85 } else 87 } else
86 printf("PASS: 0 returned as expected\n"); 88 printf("PASS: 0 returned as expected\n");
diff --git a/tools/testing/selftests/memory-hotplug/Makefile b/tools/testing/selftests/memory-hotplug/Makefile
index 7c9c20ff578a..0f49c3f5f58d 100644
--- a/tools/testing/selftests/memory-hotplug/Makefile
+++ b/tools/testing/selftests/memory-hotplug/Makefile
@@ -1,6 +1,6 @@
1all: 1all:
2 2
3run_tests: 3run_tests:
4 ./on-off-test.sh 4 @./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]"
5 5
6clean: 6clean:
diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/selftests/mqueue/Makefile
index 54c0aad2b47c..218a122c7951 100644
--- a/tools/testing/selftests/mqueue/Makefile
+++ b/tools/testing/selftests/mqueue/Makefile
@@ -3,8 +3,8 @@ all:
3 gcc -O2 -lrt -lpthread -lpopt -o mq_perf_tests mq_perf_tests.c 3 gcc -O2 -lrt -lpthread -lpopt -o mq_perf_tests mq_perf_tests.c
4 4
5run_tests: 5run_tests:
6 ./mq_open_tests /test1 6 @./mq_open_tests /test1 || echo "mq_open_tests: [FAIL]"
7 ./mq_perf_tests 7 @./mq_perf_tests || echo "mq_perf_tests: [FAIL]"
8 8
9clean: 9clean:
10 rm -f mq_open_tests mq_perf_tests 10 rm -f mq_open_tests mq_perf_tests
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index 7300d0702efe..436d2e81868b 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -8,7 +8,7 @@ all: hugepage-mmap hugepage-shm map_hugetlb thuge-gen
8 $(CC) $(CFLAGS) -o $@ $^ 8 $(CC) $(CFLAGS) -o $@ $^
9 9
10run_tests: all 10run_tests: all
11 /bin/sh ./run_vmtests 11 @/bin/sh ./run_vmtests || echo "vmtests: [FAIL]"
12 12
13clean: 13clean:
14 $(RM) hugepage-mmap hugepage-shm map_hugetlb 14 $(RM) hugepage-mmap hugepage-shm map_hugetlb