diff options
185 files changed, 2662 insertions, 1042 deletions
diff --git a/Documentation/fault-injection/fault-injection.txt b/Documentation/fault-injection/fault-injection.txt index ba4be8b77093..4cf1a2a6bd72 100644 --- a/Documentation/fault-injection/fault-injection.txt +++ b/Documentation/fault-injection/fault-injection.txt | |||
| @@ -240,3 +240,30 @@ trap "echo 0 > /sys/kernel/debug/$FAILTYPE/probability" SIGINT SIGTERM EXIT | |||
| 240 | echo "Injecting errors into the module $module... (interrupt to stop)" | 240 | echo "Injecting errors into the module $module... (interrupt to stop)" |
| 241 | sleep 1000000 | 241 | sleep 1000000 |
| 242 | 242 | ||
| 243 | Tool to run command with failslab or fail_page_alloc | ||
| 244 | ---------------------------------------------------- | ||
| 245 | In order to make it easier to accomplish the tasks mentioned above, we can use | ||
| 246 | tools/testing/fault-injection/failcmd.sh. Please run a command | ||
| 247 | "./tools/testing/fault-injection/failcmd.sh --help" for more information and | ||
| 248 | see the following examples. | ||
| 249 | |||
| 250 | Examples: | ||
| 251 | |||
| 252 | Run a command "make -C tools/testing/selftests/ run_tests" with injecting slab | ||
| 253 | allocation failure. | ||
| 254 | |||
| 255 | # ./tools/testing/fault-injection/failcmd.sh \ | ||
| 256 | -- make -C tools/testing/selftests/ run_tests | ||
| 257 | |||
| 258 | Same as above except to specify 100 times failures at most instead of one time | ||
| 259 | at most by default. | ||
| 260 | |||
| 261 | # ./tools/testing/fault-injection/failcmd.sh --times=100 \ | ||
| 262 | -- make -C tools/testing/selftests/ run_tests | ||
| 263 | |||
| 264 | Same as above except to inject page allocation failure instead of slab | ||
| 265 | allocation failure. | ||
| 266 | |||
| 267 | # env FAILCMD_TYPE=fail_page_alloc \ | ||
| 268 | ./tools/testing/fault-injection/failcmd.sh --times=100 \ | ||
| 269 | -- make -C tools/testing/selftests/ run_tests | ||
diff --git a/Documentation/fault-injection/notifier-error-inject.txt b/Documentation/fault-injection/notifier-error-inject.txt new file mode 100644 index 000000000000..c83526c364e5 --- /dev/null +++ b/Documentation/fault-injection/notifier-error-inject.txt | |||
| @@ -0,0 +1,99 @@ | |||
| 1 | Notifier error injection | ||
| 2 | ======================== | ||
| 3 | |||
| 4 | Notifier error injection provides the ability to inject artifical errors to | ||
| 5 | specified notifier chain callbacks. It is useful to test the error handling of | ||
| 6 | notifier call chain failures which is rarely executed. There are kernel | ||
| 7 | modules that can be used to test the following notifiers. | ||
| 8 | |||
| 9 | * CPU notifier | ||
| 10 | * PM notifier | ||
| 11 | * Memory hotplug notifier | ||
| 12 | * powerpc pSeries reconfig notifier | ||
| 13 | |||
| 14 | CPU notifier error injection module | ||
| 15 | ----------------------------------- | ||
| 16 | This feature can be used to test the error handling of the CPU notifiers by | ||
| 17 | injecting artifical errors to CPU notifier chain callbacks. | ||
| 18 | |||
| 19 | If the notifier call chain should be failed with some events notified, write | ||
| 20 | the error code to debugfs interface | ||
| 21 | /sys/kernel/debug/notifier-error-inject/cpu/actions/<notifier event>/error | ||
| 22 | |||
| 23 | Possible CPU notifier events to be failed are: | ||
| 24 | |||
| 25 | * CPU_UP_PREPARE | ||
| 26 | * CPU_UP_PREPARE_FROZEN | ||
| 27 | * CPU_DOWN_PREPARE | ||
| 28 | * CPU_DOWN_PREPARE_FROZEN | ||
| 29 | |||
| 30 | Example1: Inject CPU offline error (-1 == -EPERM) | ||
| 31 | |||
| 32 | # cd /sys/kernel/debug/notifier-error-inject/cpu | ||
| 33 | # echo -1 > actions/CPU_DOWN_PREPARE/error | ||
| 34 | # echo 0 > /sys/devices/system/cpu/cpu1/online | ||
| 35 | bash: echo: write error: Operation not permitted | ||
| 36 | |||
| 37 | Example2: inject CPU online error (-2 == -ENOENT) | ||
| 38 | |||
| 39 | # echo -2 > actions/CPU_UP_PREPARE/error | ||
| 40 | # echo 1 > /sys/devices/system/cpu/cpu1/online | ||
| 41 | bash: echo: write error: No such file or directory | ||
| 42 | |||
| 43 | PM notifier error injection module | ||
| 44 | ---------------------------------- | ||
| 45 | This feature is controlled through debugfs interface | ||
| 46 | /sys/kernel/debug/notifier-error-inject/pm/actions/<notifier event>/error | ||
| 47 | |||
| 48 | Possible PM notifier events to be failed are: | ||
| 49 | |||
| 50 | * PM_HIBERNATION_PREPARE | ||
| 51 | * PM_SUSPEND_PREPARE | ||
| 52 | * PM_RESTORE_PREPARE | ||
| 53 | |||
| 54 | Example: Inject PM suspend error (-12 = -ENOMEM) | ||
| 55 | |||
| 56 | # cd /sys/kernel/debug/notifier-error-inject/pm/ | ||
| 57 | # echo -12 > actions/PM_SUSPEND_PREPARE/error | ||
| 58 | # echo mem > /sys/power/state | ||
| 59 | bash: echo: write error: Cannot allocate memory | ||
| 60 | |||
| 61 | Memory hotplug notifier error injection module | ||
| 62 | ---------------------------------------------- | ||
| 63 | This feature is controlled through debugfs interface | ||
| 64 | /sys/kernel/debug/notifier-error-inject/memory/actions/<notifier event>/error | ||
| 65 | |||
| 66 | Possible memory notifier events to be failed are: | ||
| 67 | |||
| 68 | * MEM_GOING_ONLINE | ||
| 69 | * MEM_GOING_OFFLINE | ||
| 70 | |||
| 71 | Example: Inject memory hotplug offline error (-12 == -ENOMEM) | ||
| 72 | |||
| 73 | # cd /sys/kernel/debug/notifier-error-inject/memory | ||
| 74 | # echo -12 > actions/MEM_GOING_OFFLINE/error | ||
| 75 | # echo offline > /sys/devices/system/memory/memoryXXX/state | ||
| 76 | bash: echo: write error: Cannot allocate memory | ||
| 77 | |||
| 78 | powerpc pSeries reconfig notifier error injection module | ||
| 79 | -------------------------------------------------------- | ||
| 80 | This feature is controlled through debugfs interface | ||
| 81 | /sys/kernel/debug/notifier-error-inject/pSeries-reconfig/actions/<notifier event>/error | ||
| 82 | |||
| 83 | Possible pSeries reconfig notifier events to be failed are: | ||
| 84 | |||
| 85 | * PSERIES_RECONFIG_ADD | ||
| 86 | * PSERIES_RECONFIG_REMOVE | ||
| 87 | * PSERIES_DRCONF_MEM_ADD | ||
| 88 | * PSERIES_DRCONF_MEM_REMOVE | ||
| 89 | |||
| 90 | For more usage examples | ||
| 91 | ----------------------- | ||
| 92 | There are tools/testing/selftests using the notifier error injection features | ||
| 93 | for CPU and memory notifiers. | ||
| 94 | |||
| 95 | * tools/testing/selftests/cpu-hotplug/on-off-test.sh | ||
| 96 | * tools/testing/selftests/memory-hotplug/on-off-test.sh | ||
| 97 | |||
| 98 | These scripts first do simple online and offline tests and then do fault | ||
| 99 | injection tests if notifier error injection module is available. | ||
diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt index 5df176ed59b8..7561d7ed8e11 100644 --- a/Documentation/printk-formats.txt +++ b/Documentation/printk-formats.txt | |||
| @@ -53,9 +53,20 @@ Struct Resources: | |||
| 53 | For printing struct resources. The 'R' and 'r' specifiers result in a | 53 | For printing struct resources. The 'R' and 'r' specifiers result in a |
| 54 | printed resource with ('R') or without ('r') a decoded flags member. | 54 | printed resource with ('R') or without ('r') a decoded flags member. |
| 55 | 55 | ||
| 56 | Raw buffer as a hex string: | ||
| 57 | %*ph 00 01 02 ... 3f | ||
| 58 | %*phC 00:01:02: ... :3f | ||
| 59 | %*phD 00-01-02- ... -3f | ||
| 60 | %*phN 000102 ... 3f | ||
| 61 | |||
| 62 | For printing a small buffers (up to 64 bytes long) as a hex string with | ||
| 63 | certain separator. For the larger buffers consider to use | ||
| 64 | print_hex_dump(). | ||
| 65 | |||
| 56 | MAC/FDDI addresses: | 66 | MAC/FDDI addresses: |
| 57 | 67 | ||
| 58 | %pM 00:01:02:03:04:05 | 68 | %pM 00:01:02:03:04:05 |
| 69 | %pMR 05:04:03:02:01:00 | ||
| 59 | %pMF 00-01-02-03-04-05 | 70 | %pMF 00-01-02-03-04-05 |
| 60 | %pm 000102030405 | 71 | %pm 000102030405 |
| 61 | 72 | ||
| @@ -67,6 +78,10 @@ MAC/FDDI addresses: | |||
| 67 | the 'M' specifier to use dash ('-') separators instead of the default | 78 | the 'M' specifier to use dash ('-') separators instead of the default |
| 68 | separator. | 79 | separator. |
| 69 | 80 | ||
| 81 | For Bluetooth addresses the 'R' specifier shall be used after the 'M' | ||
| 82 | specifier to use reversed byte order suitable for visual interpretation | ||
| 83 | of Bluetooth addresses which are in the little endian order. | ||
| 84 | |||
| 70 | IPv4 addresses: | 85 | IPv4 addresses: |
| 71 | 86 | ||
| 72 | %pI4 1.2.3.4 | 87 | %pI4 1.2.3.4 |
diff --git a/Documentation/sysctl/fs.txt b/Documentation/sysctl/fs.txt index 13d6166d7a27..8c235b6e4246 100644 --- a/Documentation/sysctl/fs.txt +++ b/Documentation/sysctl/fs.txt | |||
| @@ -163,16 +163,22 @@ This value can be used to query and set the core dump mode for setuid | |||
| 163 | or otherwise protected/tainted binaries. The modes are | 163 | or otherwise protected/tainted binaries. The modes are |
| 164 | 164 | ||
| 165 | 0 - (default) - traditional behaviour. Any process which has changed | 165 | 0 - (default) - traditional behaviour. Any process which has changed |
| 166 | privilege levels or is execute only will not be dumped | 166 | privilege levels or is execute only will not be dumped. |
| 167 | 1 - (debug) - all processes dump core when possible. The core dump is | 167 | 1 - (debug) - all processes dump core when possible. The core dump is |
| 168 | owned by the current user and no security is applied. This is | 168 | owned by the current user and no security is applied. This is |
| 169 | intended for system debugging situations only. Ptrace is unchecked. | 169 | intended for system debugging situations only. Ptrace is unchecked. |
| 170 | This is insecure as it allows regular users to examine the memory | ||
| 171 | contents of privileged processes. | ||
| 170 | 2 - (suidsafe) - any binary which normally would not be dumped is dumped | 172 | 2 - (suidsafe) - any binary which normally would not be dumped is dumped |
| 171 | readable by root only. This allows the end user to remove | 173 | anyway, but only if the "core_pattern" kernel sysctl is set to |
| 172 | such a dump but not access it directly. For security reasons | 174 | either a pipe handler or a fully qualified path. (For more details |
| 173 | core dumps in this mode will not overwrite one another or | 175 | on this limitation, see CVE-2006-2451.) This mode is appropriate |
| 174 | other files. This mode is appropriate when administrators are | 176 | when administrators are attempting to debug problems in a normal |
| 175 | attempting to debug problems in a normal environment. | 177 | environment, and either have a core dump pipe handler that knows |
| 178 | to treat privileged core dumps with care, or specific directory | ||
| 179 | defined for catching core dumps. If a core dump happens without | ||
| 180 | a pipe handler or fully qualifid path, a message will be emitted | ||
| 181 | to syslog warning about the lack of a correct setting. | ||
| 176 | 182 | ||
| 177 | ============================================================== | 183 | ============================================================== |
| 178 | 184 | ||
diff --git a/MAINTAINERS b/MAINTAINERS index 19f705073942..b2e3d88ff4cd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -2750,6 +2750,7 @@ M: Jingoo Han <jg1.han@samsung.com> | |||
| 2750 | L: linux-fbdev@vger.kernel.org | 2750 | L: linux-fbdev@vger.kernel.org |
| 2751 | S: Maintained | 2751 | S: Maintained |
| 2752 | F: drivers/video/exynos/exynos_dp* | 2752 | F: drivers/video/exynos/exynos_dp* |
| 2753 | F: include/video/exynos_dp* | ||
| 2753 | 2754 | ||
| 2754 | EXYNOS MIPI DISPLAY DRIVERS | 2755 | EXYNOS MIPI DISPLAY DRIVERS |
| 2755 | M: Inki Dae <inki.dae@samsung.com> | 2756 | M: Inki Dae <inki.dae@samsung.com> |
diff --git a/arch/Kconfig b/arch/Kconfig index 8c3d957fa8e2..72f2fa189cc5 100644 --- a/arch/Kconfig +++ b/arch/Kconfig | |||
| @@ -248,7 +248,14 @@ config HAVE_CMPXCHG_LOCAL | |||
| 248 | config HAVE_CMPXCHG_DOUBLE | 248 | config HAVE_CMPXCHG_DOUBLE |
| 249 | bool | 249 | bool |
| 250 | 250 | ||
| 251 | config ARCH_WANT_IPC_PARSE_VERSION | ||
| 252 | bool | ||
| 253 | |||
| 254 | config ARCH_WANT_COMPAT_IPC_PARSE_VERSION | ||
| 255 | bool | ||
| 256 | |||
| 251 | config ARCH_WANT_OLD_COMPAT_IPC | 257 | config ARCH_WANT_OLD_COMPAT_IPC |
| 258 | select ARCH_WANT_COMPAT_IPC_PARSE_VERSION | ||
| 252 | bool | 259 | bool |
| 253 | 260 | ||
| 254 | config HAVE_ARCH_SECCOMP_FILTER | 261 | config HAVE_ARCH_SECCOMP_FILTER |
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index 3de74c9f9610..d5b9b5e645cc 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig | |||
| @@ -14,6 +14,7 @@ config ALPHA | |||
| 14 | select AUTO_IRQ_AFFINITY if SMP | 14 | select AUTO_IRQ_AFFINITY if SMP |
| 15 | select GENERIC_IRQ_SHOW | 15 | select GENERIC_IRQ_SHOW |
| 16 | select ARCH_WANT_OPTIONAL_GPIOLIB | 16 | select ARCH_WANT_OPTIONAL_GPIOLIB |
| 17 | select ARCH_WANT_IPC_PARSE_VERSION | ||
| 17 | select ARCH_HAVE_NMI_SAFE_CMPXCHG | 18 | select ARCH_HAVE_NMI_SAFE_CMPXCHG |
| 18 | select GENERIC_SMP_IDLE_THREAD | 19 | select GENERIC_SMP_IDLE_THREAD |
| 19 | select GENERIC_CMOS_UPDATE | 20 | select GENERIC_CMOS_UPDATE |
diff --git a/arch/alpha/include/asm/unistd.h b/arch/alpha/include/asm/unistd.h index d1f23b722df4..633b23b0664a 100644 --- a/arch/alpha/include/asm/unistd.h +++ b/arch/alpha/include/asm/unistd.h | |||
| @@ -470,7 +470,6 @@ | |||
| 470 | 470 | ||
| 471 | #define NR_SYSCALLS 504 | 471 | #define NR_SYSCALLS 504 |
| 472 | 472 | ||
| 473 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
| 474 | #define __ARCH_WANT_OLD_READDIR | 473 | #define __ARCH_WANT_OLD_READDIR |
| 475 | #define __ARCH_WANT_STAT64 | 474 | #define __ARCH_WANT_STAT64 |
| 476 | #define __ARCH_WANT_SYS_GETHOSTNAME | 475 | #define __ARCH_WANT_SYS_GETHOSTNAME |
diff --git a/arch/alpha/kernel/smc37c669.c b/arch/alpha/kernel/smc37c669.c index 0435921d41c6..c803fc76ae4f 100644 --- a/arch/alpha/kernel/smc37c669.c +++ b/arch/alpha/kernel/smc37c669.c | |||
| @@ -933,18 +933,6 @@ void SMC37c669_display_device_info( | |||
| 933 | * | 933 | * |
| 934 | *-- | 934 | *-- |
| 935 | */ | 935 | */ |
| 936 | #if 0 | ||
| 937 | /* $INCLUDE_OPTIONS$ */ | ||
| 938 | #include "cp$inc:platform_io.h" | ||
| 939 | /* $INCLUDE_OPTIONS_END$ */ | ||
| 940 | #include "cp$src:common.h" | ||
| 941 | #include "cp$inc:prototypes.h" | ||
| 942 | #include "cp$src:kernel_def.h" | ||
| 943 | #include "cp$src:msg_def.h" | ||
| 944 | #include "cp$src:smcc669_def.h" | ||
| 945 | /* Platform-specific includes */ | ||
| 946 | #include "cp$src:platform.h" | ||
| 947 | #endif | ||
| 948 | 936 | ||
| 949 | #ifndef TRUE | 937 | #ifndef TRUE |
| 950 | #define TRUE 1 | 938 | #define TRUE 1 |
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 6b86bb963a28..7980873525b2 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
| @@ -11,6 +11,7 @@ config ARM | |||
| 11 | select RTC_LIB | 11 | select RTC_LIB |
| 12 | select SYS_SUPPORTS_APM_EMULATION | 12 | select SYS_SUPPORTS_APM_EMULATION |
| 13 | select GENERIC_ATOMIC64 if (CPU_V6 || !CPU_32v6K || !AEABI) | 13 | select GENERIC_ATOMIC64 if (CPU_V6 || !CPU_32v6K || !AEABI) |
| 14 | select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE | ||
| 14 | select HAVE_OPROFILE if (HAVE_PERF_EVENTS) | 15 | select HAVE_OPROFILE if (HAVE_PERF_EVENTS) |
| 15 | select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL | 16 | select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL |
| 16 | select HAVE_ARCH_KGDB | 17 | select HAVE_ARCH_KGDB |
| @@ -38,6 +39,7 @@ config ARM | |||
| 38 | select GENERIC_IRQ_PROBE | 39 | select GENERIC_IRQ_PROBE |
| 39 | select GENERIC_IRQ_SHOW | 40 | select GENERIC_IRQ_SHOW |
| 40 | select GENERIC_IRQ_PROBE | 41 | select GENERIC_IRQ_PROBE |
| 42 | select ARCH_WANT_IPC_PARSE_VERSION | ||
| 41 | select HARDIRQS_SW_RESEND | 43 | select HARDIRQS_SW_RESEND |
| 42 | select CPU_PM if (SUSPEND || CPU_IDLE) | 44 | select CPU_PM if (SUSPEND || CPU_IDLE) |
| 43 | select GENERIC_PCI_IOMAP | 45 | select GENERIC_PCI_IOMAP |
diff --git a/arch/arm/include/asm/unistd.h b/arch/arm/include/asm/unistd.h index 512cd1473454..0cab47d4a83f 100644 --- a/arch/arm/include/asm/unistd.h +++ b/arch/arm/include/asm/unistd.h | |||
| @@ -446,7 +446,6 @@ | |||
| 446 | 446 | ||
| 447 | #ifdef __KERNEL__ | 447 | #ifdef __KERNEL__ |
| 448 | 448 | ||
| 449 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
| 450 | #define __ARCH_WANT_STAT64 | 449 | #define __ARCH_WANT_STAT64 |
| 451 | #define __ARCH_WANT_SYS_GETHOSTNAME | 450 | #define __ARCH_WANT_SYS_GETHOSTNAME |
| 452 | #define __ARCH_WANT_SYS_PAUSE | 451 | #define __ARCH_WANT_SYS_PAUSE |
diff --git a/arch/arm/lib/io-acorn.S b/arch/arm/lib/io-acorn.S index 1b197ea7aab3..69719bad674d 100644 --- a/arch/arm/lib/io-acorn.S +++ b/arch/arm/lib/io-acorn.S | |||
| @@ -11,13 +11,14 @@ | |||
| 11 | * | 11 | * |
| 12 | */ | 12 | */ |
| 13 | #include <linux/linkage.h> | 13 | #include <linux/linkage.h> |
| 14 | #include <linux/kern_levels.h> | ||
| 14 | #include <asm/assembler.h> | 15 | #include <asm/assembler.h> |
| 15 | 16 | ||
| 16 | .text | 17 | .text |
| 17 | .align | 18 | .align |
| 18 | 19 | ||
| 19 | .Liosl_warning: | 20 | .Liosl_warning: |
| 20 | .ascii "<4>insl/outsl not implemented, called from %08lX\0" | 21 | .ascii KERN_WARNING "insl/outsl not implemented, called from %08lX\0" |
| 21 | .align | 22 | .align |
| 22 | 23 | ||
| 23 | /* | 24 | /* |
diff --git a/arch/arm/mach-netx/fb.c b/arch/arm/mach-netx/fb.c index 2cdf6ef69bee..d122ee6ab991 100644 --- a/arch/arm/mach-netx/fb.c +++ b/arch/arm/mach-netx/fb.c | |||
| @@ -69,29 +69,6 @@ void netx_clcd_remove(struct clcd_fb *fb) | |||
| 69 | fb->fb.screen_base, fb->fb.fix.smem_start); | 69 | fb->fb.screen_base, fb->fb.fix.smem_start); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | void clk_disable(struct clk *clk) | ||
| 73 | { | ||
| 74 | } | ||
| 75 | |||
| 76 | int clk_set_rate(struct clk *clk, unsigned long rate) | ||
| 77 | { | ||
| 78 | return 0; | ||
| 79 | } | ||
| 80 | |||
| 81 | int clk_enable(struct clk *clk) | ||
| 82 | { | ||
| 83 | return 0; | ||
| 84 | } | ||
| 85 | |||
| 86 | struct clk *clk_get(struct device *dev, const char *id) | ||
| 87 | { | ||
| 88 | return dev && strcmp(dev_name(dev), "fb") == 0 ? NULL : ERR_PTR(-ENOENT); | ||
| 89 | } | ||
| 90 | |||
| 91 | void clk_put(struct clk *clk) | ||
| 92 | { | ||
| 93 | } | ||
| 94 | |||
| 95 | static AMBA_AHB_DEVICE(fb, "fb", 0, 0x00104000, { NETX_IRQ_LCD }, NULL); | 72 | static AMBA_AHB_DEVICE(fb, "fb", 0, 0x00104000, { NETX_IRQ_LCD }, NULL); |
| 96 | 73 | ||
| 97 | int netx_fb_init(struct clcd_board *board, struct clcd_panel *panel) | 74 | int netx_fb_init(struct clcd_board *board, struct clcd_panel *panel) |
diff --git a/arch/arm/vfp/vfphw.S b/arch/arm/vfp/vfphw.S index 2d30c7f6edd3..d50f0e486cf2 100644 --- a/arch/arm/vfp/vfphw.S +++ b/arch/arm/vfp/vfphw.S | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | */ | 16 | */ |
| 17 | #include <asm/thread_info.h> | 17 | #include <asm/thread_info.h> |
| 18 | #include <asm/vfpmacros.h> | 18 | #include <asm/vfpmacros.h> |
| 19 | #include <linux/kern_levels.h> | ||
| 19 | #include "../kernel/entry-header.S" | 20 | #include "../kernel/entry-header.S" |
| 20 | 21 | ||
| 21 | .macro DBGSTR, str | 22 | .macro DBGSTR, str |
| @@ -24,7 +25,7 @@ | |||
| 24 | add r0, pc, #4 | 25 | add r0, pc, #4 |
| 25 | bl printk | 26 | bl printk |
| 26 | b 1f | 27 | b 1f |
| 27 | .asciz "<7>VFP: \str\n" | 28 | .asciz KERN_DEBUG "VFP: \str\n" |
| 28 | .balign 4 | 29 | .balign 4 |
| 29 | 1: ldmfd sp!, {r0-r3, ip, lr} | 30 | 1: ldmfd sp!, {r0-r3, ip, lr} |
| 30 | #endif | 31 | #endif |
| @@ -37,7 +38,7 @@ | |||
| 37 | add r0, pc, #4 | 38 | add r0, pc, #4 |
| 38 | bl printk | 39 | bl printk |
| 39 | b 1f | 40 | b 1f |
| 40 | .asciz "<7>VFP: \str\n" | 41 | .asciz KERN_DEBUG "VFP: \str\n" |
| 41 | .balign 4 | 42 | .balign 4 |
| 42 | 1: ldmfd sp!, {r0-r3, ip, lr} | 43 | 1: ldmfd sp!, {r0-r3, ip, lr} |
| 43 | #endif | 44 | #endif |
| @@ -52,7 +53,7 @@ | |||
| 52 | add r0, pc, #4 | 53 | add r0, pc, #4 |
| 53 | bl printk | 54 | bl printk |
| 54 | b 1f | 55 | b 1f |
| 55 | .asciz "<7>VFP: \str\n" | 56 | .asciz KERN_DEBUG "VFP: \str\n" |
| 56 | .balign 4 | 57 | .balign 4 |
| 57 | 1: ldmfd sp!, {r0-r3, ip, lr} | 58 | 1: ldmfd sp!, {r0-r3, ip, lr} |
| 58 | #endif | 59 | #endif |
diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig index 71d38c76726c..5ade51c8a87f 100644 --- a/arch/avr32/Kconfig +++ b/arch/avr32/Kconfig | |||
| @@ -12,6 +12,7 @@ config AVR32 | |||
| 12 | select HARDIRQS_SW_RESEND | 12 | select HARDIRQS_SW_RESEND |
| 13 | select GENERIC_IRQ_SHOW | 13 | select GENERIC_IRQ_SHOW |
| 14 | select ARCH_HAVE_CUSTOM_GPIO_H | 14 | select ARCH_HAVE_CUSTOM_GPIO_H |
| 15 | select ARCH_WANT_IPC_PARSE_VERSION | ||
| 15 | select ARCH_HAVE_NMI_SAFE_CMPXCHG | 16 | select ARCH_HAVE_NMI_SAFE_CMPXCHG |
| 16 | select GENERIC_CLOCKEVENTS | 17 | select GENERIC_CLOCKEVENTS |
| 17 | help | 18 | help |
diff --git a/arch/avr32/boards/atstk1000/atstk1002.c b/arch/avr32/boards/atstk1000/atstk1002.c index dc5263321480..6c80aba7bf96 100644 --- a/arch/avr32/boards/atstk1000/atstk1002.c +++ b/arch/avr32/boards/atstk1000/atstk1002.c | |||
| @@ -97,7 +97,7 @@ static struct atmel_nand_data atstk1006_nand_data __initdata = { | |||
| 97 | .enable_pin = GPIO_PIN_PB(29), | 97 | .enable_pin = GPIO_PIN_PB(29), |
| 98 | .ecc_mode = NAND_ECC_SOFT, | 98 | .ecc_mode = NAND_ECC_SOFT, |
| 99 | .parts = nand_partitions, | 99 | .parts = nand_partitions, |
| 100 | .num_parts = ARRAY_SIZE(num_partitions), | 100 | .num_parts = ARRAY_SIZE(nand_partitions), |
| 101 | }; | 101 | }; |
| 102 | #endif | 102 | #endif |
| 103 | 103 | ||
diff --git a/arch/avr32/include/asm/unistd.h b/arch/avr32/include/asm/unistd.h index f714544e5560..1358e366f4be 100644 --- a/arch/avr32/include/asm/unistd.h +++ b/arch/avr32/include/asm/unistd.h | |||
| @@ -318,7 +318,6 @@ | |||
| 318 | /* SMP stuff */ | 318 | /* SMP stuff */ |
| 319 | #define __IGNORE_getcpu | 319 | #define __IGNORE_getcpu |
| 320 | 320 | ||
| 321 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
| 322 | #define __ARCH_WANT_STAT64 | 321 | #define __ARCH_WANT_STAT64 |
| 323 | #define __ARCH_WANT_SYS_ALARM | 322 | #define __ARCH_WANT_SYS_ALARM |
| 324 | #define __ARCH_WANT_SYS_GETHOSTNAME | 323 | #define __ARCH_WANT_SYS_GETHOSTNAME |
diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c index f7040a1e399f..b92e60958617 100644 --- a/arch/avr32/mm/fault.c +++ b/arch/avr32/mm/fault.c | |||
| @@ -61,10 +61,10 @@ asmlinkage void do_page_fault(unsigned long ecr, struct pt_regs *regs) | |||
| 61 | const struct exception_table_entry *fixup; | 61 | const struct exception_table_entry *fixup; |
| 62 | unsigned long address; | 62 | unsigned long address; |
| 63 | unsigned long page; | 63 | unsigned long page; |
| 64 | int writeaccess; | ||
| 65 | long signr; | 64 | long signr; |
| 66 | int code; | 65 | int code; |
| 67 | int fault; | 66 | int fault; |
| 67 | unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; | ||
| 68 | 68 | ||
| 69 | if (notify_page_fault(regs, ecr)) | 69 | if (notify_page_fault(regs, ecr)) |
| 70 | return; | 70 | return; |
| @@ -86,6 +86,7 @@ asmlinkage void do_page_fault(unsigned long ecr, struct pt_regs *regs) | |||
| 86 | 86 | ||
| 87 | local_irq_enable(); | 87 | local_irq_enable(); |
| 88 | 88 | ||
| 89 | retry: | ||
| 89 | down_read(&mm->mmap_sem); | 90 | down_read(&mm->mmap_sem); |
| 90 | 91 | ||
| 91 | vma = find_vma(mm, address); | 92 | vma = find_vma(mm, address); |
| @@ -104,7 +105,6 @@ asmlinkage void do_page_fault(unsigned long ecr, struct pt_regs *regs) | |||
| 104 | */ | 105 | */ |
| 105 | good_area: | 106 | good_area: |
| 106 | code = SEGV_ACCERR; | 107 | code = SEGV_ACCERR; |
| 107 | writeaccess = 0; | ||
| 108 | 108 | ||
| 109 | switch (ecr) { | 109 | switch (ecr) { |
| 110 | case ECR_PROTECTION_X: | 110 | case ECR_PROTECTION_X: |
| @@ -121,7 +121,7 @@ good_area: | |||
| 121 | case ECR_TLB_MISS_W: | 121 | case ECR_TLB_MISS_W: |
| 122 | if (!(vma->vm_flags & VM_WRITE)) | 122 | if (!(vma->vm_flags & VM_WRITE)) |
| 123 | goto bad_area; | 123 | goto bad_area; |
| 124 | writeaccess = 1; | 124 | flags |= FAULT_FLAG_WRITE; |
| 125 | break; | 125 | break; |
| 126 | default: | 126 | default: |
| 127 | panic("Unhandled case %lu in do_page_fault!", ecr); | 127 | panic("Unhandled case %lu in do_page_fault!", ecr); |
| @@ -132,7 +132,11 @@ good_area: | |||
| 132 | * sure we exit gracefully rather than endlessly redo the | 132 | * sure we exit gracefully rather than endlessly redo the |
| 133 | * fault. | 133 | * fault. |
| 134 | */ | 134 | */ |
| 135 | fault = handle_mm_fault(mm, vma, address, writeaccess ? FAULT_FLAG_WRITE : 0); | 135 | fault = handle_mm_fault(mm, vma, address, flags); |
| 136 | |||
| 137 | if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) | ||
| 138 | return; | ||
| 139 | |||
| 136 | if (unlikely(fault & VM_FAULT_ERROR)) { | 140 | if (unlikely(fault & VM_FAULT_ERROR)) { |
| 137 | if (fault & VM_FAULT_OOM) | 141 | if (fault & VM_FAULT_OOM) |
| 138 | goto out_of_memory; | 142 | goto out_of_memory; |
| @@ -140,10 +144,23 @@ good_area: | |||
| 140 | goto do_sigbus; | 144 | goto do_sigbus; |
| 141 | BUG(); | 145 | BUG(); |
| 142 | } | 146 | } |
| 143 | if (fault & VM_FAULT_MAJOR) | 147 | |
| 144 | tsk->maj_flt++; | 148 | if (flags & FAULT_FLAG_ALLOW_RETRY) { |
| 145 | else | 149 | if (fault & VM_FAULT_MAJOR) |
| 146 | tsk->min_flt++; | 150 | tsk->maj_flt++; |
| 151 | else | ||
| 152 | tsk->min_flt++; | ||
| 153 | if (fault & VM_FAULT_RETRY) { | ||
| 154 | flags &= ~FAULT_FLAG_ALLOW_RETRY; | ||
| 155 | |||
| 156 | /* | ||
| 157 | * No need to up_read(&mm->mmap_sem) as we would have | ||
| 158 | * already released it in __lock_page_or_retry() in | ||
| 159 | * mm/filemap.c. | ||
| 160 | */ | ||
| 161 | goto retry; | ||
| 162 | } | ||
| 163 | } | ||
| 147 | 164 | ||
| 148 | up_read(&mm->mmap_sem); | 165 | up_read(&mm->mmap_sem); |
| 149 | return; | 166 | return; |
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig index ec44fc6c34ca..f34861920634 100644 --- a/arch/blackfin/Kconfig +++ b/arch/blackfin/Kconfig | |||
| @@ -33,6 +33,7 @@ config BLACKFIN | |||
| 33 | select HAVE_PERF_EVENTS | 33 | select HAVE_PERF_EVENTS |
| 34 | select ARCH_HAVE_CUSTOM_GPIO_H | 34 | select ARCH_HAVE_CUSTOM_GPIO_H |
| 35 | select ARCH_WANT_OPTIONAL_GPIOLIB | 35 | select ARCH_WANT_OPTIONAL_GPIOLIB |
| 36 | select ARCH_WANT_IPC_PARSE_VERSION | ||
| 36 | select HAVE_GENERIC_HARDIRQS | 37 | select HAVE_GENERIC_HARDIRQS |
| 37 | select GENERIC_ATOMIC64 | 38 | select GENERIC_ATOMIC64 |
| 38 | select GENERIC_IRQ_PROBE | 39 | select GENERIC_IRQ_PROBE |
diff --git a/arch/blackfin/include/asm/unistd.h b/arch/blackfin/include/asm/unistd.h index 3287222cba34..5b2a0748d7d3 100644 --- a/arch/blackfin/include/asm/unistd.h +++ b/arch/blackfin/include/asm/unistd.h | |||
| @@ -434,7 +434,6 @@ | |||
| 434 | #define __IGNORE_getcpu | 434 | #define __IGNORE_getcpu |
| 435 | 435 | ||
| 436 | #ifdef __KERNEL__ | 436 | #ifdef __KERNEL__ |
| 437 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
| 438 | #define __ARCH_WANT_STAT64 | 437 | #define __ARCH_WANT_STAT64 |
| 439 | #define __ARCH_WANT_SYS_ALARM | 438 | #define __ARCH_WANT_SYS_ALARM |
| 440 | #define __ARCH_WANT_SYS_GETHOSTNAME | 439 | #define __ARCH_WANT_SYS_GETHOSTNAME |
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig index bb344650a14f..e92215428a37 100644 --- a/arch/cris/Kconfig +++ b/arch/cris/Kconfig | |||
| @@ -42,6 +42,7 @@ config CRIS | |||
| 42 | select HAVE_IDE | 42 | select HAVE_IDE |
| 43 | select GENERIC_ATOMIC64 | 43 | select GENERIC_ATOMIC64 |
| 44 | select HAVE_GENERIC_HARDIRQS | 44 | select HAVE_GENERIC_HARDIRQS |
| 45 | select ARCH_WANT_IPC_PARSE_VERSION | ||
| 45 | select GENERIC_IRQ_SHOW | 46 | select GENERIC_IRQ_SHOW |
| 46 | select GENERIC_IOMAP | 47 | select GENERIC_IOMAP |
| 47 | select GENERIC_SMP_IDLE_THREAD if ETRAX_ARCH_V32 | 48 | select GENERIC_SMP_IDLE_THREAD if ETRAX_ARCH_V32 |
diff --git a/arch/cris/include/asm/unistd.h b/arch/cris/include/asm/unistd.h index f921b8b0f97e..51873a446f87 100644 --- a/arch/cris/include/asm/unistd.h +++ b/arch/cris/include/asm/unistd.h | |||
| @@ -347,7 +347,6 @@ | |||
| 347 | 347 | ||
| 348 | #include <arch/unistd.h> | 348 | #include <arch/unistd.h> |
| 349 | 349 | ||
| 350 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
| 351 | #define __ARCH_WANT_OLD_READDIR | 350 | #define __ARCH_WANT_OLD_READDIR |
| 352 | #define __ARCH_WANT_OLD_STAT | 351 | #define __ARCH_WANT_OLD_STAT |
| 353 | #define __ARCH_WANT_STAT64 | 352 | #define __ARCH_WANT_STAT64 |
diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig index a685910d2d5c..971c0a19facb 100644 --- a/arch/frv/Kconfig +++ b/arch/frv/Kconfig | |||
| @@ -9,6 +9,7 @@ config FRV | |||
| 9 | select GENERIC_IRQ_SHOW | 9 | select GENERIC_IRQ_SHOW |
| 10 | select ARCH_HAVE_NMI_SAFE_CMPXCHG | 10 | select ARCH_HAVE_NMI_SAFE_CMPXCHG |
| 11 | select GENERIC_CPU_DEVICES | 11 | select GENERIC_CPU_DEVICES |
| 12 | select ARCH_WANT_IPC_PARSE_VERSION | ||
| 12 | 13 | ||
| 13 | config ZONE_DMA | 14 | config ZONE_DMA |
| 14 | bool | 15 | bool |
diff --git a/arch/frv/include/asm/unistd.h b/arch/frv/include/asm/unistd.h index a569dff7cd59..67f23a311db6 100644 --- a/arch/frv/include/asm/unistd.h +++ b/arch/frv/include/asm/unistd.h | |||
| @@ -349,7 +349,6 @@ | |||
| 349 | 349 | ||
| 350 | #define NR_syscalls 338 | 350 | #define NR_syscalls 338 |
| 351 | 351 | ||
| 352 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
| 353 | /* #define __ARCH_WANT_OLD_READDIR */ | 352 | /* #define __ARCH_WANT_OLD_READDIR */ |
| 354 | #define __ARCH_WANT_OLD_STAT | 353 | #define __ARCH_WANT_OLD_STAT |
| 355 | #define __ARCH_WANT_STAT64 | 354 | #define __ARCH_WANT_STAT64 |
diff --git a/arch/frv/kernel/kernel_thread.S b/arch/frv/kernel/kernel_thread.S index 4531c830d20b..f0e52943f923 100644 --- a/arch/frv/kernel/kernel_thread.S +++ b/arch/frv/kernel/kernel_thread.S | |||
| @@ -10,10 +10,10 @@ | |||
| 10 | */ | 10 | */ |
| 11 | 11 | ||
| 12 | #include <linux/linkage.h> | 12 | #include <linux/linkage.h> |
| 13 | #include <linux/kern_levels.h> | ||
| 13 | #include <asm/unistd.h> | 14 | #include <asm/unistd.h> |
| 14 | 15 | ||
| 15 | #define CLONE_VM 0x00000100 /* set if VM shared between processes */ | 16 | #define CLONE_VM 0x00000100 /* set if VM shared between processes */ |
| 16 | #define KERN_ERR "<3>" | ||
| 17 | 17 | ||
| 18 | .section .rodata | 18 | .section .rodata |
| 19 | kernel_thread_emsg: | 19 | kernel_thread_emsg: |
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig index 56e890df5053..5e8a0d9a09ce 100644 --- a/arch/h8300/Kconfig +++ b/arch/h8300/Kconfig | |||
| @@ -3,6 +3,7 @@ config H8300 | |||
| 3 | default y | 3 | default y |
| 4 | select HAVE_IDE | 4 | select HAVE_IDE |
| 5 | select HAVE_GENERIC_HARDIRQS | 5 | select HAVE_GENERIC_HARDIRQS |
| 6 | select ARCH_WANT_IPC_PARSE_VERSION | ||
| 6 | select GENERIC_IRQ_SHOW | 7 | select GENERIC_IRQ_SHOW |
| 7 | select GENERIC_CPU_DEVICES | 8 | select GENERIC_CPU_DEVICES |
| 8 | 9 | ||
diff --git a/arch/h8300/include/asm/unistd.h b/arch/h8300/include/asm/unistd.h index 718511303b4e..5cd882801d79 100644 --- a/arch/h8300/include/asm/unistd.h +++ b/arch/h8300/include/asm/unistd.h | |||
| @@ -331,7 +331,6 @@ | |||
| 331 | 331 | ||
| 332 | #define NR_syscalls 321 | 332 | #define NR_syscalls 321 |
| 333 | 333 | ||
| 334 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
| 335 | #define __ARCH_WANT_OLD_READDIR | 334 | #define __ARCH_WANT_OLD_READDIR |
| 336 | #define __ARCH_WANT_OLD_STAT | 335 | #define __ARCH_WANT_OLD_STAT |
| 337 | #define __ARCH_WANT_STAT64 | 336 | #define __ARCH_WANT_STAT64 |
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index b638d5bfa14d..49498bbb9616 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig | |||
| @@ -7,6 +7,7 @@ config M32R | |||
| 7 | select HAVE_KERNEL_GZIP | 7 | select HAVE_KERNEL_GZIP |
| 8 | select HAVE_KERNEL_BZIP2 | 8 | select HAVE_KERNEL_BZIP2 |
| 9 | select HAVE_KERNEL_LZMA | 9 | select HAVE_KERNEL_LZMA |
| 10 | select ARCH_WANT_IPC_PARSE_VERSION | ||
| 10 | select HAVE_GENERIC_HARDIRQS | 11 | select HAVE_GENERIC_HARDIRQS |
| 11 | select GENERIC_IRQ_PROBE | 12 | select GENERIC_IRQ_PROBE |
| 12 | select GENERIC_IRQ_SHOW | 13 | select GENERIC_IRQ_SHOW |
diff --git a/arch/m32r/include/asm/unistd.h b/arch/m32r/include/asm/unistd.h index 3e1db561aacc..d5e66a480782 100644 --- a/arch/m32r/include/asm/unistd.h +++ b/arch/m32r/include/asm/unistd.h | |||
| @@ -336,7 +336,6 @@ | |||
| 336 | 336 | ||
| 337 | #define NR_syscalls 326 | 337 | #define NR_syscalls 326 |
| 338 | 338 | ||
| 339 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
| 340 | #define __ARCH_WANT_STAT64 | 339 | #define __ARCH_WANT_STAT64 |
| 341 | #define __ARCH_WANT_SYS_ALARM | 340 | #define __ARCH_WANT_SYS_ALARM |
| 342 | #define __ARCH_WANT_SYS_GETHOSTNAME | 341 | #define __ARCH_WANT_SYS_GETHOSTNAME |
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index 147120128260..0b0f8b8c4a26 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig | |||
| @@ -10,6 +10,7 @@ config M68K | |||
| 10 | select GENERIC_STRNCPY_FROM_USER if MMU | 10 | select GENERIC_STRNCPY_FROM_USER if MMU |
| 11 | select GENERIC_STRNLEN_USER if MMU | 11 | select GENERIC_STRNLEN_USER if MMU |
| 12 | select FPU if MMU | 12 | select FPU if MMU |
| 13 | select ARCH_WANT_IPC_PARSE_VERSION | ||
| 13 | select ARCH_USES_GETTIMEOFFSET if MMU && !COLDFIRE | 14 | select ARCH_USES_GETTIMEOFFSET if MMU && !COLDFIRE |
| 14 | 15 | ||
| 15 | config RWSEM_GENERIC_SPINLOCK | 16 | config RWSEM_GENERIC_SPINLOCK |
diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h index ea0b502f845e..045cfd6a9e31 100644 --- a/arch/m68k/include/asm/unistd.h +++ b/arch/m68k/include/asm/unistd.h | |||
| @@ -357,7 +357,6 @@ | |||
| 357 | 357 | ||
| 358 | #define NR_syscalls 347 | 358 | #define NR_syscalls 347 |
| 359 | 359 | ||
| 360 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
| 361 | #define __ARCH_WANT_OLD_READDIR | 360 | #define __ARCH_WANT_OLD_READDIR |
| 362 | #define __ARCH_WANT_OLD_STAT | 361 | #define __ARCH_WANT_OLD_STAT |
| 363 | #define __ARCH_WANT_STAT64 | 362 | #define __ARCH_WANT_STAT64 |
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index 0bf44231aaf9..ab9afcaa7f6a 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig | |||
| @@ -15,6 +15,7 @@ config MICROBLAZE | |||
| 15 | select TRACING_SUPPORT | 15 | select TRACING_SUPPORT |
| 16 | select OF | 16 | select OF |
| 17 | select OF_EARLY_FLATTREE | 17 | select OF_EARLY_FLATTREE |
| 18 | select ARCH_WANT_IPC_PARSE_VERSION | ||
| 18 | select IRQ_DOMAIN | 19 | select IRQ_DOMAIN |
| 19 | select HAVE_GENERIC_HARDIRQS | 20 | select HAVE_GENERIC_HARDIRQS |
| 20 | select GENERIC_IRQ_PROBE | 21 | select GENERIC_IRQ_PROBE |
diff --git a/arch/microblaze/include/asm/unistd.h b/arch/microblaze/include/asm/unistd.h index d20ffbc86beb..6985e6e9d826 100644 --- a/arch/microblaze/include/asm/unistd.h +++ b/arch/microblaze/include/asm/unistd.h | |||
| @@ -400,7 +400,6 @@ | |||
| 400 | #ifdef __KERNEL__ | 400 | #ifdef __KERNEL__ |
| 401 | #ifndef __ASSEMBLY__ | 401 | #ifndef __ASSEMBLY__ |
| 402 | 402 | ||
| 403 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
| 404 | /* #define __ARCH_WANT_OLD_READDIR */ | 403 | /* #define __ARCH_WANT_OLD_READDIR */ |
| 405 | /* #define __ARCH_WANT_OLD_STAT */ | 404 | /* #define __ARCH_WANT_OLD_STAT */ |
| 406 | #define __ARCH_WANT_STAT64 | 405 | #define __ARCH_WANT_STAT64 |
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 750429018534..e3efc06e6409 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
| @@ -20,12 +20,14 @@ config MIPS | |||
| 20 | select ARCH_BINFMT_ELF_RANDOMIZE_PIE | 20 | select ARCH_BINFMT_ELF_RANDOMIZE_PIE |
| 21 | select RTC_LIB if !MACH_LOONGSON | 21 | select RTC_LIB if !MACH_LOONGSON |
| 22 | select GENERIC_ATOMIC64 if !64BIT | 22 | select GENERIC_ATOMIC64 if !64BIT |
| 23 | select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE | ||
| 23 | select HAVE_DMA_ATTRS | 24 | select HAVE_DMA_ATTRS |
| 24 | select HAVE_DMA_API_DEBUG | 25 | select HAVE_DMA_API_DEBUG |
| 25 | select HAVE_GENERIC_HARDIRQS | 26 | select HAVE_GENERIC_HARDIRQS |
| 26 | select GENERIC_IRQ_PROBE | 27 | select GENERIC_IRQ_PROBE |
| 27 | select GENERIC_IRQ_SHOW | 28 | select GENERIC_IRQ_SHOW |
| 28 | select HAVE_ARCH_JUMP_LABEL | 29 | select HAVE_ARCH_JUMP_LABEL |
| 30 | select ARCH_WANT_IPC_PARSE_VERSION | ||
| 29 | select IRQ_FORCED_THREADING | 31 | select IRQ_FORCED_THREADING |
| 30 | select HAVE_MEMBLOCK | 32 | select HAVE_MEMBLOCK |
| 31 | select HAVE_MEMBLOCK_NODE_MAP | 33 | select HAVE_MEMBLOCK_NODE_MAP |
diff --git a/arch/mips/include/asm/unistd.h b/arch/mips/include/asm/unistd.h index d8dad5340ea3..bebbde01be92 100644 --- a/arch/mips/include/asm/unistd.h +++ b/arch/mips/include/asm/unistd.h | |||
| @@ -1034,7 +1034,6 @@ | |||
| 1034 | #ifndef __ASSEMBLY__ | 1034 | #ifndef __ASSEMBLY__ |
| 1035 | 1035 | ||
| 1036 | #define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 | 1036 | #define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 |
| 1037 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
| 1038 | #define __ARCH_WANT_OLD_READDIR | 1037 | #define __ARCH_WANT_OLD_READDIR |
| 1039 | #define __ARCH_WANT_SYS_ALARM | 1038 | #define __ARCH_WANT_SYS_ALARM |
| 1040 | #define __ARCH_WANT_SYS_GETHOSTNAME | 1039 | #define __ARCH_WANT_SYS_GETHOSTNAME |
diff --git a/arch/mn10300/Kconfig b/arch/mn10300/Kconfig index 687f9b4a2ed6..5cfb086b3903 100644 --- a/arch/mn10300/Kconfig +++ b/arch/mn10300/Kconfig | |||
| @@ -3,6 +3,7 @@ config MN10300 | |||
| 3 | select HAVE_OPROFILE | 3 | select HAVE_OPROFILE |
| 4 | select HAVE_GENERIC_HARDIRQS | 4 | select HAVE_GENERIC_HARDIRQS |
| 5 | select GENERIC_IRQ_SHOW | 5 | select GENERIC_IRQ_SHOW |
| 6 | select ARCH_WANT_IPC_PARSE_VERSION | ||
| 6 | select HAVE_ARCH_TRACEHOOK | 7 | select HAVE_ARCH_TRACEHOOK |
| 7 | select HAVE_ARCH_KGDB | 8 | select HAVE_ARCH_KGDB |
| 8 | select HAVE_NMI_WATCHDOG if MN10300_WD_TIMER | 9 | select HAVE_NMI_WATCHDOG if MN10300_WD_TIMER |
diff --git a/arch/mn10300/include/asm/unistd.h b/arch/mn10300/include/asm/unistd.h index 9051f921cbc7..866eb14749d7 100644 --- a/arch/mn10300/include/asm/unistd.h +++ b/arch/mn10300/include/asm/unistd.h | |||
| @@ -358,7 +358,6 @@ | |||
| 358 | /* | 358 | /* |
| 359 | * specify the deprecated syscalls we want to support on this arch | 359 | * specify the deprecated syscalls we want to support on this arch |
| 360 | */ | 360 | */ |
| 361 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
| 362 | #define __ARCH_WANT_OLD_READDIR | 361 | #define __ARCH_WANT_OLD_READDIR |
| 363 | #define __ARCH_WANT_OLD_STAT | 362 | #define __ARCH_WANT_OLD_STAT |
| 364 | #define __ARCH_WANT_STAT64 | 363 | #define __ARCH_WANT_STAT64 |
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 9a5d3cdc3e12..352f416269ce 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
| @@ -115,11 +115,13 @@ config PPC | |||
| 115 | select HAVE_OPROFILE | 115 | select HAVE_OPROFILE |
| 116 | select HAVE_SYSCALL_WRAPPERS if PPC64 | 116 | select HAVE_SYSCALL_WRAPPERS if PPC64 |
| 117 | select GENERIC_ATOMIC64 if PPC32 | 117 | select GENERIC_ATOMIC64 if PPC32 |
| 118 | select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE | ||
| 118 | select HAVE_IRQ_WORK | 119 | select HAVE_IRQ_WORK |
| 119 | select HAVE_PERF_EVENTS | 120 | select HAVE_PERF_EVENTS |
| 120 | select HAVE_REGS_AND_STACK_ACCESS_API | 121 | select HAVE_REGS_AND_STACK_ACCESS_API |
| 121 | select HAVE_HW_BREAKPOINT if PERF_EVENTS && PPC_BOOK3S_64 | 122 | select HAVE_HW_BREAKPOINT if PERF_EVENTS && PPC_BOOK3S_64 |
| 122 | select HAVE_GENERIC_HARDIRQS | 123 | select HAVE_GENERIC_HARDIRQS |
| 124 | select ARCH_WANT_IPC_PARSE_VERSION | ||
| 123 | select SPARSE_IRQ | 125 | select SPARSE_IRQ |
| 124 | select IRQ_PER_CPU | 126 | select IRQ_PER_CPU |
| 125 | select IRQ_DOMAIN | 127 | select IRQ_DOMAIN |
diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h index d3d1b5efd7eb..bd377a368611 100644 --- a/arch/powerpc/include/asm/unistd.h +++ b/arch/powerpc/include/asm/unistd.h | |||
| @@ -389,7 +389,6 @@ | |||
| 389 | #include <linux/compiler.h> | 389 | #include <linux/compiler.h> |
| 390 | #include <linux/linkage.h> | 390 | #include <linux/linkage.h> |
| 391 | 391 | ||
| 392 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
| 393 | #define __ARCH_WANT_OLD_READDIR | 392 | #define __ARCH_WANT_OLD_READDIR |
| 394 | #define __ARCH_WANT_STAT64 | 393 | #define __ARCH_WANT_STAT64 |
| 395 | #define __ARCH_WANT_SYS_ALARM | 394 | #define __ARCH_WANT_SYS_ALARM |
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index a39b4690c171..296cd32466df 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig | |||
| @@ -85,6 +85,7 @@ config S390 | |||
| 85 | select HAVE_ARCH_MUTEX_CPU_RELAX | 85 | select HAVE_ARCH_MUTEX_CPU_RELAX |
| 86 | select HAVE_ARCH_JUMP_LABEL if !MARCH_G5 | 86 | select HAVE_ARCH_JUMP_LABEL if !MARCH_G5 |
| 87 | select ARCH_SAVE_PAGE_KEYS if HIBERNATION | 87 | select ARCH_SAVE_PAGE_KEYS if HIBERNATION |
| 88 | select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE | ||
| 88 | select HAVE_MEMBLOCK | 89 | select HAVE_MEMBLOCK |
| 89 | select HAVE_MEMBLOCK_NODE_MAP | 90 | select HAVE_MEMBLOCK_NODE_MAP |
| 90 | select HAVE_CMPXCHG_LOCAL | 91 | select HAVE_CMPXCHG_LOCAL |
| @@ -117,6 +118,7 @@ config S390 | |||
| 117 | select ARCH_INLINE_WRITE_UNLOCK_BH | 118 | select ARCH_INLINE_WRITE_UNLOCK_BH |
| 118 | select ARCH_INLINE_WRITE_UNLOCK_IRQ | 119 | select ARCH_INLINE_WRITE_UNLOCK_IRQ |
| 119 | select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE | 120 | select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE |
| 121 | select ARCH_WANT_IPC_PARSE_VERSION | ||
| 120 | select GENERIC_SMP_IDLE_THREAD | 122 | select GENERIC_SMP_IDLE_THREAD |
| 121 | select GENERIC_TIME_VSYSCALL | 123 | select GENERIC_TIME_VSYSCALL |
| 122 | select GENERIC_CLOCKEVENTS | 124 | select GENERIC_CLOCKEVENTS |
diff --git a/arch/s390/include/asm/unistd.h b/arch/s390/include/asm/unistd.h index 2e37157ba6a9..6756e78f4808 100644 --- a/arch/s390/include/asm/unistd.h +++ b/arch/s390/include/asm/unistd.h | |||
| @@ -388,7 +388,6 @@ | |||
| 388 | #define __IGNORE_recvmmsg | 388 | #define __IGNORE_recvmmsg |
| 389 | #define __IGNORE_sendmmsg | 389 | #define __IGNORE_sendmmsg |
| 390 | 390 | ||
| 391 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
| 392 | #define __ARCH_WANT_OLD_READDIR | 391 | #define __ARCH_WANT_OLD_READDIR |
| 393 | #define __ARCH_WANT_SYS_ALARM | 392 | #define __ARCH_WANT_SYS_ALARM |
| 394 | #define __ARCH_WANT_SYS_GETHOSTNAME | 393 | #define __ARCH_WANT_SYS_GETHOSTNAME |
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index a24595d83ad6..36f5141e8041 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig | |||
| @@ -21,6 +21,7 @@ config SUPERH | |||
| 21 | select HAVE_KERNEL_LZMA | 21 | select HAVE_KERNEL_LZMA |
| 22 | select HAVE_KERNEL_XZ | 22 | select HAVE_KERNEL_XZ |
| 23 | select HAVE_KERNEL_LZO | 23 | select HAVE_KERNEL_LZO |
| 24 | select ARCH_WANT_IPC_PARSE_VERSION | ||
| 24 | select HAVE_SYSCALL_TRACEPOINTS | 25 | select HAVE_SYSCALL_TRACEPOINTS |
| 25 | select HAVE_REGS_AND_STACK_ACCESS_API | 26 | select HAVE_REGS_AND_STACK_ACCESS_API |
| 26 | select HAVE_GENERIC_HARDIRQS | 27 | select HAVE_GENERIC_HARDIRQS |
| @@ -50,6 +51,7 @@ config SUPERH32 | |||
| 50 | select HAVE_DYNAMIC_FTRACE | 51 | select HAVE_DYNAMIC_FTRACE |
| 51 | select HAVE_FUNCTION_TRACE_MCOUNT_TEST | 52 | select HAVE_FUNCTION_TRACE_MCOUNT_TEST |
| 52 | select HAVE_FTRACE_NMI_ENTER if DYNAMIC_FTRACE | 53 | select HAVE_FTRACE_NMI_ENTER if DYNAMIC_FTRACE |
| 54 | select ARCH_WANT_IPC_PARSE_VERSION | ||
| 53 | select HAVE_FUNCTION_GRAPH_TRACER | 55 | select HAVE_FUNCTION_GRAPH_TRACER |
| 54 | select HAVE_ARCH_KGDB | 56 | select HAVE_ARCH_KGDB |
| 55 | select HAVE_HW_BREAKPOINT | 57 | select HAVE_HW_BREAKPOINT |
diff --git a/arch/sh/include/asm/unistd.h b/arch/sh/include/asm/unistd.h index e800a38c9f8d..7bc67076baac 100644 --- a/arch/sh/include/asm/unistd.h +++ b/arch/sh/include/asm/unistd.h | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | # endif | 6 | # endif |
| 7 | 7 | ||
| 8 | # define __ARCH_WANT_SYS_RT_SIGSUSPEND | 8 | # define __ARCH_WANT_SYS_RT_SIGSUSPEND |
| 9 | # define __ARCH_WANT_IPC_PARSE_VERSION | ||
| 10 | # define __ARCH_WANT_OLD_READDIR | 9 | # define __ARCH_WANT_OLD_READDIR |
| 11 | # define __ARCH_WANT_OLD_STAT | 10 | # define __ARCH_WANT_OLD_STAT |
| 12 | # define __ARCH_WANT_STAT64 | 11 | # define __ARCH_WANT_STAT64 |
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index e74ff1377626..67f1f6f5f4e1 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig | |||
| @@ -27,6 +27,7 @@ config SPARC | |||
| 27 | select HAVE_ARCH_JUMP_LABEL | 27 | select HAVE_ARCH_JUMP_LABEL |
| 28 | select HAVE_GENERIC_HARDIRQS | 28 | select HAVE_GENERIC_HARDIRQS |
| 29 | select GENERIC_IRQ_SHOW | 29 | select GENERIC_IRQ_SHOW |
| 30 | select ARCH_WANT_IPC_PARSE_VERSION | ||
| 30 | select USE_GENERIC_SMP_HELPERS if SMP | 31 | select USE_GENERIC_SMP_HELPERS if SMP |
| 31 | select GENERIC_PCI_IOMAP | 32 | select GENERIC_PCI_IOMAP |
| 32 | select HAVE_NMI_WATCHDOG if SPARC64 | 33 | select HAVE_NMI_WATCHDOG if SPARC64 |
diff --git a/arch/sparc/include/asm/unistd.h b/arch/sparc/include/asm/unistd.h index c7cb0af0eb59..fb2693464807 100644 --- a/arch/sparc/include/asm/unistd.h +++ b/arch/sparc/include/asm/unistd.h | |||
| @@ -423,7 +423,6 @@ | |||
| 423 | #endif | 423 | #endif |
| 424 | 424 | ||
| 425 | #ifdef __KERNEL__ | 425 | #ifdef __KERNEL__ |
| 426 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
| 427 | #define __ARCH_WANT_OLD_READDIR | 426 | #define __ARCH_WANT_OLD_READDIR |
| 428 | #define __ARCH_WANT_STAT64 | 427 | #define __ARCH_WANT_STAT64 |
| 429 | #define __ARCH_WANT_SYS_ALARM | 428 | #define __ARCH_WANT_SYS_ALARM |
diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c index c38e5aaae56f..0dc1f5786081 100644 --- a/arch/sparc/kernel/sys_sparc_64.c +++ b/arch/sparc/kernel/sys_sparc_64.c | |||
| @@ -470,7 +470,7 @@ SYSCALL_DEFINE6(sparc_ipc, unsigned int, call, int, first, unsigned long, second | |||
| 470 | switch (call) { | 470 | switch (call) { |
| 471 | case SHMAT: { | 471 | case SHMAT: { |
| 472 | ulong raddr; | 472 | ulong raddr; |
| 473 | err = do_shmat(first, ptr, (int)second, &raddr); | 473 | err = do_shmat(first, ptr, (int)second, &raddr, SHMLBA); |
| 474 | if (!err) { | 474 | if (!err) { |
| 475 | if (put_user(raddr, | 475 | if (put_user(raddr, |
| 476 | (ulong __user *) third)) | 476 | (ulong __user *) third)) |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index c70684f859e1..ba2657c49217 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
| @@ -70,6 +70,7 @@ config X86 | |||
| 70 | select HAVE_ARCH_JUMP_LABEL | 70 | select HAVE_ARCH_JUMP_LABEL |
| 71 | select HAVE_TEXT_POKE_SMP | 71 | select HAVE_TEXT_POKE_SMP |
| 72 | select HAVE_GENERIC_HARDIRQS | 72 | select HAVE_GENERIC_HARDIRQS |
| 73 | select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE | ||
| 73 | select SPARSE_IRQ | 74 | select SPARSE_IRQ |
| 74 | select GENERIC_FIND_FIRST_BIT | 75 | select GENERIC_FIND_FIRST_BIT |
| 75 | select GENERIC_IRQ_PROBE | 76 | select GENERIC_IRQ_PROBE |
| @@ -84,6 +85,7 @@ config X86 | |||
| 84 | select GENERIC_IOMAP | 85 | select GENERIC_IOMAP |
| 85 | select DCACHE_WORD_ACCESS | 86 | select DCACHE_WORD_ACCESS |
| 86 | select GENERIC_SMP_IDLE_THREAD | 87 | select GENERIC_SMP_IDLE_THREAD |
| 88 | select ARCH_WANT_IPC_PARSE_VERSION if X86_32 | ||
| 87 | select HAVE_ARCH_SECCOMP_FILTER | 89 | select HAVE_ARCH_SECCOMP_FILTER |
| 88 | select BUILDTIME_EXTABLE_SORT | 90 | select BUILDTIME_EXTABLE_SORT |
| 89 | select GENERIC_CMOS_UPDATE | 91 | select GENERIC_CMOS_UPDATE |
diff --git a/arch/x86/include/asm/unistd.h b/arch/x86/include/asm/unistd.h index 4437001d8e3d..0d9776e9e2dc 100644 --- a/arch/x86/include/asm/unistd.h +++ b/arch/x86/include/asm/unistd.h | |||
| @@ -15,7 +15,6 @@ | |||
| 15 | # ifdef CONFIG_X86_32 | 15 | # ifdef CONFIG_X86_32 |
| 16 | 16 | ||
| 17 | # include <asm/unistd_32.h> | 17 | # include <asm/unistd_32.h> |
| 18 | # define __ARCH_WANT_IPC_PARSE_VERSION | ||
| 19 | # define __ARCH_WANT_STAT64 | 18 | # define __ARCH_WANT_STAT64 |
| 20 | # define __ARCH_WANT_SYS_IPC | 19 | # define __ARCH_WANT_SYS_IPC |
| 21 | # define __ARCH_WANT_SYS_OLD_MMAP | 20 | # define __ARCH_WANT_SYS_OLD_MMAP |
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 41857970517f..ed858e9e9a74 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c | |||
| @@ -944,7 +944,7 @@ void __init e820_reserve_resources(void) | |||
| 944 | for (i = 0; i < e820_saved.nr_map; i++) { | 944 | for (i = 0; i < e820_saved.nr_map; i++) { |
| 945 | struct e820entry *entry = &e820_saved.map[i]; | 945 | struct e820entry *entry = &e820_saved.map[i]; |
| 946 | firmware_map_add_early(entry->addr, | 946 | firmware_map_add_early(entry->addr, |
| 947 | entry->addr + entry->size - 1, | 947 | entry->addr + entry->size, |
| 948 | e820_type_to_string(entry->type)); | 948 | e820_type_to_string(entry->type)); |
| 949 | } | 949 | } |
| 950 | } | 950 | } |
diff --git a/arch/xtensa/kernel/syscall.c b/arch/xtensa/kernel/syscall.c index 816e6d0d686c..05b3f093d5d7 100644 --- a/arch/xtensa/kernel/syscall.c +++ b/arch/xtensa/kernel/syscall.c | |||
| @@ -44,7 +44,7 @@ asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg) | |||
| 44 | unsigned long ret; | 44 | unsigned long ret; |
| 45 | long err; | 45 | long err; |
| 46 | 46 | ||
| 47 | err = do_shmat(shmid, shmaddr, shmflg, &ret); | 47 | err = do_shmat(shmid, shmaddr, shmflg, &ret, SHMLBA); |
| 48 | if (err) | 48 | if (err) |
| 49 | return err; | 49 | return err; |
| 50 | return (long)ret; | 50 | return (long)ret; |
diff --git a/arch/xtensa/mm/fault.c b/arch/xtensa/mm/fault.c index b17885a0b508..5a74c53bc69c 100644 --- a/arch/xtensa/mm/fault.c +++ b/arch/xtensa/mm/fault.c | |||
| @@ -44,6 +44,7 @@ void do_page_fault(struct pt_regs *regs) | |||
| 44 | 44 | ||
| 45 | int is_write, is_exec; | 45 | int is_write, is_exec; |
| 46 | int fault; | 46 | int fault; |
| 47 | unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; | ||
| 47 | 48 | ||
| 48 | info.si_code = SEGV_MAPERR; | 49 | info.si_code = SEGV_MAPERR; |
| 49 | 50 | ||
| @@ -71,6 +72,7 @@ void do_page_fault(struct pt_regs *regs) | |||
| 71 | address, exccause, regs->pc, is_write? "w":"", is_exec? "x":""); | 72 | address, exccause, regs->pc, is_write? "w":"", is_exec? "x":""); |
| 72 | #endif | 73 | #endif |
| 73 | 74 | ||
| 75 | retry: | ||
| 74 | down_read(&mm->mmap_sem); | 76 | down_read(&mm->mmap_sem); |
| 75 | vma = find_vma(mm, address); | 77 | vma = find_vma(mm, address); |
| 76 | 78 | ||
| @@ -93,6 +95,7 @@ good_area: | |||
| 93 | if (is_write) { | 95 | if (is_write) { |
| 94 | if (!(vma->vm_flags & VM_WRITE)) | 96 | if (!(vma->vm_flags & VM_WRITE)) |
| 95 | goto bad_area; | 97 | goto bad_area; |
| 98 | flags |= FAULT_FLAG_WRITE; | ||
| 96 | } else if (is_exec) { | 99 | } else if (is_exec) { |
| 97 | if (!(vma->vm_flags & VM_EXEC)) | 100 | if (!(vma->vm_flags & VM_EXEC)) |
| 98 | goto bad_area; | 101 | goto bad_area; |
| @@ -104,7 +107,11 @@ good_area: | |||
| 104 | * make sure we exit gracefully rather than endlessly redo | 107 | * make sure we exit gracefully rather than endlessly redo |
| 105 | * the fault. | 108 | * the fault. |
| 106 | */ | 109 | */ |
| 107 | fault = handle_mm_fault(mm, vma, address, is_write ? FAULT_FLAG_WRITE : 0); | 110 | fault = handle_mm_fault(mm, vma, address, flags); |
| 111 | |||
| 112 | if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) | ||
| 113 | return; | ||
| 114 | |||
| 108 | if (unlikely(fault & VM_FAULT_ERROR)) { | 115 | if (unlikely(fault & VM_FAULT_ERROR)) { |
| 109 | if (fault & VM_FAULT_OOM) | 116 | if (fault & VM_FAULT_OOM) |
| 110 | goto out_of_memory; | 117 | goto out_of_memory; |
| @@ -112,10 +119,22 @@ good_area: | |||
| 112 | goto do_sigbus; | 119 | goto do_sigbus; |
| 113 | BUG(); | 120 | BUG(); |
| 114 | } | 121 | } |
| 115 | if (fault & VM_FAULT_MAJOR) | 122 | if (flags & FAULT_FLAG_ALLOW_RETRY) { |
| 116 | current->maj_flt++; | 123 | if (fault & VM_FAULT_MAJOR) |
| 117 | else | 124 | current->maj_flt++; |
| 118 | current->min_flt++; | 125 | else |
| 126 | current->min_flt++; | ||
| 127 | if (fault & VM_FAULT_RETRY) { | ||
| 128 | flags &= ~FAULT_FLAG_ALLOW_RETRY; | ||
| 129 | |||
| 130 | /* No need to up_read(&mm->mmap_sem) as we would | ||
| 131 | * have already released it in __lock_page_or_retry | ||
| 132 | * in mm/filemap.c. | ||
| 133 | */ | ||
| 134 | |||
| 135 | goto retry; | ||
| 136 | } | ||
| 137 | } | ||
| 119 | 138 | ||
| 120 | up_read(&mm->mmap_sem); | 139 | up_read(&mm->mmap_sem); |
| 121 | return; | 140 | return; |
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c index ac6a5beb28f3..bfaa5cb1629a 100644 --- a/drivers/ata/pata_arasan_cf.c +++ b/drivers/ata/pata_arasan_cf.c | |||
| @@ -184,10 +184,8 @@ | |||
| 184 | struct arasan_cf_dev { | 184 | struct arasan_cf_dev { |
| 185 | /* pointer to ata_host structure */ | 185 | /* pointer to ata_host structure */ |
| 186 | struct ata_host *host; | 186 | struct ata_host *host; |
| 187 | /* clk structure, only if HAVE_CLK is defined */ | 187 | /* clk structure */ |
| 188 | #ifdef CONFIG_HAVE_CLK | ||
| 189 | struct clk *clk; | 188 | struct clk *clk; |
| 190 | #endif | ||
| 191 | 189 | ||
| 192 | /* physical base address of controller */ | 190 | /* physical base address of controller */ |
| 193 | dma_addr_t pbase; | 191 | dma_addr_t pbase; |
| @@ -312,13 +310,11 @@ static int cf_init(struct arasan_cf_dev *acdev) | |||
| 312 | unsigned long flags; | 310 | unsigned long flags; |
| 313 | int ret = 0; | 311 | int ret = 0; |
| 314 | 312 | ||
| 315 | #ifdef CONFIG_HAVE_CLK | ||
| 316 | ret = clk_enable(acdev->clk); | 313 | ret = clk_enable(acdev->clk); |
| 317 | if (ret) { | 314 | if (ret) { |
| 318 | dev_dbg(acdev->host->dev, "clock enable failed"); | 315 | dev_dbg(acdev->host->dev, "clock enable failed"); |
| 319 | return ret; | 316 | return ret; |
| 320 | } | 317 | } |
| 321 | #endif | ||
| 322 | 318 | ||
| 323 | spin_lock_irqsave(&acdev->host->lock, flags); | 319 | spin_lock_irqsave(&acdev->host->lock, flags); |
| 324 | /* configure CF interface clock */ | 320 | /* configure CF interface clock */ |
| @@ -344,9 +340,7 @@ static void cf_exit(struct arasan_cf_dev *acdev) | |||
| 344 | writel(readl(acdev->vbase + OP_MODE) & ~CFHOST_ENB, | 340 | writel(readl(acdev->vbase + OP_MODE) & ~CFHOST_ENB, |
| 345 | acdev->vbase + OP_MODE); | 341 | acdev->vbase + OP_MODE); |
| 346 | spin_unlock_irqrestore(&acdev->host->lock, flags); | 342 | spin_unlock_irqrestore(&acdev->host->lock, flags); |
| 347 | #ifdef CONFIG_HAVE_CLK | ||
| 348 | clk_disable(acdev->clk); | 343 | clk_disable(acdev->clk); |
| 349 | #endif | ||
| 350 | } | 344 | } |
| 351 | 345 | ||
| 352 | static void dma_callback(void *dev) | 346 | static void dma_callback(void *dev) |
| @@ -828,13 +822,11 @@ static int __devinit arasan_cf_probe(struct platform_device *pdev) | |||
| 828 | return -ENOMEM; | 822 | return -ENOMEM; |
| 829 | } | 823 | } |
| 830 | 824 | ||
| 831 | #ifdef CONFIG_HAVE_CLK | ||
| 832 | acdev->clk = clk_get(&pdev->dev, NULL); | 825 | acdev->clk = clk_get(&pdev->dev, NULL); |
| 833 | if (IS_ERR(acdev->clk)) { | 826 | if (IS_ERR(acdev->clk)) { |
| 834 | dev_warn(&pdev->dev, "Clock not found\n"); | 827 | dev_warn(&pdev->dev, "Clock not found\n"); |
| 835 | return PTR_ERR(acdev->clk); | 828 | return PTR_ERR(acdev->clk); |
| 836 | } | 829 | } |
| 837 | #endif | ||
| 838 | 830 | ||
| 839 | /* allocate host */ | 831 | /* allocate host */ |
| 840 | host = ata_host_alloc(&pdev->dev, 1); | 832 | host = ata_host_alloc(&pdev->dev, 1); |
| @@ -899,9 +891,7 @@ static int __devinit arasan_cf_probe(struct platform_device *pdev) | |||
| 899 | &arasan_cf_sht); | 891 | &arasan_cf_sht); |
| 900 | 892 | ||
| 901 | free_clk: | 893 | free_clk: |
| 902 | #ifdef CONFIG_HAVE_CLK | ||
| 903 | clk_put(acdev->clk); | 894 | clk_put(acdev->clk); |
| 904 | #endif | ||
| 905 | return ret; | 895 | return ret; |
| 906 | } | 896 | } |
| 907 | 897 | ||
| @@ -912,9 +902,7 @@ static int __devexit arasan_cf_remove(struct platform_device *pdev) | |||
| 912 | 902 | ||
| 913 | ata_host_detach(host); | 903 | ata_host_detach(host); |
| 914 | cf_exit(acdev); | 904 | cf_exit(acdev); |
| 915 | #ifdef CONFIG_HAVE_CLK | ||
| 916 | clk_put(acdev->clk); | 905 | clk_put(acdev->clk); |
| 917 | #endif | ||
| 918 | 906 | ||
| 919 | return 0; | 907 | return 0; |
| 920 | } | 908 | } |
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 3f99b9099658..7f0b5ca78516 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig | |||
| @@ -25,7 +25,6 @@ menu "Common Clock Framework" | |||
| 25 | 25 | ||
| 26 | config COMMON_CLK_DEBUG | 26 | config COMMON_CLK_DEBUG |
| 27 | bool "DebugFS representation of clock tree" | 27 | bool "DebugFS representation of clock tree" |
| 28 | depends on COMMON_CLK | ||
| 29 | select DEBUG_FS | 28 | select DEBUG_FS |
| 30 | ---help--- | 29 | ---help--- |
| 31 | Creates a directory hierchy in debugfs for visualizing the clk | 30 | Creates a directory hierchy in debugfs for visualizing the clk |
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index c87fdd710560..efdfd009c270 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c | |||
| @@ -465,6 +465,9 @@ static void __clk_disable(struct clk *clk) | |||
| 465 | if (!clk) | 465 | if (!clk) |
| 466 | return; | 466 | return; |
| 467 | 467 | ||
| 468 | if (WARN_ON(IS_ERR(clk))) | ||
| 469 | return; | ||
| 470 | |||
| 468 | if (WARN_ON(clk->enable_count == 0)) | 471 | if (WARN_ON(clk->enable_count == 0)) |
| 469 | return; | 472 | return; |
| 470 | 473 | ||
diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c index adc07102a20d..c1cdc9236666 100644 --- a/drivers/firmware/memmap.c +++ b/drivers/firmware/memmap.c | |||
| @@ -98,7 +98,7 @@ static LIST_HEAD(map_entries); | |||
| 98 | /** | 98 | /** |
| 99 | * firmware_map_add_entry() - Does the real work to add a firmware memmap entry. | 99 | * firmware_map_add_entry() - Does the real work to add a firmware memmap entry. |
| 100 | * @start: Start of the memory range. | 100 | * @start: Start of the memory range. |
| 101 | * @end: End of the memory range (inclusive). | 101 | * @end: End of the memory range (exclusive). |
| 102 | * @type: Type of the memory range. | 102 | * @type: Type of the memory range. |
| 103 | * @entry: Pre-allocated (either kmalloc() or bootmem allocator), uninitialised | 103 | * @entry: Pre-allocated (either kmalloc() or bootmem allocator), uninitialised |
| 104 | * entry. | 104 | * entry. |
| @@ -113,7 +113,7 @@ static int firmware_map_add_entry(u64 start, u64 end, | |||
| 113 | BUG_ON(start > end); | 113 | BUG_ON(start > end); |
| 114 | 114 | ||
| 115 | entry->start = start; | 115 | entry->start = start; |
| 116 | entry->end = end; | 116 | entry->end = end - 1; |
| 117 | entry->type = type; | 117 | entry->type = type; |
| 118 | INIT_LIST_HEAD(&entry->list); | 118 | INIT_LIST_HEAD(&entry->list); |
| 119 | kobject_init(&entry->kobj, &memmap_ktype); | 119 | kobject_init(&entry->kobj, &memmap_ktype); |
| @@ -148,7 +148,7 @@ static int add_sysfs_fw_map_entry(struct firmware_map_entry *entry) | |||
| 148 | * firmware_map_add_hotplug() - Adds a firmware mapping entry when we do | 148 | * firmware_map_add_hotplug() - Adds a firmware mapping entry when we do |
| 149 | * memory hotplug. | 149 | * memory hotplug. |
| 150 | * @start: Start of the memory range. | 150 | * @start: Start of the memory range. |
| 151 | * @end: End of the memory range (inclusive). | 151 | * @end: End of the memory range (exclusive) |
| 152 | * @type: Type of the memory range. | 152 | * @type: Type of the memory range. |
| 153 | * | 153 | * |
| 154 | * Adds a firmware mapping entry. This function is for memory hotplug, it is | 154 | * Adds a firmware mapping entry. This function is for memory hotplug, it is |
| @@ -175,7 +175,7 @@ int __meminit firmware_map_add_hotplug(u64 start, u64 end, const char *type) | |||
| 175 | /** | 175 | /** |
| 176 | * firmware_map_add_early() - Adds a firmware mapping entry. | 176 | * firmware_map_add_early() - Adds a firmware mapping entry. |
| 177 | * @start: Start of the memory range. | 177 | * @start: Start of the memory range. |
| 178 | * @end: End of the memory range (inclusive). | 178 | * @end: End of the memory range. |
| 179 | * @type: Type of the memory range. | 179 | * @type: Type of the memory range. |
| 180 | * | 180 | * |
| 181 | * Adds a firmware mapping entry. This function uses the bootmem allocator | 181 | * Adds a firmware mapping entry. This function uses the bootmem allocator |
diff --git a/drivers/firmware/pcdp.c b/drivers/firmware/pcdp.c index 51e0e2d8fac6..a330492e06f9 100644 --- a/drivers/firmware/pcdp.c +++ b/drivers/firmware/pcdp.c | |||
| @@ -95,7 +95,7 @@ efi_setup_pcdp_console(char *cmdline) | |||
| 95 | if (efi.hcdp == EFI_INVALID_TABLE_ADDR) | 95 | if (efi.hcdp == EFI_INVALID_TABLE_ADDR) |
| 96 | return -ENODEV; | 96 | return -ENODEV; |
| 97 | 97 | ||
| 98 | pcdp = ioremap(efi.hcdp, 4096); | 98 | pcdp = early_ioremap(efi.hcdp, 4096); |
| 99 | printk(KERN_INFO "PCDP: v%d at 0x%lx\n", pcdp->rev, efi.hcdp); | 99 | printk(KERN_INFO "PCDP: v%d at 0x%lx\n", pcdp->rev, efi.hcdp); |
| 100 | 100 | ||
| 101 | if (strstr(cmdline, "console=hcdp")) { | 101 | if (strstr(cmdline, "console=hcdp")) { |
| @@ -131,6 +131,6 @@ efi_setup_pcdp_console(char *cmdline) | |||
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | out: | 133 | out: |
| 134 | iounmap(pcdp); | 134 | early_iounmap(pcdp, 4096); |
| 135 | return rc; | 135 | return rc; |
| 136 | } | 136 | } |
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index a997c7d3f95d..1034d93fb838 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c | |||
| @@ -41,13 +41,6 @@ | |||
| 41 | 41 | ||
| 42 | #include <asm/irq.h> | 42 | #include <asm/irq.h> |
| 43 | 43 | ||
| 44 | #ifndef CONFIG_HAVE_CLK | ||
| 45 | #define clk_get(dev, id) NULL | ||
| 46 | #define clk_put(clk) do { } while (0) | ||
| 47 | #define clk_disable(clk) do { } while (0) | ||
| 48 | #define clk_enable(clk) do { } while (0) | ||
| 49 | #endif | ||
| 50 | |||
| 51 | struct pxa_reg_layout { | 44 | struct pxa_reg_layout { |
| 52 | u32 ibmr; | 45 | u32 ibmr; |
| 53 | u32 idbr; | 46 | u32 idbr; |
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c index 65ebaebf502b..627d19186d5a 100644 --- a/drivers/md/dm-log.c +++ b/drivers/md/dm-log.c | |||
| @@ -571,16 +571,6 @@ static void disk_dtr(struct dm_dirty_log *log) | |||
| 571 | destroy_log_context(lc); | 571 | destroy_log_context(lc); |
| 572 | } | 572 | } |
| 573 | 573 | ||
| 574 | static int count_bits32(uint32_t *addr, unsigned size) | ||
| 575 | { | ||
| 576 | int count = 0, i; | ||
| 577 | |||
| 578 | for (i = 0; i < size; i++) { | ||
| 579 | count += hweight32(*(addr+i)); | ||
| 580 | } | ||
| 581 | return count; | ||
| 582 | } | ||
| 583 | |||
| 584 | static void fail_log_device(struct log_c *lc) | 574 | static void fail_log_device(struct log_c *lc) |
| 585 | { | 575 | { |
| 586 | if (lc->log_dev_failed) | 576 | if (lc->log_dev_failed) |
| @@ -629,7 +619,8 @@ static int disk_resume(struct dm_dirty_log *log) | |||
| 629 | 619 | ||
| 630 | /* copy clean across to sync */ | 620 | /* copy clean across to sync */ |
| 631 | memcpy(lc->sync_bits, lc->clean_bits, size); | 621 | memcpy(lc->sync_bits, lc->clean_bits, size); |
| 632 | lc->sync_count = count_bits32(lc->clean_bits, lc->bitset_uint32_count); | 622 | lc->sync_count = memweight(lc->clean_bits, |
| 623 | lc->bitset_uint32_count * sizeof(uint32_t)); | ||
| 633 | lc->sync_search = 0; | 624 | lc->sync_search = 0; |
| 634 | 625 | ||
| 635 | /* set the correct number of regions in the header */ | 626 | /* set the correct number of regions in the header */ |
diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c index af26bbe6f76e..f7061a5ef1d2 100644 --- a/drivers/media/video/uvc/uvc_ctrl.c +++ b/drivers/media/video/uvc/uvc_ctrl.c | |||
| @@ -2083,7 +2083,7 @@ int uvc_ctrl_init_device(struct uvc_device *dev) | |||
| 2083 | /* Walk the entities list and instantiate controls */ | 2083 | /* Walk the entities list and instantiate controls */ |
| 2084 | list_for_each_entry(entity, &dev->entities, list) { | 2084 | list_for_each_entry(entity, &dev->entities, list) { |
| 2085 | struct uvc_control *ctrl; | 2085 | struct uvc_control *ctrl; |
| 2086 | unsigned int bControlSize = 0, ncontrols = 0; | 2086 | unsigned int bControlSize = 0, ncontrols; |
| 2087 | __u8 *bmControls = NULL; | 2087 | __u8 *bmControls = NULL; |
| 2088 | 2088 | ||
| 2089 | if (UVC_ENTITY_TYPE(entity) == UVC_VC_EXTENSION_UNIT) { | 2089 | if (UVC_ENTITY_TYPE(entity) == UVC_VC_EXTENSION_UNIT) { |
| @@ -2101,8 +2101,7 @@ int uvc_ctrl_init_device(struct uvc_device *dev) | |||
| 2101 | uvc_ctrl_prune_entity(dev, entity); | 2101 | uvc_ctrl_prune_entity(dev, entity); |
| 2102 | 2102 | ||
| 2103 | /* Count supported controls and allocate the controls array */ | 2103 | /* Count supported controls and allocate the controls array */ |
| 2104 | for (i = 0; i < bControlSize; ++i) | 2104 | ncontrols = memweight(bmControls, bControlSize); |
| 2105 | ncontrols += hweight8(bmControls[i]); | ||
| 2106 | if (ncontrols == 0) | 2105 | if (ncontrols == 0) |
| 2107 | continue; | 2106 | continue; |
| 2108 | 2107 | ||
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c index 098de2b35784..9a49c243a6ac 100644 --- a/drivers/message/i2o/i2o_config.c +++ b/drivers/message/i2o/i2o_config.c | |||
| @@ -188,6 +188,13 @@ static int i2o_cfg_parms(unsigned long arg, unsigned int type) | |||
| 188 | if (!dev) | 188 | if (!dev) |
| 189 | return -ENXIO; | 189 | return -ENXIO; |
| 190 | 190 | ||
| 191 | /* | ||
| 192 | * Stop users being able to try and allocate arbitary amounts | ||
| 193 | * of DMA space. 64K is way more than sufficient for this. | ||
| 194 | */ | ||
| 195 | if (kcmd.oplen > 65536) | ||
| 196 | return -EMSGSIZE; | ||
| 197 | |||
| 191 | ops = memdup_user(kcmd.opbuf, kcmd.oplen); | 198 | ops = memdup_user(kcmd.opbuf, kcmd.oplen); |
| 192 | if (IS_ERR(ops)) | 199 | if (IS_ERR(ops)) |
| 193 | return PTR_ERR(ops); | 200 | return PTR_ERR(ops); |
diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c index 506c36f6e1db..8001aa6bfb48 100644 --- a/drivers/message/i2o/i2o_proc.c +++ b/drivers/message/i2o/i2o_proc.c | |||
| @@ -255,9 +255,8 @@ static char *scsi_devices[] = { | |||
| 255 | "Array Controller Device" | 255 | "Array Controller Device" |
| 256 | }; | 256 | }; |
| 257 | 257 | ||
| 258 | static char *chtostr(u8 * chars, int n) | 258 | static char *chtostr(char *tmp, u8 *chars, int n) |
| 259 | { | 259 | { |
| 260 | char tmp[256]; | ||
| 261 | tmp[0] = 0; | 260 | tmp[0] = 0; |
| 262 | return strncat(tmp, (char *)chars, n); | 261 | return strncat(tmp, (char *)chars, n); |
| 263 | } | 262 | } |
| @@ -791,6 +790,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v) | |||
| 791 | } *result; | 790 | } *result; |
| 792 | 791 | ||
| 793 | i2o_exec_execute_ddm_table ddm_table; | 792 | i2o_exec_execute_ddm_table ddm_table; |
| 793 | char tmp[28 + 1]; | ||
| 794 | 794 | ||
| 795 | result = kmalloc(sizeof(*result), GFP_KERNEL); | 795 | result = kmalloc(sizeof(*result), GFP_KERNEL); |
| 796 | if (!result) | 796 | if (!result) |
| @@ -826,7 +826,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v) | |||
| 826 | seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id); | 826 | seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id); |
| 827 | seq_printf(seq, "%-#8x", ddm_table.module_id); | 827 | seq_printf(seq, "%-#8x", ddm_table.module_id); |
| 828 | seq_printf(seq, "%-29s", | 828 | seq_printf(seq, "%-29s", |
| 829 | chtostr(ddm_table.module_name_version, 28)); | 829 | chtostr(tmp, ddm_table.module_name_version, 28)); |
| 830 | seq_printf(seq, "%9d ", ddm_table.data_size); | 830 | seq_printf(seq, "%9d ", ddm_table.data_size); |
| 831 | seq_printf(seq, "%8d", ddm_table.code_size); | 831 | seq_printf(seq, "%8d", ddm_table.code_size); |
| 832 | 832 | ||
| @@ -893,6 +893,7 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v) | |||
| 893 | 893 | ||
| 894 | i2o_driver_result_table *result; | 894 | i2o_driver_result_table *result; |
| 895 | i2o_driver_store_table *dst; | 895 | i2o_driver_store_table *dst; |
| 896 | char tmp[28 + 1]; | ||
| 896 | 897 | ||
| 897 | result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL); | 898 | result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL); |
| 898 | if (result == NULL) | 899 | if (result == NULL) |
| @@ -927,8 +928,9 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v) | |||
| 927 | 928 | ||
| 928 | seq_printf(seq, "%-#7x", dst->i2o_vendor_id); | 929 | seq_printf(seq, "%-#7x", dst->i2o_vendor_id); |
| 929 | seq_printf(seq, "%-#8x", dst->module_id); | 930 | seq_printf(seq, "%-#8x", dst->module_id); |
| 930 | seq_printf(seq, "%-29s", chtostr(dst->module_name_version, 28)); | 931 | seq_printf(seq, "%-29s", |
| 931 | seq_printf(seq, "%-9s", chtostr(dst->date, 8)); | 932 | chtostr(tmp, dst->module_name_version, 28)); |
| 933 | seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8)); | ||
| 932 | seq_printf(seq, "%8d ", dst->module_size); | 934 | seq_printf(seq, "%8d ", dst->module_size); |
| 933 | seq_printf(seq, "%8d ", dst->mpb_size); | 935 | seq_printf(seq, "%8d ", dst->mpb_size); |
| 934 | seq_printf(seq, "0x%04x", dst->module_flags); | 936 | seq_printf(seq, "0x%04x", dst->module_flags); |
| @@ -1248,6 +1250,7 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v) | |||
| 1248 | // == (allow) 512d bytes (max) | 1250 | // == (allow) 512d bytes (max) |
| 1249 | static u16 *work16 = (u16 *) work32; | 1251 | static u16 *work16 = (u16 *) work32; |
| 1250 | int token; | 1252 | int token; |
| 1253 | char tmp[16 + 1]; | ||
| 1251 | 1254 | ||
| 1252 | token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32)); | 1255 | token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32)); |
| 1253 | 1256 | ||
| @@ -1260,13 +1263,13 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v) | |||
| 1260 | seq_printf(seq, "Owner TID : %0#5x\n", work16[2]); | 1263 | seq_printf(seq, "Owner TID : %0#5x\n", work16[2]); |
| 1261 | seq_printf(seq, "Parent TID : %0#5x\n", work16[3]); | 1264 | seq_printf(seq, "Parent TID : %0#5x\n", work16[3]); |
| 1262 | seq_printf(seq, "Vendor info : %s\n", | 1265 | seq_printf(seq, "Vendor info : %s\n", |
| 1263 | chtostr((u8 *) (work32 + 2), 16)); | 1266 | chtostr(tmp, (u8 *) (work32 + 2), 16)); |
| 1264 | seq_printf(seq, "Product info : %s\n", | 1267 | seq_printf(seq, "Product info : %s\n", |
| 1265 | chtostr((u8 *) (work32 + 6), 16)); | 1268 | chtostr(tmp, (u8 *) (work32 + 6), 16)); |
| 1266 | seq_printf(seq, "Description : %s\n", | 1269 | seq_printf(seq, "Description : %s\n", |
| 1267 | chtostr((u8 *) (work32 + 10), 16)); | 1270 | chtostr(tmp, (u8 *) (work32 + 10), 16)); |
| 1268 | seq_printf(seq, "Product rev. : %s\n", | 1271 | seq_printf(seq, "Product rev. : %s\n", |
| 1269 | chtostr((u8 *) (work32 + 14), 8)); | 1272 | chtostr(tmp, (u8 *) (work32 + 14), 8)); |
| 1270 | 1273 | ||
| 1271 | seq_printf(seq, "Serial number : "); | 1274 | seq_printf(seq, "Serial number : "); |
| 1272 | print_serial_number(seq, (u8 *) (work32 + 16), | 1275 | print_serial_number(seq, (u8 *) (work32 + 16), |
| @@ -1303,6 +1306,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v) | |||
| 1303 | u8 pad[256]; // allow up to 256 byte (max) serial number | 1306 | u8 pad[256]; // allow up to 256 byte (max) serial number |
| 1304 | } result; | 1307 | } result; |
| 1305 | 1308 | ||
| 1309 | char tmp[24 + 1]; | ||
| 1310 | |||
| 1306 | token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result)); | 1311 | token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result)); |
| 1307 | 1312 | ||
| 1308 | if (token < 0) { | 1313 | if (token < 0) { |
| @@ -1312,9 +1317,9 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v) | |||
| 1312 | 1317 | ||
| 1313 | seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid); | 1318 | seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid); |
| 1314 | seq_printf(seq, "Module name : %s\n", | 1319 | seq_printf(seq, "Module name : %s\n", |
| 1315 | chtostr(result.module_name, 24)); | 1320 | chtostr(tmp, result.module_name, 24)); |
| 1316 | seq_printf(seq, "Module revision : %s\n", | 1321 | seq_printf(seq, "Module revision : %s\n", |
| 1317 | chtostr(result.module_rev, 8)); | 1322 | chtostr(tmp, result.module_rev, 8)); |
| 1318 | 1323 | ||
| 1319 | seq_printf(seq, "Serial number : "); | 1324 | seq_printf(seq, "Serial number : "); |
| 1320 | print_serial_number(seq, result.serial_number, sizeof(result) - 36); | 1325 | print_serial_number(seq, result.serial_number, sizeof(result) - 36); |
| @@ -1338,6 +1343,8 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v) | |||
| 1338 | u8 instance_number[4]; | 1343 | u8 instance_number[4]; |
| 1339 | } result; | 1344 | } result; |
| 1340 | 1345 | ||
| 1346 | char tmp[64 + 1]; | ||
| 1347 | |||
| 1341 | token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result)); | 1348 | token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result)); |
| 1342 | 1349 | ||
| 1343 | if (token < 0) { | 1350 | if (token < 0) { |
| @@ -1346,13 +1353,13 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v) | |||
| 1346 | } | 1353 | } |
| 1347 | 1354 | ||
| 1348 | seq_printf(seq, "Device name : %s\n", | 1355 | seq_printf(seq, "Device name : %s\n", |
| 1349 | chtostr(result.device_name, 64)); | 1356 | chtostr(tmp, result.device_name, 64)); |
| 1350 | seq_printf(seq, "Service name : %s\n", | 1357 | seq_printf(seq, "Service name : %s\n", |
| 1351 | chtostr(result.service_name, 64)); | 1358 | chtostr(tmp, result.service_name, 64)); |
| 1352 | seq_printf(seq, "Physical name : %s\n", | 1359 | seq_printf(seq, "Physical name : %s\n", |
| 1353 | chtostr(result.physical_location, 64)); | 1360 | chtostr(tmp, result.physical_location, 64)); |
| 1354 | seq_printf(seq, "Instance number : %s\n", | 1361 | seq_printf(seq, "Instance number : %s\n", |
| 1355 | chtostr(result.instance_number, 4)); | 1362 | chtostr(tmp, result.instance_number, 4)); |
| 1356 | 1363 | ||
| 1357 | return 0; | 1364 | return 0; |
| 1358 | } | 1365 | } |
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c index 28adefe70f96..08aad69c8da4 100644 --- a/drivers/misc/lkdtm.c +++ b/drivers/misc/lkdtm.c | |||
| @@ -477,6 +477,8 @@ static ssize_t lkdtm_debugfs_read(struct file *f, char __user *user_buf, | |||
| 477 | int i, n, out; | 477 | int i, n, out; |
| 478 | 478 | ||
| 479 | buf = (char *)__get_free_page(GFP_KERNEL); | 479 | buf = (char *)__get_free_page(GFP_KERNEL); |
| 480 | if (buf == NULL) | ||
| 481 | return -ENOMEM; | ||
| 480 | 482 | ||
| 481 | n = snprintf(buf, PAGE_SIZE, "Available crash types:\n"); | 483 | n = snprintf(buf, PAGE_SIZE, "Available crash types:\n"); |
| 482 | for (i = 0; i < ARRAY_SIZE(cp_type); i++) | 484 | for (i = 0; i < ARRAY_SIZE(cp_type); i++) |
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c index 2b62232c2c6a..acfaeeb9e01a 100644 --- a/drivers/misc/ti-st/st_core.c +++ b/drivers/misc/ti-st/st_core.c | |||
| @@ -349,6 +349,11 @@ void st_int_recv(void *disc_data, | |||
| 349 | st_gdata->rx_skb = alloc_skb( | 349 | st_gdata->rx_skb = alloc_skb( |
| 350 | st_gdata->list[type]->max_frame_size, | 350 | st_gdata->list[type]->max_frame_size, |
| 351 | GFP_ATOMIC); | 351 | GFP_ATOMIC); |
| 352 | if (st_gdata->rx_skb == NULL) { | ||
| 353 | pr_err("out of memory: dropping\n"); | ||
| 354 | goto done; | ||
| 355 | } | ||
| 356 | |||
| 352 | skb_reserve(st_gdata->rx_skb, | 357 | skb_reserve(st_gdata->rx_skb, |
| 353 | st_gdata->list[type]->reserve); | 358 | st_gdata->list[type]->reserve); |
| 354 | /* next 2 required for BT only */ | 359 | /* next 2 required for BT only */ |
diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c index f0921d16f0a9..6ff7ad006c30 100644 --- a/drivers/net/can/c_can/c_can_platform.c +++ b/drivers/net/can/c_can/c_can_platform.c | |||
| @@ -74,7 +74,6 @@ static int __devinit c_can_plat_probe(struct platform_device *pdev) | |||
| 74 | const struct platform_device_id *id; | 74 | const struct platform_device_id *id; |
| 75 | struct resource *mem; | 75 | struct resource *mem; |
| 76 | int irq; | 76 | int irq; |
| 77 | #ifdef CONFIG_HAVE_CLK | ||
| 78 | struct clk *clk; | 77 | struct clk *clk; |
| 79 | 78 | ||
| 80 | /* get the appropriate clk */ | 79 | /* get the appropriate clk */ |
| @@ -84,7 +83,6 @@ static int __devinit c_can_plat_probe(struct platform_device *pdev) | |||
| 84 | ret = -ENODEV; | 83 | ret = -ENODEV; |
| 85 | goto exit; | 84 | goto exit; |
| 86 | } | 85 | } |
| 87 | #endif | ||
| 88 | 86 | ||
| 89 | /* get the platform data */ | 87 | /* get the platform data */ |
| 90 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 88 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| @@ -145,10 +143,8 @@ static int __devinit c_can_plat_probe(struct platform_device *pdev) | |||
| 145 | 143 | ||
| 146 | dev->irq = irq; | 144 | dev->irq = irq; |
| 147 | priv->base = addr; | 145 | priv->base = addr; |
| 148 | #ifdef CONFIG_HAVE_CLK | ||
| 149 | priv->can.clock.freq = clk_get_rate(clk); | 146 | priv->can.clock.freq = clk_get_rate(clk); |
| 150 | priv->priv = clk; | 147 | priv->priv = clk; |
| 151 | #endif | ||
| 152 | 148 | ||
| 153 | platform_set_drvdata(pdev, dev); | 149 | platform_set_drvdata(pdev, dev); |
| 154 | SET_NETDEV_DEV(dev, &pdev->dev); | 150 | SET_NETDEV_DEV(dev, &pdev->dev); |
| @@ -172,10 +168,8 @@ exit_iounmap: | |||
| 172 | exit_release_mem: | 168 | exit_release_mem: |
| 173 | release_mem_region(mem->start, resource_size(mem)); | 169 | release_mem_region(mem->start, resource_size(mem)); |
| 174 | exit_free_clk: | 170 | exit_free_clk: |
| 175 | #ifdef CONFIG_HAVE_CLK | ||
| 176 | clk_put(clk); | 171 | clk_put(clk); |
| 177 | exit: | 172 | exit: |
| 178 | #endif | ||
| 179 | dev_err(&pdev->dev, "probe failed\n"); | 173 | dev_err(&pdev->dev, "probe failed\n"); |
| 180 | 174 | ||
| 181 | return ret; | 175 | return ret; |
| @@ -196,9 +190,7 @@ static int __devexit c_can_plat_remove(struct platform_device *pdev) | |||
| 196 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 190 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 197 | release_mem_region(mem->start, resource_size(mem)); | 191 | release_mem_region(mem->start, resource_size(mem)); |
| 198 | 192 | ||
| 199 | #ifdef CONFIG_HAVE_CLK | ||
| 200 | clk_put(priv->priv); | 193 | clk_put(priv->priv); |
| 201 | #endif | ||
| 202 | 194 | ||
| 203 | return 0; | 195 | return 0; |
| 204 | } | 196 | } |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index ab4c376cb276..f2d3665430ad 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h | |||
| @@ -82,9 +82,7 @@ struct stmmac_priv { | |||
| 82 | struct stmmac_counters mmc; | 82 | struct stmmac_counters mmc; |
| 83 | struct dma_features dma_cap; | 83 | struct dma_features dma_cap; |
| 84 | int hw_cap_support; | 84 | int hw_cap_support; |
| 85 | #ifdef CONFIG_HAVE_CLK | ||
| 86 | struct clk *stmmac_clk; | 85 | struct clk *stmmac_clk; |
| 87 | #endif | ||
| 88 | int clk_csr; | 86 | int clk_csr; |
| 89 | int synopsys_id; | 87 | int synopsys_id; |
| 90 | struct timer_list eee_ctrl_timer; | 88 | struct timer_list eee_ctrl_timer; |
| @@ -113,46 +111,6 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device, | |||
| 113 | void stmmac_disable_eee_mode(struct stmmac_priv *priv); | 111 | void stmmac_disable_eee_mode(struct stmmac_priv *priv); |
| 114 | bool stmmac_eee_init(struct stmmac_priv *priv); | 112 | bool stmmac_eee_init(struct stmmac_priv *priv); |
| 115 | 113 | ||
| 116 | #ifdef CONFIG_HAVE_CLK | ||
| 117 | static inline int stmmac_clk_enable(struct stmmac_priv *priv) | ||
| 118 | { | ||
| 119 | if (!IS_ERR(priv->stmmac_clk)) | ||
| 120 | return clk_prepare_enable(priv->stmmac_clk); | ||
| 121 | |||
| 122 | return 0; | ||
| 123 | } | ||
| 124 | |||
| 125 | static inline void stmmac_clk_disable(struct stmmac_priv *priv) | ||
| 126 | { | ||
| 127 | if (IS_ERR(priv->stmmac_clk)) | ||
| 128 | return; | ||
| 129 | |||
| 130 | clk_disable_unprepare(priv->stmmac_clk); | ||
| 131 | } | ||
| 132 | static inline int stmmac_clk_get(struct stmmac_priv *priv) | ||
| 133 | { | ||
| 134 | priv->stmmac_clk = clk_get(priv->device, NULL); | ||
| 135 | |||
| 136 | if (IS_ERR(priv->stmmac_clk)) | ||
| 137 | return PTR_ERR(priv->stmmac_clk); | ||
| 138 | |||
| 139 | return 0; | ||
| 140 | } | ||
| 141 | #else | ||
| 142 | static inline int stmmac_clk_enable(struct stmmac_priv *priv) | ||
| 143 | { | ||
| 144 | return 0; | ||
| 145 | } | ||
| 146 | static inline void stmmac_clk_disable(struct stmmac_priv *priv) | ||
| 147 | { | ||
| 148 | } | ||
| 149 | static inline int stmmac_clk_get(struct stmmac_priv *priv) | ||
| 150 | { | ||
| 151 | return 0; | ||
| 152 | } | ||
| 153 | #endif /* CONFIG_HAVE_CLK */ | ||
| 154 | |||
| 155 | |||
| 156 | #ifdef CONFIG_STMMAC_PLATFORM | 114 | #ifdef CONFIG_STMMAC_PLATFORM |
| 157 | extern struct platform_driver stmmac_pltfr_driver; | 115 | extern struct platform_driver stmmac_pltfr_driver; |
| 158 | static inline int stmmac_register_platform(void) | 116 | static inline int stmmac_register_platform(void) |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index f6b04c1a3672..fd8882f9602a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | https://bugzilla.stlinux.com/ | 28 | https://bugzilla.stlinux.com/ |
| 29 | *******************************************************************************/ | 29 | *******************************************************************************/ |
| 30 | 30 | ||
| 31 | #include <linux/clk.h> | ||
| 31 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
| 32 | #include <linux/interrupt.h> | 33 | #include <linux/interrupt.h> |
| 33 | #include <linux/ip.h> | 34 | #include <linux/ip.h> |
| @@ -173,12 +174,8 @@ static void stmmac_verify_args(void) | |||
| 173 | 174 | ||
| 174 | static void stmmac_clk_csr_set(struct stmmac_priv *priv) | 175 | static void stmmac_clk_csr_set(struct stmmac_priv *priv) |
| 175 | { | 176 | { |
| 176 | #ifdef CONFIG_HAVE_CLK | ||
| 177 | u32 clk_rate; | 177 | u32 clk_rate; |
| 178 | 178 | ||
| 179 | if (IS_ERR(priv->stmmac_clk)) | ||
| 180 | return; | ||
| 181 | |||
| 182 | clk_rate = clk_get_rate(priv->stmmac_clk); | 179 | clk_rate = clk_get_rate(priv->stmmac_clk); |
| 183 | 180 | ||
| 184 | /* Platform provided default clk_csr would be assumed valid | 181 | /* Platform provided default clk_csr would be assumed valid |
| @@ -200,7 +197,6 @@ static void stmmac_clk_csr_set(struct stmmac_priv *priv) | |||
| 200 | * we can not estimate the proper divider as it is not known | 197 | * we can not estimate the proper divider as it is not known |
| 201 | * the frequency of clk_csr_i. So we do not change the default | 198 | * the frequency of clk_csr_i. So we do not change the default |
| 202 | * divider. */ | 199 | * divider. */ |
| 203 | #endif | ||
| 204 | } | 200 | } |
| 205 | 201 | ||
| 206 | #if defined(STMMAC_XMIT_DEBUG) || defined(STMMAC_RX_DEBUG) | 202 | #if defined(STMMAC_XMIT_DEBUG) || defined(STMMAC_RX_DEBUG) |
| @@ -1070,7 +1066,7 @@ static int stmmac_open(struct net_device *dev) | |||
| 1070 | } else | 1066 | } else |
| 1071 | priv->tm->enable = 1; | 1067 | priv->tm->enable = 1; |
| 1072 | #endif | 1068 | #endif |
| 1073 | stmmac_clk_enable(priv); | 1069 | clk_enable(priv->stmmac_clk); |
| 1074 | 1070 | ||
| 1075 | stmmac_check_ether_addr(priv); | 1071 | stmmac_check_ether_addr(priv); |
| 1076 | 1072 | ||
| @@ -1192,7 +1188,7 @@ open_error: | |||
| 1192 | if (priv->phydev) | 1188 | if (priv->phydev) |
| 1193 | phy_disconnect(priv->phydev); | 1189 | phy_disconnect(priv->phydev); |
| 1194 | 1190 | ||
| 1195 | stmmac_clk_disable(priv); | 1191 | clk_disable(priv->stmmac_clk); |
| 1196 | 1192 | ||
| 1197 | return ret; | 1193 | return ret; |
| 1198 | } | 1194 | } |
| @@ -1250,7 +1246,7 @@ static int stmmac_release(struct net_device *dev) | |||
| 1250 | #ifdef CONFIG_STMMAC_DEBUG_FS | 1246 | #ifdef CONFIG_STMMAC_DEBUG_FS |
| 1251 | stmmac_exit_fs(); | 1247 | stmmac_exit_fs(); |
| 1252 | #endif | 1248 | #endif |
| 1253 | stmmac_clk_disable(priv); | 1249 | clk_disable(priv->stmmac_clk); |
| 1254 | 1250 | ||
| 1255 | return 0; | 1251 | return 0; |
| 1256 | } | 1252 | } |
| @@ -2078,11 +2074,14 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device, | |||
| 2078 | ret = register_netdev(ndev); | 2074 | ret = register_netdev(ndev); |
| 2079 | if (ret) { | 2075 | if (ret) { |
| 2080 | pr_err("%s: ERROR %i registering the device\n", __func__, ret); | 2076 | pr_err("%s: ERROR %i registering the device\n", __func__, ret); |
| 2081 | goto error; | 2077 | goto error_netdev_register; |
| 2082 | } | 2078 | } |
| 2083 | 2079 | ||
| 2084 | if (stmmac_clk_get(priv)) | 2080 | priv->stmmac_clk = clk_get(priv->device, NULL); |
| 2081 | if (IS_ERR(priv->stmmac_clk)) { | ||
| 2085 | pr_warning("%s: warning: cannot get CSR clock\n", __func__); | 2082 | pr_warning("%s: warning: cannot get CSR clock\n", __func__); |
| 2083 | goto error_clk_get; | ||
| 2084 | } | ||
| 2086 | 2085 | ||
| 2087 | /* If a specific clk_csr value is passed from the platform | 2086 | /* If a specific clk_csr value is passed from the platform |
| 2088 | * this means that the CSR Clock Range selection cannot be | 2087 | * this means that the CSR Clock Range selection cannot be |
| @@ -2100,15 +2099,17 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device, | |||
| 2100 | if (ret < 0) { | 2099 | if (ret < 0) { |
| 2101 | pr_debug("%s: MDIO bus (id: %d) registration failed", | 2100 | pr_debug("%s: MDIO bus (id: %d) registration failed", |
| 2102 | __func__, priv->plat->bus_id); | 2101 | __func__, priv->plat->bus_id); |
| 2103 | goto error; | 2102 | goto error_mdio_register; |
| 2104 | } | 2103 | } |
| 2105 | 2104 | ||
| 2106 | return priv; | 2105 | return priv; |
| 2107 | 2106 | ||
| 2108 | error: | 2107 | error_mdio_register: |
| 2109 | netif_napi_del(&priv->napi); | 2108 | clk_put(priv->stmmac_clk); |
| 2110 | 2109 | error_clk_get: | |
| 2111 | unregister_netdev(ndev); | 2110 | unregister_netdev(ndev); |
| 2111 | error_netdev_register: | ||
| 2112 | netif_napi_del(&priv->napi); | ||
| 2112 | free_netdev(ndev); | 2113 | free_netdev(ndev); |
| 2113 | 2114 | ||
| 2114 | return NULL; | 2115 | return NULL; |
| @@ -2177,7 +2178,7 @@ int stmmac_suspend(struct net_device *ndev) | |||
| 2177 | else { | 2178 | else { |
| 2178 | stmmac_set_mac(priv->ioaddr, false); | 2179 | stmmac_set_mac(priv->ioaddr, false); |
| 2179 | /* Disable clock in case of PWM is off */ | 2180 | /* Disable clock in case of PWM is off */ |
| 2180 | stmmac_clk_disable(priv); | 2181 | clk_disable(priv->stmmac_clk); |
| 2181 | } | 2182 | } |
| 2182 | spin_unlock_irqrestore(&priv->lock, flags); | 2183 | spin_unlock_irqrestore(&priv->lock, flags); |
| 2183 | return 0; | 2184 | return 0; |
| @@ -2202,7 +2203,7 @@ int stmmac_resume(struct net_device *ndev) | |||
| 2202 | priv->hw->mac->pmt(priv->ioaddr, 0); | 2203 | priv->hw->mac->pmt(priv->ioaddr, 0); |
| 2203 | else | 2204 | else |
| 2204 | /* enable the clk prevously disabled */ | 2205 | /* enable the clk prevously disabled */ |
| 2205 | stmmac_clk_enable(priv); | 2206 | clk_enable(priv->stmmac_clk); |
| 2206 | 2207 | ||
| 2207 | netif_device_attach(ndev); | 2208 | netif_device_attach(ndev); |
| 2208 | 2209 | ||
diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c index 98fbe62694d4..e771487132f7 100644 --- a/drivers/pps/pps.c +++ b/drivers/pps/pps.c | |||
| @@ -327,8 +327,10 @@ int pps_register_cdev(struct pps_device *pps) | |||
| 327 | } | 327 | } |
| 328 | pps->dev = device_create(pps_class, pps->info.dev, devt, pps, | 328 | pps->dev = device_create(pps_class, pps->info.dev, devt, pps, |
| 329 | "pps%d", pps->id); | 329 | "pps%d", pps->id); |
| 330 | if (IS_ERR(pps->dev)) | 330 | if (IS_ERR(pps->dev)) { |
| 331 | err = PTR_ERR(pps->dev); | ||
| 331 | goto del_cdev; | 332 | goto del_cdev; |
| 333 | } | ||
| 332 | 334 | ||
| 333 | pps->dev->release = pps_device_destruct; | 335 | pps->dev->release = pps_device_destruct; |
| 334 | 336 | ||
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index f049c02413ce..fabc99a75c65 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
| @@ -704,6 +704,7 @@ config RTC_DRV_AB3100 | |||
| 704 | config RTC_DRV_AB8500 | 704 | config RTC_DRV_AB8500 |
| 705 | tristate "ST-Ericsson AB8500 RTC" | 705 | tristate "ST-Ericsson AB8500 RTC" |
| 706 | depends on AB8500_CORE | 706 | depends on AB8500_CORE |
| 707 | select RTC_INTF_DEV_UIE_EMUL | ||
| 707 | help | 708 | help |
| 708 | Select this to enable the ST-Ericsson AB8500 power management IC RTC | 709 | Select this to enable the ST-Ericsson AB8500 power management IC RTC |
| 709 | support. This chip contains a battery- and capacitor-backed RTC. | 710 | support. This chip contains a battery- and capacitor-backed RTC. |
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c index 370889d0489b..bf3c2f669c3c 100644 --- a/drivers/rtc/rtc-ab8500.c +++ b/drivers/rtc/rtc-ab8500.c | |||
| @@ -89,22 +89,17 @@ static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
| 89 | if (retval < 0) | 89 | if (retval < 0) |
| 90 | return retval; | 90 | return retval; |
| 91 | 91 | ||
| 92 | /* Early AB8500 chips will not clear the rtc read request bit */ | 92 | /* Wait for some cycles after enabling the rtc read in ab8500 */ |
| 93 | if (abx500_get_chip_id(dev) == 0) { | 93 | while (time_before(jiffies, timeout)) { |
| 94 | usleep_range(1000, 1000); | 94 | retval = abx500_get_register_interruptible(dev, |
| 95 | } else { | 95 | AB8500_RTC, AB8500_RTC_READ_REQ_REG, &value); |
| 96 | /* Wait for some cycles after enabling the rtc read in ab8500 */ | 96 | if (retval < 0) |
| 97 | while (time_before(jiffies, timeout)) { | 97 | return retval; |
| 98 | retval = abx500_get_register_interruptible(dev, | 98 | |
| 99 | AB8500_RTC, AB8500_RTC_READ_REQ_REG, &value); | 99 | if (!(value & RTC_READ_REQUEST)) |
| 100 | if (retval < 0) | 100 | break; |
| 101 | return retval; | 101 | |
| 102 | 102 | usleep_range(1000, 5000); | |
| 103 | if (!(value & RTC_READ_REQUEST)) | ||
| 104 | break; | ||
| 105 | |||
| 106 | usleep_range(1000, 5000); | ||
| 107 | } | ||
| 108 | } | 103 | } |
| 109 | 104 | ||
| 110 | /* Read the Watchtime registers */ | 105 | /* Read the Watchtime registers */ |
| @@ -225,7 +220,8 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) | |||
| 225 | { | 220 | { |
| 226 | int retval, i; | 221 | int retval, i; |
| 227 | unsigned char buf[ARRAY_SIZE(ab8500_rtc_alarm_regs)]; | 222 | unsigned char buf[ARRAY_SIZE(ab8500_rtc_alarm_regs)]; |
| 228 | unsigned long mins, secs = 0; | 223 | unsigned long mins, secs = 0, cursec = 0; |
| 224 | struct rtc_time curtm; | ||
| 229 | 225 | ||
| 230 | if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) { | 226 | if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) { |
| 231 | dev_dbg(dev, "year should be equal to or greater than %d\n", | 227 | dev_dbg(dev, "year should be equal to or greater than %d\n", |
| @@ -237,6 +233,18 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) | |||
| 237 | rtc_tm_to_time(&alarm->time, &secs); | 233 | rtc_tm_to_time(&alarm->time, &secs); |
| 238 | 234 | ||
| 239 | /* | 235 | /* |
| 236 | * Check whether alarm is set less than 1min. | ||
| 237 | * Since our RTC doesn't support alarm resolution less than 1min, | ||
| 238 | * return -EINVAL, so UIE EMUL can take it up, incase of UIE_ON | ||
| 239 | */ | ||
| 240 | ab8500_rtc_read_time(dev, &curtm); /* Read current time */ | ||
| 241 | rtc_tm_to_time(&curtm, &cursec); | ||
| 242 | if ((secs - cursec) < 59) { | ||
| 243 | dev_dbg(dev, "Alarm less than 1 minute not supported\r\n"); | ||
| 244 | return -EINVAL; | ||
| 245 | } | ||
| 246 | |||
| 247 | /* | ||
| 240 | * Convert it to the number of seconds since 01-01-2000 00:00:00, since | 248 | * Convert it to the number of seconds since 01-01-2000 00:00:00, since |
| 241 | * we only have a small counter in the RTC. | 249 | * we only have a small counter in the RTC. |
| 242 | */ | 250 | */ |
diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c index a5b8a0c4ea84..76b2156d3c62 100644 --- a/drivers/rtc/rtc-coh901331.c +++ b/drivers/rtc/rtc-coh901331.c | |||
| @@ -155,13 +155,10 @@ static int __exit coh901331_remove(struct platform_device *pdev) | |||
| 155 | struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev); | 155 | struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev); |
| 156 | 156 | ||
| 157 | if (rtap) { | 157 | if (rtap) { |
| 158 | free_irq(rtap->irq, rtap); | ||
| 159 | rtc_device_unregister(rtap->rtc); | 158 | rtc_device_unregister(rtap->rtc); |
| 159 | clk_unprepare(rtap->clk); | ||
| 160 | clk_put(rtap->clk); | 160 | clk_put(rtap->clk); |
| 161 | iounmap(rtap->virtbase); | ||
| 162 | release_mem_region(rtap->phybase, rtap->physize); | ||
| 163 | platform_set_drvdata(pdev, NULL); | 161 | platform_set_drvdata(pdev, NULL); |
| 164 | kfree(rtap); | ||
| 165 | } | 162 | } |
| 166 | 163 | ||
| 167 | return 0; | 164 | return 0; |
| @@ -174,49 +171,43 @@ static int __init coh901331_probe(struct platform_device *pdev) | |||
| 174 | struct coh901331_port *rtap; | 171 | struct coh901331_port *rtap; |
| 175 | struct resource *res; | 172 | struct resource *res; |
| 176 | 173 | ||
| 177 | rtap = kzalloc(sizeof(struct coh901331_port), GFP_KERNEL); | 174 | rtap = devm_kzalloc(&pdev->dev, |
| 175 | sizeof(struct coh901331_port), GFP_KERNEL); | ||
| 178 | if (!rtap) | 176 | if (!rtap) |
| 179 | return -ENOMEM; | 177 | return -ENOMEM; |
| 180 | 178 | ||
| 181 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 179 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 182 | if (!res) { | 180 | if (!res) |
| 183 | ret = -ENOENT; | 181 | return -ENOENT; |
| 184 | goto out_no_resource; | 182 | |
| 185 | } | ||
| 186 | rtap->phybase = res->start; | 183 | rtap->phybase = res->start; |
| 187 | rtap->physize = resource_size(res); | 184 | rtap->physize = resource_size(res); |
| 188 | 185 | ||
| 189 | if (request_mem_region(rtap->phybase, rtap->physize, | 186 | if (devm_request_mem_region(&pdev->dev, rtap->phybase, rtap->physize, |
| 190 | "rtc-coh901331") == NULL) { | 187 | "rtc-coh901331") == NULL) |
| 191 | ret = -EBUSY; | 188 | return -EBUSY; |
| 192 | goto out_no_memregion; | ||
| 193 | } | ||
| 194 | 189 | ||
| 195 | rtap->virtbase = ioremap(rtap->phybase, rtap->physize); | 190 | rtap->virtbase = devm_ioremap(&pdev->dev, rtap->phybase, rtap->physize); |
| 196 | if (!rtap->virtbase) { | 191 | if (!rtap->virtbase) |
| 197 | ret = -ENOMEM; | 192 | return -ENOMEM; |
| 198 | goto out_no_remap; | ||
| 199 | } | ||
| 200 | 193 | ||
| 201 | rtap->irq = platform_get_irq(pdev, 0); | 194 | rtap->irq = platform_get_irq(pdev, 0); |
| 202 | if (request_irq(rtap->irq, coh901331_interrupt, 0, | 195 | if (devm_request_irq(&pdev->dev, rtap->irq, coh901331_interrupt, 0, |
| 203 | "RTC COH 901 331 Alarm", rtap)) { | 196 | "RTC COH 901 331 Alarm", rtap)) |
| 204 | ret = -EIO; | 197 | return -EIO; |
| 205 | goto out_no_irq; | ||
| 206 | } | ||
| 207 | 198 | ||
| 208 | rtap->clk = clk_get(&pdev->dev, NULL); | 199 | rtap->clk = clk_get(&pdev->dev, NULL); |
| 209 | if (IS_ERR(rtap->clk)) { | 200 | if (IS_ERR(rtap->clk)) { |
| 210 | ret = PTR_ERR(rtap->clk); | 201 | ret = PTR_ERR(rtap->clk); |
| 211 | dev_err(&pdev->dev, "could not get clock\n"); | 202 | dev_err(&pdev->dev, "could not get clock\n"); |
| 212 | goto out_no_clk; | 203 | return ret; |
| 213 | } | 204 | } |
| 214 | 205 | ||
| 215 | /* We enable/disable the clock only to assure it works */ | 206 | /* We enable/disable the clock only to assure it works */ |
| 216 | ret = clk_enable(rtap->clk); | 207 | ret = clk_prepare_enable(rtap->clk); |
| 217 | if (ret) { | 208 | if (ret) { |
| 218 | dev_err(&pdev->dev, "could not enable clock\n"); | 209 | dev_err(&pdev->dev, "could not enable clock\n"); |
| 219 | goto out_no_clk_enable; | 210 | goto out_no_clk_prepenable; |
| 220 | } | 211 | } |
| 221 | clk_disable(rtap->clk); | 212 | clk_disable(rtap->clk); |
| 222 | 213 | ||
| @@ -232,18 +223,9 @@ static int __init coh901331_probe(struct platform_device *pdev) | |||
| 232 | 223 | ||
| 233 | out_no_rtc: | 224 | out_no_rtc: |
| 234 | platform_set_drvdata(pdev, NULL); | 225 | platform_set_drvdata(pdev, NULL); |
| 235 | out_no_clk_enable: | 226 | clk_unprepare(rtap->clk); |
| 227 | out_no_clk_prepenable: | ||
| 236 | clk_put(rtap->clk); | 228 | clk_put(rtap->clk); |
| 237 | out_no_clk: | ||
| 238 | free_irq(rtap->irq, rtap); | ||
| 239 | out_no_irq: | ||
| 240 | iounmap(rtap->virtbase); | ||
| 241 | out_no_remap: | ||
| 242 | platform_set_drvdata(pdev, NULL); | ||
| 243 | out_no_memregion: | ||
| 244 | release_mem_region(rtap->phybase, SZ_4K); | ||
| 245 | out_no_resource: | ||
| 246 | kfree(rtap); | ||
| 247 | return ret; | 229 | return ret; |
| 248 | } | 230 | } |
| 249 | 231 | ||
| @@ -265,6 +247,7 @@ static int coh901331_suspend(struct platform_device *pdev, pm_message_t state) | |||
| 265 | writel(0, rtap->virtbase + COH901331_IRQ_MASK); | 247 | writel(0, rtap->virtbase + COH901331_IRQ_MASK); |
| 266 | clk_disable(rtap->clk); | 248 | clk_disable(rtap->clk); |
| 267 | } | 249 | } |
| 250 | clk_unprepare(rtap->clk); | ||
| 268 | return 0; | 251 | return 0; |
| 269 | } | 252 | } |
| 270 | 253 | ||
| @@ -272,6 +255,7 @@ static int coh901331_resume(struct platform_device *pdev) | |||
| 272 | { | 255 | { |
| 273 | struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev); | 256 | struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev); |
| 274 | 257 | ||
| 258 | clk_prepare(rtap->clk); | ||
| 275 | if (device_may_wakeup(&pdev->dev)) { | 259 | if (device_may_wakeup(&pdev->dev)) { |
| 276 | disable_irq_wake(rtap->irq); | 260 | disable_irq_wake(rtap->irq); |
| 277 | } else { | 261 | } else { |
| @@ -293,6 +277,7 @@ static void coh901331_shutdown(struct platform_device *pdev) | |||
| 293 | clk_enable(rtap->clk); | 277 | clk_enable(rtap->clk); |
| 294 | writel(0, rtap->virtbase + COH901331_IRQ_MASK); | 278 | writel(0, rtap->virtbase + COH901331_IRQ_MASK); |
| 295 | clk_disable(rtap->clk); | 279 | clk_disable(rtap->clk); |
| 280 | clk_unprepare(rtap->clk); | ||
| 296 | } | 281 | } |
| 297 | 282 | ||
| 298 | static struct platform_driver coh901331_driver = { | 283 | static struct platform_driver coh901331_driver = { |
diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c index da6ab5291a41..78070255bd3f 100644 --- a/drivers/rtc/rtc-da9052.c +++ b/drivers/rtc/rtc-da9052.c | |||
| @@ -245,7 +245,7 @@ static int __devinit da9052_rtc_probe(struct platform_device *pdev) | |||
| 245 | "ALM", rtc); | 245 | "ALM", rtc); |
| 246 | if (ret != 0) { | 246 | if (ret != 0) { |
| 247 | rtc_err(rtc->da9052, "irq registration failed: %d\n", ret); | 247 | rtc_err(rtc->da9052, "irq registration failed: %d\n", ret); |
| 248 | goto err_mem; | 248 | return ret; |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, | 251 | rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, |
| @@ -259,8 +259,6 @@ static int __devinit da9052_rtc_probe(struct platform_device *pdev) | |||
| 259 | 259 | ||
| 260 | err_free_irq: | 260 | err_free_irq: |
| 261 | free_irq(rtc->irq, rtc); | 261 | free_irq(rtc->irq, rtc); |
| 262 | err_mem: | ||
| 263 | devm_kfree(&pdev->dev, rtc); | ||
| 264 | return ret; | 262 | return ret; |
| 265 | } | 263 | } |
| 266 | 264 | ||
| @@ -271,7 +269,6 @@ static int __devexit da9052_rtc_remove(struct platform_device *pdev) | |||
| 271 | rtc_device_unregister(rtc->rtc); | 269 | rtc_device_unregister(rtc->rtc); |
| 272 | free_irq(rtc->irq, rtc); | 270 | free_irq(rtc->irq, rtc); |
| 273 | platform_set_drvdata(pdev, NULL); | 271 | platform_set_drvdata(pdev, NULL); |
| 274 | devm_kfree(&pdev->dev, rtc); | ||
| 275 | 272 | ||
| 276 | return 0; | 273 | return 0; |
| 277 | } | 274 | } |
diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c index 546f6850bffb..2643d8874925 100644 --- a/drivers/rtc/rtc-mc13xxx.c +++ b/drivers/rtc/rtc-mc13xxx.c | |||
| @@ -404,9 +404,12 @@ static const struct platform_device_id mc13xxx_rtc_idtable[] = { | |||
| 404 | .name = "mc13783-rtc", | 404 | .name = "mc13783-rtc", |
| 405 | }, { | 405 | }, { |
| 406 | .name = "mc13892-rtc", | 406 | .name = "mc13892-rtc", |
| 407 | }, { | ||
| 408 | .name = "mc34708-rtc", | ||
| 407 | }, | 409 | }, |
| 408 | { } | 410 | { /* sentinel */ } |
| 409 | }; | 411 | }; |
| 412 | MODULE_DEVICE_TABLE(platform, mc13xxx_rtc_idtable); | ||
| 410 | 413 | ||
| 411 | static struct platform_driver mc13xxx_rtc_driver = { | 414 | static struct platform_driver mc13xxx_rtc_driver = { |
| 412 | .id_table = mc13xxx_rtc_idtable, | 415 | .id_table = mc13xxx_rtc_idtable, |
| @@ -432,4 +435,3 @@ module_exit(mc13xxx_rtc_exit); | |||
| 432 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); | 435 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); |
| 433 | MODULE_DESCRIPTION("RTC driver for Freescale MC13XXX PMIC"); | 436 | MODULE_DESCRIPTION("RTC driver for Freescale MC13XXX PMIC"); |
| 434 | MODULE_LICENSE("GPL v2"); | 437 | MODULE_LICENSE("GPL v2"); |
| 435 | MODULE_ALIAS("platform:" DRIVER_NAME); | ||
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c index 97a3284bb7c6..c2fe426a6ef2 100644 --- a/drivers/rtc/rtc-pcf8563.c +++ b/drivers/rtc/rtc-pcf8563.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <linux/rtc.h> | 19 | #include <linux/rtc.h> |
| 20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
| 21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
| 22 | #include <linux/of.h> | ||
| 22 | 23 | ||
| 23 | #define DRV_VERSION "0.4.3" | 24 | #define DRV_VERSION "0.4.3" |
| 24 | 25 | ||
| @@ -285,9 +286,19 @@ static const struct i2c_device_id pcf8563_id[] = { | |||
| 285 | }; | 286 | }; |
| 286 | MODULE_DEVICE_TABLE(i2c, pcf8563_id); | 287 | MODULE_DEVICE_TABLE(i2c, pcf8563_id); |
| 287 | 288 | ||
| 289 | #ifdef CONFIG_OF | ||
| 290 | static const struct of_device_id pcf8563_of_match[] __devinitconst = { | ||
| 291 | { .compatible = "nxp,pcf8563" }, | ||
| 292 | {} | ||
| 293 | }; | ||
| 294 | MODULE_DEVICE_TABLE(of, pcf8563_of_match); | ||
| 295 | #endif | ||
| 296 | |||
| 288 | static struct i2c_driver pcf8563_driver = { | 297 | static struct i2c_driver pcf8563_driver = { |
| 289 | .driver = { | 298 | .driver = { |
| 290 | .name = "rtc-pcf8563", | 299 | .name = "rtc-pcf8563", |
| 300 | .owner = THIS_MODULE, | ||
| 301 | .of_match_table = of_match_ptr(pcf8563_of_match), | ||
| 291 | }, | 302 | }, |
| 292 | .probe = pcf8563_probe, | 303 | .probe = pcf8563_probe, |
| 293 | .remove = pcf8563_remove, | 304 | .remove = pcf8563_remove, |
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index cc0533994f6e..08378e3cc21c 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c | |||
| @@ -68,11 +68,26 @@ | |||
| 68 | 68 | ||
| 69 | #define RTC_TIMER_FREQ 32768 | 69 | #define RTC_TIMER_FREQ 32768 |
| 70 | 70 | ||
| 71 | /** | ||
| 72 | * struct pl031_vendor_data - per-vendor variations | ||
| 73 | * @ops: the vendor-specific operations used on this silicon version | ||
| 74 | * @clockwatch: if this is an ST Microelectronics silicon version with a | ||
| 75 | * clockwatch function | ||
| 76 | * @st_weekday: if this is an ST Microelectronics silicon version that need | ||
| 77 | * the weekday fix | ||
| 78 | * @irqflags: special IRQ flags per variant | ||
| 79 | */ | ||
| 80 | struct pl031_vendor_data { | ||
| 81 | struct rtc_class_ops ops; | ||
| 82 | bool clockwatch; | ||
| 83 | bool st_weekday; | ||
| 84 | unsigned long irqflags; | ||
| 85 | }; | ||
| 86 | |||
| 71 | struct pl031_local { | 87 | struct pl031_local { |
| 88 | struct pl031_vendor_data *vendor; | ||
| 72 | struct rtc_device *rtc; | 89 | struct rtc_device *rtc; |
| 73 | void __iomem *base; | 90 | void __iomem *base; |
| 74 | u8 hw_designer; | ||
| 75 | u8 hw_revision:4; | ||
| 76 | }; | 91 | }; |
| 77 | 92 | ||
| 78 | static int pl031_alarm_irq_enable(struct device *dev, | 93 | static int pl031_alarm_irq_enable(struct device *dev, |
| @@ -303,7 +318,8 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) | |||
| 303 | { | 318 | { |
| 304 | int ret; | 319 | int ret; |
| 305 | struct pl031_local *ldata; | 320 | struct pl031_local *ldata; |
| 306 | struct rtc_class_ops *ops = id->data; | 321 | struct pl031_vendor_data *vendor = id->data; |
| 322 | struct rtc_class_ops *ops = &vendor->ops; | ||
| 307 | unsigned long time; | 323 | unsigned long time; |
| 308 | 324 | ||
| 309 | ret = amba_request_regions(adev, NULL); | 325 | ret = amba_request_regions(adev, NULL); |
| @@ -315,6 +331,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) | |||
| 315 | ret = -ENOMEM; | 331 | ret = -ENOMEM; |
| 316 | goto out; | 332 | goto out; |
| 317 | } | 333 | } |
| 334 | ldata->vendor = vendor; | ||
| 318 | 335 | ||
| 319 | ldata->base = ioremap(adev->res.start, resource_size(&adev->res)); | 336 | ldata->base = ioremap(adev->res.start, resource_size(&adev->res)); |
| 320 | 337 | ||
| @@ -325,14 +342,11 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) | |||
| 325 | 342 | ||
| 326 | amba_set_drvdata(adev, ldata); | 343 | amba_set_drvdata(adev, ldata); |
| 327 | 344 | ||
| 328 | ldata->hw_designer = amba_manf(adev); | 345 | dev_dbg(&adev->dev, "designer ID = 0x%02x\n", amba_manf(adev)); |
| 329 | ldata->hw_revision = amba_rev(adev); | 346 | dev_dbg(&adev->dev, "revision = 0x%01x\n", amba_rev(adev)); |
| 330 | |||
| 331 | dev_dbg(&adev->dev, "designer ID = 0x%02x\n", ldata->hw_designer); | ||
| 332 | dev_dbg(&adev->dev, "revision = 0x%01x\n", ldata->hw_revision); | ||
| 333 | 347 | ||
| 334 | /* Enable the clockwatch on ST Variants */ | 348 | /* Enable the clockwatch on ST Variants */ |
| 335 | if (ldata->hw_designer == AMBA_VENDOR_ST) | 349 | if (vendor->clockwatch) |
| 336 | writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN, | 350 | writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN, |
| 337 | ldata->base + RTC_CR); | 351 | ldata->base + RTC_CR); |
| 338 | 352 | ||
| @@ -340,7 +354,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) | |||
| 340 | * On ST PL031 variants, the RTC reset value does not provide correct | 354 | * On ST PL031 variants, the RTC reset value does not provide correct |
| 341 | * weekday for 2000-01-01. Correct the erroneous sunday to saturday. | 355 | * weekday for 2000-01-01. Correct the erroneous sunday to saturday. |
| 342 | */ | 356 | */ |
| 343 | if (ldata->hw_designer == AMBA_VENDOR_ST) { | 357 | if (vendor->st_weekday) { |
| 344 | if (readl(ldata->base + RTC_YDR) == 0x2000) { | 358 | if (readl(ldata->base + RTC_YDR) == 0x2000) { |
| 345 | time = readl(ldata->base + RTC_DR); | 359 | time = readl(ldata->base + RTC_DR); |
| 346 | if ((time & | 360 | if ((time & |
| @@ -361,7 +375,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) | |||
| 361 | } | 375 | } |
| 362 | 376 | ||
| 363 | if (request_irq(adev->irq[0], pl031_interrupt, | 377 | if (request_irq(adev->irq[0], pl031_interrupt, |
| 364 | 0, "rtc-pl031", ldata)) { | 378 | vendor->irqflags, "rtc-pl031", ldata)) { |
| 365 | ret = -EIO; | 379 | ret = -EIO; |
| 366 | goto out_no_irq; | 380 | goto out_no_irq; |
| 367 | } | 381 | } |
| @@ -383,48 +397,65 @@ err_req: | |||
| 383 | } | 397 | } |
| 384 | 398 | ||
| 385 | /* Operations for the original ARM version */ | 399 | /* Operations for the original ARM version */ |
| 386 | static struct rtc_class_ops arm_pl031_ops = { | 400 | static struct pl031_vendor_data arm_pl031 = { |
| 387 | .read_time = pl031_read_time, | 401 | .ops = { |
| 388 | .set_time = pl031_set_time, | 402 | .read_time = pl031_read_time, |
| 389 | .read_alarm = pl031_read_alarm, | 403 | .set_time = pl031_set_time, |
| 390 | .set_alarm = pl031_set_alarm, | 404 | .read_alarm = pl031_read_alarm, |
| 391 | .alarm_irq_enable = pl031_alarm_irq_enable, | 405 | .set_alarm = pl031_set_alarm, |
| 406 | .alarm_irq_enable = pl031_alarm_irq_enable, | ||
| 407 | }, | ||
| 408 | .irqflags = IRQF_NO_SUSPEND, | ||
| 392 | }; | 409 | }; |
| 393 | 410 | ||
| 394 | /* The First ST derivative */ | 411 | /* The First ST derivative */ |
| 395 | static struct rtc_class_ops stv1_pl031_ops = { | 412 | static struct pl031_vendor_data stv1_pl031 = { |
| 396 | .read_time = pl031_read_time, | 413 | .ops = { |
| 397 | .set_time = pl031_set_time, | 414 | .read_time = pl031_read_time, |
| 398 | .read_alarm = pl031_read_alarm, | 415 | .set_time = pl031_set_time, |
| 399 | .set_alarm = pl031_set_alarm, | 416 | .read_alarm = pl031_read_alarm, |
| 400 | .alarm_irq_enable = pl031_alarm_irq_enable, | 417 | .set_alarm = pl031_set_alarm, |
| 418 | .alarm_irq_enable = pl031_alarm_irq_enable, | ||
| 419 | }, | ||
| 420 | .clockwatch = true, | ||
| 421 | .st_weekday = true, | ||
| 422 | .irqflags = IRQF_NO_SUSPEND, | ||
| 401 | }; | 423 | }; |
| 402 | 424 | ||
| 403 | /* And the second ST derivative */ | 425 | /* And the second ST derivative */ |
| 404 | static struct rtc_class_ops stv2_pl031_ops = { | 426 | static struct pl031_vendor_data stv2_pl031 = { |
| 405 | .read_time = pl031_stv2_read_time, | 427 | .ops = { |
| 406 | .set_time = pl031_stv2_set_time, | 428 | .read_time = pl031_stv2_read_time, |
| 407 | .read_alarm = pl031_stv2_read_alarm, | 429 | .set_time = pl031_stv2_set_time, |
| 408 | .set_alarm = pl031_stv2_set_alarm, | 430 | .read_alarm = pl031_stv2_read_alarm, |
| 409 | .alarm_irq_enable = pl031_alarm_irq_enable, | 431 | .set_alarm = pl031_stv2_set_alarm, |
| 432 | .alarm_irq_enable = pl031_alarm_irq_enable, | ||
| 433 | }, | ||
| 434 | .clockwatch = true, | ||
| 435 | .st_weekday = true, | ||
| 436 | /* | ||
| 437 | * This variant shares the IRQ with another block and must not | ||
| 438 | * suspend that IRQ line. | ||
| 439 | */ | ||
| 440 | .irqflags = IRQF_SHARED | IRQF_NO_SUSPEND, | ||
| 410 | }; | 441 | }; |
| 411 | 442 | ||
| 412 | static struct amba_id pl031_ids[] = { | 443 | static struct amba_id pl031_ids[] = { |
| 413 | { | 444 | { |
| 414 | .id = 0x00041031, | 445 | .id = 0x00041031, |
| 415 | .mask = 0x000fffff, | 446 | .mask = 0x000fffff, |
| 416 | .data = &arm_pl031_ops, | 447 | .data = &arm_pl031, |
| 417 | }, | 448 | }, |
| 418 | /* ST Micro variants */ | 449 | /* ST Micro variants */ |
| 419 | { | 450 | { |
| 420 | .id = 0x00180031, | 451 | .id = 0x00180031, |
| 421 | .mask = 0x00ffffff, | 452 | .mask = 0x00ffffff, |
| 422 | .data = &stv1_pl031_ops, | 453 | .data = &stv1_pl031, |
| 423 | }, | 454 | }, |
| 424 | { | 455 | { |
| 425 | .id = 0x00280031, | 456 | .id = 0x00280031, |
| 426 | .mask = 0x00ffffff, | 457 | .mask = 0x00ffffff, |
| 427 | .data = &stv2_pl031_ops, | 458 | .data = &stv2_pl031, |
| 428 | }, | 459 | }, |
| 429 | {0, 0}, | 460 | {0, 0}, |
| 430 | }; | 461 | }; |
diff --git a/drivers/rtc/rtc-r9701.c b/drivers/rtc/rtc-r9701.c index 33b6ba0afa0d..2c183ebff715 100644 --- a/drivers/rtc/rtc-r9701.c +++ b/drivers/rtc/rtc-r9701.c | |||
| @@ -138,8 +138,7 @@ static int __devinit r9701_probe(struct spi_device *spi) | |||
| 138 | * contain invalid values. If so, try to write a default date: | 138 | * contain invalid values. If so, try to write a default date: |
| 139 | * 2000/1/1 00:00:00 | 139 | * 2000/1/1 00:00:00 |
| 140 | */ | 140 | */ |
| 141 | r9701_get_datetime(&spi->dev, &dt); | 141 | if (r9701_get_datetime(&spi->dev, &dt)) { |
| 142 | if (rtc_valid_tm(&dt)) { | ||
| 143 | dev_info(&spi->dev, "trying to repair invalid date/time\n"); | 142 | dev_info(&spi->dev, "trying to repair invalid date/time\n"); |
| 144 | dt.tm_sec = 0; | 143 | dt.tm_sec = 0; |
| 145 | dt.tm_min = 0; | 144 | dt.tm_min = 0; |
| @@ -148,7 +147,8 @@ static int __devinit r9701_probe(struct spi_device *spi) | |||
| 148 | dt.tm_mon = 0; | 147 | dt.tm_mon = 0; |
| 149 | dt.tm_year = 100; | 148 | dt.tm_year = 100; |
| 150 | 149 | ||
| 151 | if (r9701_set_datetime(&spi->dev, &dt)) { | 150 | if (r9701_set_datetime(&spi->dev, &dt) || |
| 151 | r9701_get_datetime(&spi->dev, &dt)) { | ||
| 152 | dev_err(&spi->dev, "cannot repair RTC register\n"); | 152 | dev_err(&spi->dev, "cannot repair RTC register\n"); |
| 153 | return -ENODEV; | 153 | return -ENODEV; |
| 154 | } | 154 | } |
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 7e6af0b22f17..bfbd92c8d1c9 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
| @@ -26,10 +26,10 @@ | |||
| 26 | #include <linux/log2.h> | 26 | #include <linux/log2.h> |
| 27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
| 28 | #include <linux/of.h> | 28 | #include <linux/of.h> |
| 29 | #include <linux/uaccess.h> | ||
| 30 | #include <linux/io.h> | ||
| 29 | 31 | ||
| 30 | #include <mach/hardware.h> | 32 | #include <mach/hardware.h> |
| 31 | #include <asm/uaccess.h> | ||
| 32 | #include <asm/io.h> | ||
| 33 | #include <asm/irq.h> | 33 | #include <asm/irq.h> |
| 34 | #include <plat/regs-rtc.h> | 34 | #include <plat/regs-rtc.h> |
| 35 | 35 | ||
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c index 8981fbb5748c..cf6bd626f3fe 100644 --- a/drivers/usb/gadget/m66592-udc.c +++ b/drivers/usb/gadget/m66592-udc.c | |||
| @@ -1583,12 +1583,10 @@ static int __exit m66592_remove(struct platform_device *pdev) | |||
| 1583 | iounmap(m66592->reg); | 1583 | iounmap(m66592->reg); |
| 1584 | free_irq(platform_get_irq(pdev, 0), m66592); | 1584 | free_irq(platform_get_irq(pdev, 0), m66592); |
| 1585 | m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); | 1585 | m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); |
| 1586 | #ifdef CONFIG_HAVE_CLK | ||
| 1587 | if (m66592->pdata->on_chip) { | 1586 | if (m66592->pdata->on_chip) { |
| 1588 | clk_disable(m66592->clk); | 1587 | clk_disable(m66592->clk); |
| 1589 | clk_put(m66592->clk); | 1588 | clk_put(m66592->clk); |
| 1590 | } | 1589 | } |
| 1591 | #endif | ||
| 1592 | kfree(m66592); | 1590 | kfree(m66592); |
| 1593 | return 0; | 1591 | return 0; |
| 1594 | } | 1592 | } |
| @@ -1602,9 +1600,7 @@ static int __init m66592_probe(struct platform_device *pdev) | |||
| 1602 | struct resource *res, *ires; | 1600 | struct resource *res, *ires; |
| 1603 | void __iomem *reg = NULL; | 1601 | void __iomem *reg = NULL; |
| 1604 | struct m66592 *m66592 = NULL; | 1602 | struct m66592 *m66592 = NULL; |
| 1605 | #ifdef CONFIG_HAVE_CLK | ||
| 1606 | char clk_name[8]; | 1603 | char clk_name[8]; |
| 1607 | #endif | ||
| 1608 | int ret = 0; | 1604 | int ret = 0; |
| 1609 | int i; | 1605 | int i; |
| 1610 | 1606 | ||
| @@ -1671,7 +1667,6 @@ static int __init m66592_probe(struct platform_device *pdev) | |||
| 1671 | goto clean_up; | 1667 | goto clean_up; |
| 1672 | } | 1668 | } |
| 1673 | 1669 | ||
| 1674 | #ifdef CONFIG_HAVE_CLK | ||
| 1675 | if (m66592->pdata->on_chip) { | 1670 | if (m66592->pdata->on_chip) { |
| 1676 | snprintf(clk_name, sizeof(clk_name), "usbf%d", pdev->id); | 1671 | snprintf(clk_name, sizeof(clk_name), "usbf%d", pdev->id); |
| 1677 | m66592->clk = clk_get(&pdev->dev, clk_name); | 1672 | m66592->clk = clk_get(&pdev->dev, clk_name); |
| @@ -1683,7 +1678,7 @@ static int __init m66592_probe(struct platform_device *pdev) | |||
| 1683 | } | 1678 | } |
| 1684 | clk_enable(m66592->clk); | 1679 | clk_enable(m66592->clk); |
| 1685 | } | 1680 | } |
| 1686 | #endif | 1681 | |
| 1687 | INIT_LIST_HEAD(&m66592->gadget.ep_list); | 1682 | INIT_LIST_HEAD(&m66592->gadget.ep_list); |
| 1688 | m66592->gadget.ep0 = &m66592->ep[0].ep; | 1683 | m66592->gadget.ep0 = &m66592->ep[0].ep; |
| 1689 | INIT_LIST_HEAD(&m66592->gadget.ep0->ep_list); | 1684 | INIT_LIST_HEAD(&m66592->gadget.ep0->ep_list); |
| @@ -1731,13 +1726,11 @@ err_add_udc: | |||
| 1731 | m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); | 1726 | m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); |
| 1732 | 1727 | ||
| 1733 | clean_up3: | 1728 | clean_up3: |
| 1734 | #ifdef CONFIG_HAVE_CLK | ||
| 1735 | if (m66592->pdata->on_chip) { | 1729 | if (m66592->pdata->on_chip) { |
| 1736 | clk_disable(m66592->clk); | 1730 | clk_disable(m66592->clk); |
| 1737 | clk_put(m66592->clk); | 1731 | clk_put(m66592->clk); |
| 1738 | } | 1732 | } |
| 1739 | clean_up2: | 1733 | clean_up2: |
| 1740 | #endif | ||
| 1741 | free_irq(ires->start, m66592); | 1734 | free_irq(ires->start, m66592); |
| 1742 | clean_up: | 1735 | clean_up: |
| 1743 | if (m66592) { | 1736 | if (m66592) { |
diff --git a/drivers/usb/gadget/m66592-udc.h b/drivers/usb/gadget/m66592-udc.h index 88c85b4116a2..16c7e14678b8 100644 --- a/drivers/usb/gadget/m66592-udc.h +++ b/drivers/usb/gadget/m66592-udc.h | |||
| @@ -13,10 +13,7 @@ | |||
| 13 | #ifndef __M66592_UDC_H__ | 13 | #ifndef __M66592_UDC_H__ |
| 14 | #define __M66592_UDC_H__ | 14 | #define __M66592_UDC_H__ |
| 15 | 15 | ||
| 16 | #ifdef CONFIG_HAVE_CLK | ||
| 17 | #include <linux/clk.h> | 16 | #include <linux/clk.h> |
| 18 | #endif | ||
| 19 | |||
| 20 | #include <linux/usb/m66592.h> | 17 | #include <linux/usb/m66592.h> |
| 21 | 18 | ||
| 22 | #define M66592_SYSCFG 0x00 | 19 | #define M66592_SYSCFG 0x00 |
| @@ -468,9 +465,7 @@ struct m66592_ep { | |||
| 468 | struct m66592 { | 465 | struct m66592 { |
| 469 | spinlock_t lock; | 466 | spinlock_t lock; |
| 470 | void __iomem *reg; | 467 | void __iomem *reg; |
| 471 | #ifdef CONFIG_HAVE_CLK | ||
| 472 | struct clk *clk; | 468 | struct clk *clk; |
| 473 | #endif | ||
| 474 | struct m66592_platdata *pdata; | 469 | struct m66592_platdata *pdata; |
| 475 | unsigned long irq_trigger; | 470 | unsigned long irq_trigger; |
| 476 | 471 | ||
diff --git a/drivers/usb/gadget/r8a66597-udc.c b/drivers/usb/gadget/r8a66597-udc.c index f3ac2a20c27c..5a80751accb7 100644 --- a/drivers/usb/gadget/r8a66597-udc.c +++ b/drivers/usb/gadget/r8a66597-udc.c | |||
| @@ -1831,12 +1831,12 @@ static int __exit r8a66597_remove(struct platform_device *pdev) | |||
| 1831 | iounmap(r8a66597->sudmac_reg); | 1831 | iounmap(r8a66597->sudmac_reg); |
| 1832 | free_irq(platform_get_irq(pdev, 0), r8a66597); | 1832 | free_irq(platform_get_irq(pdev, 0), r8a66597); |
| 1833 | r8a66597_free_request(&r8a66597->ep[0].ep, r8a66597->ep0_req); | 1833 | r8a66597_free_request(&r8a66597->ep[0].ep, r8a66597->ep0_req); |
| 1834 | #ifdef CONFIG_HAVE_CLK | 1834 | |
| 1835 | if (r8a66597->pdata->on_chip) { | 1835 | if (r8a66597->pdata->on_chip) { |
| 1836 | clk_disable(r8a66597->clk); | 1836 | clk_disable(r8a66597->clk); |
| 1837 | clk_put(r8a66597->clk); | 1837 | clk_put(r8a66597->clk); |
| 1838 | } | 1838 | } |
| 1839 | #endif | 1839 | |
| 1840 | device_unregister(&r8a66597->gadget.dev); | 1840 | device_unregister(&r8a66597->gadget.dev); |
| 1841 | kfree(r8a66597); | 1841 | kfree(r8a66597); |
| 1842 | return 0; | 1842 | return 0; |
| @@ -1868,9 +1868,7 @@ static int __init r8a66597_sudmac_ioremap(struct r8a66597 *r8a66597, | |||
| 1868 | 1868 | ||
| 1869 | static int __init r8a66597_probe(struct platform_device *pdev) | 1869 | static int __init r8a66597_probe(struct platform_device *pdev) |
| 1870 | { | 1870 | { |
| 1871 | #ifdef CONFIG_HAVE_CLK | ||
| 1872 | char clk_name[8]; | 1871 | char clk_name[8]; |
| 1873 | #endif | ||
| 1874 | struct resource *res, *ires; | 1872 | struct resource *res, *ires; |
| 1875 | int irq; | 1873 | int irq; |
| 1876 | void __iomem *reg = NULL; | 1874 | void __iomem *reg = NULL; |
| @@ -1934,7 +1932,6 @@ static int __init r8a66597_probe(struct platform_device *pdev) | |||
| 1934 | r8a66597->timer.data = (unsigned long)r8a66597; | 1932 | r8a66597->timer.data = (unsigned long)r8a66597; |
| 1935 | r8a66597->reg = reg; | 1933 | r8a66597->reg = reg; |
| 1936 | 1934 | ||
| 1937 | #ifdef CONFIG_HAVE_CLK | ||
| 1938 | if (r8a66597->pdata->on_chip) { | 1935 | if (r8a66597->pdata->on_chip) { |
| 1939 | snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); | 1936 | snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); |
| 1940 | r8a66597->clk = clk_get(&pdev->dev, clk_name); | 1937 | r8a66597->clk = clk_get(&pdev->dev, clk_name); |
| @@ -1946,7 +1943,7 @@ static int __init r8a66597_probe(struct platform_device *pdev) | |||
| 1946 | } | 1943 | } |
| 1947 | clk_enable(r8a66597->clk); | 1944 | clk_enable(r8a66597->clk); |
| 1948 | } | 1945 | } |
| 1949 | #endif | 1946 | |
| 1950 | if (r8a66597->pdata->sudmac) { | 1947 | if (r8a66597->pdata->sudmac) { |
| 1951 | ret = r8a66597_sudmac_ioremap(r8a66597, pdev); | 1948 | ret = r8a66597_sudmac_ioremap(r8a66597, pdev); |
| 1952 | if (ret < 0) | 1949 | if (ret < 0) |
| @@ -2006,13 +2003,11 @@ err_add_udc: | |||
| 2006 | clean_up3: | 2003 | clean_up3: |
| 2007 | free_irq(irq, r8a66597); | 2004 | free_irq(irq, r8a66597); |
| 2008 | clean_up2: | 2005 | clean_up2: |
| 2009 | #ifdef CONFIG_HAVE_CLK | ||
| 2010 | if (r8a66597->pdata->on_chip) { | 2006 | if (r8a66597->pdata->on_chip) { |
| 2011 | clk_disable(r8a66597->clk); | 2007 | clk_disable(r8a66597->clk); |
| 2012 | clk_put(r8a66597->clk); | 2008 | clk_put(r8a66597->clk); |
| 2013 | } | 2009 | } |
| 2014 | clean_up_dev: | 2010 | clean_up_dev: |
| 2015 | #endif | ||
| 2016 | device_unregister(&r8a66597->gadget.dev); | 2011 | device_unregister(&r8a66597->gadget.dev); |
| 2017 | clean_up: | 2012 | clean_up: |
| 2018 | if (r8a66597) { | 2013 | if (r8a66597) { |
diff --git a/drivers/usb/gadget/r8a66597-udc.h b/drivers/usb/gadget/r8a66597-udc.h index 99908c76ccd1..45c4b2df1785 100644 --- a/drivers/usb/gadget/r8a66597-udc.h +++ b/drivers/usb/gadget/r8a66597-udc.h | |||
| @@ -13,10 +13,7 @@ | |||
| 13 | #ifndef __R8A66597_H__ | 13 | #ifndef __R8A66597_H__ |
| 14 | #define __R8A66597_H__ | 14 | #define __R8A66597_H__ |
| 15 | 15 | ||
| 16 | #ifdef CONFIG_HAVE_CLK | ||
| 17 | #include <linux/clk.h> | 16 | #include <linux/clk.h> |
| 18 | #endif | ||
| 19 | |||
| 20 | #include <linux/usb/r8a66597.h> | 17 | #include <linux/usb/r8a66597.h> |
| 21 | 18 | ||
| 22 | #define R8A66597_MAX_SAMPLING 10 | 19 | #define R8A66597_MAX_SAMPLING 10 |
| @@ -92,9 +89,7 @@ struct r8a66597 { | |||
| 92 | void __iomem *reg; | 89 | void __iomem *reg; |
| 93 | void __iomem *sudmac_reg; | 90 | void __iomem *sudmac_reg; |
| 94 | 91 | ||
| 95 | #ifdef CONFIG_HAVE_CLK | ||
| 96 | struct clk *clk; | 92 | struct clk *clk; |
| 97 | #endif | ||
| 98 | struct r8a66597_platdata *pdata; | 93 | struct r8a66597_platdata *pdata; |
| 99 | 94 | ||
| 100 | struct usb_gadget gadget; | 95 | struct usb_gadget gadget; |
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index c868be65e763..4c634eb56358 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
| @@ -95,9 +95,7 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597) | |||
| 95 | int i = 0; | 95 | int i = 0; |
| 96 | 96 | ||
| 97 | if (r8a66597->pdata->on_chip) { | 97 | if (r8a66597->pdata->on_chip) { |
| 98 | #ifdef CONFIG_HAVE_CLK | ||
| 99 | clk_enable(r8a66597->clk); | 98 | clk_enable(r8a66597->clk); |
| 100 | #endif | ||
| 101 | do { | 99 | do { |
| 102 | r8a66597_write(r8a66597, SCKE, SYSCFG0); | 100 | r8a66597_write(r8a66597, SCKE, SYSCFG0); |
| 103 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 101 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
| @@ -141,9 +139,7 @@ static void r8a66597_clock_disable(struct r8a66597 *r8a66597) | |||
| 141 | udelay(1); | 139 | udelay(1); |
| 142 | 140 | ||
| 143 | if (r8a66597->pdata->on_chip) { | 141 | if (r8a66597->pdata->on_chip) { |
| 144 | #ifdef CONFIG_HAVE_CLK | ||
| 145 | clk_disable(r8a66597->clk); | 142 | clk_disable(r8a66597->clk); |
| 146 | #endif | ||
| 147 | } else { | 143 | } else { |
| 148 | r8a66597_bclr(r8a66597, PLLC, SYSCFG0); | 144 | r8a66597_bclr(r8a66597, PLLC, SYSCFG0); |
| 149 | r8a66597_bclr(r8a66597, XCKE, SYSCFG0); | 145 | r8a66597_bclr(r8a66597, XCKE, SYSCFG0); |
| @@ -2406,19 +2402,15 @@ static int __devexit r8a66597_remove(struct platform_device *pdev) | |||
| 2406 | del_timer_sync(&r8a66597->rh_timer); | 2402 | del_timer_sync(&r8a66597->rh_timer); |
| 2407 | usb_remove_hcd(hcd); | 2403 | usb_remove_hcd(hcd); |
| 2408 | iounmap(r8a66597->reg); | 2404 | iounmap(r8a66597->reg); |
| 2409 | #ifdef CONFIG_HAVE_CLK | ||
| 2410 | if (r8a66597->pdata->on_chip) | 2405 | if (r8a66597->pdata->on_chip) |
| 2411 | clk_put(r8a66597->clk); | 2406 | clk_put(r8a66597->clk); |
| 2412 | #endif | ||
| 2413 | usb_put_hcd(hcd); | 2407 | usb_put_hcd(hcd); |
| 2414 | return 0; | 2408 | return 0; |
| 2415 | } | 2409 | } |
| 2416 | 2410 | ||
| 2417 | static int __devinit r8a66597_probe(struct platform_device *pdev) | 2411 | static int __devinit r8a66597_probe(struct platform_device *pdev) |
| 2418 | { | 2412 | { |
| 2419 | #ifdef CONFIG_HAVE_CLK | ||
| 2420 | char clk_name[8]; | 2413 | char clk_name[8]; |
| 2421 | #endif | ||
| 2422 | struct resource *res = NULL, *ires; | 2414 | struct resource *res = NULL, *ires; |
| 2423 | int irq = -1; | 2415 | int irq = -1; |
| 2424 | void __iomem *reg = NULL; | 2416 | void __iomem *reg = NULL; |
| @@ -2482,7 +2474,6 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) | |||
| 2482 | r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; | 2474 | r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; |
| 2483 | 2475 | ||
| 2484 | if (r8a66597->pdata->on_chip) { | 2476 | if (r8a66597->pdata->on_chip) { |
| 2485 | #ifdef CONFIG_HAVE_CLK | ||
| 2486 | snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); | 2477 | snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); |
| 2487 | r8a66597->clk = clk_get(&pdev->dev, clk_name); | 2478 | r8a66597->clk = clk_get(&pdev->dev, clk_name); |
| 2488 | if (IS_ERR(r8a66597->clk)) { | 2479 | if (IS_ERR(r8a66597->clk)) { |
| @@ -2491,7 +2482,6 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) | |||
| 2491 | ret = PTR_ERR(r8a66597->clk); | 2482 | ret = PTR_ERR(r8a66597->clk); |
| 2492 | goto clean_up2; | 2483 | goto clean_up2; |
| 2493 | } | 2484 | } |
| 2494 | #endif | ||
| 2495 | r8a66597->max_root_hub = 1; | 2485 | r8a66597->max_root_hub = 1; |
| 2496 | } else | 2486 | } else |
| 2497 | r8a66597->max_root_hub = 2; | 2487 | r8a66597->max_root_hub = 2; |
| @@ -2531,11 +2521,9 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) | |||
| 2531 | return 0; | 2521 | return 0; |
| 2532 | 2522 | ||
| 2533 | clean_up3: | 2523 | clean_up3: |
| 2534 | #ifdef CONFIG_HAVE_CLK | ||
| 2535 | if (r8a66597->pdata->on_chip) | 2524 | if (r8a66597->pdata->on_chip) |
| 2536 | clk_put(r8a66597->clk); | 2525 | clk_put(r8a66597->clk); |
| 2537 | clean_up2: | 2526 | clean_up2: |
| 2538 | #endif | ||
| 2539 | usb_put_hcd(hcd); | 2527 | usb_put_hcd(hcd); |
| 2540 | 2528 | ||
| 2541 | clean_up: | 2529 | clean_up: |
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h index f28782d20eef..672cea307abb 100644 --- a/drivers/usb/host/r8a66597.h +++ b/drivers/usb/host/r8a66597.h | |||
| @@ -26,10 +26,7 @@ | |||
| 26 | #ifndef __R8A66597_H__ | 26 | #ifndef __R8A66597_H__ |
| 27 | #define __R8A66597_H__ | 27 | #define __R8A66597_H__ |
| 28 | 28 | ||
| 29 | #ifdef CONFIG_HAVE_CLK | ||
| 30 | #include <linux/clk.h> | 29 | #include <linux/clk.h> |
| 31 | #endif | ||
| 32 | |||
| 33 | #include <linux/usb/r8a66597.h> | 30 | #include <linux/usb/r8a66597.h> |
| 34 | 31 | ||
| 35 | #define R8A66597_MAX_NUM_PIPE 10 | 32 | #define R8A66597_MAX_NUM_PIPE 10 |
| @@ -113,9 +110,7 @@ struct r8a66597_root_hub { | |||
| 113 | struct r8a66597 { | 110 | struct r8a66597 { |
| 114 | spinlock_t lock; | 111 | spinlock_t lock; |
| 115 | void __iomem *reg; | 112 | void __iomem *reg; |
| 116 | #ifdef CONFIG_HAVE_CLK | ||
| 117 | struct clk *clk; | 113 | struct clk *clk; |
| 118 | #endif | ||
| 119 | struct r8a66597_platdata *pdata; | 114 | struct r8a66597_platdata *pdata; |
| 120 | struct r8a66597_device device0; | 115 | struct r8a66597_device device0; |
| 121 | struct r8a66597_root_hub root_hub[R8A66597_MAX_ROOT_HUB]; | 116 | struct r8a66597_root_hub root_hub[R8A66597_MAX_ROOT_HUB]; |
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index dbcdeea30f09..586105b55a7c 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h | |||
| @@ -81,14 +81,6 @@ struct musb_ep; | |||
| 81 | #define is_peripheral_active(m) (!(m)->is_host) | 81 | #define is_peripheral_active(m) (!(m)->is_host) |
| 82 | #define is_host_active(m) ((m)->is_host) | 82 | #define is_host_active(m) ((m)->is_host) |
| 83 | 83 | ||
| 84 | #ifndef CONFIG_HAVE_CLK | ||
| 85 | /* Dummy stub for clk framework */ | ||
| 86 | #define clk_get(dev, id) NULL | ||
| 87 | #define clk_put(clock) do {} while (0) | ||
| 88 | #define clk_enable(clock) do {} while (0) | ||
| 89 | #define clk_disable(clock) do {} while (0) | ||
| 90 | #endif | ||
| 91 | |||
| 92 | #ifdef CONFIG_PROC_FS | 84 | #ifdef CONFIG_PROC_FS |
| 93 | #include <linux/fs.h> | 85 | #include <linux/fs.h> |
| 94 | #define MUSB_CONFIG_PROC_FS | 86 | #define MUSB_CONFIG_PROC_FS |
diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c index 0443a4f71858..df1cbb7ef6ca 100644 --- a/drivers/video/backlight/atmel-pwm-bl.c +++ b/drivers/video/backlight/atmel-pwm-bl.c | |||
| @@ -127,7 +127,8 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev) | |||
| 127 | struct atmel_pwm_bl *pwmbl; | 127 | struct atmel_pwm_bl *pwmbl; |
| 128 | int retval; | 128 | int retval; |
| 129 | 129 | ||
| 130 | pwmbl = kzalloc(sizeof(struct atmel_pwm_bl), GFP_KERNEL); | 130 | pwmbl = devm_kzalloc(&pdev->dev, sizeof(struct atmel_pwm_bl), |
| 131 | GFP_KERNEL); | ||
| 131 | if (!pwmbl) | 132 | if (!pwmbl) |
| 132 | return -ENOMEM; | 133 | return -ENOMEM; |
| 133 | 134 | ||
| @@ -154,7 +155,8 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev) | |||
| 154 | goto err_free_mem; | 155 | goto err_free_mem; |
| 155 | 156 | ||
| 156 | if (pwmbl->gpio_on != -1) { | 157 | if (pwmbl->gpio_on != -1) { |
| 157 | retval = gpio_request(pwmbl->gpio_on, "gpio_atmel_pwm_bl"); | 158 | retval = devm_gpio_request(&pdev->dev, pwmbl->gpio_on, |
| 159 | "gpio_atmel_pwm_bl"); | ||
| 158 | if (retval) { | 160 | if (retval) { |
| 159 | pwmbl->gpio_on = -1; | 161 | pwmbl->gpio_on = -1; |
| 160 | goto err_free_pwm; | 162 | goto err_free_pwm; |
| @@ -164,7 +166,7 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev) | |||
| 164 | retval = gpio_direction_output(pwmbl->gpio_on, | 166 | retval = gpio_direction_output(pwmbl->gpio_on, |
| 165 | 0 ^ pdata->on_active_low); | 167 | 0 ^ pdata->on_active_low); |
| 166 | if (retval) | 168 | if (retval) |
| 167 | goto err_free_gpio; | 169 | goto err_free_pwm; |
| 168 | } | 170 | } |
| 169 | 171 | ||
| 170 | memset(&props, 0, sizeof(struct backlight_properties)); | 172 | memset(&props, 0, sizeof(struct backlight_properties)); |
| @@ -174,7 +176,7 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev) | |||
| 174 | &atmel_pwm_bl_ops, &props); | 176 | &atmel_pwm_bl_ops, &props); |
| 175 | if (IS_ERR(bldev)) { | 177 | if (IS_ERR(bldev)) { |
| 176 | retval = PTR_ERR(bldev); | 178 | retval = PTR_ERR(bldev); |
| 177 | goto err_free_gpio; | 179 | goto err_free_pwm; |
| 178 | } | 180 | } |
| 179 | 181 | ||
| 180 | pwmbl->bldev = bldev; | 182 | pwmbl->bldev = bldev; |
| @@ -196,13 +198,9 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev) | |||
| 196 | err_free_bl_dev: | 198 | err_free_bl_dev: |
| 197 | platform_set_drvdata(pdev, NULL); | 199 | platform_set_drvdata(pdev, NULL); |
| 198 | backlight_device_unregister(bldev); | 200 | backlight_device_unregister(bldev); |
| 199 | err_free_gpio: | ||
| 200 | if (pwmbl->gpio_on != -1) | ||
| 201 | gpio_free(pwmbl->gpio_on); | ||
| 202 | err_free_pwm: | 201 | err_free_pwm: |
| 203 | pwm_channel_free(&pwmbl->pwmc); | 202 | pwm_channel_free(&pwmbl->pwmc); |
| 204 | err_free_mem: | 203 | err_free_mem: |
| 205 | kfree(pwmbl); | ||
| 206 | return retval; | 204 | return retval; |
| 207 | } | 205 | } |
| 208 | 206 | ||
| @@ -210,15 +208,12 @@ static int __exit atmel_pwm_bl_remove(struct platform_device *pdev) | |||
| 210 | { | 208 | { |
| 211 | struct atmel_pwm_bl *pwmbl = platform_get_drvdata(pdev); | 209 | struct atmel_pwm_bl *pwmbl = platform_get_drvdata(pdev); |
| 212 | 210 | ||
| 213 | if (pwmbl->gpio_on != -1) { | 211 | if (pwmbl->gpio_on != -1) |
| 214 | gpio_set_value(pwmbl->gpio_on, 0); | 212 | gpio_set_value(pwmbl->gpio_on, 0); |
| 215 | gpio_free(pwmbl->gpio_on); | ||
| 216 | } | ||
| 217 | pwm_channel_disable(&pwmbl->pwmc); | 213 | pwm_channel_disable(&pwmbl->pwmc); |
| 218 | pwm_channel_free(&pwmbl->pwmc); | 214 | pwm_channel_free(&pwmbl->pwmc); |
| 219 | backlight_device_unregister(pwmbl->bldev); | 215 | backlight_device_unregister(pwmbl->bldev); |
| 220 | platform_set_drvdata(pdev, NULL); | 216 | platform_set_drvdata(pdev, NULL); |
| 221 | kfree(pwmbl); | ||
| 222 | 217 | ||
| 223 | return 0; | 218 | return 0; |
| 224 | } | 219 | } |
diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c index 23d732677ba1..c781768ba892 100644 --- a/drivers/video/backlight/corgi_lcd.c +++ b/drivers/video/backlight/corgi_lcd.c | |||
| @@ -492,7 +492,8 @@ static int setup_gpio_backlight(struct corgi_lcd *lcd, | |||
| 492 | lcd->gpio_backlight_cont = -1; | 492 | lcd->gpio_backlight_cont = -1; |
| 493 | 493 | ||
| 494 | if (gpio_is_valid(pdata->gpio_backlight_on)) { | 494 | if (gpio_is_valid(pdata->gpio_backlight_on)) { |
| 495 | err = gpio_request(pdata->gpio_backlight_on, "BL_ON"); | 495 | err = devm_gpio_request(&spi->dev, pdata->gpio_backlight_on, |
| 496 | "BL_ON"); | ||
| 496 | if (err) { | 497 | if (err) { |
| 497 | dev_err(&spi->dev, "failed to request GPIO%d for " | 498 | dev_err(&spi->dev, "failed to request GPIO%d for " |
| 498 | "backlight_on\n", pdata->gpio_backlight_on); | 499 | "backlight_on\n", pdata->gpio_backlight_on); |
| @@ -504,11 +505,12 @@ static int setup_gpio_backlight(struct corgi_lcd *lcd, | |||
| 504 | } | 505 | } |
| 505 | 506 | ||
| 506 | if (gpio_is_valid(pdata->gpio_backlight_cont)) { | 507 | if (gpio_is_valid(pdata->gpio_backlight_cont)) { |
| 507 | err = gpio_request(pdata->gpio_backlight_cont, "BL_CONT"); | 508 | err = devm_gpio_request(&spi->dev, pdata->gpio_backlight_cont, |
| 509 | "BL_CONT"); | ||
| 508 | if (err) { | 510 | if (err) { |
| 509 | dev_err(&spi->dev, "failed to request GPIO%d for " | 511 | dev_err(&spi->dev, "failed to request GPIO%d for " |
| 510 | "backlight_cont\n", pdata->gpio_backlight_cont); | 512 | "backlight_cont\n", pdata->gpio_backlight_cont); |
| 511 | goto err_free_backlight_on; | 513 | return err; |
| 512 | } | 514 | } |
| 513 | 515 | ||
| 514 | lcd->gpio_backlight_cont = pdata->gpio_backlight_cont; | 516 | lcd->gpio_backlight_cont = pdata->gpio_backlight_cont; |
| @@ -525,11 +527,6 @@ static int setup_gpio_backlight(struct corgi_lcd *lcd, | |||
| 525 | } | 527 | } |
| 526 | } | 528 | } |
| 527 | return 0; | 529 | return 0; |
| 528 | |||
| 529 | err_free_backlight_on: | ||
| 530 | if (gpio_is_valid(lcd->gpio_backlight_on)) | ||
| 531 | gpio_free(lcd->gpio_backlight_on); | ||
| 532 | return err; | ||
| 533 | } | 530 | } |
| 534 | 531 | ||
| 535 | static int __devinit corgi_lcd_probe(struct spi_device *spi) | 532 | static int __devinit corgi_lcd_probe(struct spi_device *spi) |
| @@ -602,12 +599,6 @@ static int __devexit corgi_lcd_remove(struct spi_device *spi) | |||
| 602 | backlight_update_status(lcd->bl_dev); | 599 | backlight_update_status(lcd->bl_dev); |
| 603 | backlight_device_unregister(lcd->bl_dev); | 600 | backlight_device_unregister(lcd->bl_dev); |
| 604 | 601 | ||
| 605 | if (gpio_is_valid(lcd->gpio_backlight_on)) | ||
| 606 | gpio_free(lcd->gpio_backlight_on); | ||
| 607 | |||
| 608 | if (gpio_is_valid(lcd->gpio_backlight_cont)) | ||
| 609 | gpio_free(lcd->gpio_backlight_cont); | ||
| 610 | |||
| 611 | corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN); | 602 | corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN); |
| 612 | lcd_device_unregister(lcd->lcd_dev); | 603 | lcd_device_unregister(lcd->lcd_dev); |
| 613 | 604 | ||
diff --git a/drivers/video/backlight/l4f00242t03.c b/drivers/video/backlight/l4f00242t03.c index 40f606a86093..2d90c0648aa0 100644 --- a/drivers/video/backlight/l4f00242t03.c +++ b/drivers/video/backlight/l4f00242t03.c | |||
| @@ -175,28 +175,27 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) | |||
| 175 | 175 | ||
| 176 | priv->spi = spi; | 176 | priv->spi = spi; |
| 177 | 177 | ||
| 178 | ret = gpio_request_one(pdata->reset_gpio, GPIOF_OUT_INIT_HIGH, | 178 | ret = devm_gpio_request_one(&spi->dev, pdata->reset_gpio, |
| 179 | "lcd l4f00242t03 reset"); | 179 | GPIOF_OUT_INIT_HIGH, "lcd l4f00242t03 reset"); |
| 180 | if (ret) { | 180 | if (ret) { |
| 181 | dev_err(&spi->dev, | 181 | dev_err(&spi->dev, |
| 182 | "Unable to get the lcd l4f00242t03 reset gpio.\n"); | 182 | "Unable to get the lcd l4f00242t03 reset gpio.\n"); |
| 183 | return ret; | 183 | return ret; |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | ret = gpio_request_one(pdata->data_enable_gpio, GPIOF_OUT_INIT_LOW, | 186 | ret = devm_gpio_request_one(&spi->dev, pdata->data_enable_gpio, |
| 187 | "lcd l4f00242t03 data enable"); | 187 | GPIOF_OUT_INIT_LOW, "lcd l4f00242t03 data enable"); |
| 188 | if (ret) { | 188 | if (ret) { |
| 189 | dev_err(&spi->dev, | 189 | dev_err(&spi->dev, |
| 190 | "Unable to get the lcd l4f00242t03 data en gpio.\n"); | 190 | "Unable to get the lcd l4f00242t03 data en gpio.\n"); |
| 191 | goto err; | 191 | return ret; |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | priv->io_reg = regulator_get(&spi->dev, "vdd"); | 194 | priv->io_reg = regulator_get(&spi->dev, "vdd"); |
| 195 | if (IS_ERR(priv->io_reg)) { | 195 | if (IS_ERR(priv->io_reg)) { |
| 196 | ret = PTR_ERR(priv->io_reg); | ||
| 197 | dev_err(&spi->dev, "%s: Unable to get the IO regulator\n", | 196 | dev_err(&spi->dev, "%s: Unable to get the IO regulator\n", |
| 198 | __func__); | 197 | __func__); |
| 199 | goto err2; | 198 | return PTR_ERR(priv->io_reg); |
| 200 | } | 199 | } |
| 201 | 200 | ||
| 202 | priv->core_reg = regulator_get(&spi->dev, "vcore"); | 201 | priv->core_reg = regulator_get(&spi->dev, "vcore"); |
| @@ -204,14 +203,14 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) | |||
| 204 | ret = PTR_ERR(priv->core_reg); | 203 | ret = PTR_ERR(priv->core_reg); |
| 205 | dev_err(&spi->dev, "%s: Unable to get the core regulator\n", | 204 | dev_err(&spi->dev, "%s: Unable to get the core regulator\n", |
| 206 | __func__); | 205 | __func__); |
| 207 | goto err3; | 206 | goto err1; |
| 208 | } | 207 | } |
| 209 | 208 | ||
| 210 | priv->ld = lcd_device_register("l4f00242t03", | 209 | priv->ld = lcd_device_register("l4f00242t03", |
| 211 | &spi->dev, priv, &l4f_ops); | 210 | &spi->dev, priv, &l4f_ops); |
| 212 | if (IS_ERR(priv->ld)) { | 211 | if (IS_ERR(priv->ld)) { |
| 213 | ret = PTR_ERR(priv->ld); | 212 | ret = PTR_ERR(priv->ld); |
| 214 | goto err4; | 213 | goto err2; |
| 215 | } | 214 | } |
| 216 | 215 | ||
| 217 | /* Init the LCD */ | 216 | /* Init the LCD */ |
| @@ -223,14 +222,10 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) | |||
| 223 | 222 | ||
| 224 | return 0; | 223 | return 0; |
| 225 | 224 | ||
| 226 | err4: | 225 | err2: |
| 227 | regulator_put(priv->core_reg); | 226 | regulator_put(priv->core_reg); |
| 228 | err3: | 227 | err1: |
| 229 | regulator_put(priv->io_reg); | 228 | regulator_put(priv->io_reg); |
| 230 | err2: | ||
| 231 | gpio_free(pdata->data_enable_gpio); | ||
| 232 | err: | ||
| 233 | gpio_free(pdata->reset_gpio); | ||
| 234 | 229 | ||
| 235 | return ret; | 230 | return ret; |
| 236 | } | 231 | } |
| @@ -238,16 +233,12 @@ err: | |||
| 238 | static int __devexit l4f00242t03_remove(struct spi_device *spi) | 233 | static int __devexit l4f00242t03_remove(struct spi_device *spi) |
| 239 | { | 234 | { |
| 240 | struct l4f00242t03_priv *priv = dev_get_drvdata(&spi->dev); | 235 | struct l4f00242t03_priv *priv = dev_get_drvdata(&spi->dev); |
| 241 | struct l4f00242t03_pdata *pdata = priv->spi->dev.platform_data; | ||
| 242 | 236 | ||
| 243 | l4f00242t03_lcd_power_set(priv->ld, FB_BLANK_POWERDOWN); | 237 | l4f00242t03_lcd_power_set(priv->ld, FB_BLANK_POWERDOWN); |
| 244 | lcd_device_unregister(priv->ld); | 238 | lcd_device_unregister(priv->ld); |
| 245 | 239 | ||
| 246 | dev_set_drvdata(&spi->dev, NULL); | 240 | dev_set_drvdata(&spi->dev, NULL); |
| 247 | 241 | ||
| 248 | gpio_free(pdata->data_enable_gpio); | ||
| 249 | gpio_free(pdata->reset_gpio); | ||
| 250 | |||
| 251 | regulator_put(priv->io_reg); | 242 | regulator_put(priv->io_reg); |
| 252 | regulator_put(priv->core_reg); | 243 | regulator_put(priv->core_reg); |
| 253 | 244 | ||
diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c index bebeb63607db..18dca0c29c68 100644 --- a/drivers/video/backlight/lm3533_bl.c +++ b/drivers/video/backlight/lm3533_bl.c | |||
| @@ -295,7 +295,7 @@ static int __devinit lm3533_bl_probe(struct platform_device *pdev) | |||
| 295 | return -EINVAL; | 295 | return -EINVAL; |
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | bl = kzalloc(sizeof(*bl), GFP_KERNEL); | 298 | bl = devm_kzalloc(&pdev->dev, sizeof(*bl), GFP_KERNEL); |
| 299 | if (!bl) { | 299 | if (!bl) { |
| 300 | dev_err(&pdev->dev, | 300 | dev_err(&pdev->dev, |
| 301 | "failed to allocate memory for backlight\n"); | 301 | "failed to allocate memory for backlight\n"); |
| @@ -317,8 +317,7 @@ static int __devinit lm3533_bl_probe(struct platform_device *pdev) | |||
| 317 | &lm3533_bl_ops, &props); | 317 | &lm3533_bl_ops, &props); |
| 318 | if (IS_ERR(bd)) { | 318 | if (IS_ERR(bd)) { |
| 319 | dev_err(&pdev->dev, "failed to register backlight device\n"); | 319 | dev_err(&pdev->dev, "failed to register backlight device\n"); |
| 320 | ret = PTR_ERR(bd); | 320 | return PTR_ERR(bd); |
| 321 | goto err_free; | ||
| 322 | } | 321 | } |
| 323 | 322 | ||
| 324 | bl->bd = bd; | 323 | bl->bd = bd; |
| @@ -348,8 +347,6 @@ err_sysfs_remove: | |||
| 348 | sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group); | 347 | sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group); |
| 349 | err_unregister: | 348 | err_unregister: |
| 350 | backlight_device_unregister(bd); | 349 | backlight_device_unregister(bd); |
| 351 | err_free: | ||
| 352 | kfree(bl); | ||
| 353 | 350 | ||
| 354 | return ret; | 351 | return ret; |
| 355 | } | 352 | } |
| @@ -367,7 +364,6 @@ static int __devexit lm3533_bl_remove(struct platform_device *pdev) | |||
| 367 | lm3533_ctrlbank_disable(&bl->cb); | 364 | lm3533_ctrlbank_disable(&bl->cb); |
| 368 | sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group); | 365 | sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group); |
| 369 | backlight_device_unregister(bd); | 366 | backlight_device_unregister(bd); |
| 370 | kfree(bl); | ||
| 371 | 367 | ||
| 372 | return 0; | 368 | return 0; |
| 373 | } | 369 | } |
diff --git a/drivers/video/backlight/lms283gf05.c b/drivers/video/backlight/lms283gf05.c index a9f2c36966f1..ea43f2254196 100644 --- a/drivers/video/backlight/lms283gf05.c +++ b/drivers/video/backlight/lms283gf05.c | |||
| @@ -158,29 +158,27 @@ static int __devinit 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 = gpio_request(pdata->reset_gpio, "LMS285GF05 RESET"); | 161 | ret = devm_gpio_request(&spi->dev, pdata->reset_gpio, |
| 162 | "LMS285GF05 RESET"); | ||
| 162 | if (ret) | 163 | if (ret) |
| 163 | return ret; | 164 | return ret; |
| 164 | 165 | ||
| 165 | ret = gpio_direction_output(pdata->reset_gpio, | 166 | ret = gpio_direction_output(pdata->reset_gpio, |
| 166 | !pdata->reset_inverted); | 167 | !pdata->reset_inverted); |
| 167 | if (ret) | 168 | if (ret) |
| 168 | goto err; | 169 | return ret; |
| 169 | } | 170 | } |
| 170 | 171 | ||
| 171 | st = devm_kzalloc(&spi->dev, sizeof(struct lms283gf05_state), | 172 | st = devm_kzalloc(&spi->dev, sizeof(struct lms283gf05_state), |
| 172 | GFP_KERNEL); | 173 | GFP_KERNEL); |
| 173 | if (st == NULL) { | 174 | if (st == NULL) { |
| 174 | dev_err(&spi->dev, "No memory for device state\n"); | 175 | dev_err(&spi->dev, "No memory for device state\n"); |
| 175 | ret = -ENOMEM; | 176 | return -ENOMEM; |
| 176 | goto err; | ||
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | ld = lcd_device_register("lms283gf05", &spi->dev, st, &lms_ops); | 179 | ld = lcd_device_register("lms283gf05", &spi->dev, st, &lms_ops); |
| 180 | if (IS_ERR(ld)) { | 180 | if (IS_ERR(ld)) |
| 181 | ret = PTR_ERR(ld); | 181 | return PTR_ERR(ld); |
| 182 | goto err; | ||
| 183 | } | ||
| 184 | 182 | ||
| 185 | st->spi = spi; | 183 | st->spi = spi; |
| 186 | st->ld = ld; | 184 | st->ld = ld; |
| @@ -193,24 +191,14 @@ static int __devinit lms283gf05_probe(struct spi_device *spi) | |||
| 193 | lms283gf05_toggle(spi, disp_initseq, ARRAY_SIZE(disp_initseq)); | 191 | lms283gf05_toggle(spi, disp_initseq, ARRAY_SIZE(disp_initseq)); |
| 194 | 192 | ||
| 195 | return 0; | 193 | return 0; |
| 196 | |||
| 197 | err: | ||
| 198 | if (pdata != NULL) | ||
| 199 | gpio_free(pdata->reset_gpio); | ||
| 200 | |||
| 201 | return ret; | ||
| 202 | } | 194 | } |
| 203 | 195 | ||
| 204 | static int __devexit lms283gf05_remove(struct spi_device *spi) | 196 | static int __devexit lms283gf05_remove(struct spi_device *spi) |
| 205 | { | 197 | { |
| 206 | struct lms283gf05_state *st = dev_get_drvdata(&spi->dev); | 198 | struct lms283gf05_state *st = dev_get_drvdata(&spi->dev); |
| 207 | struct lms283gf05_pdata *pdata = st->spi->dev.platform_data; | ||
| 208 | 199 | ||
| 209 | lcd_device_unregister(st->ld); | 200 | lcd_device_unregister(st->ld); |
| 210 | 201 | ||
| 211 | if (pdata != NULL) | ||
| 212 | gpio_free(pdata->reset_gpio); | ||
| 213 | |||
| 214 | return 0; | 202 | return 0; |
| 215 | } | 203 | } |
| 216 | 204 | ||
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index 72a0e0c917cf..aa6d4f71131f 100644 --- a/drivers/video/backlight/lp855x_bl.c +++ b/drivers/video/backlight/lp855x_bl.c | |||
| @@ -14,11 +14,15 @@ | |||
| 14 | #include <linux/i2c.h> | 14 | #include <linux/i2c.h> |
| 15 | #include <linux/backlight.h> | 15 | #include <linux/backlight.h> |
| 16 | #include <linux/err.h> | 16 | #include <linux/err.h> |
| 17 | #include <linux/lp855x.h> | 17 | #include <linux/platform_data/lp855x.h> |
| 18 | 18 | ||
| 19 | /* Registers */ | 19 | /* Registers */ |
| 20 | #define BRIGHTNESS_CTRL (0x00) | 20 | #define BRIGHTNESS_CTRL 0x00 |
| 21 | #define DEVICE_CTRL (0x01) | 21 | #define DEVICE_CTRL 0x01 |
| 22 | #define EEPROM_START 0xA0 | ||
| 23 | #define EEPROM_END 0xA7 | ||
| 24 | #define EPROM_START 0xA0 | ||
| 25 | #define EPROM_END 0xAF | ||
| 22 | 26 | ||
| 23 | #define BUF_SIZE 20 | 27 | #define BUF_SIZE 20 |
| 24 | #define DEFAULT_BL_NAME "lcd-backlight" | 28 | #define DEFAULT_BL_NAME "lcd-backlight" |
diff --git a/drivers/video/backlight/ot200_bl.c b/drivers/video/backlight/ot200_bl.c index f519d55a294c..469cf0f109d2 100644 --- a/drivers/video/backlight/ot200_bl.c +++ b/drivers/video/backlight/ot200_bl.c | |||
| @@ -84,7 +84,8 @@ static int ot200_backlight_probe(struct platform_device *pdev) | |||
| 84 | int retval = 0; | 84 | int retval = 0; |
| 85 | 85 | ||
| 86 | /* request gpio */ | 86 | /* request gpio */ |
| 87 | if (gpio_request(GPIO_DIMM, "ot200 backlight dimmer") < 0) { | 87 | if (devm_gpio_request(&pdev->dev, GPIO_DIMM, |
| 88 | "ot200 backlight dimmer") < 0) { | ||
| 88 | dev_err(&pdev->dev, "failed to request GPIO %d\n", GPIO_DIMM); | 89 | dev_err(&pdev->dev, "failed to request GPIO %d\n", GPIO_DIMM); |
| 89 | return -ENODEV; | 90 | return -ENODEV; |
| 90 | } | 91 | } |
| @@ -93,14 +94,13 @@ static int ot200_backlight_probe(struct platform_device *pdev) | |||
| 93 | pwm_timer = cs5535_mfgpt_alloc_timer(7, MFGPT_DOMAIN_ANY); | 94 | pwm_timer = cs5535_mfgpt_alloc_timer(7, MFGPT_DOMAIN_ANY); |
| 94 | if (!pwm_timer) { | 95 | if (!pwm_timer) { |
| 95 | dev_err(&pdev->dev, "MFGPT 7 not available\n"); | 96 | dev_err(&pdev->dev, "MFGPT 7 not available\n"); |
| 96 | retval = -ENODEV; | 97 | return -ENODEV; |
| 97 | goto error_mfgpt_alloc; | ||
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 100 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); |
| 101 | if (!data) { | 101 | if (!data) { |
| 102 | retval = -ENOMEM; | 102 | retval = -ENOMEM; |
| 103 | goto error_kzalloc; | 103 | goto error_devm_kzalloc; |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | /* setup gpio */ | 106 | /* setup gpio */ |
| @@ -122,26 +122,21 @@ static int ot200_backlight_probe(struct platform_device *pdev) | |||
| 122 | if (IS_ERR(bl)) { | 122 | if (IS_ERR(bl)) { |
| 123 | dev_err(&pdev->dev, "failed to register backlight\n"); | 123 | dev_err(&pdev->dev, "failed to register backlight\n"); |
| 124 | retval = PTR_ERR(bl); | 124 | retval = PTR_ERR(bl); |
| 125 | goto error_backlight_device_register; | 125 | goto error_devm_kzalloc; |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | platform_set_drvdata(pdev, bl); | 128 | platform_set_drvdata(pdev, bl); |
| 129 | 129 | ||
| 130 | return 0; | 130 | return 0; |
| 131 | 131 | ||
| 132 | error_backlight_device_register: | 132 | error_devm_kzalloc: |
| 133 | kfree(data); | ||
| 134 | error_kzalloc: | ||
| 135 | cs5535_mfgpt_free_timer(pwm_timer); | 133 | cs5535_mfgpt_free_timer(pwm_timer); |
| 136 | error_mfgpt_alloc: | ||
| 137 | gpio_free(GPIO_DIMM); | ||
| 138 | return retval; | 134 | return retval; |
| 139 | } | 135 | } |
| 140 | 136 | ||
| 141 | static int ot200_backlight_remove(struct platform_device *pdev) | 137 | static int ot200_backlight_remove(struct platform_device *pdev) |
| 142 | { | 138 | { |
| 143 | struct backlight_device *bl = platform_get_drvdata(pdev); | 139 | struct backlight_device *bl = platform_get_drvdata(pdev); |
| 144 | struct ot200_backlight_data *data = bl_get_data(bl); | ||
| 145 | 140 | ||
| 146 | backlight_device_unregister(bl); | 141 | backlight_device_unregister(bl); |
| 147 | 142 | ||
| @@ -152,9 +147,7 @@ static int ot200_backlight_remove(struct platform_device *pdev) | |||
| 152 | MAX_COMP2 - dim_table[100]); | 147 | MAX_COMP2 - dim_table[100]); |
| 153 | 148 | ||
| 154 | cs5535_mfgpt_free_timer(pwm_timer); | 149 | cs5535_mfgpt_free_timer(pwm_timer); |
| 155 | gpio_free(GPIO_DIMM); | ||
| 156 | 150 | ||
| 157 | kfree(data); | ||
| 158 | return 0; | 151 | return 0; |
| 159 | } | 152 | } |
| 160 | 153 | ||
diff --git a/drivers/video/backlight/tosa_bl.c b/drivers/video/backlight/tosa_bl.c index 0d54e607e82d..49342e1d20be 100644 --- a/drivers/video/backlight/tosa_bl.c +++ b/drivers/video/backlight/tosa_bl.c | |||
| @@ -92,14 +92,14 @@ static int __devinit 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 = gpio_request(TOSA_GPIO_BL_C20MA, "backlight"); | 95 | ret = devm_gpio_request(&client->dev, TOSA_GPIO_BL_C20MA, "backlight"); |
| 96 | if (ret) { | 96 | if (ret) { |
| 97 | dev_dbg(&data->bl->dev, "Unable to request gpio!\n"); | 97 | dev_dbg(&data->bl->dev, "Unable to request gpio!\n"); |
| 98 | return ret; | 98 | return ret; |
| 99 | } | 99 | } |
| 100 | ret = gpio_direction_output(TOSA_GPIO_BL_C20MA, 0); | 100 | ret = gpio_direction_output(TOSA_GPIO_BL_C20MA, 0); |
| 101 | if (ret) | 101 | if (ret) |
| 102 | goto err_gpio_dir; | 102 | return ret; |
| 103 | 103 | ||
| 104 | i2c_set_clientdata(client, data); | 104 | i2c_set_clientdata(client, data); |
| 105 | data->i2c = client; | 105 | data->i2c = client; |
| @@ -123,8 +123,6 @@ static int __devinit tosa_bl_probe(struct i2c_client *client, | |||
| 123 | 123 | ||
| 124 | err_reg: | 124 | err_reg: |
| 125 | data->bl = NULL; | 125 | data->bl = NULL; |
| 126 | err_gpio_dir: | ||
| 127 | gpio_free(TOSA_GPIO_BL_C20MA); | ||
| 128 | return ret; | 126 | return ret; |
| 129 | } | 127 | } |
| 130 | 128 | ||
| @@ -135,8 +133,6 @@ static int __devexit tosa_bl_remove(struct i2c_client *client) | |||
| 135 | backlight_device_unregister(data->bl); | 133 | backlight_device_unregister(data->bl); |
| 136 | data->bl = NULL; | 134 | data->bl = NULL; |
| 137 | 135 | ||
| 138 | gpio_free(TOSA_GPIO_BL_C20MA); | ||
| 139 | |||
| 140 | return 0; | 136 | return 0; |
| 141 | } | 137 | } |
| 142 | 138 | ||
diff --git a/drivers/video/backlight/tosa_lcd.c b/drivers/video/backlight/tosa_lcd.c index 47823b8efff0..33047a66cc24 100644 --- a/drivers/video/backlight/tosa_lcd.c +++ b/drivers/video/backlight/tosa_lcd.c | |||
| @@ -193,7 +193,7 @@ static int __devinit tosa_lcd_probe(struct spi_device *spi) | |||
| 193 | data->spi = spi; | 193 | data->spi = spi; |
| 194 | dev_set_drvdata(&spi->dev, data); | 194 | dev_set_drvdata(&spi->dev, data); |
| 195 | 195 | ||
| 196 | ret = gpio_request(TOSA_GPIO_TG_ON, "tg #pwr"); | 196 | ret = devm_gpio_request(&spi->dev, TOSA_GPIO_TG_ON, "tg #pwr"); |
| 197 | if (ret < 0) | 197 | if (ret < 0) |
| 198 | goto err_gpio_tg; | 198 | goto err_gpio_tg; |
| 199 | 199 | ||
| @@ -201,7 +201,7 @@ static int __devinit tosa_lcd_probe(struct spi_device *spi) | |||
| 201 | 201 | ||
| 202 | ret = gpio_direction_output(TOSA_GPIO_TG_ON, 0); | 202 | ret = gpio_direction_output(TOSA_GPIO_TG_ON, 0); |
| 203 | if (ret < 0) | 203 | if (ret < 0) |
| 204 | goto err_gpio_dir; | 204 | goto err_gpio_tg; |
| 205 | 205 | ||
| 206 | mdelay(60); | 206 | mdelay(60); |
| 207 | tosa_lcd_tg_init(data); | 207 | tosa_lcd_tg_init(data); |
| @@ -221,8 +221,6 @@ static int __devinit tosa_lcd_probe(struct spi_device *spi) | |||
| 221 | 221 | ||
| 222 | err_register: | 222 | err_register: |
| 223 | tosa_lcd_tg_off(data); | 223 | tosa_lcd_tg_off(data); |
| 224 | err_gpio_dir: | ||
| 225 | gpio_free(TOSA_GPIO_TG_ON); | ||
| 226 | err_gpio_tg: | 224 | err_gpio_tg: |
| 227 | dev_set_drvdata(&spi->dev, NULL); | 225 | dev_set_drvdata(&spi->dev, NULL); |
| 228 | return ret; | 226 | return ret; |
| @@ -239,7 +237,6 @@ static int __devexit tosa_lcd_remove(struct spi_device *spi) | |||
| 239 | 237 | ||
| 240 | tosa_lcd_tg_off(data); | 238 | tosa_lcd_tg_off(data); |
| 241 | 239 | ||
| 242 | gpio_free(TOSA_GPIO_TG_ON); | ||
| 243 | dev_set_drvdata(&spi->dev, NULL); | 240 | dev_set_drvdata(&spi->dev, NULL); |
| 244 | 241 | ||
| 245 | return 0; | 242 | return 0; |
diff --git a/fs/affs/bitmap.c b/fs/affs/bitmap.c index 6e0be43ef6ef..a32246b8359e 100644 --- a/fs/affs/bitmap.c +++ b/fs/affs/bitmap.c | |||
| @@ -10,30 +10,6 @@ | |||
| 10 | #include <linux/slab.h> | 10 | #include <linux/slab.h> |
| 11 | #include "affs.h" | 11 | #include "affs.h" |
| 12 | 12 | ||
| 13 | /* This is, of course, shamelessly stolen from fs/minix */ | ||
| 14 | |||
| 15 | static const int nibblemap[] = { 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4 }; | ||
| 16 | |||
| 17 | static u32 | ||
| 18 | affs_count_free_bits(u32 blocksize, const void *data) | ||
| 19 | { | ||
| 20 | const u32 *map; | ||
| 21 | u32 free; | ||
| 22 | u32 tmp; | ||
| 23 | |||
| 24 | map = data; | ||
| 25 | free = 0; | ||
| 26 | for (blocksize /= 4; blocksize > 0; blocksize--) { | ||
| 27 | tmp = *map++; | ||
| 28 | while (tmp) { | ||
| 29 | free += nibblemap[tmp & 0xf]; | ||
| 30 | tmp >>= 4; | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 34 | return free; | ||
| 35 | } | ||
| 36 | |||
| 37 | u32 | 13 | u32 |
| 38 | affs_count_free_blocks(struct super_block *sb) | 14 | affs_count_free_blocks(struct super_block *sb) |
| 39 | { | 15 | { |
| @@ -317,7 +293,7 @@ int affs_init_bitmap(struct super_block *sb, int *flags) | |||
| 317 | goto out; | 293 | goto out; |
| 318 | } | 294 | } |
| 319 | pr_debug("AFFS: read bitmap block %d: %d\n", blk, bm->bm_key); | 295 | pr_debug("AFFS: read bitmap block %d: %d\n", blk, bm->bm_key); |
| 320 | bm->bm_free = affs_count_free_bits(sb->s_blocksize - 4, bh->b_data + 4); | 296 | bm->bm_free = memweight(bh->b_data + 4, sb->s_blocksize - 4); |
| 321 | 297 | ||
| 322 | /* Don't try read the extension if this is the last block, | 298 | /* Don't try read the extension if this is the last block, |
| 323 | * but we also need the right bm pointer below | 299 | * but we also need the right bm pointer below |
| @@ -367,7 +343,7 @@ int affs_init_bitmap(struct super_block *sb, int *flags) | |||
| 367 | 343 | ||
| 368 | /* recalculate bitmap count for last block */ | 344 | /* recalculate bitmap count for last block */ |
| 369 | bm--; | 345 | bm--; |
| 370 | bm->bm_free = affs_count_free_bits(sb->s_blocksize - 4, bh->b_data + 4); | 346 | bm->bm_free = memweight(bh->b_data + 4, sb->s_blocksize - 4); |
| 371 | 347 | ||
| 372 | out: | 348 | out: |
| 373 | affs_brelse(bh); | 349 | affs_brelse(bh); |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index adb1cd7ceb9b..4bab807227ad 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
| @@ -3342,10 +3342,22 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size); | |||
| 3342 | /* super.c */ | 3342 | /* super.c */ |
| 3343 | int btrfs_parse_options(struct btrfs_root *root, char *options); | 3343 | int btrfs_parse_options(struct btrfs_root *root, char *options); |
| 3344 | int btrfs_sync_fs(struct super_block *sb, int wait); | 3344 | int btrfs_sync_fs(struct super_block *sb, int wait); |
| 3345 | |||
| 3346 | #ifdef CONFIG_PRINTK | ||
| 3347 | __printf(2, 3) | ||
| 3345 | void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...); | 3348 | void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...); |
| 3349 | #else | ||
| 3350 | static inline __printf(2, 3) | ||
| 3351 | void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...) | ||
| 3352 | { | ||
| 3353 | } | ||
| 3354 | #endif | ||
| 3355 | |||
| 3356 | __printf(5, 6) | ||
| 3346 | void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, | 3357 | void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, |
| 3347 | unsigned int line, int errno, const char *fmt, ...); | 3358 | unsigned int line, int errno, const char *fmt, ...); |
| 3348 | 3359 | ||
| 3360 | |||
| 3349 | void __btrfs_abort_transaction(struct btrfs_trans_handle *trans, | 3361 | void __btrfs_abort_transaction(struct btrfs_trans_handle *trans, |
| 3350 | struct btrfs_root *root, const char *function, | 3362 | struct btrfs_root *root, const char *function, |
| 3351 | unsigned int line, int errno); | 3363 | unsigned int line, int errno); |
| @@ -3386,6 +3398,7 @@ do { \ | |||
| 3386 | (errno), fmt, ##args); \ | 3398 | (errno), fmt, ##args); \ |
| 3387 | } while (0) | 3399 | } while (0) |
| 3388 | 3400 | ||
| 3401 | __printf(5, 6) | ||
| 3389 | void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function, | 3402 | void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function, |
| 3390 | unsigned int line, int errno, const char *fmt, ...); | 3403 | unsigned int line, int errno, const char *fmt, ...); |
| 3391 | 3404 | ||
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 502b20c56e84..fadeba6a5db9 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
| @@ -1114,7 +1114,7 @@ void clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root, | |||
| 1114 | spin_unlock(&root->fs_info->delalloc_lock); | 1114 | spin_unlock(&root->fs_info->delalloc_lock); |
| 1115 | btrfs_panic(root->fs_info, -EOVERFLOW, | 1115 | btrfs_panic(root->fs_info, -EOVERFLOW, |
| 1116 | "Can't clear %lu bytes from " | 1116 | "Can't clear %lu bytes from " |
| 1117 | " dirty_mdatadata_bytes (%lu)", | 1117 | " dirty_mdatadata_bytes (%llu)", |
| 1118 | buf->len, | 1118 | buf->len, |
| 1119 | root->fs_info->dirty_metadata_bytes); | 1119 | root->fs_info->dirty_metadata_bytes); |
| 1120 | } | 1120 | } |
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index c5dbd9149679..4da08652004d 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c | |||
| @@ -1241,7 +1241,7 @@ static int __must_check __add_reloc_root(struct btrfs_root *root) | |||
| 1241 | if (rb_node) { | 1241 | if (rb_node) { |
| 1242 | btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found " | 1242 | btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found " |
| 1243 | "for start=%llu while inserting into relocation " | 1243 | "for start=%llu while inserting into relocation " |
| 1244 | "tree\n"); | 1244 | "tree\n", node->bytenr); |
| 1245 | kfree(node); | 1245 | kfree(node); |
| 1246 | return -EEXIST; | 1246 | return -EEXIST; |
| 1247 | } | 1247 | } |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index fa61ef59cd61..8c6e61d6eed5 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
| @@ -125,6 +125,7 @@ static void btrfs_handle_error(struct btrfs_fs_info *fs_info) | |||
| 125 | } | 125 | } |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | #ifdef CONFIG_PRINTK | ||
| 128 | /* | 129 | /* |
| 129 | * __btrfs_std_error decodes expected errors from the caller and | 130 | * __btrfs_std_error decodes expected errors from the caller and |
| 130 | * invokes the approciate error response. | 131 | * invokes the approciate error response. |
| @@ -167,7 +168,7 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, | |||
| 167 | va_end(args); | 168 | va_end(args); |
| 168 | } | 169 | } |
| 169 | 170 | ||
| 170 | const char *logtypes[] = { | 171 | static const char * const logtypes[] = { |
| 171 | "emergency", | 172 | "emergency", |
| 172 | "alert", | 173 | "alert", |
| 173 | "critical", | 174 | "critical", |
| @@ -185,22 +186,50 @@ void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...) | |||
| 185 | struct va_format vaf; | 186 | struct va_format vaf; |
| 186 | va_list args; | 187 | va_list args; |
| 187 | const char *type = logtypes[4]; | 188 | const char *type = logtypes[4]; |
| 189 | int kern_level; | ||
| 188 | 190 | ||
| 189 | va_start(args, fmt); | 191 | va_start(args, fmt); |
| 190 | 192 | ||
| 191 | if (fmt[0] == '<' && isdigit(fmt[1]) && fmt[2] == '>') { | 193 | kern_level = printk_get_level(fmt); |
| 192 | memcpy(lvl, fmt, 3); | 194 | if (kern_level) { |
| 193 | lvl[3] = '\0'; | 195 | size_t size = printk_skip_level(fmt) - fmt; |
| 194 | fmt += 3; | 196 | memcpy(lvl, fmt, size); |
| 195 | type = logtypes[fmt[1] - '0']; | 197 | lvl[size] = '\0'; |
| 198 | fmt += size; | ||
| 199 | type = logtypes[kern_level - '0']; | ||
| 196 | } else | 200 | } else |
| 197 | *lvl = '\0'; | 201 | *lvl = '\0'; |
| 198 | 202 | ||
| 199 | vaf.fmt = fmt; | 203 | vaf.fmt = fmt; |
| 200 | vaf.va = &args; | 204 | vaf.va = &args; |
| 205 | |||
| 201 | printk("%sBTRFS %s (device %s): %pV", lvl, type, sb->s_id, &vaf); | 206 | printk("%sBTRFS %s (device %s): %pV", lvl, type, sb->s_id, &vaf); |
| 207 | |||
| 208 | va_end(args); | ||
| 202 | } | 209 | } |
| 203 | 210 | ||
| 211 | #else | ||
| 212 | |||
| 213 | void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, | ||
| 214 | unsigned int line, int errno, const char *fmt, ...) | ||
| 215 | { | ||
| 216 | struct super_block *sb = fs_info->sb; | ||
| 217 | |||
| 218 | /* | ||
| 219 | * Special case: if the error is EROFS, and we're already | ||
| 220 | * under MS_RDONLY, then it is safe here. | ||
| 221 | */ | ||
| 222 | if (errno == -EROFS && (sb->s_flags & MS_RDONLY)) | ||
| 223 | return; | ||
| 224 | |||
| 225 | /* Don't go through full error handling during mount */ | ||
| 226 | if (sb->s_flags & MS_BORN) { | ||
| 227 | save_error_info(fs_info); | ||
| 228 | btrfs_handle_error(fs_info); | ||
| 229 | } | ||
| 230 | } | ||
| 231 | #endif | ||
| 232 | |||
| 204 | /* | 233 | /* |
| 205 | * We only mark the transaction aborted and then set the file system read-only. | 234 | * We only mark the transaction aborted and then set the file system read-only. |
| 206 | * This will prevent new transactions from starting or trying to join this | 235 | * This will prevent new transactions from starting or trying to join this |
diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c index c0353dfac51f..c994691d9445 100644 --- a/fs/cachefiles/rdwr.c +++ b/fs/cachefiles/rdwr.c | |||
| @@ -919,7 +919,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page) | |||
| 919 | * own time */ | 919 | * own time */ |
| 920 | path.mnt = cache->mnt; | 920 | path.mnt = cache->mnt; |
| 921 | path.dentry = object->backer; | 921 | path.dentry = object->backer; |
| 922 | file = dentry_open(&path, O_RDWR, cache->cache_cred); | 922 | file = dentry_open(&path, O_RDWR | O_LARGEFILE, cache->cache_cred); |
| 923 | if (IS_ERR(file)) { | 923 | if (IS_ERR(file)) { |
| 924 | ret = PTR_ERR(file); | 924 | ret = PTR_ERR(file); |
| 925 | } else { | 925 | } else { |
| @@ -2002,17 +2002,17 @@ static void coredump_finish(struct mm_struct *mm) | |||
| 2002 | void set_dumpable(struct mm_struct *mm, int value) | 2002 | void set_dumpable(struct mm_struct *mm, int value) |
| 2003 | { | 2003 | { |
| 2004 | switch (value) { | 2004 | switch (value) { |
| 2005 | case 0: | 2005 | case SUID_DUMPABLE_DISABLED: |
| 2006 | clear_bit(MMF_DUMPABLE, &mm->flags); | 2006 | clear_bit(MMF_DUMPABLE, &mm->flags); |
| 2007 | smp_wmb(); | 2007 | smp_wmb(); |
| 2008 | clear_bit(MMF_DUMP_SECURELY, &mm->flags); | 2008 | clear_bit(MMF_DUMP_SECURELY, &mm->flags); |
| 2009 | break; | 2009 | break; |
| 2010 | case 1: | 2010 | case SUID_DUMPABLE_ENABLED: |
| 2011 | set_bit(MMF_DUMPABLE, &mm->flags); | 2011 | set_bit(MMF_DUMPABLE, &mm->flags); |
| 2012 | smp_wmb(); | 2012 | smp_wmb(); |
| 2013 | clear_bit(MMF_DUMP_SECURELY, &mm->flags); | 2013 | clear_bit(MMF_DUMP_SECURELY, &mm->flags); |
| 2014 | break; | 2014 | break; |
| 2015 | case 2: | 2015 | case SUID_DUMPABLE_SAFE: |
| 2016 | set_bit(MMF_DUMP_SECURELY, &mm->flags); | 2016 | set_bit(MMF_DUMP_SECURELY, &mm->flags); |
| 2017 | smp_wmb(); | 2017 | smp_wmb(); |
| 2018 | set_bit(MMF_DUMPABLE, &mm->flags); | 2018 | set_bit(MMF_DUMPABLE, &mm->flags); |
| @@ -2025,7 +2025,7 @@ static int __get_dumpable(unsigned long mm_flags) | |||
| 2025 | int ret; | 2025 | int ret; |
| 2026 | 2026 | ||
| 2027 | ret = mm_flags & MMF_DUMPABLE_MASK; | 2027 | ret = mm_flags & MMF_DUMPABLE_MASK; |
| 2028 | return (ret >= 2) ? 2 : ret; | 2028 | return (ret > SUID_DUMPABLE_ENABLED) ? SUID_DUMPABLE_SAFE : ret; |
| 2029 | } | 2029 | } |
| 2030 | 2030 | ||
| 2031 | int get_dumpable(struct mm_struct *mm) | 2031 | int get_dumpable(struct mm_struct *mm) |
| @@ -2111,6 +2111,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) | |||
| 2111 | int retval = 0; | 2111 | int retval = 0; |
| 2112 | int flag = 0; | 2112 | int flag = 0; |
| 2113 | int ispipe; | 2113 | int ispipe; |
| 2114 | bool need_nonrelative = false; | ||
| 2114 | static atomic_t core_dump_count = ATOMIC_INIT(0); | 2115 | static atomic_t core_dump_count = ATOMIC_INIT(0); |
| 2115 | struct coredump_params cprm = { | 2116 | struct coredump_params cprm = { |
| 2116 | .signr = signr, | 2117 | .signr = signr, |
| @@ -2136,14 +2137,16 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) | |||
| 2136 | if (!cred) | 2137 | if (!cred) |
| 2137 | goto fail; | 2138 | goto fail; |
| 2138 | /* | 2139 | /* |
| 2139 | * We cannot trust fsuid as being the "true" uid of the | 2140 | * We cannot trust fsuid as being the "true" uid of the process |
| 2140 | * process nor do we know its entire history. We only know it | 2141 | * nor do we know its entire history. We only know it was tainted |
| 2141 | * was tainted so we dump it as root in mode 2. | 2142 | * so we dump it as root in mode 2, and only into a controlled |
| 2143 | * environment (pipe handler or fully qualified path). | ||
| 2142 | */ | 2144 | */ |
| 2143 | if (__get_dumpable(cprm.mm_flags) == 2) { | 2145 | if (__get_dumpable(cprm.mm_flags) == SUID_DUMPABLE_SAFE) { |
| 2144 | /* Setuid core dump mode */ | 2146 | /* Setuid core dump mode */ |
| 2145 | flag = O_EXCL; /* Stop rewrite attacks */ | 2147 | flag = O_EXCL; /* Stop rewrite attacks */ |
| 2146 | cred->fsuid = GLOBAL_ROOT_UID; /* Dump root private */ | 2148 | cred->fsuid = GLOBAL_ROOT_UID; /* Dump root private */ |
| 2149 | need_nonrelative = true; | ||
| 2147 | } | 2150 | } |
| 2148 | 2151 | ||
| 2149 | retval = coredump_wait(exit_code, &core_state); | 2152 | retval = coredump_wait(exit_code, &core_state); |
| @@ -2171,15 +2174,16 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) | |||
| 2171 | } | 2174 | } |
| 2172 | 2175 | ||
| 2173 | if (cprm.limit == 1) { | 2176 | if (cprm.limit == 1) { |
| 2174 | /* | 2177 | /* See umh_pipe_setup() which sets RLIMIT_CORE = 1. |
| 2178 | * | ||
| 2175 | * Normally core limits are irrelevant to pipes, since | 2179 | * Normally core limits are irrelevant to pipes, since |
| 2176 | * we're not writing to the file system, but we use | 2180 | * we're not writing to the file system, but we use |
| 2177 | * cprm.limit of 1 here as a speacial value. Any | 2181 | * cprm.limit of 1 here as a speacial value, this is a |
| 2178 | * non-1 limit gets set to RLIM_INFINITY below, but | 2182 | * consistent way to catch recursive crashes. |
| 2179 | * a limit of 0 skips the dump. This is a consistent | 2183 | * We can still crash if the core_pattern binary sets |
| 2180 | * way to catch recursive crashes. We can still crash | 2184 | * RLIM_CORE = !1, but it runs as root, and can do |
| 2181 | * if the core_pattern binary sets RLIM_CORE = !1 | 2185 | * lots of stupid things. |
| 2182 | * but it runs as root, and can do lots of stupid things | 2186 | * |
| 2183 | * Note that we use task_tgid_vnr here to grab the pid | 2187 | * Note that we use task_tgid_vnr here to grab the pid |
| 2184 | * of the process group leader. That way we get the | 2188 | * of the process group leader. That way we get the |
| 2185 | * right pid if a thread in a multi-threaded | 2189 | * right pid if a thread in a multi-threaded |
| @@ -2223,6 +2227,14 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) | |||
| 2223 | if (cprm.limit < binfmt->min_coredump) | 2227 | if (cprm.limit < binfmt->min_coredump) |
| 2224 | goto fail_unlock; | 2228 | goto fail_unlock; |
| 2225 | 2229 | ||
| 2230 | if (need_nonrelative && cn.corename[0] != '/') { | ||
| 2231 | printk(KERN_WARNING "Pid %d(%s) can only dump core "\ | ||
| 2232 | "to fully qualified path!\n", | ||
| 2233 | task_tgid_vnr(current), current->comm); | ||
| 2234 | printk(KERN_WARNING "Skipping core dump\n"); | ||
| 2235 | goto fail_unlock; | ||
| 2236 | } | ||
| 2237 | |||
| 2226 | cprm.file = filp_open(cn.corename, | 2238 | cprm.file = filp_open(cn.corename, |
| 2227 | O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag, | 2239 | O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag, |
| 2228 | 0600); | 2240 | 0600); |
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c index 1c3613998862..376aa77f3ca7 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c | |||
| @@ -1444,19 +1444,9 @@ ext2_fsblk_t ext2_new_block(struct inode *inode, unsigned long goal, int *errp) | |||
| 1444 | 1444 | ||
| 1445 | #ifdef EXT2FS_DEBUG | 1445 | #ifdef EXT2FS_DEBUG |
| 1446 | 1446 | ||
| 1447 | static const int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0}; | 1447 | unsigned long ext2_count_free(struct buffer_head *map, unsigned int numchars) |
| 1448 | |||
| 1449 | unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars) | ||
| 1450 | { | 1448 | { |
| 1451 | unsigned int i; | 1449 | return numchars * BITS_PER_BYTE - memweight(map->b_data, numchars); |
| 1452 | unsigned long sum = 0; | ||
| 1453 | |||
| 1454 | if (!map) | ||
| 1455 | return (0); | ||
| 1456 | for (i = 0; i < numchars; i++) | ||
| 1457 | sum += nibblemap[map->b_data[i] & 0xf] + | ||
| 1458 | nibblemap[(map->b_data[i] >> 4) & 0xf]; | ||
| 1459 | return (sum); | ||
| 1460 | } | 1450 | } |
| 1461 | 1451 | ||
| 1462 | #endif /* EXT2FS_DEBUG */ | 1452 | #endif /* EXT2FS_DEBUG */ |
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c index c13eb7b91a11..8f370e012e61 100644 --- a/fs/ext2/ialloc.c +++ b/fs/ext2/ialloc.c | |||
| @@ -644,6 +644,7 @@ unsigned long ext2_count_free_inodes (struct super_block * sb) | |||
| 644 | } | 644 | } |
| 645 | brelse(bitmap_bh); | 645 | brelse(bitmap_bh); |
| 646 | printk("ext2_count_free_inodes: stored = %lu, computed = %lu, %lu\n", | 646 | printk("ext2_count_free_inodes: stored = %lu, computed = %lu, %lu\n", |
| 647 | (unsigned long) | ||
| 647 | percpu_counter_read(&EXT2_SB(sb)->s_freeinodes_counter), | 648 | percpu_counter_read(&EXT2_SB(sb)->s_freeinodes_counter), |
| 648 | desc_count, bitmap_count); | 649 | desc_count, bitmap_count); |
| 649 | return desc_count; | 650 | return desc_count; |
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c index 25cd60892116..90d901f0486b 100644 --- a/fs/ext3/balloc.c +++ b/fs/ext3/balloc.c | |||
| @@ -1813,7 +1813,7 @@ ext3_fsblk_t ext3_count_free_blocks(struct super_block *sb) | |||
| 1813 | brelse(bitmap_bh); | 1813 | brelse(bitmap_bh); |
| 1814 | printk("ext3_count_free_blocks: stored = "E3FSBLK | 1814 | printk("ext3_count_free_blocks: stored = "E3FSBLK |
| 1815 | ", computed = "E3FSBLK", "E3FSBLK"\n", | 1815 | ", computed = "E3FSBLK", "E3FSBLK"\n", |
| 1816 | le32_to_cpu(es->s_free_blocks_count), | 1816 | (ext3_fsblk_t)le32_to_cpu(es->s_free_blocks_count), |
| 1817 | desc_count, bitmap_count); | 1817 | desc_count, bitmap_count); |
| 1818 | return bitmap_count; | 1818 | return bitmap_count; |
| 1819 | #else | 1819 | #else |
diff --git a/fs/ext3/bitmap.c b/fs/ext3/bitmap.c index 909d13e26560..ef9c643e8e9d 100644 --- a/fs/ext3/bitmap.c +++ b/fs/ext3/bitmap.c | |||
| @@ -11,19 +11,9 @@ | |||
| 11 | 11 | ||
| 12 | #ifdef EXT3FS_DEBUG | 12 | #ifdef EXT3FS_DEBUG |
| 13 | 13 | ||
| 14 | static const int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0}; | ||
| 15 | |||
| 16 | unsigned long ext3_count_free (struct buffer_head * map, unsigned int numchars) | 14 | unsigned long ext3_count_free (struct buffer_head * map, unsigned int numchars) |
| 17 | { | 15 | { |
| 18 | unsigned int i; | 16 | return numchars * BITS_PER_BYTE - memweight(map->b_data, numchars); |
| 19 | unsigned long sum = 0; | ||
| 20 | |||
| 21 | if (!map) | ||
| 22 | return (0); | ||
| 23 | for (i = 0; i < numchars; i++) | ||
| 24 | sum += nibblemap[map->b_data[i] & 0xf] + | ||
| 25 | nibblemap[(map->b_data[i] >> 4) & 0xf]; | ||
| 26 | return (sum); | ||
| 27 | } | 17 | } |
| 28 | 18 | ||
| 29 | #endif /* EXT3FS_DEBUG */ | 19 | #endif /* EXT3FS_DEBUG */ |
diff --git a/fs/ext4/bitmap.c b/fs/ext4/bitmap.c index a94b9c63ee5c..f8716eab9995 100644 --- a/fs/ext4/bitmap.c +++ b/fs/ext4/bitmap.c | |||
| @@ -11,16 +11,9 @@ | |||
| 11 | #include <linux/jbd2.h> | 11 | #include <linux/jbd2.h> |
| 12 | #include "ext4.h" | 12 | #include "ext4.h" |
| 13 | 13 | ||
| 14 | static const int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0}; | ||
| 15 | |||
| 16 | unsigned int ext4_count_free(char *bitmap, unsigned int numchars) | 14 | unsigned int ext4_count_free(char *bitmap, unsigned int numchars) |
| 17 | { | 15 | { |
| 18 | unsigned int i, sum = 0; | 16 | return numchars * BITS_PER_BYTE - memweight(bitmap, numchars); |
| 19 | |||
| 20 | for (i = 0; i < numchars; i++) | ||
| 21 | sum += nibblemap[bitmap[i] & 0xf] + | ||
| 22 | nibblemap[(bitmap[i] >> 4) & 0xf]; | ||
| 23 | return sum; | ||
| 24 | } | 17 | } |
| 25 | 18 | ||
| 26 | int ext4_inode_bitmap_csum_verify(struct super_block *sb, ext4_group_t group, | 19 | int ext4_inode_bitmap_csum_verify(struct super_block *sb, ext4_group_t group, |
diff --git a/fs/fat/dir.c b/fs/fat/dir.c index 6eaa28c98ad1..dc49ed2cbffa 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c | |||
| @@ -35,6 +35,11 @@ | |||
| 35 | #define FAT_MAX_UNI_CHARS ((MSDOS_SLOTS - 1) * 13 + 1) | 35 | #define FAT_MAX_UNI_CHARS ((MSDOS_SLOTS - 1) * 13 + 1) |
| 36 | #define FAT_MAX_UNI_SIZE (FAT_MAX_UNI_CHARS * sizeof(wchar_t)) | 36 | #define FAT_MAX_UNI_SIZE (FAT_MAX_UNI_CHARS * sizeof(wchar_t)) |
| 37 | 37 | ||
| 38 | static inline unsigned char fat_tolower(unsigned char c) | ||
| 39 | { | ||
| 40 | return ((c >= 'A') && (c <= 'Z')) ? c+32 : c; | ||
| 41 | } | ||
| 42 | |||
| 38 | static inline loff_t fat_make_i_pos(struct super_block *sb, | 43 | static inline loff_t fat_make_i_pos(struct super_block *sb, |
| 39 | struct buffer_head *bh, | 44 | struct buffer_head *bh, |
| 40 | struct msdos_dir_entry *de) | 45 | struct msdos_dir_entry *de) |
| @@ -333,6 +338,124 @@ parse_long: | |||
| 333 | return 0; | 338 | return 0; |
| 334 | } | 339 | } |
| 335 | 340 | ||
| 341 | /** | ||
| 342 | * fat_parse_short - Parse MS-DOS (short) directory entry. | ||
| 343 | * @sb: superblock | ||
| 344 | * @de: directory entry to parse | ||
| 345 | * @name: FAT_MAX_SHORT_SIZE array in which to place extracted name | ||
| 346 | * @dot_hidden: Nonzero == prepend '.' to names with ATTR_HIDDEN | ||
| 347 | * | ||
| 348 | * Returns the number of characters extracted into 'name'. | ||
| 349 | */ | ||
| 350 | static int fat_parse_short(struct super_block *sb, | ||
| 351 | const struct msdos_dir_entry *de, | ||
| 352 | unsigned char *name, int dot_hidden) | ||
| 353 | { | ||
| 354 | const struct msdos_sb_info *sbi = MSDOS_SB(sb); | ||
| 355 | int isvfat = sbi->options.isvfat; | ||
| 356 | int nocase = sbi->options.nocase; | ||
| 357 | unsigned short opt_shortname = sbi->options.shortname; | ||
| 358 | struct nls_table *nls_disk = sbi->nls_disk; | ||
| 359 | wchar_t uni_name[14]; | ||
| 360 | unsigned char c, work[MSDOS_NAME]; | ||
| 361 | unsigned char *ptname = name; | ||
| 362 | int chi, chl, i, j, k; | ||
| 363 | int dotoffset = 0; | ||
| 364 | int name_len = 0, uni_len = 0; | ||
| 365 | |||
| 366 | if (!isvfat && dot_hidden && (de->attr & ATTR_HIDDEN)) { | ||
| 367 | *ptname++ = '.'; | ||
| 368 | dotoffset = 1; | ||
| 369 | } | ||
| 370 | |||
| 371 | memcpy(work, de->name, sizeof(work)); | ||
| 372 | /* see namei.c, msdos_format_name */ | ||
| 373 | if (work[0] == 0x05) | ||
| 374 | work[0] = 0xE5; | ||
| 375 | |||
| 376 | /* Filename */ | ||
| 377 | for (i = 0, j = 0; i < 8;) { | ||
| 378 | c = work[i]; | ||
| 379 | if (!c) | ||
| 380 | break; | ||
| 381 | chl = fat_shortname2uni(nls_disk, &work[i], 8 - i, | ||
| 382 | &uni_name[j++], opt_shortname, | ||
| 383 | de->lcase & CASE_LOWER_BASE); | ||
| 384 | if (chl <= 1) { | ||
| 385 | if (!isvfat) | ||
| 386 | ptname[i] = nocase ? c : fat_tolower(c); | ||
| 387 | i++; | ||
| 388 | if (c != ' ') { | ||
| 389 | name_len = i; | ||
| 390 | uni_len = j; | ||
| 391 | } | ||
| 392 | } else { | ||
| 393 | uni_len = j; | ||
| 394 | if (isvfat) | ||
| 395 | i += min(chl, 8-i); | ||
| 396 | else { | ||
| 397 | for (chi = 0; chi < chl && i < 8; chi++, i++) | ||
| 398 | ptname[i] = work[i]; | ||
| 399 | } | ||
| 400 | if (chl) | ||
| 401 | name_len = i; | ||
| 402 | } | ||
| 403 | } | ||
| 404 | |||
| 405 | i = name_len; | ||
| 406 | j = uni_len; | ||
| 407 | fat_short2uni(nls_disk, ".", 1, &uni_name[j++]); | ||
| 408 | if (!isvfat) | ||
| 409 | ptname[i] = '.'; | ||
| 410 | i++; | ||
| 411 | |||
| 412 | /* Extension */ | ||
| 413 | for (k = 8; k < MSDOS_NAME;) { | ||
| 414 | c = work[k]; | ||
| 415 | if (!c) | ||
| 416 | break; | ||
| 417 | chl = fat_shortname2uni(nls_disk, &work[k], MSDOS_NAME - k, | ||
| 418 | &uni_name[j++], opt_shortname, | ||
| 419 | de->lcase & CASE_LOWER_EXT); | ||
| 420 | if (chl <= 1) { | ||
| 421 | k++; | ||
| 422 | if (!isvfat) | ||
| 423 | ptname[i] = nocase ? c : fat_tolower(c); | ||
| 424 | i++; | ||
| 425 | if (c != ' ') { | ||
| 426 | name_len = i; | ||
| 427 | uni_len = j; | ||
| 428 | } | ||
| 429 | } else { | ||
| 430 | uni_len = j; | ||
| 431 | if (isvfat) { | ||
| 432 | int offset = min(chl, MSDOS_NAME-k); | ||
| 433 | k += offset; | ||
| 434 | i += offset; | ||
| 435 | } else { | ||
| 436 | for (chi = 0; chi < chl && k < MSDOS_NAME; | ||
| 437 | chi++, i++, k++) { | ||
| 438 | ptname[i] = work[k]; | ||
| 439 | } | ||
| 440 | } | ||
| 441 | if (chl) | ||
| 442 | name_len = i; | ||
| 443 | } | ||
| 444 | } | ||
| 445 | |||
| 446 | if (name_len > 0) { | ||
| 447 | name_len += dotoffset; | ||
| 448 | |||
| 449 | if (sbi->options.isvfat) { | ||
| 450 | uni_name[uni_len] = 0x0000; | ||
| 451 | name_len = fat_uni_to_x8(sb, uni_name, name, | ||
| 452 | FAT_MAX_SHORT_SIZE); | ||
| 453 | } | ||
| 454 | } | ||
| 455 | |||
| 456 | return name_len; | ||
| 457 | } | ||
| 458 | |||
| 336 | /* | 459 | /* |
| 337 | * Return values: negative -> error, 0 -> not found, positive -> found, | 460 | * Return values: negative -> error, 0 -> not found, positive -> found, |
| 338 | * value is the total amount of slots, including the shortname entry. | 461 | * value is the total amount of slots, including the shortname entry. |
| @@ -344,15 +467,11 @@ int fat_search_long(struct inode *inode, const unsigned char *name, | |||
| 344 | struct msdos_sb_info *sbi = MSDOS_SB(sb); | 467 | struct msdos_sb_info *sbi = MSDOS_SB(sb); |
| 345 | struct buffer_head *bh = NULL; | 468 | struct buffer_head *bh = NULL; |
| 346 | struct msdos_dir_entry *de; | 469 | struct msdos_dir_entry *de; |
| 347 | struct nls_table *nls_disk = sbi->nls_disk; | ||
| 348 | unsigned char nr_slots; | 470 | unsigned char nr_slots; |
| 349 | wchar_t bufuname[14]; | ||
| 350 | wchar_t *unicode = NULL; | 471 | wchar_t *unicode = NULL; |
| 351 | unsigned char work[MSDOS_NAME]; | ||
| 352 | unsigned char bufname[FAT_MAX_SHORT_SIZE]; | 472 | unsigned char bufname[FAT_MAX_SHORT_SIZE]; |
| 353 | unsigned short opt_shortname = sbi->options.shortname; | ||
| 354 | loff_t cpos = 0; | 473 | loff_t cpos = 0; |
| 355 | int chl, i, j, last_u, err, len; | 474 | int err, len; |
| 356 | 475 | ||
| 357 | err = -ENOENT; | 476 | err = -ENOENT; |
| 358 | while (1) { | 477 | while (1) { |
| @@ -380,47 +499,16 @@ parse_record: | |||
| 380 | goto end_of_dir; | 499 | goto end_of_dir; |
| 381 | } | 500 | } |
| 382 | 501 | ||
| 383 | memcpy(work, de->name, sizeof(de->name)); | 502 | /* Never prepend '.' to hidden files here. |
| 384 | /* see namei.c, msdos_format_name */ | 503 | * That is done only for msdos mounts (and only when |
| 385 | if (work[0] == 0x05) | 504 | * 'dotsOK=yes'); if we are executing here, it is in the |
| 386 | work[0] = 0xE5; | 505 | * context of a vfat mount. |
| 387 | for (i = 0, j = 0, last_u = 0; i < 8;) { | 506 | */ |
| 388 | if (!work[i]) | 507 | len = fat_parse_short(sb, de, bufname, 0); |
| 389 | break; | 508 | if (len == 0) |
| 390 | chl = fat_shortname2uni(nls_disk, &work[i], 8 - i, | ||
| 391 | &bufuname[j++], opt_shortname, | ||
| 392 | de->lcase & CASE_LOWER_BASE); | ||
| 393 | if (chl <= 1) { | ||
| 394 | if (work[i] != ' ') | ||
| 395 | last_u = j; | ||
| 396 | } else { | ||
| 397 | last_u = j; | ||
| 398 | } | ||
| 399 | i += chl; | ||
| 400 | } | ||
| 401 | j = last_u; | ||
| 402 | fat_short2uni(nls_disk, ".", 1, &bufuname[j++]); | ||
| 403 | for (i = 8; i < MSDOS_NAME;) { | ||
| 404 | if (!work[i]) | ||
| 405 | break; | ||
| 406 | chl = fat_shortname2uni(nls_disk, &work[i], | ||
| 407 | MSDOS_NAME - i, | ||
| 408 | &bufuname[j++], opt_shortname, | ||
| 409 | de->lcase & CASE_LOWER_EXT); | ||
| 410 | if (chl <= 1) { | ||
| 411 | if (work[i] != ' ') | ||
| 412 | last_u = j; | ||
| 413 | } else { | ||
| 414 | last_u = j; | ||
| 415 | } | ||
| 416 | i += chl; | ||
| 417 | } | ||
| 418 | if (!last_u) | ||
| 419 | continue; | 509 | continue; |
| 420 | 510 | ||
| 421 | /* Compare shortname */ | 511 | /* Compare shortname */ |
| 422 | bufuname[last_u] = 0x0000; | ||
| 423 | len = fat_uni_to_x8(sb, bufuname, bufname, sizeof(bufname)); | ||
| 424 | if (fat_name_match(sbi, name, name_len, bufname, len)) | 512 | if (fat_name_match(sbi, name, name_len, bufname, len)) |
| 425 | goto found; | 513 | goto found; |
| 426 | 514 | ||
| @@ -469,20 +557,15 @@ static int __fat_readdir(struct inode *inode, struct file *filp, void *dirent, | |||
| 469 | struct msdos_sb_info *sbi = MSDOS_SB(sb); | 557 | struct msdos_sb_info *sbi = MSDOS_SB(sb); |
| 470 | struct buffer_head *bh; | 558 | struct buffer_head *bh; |
| 471 | struct msdos_dir_entry *de; | 559 | struct msdos_dir_entry *de; |
| 472 | struct nls_table *nls_disk = sbi->nls_disk; | ||
| 473 | unsigned char nr_slots; | 560 | unsigned char nr_slots; |
| 474 | wchar_t bufuname[14]; | ||
| 475 | wchar_t *unicode = NULL; | 561 | wchar_t *unicode = NULL; |
| 476 | unsigned char c, work[MSDOS_NAME]; | 562 | unsigned char bufname[FAT_MAX_SHORT_SIZE]; |
| 477 | unsigned char bufname[FAT_MAX_SHORT_SIZE], *ptname = bufname; | ||
| 478 | unsigned short opt_shortname = sbi->options.shortname; | ||
| 479 | int isvfat = sbi->options.isvfat; | 563 | int isvfat = sbi->options.isvfat; |
| 480 | int nocase = sbi->options.nocase; | ||
| 481 | const char *fill_name = NULL; | 564 | const char *fill_name = NULL; |
| 482 | unsigned long inum; | 565 | unsigned long inum; |
| 483 | unsigned long lpos, dummy, *furrfu = &lpos; | 566 | unsigned long lpos, dummy, *furrfu = &lpos; |
| 484 | loff_t cpos; | 567 | loff_t cpos; |
| 485 | int chi, chl, i, i2, j, last, last_u, dotoffset = 0, fill_len = 0; | 568 | int short_len = 0, fill_len = 0; |
| 486 | int ret = 0; | 569 | int ret = 0; |
| 487 | 570 | ||
| 488 | lock_super(sb); | 571 | lock_super(sb); |
| @@ -556,74 +639,10 @@ parse_record: | |||
| 556 | } | 639 | } |
| 557 | } | 640 | } |
| 558 | 641 | ||
| 559 | if (sbi->options.dotsOK) { | 642 | short_len = fat_parse_short(sb, de, bufname, sbi->options.dotsOK); |
| 560 | ptname = bufname; | 643 | if (short_len == 0) |
| 561 | dotoffset = 0; | ||
| 562 | if (de->attr & ATTR_HIDDEN) { | ||
| 563 | *ptname++ = '.'; | ||
| 564 | dotoffset = 1; | ||
| 565 | } | ||
| 566 | } | ||
| 567 | |||
| 568 | memcpy(work, de->name, sizeof(de->name)); | ||
| 569 | /* see namei.c, msdos_format_name */ | ||
| 570 | if (work[0] == 0x05) | ||
| 571 | work[0] = 0xE5; | ||
| 572 | for (i = 0, j = 0, last = 0, last_u = 0; i < 8;) { | ||
| 573 | if (!(c = work[i])) | ||
| 574 | break; | ||
| 575 | chl = fat_shortname2uni(nls_disk, &work[i], 8 - i, | ||
| 576 | &bufuname[j++], opt_shortname, | ||
| 577 | de->lcase & CASE_LOWER_BASE); | ||
| 578 | if (chl <= 1) { | ||
| 579 | ptname[i++] = (!nocase && c>='A' && c<='Z') ? c+32 : c; | ||
| 580 | if (c != ' ') { | ||
| 581 | last = i; | ||
| 582 | last_u = j; | ||
| 583 | } | ||
| 584 | } else { | ||
| 585 | last_u = j; | ||
| 586 | for (chi = 0; chi < chl && i < 8; chi++) { | ||
| 587 | ptname[i] = work[i]; | ||
| 588 | i++; last = i; | ||
| 589 | } | ||
| 590 | } | ||
| 591 | } | ||
| 592 | i = last; | ||
| 593 | j = last_u; | ||
| 594 | fat_short2uni(nls_disk, ".", 1, &bufuname[j++]); | ||
| 595 | ptname[i++] = '.'; | ||
| 596 | for (i2 = 8; i2 < MSDOS_NAME;) { | ||
| 597 | if (!(c = work[i2])) | ||
| 598 | break; | ||
| 599 | chl = fat_shortname2uni(nls_disk, &work[i2], MSDOS_NAME - i2, | ||
| 600 | &bufuname[j++], opt_shortname, | ||
| 601 | de->lcase & CASE_LOWER_EXT); | ||
| 602 | if (chl <= 1) { | ||
| 603 | i2++; | ||
| 604 | ptname[i++] = (!nocase && c>='A' && c<='Z') ? c+32 : c; | ||
| 605 | if (c != ' ') { | ||
| 606 | last = i; | ||
| 607 | last_u = j; | ||
| 608 | } | ||
| 609 | } else { | ||
| 610 | last_u = j; | ||
| 611 | for (chi = 0; chi < chl && i2 < MSDOS_NAME; chi++) { | ||
| 612 | ptname[i++] = work[i2++]; | ||
| 613 | last = i; | ||
| 614 | } | ||
| 615 | } | ||
| 616 | } | ||
| 617 | if (!last) | ||
| 618 | goto record_end; | 644 | goto record_end; |
| 619 | 645 | ||
| 620 | i = last + dotoffset; | ||
| 621 | j = last_u; | ||
| 622 | |||
| 623 | if (isvfat) { | ||
| 624 | bufuname[j] = 0x0000; | ||
| 625 | i = fat_uni_to_x8(sb, bufuname, bufname, sizeof(bufname)); | ||
| 626 | } | ||
| 627 | if (nr_slots) { | 646 | if (nr_slots) { |
| 628 | /* hack for fat_ioctl_filldir() */ | 647 | /* hack for fat_ioctl_filldir() */ |
| 629 | struct fat_ioctl_filldir_callback *p = dirent; | 648 | struct fat_ioctl_filldir_callback *p = dirent; |
| @@ -631,12 +650,12 @@ parse_record: | |||
| 631 | p->longname = fill_name; | 650 | p->longname = fill_name; |
| 632 | p->long_len = fill_len; | 651 | p->long_len = fill_len; |
| 633 | p->shortname = bufname; | 652 | p->shortname = bufname; |
| 634 | p->short_len = i; | 653 | p->short_len = short_len; |
| 635 | fill_name = NULL; | 654 | fill_name = NULL; |
| 636 | fill_len = 0; | 655 | fill_len = 0; |
| 637 | } else { | 656 | } else { |
| 638 | fill_name = bufname; | 657 | fill_name = bufname; |
| 639 | fill_len = i; | 658 | fill_len = short_len; |
| 640 | } | 659 | } |
| 641 | 660 | ||
| 642 | start_filldir: | 661 | start_filldir: |
diff --git a/fs/fat/fat.h b/fs/fat/fat.h index fc35c5c69136..2deeeb86f331 100644 --- a/fs/fat/fat.h +++ b/fs/fat/fat.h | |||
| @@ -217,6 +217,21 @@ static inline void fat16_towchar(wchar_t *dst, const __u8 *src, size_t len) | |||
| 217 | #endif | 217 | #endif |
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | static inline int fat_get_start(const struct msdos_sb_info *sbi, | ||
| 221 | const struct msdos_dir_entry *de) | ||
| 222 | { | ||
| 223 | int cluster = le16_to_cpu(de->start); | ||
| 224 | if (sbi->fat_bits == 32) | ||
| 225 | cluster |= (le16_to_cpu(de->starthi) << 16); | ||
| 226 | return cluster; | ||
| 227 | } | ||
| 228 | |||
| 229 | static inline void fat_set_start(struct msdos_dir_entry *de, int cluster) | ||
| 230 | { | ||
| 231 | de->start = cpu_to_le16(cluster); | ||
| 232 | de->starthi = cpu_to_le16(cluster >> 16); | ||
| 233 | } | ||
| 234 | |||
| 220 | static inline void fatwchar_to16(__u8 *dst, const wchar_t *src, size_t len) | 235 | static inline void fatwchar_to16(__u8 *dst, const wchar_t *src, size_t len) |
| 221 | { | 236 | { |
| 222 | #ifdef __BIG_ENDIAN | 237 | #ifdef __BIG_ENDIAN |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 0038b32cb362..05e897fe9866 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
| @@ -369,10 +369,7 @@ static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de) | |||
| 369 | inode->i_op = sbi->dir_ops; | 369 | inode->i_op = sbi->dir_ops; |
| 370 | inode->i_fop = &fat_dir_operations; | 370 | inode->i_fop = &fat_dir_operations; |
| 371 | 371 | ||
| 372 | MSDOS_I(inode)->i_start = le16_to_cpu(de->start); | 372 | MSDOS_I(inode)->i_start = fat_get_start(sbi, de); |
| 373 | if (sbi->fat_bits == 32) | ||
| 374 | MSDOS_I(inode)->i_start |= (le16_to_cpu(de->starthi) << 16); | ||
| 375 | |||
| 376 | MSDOS_I(inode)->i_logstart = MSDOS_I(inode)->i_start; | 373 | MSDOS_I(inode)->i_logstart = MSDOS_I(inode)->i_start; |
| 377 | error = fat_calc_dir_size(inode); | 374 | error = fat_calc_dir_size(inode); |
| 378 | if (error < 0) | 375 | if (error < 0) |
| @@ -385,9 +382,7 @@ static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de) | |||
| 385 | inode->i_mode = fat_make_mode(sbi, de->attr, | 382 | inode->i_mode = fat_make_mode(sbi, de->attr, |
| 386 | ((sbi->options.showexec && !is_exec(de->name + 8)) | 383 | ((sbi->options.showexec && !is_exec(de->name + 8)) |
| 387 | ? S_IRUGO|S_IWUGO : S_IRWXUGO)); | 384 | ? S_IRUGO|S_IWUGO : S_IRWXUGO)); |
| 388 | MSDOS_I(inode)->i_start = le16_to_cpu(de->start); | 385 | MSDOS_I(inode)->i_start = fat_get_start(sbi, de); |
| 389 | if (sbi->fat_bits == 32) | ||
| 390 | MSDOS_I(inode)->i_start |= (le16_to_cpu(de->starthi) << 16); | ||
| 391 | 386 | ||
| 392 | MSDOS_I(inode)->i_logstart = MSDOS_I(inode)->i_start; | 387 | MSDOS_I(inode)->i_logstart = MSDOS_I(inode)->i_start; |
| 393 | inode->i_size = le32_to_cpu(de->size); | 388 | inode->i_size = le32_to_cpu(de->size); |
| @@ -613,8 +608,7 @@ retry: | |||
| 613 | else | 608 | else |
| 614 | raw_entry->size = cpu_to_le32(inode->i_size); | 609 | raw_entry->size = cpu_to_le32(inode->i_size); |
| 615 | raw_entry->attr = fat_make_attrs(inode); | 610 | raw_entry->attr = fat_make_attrs(inode); |
| 616 | raw_entry->start = cpu_to_le16(MSDOS_I(inode)->i_logstart); | 611 | fat_set_start(raw_entry, MSDOS_I(inode)->i_logstart); |
| 617 | raw_entry->starthi = cpu_to_le16(MSDOS_I(inode)->i_logstart >> 16); | ||
| 618 | fat_time_unix2fat(sbi, &inode->i_mtime, &raw_entry->time, | 612 | fat_time_unix2fat(sbi, &inode->i_mtime, &raw_entry->time, |
| 619 | &raw_entry->date, NULL); | 613 | &raw_entry->date, NULL); |
| 620 | if (sbi->options.isvfat) { | 614 | if (sbi->options.isvfat) { |
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c index 70d993a93805..b0e12bf9f4a1 100644 --- a/fs/fat/namei_msdos.c +++ b/fs/fat/namei_msdos.c | |||
| @@ -246,8 +246,7 @@ static int msdos_add_entry(struct inode *dir, const unsigned char *name, | |||
| 246 | de.ctime_cs = 0; | 246 | de.ctime_cs = 0; |
| 247 | de.time = time; | 247 | de.time = time; |
| 248 | de.date = date; | 248 | de.date = date; |
| 249 | de.start = cpu_to_le16(cluster); | 249 | fat_set_start(&de, cluster); |
| 250 | de.starthi = cpu_to_le16(cluster >> 16); | ||
| 251 | de.size = 0; | 250 | de.size = 0; |
| 252 | 251 | ||
| 253 | err = fat_add_entries(dir, &de, 1, sinfo); | 252 | err = fat_add_entries(dir, &de, 1, sinfo); |
| @@ -530,9 +529,7 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name, | |||
| 530 | mark_inode_dirty(old_inode); | 529 | mark_inode_dirty(old_inode); |
| 531 | 530 | ||
| 532 | if (update_dotdot) { | 531 | if (update_dotdot) { |
| 533 | int start = MSDOS_I(new_dir)->i_logstart; | 532 | fat_set_start(dotdot_de, MSDOS_I(new_dir)->i_logstart); |
| 534 | dotdot_de->start = cpu_to_le16(start); | ||
| 535 | dotdot_de->starthi = cpu_to_le16(start >> 16); | ||
| 536 | mark_buffer_dirty_inode(dotdot_bh, old_inode); | 533 | mark_buffer_dirty_inode(dotdot_bh, old_inode); |
| 537 | if (IS_DIRSYNC(new_dir)) { | 534 | if (IS_DIRSYNC(new_dir)) { |
| 538 | err = sync_dirty_buffer(dotdot_bh); | 535 | err = sync_dirty_buffer(dotdot_bh); |
| @@ -572,9 +569,7 @@ error_dotdot: | |||
| 572 | corrupt = 1; | 569 | corrupt = 1; |
| 573 | 570 | ||
| 574 | if (update_dotdot) { | 571 | if (update_dotdot) { |
| 575 | int start = MSDOS_I(old_dir)->i_logstart; | 572 | fat_set_start(dotdot_de, MSDOS_I(old_dir)->i_logstart); |
| 576 | dotdot_de->start = cpu_to_le16(start); | ||
| 577 | dotdot_de->starthi = cpu_to_le16(start >> 16); | ||
| 578 | mark_buffer_dirty_inode(dotdot_bh, old_inode); | 573 | mark_buffer_dirty_inode(dotdot_bh, old_inode); |
| 579 | corrupt |= sync_dirty_buffer(dotdot_bh); | 574 | corrupt |= sync_dirty_buffer(dotdot_bh); |
| 580 | } | 575 | } |
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c index 6cc480652433..6a6d8c0715a1 100644 --- a/fs/fat/namei_vfat.c +++ b/fs/fat/namei_vfat.c | |||
| @@ -651,8 +651,7 @@ shortname: | |||
| 651 | de->time = de->ctime = time; | 651 | de->time = de->ctime = time; |
| 652 | de->date = de->cdate = de->adate = date; | 652 | de->date = de->cdate = de->adate = date; |
| 653 | de->ctime_cs = time_cs; | 653 | de->ctime_cs = time_cs; |
| 654 | de->start = cpu_to_le16(cluster); | 654 | fat_set_start(de, cluster); |
| 655 | de->starthi = cpu_to_le16(cluster >> 16); | ||
| 656 | de->size = 0; | 655 | de->size = 0; |
| 657 | out_free: | 656 | out_free: |
| 658 | __putname(uname); | 657 | __putname(uname); |
| @@ -965,9 +964,7 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
| 965 | mark_inode_dirty(old_inode); | 964 | mark_inode_dirty(old_inode); |
| 966 | 965 | ||
| 967 | if (update_dotdot) { | 966 | if (update_dotdot) { |
| 968 | int start = MSDOS_I(new_dir)->i_logstart; | 967 | fat_set_start(dotdot_de, MSDOS_I(new_dir)->i_logstart); |
| 969 | dotdot_de->start = cpu_to_le16(start); | ||
| 970 | dotdot_de->starthi = cpu_to_le16(start >> 16); | ||
| 971 | mark_buffer_dirty_inode(dotdot_bh, old_inode); | 968 | mark_buffer_dirty_inode(dotdot_bh, old_inode); |
| 972 | if (IS_DIRSYNC(new_dir)) { | 969 | if (IS_DIRSYNC(new_dir)) { |
| 973 | err = sync_dirty_buffer(dotdot_bh); | 970 | err = sync_dirty_buffer(dotdot_bh); |
| @@ -1009,9 +1006,7 @@ error_dotdot: | |||
| 1009 | corrupt = 1; | 1006 | corrupt = 1; |
| 1010 | 1007 | ||
| 1011 | if (update_dotdot) { | 1008 | if (update_dotdot) { |
| 1012 | int start = MSDOS_I(old_dir)->i_logstart; | 1009 | fat_set_start(dotdot_de, MSDOS_I(old_dir)->i_logstart); |
| 1013 | dotdot_de->start = cpu_to_le16(start); | ||
| 1014 | dotdot_de->starthi = cpu_to_le16(start >> 16); | ||
| 1015 | mark_buffer_dirty_inode(dotdot_bh, old_inode); | 1010 | mark_buffer_dirty_inode(dotdot_bh, old_inode); |
| 1016 | corrupt |= sync_dirty_buffer(dotdot_bh); | 1011 | corrupt |= sync_dirty_buffer(dotdot_bh); |
| 1017 | } | 1012 | } |
diff --git a/fs/fcntl.c b/fs/fcntl.c index 81b70e665bf0..887b5ba8c9b5 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/signal.h> | 20 | #include <linux/signal.h> |
| 21 | #include <linux/rcupdate.h> | 21 | #include <linux/rcupdate.h> |
| 22 | #include <linux/pid_namespace.h> | 22 | #include <linux/pid_namespace.h> |
| 23 | #include <linux/user_namespace.h> | ||
| 23 | 24 | ||
| 24 | #include <asm/poll.h> | 25 | #include <asm/poll.h> |
| 25 | #include <asm/siginfo.h> | 26 | #include <asm/siginfo.h> |
| @@ -340,6 +341,31 @@ static int f_getown_ex(struct file *filp, unsigned long arg) | |||
| 340 | return ret; | 341 | return ret; |
| 341 | } | 342 | } |
| 342 | 343 | ||
| 344 | #ifdef CONFIG_CHECKPOINT_RESTORE | ||
| 345 | static int f_getowner_uids(struct file *filp, unsigned long arg) | ||
| 346 | { | ||
| 347 | struct user_namespace *user_ns = current_user_ns(); | ||
| 348 | uid_t * __user dst = (void * __user)arg; | ||
| 349 | uid_t src[2]; | ||
| 350 | int err; | ||
| 351 | |||
| 352 | read_lock(&filp->f_owner.lock); | ||
| 353 | src[0] = from_kuid(user_ns, filp->f_owner.uid); | ||
| 354 | src[1] = from_kuid(user_ns, filp->f_owner.euid); | ||
| 355 | read_unlock(&filp->f_owner.lock); | ||
| 356 | |||
| 357 | err = put_user(src[0], &dst[0]); | ||
| 358 | err |= put_user(src[1], &dst[1]); | ||
| 359 | |||
| 360 | return err; | ||
| 361 | } | ||
| 362 | #else | ||
| 363 | static int f_getowner_uids(struct file *filp, unsigned long arg) | ||
| 364 | { | ||
| 365 | return -EINVAL; | ||
| 366 | } | ||
| 367 | #endif | ||
| 368 | |||
| 343 | static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, | 369 | static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, |
| 344 | struct file *filp) | 370 | struct file *filp) |
| 345 | { | 371 | { |
| @@ -396,6 +422,9 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, | |||
| 396 | case F_SETOWN_EX: | 422 | case F_SETOWN_EX: |
| 397 | err = f_setown_ex(filp, arg); | 423 | err = f_setown_ex(filp, arg); |
| 398 | break; | 424 | break; |
| 425 | case F_GETOWNER_UIDS: | ||
| 426 | err = f_getowner_uids(filp, arg); | ||
| 427 | break; | ||
| 399 | case F_GETSIG: | 428 | case F_GETSIG: |
| 400 | err = filp->f_owner.signum; | 429 | err = filp->f_owner.signum; |
| 401 | break; | 430 | break; |
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c index 473332098013..fdafb2d71654 100644 --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c | |||
| @@ -365,7 +365,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
| 365 | u64 last_fs_block, last_fs_page; | 365 | u64 last_fs_block, last_fs_page; |
| 366 | int err; | 366 | int err; |
| 367 | 367 | ||
| 368 | err = -EINVAL; | 368 | err = -ENOMEM; |
| 369 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); | 369 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); |
| 370 | if (!sbi) | 370 | if (!sbi) |
| 371 | goto out; | 371 | goto out; |
diff --git a/fs/minix/itree_v2.c b/fs/minix/itree_v2.c index 13487ad16894..78e2d93e5c83 100644 --- a/fs/minix/itree_v2.c +++ b/fs/minix/itree_v2.c | |||
| @@ -32,7 +32,8 @@ static int block_to_path(struct inode * inode, long block, int offsets[DEPTH]) | |||
| 32 | if (block < 0) { | 32 | if (block < 0) { |
| 33 | printk("MINIX-fs: block_to_path: block %ld < 0 on dev %s\n", | 33 | printk("MINIX-fs: block_to_path: block %ld < 0 on dev %s\n", |
| 34 | block, bdevname(sb->s_bdev, b)); | 34 | block, bdevname(sb->s_bdev, b)); |
| 35 | } else if (block >= (minix_sb(inode->i_sb)->s_max_size/sb->s_blocksize)) { | 35 | } else if ((u64)block * (u64)sb->s_blocksize >= |
| 36 | minix_sb(sb)->s_max_size) { | ||
| 36 | if (printk_ratelimit()) | 37 | if (printk_ratelimit()) |
| 37 | printk("MINIX-fs: block_to_path: " | 38 | printk("MINIX-fs: block_to_path: " |
| 38 | "block %ld too big on dev %s\n", | 39 | "block %ld too big on dev %s\n", |
diff --git a/fs/nilfs2/alloc.h b/fs/nilfs2/alloc.h index f5fde36b9e28..fb7238100548 100644 --- a/fs/nilfs2/alloc.h +++ b/fs/nilfs2/alloc.h | |||
| @@ -76,15 +76,23 @@ int nilfs_palloc_freev(struct inode *, __u64 *, size_t); | |||
| 76 | #define nilfs_clear_bit_atomic ext2_clear_bit_atomic | 76 | #define nilfs_clear_bit_atomic ext2_clear_bit_atomic |
| 77 | #define nilfs_find_next_zero_bit find_next_zero_bit_le | 77 | #define nilfs_find_next_zero_bit find_next_zero_bit_le |
| 78 | 78 | ||
| 79 | /* | 79 | /** |
| 80 | * persistent object allocator cache | 80 | * struct nilfs_bh_assoc - block offset and buffer head association |
| 81 | * @blkoff: block offset | ||
| 82 | * @bh: buffer head | ||
| 81 | */ | 83 | */ |
| 82 | |||
| 83 | struct nilfs_bh_assoc { | 84 | struct nilfs_bh_assoc { |
| 84 | unsigned long blkoff; | 85 | unsigned long blkoff; |
| 85 | struct buffer_head *bh; | 86 | struct buffer_head *bh; |
| 86 | }; | 87 | }; |
| 87 | 88 | ||
| 89 | /** | ||
| 90 | * struct nilfs_palloc_cache - persistent object allocator cache | ||
| 91 | * @lock: cache protecting lock | ||
| 92 | * @prev_desc: blockgroup descriptors cache | ||
| 93 | * @prev_bitmap: blockgroup bitmap cache | ||
| 94 | * @prev_entry: translation entries cache | ||
| 95 | */ | ||
| 88 | struct nilfs_palloc_cache { | 96 | struct nilfs_palloc_cache { |
| 89 | spinlock_t lock; | 97 | spinlock_t lock; |
| 90 | struct nilfs_bh_assoc prev_desc; | 98 | struct nilfs_bh_assoc prev_desc; |
diff --git a/fs/nilfs2/bmap.h b/fs/nilfs2/bmap.h index 40d9f453d31c..b89e68076adc 100644 --- a/fs/nilfs2/bmap.h +++ b/fs/nilfs2/bmap.h | |||
| @@ -135,6 +135,13 @@ struct nilfs_bmap { | |||
| 135 | /* state */ | 135 | /* state */ |
| 136 | #define NILFS_BMAP_DIRTY 0x00000001 | 136 | #define NILFS_BMAP_DIRTY 0x00000001 |
| 137 | 137 | ||
| 138 | /** | ||
| 139 | * struct nilfs_bmap_store - shadow copy of bmap state | ||
| 140 | * @data: cached raw block mapping of on-disk inode | ||
| 141 | * @last_allocated_key: cached value of last allocated key for data block | ||
| 142 | * @last_allocated_ptr: cached value of last allocated ptr for data block | ||
| 143 | * @state: cached value of state field of bmap structure | ||
| 144 | */ | ||
| 138 | struct nilfs_bmap_store { | 145 | struct nilfs_bmap_store { |
| 139 | __le64 data[NILFS_BMAP_SIZE / sizeof(__le64)]; | 146 | __le64 data[NILFS_BMAP_SIZE / sizeof(__le64)]; |
| 140 | __u64 last_allocated_key; | 147 | __u64 last_allocated_key; |
diff --git a/fs/nilfs2/btnode.h b/fs/nilfs2/btnode.h index 3a4dd2d8d3fc..d876b565ce64 100644 --- a/fs/nilfs2/btnode.h +++ b/fs/nilfs2/btnode.h | |||
| @@ -29,7 +29,13 @@ | |||
| 29 | #include <linux/fs.h> | 29 | #include <linux/fs.h> |
| 30 | #include <linux/backing-dev.h> | 30 | #include <linux/backing-dev.h> |
| 31 | 31 | ||
| 32 | 32 | /** | |
| 33 | * struct nilfs_btnode_chkey_ctxt - change key context | ||
| 34 | * @oldkey: old key of block's moving content | ||
| 35 | * @newkey: new key for block's content | ||
| 36 | * @bh: buffer head of old buffer | ||
| 37 | * @newbh: buffer head of new buffer | ||
| 38 | */ | ||
| 33 | struct nilfs_btnode_chkey_ctxt { | 39 | struct nilfs_btnode_chkey_ctxt { |
| 34 | __u64 oldkey; | 40 | __u64 oldkey; |
| 35 | __u64 newkey; | 41 | __u64 newkey; |
diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c index dab5c4c6dfaf..deaa3d33a0aa 100644 --- a/fs/nilfs2/cpfile.c +++ b/fs/nilfs2/cpfile.c | |||
| @@ -286,7 +286,7 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile, | |||
| 286 | __u64 cno; | 286 | __u64 cno; |
| 287 | void *kaddr; | 287 | void *kaddr; |
| 288 | unsigned long tnicps; | 288 | unsigned long tnicps; |
| 289 | int ret, ncps, nicps, count, i; | 289 | int ret, ncps, nicps, nss, count, i; |
| 290 | 290 | ||
| 291 | if (unlikely(start == 0 || start > end)) { | 291 | if (unlikely(start == 0 || start > end)) { |
| 292 | printk(KERN_ERR "%s: invalid range of checkpoint numbers: " | 292 | printk(KERN_ERR "%s: invalid range of checkpoint numbers: " |
| @@ -301,6 +301,7 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile, | |||
| 301 | if (ret < 0) | 301 | if (ret < 0) |
| 302 | goto out_sem; | 302 | goto out_sem; |
| 303 | tnicps = 0; | 303 | tnicps = 0; |
| 304 | nss = 0; | ||
| 304 | 305 | ||
| 305 | for (cno = start; cno < end; cno += ncps) { | 306 | for (cno = start; cno < end; cno += ncps) { |
| 306 | ncps = nilfs_cpfile_checkpoints_in_block(cpfile, cno, end); | 307 | ncps = nilfs_cpfile_checkpoints_in_block(cpfile, cno, end); |
| @@ -318,8 +319,9 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile, | |||
| 318 | cpfile, cno, cp_bh, kaddr); | 319 | cpfile, cno, cp_bh, kaddr); |
| 319 | nicps = 0; | 320 | nicps = 0; |
| 320 | for (i = 0; i < ncps; i++, cp = (void *)cp + cpsz) { | 321 | for (i = 0; i < ncps; i++, cp = (void *)cp + cpsz) { |
| 321 | WARN_ON(nilfs_checkpoint_snapshot(cp)); | 322 | if (nilfs_checkpoint_snapshot(cp)) { |
| 322 | if (!nilfs_checkpoint_invalid(cp)) { | 323 | nss++; |
| 324 | } else if (!nilfs_checkpoint_invalid(cp)) { | ||
| 323 | nilfs_checkpoint_set_invalid(cp); | 325 | nilfs_checkpoint_set_invalid(cp); |
| 324 | nicps++; | 326 | nicps++; |
| 325 | } | 327 | } |
| @@ -364,6 +366,8 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile, | |||
| 364 | } | 366 | } |
| 365 | 367 | ||
| 366 | brelse(header_bh); | 368 | brelse(header_bh); |
| 369 | if (nss > 0) | ||
| 370 | ret = -EBUSY; | ||
| 367 | 371 | ||
| 368 | out_sem: | 372 | out_sem: |
| 369 | up_write(&NILFS_MDT(cpfile)->mi_sem); | 373 | up_write(&NILFS_MDT(cpfile)->mi_sem); |
diff --git a/fs/nilfs2/dat.c b/fs/nilfs2/dat.c index b5c13f3576b9..fa0f80308c2d 100644 --- a/fs/nilfs2/dat.c +++ b/fs/nilfs2/dat.c | |||
| @@ -33,6 +33,12 @@ | |||
| 33 | #define NILFS_CNO_MIN ((__u64)1) | 33 | #define NILFS_CNO_MIN ((__u64)1) |
| 34 | #define NILFS_CNO_MAX (~(__u64)0) | 34 | #define NILFS_CNO_MAX (~(__u64)0) |
| 35 | 35 | ||
| 36 | /** | ||
| 37 | * struct nilfs_dat_info - on-memory private data of DAT file | ||
| 38 | * @mi: on-memory private data of metadata file | ||
| 39 | * @palloc_cache: persistent object allocator cache of DAT file | ||
| 40 | * @shadow: shadow map of DAT file | ||
| 41 | */ | ||
| 36 | struct nilfs_dat_info { | 42 | struct nilfs_dat_info { |
| 37 | struct nilfs_mdt_info mi; | 43 | struct nilfs_mdt_info mi; |
| 38 | struct nilfs_palloc_cache palloc_cache; | 44 | struct nilfs_palloc_cache palloc_cache; |
diff --git a/fs/nilfs2/export.h b/fs/nilfs2/export.h index a71cc412b651..19ccbf9522ab 100644 --- a/fs/nilfs2/export.h +++ b/fs/nilfs2/export.h | |||
| @@ -5,6 +5,14 @@ | |||
| 5 | 5 | ||
| 6 | extern const struct export_operations nilfs_export_ops; | 6 | extern const struct export_operations nilfs_export_ops; |
| 7 | 7 | ||
| 8 | /** | ||
| 9 | * struct nilfs_fid - NILFS file id type | ||
| 10 | * @cno: checkpoint number | ||
| 11 | * @ino: inode number | ||
| 12 | * @gen: file generation (version) for NFS | ||
| 13 | * @parent_gen: parent generation (version) for NFS | ||
| 14 | * @parent_ino: parent inode number | ||
| 15 | */ | ||
| 8 | struct nilfs_fid { | 16 | struct nilfs_fid { |
| 9 | u64 cno; | 17 | u64 cno; |
| 10 | u64 ino; | 18 | u64 ino; |
diff --git a/fs/nilfs2/ifile.c b/fs/nilfs2/ifile.c index 5a48df79d674..d8e65bde083c 100644 --- a/fs/nilfs2/ifile.c +++ b/fs/nilfs2/ifile.c | |||
| @@ -29,7 +29,11 @@ | |||
| 29 | #include "alloc.h" | 29 | #include "alloc.h" |
| 30 | #include "ifile.h" | 30 | #include "ifile.h" |
| 31 | 31 | ||
| 32 | 32 | /** | |
| 33 | * struct nilfs_ifile_info - on-memory private data of ifile | ||
| 34 | * @mi: on-memory private data of metadata file | ||
| 35 | * @palloc_cache: persistent object allocator cache of ifile | ||
| 36 | */ | ||
| 33 | struct nilfs_ifile_info { | 37 | struct nilfs_ifile_info { |
| 34 | struct nilfs_mdt_info mi; | 38 | struct nilfs_mdt_info mi; |
| 35 | struct nilfs_palloc_cache palloc_cache; | 39 | struct nilfs_palloc_cache palloc_cache; |
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index 7cc64465ec26..6e2c3db976b2 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c | |||
| @@ -34,6 +34,13 @@ | |||
| 34 | #include "cpfile.h" | 34 | #include "cpfile.h" |
| 35 | #include "ifile.h" | 35 | #include "ifile.h" |
| 36 | 36 | ||
| 37 | /** | ||
| 38 | * struct nilfs_iget_args - arguments used during comparison between inodes | ||
| 39 | * @ino: inode number | ||
| 40 | * @cno: checkpoint number | ||
| 41 | * @root: pointer on NILFS root object (mounted checkpoint) | ||
| 42 | * @for_gc: inode for GC flag | ||
| 43 | */ | ||
| 37 | struct nilfs_iget_args { | 44 | struct nilfs_iget_args { |
| 38 | u64 ino; | 45 | u64 ino; |
| 39 | __u64 cno; | 46 | __u64 cno; |
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c index 06658caa18bd..0b6387c67e6c 100644 --- a/fs/nilfs2/ioctl.c +++ b/fs/nilfs2/ioctl.c | |||
| @@ -182,7 +182,7 @@ static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp, | |||
| 182 | if (copy_from_user(&cpmode, argp, sizeof(cpmode))) | 182 | if (copy_from_user(&cpmode, argp, sizeof(cpmode))) |
| 183 | goto out; | 183 | goto out; |
| 184 | 184 | ||
| 185 | down_read(&inode->i_sb->s_umount); | 185 | mutex_lock(&nilfs->ns_snapshot_mount_mutex); |
| 186 | 186 | ||
| 187 | nilfs_transaction_begin(inode->i_sb, &ti, 0); | 187 | nilfs_transaction_begin(inode->i_sb, &ti, 0); |
| 188 | ret = nilfs_cpfile_change_cpmode( | 188 | ret = nilfs_cpfile_change_cpmode( |
| @@ -192,7 +192,7 @@ static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp, | |||
| 192 | else | 192 | else |
| 193 | nilfs_transaction_commit(inode->i_sb); /* never fails */ | 193 | nilfs_transaction_commit(inode->i_sb); /* never fails */ |
| 194 | 194 | ||
| 195 | up_read(&inode->i_sb->s_umount); | 195 | mutex_unlock(&nilfs->ns_snapshot_mount_mutex); |
| 196 | out: | 196 | out: |
| 197 | mnt_drop_write_file(filp); | 197 | mnt_drop_write_file(filp); |
| 198 | return ret; | 198 | return ret; |
diff --git a/fs/nilfs2/mdt.h b/fs/nilfs2/mdt.h index ab20a4baa50f..ab172e8549c5 100644 --- a/fs/nilfs2/mdt.h +++ b/fs/nilfs2/mdt.h | |||
| @@ -28,6 +28,13 @@ | |||
| 28 | #include "nilfs.h" | 28 | #include "nilfs.h" |
| 29 | #include "page.h" | 29 | #include "page.h" |
| 30 | 30 | ||
| 31 | /** | ||
| 32 | * struct nilfs_shadow_map - shadow mapping of meta data file | ||
| 33 | * @bmap_store: shadow copy of bmap state | ||
| 34 | * @frozen_data: shadowed dirty data pages | ||
| 35 | * @frozen_btnodes: shadowed dirty b-tree nodes' pages | ||
| 36 | * @frozen_buffers: list of frozen buffers | ||
| 37 | */ | ||
| 31 | struct nilfs_shadow_map { | 38 | struct nilfs_shadow_map { |
| 32 | struct nilfs_bmap_store bmap_store; | 39 | struct nilfs_bmap_store bmap_store; |
| 33 | struct address_space frozen_data; | 40 | struct address_space frozen_data; |
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h index 250add84da76..74cece80e9a3 100644 --- a/fs/nilfs2/nilfs.h +++ b/fs/nilfs2/nilfs.h | |||
| @@ -32,8 +32,21 @@ | |||
| 32 | #include "the_nilfs.h" | 32 | #include "the_nilfs.h" |
| 33 | #include "bmap.h" | 33 | #include "bmap.h" |
| 34 | 34 | ||
| 35 | /* | 35 | /** |
| 36 | * nilfs inode data in memory | 36 | * struct nilfs_inode_info - nilfs inode data in memory |
| 37 | * @i_flags: inode flags | ||
| 38 | * @i_state: dynamic state flags | ||
| 39 | * @i_bmap: pointer on i_bmap_data | ||
| 40 | * @i_bmap_data: raw block mapping | ||
| 41 | * @i_xattr: <TODO> | ||
| 42 | * @i_dir_start_lookup: page index of last successful search | ||
| 43 | * @i_cno: checkpoint number for GC inode | ||
| 44 | * @i_btnode_cache: cached pages of b-tree nodes | ||
| 45 | * @i_dirty: list for connecting dirty files | ||
| 46 | * @xattr_sem: semaphore for extended attributes processing | ||
| 47 | * @i_bh: buffer contains disk inode | ||
| 48 | * @i_root: root object of the current filesystem tree | ||
| 49 | * @vfs_inode: VFS inode object | ||
| 37 | */ | 50 | */ |
| 38 | struct nilfs_inode_info { | 51 | struct nilfs_inode_info { |
| 39 | __u32 i_flags; | 52 | __u32 i_flags; |
diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c index c5b7653a4391..3127e9f438a7 100644 --- a/fs/nilfs2/sufile.c +++ b/fs/nilfs2/sufile.c | |||
| @@ -30,7 +30,13 @@ | |||
| 30 | #include "mdt.h" | 30 | #include "mdt.h" |
| 31 | #include "sufile.h" | 31 | #include "sufile.h" |
| 32 | 32 | ||
| 33 | 33 | /** | |
| 34 | * struct nilfs_sufile_info - on-memory private data of sufile | ||
| 35 | * @mi: on-memory private data of metadata file | ||
| 36 | * @ncleansegs: number of clean segments | ||
| 37 | * @allocmin: lower limit of allocatable segment range | ||
| 38 | * @allocmax: upper limit of allocatable segment range | ||
| 39 | */ | ||
| 34 | struct nilfs_sufile_info { | 40 | struct nilfs_sufile_info { |
| 35 | struct nilfs_mdt_info mi; | 41 | struct nilfs_mdt_info mi; |
| 36 | unsigned long ncleansegs;/* number of clean segments */ | 42 | unsigned long ncleansegs;/* number of clean segments */ |
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index d57c42f974ea..6522cac6057c 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c | |||
| @@ -677,7 +677,6 @@ static const struct super_operations nilfs_sops = { | |||
| 677 | .destroy_inode = nilfs_destroy_inode, | 677 | .destroy_inode = nilfs_destroy_inode, |
| 678 | .dirty_inode = nilfs_dirty_inode, | 678 | .dirty_inode = nilfs_dirty_inode, |
| 679 | /* .write_inode = nilfs_write_inode, */ | 679 | /* .write_inode = nilfs_write_inode, */ |
| 680 | /* .put_inode = nilfs_put_inode, */ | ||
| 681 | /* .drop_inode = nilfs_drop_inode, */ | 680 | /* .drop_inode = nilfs_drop_inode, */ |
| 682 | .evict_inode = nilfs_evict_inode, | 681 | .evict_inode = nilfs_evict_inode, |
| 683 | .put_super = nilfs_put_super, | 682 | .put_super = nilfs_put_super, |
| @@ -685,8 +684,6 @@ static const struct super_operations nilfs_sops = { | |||
| 685 | .sync_fs = nilfs_sync_fs, | 684 | .sync_fs = nilfs_sync_fs, |
| 686 | .freeze_fs = nilfs_freeze, | 685 | .freeze_fs = nilfs_freeze, |
| 687 | .unfreeze_fs = nilfs_unfreeze, | 686 | .unfreeze_fs = nilfs_unfreeze, |
| 688 | /* .write_super_lockfs */ | ||
| 689 | /* .unlockfs */ | ||
| 690 | .statfs = nilfs_statfs, | 687 | .statfs = nilfs_statfs, |
| 691 | .remount_fs = nilfs_remount, | 688 | .remount_fs = nilfs_remount, |
| 692 | /* .umount_begin */ | 689 | /* .umount_begin */ |
| @@ -948,6 +945,8 @@ static int nilfs_attach_snapshot(struct super_block *s, __u64 cno, | |||
| 948 | struct nilfs_root *root; | 945 | struct nilfs_root *root; |
| 949 | int ret; | 946 | int ret; |
| 950 | 947 | ||
| 948 | mutex_lock(&nilfs->ns_snapshot_mount_mutex); | ||
| 949 | |||
| 951 | down_read(&nilfs->ns_segctor_sem); | 950 | down_read(&nilfs->ns_segctor_sem); |
| 952 | ret = nilfs_cpfile_is_snapshot(nilfs->ns_cpfile, cno); | 951 | ret = nilfs_cpfile_is_snapshot(nilfs->ns_cpfile, cno); |
| 953 | up_read(&nilfs->ns_segctor_sem); | 952 | up_read(&nilfs->ns_segctor_sem); |
| @@ -972,6 +971,7 @@ static int nilfs_attach_snapshot(struct super_block *s, __u64 cno, | |||
| 972 | ret = nilfs_get_root_dentry(s, root, root_dentry); | 971 | ret = nilfs_get_root_dentry(s, root, root_dentry); |
| 973 | nilfs_put_root(root); | 972 | nilfs_put_root(root); |
| 974 | out: | 973 | out: |
| 974 | mutex_unlock(&nilfs->ns_snapshot_mount_mutex); | ||
| 975 | return ret; | 975 | return ret; |
| 976 | } | 976 | } |
| 977 | 977 | ||
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index 501b7f8b739f..41e6a04a561f 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c | |||
| @@ -76,6 +76,7 @@ struct the_nilfs *alloc_nilfs(struct block_device *bdev) | |||
| 76 | nilfs->ns_bdev = bdev; | 76 | nilfs->ns_bdev = bdev; |
| 77 | atomic_set(&nilfs->ns_ndirtyblks, 0); | 77 | atomic_set(&nilfs->ns_ndirtyblks, 0); |
| 78 | init_rwsem(&nilfs->ns_sem); | 78 | init_rwsem(&nilfs->ns_sem); |
| 79 | mutex_init(&nilfs->ns_snapshot_mount_mutex); | ||
| 79 | INIT_LIST_HEAD(&nilfs->ns_dirty_files); | 80 | INIT_LIST_HEAD(&nilfs->ns_dirty_files); |
| 80 | INIT_LIST_HEAD(&nilfs->ns_gc_inodes); | 81 | INIT_LIST_HEAD(&nilfs->ns_gc_inodes); |
| 81 | spin_lock_init(&nilfs->ns_inode_lock); | 82 | spin_lock_init(&nilfs->ns_inode_lock); |
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h index 9992b11312ff..6eee4177807b 100644 --- a/fs/nilfs2/the_nilfs.h +++ b/fs/nilfs2/the_nilfs.h | |||
| @@ -47,11 +47,13 @@ enum { | |||
| 47 | * @ns_flags: flags | 47 | * @ns_flags: flags |
| 48 | * @ns_bdev: block device | 48 | * @ns_bdev: block device |
| 49 | * @ns_sem: semaphore for shared states | 49 | * @ns_sem: semaphore for shared states |
| 50 | * @ns_snapshot_mount_mutex: mutex to protect snapshot mounts | ||
| 50 | * @ns_sbh: buffer heads of on-disk super blocks | 51 | * @ns_sbh: buffer heads of on-disk super blocks |
| 51 | * @ns_sbp: pointers to super block data | 52 | * @ns_sbp: pointers to super block data |
| 52 | * @ns_sbwtime: previous write time of super block | 53 | * @ns_sbwtime: previous write time of super block |
| 53 | * @ns_sbwcount: write count of super block | 54 | * @ns_sbwcount: write count of super block |
| 54 | * @ns_sbsize: size of valid data in super block | 55 | * @ns_sbsize: size of valid data in super block |
| 56 | * @ns_mount_state: file system state | ||
| 55 | * @ns_seg_seq: segment sequence counter | 57 | * @ns_seg_seq: segment sequence counter |
| 56 | * @ns_segnum: index number of the latest full segment. | 58 | * @ns_segnum: index number of the latest full segment. |
| 57 | * @ns_nextnum: index number of the full segment index to be used next | 59 | * @ns_nextnum: index number of the full segment index to be used next |
| @@ -99,6 +101,7 @@ struct the_nilfs { | |||
| 99 | 101 | ||
| 100 | struct block_device *ns_bdev; | 102 | struct block_device *ns_bdev; |
| 101 | struct rw_semaphore ns_sem; | 103 | struct rw_semaphore ns_sem; |
| 104 | struct mutex ns_snapshot_mount_mutex; | ||
| 102 | 105 | ||
| 103 | /* | 106 | /* |
| 104 | * used for | 107 | * used for |
| @@ -229,9 +232,8 @@ THE_NILFS_FNS(SB_DIRTY, sb_dirty) | |||
| 229 | * @count: refcount of this structure | 232 | * @count: refcount of this structure |
| 230 | * @nilfs: nilfs object | 233 | * @nilfs: nilfs object |
| 231 | * @ifile: inode file | 234 | * @ifile: inode file |
| 232 | * @root: root inode | ||
| 233 | * @inodes_count: number of inodes | 235 | * @inodes_count: number of inodes |
| 234 | * @blocks_count: number of blocks (Reserved) | 236 | * @blocks_count: number of blocks |
| 235 | */ | 237 | */ |
| 236 | struct nilfs_root { | 238 | struct nilfs_root { |
| 237 | __u64 cno; | 239 | __u64 cno; |
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index b341492542ca..2bc149d6a784 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c | |||
| @@ -2660,31 +2660,14 @@ static const struct super_operations ntfs_sops = { | |||
| 2660 | .alloc_inode = ntfs_alloc_big_inode, /* VFS: Allocate new inode. */ | 2660 | .alloc_inode = ntfs_alloc_big_inode, /* VFS: Allocate new inode. */ |
| 2661 | .destroy_inode = ntfs_destroy_big_inode, /* VFS: Deallocate inode. */ | 2661 | .destroy_inode = ntfs_destroy_big_inode, /* VFS: Deallocate inode. */ |
| 2662 | #ifdef NTFS_RW | 2662 | #ifdef NTFS_RW |
| 2663 | //.dirty_inode = NULL, /* VFS: Called from | ||
| 2664 | // __mark_inode_dirty(). */ | ||
| 2665 | .write_inode = ntfs_write_inode, /* VFS: Write dirty inode to | 2663 | .write_inode = ntfs_write_inode, /* VFS: Write dirty inode to |
| 2666 | disk. */ | 2664 | disk. */ |
| 2667 | //.drop_inode = NULL, /* VFS: Called just after the | ||
| 2668 | // inode reference count has | ||
| 2669 | // been decreased to zero. | ||
| 2670 | // NOTE: The inode lock is | ||
| 2671 | // held. See fs/inode.c:: | ||
| 2672 | // generic_drop_inode(). */ | ||
| 2673 | //.delete_inode = NULL, /* VFS: Delete inode from disk. | ||
| 2674 | // Called when i_count becomes | ||
| 2675 | // 0 and i_nlink is also 0. */ | ||
| 2676 | //.write_super = NULL, /* Flush dirty super block to | ||
| 2677 | // disk. */ | ||
| 2678 | //.sync_fs = NULL, /* ? */ | ||
| 2679 | //.write_super_lockfs = NULL, /* ? */ | ||
| 2680 | //.unlockfs = NULL, /* ? */ | ||
| 2681 | #endif /* NTFS_RW */ | 2665 | #endif /* NTFS_RW */ |
| 2682 | .put_super = ntfs_put_super, /* Syscall: umount. */ | 2666 | .put_super = ntfs_put_super, /* Syscall: umount. */ |
| 2683 | .statfs = ntfs_statfs, /* Syscall: statfs */ | 2667 | .statfs = ntfs_statfs, /* Syscall: statfs */ |
| 2684 | .remount_fs = ntfs_remount, /* Syscall: mount -o remount. */ | 2668 | .remount_fs = ntfs_remount, /* Syscall: mount -o remount. */ |
| 2685 | .evict_inode = ntfs_evict_big_inode, /* VFS: Called when an inode is | 2669 | .evict_inode = ntfs_evict_big_inode, /* VFS: Called when an inode is |
| 2686 | removed from memory. */ | 2670 | removed from memory. */ |
| 2687 | //.umount_begin = NULL, /* Forced umount. */ | ||
| 2688 | .show_options = ntfs_show_options, /* Show mount options in | 2671 | .show_options = ntfs_show_options, /* Show mount options in |
| 2689 | proc. */ | 2672 | proc. */ |
| 2690 | }; | 2673 | }; |
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index 210c35237548..a9f78c74d687 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c | |||
| @@ -784,14 +784,10 @@ bail: | |||
| 784 | 784 | ||
| 785 | static u32 ocfs2_local_alloc_count_bits(struct ocfs2_dinode *alloc) | 785 | static u32 ocfs2_local_alloc_count_bits(struct ocfs2_dinode *alloc) |
| 786 | { | 786 | { |
| 787 | int i; | 787 | u32 count; |
| 788 | u8 *buffer; | ||
| 789 | u32 count = 0; | ||
| 790 | struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); | 788 | struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); |
| 791 | 789 | ||
| 792 | buffer = la->la_bitmap; | 790 | count = memweight(la->la_bitmap, le16_to_cpu(la->la_size)); |
| 793 | for (i = 0; i < le16_to_cpu(la->la_size); i++) | ||
| 794 | count += hweight8(buffer[i]); | ||
| 795 | 791 | ||
| 796 | trace_ocfs2_local_alloc_count_bits(count); | 792 | trace_ocfs2_local_alloc_count_bits(count); |
| 797 | return count; | 793 | return count; |
diff --git a/fs/proc/base.c b/fs/proc/base.c index 2772208338f8..1b6c84cbdb73 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
| @@ -695,8 +695,6 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode) | |||
| 695 | mmput(mm); | 695 | mmput(mm); |
| 696 | } | 696 | } |
| 697 | 697 | ||
| 698 | /* OK to pass negative loff_t, we can catch out-of-range */ | ||
| 699 | file->f_mode |= FMODE_UNSIGNED_OFFSET; | ||
| 700 | file->private_data = mm; | 698 | file->private_data = mm; |
| 701 | 699 | ||
| 702 | return 0; | 700 | return 0; |
| @@ -704,7 +702,12 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode) | |||
| 704 | 702 | ||
| 705 | static int mem_open(struct inode *inode, struct file *file) | 703 | static int mem_open(struct inode *inode, struct file *file) |
| 706 | { | 704 | { |
| 707 | return __mem_open(inode, file, PTRACE_MODE_ATTACH); | 705 | int ret = __mem_open(inode, file, PTRACE_MODE_ATTACH); |
| 706 | |||
| 707 | /* OK to pass negative loff_t, we can catch out-of-range */ | ||
| 708 | file->f_mode |= FMODE_UNSIGNED_OFFSET; | ||
| 709 | |||
| 710 | return ret; | ||
| 708 | } | 711 | } |
| 709 | 712 | ||
| 710 | static ssize_t mem_rw(struct file *file, char __user *buf, | 713 | static ssize_t mem_rw(struct file *file, char __user *buf, |
| @@ -827,15 +830,16 @@ static ssize_t environ_read(struct file *file, char __user *buf, | |||
| 827 | if (!atomic_inc_not_zero(&mm->mm_users)) | 830 | if (!atomic_inc_not_zero(&mm->mm_users)) |
| 828 | goto free; | 831 | goto free; |
| 829 | while (count > 0) { | 832 | while (count > 0) { |
| 830 | int this_len, retval, max_len; | 833 | size_t this_len, max_len; |
| 831 | 834 | int retval; | |
| 832 | this_len = mm->env_end - (mm->env_start + src); | ||
| 833 | 835 | ||
| 834 | if (this_len <= 0) | 836 | if (src >= (mm->env_end - mm->env_start)) |
| 835 | break; | 837 | break; |
| 836 | 838 | ||
| 837 | max_len = (count > PAGE_SIZE) ? PAGE_SIZE : count; | 839 | this_len = mm->env_end - (mm->env_start + src); |
| 838 | this_len = (this_len > max_len) ? max_len : this_len; | 840 | |
| 841 | max_len = min_t(size_t, PAGE_SIZE, count); | ||
| 842 | this_len = min(max_len, this_len); | ||
| 839 | 843 | ||
| 840 | retval = access_remote_vm(mm, (mm->env_start + src), | 844 | retval = access_remote_vm(mm, (mm->env_start + src), |
| 841 | page, this_len, 0); | 845 | page, this_len, 0); |
diff --git a/fs/qnx4/bitmap.c b/fs/qnx4/bitmap.c index 22e0d60e53ef..76a7a697b778 100644 --- a/fs/qnx4/bitmap.c +++ b/fs/qnx4/bitmap.c | |||
| @@ -17,23 +17,6 @@ | |||
| 17 | #include <linux/bitops.h> | 17 | #include <linux/bitops.h> |
| 18 | #include "qnx4.h" | 18 | #include "qnx4.h" |
| 19 | 19 | ||
| 20 | static void count_bits(register const char *bmPart, register int size, | ||
| 21 | int *const tf) | ||
| 22 | { | ||
| 23 | char b; | ||
| 24 | int tot = *tf; | ||
| 25 | |||
| 26 | if (size > QNX4_BLOCK_SIZE) { | ||
| 27 | size = QNX4_BLOCK_SIZE; | ||
| 28 | } | ||
| 29 | do { | ||
| 30 | b = *bmPart++; | ||
| 31 | tot += 8 - hweight8(b); | ||
| 32 | size--; | ||
| 33 | } while (size != 0); | ||
| 34 | *tf = tot; | ||
| 35 | } | ||
| 36 | |||
| 37 | unsigned long qnx4_count_free_blocks(struct super_block *sb) | 20 | unsigned long qnx4_count_free_blocks(struct super_block *sb) |
| 38 | { | 21 | { |
| 39 | int start = le32_to_cpu(qnx4_sb(sb)->BitMap->di_first_xtnt.xtnt_blk) - 1; | 22 | int start = le32_to_cpu(qnx4_sb(sb)->BitMap->di_first_xtnt.xtnt_blk) - 1; |
| @@ -44,13 +27,16 @@ unsigned long qnx4_count_free_blocks(struct super_block *sb) | |||
| 44 | struct buffer_head *bh; | 27 | struct buffer_head *bh; |
| 45 | 28 | ||
| 46 | while (total < size) { | 29 | while (total < size) { |
| 30 | int bytes = min(size - total, QNX4_BLOCK_SIZE); | ||
| 31 | |||
| 47 | if ((bh = sb_bread(sb, start + offset)) == NULL) { | 32 | if ((bh = sb_bread(sb, start + offset)) == NULL) { |
| 48 | printk(KERN_ERR "qnx4: I/O error in counting free blocks\n"); | 33 | printk(KERN_ERR "qnx4: I/O error in counting free blocks\n"); |
| 49 | break; | 34 | break; |
| 50 | } | 35 | } |
| 51 | count_bits(bh->b_data, size - total, &total_free); | 36 | total_free += bytes * BITS_PER_BYTE - |
| 37 | memweight(bh->b_data, bytes); | ||
| 52 | brelse(bh); | 38 | brelse(bh); |
| 53 | total += QNX4_BLOCK_SIZE; | 39 | total += bytes; |
| 54 | offset++; | 40 | offset++; |
| 55 | } | 41 | } |
| 56 | 42 | ||
diff --git a/fs/xattr.c b/fs/xattr.c index 1d7ac3790458..4d45b7189e7e 100644 --- a/fs/xattr.c +++ b/fs/xattr.c | |||
| @@ -427,6 +427,7 @@ getxattr(struct dentry *d, const char __user *name, void __user *value, | |||
| 427 | { | 427 | { |
| 428 | ssize_t error; | 428 | ssize_t error; |
| 429 | void *kvalue = NULL; | 429 | void *kvalue = NULL; |
| 430 | void *vvalue = NULL; | ||
| 430 | char kname[XATTR_NAME_MAX + 1]; | 431 | char kname[XATTR_NAME_MAX + 1]; |
| 431 | 432 | ||
| 432 | error = strncpy_from_user(kname, name, sizeof(kname)); | 433 | error = strncpy_from_user(kname, name, sizeof(kname)); |
| @@ -438,9 +439,13 @@ getxattr(struct dentry *d, const char __user *name, void __user *value, | |||
| 438 | if (size) { | 439 | if (size) { |
| 439 | if (size > XATTR_SIZE_MAX) | 440 | if (size > XATTR_SIZE_MAX) |
| 440 | size = XATTR_SIZE_MAX; | 441 | size = XATTR_SIZE_MAX; |
| 441 | kvalue = kzalloc(size, GFP_KERNEL); | 442 | kvalue = kzalloc(size, GFP_KERNEL | __GFP_NOWARN); |
| 442 | if (!kvalue) | 443 | if (!kvalue) { |
| 443 | return -ENOMEM; | 444 | vvalue = vmalloc(size); |
| 445 | if (!vvalue) | ||
| 446 | return -ENOMEM; | ||
| 447 | kvalue = vvalue; | ||
| 448 | } | ||
| 444 | } | 449 | } |
| 445 | 450 | ||
| 446 | error = vfs_getxattr(d, kname, kvalue, size); | 451 | error = vfs_getxattr(d, kname, kvalue, size); |
| @@ -452,7 +457,10 @@ getxattr(struct dentry *d, const char __user *name, void __user *value, | |||
| 452 | than XATTR_SIZE_MAX bytes. Not possible. */ | 457 | than XATTR_SIZE_MAX bytes. Not possible. */ |
| 453 | error = -E2BIG; | 458 | error = -E2BIG; |
| 454 | } | 459 | } |
| 455 | kfree(kvalue); | 460 | if (vvalue) |
| 461 | vfree(vvalue); | ||
| 462 | else | ||
| 463 | kfree(kvalue); | ||
| 456 | return error; | 464 | return error; |
| 457 | } | 465 | } |
| 458 | 466 | ||
diff --git a/include/asm-generic/fcntl.h b/include/asm-generic/fcntl.h index 9e5b0356e2bb..a48937d4a5ea 100644 --- a/include/asm-generic/fcntl.h +++ b/include/asm-generic/fcntl.h | |||
| @@ -120,6 +120,10 @@ | |||
| 120 | #define F_GETOWN_EX 16 | 120 | #define F_GETOWN_EX 16 |
| 121 | #endif | 121 | #endif |
| 122 | 122 | ||
| 123 | #ifndef F_GETOWNER_UIDS | ||
| 124 | #define F_GETOWNER_UIDS 17 | ||
| 125 | #endif | ||
| 126 | |||
| 123 | #define F_OWNER_TID 0 | 127 | #define F_OWNER_TID 0 |
| 124 | #define F_OWNER_PID 1 | 128 | #define F_OWNER_PID 1 |
| 125 | #define F_OWNER_PGRP 2 | 129 | #define F_OWNER_PGRP 2 |
diff --git a/include/linux/aio.h b/include/linux/aio.h index b1a520ec8b59..31ff6dba4872 100644 --- a/include/linux/aio.h +++ b/include/linux/aio.h | |||
| @@ -126,22 +126,20 @@ struct kiocb { | |||
| 126 | struct eventfd_ctx *ki_eventfd; | 126 | struct eventfd_ctx *ki_eventfd; |
| 127 | }; | 127 | }; |
| 128 | 128 | ||
| 129 | #define is_sync_kiocb(iocb) ((iocb)->ki_key == KIOCB_SYNC_KEY) | 129 | static inline bool is_sync_kiocb(struct kiocb *kiocb) |
| 130 | #define init_sync_kiocb(x, filp) \ | 130 | { |
| 131 | do { \ | 131 | return kiocb->ki_key == KIOCB_SYNC_KEY; |
| 132 | struct task_struct *tsk = current; \ | 132 | } |
| 133 | (x)->ki_flags = 0; \ | 133 | |
| 134 | (x)->ki_users = 1; \ | 134 | static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp) |
| 135 | (x)->ki_key = KIOCB_SYNC_KEY; \ | 135 | { |
| 136 | (x)->ki_filp = (filp); \ | 136 | *kiocb = (struct kiocb) { |
| 137 | (x)->ki_ctx = NULL; \ | 137 | .ki_users = 1, |
| 138 | (x)->ki_cancel = NULL; \ | 138 | .ki_key = KIOCB_SYNC_KEY, |
| 139 | (x)->ki_retry = NULL; \ | 139 | .ki_filp = filp, |
| 140 | (x)->ki_dtor = NULL; \ | 140 | .ki_obj.tsk = current, |
| 141 | (x)->ki_obj.tsk = tsk; \ | 141 | }; |
| 142 | (x)->ki_user_data = 0; \ | 142 | } |
| 143 | (x)->private = NULL; \ | ||
| 144 | } while (0) | ||
| 145 | 143 | ||
| 146 | #define AIO_RING_MAGIC 0xa10a10a1 | 144 | #define AIO_RING_MAGIC 0xa10a10a1 |
| 147 | #define AIO_RING_COMPAT_FEATURES 1 | 145 | #define AIO_RING_COMPAT_FEATURES 1 |
| @@ -161,8 +159,6 @@ struct aio_ring { | |||
| 161 | struct io_event io_events[0]; | 159 | struct io_event io_events[0]; |
| 162 | }; /* 128 bytes + ring size */ | 160 | }; /* 128 bytes + ring size */ |
| 163 | 161 | ||
| 164 | #define aio_ring_avail(info, ring) (((ring)->head + (info)->nr - 1 - (ring)->tail) % (info)->nr) | ||
| 165 | |||
| 166 | #define AIO_RING_PAGES 8 | 162 | #define AIO_RING_PAGES 8 |
| 167 | struct aio_ring_info { | 163 | struct aio_ring_info { |
| 168 | unsigned long mmap_base; | 164 | unsigned long mmap_base; |
| @@ -177,6 +173,12 @@ struct aio_ring_info { | |||
| 177 | struct page *internal_pages[AIO_RING_PAGES]; | 173 | struct page *internal_pages[AIO_RING_PAGES]; |
| 178 | }; | 174 | }; |
| 179 | 175 | ||
| 176 | static inline unsigned aio_ring_avail(struct aio_ring_info *info, | ||
| 177 | struct aio_ring *ring) | ||
| 178 | { | ||
| 179 | return (ring->head + info->nr - 1 - ring->tail) % info->nr; | ||
| 180 | } | ||
| 181 | |||
| 180 | struct kioctx { | 182 | struct kioctx { |
| 181 | atomic_t users; | 183 | atomic_t users; |
| 182 | int dead; | 184 | int dead; |
diff --git a/include/linux/clk.h b/include/linux/clk.h index 2fd6a4234531..b3ac22d0fc1f 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h | |||
| @@ -85,6 +85,43 @@ int clk_notifier_unregister(struct clk *clk, struct notifier_block *nb); | |||
| 85 | #endif | 85 | #endif |
| 86 | 86 | ||
| 87 | /** | 87 | /** |
| 88 | * clk_prepare - prepare a clock source | ||
| 89 | * @clk: clock source | ||
| 90 | * | ||
| 91 | * This prepares the clock source for use. | ||
| 92 | * | ||
| 93 | * Must not be called from within atomic context. | ||
| 94 | */ | ||
| 95 | #ifdef CONFIG_HAVE_CLK_PREPARE | ||
| 96 | int clk_prepare(struct clk *clk); | ||
| 97 | #else | ||
| 98 | static inline int clk_prepare(struct clk *clk) | ||
| 99 | { | ||
| 100 | might_sleep(); | ||
| 101 | return 0; | ||
| 102 | } | ||
| 103 | #endif | ||
| 104 | |||
| 105 | /** | ||
| 106 | * clk_unprepare - undo preparation of a clock source | ||
| 107 | * @clk: clock source | ||
| 108 | * | ||
| 109 | * This undoes a previously prepared clock. The caller must balance | ||
| 110 | * the number of prepare and unprepare calls. | ||
| 111 | * | ||
| 112 | * Must not be called from within atomic context. | ||
| 113 | */ | ||
| 114 | #ifdef CONFIG_HAVE_CLK_PREPARE | ||
| 115 | void clk_unprepare(struct clk *clk); | ||
| 116 | #else | ||
| 117 | static inline void clk_unprepare(struct clk *clk) | ||
| 118 | { | ||
| 119 | might_sleep(); | ||
| 120 | } | ||
| 121 | #endif | ||
| 122 | |||
| 123 | #ifdef CONFIG_HAVE_CLK | ||
| 124 | /** | ||
| 88 | * clk_get - lookup and obtain a reference to a clock producer. | 125 | * clk_get - lookup and obtain a reference to a clock producer. |
| 89 | * @dev: device for clock "consumer" | 126 | * @dev: device for clock "consumer" |
| 90 | * @id: clock consumer ID | 127 | * @id: clock consumer ID |
| @@ -122,24 +159,6 @@ struct clk *clk_get(struct device *dev, const char *id); | |||
| 122 | struct clk *devm_clk_get(struct device *dev, const char *id); | 159 | struct clk *devm_clk_get(struct device *dev, const char *id); |
| 123 | 160 | ||
| 124 | /** | 161 | /** |
| 125 | * clk_prepare - prepare a clock source | ||
| 126 | * @clk: clock source | ||
| 127 | * | ||
| 128 | * This prepares the clock source for use. | ||
| 129 | * | ||
| 130 | * Must not be called from within atomic context. | ||
| 131 | */ | ||
| 132 | #ifdef CONFIG_HAVE_CLK_PREPARE | ||
| 133 | int clk_prepare(struct clk *clk); | ||
| 134 | #else | ||
| 135 | static inline int clk_prepare(struct clk *clk) | ||
| 136 | { | ||
| 137 | might_sleep(); | ||
| 138 | return 0; | ||
| 139 | } | ||
| 140 | #endif | ||
| 141 | |||
| 142 | /** | ||
| 143 | * clk_enable - inform the system when the clock source should be running. | 162 | * clk_enable - inform the system when the clock source should be running. |
| 144 | * @clk: clock source | 163 | * @clk: clock source |
| 145 | * | 164 | * |
| @@ -167,47 +186,6 @@ int clk_enable(struct clk *clk); | |||
| 167 | */ | 186 | */ |
| 168 | void clk_disable(struct clk *clk); | 187 | void clk_disable(struct clk *clk); |
| 169 | 188 | ||
| 170 | |||
| 171 | /** | ||
| 172 | * clk_unprepare - undo preparation of a clock source | ||
| 173 | * @clk: clock source | ||
| 174 | * | ||
| 175 | * This undoes a previously prepared clock. The caller must balance | ||
| 176 | * the number of prepare and unprepare calls. | ||
| 177 | * | ||
| 178 | * Must not be called from within atomic context. | ||
| 179 | */ | ||
| 180 | #ifdef CONFIG_HAVE_CLK_PREPARE | ||
| 181 | void clk_unprepare(struct clk *clk); | ||
| 182 | #else | ||
| 183 | static inline void clk_unprepare(struct clk *clk) | ||
| 184 | { | ||
| 185 | might_sleep(); | ||
| 186 | } | ||
| 187 | #endif | ||
| 188 | |||
| 189 | /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */ | ||
| 190 | static inline int clk_prepare_enable(struct clk *clk) | ||
| 191 | { | ||
| 192 | int ret; | ||
| 193 | |||
| 194 | ret = clk_prepare(clk); | ||
| 195 | if (ret) | ||
| 196 | return ret; | ||
| 197 | ret = clk_enable(clk); | ||
| 198 | if (ret) | ||
| 199 | clk_unprepare(clk); | ||
| 200 | |||
| 201 | return ret; | ||
| 202 | } | ||
| 203 | |||
| 204 | /* clk_disable_unprepare helps cases using clk_disable in non-atomic context. */ | ||
| 205 | static inline void clk_disable_unprepare(struct clk *clk) | ||
| 206 | { | ||
| 207 | clk_disable(clk); | ||
| 208 | clk_unprepare(clk); | ||
| 209 | } | ||
| 210 | |||
| 211 | /** | 189 | /** |
| 212 | * clk_get_rate - obtain the current clock rate (in Hz) for a clock source. | 190 | * clk_get_rate - obtain the current clock rate (in Hz) for a clock source. |
| 213 | * This is only valid once the clock source has been enabled. | 191 | * This is only valid once the clock source has been enabled. |
| @@ -298,6 +276,78 @@ struct clk *clk_get_parent(struct clk *clk); | |||
| 298 | */ | 276 | */ |
| 299 | struct clk *clk_get_sys(const char *dev_id, const char *con_id); | 277 | struct clk *clk_get_sys(const char *dev_id, const char *con_id); |
| 300 | 278 | ||
| 279 | #else /* !CONFIG_HAVE_CLK */ | ||
| 280 | |||
| 281 | static inline struct clk *clk_get(struct device *dev, const char *id) | ||
| 282 | { | ||
| 283 | return NULL; | ||
| 284 | } | ||
| 285 | |||
| 286 | static inline struct clk *devm_clk_get(struct device *dev, const char *id) | ||
| 287 | { | ||
| 288 | return NULL; | ||
| 289 | } | ||
| 290 | |||
| 291 | static inline void clk_put(struct clk *clk) {} | ||
| 292 | |||
| 293 | static inline void devm_clk_put(struct device *dev, struct clk *clk) {} | ||
| 294 | |||
| 295 | static inline int clk_enable(struct clk *clk) | ||
| 296 | { | ||
| 297 | return 0; | ||
| 298 | } | ||
| 299 | |||
| 300 | static inline void clk_disable(struct clk *clk) {} | ||
| 301 | |||
| 302 | static inline unsigned long clk_get_rate(struct clk *clk) | ||
| 303 | { | ||
| 304 | return 0; | ||
| 305 | } | ||
| 306 | |||
| 307 | static inline int clk_set_rate(struct clk *clk, unsigned long rate) | ||
| 308 | { | ||
| 309 | return 0; | ||
| 310 | } | ||
| 311 | |||
| 312 | static inline long clk_round_rate(struct clk *clk, unsigned long rate) | ||
| 313 | { | ||
| 314 | return 0; | ||
| 315 | } | ||
| 316 | |||
| 317 | static inline int clk_set_parent(struct clk *clk, struct clk *parent) | ||
| 318 | { | ||
| 319 | return 0; | ||
| 320 | } | ||
| 321 | |||
| 322 | static inline struct clk *clk_get_parent(struct clk *clk) | ||
| 323 | { | ||
| 324 | return NULL; | ||
| 325 | } | ||
| 326 | |||
| 327 | #endif | ||
| 328 | |||
| 329 | /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */ | ||
| 330 | static inline int clk_prepare_enable(struct clk *clk) | ||
| 331 | { | ||
| 332 | int ret; | ||
| 333 | |||
| 334 | ret = clk_prepare(clk); | ||
| 335 | if (ret) | ||
| 336 | return ret; | ||
| 337 | ret = clk_enable(clk); | ||
| 338 | if (ret) | ||
| 339 | clk_unprepare(clk); | ||
| 340 | |||
| 341 | return ret; | ||
| 342 | } | ||
| 343 | |||
| 344 | /* clk_disable_unprepare helps cases using clk_disable in non-atomic context. */ | ||
| 345 | static inline void clk_disable_unprepare(struct clk *clk) | ||
| 346 | { | ||
| 347 | clk_disable(clk); | ||
| 348 | clk_unprepare(clk); | ||
| 349 | } | ||
| 350 | |||
| 301 | /** | 351 | /** |
| 302 | * clk_add_alias - add a new clock alias | 352 | * clk_add_alias - add a new clock alias |
| 303 | * @alias: name for clock alias | 353 | * @alias: name for clock alias |
diff --git a/include/linux/compat.h b/include/linux/compat.h index 4e890394ef99..09b28b7369d7 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h | |||
| @@ -265,9 +265,9 @@ long compat_sys_shmat(int first, int second, compat_uptr_t third, int version, | |||
| 265 | #else | 265 | #else |
| 266 | long compat_sys_semctl(int semid, int semnum, int cmd, int arg); | 266 | long compat_sys_semctl(int semid, int semnum, int cmd, int arg); |
| 267 | long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp, | 267 | long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp, |
| 268 | size_t msgsz, int msgflg); | 268 | compat_ssize_t msgsz, int msgflg); |
| 269 | long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp, | 269 | long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp, |
| 270 | size_t msgsz, long msgtyp, int msgflg); | 270 | compat_ssize_t msgsz, long msgtyp, int msgflg); |
| 271 | long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg); | 271 | long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg); |
| 272 | #endif | 272 | #endif |
| 273 | long compat_sys_msgctl(int first, int second, void __user *uptr); | 273 | long compat_sys_msgctl(int first, int second, void __user *uptr); |
diff --git a/include/linux/kern_levels.h b/include/linux/kern_levels.h new file mode 100644 index 000000000000..866caaa9e2bb --- /dev/null +++ b/include/linux/kern_levels.h | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | #ifndef __KERN_LEVELS_H__ | ||
| 2 | #define __KERN_LEVELS_H__ | ||
| 3 | |||
| 4 | #define KERN_SOH "\001" /* ASCII Start Of Header */ | ||
| 5 | #define KERN_SOH_ASCII '\001' | ||
| 6 | |||
| 7 | #define KERN_EMERG KERN_SOH "0" /* system is unusable */ | ||
| 8 | #define KERN_ALERT KERN_SOH "1" /* action must be taken immediately */ | ||
| 9 | #define KERN_CRIT KERN_SOH "2" /* critical conditions */ | ||
| 10 | #define KERN_ERR KERN_SOH "3" /* error conditions */ | ||
| 11 | #define KERN_WARNING KERN_SOH "4" /* warning conditions */ | ||
| 12 | #define KERN_NOTICE KERN_SOH "5" /* normal but significant condition */ | ||
| 13 | #define KERN_INFO KERN_SOH "6" /* informational */ | ||
| 14 | #define KERN_DEBUG KERN_SOH "7" /* debug-level messages */ | ||
| 15 | |||
| 16 | #define KERN_DEFAULT KERN_SOH "d" /* the default kernel loglevel */ | ||
| 17 | |||
| 18 | /* | ||
| 19 | * Annotation for a "continued" line of log printout (only done after a | ||
| 20 | * line that had no enclosing \n). Only to be used by core/arch code | ||
| 21 | * during early bootup (a continued line is not SMP-safe otherwise). | ||
| 22 | */ | ||
| 23 | #define KERN_CONT "" | ||
| 24 | |||
| 25 | #endif | ||
diff --git a/include/linux/nilfs2_fs.h b/include/linux/nilfs2_fs.h index 89bd4a4dcfb4..98755767c7b0 100644 --- a/include/linux/nilfs2_fs.h +++ b/include/linux/nilfs2_fs.h | |||
| @@ -293,7 +293,7 @@ struct nilfs_dir_entry { | |||
| 293 | __le64 inode; /* Inode number */ | 293 | __le64 inode; /* Inode number */ |
| 294 | __le16 rec_len; /* Directory entry length */ | 294 | __le16 rec_len; /* Directory entry length */ |
| 295 | __u8 name_len; /* Name length */ | 295 | __u8 name_len; /* Name length */ |
| 296 | __u8 file_type; | 296 | __u8 file_type; /* Dir entry type (file, dir, etc) */ |
| 297 | char name[NILFS_NAME_LEN]; /* File name */ | 297 | char name[NILFS_NAME_LEN]; /* File name */ |
| 298 | char pad; | 298 | char pad; |
| 299 | }; | 299 | }; |
| @@ -395,7 +395,7 @@ union nilfs_binfo { | |||
| 395 | }; | 395 | }; |
| 396 | 396 | ||
| 397 | /** | 397 | /** |
| 398 | * struct nilfs_segment_summary - segment summary | 398 | * struct nilfs_segment_summary - segment summary header |
| 399 | * @ss_datasum: checksum of data | 399 | * @ss_datasum: checksum of data |
| 400 | * @ss_sumsum: checksum of segment summary | 400 | * @ss_sumsum: checksum of segment summary |
| 401 | * @ss_magic: magic number | 401 | * @ss_magic: magic number |
| @@ -683,9 +683,9 @@ struct nilfs_sufile_header { | |||
| 683 | 683 | ||
| 684 | /** | 684 | /** |
| 685 | * nilfs_suinfo - segment usage information | 685 | * nilfs_suinfo - segment usage information |
| 686 | * @sui_lastmod: | 686 | * @sui_lastmod: timestamp of last modification |
| 687 | * @sui_nblocks: | 687 | * @sui_nblocks: number of written blocks in segment |
| 688 | * @sui_flags: | 688 | * @sui_flags: segment usage flags |
| 689 | */ | 689 | */ |
| 690 | struct nilfs_suinfo { | 690 | struct nilfs_suinfo { |
| 691 | __u64 sui_lastmod; | 691 | __u64 sui_lastmod; |
| @@ -716,9 +716,10 @@ enum { | |||
| 716 | }; | 716 | }; |
| 717 | 717 | ||
| 718 | /** | 718 | /** |
| 719 | * struct nilfs_cpmode - | 719 | * struct nilfs_cpmode - change checkpoint mode structure |
| 720 | * @cc_cno: | 720 | * @cm_cno: checkpoint number |
| 721 | * @cc_mode: | 721 | * @cm_mode: mode of checkpoint |
| 722 | * @cm_pad: padding | ||
| 722 | */ | 723 | */ |
| 723 | struct nilfs_cpmode { | 724 | struct nilfs_cpmode { |
| 724 | __u64 cm_cno; | 725 | __u64 cm_cno; |
| @@ -728,11 +729,11 @@ struct nilfs_cpmode { | |||
| 728 | 729 | ||
| 729 | /** | 730 | /** |
| 730 | * struct nilfs_argv - argument vector | 731 | * struct nilfs_argv - argument vector |
| 731 | * @v_base: | 732 | * @v_base: pointer on data array from userspace |
| 732 | * @v_nmembs: | 733 | * @v_nmembs: number of members in data array |
| 733 | * @v_size: | 734 | * @v_size: size of data array in bytes |
| 734 | * @v_flags: | 735 | * @v_flags: flags |
| 735 | * @v_index: | 736 | * @v_index: start number of target data items |
| 736 | */ | 737 | */ |
| 737 | struct nilfs_argv { | 738 | struct nilfs_argv { |
| 738 | __u64 v_base; | 739 | __u64 v_base; |
| @@ -743,9 +744,9 @@ struct nilfs_argv { | |||
| 743 | }; | 744 | }; |
| 744 | 745 | ||
| 745 | /** | 746 | /** |
| 746 | * struct nilfs_period - | 747 | * struct nilfs_period - period of checkpoint numbers |
| 747 | * @p_start: | 748 | * @p_start: start checkpoint number (inclusive) |
| 748 | * @p_end: | 749 | * @p_end: end checkpoint number (exclusive) |
| 749 | */ | 750 | */ |
| 750 | struct nilfs_period { | 751 | struct nilfs_period { |
| 751 | __u64 p_start; | 752 | __u64 p_start; |
| @@ -753,7 +754,7 @@ struct nilfs_period { | |||
| 753 | }; | 754 | }; |
| 754 | 755 | ||
| 755 | /** | 756 | /** |
| 756 | * struct nilfs_cpstat - | 757 | * struct nilfs_cpstat - checkpoint statistics |
| 757 | * @cs_cno: checkpoint number | 758 | * @cs_cno: checkpoint number |
| 758 | * @cs_ncps: number of checkpoints | 759 | * @cs_ncps: number of checkpoints |
| 759 | * @cs_nsss: number of snapshots | 760 | * @cs_nsss: number of snapshots |
| @@ -765,7 +766,7 @@ struct nilfs_cpstat { | |||
| 765 | }; | 766 | }; |
| 766 | 767 | ||
| 767 | /** | 768 | /** |
| 768 | * struct nilfs_sustat - | 769 | * struct nilfs_sustat - segment usage statistics |
| 769 | * @ss_nsegs: number of segments | 770 | * @ss_nsegs: number of segments |
| 770 | * @ss_ncleansegs: number of clean segments | 771 | * @ss_ncleansegs: number of clean segments |
| 771 | * @ss_ndirtysegs: number of dirty segments | 772 | * @ss_ndirtysegs: number of dirty segments |
| @@ -784,10 +785,10 @@ struct nilfs_sustat { | |||
| 784 | 785 | ||
| 785 | /** | 786 | /** |
| 786 | * struct nilfs_vinfo - virtual block number information | 787 | * struct nilfs_vinfo - virtual block number information |
| 787 | * @vi_vblocknr: | 788 | * @vi_vblocknr: virtual block number |
| 788 | * @vi_start: | 789 | * @vi_start: start checkpoint number (inclusive) |
| 789 | * @vi_end: | 790 | * @vi_end: end checkpoint number (exclusive) |
| 790 | * @vi_blocknr: | 791 | * @vi_blocknr: disk block number |
| 791 | */ | 792 | */ |
| 792 | struct nilfs_vinfo { | 793 | struct nilfs_vinfo { |
| 793 | __u64 vi_vblocknr; | 794 | __u64 vi_vblocknr; |
| @@ -797,7 +798,15 @@ struct nilfs_vinfo { | |||
| 797 | }; | 798 | }; |
| 798 | 799 | ||
| 799 | /** | 800 | /** |
| 800 | * struct nilfs_vdesc - | 801 | * struct nilfs_vdesc - descriptor of virtual block number |
| 802 | * @vd_ino: inode number | ||
| 803 | * @vd_cno: checkpoint number | ||
| 804 | * @vd_vblocknr: virtual block number | ||
| 805 | * @vd_period: period of checkpoint numbers | ||
| 806 | * @vd_blocknr: disk block number | ||
| 807 | * @vd_offset: logical block offset inside a file | ||
| 808 | * @vd_flags: flags (data or node block) | ||
| 809 | * @vd_pad: padding | ||
| 801 | */ | 810 | */ |
| 802 | struct nilfs_vdesc { | 811 | struct nilfs_vdesc { |
| 803 | __u64 vd_ino; | 812 | __u64 vd_ino; |
| @@ -811,7 +820,13 @@ struct nilfs_vdesc { | |||
| 811 | }; | 820 | }; |
| 812 | 821 | ||
| 813 | /** | 822 | /** |
| 814 | * struct nilfs_bdesc - | 823 | * struct nilfs_bdesc - descriptor of disk block number |
| 824 | * @bd_ino: inode number | ||
| 825 | * @bd_oblocknr: disk block address (for skipping dead blocks) | ||
| 826 | * @bd_blocknr: disk block address | ||
| 827 | * @bd_offset: logical block offset inside a file | ||
| 828 | * @bd_level: level in the b-tree organization | ||
| 829 | * @bd_pad: padding | ||
| 815 | */ | 830 | */ |
| 816 | struct nilfs_bdesc { | 831 | struct nilfs_bdesc { |
| 817 | __u64 bd_ino; | 832 | __u64 bd_ino; |
diff --git a/include/linux/lp855x.h b/include/linux/platform_data/lp855x.h index 781a490a451b..cc76f1f18f18 100644 --- a/include/linux/lp855x.h +++ b/include/linux/platform_data/lp855x.h | |||
| @@ -47,12 +47,6 @@ | |||
| 47 | (LP8556_I2C_ONLY << BRT_MODE_SHFT)) | 47 | (LP8556_I2C_ONLY << BRT_MODE_SHFT)) |
| 48 | #define LP8556_COMB2_CONFIG (LP8556_COMBINED2 << BRT_MODE_SHFT) | 48 | #define LP8556_COMB2_CONFIG (LP8556_COMBINED2 << BRT_MODE_SHFT) |
| 49 | 49 | ||
| 50 | /* ROM area boundary */ | ||
| 51 | #define EEPROM_START (0xA0) | ||
| 52 | #define EEPROM_END (0xA7) | ||
| 53 | #define EPROM_START (0xA0) | ||
| 54 | #define EPROM_END (0xAF) | ||
| 55 | |||
| 56 | enum lp855x_chip_id { | 50 | enum lp855x_chip_id { |
| 57 | LP8550, | 51 | LP8550, |
| 58 | LP8551, | 52 | LP8551, |
diff --git a/include/linux/platform_data/mv_usb.h b/include/linux/platform_data/mv_usb.h index d94804aca764..944b01dd103e 100644 --- a/include/linux/platform_data/mv_usb.h +++ b/include/linux/platform_data/mv_usb.h | |||
| @@ -52,13 +52,4 @@ struct mv_usb_platform_data { | |||
| 52 | int (*set_vbus)(unsigned int vbus); | 52 | int (*set_vbus)(unsigned int vbus); |
| 53 | int (*private_init)(void __iomem *opregs, void __iomem *phyregs); | 53 | int (*private_init)(void __iomem *opregs, void __iomem *phyregs); |
| 54 | }; | 54 | }; |
| 55 | |||
| 56 | #ifndef CONFIG_HAVE_CLK | ||
| 57 | /* Dummy stub for clk framework */ | ||
| 58 | #define clk_get(dev, id) NULL | ||
| 59 | #define clk_put(clock) do {} while (0) | ||
| 60 | #define clk_enable(clock) do {} while (0) | ||
| 61 | #define clk_disable(clock) do {} while (0) | ||
| 62 | #endif | ||
| 63 | |||
| 64 | #endif | 55 | #endif |
diff --git a/include/linux/printk.h b/include/linux/printk.h index 1bec2f7a2d42..9afc01e5a0a6 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h | |||
| @@ -2,27 +2,34 @@ | |||
| 2 | #define __KERNEL_PRINTK__ | 2 | #define __KERNEL_PRINTK__ |
| 3 | 3 | ||
| 4 | #include <linux/init.h> | 4 | #include <linux/init.h> |
| 5 | #include <linux/kern_levels.h> | ||
| 5 | 6 | ||
| 6 | extern const char linux_banner[]; | 7 | extern const char linux_banner[]; |
| 7 | extern const char linux_proc_banner[]; | 8 | extern const char linux_proc_banner[]; |
| 8 | 9 | ||
| 9 | #define KERN_EMERG "<0>" /* system is unusable */ | 10 | static inline int printk_get_level(const char *buffer) |
| 10 | #define KERN_ALERT "<1>" /* action must be taken immediately */ | 11 | { |
| 11 | #define KERN_CRIT "<2>" /* critical conditions */ | 12 | if (buffer[0] == KERN_SOH_ASCII && buffer[1]) { |
| 12 | #define KERN_ERR "<3>" /* error conditions */ | 13 | switch (buffer[1]) { |
| 13 | #define KERN_WARNING "<4>" /* warning conditions */ | 14 | case '0' ... '7': |
| 14 | #define KERN_NOTICE "<5>" /* normal but significant condition */ | 15 | case 'd': /* KERN_DEFAULT */ |
| 15 | #define KERN_INFO "<6>" /* informational */ | 16 | return buffer[1]; |
| 16 | #define KERN_DEBUG "<7>" /* debug-level messages */ | 17 | } |
| 17 | 18 | } | |
| 18 | /* Use the default kernel loglevel */ | 19 | return 0; |
| 19 | #define KERN_DEFAULT "<d>" | 20 | } |
| 20 | /* | 21 | |
| 21 | * Annotation for a "continued" line of log printout (only done after a | 22 | static inline const char *printk_skip_level(const char *buffer) |
| 22 | * line that had no enclosing \n). Only to be used by core/arch code | 23 | { |
| 23 | * during early bootup (a continued line is not SMP-safe otherwise). | 24 | if (printk_get_level(buffer)) { |
| 24 | */ | 25 | switch (buffer[1]) { |
| 25 | #define KERN_CONT "<c>" | 26 | case '0' ... '7': |
| 27 | case 'd': /* KERN_DEFAULT */ | ||
| 28 | return buffer + 2; | ||
| 29 | } | ||
| 30 | } | ||
| 31 | return buffer; | ||
| 32 | } | ||
| 26 | 33 | ||
| 27 | extern int console_printk[]; | 34 | extern int console_printk[]; |
| 28 | 35 | ||
diff --git a/include/linux/sched.h b/include/linux/sched.h index a721cef7e2d4..68dcffaa62a0 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -334,6 +334,14 @@ static inline void lockup_detector_init(void) | |||
| 334 | } | 334 | } |
| 335 | #endif | 335 | #endif |
| 336 | 336 | ||
| 337 | #if defined(CONFIG_LOCKUP_DETECTOR) && defined(CONFIG_SUSPEND) | ||
| 338 | void lockup_detector_bootcpu_resume(void); | ||
| 339 | #else | ||
| 340 | static inline void lockup_detector_bootcpu_resume(void) | ||
| 341 | { | ||
| 342 | } | ||
| 343 | #endif | ||
| 344 | |||
| 337 | #ifdef CONFIG_DETECT_HUNG_TASK | 345 | #ifdef CONFIG_DETECT_HUNG_TASK |
| 338 | extern unsigned int sysctl_hung_task_panic; | 346 | extern unsigned int sysctl_hung_task_panic; |
| 339 | extern unsigned long sysctl_hung_task_check_count; | 347 | extern unsigned long sysctl_hung_task_check_count; |
| @@ -406,6 +414,11 @@ static inline void arch_pick_mmap_layout(struct mm_struct *mm) {} | |||
| 406 | extern void set_dumpable(struct mm_struct *mm, int value); | 414 | extern void set_dumpable(struct mm_struct *mm, int value); |
| 407 | extern int get_dumpable(struct mm_struct *mm); | 415 | extern int get_dumpable(struct mm_struct *mm); |
| 408 | 416 | ||
| 417 | /* get/set_dumpable() values */ | ||
| 418 | #define SUID_DUMPABLE_DISABLED 0 | ||
| 419 | #define SUID_DUMPABLE_ENABLED 1 | ||
| 420 | #define SUID_DUMPABLE_SAFE 2 | ||
| 421 | |||
| 409 | /* mm flags */ | 422 | /* mm flags */ |
| 410 | /* dumpable bits */ | 423 | /* dumpable bits */ |
| 411 | #define MMF_DUMPABLE 0 /* core dump is permitted */ | 424 | #define MMF_DUMPABLE 0 /* core dump is permitted */ |
diff --git a/include/linux/shm.h b/include/linux/shm.h index 92808b86703b..edd086883ccb 100644 --- a/include/linux/shm.h +++ b/include/linux/shm.h | |||
| @@ -107,12 +107,14 @@ struct shmid_kernel /* private to the kernel */ | |||
| 107 | #define SHM_NORESERVE 010000 /* don't check for reservations */ | 107 | #define SHM_NORESERVE 010000 /* don't check for reservations */ |
| 108 | 108 | ||
| 109 | #ifdef CONFIG_SYSVIPC | 109 | #ifdef CONFIG_SYSVIPC |
| 110 | long do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr); | 110 | long do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr, |
| 111 | unsigned long shmlba); | ||
| 111 | extern int is_file_shm_hugepages(struct file *file); | 112 | extern int is_file_shm_hugepages(struct file *file); |
| 112 | extern void exit_shm(struct task_struct *task); | 113 | extern void exit_shm(struct task_struct *task); |
| 113 | #else | 114 | #else |
| 114 | static inline long do_shmat(int shmid, char __user *shmaddr, | 115 | static inline long do_shmat(int shmid, char __user *shmaddr, |
| 115 | int shmflg, unsigned long *addr) | 116 | int shmflg, unsigned long *addr, |
| 117 | unsigned long shmlba) | ||
| 116 | { | 118 | { |
| 117 | return -ENOSYS; | 119 | return -ENOSYS; |
| 118 | } | 120 | } |
diff --git a/include/linux/string.h b/include/linux/string.h index e033564f10ba..ffe0442e18d2 100644 --- a/include/linux/string.h +++ b/include/linux/string.h | |||
| @@ -145,4 +145,7 @@ static inline bool strstarts(const char *str, const char *prefix) | |||
| 145 | return strncmp(str, prefix, strlen(prefix)) == 0; | 145 | return strncmp(str, prefix, strlen(prefix)) == 0; |
| 146 | } | 146 | } |
| 147 | #endif | 147 | #endif |
| 148 | |||
| 149 | extern size_t memweight(const void *ptr, size_t bytes); | ||
| 150 | |||
| 148 | #endif /* _LINUX_STRING_H_ */ | 151 | #endif /* _LINUX_STRING_H_ */ |
diff --git a/ipc/compat.c b/ipc/compat.c index a6df704f521e..ad9518eb26e0 100644 --- a/ipc/compat.c +++ b/ipc/compat.c | |||
| @@ -118,7 +118,7 @@ extern int sem_ctls[]; | |||
| 118 | 118 | ||
| 119 | static inline int compat_ipc_parse_version(int *cmd) | 119 | static inline int compat_ipc_parse_version(int *cmd) |
| 120 | { | 120 | { |
| 121 | #ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC | 121 | #ifdef CONFIG_ARCH_WANT_COMPAT_IPC_PARSE_VERSION |
| 122 | int version = *cmd & IPC_64; | 122 | int version = *cmd & IPC_64; |
| 123 | 123 | ||
| 124 | /* this is tricky: architectures that have support for the old | 124 | /* this is tricky: architectures that have support for the old |
| @@ -373,21 +373,21 @@ long compat_sys_semctl(int semid, int semnum, int cmd, int arg) | |||
| 373 | } | 373 | } |
| 374 | 374 | ||
| 375 | long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp, | 375 | long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp, |
| 376 | size_t msgsz, int msgflg) | 376 | compat_ssize_t msgsz, int msgflg) |
| 377 | { | 377 | { |
| 378 | compat_long_t mtype; | 378 | compat_long_t mtype; |
| 379 | 379 | ||
| 380 | if (get_user(mtype, &msgp->mtype)) | 380 | if (get_user(mtype, &msgp->mtype)) |
| 381 | return -EFAULT; | 381 | return -EFAULT; |
| 382 | return do_msgsnd(msqid, mtype, msgp->mtext, msgsz, msgflg); | 382 | return do_msgsnd(msqid, mtype, msgp->mtext, (ssize_t)msgsz, msgflg); |
| 383 | } | 383 | } |
| 384 | 384 | ||
| 385 | long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp, | 385 | long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp, |
| 386 | size_t msgsz, long msgtyp, int msgflg) | 386 | compat_ssize_t msgsz, long msgtyp, int msgflg) |
| 387 | { | 387 | { |
| 388 | long err, mtype; | 388 | long err, mtype; |
| 389 | 389 | ||
| 390 | err = do_msgrcv(msqid, &mtype, msgp->mtext, msgsz, msgtyp, msgflg); | 390 | err = do_msgrcv(msqid, &mtype, msgp->mtext, (ssize_t)msgsz, msgtyp, msgflg); |
| 391 | if (err < 0) | 391 | if (err < 0) |
| 392 | goto out; | 392 | goto out; |
| 393 | 393 | ||
| @@ -514,6 +514,10 @@ long compat_sys_msgctl(int first, int second, void __user *uptr) | |||
| 514 | return err; | 514 | return err; |
| 515 | } | 515 | } |
| 516 | 516 | ||
| 517 | #ifndef COMPAT_SHMLBA | ||
| 518 | #define COMPAT_SHMLBA SHMLBA | ||
| 519 | #endif | ||
| 520 | |||
| 517 | #ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC | 521 | #ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC |
| 518 | long compat_sys_shmat(int first, int second, compat_uptr_t third, int version, | 522 | long compat_sys_shmat(int first, int second, compat_uptr_t third, int version, |
| 519 | void __user *uptr) | 523 | void __user *uptr) |
| @@ -524,7 +528,7 @@ long compat_sys_shmat(int first, int second, compat_uptr_t third, int version, | |||
| 524 | 528 | ||
| 525 | if (version == 1) | 529 | if (version == 1) |
| 526 | return -EINVAL; | 530 | return -EINVAL; |
| 527 | err = do_shmat(first, uptr, second, &raddr); | 531 | err = do_shmat(first, uptr, second, &raddr, COMPAT_SHMLBA); |
| 528 | if (err < 0) | 532 | if (err < 0) |
| 529 | return err; | 533 | return err; |
| 530 | uaddr = compat_ptr(third); | 534 | uaddr = compat_ptr(third); |
| @@ -536,7 +540,7 @@ long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) | |||
| 536 | unsigned long ret; | 540 | unsigned long ret; |
| 537 | long err; | 541 | long err; |
| 538 | 542 | ||
| 539 | err = do_shmat(shmid, compat_ptr(shmaddr), shmflg, &ret); | 543 | err = do_shmat(shmid, compat_ptr(shmaddr), shmflg, &ret, COMPAT_SHMLBA); |
| 540 | if (err) | 544 | if (err) |
| 541 | return err; | 545 | return err; |
| 542 | force_successful_syscall_return(); | 546 | force_successful_syscall_return(); |
| @@ -953,7 +953,8 @@ out: | |||
| 953 | * "raddr" thing points to kernel space, and there has to be a wrapper around | 953 | * "raddr" thing points to kernel space, and there has to be a wrapper around |
| 954 | * this. | 954 | * this. |
| 955 | */ | 955 | */ |
| 956 | long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr) | 956 | long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr, |
| 957 | unsigned long shmlba) | ||
| 957 | { | 958 | { |
| 958 | struct shmid_kernel *shp; | 959 | struct shmid_kernel *shp; |
| 959 | unsigned long addr; | 960 | unsigned long addr; |
| @@ -973,9 +974,9 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr) | |||
| 973 | if (shmid < 0) | 974 | if (shmid < 0) |
| 974 | goto out; | 975 | goto out; |
| 975 | else if ((addr = (ulong)shmaddr)) { | 976 | else if ((addr = (ulong)shmaddr)) { |
| 976 | if (addr & (SHMLBA-1)) { | 977 | if (addr & (shmlba - 1)) { |
| 977 | if (shmflg & SHM_RND) | 978 | if (shmflg & SHM_RND) |
| 978 | addr &= ~(SHMLBA-1); /* round down */ | 979 | addr &= ~(shmlba - 1); /* round down */ |
| 979 | else | 980 | else |
| 980 | #ifndef __ARCH_FORCE_SHMLBA | 981 | #ifndef __ARCH_FORCE_SHMLBA |
| 981 | if (addr & ~PAGE_MASK) | 982 | if (addr & ~PAGE_MASK) |
| @@ -1107,7 +1108,7 @@ SYSCALL_DEFINE3(shmat, int, shmid, char __user *, shmaddr, int, shmflg) | |||
| 1107 | unsigned long ret; | 1108 | unsigned long ret; |
| 1108 | long err; | 1109 | long err; |
| 1109 | 1110 | ||
| 1110 | err = do_shmat(shmid, shmaddr, shmflg, &ret); | 1111 | err = do_shmat(shmid, shmaddr, shmflg, &ret, SHMLBA); |
| 1111 | if (err) | 1112 | if (err) |
| 1112 | return err; | 1113 | return err; |
| 1113 | force_successful_syscall_return(); | 1114 | force_successful_syscall_return(); |
diff --git a/ipc/syscall.c b/ipc/syscall.c index 1d6f53f6b562..0d1e32ce048e 100644 --- a/ipc/syscall.c +++ b/ipc/syscall.c | |||
| @@ -73,7 +73,7 @@ SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second, | |||
| 73 | default: { | 73 | default: { |
| 74 | unsigned long raddr; | 74 | unsigned long raddr; |
| 75 | ret = do_shmat(first, (char __user *)ptr, | 75 | ret = do_shmat(first, (char __user *)ptr, |
| 76 | second, &raddr); | 76 | second, &raddr, SHMLBA); |
| 77 | if (ret) | 77 | if (ret) |
| 78 | return ret; | 78 | return ret; |
| 79 | return put_user(raddr, (unsigned long __user *) third); | 79 | return put_user(raddr, (unsigned long __user *) third); |
diff --git a/ipc/util.c b/ipc/util.c index 75261a31d48d..eb07fd356f27 100644 --- a/ipc/util.c +++ b/ipc/util.c | |||
| @@ -804,7 +804,7 @@ out_up: | |||
| 804 | return ERR_PTR(err); | 804 | return ERR_PTR(err); |
| 805 | } | 805 | } |
| 806 | 806 | ||
| 807 | #ifdef __ARCH_WANT_IPC_PARSE_VERSION | 807 | #ifdef CONFIG_ARCH_WANT_IPC_PARSE_VERSION |
| 808 | 808 | ||
| 809 | 809 | ||
| 810 | /** | 810 | /** |
| @@ -826,7 +826,7 @@ int ipc_parse_version (int *cmd) | |||
| 826 | } | 826 | } |
| 827 | } | 827 | } |
| 828 | 828 | ||
| 829 | #endif /* __ARCH_WANT_IPC_PARSE_VERSION */ | 829 | #endif /* CONFIG_ARCH_WANT_IPC_PARSE_VERSION */ |
| 830 | 830 | ||
| 831 | #ifdef CONFIG_PROC_FS | 831 | #ifdef CONFIG_PROC_FS |
| 832 | struct ipc_proc_iter { | 832 | struct ipc_proc_iter { |
diff --git a/ipc/util.h b/ipc/util.h index 6f5c20bedaab..850ef3e962cb 100644 --- a/ipc/util.h +++ b/ipc/util.h | |||
| @@ -130,7 +130,7 @@ struct kern_ipc_perm *ipcctl_pre_down(struct ipc_namespace *ns, | |||
| 130 | struct ipc_ids *ids, int id, int cmd, | 130 | struct ipc_ids *ids, int id, int cmd, |
| 131 | struct ipc64_perm *perm, int extra_perm); | 131 | struct ipc64_perm *perm, int extra_perm); |
| 132 | 132 | ||
| 133 | #ifndef __ARCH_WANT_IPC_PARSE_VERSION | 133 | #ifndef CONFIG_ARCH_WANT_IPC_PARSE_VERSION |
| 134 | /* On IA-64, we always use the "64-bit version" of the IPC structures. */ | 134 | /* On IA-64, we always use the "64-bit version" of the IPC structures. */ |
| 135 | # define ipc_parse_version(cmd) IPC_64 | 135 | # define ipc_parse_version(cmd) IPC_64 |
| 136 | #else | 136 | #else |
diff --git a/kernel/fork.c b/kernel/fork.c index ff1cad3b7bdc..8efac1fe56bc 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
| @@ -114,6 +114,10 @@ int nr_processes(void) | |||
| 114 | return total; | 114 | return total; |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | void __weak arch_release_task_struct(struct task_struct *tsk) | ||
| 118 | { | ||
| 119 | } | ||
| 120 | |||
| 117 | #ifndef CONFIG_ARCH_TASK_STRUCT_ALLOCATOR | 121 | #ifndef CONFIG_ARCH_TASK_STRUCT_ALLOCATOR |
| 118 | static struct kmem_cache *task_struct_cachep; | 122 | static struct kmem_cache *task_struct_cachep; |
| 119 | 123 | ||
| @@ -122,17 +126,17 @@ static inline struct task_struct *alloc_task_struct_node(int node) | |||
| 122 | return kmem_cache_alloc_node(task_struct_cachep, GFP_KERNEL, node); | 126 | return kmem_cache_alloc_node(task_struct_cachep, GFP_KERNEL, node); |
| 123 | } | 127 | } |
| 124 | 128 | ||
| 125 | void __weak arch_release_task_struct(struct task_struct *tsk) { } | ||
| 126 | |||
| 127 | static inline void free_task_struct(struct task_struct *tsk) | 129 | static inline void free_task_struct(struct task_struct *tsk) |
| 128 | { | 130 | { |
| 129 | arch_release_task_struct(tsk); | ||
| 130 | kmem_cache_free(task_struct_cachep, tsk); | 131 | kmem_cache_free(task_struct_cachep, tsk); |
| 131 | } | 132 | } |
| 132 | #endif | 133 | #endif |
| 133 | 134 | ||
| 135 | void __weak arch_release_thread_info(struct thread_info *ti) | ||
| 136 | { | ||
| 137 | } | ||
| 138 | |||
| 134 | #ifndef CONFIG_ARCH_THREAD_INFO_ALLOCATOR | 139 | #ifndef CONFIG_ARCH_THREAD_INFO_ALLOCATOR |
| 135 | void __weak arch_release_thread_info(struct thread_info *ti) { } | ||
| 136 | 140 | ||
| 137 | /* | 141 | /* |
| 138 | * Allocate pages if THREAD_SIZE is >= PAGE_SIZE, otherwise use a | 142 | * Allocate pages if THREAD_SIZE is >= PAGE_SIZE, otherwise use a |
| @@ -150,7 +154,6 @@ static struct thread_info *alloc_thread_info_node(struct task_struct *tsk, | |||
| 150 | 154 | ||
| 151 | static inline void free_thread_info(struct thread_info *ti) | 155 | static inline void free_thread_info(struct thread_info *ti) |
| 152 | { | 156 | { |
| 153 | arch_release_thread_info(ti); | ||
| 154 | free_pages((unsigned long)ti, THREAD_SIZE_ORDER); | 157 | free_pages((unsigned long)ti, THREAD_SIZE_ORDER); |
| 155 | } | 158 | } |
| 156 | # else | 159 | # else |
| @@ -164,7 +167,6 @@ static struct thread_info *alloc_thread_info_node(struct task_struct *tsk, | |||
| 164 | 167 | ||
| 165 | static void free_thread_info(struct thread_info *ti) | 168 | static void free_thread_info(struct thread_info *ti) |
| 166 | { | 169 | { |
| 167 | arch_release_thread_info(ti); | ||
| 168 | kmem_cache_free(thread_info_cache, ti); | 170 | kmem_cache_free(thread_info_cache, ti); |
| 169 | } | 171 | } |
| 170 | 172 | ||
| @@ -205,10 +207,12 @@ static void account_kernel_stack(struct thread_info *ti, int account) | |||
| 205 | void free_task(struct task_struct *tsk) | 207 | void free_task(struct task_struct *tsk) |
| 206 | { | 208 | { |
| 207 | account_kernel_stack(tsk->stack, -1); | 209 | account_kernel_stack(tsk->stack, -1); |
| 210 | arch_release_thread_info(tsk->stack); | ||
| 208 | free_thread_info(tsk->stack); | 211 | free_thread_info(tsk->stack); |
| 209 | rt_mutex_debug_task_free(tsk); | 212 | rt_mutex_debug_task_free(tsk); |
| 210 | ftrace_graph_exit_task(tsk); | 213 | ftrace_graph_exit_task(tsk); |
| 211 | put_seccomp_filter(tsk); | 214 | put_seccomp_filter(tsk); |
| 215 | arch_release_task_struct(tsk); | ||
| 212 | free_task_struct(tsk); | 216 | free_task_struct(tsk); |
| 213 | } | 217 | } |
| 214 | EXPORT_SYMBOL(free_task); | 218 | EXPORT_SYMBOL(free_task); |
| @@ -298,23 +302,16 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) | |||
| 298 | return NULL; | 302 | return NULL; |
| 299 | 303 | ||
| 300 | ti = alloc_thread_info_node(tsk, node); | 304 | ti = alloc_thread_info_node(tsk, node); |
| 301 | if (!ti) { | 305 | if (!ti) |
| 302 | free_task_struct(tsk); | 306 | goto free_tsk; |
| 303 | return NULL; | ||
| 304 | } | ||
| 305 | 307 | ||
| 306 | err = arch_dup_task_struct(tsk, orig); | 308 | err = arch_dup_task_struct(tsk, orig); |
| 309 | if (err) | ||
| 310 | goto free_ti; | ||
| 307 | 311 | ||
| 308 | /* | ||
| 309 | * We defer looking at err, because we will need this setup | ||
| 310 | * for the clean up path to work correctly. | ||
| 311 | */ | ||
| 312 | tsk->stack = ti; | 312 | tsk->stack = ti; |
| 313 | setup_thread_stack(tsk, orig); | ||
| 314 | |||
| 315 | if (err) | ||
| 316 | goto out; | ||
| 317 | 313 | ||
| 314 | setup_thread_stack(tsk, orig); | ||
| 318 | clear_user_return_notifier(tsk); | 315 | clear_user_return_notifier(tsk); |
| 319 | clear_tsk_need_resched(tsk); | 316 | clear_tsk_need_resched(tsk); |
| 320 | stackend = end_of_stack(tsk); | 317 | stackend = end_of_stack(tsk); |
| @@ -338,8 +335,9 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) | |||
| 338 | 335 | ||
| 339 | return tsk; | 336 | return tsk; |
| 340 | 337 | ||
| 341 | out: | 338 | free_ti: |
| 342 | free_thread_info(ti); | 339 | free_thread_info(ti); |
| 340 | free_tsk: | ||
| 343 | free_task_struct(tsk); | 341 | free_task_struct(tsk); |
| 344 | return NULL; | 342 | return NULL; |
| 345 | } | 343 | } |
| @@ -391,8 +389,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm) | |||
| 391 | } | 389 | } |
| 392 | charge = 0; | 390 | charge = 0; |
| 393 | if (mpnt->vm_flags & VM_ACCOUNT) { | 391 | if (mpnt->vm_flags & VM_ACCOUNT) { |
| 394 | unsigned long len; | 392 | unsigned long len = vma_pages(mpnt); |
| 395 | len = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT; | 393 | |
| 396 | if (security_vm_enough_memory_mm(oldmm, len)) /* sic */ | 394 | if (security_vm_enough_memory_mm(oldmm, len)) /* sic */ |
| 397 | goto fail_nomem; | 395 | goto fail_nomem; |
| 398 | charge = len; | 396 | charge = len; |
diff --git a/kernel/kexec.c b/kernel/kexec.c index 4e2e472f6aeb..0668d58d6413 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c | |||
| @@ -1424,7 +1424,7 @@ static void update_vmcoreinfo_note(void) | |||
| 1424 | 1424 | ||
| 1425 | void crash_save_vmcoreinfo(void) | 1425 | void crash_save_vmcoreinfo(void) |
| 1426 | { | 1426 | { |
| 1427 | vmcoreinfo_append_str("CRASHTIME=%ld", get_seconds()); | 1427 | vmcoreinfo_append_str("CRASHTIME=%ld\n", get_seconds()); |
| 1428 | update_vmcoreinfo_note(); | 1428 | update_vmcoreinfo_note(); |
| 1429 | } | 1429 | } |
| 1430 | 1430 | ||
diff --git a/kernel/kmod.c b/kernel/kmod.c index ff2c7cb86d77..6f99aead66c6 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c | |||
| @@ -45,6 +45,13 @@ extern int max_threads; | |||
| 45 | 45 | ||
| 46 | static struct workqueue_struct *khelper_wq; | 46 | static struct workqueue_struct *khelper_wq; |
| 47 | 47 | ||
| 48 | /* | ||
| 49 | * kmod_thread_locker is used for deadlock avoidance. There is no explicit | ||
| 50 | * locking to protect this global - it is private to the singleton khelper | ||
| 51 | * thread and should only ever be modified by that thread. | ||
| 52 | */ | ||
| 53 | static const struct task_struct *kmod_thread_locker; | ||
| 54 | |||
| 48 | #define CAP_BSET (void *)1 | 55 | #define CAP_BSET (void *)1 |
| 49 | #define CAP_PI (void *)2 | 56 | #define CAP_PI (void *)2 |
| 50 | 57 | ||
| @@ -221,6 +228,13 @@ fail: | |||
| 221 | return 0; | 228 | return 0; |
| 222 | } | 229 | } |
| 223 | 230 | ||
| 231 | static int call_helper(void *data) | ||
| 232 | { | ||
| 233 | /* Worker thread started blocking khelper thread. */ | ||
| 234 | kmod_thread_locker = current; | ||
| 235 | return ____call_usermodehelper(data); | ||
| 236 | } | ||
| 237 | |||
| 224 | static void call_usermodehelper_freeinfo(struct subprocess_info *info) | 238 | static void call_usermodehelper_freeinfo(struct subprocess_info *info) |
| 225 | { | 239 | { |
| 226 | if (info->cleanup) | 240 | if (info->cleanup) |
| @@ -295,9 +309,12 @@ static void __call_usermodehelper(struct work_struct *work) | |||
| 295 | if (wait == UMH_WAIT_PROC) | 309 | if (wait == UMH_WAIT_PROC) |
| 296 | pid = kernel_thread(wait_for_helper, sub_info, | 310 | pid = kernel_thread(wait_for_helper, sub_info, |
| 297 | CLONE_FS | CLONE_FILES | SIGCHLD); | 311 | CLONE_FS | CLONE_FILES | SIGCHLD); |
| 298 | else | 312 | else { |
| 299 | pid = kernel_thread(____call_usermodehelper, sub_info, | 313 | pid = kernel_thread(call_helper, sub_info, |
| 300 | CLONE_VFORK | SIGCHLD); | 314 | CLONE_VFORK | SIGCHLD); |
| 315 | /* Worker thread stopped blocking khelper thread. */ | ||
| 316 | kmod_thread_locker = NULL; | ||
| 317 | } | ||
| 301 | 318 | ||
| 302 | switch (wait) { | 319 | switch (wait) { |
| 303 | case UMH_NO_WAIT: | 320 | case UMH_NO_WAIT: |
| @@ -548,6 +565,16 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait) | |||
| 548 | retval = -EBUSY; | 565 | retval = -EBUSY; |
| 549 | goto out; | 566 | goto out; |
| 550 | } | 567 | } |
| 568 | /* | ||
| 569 | * Worker thread must not wait for khelper thread at below | ||
| 570 | * wait_for_completion() if the thread was created with CLONE_VFORK | ||
| 571 | * flag, for khelper thread is already waiting for the thread at | ||
| 572 | * wait_for_completion() in do_fork(). | ||
| 573 | */ | ||
| 574 | if (wait != UMH_NO_WAIT && current == kmod_thread_locker) { | ||
| 575 | retval = -EBUSY; | ||
| 576 | goto out; | ||
| 577 | } | ||
| 551 | 578 | ||
| 552 | sub_info->complete = &done; | 579 | sub_info->complete = &done; |
| 553 | sub_info->wait = wait; | 580 | sub_info->wait = wait; |
| @@ -577,6 +604,12 @@ unlock: | |||
| 577 | return retval; | 604 | return retval; |
| 578 | } | 605 | } |
| 579 | 606 | ||
| 607 | /* | ||
| 608 | * call_usermodehelper_fns() will not run the caller-provided cleanup function | ||
| 609 | * if a memory allocation failure is experienced. So the caller might need to | ||
| 610 | * check the call_usermodehelper_fns() return value: if it is -ENOMEM, perform | ||
| 611 | * the necessaary cleanup within the caller. | ||
| 612 | */ | ||
| 580 | int call_usermodehelper_fns( | 613 | int call_usermodehelper_fns( |
| 581 | char *path, char **argv, char **envp, int wait, | 614 | char *path, char **argv, char **envp, int wait, |
| 582 | int (*init)(struct subprocess_info *info, struct cred *new), | 615 | int (*init)(struct subprocess_info *info, struct cred *new), |
diff --git a/kernel/panic.c b/kernel/panic.c index d2a5f4ecc6dd..e1b2822fff97 100644 --- a/kernel/panic.c +++ b/kernel/panic.c | |||
| @@ -75,6 +75,14 @@ void panic(const char *fmt, ...) | |||
| 75 | int state = 0; | 75 | int state = 0; |
| 76 | 76 | ||
| 77 | /* | 77 | /* |
| 78 | * Disable local interrupts. This will prevent panic_smp_self_stop | ||
| 79 | * from deadlocking the first cpu that invokes the panic, since | ||
| 80 | * there is nothing to prevent an interrupt handler (that runs | ||
| 81 | * after the panic_lock is acquired) from invoking panic again. | ||
| 82 | */ | ||
| 83 | local_irq_disable(); | ||
| 84 | |||
| 85 | /* | ||
| 78 | * It's possible to come here directly from a panic-assertion and | 86 | * It's possible to come here directly from a panic-assertion and |
| 79 | * not have preempt disabled. Some functions called from here want | 87 | * not have preempt disabled. Some functions called from here want |
| 80 | * preempt to be disabled. No point enabling it later though... | 88 | * preempt to be disabled. No point enabling it later though... |
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index c8b7446b27df..1da39ea248fd 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c | |||
| @@ -178,6 +178,9 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) | |||
| 178 | arch_suspend_enable_irqs(); | 178 | arch_suspend_enable_irqs(); |
| 179 | BUG_ON(irqs_disabled()); | 179 | BUG_ON(irqs_disabled()); |
| 180 | 180 | ||
| 181 | /* Kick the lockup detector */ | ||
| 182 | lockup_detector_bootcpu_resume(); | ||
| 183 | |||
| 181 | Enable_cpus: | 184 | Enable_cpus: |
| 182 | enable_nonboot_cpus(); | 185 | enable_nonboot_cpus(); |
| 183 | 186 | ||
diff --git a/kernel/printk.c b/kernel/printk.c index 50c96b5651b6..6a76ab9d4476 100644 --- a/kernel/printk.c +++ b/kernel/printk.c | |||
| @@ -389,8 +389,10 @@ static ssize_t devkmsg_writev(struct kiocb *iocb, const struct iovec *iv, | |||
| 389 | 389 | ||
| 390 | line = buf; | 390 | line = buf; |
| 391 | for (i = 0; i < count; i++) { | 391 | for (i = 0; i < count; i++) { |
| 392 | if (copy_from_user(line, iv[i].iov_base, iv[i].iov_len)) | 392 | if (copy_from_user(line, iv[i].iov_base, iv[i].iov_len)) { |
| 393 | ret = -EFAULT; | ||
| 393 | goto out; | 394 | goto out; |
| 395 | } | ||
| 394 | line += iv[i].iov_len; | 396 | line += iv[i].iov_len; |
| 395 | } | 397 | } |
| 396 | 398 | ||
| @@ -1540,17 +1542,23 @@ asmlinkage int vprintk_emit(int facility, int level, | |||
| 1540 | lflags |= LOG_NEWLINE; | 1542 | lflags |= LOG_NEWLINE; |
| 1541 | } | 1543 | } |
| 1542 | 1544 | ||
| 1543 | /* strip syslog prefix and extract log level or control flags */ | 1545 | /* strip kernel syslog prefix and extract log level or control flags */ |
| 1544 | if (text[0] == '<' && text[1] && text[2] == '>') { | 1546 | if (facility == 0) { |
| 1545 | switch (text[1]) { | 1547 | int kern_level = printk_get_level(text); |
| 1546 | case '0' ... '7': | 1548 | |
| 1547 | if (level == -1) | 1549 | if (kern_level) { |
| 1548 | level = text[1] - '0'; | 1550 | const char *end_of_header = printk_skip_level(text); |
| 1549 | case 'd': /* KERN_DEFAULT */ | 1551 | switch (kern_level) { |
| 1550 | lflags |= LOG_PREFIX; | 1552 | case '0' ... '7': |
| 1551 | case 'c': /* KERN_CONT */ | 1553 | if (level == -1) |
| 1552 | text += 3; | 1554 | level = kern_level - '0'; |
| 1553 | text_len -= 3; | 1555 | case 'd': /* KERN_DEFAULT */ |
| 1556 | lflags |= LOG_PREFIX; | ||
| 1557 | case 'c': /* KERN_CONT */ | ||
| 1558 | break; | ||
| 1559 | } | ||
| 1560 | text_len -= end_of_header - text; | ||
| 1561 | text = (char *)end_of_header; | ||
| 1554 | } | 1562 | } |
| 1555 | } | 1563 | } |
| 1556 | 1564 | ||
diff --git a/kernel/resource.c b/kernel/resource.c index dc8b47764443..34d45886ee84 100644 --- a/kernel/resource.c +++ b/kernel/resource.c | |||
| @@ -7,6 +7,8 @@ | |||
| 7 | * Arbitrary resource management. | 7 | * Arbitrary resource management. |
| 8 | */ | 8 | */ |
| 9 | 9 | ||
| 10 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 11 | |||
| 10 | #include <linux/export.h> | 12 | #include <linux/export.h> |
| 11 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
| 12 | #include <linux/ioport.h> | 14 | #include <linux/ioport.h> |
| @@ -791,8 +793,28 @@ void __init reserve_region_with_split(struct resource *root, | |||
| 791 | resource_size_t start, resource_size_t end, | 793 | resource_size_t start, resource_size_t end, |
| 792 | const char *name) | 794 | const char *name) |
| 793 | { | 795 | { |
| 796 | int abort = 0; | ||
| 797 | |||
| 794 | write_lock(&resource_lock); | 798 | write_lock(&resource_lock); |
| 795 | __reserve_region_with_split(root, start, end, name); | 799 | if (root->start > start || root->end < end) { |
| 800 | pr_err("requested range [0x%llx-0x%llx] not in root %pr\n", | ||
| 801 | (unsigned long long)start, (unsigned long long)end, | ||
| 802 | root); | ||
| 803 | if (start > root->end || end < root->start) | ||
| 804 | abort = 1; | ||
| 805 | else { | ||
| 806 | if (end > root->end) | ||
| 807 | end = root->end; | ||
| 808 | if (start < root->start) | ||
| 809 | start = root->start; | ||
| 810 | pr_err("fixing request to [0x%llx-0x%llx]\n", | ||
| 811 | (unsigned long long)start, | ||
| 812 | (unsigned long long)end); | ||
| 813 | } | ||
| 814 | dump_stack(); | ||
| 815 | } | ||
| 816 | if (!abort) | ||
| 817 | __reserve_region_with_split(root, start, end, name); | ||
| 796 | write_unlock(&resource_lock); | 818 | write_unlock(&resource_lock); |
| 797 | } | 819 | } |
| 798 | 820 | ||
diff --git a/kernel/sys.c b/kernel/sys.c index 2d39a84cd857..241507f23eca 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
| @@ -2015,7 +2015,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, | |||
| 2015 | break; | 2015 | break; |
| 2016 | } | 2016 | } |
| 2017 | me->pdeath_signal = arg2; | 2017 | me->pdeath_signal = arg2; |
| 2018 | error = 0; | ||
| 2019 | break; | 2018 | break; |
| 2020 | case PR_GET_PDEATHSIG: | 2019 | case PR_GET_PDEATHSIG: |
| 2021 | error = put_user(me->pdeath_signal, (int __user *)arg2); | 2020 | error = put_user(me->pdeath_signal, (int __user *)arg2); |
| @@ -2029,7 +2028,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, | |||
| 2029 | break; | 2028 | break; |
| 2030 | } | 2029 | } |
| 2031 | set_dumpable(me->mm, arg2); | 2030 | set_dumpable(me->mm, arg2); |
| 2032 | error = 0; | ||
| 2033 | break; | 2031 | break; |
| 2034 | 2032 | ||
| 2035 | case PR_SET_UNALIGN: | 2033 | case PR_SET_UNALIGN: |
| @@ -2056,10 +2054,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, | |||
| 2056 | case PR_SET_TIMING: | 2054 | case PR_SET_TIMING: |
| 2057 | if (arg2 != PR_TIMING_STATISTICAL) | 2055 | if (arg2 != PR_TIMING_STATISTICAL) |
| 2058 | error = -EINVAL; | 2056 | error = -EINVAL; |
| 2059 | else | ||
| 2060 | error = 0; | ||
| 2061 | break; | 2057 | break; |
| 2062 | |||
| 2063 | case PR_SET_NAME: | 2058 | case PR_SET_NAME: |
| 2064 | comm[sizeof(me->comm)-1] = 0; | 2059 | comm[sizeof(me->comm)-1] = 0; |
| 2065 | if (strncpy_from_user(comm, (char __user *)arg2, | 2060 | if (strncpy_from_user(comm, (char __user *)arg2, |
| @@ -2067,20 +2062,19 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, | |||
| 2067 | return -EFAULT; | 2062 | return -EFAULT; |
| 2068 | set_task_comm(me, comm); | 2063 | set_task_comm(me, comm); |
| 2069 | proc_comm_connector(me); | 2064 | proc_comm_connector(me); |
| 2070 | return 0; | 2065 | break; |
| 2071 | case PR_GET_NAME: | 2066 | case PR_GET_NAME: |
| 2072 | get_task_comm(comm, me); | 2067 | get_task_comm(comm, me); |
| 2073 | if (copy_to_user((char __user *)arg2, comm, | 2068 | if (copy_to_user((char __user *)arg2, comm, |
| 2074 | sizeof(comm))) | 2069 | sizeof(comm))) |
| 2075 | return -EFAULT; | 2070 | return -EFAULT; |
| 2076 | return 0; | 2071 | break; |
| 2077 | case PR_GET_ENDIAN: | 2072 | case PR_GET_ENDIAN: |
| 2078 | error = GET_ENDIAN(me, arg2); | 2073 | error = GET_ENDIAN(me, arg2); |
| 2079 | break; | 2074 | break; |
| 2080 | case PR_SET_ENDIAN: | 2075 | case PR_SET_ENDIAN: |
| 2081 | error = SET_ENDIAN(me, arg2); | 2076 | error = SET_ENDIAN(me, arg2); |
| 2082 | break; | 2077 | break; |
| 2083 | |||
| 2084 | case PR_GET_SECCOMP: | 2078 | case PR_GET_SECCOMP: |
| 2085 | error = prctl_get_seccomp(); | 2079 | error = prctl_get_seccomp(); |
| 2086 | break; | 2080 | break; |
| @@ -2108,7 +2102,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, | |||
| 2108 | current->default_timer_slack_ns; | 2102 | current->default_timer_slack_ns; |
| 2109 | else | 2103 | else |
| 2110 | current->timer_slack_ns = arg2; | 2104 | current->timer_slack_ns = arg2; |
| 2111 | error = 0; | ||
| 2112 | break; | 2105 | break; |
| 2113 | case PR_MCE_KILL: | 2106 | case PR_MCE_KILL: |
| 2114 | if (arg4 | arg5) | 2107 | if (arg4 | arg5) |
| @@ -2134,7 +2127,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, | |||
| 2134 | default: | 2127 | default: |
| 2135 | return -EINVAL; | 2128 | return -EINVAL; |
| 2136 | } | 2129 | } |
| 2137 | error = 0; | ||
| 2138 | break; | 2130 | break; |
| 2139 | case PR_MCE_KILL_GET: | 2131 | case PR_MCE_KILL_GET: |
| 2140 | if (arg2 | arg3 | arg4 | arg5) | 2132 | if (arg2 | arg3 | arg4 | arg5) |
| @@ -2153,7 +2145,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, | |||
| 2153 | break; | 2145 | break; |
| 2154 | case PR_SET_CHILD_SUBREAPER: | 2146 | case PR_SET_CHILD_SUBREAPER: |
| 2155 | me->signal->is_child_subreaper = !!arg2; | 2147 | me->signal->is_child_subreaper = !!arg2; |
| 2156 | error = 0; | ||
| 2157 | break; | 2148 | break; |
| 2158 | case PR_GET_CHILD_SUBREAPER: | 2149 | case PR_GET_CHILD_SUBREAPER: |
| 2159 | error = put_user(me->signal->is_child_subreaper, | 2150 | error = put_user(me->signal->is_child_subreaper, |
| @@ -2195,46 +2186,52 @@ static void argv_cleanup(struct subprocess_info *info) | |||
| 2195 | argv_free(info->argv); | 2186 | argv_free(info->argv); |
| 2196 | } | 2187 | } |
| 2197 | 2188 | ||
| 2198 | /** | 2189 | static int __orderly_poweroff(void) |
| 2199 | * orderly_poweroff - Trigger an orderly system poweroff | ||
| 2200 | * @force: force poweroff if command execution fails | ||
| 2201 | * | ||
| 2202 | * This may be called from any context to trigger a system shutdown. | ||
| 2203 | * If the orderly shutdown fails, it will force an immediate shutdown. | ||
| 2204 | */ | ||
| 2205 | int orderly_poweroff(bool force) | ||
| 2206 | { | 2190 | { |
| 2207 | int argc; | 2191 | int argc; |
| 2208 | char **argv = argv_split(GFP_ATOMIC, poweroff_cmd, &argc); | 2192 | char **argv; |
| 2209 | static char *envp[] = { | 2193 | static char *envp[] = { |
| 2210 | "HOME=/", | 2194 | "HOME=/", |
| 2211 | "PATH=/sbin:/bin:/usr/sbin:/usr/bin", | 2195 | "PATH=/sbin:/bin:/usr/sbin:/usr/bin", |
| 2212 | NULL | 2196 | NULL |
| 2213 | }; | 2197 | }; |
| 2214 | int ret = -ENOMEM; | 2198 | int ret; |
| 2215 | 2199 | ||
| 2200 | argv = argv_split(GFP_ATOMIC, poweroff_cmd, &argc); | ||
| 2216 | if (argv == NULL) { | 2201 | if (argv == NULL) { |
| 2217 | printk(KERN_WARNING "%s failed to allocate memory for \"%s\"\n", | 2202 | printk(KERN_WARNING "%s failed to allocate memory for \"%s\"\n", |
| 2218 | __func__, poweroff_cmd); | 2203 | __func__, poweroff_cmd); |
| 2219 | goto out; | 2204 | return -ENOMEM; |
| 2220 | } | 2205 | } |
| 2221 | 2206 | ||
| 2222 | ret = call_usermodehelper_fns(argv[0], argv, envp, UMH_NO_WAIT, | 2207 | ret = call_usermodehelper_fns(argv[0], argv, envp, UMH_NO_WAIT, |
| 2223 | NULL, argv_cleanup, NULL); | 2208 | NULL, argv_cleanup, NULL); |
| 2224 | out: | ||
| 2225 | if (likely(!ret)) | ||
| 2226 | return 0; | ||
| 2227 | |||
| 2228 | if (ret == -ENOMEM) | 2209 | if (ret == -ENOMEM) |
| 2229 | argv_free(argv); | 2210 | argv_free(argv); |
| 2230 | 2211 | ||
| 2231 | if (force) { | 2212 | return ret; |
| 2213 | } | ||
| 2214 | |||
| 2215 | /** | ||
| 2216 | * orderly_poweroff - Trigger an orderly system poweroff | ||
| 2217 | * @force: force poweroff if command execution fails | ||
| 2218 | * | ||
| 2219 | * This may be called from any context to trigger a system shutdown. | ||
| 2220 | * If the orderly shutdown fails, it will force an immediate shutdown. | ||
| 2221 | */ | ||
| 2222 | int orderly_poweroff(bool force) | ||
| 2223 | { | ||
| 2224 | int ret = __orderly_poweroff(); | ||
| 2225 | |||
| 2226 | if (ret && force) { | ||
| 2232 | printk(KERN_WARNING "Failed to start orderly shutdown: " | 2227 | printk(KERN_WARNING "Failed to start orderly shutdown: " |
| 2233 | "forcing the issue\n"); | 2228 | "forcing the issue\n"); |
| 2234 | 2229 | ||
| 2235 | /* I guess this should try to kick off some daemon to | 2230 | /* |
| 2236 | sync and poweroff asap. Or not even bother syncing | 2231 | * I guess this should try to kick off some daemon to sync and |
| 2237 | if we're doing an emergency shutdown? */ | 2232 | * poweroff asap. Or not even bother syncing if we're doing an |
| 2233 | * emergency shutdown? | ||
| 2234 | */ | ||
| 2238 | emergency_sync(); | 2235 | emergency_sync(); |
| 2239 | kernel_power_off(); | 2236 | kernel_power_off(); |
| 2240 | } | 2237 | } |
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 4ab11879aeb4..97186b99b0e4 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <linux/security.h> | 30 | #include <linux/security.h> |
| 31 | #include <linux/ctype.h> | 31 | #include <linux/ctype.h> |
| 32 | #include <linux/kmemcheck.h> | 32 | #include <linux/kmemcheck.h> |
| 33 | #include <linux/kmemleak.h> | ||
| 33 | #include <linux/fs.h> | 34 | #include <linux/fs.h> |
| 34 | #include <linux/init.h> | 35 | #include <linux/init.h> |
| 35 | #include <linux/kernel.h> | 36 | #include <linux/kernel.h> |
| @@ -174,6 +175,11 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, | |||
| 174 | void __user *buffer, size_t *lenp, loff_t *ppos); | 175 | void __user *buffer, size_t *lenp, loff_t *ppos); |
| 175 | #endif | 176 | #endif |
| 176 | 177 | ||
| 178 | static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, | ||
| 179 | void __user *buffer, size_t *lenp, loff_t *ppos); | ||
| 180 | static int proc_dostring_coredump(struct ctl_table *table, int write, | ||
| 181 | void __user *buffer, size_t *lenp, loff_t *ppos); | ||
| 182 | |||
| 177 | #ifdef CONFIG_MAGIC_SYSRQ | 183 | #ifdef CONFIG_MAGIC_SYSRQ |
| 178 | /* Note: sysrq code uses it's own private copy */ | 184 | /* Note: sysrq code uses it's own private copy */ |
| 179 | static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE; | 185 | static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE; |
| @@ -410,7 +416,7 @@ static struct ctl_table kern_table[] = { | |||
| 410 | .data = core_pattern, | 416 | .data = core_pattern, |
| 411 | .maxlen = CORENAME_MAX_SIZE, | 417 | .maxlen = CORENAME_MAX_SIZE, |
| 412 | .mode = 0644, | 418 | .mode = 0644, |
| 413 | .proc_handler = proc_dostring, | 419 | .proc_handler = proc_dostring_coredump, |
| 414 | }, | 420 | }, |
| 415 | { | 421 | { |
| 416 | .procname = "core_pipe_limit", | 422 | .procname = "core_pipe_limit", |
| @@ -1498,7 +1504,7 @@ static struct ctl_table fs_table[] = { | |||
| 1498 | .data = &suid_dumpable, | 1504 | .data = &suid_dumpable, |
| 1499 | .maxlen = sizeof(int), | 1505 | .maxlen = sizeof(int), |
| 1500 | .mode = 0644, | 1506 | .mode = 0644, |
| 1501 | .proc_handler = proc_dointvec_minmax, | 1507 | .proc_handler = proc_dointvec_minmax_coredump, |
| 1502 | .extra1 = &zero, | 1508 | .extra1 = &zero, |
| 1503 | .extra2 = &two, | 1509 | .extra2 = &two, |
| 1504 | }, | 1510 | }, |
| @@ -1551,7 +1557,10 @@ static struct ctl_table dev_table[] = { | |||
| 1551 | 1557 | ||
| 1552 | int __init sysctl_init(void) | 1558 | int __init sysctl_init(void) |
| 1553 | { | 1559 | { |
| 1554 | register_sysctl_table(sysctl_base_table); | 1560 | struct ctl_table_header *hdr; |
| 1561 | |||
| 1562 | hdr = register_sysctl_table(sysctl_base_table); | ||
| 1563 | kmemleak_not_leak(hdr); | ||
| 1555 | return 0; | 1564 | return 0; |
| 1556 | } | 1565 | } |
| 1557 | 1566 | ||
| @@ -2009,6 +2018,34 @@ int proc_dointvec_minmax(struct ctl_table *table, int write, | |||
| 2009 | do_proc_dointvec_minmax_conv, ¶m); | 2018 | do_proc_dointvec_minmax_conv, ¶m); |
| 2010 | } | 2019 | } |
| 2011 | 2020 | ||
| 2021 | static void validate_coredump_safety(void) | ||
| 2022 | { | ||
| 2023 | if (suid_dumpable == SUID_DUMPABLE_SAFE && | ||
| 2024 | core_pattern[0] != '/' && core_pattern[0] != '|') { | ||
| 2025 | printk(KERN_WARNING "Unsafe core_pattern used with "\ | ||
| 2026 | "suid_dumpable=2. Pipe handler or fully qualified "\ | ||
| 2027 | "core dump path required.\n"); | ||
| 2028 | } | ||
| 2029 | } | ||
| 2030 | |||
| 2031 | static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, | ||
| 2032 | void __user *buffer, size_t *lenp, loff_t *ppos) | ||
| 2033 | { | ||
| 2034 | int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos); | ||
| 2035 | if (!error) | ||
| 2036 | validate_coredump_safety(); | ||
| 2037 | return error; | ||
| 2038 | } | ||
| 2039 | |||
| 2040 | static int proc_dostring_coredump(struct ctl_table *table, int write, | ||
| 2041 | void __user *buffer, size_t *lenp, loff_t *ppos) | ||
| 2042 | { | ||
| 2043 | int error = proc_dostring(table, write, buffer, lenp, ppos); | ||
| 2044 | if (!error) | ||
| 2045 | validate_coredump_safety(); | ||
| 2046 | return error; | ||
| 2047 | } | ||
| 2048 | |||
| 2012 | static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, | 2049 | static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, |
| 2013 | void __user *buffer, | 2050 | void __user *buffer, |
| 2014 | size_t *lenp, loff_t *ppos, | 2051 | size_t *lenp, loff_t *ppos, |
diff --git a/kernel/taskstats.c b/kernel/taskstats.c index e66046456f4f..d0a32796550f 100644 --- a/kernel/taskstats.c +++ b/kernel/taskstats.c | |||
| @@ -436,6 +436,11 @@ static int cgroupstats_user_cmd(struct sk_buff *skb, struct genl_info *info) | |||
| 436 | 436 | ||
| 437 | na = nla_reserve(rep_skb, CGROUPSTATS_TYPE_CGROUP_STATS, | 437 | na = nla_reserve(rep_skb, CGROUPSTATS_TYPE_CGROUP_STATS, |
| 438 | sizeof(struct cgroupstats)); | 438 | sizeof(struct cgroupstats)); |
| 439 | if (na == NULL) { | ||
| 440 | rc = -EMSGSIZE; | ||
| 441 | goto err; | ||
| 442 | } | ||
| 443 | |||
| 439 | stats = nla_data(na); | 444 | stats = nla_data(na); |
| 440 | memset(stats, 0, sizeof(*stats)); | 445 | memset(stats, 0, sizeof(*stats)); |
| 441 | 446 | ||
diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 4b1dfba70f7c..69add8a9da68 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c | |||
| @@ -575,7 +575,7 @@ out: | |||
| 575 | /* | 575 | /* |
| 576 | * Create/destroy watchdog threads as CPUs come and go: | 576 | * Create/destroy watchdog threads as CPUs come and go: |
| 577 | */ | 577 | */ |
| 578 | static int __cpuinit | 578 | static int |
| 579 | cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) | 579 | cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) |
| 580 | { | 580 | { |
| 581 | int hotcpu = (unsigned long)hcpu; | 581 | int hotcpu = (unsigned long)hcpu; |
| @@ -610,10 +610,27 @@ cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) | |||
| 610 | return NOTIFY_OK; | 610 | return NOTIFY_OK; |
| 611 | } | 611 | } |
| 612 | 612 | ||
| 613 | static struct notifier_block __cpuinitdata cpu_nfb = { | 613 | static struct notifier_block cpu_nfb = { |
| 614 | .notifier_call = cpu_callback | 614 | .notifier_call = cpu_callback |
| 615 | }; | 615 | }; |
| 616 | 616 | ||
| 617 | #ifdef CONFIG_SUSPEND | ||
| 618 | /* | ||
| 619 | * On exit from suspend we force an offline->online transition on the boot CPU | ||
| 620 | * so that the PMU state that was lost while in suspended state gets set up | ||
| 621 | * properly for the boot CPU. This information is required for restarting the | ||
| 622 | * NMI watchdog. | ||
| 623 | */ | ||
| 624 | void lockup_detector_bootcpu_resume(void) | ||
| 625 | { | ||
| 626 | void *cpu = (void *)(long)smp_processor_id(); | ||
| 627 | |||
| 628 | cpu_callback(&cpu_nfb, CPU_DEAD_FROZEN, cpu); | ||
| 629 | cpu_callback(&cpu_nfb, CPU_UP_PREPARE_FROZEN, cpu); | ||
| 630 | cpu_callback(&cpu_nfb, CPU_ONLINE_FROZEN, cpu); | ||
| 631 | } | ||
| 632 | #endif | ||
| 633 | |||
| 617 | void __init lockup_detector_init(void) | 634 | void __init lockup_detector_init(void) |
| 618 | { | 635 | { |
| 619 | void *cpu = (void *)(long)smp_processor_id(); | 636 | void *cpu = (void *)(long)smp_processor_id(); |
diff --git a/lib/Kconfig b/lib/Kconfig index bfdbb1ff0aa3..bb94c1ba616a 100644 --- a/lib/Kconfig +++ b/lib/Kconfig | |||
| @@ -340,6 +340,9 @@ config NLATTR | |||
| 340 | config GENERIC_ATOMIC64 | 340 | config GENERIC_ATOMIC64 |
| 341 | bool | 341 | bool |
| 342 | 342 | ||
| 343 | config ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE | ||
| 344 | def_bool y if GENERIC_ATOMIC64 | ||
| 345 | |||
| 343 | config LRU_CACHE | 346 | config LRU_CACHE |
| 344 | tristate | 347 | tristate |
| 345 | 348 | ||
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 4a186508bf8b..2403a63b5da5 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
| @@ -1084,18 +1084,105 @@ config LKDTM | |||
| 1084 | Documentation on how to use the module can be found in | 1084 | Documentation on how to use the module can be found in |
| 1085 | Documentation/fault-injection/provoke-crashes.txt | 1085 | Documentation/fault-injection/provoke-crashes.txt |
| 1086 | 1086 | ||
| 1087 | config NOTIFIER_ERROR_INJECTION | ||
| 1088 | tristate "Notifier error injection" | ||
| 1089 | depends on DEBUG_KERNEL | ||
| 1090 | select DEBUG_FS | ||
| 1091 | help | ||
| 1092 | This option provides the ability to inject artifical errors to | ||
| 1093 | specified notifier chain callbacks. It is useful to test the error | ||
| 1094 | handling of notifier call chain failures. | ||
| 1095 | |||
| 1096 | Say N if unsure. | ||
| 1097 | |||
| 1087 | config CPU_NOTIFIER_ERROR_INJECT | 1098 | config CPU_NOTIFIER_ERROR_INJECT |
| 1088 | tristate "CPU notifier error injection module" | 1099 | tristate "CPU notifier error injection module" |
| 1089 | depends on HOTPLUG_CPU && DEBUG_KERNEL | 1100 | depends on HOTPLUG_CPU && NOTIFIER_ERROR_INJECTION |
| 1090 | help | 1101 | help |
| 1091 | This option provides a kernel module that can be used to test | 1102 | This option provides a kernel module that can be used to test |
| 1092 | the error handling of the cpu notifiers | 1103 | the error handling of the cpu notifiers by injecting artifical |
| 1104 | errors to CPU notifier chain callbacks. It is controlled through | ||
| 1105 | debugfs interface under /sys/kernel/debug/notifier-error-inject/cpu | ||
| 1106 | |||
| 1107 | If the notifier call chain should be failed with some events | ||
| 1108 | notified, write the error code to "actions/<notifier event>/error". | ||
| 1109 | |||
| 1110 | Example: Inject CPU offline error (-1 == -EPERM) | ||
| 1111 | |||
| 1112 | # cd /sys/kernel/debug/notifier-error-inject/cpu | ||
| 1113 | # echo -1 > actions/CPU_DOWN_PREPARE/error | ||
| 1114 | # echo 0 > /sys/devices/system/cpu/cpu1/online | ||
| 1115 | bash: echo: write error: Operation not permitted | ||
| 1093 | 1116 | ||
| 1094 | To compile this code as a module, choose M here: the module will | 1117 | To compile this code as a module, choose M here: the module will |
| 1095 | be called cpu-notifier-error-inject. | 1118 | be called cpu-notifier-error-inject. |
| 1096 | 1119 | ||
| 1097 | If unsure, say N. | 1120 | If unsure, say N. |
| 1098 | 1121 | ||
| 1122 | config PM_NOTIFIER_ERROR_INJECT | ||
| 1123 | tristate "PM notifier error injection module" | ||
| 1124 | depends on PM && NOTIFIER_ERROR_INJECTION | ||
| 1125 | default m if PM_DEBUG | ||
| 1126 | help | ||
| 1127 | This option provides the ability to inject artifical errors to | ||
| 1128 | PM notifier chain callbacks. It is controlled through debugfs | ||
| 1129 | interface /sys/kernel/debug/notifier-error-inject/pm | ||
| 1130 | |||
| 1131 | If the notifier call chain should be failed with some events | ||
| 1132 | notified, write the error code to "actions/<notifier event>/error". | ||
| 1133 | |||
| 1134 | Example: Inject PM suspend error (-12 = -ENOMEM) | ||
| 1135 | |||
| 1136 | # cd /sys/kernel/debug/notifier-error-inject/pm/ | ||
| 1137 | # echo -12 > actions/PM_SUSPEND_PREPARE/error | ||
| 1138 | # echo mem > /sys/power/state | ||
| 1139 | bash: echo: write error: Cannot allocate memory | ||
| 1140 | |||
| 1141 | To compile this code as a module, choose M here: the module will | ||
| 1142 | be called pm-notifier-error-inject. | ||
| 1143 | |||
| 1144 | If unsure, say N. | ||
| 1145 | |||
| 1146 | config MEMORY_NOTIFIER_ERROR_INJECT | ||
| 1147 | tristate "Memory hotplug notifier error injection module" | ||
| 1148 | depends on MEMORY_HOTPLUG_SPARSE && NOTIFIER_ERROR_INJECTION | ||
| 1149 | help | ||
| 1150 | This option provides the ability to inject artifical errors to | ||
| 1151 | memory hotplug notifier chain callbacks. It is controlled through | ||
| 1152 | debugfs interface under /sys/kernel/debug/notifier-error-inject/memory | ||
| 1153 | |||
| 1154 | If the notifier call chain should be failed with some events | ||
| 1155 | notified, write the error code to "actions/<notifier event>/error". | ||
| 1156 | |||
| 1157 | Example: Inject memory hotplug offline error (-12 == -ENOMEM) | ||
| 1158 | |||
| 1159 | # cd /sys/kernel/debug/notifier-error-inject/memory | ||
| 1160 | # echo -12 > actions/MEM_GOING_OFFLINE/error | ||
| 1161 | # echo offline > /sys/devices/system/memory/memoryXXX/state | ||
| 1162 | bash: echo: write error: Cannot allocate memory | ||
| 1163 | |||
| 1164 | To compile this code as a module, choose M here: the module will | ||
| 1165 | be called pSeries-reconfig-notifier-error-inject. | ||
| 1166 | |||
| 1167 | If unsure, say N. | ||
| 1168 | |||
| 1169 | config PSERIES_RECONFIG_NOTIFIER_ERROR_INJECT | ||
| 1170 | tristate "pSeries reconfig notifier error injection module" | ||
| 1171 | depends on PPC_PSERIES && NOTIFIER_ERROR_INJECTION | ||
| 1172 | help | ||
| 1173 | This option provides the ability to inject artifical errors to | ||
| 1174 | pSeries reconfig notifier chain callbacks. It is controlled | ||
| 1175 | through debugfs interface under | ||
| 1176 | /sys/kernel/debug/notifier-error-inject/pSeries-reconfig/ | ||
| 1177 | |||
| 1178 | If the notifier call chain should be failed with some events | ||
| 1179 | notified, write the error code to "actions/<notifier event>/error". | ||
| 1180 | |||
| 1181 | To compile this code as a module, choose M here: the module will | ||
| 1182 | be called memory-notifier-error-inject. | ||
| 1183 | |||
| 1184 | If unsure, say N. | ||
| 1185 | |||
| 1099 | config FAULT_INJECTION | 1186 | config FAULT_INJECTION |
| 1100 | bool "Fault-injection framework" | 1187 | bool "Fault-injection framework" |
| 1101 | depends on DEBUG_KERNEL | 1188 | depends on DEBUG_KERNEL |
diff --git a/lib/Makefile b/lib/Makefile index 2f2be5a8734c..9cb4104f47d9 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
| @@ -22,7 +22,7 @@ lib-y += kobject.o klist.o | |||
| 22 | obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ | 22 | obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ |
| 23 | bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ | 23 | bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ |
| 24 | string_helpers.o gcd.o lcm.o list_sort.o uuid.o flex_array.o \ | 24 | string_helpers.o gcd.o lcm.o list_sort.o uuid.o flex_array.o \ |
| 25 | bsearch.o find_last_bit.o find_next_bit.o llist.o | 25 | bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o |
| 26 | obj-y += kstrtox.o | 26 | obj-y += kstrtox.o |
| 27 | obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o | 27 | obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o |
| 28 | 28 | ||
| @@ -90,7 +90,12 @@ obj-$(CONFIG_AUDIT_GENERIC) += audit.o | |||
| 90 | obj-$(CONFIG_SWIOTLB) += swiotlb.o | 90 | obj-$(CONFIG_SWIOTLB) += swiotlb.o |
| 91 | obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o | 91 | obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o |
| 92 | obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o | 92 | obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o |
| 93 | obj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o | ||
| 93 | obj-$(CONFIG_CPU_NOTIFIER_ERROR_INJECT) += cpu-notifier-error-inject.o | 94 | obj-$(CONFIG_CPU_NOTIFIER_ERROR_INJECT) += cpu-notifier-error-inject.o |
| 95 | obj-$(CONFIG_PM_NOTIFIER_ERROR_INJECT) += pm-notifier-error-inject.o | ||
| 96 | obj-$(CONFIG_MEMORY_NOTIFIER_ERROR_INJECT) += memory-notifier-error-inject.o | ||
| 97 | obj-$(CONFIG_PSERIES_RECONFIG_NOTIFIER_ERROR_INJECT) += \ | ||
| 98 | pSeries-reconfig-notifier-error-inject.o | ||
| 94 | 99 | ||
| 95 | lib-$(CONFIG_GENERIC_BUG) += bug.o | 100 | lib-$(CONFIG_GENERIC_BUG) += bug.o |
| 96 | 101 | ||
diff --git a/lib/atomic64_test.c b/lib/atomic64_test.c index cb99b91c3a1d..00bca223d1e1 100644 --- a/lib/atomic64_test.c +++ b/lib/atomic64_test.c | |||
| @@ -114,8 +114,7 @@ static __init int test_atomic64(void) | |||
| 114 | r += one; | 114 | r += one; |
| 115 | BUG_ON(v.counter != r); | 115 | BUG_ON(v.counter != r); |
| 116 | 116 | ||
| 117 | #if defined(CONFIG_X86) || defined(CONFIG_MIPS) || defined(CONFIG_PPC) || \ | 117 | #ifdef CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE |
| 118 | defined(CONFIG_S390) || defined(_ASM_GENERIC_ATOMIC64_H) || defined(CONFIG_ARM) | ||
| 119 | INIT(onestwos); | 118 | INIT(onestwos); |
| 120 | BUG_ON(atomic64_dec_if_positive(&v) != (onestwos - 1)); | 119 | BUG_ON(atomic64_dec_if_positive(&v) != (onestwos - 1)); |
| 121 | r -= one; | 120 | r -= one; |
| @@ -129,7 +128,7 @@ static __init int test_atomic64(void) | |||
| 129 | BUG_ON(atomic64_dec_if_positive(&v) != (-one - one)); | 128 | BUG_ON(atomic64_dec_if_positive(&v) != (-one - one)); |
| 130 | BUG_ON(v.counter != r); | 129 | BUG_ON(v.counter != r); |
| 131 | #else | 130 | #else |
| 132 | #warning Please implement atomic64_dec_if_positive for your architecture, and add it to the IF above | 131 | #warning Please implement atomic64_dec_if_positive for your architecture and select the above Kconfig symbol |
| 133 | #endif | 132 | #endif |
| 134 | 133 | ||
| 135 | INIT(onestwos); | 134 | INIT(onestwos); |
diff --git a/lib/cpu-notifier-error-inject.c b/lib/cpu-notifier-error-inject.c index 4dc20321b0d5..707ca24f7b18 100644 --- a/lib/cpu-notifier-error-inject.c +++ b/lib/cpu-notifier-error-inject.c | |||
| @@ -1,58 +1,45 @@ | |||
| 1 | #include <linux/kernel.h> | 1 | #include <linux/kernel.h> |
| 2 | #include <linux/cpu.h> | ||
| 3 | #include <linux/module.h> | 2 | #include <linux/module.h> |
| 4 | #include <linux/notifier.h> | 3 | #include <linux/cpu.h> |
| 5 | 4 | ||
| 6 | static int priority; | 5 | #include "notifier-error-inject.h" |
| 7 | static int cpu_up_prepare_error; | ||
| 8 | static int cpu_down_prepare_error; | ||
| 9 | 6 | ||
| 7 | static int priority; | ||
| 10 | module_param(priority, int, 0); | 8 | module_param(priority, int, 0); |
| 11 | MODULE_PARM_DESC(priority, "specify cpu notifier priority"); | 9 | MODULE_PARM_DESC(priority, "specify cpu notifier priority"); |
| 12 | 10 | ||
| 13 | module_param(cpu_up_prepare_error, int, 0644); | 11 | static struct notifier_err_inject cpu_notifier_err_inject = { |
| 14 | MODULE_PARM_DESC(cpu_up_prepare_error, | 12 | .actions = { |
| 15 | "specify error code to inject CPU_UP_PREPARE action"); | 13 | { NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE) }, |
| 16 | 14 | { NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE_FROZEN) }, | |
| 17 | module_param(cpu_down_prepare_error, int, 0644); | 15 | { NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE) }, |
| 18 | MODULE_PARM_DESC(cpu_down_prepare_error, | 16 | { NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE_FROZEN) }, |
| 19 | "specify error code to inject CPU_DOWN_PREPARE action"); | 17 | {} |
| 20 | |||
| 21 | static int err_inject_cpu_callback(struct notifier_block *nfb, | ||
| 22 | unsigned long action, void *hcpu) | ||
| 23 | { | ||
| 24 | int err = 0; | ||
| 25 | |||
| 26 | switch (action) { | ||
| 27 | case CPU_UP_PREPARE: | ||
| 28 | case CPU_UP_PREPARE_FROZEN: | ||
| 29 | err = cpu_up_prepare_error; | ||
| 30 | break; | ||
| 31 | case CPU_DOWN_PREPARE: | ||
| 32 | case CPU_DOWN_PREPARE_FROZEN: | ||
| 33 | err = cpu_down_prepare_error; | ||
| 34 | break; | ||
| 35 | } | 18 | } |
| 36 | if (err) | ||
| 37 | printk(KERN_INFO "Injecting error (%d) at cpu notifier\n", err); | ||
| 38 | |||
| 39 | return notifier_from_errno(err); | ||
| 40 | } | ||
| 41 | |||
| 42 | static struct notifier_block err_inject_cpu_notifier = { | ||
| 43 | .notifier_call = err_inject_cpu_callback, | ||
| 44 | }; | 19 | }; |
| 45 | 20 | ||
| 21 | static struct dentry *dir; | ||
| 22 | |||
| 46 | static int err_inject_init(void) | 23 | static int err_inject_init(void) |
| 47 | { | 24 | { |
| 48 | err_inject_cpu_notifier.priority = priority; | 25 | int err; |
| 26 | |||
| 27 | dir = notifier_err_inject_init("cpu", notifier_err_inject_dir, | ||
| 28 | &cpu_notifier_err_inject, priority); | ||
| 29 | if (IS_ERR(dir)) | ||
| 30 | return PTR_ERR(dir); | ||
| 31 | |||
| 32 | err = register_hotcpu_notifier(&cpu_notifier_err_inject.nb); | ||
| 33 | if (err) | ||
| 34 | debugfs_remove_recursive(dir); | ||
| 49 | 35 | ||
| 50 | return register_hotcpu_notifier(&err_inject_cpu_notifier); | 36 | return err; |
| 51 | } | 37 | } |
| 52 | 38 | ||
| 53 | static void err_inject_exit(void) | 39 | static void err_inject_exit(void) |
| 54 | { | 40 | { |
| 55 | unregister_hotcpu_notifier(&err_inject_cpu_notifier); | 41 | unregister_hotcpu_notifier(&cpu_notifier_err_inject.nb); |
| 42 | debugfs_remove_recursive(dir); | ||
| 56 | } | 43 | } |
| 57 | 44 | ||
| 58 | module_init(err_inject_init); | 45 | module_init(err_inject_init); |
diff --git a/lib/crc32.c b/lib/crc32.c index b0d278fb1d91..61774b8db4de 100644 --- a/lib/crc32.c +++ b/lib/crc32.c | |||
| @@ -74,7 +74,9 @@ crc32_body(u32 crc, unsigned char const *buf, size_t len, const u32 (*tab)[256]) | |||
| 74 | size_t i; | 74 | size_t i; |
| 75 | # endif | 75 | # endif |
| 76 | const u32 *t0=tab[0], *t1=tab[1], *t2=tab[2], *t3=tab[3]; | 76 | const u32 *t0=tab[0], *t1=tab[1], *t2=tab[2], *t3=tab[3]; |
| 77 | # if CRC_LE_BITS != 32 | ||
| 77 | const u32 *t4 = tab[4], *t5 = tab[5], *t6 = tab[6], *t7 = tab[7]; | 78 | const u32 *t4 = tab[4], *t5 = tab[5], *t6 = tab[6], *t7 = tab[7]; |
| 79 | # endif | ||
| 78 | u32 q; | 80 | u32 q; |
| 79 | 81 | ||
| 80 | /* Align it */ | 82 | /* Align it */ |
diff --git a/lib/memory-notifier-error-inject.c b/lib/memory-notifier-error-inject.c new file mode 100644 index 000000000000..e6239bf0b0df --- /dev/null +++ b/lib/memory-notifier-error-inject.c | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | #include <linux/kernel.h> | ||
| 2 | #include <linux/module.h> | ||
| 3 | #include <linux/memory.h> | ||
| 4 | |||
| 5 | #include "notifier-error-inject.h" | ||
| 6 | |||
| 7 | static int priority; | ||
| 8 | module_param(priority, int, 0); | ||
| 9 | MODULE_PARM_DESC(priority, "specify memory notifier priority"); | ||
| 10 | |||
| 11 | static struct notifier_err_inject memory_notifier_err_inject = { | ||
| 12 | .actions = { | ||
| 13 | { NOTIFIER_ERR_INJECT_ACTION(MEM_GOING_ONLINE) }, | ||
| 14 | { NOTIFIER_ERR_INJECT_ACTION(MEM_GOING_OFFLINE) }, | ||
| 15 | {} | ||
| 16 | } | ||
| 17 | }; | ||
| 18 | |||
| 19 | static struct dentry *dir; | ||
| 20 | |||
| 21 | static int err_inject_init(void) | ||
| 22 | { | ||
| 23 | int err; | ||
| 24 | |||
| 25 | dir = notifier_err_inject_init("memory", notifier_err_inject_dir, | ||
| 26 | &memory_notifier_err_inject, priority); | ||
| 27 | if (IS_ERR(dir)) | ||
| 28 | return PTR_ERR(dir); | ||
| 29 | |||
| 30 | err = register_memory_notifier(&memory_notifier_err_inject.nb); | ||
| 31 | if (err) | ||
| 32 | debugfs_remove_recursive(dir); | ||
| 33 | |||
| 34 | return err; | ||
| 35 | } | ||
| 36 | |||
| 37 | static void err_inject_exit(void) | ||
| 38 | { | ||
| 39 | unregister_memory_notifier(&memory_notifier_err_inject.nb); | ||
| 40 | debugfs_remove_recursive(dir); | ||
| 41 | } | ||
| 42 | |||
| 43 | module_init(err_inject_init); | ||
| 44 | module_exit(err_inject_exit); | ||
| 45 | |||
| 46 | MODULE_DESCRIPTION("memory notifier error injection module"); | ||
| 47 | MODULE_LICENSE("GPL"); | ||
| 48 | MODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>"); | ||
diff --git a/lib/memweight.c b/lib/memweight.c new file mode 100644 index 000000000000..e35fc8771893 --- /dev/null +++ b/lib/memweight.c | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | #include <linux/export.h> | ||
| 2 | #include <linux/bug.h> | ||
| 3 | #include <linux/bitmap.h> | ||
| 4 | |||
| 5 | /** | ||
| 6 | * memweight - count the total number of bits set in memory area | ||
| 7 | * @ptr: pointer to the start of the area | ||
| 8 | * @bytes: the size of the area | ||
| 9 | */ | ||
| 10 | size_t memweight(const void *ptr, size_t bytes) | ||
| 11 | { | ||
| 12 | size_t ret = 0; | ||
| 13 | size_t longs; | ||
| 14 | const unsigned char *bitmap = ptr; | ||
| 15 | |||
| 16 | for (; bytes > 0 && ((unsigned long)bitmap) % sizeof(long); | ||
| 17 | bytes--, bitmap++) | ||
| 18 | ret += hweight8(*bitmap); | ||
| 19 | |||
| 20 | longs = bytes / sizeof(long); | ||
| 21 | if (longs) { | ||
| 22 | BUG_ON(longs >= INT_MAX / BITS_PER_LONG); | ||
| 23 | ret += bitmap_weight((unsigned long *)bitmap, | ||
| 24 | longs * BITS_PER_LONG); | ||
| 25 | bytes -= longs * sizeof(long); | ||
| 26 | bitmap += longs * sizeof(long); | ||
| 27 | } | ||
| 28 | /* | ||
| 29 | * The reason that this last loop is distinct from the preceding | ||
| 30 | * bitmap_weight() call is to compute 1-bits in the last region smaller | ||
| 31 | * than sizeof(long) properly on big-endian systems. | ||
| 32 | */ | ||
| 33 | for (; bytes > 0; bytes--, bitmap++) | ||
| 34 | ret += hweight8(*bitmap); | ||
| 35 | |||
| 36 | return ret; | ||
| 37 | } | ||
| 38 | EXPORT_SYMBOL(memweight); | ||
diff --git a/lib/notifier-error-inject.c b/lib/notifier-error-inject.c new file mode 100644 index 000000000000..44b92cb6224f --- /dev/null +++ b/lib/notifier-error-inject.c | |||
| @@ -0,0 +1,112 @@ | |||
| 1 | #include <linux/module.h> | ||
| 2 | |||
| 3 | #include "notifier-error-inject.h" | ||
| 4 | |||
| 5 | static int debugfs_errno_set(void *data, u64 val) | ||
| 6 | { | ||
| 7 | *(int *)data = clamp_t(int, val, -MAX_ERRNO, 0); | ||
| 8 | return 0; | ||
| 9 | } | ||
| 10 | |||
| 11 | static int debugfs_errno_get(void *data, u64 *val) | ||
| 12 | { | ||
| 13 | *val = *(int *)data; | ||
| 14 | return 0; | ||
| 15 | } | ||
| 16 | |||
| 17 | DEFINE_SIMPLE_ATTRIBUTE(fops_errno, debugfs_errno_get, debugfs_errno_set, | ||
| 18 | "%lld\n"); | ||
| 19 | |||
| 20 | static struct dentry *debugfs_create_errno(const char *name, mode_t mode, | ||
| 21 | struct dentry *parent, int *value) | ||
| 22 | { | ||
| 23 | return debugfs_create_file(name, mode, parent, value, &fops_errno); | ||
| 24 | } | ||
| 25 | |||
| 26 | static int notifier_err_inject_callback(struct notifier_block *nb, | ||
| 27 | unsigned long val, void *p) | ||
| 28 | { | ||
| 29 | int err = 0; | ||
| 30 | struct notifier_err_inject *err_inject = | ||
| 31 | container_of(nb, struct notifier_err_inject, nb); | ||
| 32 | struct notifier_err_inject_action *action; | ||
| 33 | |||
| 34 | for (action = err_inject->actions; action->name; action++) { | ||
| 35 | if (action->val == val) { | ||
| 36 | err = action->error; | ||
| 37 | break; | ||
| 38 | } | ||
| 39 | } | ||
| 40 | if (err) | ||
| 41 | pr_info("Injecting error (%d) to %s\n", err, action->name); | ||
| 42 | |||
| 43 | return notifier_from_errno(err); | ||
| 44 | } | ||
| 45 | |||
| 46 | struct dentry *notifier_err_inject_dir; | ||
| 47 | EXPORT_SYMBOL_GPL(notifier_err_inject_dir); | ||
| 48 | |||
| 49 | struct dentry *notifier_err_inject_init(const char *name, struct dentry *parent, | ||
| 50 | struct notifier_err_inject *err_inject, int priority) | ||
| 51 | { | ||
| 52 | struct notifier_err_inject_action *action; | ||
| 53 | mode_t mode = S_IFREG | S_IRUSR | S_IWUSR; | ||
| 54 | struct dentry *dir; | ||
| 55 | struct dentry *actions_dir; | ||
| 56 | |||
| 57 | err_inject->nb.notifier_call = notifier_err_inject_callback; | ||
| 58 | err_inject->nb.priority = priority; | ||
| 59 | |||
| 60 | dir = debugfs_create_dir(name, parent); | ||
| 61 | if (!dir) | ||
| 62 | return ERR_PTR(-ENOMEM); | ||
| 63 | |||
| 64 | actions_dir = debugfs_create_dir("actions", dir); | ||
| 65 | if (!actions_dir) | ||
| 66 | goto fail; | ||
| 67 | |||
| 68 | for (action = err_inject->actions; action->name; action++) { | ||
| 69 | struct dentry *action_dir; | ||
| 70 | |||
| 71 | action_dir = debugfs_create_dir(action->name, actions_dir); | ||
| 72 | if (!action_dir) | ||
| 73 | goto fail; | ||
| 74 | |||
| 75 | /* | ||
| 76 | * Create debugfs r/w file containing action->error. If | ||
| 77 | * notifier call chain is called with action->val, it will | ||
| 78 | * fail with the error code | ||
| 79 | */ | ||
| 80 | if (!debugfs_create_errno("error", mode, action_dir, | ||
| 81 | &action->error)) | ||
| 82 | goto fail; | ||
| 83 | } | ||
| 84 | return dir; | ||
| 85 | fail: | ||
| 86 | debugfs_remove_recursive(dir); | ||
| 87 | return ERR_PTR(-ENOMEM); | ||
| 88 | } | ||
| 89 | EXPORT_SYMBOL_GPL(notifier_err_inject_init); | ||
| 90 | |||
| 91 | static int __init err_inject_init(void) | ||
| 92 | { | ||
| 93 | notifier_err_inject_dir = | ||
| 94 | debugfs_create_dir("notifier-error-inject", NULL); | ||
| 95 | |||
| 96 | if (!notifier_err_inject_dir) | ||
| 97 | return -ENOMEM; | ||
| 98 | |||
| 99 | return 0; | ||
| 100 | } | ||
| 101 | |||
| 102 | static void __exit err_inject_exit(void) | ||
| 103 | { | ||
| 104 | debugfs_remove_recursive(notifier_err_inject_dir); | ||
| 105 | } | ||
| 106 | |||
| 107 | module_init(err_inject_init); | ||
| 108 | module_exit(err_inject_exit); | ||
| 109 | |||
| 110 | MODULE_DESCRIPTION("Notifier error injection module"); | ||
| 111 | MODULE_LICENSE("GPL"); | ||
| 112 | MODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>"); | ||
diff --git a/lib/notifier-error-inject.h b/lib/notifier-error-inject.h new file mode 100644 index 000000000000..99b3b6fc470b --- /dev/null +++ b/lib/notifier-error-inject.h | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | #include <linux/atomic.h> | ||
| 2 | #include <linux/debugfs.h> | ||
| 3 | #include <linux/notifier.h> | ||
| 4 | |||
| 5 | struct notifier_err_inject_action { | ||
| 6 | unsigned long val; | ||
| 7 | int error; | ||
| 8 | const char *name; | ||
| 9 | }; | ||
| 10 | |||
| 11 | #define NOTIFIER_ERR_INJECT_ACTION(action) \ | ||
| 12 | .name = #action, .val = (action), | ||
| 13 | |||
| 14 | struct notifier_err_inject { | ||
| 15 | struct notifier_block nb; | ||
| 16 | struct notifier_err_inject_action actions[]; | ||
| 17 | /* The last slot must be terminated with zero sentinel */ | ||
| 18 | }; | ||
| 19 | |||
| 20 | extern struct dentry *notifier_err_inject_dir; | ||
| 21 | |||
| 22 | extern struct dentry *notifier_err_inject_init(const char *name, | ||
| 23 | struct dentry *parent, struct notifier_err_inject *err_inject, | ||
| 24 | int priority); | ||
diff --git a/lib/pSeries-reconfig-notifier-error-inject.c b/lib/pSeries-reconfig-notifier-error-inject.c new file mode 100644 index 000000000000..7f7c98dcd5c4 --- /dev/null +++ b/lib/pSeries-reconfig-notifier-error-inject.c | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | #include <linux/kernel.h> | ||
| 2 | #include <linux/module.h> | ||
| 3 | |||
| 4 | #include <asm/pSeries_reconfig.h> | ||
| 5 | |||
| 6 | #include "notifier-error-inject.h" | ||
| 7 | |||
| 8 | static int priority; | ||
| 9 | module_param(priority, int, 0); | ||
| 10 | MODULE_PARM_DESC(priority, "specify pSeries reconfig notifier priority"); | ||
| 11 | |||
| 12 | static struct notifier_err_inject reconfig_err_inject = { | ||
| 13 | .actions = { | ||
| 14 | { NOTIFIER_ERR_INJECT_ACTION(PSERIES_RECONFIG_ADD) }, | ||
| 15 | { NOTIFIER_ERR_INJECT_ACTION(PSERIES_RECONFIG_REMOVE) }, | ||
| 16 | { NOTIFIER_ERR_INJECT_ACTION(PSERIES_DRCONF_MEM_ADD) }, | ||
| 17 | { NOTIFIER_ERR_INJECT_ACTION(PSERIES_DRCONF_MEM_REMOVE) }, | ||
| 18 | {} | ||
| 19 | } | ||
| 20 | }; | ||
| 21 | |||
| 22 | static struct dentry *dir; | ||
| 23 | |||
| 24 | static int err_inject_init(void) | ||
| 25 | { | ||
| 26 | int err; | ||
| 27 | |||
| 28 | dir = notifier_err_inject_init("pSeries-reconfig", | ||
| 29 | notifier_err_inject_dir, &reconfig_err_inject, priority); | ||
| 30 | if (IS_ERR(dir)) | ||
| 31 | return PTR_ERR(dir); | ||
| 32 | |||
| 33 | err = pSeries_reconfig_notifier_register(&reconfig_err_inject.nb); | ||
| 34 | if (err) | ||
| 35 | debugfs_remove_recursive(dir); | ||
| 36 | |||
| 37 | return err; | ||
| 38 | } | ||
| 39 | |||
| 40 | static void err_inject_exit(void) | ||
| 41 | { | ||
| 42 | pSeries_reconfig_notifier_unregister(&reconfig_err_inject.nb); | ||
| 43 | debugfs_remove_recursive(dir); | ||
| 44 | } | ||
| 45 | |||
| 46 | module_init(err_inject_init); | ||
| 47 | module_exit(err_inject_exit); | ||
| 48 | |||
| 49 | MODULE_DESCRIPTION("pSeries reconfig notifier error injection module"); | ||
| 50 | MODULE_LICENSE("GPL"); | ||
| 51 | MODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>"); | ||
diff --git a/lib/pm-notifier-error-inject.c b/lib/pm-notifier-error-inject.c new file mode 100644 index 000000000000..c094b2dedc23 --- /dev/null +++ b/lib/pm-notifier-error-inject.c | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | #include <linux/kernel.h> | ||
| 2 | #include <linux/module.h> | ||
| 3 | #include <linux/suspend.h> | ||
| 4 | |||
| 5 | #include "notifier-error-inject.h" | ||
| 6 | |||
| 7 | static int priority; | ||
| 8 | module_param(priority, int, 0); | ||
| 9 | MODULE_PARM_DESC(priority, "specify PM notifier priority"); | ||
| 10 | |||
| 11 | static struct notifier_err_inject pm_notifier_err_inject = { | ||
| 12 | .actions = { | ||
| 13 | { NOTIFIER_ERR_INJECT_ACTION(PM_HIBERNATION_PREPARE) }, | ||
| 14 | { NOTIFIER_ERR_INJECT_ACTION(PM_SUSPEND_PREPARE) }, | ||
| 15 | { NOTIFIER_ERR_INJECT_ACTION(PM_RESTORE_PREPARE) }, | ||
| 16 | {} | ||
| 17 | } | ||
| 18 | }; | ||
| 19 | |||
| 20 | static struct dentry *dir; | ||
| 21 | |||
| 22 | static int err_inject_init(void) | ||
| 23 | { | ||
| 24 | int err; | ||
| 25 | |||
| 26 | dir = notifier_err_inject_init("pm", notifier_err_inject_dir, | ||
| 27 | &pm_notifier_err_inject, priority); | ||
| 28 | if (IS_ERR(dir)) | ||
| 29 | return PTR_ERR(dir); | ||
| 30 | |||
| 31 | err = register_pm_notifier(&pm_notifier_err_inject.nb); | ||
| 32 | if (err) | ||
| 33 | debugfs_remove_recursive(dir); | ||
| 34 | |||
| 35 | return err; | ||
| 36 | } | ||
| 37 | |||
| 38 | static void err_inject_exit(void) | ||
| 39 | { | ||
| 40 | unregister_pm_notifier(&pm_notifier_err_inject.nb); | ||
| 41 | debugfs_remove_recursive(dir); | ||
| 42 | } | ||
| 43 | |||
| 44 | module_init(err_inject_init); | ||
| 45 | module_exit(err_inject_exit); | ||
| 46 | |||
| 47 | MODULE_DESCRIPTION("PM notifier error injection module"); | ||
| 48 | MODULE_LICENSE("GPL"); | ||
| 49 | MODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>"); | ||
diff --git a/lib/scatterlist.c b/lib/scatterlist.c index e719adf695bf..fadae774a20c 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c | |||
| @@ -279,14 +279,6 @@ int __sg_alloc_table(struct sg_table *table, unsigned int nents, | |||
| 279 | if (!left) | 279 | if (!left) |
| 280 | sg_mark_end(&sg[sg_size - 1]); | 280 | sg_mark_end(&sg[sg_size - 1]); |
| 281 | 281 | ||
| 282 | /* | ||
| 283 | * only really needed for mempool backed sg allocations (like | ||
| 284 | * SCSI), a possible improvement here would be to pass the | ||
| 285 | * table pointer into the allocator and let that clear these | ||
| 286 | * flags | ||
| 287 | */ | ||
| 288 | gfp_mask &= ~__GFP_WAIT; | ||
| 289 | gfp_mask |= __GFP_HIGH; | ||
| 290 | prv = sg; | 282 | prv = sg; |
| 291 | } while (left); | 283 | } while (left); |
| 292 | 284 | ||
diff --git a/lib/spinlock_debug.c b/lib/spinlock_debug.c index e91fbc23fff1..eb10578ae055 100644 --- a/lib/spinlock_debug.c +++ b/lib/spinlock_debug.c | |||
| @@ -58,7 +58,7 @@ static void spin_dump(raw_spinlock_t *lock, const char *msg) | |||
| 58 | printk(KERN_EMERG "BUG: spinlock %s on CPU#%d, %s/%d\n", | 58 | printk(KERN_EMERG "BUG: spinlock %s on CPU#%d, %s/%d\n", |
| 59 | msg, raw_smp_processor_id(), | 59 | msg, raw_smp_processor_id(), |
| 60 | current->comm, task_pid_nr(current)); | 60 | current->comm, task_pid_nr(current)); |
| 61 | printk(KERN_EMERG " lock: %ps, .magic: %08x, .owner: %s/%d, " | 61 | printk(KERN_EMERG " lock: %pS, .magic: %08x, .owner: %s/%d, " |
| 62 | ".owner_cpu: %d\n", | 62 | ".owner_cpu: %d\n", |
| 63 | lock, lock->magic, | 63 | lock, lock->magic, |
| 64 | owner ? owner->comm : "<none>", | 64 | owner ? owner->comm : "<none>", |
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index c3f36d415bdf..0e337541f005 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
| @@ -655,6 +655,50 @@ char *resource_string(char *buf, char *end, struct resource *res, | |||
| 655 | } | 655 | } |
| 656 | 656 | ||
| 657 | static noinline_for_stack | 657 | static noinline_for_stack |
| 658 | char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec, | ||
| 659 | const char *fmt) | ||
| 660 | { | ||
| 661 | int i, len = 1; /* if we pass '%ph[CDN]', field witdh remains | ||
| 662 | negative value, fallback to the default */ | ||
| 663 | char separator; | ||
| 664 | |||
| 665 | if (spec.field_width == 0) | ||
| 666 | /* nothing to print */ | ||
| 667 | return buf; | ||
| 668 | |||
| 669 | if (ZERO_OR_NULL_PTR(addr)) | ||
| 670 | /* NULL pointer */ | ||
| 671 | return string(buf, end, NULL, spec); | ||
| 672 | |||
| 673 | switch (fmt[1]) { | ||
| 674 | case 'C': | ||
| 675 | separator = ':'; | ||
| 676 | break; | ||
| 677 | case 'D': | ||
| 678 | separator = '-'; | ||
| 679 | break; | ||
| 680 | case 'N': | ||
| 681 | separator = 0; | ||
| 682 | break; | ||
| 683 | default: | ||
| 684 | separator = ' '; | ||
| 685 | break; | ||
| 686 | } | ||
| 687 | |||
| 688 | if (spec.field_width > 0) | ||
| 689 | len = min_t(int, spec.field_width, 64); | ||
| 690 | |||
| 691 | for (i = 0; i < len && buf < end - 1; i++) { | ||
| 692 | buf = hex_byte_pack(buf, addr[i]); | ||
| 693 | |||
| 694 | if (buf < end && separator && i != len - 1) | ||
| 695 | *buf++ = separator; | ||
| 696 | } | ||
| 697 | |||
| 698 | return buf; | ||
| 699 | } | ||
| 700 | |||
| 701 | static noinline_for_stack | ||
| 658 | char *mac_address_string(char *buf, char *end, u8 *addr, | 702 | char *mac_address_string(char *buf, char *end, u8 *addr, |
| 659 | struct printf_spec spec, const char *fmt) | 703 | struct printf_spec spec, const char *fmt) |
| 660 | { | 704 | { |
| @@ -662,15 +706,28 @@ char *mac_address_string(char *buf, char *end, u8 *addr, | |||
| 662 | char *p = mac_addr; | 706 | char *p = mac_addr; |
| 663 | int i; | 707 | int i; |
| 664 | char separator; | 708 | char separator; |
| 709 | bool reversed = false; | ||
| 665 | 710 | ||
| 666 | if (fmt[1] == 'F') { /* FDDI canonical format */ | 711 | switch (fmt[1]) { |
| 712 | case 'F': | ||
| 667 | separator = '-'; | 713 | separator = '-'; |
| 668 | } else { | 714 | break; |
| 715 | |||
| 716 | case 'R': | ||
| 717 | reversed = true; | ||
| 718 | /* fall through */ | ||
| 719 | |||
| 720 | default: | ||
| 669 | separator = ':'; | 721 | separator = ':'; |
| 722 | break; | ||
| 670 | } | 723 | } |
| 671 | 724 | ||
| 672 | for (i = 0; i < 6; i++) { | 725 | for (i = 0; i < 6; i++) { |
| 673 | p = hex_byte_pack(p, addr[i]); | 726 | if (reversed) |
| 727 | p = hex_byte_pack(p, addr[5 - i]); | ||
| 728 | else | ||
| 729 | p = hex_byte_pack(p, addr[i]); | ||
| 730 | |||
| 674 | if (fmt[0] == 'M' && i != 5) | 731 | if (fmt[0] == 'M' && i != 5) |
| 675 | *p++ = separator; | 732 | *p++ = separator; |
| 676 | } | 733 | } |
| @@ -933,6 +990,7 @@ int kptr_restrict __read_mostly; | |||
| 933 | * - 'm' For a 6-byte MAC address, it prints the hex address without colons | 990 | * - 'm' For a 6-byte MAC address, it prints the hex address without colons |
| 934 | * - 'MF' For a 6-byte MAC FDDI address, it prints the address | 991 | * - 'MF' For a 6-byte MAC FDDI address, it prints the address |
| 935 | * with a dash-separated hex notation | 992 | * with a dash-separated hex notation |
| 993 | * - '[mM]R For a 6-byte MAC address, Reverse order (Bluetooth) | ||
| 936 | * - 'I' [46] for IPv4/IPv6 addresses printed in the usual way | 994 | * - 'I' [46] for IPv4/IPv6 addresses printed in the usual way |
| 937 | * IPv4 uses dot-separated decimal without leading 0's (1.2.3.4) | 995 | * IPv4 uses dot-separated decimal without leading 0's (1.2.3.4) |
| 938 | * IPv6 uses colon separated network-order 16 bit hex with leading 0's | 996 | * IPv6 uses colon separated network-order 16 bit hex with leading 0's |
| @@ -960,6 +1018,13 @@ int kptr_restrict __read_mostly; | |||
| 960 | * correctness of the format string and va_list arguments. | 1018 | * correctness of the format string and va_list arguments. |
| 961 | * - 'K' For a kernel pointer that should be hidden from unprivileged users | 1019 | * - 'K' For a kernel pointer that should be hidden from unprivileged users |
| 962 | * - 'NF' For a netdev_features_t | 1020 | * - 'NF' For a netdev_features_t |
| 1021 | * - 'h[CDN]' For a variable-length buffer, it prints it as a hex string with | ||
| 1022 | * a certain separator (' ' by default): | ||
| 1023 | * C colon | ||
| 1024 | * D dash | ||
| 1025 | * N no separator | ||
| 1026 | * The maximum supported length is 64 bytes of the input. Consider | ||
| 1027 | * to use print_hex_dump() for the larger input. | ||
| 963 | * | 1028 | * |
| 964 | * Note: The difference between 'S' and 'F' is that on ia64 and ppc64 | 1029 | * Note: The difference between 'S' and 'F' is that on ia64 and ppc64 |
| 965 | * function pointers are really function descriptors, which contain a | 1030 | * function pointers are really function descriptors, which contain a |
| @@ -993,9 +1058,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, | |||
| 993 | case 'R': | 1058 | case 'R': |
| 994 | case 'r': | 1059 | case 'r': |
| 995 | return resource_string(buf, end, ptr, spec, fmt); | 1060 | return resource_string(buf, end, ptr, spec, fmt); |
| 1061 | case 'h': | ||
| 1062 | return hex_string(buf, end, ptr, spec, fmt); | ||
| 996 | case 'M': /* Colon separated: 00:01:02:03:04:05 */ | 1063 | case 'M': /* Colon separated: 00:01:02:03:04:05 */ |
| 997 | case 'm': /* Contiguous: 000102030405 */ | 1064 | case 'm': /* Contiguous: 000102030405 */ |
| 998 | /* [mM]F (FDDI, bit reversed) */ | 1065 | /* [mM]F (FDDI) */ |
| 1066 | /* [mM]R (Reverse order; Bluetooth) */ | ||
| 999 | return mac_address_string(buf, end, ptr, spec, fmt); | 1067 | return mac_address_string(buf, end, ptr, spec, fmt); |
| 1000 | case 'I': /* Formatted IP supported | 1068 | case 'I': /* Formatted IP supported |
| 1001 | * 4: 1.2.3.4 | 1069 | * 4: 1.2.3.4 |
| @@ -1030,7 +1098,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, | |||
| 1030 | * %pK cannot be used in IRQ context because its test | 1098 | * %pK cannot be used in IRQ context because its test |
| 1031 | * for CAP_SYSLOG would be meaningless. | 1099 | * for CAP_SYSLOG would be meaningless. |
| 1032 | */ | 1100 | */ |
| 1033 | if (in_irq() || in_serving_softirq() || in_nmi()) { | 1101 | if (kptr_restrict && (in_irq() || in_serving_softirq() || |
| 1102 | in_nmi())) { | ||
| 1034 | if (spec.field_width == -1) | 1103 | if (spec.field_width == -1) |
| 1035 | spec.field_width = default_width; | 1104 | spec.field_width = default_width; |
| 1036 | return string(buf, end, "pK-error", spec); | 1105 | return string(buf, end, "pK-error", spec); |
| @@ -1280,8 +1349,12 @@ qualifier: | |||
| 1280 | * %pI6c print an IPv6 address as specified by RFC 5952 | 1349 | * %pI6c print an IPv6 address as specified by RFC 5952 |
| 1281 | * %pU[bBlL] print a UUID/GUID in big or little endian using lower or upper | 1350 | * %pU[bBlL] print a UUID/GUID in big or little endian using lower or upper |
| 1282 | * case. | 1351 | * case. |
| 1352 | * %*ph[CDN] a variable-length hex string with a separator (supports up to 64 | ||
| 1353 | * bytes of the input) | ||
| 1283 | * %n is ignored | 1354 | * %n is ignored |
| 1284 | * | 1355 | * |
| 1356 | * ** Please update Documentation/printk-formats.txt when making changes ** | ||
| 1357 | * | ||
| 1285 | * The return value is the number of characters which would | 1358 | * The return value is the number of characters which would |
| 1286 | * be generated for the given input, excluding the trailing | 1359 | * be generated for the given input, excluding the trailing |
| 1287 | * '\0', as per ISO C99. If you want to have the exact | 1360 | * '\0', as per ISO C99. If you want to have the exact |
diff --git a/mm/memory-failure.c b/mm/memory-failure.c index de4ce7058450..6de0d613bbe6 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c | |||
| @@ -1433,8 +1433,8 @@ static int soft_offline_huge_page(struct page *page, int flags) | |||
| 1433 | /* Keep page count to indicate a given hugepage is isolated. */ | 1433 | /* Keep page count to indicate a given hugepage is isolated. */ |
| 1434 | 1434 | ||
| 1435 | list_add(&hpage->lru, &pagelist); | 1435 | list_add(&hpage->lru, &pagelist); |
| 1436 | ret = migrate_huge_pages(&pagelist, new_page, MPOL_MF_MOVE_ALL, 0, | 1436 | ret = migrate_huge_pages(&pagelist, new_page, MPOL_MF_MOVE_ALL, false, |
| 1437 | true); | 1437 | MIGRATE_SYNC); |
| 1438 | if (ret) { | 1438 | if (ret) { |
| 1439 | struct page *page1, *page2; | 1439 | struct page *page1, *page2; |
| 1440 | list_for_each_entry_safe(page1, page2, &pagelist, lru) | 1440 | list_for_each_entry_safe(page1, page2, &pagelist, lru) |
| @@ -1563,7 +1563,7 @@ int soft_offline_page(struct page *page, int flags) | |||
| 1563 | page_is_file_cache(page)); | 1563 | page_is_file_cache(page)); |
| 1564 | list_add(&page->lru, &pagelist); | 1564 | list_add(&page->lru, &pagelist); |
| 1565 | ret = migrate_pages(&pagelist, new_page, MPOL_MF_MOVE_ALL, | 1565 | ret = migrate_pages(&pagelist, new_page, MPOL_MF_MOVE_ALL, |
| 1566 | 0, MIGRATE_SYNC); | 1566 | false, MIGRATE_SYNC); |
| 1567 | if (ret) { | 1567 | if (ret) { |
| 1568 | putback_lru_pages(&pagelist); | 1568 | putback_lru_pages(&pagelist); |
| 1569 | pr_info("soft offline: %#lx: migration failed %d, type %lx\n", | 1569 | pr_info("soft offline: %#lx: migration failed %d, type %lx\n", |
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index e5bd60ff48e3..913d6bdfdda3 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -1600,13 +1600,17 @@ sub process { | |||
| 1600 | 1600 | ||
| 1601 | # Check signature styles | 1601 | # Check signature styles |
| 1602 | if (!$in_header_lines && | 1602 | if (!$in_header_lines && |
| 1603 | $line =~ /^(\s*)($signature_tags)(\s*)(.*)/) { | 1603 | $line =~ /^(\s*)([a-z0-9_-]+by:|$signature_tags)(\s*)(.*)/i) { |
| 1604 | my $space_before = $1; | 1604 | my $space_before = $1; |
| 1605 | my $sign_off = $2; | 1605 | my $sign_off = $2; |
| 1606 | my $space_after = $3; | 1606 | my $space_after = $3; |
| 1607 | my $email = $4; | 1607 | my $email = $4; |
| 1608 | my $ucfirst_sign_off = ucfirst(lc($sign_off)); | 1608 | my $ucfirst_sign_off = ucfirst(lc($sign_off)); |
| 1609 | 1609 | ||
| 1610 | if ($sign_off !~ /$signature_tags/) { | ||
| 1611 | WARN("BAD_SIGN_OFF", | ||
| 1612 | "Non-standard signature: $sign_off\n" . $herecurr); | ||
| 1613 | } | ||
| 1610 | if (defined $space_before && $space_before ne "") { | 1614 | if (defined $space_before && $space_before ne "") { |
| 1611 | WARN("BAD_SIGN_OFF", | 1615 | WARN("BAD_SIGN_OFF", |
| 1612 | "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr); | 1616 | "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr); |
| @@ -1848,8 +1852,8 @@ sub process { | |||
| 1848 | 1852 | ||
| 1849 | my $pos = pos_last_openparen($rest); | 1853 | my $pos = pos_last_openparen($rest); |
| 1850 | if ($pos >= 0) { | 1854 | if ($pos >= 0) { |
| 1851 | $line =~ /^\+([ \t]*)/; | 1855 | $line =~ /^(\+| )([ \t]*)/; |
| 1852 | my $newindent = $1; | 1856 | my $newindent = $2; |
| 1853 | 1857 | ||
| 1854 | my $goodtabindent = $oldindent . | 1858 | my $goodtabindent = $oldindent . |
| 1855 | "\t" x ($pos / 8) . | 1859 | "\t" x ($pos / 8) . |
| @@ -2984,6 +2988,45 @@ sub process { | |||
| 2984 | } | 2988 | } |
| 2985 | } | 2989 | } |
| 2986 | 2990 | ||
| 2991 | # do {} while (0) macro tests: | ||
| 2992 | # single-statement macros do not need to be enclosed in do while (0) loop, | ||
| 2993 | # macro should not end with a semicolon | ||
| 2994 | if ($^V && $^V ge 5.10.0 && | ||
| 2995 | $realfile !~ m@/vmlinux.lds.h$@ && | ||
| 2996 | $line =~ /^.\s*\#\s*define\s+$Ident(\()?/) { | ||
| 2997 | my $ln = $linenr; | ||
| 2998 | my $cnt = $realcnt; | ||
| 2999 | my ($off, $dstat, $dcond, $rest); | ||
| 3000 | my $ctx = ''; | ||
| 3001 | ($dstat, $dcond, $ln, $cnt, $off) = | ||
| 3002 | ctx_statement_block($linenr, $realcnt, 0); | ||
| 3003 | $ctx = $dstat; | ||
| 3004 | |||
| 3005 | $dstat =~ s/\\\n.//g; | ||
| 3006 | |||
| 3007 | if ($dstat =~ /^\+\s*#\s*define\s+$Ident\s*${balanced_parens}\s*do\s*{(.*)\s*}\s*while\s*\(\s*0\s*\)\s*([;\s]*)\s*$/) { | ||
| 3008 | my $stmts = $2; | ||
| 3009 | my $semis = $3; | ||
| 3010 | |||
| 3011 | $ctx =~ s/\n*$//; | ||
| 3012 | my $cnt = statement_rawlines($ctx); | ||
| 3013 | my $herectx = $here . "\n"; | ||
| 3014 | |||
| 3015 | for (my $n = 0; $n < $cnt; $n++) { | ||
| 3016 | $herectx .= raw_line($linenr, $n) . "\n"; | ||
| 3017 | } | ||
| 3018 | |||
| 3019 | if (($stmts =~ tr/;/;/) == 1) { | ||
| 3020 | WARN("SINGLE_STATEMENT_DO_WHILE_MACRO", | ||
| 3021 | "Single statement macros should not use a do {} while (0) loop\n" . "$herectx"); | ||
| 3022 | } | ||
| 3023 | if (defined $semis && $semis ne "") { | ||
| 3024 | WARN("DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON", | ||
| 3025 | "do {} while (0) macros should not be semicolon terminated\n" . "$herectx"); | ||
| 3026 | } | ||
| 3027 | } | ||
| 3028 | } | ||
| 3029 | |||
| 2987 | # make sure symbols are always wrapped with VMLINUX_SYMBOL() ... | 3030 | # make sure symbols are always wrapped with VMLINUX_SYMBOL() ... |
| 2988 | # all assignments may have only one of the following with an assignment: | 3031 | # all assignments may have only one of the following with an assignment: |
| 2989 | # . | 3032 | # . |
| @@ -3261,6 +3304,12 @@ sub process { | |||
| 3261 | "sizeof(& should be avoided\n" . $herecurr); | 3304 | "sizeof(& should be avoided\n" . $herecurr); |
| 3262 | } | 3305 | } |
| 3263 | 3306 | ||
| 3307 | # check for sizeof without parenthesis | ||
| 3308 | if ($line =~ /\bsizeof\s+((?:\*\s*|)$Lval|$Type(?:\s+$Lval|))/) { | ||
| 3309 | WARN("SIZEOF_PARENTHESIS", | ||
| 3310 | "sizeof $1 should be sizeof($1)\n" . $herecurr); | ||
| 3311 | } | ||
| 3312 | |||
| 3264 | # check for line continuations in quoted strings with odd counts of " | 3313 | # check for line continuations in quoted strings with odd counts of " |
| 3265 | if ($rawline =~ /\\$/ && $rawline =~ tr/"/"/ % 2) { | 3314 | if ($rawline =~ /\\$/ && $rawline =~ tr/"/"/ % 2) { |
| 3266 | WARN("LINE_CONTINUATIONS", | 3315 | WARN("LINE_CONTINUATIONS", |
| @@ -3309,6 +3358,22 @@ sub process { | |||
| 3309 | } | 3358 | } |
| 3310 | } | 3359 | } |
| 3311 | 3360 | ||
| 3361 | # check usleep_range arguments | ||
| 3362 | if ($^V && $^V ge 5.10.0 && | ||
| 3363 | defined $stat && | ||
| 3364 | $stat =~ /^\+(?:.*?)\busleep_range\s*\(\s*($FuncArg)\s*,\s*($FuncArg)\s*\)/) { | ||
| 3365 | my $min = $1; | ||
| 3366 | my $max = $7; | ||
| 3367 | if ($min eq $max) { | ||
| 3368 | WARN("USLEEP_RANGE", | ||
| 3369 | "usleep_range should not use min == max args; see Documentation/timers/timers-howto.txt\n" . "$here\n$stat\n"); | ||
| 3370 | } elsif ($min =~ /^\d+$/ && $max =~ /^\d+$/ && | ||
| 3371 | $min > $max) { | ||
| 3372 | WARN("USLEEP_RANGE", | ||
| 3373 | "usleep_range args reversed, use min then max; see Documentation/timers/timers-howto.txt\n" . "$here\n$stat\n"); | ||
| 3374 | } | ||
| 3375 | } | ||
| 3376 | |||
| 3312 | # check for new externs in .c files. | 3377 | # check for new externs in .c files. |
| 3313 | if ($realfile =~ /\.c$/ && defined $stat && | 3378 | if ($realfile =~ /\.c$/ && defined $stat && |
| 3314 | $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) | 3379 | $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) |
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 79690f401a58..6c77f63c7591 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
| @@ -3185,6 +3185,7 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd, | |||
| 3185 | case F_GETFL: | 3185 | case F_GETFL: |
| 3186 | case F_GETOWN: | 3186 | case F_GETOWN: |
| 3187 | case F_GETSIG: | 3187 | case F_GETSIG: |
| 3188 | case F_GETOWNER_UIDS: | ||
| 3188 | /* Just check FD__USE permission */ | 3189 | /* Just check FD__USE permission */ |
| 3189 | err = file_has_perm(cred, file, 0); | 3190 | err = file_has_perm(cred, file, 0); |
| 3190 | break; | 3191 | break; |
diff --git a/sound/core/misc.c b/sound/core/misc.c index 768167925409..30e027ecf4da 100644 --- a/sound/core/misc.c +++ b/sound/core/misc.c | |||
| @@ -68,6 +68,7 @@ void __snd_printk(unsigned int level, const char *path, int line, | |||
| 68 | { | 68 | { |
| 69 | va_list args; | 69 | va_list args; |
| 70 | #ifdef CONFIG_SND_VERBOSE_PRINTK | 70 | #ifdef CONFIG_SND_VERBOSE_PRINTK |
| 71 | int kern_level; | ||
| 71 | struct va_format vaf; | 72 | struct va_format vaf; |
| 72 | char verbose_fmt[] = KERN_DEFAULT "ALSA %s:%d %pV"; | 73 | char verbose_fmt[] = KERN_DEFAULT "ALSA %s:%d %pV"; |
| 73 | #endif | 74 | #endif |
| @@ -81,12 +82,16 @@ void __snd_printk(unsigned int level, const char *path, int line, | |||
| 81 | #ifdef CONFIG_SND_VERBOSE_PRINTK | 82 | #ifdef CONFIG_SND_VERBOSE_PRINTK |
| 82 | vaf.fmt = format; | 83 | vaf.fmt = format; |
| 83 | vaf.va = &args; | 84 | vaf.va = &args; |
| 84 | if (format[0] == '<' && format[2] == '>') { | 85 | |
| 85 | memcpy(verbose_fmt, format, 3); | 86 | kern_level = printk_get_level(format); |
| 86 | vaf.fmt = format + 3; | 87 | if (kern_level) { |
| 88 | const char *end_of_header = printk_skip_level(format); | ||
| 89 | memcpy(verbose_fmt, format, end_of_header - format); | ||
| 90 | vaf.fmt = end_of_header; | ||
| 87 | } else if (level) | 91 | } else if (level) |
| 88 | memcpy(verbose_fmt, KERN_DEBUG, 3); | 92 | memcpy(verbose_fmt, KERN_DEBUG, sizeof(KERN_DEBUG) - 1); |
| 89 | printk(verbose_fmt, sanity_file_name(path), line, &vaf); | 93 | printk(verbose_fmt, sanity_file_name(path), line, &vaf); |
| 94 | |||
| 90 | #else | 95 | #else |
| 91 | vprintk(format, args); | 96 | vprintk(format, args); |
| 92 | #endif | 97 | #endif |
diff --git a/tools/testing/fault-injection/failcmd.sh b/tools/testing/fault-injection/failcmd.sh new file mode 100644 index 000000000000..1776e924b202 --- /dev/null +++ b/tools/testing/fault-injection/failcmd.sh | |||
| @@ -0,0 +1,219 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # NAME | ||
| 4 | # failcmd.sh - run a command with injecting slab/page allocation failures | ||
| 5 | # | ||
| 6 | # SYNOPSIS | ||
| 7 | # failcmd.sh --help | ||
| 8 | # failcmd.sh [<options>] command [arguments] | ||
| 9 | # | ||
| 10 | # DESCRIPTION | ||
| 11 | # Run command with injecting slab/page allocation failures by fault | ||
| 12 | # injection. | ||
| 13 | # | ||
| 14 | # NOTE: you need to run this script as root. | ||
| 15 | # | ||
| 16 | |||
| 17 | usage() | ||
| 18 | { | ||
| 19 | cat >&2 <<EOF | ||
| 20 | Usage: $0 [options] command [arguments] | ||
| 21 | |||
| 22 | OPTIONS | ||
| 23 | -p percent | ||
| 24 | --probability=percent | ||
| 25 | likelihood of failure injection, in percent. | ||
| 26 | Default value is 1 | ||
| 27 | |||
| 28 | -t value | ||
| 29 | --times=value | ||
| 30 | specifies how many times failures may happen at most. | ||
| 31 | Default value is 1 | ||
| 32 | |||
| 33 | --oom-kill-allocating-task=value | ||
| 34 | set /proc/sys/vm/oom_kill_allocating_task to specified value | ||
| 35 | before running the command. | ||
| 36 | Default value is 1 | ||
| 37 | |||
| 38 | -h, --help | ||
| 39 | Display a usage message and exit | ||
| 40 | |||
| 41 | --interval=value, --space=value, --verbose=value, --task-filter=value, | ||
| 42 | --stacktrace-depth=value, --require-start=value, --require-end=value, | ||
| 43 | --reject-start=value, --reject-end=value, --ignore-gfp-wait=value | ||
| 44 | See Documentation/fault-injection/fault-injection.txt for more | ||
| 45 | information | ||
| 46 | |||
| 47 | failslab options: | ||
| 48 | --cache-filter=value | ||
| 49 | |||
| 50 | fail_page_alloc options: | ||
| 51 | --ignore-gfp-highmem=value, --min-order=value | ||
| 52 | |||
| 53 | ENVIRONMENT | ||
| 54 | FAILCMD_TYPE | ||
| 55 | The following values for FAILCMD_TYPE are recognized: | ||
| 56 | |||
| 57 | failslab | ||
| 58 | inject slab allocation failures | ||
| 59 | fail_page_alloc | ||
| 60 | inject page allocation failures | ||
| 61 | |||
| 62 | If FAILCMD_TYPE is not defined, then failslab is used. | ||
| 63 | EOF | ||
| 64 | } | ||
| 65 | |||
| 66 | if [ $UID != 0 ]; then | ||
| 67 | echo must be run as root >&2 | ||
| 68 | exit 1 | ||
| 69 | fi | ||
| 70 | |||
| 71 | DEBUGFS=`mount -t debugfs | head -1 | awk '{ print $3}'` | ||
| 72 | |||
| 73 | if [ ! -d "$DEBUGFS" ]; then | ||
| 74 | echo debugfs is not mounted >&2 | ||
| 75 | exit 1 | ||
| 76 | fi | ||
| 77 | |||
| 78 | FAILCMD_TYPE=${FAILCMD_TYPE:-failslab} | ||
| 79 | FAULTATTR=$DEBUGFS/$FAILCMD_TYPE | ||
| 80 | |||
| 81 | if [ ! -d $FAULTATTR ]; then | ||
| 82 | echo $FAILCMD_TYPE is not available >&2 | ||
| 83 | exit 1 | ||
| 84 | fi | ||
| 85 | |||
| 86 | LONGOPTS=probability:,interval:,times:,space:,verbose:,task-filter: | ||
| 87 | LONGOPTS=$LONGOPTS,stacktrace-depth:,require-start:,require-end: | ||
| 88 | LONGOPTS=$LONGOPTS,reject-start:,reject-end:,oom-kill-allocating-task:,help | ||
| 89 | |||
| 90 | if [ $FAILCMD_TYPE = failslab ]; then | ||
| 91 | LONGOPTS=$LONGOPTS,ignore-gfp-wait:,cache-filter: | ||
| 92 | elif [ $FAILCMD_TYPE = fail_page_alloc ]; then | ||
| 93 | LONGOPTS=$LONGOPTS,ignore-gfp-wait:,ignore-gfp-highmem:,min-order: | ||
| 94 | fi | ||
| 95 | |||
| 96 | TEMP=`getopt -o p:i:t:s:v:h --long $LONGOPTS -n 'failcmd.sh' -- "$@"` | ||
| 97 | |||
| 98 | if [ $? != 0 ]; then | ||
| 99 | usage | ||
| 100 | exit 1 | ||
| 101 | fi | ||
| 102 | |||
| 103 | eval set -- "$TEMP" | ||
| 104 | |||
| 105 | fault_attr_default() | ||
| 106 | { | ||
| 107 | echo N > $FAULTATTR/task-filter | ||
| 108 | echo 0 > $FAULTATTR/probability | ||
| 109 | echo 1 > $FAULTATTR/times | ||
| 110 | } | ||
| 111 | |||
| 112 | fault_attr_default | ||
| 113 | |||
| 114 | oom_kill_allocating_task_saved=`cat /proc/sys/vm/oom_kill_allocating_task` | ||
| 115 | |||
| 116 | restore_values() | ||
| 117 | { | ||
| 118 | fault_attr_default | ||
| 119 | echo $oom_kill_allocating_task_saved \ | ||
| 120 | > /proc/sys/vm/oom_kill_allocating_task | ||
| 121 | } | ||
| 122 | |||
| 123 | # | ||
| 124 | # Default options | ||
| 125 | # | ||
| 126 | declare -i oom_kill_allocating_task=1 | ||
| 127 | declare task_filter=Y | ||
| 128 | declare -i probability=1 | ||
| 129 | declare -i times=1 | ||
| 130 | |||
| 131 | while true; do | ||
| 132 | case "$1" in | ||
| 133 | -p|--probability) | ||
| 134 | probability=$2 | ||
| 135 | shift 2 | ||
| 136 | ;; | ||
| 137 | -i|--interval) | ||
| 138 | echo $2 > $FAULTATTR/interval | ||
| 139 | shift 2 | ||
| 140 | ;; | ||
| 141 | -t|--times) | ||
| 142 | times=$2 | ||
| 143 | shift 2 | ||
| 144 | ;; | ||
| 145 | -s|--space) | ||
| 146 | echo $2 > $FAULTATTR/space | ||
| 147 | shift 2 | ||
| 148 | ;; | ||
| 149 | -v|--verbose) | ||
| 150 | echo $2 > $FAULTATTR/verbose | ||
| 151 | shift 2 | ||
| 152 | ;; | ||
| 153 | --task-filter) | ||
| 154 | task_filter=$2 | ||
| 155 | shift 2 | ||
| 156 | ;; | ||
| 157 | --stacktrace-depth) | ||
| 158 | echo $2 > $FAULTATTR/stacktrace-depth | ||
| 159 | shift 2 | ||
| 160 | ;; | ||
| 161 | --require-start) | ||
| 162 | echo $2 > $FAULTATTR/require-start | ||
| 163 | shift 2 | ||
| 164 | ;; | ||
| 165 | --require-end) | ||
| 166 | echo $2 > $FAULTATTR/require-end | ||
| 167 | shift 2 | ||
| 168 | ;; | ||
| 169 | --reject-start) | ||
| 170 | echo $2 > $FAULTATTR/reject-start | ||
| 171 | shift 2 | ||
| 172 | ;; | ||
| 173 | --reject-end) | ||
| 174 | echo $2 > $FAULTATTR/reject-end | ||
| 175 | shift 2 | ||
| 176 | ;; | ||
| 177 | --oom-kill-allocating-task) | ||
| 178 | oom_kill_allocating_task=$2 | ||
| 179 | shift 2 | ||
| 180 | ;; | ||
| 181 | --ignore-gfp-wait) | ||
| 182 | echo $2 > $FAULTATTR/ignore-gfp-wait | ||
| 183 | shift 2 | ||
| 184 | ;; | ||
| 185 | --cache-filter) | ||
| 186 | echo $2 > $FAULTATTR/cache_filter | ||
| 187 | shift 2 | ||
| 188 | ;; | ||
| 189 | --ignore-gfp-highmem) | ||
| 190 | echo $2 > $FAULTATTR/ignore-gfp-highmem | ||
| 191 | shift 2 | ||
| 192 | ;; | ||
| 193 | --min-order) | ||
| 194 | echo $2 > $FAULTATTR/min-order | ||
| 195 | shift 2 | ||
| 196 | ;; | ||
| 197 | -h|--help) | ||
| 198 | usage | ||
| 199 | exit 0 | ||
| 200 | shift | ||
| 201 | ;; | ||
| 202 | --) | ||
| 203 | shift | ||
| 204 | break | ||
| 205 | ;; | ||
| 206 | esac | ||
| 207 | done | ||
| 208 | |||
| 209 | [ -z "$@" ] && exit 0 | ||
| 210 | |||
| 211 | echo $oom_kill_allocating_task > /proc/sys/vm/oom_kill_allocating_task | ||
| 212 | echo $task_filter > $FAULTATTR/task-filter | ||
| 213 | echo $probability > $FAULTATTR/probability | ||
| 214 | echo $times > $FAULTATTR/times | ||
| 215 | |||
| 216 | trap "restore_values" SIGINT SIGTERM EXIT | ||
| 217 | |||
| 218 | cmd="echo 1 > /proc/self/make-it-fail && exec $@" | ||
| 219 | bash -c "$cmd" | ||
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index a4162e15c25f..85baf11e2acd 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | TARGETS = breakpoints kcmp mqueue vm | 1 | TARGETS = breakpoints kcmp mqueue vm cpu-hotplug memory-hotplug |
| 2 | 2 | ||
| 3 | all: | 3 | all: |
| 4 | for TARGET in $(TARGETS); do \ | 4 | for TARGET in $(TARGETS); do \ |
diff --git a/tools/testing/selftests/cpu-hotplug/Makefile b/tools/testing/selftests/cpu-hotplug/Makefile new file mode 100644 index 000000000000..7c9c20ff578a --- /dev/null +++ b/tools/testing/selftests/cpu-hotplug/Makefile | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | all: | ||
| 2 | |||
| 3 | run_tests: | ||
| 4 | ./on-off-test.sh | ||
| 5 | |||
| 6 | clean: | ||
diff --git a/tools/testing/selftests/cpu-hotplug/on-off-test.sh b/tools/testing/selftests/cpu-hotplug/on-off-test.sh new file mode 100644 index 000000000000..bdde7cf428bb --- /dev/null +++ b/tools/testing/selftests/cpu-hotplug/on-off-test.sh | |||
| @@ -0,0 +1,221 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | SYSFS= | ||
| 4 | |||
| 5 | prerequisite() | ||
| 6 | { | ||
| 7 | msg="skip all tests:" | ||
| 8 | |||
| 9 | if [ $UID != 0 ]; then | ||
| 10 | echo $msg must be run as root >&2 | ||
| 11 | exit 0 | ||
| 12 | fi | ||
| 13 | |||
| 14 | SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'` | ||
| 15 | |||
| 16 | if [ ! -d "$SYSFS" ]; then | ||
| 17 | echo $msg sysfs is not mounted >&2 | ||
| 18 | exit 0 | ||
| 19 | fi | ||
| 20 | |||
| 21 | if ! ls $SYSFS/devices/system/cpu/cpu* > /dev/null 2>&1; then | ||
| 22 | echo $msg cpu hotplug is not supported >&2 | ||
| 23 | exit 0 | ||
| 24 | fi | ||
| 25 | } | ||
| 26 | |||
| 27 | # | ||
| 28 | # list all hot-pluggable CPUs | ||
| 29 | # | ||
| 30 | hotpluggable_cpus() | ||
| 31 | { | ||
| 32 | local state=${1:-.\*} | ||
| 33 | |||
| 34 | for cpu in $SYSFS/devices/system/cpu/cpu*; do | ||
| 35 | if [ -f $cpu/online ] && grep -q $state $cpu/online; then | ||
| 36 | echo ${cpu##/*/cpu} | ||
| 37 | fi | ||
| 38 | done | ||
| 39 | } | ||
| 40 | |||
| 41 | hotplaggable_offline_cpus() | ||
| 42 | { | ||
| 43 | hotpluggable_cpus 0 | ||
| 44 | } | ||
| 45 | |||
| 46 | hotpluggable_online_cpus() | ||
| 47 | { | ||
| 48 | hotpluggable_cpus 1 | ||
| 49 | } | ||
| 50 | |||
| 51 | cpu_is_online() | ||
| 52 | { | ||
| 53 | grep -q 1 $SYSFS/devices/system/cpu/cpu$1/online | ||
| 54 | } | ||
| 55 | |||
| 56 | cpu_is_offline() | ||
| 57 | { | ||
| 58 | grep -q 0 $SYSFS/devices/system/cpu/cpu$1/online | ||
| 59 | } | ||
| 60 | |||
| 61 | online_cpu() | ||
| 62 | { | ||
| 63 | echo 1 > $SYSFS/devices/system/cpu/cpu$1/online | ||
| 64 | } | ||
| 65 | |||
| 66 | offline_cpu() | ||
| 67 | { | ||
| 68 | echo 0 > $SYSFS/devices/system/cpu/cpu$1/online | ||
| 69 | } | ||
| 70 | |||
| 71 | online_cpu_expect_success() | ||
| 72 | { | ||
| 73 | local cpu=$1 | ||
| 74 | |||
| 75 | if ! online_cpu $cpu; then | ||
| 76 | echo $FUNCNAME $cpu: unexpected fail >&2 | ||
| 77 | elif ! cpu_is_online $cpu; then | ||
| 78 | echo $FUNCNAME $cpu: unexpected offline >&2 | ||
| 79 | fi | ||
| 80 | } | ||
| 81 | |||
| 82 | online_cpu_expect_fail() | ||
| 83 | { | ||
| 84 | local cpu=$1 | ||
| 85 | |||
| 86 | if online_cpu $cpu 2> /dev/null; then | ||
| 87 | echo $FUNCNAME $cpu: unexpected success >&2 | ||
| 88 | elif ! cpu_is_offline $cpu; then | ||
| 89 | echo $FUNCNAME $cpu: unexpected online >&2 | ||
| 90 | fi | ||
| 91 | } | ||
| 92 | |||
| 93 | offline_cpu_expect_success() | ||
| 94 | { | ||
| 95 | local cpu=$1 | ||
| 96 | |||
| 97 | if ! offline_cpu $cpu; then | ||
| 98 | echo $FUNCNAME $cpu: unexpected fail >&2 | ||
| 99 | elif ! cpu_is_offline $cpu; then | ||
| 100 | echo $FUNCNAME $cpu: unexpected offline >&2 | ||
| 101 | fi | ||
| 102 | } | ||
| 103 | |||
| 104 | offline_cpu_expect_fail() | ||
| 105 | { | ||
| 106 | local cpu=$1 | ||
| 107 | |||
| 108 | if offline_cpu $cpu 2> /dev/null; then | ||
| 109 | echo $FUNCNAME $cpu: unexpected success >&2 | ||
| 110 | elif ! cpu_is_online $cpu; then | ||
| 111 | echo $FUNCNAME $cpu: unexpected offline >&2 | ||
| 112 | fi | ||
| 113 | } | ||
| 114 | |||
| 115 | error=-12 | ||
| 116 | priority=0 | ||
| 117 | |||
| 118 | while getopts e:hp: opt; do | ||
| 119 | case $opt in | ||
| 120 | e) | ||
| 121 | error=$OPTARG | ||
| 122 | ;; | ||
| 123 | h) | ||
| 124 | echo "Usage $0 [ -e errno ] [ -p notifier-priority ]" | ||
| 125 | exit | ||
| 126 | ;; | ||
| 127 | p) | ||
| 128 | priority=$OPTARG | ||
| 129 | ;; | ||
| 130 | esac | ||
| 131 | done | ||
| 132 | |||
| 133 | if ! [ "$error" -ge -4095 -a "$error" -lt 0 ]; then | ||
| 134 | echo "error code must be -4095 <= errno < 0" >&2 | ||
| 135 | exit 1 | ||
| 136 | fi | ||
| 137 | |||
| 138 | prerequisite | ||
| 139 | |||
| 140 | # | ||
| 141 | # Online all hot-pluggable CPUs | ||
| 142 | # | ||
| 143 | for cpu in `hotplaggable_offline_cpus`; do | ||
| 144 | online_cpu_expect_success $cpu | ||
| 145 | done | ||
| 146 | |||
| 147 | # | ||
| 148 | # Offline all hot-pluggable CPUs | ||
| 149 | # | ||
| 150 | for cpu in `hotpluggable_online_cpus`; do | ||
| 151 | offline_cpu_expect_success $cpu | ||
| 152 | done | ||
| 153 | |||
| 154 | # | ||
| 155 | # Online all hot-pluggable CPUs again | ||
| 156 | # | ||
| 157 | for cpu in `hotplaggable_offline_cpus`; do | ||
| 158 | online_cpu_expect_success $cpu | ||
| 159 | done | ||
| 160 | |||
| 161 | # | ||
| 162 | # Test with cpu notifier error injection | ||
| 163 | # | ||
| 164 | |||
| 165 | DEBUGFS=`mount -t debugfs | head -1 | awk '{ print $3 }'` | ||
| 166 | NOTIFIER_ERR_INJECT_DIR=$DEBUGFS/notifier-error-inject/cpu | ||
| 167 | |||
| 168 | prerequisite_extra() | ||
| 169 | { | ||
| 170 | msg="skip extra tests:" | ||
| 171 | |||
| 172 | /sbin/modprobe -q -r cpu-notifier-error-inject | ||
| 173 | /sbin/modprobe -q cpu-notifier-error-inject priority=$priority | ||
| 174 | |||
| 175 | if [ ! -d "$DEBUGFS" ]; then | ||
| 176 | echo $msg debugfs is not mounted >&2 | ||
| 177 | exit 0 | ||
| 178 | fi | ||
| 179 | |||
| 180 | if [ ! -d $NOTIFIER_ERR_INJECT_DIR ]; then | ||
| 181 | echo $msg cpu-notifier-error-inject module is not available >&2 | ||
| 182 | exit 0 | ||
| 183 | fi | ||
| 184 | } | ||
| 185 | |||
| 186 | prerequisite_extra | ||
| 187 | |||
| 188 | # | ||
| 189 | # Offline all hot-pluggable CPUs | ||
| 190 | # | ||
| 191 | echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_DOWN_PREPARE/error | ||
| 192 | for cpu in `hotpluggable_online_cpus`; do | ||
| 193 | offline_cpu_expect_success $cpu | ||
| 194 | done | ||
| 195 | |||
| 196 | # | ||
| 197 | # Test CPU hot-add error handling (offline => online) | ||
| 198 | # | ||
| 199 | echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_UP_PREPARE/error | ||
| 200 | for cpu in `hotplaggable_offline_cpus`; do | ||
| 201 | online_cpu_expect_fail $cpu | ||
| 202 | done | ||
| 203 | |||
| 204 | # | ||
| 205 | # Online all hot-pluggable CPUs | ||
| 206 | # | ||
| 207 | echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_UP_PREPARE/error | ||
| 208 | for cpu in `hotplaggable_offline_cpus`; do | ||
| 209 | online_cpu_expect_success $cpu | ||
| 210 | done | ||
| 211 | |||
| 212 | # | ||
| 213 | # Test CPU hot-remove error handling (online => offline) | ||
| 214 | # | ||
| 215 | echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_DOWN_PREPARE/error | ||
| 216 | for cpu in `hotpluggable_online_cpus`; do | ||
| 217 | offline_cpu_expect_fail $cpu | ||
| 218 | done | ||
| 219 | |||
| 220 | echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_DOWN_PREPARE/error | ||
| 221 | /sbin/modprobe -q -r cpu-notifier-error-inject | ||
diff --git a/tools/testing/selftests/memory-hotplug/Makefile b/tools/testing/selftests/memory-hotplug/Makefile new file mode 100644 index 000000000000..7c9c20ff578a --- /dev/null +++ b/tools/testing/selftests/memory-hotplug/Makefile | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | all: | ||
| 2 | |||
| 3 | run_tests: | ||
| 4 | ./on-off-test.sh | ||
| 5 | |||
| 6 | clean: | ||
diff --git a/tools/testing/selftests/memory-hotplug/on-off-test.sh b/tools/testing/selftests/memory-hotplug/on-off-test.sh new file mode 100644 index 000000000000..a2816f631542 --- /dev/null +++ b/tools/testing/selftests/memory-hotplug/on-off-test.sh | |||
| @@ -0,0 +1,230 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | SYSFS= | ||
| 4 | |||
| 5 | prerequisite() | ||
| 6 | { | ||
| 7 | msg="skip all tests:" | ||
| 8 | |||
| 9 | if [ $UID != 0 ]; then | ||
| 10 | echo $msg must be run as root >&2 | ||
| 11 | exit 0 | ||
| 12 | fi | ||
| 13 | |||
| 14 | SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'` | ||
| 15 | |||
| 16 | if [ ! -d "$SYSFS" ]; then | ||
| 17 | echo $msg sysfs is not mounted >&2 | ||
| 18 | exit 0 | ||
| 19 | fi | ||
| 20 | |||
| 21 | if ! ls $SYSFS/devices/system/memory/memory* > /dev/null 2>&1; then | ||
| 22 | echo $msg memory hotplug is not supported >&2 | ||
| 23 | exit 0 | ||
| 24 | fi | ||
| 25 | } | ||
| 26 | |||
| 27 | # | ||
| 28 | # list all hot-pluggable memory | ||
| 29 | # | ||
| 30 | hotpluggable_memory() | ||
| 31 | { | ||
| 32 | local state=${1:-.\*} | ||
| 33 | |||
| 34 | for memory in $SYSFS/devices/system/memory/memory*; do | ||
| 35 | if grep -q 1 $memory/removable && | ||
| 36 | grep -q $state $memory/state; then | ||
| 37 | echo ${memory##/*/memory} | ||
| 38 | fi | ||
| 39 | done | ||
| 40 | } | ||
| 41 | |||
| 42 | hotplaggable_offline_memory() | ||
| 43 | { | ||
| 44 | hotpluggable_memory offline | ||
| 45 | } | ||
| 46 | |||
| 47 | hotpluggable_online_memory() | ||
| 48 | { | ||
| 49 | hotpluggable_memory online | ||
| 50 | } | ||
| 51 | |||
| 52 | memory_is_online() | ||
| 53 | { | ||
| 54 | grep -q online $SYSFS/devices/system/memory/memory$1/state | ||
| 55 | } | ||
| 56 | |||
| 57 | memory_is_offline() | ||
| 58 | { | ||
| 59 | grep -q offline $SYSFS/devices/system/memory/memory$1/state | ||
| 60 | } | ||
| 61 | |||
| 62 | online_memory() | ||
| 63 | { | ||
| 64 | echo online > $SYSFS/devices/system/memory/memory$1/state | ||
| 65 | } | ||
| 66 | |||
| 67 | offline_memory() | ||
| 68 | { | ||
| 69 | echo offline > $SYSFS/devices/system/memory/memory$1/state | ||
| 70 | } | ||
| 71 | |||
| 72 | online_memory_expect_success() | ||
| 73 | { | ||
| 74 | local memory=$1 | ||
| 75 | |||
| 76 | if ! online_memory $memory; then | ||
| 77 | echo $FUNCNAME $memory: unexpected fail >&2 | ||
| 78 | elif ! memory_is_online $memory; then | ||
| 79 | echo $FUNCNAME $memory: unexpected offline >&2 | ||
| 80 | fi | ||
| 81 | } | ||
| 82 | |||
| 83 | online_memory_expect_fail() | ||
| 84 | { | ||
| 85 | local memory=$1 | ||
| 86 | |||
| 87 | if online_memory $memory 2> /dev/null; then | ||
| 88 | echo $FUNCNAME $memory: unexpected success >&2 | ||
| 89 | elif ! memory_is_offline $memory; then | ||
| 90 | echo $FUNCNAME $memory: unexpected online >&2 | ||
| 91 | fi | ||
| 92 | } | ||
| 93 | |||
| 94 | offline_memory_expect_success() | ||
| 95 | { | ||
| 96 | local memory=$1 | ||
| 97 | |||
| 98 | if ! offline_memory $memory; then | ||
| 99 | echo $FUNCNAME $memory: unexpected fail >&2 | ||
| 100 | elif ! memory_is_offline $memory; then | ||
| 101 | echo $FUNCNAME $memory: unexpected offline >&2 | ||
| 102 | fi | ||
| 103 | } | ||
| 104 | |||
| 105 | offline_memory_expect_fail() | ||
| 106 | { | ||
| 107 | local memory=$1 | ||
| 108 | |||
| 109 | if offline_memory $memory 2> /dev/null; then | ||
| 110 | echo $FUNCNAME $memory: unexpected success >&2 | ||
| 111 | elif ! memory_is_online $memory; then | ||
| 112 | echo $FUNCNAME $memory: unexpected offline >&2 | ||
| 113 | fi | ||
| 114 | } | ||
| 115 | |||
| 116 | error=-12 | ||
| 117 | priority=0 | ||
| 118 | ratio=10 | ||
| 119 | |||
| 120 | while getopts e:hp:r: opt; do | ||
| 121 | case $opt in | ||
| 122 | e) | ||
| 123 | error=$OPTARG | ||
| 124 | ;; | ||
| 125 | h) | ||
| 126 | echo "Usage $0 [ -e errno ] [ -p notifier-priority ] [ -r percent-of-memory-to-offline ]" | ||
| 127 | exit | ||
| 128 | ;; | ||
| 129 | p) | ||
| 130 | priority=$OPTARG | ||
| 131 | ;; | ||
| 132 | r) | ||
| 133 | ratio=$OPTARG | ||
| 134 | ;; | ||
| 135 | esac | ||
| 136 | done | ||
| 137 | |||
| 138 | if ! [ "$error" -ge -4095 -a "$error" -lt 0 ]; then | ||
| 139 | echo "error code must be -4095 <= errno < 0" >&2 | ||
| 140 | exit 1 | ||
| 141 | fi | ||
| 142 | |||
| 143 | prerequisite | ||
| 144 | |||
| 145 | # | ||
| 146 | # Online all hot-pluggable memory | ||
| 147 | # | ||
| 148 | for memory in `hotplaggable_offline_memory`; do | ||
| 149 | online_memory_expect_success $memory | ||
| 150 | done | ||
| 151 | |||
| 152 | # | ||
| 153 | # Offline $ratio percent of hot-pluggable memory | ||
| 154 | # | ||
| 155 | for memory in `hotpluggable_online_memory`; do | ||
| 156 | if [ $((RANDOM % 100)) -lt $ratio ]; then | ||
| 157 | offline_memory_expect_success $memory | ||
| 158 | fi | ||
| 159 | done | ||
| 160 | |||
| 161 | # | ||
| 162 | # Online all hot-pluggable memory again | ||
| 163 | # | ||
| 164 | for memory in `hotplaggable_offline_memory`; do | ||
| 165 | online_memory_expect_success $memory | ||
| 166 | done | ||
| 167 | |||
| 168 | # | ||
| 169 | # Test with memory notifier error injection | ||
| 170 | # | ||
| 171 | |||
| 172 | DEBUGFS=`mount -t debugfs | head -1 | awk '{ print $3 }'` | ||
| 173 | NOTIFIER_ERR_INJECT_DIR=$DEBUGFS/notifier-error-inject/memory | ||
| 174 | |||
| 175 | prerequisite_extra() | ||
| 176 | { | ||
| 177 | msg="skip extra tests:" | ||
| 178 | |||
| 179 | /sbin/modprobe -q -r memory-notifier-error-inject | ||
| 180 | /sbin/modprobe -q memory-notifier-error-inject priority=$priority | ||
| 181 | |||
| 182 | if [ ! -d "$DEBUGFS" ]; then | ||
| 183 | echo $msg debugfs is not mounted >&2 | ||
| 184 | exit 0 | ||
| 185 | fi | ||
| 186 | |||
| 187 | if [ ! -d $NOTIFIER_ERR_INJECT_DIR ]; then | ||
| 188 | echo $msg memory-notifier-error-inject module is not available >&2 | ||
| 189 | exit 0 | ||
| 190 | fi | ||
| 191 | } | ||
| 192 | |||
| 193 | prerequisite_extra | ||
| 194 | |||
| 195 | # | ||
| 196 | # Offline $ratio percent of hot-pluggable memory | ||
| 197 | # | ||
| 198 | echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error | ||
| 199 | for memory in `hotpluggable_online_memory`; do | ||
| 200 | if [ $((RANDOM % 100)) -lt $ratio ]; then | ||
| 201 | offline_memory_expect_success $memory | ||
| 202 | fi | ||
| 203 | done | ||
| 204 | |||
| 205 | # | ||
| 206 | # Test memory hot-add error handling (offline => online) | ||
| 207 | # | ||
| 208 | echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/error | ||
| 209 | for memory in `hotplaggable_offline_memory`; do | ||
| 210 | online_memory_expect_fail $memory | ||
| 211 | done | ||
| 212 | |||
| 213 | # | ||
| 214 | # Online all hot-pluggable memory | ||
| 215 | # | ||
| 216 | echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/error | ||
| 217 | for memory in `hotplaggable_offline_memory`; do | ||
| 218 | online_memory_expect_success $memory | ||
| 219 | done | ||
| 220 | |||
| 221 | # | ||
| 222 | # Test memory hot-remove error handling (online => offline) | ||
| 223 | # | ||
| 224 | echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error | ||
| 225 | for memory in `hotpluggable_online_memory`; do | ||
| 226 | offline_memory_expect_fail $memory | ||
| 227 | done | ||
| 228 | |||
| 229 | echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error | ||
| 230 | /sbin/modprobe -q -r memory-notifier-error-inject | ||
