diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-06 19:35:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-06 19:35:10 -0400 |
commit | 57d326169e878a1a37b2bccd1cf81f6809ee67b9 (patch) | |
tree | 86ed74ae4dc2beaebce1c67b8459f1873b777d3a | |
parent | 7b215de3d0abbc4f6daf2efd19e8809af0564490 (diff) | |
parent | 0244756edc4b98c129e92c7061d9f383708cf786 (diff) |
Merge branch 'akpm' (patches from Andrew Morton) into next
Merge more updates from Andrew Morton:
- Most of the rest of MM.
This includes "mark remap_file_pages syscall as deprecated" but the
actual "replace remap_file_pages syscall with emulation" is held
back. I guess we'll need to work out when to pull the trigger on
that one.
- various minor cleanups to obscure filesystems
- the drivers/rtc queue
- hfsplus updates
- ufs, hpfs, fatfs, affs, reiserfs
- Documentation/
- signals
- procfs
- cpu hotplug
- lib/idr.c
- rapidio
- sysctl
- ipc updates
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (171 commits)
ufs: sb mutex merge + mutex_destroy
powerpc: update comments for generic idle conversion
cris: update comments for generic idle conversion
idle: remove cpu_idle() forward declarations
nbd: zero from and len fields in NBD_CMD_DISCONNECT.
mm: convert some level-less printks to pr_*
MAINTAINERS: adi-buildroot-devel is moderated
MAINTAINERS: add linux-api for review of API/ABI changes
mm/kmemleak-test.c: use pr_fmt for logging
fs/dlm/debug_fs.c: replace seq_printf by seq_puts
fs/dlm/lockspace.c: convert simple_str to kstr
fs/dlm/config.c: convert simple_str to kstr
mm: mark remap_file_pages() syscall as deprecated
mm: memcontrol: remove unnecessary memcg argument from soft limit functions
mm: memcontrol: clean up memcg zoneinfo lookup
mm/memblock.c: call kmemleak directly from memblock_(alloc|free)
mm/mempool.c: update the kmemleak stack trace for mempool allocations
lib/radix-tree.c: update the kmemleak stack trace for radix tree allocations
mm: introduce kmemleak_update_trace()
mm/kmemleak.c: use %u to print ->checksum
...
198 files changed, 4205 insertions, 1800 deletions
diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index 2a8e89e13e45..7e9abb8a276b 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches | |||
@@ -132,6 +132,20 @@ Example: | |||
132 | platform_set_drvdata(), but left the variable "dev" unused, | 132 | platform_set_drvdata(), but left the variable "dev" unused, |
133 | delete it. | 133 | delete it. |
134 | 134 | ||
135 | If your patch fixes a bug in a specific commit, e.g. you found an issue using | ||
136 | git-bisect, please use the 'Fixes:' tag with the first 12 characters of the | ||
137 | SHA-1 ID, and the one line summary. | ||
138 | Example: | ||
139 | |||
140 | Fixes: e21d2170f366 ("video: remove unnecessary platform_set_drvdata()") | ||
141 | |||
142 | The following git-config settings can be used to add a pretty format for | ||
143 | outputting the above style in the git log or git show commands | ||
144 | |||
145 | [core] | ||
146 | abbrev = 12 | ||
147 | [pretty] | ||
148 | fixes = Fixes: %h (\"%s\") | ||
135 | 149 | ||
136 | 3) Separate your changes. | 150 | 3) Separate your changes. |
137 | 151 | ||
@@ -443,7 +457,7 @@ person it names. This tag documents that potentially interested parties | |||
443 | have been included in the discussion | 457 | have been included in the discussion |
444 | 458 | ||
445 | 459 | ||
446 | 14) Using Reported-by:, Tested-by:, Reviewed-by: and Suggested-by: | 460 | 14) Using Reported-by:, Tested-by:, Reviewed-by:, Suggested-by: and Fixes: |
447 | 461 | ||
448 | If this patch fixes a problem reported by somebody else, consider adding a | 462 | If this patch fixes a problem reported by somebody else, consider adding a |
449 | Reported-by: tag to credit the reporter for their contribution. Please | 463 | Reported-by: tag to credit the reporter for their contribution. Please |
@@ -498,6 +512,12 @@ idea was not posted in a public forum. That said, if we diligently credit our | |||
498 | idea reporters, they will, hopefully, be inspired to help us again in the | 512 | idea reporters, they will, hopefully, be inspired to help us again in the |
499 | future. | 513 | future. |
500 | 514 | ||
515 | A Fixes: tag indicates that the patch fixes an issue in a previous commit. It | ||
516 | is used to make it easy to determine where a bug originated, which can help | ||
517 | review a bug fix. This tag also assists the stable kernel team in determining | ||
518 | which stable kernel versions should receive your fix. This is the preferred | ||
519 | method for indicating a bug fixed by the patch. See #2 above for more details. | ||
520 | |||
501 | 521 | ||
502 | 15) The canonical patch format | 522 | 15) The canonical patch format |
503 | 523 | ||
diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt index 4937e6fff9b4..b3429aec444c 100644 --- a/Documentation/cgroups/memory.txt +++ b/Documentation/cgroups/memory.txt | |||
@@ -540,14 +540,13 @@ Note: | |||
540 | 540 | ||
541 | 5.3 swappiness | 541 | 5.3 swappiness |
542 | 542 | ||
543 | Similar to /proc/sys/vm/swappiness, but only affecting reclaim that is | 543 | Overrides /proc/sys/vm/swappiness for the particular group. The tunable |
544 | triggered by this cgroup's hard limit. The tunable in the root cgroup | 544 | in the root cgroup corresponds to the global swappiness setting. |
545 | corresponds to the global swappiness setting. | 545 | |
546 | 546 | Please note that unlike during the global reclaim, limit reclaim | |
547 | Please note that unlike the global swappiness, memcg knob set to 0 | 547 | enforces that 0 swappiness really prevents from any swapping even if |
548 | really prevents from any swapping even if there is a swap storage | 548 | there is a swap storage available. This might lead to memcg OOM killer |
549 | available. This might lead to memcg OOM killer if there are no file | 549 | if there are no file pages to reclaim. |
550 | pages to reclaim. | ||
551 | 550 | ||
552 | 5.4 failcnt | 551 | 5.4 failcnt |
553 | 552 | ||
diff --git a/Documentation/devicetree/bindings/rtc/haoyu,hym8563.txt b/Documentation/devicetree/bindings/rtc/haoyu,hym8563.txt index 31406fd4a43e..5c199ee044cb 100644 --- a/Documentation/devicetree/bindings/rtc/haoyu,hym8563.txt +++ b/Documentation/devicetree/bindings/rtc/haoyu,hym8563.txt | |||
@@ -9,6 +9,9 @@ Required properties: | |||
9 | - interrupts: rtc alarm/event interrupt | 9 | - interrupts: rtc alarm/event interrupt |
10 | - #clock-cells: the value should be 0 | 10 | - #clock-cells: the value should be 0 |
11 | 11 | ||
12 | Optional properties: | ||
13 | - clock-output-names: From common clock binding | ||
14 | |||
12 | Example: | 15 | Example: |
13 | 16 | ||
14 | hym8563: hym8563@51 { | 17 | hym8563: hym8563@51 { |
diff --git a/Documentation/devicetree/bindings/rtc/xgene-rtc.txt b/Documentation/devicetree/bindings/rtc/xgene-rtc.txt new file mode 100644 index 000000000000..fd195c358446 --- /dev/null +++ b/Documentation/devicetree/bindings/rtc/xgene-rtc.txt | |||
@@ -0,0 +1,28 @@ | |||
1 | * APM X-Gene Real Time Clock | ||
2 | |||
3 | RTC controller for the APM X-Gene Real Time Clock | ||
4 | |||
5 | Required properties: | ||
6 | - compatible : Should be "apm,xgene-rtc" | ||
7 | - reg: physical base address of the controller and length of memory mapped | ||
8 | region. | ||
9 | - interrupts: IRQ line for the RTC. | ||
10 | - #clock-cells: Should be 1. | ||
11 | - clocks: Reference to the clock entry. | ||
12 | |||
13 | Example: | ||
14 | |||
15 | rtcclk: rtcclk { | ||
16 | compatible = "fixed-clock"; | ||
17 | #clock-cells = <1>; | ||
18 | clock-frequency = <100000000>; | ||
19 | clock-output-names = "rtcclk"; | ||
20 | }; | ||
21 | |||
22 | rtc: rtc@10510000 { | ||
23 | compatible = "apm,xgene-rtc"; | ||
24 | reg = <0x0 0x10510000 0x0 0x400>; | ||
25 | interrupts = <0x0 0x46 0x4>; | ||
26 | #clock-cells = <1>; | ||
27 | clocks = <&rtcclk 0>; | ||
28 | }; | ||
diff --git a/Documentation/filesystems/seq_file.txt b/Documentation/filesystems/seq_file.txt index a1e2e0dda907..1fe0ccb1af55 100644 --- a/Documentation/filesystems/seq_file.txt +++ b/Documentation/filesystems/seq_file.txt | |||
@@ -54,6 +54,15 @@ how the mechanism works without getting lost in other details. (Those | |||
54 | wanting to see the full source for this module can find it at | 54 | wanting to see the full source for this module can find it at |
55 | http://lwn.net/Articles/22359/). | 55 | http://lwn.net/Articles/22359/). |
56 | 56 | ||
57 | Deprecated create_proc_entry | ||
58 | |||
59 | Note that the above article uses create_proc_entry which was removed in | ||
60 | kernel 3.10. Current versions require the following update | ||
61 | |||
62 | - entry = create_proc_entry("sequence", 0, NULL); | ||
63 | - if (entry) | ||
64 | - entry->proc_fops = &ct_file_ops; | ||
65 | + entry = proc_create("sequence", 0, NULL, &ct_file_ops); | ||
57 | 66 | ||
58 | The iterator interface | 67 | The iterator interface |
59 | 68 | ||
diff --git a/Documentation/filesystems/vfat.txt b/Documentation/filesystems/vfat.txt index 4a93e98b290a..ce1126aceed8 100644 --- a/Documentation/filesystems/vfat.txt +++ b/Documentation/filesystems/vfat.txt | |||
@@ -172,6 +172,11 @@ nfs=stale_rw|nostale_ro | |||
172 | To maintain backward compatibility, '-o nfs' is also accepted, | 172 | To maintain backward compatibility, '-o nfs' is also accepted, |
173 | defaulting to stale_rw | 173 | defaulting to stale_rw |
174 | 174 | ||
175 | dos1xfloppy -- If set, use a fallback default BIOS Parameter Block | ||
176 | configuration, determined by backing device size. These static | ||
177 | parameters match defaults assumed by DOS 1.x for 160 kiB, | ||
178 | 180 kiB, 320 kiB, and 360 kiB floppies and floppy images. | ||
179 | |||
175 | 180 | ||
176 | <bool>: 0,1,yes,no,true,false | 181 | <bool>: 0,1,yes,no,true,false |
177 | 182 | ||
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 9973a7e2e0ac..b9f67781c577 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -2361,6 +2361,14 @@ bytes respectively. Such letter suffixes can also be entirely omitted. | |||
2361 | timeout < 0: reboot immediately | 2361 | timeout < 0: reboot immediately |
2362 | Format: <timeout> | 2362 | Format: <timeout> |
2363 | 2363 | ||
2364 | crash_kexec_post_notifiers | ||
2365 | Run kdump after running panic-notifiers and dumping | ||
2366 | kmsg. This only for the users who doubt kdump always | ||
2367 | succeeds in any situation. | ||
2368 | Note that this also increases risks of kdump failure, | ||
2369 | because some panic notifiers can make the crashed | ||
2370 | kernel more unstable. | ||
2371 | |||
2364 | parkbd.port= [HW] Parallel port number the keyboard adapter is | 2372 | parkbd.port= [HW] Parallel port number the keyboard adapter is |
2365 | connected to, default is 0. | 2373 | connected to, default is 0. |
2366 | Format: <parport#> | 2374 | Format: <parport#> |
diff --git a/Documentation/kmemleak.txt b/Documentation/kmemleak.txt index a7563ec4ea7b..b772418bf064 100644 --- a/Documentation/kmemleak.txt +++ b/Documentation/kmemleak.txt | |||
@@ -142,6 +142,7 @@ kmemleak_alloc_percpu - notify of a percpu memory block allocation | |||
142 | kmemleak_free - notify of a memory block freeing | 142 | kmemleak_free - notify of a memory block freeing |
143 | kmemleak_free_part - notify of a partial memory block freeing | 143 | kmemleak_free_part - notify of a partial memory block freeing |
144 | kmemleak_free_percpu - notify of a percpu memory block freeing | 144 | kmemleak_free_percpu - notify of a percpu memory block freeing |
145 | kmemleak_update_trace - update object allocation stack trace | ||
145 | kmemleak_not_leak - mark an object as not a leak | 146 | kmemleak_not_leak - mark an object as not a leak |
146 | kmemleak_ignore - do not scan or report an object as leak | 147 | kmemleak_ignore - do not scan or report an object as leak |
147 | kmemleak_scan_area - add scan areas inside a memory block | 148 | kmemleak_scan_area - add scan areas inside a memory block |
diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt index 46412bded104..f1dc4a215593 100644 --- a/Documentation/memory-barriers.txt +++ b/Documentation/memory-barriers.txt | |||
@@ -115,8 +115,8 @@ For example, consider the following sequence of events: | |||
115 | CPU 1 CPU 2 | 115 | CPU 1 CPU 2 |
116 | =============== =============== | 116 | =============== =============== |
117 | { A == 1; B == 2 } | 117 | { A == 1; B == 2 } |
118 | A = 3; x = A; | 118 | A = 3; x = B; |
119 | B = 4; y = B; | 119 | B = 4; y = A; |
120 | 120 | ||
121 | The set of accesses as seen by the memory system in the middle can be arranged | 121 | The set of accesses as seen by the memory system in the middle can be arranged |
122 | in 24 different combinations: | 122 | in 24 different combinations: |
diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt index 9886c3d57fc2..708bb7f1b7e0 100644 --- a/Documentation/sysctl/kernel.txt +++ b/Documentation/sysctl/kernel.txt | |||
@@ -77,6 +77,7 @@ show up in /proc/sys/kernel: | |||
77 | - shmmni | 77 | - shmmni |
78 | - stop-a [ SPARC only ] | 78 | - stop-a [ SPARC only ] |
79 | - sysrq ==> Documentation/sysrq.txt | 79 | - sysrq ==> Documentation/sysrq.txt |
80 | - sysctl_writes_strict | ||
80 | - tainted | 81 | - tainted |
81 | - threads-max | 82 | - threads-max |
82 | - unknown_nmi_panic | 83 | - unknown_nmi_panic |
@@ -762,6 +763,26 @@ without users and with a dead originative process will be destroyed. | |||
762 | 763 | ||
763 | ============================================================== | 764 | ============================================================== |
764 | 765 | ||
766 | sysctl_writes_strict: | ||
767 | |||
768 | Control how file position affects the behavior of updating sysctl values | ||
769 | via the /proc/sys interface: | ||
770 | |||
771 | -1 - Legacy per-write sysctl value handling, with no printk warnings. | ||
772 | Each write syscall must fully contain the sysctl value to be | ||
773 | written, and multiple writes on the same sysctl file descriptor | ||
774 | will rewrite the sysctl value, regardless of file position. | ||
775 | 0 - (default) Same behavior as above, but warn about processes that | ||
776 | perform writes to a sysctl file descriptor when the file position | ||
777 | is not 0. | ||
778 | 1 - Respect file position when writing sysctl strings. Multiple writes | ||
779 | will append to the sysctl value buffer. Anything past the max length | ||
780 | of the sysctl value buffer will be ignored. Writes to numeric sysctl | ||
781 | entries must always be at file position 0 and the value must be | ||
782 | fully contained in the buffer sent in the write syscall. | ||
783 | |||
784 | ============================================================== | ||
785 | |||
765 | tainted: | 786 | tainted: |
766 | 787 | ||
767 | Non-zero if the kernel has been tainted. Numeric values, which | 788 | Non-zero if the kernel has been tainted. Numeric values, which |
diff --git a/Documentation/vm/remap_file_pages.txt b/Documentation/vm/remap_file_pages.txt new file mode 100644 index 000000000000..560e4363a55d --- /dev/null +++ b/Documentation/vm/remap_file_pages.txt | |||
@@ -0,0 +1,28 @@ | |||
1 | The remap_file_pages() system call is used to create a nonlinear mapping, | ||
2 | that is, a mapping in which the pages of the file are mapped into a | ||
3 | nonsequential order in memory. The advantage of using remap_file_pages() | ||
4 | over using repeated calls to mmap(2) is that the former approach does not | ||
5 | require the kernel to create additional VMA (Virtual Memory Area) data | ||
6 | structures. | ||
7 | |||
8 | Supporting of nonlinear mapping requires significant amount of non-trivial | ||
9 | code in kernel virtual memory subsystem including hot paths. Also to get | ||
10 | nonlinear mapping work kernel need a way to distinguish normal page table | ||
11 | entries from entries with file offset (pte_file). Kernel reserves flag in | ||
12 | PTE for this purpose. PTE flags are scarce resource especially on some CPU | ||
13 | architectures. It would be nice to free up the flag for other usage. | ||
14 | |||
15 | Fortunately, there are not many users of remap_file_pages() in the wild. | ||
16 | It's only known that one enterprise RDBMS implementation uses the syscall | ||
17 | on 32-bit systems to map files bigger than can linearly fit into 32-bit | ||
18 | virtual address space. This use-case is not critical anymore since 64-bit | ||
19 | systems are widely available. | ||
20 | |||
21 | The plan is to deprecate the syscall and replace it with an emulation. | ||
22 | The emulation will create new VMAs instead of nonlinear mappings. It's | ||
23 | going to work slower for rare users of remap_file_pages() but ABI is | ||
24 | preserved. | ||
25 | |||
26 | One side effect of emulation (apart from performance) is that user can hit | ||
27 | vm.max_map_count limit more easily due to additional VMAs. See comment for | ||
28 | DEFAULT_MAX_MAP_COUNT for more details on the limit. | ||
diff --git a/MAINTAINERS b/MAINTAINERS index 7d101d5ba953..f98da9025d7d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -210,6 +210,13 @@ S: Supported | |||
210 | F: Documentation/scsi/aacraid.txt | 210 | F: Documentation/scsi/aacraid.txt |
211 | F: drivers/scsi/aacraid/ | 211 | F: drivers/scsi/aacraid/ |
212 | 212 | ||
213 | ABI/API | ||
214 | L: linux-api@vger.kernel.org | ||
215 | F: Documentation/ABI/ | ||
216 | F: include/linux/syscalls.h | ||
217 | F: include/uapi/ | ||
218 | F: kernel/sys_ni.c | ||
219 | |||
213 | ABIT UGURU 1,2 HARDWARE MONITOR DRIVER | 220 | ABIT UGURU 1,2 HARDWARE MONITOR DRIVER |
214 | M: Hans de Goede <hdegoede@redhat.com> | 221 | M: Hans de Goede <hdegoede@redhat.com> |
215 | L: lm-sensors@lm-sensors.org | 222 | L: lm-sensors@lm-sensors.org |
@@ -647,7 +654,7 @@ F: sound/soc/codecs/ssm* | |||
647 | F: sound/soc/codecs/sigmadsp.* | 654 | F: sound/soc/codecs/sigmadsp.* |
648 | 655 | ||
649 | ANALOG DEVICES INC ASOC DRIVERS | 656 | ANALOG DEVICES INC ASOC DRIVERS |
650 | L: adi-buildroot-devel@lists.sourceforge.net | 657 | L: adi-buildroot-devel@lists.sourceforge.net (moderated for non-subscribers) |
651 | L: alsa-devel@alsa-project.org (moderated for non-subscribers) | 658 | L: alsa-devel@alsa-project.org (moderated for non-subscribers) |
652 | W: http://blackfin.uclinux.org/ | 659 | W: http://blackfin.uclinux.org/ |
653 | S: Supported | 660 | S: Supported |
@@ -1758,54 +1765,54 @@ F: include/uapi/linux/bfs_fs.h | |||
1758 | 1765 | ||
1759 | BLACKFIN ARCHITECTURE | 1766 | BLACKFIN ARCHITECTURE |
1760 | M: Steven Miao <realmz6@gmail.com> | 1767 | M: Steven Miao <realmz6@gmail.com> |
1761 | L: adi-buildroot-devel@lists.sourceforge.net | 1768 | L: adi-buildroot-devel@lists.sourceforge.net (moderated for non-subscribers) |
1762 | T: git git://git.code.sf.net/p/adi-linux/code | 1769 | T: git git://git.code.sf.net/p/adi-linux/code |
1763 | W: http://blackfin.uclinux.org | 1770 | W: http://blackfin.uclinux.org |
1764 | S: Supported | 1771 | S: Supported |
1765 | F: arch/blackfin/ | 1772 | F: arch/blackfin/ |
1766 | 1773 | ||
1767 | BLACKFIN EMAC DRIVER | 1774 | BLACKFIN EMAC DRIVER |
1768 | L: adi-buildroot-devel@lists.sourceforge.net | 1775 | L: adi-buildroot-devel@lists.sourceforge.net (moderated for non-subscribers) |
1769 | W: http://blackfin.uclinux.org | 1776 | W: http://blackfin.uclinux.org |
1770 | S: Supported | 1777 | S: Supported |
1771 | F: drivers/net/ethernet/adi/ | 1778 | F: drivers/net/ethernet/adi/ |
1772 | 1779 | ||
1773 | BLACKFIN RTC DRIVER | 1780 | BLACKFIN RTC DRIVER |
1774 | L: adi-buildroot-devel@lists.sourceforge.net | 1781 | L: adi-buildroot-devel@lists.sourceforge.net (moderated for non-subscribers) |
1775 | W: http://blackfin.uclinux.org | 1782 | W: http://blackfin.uclinux.org |
1776 | S: Supported | 1783 | S: Supported |
1777 | F: drivers/rtc/rtc-bfin.c | 1784 | F: drivers/rtc/rtc-bfin.c |
1778 | 1785 | ||
1779 | BLACKFIN SDH DRIVER | 1786 | BLACKFIN SDH DRIVER |
1780 | M: Sonic Zhang <sonic.zhang@analog.com> | 1787 | M: Sonic Zhang <sonic.zhang@analog.com> |
1781 | L: adi-buildroot-devel@lists.sourceforge.net | 1788 | L: adi-buildroot-devel@lists.sourceforge.net (moderated for non-subscribers) |
1782 | W: http://blackfin.uclinux.org | 1789 | W: http://blackfin.uclinux.org |
1783 | S: Supported | 1790 | S: Supported |
1784 | F: drivers/mmc/host/bfin_sdh.c | 1791 | F: drivers/mmc/host/bfin_sdh.c |
1785 | 1792 | ||
1786 | BLACKFIN SERIAL DRIVER | 1793 | BLACKFIN SERIAL DRIVER |
1787 | M: Sonic Zhang <sonic.zhang@analog.com> | 1794 | M: Sonic Zhang <sonic.zhang@analog.com> |
1788 | L: adi-buildroot-devel@lists.sourceforge.net | 1795 | L: adi-buildroot-devel@lists.sourceforge.net (moderated for non-subscribers) |
1789 | W: http://blackfin.uclinux.org | 1796 | W: http://blackfin.uclinux.org |
1790 | S: Supported | 1797 | S: Supported |
1791 | F: drivers/tty/serial/bfin_uart.c | 1798 | F: drivers/tty/serial/bfin_uart.c |
1792 | 1799 | ||
1793 | BLACKFIN WATCHDOG DRIVER | 1800 | BLACKFIN WATCHDOG DRIVER |
1794 | L: adi-buildroot-devel@lists.sourceforge.net | 1801 | L: adi-buildroot-devel@lists.sourceforge.net (moderated for non-subscribers) |
1795 | W: http://blackfin.uclinux.org | 1802 | W: http://blackfin.uclinux.org |
1796 | S: Supported | 1803 | S: Supported |
1797 | F: drivers/watchdog/bfin_wdt.c | 1804 | F: drivers/watchdog/bfin_wdt.c |
1798 | 1805 | ||
1799 | BLACKFIN I2C TWI DRIVER | 1806 | BLACKFIN I2C TWI DRIVER |
1800 | M: Sonic Zhang <sonic.zhang@analog.com> | 1807 | M: Sonic Zhang <sonic.zhang@analog.com> |
1801 | L: adi-buildroot-devel@lists.sourceforge.net | 1808 | L: adi-buildroot-devel@lists.sourceforge.net (moderated for non-subscribers) |
1802 | W: http://blackfin.uclinux.org/ | 1809 | W: http://blackfin.uclinux.org/ |
1803 | S: Supported | 1810 | S: Supported |
1804 | F: drivers/i2c/busses/i2c-bfin-twi.c | 1811 | F: drivers/i2c/busses/i2c-bfin-twi.c |
1805 | 1812 | ||
1806 | BLACKFIN MEDIA DRIVER | 1813 | BLACKFIN MEDIA DRIVER |
1807 | M: Scott Jiang <scott.jiang.linux@gmail.com> | 1814 | M: Scott Jiang <scott.jiang.linux@gmail.com> |
1808 | L: adi-buildroot-devel@lists.sourceforge.net | 1815 | L: adi-buildroot-devel@lists.sourceforge.net (moderated for non-subscribers) |
1809 | W: http://blackfin.uclinux.org/ | 1816 | W: http://blackfin.uclinux.org/ |
1810 | S: Supported | 1817 | S: Supported |
1811 | F: drivers/media/platform/blackfin/ | 1818 | F: drivers/media/platform/blackfin/ |
diff --git a/arch/arm/kernel/isa.c b/arch/arm/kernel/isa.c index 346485910732..9d1cf7156895 100644 --- a/arch/arm/kernel/isa.c +++ b/arch/arm/kernel/isa.c | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | static unsigned int isa_membase, isa_portbase, isa_portshift; | 21 | static unsigned int isa_membase, isa_portbase, isa_portshift; |
22 | 22 | ||
23 | static ctl_table ctl_isa_vars[4] = { | 23 | static struct ctl_table ctl_isa_vars[4] = { |
24 | { | 24 | { |
25 | .procname = "membase", | 25 | .procname = "membase", |
26 | .data = &isa_membase, | 26 | .data = &isa_membase, |
@@ -44,7 +44,7 @@ static ctl_table ctl_isa_vars[4] = { | |||
44 | 44 | ||
45 | static struct ctl_table_header *isa_sysctl_header; | 45 | static struct ctl_table_header *isa_sysctl_header; |
46 | 46 | ||
47 | static ctl_table ctl_isa[2] = { | 47 | static struct ctl_table ctl_isa[2] = { |
48 | { | 48 | { |
49 | .procname = "isa", | 49 | .procname = "isa", |
50 | .mode = 0555, | 50 | .mode = 0555, |
@@ -52,7 +52,7 @@ static ctl_table ctl_isa[2] = { | |||
52 | }, {} | 52 | }, {} |
53 | }; | 53 | }; |
54 | 54 | ||
55 | static ctl_table ctl_bus[2] = { | 55 | static struct ctl_table ctl_bus[2] = { |
56 | { | 56 | { |
57 | .procname = "bus", | 57 | .procname = "bus", |
58 | .mode = 0555, | 58 | .mode = 0555, |
diff --git a/arch/arm/mach-at91/sysirq_mask.c b/arch/arm/mach-at91/sysirq_mask.c index 2ba694f9626b..f8bc3511a8c8 100644 --- a/arch/arm/mach-at91/sysirq_mask.c +++ b/arch/arm/mach-at91/sysirq_mask.c | |||
@@ -25,24 +25,28 @@ | |||
25 | 25 | ||
26 | #include "generic.h" | 26 | #include "generic.h" |
27 | 27 | ||
28 | #define AT91_RTC_IDR 0x24 /* Interrupt Disable Register */ | 28 | #define AT91_RTC_IDR 0x24 /* Interrupt Disable Register */ |
29 | #define AT91_RTC_IMR 0x28 /* Interrupt Mask Register */ | 29 | #define AT91_RTC_IMR 0x28 /* Interrupt Mask Register */ |
30 | #define AT91_RTC_IRQ_MASK 0x1f /* Available IRQs mask */ | ||
30 | 31 | ||
31 | void __init at91_sysirq_mask_rtc(u32 rtc_base) | 32 | void __init at91_sysirq_mask_rtc(u32 rtc_base) |
32 | { | 33 | { |
33 | void __iomem *base; | 34 | void __iomem *base; |
34 | u32 mask; | ||
35 | 35 | ||
36 | base = ioremap(rtc_base, 64); | 36 | base = ioremap(rtc_base, 64); |
37 | if (!base) | 37 | if (!base) |
38 | return; | 38 | return; |
39 | 39 | ||
40 | mask = readl_relaxed(base + AT91_RTC_IMR); | 40 | /* |
41 | if (mask) { | 41 | * sam9x5 SoCs have the following errata: |
42 | pr_info("AT91: Disabling rtc irq\n"); | 42 | * "RTC: Interrupt Mask Register cannot be used |
43 | writel_relaxed(mask, base + AT91_RTC_IDR); | 43 | * Interrupt Mask Register read always returns 0." |
44 | (void)readl_relaxed(base + AT91_RTC_IMR); /* flush */ | 44 | * |
45 | } | 45 | * Hence we're not relying on IMR values to disable |
46 | * interrupts. | ||
47 | */ | ||
48 | writel_relaxed(AT91_RTC_IRQ_MASK, base + AT91_RTC_IDR); | ||
49 | (void)readl_relaxed(base + AT91_RTC_IMR); /* flush */ | ||
46 | 50 | ||
47 | iounmap(base); | 51 | iounmap(base); |
48 | } | 52 | } |
diff --git a/arch/arm64/boot/dts/apm-storm.dtsi b/arch/arm64/boot/dts/apm-storm.dtsi index f8c40a66e65d..c5f0a47a1375 100644 --- a/arch/arm64/boot/dts/apm-storm.dtsi +++ b/arch/arm64/boot/dts/apm-storm.dtsi | |||
@@ -257,6 +257,19 @@ | |||
257 | enable-offset = <0x0>; | 257 | enable-offset = <0x0>; |
258 | enable-mask = <0x39>; | 258 | enable-mask = <0x39>; |
259 | }; | 259 | }; |
260 | |||
261 | rtcclk: rtcclk@17000000 { | ||
262 | compatible = "apm,xgene-device-clock"; | ||
263 | #clock-cells = <1>; | ||
264 | clocks = <&socplldiv2 0>; | ||
265 | reg = <0x0 0x17000000 0x0 0x2000>; | ||
266 | reg-names = "csr-reg"; | ||
267 | csr-offset = <0xc>; | ||
268 | csr-mask = <0x2>; | ||
269 | enable-offset = <0x10>; | ||
270 | enable-mask = <0x2>; | ||
271 | clock-output-names = "rtcclk"; | ||
272 | }; | ||
260 | }; | 273 | }; |
261 | 274 | ||
262 | serial0: serial@1c020000 { | 275 | serial0: serial@1c020000 { |
@@ -342,5 +355,13 @@ | |||
342 | phys = <&phy3 0>; | 355 | phys = <&phy3 0>; |
343 | phy-names = "sata-phy"; | 356 | phy-names = "sata-phy"; |
344 | }; | 357 | }; |
358 | |||
359 | rtc: rtc@10510000 { | ||
360 | compatible = "apm,xgene-rtc"; | ||
361 | reg = <0x0 0x10510000 0x0 0x400>; | ||
362 | interrupts = <0x0 0x46 0x4>; | ||
363 | #clock-cells = <1>; | ||
364 | clocks = <&rtcclk 0>; | ||
365 | }; | ||
345 | }; | 366 | }; |
346 | }; | 367 | }; |
diff --git a/arch/blackfin/kernel/ptrace.c b/arch/blackfin/kernel/ptrace.c index e1f88e028cfe..8b8fe671b1a6 100644 --- a/arch/blackfin/kernel/ptrace.c +++ b/arch/blackfin/kernel/ptrace.c | |||
@@ -117,6 +117,7 @@ put_reg(struct task_struct *task, unsigned long regno, unsigned long data) | |||
117 | int | 117 | int |
118 | is_user_addr_valid(struct task_struct *child, unsigned long start, unsigned long len) | 118 | is_user_addr_valid(struct task_struct *child, unsigned long start, unsigned long len) |
119 | { | 119 | { |
120 | bool valid; | ||
120 | struct vm_area_struct *vma; | 121 | struct vm_area_struct *vma; |
121 | struct sram_list_struct *sraml; | 122 | struct sram_list_struct *sraml; |
122 | 123 | ||
@@ -124,9 +125,12 @@ is_user_addr_valid(struct task_struct *child, unsigned long start, unsigned long | |||
124 | if (start + len < start) | 125 | if (start + len < start) |
125 | return -EIO; | 126 | return -EIO; |
126 | 127 | ||
128 | down_read(&child->mm->mmap_sem); | ||
127 | vma = find_vma(child->mm, start); | 129 | vma = find_vma(child->mm, start); |
128 | if (vma && start >= vma->vm_start && start + len <= vma->vm_end) | 130 | valid = vma && start >= vma->vm_start && start + len <= vma->vm_end; |
129 | return 0; | 131 | up_read(&child->mm->mmap_sem); |
132 | if (valid) | ||
133 | return 0; | ||
130 | 134 | ||
131 | for (sraml = child->mm->context.sram_list; sraml; sraml = sraml->next) | 135 | for (sraml = child->mm->context.sram_list; sraml; sraml = sraml->next) |
132 | if (start >= (unsigned long)sraml->addr | 136 | if (start >= (unsigned long)sraml->addr |
diff --git a/arch/cris/arch-v10/drivers/gpio.c b/arch/cris/arch-v10/drivers/gpio.c index f4374bae4fb4..64285e0d3481 100644 --- a/arch/cris/arch-v10/drivers/gpio.c +++ b/arch/cris/arch-v10/drivers/gpio.c | |||
@@ -833,8 +833,8 @@ static int __init gpio_init(void) | |||
833 | printk(KERN_INFO "ETRAX 100LX GPIO driver v2.5, (c) 2001-2008 " | 833 | printk(KERN_INFO "ETRAX 100LX GPIO driver v2.5, (c) 2001-2008 " |
834 | "Axis Communications AB\n"); | 834 | "Axis Communications AB\n"); |
835 | /* We call etrax_gpio_wake_up_check() from timer interrupt and | 835 | /* We call etrax_gpio_wake_up_check() from timer interrupt and |
836 | * from cpu_idle() in kernel/process.c | 836 | * from default_idle() in kernel/process.c |
837 | * The check in cpu_idle() reduces latency from ~15 ms to ~6 ms | 837 | * The check in default_idle() reduces latency from ~15 ms to ~6 ms |
838 | * in some tests. | 838 | * in some tests. |
839 | */ | 839 | */ |
840 | res = request_irq(TIMER0_IRQ_NBR, gpio_poll_timer_interrupt, | 840 | res = request_irq(TIMER0_IRQ_NBR, gpio_poll_timer_interrupt, |
diff --git a/arch/cris/arch-v32/drivers/mach-fs/gpio.c b/arch/cris/arch-v32/drivers/mach-fs/gpio.c index 9e54273af0ca..009f4ee1bd09 100644 --- a/arch/cris/arch-v32/drivers/mach-fs/gpio.c +++ b/arch/cris/arch-v32/drivers/mach-fs/gpio.c | |||
@@ -958,11 +958,7 @@ gpio_init(void) | |||
958 | 958 | ||
959 | printk(KERN_INFO "ETRAX FS GPIO driver v2.5, (c) 2003-2007 " | 959 | printk(KERN_INFO "ETRAX FS GPIO driver v2.5, (c) 2003-2007 " |
960 | "Axis Communications AB\n"); | 960 | "Axis Communications AB\n"); |
961 | /* We call etrax_gpio_wake_up_check() from timer interrupt and | 961 | /* We call etrax_gpio_wake_up_check() from timer interrupt */ |
962 | * from cpu_idle() in kernel/process.c | ||
963 | * The check in cpu_idle() reduces latency from ~15 ms to ~6 ms | ||
964 | * in some tests. | ||
965 | */ | ||
966 | if (request_irq(TIMER0_INTR_VECT, gpio_poll_timer_interrupt, | 962 | if (request_irq(TIMER0_INTR_VECT, gpio_poll_timer_interrupt, |
967 | IRQF_SHARED, "gpio poll", &alarmlist)) | 963 | IRQF_SHARED, "gpio poll", &alarmlist)) |
968 | printk(KERN_ERR "timer0 irq for gpio\n"); | 964 | printk(KERN_ERR "timer0 irq for gpio\n"); |
diff --git a/arch/ia64/kernel/crash.c b/arch/ia64/kernel/crash.c index b942f4032d7a..2955f359e2a7 100644 --- a/arch/ia64/kernel/crash.c +++ b/arch/ia64/kernel/crash.c | |||
@@ -237,7 +237,7 @@ kdump_init_notifier(struct notifier_block *self, unsigned long val, void *data) | |||
237 | } | 237 | } |
238 | 238 | ||
239 | #ifdef CONFIG_SYSCTL | 239 | #ifdef CONFIG_SYSCTL |
240 | static ctl_table kdump_ctl_table[] = { | 240 | static struct ctl_table kdump_ctl_table[] = { |
241 | { | 241 | { |
242 | .procname = "kdump_on_init", | 242 | .procname = "kdump_on_init", |
243 | .data = &kdump_on_init, | 243 | .data = &kdump_on_init, |
@@ -255,7 +255,7 @@ static ctl_table kdump_ctl_table[] = { | |||
255 | { } | 255 | { } |
256 | }; | 256 | }; |
257 | 257 | ||
258 | static ctl_table sys_table[] = { | 258 | static struct ctl_table sys_table[] = { |
259 | { | 259 | { |
260 | .procname = "kernel", | 260 | .procname = "kernel", |
261 | .mode = 0555, | 261 | .mode = 0555, |
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c index d841c4bd6864..5845ffea67c3 100644 --- a/arch/ia64/kernel/perfmon.c +++ b/arch/ia64/kernel/perfmon.c | |||
@@ -521,7 +521,7 @@ static pmu_config_t *pmu_conf; | |||
521 | pfm_sysctl_t pfm_sysctl; | 521 | pfm_sysctl_t pfm_sysctl; |
522 | EXPORT_SYMBOL(pfm_sysctl); | 522 | EXPORT_SYMBOL(pfm_sysctl); |
523 | 523 | ||
524 | static ctl_table pfm_ctl_table[]={ | 524 | static struct ctl_table pfm_ctl_table[] = { |
525 | { | 525 | { |
526 | .procname = "debug", | 526 | .procname = "debug", |
527 | .data = &pfm_sysctl.debug, | 527 | .data = &pfm_sysctl.debug, |
@@ -552,7 +552,7 @@ static ctl_table pfm_ctl_table[]={ | |||
552 | }, | 552 | }, |
553 | {} | 553 | {} |
554 | }; | 554 | }; |
555 | static ctl_table pfm_sysctl_dir[] = { | 555 | static struct ctl_table pfm_sysctl_dir[] = { |
556 | { | 556 | { |
557 | .procname = "perfmon", | 557 | .procname = "perfmon", |
558 | .mode = 0555, | 558 | .mode = 0555, |
@@ -560,7 +560,7 @@ static ctl_table pfm_sysctl_dir[] = { | |||
560 | }, | 560 | }, |
561 | {} | 561 | {} |
562 | }; | 562 | }; |
563 | static ctl_table pfm_sysctl_root[] = { | 563 | static struct ctl_table pfm_sysctl_root[] = { |
564 | { | 564 | { |
565 | .procname = "kernel", | 565 | .procname = "kernel", |
566 | .mode = 0555, | 566 | .mode = 0555, |
diff --git a/arch/m68k/include/asm/signal.h b/arch/m68k/include/asm/signal.h index 214320b50384..8c8ce5e1ee0e 100644 --- a/arch/m68k/include/asm/signal.h +++ b/arch/m68k/include/asm/signal.h | |||
@@ -60,15 +60,6 @@ static inline int __gen_sigismember(sigset_t *set, int _sig) | |||
60 | __const_sigismember(set,sig) : \ | 60 | __const_sigismember(set,sig) : \ |
61 | __gen_sigismember(set,sig)) | 61 | __gen_sigismember(set,sig)) |
62 | 62 | ||
63 | static inline int sigfindinword(unsigned long word) | ||
64 | { | ||
65 | asm ("bfffo %1{#0,#0},%0" | ||
66 | : "=d" (word) | ||
67 | : "d" (word & -word) | ||
68 | : "cc"); | ||
69 | return word ^ 31; | ||
70 | } | ||
71 | |||
72 | #endif /* !CONFIG_CPU_HAS_NO_BITFIELDS */ | 63 | #endif /* !CONFIG_CPU_HAS_NO_BITFIELDS */ |
73 | 64 | ||
74 | #ifndef __uClinux__ | 65 | #ifndef __uClinux__ |
diff --git a/arch/mips/dec/Makefile b/arch/mips/dec/Makefile index 3d5d2c56de8d..bd74e05c90b0 100644 --- a/arch/mips/dec/Makefile +++ b/arch/mips/dec/Makefile | |||
@@ -3,7 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y := ecc-berr.o int-handler.o ioasic-irq.o kn01-berr.o \ | 5 | obj-y := ecc-berr.o int-handler.o ioasic-irq.o kn01-berr.o \ |
6 | kn02-irq.o kn02xa-berr.o reset.o setup.o time.o | 6 | kn02-irq.o kn02xa-berr.o platform.o reset.o setup.o time.o |
7 | 7 | ||
8 | obj-$(CONFIG_TC) += tc.o | 8 | obj-$(CONFIG_TC) += tc.o |
9 | obj-$(CONFIG_CPU_HAS_WB) += wbflush.o | 9 | obj-$(CONFIG_CPU_HAS_WB) += wbflush.o |
diff --git a/arch/mips/dec/platform.c b/arch/mips/dec/platform.c new file mode 100644 index 000000000000..c7ac86af847a --- /dev/null +++ b/arch/mips/dec/platform.c | |||
@@ -0,0 +1,44 @@ | |||
1 | /* | ||
2 | * DEC platform devices. | ||
3 | * | ||
4 | * Copyright (c) 2014 Maciej W. Rozycki | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/ioport.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/mc146818rtc.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | |||
17 | static struct resource dec_rtc_resources[] = { | ||
18 | { | ||
19 | .name = "rtc", | ||
20 | .flags = IORESOURCE_MEM, | ||
21 | }, | ||
22 | }; | ||
23 | |||
24 | static struct cmos_rtc_board_info dec_rtc_info = { | ||
25 | .flags = CMOS_RTC_FLAGS_NOFREQ, | ||
26 | .address_space = 64, | ||
27 | }; | ||
28 | |||
29 | static struct platform_device dec_rtc_device = { | ||
30 | .name = "rtc_cmos", | ||
31 | .id = PLATFORM_DEVID_NONE, | ||
32 | .dev.platform_data = &dec_rtc_info, | ||
33 | .resource = dec_rtc_resources, | ||
34 | .num_resources = ARRAY_SIZE(dec_rtc_resources), | ||
35 | }; | ||
36 | |||
37 | static int __init dec_add_devices(void) | ||
38 | { | ||
39 | dec_rtc_resources[0].start = RTC_PORT(0); | ||
40 | dec_rtc_resources[0].end = RTC_PORT(0) + dec_kn_slot_size - 1; | ||
41 | return platform_device_register(&dec_rtc_device); | ||
42 | } | ||
43 | |||
44 | device_initcall(dec_add_devices); | ||
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c index ca1cd7459c4a..248ee7e5bebd 100644 --- a/arch/powerpc/kernel/irq.c +++ b/arch/powerpc/kernel/irq.c | |||
@@ -304,7 +304,7 @@ void notrace restore_interrupts(void) | |||
304 | * being re-enabled and generally sanitized the lazy irq state, | 304 | * being re-enabled and generally sanitized the lazy irq state, |
305 | * and in the latter case it will leave with interrupts hard | 305 | * and in the latter case it will leave with interrupts hard |
306 | * disabled and marked as such, so the local_irq_enable() call | 306 | * disabled and marked as such, so the local_irq_enable() call |
307 | * in cpu_idle() will properly re-enable everything. | 307 | * in arch_cpu_idle() will properly re-enable everything. |
308 | */ | 308 | */ |
309 | bool prep_irq_for_idle(void) | 309 | bool prep_irq_for_idle(void) |
310 | { | 310 | { |
diff --git a/arch/tile/kernel/proc.c b/arch/tile/kernel/proc.c index 681100c59fda..6829a9508649 100644 --- a/arch/tile/kernel/proc.c +++ b/arch/tile/kernel/proc.c | |||
@@ -113,7 +113,7 @@ arch_initcall(proc_tile_init); | |||
113 | * Support /proc/sys/tile directory | 113 | * Support /proc/sys/tile directory |
114 | */ | 114 | */ |
115 | 115 | ||
116 | static ctl_table unaligned_subtable[] = { | 116 | static struct ctl_table unaligned_subtable[] = { |
117 | { | 117 | { |
118 | .procname = "enabled", | 118 | .procname = "enabled", |
119 | .data = &unaligned_fixup, | 119 | .data = &unaligned_fixup, |
@@ -138,7 +138,7 @@ static ctl_table unaligned_subtable[] = { | |||
138 | {} | 138 | {} |
139 | }; | 139 | }; |
140 | 140 | ||
141 | static ctl_table unaligned_table[] = { | 141 | static struct ctl_table unaligned_table[] = { |
142 | { | 142 | { |
143 | .procname = "unaligned_fixup", | 143 | .procname = "unaligned_fixup", |
144 | .mode = 0555, | 144 | .mode = 0555, |
diff --git a/arch/x86/include/asm/signal.h b/arch/x86/include/asm/signal.h index 35e67a457182..31eab867e6d3 100644 --- a/arch/x86/include/asm/signal.h +++ b/arch/x86/include/asm/signal.h | |||
@@ -92,12 +92,6 @@ static inline int __gen_sigismember(sigset_t *set, int _sig) | |||
92 | ? __const_sigismember((set), (sig)) \ | 92 | ? __const_sigismember((set), (sig)) \ |
93 | : __gen_sigismember((set), (sig))) | 93 | : __gen_sigismember((set), (sig))) |
94 | 94 | ||
95 | static inline int sigfindinword(unsigned long word) | ||
96 | { | ||
97 | asm("bsfl %1,%0" : "=r"(word) : "rm"(word) : "cc"); | ||
98 | return word; | ||
99 | } | ||
100 | |||
101 | struct pt_regs; | 95 | struct pt_regs; |
102 | 96 | ||
103 | #else /* __i386__ */ | 97 | #else /* __i386__ */ |
diff --git a/block/bounce.c b/block/bounce.c index 523918b8c6dc..ab21ba203d5c 100644 --- a/block/bounce.c +++ b/block/bounce.c | |||
@@ -3,6 +3,8 @@ | |||
3 | * - Split from highmem.c | 3 | * - Split from highmem.c |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
7 | |||
6 | #include <linux/mm.h> | 8 | #include <linux/mm.h> |
7 | #include <linux/export.h> | 9 | #include <linux/export.h> |
8 | #include <linux/swap.h> | 10 | #include <linux/swap.h> |
@@ -15,6 +17,7 @@ | |||
15 | #include <linux/hash.h> | 17 | #include <linux/hash.h> |
16 | #include <linux/highmem.h> | 18 | #include <linux/highmem.h> |
17 | #include <linux/bootmem.h> | 19 | #include <linux/bootmem.h> |
20 | #include <linux/printk.h> | ||
18 | #include <asm/tlbflush.h> | 21 | #include <asm/tlbflush.h> |
19 | 22 | ||
20 | #include <trace/events/block.h> | 23 | #include <trace/events/block.h> |
@@ -34,7 +37,7 @@ static __init int init_emergency_pool(void) | |||
34 | 37 | ||
35 | page_pool = mempool_create_page_pool(POOL_SIZE, 0); | 38 | page_pool = mempool_create_page_pool(POOL_SIZE, 0); |
36 | BUG_ON(!page_pool); | 39 | BUG_ON(!page_pool); |
37 | printk("bounce pool size: %d pages\n", POOL_SIZE); | 40 | pr_info("pool size: %d pages\n", POOL_SIZE); |
38 | 41 | ||
39 | return 0; | 42 | return 0; |
40 | } | 43 | } |
@@ -86,7 +89,7 @@ int init_emergency_isa_pool(void) | |||
86 | mempool_free_pages, (void *) 0); | 89 | mempool_free_pages, (void *) 0); |
87 | BUG_ON(!isa_page_pool); | 90 | BUG_ON(!isa_page_pool); |
88 | 91 | ||
89 | printk("isa bounce pool size: %d pages\n", ISA_POOL_SIZE); | 92 | pr_info("isa pool size: %d pages\n", ISA_POOL_SIZE); |
90 | return 0; | 93 | return 0; |
91 | } | 94 | } |
92 | 95 | ||
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 56a027d6115e..fb31b8ee4372 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -243,14 +243,11 @@ static int nbd_send_req(struct nbd_device *nbd, struct request *req) | |||
243 | struct nbd_request request; | 243 | struct nbd_request request; |
244 | unsigned long size = blk_rq_bytes(req); | 244 | unsigned long size = blk_rq_bytes(req); |
245 | 245 | ||
246 | memset(&request, 0, sizeof(request)); | ||
246 | request.magic = htonl(NBD_REQUEST_MAGIC); | 247 | request.magic = htonl(NBD_REQUEST_MAGIC); |
247 | request.type = htonl(nbd_cmd(req)); | 248 | request.type = htonl(nbd_cmd(req)); |
248 | 249 | ||
249 | if (nbd_cmd(req) == NBD_CMD_FLUSH) { | 250 | if (nbd_cmd(req) != NBD_CMD_FLUSH && nbd_cmd(req) != NBD_CMD_DISC) { |
250 | /* Other values are reserved for FLUSH requests. */ | ||
251 | request.from = 0; | ||
252 | request.len = 0; | ||
253 | } else { | ||
254 | request.from = cpu_to_be64((u64)blk_rq_pos(req) << 9); | 251 | request.from = cpu_to_be64((u64)blk_rq_pos(req) << 9); |
255 | request.len = htonl(size); | 252 | request.len = htonl(size); |
256 | } | 253 | } |
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 49ac5662585b..2a44767891f5 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c | |||
@@ -3470,7 +3470,7 @@ static int cdrom_print_info(const char *header, int val, char *info, | |||
3470 | return 0; | 3470 | return 0; |
3471 | } | 3471 | } |
3472 | 3472 | ||
3473 | static int cdrom_sysctl_info(ctl_table *ctl, int write, | 3473 | static int cdrom_sysctl_info(struct ctl_table *ctl, int write, |
3474 | void __user *buffer, size_t *lenp, loff_t *ppos) | 3474 | void __user *buffer, size_t *lenp, loff_t *ppos) |
3475 | { | 3475 | { |
3476 | int pos; | 3476 | int pos; |
@@ -3583,7 +3583,7 @@ static void cdrom_update_settings(void) | |||
3583 | mutex_unlock(&cdrom_mutex); | 3583 | mutex_unlock(&cdrom_mutex); |
3584 | } | 3584 | } |
3585 | 3585 | ||
3586 | static int cdrom_sysctl_handler(ctl_table *ctl, int write, | 3586 | static int cdrom_sysctl_handler(struct ctl_table *ctl, int write, |
3587 | void __user *buffer, size_t *lenp, loff_t *ppos) | 3587 | void __user *buffer, size_t *lenp, loff_t *ppos) |
3588 | { | 3588 | { |
3589 | int ret; | 3589 | int ret; |
@@ -3609,7 +3609,7 @@ static int cdrom_sysctl_handler(ctl_table *ctl, int write, | |||
3609 | } | 3609 | } |
3610 | 3610 | ||
3611 | /* Place files in /proc/sys/dev/cdrom */ | 3611 | /* Place files in /proc/sys/dev/cdrom */ |
3612 | static ctl_table cdrom_table[] = { | 3612 | static struct ctl_table cdrom_table[] = { |
3613 | { | 3613 | { |
3614 | .procname = "info", | 3614 | .procname = "info", |
3615 | .data = &cdrom_sysctl_settings.info, | 3615 | .data = &cdrom_sysctl_settings.info, |
@@ -3655,7 +3655,7 @@ static ctl_table cdrom_table[] = { | |||
3655 | { } | 3655 | { } |
3656 | }; | 3656 | }; |
3657 | 3657 | ||
3658 | static ctl_table cdrom_cdrom_table[] = { | 3658 | static struct ctl_table cdrom_cdrom_table[] = { |
3659 | { | 3659 | { |
3660 | .procname = "cdrom", | 3660 | .procname = "cdrom", |
3661 | .maxlen = 0, | 3661 | .maxlen = 0, |
@@ -3666,7 +3666,7 @@ static ctl_table cdrom_cdrom_table[] = { | |||
3666 | }; | 3666 | }; |
3667 | 3667 | ||
3668 | /* Make sure that /proc/sys/dev is there */ | 3668 | /* Make sure that /proc/sys/dev is there */ |
3669 | static ctl_table cdrom_root_table[] = { | 3669 | static struct ctl_table cdrom_root_table[] = { |
3670 | { | 3670 | { |
3671 | .procname = "dev", | 3671 | .procname = "dev", |
3672 | .maxlen = 0, | 3672 | .maxlen = 0, |
diff --git a/drivers/char/random.c b/drivers/char/random.c index 06cea7ff3a7c..4ad71ef2cd59 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -1582,10 +1582,10 @@ static int proc_do_uuid(struct ctl_table *table, int write, | |||
1582 | /* | 1582 | /* |
1583 | * Return entropy available scaled to integral bits | 1583 | * Return entropy available scaled to integral bits |
1584 | */ | 1584 | */ |
1585 | static int proc_do_entropy(ctl_table *table, int write, | 1585 | static int proc_do_entropy(struct ctl_table *table, int write, |
1586 | void __user *buffer, size_t *lenp, loff_t *ppos) | 1586 | void __user *buffer, size_t *lenp, loff_t *ppos) |
1587 | { | 1587 | { |
1588 | ctl_table fake_table; | 1588 | struct ctl_table fake_table; |
1589 | int entropy_count; | 1589 | int entropy_count; |
1590 | 1590 | ||
1591 | entropy_count = *(int *)table->data >> ENTROPY_SHIFT; | 1591 | entropy_count = *(int *)table->data >> ENTROPY_SHIFT; |
diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c index 92ed045a5f93..3b470801a04f 100644 --- a/drivers/parport/procfs.c +++ b/drivers/parport/procfs.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #define PARPORT_MIN_SPINTIME_VALUE 1 | 31 | #define PARPORT_MIN_SPINTIME_VALUE 1 |
32 | #define PARPORT_MAX_SPINTIME_VALUE 1000 | 32 | #define PARPORT_MAX_SPINTIME_VALUE 1000 |
33 | 33 | ||
34 | static int do_active_device(ctl_table *table, int write, | 34 | static int do_active_device(struct ctl_table *table, int write, |
35 | void __user *result, size_t *lenp, loff_t *ppos) | 35 | void __user *result, size_t *lenp, loff_t *ppos) |
36 | { | 36 | { |
37 | struct parport *port = (struct parport *)table->extra1; | 37 | struct parport *port = (struct parport *)table->extra1; |
@@ -68,7 +68,7 @@ static int do_active_device(ctl_table *table, int write, | |||
68 | } | 68 | } |
69 | 69 | ||
70 | #ifdef CONFIG_PARPORT_1284 | 70 | #ifdef CONFIG_PARPORT_1284 |
71 | static int do_autoprobe(ctl_table *table, int write, | 71 | static int do_autoprobe(struct ctl_table *table, int write, |
72 | void __user *result, size_t *lenp, loff_t *ppos) | 72 | void __user *result, size_t *lenp, loff_t *ppos) |
73 | { | 73 | { |
74 | struct parport_device_info *info = table->extra2; | 74 | struct parport_device_info *info = table->extra2; |
@@ -110,9 +110,9 @@ static int do_autoprobe(ctl_table *table, int write, | |||
110 | } | 110 | } |
111 | #endif /* IEEE1284.3 support. */ | 111 | #endif /* IEEE1284.3 support. */ |
112 | 112 | ||
113 | static int do_hardware_base_addr (ctl_table *table, int write, | 113 | static int do_hardware_base_addr(struct ctl_table *table, int write, |
114 | void __user *result, | 114 | void __user *result, |
115 | size_t *lenp, loff_t *ppos) | 115 | size_t *lenp, loff_t *ppos) |
116 | { | 116 | { |
117 | struct parport *port = (struct parport *)table->extra1; | 117 | struct parport *port = (struct parport *)table->extra1; |
118 | char buffer[20]; | 118 | char buffer[20]; |
@@ -138,9 +138,9 @@ static int do_hardware_base_addr (ctl_table *table, int write, | |||
138 | return copy_to_user(result, buffer, len) ? -EFAULT : 0; | 138 | return copy_to_user(result, buffer, len) ? -EFAULT : 0; |
139 | } | 139 | } |
140 | 140 | ||
141 | static int do_hardware_irq (ctl_table *table, int write, | 141 | static int do_hardware_irq(struct ctl_table *table, int write, |
142 | void __user *result, | 142 | void __user *result, |
143 | size_t *lenp, loff_t *ppos) | 143 | size_t *lenp, loff_t *ppos) |
144 | { | 144 | { |
145 | struct parport *port = (struct parport *)table->extra1; | 145 | struct parport *port = (struct parport *)table->extra1; |
146 | char buffer[20]; | 146 | char buffer[20]; |
@@ -166,9 +166,9 @@ static int do_hardware_irq (ctl_table *table, int write, | |||
166 | return copy_to_user(result, buffer, len) ? -EFAULT : 0; | 166 | return copy_to_user(result, buffer, len) ? -EFAULT : 0; |
167 | } | 167 | } |
168 | 168 | ||
169 | static int do_hardware_dma (ctl_table *table, int write, | 169 | static int do_hardware_dma(struct ctl_table *table, int write, |
170 | void __user *result, | 170 | void __user *result, |
171 | size_t *lenp, loff_t *ppos) | 171 | size_t *lenp, loff_t *ppos) |
172 | { | 172 | { |
173 | struct parport *port = (struct parport *)table->extra1; | 173 | struct parport *port = (struct parport *)table->extra1; |
174 | char buffer[20]; | 174 | char buffer[20]; |
@@ -194,9 +194,9 @@ static int do_hardware_dma (ctl_table *table, int write, | |||
194 | return copy_to_user(result, buffer, len) ? -EFAULT : 0; | 194 | return copy_to_user(result, buffer, len) ? -EFAULT : 0; |
195 | } | 195 | } |
196 | 196 | ||
197 | static int do_hardware_modes (ctl_table *table, int write, | 197 | static int do_hardware_modes(struct ctl_table *table, int write, |
198 | void __user *result, | 198 | void __user *result, |
199 | size_t *lenp, loff_t *ppos) | 199 | size_t *lenp, loff_t *ppos) |
200 | { | 200 | { |
201 | struct parport *port = (struct parport *)table->extra1; | 201 | struct parport *port = (struct parport *)table->extra1; |
202 | char buffer[40]; | 202 | char buffer[40]; |
@@ -255,11 +255,11 @@ PARPORT_MAX_SPINTIME_VALUE; | |||
255 | 255 | ||
256 | struct parport_sysctl_table { | 256 | struct parport_sysctl_table { |
257 | struct ctl_table_header *sysctl_header; | 257 | struct ctl_table_header *sysctl_header; |
258 | ctl_table vars[12]; | 258 | struct ctl_table vars[12]; |
259 | ctl_table device_dir[2]; | 259 | struct ctl_table device_dir[2]; |
260 | ctl_table port_dir[2]; | 260 | struct ctl_table port_dir[2]; |
261 | ctl_table parport_dir[2]; | 261 | struct ctl_table parport_dir[2]; |
262 | ctl_table dev_dir[2]; | 262 | struct ctl_table dev_dir[2]; |
263 | }; | 263 | }; |
264 | 264 | ||
265 | static const struct parport_sysctl_table parport_sysctl_template = { | 265 | static const struct parport_sysctl_table parport_sysctl_template = { |
@@ -369,12 +369,12 @@ static const struct parport_sysctl_table parport_sysctl_template = { | |||
369 | struct parport_device_sysctl_table | 369 | struct parport_device_sysctl_table |
370 | { | 370 | { |
371 | struct ctl_table_header *sysctl_header; | 371 | struct ctl_table_header *sysctl_header; |
372 | ctl_table vars[2]; | 372 | struct ctl_table vars[2]; |
373 | ctl_table device_dir[2]; | 373 | struct ctl_table device_dir[2]; |
374 | ctl_table devices_root_dir[2]; | 374 | struct ctl_table devices_root_dir[2]; |
375 | ctl_table port_dir[2]; | 375 | struct ctl_table port_dir[2]; |
376 | ctl_table parport_dir[2]; | 376 | struct ctl_table parport_dir[2]; |
377 | ctl_table dev_dir[2]; | 377 | struct ctl_table dev_dir[2]; |
378 | }; | 378 | }; |
379 | 379 | ||
380 | static const struct parport_device_sysctl_table | 380 | static const struct parport_device_sysctl_table |
@@ -422,10 +422,10 @@ parport_device_sysctl_template = { | |||
422 | struct parport_default_sysctl_table | 422 | struct parport_default_sysctl_table |
423 | { | 423 | { |
424 | struct ctl_table_header *sysctl_header; | 424 | struct ctl_table_header *sysctl_header; |
425 | ctl_table vars[3]; | 425 | struct ctl_table vars[3]; |
426 | ctl_table default_dir[2]; | 426 | struct ctl_table default_dir[2]; |
427 | ctl_table parport_dir[2]; | 427 | struct ctl_table parport_dir[2]; |
428 | ctl_table dev_dir[2]; | 428 | struct ctl_table dev_dir[2]; |
429 | }; | 429 | }; |
430 | 430 | ||
431 | static struct parport_default_sysctl_table | 431 | static struct parport_default_sysctl_table |
diff --git a/drivers/rapidio/devices/tsi721.c b/drivers/rapidio/devices/tsi721.c index 1753dc693c15..2ca1a0b3ad57 100644 --- a/drivers/rapidio/devices/tsi721.c +++ b/drivers/rapidio/devices/tsi721.c | |||
@@ -768,15 +768,10 @@ static int tsi721_enable_msix(struct tsi721_device *priv) | |||
768 | } | 768 | } |
769 | #endif /* CONFIG_RAPIDIO_DMA_ENGINE */ | 769 | #endif /* CONFIG_RAPIDIO_DMA_ENGINE */ |
770 | 770 | ||
771 | err = pci_enable_msix(priv->pdev, entries, ARRAY_SIZE(entries)); | 771 | err = pci_enable_msix_exact(priv->pdev, entries, ARRAY_SIZE(entries)); |
772 | if (err) { | 772 | if (err) { |
773 | if (err > 0) | 773 | dev_err(&priv->pdev->dev, |
774 | dev_info(&priv->pdev->dev, | 774 | "Failed to enable MSI-X (err=%d)\n", err); |
775 | "Only %d MSI-X vectors available, " | ||
776 | "not using MSI-X\n", err); | ||
777 | else | ||
778 | dev_err(&priv->pdev->dev, | ||
779 | "Failed to enable MSI-X (err=%d)\n", err); | ||
780 | return err; | 775 | return err; |
781 | } | 776 | } |
782 | 777 | ||
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 2e565f8e5165..71988b69eca6 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -386,12 +386,12 @@ config RTC_DRV_PCF8583 | |||
386 | will be called rtc-pcf8583. | 386 | will be called rtc-pcf8583. |
387 | 387 | ||
388 | config RTC_DRV_M41T80 | 388 | config RTC_DRV_M41T80 |
389 | tristate "ST M41T62/65/M41T80/81/82/83/84/85/87" | 389 | tristate "ST M41T62/65/M41T80/81/82/83/84/85/87 and compatible" |
390 | help | 390 | help |
391 | If you say Y here you will get support for the ST M41T60 | 391 | If you say Y here you will get support for the ST M41T60 |
392 | and M41T80 RTC chips series. Currently, the following chips are | 392 | and M41T80 RTC chips series. Currently, the following chips are |
393 | supported: M41T62, M41T65, M41T80, M41T81, M41T82, M41T83, M41ST84, | 393 | supported: M41T62, M41T65, M41T80, M41T81, M41T82, M41T83, M41ST84, |
394 | M41ST85, and M41ST87. | 394 | M41ST85, M41ST87, and MicroCrystal RV4162. |
395 | 395 | ||
396 | This driver can also be built as a module. If so, the module | 396 | This driver can also be built as a module. If so, the module |
397 | will be called rtc-m41t80. | 397 | will be called rtc-m41t80. |
@@ -573,6 +573,17 @@ config RTC_DRV_DS1305 | |||
573 | This driver can also be built as a module. If so, the module | 573 | This driver can also be built as a module. If so, the module |
574 | will be called rtc-ds1305. | 574 | will be called rtc-ds1305. |
575 | 575 | ||
576 | config RTC_DRV_DS1343 | ||
577 | select REGMAP_SPI | ||
578 | tristate "Dallas/Maxim DS1343/DS1344" | ||
579 | help | ||
580 | If you say yes here you get support for the | ||
581 | Dallas/Maxim DS1343 and DS1344 real time clock chips. | ||
582 | Support for trickle charger, alarm is provided. | ||
583 | |||
584 | This driver can also be built as a module. If so, the module | ||
585 | will be called rtc-ds1343. | ||
586 | |||
576 | config RTC_DRV_DS1347 | 587 | config RTC_DRV_DS1347 |
577 | tristate "Dallas/Maxim DS1347" | 588 | tristate "Dallas/Maxim DS1347" |
578 | help | 589 | help |
@@ -650,6 +661,14 @@ config RTC_DRV_RX4581 | |||
650 | This driver can also be built as a module. If so the module | 661 | This driver can also be built as a module. If so the module |
651 | will be called rtc-rx4581. | 662 | will be called rtc-rx4581. |
652 | 663 | ||
664 | config RTC_DRV_MCP795 | ||
665 | tristate "Microchip MCP795" | ||
666 | help | ||
667 | If you say yes here you will get support for the Microchip MCP795. | ||
668 | |||
669 | This driver can also be built as a module. If so the module | ||
670 | will be called rtc-mcp795. | ||
671 | |||
653 | endif # SPI_MASTER | 672 | endif # SPI_MASTER |
654 | 673 | ||
655 | comment "Platform RTC drivers" | 674 | comment "Platform RTC drivers" |
@@ -758,6 +777,16 @@ config RTC_DRV_DA9055 | |||
758 | This driver can also be built as a module. If so, the module | 777 | This driver can also be built as a module. If so, the module |
759 | will be called rtc-da9055 | 778 | will be called rtc-da9055 |
760 | 779 | ||
780 | config RTC_DRV_DA9063 | ||
781 | tristate "Dialog Semiconductor DA9063 RTC" | ||
782 | depends on MFD_DA9063 | ||
783 | help | ||
784 | If you say yes here you will get support for the RTC subsystem | ||
785 | of the Dialog Semiconductor DA9063. | ||
786 | |||
787 | This driver can also be built as a module. If so, the module | ||
788 | will be called "rtc-da9063". | ||
789 | |||
761 | config RTC_DRV_EFI | 790 | config RTC_DRV_EFI |
762 | tristate "EFI RTC" | 791 | tristate "EFI RTC" |
763 | depends on IA64 | 792 | depends on IA64 |
@@ -1327,6 +1356,15 @@ config RTC_DRV_MOXART | |||
1327 | This driver can also be built as a module. If so, the module | 1356 | This driver can also be built as a module. If so, the module |
1328 | will be called rtc-moxart | 1357 | will be called rtc-moxart |
1329 | 1358 | ||
1359 | config RTC_DRV_XGENE | ||
1360 | tristate "APM X-Gene RTC" | ||
1361 | help | ||
1362 | If you say yes here you get support for the APM X-Gene SoC real time | ||
1363 | clock. | ||
1364 | |||
1365 | This driver can also be built as a module, if so, the module | ||
1366 | will be called "rtc-xgene". | ||
1367 | |||
1330 | comment "HID Sensor RTC drivers" | 1368 | comment "HID Sensor RTC drivers" |
1331 | 1369 | ||
1332 | config RTC_DRV_HID_SENSOR_TIME | 1370 | config RTC_DRV_HID_SENSOR_TIME |
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 40a09915c8f6..70347d041d10 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
@@ -32,6 +32,7 @@ obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o | |||
32 | obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o | 32 | obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o |
33 | obj-$(CONFIG_RTC_DRV_DA9052) += rtc-da9052.o | 33 | obj-$(CONFIG_RTC_DRV_DA9052) += rtc-da9052.o |
34 | obj-$(CONFIG_RTC_DRV_DA9055) += rtc-da9055.o | 34 | obj-$(CONFIG_RTC_DRV_DA9055) += rtc-da9055.o |
35 | obj-$(CONFIG_RTC_DRV_DA9063) += rtc-da9063.o | ||
35 | obj-$(CONFIG_RTC_DRV_DAVINCI) += rtc-davinci.o | 36 | obj-$(CONFIG_RTC_DRV_DAVINCI) += rtc-davinci.o |
36 | obj-$(CONFIG_RTC_DRV_DM355EVM) += rtc-dm355evm.o | 37 | obj-$(CONFIG_RTC_DRV_DM355EVM) += rtc-dm355evm.o |
37 | obj-$(CONFIG_RTC_DRV_VRTC) += rtc-mrst.o | 38 | obj-$(CONFIG_RTC_DRV_VRTC) += rtc-mrst.o |
@@ -40,6 +41,7 @@ obj-$(CONFIG_RTC_DRV_DS1286) += rtc-ds1286.o | |||
40 | obj-$(CONFIG_RTC_DRV_DS1302) += rtc-ds1302.o | 41 | obj-$(CONFIG_RTC_DRV_DS1302) += rtc-ds1302.o |
41 | obj-$(CONFIG_RTC_DRV_DS1305) += rtc-ds1305.o | 42 | obj-$(CONFIG_RTC_DRV_DS1305) += rtc-ds1305.o |
42 | obj-$(CONFIG_RTC_DRV_DS1307) += rtc-ds1307.o | 43 | obj-$(CONFIG_RTC_DRV_DS1307) += rtc-ds1307.o |
44 | obj-$(CONFIG_RTC_DRV_DS1343) += rtc-ds1343.o | ||
43 | obj-$(CONFIG_RTC_DRV_DS1347) += rtc-ds1347.o | 45 | obj-$(CONFIG_RTC_DRV_DS1347) += rtc-ds1347.o |
44 | obj-$(CONFIG_RTC_DRV_DS1374) += rtc-ds1374.o | 46 | obj-$(CONFIG_RTC_DRV_DS1374) += rtc-ds1374.o |
45 | obj-$(CONFIG_RTC_DRV_DS1390) += rtc-ds1390.o | 47 | obj-$(CONFIG_RTC_DRV_DS1390) += rtc-ds1390.o |
@@ -80,6 +82,7 @@ obj-$(CONFIG_RTC_DRV_MAX8997) += rtc-max8997.o | |||
80 | obj-$(CONFIG_RTC_DRV_MAX6902) += rtc-max6902.o | 82 | obj-$(CONFIG_RTC_DRV_MAX6902) += rtc-max6902.o |
81 | obj-$(CONFIG_RTC_DRV_MAX77686) += rtc-max77686.o | 83 | obj-$(CONFIG_RTC_DRV_MAX77686) += rtc-max77686.o |
82 | obj-$(CONFIG_RTC_DRV_MC13XXX) += rtc-mc13xxx.o | 84 | obj-$(CONFIG_RTC_DRV_MC13XXX) += rtc-mc13xxx.o |
85 | obj-$(CONFIG_RTC_DRV_MCP795) += rtc-mcp795.o | ||
83 | obj-$(CONFIG_RTC_DRV_MSM6242) += rtc-msm6242.o | 86 | obj-$(CONFIG_RTC_DRV_MSM6242) += rtc-msm6242.o |
84 | obj-$(CONFIG_RTC_DRV_MPC5121) += rtc-mpc5121.o | 87 | obj-$(CONFIG_RTC_DRV_MPC5121) += rtc-mpc5121.o |
85 | obj-$(CONFIG_RTC_DRV_MV) += rtc-mv.o | 88 | obj-$(CONFIG_RTC_DRV_MV) += rtc-mv.o |
@@ -135,5 +138,6 @@ obj-$(CONFIG_RTC_DRV_VT8500) += rtc-vt8500.o | |||
135 | obj-$(CONFIG_RTC_DRV_WM831X) += rtc-wm831x.o | 138 | obj-$(CONFIG_RTC_DRV_WM831X) += rtc-wm831x.o |
136 | obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o | 139 | obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o |
137 | obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o | 140 | obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o |
141 | obj-$(CONFIG_RTC_DRV_XGENE) += rtc-xgene.o | ||
138 | obj-$(CONFIG_RTC_DRV_SIRFSOC) += rtc-sirfsoc.o | 142 | obj-$(CONFIG_RTC_DRV_SIRFSOC) += rtc-sirfsoc.o |
139 | obj-$(CONFIG_RTC_DRV_MOXART) += rtc-moxart.o | 143 | obj-$(CONFIG_RTC_DRV_MOXART) += rtc-moxart.o |
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index c2eff6082363..5813fa52c3d4 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
@@ -292,7 +292,8 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
292 | dev_dbg(&rtc->dev, "alarm rollover: %s\n", "year"); | 292 | dev_dbg(&rtc->dev, "alarm rollover: %s\n", "year"); |
293 | do { | 293 | do { |
294 | alarm->time.tm_year++; | 294 | alarm->time.tm_year++; |
295 | } while (rtc_valid_tm(&alarm->time) != 0); | 295 | } while (!is_leap_year(alarm->time.tm_year + 1900) |
296 | && rtc_valid_tm(&alarm->time) != 0); | ||
296 | break; | 297 | break; |
297 | 298 | ||
298 | default: | 299 | default: |
@@ -300,7 +301,16 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
300 | } | 301 | } |
301 | 302 | ||
302 | done: | 303 | done: |
303 | return 0; | 304 | err = rtc_valid_tm(&alarm->time); |
305 | |||
306 | if (err) { | ||
307 | dev_warn(&rtc->dev, "invalid alarm value: %d-%d-%d %d:%d:%d\n", | ||
308 | alarm->time.tm_year + 1900, alarm->time.tm_mon + 1, | ||
309 | alarm->time.tm_mday, alarm->time.tm_hour, alarm->time.tm_min, | ||
310 | alarm->time.tm_sec); | ||
311 | } | ||
312 | |||
313 | return err; | ||
304 | } | 314 | } |
305 | 315 | ||
306 | int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | 316 | int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) |
diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c index 816504846cdd..0c6add1a38dc 100644 --- a/drivers/rtc/rtc-88pm860x.c +++ b/drivers/rtc/rtc-88pm860x.c | |||
@@ -293,7 +293,7 @@ static int pm860x_rtc_dt_init(struct platform_device *pdev, | |||
293 | int ret; | 293 | int ret; |
294 | if (!np) | 294 | if (!np) |
295 | return -ENODEV; | 295 | return -ENODEV; |
296 | np = of_find_node_by_name(np, "rtc"); | 296 | np = of_get_child_by_name(np, "rtc"); |
297 | if (!np) { | 297 | if (!np) { |
298 | dev_err(&pdev->dev, "failed to find rtc node\n"); | 298 | dev_err(&pdev->dev, "failed to find rtc node\n"); |
299 | return -ENODEV; | 299 | return -ENODEV; |
@@ -301,6 +301,7 @@ static int pm860x_rtc_dt_init(struct platform_device *pdev, | |||
301 | ret = of_property_read_u32(np, "marvell,88pm860x-vrtc", &info->vrtc); | 301 | ret = of_property_read_u32(np, "marvell,88pm860x-vrtc", &info->vrtc); |
302 | if (ret) | 302 | if (ret) |
303 | info->vrtc = 0; | 303 | info->vrtc = 0; |
304 | of_node_put(np); | ||
304 | return 0; | 305 | return 0; |
305 | } | 306 | } |
306 | #else | 307 | #else |
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c index 3281c90691c3..44fe83ee9bee 100644 --- a/drivers/rtc/rtc-at91rm9200.c +++ b/drivers/rtc/rtc-at91rm9200.c | |||
@@ -48,6 +48,7 @@ struct at91_rtc_config { | |||
48 | 48 | ||
49 | static const struct at91_rtc_config *at91_rtc_config; | 49 | static const struct at91_rtc_config *at91_rtc_config; |
50 | static DECLARE_COMPLETION(at91_rtc_updated); | 50 | static DECLARE_COMPLETION(at91_rtc_updated); |
51 | static DECLARE_COMPLETION(at91_rtc_upd_rdy); | ||
51 | static unsigned int at91_alarm_year = AT91_RTC_EPOCH; | 52 | static unsigned int at91_alarm_year = AT91_RTC_EPOCH; |
52 | static void __iomem *at91_rtc_regs; | 53 | static void __iomem *at91_rtc_regs; |
53 | static int irq; | 54 | static int irq; |
@@ -161,6 +162,8 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm) | |||
161 | 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, | 162 | 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, |
162 | tm->tm_hour, tm->tm_min, tm->tm_sec); | 163 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
163 | 164 | ||
165 | wait_for_completion(&at91_rtc_upd_rdy); | ||
166 | |||
164 | /* Stop Time/Calendar from counting */ | 167 | /* Stop Time/Calendar from counting */ |
165 | cr = at91_rtc_read(AT91_RTC_CR); | 168 | cr = at91_rtc_read(AT91_RTC_CR); |
166 | at91_rtc_write(AT91_RTC_CR, cr | AT91_RTC_UPDCAL | AT91_RTC_UPDTIM); | 169 | at91_rtc_write(AT91_RTC_CR, cr | AT91_RTC_UPDCAL | AT91_RTC_UPDTIM); |
@@ -183,7 +186,9 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm) | |||
183 | 186 | ||
184 | /* Restart Time/Calendar */ | 187 | /* Restart Time/Calendar */ |
185 | cr = at91_rtc_read(AT91_RTC_CR); | 188 | cr = at91_rtc_read(AT91_RTC_CR); |
189 | at91_rtc_write(AT91_RTC_SCCR, AT91_RTC_SECEV); | ||
186 | at91_rtc_write(AT91_RTC_CR, cr & ~(AT91_RTC_UPDCAL | AT91_RTC_UPDTIM)); | 190 | at91_rtc_write(AT91_RTC_CR, cr & ~(AT91_RTC_UPDCAL | AT91_RTC_UPDTIM)); |
191 | at91_rtc_write_ier(AT91_RTC_SECEV); | ||
187 | 192 | ||
188 | return 0; | 193 | return 0; |
189 | } | 194 | } |
@@ -290,8 +295,10 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *dev_id) | |||
290 | if (rtsr) { /* this interrupt is shared! Is it ours? */ | 295 | if (rtsr) { /* this interrupt is shared! Is it ours? */ |
291 | if (rtsr & AT91_RTC_ALARM) | 296 | if (rtsr & AT91_RTC_ALARM) |
292 | events |= (RTC_AF | RTC_IRQF); | 297 | events |= (RTC_AF | RTC_IRQF); |
293 | if (rtsr & AT91_RTC_SECEV) | 298 | if (rtsr & AT91_RTC_SECEV) { |
294 | events |= (RTC_UF | RTC_IRQF); | 299 | complete(&at91_rtc_upd_rdy); |
300 | at91_rtc_write_idr(AT91_RTC_SECEV); | ||
301 | } | ||
295 | if (rtsr & AT91_RTC_ACKUPD) | 302 | if (rtsr & AT91_RTC_ACKUPD) |
296 | complete(&at91_rtc_updated); | 303 | complete(&at91_rtc_updated); |
297 | 304 | ||
@@ -413,6 +420,11 @@ static int __init at91_rtc_probe(struct platform_device *pdev) | |||
413 | return PTR_ERR(rtc); | 420 | return PTR_ERR(rtc); |
414 | platform_set_drvdata(pdev, rtc); | 421 | platform_set_drvdata(pdev, rtc); |
415 | 422 | ||
423 | /* enable SECEV interrupt in order to initialize at91_rtc_upd_rdy | ||
424 | * completion. | ||
425 | */ | ||
426 | at91_rtc_write_ier(AT91_RTC_SECEV); | ||
427 | |||
416 | dev_info(&pdev->dev, "AT91 Real Time Clock driver.\n"); | 428 | dev_info(&pdev->dev, "AT91 Real Time Clock driver.\n"); |
417 | return 0; | 429 | return 0; |
418 | } | 430 | } |
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c index 0c53f452849d..fe4bdb06a55a 100644 --- a/drivers/rtc/rtc-bfin.c +++ b/drivers/rtc/rtc-bfin.c | |||
@@ -346,7 +346,7 @@ static int bfin_rtc_probe(struct platform_device *pdev) | |||
346 | { | 346 | { |
347 | struct bfin_rtc *rtc; | 347 | struct bfin_rtc *rtc; |
348 | struct device *dev = &pdev->dev; | 348 | struct device *dev = &pdev->dev; |
349 | int ret = 0; | 349 | int ret; |
350 | unsigned long timeout = jiffies + HZ; | 350 | unsigned long timeout = jiffies + HZ; |
351 | 351 | ||
352 | dev_dbg_stamp(dev); | 352 | dev_dbg_stamp(dev); |
@@ -361,16 +361,17 @@ static int bfin_rtc_probe(struct platform_device *pdev) | |||
361 | /* Register our RTC with the RTC framework */ | 361 | /* Register our RTC with the RTC framework */ |
362 | rtc->rtc_dev = devm_rtc_device_register(dev, pdev->name, &bfin_rtc_ops, | 362 | rtc->rtc_dev = devm_rtc_device_register(dev, pdev->name, &bfin_rtc_ops, |
363 | THIS_MODULE); | 363 | THIS_MODULE); |
364 | if (unlikely(IS_ERR(rtc->rtc_dev))) { | 364 | if (unlikely(IS_ERR(rtc->rtc_dev))) |
365 | ret = PTR_ERR(rtc->rtc_dev); | 365 | return PTR_ERR(rtc->rtc_dev); |
366 | goto err; | ||
367 | } | ||
368 | 366 | ||
369 | /* Grab the IRQ and init the hardware */ | 367 | /* Grab the IRQ and init the hardware */ |
370 | ret = devm_request_irq(dev, IRQ_RTC, bfin_rtc_interrupt, 0, | 368 | ret = devm_request_irq(dev, IRQ_RTC, bfin_rtc_interrupt, 0, |
371 | pdev->name, dev); | 369 | pdev->name, dev); |
372 | if (unlikely(ret)) | 370 | if (unlikely(ret)) |
373 | goto err; | 371 | dev_err(&pdev->dev, |
372 | "unable to request IRQ; alarm won't work, " | ||
373 | "and writes will be delayed\n"); | ||
374 | |||
374 | /* sometimes the bootloader touched things, but the write complete was not | 375 | /* sometimes the bootloader touched things, but the write complete was not |
375 | * enabled, so let's just do a quick timeout here since the IRQ will not fire ... | 376 | * enabled, so let's just do a quick timeout here since the IRQ will not fire ... |
376 | */ | 377 | */ |
@@ -381,9 +382,6 @@ static int bfin_rtc_probe(struct platform_device *pdev) | |||
381 | bfin_write_RTC_SWCNT(0); | 382 | bfin_write_RTC_SWCNT(0); |
382 | 383 | ||
383 | return 0; | 384 | return 0; |
384 | |||
385 | err: | ||
386 | return ret; | ||
387 | } | 385 | } |
388 | 386 | ||
389 | static int bfin_rtc_remove(struct platform_device *pdev) | 387 | static int bfin_rtc_remove(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index 0963c9309c74..b0e4a3eb33c7 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c | |||
@@ -647,6 +647,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) | |||
647 | int retval = 0; | 647 | int retval = 0; |
648 | unsigned char rtc_control; | 648 | unsigned char rtc_control; |
649 | unsigned address_space; | 649 | unsigned address_space; |
650 | u32 flags = 0; | ||
650 | 651 | ||
651 | /* there can be only one ... */ | 652 | /* there can be only one ... */ |
652 | if (cmos_rtc.dev) | 653 | if (cmos_rtc.dev) |
@@ -660,9 +661,12 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) | |||
660 | * REVISIT non-x86 systems may instead use memory space resources | 661 | * REVISIT non-x86 systems may instead use memory space resources |
661 | * (needing ioremap etc), not i/o space resources like this ... | 662 | * (needing ioremap etc), not i/o space resources like this ... |
662 | */ | 663 | */ |
663 | ports = request_region(ports->start, | 664 | if (RTC_IOMAPPED) |
664 | resource_size(ports), | 665 | ports = request_region(ports->start, resource_size(ports), |
665 | driver_name); | 666 | driver_name); |
667 | else | ||
668 | ports = request_mem_region(ports->start, resource_size(ports), | ||
669 | driver_name); | ||
666 | if (!ports) { | 670 | if (!ports) { |
667 | dev_dbg(dev, "i/o registers already in use\n"); | 671 | dev_dbg(dev, "i/o registers already in use\n"); |
668 | return -EBUSY; | 672 | return -EBUSY; |
@@ -699,6 +703,11 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) | |||
699 | * expect CMOS_READ and friends to handle. | 703 | * expect CMOS_READ and friends to handle. |
700 | */ | 704 | */ |
701 | if (info) { | 705 | if (info) { |
706 | if (info->flags) | ||
707 | flags = info->flags; | ||
708 | if (info->address_space) | ||
709 | address_space = info->address_space; | ||
710 | |||
702 | if (info->rtc_day_alarm && info->rtc_day_alarm < 128) | 711 | if (info->rtc_day_alarm && info->rtc_day_alarm < 128) |
703 | cmos_rtc.day_alrm = info->rtc_day_alarm; | 712 | cmos_rtc.day_alrm = info->rtc_day_alarm; |
704 | if (info->rtc_mon_alarm && info->rtc_mon_alarm < 128) | 713 | if (info->rtc_mon_alarm && info->rtc_mon_alarm < 128) |
@@ -726,18 +735,21 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) | |||
726 | 735 | ||
727 | spin_lock_irq(&rtc_lock); | 736 | spin_lock_irq(&rtc_lock); |
728 | 737 | ||
729 | /* force periodic irq to CMOS reset default of 1024Hz; | 738 | if (!(flags & CMOS_RTC_FLAGS_NOFREQ)) { |
730 | * | 739 | /* force periodic irq to CMOS reset default of 1024Hz; |
731 | * REVISIT it's been reported that at least one x86_64 ALI mobo | 740 | * |
732 | * doesn't use 32KHz here ... for portability we might need to | 741 | * REVISIT it's been reported that at least one x86_64 ALI |
733 | * do something about other clock frequencies. | 742 | * mobo doesn't use 32KHz here ... for portability we might |
734 | */ | 743 | * need to do something about other clock frequencies. |
735 | cmos_rtc.rtc->irq_freq = 1024; | 744 | */ |
736 | hpet_set_periodic_freq(cmos_rtc.rtc->irq_freq); | 745 | cmos_rtc.rtc->irq_freq = 1024; |
737 | CMOS_WRITE(RTC_REF_CLCK_32KHZ | 0x06, RTC_FREQ_SELECT); | 746 | hpet_set_periodic_freq(cmos_rtc.rtc->irq_freq); |
747 | CMOS_WRITE(RTC_REF_CLCK_32KHZ | 0x06, RTC_FREQ_SELECT); | ||
748 | } | ||
738 | 749 | ||
739 | /* disable irqs */ | 750 | /* disable irqs */ |
740 | cmos_irq_disable(&cmos_rtc, RTC_PIE | RTC_AIE | RTC_UIE); | 751 | if (is_valid_irq(rtc_irq)) |
752 | cmos_irq_disable(&cmos_rtc, RTC_PIE | RTC_AIE | RTC_UIE); | ||
741 | 753 | ||
742 | rtc_control = CMOS_READ(RTC_CONTROL); | 754 | rtc_control = CMOS_READ(RTC_CONTROL); |
743 | 755 | ||
@@ -802,14 +814,18 @@ cleanup1: | |||
802 | cmos_rtc.dev = NULL; | 814 | cmos_rtc.dev = NULL; |
803 | rtc_device_unregister(cmos_rtc.rtc); | 815 | rtc_device_unregister(cmos_rtc.rtc); |
804 | cleanup0: | 816 | cleanup0: |
805 | release_region(ports->start, resource_size(ports)); | 817 | if (RTC_IOMAPPED) |
818 | release_region(ports->start, resource_size(ports)); | ||
819 | else | ||
820 | release_mem_region(ports->start, resource_size(ports)); | ||
806 | return retval; | 821 | return retval; |
807 | } | 822 | } |
808 | 823 | ||
809 | static void cmos_do_shutdown(void) | 824 | static void cmos_do_shutdown(int rtc_irq) |
810 | { | 825 | { |
811 | spin_lock_irq(&rtc_lock); | 826 | spin_lock_irq(&rtc_lock); |
812 | cmos_irq_disable(&cmos_rtc, RTC_IRQMASK); | 827 | if (is_valid_irq(rtc_irq)) |
828 | cmos_irq_disable(&cmos_rtc, RTC_IRQMASK); | ||
813 | spin_unlock_irq(&rtc_lock); | 829 | spin_unlock_irq(&rtc_lock); |
814 | } | 830 | } |
815 | 831 | ||
@@ -818,7 +834,7 @@ static void __exit cmos_do_remove(struct device *dev) | |||
818 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | 834 | struct cmos_rtc *cmos = dev_get_drvdata(dev); |
819 | struct resource *ports; | 835 | struct resource *ports; |
820 | 836 | ||
821 | cmos_do_shutdown(); | 837 | cmos_do_shutdown(cmos->irq); |
822 | 838 | ||
823 | sysfs_remove_bin_file(&dev->kobj, &nvram); | 839 | sysfs_remove_bin_file(&dev->kobj, &nvram); |
824 | 840 | ||
@@ -831,7 +847,10 @@ static void __exit cmos_do_remove(struct device *dev) | |||
831 | cmos->rtc = NULL; | 847 | cmos->rtc = NULL; |
832 | 848 | ||
833 | ports = cmos->iomem; | 849 | ports = cmos->iomem; |
834 | release_region(ports->start, resource_size(ports)); | 850 | if (RTC_IOMAPPED) |
851 | release_region(ports->start, resource_size(ports)); | ||
852 | else | ||
853 | release_mem_region(ports->start, resource_size(ports)); | ||
835 | cmos->iomem = NULL; | 854 | cmos->iomem = NULL; |
836 | 855 | ||
837 | cmos->dev = NULL; | 856 | cmos->dev = NULL; |
@@ -1065,10 +1084,13 @@ static void __exit cmos_pnp_remove(struct pnp_dev *pnp) | |||
1065 | 1084 | ||
1066 | static void cmos_pnp_shutdown(struct pnp_dev *pnp) | 1085 | static void cmos_pnp_shutdown(struct pnp_dev *pnp) |
1067 | { | 1086 | { |
1068 | if (system_state == SYSTEM_POWER_OFF && !cmos_poweroff(&pnp->dev)) | 1087 | struct device *dev = &pnp->dev; |
1088 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | ||
1089 | |||
1090 | if (system_state == SYSTEM_POWER_OFF && !cmos_poweroff(dev)) | ||
1069 | return; | 1091 | return; |
1070 | 1092 | ||
1071 | cmos_do_shutdown(); | 1093 | cmos_do_shutdown(cmos->irq); |
1072 | } | 1094 | } |
1073 | 1095 | ||
1074 | static const struct pnp_device_id rtc_ids[] = { | 1096 | static const struct pnp_device_id rtc_ids[] = { |
@@ -1143,11 +1165,21 @@ static inline void cmos_of_init(struct platform_device *pdev) {} | |||
1143 | 1165 | ||
1144 | static int __init cmos_platform_probe(struct platform_device *pdev) | 1166 | static int __init cmos_platform_probe(struct platform_device *pdev) |
1145 | { | 1167 | { |
1168 | struct resource *resource; | ||
1169 | int irq; | ||
1170 | |||
1146 | cmos_of_init(pdev); | 1171 | cmos_of_init(pdev); |
1147 | cmos_wake_setup(&pdev->dev); | 1172 | cmos_wake_setup(&pdev->dev); |
1148 | return cmos_do_probe(&pdev->dev, | 1173 | |
1149 | platform_get_resource(pdev, IORESOURCE_IO, 0), | 1174 | if (RTC_IOMAPPED) |
1150 | platform_get_irq(pdev, 0)); | 1175 | resource = platform_get_resource(pdev, IORESOURCE_IO, 0); |
1176 | else | ||
1177 | resource = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1178 | irq = platform_get_irq(pdev, 0); | ||
1179 | if (irq < 0) | ||
1180 | irq = -1; | ||
1181 | |||
1182 | return cmos_do_probe(&pdev->dev, resource, irq); | ||
1151 | } | 1183 | } |
1152 | 1184 | ||
1153 | static int __exit cmos_platform_remove(struct platform_device *pdev) | 1185 | static int __exit cmos_platform_remove(struct platform_device *pdev) |
@@ -1158,10 +1190,13 @@ static int __exit cmos_platform_remove(struct platform_device *pdev) | |||
1158 | 1190 | ||
1159 | static void cmos_platform_shutdown(struct platform_device *pdev) | 1191 | static void cmos_platform_shutdown(struct platform_device *pdev) |
1160 | { | 1192 | { |
1161 | if (system_state == SYSTEM_POWER_OFF && !cmos_poweroff(&pdev->dev)) | 1193 | struct device *dev = &pdev->dev; |
1194 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | ||
1195 | |||
1196 | if (system_state == SYSTEM_POWER_OFF && !cmos_poweroff(dev)) | ||
1162 | return; | 1197 | return; |
1163 | 1198 | ||
1164 | cmos_do_shutdown(); | 1199 | cmos_do_shutdown(cmos->irq); |
1165 | } | 1200 | } |
1166 | 1201 | ||
1167 | /* work with hotplug and coldplug */ | 1202 | /* work with hotplug and coldplug */ |
diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c index a1cbf64242a5..e5c9486cf452 100644 --- a/drivers/rtc/rtc-da9052.c +++ b/drivers/rtc/rtc-da9052.c | |||
@@ -20,28 +20,28 @@ | |||
20 | #include <linux/mfd/da9052/da9052.h> | 20 | #include <linux/mfd/da9052/da9052.h> |
21 | #include <linux/mfd/da9052/reg.h> | 21 | #include <linux/mfd/da9052/reg.h> |
22 | 22 | ||
23 | #define rtc_err(da9052, fmt, ...) \ | 23 | #define rtc_err(rtc, fmt, ...) \ |
24 | dev_err(da9052->dev, "%s: " fmt, __func__, ##__VA_ARGS__) | 24 | dev_err(rtc->da9052->dev, "%s: " fmt, __func__, ##__VA_ARGS__) |
25 | 25 | ||
26 | struct da9052_rtc { | 26 | struct da9052_rtc { |
27 | struct rtc_device *rtc; | 27 | struct rtc_device *rtc; |
28 | struct da9052 *da9052; | 28 | struct da9052 *da9052; |
29 | }; | 29 | }; |
30 | 30 | ||
31 | static int da9052_rtc_enable_alarm(struct da9052 *da9052, bool enable) | 31 | static int da9052_rtc_enable_alarm(struct da9052_rtc *rtc, bool enable) |
32 | { | 32 | { |
33 | int ret; | 33 | int ret; |
34 | if (enable) { | 34 | if (enable) { |
35 | ret = da9052_reg_update(da9052, DA9052_ALARM_Y_REG, | 35 | ret = da9052_reg_update(rtc->da9052, DA9052_ALARM_Y_REG, |
36 | DA9052_ALARM_Y_ALARM_ON, | 36 | DA9052_ALARM_Y_ALARM_ON|DA9052_ALARM_Y_TICK_ON, |
37 | DA9052_ALARM_Y_ALARM_ON); | 37 | DA9052_ALARM_Y_ALARM_ON); |
38 | if (ret != 0) | 38 | if (ret != 0) |
39 | rtc_err(da9052, "Failed to enable ALM: %d\n", ret); | 39 | rtc_err(rtc, "Failed to enable ALM: %d\n", ret); |
40 | } else { | 40 | } else { |
41 | ret = da9052_reg_update(da9052, DA9052_ALARM_Y_REG, | 41 | ret = da9052_reg_update(rtc->da9052, DA9052_ALARM_Y_REG, |
42 | DA9052_ALARM_Y_ALARM_ON, 0); | 42 | DA9052_ALARM_Y_ALARM_ON|DA9052_ALARM_Y_TICK_ON, 0); |
43 | if (ret != 0) | 43 | if (ret != 0) |
44 | rtc_err(da9052, "Write error: %d\n", ret); | 44 | rtc_err(rtc, "Write error: %d\n", ret); |
45 | } | 45 | } |
46 | return ret; | 46 | return ret; |
47 | } | 47 | } |
@@ -49,31 +49,20 @@ static int da9052_rtc_enable_alarm(struct da9052 *da9052, bool enable) | |||
49 | static irqreturn_t da9052_rtc_irq(int irq, void *data) | 49 | static irqreturn_t da9052_rtc_irq(int irq, void *data) |
50 | { | 50 | { |
51 | struct da9052_rtc *rtc = data; | 51 | struct da9052_rtc *rtc = data; |
52 | int ret; | ||
53 | 52 | ||
54 | ret = da9052_reg_read(rtc->da9052, DA9052_ALARM_MI_REG); | 53 | rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_AF); |
55 | if (ret < 0) { | ||
56 | rtc_err(rtc->da9052, "Read error: %d\n", ret); | ||
57 | return IRQ_NONE; | ||
58 | } | ||
59 | |||
60 | if (ret & DA9052_ALARMMI_ALARMTYPE) { | ||
61 | da9052_rtc_enable_alarm(rtc->da9052, 0); | ||
62 | rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_AF); | ||
63 | } else | ||
64 | rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_PF); | ||
65 | 54 | ||
66 | return IRQ_HANDLED; | 55 | return IRQ_HANDLED; |
67 | } | 56 | } |
68 | 57 | ||
69 | static int da9052_read_alarm(struct da9052 *da9052, struct rtc_time *rtc_tm) | 58 | static int da9052_read_alarm(struct da9052_rtc *rtc, struct rtc_time *rtc_tm) |
70 | { | 59 | { |
71 | int ret; | 60 | int ret; |
72 | uint8_t v[5]; | 61 | uint8_t v[5]; |
73 | 62 | ||
74 | ret = da9052_group_read(da9052, DA9052_ALARM_MI_REG, 5, v); | 63 | ret = da9052_group_read(rtc->da9052, DA9052_ALARM_MI_REG, 5, v); |
75 | if (ret != 0) { | 64 | if (ret != 0) { |
76 | rtc_err(da9052, "Failed to group read ALM: %d\n", ret); | 65 | rtc_err(rtc, "Failed to group read ALM: %d\n", ret); |
77 | return ret; | 66 | return ret; |
78 | } | 67 | } |
79 | 68 | ||
@@ -84,23 +73,33 @@ static int da9052_read_alarm(struct da9052 *da9052, struct rtc_time *rtc_tm) | |||
84 | rtc_tm->tm_min = v[0] & DA9052_RTC_MIN; | 73 | rtc_tm->tm_min = v[0] & DA9052_RTC_MIN; |
85 | 74 | ||
86 | ret = rtc_valid_tm(rtc_tm); | 75 | ret = rtc_valid_tm(rtc_tm); |
87 | if (ret != 0) | ||
88 | return ret; | ||
89 | return ret; | 76 | return ret; |
90 | } | 77 | } |
91 | 78 | ||
92 | static int da9052_set_alarm(struct da9052 *da9052, struct rtc_time *rtc_tm) | 79 | static int da9052_set_alarm(struct da9052_rtc *rtc, struct rtc_time *rtc_tm) |
93 | { | 80 | { |
81 | struct da9052 *da9052 = rtc->da9052; | ||
82 | unsigned long alm_time; | ||
94 | int ret; | 83 | int ret; |
95 | uint8_t v[3]; | 84 | uint8_t v[3]; |
96 | 85 | ||
86 | ret = rtc_tm_to_time(rtc_tm, &alm_time); | ||
87 | if (ret != 0) | ||
88 | return ret; | ||
89 | |||
90 | if (rtc_tm->tm_sec > 0) { | ||
91 | alm_time += 60 - rtc_tm->tm_sec; | ||
92 | rtc_time_to_tm(alm_time, rtc_tm); | ||
93 | } | ||
94 | BUG_ON(rtc_tm->tm_sec); /* it will cause repeated irqs if not zero */ | ||
95 | |||
97 | rtc_tm->tm_year -= 100; | 96 | rtc_tm->tm_year -= 100; |
98 | rtc_tm->tm_mon += 1; | 97 | rtc_tm->tm_mon += 1; |
99 | 98 | ||
100 | ret = da9052_reg_update(da9052, DA9052_ALARM_MI_REG, | 99 | ret = da9052_reg_update(da9052, DA9052_ALARM_MI_REG, |
101 | DA9052_RTC_MIN, rtc_tm->tm_min); | 100 | DA9052_RTC_MIN, rtc_tm->tm_min); |
102 | if (ret != 0) { | 101 | if (ret != 0) { |
103 | rtc_err(da9052, "Failed to write ALRM MIN: %d\n", ret); | 102 | rtc_err(rtc, "Failed to write ALRM MIN: %d\n", ret); |
104 | return ret; | 103 | return ret; |
105 | } | 104 | } |
106 | 105 | ||
@@ -115,22 +114,22 @@ static int da9052_set_alarm(struct da9052 *da9052, struct rtc_time *rtc_tm) | |||
115 | ret = da9052_reg_update(da9052, DA9052_ALARM_Y_REG, | 114 | ret = da9052_reg_update(da9052, DA9052_ALARM_Y_REG, |
116 | DA9052_RTC_YEAR, rtc_tm->tm_year); | 115 | DA9052_RTC_YEAR, rtc_tm->tm_year); |
117 | if (ret != 0) | 116 | if (ret != 0) |
118 | rtc_err(da9052, "Failed to write ALRM YEAR: %d\n", ret); | 117 | rtc_err(rtc, "Failed to write ALRM YEAR: %d\n", ret); |
119 | 118 | ||
120 | return ret; | 119 | return ret; |
121 | } | 120 | } |
122 | 121 | ||
123 | static int da9052_rtc_get_alarm_status(struct da9052 *da9052) | 122 | static int da9052_rtc_get_alarm_status(struct da9052_rtc *rtc) |
124 | { | 123 | { |
125 | int ret; | 124 | int ret; |
126 | 125 | ||
127 | ret = da9052_reg_read(da9052, DA9052_ALARM_Y_REG); | 126 | ret = da9052_reg_read(rtc->da9052, DA9052_ALARM_Y_REG); |
128 | if (ret < 0) { | 127 | if (ret < 0) { |
129 | rtc_err(da9052, "Failed to read ALM: %d\n", ret); | 128 | rtc_err(rtc, "Failed to read ALM: %d\n", ret); |
130 | return ret; | 129 | return ret; |
131 | } | 130 | } |
132 | ret &= DA9052_ALARM_Y_ALARM_ON; | 131 | |
133 | return (ret > 0) ? 1 : 0; | 132 | return !!(ret&DA9052_ALARM_Y_ALARM_ON); |
134 | } | 133 | } |
135 | 134 | ||
136 | static int da9052_rtc_read_time(struct device *dev, struct rtc_time *rtc_tm) | 135 | static int da9052_rtc_read_time(struct device *dev, struct rtc_time *rtc_tm) |
@@ -141,7 +140,7 @@ static int da9052_rtc_read_time(struct device *dev, struct rtc_time *rtc_tm) | |||
141 | 140 | ||
142 | ret = da9052_group_read(rtc->da9052, DA9052_COUNT_S_REG, 6, v); | 141 | ret = da9052_group_read(rtc->da9052, DA9052_COUNT_S_REG, 6, v); |
143 | if (ret < 0) { | 142 | if (ret < 0) { |
144 | rtc_err(rtc->da9052, "Failed to read RTC time : %d\n", ret); | 143 | rtc_err(rtc, "Failed to read RTC time : %d\n", ret); |
145 | return ret; | 144 | return ret; |
146 | } | 145 | } |
147 | 146 | ||
@@ -153,18 +152,14 @@ static int da9052_rtc_read_time(struct device *dev, struct rtc_time *rtc_tm) | |||
153 | rtc_tm->tm_sec = v[0] & DA9052_RTC_SEC; | 152 | rtc_tm->tm_sec = v[0] & DA9052_RTC_SEC; |
154 | 153 | ||
155 | ret = rtc_valid_tm(rtc_tm); | 154 | ret = rtc_valid_tm(rtc_tm); |
156 | if (ret != 0) { | 155 | return ret; |
157 | rtc_err(rtc->da9052, "rtc_valid_tm failed: %d\n", ret); | ||
158 | return ret; | ||
159 | } | ||
160 | |||
161 | return 0; | ||
162 | } | 156 | } |
163 | 157 | ||
164 | static int da9052_rtc_set_time(struct device *dev, struct rtc_time *tm) | 158 | static int da9052_rtc_set_time(struct device *dev, struct rtc_time *tm) |
165 | { | 159 | { |
166 | struct da9052_rtc *rtc; | 160 | struct da9052_rtc *rtc; |
167 | uint8_t v[6]; | 161 | uint8_t v[6]; |
162 | int ret; | ||
168 | 163 | ||
169 | rtc = dev_get_drvdata(dev); | 164 | rtc = dev_get_drvdata(dev); |
170 | 165 | ||
@@ -175,7 +170,10 @@ static int da9052_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
175 | v[4] = tm->tm_mon + 1; | 170 | v[4] = tm->tm_mon + 1; |
176 | v[5] = tm->tm_year - 100; | 171 | v[5] = tm->tm_year - 100; |
177 | 172 | ||
178 | return da9052_group_write(rtc->da9052, DA9052_COUNT_S_REG, 6, v); | 173 | ret = da9052_group_write(rtc->da9052, DA9052_COUNT_S_REG, 6, v); |
174 | if (ret < 0) | ||
175 | rtc_err(rtc, "failed to set RTC time: %d\n", ret); | ||
176 | return ret; | ||
179 | } | 177 | } |
180 | 178 | ||
181 | static int da9052_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 179 | static int da9052_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
@@ -184,13 +182,13 @@ static int da9052_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
184 | struct rtc_time *tm = &alrm->time; | 182 | struct rtc_time *tm = &alrm->time; |
185 | struct da9052_rtc *rtc = dev_get_drvdata(dev); | 183 | struct da9052_rtc *rtc = dev_get_drvdata(dev); |
186 | 184 | ||
187 | ret = da9052_read_alarm(rtc->da9052, tm); | 185 | ret = da9052_read_alarm(rtc, tm); |
188 | 186 | if (ret < 0) { | |
189 | if (ret) | 187 | rtc_err(rtc, "failed to read RTC alarm: %d\n", ret); |
190 | return ret; | 188 | return ret; |
189 | } | ||
191 | 190 | ||
192 | alrm->enabled = da9052_rtc_get_alarm_status(rtc->da9052); | 191 | alrm->enabled = da9052_rtc_get_alarm_status(rtc); |
193 | |||
194 | return 0; | 192 | return 0; |
195 | } | 193 | } |
196 | 194 | ||
@@ -200,16 +198,15 @@ static int da9052_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
200 | struct rtc_time *tm = &alrm->time; | 198 | struct rtc_time *tm = &alrm->time; |
201 | struct da9052_rtc *rtc = dev_get_drvdata(dev); | 199 | struct da9052_rtc *rtc = dev_get_drvdata(dev); |
202 | 200 | ||
203 | ret = da9052_rtc_enable_alarm(rtc->da9052, 0); | 201 | ret = da9052_rtc_enable_alarm(rtc, 0); |
204 | if (ret < 0) | 202 | if (ret < 0) |
205 | return ret; | 203 | return ret; |
206 | 204 | ||
207 | ret = da9052_set_alarm(rtc->da9052, tm); | 205 | ret = da9052_set_alarm(rtc, tm); |
208 | if (ret) | 206 | if (ret < 0) |
209 | return ret; | 207 | return ret; |
210 | 208 | ||
211 | ret = da9052_rtc_enable_alarm(rtc->da9052, 1); | 209 | ret = da9052_rtc_enable_alarm(rtc, 1); |
212 | |||
213 | return ret; | 210 | return ret; |
214 | } | 211 | } |
215 | 212 | ||
@@ -217,7 +214,7 @@ static int da9052_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
217 | { | 214 | { |
218 | struct da9052_rtc *rtc = dev_get_drvdata(dev); | 215 | struct da9052_rtc *rtc = dev_get_drvdata(dev); |
219 | 216 | ||
220 | return da9052_rtc_enable_alarm(rtc->da9052, enabled); | 217 | return da9052_rtc_enable_alarm(rtc, enabled); |
221 | } | 218 | } |
222 | 219 | ||
223 | static const struct rtc_class_ops da9052_rtc_ops = { | 220 | static const struct rtc_class_ops da9052_rtc_ops = { |
@@ -239,10 +236,23 @@ static int da9052_rtc_probe(struct platform_device *pdev) | |||
239 | 236 | ||
240 | rtc->da9052 = dev_get_drvdata(pdev->dev.parent); | 237 | rtc->da9052 = dev_get_drvdata(pdev->dev.parent); |
241 | platform_set_drvdata(pdev, rtc); | 238 | platform_set_drvdata(pdev, rtc); |
239 | |||
240 | ret = da9052_reg_write(rtc->da9052, DA9052_BBAT_CONT_REG, 0xFE); | ||
241 | if (ret < 0) { | ||
242 | rtc_err(rtc, | ||
243 | "Failed to setup RTC battery charging: %d\n", ret); | ||
244 | return ret; | ||
245 | } | ||
246 | |||
247 | ret = da9052_reg_update(rtc->da9052, DA9052_ALARM_Y_REG, | ||
248 | DA9052_ALARM_Y_TICK_ON, 0); | ||
249 | if (ret != 0) | ||
250 | rtc_err(rtc, "Failed to disable TICKS: %d\n", ret); | ||
251 | |||
242 | ret = da9052_request_irq(rtc->da9052, DA9052_IRQ_ALARM, "ALM", | 252 | ret = da9052_request_irq(rtc->da9052, DA9052_IRQ_ALARM, "ALM", |
243 | da9052_rtc_irq, rtc); | 253 | da9052_rtc_irq, rtc); |
244 | if (ret != 0) { | 254 | if (ret != 0) { |
245 | rtc_err(rtc->da9052, "irq registration failed: %d\n", ret); | 255 | rtc_err(rtc, "irq registration failed: %d\n", ret); |
246 | return ret; | 256 | return ret; |
247 | } | 257 | } |
248 | 258 | ||
@@ -261,7 +271,7 @@ static struct platform_driver da9052_rtc_driver = { | |||
261 | 271 | ||
262 | module_platform_driver(da9052_rtc_driver); | 272 | module_platform_driver(da9052_rtc_driver); |
263 | 273 | ||
264 | MODULE_AUTHOR("David Dajun Chen <dchen@diasemi.com>"); | 274 | MODULE_AUTHOR("Anthony Olech <Anthony.Olech@diasemi.com>"); |
265 | MODULE_DESCRIPTION("RTC driver for Dialog DA9052 PMIC"); | 275 | MODULE_DESCRIPTION("RTC driver for Dialog DA9052 PMIC"); |
266 | MODULE_LICENSE("GPL"); | 276 | MODULE_LICENSE("GPL"); |
267 | MODULE_ALIAS("platform:da9052-rtc"); | 277 | MODULE_ALIAS("platform:da9052-rtc"); |
diff --git a/drivers/rtc/rtc-da9063.c b/drivers/rtc/rtc-da9063.c new file mode 100644 index 000000000000..595393098b09 --- /dev/null +++ b/drivers/rtc/rtc-da9063.c | |||
@@ -0,0 +1,333 @@ | |||
1 | /* rtc-da9063.c - Real time clock device driver for DA9063 | ||
2 | * Copyright (C) 2013-14 Dialog Semiconductor Ltd. | ||
3 | * | ||
4 | * This library is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Library General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2 of the License, or (at your option) any later version. | ||
8 | * | ||
9 | * This library is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * Library General Public License for more details. | ||
13 | */ | ||
14 | |||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/platform_device.h> | ||
19 | #include <linux/interrupt.h> | ||
20 | #include <linux/rtc.h> | ||
21 | #include <linux/slab.h> | ||
22 | #include <linux/delay.h> | ||
23 | #include <linux/regmap.h> | ||
24 | #include <linux/mfd/da9063/registers.h> | ||
25 | #include <linux/mfd/da9063/core.h> | ||
26 | |||
27 | #define YEARS_TO_DA9063(year) ((year) - 100) | ||
28 | #define MONTHS_TO_DA9063(month) ((month) + 1) | ||
29 | #define YEARS_FROM_DA9063(year) ((year) + 100) | ||
30 | #define MONTHS_FROM_DA9063(month) ((month) - 1) | ||
31 | |||
32 | #define RTC_DATA_LEN (DA9063_REG_COUNT_Y - DA9063_REG_COUNT_S + 1) | ||
33 | #define RTC_SEC 0 | ||
34 | #define RTC_MIN 1 | ||
35 | #define RTC_HOUR 2 | ||
36 | #define RTC_DAY 3 | ||
37 | #define RTC_MONTH 4 | ||
38 | #define RTC_YEAR 5 | ||
39 | |||
40 | struct da9063_rtc { | ||
41 | struct rtc_device *rtc_dev; | ||
42 | struct da9063 *hw; | ||
43 | struct rtc_time alarm_time; | ||
44 | bool rtc_sync; | ||
45 | }; | ||
46 | |||
47 | static void da9063_data_to_tm(u8 *data, struct rtc_time *tm) | ||
48 | { | ||
49 | tm->tm_sec = data[RTC_SEC] & DA9063_COUNT_SEC_MASK; | ||
50 | tm->tm_min = data[RTC_MIN] & DA9063_COUNT_MIN_MASK; | ||
51 | tm->tm_hour = data[RTC_HOUR] & DA9063_COUNT_HOUR_MASK; | ||
52 | tm->tm_mday = data[RTC_DAY] & DA9063_COUNT_DAY_MASK; | ||
53 | tm->tm_mon = MONTHS_FROM_DA9063(data[RTC_MONTH] & | ||
54 | DA9063_COUNT_MONTH_MASK); | ||
55 | tm->tm_year = YEARS_FROM_DA9063(data[RTC_YEAR] & | ||
56 | DA9063_COUNT_YEAR_MASK); | ||
57 | } | ||
58 | |||
59 | static void da9063_tm_to_data(struct rtc_time *tm, u8 *data) | ||
60 | { | ||
61 | data[RTC_SEC] &= ~DA9063_COUNT_SEC_MASK; | ||
62 | data[RTC_SEC] |= tm->tm_sec & DA9063_COUNT_SEC_MASK; | ||
63 | |||
64 | data[RTC_MIN] &= ~DA9063_COUNT_MIN_MASK; | ||
65 | data[RTC_MIN] |= tm->tm_min & DA9063_COUNT_MIN_MASK; | ||
66 | |||
67 | data[RTC_HOUR] &= ~DA9063_COUNT_HOUR_MASK; | ||
68 | data[RTC_HOUR] |= tm->tm_hour & DA9063_COUNT_HOUR_MASK; | ||
69 | |||
70 | data[RTC_DAY] &= ~DA9063_COUNT_DAY_MASK; | ||
71 | data[RTC_DAY] |= tm->tm_mday & DA9063_COUNT_DAY_MASK; | ||
72 | |||
73 | data[RTC_MONTH] &= ~DA9063_COUNT_MONTH_MASK; | ||
74 | data[RTC_MONTH] |= MONTHS_TO_DA9063(tm->tm_mon) & | ||
75 | DA9063_COUNT_MONTH_MASK; | ||
76 | |||
77 | data[RTC_YEAR] &= ~DA9063_COUNT_YEAR_MASK; | ||
78 | data[RTC_YEAR] |= YEARS_TO_DA9063(tm->tm_year) & | ||
79 | DA9063_COUNT_YEAR_MASK; | ||
80 | } | ||
81 | |||
82 | static int da9063_rtc_stop_alarm(struct device *dev) | ||
83 | { | ||
84 | struct da9063_rtc *rtc = dev_get_drvdata(dev); | ||
85 | |||
86 | return regmap_update_bits(rtc->hw->regmap, DA9063_REG_ALARM_Y, | ||
87 | DA9063_ALARM_ON, 0); | ||
88 | } | ||
89 | |||
90 | static int da9063_rtc_start_alarm(struct device *dev) | ||
91 | { | ||
92 | struct da9063_rtc *rtc = dev_get_drvdata(dev); | ||
93 | |||
94 | return regmap_update_bits(rtc->hw->regmap, DA9063_REG_ALARM_Y, | ||
95 | DA9063_ALARM_ON, DA9063_ALARM_ON); | ||
96 | } | ||
97 | |||
98 | static int da9063_rtc_read_time(struct device *dev, struct rtc_time *tm) | ||
99 | { | ||
100 | struct da9063_rtc *rtc = dev_get_drvdata(dev); | ||
101 | unsigned long tm_secs; | ||
102 | unsigned long al_secs; | ||
103 | u8 data[RTC_DATA_LEN]; | ||
104 | int ret; | ||
105 | |||
106 | ret = regmap_bulk_read(rtc->hw->regmap, DA9063_REG_COUNT_S, | ||
107 | data, RTC_DATA_LEN); | ||
108 | if (ret < 0) { | ||
109 | dev_err(dev, "Failed to read RTC time data: %d\n", ret); | ||
110 | return ret; | ||
111 | } | ||
112 | |||
113 | if (!(data[RTC_SEC] & DA9063_RTC_READ)) { | ||
114 | dev_dbg(dev, "RTC not yet ready to be read by the host\n"); | ||
115 | return -EINVAL; | ||
116 | } | ||
117 | |||
118 | da9063_data_to_tm(data, tm); | ||
119 | |||
120 | rtc_tm_to_time(tm, &tm_secs); | ||
121 | rtc_tm_to_time(&rtc->alarm_time, &al_secs); | ||
122 | |||
123 | /* handle the rtc synchronisation delay */ | ||
124 | if (rtc->rtc_sync == true && al_secs - tm_secs == 1) | ||
125 | memcpy(tm, &rtc->alarm_time, sizeof(struct rtc_time)); | ||
126 | else | ||
127 | rtc->rtc_sync = false; | ||
128 | |||
129 | return rtc_valid_tm(tm); | ||
130 | } | ||
131 | |||
132 | static int da9063_rtc_set_time(struct device *dev, struct rtc_time *tm) | ||
133 | { | ||
134 | struct da9063_rtc *rtc = dev_get_drvdata(dev); | ||
135 | u8 data[RTC_DATA_LEN]; | ||
136 | int ret; | ||
137 | |||
138 | da9063_tm_to_data(tm, data); | ||
139 | ret = regmap_bulk_write(rtc->hw->regmap, DA9063_REG_COUNT_S, | ||
140 | data, RTC_DATA_LEN); | ||
141 | if (ret < 0) | ||
142 | dev_err(dev, "Failed to set RTC time data: %d\n", ret); | ||
143 | |||
144 | return ret; | ||
145 | } | ||
146 | |||
147 | static int da9063_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | ||
148 | { | ||
149 | struct da9063_rtc *rtc = dev_get_drvdata(dev); | ||
150 | u8 data[RTC_DATA_LEN]; | ||
151 | int ret; | ||
152 | unsigned int val; | ||
153 | |||
154 | ret = regmap_bulk_read(rtc->hw->regmap, DA9063_REG_ALARM_S, | ||
155 | &data[RTC_SEC], RTC_DATA_LEN); | ||
156 | if (ret < 0) | ||
157 | return ret; | ||
158 | |||
159 | da9063_data_to_tm(data, &alrm->time); | ||
160 | |||
161 | alrm->enabled = !!(data[RTC_YEAR] & DA9063_ALARM_ON); | ||
162 | |||
163 | ret = regmap_read(rtc->hw->regmap, DA9063_REG_EVENT_A, &val); | ||
164 | if (ret < 0) | ||
165 | return ret; | ||
166 | |||
167 | if (val & (DA9063_E_ALARM)) | ||
168 | alrm->pending = 1; | ||
169 | else | ||
170 | alrm->pending = 0; | ||
171 | |||
172 | return 0; | ||
173 | } | ||
174 | |||
175 | static int da9063_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | ||
176 | { | ||
177 | struct da9063_rtc *rtc = dev_get_drvdata(dev); | ||
178 | u8 data[RTC_DATA_LEN]; | ||
179 | int ret; | ||
180 | |||
181 | da9063_tm_to_data(&alrm->time, data); | ||
182 | |||
183 | ret = da9063_rtc_stop_alarm(dev); | ||
184 | if (ret < 0) { | ||
185 | dev_err(dev, "Failed to stop alarm: %d\n", ret); | ||
186 | return ret; | ||
187 | } | ||
188 | |||
189 | ret = regmap_bulk_write(rtc->hw->regmap, DA9063_REG_ALARM_S, | ||
190 | data, RTC_DATA_LEN); | ||
191 | if (ret < 0) { | ||
192 | dev_err(dev, "Failed to write alarm: %d\n", ret); | ||
193 | return ret; | ||
194 | } | ||
195 | |||
196 | rtc->alarm_time = alrm->time; | ||
197 | |||
198 | if (alrm->enabled) { | ||
199 | ret = da9063_rtc_start_alarm(dev); | ||
200 | if (ret < 0) { | ||
201 | dev_err(dev, "Failed to start alarm: %d\n", ret); | ||
202 | return ret; | ||
203 | } | ||
204 | } | ||
205 | |||
206 | return ret; | ||
207 | } | ||
208 | |||
209 | static int da9063_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | ||
210 | { | ||
211 | if (enabled) | ||
212 | return da9063_rtc_start_alarm(dev); | ||
213 | else | ||
214 | return da9063_rtc_stop_alarm(dev); | ||
215 | } | ||
216 | |||
217 | static irqreturn_t da9063_alarm_event(int irq, void *data) | ||
218 | { | ||
219 | struct da9063_rtc *rtc = data; | ||
220 | |||
221 | regmap_update_bits(rtc->hw->regmap, DA9063_REG_ALARM_Y, | ||
222 | DA9063_ALARM_ON, 0); | ||
223 | |||
224 | rtc->rtc_sync = true; | ||
225 | rtc_update_irq(rtc->rtc_dev, 1, RTC_IRQF | RTC_AF); | ||
226 | |||
227 | return IRQ_HANDLED; | ||
228 | } | ||
229 | |||
230 | static const struct rtc_class_ops da9063_rtc_ops = { | ||
231 | .read_time = da9063_rtc_read_time, | ||
232 | .set_time = da9063_rtc_set_time, | ||
233 | .read_alarm = da9063_rtc_read_alarm, | ||
234 | .set_alarm = da9063_rtc_set_alarm, | ||
235 | .alarm_irq_enable = da9063_rtc_alarm_irq_enable, | ||
236 | }; | ||
237 | |||
238 | static int da9063_rtc_probe(struct platform_device *pdev) | ||
239 | { | ||
240 | struct da9063 *da9063 = dev_get_drvdata(pdev->dev.parent); | ||
241 | struct da9063_rtc *rtc; | ||
242 | int irq_alarm; | ||
243 | u8 data[RTC_DATA_LEN]; | ||
244 | int ret; | ||
245 | |||
246 | ret = regmap_update_bits(da9063->regmap, DA9063_REG_CONTROL_E, | ||
247 | DA9063_RTC_EN, DA9063_RTC_EN); | ||
248 | if (ret < 0) { | ||
249 | dev_err(&pdev->dev, "Failed to enable RTC\n"); | ||
250 | goto err; | ||
251 | } | ||
252 | |||
253 | ret = regmap_update_bits(da9063->regmap, DA9063_REG_EN_32K, | ||
254 | DA9063_CRYSTAL, DA9063_CRYSTAL); | ||
255 | if (ret < 0) { | ||
256 | dev_err(&pdev->dev, "Failed to run 32kHz oscillator\n"); | ||
257 | goto err; | ||
258 | } | ||
259 | |||
260 | ret = regmap_update_bits(da9063->regmap, DA9063_REG_ALARM_S, | ||
261 | DA9063_ALARM_STATUS_TICK | DA9063_ALARM_STATUS_ALARM, | ||
262 | 0); | ||
263 | if (ret < 0) { | ||
264 | dev_err(&pdev->dev, "Failed to access RTC alarm register\n"); | ||
265 | goto err; | ||
266 | } | ||
267 | |||
268 | ret = regmap_update_bits(da9063->regmap, DA9063_REG_ALARM_S, | ||
269 | DA9063_ALARM_STATUS_ALARM, | ||
270 | DA9063_ALARM_STATUS_ALARM); | ||
271 | if (ret < 0) { | ||
272 | dev_err(&pdev->dev, "Failed to access RTC alarm register\n"); | ||
273 | goto err; | ||
274 | } | ||
275 | |||
276 | ret = regmap_update_bits(da9063->regmap, DA9063_REG_ALARM_Y, | ||
277 | DA9063_TICK_ON, 0); | ||
278 | if (ret < 0) { | ||
279 | dev_err(&pdev->dev, "Failed to disable TICKs\n"); | ||
280 | goto err; | ||
281 | } | ||
282 | |||
283 | ret = regmap_bulk_read(da9063->regmap, DA9063_REG_ALARM_S, | ||
284 | data, RTC_DATA_LEN); | ||
285 | if (ret < 0) { | ||
286 | dev_err(&pdev->dev, "Failed to read initial alarm data: %d\n", | ||
287 | ret); | ||
288 | goto err; | ||
289 | } | ||
290 | |||
291 | rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); | ||
292 | if (!rtc) | ||
293 | return -ENOMEM; | ||
294 | |||
295 | platform_set_drvdata(pdev, rtc); | ||
296 | |||
297 | irq_alarm = platform_get_irq_byname(pdev, "ALARM"); | ||
298 | ret = devm_request_threaded_irq(&pdev->dev, irq_alarm, NULL, | ||
299 | da9063_alarm_event, | ||
300 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, | ||
301 | "ALARM", rtc); | ||
302 | if (ret) { | ||
303 | dev_err(&pdev->dev, "Failed to request ALARM IRQ %d: %d\n", | ||
304 | irq_alarm, ret); | ||
305 | goto err; | ||
306 | } | ||
307 | |||
308 | rtc->hw = da9063; | ||
309 | rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, DA9063_DRVNAME_RTC, | ||
310 | &da9063_rtc_ops, THIS_MODULE); | ||
311 | if (IS_ERR(rtc->rtc_dev)) | ||
312 | return PTR_ERR(rtc->rtc_dev); | ||
313 | |||
314 | da9063_data_to_tm(data, &rtc->alarm_time); | ||
315 | rtc->rtc_sync = false; | ||
316 | err: | ||
317 | return ret; | ||
318 | } | ||
319 | |||
320 | static struct platform_driver da9063_rtc_driver = { | ||
321 | .probe = da9063_rtc_probe, | ||
322 | .driver = { | ||
323 | .name = DA9063_DRVNAME_RTC, | ||
324 | .owner = THIS_MODULE, | ||
325 | }, | ||
326 | }; | ||
327 | |||
328 | module_platform_driver(da9063_rtc_driver); | ||
329 | |||
330 | MODULE_AUTHOR("S Twiss <stwiss.opensource@diasemi.com>"); | ||
331 | MODULE_DESCRIPTION("Real time clock device driver for Dialog DA9063"); | ||
332 | MODULE_LICENSE("GPL v2"); | ||
333 | MODULE_ALIAS("platform:" DA9063_DRVNAME_RTC); | ||
diff --git a/drivers/rtc/rtc-ds1343.c b/drivers/rtc/rtc-ds1343.c new file mode 100644 index 000000000000..c3719189dd96 --- /dev/null +++ b/drivers/rtc/rtc-ds1343.c | |||
@@ -0,0 +1,689 @@ | |||
1 | /* rtc-ds1343.c | ||
2 | * | ||
3 | * Driver for Dallas Semiconductor DS1343 Low Current, SPI Compatible | ||
4 | * Real Time Clock | ||
5 | * | ||
6 | * Author : Raghavendra Chandra Ganiga <ravi23ganiga@gmail.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/init.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/interrupt.h> | ||
17 | #include <linux/device.h> | ||
18 | #include <linux/spi/spi.h> | ||
19 | #include <linux/regmap.h> | ||
20 | #include <linux/rtc.h> | ||
21 | #include <linux/bcd.h> | ||
22 | #include <linux/pm.h> | ||
23 | #include <linux/slab.h> | ||
24 | |||
25 | #define DS1343_DRV_VERSION "01.00" | ||
26 | #define DALLAS_MAXIM_DS1343 0 | ||
27 | #define DALLAS_MAXIM_DS1344 1 | ||
28 | |||
29 | /* RTC DS1343 Registers */ | ||
30 | #define DS1343_SECONDS_REG 0x00 | ||
31 | #define DS1343_MINUTES_REG 0x01 | ||
32 | #define DS1343_HOURS_REG 0x02 | ||
33 | #define DS1343_DAY_REG 0x03 | ||
34 | #define DS1343_DATE_REG 0x04 | ||
35 | #define DS1343_MONTH_REG 0x05 | ||
36 | #define DS1343_YEAR_REG 0x06 | ||
37 | #define DS1343_ALM0_SEC_REG 0x07 | ||
38 | #define DS1343_ALM0_MIN_REG 0x08 | ||
39 | #define DS1343_ALM0_HOUR_REG 0x09 | ||
40 | #define DS1343_ALM0_DAY_REG 0x0A | ||
41 | #define DS1343_ALM1_SEC_REG 0x0B | ||
42 | #define DS1343_ALM1_MIN_REG 0x0C | ||
43 | #define DS1343_ALM1_HOUR_REG 0x0D | ||
44 | #define DS1343_ALM1_DAY_REG 0x0E | ||
45 | #define DS1343_CONTROL_REG 0x0F | ||
46 | #define DS1343_STATUS_REG 0x10 | ||
47 | #define DS1343_TRICKLE_REG 0x11 | ||
48 | |||
49 | /* DS1343 Control Registers bits */ | ||
50 | #define DS1343_EOSC 0x80 | ||
51 | #define DS1343_DOSF 0x20 | ||
52 | #define DS1343_EGFIL 0x10 | ||
53 | #define DS1343_SQW 0x08 | ||
54 | #define DS1343_INTCN 0x04 | ||
55 | #define DS1343_A1IE 0x02 | ||
56 | #define DS1343_A0IE 0x01 | ||
57 | |||
58 | /* DS1343 Status Registers bits */ | ||
59 | #define DS1343_OSF 0x80 | ||
60 | #define DS1343_IRQF1 0x02 | ||
61 | #define DS1343_IRQF0 0x01 | ||
62 | |||
63 | /* DS1343 Trickle Charger Registers bits */ | ||
64 | #define DS1343_TRICKLE_MAGIC 0xa0 | ||
65 | #define DS1343_TRICKLE_DS1 0x08 | ||
66 | #define DS1343_TRICKLE_1K 0x01 | ||
67 | #define DS1343_TRICKLE_2K 0x02 | ||
68 | #define DS1343_TRICKLE_4K 0x03 | ||
69 | |||
70 | static const struct spi_device_id ds1343_id[] = { | ||
71 | { "ds1343", DALLAS_MAXIM_DS1343 }, | ||
72 | { "ds1344", DALLAS_MAXIM_DS1344 }, | ||
73 | { } | ||
74 | }; | ||
75 | MODULE_DEVICE_TABLE(spi, ds1343_id); | ||
76 | |||
77 | struct ds1343_priv { | ||
78 | struct spi_device *spi; | ||
79 | struct rtc_device *rtc; | ||
80 | struct regmap *map; | ||
81 | struct mutex mutex; | ||
82 | unsigned int irqen; | ||
83 | int irq; | ||
84 | int alarm_sec; | ||
85 | int alarm_min; | ||
86 | int alarm_hour; | ||
87 | int alarm_mday; | ||
88 | }; | ||
89 | |||
90 | static int ds1343_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
91 | { | ||
92 | switch (cmd) { | ||
93 | #ifdef RTC_SET_CHARGE | ||
94 | case RTC_SET_CHARGE: | ||
95 | { | ||
96 | int val; | ||
97 | |||
98 | if (copy_from_user(&val, (int __user *)arg, sizeof(int))) | ||
99 | return -EFAULT; | ||
100 | |||
101 | return regmap_write(priv->map, DS1343_TRICKLE_REG, val); | ||
102 | } | ||
103 | break; | ||
104 | #endif | ||
105 | } | ||
106 | |||
107 | return -ENOIOCTLCMD; | ||
108 | } | ||
109 | |||
110 | static ssize_t ds1343_show_glitchfilter(struct device *dev, | ||
111 | struct device_attribute *attr, char *buf) | ||
112 | { | ||
113 | struct ds1343_priv *priv = dev_get_drvdata(dev); | ||
114 | int glitch_filt_status, data; | ||
115 | |||
116 | regmap_read(priv->map, DS1343_CONTROL_REG, &data); | ||
117 | |||
118 | glitch_filt_status = !!(data & DS1343_EGFIL); | ||
119 | |||
120 | if (glitch_filt_status) | ||
121 | return sprintf(buf, "enabled\n"); | ||
122 | else | ||
123 | return sprintf(buf, "disabled\n"); | ||
124 | } | ||
125 | |||
126 | static ssize_t ds1343_store_glitchfilter(struct device *dev, | ||
127 | struct device_attribute *attr, | ||
128 | const char *buf, size_t count) | ||
129 | { | ||
130 | struct ds1343_priv *priv = dev_get_drvdata(dev); | ||
131 | int data; | ||
132 | |||
133 | regmap_read(priv->map, DS1343_CONTROL_REG, &data); | ||
134 | |||
135 | if (strncmp(buf, "enabled", 7) == 0) | ||
136 | data |= DS1343_EGFIL; | ||
137 | |||
138 | else if (strncmp(buf, "disabled", 8) == 0) | ||
139 | data &= ~(DS1343_EGFIL); | ||
140 | |||
141 | else | ||
142 | return -EINVAL; | ||
143 | |||
144 | regmap_write(priv->map, DS1343_CONTROL_REG, data); | ||
145 | |||
146 | return count; | ||
147 | } | ||
148 | |||
149 | static DEVICE_ATTR(glitch_filter, S_IRUGO | S_IWUSR, ds1343_show_glitchfilter, | ||
150 | ds1343_store_glitchfilter); | ||
151 | |||
152 | static ssize_t ds1343_show_alarmstatus(struct device *dev, | ||
153 | struct device_attribute *attr, char *buf) | ||
154 | { | ||
155 | struct ds1343_priv *priv = dev_get_drvdata(dev); | ||
156 | int alarmstatus, data; | ||
157 | |||
158 | regmap_read(priv->map, DS1343_CONTROL_REG, &data); | ||
159 | |||
160 | alarmstatus = !!(data & DS1343_A0IE); | ||
161 | |||
162 | if (alarmstatus) | ||
163 | return sprintf(buf, "enabled\n"); | ||
164 | else | ||
165 | return sprintf(buf, "disabled\n"); | ||
166 | } | ||
167 | |||
168 | static DEVICE_ATTR(alarm_status, S_IRUGO, ds1343_show_alarmstatus, NULL); | ||
169 | |||
170 | static ssize_t ds1343_show_alarmmode(struct device *dev, | ||
171 | struct device_attribute *attr, char *buf) | ||
172 | { | ||
173 | struct ds1343_priv *priv = dev_get_drvdata(dev); | ||
174 | int alarm_mode, data; | ||
175 | char *alarm_str; | ||
176 | |||
177 | regmap_read(priv->map, DS1343_ALM0_SEC_REG, &data); | ||
178 | alarm_mode = (data & 0x80) >> 4; | ||
179 | |||
180 | regmap_read(priv->map, DS1343_ALM0_MIN_REG, &data); | ||
181 | alarm_mode |= (data & 0x80) >> 5; | ||
182 | |||
183 | regmap_read(priv->map, DS1343_ALM0_HOUR_REG, &data); | ||
184 | alarm_mode |= (data & 0x80) >> 6; | ||
185 | |||
186 | regmap_read(priv->map, DS1343_ALM0_DAY_REG, &data); | ||
187 | alarm_mode |= (data & 0x80) >> 7; | ||
188 | |||
189 | switch (alarm_mode) { | ||
190 | case 15: | ||
191 | alarm_str = "each second"; | ||
192 | break; | ||
193 | |||
194 | case 7: | ||
195 | alarm_str = "seconds match"; | ||
196 | break; | ||
197 | |||
198 | case 3: | ||
199 | alarm_str = "minutes and seconds match"; | ||
200 | break; | ||
201 | |||
202 | case 1: | ||
203 | alarm_str = "hours, minutes and seconds match"; | ||
204 | break; | ||
205 | |||
206 | case 0: | ||
207 | alarm_str = "day, hours, minutes and seconds match"; | ||
208 | break; | ||
209 | |||
210 | default: | ||
211 | alarm_str = "invalid"; | ||
212 | break; | ||
213 | } | ||
214 | |||
215 | return sprintf(buf, "%s\n", alarm_str); | ||
216 | } | ||
217 | |||
218 | static DEVICE_ATTR(alarm_mode, S_IRUGO, ds1343_show_alarmmode, NULL); | ||
219 | |||
220 | static ssize_t ds1343_show_tricklecharger(struct device *dev, | ||
221 | struct device_attribute *attr, char *buf) | ||
222 | { | ||
223 | struct ds1343_priv *priv = dev_get_drvdata(dev); | ||
224 | int data; | ||
225 | char *diodes = "disabled", *resistors = " "; | ||
226 | |||
227 | regmap_read(priv->map, DS1343_TRICKLE_REG, &data); | ||
228 | |||
229 | if ((data & 0xf0) == DS1343_TRICKLE_MAGIC) { | ||
230 | switch (data & 0x0c) { | ||
231 | case DS1343_TRICKLE_DS1: | ||
232 | diodes = "one diode,"; | ||
233 | break; | ||
234 | |||
235 | default: | ||
236 | diodes = "no diode,"; | ||
237 | break; | ||
238 | } | ||
239 | |||
240 | switch (data & 0x03) { | ||
241 | case DS1343_TRICKLE_1K: | ||
242 | resistors = "1k Ohm"; | ||
243 | break; | ||
244 | |||
245 | case DS1343_TRICKLE_2K: | ||
246 | resistors = "2k Ohm"; | ||
247 | break; | ||
248 | |||
249 | case DS1343_TRICKLE_4K: | ||
250 | resistors = "4k Ohm"; | ||
251 | break; | ||
252 | |||
253 | default: | ||
254 | diodes = "disabled"; | ||
255 | break; | ||
256 | } | ||
257 | } | ||
258 | |||
259 | return sprintf(buf, "%s %s\n", diodes, resistors); | ||
260 | } | ||
261 | |||
262 | static DEVICE_ATTR(trickle_charger, S_IRUGO, ds1343_show_tricklecharger, NULL); | ||
263 | |||
264 | static int ds1343_sysfs_register(struct device *dev) | ||
265 | { | ||
266 | struct ds1343_priv *priv = dev_get_drvdata(dev); | ||
267 | int err; | ||
268 | |||
269 | err = device_create_file(dev, &dev_attr_glitch_filter); | ||
270 | if (err) | ||
271 | return err; | ||
272 | |||
273 | err = device_create_file(dev, &dev_attr_trickle_charger); | ||
274 | if (err) | ||
275 | goto error1; | ||
276 | |||
277 | if (priv->irq <= 0) | ||
278 | return err; | ||
279 | |||
280 | err = device_create_file(dev, &dev_attr_alarm_mode); | ||
281 | if (err) | ||
282 | goto error2; | ||
283 | |||
284 | err = device_create_file(dev, &dev_attr_alarm_status); | ||
285 | if (!err) | ||
286 | return err; | ||
287 | |||
288 | device_remove_file(dev, &dev_attr_alarm_mode); | ||
289 | |||
290 | error2: | ||
291 | device_remove_file(dev, &dev_attr_trickle_charger); | ||
292 | |||
293 | error1: | ||
294 | device_remove_file(dev, &dev_attr_glitch_filter); | ||
295 | |||
296 | return err; | ||
297 | } | ||
298 | |||
299 | static void ds1343_sysfs_unregister(struct device *dev) | ||
300 | { | ||
301 | struct ds1343_priv *priv = dev_get_drvdata(dev); | ||
302 | |||
303 | device_remove_file(dev, &dev_attr_glitch_filter); | ||
304 | device_remove_file(dev, &dev_attr_trickle_charger); | ||
305 | |||
306 | if (priv->irq <= 0) | ||
307 | return; | ||
308 | |||
309 | device_remove_file(dev, &dev_attr_alarm_status); | ||
310 | device_remove_file(dev, &dev_attr_alarm_mode); | ||
311 | } | ||
312 | |||
313 | static int ds1343_read_time(struct device *dev, struct rtc_time *dt) | ||
314 | { | ||
315 | struct ds1343_priv *priv = dev_get_drvdata(dev); | ||
316 | unsigned char buf[7]; | ||
317 | int res; | ||
318 | |||
319 | res = regmap_bulk_read(priv->map, DS1343_SECONDS_REG, buf, 7); | ||
320 | if (res) | ||
321 | return res; | ||
322 | |||
323 | dt->tm_sec = bcd2bin(buf[0]); | ||
324 | dt->tm_min = bcd2bin(buf[1]); | ||
325 | dt->tm_hour = bcd2bin(buf[2] & 0x3F); | ||
326 | dt->tm_wday = bcd2bin(buf[3]) - 1; | ||
327 | dt->tm_mday = bcd2bin(buf[4]); | ||
328 | dt->tm_mon = bcd2bin(buf[5] & 0x1F) - 1; | ||
329 | dt->tm_year = bcd2bin(buf[6]) + 100; /* year offset from 1900 */ | ||
330 | |||
331 | return rtc_valid_tm(dt); | ||
332 | } | ||
333 | |||
334 | static int ds1343_set_time(struct device *dev, struct rtc_time *dt) | ||
335 | { | ||
336 | struct ds1343_priv *priv = dev_get_drvdata(dev); | ||
337 | int res; | ||
338 | |||
339 | res = regmap_write(priv->map, DS1343_SECONDS_REG, | ||
340 | bin2bcd(dt->tm_sec)); | ||
341 | if (res) | ||
342 | return res; | ||
343 | |||
344 | res = regmap_write(priv->map, DS1343_MINUTES_REG, | ||
345 | bin2bcd(dt->tm_min)); | ||
346 | if (res) | ||
347 | return res; | ||
348 | |||
349 | res = regmap_write(priv->map, DS1343_HOURS_REG, | ||
350 | bin2bcd(dt->tm_hour) & 0x3F); | ||
351 | if (res) | ||
352 | return res; | ||
353 | |||
354 | res = regmap_write(priv->map, DS1343_DAY_REG, | ||
355 | bin2bcd(dt->tm_wday + 1)); | ||
356 | if (res) | ||
357 | return res; | ||
358 | |||
359 | res = regmap_write(priv->map, DS1343_DATE_REG, | ||
360 | bin2bcd(dt->tm_mday)); | ||
361 | if (res) | ||
362 | return res; | ||
363 | |||
364 | res = regmap_write(priv->map, DS1343_MONTH_REG, | ||
365 | bin2bcd(dt->tm_mon + 1)); | ||
366 | if (res) | ||
367 | return res; | ||
368 | |||
369 | dt->tm_year %= 100; | ||
370 | |||
371 | res = regmap_write(priv->map, DS1343_YEAR_REG, | ||
372 | bin2bcd(dt->tm_year)); | ||
373 | if (res) | ||
374 | return res; | ||
375 | |||
376 | return 0; | ||
377 | } | ||
378 | |||
379 | static int ds1343_update_alarm(struct device *dev) | ||
380 | { | ||
381 | struct ds1343_priv *priv = dev_get_drvdata(dev); | ||
382 | unsigned int control, stat; | ||
383 | unsigned char buf[4]; | ||
384 | int res = 0; | ||
385 | |||
386 | res = regmap_read(priv->map, DS1343_CONTROL_REG, &control); | ||
387 | if (res) | ||
388 | return res; | ||
389 | |||
390 | res = regmap_read(priv->map, DS1343_STATUS_REG, &stat); | ||
391 | if (res) | ||
392 | return res; | ||
393 | |||
394 | control &= ~(DS1343_A0IE); | ||
395 | stat &= ~(DS1343_IRQF0); | ||
396 | |||
397 | res = regmap_write(priv->map, DS1343_CONTROL_REG, control); | ||
398 | if (res) | ||
399 | return res; | ||
400 | |||
401 | res = regmap_write(priv->map, DS1343_STATUS_REG, stat); | ||
402 | if (res) | ||
403 | return res; | ||
404 | |||
405 | buf[0] = priv->alarm_sec < 0 || (priv->irqen & RTC_UF) ? | ||
406 | 0x80 : bin2bcd(priv->alarm_sec) & 0x7F; | ||
407 | buf[1] = priv->alarm_min < 0 || (priv->irqen & RTC_UF) ? | ||
408 | 0x80 : bin2bcd(priv->alarm_min) & 0x7F; | ||
409 | buf[2] = priv->alarm_hour < 0 || (priv->irqen & RTC_UF) ? | ||
410 | 0x80 : bin2bcd(priv->alarm_hour) & 0x3F; | ||
411 | buf[3] = priv->alarm_mday < 0 || (priv->irqen & RTC_UF) ? | ||
412 | 0x80 : bin2bcd(priv->alarm_mday) & 0x7F; | ||
413 | |||
414 | res = regmap_bulk_write(priv->map, DS1343_ALM0_SEC_REG, buf, 4); | ||
415 | if (res) | ||
416 | return res; | ||
417 | |||
418 | if (priv->irqen) { | ||
419 | control |= DS1343_A0IE; | ||
420 | res = regmap_write(priv->map, DS1343_CONTROL_REG, control); | ||
421 | } | ||
422 | |||
423 | return res; | ||
424 | } | ||
425 | |||
426 | static int ds1343_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) | ||
427 | { | ||
428 | struct ds1343_priv *priv = dev_get_drvdata(dev); | ||
429 | int res = 0; | ||
430 | unsigned int stat; | ||
431 | |||
432 | if (priv->irq <= 0) | ||
433 | return -EINVAL; | ||
434 | |||
435 | mutex_lock(&priv->mutex); | ||
436 | |||
437 | res = regmap_read(priv->map, DS1343_STATUS_REG, &stat); | ||
438 | if (res) | ||
439 | goto out; | ||
440 | |||
441 | alarm->enabled = !!(priv->irqen & RTC_AF); | ||
442 | alarm->pending = !!(stat & DS1343_IRQF0); | ||
443 | |||
444 | alarm->time.tm_sec = priv->alarm_sec < 0 ? 0 : priv->alarm_sec; | ||
445 | alarm->time.tm_min = priv->alarm_min < 0 ? 0 : priv->alarm_min; | ||
446 | alarm->time.tm_hour = priv->alarm_hour < 0 ? 0 : priv->alarm_hour; | ||
447 | alarm->time.tm_mday = priv->alarm_mday < 0 ? 0 : priv->alarm_mday; | ||
448 | |||
449 | alarm->time.tm_mon = -1; | ||
450 | alarm->time.tm_year = -1; | ||
451 | alarm->time.tm_wday = -1; | ||
452 | alarm->time.tm_yday = -1; | ||
453 | alarm->time.tm_isdst = -1; | ||
454 | |||
455 | out: | ||
456 | mutex_unlock(&priv->mutex); | ||
457 | return res; | ||
458 | } | ||
459 | |||
460 | static int ds1343_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) | ||
461 | { | ||
462 | struct ds1343_priv *priv = dev_get_drvdata(dev); | ||
463 | int res = 0; | ||
464 | |||
465 | if (priv->irq <= 0) | ||
466 | return -EINVAL; | ||
467 | |||
468 | mutex_lock(&priv->mutex); | ||
469 | |||
470 | priv->alarm_sec = alarm->time.tm_sec; | ||
471 | priv->alarm_min = alarm->time.tm_min; | ||
472 | priv->alarm_hour = alarm->time.tm_hour; | ||
473 | priv->alarm_mday = alarm->time.tm_mday; | ||
474 | |||
475 | if (alarm->enabled) | ||
476 | priv->irqen |= RTC_AF; | ||
477 | |||
478 | res = ds1343_update_alarm(dev); | ||
479 | |||
480 | mutex_unlock(&priv->mutex); | ||
481 | |||
482 | return res; | ||
483 | } | ||
484 | |||
485 | static int ds1343_alarm_irq_enable(struct device *dev, unsigned int enabled) | ||
486 | { | ||
487 | struct ds1343_priv *priv = dev_get_drvdata(dev); | ||
488 | int res = 0; | ||
489 | |||
490 | if (priv->irq <= 0) | ||
491 | return -EINVAL; | ||
492 | |||
493 | mutex_lock(&priv->mutex); | ||
494 | |||
495 | if (enabled) | ||
496 | priv->irqen |= RTC_AF; | ||
497 | else | ||
498 | priv->irqen &= ~RTC_AF; | ||
499 | |||
500 | res = ds1343_update_alarm(dev); | ||
501 | |||
502 | mutex_unlock(&priv->mutex); | ||
503 | |||
504 | return res; | ||
505 | } | ||
506 | |||
507 | static irqreturn_t ds1343_thread(int irq, void *dev_id) | ||
508 | { | ||
509 | struct ds1343_priv *priv = dev_id; | ||
510 | unsigned int stat, control; | ||
511 | int res = 0; | ||
512 | |||
513 | mutex_lock(&priv->mutex); | ||
514 | |||
515 | res = regmap_read(priv->map, DS1343_STATUS_REG, &stat); | ||
516 | if (res) | ||
517 | goto out; | ||
518 | |||
519 | if (stat & DS1343_IRQF0) { | ||
520 | stat &= ~DS1343_IRQF0; | ||
521 | regmap_write(priv->map, DS1343_STATUS_REG, stat); | ||
522 | |||
523 | res = regmap_read(priv->map, DS1343_CONTROL_REG, &control); | ||
524 | if (res) | ||
525 | goto out; | ||
526 | |||
527 | control &= ~DS1343_A0IE; | ||
528 | regmap_write(priv->map, DS1343_CONTROL_REG, control); | ||
529 | |||
530 | rtc_update_irq(priv->rtc, 1, RTC_AF | RTC_IRQF); | ||
531 | } | ||
532 | |||
533 | out: | ||
534 | mutex_unlock(&priv->mutex); | ||
535 | return IRQ_HANDLED; | ||
536 | } | ||
537 | |||
538 | static const struct rtc_class_ops ds1343_rtc_ops = { | ||
539 | .ioctl = ds1343_ioctl, | ||
540 | .read_time = ds1343_read_time, | ||
541 | .set_time = ds1343_set_time, | ||
542 | .read_alarm = ds1343_read_alarm, | ||
543 | .set_alarm = ds1343_set_alarm, | ||
544 | .alarm_irq_enable = ds1343_alarm_irq_enable, | ||
545 | }; | ||
546 | |||
547 | static int ds1343_probe(struct spi_device *spi) | ||
548 | { | ||
549 | struct ds1343_priv *priv; | ||
550 | struct regmap_config config; | ||
551 | unsigned int data; | ||
552 | int res; | ||
553 | |||
554 | memset(&config, 0, sizeof(config)); | ||
555 | config.reg_bits = 8; | ||
556 | config.val_bits = 8; | ||
557 | config.write_flag_mask = 0x80; | ||
558 | |||
559 | priv = devm_kzalloc(&spi->dev, sizeof(struct ds1343_priv), GFP_KERNEL); | ||
560 | if (!priv) | ||
561 | return -ENOMEM; | ||
562 | |||
563 | priv->spi = spi; | ||
564 | mutex_init(&priv->mutex); | ||
565 | |||
566 | /* RTC DS1347 works in spi mode 3 and | ||
567 | * its chip select is active high | ||
568 | */ | ||
569 | spi->mode = SPI_MODE_3 | SPI_CS_HIGH; | ||
570 | spi->bits_per_word = 8; | ||
571 | res = spi_setup(spi); | ||
572 | if (res) | ||
573 | return res; | ||
574 | |||
575 | spi_set_drvdata(spi, priv); | ||
576 | |||
577 | priv->map = devm_regmap_init_spi(spi, &config); | ||
578 | |||
579 | if (IS_ERR(priv->map)) { | ||
580 | dev_err(&spi->dev, "spi regmap init failed for rtc ds1343\n"); | ||
581 | return PTR_ERR(priv->map); | ||
582 | } | ||
583 | |||
584 | res = regmap_read(priv->map, DS1343_SECONDS_REG, &data); | ||
585 | if (res) | ||
586 | return res; | ||
587 | |||
588 | regmap_read(priv->map, DS1343_CONTROL_REG, &data); | ||
589 | data |= DS1343_INTCN; | ||
590 | data &= ~(DS1343_EOSC | DS1343_A1IE | DS1343_A0IE); | ||
591 | regmap_write(priv->map, DS1343_CONTROL_REG, data); | ||
592 | |||
593 | regmap_read(priv->map, DS1343_STATUS_REG, &data); | ||
594 | data &= ~(DS1343_OSF | DS1343_IRQF1 | DS1343_IRQF0); | ||
595 | regmap_write(priv->map, DS1343_STATUS_REG, data); | ||
596 | |||
597 | priv->rtc = devm_rtc_device_register(&spi->dev, "ds1343", | ||
598 | &ds1343_rtc_ops, THIS_MODULE); | ||
599 | if (IS_ERR(priv->rtc)) { | ||
600 | dev_err(&spi->dev, "unable to register rtc ds1343\n"); | ||
601 | return PTR_ERR(priv->rtc); | ||
602 | } | ||
603 | |||
604 | priv->irq = spi->irq; | ||
605 | |||
606 | if (priv->irq >= 0) { | ||
607 | res = devm_request_threaded_irq(&spi->dev, spi->irq, NULL, | ||
608 | ds1343_thread, | ||
609 | IRQF_NO_SUSPEND | IRQF_ONESHOT, | ||
610 | "ds1343", priv); | ||
611 | if (res) { | ||
612 | priv->irq = -1; | ||
613 | dev_err(&spi->dev, | ||
614 | "unable to request irq for rtc ds1343\n"); | ||
615 | } else { | ||
616 | device_set_wakeup_capable(&spi->dev, 1); | ||
617 | } | ||
618 | } | ||
619 | |||
620 | res = ds1343_sysfs_register(&spi->dev); | ||
621 | if (res) | ||
622 | dev_err(&spi->dev, | ||
623 | "unable to create sysfs entries for rtc ds1343\n"); | ||
624 | |||
625 | return 0; | ||
626 | } | ||
627 | |||
628 | static int ds1343_remove(struct spi_device *spi) | ||
629 | { | ||
630 | struct ds1343_priv *priv = spi_get_drvdata(spi); | ||
631 | |||
632 | if (spi->irq) { | ||
633 | mutex_lock(&priv->mutex); | ||
634 | priv->irqen &= ~RTC_AF; | ||
635 | mutex_unlock(&priv->mutex); | ||
636 | |||
637 | devm_free_irq(&spi->dev, spi->irq, priv); | ||
638 | } | ||
639 | |||
640 | spi_set_drvdata(spi, NULL); | ||
641 | |||
642 | ds1343_sysfs_unregister(&spi->dev); | ||
643 | |||
644 | return 0; | ||
645 | } | ||
646 | |||
647 | #ifdef CONFIG_PM_SLEEP | ||
648 | |||
649 | static int ds1343_suspend(struct device *dev) | ||
650 | { | ||
651 | struct spi_device *spi = to_spi_device(dev); | ||
652 | |||
653 | if (spi->irq >= 0 && device_may_wakeup(dev)) | ||
654 | enable_irq_wake(spi->irq); | ||
655 | |||
656 | return 0; | ||
657 | } | ||
658 | |||
659 | static int ds1343_resume(struct device *dev) | ||
660 | { | ||
661 | struct spi_device *spi = to_spi_device(dev); | ||
662 | |||
663 | if (spi->irq >= 0 && device_may_wakeup(dev)) | ||
664 | disable_irq_wake(spi->irq); | ||
665 | |||
666 | return 0; | ||
667 | } | ||
668 | |||
669 | #endif | ||
670 | |||
671 | static SIMPLE_DEV_PM_OPS(ds1343_pm, ds1343_suspend, ds1343_resume); | ||
672 | |||
673 | static struct spi_driver ds1343_driver = { | ||
674 | .driver = { | ||
675 | .name = "ds1343", | ||
676 | .owner = THIS_MODULE, | ||
677 | .pm = &ds1343_pm, | ||
678 | }, | ||
679 | .probe = ds1343_probe, | ||
680 | .remove = ds1343_remove, | ||
681 | .id_table = ds1343_id, | ||
682 | }; | ||
683 | |||
684 | module_spi_driver(ds1343_driver); | ||
685 | |||
686 | MODULE_DESCRIPTION("DS1343 RTC SPI Driver"); | ||
687 | MODULE_AUTHOR("Raghavendra Chandra Ganiga <ravi23ganiga@gmail.com>"); | ||
688 | MODULE_LICENSE("GPL v2"); | ||
689 | MODULE_VERSION(DS1343_DRV_VERSION); | ||
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c index 942103dac30f..c6b2191a4128 100644 --- a/drivers/rtc/rtc-ds1742.c +++ b/drivers/rtc/rtc-ds1742.c | |||
@@ -219,7 +219,7 @@ static int ds1742_rtc_remove(struct platform_device *pdev) | |||
219 | return 0; | 219 | return 0; |
220 | } | 220 | } |
221 | 221 | ||
222 | static struct of_device_id __maybe_unused ds1742_rtc_of_match[] = { | 222 | static const struct of_device_id __maybe_unused ds1742_rtc_of_match[] = { |
223 | { .compatible = "maxim,ds1742", }, | 223 | { .compatible = "maxim,ds1742", }, |
224 | { } | 224 | { } |
225 | }; | 225 | }; |
diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c index 797aa0252ba9..c4c38431012e 100644 --- a/drivers/rtc/rtc-efi.c +++ b/drivers/rtc/rtc-efi.c | |||
@@ -35,7 +35,7 @@ static inline int | |||
35 | compute_yday(efi_time_t *eft) | 35 | compute_yday(efi_time_t *eft) |
36 | { | 36 | { |
37 | /* efi_time_t.month is in the [1-12] so, we need -1 */ | 37 | /* efi_time_t.month is in the [1-12] so, we need -1 */ |
38 | return rtc_year_days(eft->day - 1, eft->month - 1, eft->year); | 38 | return rtc_year_days(eft->day, eft->month - 1, eft->year); |
39 | } | 39 | } |
40 | /* | 40 | /* |
41 | * returns day of the week [0-6] 0=Sunday | 41 | * returns day of the week [0-6] 0=Sunday |
diff --git a/drivers/rtc/rtc-hym8563.c b/drivers/rtc/rtc-hym8563.c index e5f13c4310fe..b936bb4096b5 100644 --- a/drivers/rtc/rtc-hym8563.c +++ b/drivers/rtc/rtc-hym8563.c | |||
@@ -418,6 +418,9 @@ static struct clk *hym8563_clkout_register_clk(struct hym8563 *hym8563) | |||
418 | init.num_parents = 0; | 418 | init.num_parents = 0; |
419 | hym8563->clkout_hw.init = &init; | 419 | hym8563->clkout_hw.init = &init; |
420 | 420 | ||
421 | /* optional override of the clockname */ | ||
422 | of_property_read_string(node, "clock-output-names", &init.name); | ||
423 | |||
421 | /* register the clock */ | 424 | /* register the clock */ |
422 | clk = clk_register(&client->dev, &hym8563->clkout_hw); | 425 | clk = clk_register(&client->dev, &hym8563->clkout_hw); |
423 | 426 | ||
@@ -585,7 +588,7 @@ static const struct i2c_device_id hym8563_id[] = { | |||
585 | }; | 588 | }; |
586 | MODULE_DEVICE_TABLE(i2c, hym8563_id); | 589 | MODULE_DEVICE_TABLE(i2c, hym8563_id); |
587 | 590 | ||
588 | static struct of_device_id hym8563_dt_idtable[] = { | 591 | static const struct of_device_id hym8563_dt_idtable[] = { |
589 | { .compatible = "haoyu,hym8563" }, | 592 | { .compatible = "haoyu,hym8563" }, |
590 | {}, | 593 | {}, |
591 | }; | 594 | }; |
diff --git a/drivers/rtc/rtc-isl12057.c b/drivers/rtc/rtc-isl12057.c index 41bd76aaff76..455b601d731d 100644 --- a/drivers/rtc/rtc-isl12057.c +++ b/drivers/rtc/rtc-isl12057.c | |||
@@ -278,7 +278,7 @@ static int isl12057_probe(struct i2c_client *client, | |||
278 | } | 278 | } |
279 | 279 | ||
280 | #ifdef CONFIG_OF | 280 | #ifdef CONFIG_OF |
281 | static struct of_device_id isl12057_dt_match[] = { | 281 | static const struct of_device_id isl12057_dt_match[] = { |
282 | { .compatible = "isl,isl12057" }, | 282 | { .compatible = "isl,isl12057" }, |
283 | { }, | 283 | { }, |
284 | }; | 284 | }; |
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index a5248aa1abf1..7ff7427c2e6a 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -66,8 +66,6 @@ | |||
66 | #define M41T80_FEATURE_WD (1 << 3) /* Extra watchdog resolution */ | 66 | #define M41T80_FEATURE_WD (1 << 3) /* Extra watchdog resolution */ |
67 | #define M41T80_FEATURE_SQ_ALT (1 << 4) /* RSx bits are in reg 4 */ | 67 | #define M41T80_FEATURE_SQ_ALT (1 << 4) /* RSx bits are in reg 4 */ |
68 | 68 | ||
69 | #define DRV_VERSION "0.05" | ||
70 | |||
71 | static DEFINE_MUTEX(m41t80_rtc_mutex); | 69 | static DEFINE_MUTEX(m41t80_rtc_mutex); |
72 | static const struct i2c_device_id m41t80_id[] = { | 70 | static const struct i2c_device_id m41t80_id[] = { |
73 | { "m41t62", M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT }, | 71 | { "m41t62", M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT }, |
@@ -80,6 +78,7 @@ static const struct i2c_device_id m41t80_id[] = { | |||
80 | { "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ }, | 78 | { "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ }, |
81 | { "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ }, | 79 | { "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ }, |
82 | { "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ }, | 80 | { "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ }, |
81 | { "rv4162", M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT }, | ||
83 | { } | 82 | { } |
84 | }; | 83 | }; |
85 | MODULE_DEVICE_TABLE(i2c, m41t80_id); | 84 | MODULE_DEVICE_TABLE(i2c, m41t80_id); |
@@ -232,7 +231,7 @@ static ssize_t m41t80_sysfs_show_flags(struct device *dev, | |||
232 | 231 | ||
233 | val = i2c_smbus_read_byte_data(client, M41T80_REG_FLAGS); | 232 | val = i2c_smbus_read_byte_data(client, M41T80_REG_FLAGS); |
234 | if (val < 0) | 233 | if (val < 0) |
235 | return -EIO; | 234 | return val; |
236 | return sprintf(buf, "%#x\n", val); | 235 | return sprintf(buf, "%#x\n", val); |
237 | } | 236 | } |
238 | static DEVICE_ATTR(flags, S_IRUGO, m41t80_sysfs_show_flags, NULL); | 237 | static DEVICE_ATTR(flags, S_IRUGO, m41t80_sysfs_show_flags, NULL); |
@@ -252,7 +251,7 @@ static ssize_t m41t80_sysfs_show_sqwfreq(struct device *dev, | |||
252 | reg_sqw = M41T80_REG_WDAY; | 251 | reg_sqw = M41T80_REG_WDAY; |
253 | val = i2c_smbus_read_byte_data(client, reg_sqw); | 252 | val = i2c_smbus_read_byte_data(client, reg_sqw); |
254 | if (val < 0) | 253 | if (val < 0) |
255 | return -EIO; | 254 | return val; |
256 | val = (val >> 4) & 0xf; | 255 | val = (val >> 4) & 0xf; |
257 | switch (val) { | 256 | switch (val) { |
258 | case 0: | 257 | case 0: |
@@ -271,7 +270,7 @@ static ssize_t m41t80_sysfs_set_sqwfreq(struct device *dev, | |||
271 | { | 270 | { |
272 | struct i2c_client *client = to_i2c_client(dev); | 271 | struct i2c_client *client = to_i2c_client(dev); |
273 | struct m41t80_data *clientdata = i2c_get_clientdata(client); | 272 | struct m41t80_data *clientdata = i2c_get_clientdata(client); |
274 | int almon, sqw, reg_sqw; | 273 | int almon, sqw, reg_sqw, rc; |
275 | int val = simple_strtoul(buf, NULL, 0); | 274 | int val = simple_strtoul(buf, NULL, 0); |
276 | 275 | ||
277 | if (!(clientdata->features & M41T80_FEATURE_SQ)) | 276 | if (!(clientdata->features & M41T80_FEATURE_SQ)) |
@@ -291,21 +290,30 @@ static ssize_t m41t80_sysfs_set_sqwfreq(struct device *dev, | |||
291 | /* disable SQW, set SQW frequency & re-enable */ | 290 | /* disable SQW, set SQW frequency & re-enable */ |
292 | almon = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_MON); | 291 | almon = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_MON); |
293 | if (almon < 0) | 292 | if (almon < 0) |
294 | return -EIO; | 293 | return almon; |
295 | reg_sqw = M41T80_REG_SQW; | 294 | reg_sqw = M41T80_REG_SQW; |
296 | if (clientdata->features & M41T80_FEATURE_SQ_ALT) | 295 | if (clientdata->features & M41T80_FEATURE_SQ_ALT) |
297 | reg_sqw = M41T80_REG_WDAY; | 296 | reg_sqw = M41T80_REG_WDAY; |
298 | sqw = i2c_smbus_read_byte_data(client, reg_sqw); | 297 | sqw = i2c_smbus_read_byte_data(client, reg_sqw); |
299 | if (sqw < 0) | 298 | if (sqw < 0) |
300 | return -EIO; | 299 | return sqw; |
301 | sqw = (sqw & 0x0f) | (val << 4); | 300 | sqw = (sqw & 0x0f) | (val << 4); |
302 | if (i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON, | 301 | |
303 | almon & ~M41T80_ALMON_SQWE) < 0 || | 302 | rc = i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON, |
304 | i2c_smbus_write_byte_data(client, reg_sqw, sqw) < 0) | 303 | almon & ~M41T80_ALMON_SQWE); |
305 | return -EIO; | 304 | if (rc < 0) |
306 | if (val && i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON, | 305 | return rc; |
307 | almon | M41T80_ALMON_SQWE) < 0) | 306 | |
308 | return -EIO; | 307 | if (val) { |
308 | rc = i2c_smbus_write_byte_data(client, reg_sqw, sqw); | ||
309 | if (rc < 0) | ||
310 | return rc; | ||
311 | |||
312 | rc = i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON, | ||
313 | almon | M41T80_ALMON_SQWE); | ||
314 | if (rc <0) | ||
315 | return rc; | ||
316 | } | ||
309 | return count; | 317 | return count; |
310 | } | 318 | } |
311 | static DEVICE_ATTR(sqwfreq, S_IRUGO | S_IWUSR, | 319 | static DEVICE_ATTR(sqwfreq, S_IRUGO | S_IWUSR, |
@@ -629,40 +637,28 @@ static int m41t80_probe(struct i2c_client *client, | |||
629 | struct m41t80_data *clientdata = NULL; | 637 | struct m41t80_data *clientdata = NULL; |
630 | 638 | ||
631 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C | 639 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C |
632 | | I2C_FUNC_SMBUS_BYTE_DATA)) { | 640 | | I2C_FUNC_SMBUS_BYTE_DATA)) |
633 | rc = -ENODEV; | 641 | return -ENODEV; |
634 | goto exit; | ||
635 | } | ||
636 | |||
637 | dev_info(&client->dev, | ||
638 | "chip found, driver version " DRV_VERSION "\n"); | ||
639 | 642 | ||
640 | clientdata = devm_kzalloc(&client->dev, sizeof(*clientdata), | 643 | clientdata = devm_kzalloc(&client->dev, sizeof(*clientdata), |
641 | GFP_KERNEL); | 644 | GFP_KERNEL); |
642 | if (!clientdata) { | 645 | if (!clientdata) |
643 | rc = -ENOMEM; | 646 | return -ENOMEM; |
644 | goto exit; | ||
645 | } | ||
646 | 647 | ||
647 | clientdata->features = id->driver_data; | 648 | clientdata->features = id->driver_data; |
648 | i2c_set_clientdata(client, clientdata); | 649 | i2c_set_clientdata(client, clientdata); |
649 | 650 | ||
650 | rtc = devm_rtc_device_register(&client->dev, client->name, | 651 | rtc = devm_rtc_device_register(&client->dev, client->name, |
651 | &m41t80_rtc_ops, THIS_MODULE); | 652 | &m41t80_rtc_ops, THIS_MODULE); |
652 | if (IS_ERR(rtc)) { | 653 | if (IS_ERR(rtc)) |
653 | rc = PTR_ERR(rtc); | 654 | return PTR_ERR(rtc); |
654 | rtc = NULL; | ||
655 | goto exit; | ||
656 | } | ||
657 | 655 | ||
658 | clientdata->rtc = rtc; | 656 | clientdata->rtc = rtc; |
659 | 657 | ||
660 | /* Make sure HT (Halt Update) bit is cleared */ | 658 | /* Make sure HT (Halt Update) bit is cleared */ |
661 | rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR); | 659 | rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR); |
662 | if (rc < 0) | ||
663 | goto ht_err; | ||
664 | 660 | ||
665 | if (rc & M41T80_ALHOUR_HT) { | 661 | if (rc >= 0 && rc & M41T80_ALHOUR_HT) { |
666 | if (clientdata->features & M41T80_FEATURE_HT) { | 662 | if (clientdata->features & M41T80_FEATURE_HT) { |
667 | m41t80_get_datetime(client, &tm); | 663 | m41t80_get_datetime(client, &tm); |
668 | dev_info(&client->dev, "HT bit was set!\n"); | 664 | dev_info(&client->dev, "HT bit was set!\n"); |
@@ -673,53 +669,44 @@ static int m41t80_probe(struct i2c_client *client, | |||
673 | tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, | 669 | tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, |
674 | tm.tm_min, tm.tm_sec); | 670 | tm.tm_min, tm.tm_sec); |
675 | } | 671 | } |
676 | if (i2c_smbus_write_byte_data(client, | 672 | rc = i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_HOUR, |
677 | M41T80_REG_ALARM_HOUR, | 673 | rc & ~M41T80_ALHOUR_HT); |
678 | rc & ~M41T80_ALHOUR_HT) < 0) | 674 | } |
679 | goto ht_err; | 675 | |
676 | if (rc < 0) { | ||
677 | dev_err(&client->dev, "Can't clear HT bit\n"); | ||
678 | return rc; | ||
680 | } | 679 | } |
681 | 680 | ||
682 | /* Make sure ST (stop) bit is cleared */ | 681 | /* Make sure ST (stop) bit is cleared */ |
683 | rc = i2c_smbus_read_byte_data(client, M41T80_REG_SEC); | 682 | rc = i2c_smbus_read_byte_data(client, M41T80_REG_SEC); |
684 | if (rc < 0) | ||
685 | goto st_err; | ||
686 | 683 | ||
687 | if (rc & M41T80_SEC_ST) { | 684 | if (rc >= 0 && rc & M41T80_SEC_ST) |
688 | if (i2c_smbus_write_byte_data(client, M41T80_REG_SEC, | 685 | rc = i2c_smbus_write_byte_data(client, M41T80_REG_SEC, |
689 | rc & ~M41T80_SEC_ST) < 0) | 686 | rc & ~M41T80_SEC_ST); |
690 | goto st_err; | 687 | if (rc < 0) { |
688 | dev_err(&client->dev, "Can't clear ST bit\n"); | ||
689 | return rc; | ||
691 | } | 690 | } |
692 | 691 | ||
693 | rc = m41t80_sysfs_register(&client->dev); | 692 | rc = m41t80_sysfs_register(&client->dev); |
694 | if (rc) | 693 | if (rc) |
695 | goto exit; | 694 | return rc; |
696 | 695 | ||
697 | #ifdef CONFIG_RTC_DRV_M41T80_WDT | 696 | #ifdef CONFIG_RTC_DRV_M41T80_WDT |
698 | if (clientdata->features & M41T80_FEATURE_HT) { | 697 | if (clientdata->features & M41T80_FEATURE_HT) { |
699 | save_client = client; | 698 | save_client = client; |
700 | rc = misc_register(&wdt_dev); | 699 | rc = misc_register(&wdt_dev); |
701 | if (rc) | 700 | if (rc) |
702 | goto exit; | 701 | return rc; |
703 | rc = register_reboot_notifier(&wdt_notifier); | 702 | rc = register_reboot_notifier(&wdt_notifier); |
704 | if (rc) { | 703 | if (rc) { |
705 | misc_deregister(&wdt_dev); | 704 | misc_deregister(&wdt_dev); |
706 | goto exit; | 705 | return rc; |
707 | } | 706 | } |
708 | } | 707 | } |
709 | #endif | 708 | #endif |
710 | return 0; | 709 | return 0; |
711 | |||
712 | st_err: | ||
713 | rc = -EIO; | ||
714 | dev_err(&client->dev, "Can't clear ST bit\n"); | ||
715 | goto exit; | ||
716 | ht_err: | ||
717 | rc = -EIO; | ||
718 | dev_err(&client->dev, "Can't clear HT bit\n"); | ||
719 | goto exit; | ||
720 | |||
721 | exit: | ||
722 | return rc; | ||
723 | } | 710 | } |
724 | 711 | ||
725 | static int m41t80_remove(struct i2c_client *client) | 712 | static int m41t80_remove(struct i2c_client *client) |
@@ -750,4 +737,3 @@ module_i2c_driver(m41t80_driver); | |||
750 | MODULE_AUTHOR("Alexander Bigga <ab@mycable.de>"); | 737 | MODULE_AUTHOR("Alexander Bigga <ab@mycable.de>"); |
751 | MODULE_DESCRIPTION("ST Microelectronics M41T80 series RTC I2C Client Driver"); | 738 | MODULE_DESCRIPTION("ST Microelectronics M41T80 series RTC I2C Client Driver"); |
752 | MODULE_LICENSE("GPL"); | 739 | MODULE_LICENSE("GPL"); |
753 | MODULE_VERSION(DRV_VERSION); | ||
diff --git a/drivers/rtc/rtc-mcp795.c b/drivers/rtc/rtc-mcp795.c new file mode 100644 index 000000000000..34295bf00416 --- /dev/null +++ b/drivers/rtc/rtc-mcp795.c | |||
@@ -0,0 +1,199 @@ | |||
1 | /* | ||
2 | * SPI Driver for Microchip MCP795 RTC | ||
3 | * | ||
4 | * Copyright (C) Josef Gajdusek <atx@atx.name> | ||
5 | * | ||
6 | * based on other Linux RTC drivers | ||
7 | * | ||
8 | * Device datasheet: | ||
9 | * http://ww1.microchip.com/downloads/en/DeviceDoc/22280A.pdf | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License version 2 as | ||
13 | * published by the Free Software Foundation. | ||
14 | * | ||
15 | * */ | ||
16 | |||
17 | #include <linux/module.h> | ||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/device.h> | ||
20 | #include <linux/printk.h> | ||
21 | #include <linux/spi/spi.h> | ||
22 | #include <linux/rtc.h> | ||
23 | |||
24 | /* MCP795 Instructions, see datasheet table 3-1 */ | ||
25 | #define MCP795_EEREAD 0x03 | ||
26 | #define MCP795_EEWRITE 0x02 | ||
27 | #define MCP795_EEWRDI 0x04 | ||
28 | #define MCP795_EEWREN 0x06 | ||
29 | #define MCP795_SRREAD 0x05 | ||
30 | #define MCP795_SRWRITE 0x01 | ||
31 | #define MCP795_READ 0x13 | ||
32 | #define MCP795_WRITE 0x12 | ||
33 | #define MCP795_UNLOCK 0x14 | ||
34 | #define MCP795_IDWRITE 0x32 | ||
35 | #define MCP795_IDREAD 0x33 | ||
36 | #define MCP795_CLRWDT 0x44 | ||
37 | #define MCP795_CLRRAM 0x54 | ||
38 | |||
39 | #define MCP795_ST_BIT 0x80 | ||
40 | #define MCP795_24_BIT 0x40 | ||
41 | |||
42 | static int mcp795_rtcc_read(struct device *dev, u8 addr, u8 *buf, u8 count) | ||
43 | { | ||
44 | struct spi_device *spi = to_spi_device(dev); | ||
45 | int ret; | ||
46 | u8 tx[2]; | ||
47 | |||
48 | tx[0] = MCP795_READ; | ||
49 | tx[1] = addr; | ||
50 | ret = spi_write_then_read(spi, tx, sizeof(tx), buf, count); | ||
51 | |||
52 | if (ret) | ||
53 | dev_err(dev, "Failed reading %d bytes from address %x.\n", | ||
54 | count, addr); | ||
55 | |||
56 | return ret; | ||
57 | } | ||
58 | |||
59 | static int mcp795_rtcc_write(struct device *dev, u8 addr, u8 *data, u8 count) | ||
60 | { | ||
61 | struct spi_device *spi = to_spi_device(dev); | ||
62 | int ret; | ||
63 | u8 tx[2 + count]; | ||
64 | |||
65 | tx[0] = MCP795_WRITE; | ||
66 | tx[1] = addr; | ||
67 | memcpy(&tx[2], data, count); | ||
68 | |||
69 | ret = spi_write(spi, tx, 2 + count); | ||
70 | |||
71 | if (ret) | ||
72 | dev_err(dev, "Failed to write %d bytes to address %x.\n", | ||
73 | count, addr); | ||
74 | |||
75 | return ret; | ||
76 | } | ||
77 | |||
78 | static int mcp795_rtcc_set_bits(struct device *dev, u8 addr, u8 mask, u8 state) | ||
79 | { | ||
80 | int ret; | ||
81 | u8 tmp; | ||
82 | |||
83 | ret = mcp795_rtcc_read(dev, addr, &tmp, 1); | ||
84 | if (ret) | ||
85 | return ret; | ||
86 | |||
87 | if ((tmp & mask) != state) { | ||
88 | tmp = (tmp & ~mask) | state; | ||
89 | ret = mcp795_rtcc_write(dev, addr, &tmp, 1); | ||
90 | } | ||
91 | |||
92 | return ret; | ||
93 | } | ||
94 | |||
95 | static int mcp795_set_time(struct device *dev, struct rtc_time *tim) | ||
96 | { | ||
97 | int ret; | ||
98 | u8 data[7]; | ||
99 | |||
100 | /* Read first, so we can leave config bits untouched */ | ||
101 | ret = mcp795_rtcc_read(dev, 0x01, data, sizeof(data)); | ||
102 | |||
103 | if (ret) | ||
104 | return ret; | ||
105 | |||
106 | data[0] = (data[0] & 0x80) | ((tim->tm_sec / 10) << 4) | (tim->tm_sec % 10); | ||
107 | data[1] = (data[1] & 0x80) | ((tim->tm_min / 10) << 4) | (tim->tm_min % 10); | ||
108 | data[2] = ((tim->tm_hour / 10) << 4) | (tim->tm_hour % 10); | ||
109 | data[4] = ((tim->tm_mday / 10) << 4) | ((tim->tm_mday) % 10); | ||
110 | data[5] = (data[5] & 0x10) | (tim->tm_mon / 10) | (tim->tm_mon % 10); | ||
111 | |||
112 | if (tim->tm_year > 100) | ||
113 | tim->tm_year -= 100; | ||
114 | |||
115 | data[6] = ((tim->tm_year / 10) << 4) | (tim->tm_year % 10); | ||
116 | |||
117 | ret = mcp795_rtcc_write(dev, 0x01, data, sizeof(data)); | ||
118 | |||
119 | if (ret) | ||
120 | return ret; | ||
121 | |||
122 | dev_dbg(dev, "Set mcp795: %04d-%02d-%02d %02d:%02d:%02d\n", | ||
123 | tim->tm_year + 1900, tim->tm_mon, tim->tm_mday, | ||
124 | tim->tm_hour, tim->tm_min, tim->tm_sec); | ||
125 | |||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | static int mcp795_read_time(struct device *dev, struct rtc_time *tim) | ||
130 | { | ||
131 | int ret; | ||
132 | u8 data[7]; | ||
133 | |||
134 | ret = mcp795_rtcc_read(dev, 0x01, data, sizeof(data)); | ||
135 | |||
136 | if (ret) | ||
137 | return ret; | ||
138 | |||
139 | tim->tm_sec = ((data[0] & 0x70) >> 4) * 10 + (data[0] & 0x0f); | ||
140 | tim->tm_min = ((data[1] & 0x70) >> 4) * 10 + (data[1] & 0x0f); | ||
141 | tim->tm_hour = ((data[2] & 0x30) >> 4) * 10 + (data[2] & 0x0f); | ||
142 | tim->tm_mday = ((data[4] & 0x30) >> 4) * 10 + (data[4] & 0x0f); | ||
143 | tim->tm_mon = ((data[5] & 0x10) >> 4) * 10 + (data[5] & 0x0f); | ||
144 | tim->tm_year = ((data[6] & 0xf0) >> 4) * 10 + (data[6] & 0x0f) + 100; /* Assume we are in 20xx */ | ||
145 | |||
146 | dev_dbg(dev, "Read from mcp795: %04d-%02d-%02d %02d:%02d:%02d\n", | ||
147 | tim->tm_year + 1900, tim->tm_mon, tim->tm_mday, | ||
148 | tim->tm_hour, tim->tm_min, tim->tm_sec); | ||
149 | |||
150 | return rtc_valid_tm(tim); | ||
151 | } | ||
152 | |||
153 | static struct rtc_class_ops mcp795_rtc_ops = { | ||
154 | .read_time = mcp795_read_time, | ||
155 | .set_time = mcp795_set_time | ||
156 | }; | ||
157 | |||
158 | static int mcp795_probe(struct spi_device *spi) | ||
159 | { | ||
160 | struct rtc_device *rtc; | ||
161 | int ret; | ||
162 | |||
163 | spi->mode = SPI_MODE_0; | ||
164 | spi->bits_per_word = 8; | ||
165 | ret = spi_setup(spi); | ||
166 | if (ret) { | ||
167 | dev_err(&spi->dev, "Unable to setup SPI\n"); | ||
168 | return ret; | ||
169 | } | ||
170 | |||
171 | /* Start the oscillator */ | ||
172 | mcp795_rtcc_set_bits(&spi->dev, 0x01, MCP795_ST_BIT, MCP795_ST_BIT); | ||
173 | /* Clear the 12 hour mode flag*/ | ||
174 | mcp795_rtcc_set_bits(&spi->dev, 0x03, MCP795_24_BIT, 0); | ||
175 | |||
176 | rtc = devm_rtc_device_register(&spi->dev, "rtc-mcp795", | ||
177 | &mcp795_rtc_ops, THIS_MODULE); | ||
178 | if (IS_ERR(rtc)) | ||
179 | return PTR_ERR(rtc); | ||
180 | |||
181 | spi_set_drvdata(spi, rtc); | ||
182 | |||
183 | return 0; | ||
184 | } | ||
185 | |||
186 | static struct spi_driver mcp795_driver = { | ||
187 | .driver = { | ||
188 | .name = "rtc-mcp795", | ||
189 | .owner = THIS_MODULE, | ||
190 | }, | ||
191 | .probe = mcp795_probe, | ||
192 | }; | ||
193 | |||
194 | module_spi_driver(mcp795_driver); | ||
195 | |||
196 | MODULE_DESCRIPTION("MCP795 RTC SPI Driver"); | ||
197 | MODULE_AUTHOR("Josef Gajdusek <atx@atx.name>"); | ||
198 | MODULE_LICENSE("GPL"); | ||
199 | MODULE_ALIAS("spi:mcp795"); | ||
diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c index d15a999363fc..6aaec2fc7c0d 100644 --- a/drivers/rtc/rtc-mv.c +++ b/drivers/rtc/rtc-mv.c | |||
@@ -319,7 +319,7 @@ static int __exit mv_rtc_remove(struct platform_device *pdev) | |||
319 | } | 319 | } |
320 | 320 | ||
321 | #ifdef CONFIG_OF | 321 | #ifdef CONFIG_OF |
322 | static struct of_device_id rtc_mv_of_match_table[] = { | 322 | static const struct of_device_id rtc_mv_of_match_table[] = { |
323 | { .compatible = "marvell,orion-rtc", }, | 323 | { .compatible = "marvell,orion-rtc", }, |
324 | {} | 324 | {} |
325 | }; | 325 | }; |
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 26de5f8c2ae4..21142e6574a9 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
@@ -73,43 +73,52 @@ | |||
73 | #define OMAP_RTC_IRQWAKEEN 0x7c | 73 | #define OMAP_RTC_IRQWAKEEN 0x7c |
74 | 74 | ||
75 | /* OMAP_RTC_CTRL_REG bit fields: */ | 75 | /* OMAP_RTC_CTRL_REG bit fields: */ |
76 | #define OMAP_RTC_CTRL_SPLIT (1<<7) | 76 | #define OMAP_RTC_CTRL_SPLIT BIT(7) |
77 | #define OMAP_RTC_CTRL_DISABLE (1<<6) | 77 | #define OMAP_RTC_CTRL_DISABLE BIT(6) |
78 | #define OMAP_RTC_CTRL_SET_32_COUNTER (1<<5) | 78 | #define OMAP_RTC_CTRL_SET_32_COUNTER BIT(5) |
79 | #define OMAP_RTC_CTRL_TEST (1<<4) | 79 | #define OMAP_RTC_CTRL_TEST BIT(4) |
80 | #define OMAP_RTC_CTRL_MODE_12_24 (1<<3) | 80 | #define OMAP_RTC_CTRL_MODE_12_24 BIT(3) |
81 | #define OMAP_RTC_CTRL_AUTO_COMP (1<<2) | 81 | #define OMAP_RTC_CTRL_AUTO_COMP BIT(2) |
82 | #define OMAP_RTC_CTRL_ROUND_30S (1<<1) | 82 | #define OMAP_RTC_CTRL_ROUND_30S BIT(1) |
83 | #define OMAP_RTC_CTRL_STOP (1<<0) | 83 | #define OMAP_RTC_CTRL_STOP BIT(0) |
84 | 84 | ||
85 | /* OMAP_RTC_STATUS_REG bit fields: */ | 85 | /* OMAP_RTC_STATUS_REG bit fields: */ |
86 | #define OMAP_RTC_STATUS_POWER_UP (1<<7) | 86 | #define OMAP_RTC_STATUS_POWER_UP BIT(7) |
87 | #define OMAP_RTC_STATUS_ALARM (1<<6) | 87 | #define OMAP_RTC_STATUS_ALARM BIT(6) |
88 | #define OMAP_RTC_STATUS_1D_EVENT (1<<5) | 88 | #define OMAP_RTC_STATUS_1D_EVENT BIT(5) |
89 | #define OMAP_RTC_STATUS_1H_EVENT (1<<4) | 89 | #define OMAP_RTC_STATUS_1H_EVENT BIT(4) |
90 | #define OMAP_RTC_STATUS_1M_EVENT (1<<3) | 90 | #define OMAP_RTC_STATUS_1M_EVENT BIT(3) |
91 | #define OMAP_RTC_STATUS_1S_EVENT (1<<2) | 91 | #define OMAP_RTC_STATUS_1S_EVENT BIT(2) |
92 | #define OMAP_RTC_STATUS_RUN (1<<1) | 92 | #define OMAP_RTC_STATUS_RUN BIT(1) |
93 | #define OMAP_RTC_STATUS_BUSY (1<<0) | 93 | #define OMAP_RTC_STATUS_BUSY BIT(0) |
94 | 94 | ||
95 | /* OMAP_RTC_INTERRUPTS_REG bit fields: */ | 95 | /* OMAP_RTC_INTERRUPTS_REG bit fields: */ |
96 | #define OMAP_RTC_INTERRUPTS_IT_ALARM (1<<3) | 96 | #define OMAP_RTC_INTERRUPTS_IT_ALARM BIT(3) |
97 | #define OMAP_RTC_INTERRUPTS_IT_TIMER (1<<2) | 97 | #define OMAP_RTC_INTERRUPTS_IT_TIMER BIT(2) |
98 | |||
99 | /* OMAP_RTC_OSC_REG bit fields: */ | ||
100 | #define OMAP_RTC_OSC_32KCLK_EN BIT(6) | ||
98 | 101 | ||
99 | /* OMAP_RTC_IRQWAKEEN bit fields: */ | 102 | /* OMAP_RTC_IRQWAKEEN bit fields: */ |
100 | #define OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN (1<<1) | 103 | #define OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN BIT(1) |
101 | 104 | ||
102 | /* OMAP_RTC_KICKER values */ | 105 | /* OMAP_RTC_KICKER values */ |
103 | #define KICK0_VALUE 0x83e70b13 | 106 | #define KICK0_VALUE 0x83e70b13 |
104 | #define KICK1_VALUE 0x95a4f1e0 | 107 | #define KICK1_VALUE 0x95a4f1e0 |
105 | 108 | ||
106 | #define OMAP_RTC_HAS_KICKER 0x1 | 109 | #define OMAP_RTC_HAS_KICKER BIT(0) |
107 | 110 | ||
108 | /* | 111 | /* |
109 | * Few RTC IP revisions has special WAKE-EN Register to enable Wakeup | 112 | * Few RTC IP revisions has special WAKE-EN Register to enable Wakeup |
110 | * generation for event Alarm. | 113 | * generation for event Alarm. |
111 | */ | 114 | */ |
112 | #define OMAP_RTC_HAS_IRQWAKEEN 0x2 | 115 | #define OMAP_RTC_HAS_IRQWAKEEN BIT(1) |
116 | |||
117 | /* | ||
118 | * Some RTC IP revisions (like those in AM335x and DRA7x) need | ||
119 | * the 32KHz clock to be explicitly enabled. | ||
120 | */ | ||
121 | #define OMAP_RTC_HAS_32KCLK_EN BIT(2) | ||
113 | 122 | ||
114 | static void __iomem *rtc_base; | 123 | static void __iomem *rtc_base; |
115 | 124 | ||
@@ -162,17 +171,28 @@ static irqreturn_t rtc_irq(int irq, void *rtc) | |||
162 | 171 | ||
163 | static int omap_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | 172 | static int omap_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
164 | { | 173 | { |
165 | u8 reg; | 174 | u8 reg, irqwake_reg = 0; |
175 | struct platform_device *pdev = to_platform_device(dev); | ||
176 | const struct platform_device_id *id_entry = | ||
177 | platform_get_device_id(pdev); | ||
166 | 178 | ||
167 | local_irq_disable(); | 179 | local_irq_disable(); |
168 | rtc_wait_not_busy(); | 180 | rtc_wait_not_busy(); |
169 | reg = rtc_read(OMAP_RTC_INTERRUPTS_REG); | 181 | reg = rtc_read(OMAP_RTC_INTERRUPTS_REG); |
170 | if (enabled) | 182 | if (id_entry->driver_data & OMAP_RTC_HAS_IRQWAKEEN) |
183 | irqwake_reg = rtc_read(OMAP_RTC_IRQWAKEEN); | ||
184 | |||
185 | if (enabled) { | ||
171 | reg |= OMAP_RTC_INTERRUPTS_IT_ALARM; | 186 | reg |= OMAP_RTC_INTERRUPTS_IT_ALARM; |
172 | else | 187 | irqwake_reg |= OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN; |
188 | } else { | ||
173 | reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM; | 189 | reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM; |
190 | irqwake_reg &= ~OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN; | ||
191 | } | ||
174 | rtc_wait_not_busy(); | 192 | rtc_wait_not_busy(); |
175 | rtc_write(reg, OMAP_RTC_INTERRUPTS_REG); | 193 | rtc_write(reg, OMAP_RTC_INTERRUPTS_REG); |
194 | if (id_entry->driver_data & OMAP_RTC_HAS_IRQWAKEEN) | ||
195 | rtc_write(irqwake_reg, OMAP_RTC_IRQWAKEEN); | ||
176 | local_irq_enable(); | 196 | local_irq_enable(); |
177 | 197 | ||
178 | return 0; | 198 | return 0; |
@@ -272,7 +292,10 @@ static int omap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
272 | 292 | ||
273 | static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | 293 | static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) |
274 | { | 294 | { |
275 | u8 reg; | 295 | u8 reg, irqwake_reg = 0; |
296 | struct platform_device *pdev = to_platform_device(dev); | ||
297 | const struct platform_device_id *id_entry = | ||
298 | platform_get_device_id(pdev); | ||
276 | 299 | ||
277 | if (tm2bcd(&alm->time) < 0) | 300 | if (tm2bcd(&alm->time) < 0) |
278 | return -EINVAL; | 301 | return -EINVAL; |
@@ -288,11 +311,19 @@ static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
288 | rtc_write(alm->time.tm_sec, OMAP_RTC_ALARM_SECONDS_REG); | 311 | rtc_write(alm->time.tm_sec, OMAP_RTC_ALARM_SECONDS_REG); |
289 | 312 | ||
290 | reg = rtc_read(OMAP_RTC_INTERRUPTS_REG); | 313 | reg = rtc_read(OMAP_RTC_INTERRUPTS_REG); |
291 | if (alm->enabled) | 314 | if (id_entry->driver_data & OMAP_RTC_HAS_IRQWAKEEN) |
315 | irqwake_reg = rtc_read(OMAP_RTC_IRQWAKEEN); | ||
316 | |||
317 | if (alm->enabled) { | ||
292 | reg |= OMAP_RTC_INTERRUPTS_IT_ALARM; | 318 | reg |= OMAP_RTC_INTERRUPTS_IT_ALARM; |
293 | else | 319 | irqwake_reg |= OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN; |
320 | } else { | ||
294 | reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM; | 321 | reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM; |
322 | irqwake_reg &= ~OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN; | ||
323 | } | ||
295 | rtc_write(reg, OMAP_RTC_INTERRUPTS_REG); | 324 | rtc_write(reg, OMAP_RTC_INTERRUPTS_REG); |
325 | if (id_entry->driver_data & OMAP_RTC_HAS_IRQWAKEEN) | ||
326 | rtc_write(irqwake_reg, OMAP_RTC_IRQWAKEEN); | ||
296 | 327 | ||
297 | local_irq_enable(); | 328 | local_irq_enable(); |
298 | 329 | ||
@@ -319,7 +350,8 @@ static struct platform_device_id omap_rtc_devtype[] = { | |||
319 | }, | 350 | }, |
320 | [OMAP_RTC_DATA_AM3352_IDX] = { | 351 | [OMAP_RTC_DATA_AM3352_IDX] = { |
321 | .name = "am3352-rtc", | 352 | .name = "am3352-rtc", |
322 | .driver_data = OMAP_RTC_HAS_KICKER | OMAP_RTC_HAS_IRQWAKEEN, | 353 | .driver_data = OMAP_RTC_HAS_KICKER | OMAP_RTC_HAS_IRQWAKEEN | |
354 | OMAP_RTC_HAS_32KCLK_EN, | ||
323 | }, | 355 | }, |
324 | [OMAP_RTC_DATA_DA830_IDX] = { | 356 | [OMAP_RTC_DATA_DA830_IDX] = { |
325 | .name = "da830-rtc", | 357 | .name = "da830-rtc", |
@@ -352,6 +384,12 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
352 | if (of_id) | 384 | if (of_id) |
353 | pdev->id_entry = of_id->data; | 385 | pdev->id_entry = of_id->data; |
354 | 386 | ||
387 | id_entry = platform_get_device_id(pdev); | ||
388 | if (!id_entry) { | ||
389 | dev_err(&pdev->dev, "no matching device entry\n"); | ||
390 | return -ENODEV; | ||
391 | } | ||
392 | |||
355 | omap_rtc_timer = platform_get_irq(pdev, 0); | 393 | omap_rtc_timer = platform_get_irq(pdev, 0); |
356 | if (omap_rtc_timer <= 0) { | 394 | if (omap_rtc_timer <= 0) { |
357 | pr_debug("%s: no update irq?\n", pdev->name); | 395 | pr_debug("%s: no update irq?\n", pdev->name); |
@@ -373,8 +411,7 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
373 | pm_runtime_enable(&pdev->dev); | 411 | pm_runtime_enable(&pdev->dev); |
374 | pm_runtime_get_sync(&pdev->dev); | 412 | pm_runtime_get_sync(&pdev->dev); |
375 | 413 | ||
376 | id_entry = platform_get_device_id(pdev); | 414 | if (id_entry->driver_data & OMAP_RTC_HAS_KICKER) { |
377 | if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) { | ||
378 | rtc_writel(KICK0_VALUE, OMAP_RTC_KICK0_REG); | 415 | rtc_writel(KICK0_VALUE, OMAP_RTC_KICK0_REG); |
379 | rtc_writel(KICK1_VALUE, OMAP_RTC_KICK1_REG); | 416 | rtc_writel(KICK1_VALUE, OMAP_RTC_KICK1_REG); |
380 | } | 417 | } |
@@ -393,6 +430,10 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
393 | */ | 430 | */ |
394 | rtc_write(0, OMAP_RTC_INTERRUPTS_REG); | 431 | rtc_write(0, OMAP_RTC_INTERRUPTS_REG); |
395 | 432 | ||
433 | /* enable RTC functional clock */ | ||
434 | if (id_entry->driver_data & OMAP_RTC_HAS_32KCLK_EN) | ||
435 | rtc_writel(OMAP_RTC_OSC_32KCLK_EN, OMAP_RTC_OSC_REG); | ||
436 | |||
396 | /* clear old status */ | 437 | /* clear old status */ |
397 | reg = rtc_read(OMAP_RTC_STATUS_REG); | 438 | reg = rtc_read(OMAP_RTC_STATUS_REG); |
398 | if (reg & (u8) OMAP_RTC_STATUS_POWER_UP) { | 439 | if (reg & (u8) OMAP_RTC_STATUS_POWER_UP) { |
@@ -452,7 +493,7 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
452 | return 0; | 493 | return 0; |
453 | 494 | ||
454 | fail0: | 495 | fail0: |
455 | if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) | 496 | if (id_entry->driver_data & OMAP_RTC_HAS_KICKER) |
456 | rtc_writel(0, OMAP_RTC_KICK0_REG); | 497 | rtc_writel(0, OMAP_RTC_KICK0_REG); |
457 | pm_runtime_put_sync(&pdev->dev); | 498 | pm_runtime_put_sync(&pdev->dev); |
458 | pm_runtime_disable(&pdev->dev); | 499 | pm_runtime_disable(&pdev->dev); |
@@ -469,7 +510,7 @@ static int __exit omap_rtc_remove(struct platform_device *pdev) | |||
469 | /* leave rtc running, but disable irqs */ | 510 | /* leave rtc running, but disable irqs */ |
470 | rtc_write(0, OMAP_RTC_INTERRUPTS_REG); | 511 | rtc_write(0, OMAP_RTC_INTERRUPTS_REG); |
471 | 512 | ||
472 | if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) | 513 | if (id_entry->driver_data & OMAP_RTC_HAS_KICKER) |
473 | rtc_writel(0, OMAP_RTC_KICK0_REG); | 514 | rtc_writel(0, OMAP_RTC_KICK0_REG); |
474 | 515 | ||
475 | /* Disable the clock/module */ | 516 | /* Disable the clock/module */ |
@@ -484,28 +525,16 @@ static u8 irqstat; | |||
484 | 525 | ||
485 | static int omap_rtc_suspend(struct device *dev) | 526 | static int omap_rtc_suspend(struct device *dev) |
486 | { | 527 | { |
487 | u8 irqwake_stat; | ||
488 | struct platform_device *pdev = to_platform_device(dev); | ||
489 | const struct platform_device_id *id_entry = | ||
490 | platform_get_device_id(pdev); | ||
491 | |||
492 | irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG); | 528 | irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG); |
493 | 529 | ||
494 | /* FIXME the RTC alarm is not currently acting as a wakeup event | 530 | /* FIXME the RTC alarm is not currently acting as a wakeup event |
495 | * source on some platforms, and in fact this enable() call is just | 531 | * source on some platforms, and in fact this enable() call is just |
496 | * saving a flag that's never used... | 532 | * saving a flag that's never used... |
497 | */ | 533 | */ |
498 | if (device_may_wakeup(dev)) { | 534 | if (device_may_wakeup(dev)) |
499 | enable_irq_wake(omap_rtc_alarm); | 535 | enable_irq_wake(omap_rtc_alarm); |
500 | 536 | else | |
501 | if (id_entry->driver_data & OMAP_RTC_HAS_IRQWAKEEN) { | ||
502 | irqwake_stat = rtc_read(OMAP_RTC_IRQWAKEEN); | ||
503 | irqwake_stat |= OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN; | ||
504 | rtc_write(irqwake_stat, OMAP_RTC_IRQWAKEEN); | ||
505 | } | ||
506 | } else { | ||
507 | rtc_write(0, OMAP_RTC_INTERRUPTS_REG); | 537 | rtc_write(0, OMAP_RTC_INTERRUPTS_REG); |
508 | } | ||
509 | 538 | ||
510 | /* Disable the clock/module */ | 539 | /* Disable the clock/module */ |
511 | pm_runtime_put_sync(dev); | 540 | pm_runtime_put_sync(dev); |
@@ -515,25 +544,14 @@ static int omap_rtc_suspend(struct device *dev) | |||
515 | 544 | ||
516 | static int omap_rtc_resume(struct device *dev) | 545 | static int omap_rtc_resume(struct device *dev) |
517 | { | 546 | { |
518 | u8 irqwake_stat; | ||
519 | struct platform_device *pdev = to_platform_device(dev); | ||
520 | const struct platform_device_id *id_entry = | ||
521 | platform_get_device_id(pdev); | ||
522 | |||
523 | /* Enable the clock/module so that we can access the registers */ | 547 | /* Enable the clock/module so that we can access the registers */ |
524 | pm_runtime_get_sync(dev); | 548 | pm_runtime_get_sync(dev); |
525 | 549 | ||
526 | if (device_may_wakeup(dev)) { | 550 | if (device_may_wakeup(dev)) |
527 | disable_irq_wake(omap_rtc_alarm); | 551 | disable_irq_wake(omap_rtc_alarm); |
528 | 552 | else | |
529 | if (id_entry->driver_data & OMAP_RTC_HAS_IRQWAKEEN) { | ||
530 | irqwake_stat = rtc_read(OMAP_RTC_IRQWAKEEN); | ||
531 | irqwake_stat &= ~OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN; | ||
532 | rtc_write(irqwake_stat, OMAP_RTC_IRQWAKEEN); | ||
533 | } | ||
534 | } else { | ||
535 | rtc_write(irqstat, OMAP_RTC_INTERRUPTS_REG); | 553 | rtc_write(irqstat, OMAP_RTC_INTERRUPTS_REG); |
536 | } | 554 | |
537 | return 0; | 555 | return 0; |
538 | } | 556 | } |
539 | #endif | 557 | #endif |
diff --git a/drivers/rtc/rtc-palmas.c b/drivers/rtc/rtc-palmas.c index c360d62fb3f6..4dfe2d793fa3 100644 --- a/drivers/rtc/rtc-palmas.c +++ b/drivers/rtc/rtc-palmas.c | |||
@@ -352,7 +352,7 @@ static SIMPLE_DEV_PM_OPS(palmas_rtc_pm_ops, palmas_rtc_suspend, | |||
352 | palmas_rtc_resume); | 352 | palmas_rtc_resume); |
353 | 353 | ||
354 | #ifdef CONFIG_OF | 354 | #ifdef CONFIG_OF |
355 | static struct of_device_id of_palmas_rtc_match[] = { | 355 | static const struct of_device_id of_palmas_rtc_match[] = { |
356 | { .compatible = "ti,palmas-rtc"}, | 356 | { .compatible = "ti,palmas-rtc"}, |
357 | { }, | 357 | { }, |
358 | }; | 358 | }; |
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c index cccbf9d89729..4561f375327d 100644 --- a/drivers/rtc/rtc-pxa.c +++ b/drivers/rtc/rtc-pxa.c | |||
@@ -389,7 +389,7 @@ static int __exit pxa_rtc_remove(struct platform_device *pdev) | |||
389 | } | 389 | } |
390 | 390 | ||
391 | #ifdef CONFIG_OF | 391 | #ifdef CONFIG_OF |
392 | static struct of_device_id pxa_rtc_dt_ids[] = { | 392 | static const struct of_device_id pxa_rtc_dt_ids[] = { |
393 | { .compatible = "marvell,pxa-rtc" }, | 393 | { .compatible = "marvell,pxa-rtc" }, |
394 | {} | 394 | {} |
395 | }; | 395 | }; |
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index 0f7adeb1944a..b6e1ca08c2c0 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
@@ -338,7 +338,7 @@ static SIMPLE_DEV_PM_OPS(sa1100_rtc_pm_ops, sa1100_rtc_suspend, | |||
338 | sa1100_rtc_resume); | 338 | sa1100_rtc_resume); |
339 | 339 | ||
340 | #ifdef CONFIG_OF | 340 | #ifdef CONFIG_OF |
341 | static struct of_device_id sa1100_rtc_dt_ids[] = { | 341 | static const struct of_device_id sa1100_rtc_dt_ids[] = { |
342 | { .compatible = "mrvl,sa1100-rtc", }, | 342 | { .compatible = "mrvl,sa1100-rtc", }, |
343 | { .compatible = "mrvl,mmp-rtc", }, | 343 | { .compatible = "mrvl,mmp-rtc", }, |
344 | {} | 344 | {} |
diff --git a/drivers/rtc/rtc-xgene.c b/drivers/rtc/rtc-xgene.c new file mode 100644 index 000000000000..14129cc85bdb --- /dev/null +++ b/drivers/rtc/rtc-xgene.c | |||
@@ -0,0 +1,278 @@ | |||
1 | /* | ||
2 | * APM X-Gene SoC Real Time Clock Driver | ||
3 | * | ||
4 | * Copyright (c) 2014, Applied Micro Circuits Corporation | ||
5 | * Author: Rameshwar Prasad Sahu <rsahu@apm.com> | ||
6 | * Loc Ho <lho@apm.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <linux/init.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/of.h> | ||
26 | #include <linux/platform_device.h> | ||
27 | #include <linux/io.h> | ||
28 | #include <linux/slab.h> | ||
29 | #include <linux/clk.h> | ||
30 | #include <linux/delay.h> | ||
31 | #include <linux/rtc.h> | ||
32 | |||
33 | /* RTC CSR Registers */ | ||
34 | #define RTC_CCVR 0x00 | ||
35 | #define RTC_CMR 0x04 | ||
36 | #define RTC_CLR 0x08 | ||
37 | #define RTC_CCR 0x0C | ||
38 | #define RTC_CCR_IE BIT(0) | ||
39 | #define RTC_CCR_MASK BIT(1) | ||
40 | #define RTC_CCR_EN BIT(2) | ||
41 | #define RTC_CCR_WEN BIT(3) | ||
42 | #define RTC_STAT 0x10 | ||
43 | #define RTC_STAT_BIT BIT(0) | ||
44 | #define RTC_RSTAT 0x14 | ||
45 | #define RTC_EOI 0x18 | ||
46 | #define RTC_VER 0x1C | ||
47 | |||
48 | struct xgene_rtc_dev { | ||
49 | struct rtc_device *rtc; | ||
50 | struct device *dev; | ||
51 | unsigned long alarm_time; | ||
52 | void __iomem *csr_base; | ||
53 | struct clk *clk; | ||
54 | unsigned int irq_wake; | ||
55 | }; | ||
56 | |||
57 | static int xgene_rtc_read_time(struct device *dev, struct rtc_time *tm) | ||
58 | { | ||
59 | struct xgene_rtc_dev *pdata = dev_get_drvdata(dev); | ||
60 | |||
61 | rtc_time_to_tm(readl(pdata->csr_base + RTC_CCVR), tm); | ||
62 | return rtc_valid_tm(tm); | ||
63 | } | ||
64 | |||
65 | static int xgene_rtc_set_mmss(struct device *dev, unsigned long secs) | ||
66 | { | ||
67 | struct xgene_rtc_dev *pdata = dev_get_drvdata(dev); | ||
68 | |||
69 | /* | ||
70 | * NOTE: After the following write, the RTC_CCVR is only reflected | ||
71 | * after the update cycle of 1 seconds. | ||
72 | */ | ||
73 | writel((u32) secs, pdata->csr_base + RTC_CLR); | ||
74 | readl(pdata->csr_base + RTC_CLR); /* Force a barrier */ | ||
75 | |||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | static int xgene_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | ||
80 | { | ||
81 | struct xgene_rtc_dev *pdata = dev_get_drvdata(dev); | ||
82 | |||
83 | rtc_time_to_tm(pdata->alarm_time, &alrm->time); | ||
84 | alrm->enabled = readl(pdata->csr_base + RTC_CCR) & RTC_CCR_IE; | ||
85 | |||
86 | return 0; | ||
87 | } | ||
88 | |||
89 | static int xgene_rtc_alarm_irq_enable(struct device *dev, u32 enabled) | ||
90 | { | ||
91 | struct xgene_rtc_dev *pdata = dev_get_drvdata(dev); | ||
92 | u32 ccr; | ||
93 | |||
94 | ccr = readl(pdata->csr_base + RTC_CCR); | ||
95 | if (enabled) { | ||
96 | ccr &= ~RTC_CCR_MASK; | ||
97 | ccr |= RTC_CCR_IE; | ||
98 | } else { | ||
99 | ccr &= ~RTC_CCR_IE; | ||
100 | ccr |= RTC_CCR_MASK; | ||
101 | } | ||
102 | writel(ccr, pdata->csr_base + RTC_CCR); | ||
103 | |||
104 | return 0; | ||
105 | } | ||
106 | |||
107 | static int xgene_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | ||
108 | { | ||
109 | struct xgene_rtc_dev *pdata = dev_get_drvdata(dev); | ||
110 | unsigned long rtc_time; | ||
111 | unsigned long alarm_time; | ||
112 | |||
113 | rtc_time = readl(pdata->csr_base + RTC_CCVR); | ||
114 | rtc_tm_to_time(&alrm->time, &alarm_time); | ||
115 | |||
116 | pdata->alarm_time = alarm_time; | ||
117 | writel((u32) pdata->alarm_time, pdata->csr_base + RTC_CMR); | ||
118 | |||
119 | xgene_rtc_alarm_irq_enable(dev, alrm->enabled); | ||
120 | |||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | static const struct rtc_class_ops xgene_rtc_ops = { | ||
125 | .read_time = xgene_rtc_read_time, | ||
126 | .set_mmss = xgene_rtc_set_mmss, | ||
127 | .read_alarm = xgene_rtc_read_alarm, | ||
128 | .set_alarm = xgene_rtc_set_alarm, | ||
129 | .alarm_irq_enable = xgene_rtc_alarm_irq_enable, | ||
130 | }; | ||
131 | |||
132 | static irqreturn_t xgene_rtc_interrupt(int irq, void *id) | ||
133 | { | ||
134 | struct xgene_rtc_dev *pdata = (struct xgene_rtc_dev *) id; | ||
135 | |||
136 | /* Check if interrupt asserted */ | ||
137 | if (!(readl(pdata->csr_base + RTC_STAT) & RTC_STAT_BIT)) | ||
138 | return IRQ_NONE; | ||
139 | |||
140 | /* Clear interrupt */ | ||
141 | readl(pdata->csr_base + RTC_EOI); | ||
142 | |||
143 | rtc_update_irq(pdata->rtc, 1, RTC_IRQF | RTC_AF); | ||
144 | |||
145 | return IRQ_HANDLED; | ||
146 | } | ||
147 | |||
148 | static int xgene_rtc_probe(struct platform_device *pdev) | ||
149 | { | ||
150 | struct xgene_rtc_dev *pdata; | ||
151 | struct resource *res; | ||
152 | int ret; | ||
153 | int irq; | ||
154 | |||
155 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
156 | if (!pdata) | ||
157 | return -ENOMEM; | ||
158 | platform_set_drvdata(pdev, pdata); | ||
159 | pdata->dev = &pdev->dev; | ||
160 | |||
161 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
162 | pdata->csr_base = devm_ioremap_resource(&pdev->dev, res); | ||
163 | if (IS_ERR(pdata->csr_base)) | ||
164 | return PTR_ERR(pdata->csr_base); | ||
165 | |||
166 | irq = platform_get_irq(pdev, 0); | ||
167 | if (irq < 0) { | ||
168 | dev_err(&pdev->dev, "No IRQ resource\n"); | ||
169 | return irq; | ||
170 | } | ||
171 | ret = devm_request_irq(&pdev->dev, irq, xgene_rtc_interrupt, 0, | ||
172 | dev_name(&pdev->dev), pdata); | ||
173 | if (ret) { | ||
174 | dev_err(&pdev->dev, "Could not request IRQ\n"); | ||
175 | return ret; | ||
176 | } | ||
177 | |||
178 | pdata->clk = devm_clk_get(&pdev->dev, NULL); | ||
179 | if (IS_ERR(pdata->clk)) { | ||
180 | dev_err(&pdev->dev, "Couldn't get the clock for RTC\n"); | ||
181 | return -ENODEV; | ||
182 | } | ||
183 | clk_prepare_enable(pdata->clk); | ||
184 | |||
185 | /* Turn on the clock and the crystal */ | ||
186 | writel(RTC_CCR_EN, pdata->csr_base + RTC_CCR); | ||
187 | |||
188 | device_init_wakeup(&pdev->dev, 1); | ||
189 | |||
190 | pdata->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, | ||
191 | &xgene_rtc_ops, THIS_MODULE); | ||
192 | if (IS_ERR(pdata->rtc)) { | ||
193 | clk_disable_unprepare(pdata->clk); | ||
194 | return PTR_ERR(pdata->rtc); | ||
195 | } | ||
196 | |||
197 | /* HW does not support update faster than 1 seconds */ | ||
198 | pdata->rtc->uie_unsupported = 1; | ||
199 | |||
200 | return 0; | ||
201 | } | ||
202 | |||
203 | static int xgene_rtc_remove(struct platform_device *pdev) | ||
204 | { | ||
205 | struct xgene_rtc_dev *pdata = platform_get_drvdata(pdev); | ||
206 | |||
207 | xgene_rtc_alarm_irq_enable(&pdev->dev, 0); | ||
208 | device_init_wakeup(&pdev->dev, 0); | ||
209 | clk_disable_unprepare(pdata->clk); | ||
210 | return 0; | ||
211 | } | ||
212 | |||
213 | #ifdef CONFIG_PM_SLEEP | ||
214 | static int xgene_rtc_suspend(struct device *dev) | ||
215 | { | ||
216 | struct platform_device *pdev = to_platform_device(dev); | ||
217 | struct xgene_rtc_dev *pdata = platform_get_drvdata(pdev); | ||
218 | int irq; | ||
219 | |||
220 | irq = platform_get_irq(pdev, 0); | ||
221 | if (device_may_wakeup(&pdev->dev)) { | ||
222 | if (!enable_irq_wake(irq)) | ||
223 | pdata->irq_wake = 1; | ||
224 | } else { | ||
225 | xgene_rtc_alarm_irq_enable(dev, 0); | ||
226 | clk_disable(pdata->clk); | ||
227 | } | ||
228 | |||
229 | return 0; | ||
230 | } | ||
231 | |||
232 | static int xgene_rtc_resume(struct device *dev) | ||
233 | { | ||
234 | struct platform_device *pdev = to_platform_device(dev); | ||
235 | struct xgene_rtc_dev *pdata = platform_get_drvdata(pdev); | ||
236 | int irq; | ||
237 | |||
238 | irq = platform_get_irq(pdev, 0); | ||
239 | if (device_may_wakeup(&pdev->dev)) { | ||
240 | if (pdata->irq_wake) { | ||
241 | disable_irq_wake(irq); | ||
242 | pdata->irq_wake = 0; | ||
243 | } | ||
244 | } else { | ||
245 | clk_enable(pdata->clk); | ||
246 | xgene_rtc_alarm_irq_enable(dev, 1); | ||
247 | } | ||
248 | |||
249 | return 0; | ||
250 | } | ||
251 | #endif | ||
252 | |||
253 | static SIMPLE_DEV_PM_OPS(xgene_rtc_pm_ops, xgene_rtc_suspend, xgene_rtc_resume); | ||
254 | |||
255 | #ifdef CONFIG_OF | ||
256 | static const struct of_device_id xgene_rtc_of_match[] = { | ||
257 | {.compatible = "apm,xgene-rtc" }, | ||
258 | { } | ||
259 | }; | ||
260 | MODULE_DEVICE_TABLE(of, xgene_rtc_of_match); | ||
261 | #endif | ||
262 | |||
263 | static struct platform_driver xgene_rtc_driver = { | ||
264 | .probe = xgene_rtc_probe, | ||
265 | .remove = xgene_rtc_remove, | ||
266 | .driver = { | ||
267 | .owner = THIS_MODULE, | ||
268 | .name = "xgene-rtc", | ||
269 | .pm = &xgene_rtc_pm_ops, | ||
270 | .of_match_table = of_match_ptr(xgene_rtc_of_match), | ||
271 | }, | ||
272 | }; | ||
273 | |||
274 | module_platform_driver(xgene_rtc_driver); | ||
275 | |||
276 | MODULE_DESCRIPTION("APM X-Gene SoC RTC driver"); | ||
277 | MODULE_AUTHOR("Rameshwar Sahu <rsahu@apm.com>"); | ||
278 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/scsi/scsi_sysctl.c b/drivers/scsi/scsi_sysctl.c index 2b6b93f7d8ef..546f16299ef9 100644 --- a/drivers/scsi/scsi_sysctl.c +++ b/drivers/scsi/scsi_sysctl.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include "scsi_priv.h" | 12 | #include "scsi_priv.h" |
13 | 13 | ||
14 | 14 | ||
15 | static ctl_table scsi_table[] = { | 15 | static struct ctl_table scsi_table[] = { |
16 | { .procname = "logging_level", | 16 | { .procname = "logging_level", |
17 | .data = &scsi_logging_level, | 17 | .data = &scsi_logging_level, |
18 | .maxlen = sizeof(scsi_logging_level), | 18 | .maxlen = sizeof(scsi_logging_level), |
@@ -21,14 +21,14 @@ static ctl_table scsi_table[] = { | |||
21 | { } | 21 | { } |
22 | }; | 22 | }; |
23 | 23 | ||
24 | static ctl_table scsi_dir_table[] = { | 24 | static struct ctl_table scsi_dir_table[] = { |
25 | { .procname = "scsi", | 25 | { .procname = "scsi", |
26 | .mode = 0555, | 26 | .mode = 0555, |
27 | .child = scsi_table }, | 27 | .child = scsi_table }, |
28 | { } | 28 | { } |
29 | }; | 29 | }; |
30 | 30 | ||
31 | static ctl_table scsi_root_table[] = { | 31 | static struct ctl_table scsi_root_table[] = { |
32 | { .procname = "dev", | 32 | { .procname = "dev", |
33 | .mode = 0555, | 33 | .mode = 0555, |
34 | .child = scsi_dir_table }, | 34 | .child = scsi_dir_table }, |
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index b767a64e49d9..454b65898e2c 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/jiffies.h> | 46 | #include <linux/jiffies.h> |
47 | #include <linux/syscalls.h> | 47 | #include <linux/syscalls.h> |
48 | #include <linux/of.h> | 48 | #include <linux/of.h> |
49 | #include <linux/rcupdate.h> | ||
49 | 50 | ||
50 | #include <asm/ptrace.h> | 51 | #include <asm/ptrace.h> |
51 | #include <asm/irq_regs.h> | 52 | #include <asm/irq_regs.h> |
@@ -510,9 +511,9 @@ void __handle_sysrq(int key, bool check_mask) | |||
510 | struct sysrq_key_op *op_p; | 511 | struct sysrq_key_op *op_p; |
511 | int orig_log_level; | 512 | int orig_log_level; |
512 | int i; | 513 | int i; |
513 | unsigned long flags; | ||
514 | 514 | ||
515 | spin_lock_irqsave(&sysrq_key_table_lock, flags); | 515 | rcu_sysrq_start(); |
516 | rcu_read_lock(); | ||
516 | /* | 517 | /* |
517 | * Raise the apparent loglevel to maximum so that the sysrq header | 518 | * Raise the apparent loglevel to maximum so that the sysrq header |
518 | * is shown to provide the user with positive feedback. We do not | 519 | * is shown to provide the user with positive feedback. We do not |
@@ -554,7 +555,8 @@ void __handle_sysrq(int key, bool check_mask) | |||
554 | printk("\n"); | 555 | printk("\n"); |
555 | console_loglevel = orig_log_level; | 556 | console_loglevel = orig_log_level; |
556 | } | 557 | } |
557 | spin_unlock_irqrestore(&sysrq_key_table_lock, flags); | 558 | rcu_read_unlock(); |
559 | rcu_sysrq_end(); | ||
558 | } | 560 | } |
559 | 561 | ||
560 | void handle_sysrq(int key) | 562 | void handle_sysrq(int key) |
@@ -1043,16 +1045,23 @@ static int __sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p, | |||
1043 | struct sysrq_key_op *remove_op_p) | 1045 | struct sysrq_key_op *remove_op_p) |
1044 | { | 1046 | { |
1045 | int retval; | 1047 | int retval; |
1046 | unsigned long flags; | ||
1047 | 1048 | ||
1048 | spin_lock_irqsave(&sysrq_key_table_lock, flags); | 1049 | spin_lock(&sysrq_key_table_lock); |
1049 | if (__sysrq_get_key_op(key) == remove_op_p) { | 1050 | if (__sysrq_get_key_op(key) == remove_op_p) { |
1050 | __sysrq_put_key_op(key, insert_op_p); | 1051 | __sysrq_put_key_op(key, insert_op_p); |
1051 | retval = 0; | 1052 | retval = 0; |
1052 | } else { | 1053 | } else { |
1053 | retval = -1; | 1054 | retval = -1; |
1054 | } | 1055 | } |
1055 | spin_unlock_irqrestore(&sysrq_key_table_lock, flags); | 1056 | spin_unlock(&sysrq_key_table_lock); |
1057 | |||
1058 | /* | ||
1059 | * A concurrent __handle_sysrq either got the old op or the new op. | ||
1060 | * Wait for it to go away before returning, so the code for an old | ||
1061 | * op is not freed (eg. on module unload) while it is in use. | ||
1062 | */ | ||
1063 | synchronize_rcu(); | ||
1064 | |||
1056 | return retval; | 1065 | return retval; |
1057 | } | 1066 | } |
1058 | 1067 | ||
diff --git a/fs/affs/affs.h b/fs/affs/affs.h index 25b23b1e7f22..9bca88159725 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h | |||
@@ -1,3 +1,9 @@ | |||
1 | #ifdef pr_fmt | ||
2 | #undef pr_fmt | ||
3 | #endif | ||
4 | |||
5 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
6 | |||
1 | #include <linux/types.h> | 7 | #include <linux/types.h> |
2 | #include <linux/fs.h> | 8 | #include <linux/fs.h> |
3 | #include <linux/buffer_head.h> | 9 | #include <linux/buffer_head.h> |
@@ -206,7 +212,7 @@ affs_set_blocksize(struct super_block *sb, int size) | |||
206 | static inline struct buffer_head * | 212 | static inline struct buffer_head * |
207 | affs_bread(struct super_block *sb, int block) | 213 | affs_bread(struct super_block *sb, int block) |
208 | { | 214 | { |
209 | pr_debug("affs_bread: %d\n", block); | 215 | pr_debug("%s: %d\n", __func__, block); |
210 | if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) | 216 | if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) |
211 | return sb_bread(sb, block); | 217 | return sb_bread(sb, block); |
212 | return NULL; | 218 | return NULL; |
@@ -214,7 +220,7 @@ affs_bread(struct super_block *sb, int block) | |||
214 | static inline struct buffer_head * | 220 | static inline struct buffer_head * |
215 | affs_getblk(struct super_block *sb, int block) | 221 | affs_getblk(struct super_block *sb, int block) |
216 | { | 222 | { |
217 | pr_debug("affs_getblk: %d\n", block); | 223 | pr_debug("%s: %d\n", __func__, block); |
218 | if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) | 224 | if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) |
219 | return sb_getblk(sb, block); | 225 | return sb_getblk(sb, block); |
220 | return NULL; | 226 | return NULL; |
@@ -223,7 +229,7 @@ static inline struct buffer_head * | |||
223 | affs_getzeroblk(struct super_block *sb, int block) | 229 | affs_getzeroblk(struct super_block *sb, int block) |
224 | { | 230 | { |
225 | struct buffer_head *bh; | 231 | struct buffer_head *bh; |
226 | pr_debug("affs_getzeroblk: %d\n", block); | 232 | pr_debug("%s: %d\n", __func__, block); |
227 | if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) { | 233 | if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) { |
228 | bh = sb_getblk(sb, block); | 234 | bh = sb_getblk(sb, block); |
229 | lock_buffer(bh); | 235 | lock_buffer(bh); |
@@ -238,7 +244,7 @@ static inline struct buffer_head * | |||
238 | affs_getemptyblk(struct super_block *sb, int block) | 244 | affs_getemptyblk(struct super_block *sb, int block) |
239 | { | 245 | { |
240 | struct buffer_head *bh; | 246 | struct buffer_head *bh; |
241 | pr_debug("affs_getemptyblk: %d\n", block); | 247 | pr_debug("%s: %d\n", __func__, block); |
242 | if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) { | 248 | if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) { |
243 | bh = sb_getblk(sb, block); | 249 | bh = sb_getblk(sb, block); |
244 | wait_on_buffer(bh); | 250 | wait_on_buffer(bh); |
@@ -251,7 +257,7 @@ static inline void | |||
251 | affs_brelse(struct buffer_head *bh) | 257 | affs_brelse(struct buffer_head *bh) |
252 | { | 258 | { |
253 | if (bh) | 259 | if (bh) |
254 | pr_debug("affs_brelse: %lld\n", (long long) bh->b_blocknr); | 260 | pr_debug("%s: %lld\n", __func__, (long long) bh->b_blocknr); |
255 | brelse(bh); | 261 | brelse(bh); |
256 | } | 262 | } |
257 | 263 | ||
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c index 533a322c41c0..406b29836b19 100644 --- a/fs/affs/amigaffs.c +++ b/fs/affs/amigaffs.c | |||
@@ -34,7 +34,7 @@ affs_insert_hash(struct inode *dir, struct buffer_head *bh) | |||
34 | ino = bh->b_blocknr; | 34 | ino = bh->b_blocknr; |
35 | offset = affs_hash_name(sb, AFFS_TAIL(sb, bh)->name + 1, AFFS_TAIL(sb, bh)->name[0]); | 35 | offset = affs_hash_name(sb, AFFS_TAIL(sb, bh)->name + 1, AFFS_TAIL(sb, bh)->name[0]); |
36 | 36 | ||
37 | pr_debug("AFFS: insert_hash(dir=%u, ino=%d)\n", (u32)dir->i_ino, ino); | 37 | pr_debug("%s(dir=%u, ino=%d)\n", __func__, (u32)dir->i_ino, ino); |
38 | 38 | ||
39 | dir_bh = affs_bread(sb, dir->i_ino); | 39 | dir_bh = affs_bread(sb, dir->i_ino); |
40 | if (!dir_bh) | 40 | if (!dir_bh) |
@@ -84,7 +84,8 @@ affs_remove_hash(struct inode *dir, struct buffer_head *rem_bh) | |||
84 | sb = dir->i_sb; | 84 | sb = dir->i_sb; |
85 | rem_ino = rem_bh->b_blocknr; | 85 | rem_ino = rem_bh->b_blocknr; |
86 | offset = affs_hash_name(sb, AFFS_TAIL(sb, rem_bh)->name+1, AFFS_TAIL(sb, rem_bh)->name[0]); | 86 | offset = affs_hash_name(sb, AFFS_TAIL(sb, rem_bh)->name+1, AFFS_TAIL(sb, rem_bh)->name[0]); |
87 | pr_debug("AFFS: remove_hash(dir=%d, ino=%d, hashval=%d)\n", (u32)dir->i_ino, rem_ino, offset); | 87 | pr_debug("%s(dir=%d, ino=%d, hashval=%d)\n", |
88 | __func__, (u32)dir->i_ino, rem_ino, offset); | ||
88 | 89 | ||
89 | bh = affs_bread(sb, dir->i_ino); | 90 | bh = affs_bread(sb, dir->i_ino); |
90 | if (!bh) | 91 | if (!bh) |
@@ -147,7 +148,7 @@ affs_remove_link(struct dentry *dentry) | |||
147 | u32 link_ino, ino; | 148 | u32 link_ino, ino; |
148 | int retval; | 149 | int retval; |
149 | 150 | ||
150 | pr_debug("AFFS: remove_link(key=%ld)\n", inode->i_ino); | 151 | pr_debug("%s(key=%ld)\n", __func__, inode->i_ino); |
151 | retval = -EIO; | 152 | retval = -EIO; |
152 | bh = affs_bread(sb, inode->i_ino); | 153 | bh = affs_bread(sb, inode->i_ino); |
153 | if (!bh) | 154 | if (!bh) |
@@ -279,7 +280,7 @@ affs_remove_header(struct dentry *dentry) | |||
279 | if (!inode) | 280 | if (!inode) |
280 | goto done; | 281 | goto done; |
281 | 282 | ||
282 | pr_debug("AFFS: remove_header(key=%ld)\n", inode->i_ino); | 283 | pr_debug("%s(key=%ld)\n", __func__, inode->i_ino); |
283 | retval = -EIO; | 284 | retval = -EIO; |
284 | bh = affs_bread(sb, (u32)(long)dentry->d_fsdata); | 285 | bh = affs_bread(sb, (u32)(long)dentry->d_fsdata); |
285 | if (!bh) | 286 | if (!bh) |
@@ -451,10 +452,10 @@ affs_error(struct super_block *sb, const char *function, const char *fmt, ...) | |||
451 | vsnprintf(ErrorBuffer,sizeof(ErrorBuffer),fmt,args); | 452 | vsnprintf(ErrorBuffer,sizeof(ErrorBuffer),fmt,args); |
452 | va_end(args); | 453 | va_end(args); |
453 | 454 | ||
454 | printk(KERN_CRIT "AFFS error (device %s): %s(): %s\n", sb->s_id, | 455 | pr_crit("error (device %s): %s(): %s\n", sb->s_id, |
455 | function,ErrorBuffer); | 456 | function,ErrorBuffer); |
456 | if (!(sb->s_flags & MS_RDONLY)) | 457 | if (!(sb->s_flags & MS_RDONLY)) |
457 | printk(KERN_WARNING "AFFS: Remounting filesystem read-only\n"); | 458 | pr_warn("Remounting filesystem read-only\n"); |
458 | sb->s_flags |= MS_RDONLY; | 459 | sb->s_flags |= MS_RDONLY; |
459 | } | 460 | } |
460 | 461 | ||
@@ -467,7 +468,7 @@ affs_warning(struct super_block *sb, const char *function, const char *fmt, ...) | |||
467 | vsnprintf(ErrorBuffer,sizeof(ErrorBuffer),fmt,args); | 468 | vsnprintf(ErrorBuffer,sizeof(ErrorBuffer),fmt,args); |
468 | va_end(args); | 469 | va_end(args); |
469 | 470 | ||
470 | printk(KERN_WARNING "AFFS warning (device %s): %s(): %s\n", sb->s_id, | 471 | pr_warn("(device %s): %s(): %s\n", sb->s_id, |
471 | function,ErrorBuffer); | 472 | function,ErrorBuffer); |
472 | } | 473 | } |
473 | 474 | ||
diff --git a/fs/affs/bitmap.c b/fs/affs/bitmap.c index a32246b8359e..c8de51185c23 100644 --- a/fs/affs/bitmap.c +++ b/fs/affs/bitmap.c | |||
@@ -17,7 +17,7 @@ affs_count_free_blocks(struct super_block *sb) | |||
17 | u32 free; | 17 | u32 free; |
18 | int i; | 18 | int i; |
19 | 19 | ||
20 | pr_debug("AFFS: count_free_blocks()\n"); | 20 | pr_debug("%s()\n", __func__); |
21 | 21 | ||
22 | if (sb->s_flags & MS_RDONLY) | 22 | if (sb->s_flags & MS_RDONLY) |
23 | return 0; | 23 | return 0; |
@@ -43,7 +43,7 @@ affs_free_block(struct super_block *sb, u32 block) | |||
43 | u32 blk, bmap, bit, mask, tmp; | 43 | u32 blk, bmap, bit, mask, tmp; |
44 | __be32 *data; | 44 | __be32 *data; |
45 | 45 | ||
46 | pr_debug("AFFS: free_block(%u)\n", block); | 46 | pr_debug("%s(%u)\n", __func__, block); |
47 | 47 | ||
48 | if (block > sbi->s_partition_size) | 48 | if (block > sbi->s_partition_size) |
49 | goto err_range; | 49 | goto err_range; |
@@ -125,7 +125,7 @@ affs_alloc_block(struct inode *inode, u32 goal) | |||
125 | sb = inode->i_sb; | 125 | sb = inode->i_sb; |
126 | sbi = AFFS_SB(sb); | 126 | sbi = AFFS_SB(sb); |
127 | 127 | ||
128 | pr_debug("AFFS: balloc(inode=%lu,goal=%u): ", inode->i_ino, goal); | 128 | pr_debug("balloc(inode=%lu,goal=%u): ", inode->i_ino, goal); |
129 | 129 | ||
130 | if (AFFS_I(inode)->i_pa_cnt) { | 130 | if (AFFS_I(inode)->i_pa_cnt) { |
131 | pr_debug("%d\n", AFFS_I(inode)->i_lastalloc+1); | 131 | pr_debug("%d\n", AFFS_I(inode)->i_lastalloc+1); |
@@ -254,8 +254,7 @@ int affs_init_bitmap(struct super_block *sb, int *flags) | |||
254 | return 0; | 254 | return 0; |
255 | 255 | ||
256 | if (!AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->bm_flag) { | 256 | if (!AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->bm_flag) { |
257 | printk(KERN_NOTICE "AFFS: Bitmap invalid - mounting %s read only\n", | 257 | pr_notice("Bitmap invalid - mounting %s read only\n", sb->s_id); |
258 | sb->s_id); | ||
259 | *flags |= MS_RDONLY; | 258 | *flags |= MS_RDONLY; |
260 | return 0; | 259 | return 0; |
261 | } | 260 | } |
@@ -268,7 +267,7 @@ int affs_init_bitmap(struct super_block *sb, int *flags) | |||
268 | size = sbi->s_bmap_count * sizeof(*bm); | 267 | size = sbi->s_bmap_count * sizeof(*bm); |
269 | bm = sbi->s_bitmap = kzalloc(size, GFP_KERNEL); | 268 | bm = sbi->s_bitmap = kzalloc(size, GFP_KERNEL); |
270 | if (!sbi->s_bitmap) { | 269 | if (!sbi->s_bitmap) { |
271 | printk(KERN_ERR "AFFS: Bitmap allocation failed\n"); | 270 | pr_err("Bitmap allocation failed\n"); |
272 | return -ENOMEM; | 271 | return -ENOMEM; |
273 | } | 272 | } |
274 | 273 | ||
@@ -282,17 +281,17 @@ int affs_init_bitmap(struct super_block *sb, int *flags) | |||
282 | bm->bm_key = be32_to_cpu(bmap_blk[blk]); | 281 | bm->bm_key = be32_to_cpu(bmap_blk[blk]); |
283 | bh = affs_bread(sb, bm->bm_key); | 282 | bh = affs_bread(sb, bm->bm_key); |
284 | if (!bh) { | 283 | if (!bh) { |
285 | printk(KERN_ERR "AFFS: Cannot read bitmap\n"); | 284 | pr_err("Cannot read bitmap\n"); |
286 | res = -EIO; | 285 | res = -EIO; |
287 | goto out; | 286 | goto out; |
288 | } | 287 | } |
289 | if (affs_checksum_block(sb, bh)) { | 288 | if (affs_checksum_block(sb, bh)) { |
290 | printk(KERN_WARNING "AFFS: Bitmap %u invalid - mounting %s read only.\n", | 289 | pr_warn("Bitmap %u invalid - mounting %s read only.\n", |
291 | bm->bm_key, sb->s_id); | 290 | bm->bm_key, sb->s_id); |
292 | *flags |= MS_RDONLY; | 291 | *flags |= MS_RDONLY; |
293 | goto out; | 292 | goto out; |
294 | } | 293 | } |
295 | pr_debug("AFFS: read bitmap block %d: %d\n", blk, bm->bm_key); | 294 | pr_debug("read bitmap block %d: %d\n", blk, bm->bm_key); |
296 | bm->bm_free = memweight(bh->b_data + 4, sb->s_blocksize - 4); | 295 | bm->bm_free = memweight(bh->b_data + 4, sb->s_blocksize - 4); |
297 | 296 | ||
298 | /* Don't try read the extension if this is the last block, | 297 | /* Don't try read the extension if this is the last block, |
@@ -304,7 +303,7 @@ int affs_init_bitmap(struct super_block *sb, int *flags) | |||
304 | affs_brelse(bmap_bh); | 303 | affs_brelse(bmap_bh); |
305 | bmap_bh = affs_bread(sb, be32_to_cpu(bmap_blk[blk])); | 304 | bmap_bh = affs_bread(sb, be32_to_cpu(bmap_blk[blk])); |
306 | if (!bmap_bh) { | 305 | if (!bmap_bh) { |
307 | printk(KERN_ERR "AFFS: Cannot read bitmap extension\n"); | 306 | pr_err("Cannot read bitmap extension\n"); |
308 | res = -EIO; | 307 | res = -EIO; |
309 | goto out; | 308 | goto out; |
310 | } | 309 | } |
diff --git a/fs/affs/dir.c b/fs/affs/dir.c index cbbda476a805..59f07bec92a6 100644 --- a/fs/affs/dir.c +++ b/fs/affs/dir.c | |||
@@ -54,8 +54,8 @@ affs_readdir(struct file *file, struct dir_context *ctx) | |||
54 | u32 ino; | 54 | u32 ino; |
55 | int error = 0; | 55 | int error = 0; |
56 | 56 | ||
57 | pr_debug("AFFS: readdir(ino=%lu,f_pos=%lx)\n", | 57 | pr_debug("%s(ino=%lu,f_pos=%lx)\n", |
58 | inode->i_ino, (unsigned long)ctx->pos); | 58 | __func__, inode->i_ino, (unsigned long)ctx->pos); |
59 | 59 | ||
60 | if (ctx->pos < 2) { | 60 | if (ctx->pos < 2) { |
61 | file->private_data = (void *)0; | 61 | file->private_data = (void *)0; |
@@ -81,7 +81,7 @@ affs_readdir(struct file *file, struct dir_context *ctx) | |||
81 | */ | 81 | */ |
82 | ino = (u32)(long)file->private_data; | 82 | ino = (u32)(long)file->private_data; |
83 | if (ino && file->f_version == inode->i_version) { | 83 | if (ino && file->f_version == inode->i_version) { |
84 | pr_debug("AFFS: readdir() left off=%d\n", ino); | 84 | pr_debug("readdir() left off=%d\n", ino); |
85 | goto inside; | 85 | goto inside; |
86 | } | 86 | } |
87 | 87 | ||
@@ -117,7 +117,7 @@ inside: | |||
117 | 117 | ||
118 | namelen = min(AFFS_TAIL(sb, fh_bh)->name[0], (u8)30); | 118 | namelen = min(AFFS_TAIL(sb, fh_bh)->name[0], (u8)30); |
119 | name = AFFS_TAIL(sb, fh_bh)->name + 1; | 119 | name = AFFS_TAIL(sb, fh_bh)->name + 1; |
120 | pr_debug("AFFS: readdir(): dir_emit(\"%.*s\", " | 120 | pr_debug("readdir(): dir_emit(\"%.*s\", " |
121 | "ino=%u), hash=%d, f_pos=%x\n", | 121 | "ino=%u), hash=%d, f_pos=%x\n", |
122 | namelen, name, ino, hash_pos, (u32)ctx->pos); | 122 | namelen, name, ino, hash_pos, (u32)ctx->pos); |
123 | 123 | ||
diff --git a/fs/affs/file.c b/fs/affs/file.c index 8669b6ecddee..0270303388ee 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c | |||
@@ -45,7 +45,7 @@ const struct inode_operations affs_file_inode_operations = { | |||
45 | static int | 45 | static int |
46 | affs_file_open(struct inode *inode, struct file *filp) | 46 | affs_file_open(struct inode *inode, struct file *filp) |
47 | { | 47 | { |
48 | pr_debug("AFFS: open(%lu,%d)\n", | 48 | pr_debug("open(%lu,%d)\n", |
49 | inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt)); | 49 | inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt)); |
50 | atomic_inc(&AFFS_I(inode)->i_opencnt); | 50 | atomic_inc(&AFFS_I(inode)->i_opencnt); |
51 | return 0; | 51 | return 0; |
@@ -54,7 +54,7 @@ affs_file_open(struct inode *inode, struct file *filp) | |||
54 | static int | 54 | static int |
55 | affs_file_release(struct inode *inode, struct file *filp) | 55 | affs_file_release(struct inode *inode, struct file *filp) |
56 | { | 56 | { |
57 | pr_debug("AFFS: release(%lu, %d)\n", | 57 | pr_debug("release(%lu, %d)\n", |
58 | inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt)); | 58 | inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt)); |
59 | 59 | ||
60 | if (atomic_dec_and_test(&AFFS_I(inode)->i_opencnt)) { | 60 | if (atomic_dec_and_test(&AFFS_I(inode)->i_opencnt)) { |
@@ -324,7 +324,8 @@ affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_resul | |||
324 | struct buffer_head *ext_bh; | 324 | struct buffer_head *ext_bh; |
325 | u32 ext; | 325 | u32 ext; |
326 | 326 | ||
327 | pr_debug("AFFS: get_block(%u, %lu)\n", (u32)inode->i_ino, (unsigned long)block); | 327 | pr_debug("%s(%u, %lu)\n", |
328 | __func__, (u32)inode->i_ino, (unsigned long)block); | ||
328 | 329 | ||
329 | BUG_ON(block > (sector_t)0x7fffffffUL); | 330 | BUG_ON(block > (sector_t)0x7fffffffUL); |
330 | 331 | ||
@@ -498,34 +499,36 @@ affs_getemptyblk_ino(struct inode *inode, int block) | |||
498 | } | 499 | } |
499 | 500 | ||
500 | static int | 501 | static int |
501 | affs_do_readpage_ofs(struct file *file, struct page *page, unsigned from, unsigned to) | 502 | affs_do_readpage_ofs(struct page *page, unsigned to) |
502 | { | 503 | { |
503 | struct inode *inode = page->mapping->host; | 504 | struct inode *inode = page->mapping->host; |
504 | struct super_block *sb = inode->i_sb; | 505 | struct super_block *sb = inode->i_sb; |
505 | struct buffer_head *bh; | 506 | struct buffer_head *bh; |
506 | char *data; | 507 | char *data; |
508 | unsigned pos = 0; | ||
507 | u32 bidx, boff, bsize; | 509 | u32 bidx, boff, bsize; |
508 | u32 tmp; | 510 | u32 tmp; |
509 | 511 | ||
510 | pr_debug("AFFS: read_page(%u, %ld, %d, %d)\n", (u32)inode->i_ino, page->index, from, to); | 512 | pr_debug("%s(%u, %ld, 0, %d)\n", __func__, (u32)inode->i_ino, |
511 | BUG_ON(from > to || to > PAGE_CACHE_SIZE); | 513 | page->index, to); |
514 | BUG_ON(to > PAGE_CACHE_SIZE); | ||
512 | kmap(page); | 515 | kmap(page); |
513 | data = page_address(page); | 516 | data = page_address(page); |
514 | bsize = AFFS_SB(sb)->s_data_blksize; | 517 | bsize = AFFS_SB(sb)->s_data_blksize; |
515 | tmp = (page->index << PAGE_CACHE_SHIFT) + from; | 518 | tmp = page->index << PAGE_CACHE_SHIFT; |
516 | bidx = tmp / bsize; | 519 | bidx = tmp / bsize; |
517 | boff = tmp % bsize; | 520 | boff = tmp % bsize; |
518 | 521 | ||
519 | while (from < to) { | 522 | while (pos < to) { |
520 | bh = affs_bread_ino(inode, bidx, 0); | 523 | bh = affs_bread_ino(inode, bidx, 0); |
521 | if (IS_ERR(bh)) | 524 | if (IS_ERR(bh)) |
522 | return PTR_ERR(bh); | 525 | return PTR_ERR(bh); |
523 | tmp = min(bsize - boff, to - from); | 526 | tmp = min(bsize - boff, to - pos); |
524 | BUG_ON(from + tmp > to || tmp > bsize); | 527 | BUG_ON(pos + tmp > to || tmp > bsize); |
525 | memcpy(data + from, AFFS_DATA(bh) + boff, tmp); | 528 | memcpy(data + pos, AFFS_DATA(bh) + boff, tmp); |
526 | affs_brelse(bh); | 529 | affs_brelse(bh); |
527 | bidx++; | 530 | bidx++; |
528 | from += tmp; | 531 | pos += tmp; |
529 | boff = 0; | 532 | boff = 0; |
530 | } | 533 | } |
531 | flush_dcache_page(page); | 534 | flush_dcache_page(page); |
@@ -542,7 +545,7 @@ affs_extent_file_ofs(struct inode *inode, u32 newsize) | |||
542 | u32 size, bsize; | 545 | u32 size, bsize; |
543 | u32 tmp; | 546 | u32 tmp; |
544 | 547 | ||
545 | pr_debug("AFFS: extent_file(%u, %d)\n", (u32)inode->i_ino, newsize); | 548 | pr_debug("%s(%u, %d)\n", __func__, (u32)inode->i_ino, newsize); |
546 | bsize = AFFS_SB(sb)->s_data_blksize; | 549 | bsize = AFFS_SB(sb)->s_data_blksize; |
547 | bh = NULL; | 550 | bh = NULL; |
548 | size = AFFS_I(inode)->mmu_private; | 551 | size = AFFS_I(inode)->mmu_private; |
@@ -608,14 +611,14 @@ affs_readpage_ofs(struct file *file, struct page *page) | |||
608 | u32 to; | 611 | u32 to; |
609 | int err; | 612 | int err; |
610 | 613 | ||
611 | pr_debug("AFFS: read_page(%u, %ld)\n", (u32)inode->i_ino, page->index); | 614 | pr_debug("%s(%u, %ld)\n", __func__, (u32)inode->i_ino, page->index); |
612 | to = PAGE_CACHE_SIZE; | 615 | to = PAGE_CACHE_SIZE; |
613 | if (((page->index + 1) << PAGE_CACHE_SHIFT) > inode->i_size) { | 616 | if (((page->index + 1) << PAGE_CACHE_SHIFT) > inode->i_size) { |
614 | to = inode->i_size & ~PAGE_CACHE_MASK; | 617 | to = inode->i_size & ~PAGE_CACHE_MASK; |
615 | memset(page_address(page) + to, 0, PAGE_CACHE_SIZE - to); | 618 | memset(page_address(page) + to, 0, PAGE_CACHE_SIZE - to); |
616 | } | 619 | } |
617 | 620 | ||
618 | err = affs_do_readpage_ofs(file, page, 0, to); | 621 | err = affs_do_readpage_ofs(page, to); |
619 | if (!err) | 622 | if (!err) |
620 | SetPageUptodate(page); | 623 | SetPageUptodate(page); |
621 | unlock_page(page); | 624 | unlock_page(page); |
@@ -631,7 +634,8 @@ static int affs_write_begin_ofs(struct file *file, struct address_space *mapping | |||
631 | pgoff_t index; | 634 | pgoff_t index; |
632 | int err = 0; | 635 | int err = 0; |
633 | 636 | ||
634 | pr_debug("AFFS: write_begin(%u, %llu, %llu)\n", (u32)inode->i_ino, (unsigned long long)pos, (unsigned long long)pos + len); | 637 | pr_debug("%s(%u, %llu, %llu)\n", __func__, (u32)inode->i_ino, |
638 | (unsigned long long)pos, (unsigned long long)pos + len); | ||
635 | if (pos > AFFS_I(inode)->mmu_private) { | 639 | if (pos > AFFS_I(inode)->mmu_private) { |
636 | /* XXX: this probably leaves a too-big i_size in case of | 640 | /* XXX: this probably leaves a too-big i_size in case of |
637 | * failure. Should really be updating i_size at write_end time | 641 | * failure. Should really be updating i_size at write_end time |
@@ -651,7 +655,7 @@ static int affs_write_begin_ofs(struct file *file, struct address_space *mapping | |||
651 | return 0; | 655 | return 0; |
652 | 656 | ||
653 | /* XXX: inefficient but safe in the face of short writes */ | 657 | /* XXX: inefficient but safe in the face of short writes */ |
654 | err = affs_do_readpage_ofs(file, page, 0, PAGE_CACHE_SIZE); | 658 | err = affs_do_readpage_ofs(page, PAGE_CACHE_SIZE); |
655 | if (err) { | 659 | if (err) { |
656 | unlock_page(page); | 660 | unlock_page(page); |
657 | page_cache_release(page); | 661 | page_cache_release(page); |
@@ -680,7 +684,9 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping, | |||
680 | * due to write_begin. | 684 | * due to write_begin. |
681 | */ | 685 | */ |
682 | 686 | ||
683 | pr_debug("AFFS: write_begin(%u, %llu, %llu)\n", (u32)inode->i_ino, (unsigned long long)pos, (unsigned long long)pos + len); | 687 | pr_debug("%s(%u, %llu, %llu)\n", |
688 | __func__, (u32)inode->i_ino, (unsigned long long)pos, | ||
689 | (unsigned long long)pos + len); | ||
684 | bsize = AFFS_SB(sb)->s_data_blksize; | 690 | bsize = AFFS_SB(sb)->s_data_blksize; |
685 | data = page_address(page); | 691 | data = page_address(page); |
686 | 692 | ||
@@ -802,7 +808,7 @@ affs_free_prealloc(struct inode *inode) | |||
802 | { | 808 | { |
803 | struct super_block *sb = inode->i_sb; | 809 | struct super_block *sb = inode->i_sb; |
804 | 810 | ||
805 | pr_debug("AFFS: free_prealloc(ino=%lu)\n", inode->i_ino); | 811 | pr_debug("free_prealloc(ino=%lu)\n", inode->i_ino); |
806 | 812 | ||
807 | while (AFFS_I(inode)->i_pa_cnt) { | 813 | while (AFFS_I(inode)->i_pa_cnt) { |
808 | AFFS_I(inode)->i_pa_cnt--; | 814 | AFFS_I(inode)->i_pa_cnt--; |
@@ -822,7 +828,7 @@ affs_truncate(struct inode *inode) | |||
822 | struct buffer_head *ext_bh; | 828 | struct buffer_head *ext_bh; |
823 | int i; | 829 | int i; |
824 | 830 | ||
825 | pr_debug("AFFS: truncate(inode=%d, oldsize=%u, newsize=%u)\n", | 831 | pr_debug("truncate(inode=%d, oldsize=%u, newsize=%u)\n", |
826 | (u32)inode->i_ino, (u32)AFFS_I(inode)->mmu_private, (u32)inode->i_size); | 832 | (u32)inode->i_ino, (u32)AFFS_I(inode)->mmu_private, (u32)inode->i_size); |
827 | 833 | ||
828 | last_blk = 0; | 834 | last_blk = 0; |
diff --git a/fs/affs/inode.c b/fs/affs/inode.c index 96df91e8c334..bec2d1a0c91c 100644 --- a/fs/affs/inode.c +++ b/fs/affs/inode.c | |||
@@ -34,7 +34,7 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino) | |||
34 | if (!(inode->i_state & I_NEW)) | 34 | if (!(inode->i_state & I_NEW)) |
35 | return inode; | 35 | return inode; |
36 | 36 | ||
37 | pr_debug("AFFS: affs_iget(%lu)\n", inode->i_ino); | 37 | pr_debug("affs_iget(%lu)\n", inode->i_ino); |
38 | 38 | ||
39 | block = inode->i_ino; | 39 | block = inode->i_ino; |
40 | bh = affs_bread(sb, block); | 40 | bh = affs_bread(sb, block); |
@@ -175,7 +175,7 @@ affs_write_inode(struct inode *inode, struct writeback_control *wbc) | |||
175 | uid_t uid; | 175 | uid_t uid; |
176 | gid_t gid; | 176 | gid_t gid; |
177 | 177 | ||
178 | pr_debug("AFFS: write_inode(%lu)\n",inode->i_ino); | 178 | pr_debug("write_inode(%lu)\n", inode->i_ino); |
179 | 179 | ||
180 | if (!inode->i_nlink) | 180 | if (!inode->i_nlink) |
181 | // possibly free block | 181 | // possibly free block |
@@ -220,7 +220,7 @@ affs_notify_change(struct dentry *dentry, struct iattr *attr) | |||
220 | struct inode *inode = dentry->d_inode; | 220 | struct inode *inode = dentry->d_inode; |
221 | int error; | 221 | int error; |
222 | 222 | ||
223 | pr_debug("AFFS: notify_change(%lu,0x%x)\n",inode->i_ino,attr->ia_valid); | 223 | pr_debug("notify_change(%lu,0x%x)\n", inode->i_ino, attr->ia_valid); |
224 | 224 | ||
225 | error = inode_change_ok(inode,attr); | 225 | error = inode_change_ok(inode,attr); |
226 | if (error) | 226 | if (error) |
@@ -258,7 +258,8 @@ void | |||
258 | affs_evict_inode(struct inode *inode) | 258 | affs_evict_inode(struct inode *inode) |
259 | { | 259 | { |
260 | unsigned long cache_page; | 260 | unsigned long cache_page; |
261 | pr_debug("AFFS: evict_inode(ino=%lu, nlink=%u)\n", inode->i_ino, inode->i_nlink); | 261 | pr_debug("evict_inode(ino=%lu, nlink=%u)\n", |
262 | inode->i_ino, inode->i_nlink); | ||
262 | truncate_inode_pages_final(&inode->i_data); | 263 | truncate_inode_pages_final(&inode->i_data); |
263 | 264 | ||
264 | if (!inode->i_nlink) { | 265 | if (!inode->i_nlink) { |
@@ -271,7 +272,7 @@ affs_evict_inode(struct inode *inode) | |||
271 | affs_free_prealloc(inode); | 272 | affs_free_prealloc(inode); |
272 | cache_page = (unsigned long)AFFS_I(inode)->i_lc; | 273 | cache_page = (unsigned long)AFFS_I(inode)->i_lc; |
273 | if (cache_page) { | 274 | if (cache_page) { |
274 | pr_debug("AFFS: freeing ext cache\n"); | 275 | pr_debug("freeing ext cache\n"); |
275 | AFFS_I(inode)->i_lc = NULL; | 276 | AFFS_I(inode)->i_lc = NULL; |
276 | AFFS_I(inode)->i_ac = NULL; | 277 | AFFS_I(inode)->i_ac = NULL; |
277 | free_page(cache_page); | 278 | free_page(cache_page); |
@@ -350,7 +351,8 @@ affs_add_entry(struct inode *dir, struct inode *inode, struct dentry *dentry, s3 | |||
350 | u32 block = 0; | 351 | u32 block = 0; |
351 | int retval; | 352 | int retval; |
352 | 353 | ||
353 | pr_debug("AFFS: add_entry(dir=%u, inode=%u, \"%*s\", type=%d)\n", (u32)dir->i_ino, | 354 | pr_debug("%s(dir=%u, inode=%u, \"%*s\", type=%d)\n", |
355 | __func__, (u32)dir->i_ino, | ||
354 | (u32)inode->i_ino, (int)dentry->d_name.len, dentry->d_name.name, type); | 356 | (u32)inode->i_ino, (int)dentry->d_name.len, dentry->d_name.name, type); |
355 | 357 | ||
356 | retval = -EIO; | 358 | retval = -EIO; |
diff --git a/fs/affs/namei.c b/fs/affs/namei.c index 6dae1ccd176d..035bd31556fc 100644 --- a/fs/affs/namei.c +++ b/fs/affs/namei.c | |||
@@ -190,7 +190,8 @@ affs_find_entry(struct inode *dir, struct dentry *dentry) | |||
190 | toupper_t toupper = affs_get_toupper(sb); | 190 | toupper_t toupper = affs_get_toupper(sb); |
191 | u32 key; | 191 | u32 key; |
192 | 192 | ||
193 | pr_debug("AFFS: find_entry(\"%.*s\")\n", (int)dentry->d_name.len, dentry->d_name.name); | 193 | pr_debug("%s(\"%.*s\")\n", |
194 | __func__, (int)dentry->d_name.len, dentry->d_name.name); | ||
194 | 195 | ||
195 | bh = affs_bread(sb, dir->i_ino); | 196 | bh = affs_bread(sb, dir->i_ino); |
196 | if (!bh) | 197 | if (!bh) |
@@ -218,7 +219,8 @@ affs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) | |||
218 | struct buffer_head *bh; | 219 | struct buffer_head *bh; |
219 | struct inode *inode = NULL; | 220 | struct inode *inode = NULL; |
220 | 221 | ||
221 | pr_debug("AFFS: lookup(\"%.*s\")\n",(int)dentry->d_name.len,dentry->d_name.name); | 222 | pr_debug("%s(\"%.*s\")\n", |
223 | __func__, (int)dentry->d_name.len, dentry->d_name.name); | ||
222 | 224 | ||
223 | affs_lock_dir(dir); | 225 | affs_lock_dir(dir); |
224 | bh = affs_find_entry(dir, dentry); | 226 | bh = affs_find_entry(dir, dentry); |
@@ -248,9 +250,9 @@ affs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) | |||
248 | int | 250 | int |
249 | affs_unlink(struct inode *dir, struct dentry *dentry) | 251 | affs_unlink(struct inode *dir, struct dentry *dentry) |
250 | { | 252 | { |
251 | pr_debug("AFFS: unlink(dir=%d, %lu \"%.*s\")\n", (u32)dir->i_ino, | 253 | pr_debug("%s(dir=%d, %lu \"%.*s\")\n", |
252 | dentry->d_inode->i_ino, | 254 | __func__, (u32)dir->i_ino, dentry->d_inode->i_ino, |
253 | (int)dentry->d_name.len, dentry->d_name.name); | 255 | (int)dentry->d_name.len, dentry->d_name.name); |
254 | 256 | ||
255 | return affs_remove_header(dentry); | 257 | return affs_remove_header(dentry); |
256 | } | 258 | } |
@@ -262,7 +264,8 @@ affs_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool excl) | |||
262 | struct inode *inode; | 264 | struct inode *inode; |
263 | int error; | 265 | int error; |
264 | 266 | ||
265 | pr_debug("AFFS: create(%lu,\"%.*s\",0%ho)\n",dir->i_ino,(int)dentry->d_name.len, | 267 | pr_debug("%s(%lu,\"%.*s\",0%ho)\n", |
268 | __func__, dir->i_ino, (int)dentry->d_name.len, | ||
266 | dentry->d_name.name,mode); | 269 | dentry->d_name.name,mode); |
267 | 270 | ||
268 | inode = affs_new_inode(dir); | 271 | inode = affs_new_inode(dir); |
@@ -291,8 +294,9 @@ affs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
291 | struct inode *inode; | 294 | struct inode *inode; |
292 | int error; | 295 | int error; |
293 | 296 | ||
294 | pr_debug("AFFS: mkdir(%lu,\"%.*s\",0%ho)\n",dir->i_ino, | 297 | pr_debug("%s(%lu,\"%.*s\",0%ho)\n", |
295 | (int)dentry->d_name.len,dentry->d_name.name,mode); | 298 | __func__, dir->i_ino, (int)dentry->d_name.len, |
299 | dentry->d_name.name, mode); | ||
296 | 300 | ||
297 | inode = affs_new_inode(dir); | 301 | inode = affs_new_inode(dir); |
298 | if (!inode) | 302 | if (!inode) |
@@ -317,8 +321,8 @@ affs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
317 | int | 321 | int |
318 | affs_rmdir(struct inode *dir, struct dentry *dentry) | 322 | affs_rmdir(struct inode *dir, struct dentry *dentry) |
319 | { | 323 | { |
320 | pr_debug("AFFS: rmdir(dir=%u, %lu \"%.*s\")\n", (u32)dir->i_ino, | 324 | pr_debug("%s(dir=%u, %lu \"%.*s\")\n", |
321 | dentry->d_inode->i_ino, | 325 | __func__, (u32)dir->i_ino, dentry->d_inode->i_ino, |
322 | (int)dentry->d_name.len, dentry->d_name.name); | 326 | (int)dentry->d_name.len, dentry->d_name.name); |
323 | 327 | ||
324 | return affs_remove_header(dentry); | 328 | return affs_remove_header(dentry); |
@@ -334,8 +338,9 @@ affs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) | |||
334 | int i, maxlen, error; | 338 | int i, maxlen, error; |
335 | char c, lc; | 339 | char c, lc; |
336 | 340 | ||
337 | pr_debug("AFFS: symlink(%lu,\"%.*s\" -> \"%s\")\n",dir->i_ino, | 341 | pr_debug("%s(%lu,\"%.*s\" -> \"%s\")\n", |
338 | (int)dentry->d_name.len,dentry->d_name.name,symname); | 342 | __func__, dir->i_ino, (int)dentry->d_name.len, |
343 | dentry->d_name.name, symname); | ||
339 | 344 | ||
340 | maxlen = AFFS_SB(sb)->s_hashsize * sizeof(u32) - 1; | 345 | maxlen = AFFS_SB(sb)->s_hashsize * sizeof(u32) - 1; |
341 | inode = affs_new_inode(dir); | 346 | inode = affs_new_inode(dir); |
@@ -404,7 +409,8 @@ affs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) | |||
404 | { | 409 | { |
405 | struct inode *inode = old_dentry->d_inode; | 410 | struct inode *inode = old_dentry->d_inode; |
406 | 411 | ||
407 | pr_debug("AFFS: link(%u, %u, \"%.*s\")\n", (u32)inode->i_ino, (u32)dir->i_ino, | 412 | pr_debug("%s(%u, %u, \"%.*s\")\n", |
413 | __func__, (u32)inode->i_ino, (u32)dir->i_ino, | ||
408 | (int)dentry->d_name.len,dentry->d_name.name); | 414 | (int)dentry->d_name.len,dentry->d_name.name); |
409 | 415 | ||
410 | return affs_add_entry(dir, inode, dentry, ST_LINKFILE); | 416 | return affs_add_entry(dir, inode, dentry, ST_LINKFILE); |
@@ -418,9 +424,10 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
418 | struct buffer_head *bh = NULL; | 424 | struct buffer_head *bh = NULL; |
419 | int retval; | 425 | int retval; |
420 | 426 | ||
421 | pr_debug("AFFS: rename(old=%u,\"%*s\" to new=%u,\"%*s\")\n", | 427 | pr_debug("%s(old=%u,\"%*s\" to new=%u,\"%*s\")\n", |
422 | (u32)old_dir->i_ino, (int)old_dentry->d_name.len, old_dentry->d_name.name, | 428 | __func__, (u32)old_dir->i_ino, (int)old_dentry->d_name.len, |
423 | (u32)new_dir->i_ino, (int)new_dentry->d_name.len, new_dentry->d_name.name); | 429 | old_dentry->d_name.name, (u32)new_dir->i_ino, |
430 | (int)new_dentry->d_name.len, new_dentry->d_name.name); | ||
424 | 431 | ||
425 | retval = affs_check_name(new_dentry->d_name.name, | 432 | retval = affs_check_name(new_dentry->d_name.name, |
426 | new_dentry->d_name.len, | 433 | new_dentry->d_name.len, |
diff --git a/fs/affs/super.c b/fs/affs/super.c index 895ac7dc9dbf..51f1a95bff73 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c | |||
@@ -46,7 +46,7 @@ static void | |||
46 | affs_put_super(struct super_block *sb) | 46 | affs_put_super(struct super_block *sb) |
47 | { | 47 | { |
48 | struct affs_sb_info *sbi = AFFS_SB(sb); | 48 | struct affs_sb_info *sbi = AFFS_SB(sb); |
49 | pr_debug("AFFS: put_super()\n"); | 49 | pr_debug("%s()\n", __func__); |
50 | 50 | ||
51 | cancel_delayed_work_sync(&sbi->sb_work); | 51 | cancel_delayed_work_sync(&sbi->sb_work); |
52 | } | 52 | } |
@@ -220,7 +220,7 @@ parse_options(char *options, kuid_t *uid, kgid_t *gid, int *mode, int *reserved, | |||
220 | return 0; | 220 | return 0; |
221 | if (n != 512 && n != 1024 && n != 2048 | 221 | if (n != 512 && n != 1024 && n != 2048 |
222 | && n != 4096) { | 222 | && n != 4096) { |
223 | printk ("AFFS: Invalid blocksize (512, 1024, 2048, 4096 allowed)\n"); | 223 | pr_warn("Invalid blocksize (512, 1024, 2048, 4096 allowed)\n"); |
224 | return 0; | 224 | return 0; |
225 | } | 225 | } |
226 | *blocksize = n; | 226 | *blocksize = n; |
@@ -285,8 +285,8 @@ parse_options(char *options, kuid_t *uid, kgid_t *gid, int *mode, int *reserved, | |||
285 | /* Silently ignore the quota options */ | 285 | /* Silently ignore the quota options */ |
286 | break; | 286 | break; |
287 | default: | 287 | default: |
288 | printk("AFFS: Unrecognized mount option \"%s\" " | 288 | pr_warn("Unrecognized mount option \"%s\" or missing value\n", |
289 | "or missing value\n", p); | 289 | p); |
290 | return 0; | 290 | return 0; |
291 | } | 291 | } |
292 | } | 292 | } |
@@ -319,7 +319,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) | |||
319 | 319 | ||
320 | save_mount_options(sb, data); | 320 | save_mount_options(sb, data); |
321 | 321 | ||
322 | pr_debug("AFFS: read_super(%s)\n",data ? (const char *)data : "no options"); | 322 | pr_debug("read_super(%s)\n", data ? (const char *)data : "no options"); |
323 | 323 | ||
324 | sb->s_magic = AFFS_SUPER_MAGIC; | 324 | sb->s_magic = AFFS_SUPER_MAGIC; |
325 | sb->s_op = &affs_sops; | 325 | sb->s_op = &affs_sops; |
@@ -339,7 +339,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) | |||
339 | if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block, | 339 | if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block, |
340 | &blocksize,&sbi->s_prefix, | 340 | &blocksize,&sbi->s_prefix, |
341 | sbi->s_volume, &mount_flags)) { | 341 | sbi->s_volume, &mount_flags)) { |
342 | printk(KERN_ERR "AFFS: Error parsing options\n"); | 342 | pr_err("Error parsing options\n"); |
343 | return -EINVAL; | 343 | return -EINVAL; |
344 | } | 344 | } |
345 | /* N.B. after this point s_prefix must be released */ | 345 | /* N.B. after this point s_prefix must be released */ |
@@ -356,7 +356,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) | |||
356 | */ | 356 | */ |
357 | 357 | ||
358 | size = sb->s_bdev->bd_inode->i_size >> 9; | 358 | size = sb->s_bdev->bd_inode->i_size >> 9; |
359 | pr_debug("AFFS: initial blocksize=%d, #blocks=%d\n", 512, size); | 359 | pr_debug("initial blocksize=%d, #blocks=%d\n", 512, size); |
360 | 360 | ||
361 | affs_set_blocksize(sb, PAGE_SIZE); | 361 | affs_set_blocksize(sb, PAGE_SIZE); |
362 | /* Try to find root block. Its location depends on the block size. */ | 362 | /* Try to find root block. Its location depends on the block size. */ |
@@ -371,7 +371,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) | |||
371 | sbi->s_root_block = root_block; | 371 | sbi->s_root_block = root_block; |
372 | if (root_block < 0) | 372 | if (root_block < 0) |
373 | sbi->s_root_block = (reserved + size - 1) / 2; | 373 | sbi->s_root_block = (reserved + size - 1) / 2; |
374 | pr_debug("AFFS: setting blocksize to %d\n", blocksize); | 374 | pr_debug("setting blocksize to %d\n", blocksize); |
375 | affs_set_blocksize(sb, blocksize); | 375 | affs_set_blocksize(sb, blocksize); |
376 | sbi->s_partition_size = size; | 376 | sbi->s_partition_size = size; |
377 | 377 | ||
@@ -386,7 +386,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) | |||
386 | * block behind the calculated one. So we check this one, too. | 386 | * block behind the calculated one. So we check this one, too. |
387 | */ | 387 | */ |
388 | for (num_bm = 0; num_bm < 2; num_bm++) { | 388 | for (num_bm = 0; num_bm < 2; num_bm++) { |
389 | pr_debug("AFFS: Dev %s, trying root=%u, bs=%d, " | 389 | pr_debug("Dev %s, trying root=%u, bs=%d, " |
390 | "size=%d, reserved=%d\n", | 390 | "size=%d, reserved=%d\n", |
391 | sb->s_id, | 391 | sb->s_id, |
392 | sbi->s_root_block + num_bm, | 392 | sbi->s_root_block + num_bm, |
@@ -407,8 +407,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) | |||
407 | } | 407 | } |
408 | } | 408 | } |
409 | if (!silent) | 409 | if (!silent) |
410 | printk(KERN_ERR "AFFS: No valid root block on device %s\n", | 410 | pr_err("No valid root block on device %s\n", sb->s_id); |
411 | sb->s_id); | ||
412 | return -EINVAL; | 411 | return -EINVAL; |
413 | 412 | ||
414 | /* N.B. after this point bh must be released */ | 413 | /* N.B. after this point bh must be released */ |
@@ -420,7 +419,7 @@ got_root: | |||
420 | /* Find out which kind of FS we have */ | 419 | /* Find out which kind of FS we have */ |
421 | boot_bh = sb_bread(sb, 0); | 420 | boot_bh = sb_bread(sb, 0); |
422 | if (!boot_bh) { | 421 | if (!boot_bh) { |
423 | printk(KERN_ERR "AFFS: Cannot read boot block\n"); | 422 | pr_err("Cannot read boot block\n"); |
424 | return -EINVAL; | 423 | return -EINVAL; |
425 | } | 424 | } |
426 | memcpy(sig, boot_bh->b_data, 4); | 425 | memcpy(sig, boot_bh->b_data, 4); |
@@ -433,8 +432,7 @@ got_root: | |||
433 | */ | 432 | */ |
434 | if ((chksum == FS_DCFFS || chksum == MUFS_DCFFS || chksum == FS_DCOFS | 433 | if ((chksum == FS_DCFFS || chksum == MUFS_DCFFS || chksum == FS_DCOFS |
435 | || chksum == MUFS_DCOFS) && !(sb->s_flags & MS_RDONLY)) { | 434 | || chksum == MUFS_DCOFS) && !(sb->s_flags & MS_RDONLY)) { |
436 | printk(KERN_NOTICE "AFFS: Dircache FS - mounting %s read only\n", | 435 | pr_notice("Dircache FS - mounting %s read only\n", sb->s_id); |
437 | sb->s_id); | ||
438 | sb->s_flags |= MS_RDONLY; | 436 | sb->s_flags |= MS_RDONLY; |
439 | } | 437 | } |
440 | switch (chksum) { | 438 | switch (chksum) { |
@@ -468,14 +466,14 @@ got_root: | |||
468 | sb->s_flags |= MS_NOEXEC; | 466 | sb->s_flags |= MS_NOEXEC; |
469 | break; | 467 | break; |
470 | default: | 468 | default: |
471 | printk(KERN_ERR "AFFS: Unknown filesystem on device %s: %08X\n", | 469 | pr_err("Unknown filesystem on device %s: %08X\n", |
472 | sb->s_id, chksum); | 470 | sb->s_id, chksum); |
473 | return -EINVAL; | 471 | return -EINVAL; |
474 | } | 472 | } |
475 | 473 | ||
476 | if (mount_flags & SF_VERBOSE) { | 474 | if (mount_flags & SF_VERBOSE) { |
477 | u8 len = AFFS_ROOT_TAIL(sb, root_bh)->disk_name[0]; | 475 | u8 len = AFFS_ROOT_TAIL(sb, root_bh)->disk_name[0]; |
478 | printk(KERN_NOTICE "AFFS: Mounting volume \"%.*s\": Type=%.3s\\%c, Blocksize=%d\n", | 476 | pr_notice("Mounting volume \"%.*s\": Type=%.3s\\%c, Blocksize=%d\n", |
479 | len > 31 ? 31 : len, | 477 | len > 31 ? 31 : len, |
480 | AFFS_ROOT_TAIL(sb, root_bh)->disk_name + 1, | 478 | AFFS_ROOT_TAIL(sb, root_bh)->disk_name + 1, |
481 | sig, sig[3] + '0', blocksize); | 479 | sig, sig[3] + '0', blocksize); |
@@ -506,11 +504,11 @@ got_root: | |||
506 | 504 | ||
507 | sb->s_root = d_make_root(root_inode); | 505 | sb->s_root = d_make_root(root_inode); |
508 | if (!sb->s_root) { | 506 | if (!sb->s_root) { |
509 | printk(KERN_ERR "AFFS: Get root inode failed\n"); | 507 | pr_err("AFFS: Get root inode failed\n"); |
510 | return -ENOMEM; | 508 | return -ENOMEM; |
511 | } | 509 | } |
512 | 510 | ||
513 | pr_debug("AFFS: s_flags=%lX\n",sb->s_flags); | 511 | pr_debug("s_flags=%lX\n", sb->s_flags); |
514 | return 0; | 512 | return 0; |
515 | } | 513 | } |
516 | 514 | ||
@@ -530,7 +528,7 @@ affs_remount(struct super_block *sb, int *flags, char *data) | |||
530 | char volume[32]; | 528 | char volume[32]; |
531 | char *prefix = NULL; | 529 | char *prefix = NULL; |
532 | 530 | ||
533 | pr_debug("AFFS: remount(flags=0x%x,opts=\"%s\")\n",*flags,data); | 531 | pr_debug("%s(flags=0x%x,opts=\"%s\")\n", __func__, *flags, data); |
534 | 532 | ||
535 | sync_filesystem(sb); | 533 | sync_filesystem(sb); |
536 | *flags |= MS_NODIRATIME; | 534 | *flags |= MS_NODIRATIME; |
@@ -578,8 +576,9 @@ affs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
578 | int free; | 576 | int free; |
579 | u64 id = huge_encode_dev(sb->s_bdev->bd_dev); | 577 | u64 id = huge_encode_dev(sb->s_bdev->bd_dev); |
580 | 578 | ||
581 | pr_debug("AFFS: statfs() partsize=%d, reserved=%d\n",AFFS_SB(sb)->s_partition_size, | 579 | pr_debug("%s() partsize=%d, reserved=%d\n", |
582 | AFFS_SB(sb)->s_reserved); | 580 | __func__, AFFS_SB(sb)->s_partition_size, |
581 | AFFS_SB(sb)->s_reserved); | ||
583 | 582 | ||
584 | free = affs_count_free_blocks(sb); | 583 | free = affs_count_free_blocks(sb); |
585 | buf->f_type = AFFS_SUPER_MAGIC; | 584 | buf->f_type = AFFS_SUPER_MAGIC; |
diff --git a/fs/affs/symlink.c b/fs/affs/symlink.c index ee00f08c4f53..f39b71c3981e 100644 --- a/fs/affs/symlink.c +++ b/fs/affs/symlink.c | |||
@@ -21,7 +21,7 @@ static int affs_symlink_readpage(struct file *file, struct page *page) | |||
21 | char c; | 21 | char c; |
22 | char lc; | 22 | char lc; |
23 | 23 | ||
24 | pr_debug("AFFS: follow_link(ino=%lu)\n",inode->i_ino); | 24 | pr_debug("follow_link(ino=%lu)\n", inode->i_ino); |
25 | 25 | ||
26 | err = -EIO; | 26 | err = -EIO; |
27 | bh = affs_bread(inode->i_sb, inode->i_ino); | 27 | bh = affs_bread(inode->i_sb, inode->i_ino); |
diff --git a/fs/befs/btree.c b/fs/befs/btree.c index a2cd305a993a..9c7faa8a9288 100644 --- a/fs/befs/btree.c +++ b/fs/befs/btree.c | |||
@@ -318,7 +318,7 @@ befs_btree_find(struct super_block *sb, befs_data_stream * ds, | |||
318 | * befs_find_key - Search for a key within a node | 318 | * befs_find_key - Search for a key within a node |
319 | * @sb: Filesystem superblock | 319 | * @sb: Filesystem superblock |
320 | * @node: Node to find the key within | 320 | * @node: Node to find the key within |
321 | * @key: Keystring to search for | 321 | * @findkey: Keystring to search for |
322 | * @value: If key is found, the value stored with the key is put here | 322 | * @value: If key is found, the value stored with the key is put here |
323 | * | 323 | * |
324 | * finds exact match if one exists, and returns BEFS_BT_MATCH | 324 | * finds exact match if one exists, and returns BEFS_BT_MATCH |
@@ -405,7 +405,7 @@ befs_find_key(struct super_block *sb, befs_btree_node * node, | |||
405 | * Heres how it works: Key_no is the index of the key/value pair to | 405 | * Heres how it works: Key_no is the index of the key/value pair to |
406 | * return in keybuf/value. | 406 | * return in keybuf/value. |
407 | * Bufsize is the size of keybuf (BEFS_NAME_LEN+1 is a good size). Keysize is | 407 | * Bufsize is the size of keybuf (BEFS_NAME_LEN+1 is a good size). Keysize is |
408 | * the number of charecters in the key (just a convenience). | 408 | * the number of characters in the key (just a convenience). |
409 | * | 409 | * |
410 | * Algorithm: | 410 | * Algorithm: |
411 | * Get the first leafnode of the tree. See if the requested key is in that | 411 | * Get the first leafnode of the tree. See if the requested key is in that |
@@ -502,12 +502,11 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds, | |||
502 | "for key of size %d", __func__, bufsize, keylen); | 502 | "for key of size %d", __func__, bufsize, keylen); |
503 | brelse(this_node->bh); | 503 | brelse(this_node->bh); |
504 | goto error_alloc; | 504 | goto error_alloc; |
505 | }; | 505 | } |
506 | 506 | ||
507 | strncpy(keybuf, keystart, keylen); | 507 | strlcpy(keybuf, keystart, keylen + 1); |
508 | *value = fs64_to_cpu(sb, valarray[cur_key]); | 508 | *value = fs64_to_cpu(sb, valarray[cur_key]); |
509 | *keysize = keylen; | 509 | *keysize = keylen; |
510 | keybuf[keylen] = '\0'; | ||
511 | 510 | ||
512 | befs_debug(sb, "Read [%llu,%d]: Key \"%.*s\", Value %llu", node_off, | 511 | befs_debug(sb, "Read [%llu,%d]: Key \"%.*s\", Value %llu", node_off, |
513 | cur_key, keylen, keybuf, *value); | 512 | cur_key, keylen, keybuf, *value); |
@@ -707,7 +706,7 @@ befs_bt_get_key(struct super_block *sb, befs_btree_node * node, | |||
707 | * @key1: pointer to the first key to be compared | 706 | * @key1: pointer to the first key to be compared |
708 | * @keylen1: length in bytes of key1 | 707 | * @keylen1: length in bytes of key1 |
709 | * @key2: pointer to the second key to be compared | 708 | * @key2: pointer to the second key to be compared |
710 | * @kelen2: length in bytes of key2 | 709 | * @keylen2: length in bytes of key2 |
711 | * | 710 | * |
712 | * Returns 0 if @key1 and @key2 are equal. | 711 | * Returns 0 if @key1 and @key2 are equal. |
713 | * Returns >0 if @key1 is greater. | 712 | * Returns >0 if @key1 is greater. |
diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c index c467bebd50af..1e8e0b8d8836 100644 --- a/fs/befs/datastream.c +++ b/fs/befs/datastream.c | |||
@@ -116,7 +116,7 @@ befs_fblock2brun(struct super_block *sb, befs_data_stream * data, | |||
116 | * befs_read_lsmylink - read long symlink from datastream. | 116 | * befs_read_lsmylink - read long symlink from datastream. |
117 | * @sb: Filesystem superblock | 117 | * @sb: Filesystem superblock |
118 | * @ds: Datastrem to read from | 118 | * @ds: Datastrem to read from |
119 | * @buf: Buffer in which to place long symlink data | 119 | * @buff: Buffer in which to place long symlink data |
120 | * @len: Length of the long symlink in bytes | 120 | * @len: Length of the long symlink in bytes |
121 | * | 121 | * |
122 | * Returns the number of bytes read | 122 | * Returns the number of bytes read |
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index d626756ff721..a16fbd4e8241 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c | |||
@@ -133,14 +133,6 @@ befs_get_block(struct inode *inode, sector_t block, | |||
133 | 133 | ||
134 | befs_debug(sb, "---> befs_get_block() for inode %lu, block %ld", | 134 | befs_debug(sb, "---> befs_get_block() for inode %lu, block %ld", |
135 | (unsigned long)inode->i_ino, (long)block); | 135 | (unsigned long)inode->i_ino, (long)block); |
136 | |||
137 | if (block < 0) { | ||
138 | befs_error(sb, "befs_get_block() was asked for a block " | ||
139 | "number less than zero: block %ld in inode %lu", | ||
140 | (long)block, (unsigned long)inode->i_ino); | ||
141 | return -EIO; | ||
142 | } | ||
143 | |||
144 | if (create) { | 136 | if (create) { |
145 | befs_error(sb, "befs_get_block() was asked to write to " | 137 | befs_error(sb, "befs_get_block() was asked to write to " |
146 | "block %ld in inode %lu", (long)block, | 138 | "block %ld in inode %lu", (long)block, |
@@ -396,9 +388,8 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino) | |||
396 | if (S_ISLNK(inode->i_mode) && !(befs_ino->i_flags & BEFS_LONG_SYMLINK)){ | 388 | if (S_ISLNK(inode->i_mode) && !(befs_ino->i_flags & BEFS_LONG_SYMLINK)){ |
397 | inode->i_size = 0; | 389 | inode->i_size = 0; |
398 | inode->i_blocks = befs_sb->block_size / VFS_BLOCK_SIZE; | 390 | inode->i_blocks = befs_sb->block_size / VFS_BLOCK_SIZE; |
399 | strncpy(befs_ino->i_data.symlink, raw_inode->data.symlink, | 391 | strlcpy(befs_ino->i_data.symlink, raw_inode->data.symlink, |
400 | BEFS_SYMLINK_LEN - 1); | 392 | BEFS_SYMLINK_LEN); |
401 | befs_ino->i_data.symlink[BEFS_SYMLINK_LEN - 1] = '\0'; | ||
402 | } else { | 393 | } else { |
403 | int num_blks; | 394 | int num_blks; |
404 | 395 | ||
@@ -591,21 +582,21 @@ befs_utf2nls(struct super_block *sb, const char *in, | |||
591 | /** | 582 | /** |
592 | * befs_nls2utf - Convert NLS string to utf8 encodeing | 583 | * befs_nls2utf - Convert NLS string to utf8 encodeing |
593 | * @sb: Superblock | 584 | * @sb: Superblock |
594 | * @src: Input string buffer in NLS format | 585 | * @in: Input string buffer in NLS format |
595 | * @srclen: Length of input string in bytes | 586 | * @in_len: Length of input string in bytes |
596 | * @dest: The output string in UTF-8 format | 587 | * @out: The output string in UTF-8 format |
597 | * @destlen: Length of the output buffer | 588 | * @out_len: Length of the output buffer |
598 | * | 589 | * |
599 | * Converts input string @src, which is in the format of the loaded NLS map, | 590 | * Converts input string @in, which is in the format of the loaded NLS map, |
600 | * into a utf8 string. | 591 | * into a utf8 string. |
601 | * | 592 | * |
602 | * The destination string @dest is allocated by this function and the caller is | 593 | * The destination string @out is allocated by this function and the caller is |
603 | * responsible for freeing it with kfree() | 594 | * responsible for freeing it with kfree() |
604 | * | 595 | * |
605 | * On return, *@destlen is the length of @dest in bytes. | 596 | * On return, *@out_len is the length of @out in bytes. |
606 | * | 597 | * |
607 | * On success, the return value is the number of utf8 characters written to | 598 | * On success, the return value is the number of utf8 characters written to |
608 | * the output buffer @dest. | 599 | * the output buffer @out. |
609 | * | 600 | * |
610 | * On Failure, a negative number coresponding to the error code is returned. | 601 | * On Failure, a negative number coresponding to the error code is returned. |
611 | */ | 602 | */ |
diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c index 5b99bafc31d1..d749731dc0ee 100644 --- a/fs/cachefiles/bind.c +++ b/fs/cachefiles/bind.c | |||
@@ -50,18 +50,18 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args) | |||
50 | cache->brun_percent < 100); | 50 | cache->brun_percent < 100); |
51 | 51 | ||
52 | if (*args) { | 52 | if (*args) { |
53 | kerror("'bind' command doesn't take an argument"); | 53 | pr_err("'bind' command doesn't take an argument"); |
54 | return -EINVAL; | 54 | return -EINVAL; |
55 | } | 55 | } |
56 | 56 | ||
57 | if (!cache->rootdirname) { | 57 | if (!cache->rootdirname) { |
58 | kerror("No cache directory specified"); | 58 | pr_err("No cache directory specified"); |
59 | return -EINVAL; | 59 | return -EINVAL; |
60 | } | 60 | } |
61 | 61 | ||
62 | /* don't permit already bound caches to be re-bound */ | 62 | /* don't permit already bound caches to be re-bound */ |
63 | if (test_bit(CACHEFILES_READY, &cache->flags)) { | 63 | if (test_bit(CACHEFILES_READY, &cache->flags)) { |
64 | kerror("Cache already bound"); | 64 | pr_err("Cache already bound"); |
65 | return -EBUSY; | 65 | return -EBUSY; |
66 | } | 66 | } |
67 | 67 | ||
@@ -228,9 +228,7 @@ static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache) | |||
228 | set_bit(CACHEFILES_READY, &cache->flags); | 228 | set_bit(CACHEFILES_READY, &cache->flags); |
229 | dput(root); | 229 | dput(root); |
230 | 230 | ||
231 | printk(KERN_INFO "CacheFiles:" | 231 | pr_info("File cache on %s registered\n", cache->cache.identifier); |
232 | " File cache on %s registered\n", | ||
233 | cache->cache.identifier); | ||
234 | 232 | ||
235 | /* check how much space the cache has */ | 233 | /* check how much space the cache has */ |
236 | cachefiles_has_space(cache, 0, 0); | 234 | cachefiles_has_space(cache, 0, 0); |
@@ -250,7 +248,7 @@ error_open_root: | |||
250 | kmem_cache_free(cachefiles_object_jar, fsdef); | 248 | kmem_cache_free(cachefiles_object_jar, fsdef); |
251 | error_root_object: | 249 | error_root_object: |
252 | cachefiles_end_secure(cache, saved_cred); | 250 | cachefiles_end_secure(cache, saved_cred); |
253 | kerror("Failed to register: %d", ret); | 251 | pr_err("Failed to register: %d", ret); |
254 | return ret; | 252 | return ret; |
255 | } | 253 | } |
256 | 254 | ||
@@ -262,9 +260,8 @@ void cachefiles_daemon_unbind(struct cachefiles_cache *cache) | |||
262 | _enter(""); | 260 | _enter(""); |
263 | 261 | ||
264 | if (test_bit(CACHEFILES_READY, &cache->flags)) { | 262 | if (test_bit(CACHEFILES_READY, &cache->flags)) { |
265 | printk(KERN_INFO "CacheFiles:" | 263 | pr_info("File cache on %s unregistering\n", |
266 | " File cache on %s unregistering\n", | 264 | cache->cache.identifier); |
267 | cache->cache.identifier); | ||
268 | 265 | ||
269 | fscache_withdraw_cache(&cache->cache); | 266 | fscache_withdraw_cache(&cache->cache); |
270 | } | 267 | } |
diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c index 0a1467b15516..b078d3081d6c 100644 --- a/fs/cachefiles/daemon.c +++ b/fs/cachefiles/daemon.c | |||
@@ -315,8 +315,7 @@ static unsigned int cachefiles_daemon_poll(struct file *file, | |||
315 | static int cachefiles_daemon_range_error(struct cachefiles_cache *cache, | 315 | static int cachefiles_daemon_range_error(struct cachefiles_cache *cache, |
316 | char *args) | 316 | char *args) |
317 | { | 317 | { |
318 | kerror("Free space limits must be in range" | 318 | pr_err("Free space limits must be in range 0%%<=stop<cull<run<100%%"); |
319 | " 0%%<=stop<cull<run<100%%"); | ||
320 | 319 | ||
321 | return -EINVAL; | 320 | return -EINVAL; |
322 | } | 321 | } |
@@ -476,12 +475,12 @@ static int cachefiles_daemon_dir(struct cachefiles_cache *cache, char *args) | |||
476 | _enter(",%s", args); | 475 | _enter(",%s", args); |
477 | 476 | ||
478 | if (!*args) { | 477 | if (!*args) { |
479 | kerror("Empty directory specified"); | 478 | pr_err("Empty directory specified"); |
480 | return -EINVAL; | 479 | return -EINVAL; |
481 | } | 480 | } |
482 | 481 | ||
483 | if (cache->rootdirname) { | 482 | if (cache->rootdirname) { |
484 | kerror("Second cache directory specified"); | 483 | pr_err("Second cache directory specified"); |
485 | return -EEXIST; | 484 | return -EEXIST; |
486 | } | 485 | } |
487 | 486 | ||
@@ -504,12 +503,12 @@ static int cachefiles_daemon_secctx(struct cachefiles_cache *cache, char *args) | |||
504 | _enter(",%s", args); | 503 | _enter(",%s", args); |
505 | 504 | ||
506 | if (!*args) { | 505 | if (!*args) { |
507 | kerror("Empty security context specified"); | 506 | pr_err("Empty security context specified"); |
508 | return -EINVAL; | 507 | return -EINVAL; |
509 | } | 508 | } |
510 | 509 | ||
511 | if (cache->secctx) { | 510 | if (cache->secctx) { |
512 | kerror("Second security context specified"); | 511 | pr_err("Second security context specified"); |
513 | return -EINVAL; | 512 | return -EINVAL; |
514 | } | 513 | } |
515 | 514 | ||
@@ -532,7 +531,7 @@ static int cachefiles_daemon_tag(struct cachefiles_cache *cache, char *args) | |||
532 | _enter(",%s", args); | 531 | _enter(",%s", args); |
533 | 532 | ||
534 | if (!*args) { | 533 | if (!*args) { |
535 | kerror("Empty tag specified"); | 534 | pr_err("Empty tag specified"); |
536 | return -EINVAL; | 535 | return -EINVAL; |
537 | } | 536 | } |
538 | 537 | ||
@@ -563,12 +562,12 @@ static int cachefiles_daemon_cull(struct cachefiles_cache *cache, char *args) | |||
563 | goto inval; | 562 | goto inval; |
564 | 563 | ||
565 | if (!test_bit(CACHEFILES_READY, &cache->flags)) { | 564 | if (!test_bit(CACHEFILES_READY, &cache->flags)) { |
566 | kerror("cull applied to unready cache"); | 565 | pr_err("cull applied to unready cache"); |
567 | return -EIO; | 566 | return -EIO; |
568 | } | 567 | } |
569 | 568 | ||
570 | if (test_bit(CACHEFILES_DEAD, &cache->flags)) { | 569 | if (test_bit(CACHEFILES_DEAD, &cache->flags)) { |
571 | kerror("cull applied to dead cache"); | 570 | pr_err("cull applied to dead cache"); |
572 | return -EIO; | 571 | return -EIO; |
573 | } | 572 | } |
574 | 573 | ||
@@ -588,11 +587,11 @@ static int cachefiles_daemon_cull(struct cachefiles_cache *cache, char *args) | |||
588 | 587 | ||
589 | notdir: | 588 | notdir: |
590 | path_put(&path); | 589 | path_put(&path); |
591 | kerror("cull command requires dirfd to be a directory"); | 590 | pr_err("cull command requires dirfd to be a directory"); |
592 | return -ENOTDIR; | 591 | return -ENOTDIR; |
593 | 592 | ||
594 | inval: | 593 | inval: |
595 | kerror("cull command requires dirfd and filename"); | 594 | pr_err("cull command requires dirfd and filename"); |
596 | return -EINVAL; | 595 | return -EINVAL; |
597 | } | 596 | } |
598 | 597 | ||
@@ -615,7 +614,7 @@ static int cachefiles_daemon_debug(struct cachefiles_cache *cache, char *args) | |||
615 | return 0; | 614 | return 0; |
616 | 615 | ||
617 | inval: | 616 | inval: |
618 | kerror("debug command requires mask"); | 617 | pr_err("debug command requires mask"); |
619 | return -EINVAL; | 618 | return -EINVAL; |
620 | } | 619 | } |
621 | 620 | ||
@@ -635,12 +634,12 @@ static int cachefiles_daemon_inuse(struct cachefiles_cache *cache, char *args) | |||
635 | goto inval; | 634 | goto inval; |
636 | 635 | ||
637 | if (!test_bit(CACHEFILES_READY, &cache->flags)) { | 636 | if (!test_bit(CACHEFILES_READY, &cache->flags)) { |
638 | kerror("inuse applied to unready cache"); | 637 | pr_err("inuse applied to unready cache"); |
639 | return -EIO; | 638 | return -EIO; |
640 | } | 639 | } |
641 | 640 | ||
642 | if (test_bit(CACHEFILES_DEAD, &cache->flags)) { | 641 | if (test_bit(CACHEFILES_DEAD, &cache->flags)) { |
643 | kerror("inuse applied to dead cache"); | 642 | pr_err("inuse applied to dead cache"); |
644 | return -EIO; | 643 | return -EIO; |
645 | } | 644 | } |
646 | 645 | ||
@@ -660,11 +659,11 @@ static int cachefiles_daemon_inuse(struct cachefiles_cache *cache, char *args) | |||
660 | 659 | ||
661 | notdir: | 660 | notdir: |
662 | path_put(&path); | 661 | path_put(&path); |
663 | kerror("inuse command requires dirfd to be a directory"); | 662 | pr_err("inuse command requires dirfd to be a directory"); |
664 | return -ENOTDIR; | 663 | return -ENOTDIR; |
665 | 664 | ||
666 | inval: | 665 | inval: |
667 | kerror("inuse command requires dirfd and filename"); | 666 | pr_err("inuse command requires dirfd and filename"); |
668 | return -EINVAL; | 667 | return -EINVAL; |
669 | } | 668 | } |
670 | 669 | ||
diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c index 57e17fe6121a..584743d456c3 100644 --- a/fs/cachefiles/interface.c +++ b/fs/cachefiles/interface.c | |||
@@ -146,8 +146,7 @@ static int cachefiles_lookup_object(struct fscache_object *_object) | |||
146 | 146 | ||
147 | if (ret < 0 && ret != -ETIMEDOUT) { | 147 | if (ret < 0 && ret != -ETIMEDOUT) { |
148 | if (ret != -ENOBUFS) | 148 | if (ret != -ENOBUFS) |
149 | printk(KERN_WARNING | 149 | pr_warn("Lookup failed error %d\n", ret); |
150 | "CacheFiles: Lookup failed error %d\n", ret); | ||
151 | fscache_object_lookup_error(&object->fscache); | 150 | fscache_object_lookup_error(&object->fscache); |
152 | } | 151 | } |
153 | 152 | ||
diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index 5349473df1b1..3d50998abf57 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h | |||
@@ -9,6 +9,13 @@ | |||
9 | * 2 of the Licence, or (at your option) any later version. | 9 | * 2 of the Licence, or (at your option) any later version. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #ifdef pr_fmt | ||
13 | #undef pr_fmt | ||
14 | #endif | ||
15 | |||
16 | #define pr_fmt(fmt) "CacheFiles: " fmt | ||
17 | |||
18 | |||
12 | #include <linux/fscache-cache.h> | 19 | #include <linux/fscache-cache.h> |
13 | #include <linux/timer.h> | 20 | #include <linux/timer.h> |
14 | #include <linux/wait.h> | 21 | #include <linux/wait.h> |
@@ -245,11 +252,10 @@ extern int cachefiles_remove_object_xattr(struct cachefiles_cache *cache, | |||
245 | /* | 252 | /* |
246 | * error handling | 253 | * error handling |
247 | */ | 254 | */ |
248 | #define kerror(FMT, ...) printk(KERN_ERR "CacheFiles: "FMT"\n", ##__VA_ARGS__) | ||
249 | 255 | ||
250 | #define cachefiles_io_error(___cache, FMT, ...) \ | 256 | #define cachefiles_io_error(___cache, FMT, ...) \ |
251 | do { \ | 257 | do { \ |
252 | kerror("I/O Error: " FMT, ##__VA_ARGS__); \ | 258 | pr_err("I/O Error: " FMT, ##__VA_ARGS__); \ |
253 | fscache_io_error(&(___cache)->cache); \ | 259 | fscache_io_error(&(___cache)->cache); \ |
254 | set_bit(CACHEFILES_DEAD, &(___cache)->flags); \ | 260 | set_bit(CACHEFILES_DEAD, &(___cache)->flags); \ |
255 | } while (0) | 261 | } while (0) |
@@ -310,8 +316,8 @@ do { \ | |||
310 | #define ASSERT(X) \ | 316 | #define ASSERT(X) \ |
311 | do { \ | 317 | do { \ |
312 | if (unlikely(!(X))) { \ | 318 | if (unlikely(!(X))) { \ |
313 | printk(KERN_ERR "\n"); \ | 319 | pr_err("\n"); \ |
314 | printk(KERN_ERR "CacheFiles: Assertion failed\n"); \ | 320 | pr_err("Assertion failed\n"); \ |
315 | BUG(); \ | 321 | BUG(); \ |
316 | } \ | 322 | } \ |
317 | } while (0) | 323 | } while (0) |
@@ -319,9 +325,9 @@ do { \ | |||
319 | #define ASSERTCMP(X, OP, Y) \ | 325 | #define ASSERTCMP(X, OP, Y) \ |
320 | do { \ | 326 | do { \ |
321 | if (unlikely(!((X) OP (Y)))) { \ | 327 | if (unlikely(!((X) OP (Y)))) { \ |
322 | printk(KERN_ERR "\n"); \ | 328 | pr_err("\n"); \ |
323 | printk(KERN_ERR "CacheFiles: Assertion failed\n"); \ | 329 | pr_err("Assertion failed\n"); \ |
324 | printk(KERN_ERR "%lx " #OP " %lx is false\n", \ | 330 | pr_err("%lx " #OP " %lx is false\n", \ |
325 | (unsigned long)(X), (unsigned long)(Y)); \ | 331 | (unsigned long)(X), (unsigned long)(Y)); \ |
326 | BUG(); \ | 332 | BUG(); \ |
327 | } \ | 333 | } \ |
@@ -330,8 +336,8 @@ do { \ | |||
330 | #define ASSERTIF(C, X) \ | 336 | #define ASSERTIF(C, X) \ |
331 | do { \ | 337 | do { \ |
332 | if (unlikely((C) && !(X))) { \ | 338 | if (unlikely((C) && !(X))) { \ |
333 | printk(KERN_ERR "\n"); \ | 339 | pr_err("\n"); \ |
334 | printk(KERN_ERR "CacheFiles: Assertion failed\n"); \ | 340 | pr_err("Assertion failed\n"); \ |
335 | BUG(); \ | 341 | BUG(); \ |
336 | } \ | 342 | } \ |
337 | } while (0) | 343 | } while (0) |
@@ -339,9 +345,9 @@ do { \ | |||
339 | #define ASSERTIFCMP(C, X, OP, Y) \ | 345 | #define ASSERTIFCMP(C, X, OP, Y) \ |
340 | do { \ | 346 | do { \ |
341 | if (unlikely((C) && !((X) OP (Y)))) { \ | 347 | if (unlikely((C) && !((X) OP (Y)))) { \ |
342 | printk(KERN_ERR "\n"); \ | 348 | pr_err("\n"); \ |
343 | printk(KERN_ERR "CacheFiles: Assertion failed\n"); \ | 349 | pr_err("Assertion failed\n"); \ |
344 | printk(KERN_ERR "%lx " #OP " %lx is false\n", \ | 350 | pr_err("%lx " #OP " %lx is false\n", \ |
345 | (unsigned long)(X), (unsigned long)(Y)); \ | 351 | (unsigned long)(X), (unsigned long)(Y)); \ |
346 | BUG(); \ | 352 | BUG(); \ |
347 | } \ | 353 | } \ |
diff --git a/fs/cachefiles/main.c b/fs/cachefiles/main.c index 4bfa8cf43bf5..180edfb45f66 100644 --- a/fs/cachefiles/main.c +++ b/fs/cachefiles/main.c | |||
@@ -68,8 +68,7 @@ static int __init cachefiles_init(void) | |||
68 | SLAB_HWCACHE_ALIGN, | 68 | SLAB_HWCACHE_ALIGN, |
69 | cachefiles_object_init_once); | 69 | cachefiles_object_init_once); |
70 | if (!cachefiles_object_jar) { | 70 | if (!cachefiles_object_jar) { |
71 | printk(KERN_NOTICE | 71 | pr_notice("Failed to allocate an object jar\n"); |
72 | "CacheFiles: Failed to allocate an object jar\n"); | ||
73 | goto error_object_jar; | 72 | goto error_object_jar; |
74 | } | 73 | } |
75 | 74 | ||
@@ -77,7 +76,7 @@ static int __init cachefiles_init(void) | |||
77 | if (ret < 0) | 76 | if (ret < 0) |
78 | goto error_proc; | 77 | goto error_proc; |
79 | 78 | ||
80 | printk(KERN_INFO "CacheFiles: Loaded\n"); | 79 | pr_info("Loaded\n"); |
81 | return 0; | 80 | return 0; |
82 | 81 | ||
83 | error_proc: | 82 | error_proc: |
@@ -85,7 +84,7 @@ error_proc: | |||
85 | error_object_jar: | 84 | error_object_jar: |
86 | misc_deregister(&cachefiles_dev); | 85 | misc_deregister(&cachefiles_dev); |
87 | error_dev: | 86 | error_dev: |
88 | kerror("failed to register: %d", ret); | 87 | pr_err("failed to register: %d", ret); |
89 | return ret; | 88 | return ret; |
90 | } | 89 | } |
91 | 90 | ||
@@ -96,7 +95,7 @@ fs_initcall(cachefiles_init); | |||
96 | */ | 95 | */ |
97 | static void __exit cachefiles_exit(void) | 96 | static void __exit cachefiles_exit(void) |
98 | { | 97 | { |
99 | printk(KERN_INFO "CacheFiles: Unloading\n"); | 98 | pr_info("Unloading\n"); |
100 | 99 | ||
101 | cachefiles_proc_cleanup(); | 100 | cachefiles_proc_cleanup(); |
102 | kmem_cache_destroy(cachefiles_object_jar); | 101 | kmem_cache_destroy(cachefiles_object_jar); |
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index c0a681705104..5bf2b41e66d3 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c | |||
@@ -35,22 +35,21 @@ void __cachefiles_printk_object(struct cachefiles_object *object, | |||
35 | struct fscache_cookie *cookie; | 35 | struct fscache_cookie *cookie; |
36 | unsigned keylen, loop; | 36 | unsigned keylen, loop; |
37 | 37 | ||
38 | printk(KERN_ERR "%sobject: OBJ%x\n", | 38 | pr_err("%sobject: OBJ%x\n", prefix, object->fscache.debug_id); |
39 | prefix, object->fscache.debug_id); | 39 | pr_err("%sobjstate=%s fl=%lx wbusy=%x ev=%lx[%lx]\n", |
40 | printk(KERN_ERR "%sobjstate=%s fl=%lx wbusy=%x ev=%lx[%lx]\n", | ||
41 | prefix, object->fscache.state->name, | 40 | prefix, object->fscache.state->name, |
42 | object->fscache.flags, work_busy(&object->fscache.work), | 41 | object->fscache.flags, work_busy(&object->fscache.work), |
43 | object->fscache.events, object->fscache.event_mask); | 42 | object->fscache.events, object->fscache.event_mask); |
44 | printk(KERN_ERR "%sops=%u inp=%u exc=%u\n", | 43 | pr_err("%sops=%u inp=%u exc=%u\n", |
45 | prefix, object->fscache.n_ops, object->fscache.n_in_progress, | 44 | prefix, object->fscache.n_ops, object->fscache.n_in_progress, |
46 | object->fscache.n_exclusive); | 45 | object->fscache.n_exclusive); |
47 | printk(KERN_ERR "%sparent=%p\n", | 46 | pr_err("%sparent=%p\n", |
48 | prefix, object->fscache.parent); | 47 | prefix, object->fscache.parent); |
49 | 48 | ||
50 | spin_lock(&object->fscache.lock); | 49 | spin_lock(&object->fscache.lock); |
51 | cookie = object->fscache.cookie; | 50 | cookie = object->fscache.cookie; |
52 | if (cookie) { | 51 | if (cookie) { |
53 | printk(KERN_ERR "%scookie=%p [pr=%p nd=%p fl=%lx]\n", | 52 | pr_err("%scookie=%p [pr=%p nd=%p fl=%lx]\n", |
54 | prefix, | 53 | prefix, |
55 | object->fscache.cookie, | 54 | object->fscache.cookie, |
56 | object->fscache.cookie->parent, | 55 | object->fscache.cookie->parent, |
@@ -62,16 +61,16 @@ void __cachefiles_printk_object(struct cachefiles_object *object, | |||
62 | else | 61 | else |
63 | keylen = 0; | 62 | keylen = 0; |
64 | } else { | 63 | } else { |
65 | printk(KERN_ERR "%scookie=NULL\n", prefix); | 64 | pr_err("%scookie=NULL\n", prefix); |
66 | keylen = 0; | 65 | keylen = 0; |
67 | } | 66 | } |
68 | spin_unlock(&object->fscache.lock); | 67 | spin_unlock(&object->fscache.lock); |
69 | 68 | ||
70 | if (keylen) { | 69 | if (keylen) { |
71 | printk(KERN_ERR "%skey=[%u] '", prefix, keylen); | 70 | pr_err("%skey=[%u] '", prefix, keylen); |
72 | for (loop = 0; loop < keylen; loop++) | 71 | for (loop = 0; loop < keylen; loop++) |
73 | printk("%02x", keybuf[loop]); | 72 | pr_cont("%02x", keybuf[loop]); |
74 | printk("'\n"); | 73 | pr_cont("'\n"); |
75 | } | 74 | } |
76 | } | 75 | } |
77 | 76 | ||
@@ -131,13 +130,11 @@ found_dentry: | |||
131 | dentry); | 130 | dentry); |
132 | 131 | ||
133 | if (fscache_object_is_live(&object->fscache)) { | 132 | if (fscache_object_is_live(&object->fscache)) { |
134 | printk(KERN_ERR "\n"); | 133 | pr_err("\n"); |
135 | printk(KERN_ERR "CacheFiles: Error:" | 134 | pr_err("Error: Can't preemptively bury live object\n"); |
136 | " Can't preemptively bury live object\n"); | ||
137 | cachefiles_printk_object(object, NULL); | 135 | cachefiles_printk_object(object, NULL); |
138 | } else if (test_and_set_bit(CACHEFILES_OBJECT_BURIED, &object->flags)) { | 136 | } else if (test_and_set_bit(CACHEFILES_OBJECT_BURIED, &object->flags)) { |
139 | printk(KERN_ERR "CacheFiles: Error:" | 137 | pr_err("Error: Object already preemptively buried\n"); |
140 | " Object already preemptively buried\n"); | ||
141 | } | 138 | } |
142 | 139 | ||
143 | write_unlock(&cache->active_lock); | 140 | write_unlock(&cache->active_lock); |
@@ -160,7 +157,7 @@ try_again: | |||
160 | write_lock(&cache->active_lock); | 157 | write_lock(&cache->active_lock); |
161 | 158 | ||
162 | if (test_and_set_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags)) { | 159 | if (test_and_set_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags)) { |
163 | printk(KERN_ERR "CacheFiles: Error: Object already active\n"); | 160 | pr_err("Error: Object already active\n"); |
164 | cachefiles_printk_object(object, NULL); | 161 | cachefiles_printk_object(object, NULL); |
165 | BUG(); | 162 | BUG(); |
166 | } | 163 | } |
@@ -193,9 +190,8 @@ try_again: | |||
193 | * need to wait for it to be destroyed */ | 190 | * need to wait for it to be destroyed */ |
194 | wait_for_old_object: | 191 | wait_for_old_object: |
195 | if (fscache_object_is_live(&object->fscache)) { | 192 | if (fscache_object_is_live(&object->fscache)) { |
196 | printk(KERN_ERR "\n"); | 193 | pr_err("\n"); |
197 | printk(KERN_ERR "CacheFiles: Error:" | 194 | pr_err("Error: Unexpected object collision\n"); |
198 | " Unexpected object collision\n"); | ||
199 | cachefiles_printk_object(object, xobject); | 195 | cachefiles_printk_object(object, xobject); |
200 | BUG(); | 196 | BUG(); |
201 | } | 197 | } |
@@ -241,9 +237,8 @@ wait_for_old_object: | |||
241 | } | 237 | } |
242 | 238 | ||
243 | if (timeout <= 0) { | 239 | if (timeout <= 0) { |
244 | printk(KERN_ERR "\n"); | 240 | pr_err("\n"); |
245 | printk(KERN_ERR "CacheFiles: Error: Overlong" | 241 | pr_err("Error: Overlong wait for old active object to go away\n"); |
246 | " wait for old active object to go away\n"); | ||
247 | cachefiles_printk_object(object, xobject); | 242 | cachefiles_printk_object(object, xobject); |
248 | goto requeue; | 243 | goto requeue; |
249 | } | 244 | } |
@@ -548,7 +543,7 @@ lookup_again: | |||
548 | next, next->d_inode, next->d_inode->i_ino); | 543 | next, next->d_inode, next->d_inode->i_ino); |
549 | 544 | ||
550 | } else if (!S_ISDIR(next->d_inode->i_mode)) { | 545 | } else if (!S_ISDIR(next->d_inode->i_mode)) { |
551 | kerror("inode %lu is not a directory", | 546 | pr_err("inode %lu is not a directory", |
552 | next->d_inode->i_ino); | 547 | next->d_inode->i_ino); |
553 | ret = -ENOBUFS; | 548 | ret = -ENOBUFS; |
554 | goto error; | 549 | goto error; |
@@ -579,7 +574,7 @@ lookup_again: | |||
579 | } else if (!S_ISDIR(next->d_inode->i_mode) && | 574 | } else if (!S_ISDIR(next->d_inode->i_mode) && |
580 | !S_ISREG(next->d_inode->i_mode) | 575 | !S_ISREG(next->d_inode->i_mode) |
581 | ) { | 576 | ) { |
582 | kerror("inode %lu is not a file or directory", | 577 | pr_err("inode %lu is not a file or directory", |
583 | next->d_inode->i_ino); | 578 | next->d_inode->i_ino); |
584 | ret = -ENOBUFS; | 579 | ret = -ENOBUFS; |
585 | goto error; | 580 | goto error; |
@@ -773,7 +768,7 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache, | |||
773 | ASSERT(subdir->d_inode); | 768 | ASSERT(subdir->d_inode); |
774 | 769 | ||
775 | if (!S_ISDIR(subdir->d_inode->i_mode)) { | 770 | if (!S_ISDIR(subdir->d_inode->i_mode)) { |
776 | kerror("%s is not a directory", dirname); | 771 | pr_err("%s is not a directory", dirname); |
777 | ret = -EIO; | 772 | ret = -EIO; |
778 | goto check_error; | 773 | goto check_error; |
779 | } | 774 | } |
@@ -800,13 +795,13 @@ check_error: | |||
800 | mkdir_error: | 795 | mkdir_error: |
801 | mutex_unlock(&dir->d_inode->i_mutex); | 796 | mutex_unlock(&dir->d_inode->i_mutex); |
802 | dput(subdir); | 797 | dput(subdir); |
803 | kerror("mkdir %s failed with error %d", dirname, ret); | 798 | pr_err("mkdir %s failed with error %d", dirname, ret); |
804 | return ERR_PTR(ret); | 799 | return ERR_PTR(ret); |
805 | 800 | ||
806 | lookup_error: | 801 | lookup_error: |
807 | mutex_unlock(&dir->d_inode->i_mutex); | 802 | mutex_unlock(&dir->d_inode->i_mutex); |
808 | ret = PTR_ERR(subdir); | 803 | ret = PTR_ERR(subdir); |
809 | kerror("Lookup %s failed with error %d", dirname, ret); | 804 | pr_err("Lookup %s failed with error %d", dirname, ret); |
810 | return ERR_PTR(ret); | 805 | return ERR_PTR(ret); |
811 | 806 | ||
812 | nomem_d_alloc: | 807 | nomem_d_alloc: |
@@ -896,7 +891,7 @@ lookup_error: | |||
896 | if (ret == -EIO) { | 891 | if (ret == -EIO) { |
897 | cachefiles_io_error(cache, "Lookup failed"); | 892 | cachefiles_io_error(cache, "Lookup failed"); |
898 | } else if (ret != -ENOMEM) { | 893 | } else if (ret != -ENOMEM) { |
899 | kerror("Internal error: %d", ret); | 894 | pr_err("Internal error: %d", ret); |
900 | ret = -EIO; | 895 | ret = -EIO; |
901 | } | 896 | } |
902 | 897 | ||
@@ -955,7 +950,7 @@ error: | |||
955 | } | 950 | } |
956 | 951 | ||
957 | if (ret != -ENOMEM) { | 952 | if (ret != -ENOMEM) { |
958 | kerror("Internal error: %d", ret); | 953 | pr_err("Internal error: %d", ret); |
959 | ret = -EIO; | 954 | ret = -EIO; |
960 | } | 955 | } |
961 | 956 | ||
diff --git a/fs/cachefiles/security.c b/fs/cachefiles/security.c index 039b5011d83b..396c18ea2764 100644 --- a/fs/cachefiles/security.c +++ b/fs/cachefiles/security.c | |||
@@ -34,9 +34,7 @@ int cachefiles_get_security_ID(struct cachefiles_cache *cache) | |||
34 | ret = set_security_override_from_ctx(new, cache->secctx); | 34 | ret = set_security_override_from_ctx(new, cache->secctx); |
35 | if (ret < 0) { | 35 | if (ret < 0) { |
36 | put_cred(new); | 36 | put_cred(new); |
37 | printk(KERN_ERR "CacheFiles:" | 37 | pr_err("Security denies permission to nominate security context: error %d\n", |
38 | " Security denies permission to nominate" | ||
39 | " security context: error %d\n", | ||
40 | ret); | 38 | ret); |
41 | goto error; | 39 | goto error; |
42 | } | 40 | } |
@@ -59,16 +57,14 @@ static int cachefiles_check_cache_dir(struct cachefiles_cache *cache, | |||
59 | 57 | ||
60 | ret = security_inode_mkdir(root->d_inode, root, 0); | 58 | ret = security_inode_mkdir(root->d_inode, root, 0); |
61 | if (ret < 0) { | 59 | if (ret < 0) { |
62 | printk(KERN_ERR "CacheFiles:" | 60 | pr_err("Security denies permission to make dirs: error %d", |
63 | " Security denies permission to make dirs: error %d", | ||
64 | ret); | 61 | ret); |
65 | return ret; | 62 | return ret; |
66 | } | 63 | } |
67 | 64 | ||
68 | ret = security_inode_create(root->d_inode, root, 0); | 65 | ret = security_inode_create(root->d_inode, root, 0); |
69 | if (ret < 0) | 66 | if (ret < 0) |
70 | printk(KERN_ERR "CacheFiles:" | 67 | pr_err("Security denies permission to create files: error %d", |
71 | " Security denies permission to create files: error %d", | ||
72 | ret); | 68 | ret); |
73 | 69 | ||
74 | return ret; | 70 | return ret; |
diff --git a/fs/cachefiles/xattr.c b/fs/cachefiles/xattr.c index 12b0eef84183..1ad51ffbb275 100644 --- a/fs/cachefiles/xattr.c +++ b/fs/cachefiles/xattr.c | |||
@@ -51,7 +51,7 @@ int cachefiles_check_object_type(struct cachefiles_object *object) | |||
51 | } | 51 | } |
52 | 52 | ||
53 | if (ret != -EEXIST) { | 53 | if (ret != -EEXIST) { |
54 | kerror("Can't set xattr on %*.*s [%lu] (err %d)", | 54 | pr_err("Can't set xattr on %*.*s [%lu] (err %d)", |
55 | dentry->d_name.len, dentry->d_name.len, | 55 | dentry->d_name.len, dentry->d_name.len, |
56 | dentry->d_name.name, dentry->d_inode->i_ino, | 56 | dentry->d_name.name, dentry->d_inode->i_ino, |
57 | -ret); | 57 | -ret); |
@@ -64,7 +64,7 @@ int cachefiles_check_object_type(struct cachefiles_object *object) | |||
64 | if (ret == -ERANGE) | 64 | if (ret == -ERANGE) |
65 | goto bad_type_length; | 65 | goto bad_type_length; |
66 | 66 | ||
67 | kerror("Can't read xattr on %*.*s [%lu] (err %d)", | 67 | pr_err("Can't read xattr on %*.*s [%lu] (err %d)", |
68 | dentry->d_name.len, dentry->d_name.len, | 68 | dentry->d_name.len, dentry->d_name.len, |
69 | dentry->d_name.name, dentry->d_inode->i_ino, | 69 | dentry->d_name.name, dentry->d_inode->i_ino, |
70 | -ret); | 70 | -ret); |
@@ -85,14 +85,14 @@ error: | |||
85 | return ret; | 85 | return ret; |
86 | 86 | ||
87 | bad_type_length: | 87 | bad_type_length: |
88 | kerror("Cache object %lu type xattr length incorrect", | 88 | pr_err("Cache object %lu type xattr length incorrect", |
89 | dentry->d_inode->i_ino); | 89 | dentry->d_inode->i_ino); |
90 | ret = -EIO; | 90 | ret = -EIO; |
91 | goto error; | 91 | goto error; |
92 | 92 | ||
93 | bad_type: | 93 | bad_type: |
94 | xtype[2] = 0; | 94 | xtype[2] = 0; |
95 | kerror("Cache object %*.*s [%lu] type %s not %s", | 95 | pr_err("Cache object %*.*s [%lu] type %s not %s", |
96 | dentry->d_name.len, dentry->d_name.len, | 96 | dentry->d_name.len, dentry->d_name.len, |
97 | dentry->d_name.name, dentry->d_inode->i_ino, | 97 | dentry->d_name.name, dentry->d_inode->i_ino, |
98 | xtype, type); | 98 | xtype, type); |
@@ -293,7 +293,7 @@ error: | |||
293 | return ret; | 293 | return ret; |
294 | 294 | ||
295 | bad_type_length: | 295 | bad_type_length: |
296 | kerror("Cache object %lu xattr length incorrect", | 296 | pr_err("Cache object %lu xattr length incorrect", |
297 | dentry->d_inode->i_ino); | 297 | dentry->d_inode->i_ino); |
298 | ret = -EIO; | 298 | ret = -EIO; |
299 | goto error; | 299 | goto error; |
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index b53278c9fd97..65a30e817dd8 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c | |||
@@ -694,7 +694,7 @@ static int ceph_writepages_start(struct address_space *mapping, | |||
694 | (wbc->sync_mode == WB_SYNC_ALL ? "ALL" : "HOLD")); | 694 | (wbc->sync_mode == WB_SYNC_ALL ? "ALL" : "HOLD")); |
695 | 695 | ||
696 | if (fsc->mount_state == CEPH_MOUNT_SHUTDOWN) { | 696 | if (fsc->mount_state == CEPH_MOUNT_SHUTDOWN) { |
697 | pr_warning("writepage_start %p on forced umount\n", inode); | 697 | pr_warn("writepage_start %p on forced umount\n", inode); |
698 | return -EIO; /* we're in a forced umount, don't write! */ | 698 | return -EIO; /* we're in a forced umount, don't write! */ |
699 | } | 699 | } |
700 | if (fsc->mount_options->wsize && fsc->mount_options->wsize < wsize) | 700 | if (fsc->mount_options->wsize && fsc->mount_options->wsize < wsize) |
diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c index 16b54aa31f08..5a743ac141ab 100644 --- a/fs/ceph/debugfs.c +++ b/fs/ceph/debugfs.c | |||
@@ -71,9 +71,9 @@ static int mdsc_show(struct seq_file *s, void *p) | |||
71 | seq_printf(s, "%s", ceph_mds_op_name(req->r_op)); | 71 | seq_printf(s, "%s", ceph_mds_op_name(req->r_op)); |
72 | 72 | ||
73 | if (req->r_got_unsafe) | 73 | if (req->r_got_unsafe) |
74 | seq_printf(s, "\t(unsafe)"); | 74 | seq_puts(s, "\t(unsafe)"); |
75 | else | 75 | else |
76 | seq_printf(s, "\t"); | 76 | seq_puts(s, "\t"); |
77 | 77 | ||
78 | if (req->r_inode) { | 78 | if (req->r_inode) { |
79 | seq_printf(s, " #%llx", ceph_ino(req->r_inode)); | 79 | seq_printf(s, " #%llx", ceph_ino(req->r_inode)); |
@@ -119,7 +119,7 @@ static int mdsc_show(struct seq_file *s, void *p) | |||
119 | seq_printf(s, " %s", req->r_path2); | 119 | seq_printf(s, " %s", req->r_path2); |
120 | } | 120 | } |
121 | 121 | ||
122 | seq_printf(s, "\n"); | 122 | seq_puts(s, "\n"); |
123 | } | 123 | } |
124 | mutex_unlock(&mdsc->mutex); | 124 | mutex_unlock(&mdsc->mutex); |
125 | 125 | ||
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 233c6f96910a..e4fff9ff1c27 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c | |||
@@ -821,7 +821,7 @@ no_change: | |||
821 | spin_unlock(&ci->i_ceph_lock); | 821 | spin_unlock(&ci->i_ceph_lock); |
822 | } | 822 | } |
823 | } else if (cap_fmode >= 0) { | 823 | } else if (cap_fmode >= 0) { |
824 | pr_warning("mds issued no caps on %llx.%llx\n", | 824 | pr_warn("mds issued no caps on %llx.%llx\n", |
825 | ceph_vinop(inode)); | 825 | ceph_vinop(inode)); |
826 | __ceph_get_fmode(ci, cap_fmode); | 826 | __ceph_get_fmode(ci, cap_fmode); |
827 | } | 827 | } |
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 2b4d093d0563..9a33b98cb000 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -2218,13 +2218,13 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg) | |||
2218 | /* dup? */ | 2218 | /* dup? */ |
2219 | if ((req->r_got_unsafe && !head->safe) || | 2219 | if ((req->r_got_unsafe && !head->safe) || |
2220 | (req->r_got_safe && head->safe)) { | 2220 | (req->r_got_safe && head->safe)) { |
2221 | pr_warning("got a dup %s reply on %llu from mds%d\n", | 2221 | pr_warn("got a dup %s reply on %llu from mds%d\n", |
2222 | head->safe ? "safe" : "unsafe", tid, mds); | 2222 | head->safe ? "safe" : "unsafe", tid, mds); |
2223 | mutex_unlock(&mdsc->mutex); | 2223 | mutex_unlock(&mdsc->mutex); |
2224 | goto out; | 2224 | goto out; |
2225 | } | 2225 | } |
2226 | if (req->r_got_safe && !head->safe) { | 2226 | if (req->r_got_safe && !head->safe) { |
2227 | pr_warning("got unsafe after safe on %llu from mds%d\n", | 2227 | pr_warn("got unsafe after safe on %llu from mds%d\n", |
2228 | tid, mds); | 2228 | tid, mds); |
2229 | mutex_unlock(&mdsc->mutex); | 2229 | mutex_unlock(&mdsc->mutex); |
2230 | goto out; | 2230 | goto out; |
@@ -3525,7 +3525,7 @@ static void peer_reset(struct ceph_connection *con) | |||
3525 | struct ceph_mds_session *s = con->private; | 3525 | struct ceph_mds_session *s = con->private; |
3526 | struct ceph_mds_client *mdsc = s->s_mdsc; | 3526 | struct ceph_mds_client *mdsc = s->s_mdsc; |
3527 | 3527 | ||
3528 | pr_warning("mds%d closed our session\n", s->s_mds); | 3528 | pr_warn("mds%d closed our session\n", s->s_mds); |
3529 | send_mds_reconnect(mdsc, s); | 3529 | send_mds_reconnect(mdsc, s); |
3530 | } | 3530 | } |
3531 | 3531 | ||
diff --git a/fs/ceph/mdsmap.c b/fs/ceph/mdsmap.c index 132b64eeecd4..261531e55e9d 100644 --- a/fs/ceph/mdsmap.c +++ b/fs/ceph/mdsmap.c | |||
@@ -62,7 +62,7 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end) | |||
62 | 62 | ||
63 | ceph_decode_16_safe(p, end, version, bad); | 63 | ceph_decode_16_safe(p, end, version, bad); |
64 | if (version > 3) { | 64 | if (version > 3) { |
65 | pr_warning("got mdsmap version %d > 3, failing", version); | 65 | pr_warn("got mdsmap version %d > 3, failing", version); |
66 | goto bad; | 66 | goto bad; |
67 | } | 67 | } |
68 | 68 | ||
diff --git a/fs/coda/cnode.c b/fs/coda/cnode.c index 911cf30d057d..7740b1c871c1 100644 --- a/fs/coda/cnode.c +++ b/fs/coda/cnode.c | |||
@@ -101,7 +101,7 @@ struct inode *coda_cnode_make(struct CodaFid *fid, struct super_block *sb) | |||
101 | 101 | ||
102 | inode = coda_iget(sb, fid, &attr); | 102 | inode = coda_iget(sb, fid, &attr); |
103 | if (IS_ERR(inode)) | 103 | if (IS_ERR(inode)) |
104 | printk("coda_cnode_make: coda_iget failed\n"); | 104 | pr_warn("%s: coda_iget failed\n", __func__); |
105 | return inode; | 105 | return inode; |
106 | } | 106 | } |
107 | 107 | ||
@@ -137,7 +137,7 @@ struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb) | |||
137 | unsigned long hash = coda_f2i(fid); | 137 | unsigned long hash = coda_f2i(fid); |
138 | 138 | ||
139 | if ( !sb ) { | 139 | if ( !sb ) { |
140 | printk("coda_fid_to_inode: no sb!\n"); | 140 | pr_warn("%s: no sb!\n", __func__); |
141 | return NULL; | 141 | return NULL; |
142 | } | 142 | } |
143 | 143 | ||
diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h index e7550cb9fb74..d42b725b1d21 100644 --- a/fs/coda/coda_linux.h +++ b/fs/coda/coda_linux.h | |||
@@ -12,6 +12,12 @@ | |||
12 | #ifndef _LINUX_CODA_FS | 12 | #ifndef _LINUX_CODA_FS |
13 | #define _LINUX_CODA_FS | 13 | #define _LINUX_CODA_FS |
14 | 14 | ||
15 | #ifdef pr_fmt | ||
16 | #undef pr_fmt | ||
17 | #endif | ||
18 | |||
19 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
20 | |||
15 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
16 | #include <linux/param.h> | 22 | #include <linux/param.h> |
17 | #include <linux/mm.h> | 23 | #include <linux/mm.h> |
@@ -63,7 +69,7 @@ void coda_sysctl_clean(void); | |||
63 | else \ | 69 | else \ |
64 | ptr = (cast)vzalloc((unsigned long) size); \ | 70 | ptr = (cast)vzalloc((unsigned long) size); \ |
65 | if (!ptr) \ | 71 | if (!ptr) \ |
66 | printk("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \ | 72 | pr_warn("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \ |
67 | } while (0) | 73 | } while (0) |
68 | 74 | ||
69 | 75 | ||
diff --git a/fs/coda/dir.c b/fs/coda/dir.c index 5efbb5ee0adc..cd8a63238b11 100644 --- a/fs/coda/dir.c +++ b/fs/coda/dir.c | |||
@@ -102,7 +102,7 @@ static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, unsig | |||
102 | int type = 0; | 102 | int type = 0; |
103 | 103 | ||
104 | if (length > CODA_MAXNAMLEN) { | 104 | if (length > CODA_MAXNAMLEN) { |
105 | printk(KERN_ERR "name too long: lookup, %s (%*s)\n", | 105 | pr_err("name too long: lookup, %s (%*s)\n", |
106 | coda_i2s(dir), (int)length, name); | 106 | coda_i2s(dir), (int)length, name); |
107 | return ERR_PTR(-ENAMETOOLONG); | 107 | return ERR_PTR(-ENAMETOOLONG); |
108 | } | 108 | } |
@@ -453,23 +453,23 @@ static int coda_venus_readdir(struct file *coda_file, struct dir_context *ctx) | |||
453 | ret = kernel_read(host_file, ctx->pos - 2, (char *)vdir, | 453 | ret = kernel_read(host_file, ctx->pos - 2, (char *)vdir, |
454 | sizeof(*vdir)); | 454 | sizeof(*vdir)); |
455 | if (ret < 0) { | 455 | if (ret < 0) { |
456 | printk(KERN_ERR "coda readdir: read dir %s failed %d\n", | 456 | pr_err("%s: read dir %s failed %d\n", |
457 | coda_f2s(&cii->c_fid), ret); | 457 | __func__, coda_f2s(&cii->c_fid), ret); |
458 | break; | 458 | break; |
459 | } | 459 | } |
460 | if (ret == 0) break; /* end of directory file reached */ | 460 | if (ret == 0) break; /* end of directory file reached */ |
461 | 461 | ||
462 | /* catch truncated reads */ | 462 | /* catch truncated reads */ |
463 | if (ret < vdir_size || ret < vdir_size + vdir->d_namlen) { | 463 | if (ret < vdir_size || ret < vdir_size + vdir->d_namlen) { |
464 | printk(KERN_ERR "coda readdir: short read on %s\n", | 464 | pr_err("%s: short read on %s\n", |
465 | coda_f2s(&cii->c_fid)); | 465 | __func__, coda_f2s(&cii->c_fid)); |
466 | ret = -EBADF; | 466 | ret = -EBADF; |
467 | break; | 467 | break; |
468 | } | 468 | } |
469 | /* validate whether the directory file actually makes sense */ | 469 | /* validate whether the directory file actually makes sense */ |
470 | if (vdir->d_reclen < vdir_size + vdir->d_namlen) { | 470 | if (vdir->d_reclen < vdir_size + vdir->d_namlen) { |
471 | printk(KERN_ERR "coda readdir: invalid dir %s\n", | 471 | pr_err("%s: invalid dir %s\n", |
472 | coda_f2s(&cii->c_fid)); | 472 | __func__, coda_f2s(&cii->c_fid)); |
473 | ret = -EBADF; | 473 | ret = -EBADF; |
474 | break; | 474 | break; |
475 | } | 475 | } |
@@ -589,8 +589,8 @@ int coda_revalidate_inode(struct inode *inode) | |||
589 | coda_vattr_to_iattr(inode, &attr); | 589 | coda_vattr_to_iattr(inode, &attr); |
590 | 590 | ||
591 | if ((old_mode & S_IFMT) != (inode->i_mode & S_IFMT)) { | 591 | if ((old_mode & S_IFMT) != (inode->i_mode & S_IFMT)) { |
592 | printk("Coda: inode %ld, fid %s changed type!\n", | 592 | pr_warn("inode %ld, fid %s changed type!\n", |
593 | inode->i_ino, coda_f2s(&(cii->c_fid))); | 593 | inode->i_ino, coda_f2s(&(cii->c_fid))); |
594 | } | 594 | } |
595 | 595 | ||
596 | /* the following can happen when a local fid is replaced | 596 | /* the following can happen when a local fid is replaced |
diff --git a/fs/coda/inode.c b/fs/coda/inode.c index d9c7751f10ac..fe3afb2de880 100644 --- a/fs/coda/inode.c +++ b/fs/coda/inode.c | |||
@@ -119,12 +119,12 @@ static int get_device_index(struct coda_mount_data *data) | |||
119 | int idx; | 119 | int idx; |
120 | 120 | ||
121 | if (data == NULL) { | 121 | if (data == NULL) { |
122 | printk("coda_read_super: Bad mount data\n"); | 122 | pr_warn("%s: Bad mount data\n", __func__); |
123 | return -1; | 123 | return -1; |
124 | } | 124 | } |
125 | 125 | ||
126 | if (data->version != CODA_MOUNT_VERSION) { | 126 | if (data->version != CODA_MOUNT_VERSION) { |
127 | printk("coda_read_super: Bad mount version\n"); | 127 | pr_warn("%s: Bad mount version\n", __func__); |
128 | return -1; | 128 | return -1; |
129 | } | 129 | } |
130 | 130 | ||
@@ -141,13 +141,13 @@ static int get_device_index(struct coda_mount_data *data) | |||
141 | fdput(f); | 141 | fdput(f); |
142 | 142 | ||
143 | if (idx < 0 || idx >= MAX_CODADEVS) { | 143 | if (idx < 0 || idx >= MAX_CODADEVS) { |
144 | printk("coda_read_super: Bad minor number\n"); | 144 | pr_warn("%s: Bad minor number\n", __func__); |
145 | return -1; | 145 | return -1; |
146 | } | 146 | } |
147 | 147 | ||
148 | return idx; | 148 | return idx; |
149 | Ebadf: | 149 | Ebadf: |
150 | printk("coda_read_super: Bad file\n"); | 150 | pr_warn("%s: Bad file\n", __func__); |
151 | return -1; | 151 | return -1; |
152 | } | 152 | } |
153 | 153 | ||
@@ -168,19 +168,19 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent) | |||
168 | if(idx == -1) | 168 | if(idx == -1) |
169 | idx = 0; | 169 | idx = 0; |
170 | 170 | ||
171 | printk(KERN_INFO "coda_read_super: device index: %i\n", idx); | 171 | pr_info("%s: device index: %i\n", __func__, idx); |
172 | 172 | ||
173 | vc = &coda_comms[idx]; | 173 | vc = &coda_comms[idx]; |
174 | mutex_lock(&vc->vc_mutex); | 174 | mutex_lock(&vc->vc_mutex); |
175 | 175 | ||
176 | if (!vc->vc_inuse) { | 176 | if (!vc->vc_inuse) { |
177 | printk("coda_read_super: No pseudo device\n"); | 177 | pr_warn("%s: No pseudo device\n", __func__); |
178 | error = -EINVAL; | 178 | error = -EINVAL; |
179 | goto unlock_out; | 179 | goto unlock_out; |
180 | } | 180 | } |
181 | 181 | ||
182 | if (vc->vc_sb) { | 182 | if (vc->vc_sb) { |
183 | printk("coda_read_super: Device already mounted\n"); | 183 | pr_warn("%s: Device already mounted\n", __func__); |
184 | error = -EBUSY; | 184 | error = -EBUSY; |
185 | goto unlock_out; | 185 | goto unlock_out; |
186 | } | 186 | } |
@@ -204,22 +204,23 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent) | |||
204 | /* get root fid from Venus: this needs the root inode */ | 204 | /* get root fid from Venus: this needs the root inode */ |
205 | error = venus_rootfid(sb, &fid); | 205 | error = venus_rootfid(sb, &fid); |
206 | if ( error ) { | 206 | if ( error ) { |
207 | printk("coda_read_super: coda_get_rootfid failed with %d\n", | 207 | pr_warn("%s: coda_get_rootfid failed with %d\n", |
208 | error); | 208 | __func__, error); |
209 | goto error; | 209 | goto error; |
210 | } | 210 | } |
211 | printk("coda_read_super: rootfid is %s\n", coda_f2s(&fid)); | 211 | pr_info("%s: rootfid is %s\n", __func__, coda_f2s(&fid)); |
212 | 212 | ||
213 | /* make root inode */ | 213 | /* make root inode */ |
214 | root = coda_cnode_make(&fid, sb); | 214 | root = coda_cnode_make(&fid, sb); |
215 | if (IS_ERR(root)) { | 215 | if (IS_ERR(root)) { |
216 | error = PTR_ERR(root); | 216 | error = PTR_ERR(root); |
217 | printk("Failure of coda_cnode_make for root: error %d\n", error); | 217 | pr_warn("Failure of coda_cnode_make for root: error %d\n", |
218 | error); | ||
218 | goto error; | 219 | goto error; |
219 | } | 220 | } |
220 | 221 | ||
221 | printk("coda_read_super: rootinode is %ld dev %s\n", | 222 | pr_info("%s: rootinode is %ld dev %s\n", |
222 | root->i_ino, root->i_sb->s_id); | 223 | __func__, root->i_ino, root->i_sb->s_id); |
223 | sb->s_root = d_make_root(root); | 224 | sb->s_root = d_make_root(root); |
224 | if (!sb->s_root) { | 225 | if (!sb->s_root) { |
225 | error = -EINVAL; | 226 | error = -EINVAL; |
@@ -246,7 +247,7 @@ static void coda_put_super(struct super_block *sb) | |||
246 | sb->s_fs_info = NULL; | 247 | sb->s_fs_info = NULL; |
247 | mutex_unlock(&vcp->vc_mutex); | 248 | mutex_unlock(&vcp->vc_mutex); |
248 | 249 | ||
249 | printk("Coda: Bye bye.\n"); | 250 | pr_info("Bye bye.\n"); |
250 | } | 251 | } |
251 | 252 | ||
252 | static void coda_evict_inode(struct inode *inode) | 253 | static void coda_evict_inode(struct inode *inode) |
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c index ebc2bae6c289..5c1e4242368b 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c | |||
@@ -114,14 +114,14 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf, | |||
114 | int size = sizeof(*dcbuf); | 114 | int size = sizeof(*dcbuf); |
115 | 115 | ||
116 | if ( nbytes < sizeof(struct coda_out_hdr) ) { | 116 | if ( nbytes < sizeof(struct coda_out_hdr) ) { |
117 | printk("coda_downcall opc %d uniq %d, not enough!\n", | 117 | pr_warn("coda_downcall opc %d uniq %d, not enough!\n", |
118 | hdr.opcode, hdr.unique); | 118 | hdr.opcode, hdr.unique); |
119 | count = nbytes; | 119 | count = nbytes; |
120 | goto out; | 120 | goto out; |
121 | } | 121 | } |
122 | if ( nbytes > size ) { | 122 | if ( nbytes > size ) { |
123 | printk("Coda: downcall opc %d, uniq %d, too much!", | 123 | pr_warn("downcall opc %d, uniq %d, too much!", |
124 | hdr.opcode, hdr.unique); | 124 | hdr.opcode, hdr.unique); |
125 | nbytes = size; | 125 | nbytes = size; |
126 | } | 126 | } |
127 | CODA_ALLOC(dcbuf, union outputArgs *, nbytes); | 127 | CODA_ALLOC(dcbuf, union outputArgs *, nbytes); |
@@ -136,7 +136,8 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf, | |||
136 | 136 | ||
137 | CODA_FREE(dcbuf, nbytes); | 137 | CODA_FREE(dcbuf, nbytes); |
138 | if (error) { | 138 | if (error) { |
139 | printk("psdev_write: coda_downcall error: %d\n", error); | 139 | pr_warn("%s: coda_downcall error: %d\n", |
140 | __func__, error); | ||
140 | retval = error; | 141 | retval = error; |
141 | goto out; | 142 | goto out; |
142 | } | 143 | } |
@@ -157,16 +158,17 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf, | |||
157 | mutex_unlock(&vcp->vc_mutex); | 158 | mutex_unlock(&vcp->vc_mutex); |
158 | 159 | ||
159 | if (!req) { | 160 | if (!req) { |
160 | printk("psdev_write: msg (%d, %d) not found\n", | 161 | pr_warn("%s: msg (%d, %d) not found\n", |
161 | hdr.opcode, hdr.unique); | 162 | __func__, hdr.opcode, hdr.unique); |
162 | retval = -ESRCH; | 163 | retval = -ESRCH; |
163 | goto out; | 164 | goto out; |
164 | } | 165 | } |
165 | 166 | ||
166 | /* move data into response buffer. */ | 167 | /* move data into response buffer. */ |
167 | if (req->uc_outSize < nbytes) { | 168 | if (req->uc_outSize < nbytes) { |
168 | printk("psdev_write: too much cnt: %d, cnt: %ld, opc: %d, uniq: %d.\n", | 169 | pr_warn("%s: too much cnt: %d, cnt: %ld, opc: %d, uniq: %d.\n", |
169 | req->uc_outSize, (long)nbytes, hdr.opcode, hdr.unique); | 170 | __func__, req->uc_outSize, (long)nbytes, |
171 | hdr.opcode, hdr.unique); | ||
170 | nbytes = req->uc_outSize; /* don't have more space! */ | 172 | nbytes = req->uc_outSize; /* don't have more space! */ |
171 | } | 173 | } |
172 | if (copy_from_user(req->uc_data, buf, nbytes)) { | 174 | if (copy_from_user(req->uc_data, buf, nbytes)) { |
@@ -240,8 +242,8 @@ static ssize_t coda_psdev_read(struct file * file, char __user * buf, | |||
240 | /* Move the input args into userspace */ | 242 | /* Move the input args into userspace */ |
241 | count = req->uc_inSize; | 243 | count = req->uc_inSize; |
242 | if (nbytes < req->uc_inSize) { | 244 | if (nbytes < req->uc_inSize) { |
243 | printk ("psdev_read: Venus read %ld bytes of %d in message\n", | 245 | pr_warn("%s: Venus read %ld bytes of %d in message\n", |
244 | (long)nbytes, req->uc_inSize); | 246 | __func__, (long)nbytes, req->uc_inSize); |
245 | count = nbytes; | 247 | count = nbytes; |
246 | } | 248 | } |
247 | 249 | ||
@@ -305,7 +307,7 @@ static int coda_psdev_release(struct inode * inode, struct file * file) | |||
305 | struct upc_req *req, *tmp; | 307 | struct upc_req *req, *tmp; |
306 | 308 | ||
307 | if (!vcp || !vcp->vc_inuse ) { | 309 | if (!vcp || !vcp->vc_inuse ) { |
308 | printk("psdev_release: Not open.\n"); | 310 | pr_warn("%s: Not open.\n", __func__); |
309 | return -1; | 311 | return -1; |
310 | } | 312 | } |
311 | 313 | ||
@@ -354,8 +356,8 @@ static int init_coda_psdev(void) | |||
354 | { | 356 | { |
355 | int i, err = 0; | 357 | int i, err = 0; |
356 | if (register_chrdev(CODA_PSDEV_MAJOR, "coda", &coda_psdev_fops)) { | 358 | if (register_chrdev(CODA_PSDEV_MAJOR, "coda", &coda_psdev_fops)) { |
357 | printk(KERN_ERR "coda_psdev: unable to get major %d\n", | 359 | pr_err("%s: unable to get major %d\n", |
358 | CODA_PSDEV_MAJOR); | 360 | __func__, CODA_PSDEV_MAJOR); |
359 | return -EIO; | 361 | return -EIO; |
360 | } | 362 | } |
361 | coda_psdev_class = class_create(THIS_MODULE, "coda"); | 363 | coda_psdev_class = class_create(THIS_MODULE, "coda"); |
@@ -393,13 +395,13 @@ static int __init init_coda(void) | |||
393 | goto out2; | 395 | goto out2; |
394 | status = init_coda_psdev(); | 396 | status = init_coda_psdev(); |
395 | if ( status ) { | 397 | if ( status ) { |
396 | printk("Problem (%d) in init_coda_psdev\n", status); | 398 | pr_warn("Problem (%d) in init_coda_psdev\n", status); |
397 | goto out1; | 399 | goto out1; |
398 | } | 400 | } |
399 | 401 | ||
400 | status = register_filesystem(&coda_fs_type); | 402 | status = register_filesystem(&coda_fs_type); |
401 | if (status) { | 403 | if (status) { |
402 | printk("coda: failed to register filesystem!\n"); | 404 | pr_warn("failed to register filesystem!\n"); |
403 | goto out; | 405 | goto out; |
404 | } | 406 | } |
405 | return 0; | 407 | return 0; |
@@ -420,9 +422,8 @@ static void __exit exit_coda(void) | |||
420 | int err, i; | 422 | int err, i; |
421 | 423 | ||
422 | err = unregister_filesystem(&coda_fs_type); | 424 | err = unregister_filesystem(&coda_fs_type); |
423 | if ( err != 0 ) { | 425 | if (err != 0) |
424 | printk("coda: failed to unregister filesystem\n"); | 426 | pr_warn("failed to unregister filesystem\n"); |
425 | } | ||
426 | for (i = 0; i < MAX_CODADEVS; i++) | 427 | for (i = 0; i < MAX_CODADEVS; i++) |
427 | device_destroy(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR, i)); | 428 | device_destroy(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR, i)); |
428 | class_destroy(coda_psdev_class); | 429 | class_destroy(coda_psdev_class); |
diff --git a/fs/coda/sysctl.c b/fs/coda/sysctl.c index af56ad56a89a..34218a8a28cd 100644 --- a/fs/coda/sysctl.c +++ b/fs/coda/sysctl.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #ifdef CONFIG_SYSCTL | 14 | #ifdef CONFIG_SYSCTL |
15 | static struct ctl_table_header *fs_table_header; | 15 | static struct ctl_table_header *fs_table_header; |
16 | 16 | ||
17 | static ctl_table coda_table[] = { | 17 | static struct ctl_table coda_table[] = { |
18 | { | 18 | { |
19 | .procname = "timeout", | 19 | .procname = "timeout", |
20 | .data = &coda_timeout, | 20 | .data = &coda_timeout, |
@@ -39,7 +39,7 @@ static ctl_table coda_table[] = { | |||
39 | {} | 39 | {} |
40 | }; | 40 | }; |
41 | 41 | ||
42 | static ctl_table fs_table[] = { | 42 | static struct ctl_table fs_table[] = { |
43 | { | 43 | { |
44 | .procname = "coda", | 44 | .procname = "coda", |
45 | .mode = 0555, | 45 | .mode = 0555, |
diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c index 3a731976dc5e..21fcf8dcb9cd 100644 --- a/fs/coda/upcall.c +++ b/fs/coda/upcall.c | |||
@@ -508,8 +508,8 @@ int venus_pioctl(struct super_block *sb, struct CodaFid *fid, | |||
508 | inp->coda_ioctl.data = (char *)(INSIZE(ioctl)); | 508 | inp->coda_ioctl.data = (char *)(INSIZE(ioctl)); |
509 | 509 | ||
510 | /* get the data out of user space */ | 510 | /* get the data out of user space */ |
511 | if ( copy_from_user((char*)inp + (long)inp->coda_ioctl.data, | 511 | if (copy_from_user((char *)inp + (long)inp->coda_ioctl.data, |
512 | data->vi.in, data->vi.in_size) ) { | 512 | data->vi.in, data->vi.in_size)) { |
513 | error = -EINVAL; | 513 | error = -EINVAL; |
514 | goto exit; | 514 | goto exit; |
515 | } | 515 | } |
@@ -518,8 +518,8 @@ int venus_pioctl(struct super_block *sb, struct CodaFid *fid, | |||
518 | &outsize, inp); | 518 | &outsize, inp); |
519 | 519 | ||
520 | if (error) { | 520 | if (error) { |
521 | printk("coda_pioctl: Venus returns: %d for %s\n", | 521 | pr_warn("%s: Venus returns: %d for %s\n", |
522 | error, coda_f2s(fid)); | 522 | __func__, error, coda_f2s(fid)); |
523 | goto exit; | 523 | goto exit; |
524 | } | 524 | } |
525 | 525 | ||
@@ -675,7 +675,7 @@ static int coda_upcall(struct venus_comm *vcp, | |||
675 | mutex_lock(&vcp->vc_mutex); | 675 | mutex_lock(&vcp->vc_mutex); |
676 | 676 | ||
677 | if (!vcp->vc_inuse) { | 677 | if (!vcp->vc_inuse) { |
678 | printk(KERN_NOTICE "coda: Venus dead, not sending upcall\n"); | 678 | pr_notice("Venus dead, not sending upcall\n"); |
679 | error = -ENXIO; | 679 | error = -ENXIO; |
680 | goto exit; | 680 | goto exit; |
681 | } | 681 | } |
@@ -725,7 +725,7 @@ static int coda_upcall(struct venus_comm *vcp, | |||
725 | 725 | ||
726 | error = -EINTR; | 726 | error = -EINTR; |
727 | if ((req->uc_flags & CODA_REQ_ABORT) || !signal_pending(current)) { | 727 | if ((req->uc_flags & CODA_REQ_ABORT) || !signal_pending(current)) { |
728 | printk(KERN_WARNING "coda: Unexpected interruption.\n"); | 728 | pr_warn("Unexpected interruption.\n"); |
729 | goto exit; | 729 | goto exit; |
730 | } | 730 | } |
731 | 731 | ||
@@ -735,7 +735,7 @@ static int coda_upcall(struct venus_comm *vcp, | |||
735 | 735 | ||
736 | /* Venus saw the upcall, make sure we can send interrupt signal */ | 736 | /* Venus saw the upcall, make sure we can send interrupt signal */ |
737 | if (!vcp->vc_inuse) { | 737 | if (!vcp->vc_inuse) { |
738 | printk(KERN_INFO "coda: Venus dead, not sending signal.\n"); | 738 | pr_info("Venus dead, not sending signal.\n"); |
739 | goto exit; | 739 | goto exit; |
740 | } | 740 | } |
741 | 741 | ||
diff --git a/fs/dcache.c b/fs/dcache.c index be2bea834bf4..1792d6075b4f 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -150,7 +150,7 @@ static long get_nr_dentry_unused(void) | |||
150 | return sum < 0 ? 0 : sum; | 150 | return sum < 0 ? 0 : sum; |
151 | } | 151 | } |
152 | 152 | ||
153 | int proc_nr_dentry(ctl_table *table, int write, void __user *buffer, | 153 | int proc_nr_dentry(struct ctl_table *table, int write, void __user *buffer, |
154 | size_t *lenp, loff_t *ppos) | 154 | size_t *lenp, loff_t *ppos) |
155 | { | 155 | { |
156 | dentry_stat.nr_dentry = get_nr_dentry(); | 156 | dentry_stat.nr_dentry = get_nr_dentry(); |
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index c71038079b47..cfe8466f7fef 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c | |||
@@ -10,6 +10,8 @@ | |||
10 | * | 10 | * |
11 | * ------------------------------------------------------------------------- */ | 11 | * ------------------------------------------------------------------------- */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
13 | #include <linux/module.h> | 15 | #include <linux/module.h> |
14 | #include <linux/init.h> | 16 | #include <linux/init.h> |
15 | #include <linux/fs.h> | 17 | #include <linux/fs.h> |
@@ -148,10 +150,10 @@ static inline struct super_block *pts_sb_from_inode(struct inode *inode) | |||
148 | 150 | ||
149 | /* | 151 | /* |
150 | * parse_mount_options(): | 152 | * parse_mount_options(): |
151 | * Set @opts to mount options specified in @data. If an option is not | 153 | * Set @opts to mount options specified in @data. If an option is not |
152 | * specified in @data, set it to its default value. The exception is | 154 | * specified in @data, set it to its default value. The exception is |
153 | * 'newinstance' option which can only be set/cleared on a mount (i.e. | 155 | * 'newinstance' option which can only be set/cleared on a mount (i.e. |
154 | * cannot be changed during remount). | 156 | * cannot be changed during remount). |
155 | * | 157 | * |
156 | * Note: @data may be NULL (in which case all options are set to default). | 158 | * Note: @data may be NULL (in which case all options are set to default). |
157 | */ | 159 | */ |
@@ -225,7 +227,7 @@ static int parse_mount_options(char *data, int op, struct pts_mount_opts *opts) | |||
225 | break; | 227 | break; |
226 | #endif | 228 | #endif |
227 | default: | 229 | default: |
228 | printk(KERN_ERR "devpts: called with bogus options\n"); | 230 | pr_err("called with bogus options\n"); |
229 | return -EINVAL; | 231 | return -EINVAL; |
230 | } | 232 | } |
231 | } | 233 | } |
@@ -261,7 +263,7 @@ static int mknod_ptmx(struct super_block *sb) | |||
261 | 263 | ||
262 | dentry = d_alloc_name(root, "ptmx"); | 264 | dentry = d_alloc_name(root, "ptmx"); |
263 | if (!dentry) { | 265 | if (!dentry) { |
264 | printk(KERN_NOTICE "Unable to alloc dentry for ptmx node\n"); | 266 | pr_err("Unable to alloc dentry for ptmx node\n"); |
265 | goto out; | 267 | goto out; |
266 | } | 268 | } |
267 | 269 | ||
@@ -270,7 +272,7 @@ static int mknod_ptmx(struct super_block *sb) | |||
270 | */ | 272 | */ |
271 | inode = new_inode(sb); | 273 | inode = new_inode(sb); |
272 | if (!inode) { | 274 | if (!inode) { |
273 | printk(KERN_ERR "Unable to alloc inode for ptmx node\n"); | 275 | pr_err("Unable to alloc inode for ptmx node\n"); |
274 | dput(dentry); | 276 | dput(dentry); |
275 | goto out; | 277 | goto out; |
276 | } | 278 | } |
@@ -303,7 +305,7 @@ static void update_ptmx_mode(struct pts_fs_info *fsi) | |||
303 | #else | 305 | #else |
304 | static inline void update_ptmx_mode(struct pts_fs_info *fsi) | 306 | static inline void update_ptmx_mode(struct pts_fs_info *fsi) |
305 | { | 307 | { |
306 | return; | 308 | return; |
307 | } | 309 | } |
308 | #endif | 310 | #endif |
309 | 311 | ||
@@ -333,9 +335,11 @@ static int devpts_show_options(struct seq_file *seq, struct dentry *root) | |||
333 | struct pts_mount_opts *opts = &fsi->mount_opts; | 335 | struct pts_mount_opts *opts = &fsi->mount_opts; |
334 | 336 | ||
335 | if (opts->setuid) | 337 | if (opts->setuid) |
336 | seq_printf(seq, ",uid=%u", from_kuid_munged(&init_user_ns, opts->uid)); | 338 | seq_printf(seq, ",uid=%u", |
339 | from_kuid_munged(&init_user_ns, opts->uid)); | ||
337 | if (opts->setgid) | 340 | if (opts->setgid) |
338 | seq_printf(seq, ",gid=%u", from_kgid_munged(&init_user_ns, opts->gid)); | 341 | seq_printf(seq, ",gid=%u", |
342 | from_kgid_munged(&init_user_ns, opts->gid)); | ||
339 | seq_printf(seq, ",mode=%03o", opts->mode); | 343 | seq_printf(seq, ",mode=%03o", opts->mode); |
340 | #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES | 344 | #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES |
341 | seq_printf(seq, ",ptmxmode=%03o", opts->ptmxmode); | 345 | seq_printf(seq, ",ptmxmode=%03o", opts->ptmxmode); |
@@ -396,7 +400,7 @@ devpts_fill_super(struct super_block *s, void *data, int silent) | |||
396 | if (s->s_root) | 400 | if (s->s_root) |
397 | return 0; | 401 | return 0; |
398 | 402 | ||
399 | printk(KERN_ERR "devpts: get root dentry failed\n"); | 403 | pr_err("get root dentry failed\n"); |
400 | 404 | ||
401 | fail: | 405 | fail: |
402 | return -ENOMEM; | 406 | return -ENOMEM; |
diff --git a/fs/dlm/config.c b/fs/dlm/config.c index 76feb4b60fa6..d521bddf876d 100644 --- a/fs/dlm/config.c +++ b/fs/dlm/config.c | |||
@@ -157,11 +157,13 @@ static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field, | |||
157 | const char *buf, size_t len) | 157 | const char *buf, size_t len) |
158 | { | 158 | { |
159 | unsigned int x; | 159 | unsigned int x; |
160 | int rc; | ||
160 | 161 | ||
161 | if (!capable(CAP_SYS_ADMIN)) | 162 | if (!capable(CAP_SYS_ADMIN)) |
162 | return -EPERM; | 163 | return -EPERM; |
163 | 164 | rc = kstrtouint(buf, 0, &x); | |
164 | x = simple_strtoul(buf, NULL, 0); | 165 | if (rc) |
166 | return rc; | ||
165 | 167 | ||
166 | if (check_zero && !x) | 168 | if (check_zero && !x) |
167 | return -EINVAL; | 169 | return -EINVAL; |
@@ -730,7 +732,10 @@ static ssize_t comm_nodeid_read(struct dlm_comm *cm, char *buf) | |||
730 | static ssize_t comm_nodeid_write(struct dlm_comm *cm, const char *buf, | 732 | static ssize_t comm_nodeid_write(struct dlm_comm *cm, const char *buf, |
731 | size_t len) | 733 | size_t len) |
732 | { | 734 | { |
733 | cm->nodeid = simple_strtol(buf, NULL, 0); | 735 | int rc = kstrtoint(buf, 0, &cm->nodeid); |
736 | |||
737 | if (rc) | ||
738 | return rc; | ||
734 | return len; | 739 | return len; |
735 | } | 740 | } |
736 | 741 | ||
@@ -742,7 +747,10 @@ static ssize_t comm_local_read(struct dlm_comm *cm, char *buf) | |||
742 | static ssize_t comm_local_write(struct dlm_comm *cm, const char *buf, | 747 | static ssize_t comm_local_write(struct dlm_comm *cm, const char *buf, |
743 | size_t len) | 748 | size_t len) |
744 | { | 749 | { |
745 | cm->local= simple_strtol(buf, NULL, 0); | 750 | int rc = kstrtoint(buf, 0, &cm->local); |
751 | |||
752 | if (rc) | ||
753 | return rc; | ||
746 | if (cm->local && !local_comm) | 754 | if (cm->local && !local_comm) |
747 | local_comm = cm; | 755 | local_comm = cm; |
748 | return len; | 756 | return len; |
@@ -846,7 +854,10 @@ static ssize_t node_nodeid_write(struct dlm_node *nd, const char *buf, | |||
846 | size_t len) | 854 | size_t len) |
847 | { | 855 | { |
848 | uint32_t seq = 0; | 856 | uint32_t seq = 0; |
849 | nd->nodeid = simple_strtol(buf, NULL, 0); | 857 | int rc = kstrtoint(buf, 0, &nd->nodeid); |
858 | |||
859 | if (rc) | ||
860 | return rc; | ||
850 | dlm_comm_seq(nd->nodeid, &seq); | 861 | dlm_comm_seq(nd->nodeid, &seq); |
851 | nd->comm_seq = seq; | 862 | nd->comm_seq = seq; |
852 | return len; | 863 | return len; |
@@ -860,7 +871,10 @@ static ssize_t node_weight_read(struct dlm_node *nd, char *buf) | |||
860 | static ssize_t node_weight_write(struct dlm_node *nd, const char *buf, | 871 | static ssize_t node_weight_write(struct dlm_node *nd, const char *buf, |
861 | size_t len) | 872 | size_t len) |
862 | { | 873 | { |
863 | nd->weight = simple_strtol(buf, NULL, 0); | 874 | int rc = kstrtoint(buf, 0, &nd->weight); |
875 | |||
876 | if (rc) | ||
877 | return rc; | ||
864 | return len; | 878 | return len; |
865 | } | 879 | } |
866 | 880 | ||
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c index b969deef9ebb..8d77ba7b1756 100644 --- a/fs/dlm/debug_fs.c +++ b/fs/dlm/debug_fs.c | |||
@@ -68,7 +68,7 @@ static int print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb, | |||
68 | if (lkb->lkb_wait_type) | 68 | if (lkb->lkb_wait_type) |
69 | seq_printf(s, " wait_type: %d", lkb->lkb_wait_type); | 69 | seq_printf(s, " wait_type: %d", lkb->lkb_wait_type); |
70 | 70 | ||
71 | return seq_printf(s, "\n"); | 71 | return seq_puts(s, "\n"); |
72 | } | 72 | } |
73 | 73 | ||
74 | static int print_format1(struct dlm_rsb *res, struct seq_file *s) | 74 | static int print_format1(struct dlm_rsb *res, struct seq_file *s) |
@@ -92,31 +92,31 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s) | |||
92 | } | 92 | } |
93 | 93 | ||
94 | if (res->res_nodeid > 0) | 94 | if (res->res_nodeid > 0) |
95 | rv = seq_printf(s, "\" \nLocal Copy, Master is node %d\n", | 95 | rv = seq_printf(s, "\"\nLocal Copy, Master is node %d\n", |
96 | res->res_nodeid); | 96 | res->res_nodeid); |
97 | else if (res->res_nodeid == 0) | 97 | else if (res->res_nodeid == 0) |
98 | rv = seq_printf(s, "\" \nMaster Copy\n"); | 98 | rv = seq_puts(s, "\"\nMaster Copy\n"); |
99 | else if (res->res_nodeid == -1) | 99 | else if (res->res_nodeid == -1) |
100 | rv = seq_printf(s, "\" \nLooking up master (lkid %x)\n", | 100 | rv = seq_printf(s, "\"\nLooking up master (lkid %x)\n", |
101 | res->res_first_lkid); | 101 | res->res_first_lkid); |
102 | else | 102 | else |
103 | rv = seq_printf(s, "\" \nInvalid master %d\n", | 103 | rv = seq_printf(s, "\"\nInvalid master %d\n", |
104 | res->res_nodeid); | 104 | res->res_nodeid); |
105 | if (rv) | 105 | if (rv) |
106 | goto out; | 106 | goto out; |
107 | 107 | ||
108 | /* Print the LVB: */ | 108 | /* Print the LVB: */ |
109 | if (res->res_lvbptr) { | 109 | if (res->res_lvbptr) { |
110 | seq_printf(s, "LVB: "); | 110 | seq_puts(s, "LVB: "); |
111 | for (i = 0; i < lvblen; i++) { | 111 | for (i = 0; i < lvblen; i++) { |
112 | if (i == lvblen / 2) | 112 | if (i == lvblen / 2) |
113 | seq_printf(s, "\n "); | 113 | seq_puts(s, "\n "); |
114 | seq_printf(s, "%02x ", | 114 | seq_printf(s, "%02x ", |
115 | (unsigned char) res->res_lvbptr[i]); | 115 | (unsigned char) res->res_lvbptr[i]); |
116 | } | 116 | } |
117 | if (rsb_flag(res, RSB_VALNOTVALID)) | 117 | if (rsb_flag(res, RSB_VALNOTVALID)) |
118 | seq_printf(s, " (INVALID)"); | 118 | seq_puts(s, " (INVALID)"); |
119 | rv = seq_printf(s, "\n"); | 119 | rv = seq_puts(s, "\n"); |
120 | if (rv) | 120 | if (rv) |
121 | goto out; | 121 | goto out; |
122 | } | 122 | } |
@@ -133,21 +133,21 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s) | |||
133 | } | 133 | } |
134 | 134 | ||
135 | /* Print the locks attached to this resource */ | 135 | /* Print the locks attached to this resource */ |
136 | seq_printf(s, "Granted Queue\n"); | 136 | seq_puts(s, "Granted Queue\n"); |
137 | list_for_each_entry(lkb, &res->res_grantqueue, lkb_statequeue) { | 137 | list_for_each_entry(lkb, &res->res_grantqueue, lkb_statequeue) { |
138 | rv = print_format1_lock(s, lkb, res); | 138 | rv = print_format1_lock(s, lkb, res); |
139 | if (rv) | 139 | if (rv) |
140 | goto out; | 140 | goto out; |
141 | } | 141 | } |
142 | 142 | ||
143 | seq_printf(s, "Conversion Queue\n"); | 143 | seq_puts(s, "Conversion Queue\n"); |
144 | list_for_each_entry(lkb, &res->res_convertqueue, lkb_statequeue) { | 144 | list_for_each_entry(lkb, &res->res_convertqueue, lkb_statequeue) { |
145 | rv = print_format1_lock(s, lkb, res); | 145 | rv = print_format1_lock(s, lkb, res); |
146 | if (rv) | 146 | if (rv) |
147 | goto out; | 147 | goto out; |
148 | } | 148 | } |
149 | 149 | ||
150 | seq_printf(s, "Waiting Queue\n"); | 150 | seq_puts(s, "Waiting Queue\n"); |
151 | list_for_each_entry(lkb, &res->res_waitqueue, lkb_statequeue) { | 151 | list_for_each_entry(lkb, &res->res_waitqueue, lkb_statequeue) { |
152 | rv = print_format1_lock(s, lkb, res); | 152 | rv = print_format1_lock(s, lkb, res); |
153 | if (rv) | 153 | if (rv) |
@@ -157,13 +157,13 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s) | |||
157 | if (list_empty(&res->res_lookup)) | 157 | if (list_empty(&res->res_lookup)) |
158 | goto out; | 158 | goto out; |
159 | 159 | ||
160 | seq_printf(s, "Lookup Queue\n"); | 160 | seq_puts(s, "Lookup Queue\n"); |
161 | list_for_each_entry(lkb, &res->res_lookup, lkb_rsb_lookup) { | 161 | list_for_each_entry(lkb, &res->res_lookup, lkb_rsb_lookup) { |
162 | rv = seq_printf(s, "%08x %s", lkb->lkb_id, | 162 | rv = seq_printf(s, "%08x %s", lkb->lkb_id, |
163 | print_lockmode(lkb->lkb_rqmode)); | 163 | print_lockmode(lkb->lkb_rqmode)); |
164 | if (lkb->lkb_wait_type) | 164 | if (lkb->lkb_wait_type) |
165 | seq_printf(s, " wait_type: %d", lkb->lkb_wait_type); | 165 | seq_printf(s, " wait_type: %d", lkb->lkb_wait_type); |
166 | rv = seq_printf(s, "\n"); | 166 | rv = seq_puts(s, "\n"); |
167 | } | 167 | } |
168 | out: | 168 | out: |
169 | unlock_rsb(res); | 169 | unlock_rsb(res); |
@@ -300,7 +300,7 @@ static int print_format3(struct dlm_rsb *r, struct seq_file *s) | |||
300 | else | 300 | else |
301 | seq_printf(s, " %02x", (unsigned char)r->res_name[i]); | 301 | seq_printf(s, " %02x", (unsigned char)r->res_name[i]); |
302 | } | 302 | } |
303 | rv = seq_printf(s, "\n"); | 303 | rv = seq_puts(s, "\n"); |
304 | if (rv) | 304 | if (rv) |
305 | goto out; | 305 | goto out; |
306 | 306 | ||
@@ -311,7 +311,7 @@ static int print_format3(struct dlm_rsb *r, struct seq_file *s) | |||
311 | 311 | ||
312 | for (i = 0; i < lvblen; i++) | 312 | for (i = 0; i < lvblen; i++) |
313 | seq_printf(s, " %02x", (unsigned char)r->res_lvbptr[i]); | 313 | seq_printf(s, " %02x", (unsigned char)r->res_lvbptr[i]); |
314 | rv = seq_printf(s, "\n"); | 314 | rv = seq_puts(s, "\n"); |
315 | if (rv) | 315 | if (rv) |
316 | goto out; | 316 | goto out; |
317 | 317 | ||
@@ -377,7 +377,7 @@ static int print_format4(struct dlm_rsb *r, struct seq_file *s) | |||
377 | else | 377 | else |
378 | seq_printf(s, " %02x", (unsigned char)r->res_name[i]); | 378 | seq_printf(s, " %02x", (unsigned char)r->res_name[i]); |
379 | } | 379 | } |
380 | rv = seq_printf(s, "\n"); | 380 | rv = seq_puts(s, "\n"); |
381 | out: | 381 | out: |
382 | unlock_rsb(r); | 382 | unlock_rsb(r); |
383 | return rv; | 383 | return rv; |
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c index 04d6398c1f1c..f3e72787e7f9 100644 --- a/fs/dlm/lockspace.c +++ b/fs/dlm/lockspace.c | |||
@@ -35,8 +35,11 @@ static struct task_struct * scand_task; | |||
35 | static ssize_t dlm_control_store(struct dlm_ls *ls, const char *buf, size_t len) | 35 | static ssize_t dlm_control_store(struct dlm_ls *ls, const char *buf, size_t len) |
36 | { | 36 | { |
37 | ssize_t ret = len; | 37 | ssize_t ret = len; |
38 | int n = simple_strtol(buf, NULL, 0); | 38 | int n; |
39 | int rc = kstrtoint(buf, 0, &n); | ||
39 | 40 | ||
41 | if (rc) | ||
42 | return rc; | ||
40 | ls = dlm_find_lockspace_local(ls->ls_local_handle); | 43 | ls = dlm_find_lockspace_local(ls->ls_local_handle); |
41 | if (!ls) | 44 | if (!ls) |
42 | return -EINVAL; | 45 | return -EINVAL; |
@@ -57,7 +60,10 @@ static ssize_t dlm_control_store(struct dlm_ls *ls, const char *buf, size_t len) | |||
57 | 60 | ||
58 | static ssize_t dlm_event_store(struct dlm_ls *ls, const char *buf, size_t len) | 61 | static ssize_t dlm_event_store(struct dlm_ls *ls, const char *buf, size_t len) |
59 | { | 62 | { |
60 | ls->ls_uevent_result = simple_strtol(buf, NULL, 0); | 63 | int rc = kstrtoint(buf, 0, &ls->ls_uevent_result); |
64 | |||
65 | if (rc) | ||
66 | return rc; | ||
61 | set_bit(LSFL_UEVENT_WAIT, &ls->ls_flags); | 67 | set_bit(LSFL_UEVENT_WAIT, &ls->ls_flags); |
62 | wake_up(&ls->ls_uevent_wait); | 68 | wake_up(&ls->ls_uevent_wait); |
63 | return len; | 69 | return len; |
@@ -70,7 +76,10 @@ static ssize_t dlm_id_show(struct dlm_ls *ls, char *buf) | |||
70 | 76 | ||
71 | static ssize_t dlm_id_store(struct dlm_ls *ls, const char *buf, size_t len) | 77 | static ssize_t dlm_id_store(struct dlm_ls *ls, const char *buf, size_t len) |
72 | { | 78 | { |
73 | ls->ls_global_id = simple_strtoul(buf, NULL, 0); | 79 | int rc = kstrtouint(buf, 0, &ls->ls_global_id); |
80 | |||
81 | if (rc) | ||
82 | return rc; | ||
74 | return len; | 83 | return len; |
75 | } | 84 | } |
76 | 85 | ||
@@ -81,7 +90,11 @@ static ssize_t dlm_nodir_show(struct dlm_ls *ls, char *buf) | |||
81 | 90 | ||
82 | static ssize_t dlm_nodir_store(struct dlm_ls *ls, const char *buf, size_t len) | 91 | static ssize_t dlm_nodir_store(struct dlm_ls *ls, const char *buf, size_t len) |
83 | { | 92 | { |
84 | int val = simple_strtoul(buf, NULL, 0); | 93 | int val; |
94 | int rc = kstrtoint(buf, 0, &val); | ||
95 | |||
96 | if (rc) | ||
97 | return rc; | ||
85 | if (val == 1) | 98 | if (val == 1) |
86 | set_bit(LSFL_NODIR, &ls->ls_flags); | 99 | set_bit(LSFL_NODIR, &ls->ls_flags); |
87 | return len; | 100 | return len; |
diff --git a/fs/drop_caches.c b/fs/drop_caches.c index 9280202e488c..1de7294aad20 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c | |||
@@ -50,7 +50,7 @@ static void drop_slab(void) | |||
50 | } while (nr_objects > 10); | 50 | } while (nr_objects > 10); |
51 | } | 51 | } |
52 | 52 | ||
53 | int drop_caches_sysctl_handler(ctl_table *table, int write, | 53 | int drop_caches_sysctl_handler(struct ctl_table *table, int write, |
54 | void __user *buffer, size_t *length, loff_t *ppos) | 54 | void __user *buffer, size_t *length, loff_t *ppos) |
55 | { | 55 | { |
56 | int ret; | 56 | int ret; |
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index af903128891c..b73e0621ce9e 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c | |||
@@ -293,7 +293,7 @@ static LIST_HEAD(tfile_check_list); | |||
293 | static long zero; | 293 | static long zero; |
294 | static long long_max = LONG_MAX; | 294 | static long long_max = LONG_MAX; |
295 | 295 | ||
296 | ctl_table epoll_table[] = { | 296 | struct ctl_table epoll_table[] = { |
297 | { | 297 | { |
298 | .procname = "max_user_watches", | 298 | .procname = "max_user_watches", |
299 | .data = &max_user_watches, | 299 | .data = &max_user_watches, |
diff --git a/fs/fat/fat.h b/fs/fat/fat.h index 7c31f4bc74a9..e0c4ba39a377 100644 --- a/fs/fat/fat.h +++ b/fs/fat/fat.h | |||
@@ -52,7 +52,8 @@ struct fat_mount_options { | |||
52 | usefree:1, /* Use free_clusters for FAT32 */ | 52 | usefree:1, /* Use free_clusters for FAT32 */ |
53 | tz_set:1, /* Filesystem timestamps' offset set */ | 53 | tz_set:1, /* Filesystem timestamps' offset set */ |
54 | rodir:1, /* allow ATTR_RO for directory */ | 54 | rodir:1, /* allow ATTR_RO for directory */ |
55 | discard:1; /* Issue discard requests on deletions */ | 55 | discard:1, /* Issue discard requests on deletions */ |
56 | dos1xfloppy:1; /* Assume default BPB for DOS 1.x floppies */ | ||
56 | }; | 57 | }; |
57 | 58 | ||
58 | #define FAT_HASH_BITS 8 | 59 | #define FAT_HASH_BITS 8 |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index b3361fe2bcb5..9c83594d7fb5 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -35,9 +35,71 @@ | |||
35 | #define CONFIG_FAT_DEFAULT_IOCHARSET "" | 35 | #define CONFIG_FAT_DEFAULT_IOCHARSET "" |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #define KB_IN_SECTORS 2 | ||
39 | |||
40 | /* | ||
41 | * A deserialized copy of the on-disk structure laid out in struct | ||
42 | * fat_boot_sector. | ||
43 | */ | ||
44 | struct fat_bios_param_block { | ||
45 | u16 fat_sector_size; | ||
46 | u8 fat_sec_per_clus; | ||
47 | u16 fat_reserved; | ||
48 | u8 fat_fats; | ||
49 | u16 fat_dir_entries; | ||
50 | u16 fat_sectors; | ||
51 | u16 fat_fat_length; | ||
52 | u32 fat_total_sect; | ||
53 | |||
54 | u8 fat16_state; | ||
55 | u32 fat16_vol_id; | ||
56 | |||
57 | u32 fat32_length; | ||
58 | u32 fat32_root_cluster; | ||
59 | u16 fat32_info_sector; | ||
60 | u8 fat32_state; | ||
61 | u32 fat32_vol_id; | ||
62 | }; | ||
63 | |||
38 | static int fat_default_codepage = CONFIG_FAT_DEFAULT_CODEPAGE; | 64 | static int fat_default_codepage = CONFIG_FAT_DEFAULT_CODEPAGE; |
39 | static char fat_default_iocharset[] = CONFIG_FAT_DEFAULT_IOCHARSET; | 65 | static char fat_default_iocharset[] = CONFIG_FAT_DEFAULT_IOCHARSET; |
40 | 66 | ||
67 | static struct fat_floppy_defaults { | ||
68 | unsigned nr_sectors; | ||
69 | unsigned sec_per_clus; | ||
70 | unsigned dir_entries; | ||
71 | unsigned media; | ||
72 | unsigned fat_length; | ||
73 | } floppy_defaults[] = { | ||
74 | { | ||
75 | .nr_sectors = 160 * KB_IN_SECTORS, | ||
76 | .sec_per_clus = 1, | ||
77 | .dir_entries = 64, | ||
78 | .media = 0xFE, | ||
79 | .fat_length = 1, | ||
80 | }, | ||
81 | { | ||
82 | .nr_sectors = 180 * KB_IN_SECTORS, | ||
83 | .sec_per_clus = 1, | ||
84 | .dir_entries = 64, | ||
85 | .media = 0xFC, | ||
86 | .fat_length = 2, | ||
87 | }, | ||
88 | { | ||
89 | .nr_sectors = 320 * KB_IN_SECTORS, | ||
90 | .sec_per_clus = 2, | ||
91 | .dir_entries = 112, | ||
92 | .media = 0xFF, | ||
93 | .fat_length = 1, | ||
94 | }, | ||
95 | { | ||
96 | .nr_sectors = 360 * KB_IN_SECTORS, | ||
97 | .sec_per_clus = 2, | ||
98 | .dir_entries = 112, | ||
99 | .media = 0xFD, | ||
100 | .fat_length = 2, | ||
101 | }, | ||
102 | }; | ||
41 | 103 | ||
42 | static int fat_add_cluster(struct inode *inode) | 104 | static int fat_add_cluster(struct inode *inode) |
43 | { | 105 | { |
@@ -359,7 +421,7 @@ struct inode *fat_iget(struct super_block *sb, loff_t i_pos) | |||
359 | 421 | ||
360 | static int is_exec(unsigned char *extension) | 422 | static int is_exec(unsigned char *extension) |
361 | { | 423 | { |
362 | unsigned char *exe_extensions = "EXECOMBAT", *walk; | 424 | unsigned char exe_extensions[] = "EXECOMBAT", *walk; |
363 | 425 | ||
364 | for (walk = exe_extensions; *walk; walk += 3) | 426 | for (walk = exe_extensions; *walk; walk += 3) |
365 | if (!strncmp(extension, walk, 3)) | 427 | if (!strncmp(extension, walk, 3)) |
@@ -853,6 +915,8 @@ static int fat_show_options(struct seq_file *m, struct dentry *root) | |||
853 | seq_puts(m, ",nfs=stale_rw"); | 915 | seq_puts(m, ",nfs=stale_rw"); |
854 | if (opts->discard) | 916 | if (opts->discard) |
855 | seq_puts(m, ",discard"); | 917 | seq_puts(m, ",discard"); |
918 | if (opts->dos1xfloppy) | ||
919 | seq_puts(m, ",dos1xfloppy"); | ||
856 | 920 | ||
857 | return 0; | 921 | return 0; |
858 | } | 922 | } |
@@ -867,7 +931,7 @@ enum { | |||
867 | Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes, | 931 | Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes, |
868 | Opt_obsolete, Opt_flush, Opt_tz_utc, Opt_rodir, Opt_err_cont, | 932 | Opt_obsolete, Opt_flush, Opt_tz_utc, Opt_rodir, Opt_err_cont, |
869 | Opt_err_panic, Opt_err_ro, Opt_discard, Opt_nfs, Opt_time_offset, | 933 | Opt_err_panic, Opt_err_ro, Opt_discard, Opt_nfs, Opt_time_offset, |
870 | Opt_nfs_stale_rw, Opt_nfs_nostale_ro, Opt_err, | 934 | Opt_nfs_stale_rw, Opt_nfs_nostale_ro, Opt_err, Opt_dos1xfloppy, |
871 | }; | 935 | }; |
872 | 936 | ||
873 | static const match_table_t fat_tokens = { | 937 | static const match_table_t fat_tokens = { |
@@ -900,6 +964,7 @@ static const match_table_t fat_tokens = { | |||
900 | {Opt_nfs_stale_rw, "nfs"}, | 964 | {Opt_nfs_stale_rw, "nfs"}, |
901 | {Opt_nfs_stale_rw, "nfs=stale_rw"}, | 965 | {Opt_nfs_stale_rw, "nfs=stale_rw"}, |
902 | {Opt_nfs_nostale_ro, "nfs=nostale_ro"}, | 966 | {Opt_nfs_nostale_ro, "nfs=nostale_ro"}, |
967 | {Opt_dos1xfloppy, "dos1xfloppy"}, | ||
903 | {Opt_obsolete, "conv=binary"}, | 968 | {Opt_obsolete, "conv=binary"}, |
904 | {Opt_obsolete, "conv=text"}, | 969 | {Opt_obsolete, "conv=text"}, |
905 | {Opt_obsolete, "conv=auto"}, | 970 | {Opt_obsolete, "conv=auto"}, |
@@ -1102,6 +1167,9 @@ static int parse_options(struct super_block *sb, char *options, int is_vfat, | |||
1102 | case Opt_nfs_nostale_ro: | 1167 | case Opt_nfs_nostale_ro: |
1103 | opts->nfs = FAT_NFS_NOSTALE_RO; | 1168 | opts->nfs = FAT_NFS_NOSTALE_RO; |
1104 | break; | 1169 | break; |
1170 | case Opt_dos1xfloppy: | ||
1171 | opts->dos1xfloppy = 1; | ||
1172 | break; | ||
1105 | 1173 | ||
1106 | /* msdos specific */ | 1174 | /* msdos specific */ |
1107 | case Opt_dots: | 1175 | case Opt_dots: |
@@ -1247,6 +1315,169 @@ static unsigned long calc_fat_clusters(struct super_block *sb) | |||
1247 | return sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits; | 1315 | return sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits; |
1248 | } | 1316 | } |
1249 | 1317 | ||
1318 | static bool fat_bpb_is_zero(struct fat_boot_sector *b) | ||
1319 | { | ||
1320 | if (get_unaligned_le16(&b->sector_size)) | ||
1321 | return false; | ||
1322 | if (b->sec_per_clus) | ||
1323 | return false; | ||
1324 | if (b->reserved) | ||
1325 | return false; | ||
1326 | if (b->fats) | ||
1327 | return false; | ||
1328 | if (get_unaligned_le16(&b->dir_entries)) | ||
1329 | return false; | ||
1330 | if (get_unaligned_le16(&b->sectors)) | ||
1331 | return false; | ||
1332 | if (b->media) | ||
1333 | return false; | ||
1334 | if (b->fat_length) | ||
1335 | return false; | ||
1336 | if (b->secs_track) | ||
1337 | return false; | ||
1338 | if (b->heads) | ||
1339 | return false; | ||
1340 | return true; | ||
1341 | } | ||
1342 | |||
1343 | static int fat_read_bpb(struct super_block *sb, struct fat_boot_sector *b, | ||
1344 | int silent, struct fat_bios_param_block *bpb) | ||
1345 | { | ||
1346 | int error = -EINVAL; | ||
1347 | |||
1348 | /* Read in BPB ... */ | ||
1349 | memset(bpb, 0, sizeof(*bpb)); | ||
1350 | bpb->fat_sector_size = get_unaligned_le16(&b->sector_size); | ||
1351 | bpb->fat_sec_per_clus = b->sec_per_clus; | ||
1352 | bpb->fat_reserved = le16_to_cpu(b->reserved); | ||
1353 | bpb->fat_fats = b->fats; | ||
1354 | bpb->fat_dir_entries = get_unaligned_le16(&b->dir_entries); | ||
1355 | bpb->fat_sectors = get_unaligned_le16(&b->sectors); | ||
1356 | bpb->fat_fat_length = le16_to_cpu(b->fat_length); | ||
1357 | bpb->fat_total_sect = le32_to_cpu(b->total_sect); | ||
1358 | |||
1359 | bpb->fat16_state = b->fat16.state; | ||
1360 | bpb->fat16_vol_id = get_unaligned_le32(b->fat16.vol_id); | ||
1361 | |||
1362 | bpb->fat32_length = le32_to_cpu(b->fat32.length); | ||
1363 | bpb->fat32_root_cluster = le32_to_cpu(b->fat32.root_cluster); | ||
1364 | bpb->fat32_info_sector = le16_to_cpu(b->fat32.info_sector); | ||
1365 | bpb->fat32_state = b->fat32.state; | ||
1366 | bpb->fat32_vol_id = get_unaligned_le32(b->fat32.vol_id); | ||
1367 | |||
1368 | /* Validate this looks like a FAT filesystem BPB */ | ||
1369 | if (!bpb->fat_reserved) { | ||
1370 | if (!silent) | ||
1371 | fat_msg(sb, KERN_ERR, | ||
1372 | "bogus number of reserved sectors"); | ||
1373 | goto out; | ||
1374 | } | ||
1375 | if (!bpb->fat_fats) { | ||
1376 | if (!silent) | ||
1377 | fat_msg(sb, KERN_ERR, "bogus number of FAT structure"); | ||
1378 | goto out; | ||
1379 | } | ||
1380 | |||
1381 | /* | ||
1382 | * Earlier we checked here that b->secs_track and b->head are nonzero, | ||
1383 | * but it turns out valid FAT filesystems can have zero there. | ||
1384 | */ | ||
1385 | |||
1386 | if (!fat_valid_media(b->media)) { | ||
1387 | if (!silent) | ||
1388 | fat_msg(sb, KERN_ERR, "invalid media value (0x%02x)", | ||
1389 | (unsigned)b->media); | ||
1390 | goto out; | ||
1391 | } | ||
1392 | |||
1393 | if (!is_power_of_2(bpb->fat_sector_size) | ||
1394 | || (bpb->fat_sector_size < 512) | ||
1395 | || (bpb->fat_sector_size > 4096)) { | ||
1396 | if (!silent) | ||
1397 | fat_msg(sb, KERN_ERR, "bogus logical sector size %u", | ||
1398 | (unsigned)bpb->fat_sector_size); | ||
1399 | goto out; | ||
1400 | } | ||
1401 | |||
1402 | if (!is_power_of_2(bpb->fat_sec_per_clus)) { | ||
1403 | if (!silent) | ||
1404 | fat_msg(sb, KERN_ERR, "bogus sectors per cluster %u", | ||
1405 | (unsigned)bpb->fat_sec_per_clus); | ||
1406 | goto out; | ||
1407 | } | ||
1408 | |||
1409 | error = 0; | ||
1410 | |||
1411 | out: | ||
1412 | return error; | ||
1413 | } | ||
1414 | |||
1415 | static int fat_read_static_bpb(struct super_block *sb, | ||
1416 | struct fat_boot_sector *b, int silent, | ||
1417 | struct fat_bios_param_block *bpb) | ||
1418 | { | ||
1419 | static const char *notdos1x = "This doesn't look like a DOS 1.x volume"; | ||
1420 | |||
1421 | struct fat_floppy_defaults *fdefaults = NULL; | ||
1422 | int error = -EINVAL; | ||
1423 | sector_t bd_sects; | ||
1424 | unsigned i; | ||
1425 | |||
1426 | bd_sects = i_size_read(sb->s_bdev->bd_inode) / SECTOR_SIZE; | ||
1427 | |||
1428 | /* 16-bit DOS 1.x reliably wrote bootstrap short-jmp code */ | ||
1429 | if (b->ignored[0] != 0xeb || b->ignored[2] != 0x90) { | ||
1430 | if (!silent) | ||
1431 | fat_msg(sb, KERN_ERR, | ||
1432 | "%s; no bootstrapping code", notdos1x); | ||
1433 | goto out; | ||
1434 | } | ||
1435 | |||
1436 | /* | ||
1437 | * If any value in this region is non-zero, it isn't archaic | ||
1438 | * DOS. | ||
1439 | */ | ||
1440 | if (!fat_bpb_is_zero(b)) { | ||
1441 | if (!silent) | ||
1442 | fat_msg(sb, KERN_ERR, | ||
1443 | "%s; DOS 2.x BPB is non-zero", notdos1x); | ||
1444 | goto out; | ||
1445 | } | ||
1446 | |||
1447 | for (i = 0; i < ARRAY_SIZE(floppy_defaults); i++) { | ||
1448 | if (floppy_defaults[i].nr_sectors == bd_sects) { | ||
1449 | fdefaults = &floppy_defaults[i]; | ||
1450 | break; | ||
1451 | } | ||
1452 | } | ||
1453 | |||
1454 | if (fdefaults == NULL) { | ||
1455 | if (!silent) | ||
1456 | fat_msg(sb, KERN_WARNING, | ||
1457 | "This looks like a DOS 1.x volume, but isn't a recognized floppy size (%llu sectors)", | ||
1458 | (u64)bd_sects); | ||
1459 | goto out; | ||
1460 | } | ||
1461 | |||
1462 | if (!silent) | ||
1463 | fat_msg(sb, KERN_INFO, | ||
1464 | "This looks like a DOS 1.x volume; assuming default BPB values"); | ||
1465 | |||
1466 | memset(bpb, 0, sizeof(*bpb)); | ||
1467 | bpb->fat_sector_size = SECTOR_SIZE; | ||
1468 | bpb->fat_sec_per_clus = fdefaults->sec_per_clus; | ||
1469 | bpb->fat_reserved = 1; | ||
1470 | bpb->fat_fats = 2; | ||
1471 | bpb->fat_dir_entries = fdefaults->dir_entries; | ||
1472 | bpb->fat_sectors = fdefaults->nr_sectors; | ||
1473 | bpb->fat_fat_length = fdefaults->fat_length; | ||
1474 | |||
1475 | error = 0; | ||
1476 | |||
1477 | out: | ||
1478 | return error; | ||
1479 | } | ||
1480 | |||
1250 | /* | 1481 | /* |
1251 | * Read the super block of an MS-DOS FS. | 1482 | * Read the super block of an MS-DOS FS. |
1252 | */ | 1483 | */ |
@@ -1256,12 +1487,11 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, | |||
1256 | struct inode *root_inode = NULL, *fat_inode = NULL; | 1487 | struct inode *root_inode = NULL, *fat_inode = NULL; |
1257 | struct inode *fsinfo_inode = NULL; | 1488 | struct inode *fsinfo_inode = NULL; |
1258 | struct buffer_head *bh; | 1489 | struct buffer_head *bh; |
1259 | struct fat_boot_sector *b; | 1490 | struct fat_bios_param_block bpb; |
1260 | struct msdos_sb_info *sbi; | 1491 | struct msdos_sb_info *sbi; |
1261 | u16 logical_sector_size; | 1492 | u16 logical_sector_size; |
1262 | u32 total_sectors, total_clusters, fat_clusters, rootdir_sectors; | 1493 | u32 total_sectors, total_clusters, fat_clusters, rootdir_sectors; |
1263 | int debug; | 1494 | int debug; |
1264 | unsigned int media; | ||
1265 | long error; | 1495 | long error; |
1266 | char buf[50]; | 1496 | char buf[50]; |
1267 | 1497 | ||
@@ -1298,100 +1528,72 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, | |||
1298 | goto out_fail; | 1528 | goto out_fail; |
1299 | } | 1529 | } |
1300 | 1530 | ||
1301 | b = (struct fat_boot_sector *) bh->b_data; | 1531 | error = fat_read_bpb(sb, (struct fat_boot_sector *)bh->b_data, silent, |
1302 | if (!b->reserved) { | 1532 | &bpb); |
1303 | if (!silent) | 1533 | if (error == -EINVAL && sbi->options.dos1xfloppy) |
1304 | fat_msg(sb, KERN_ERR, "bogus number of reserved sectors"); | 1534 | error = fat_read_static_bpb(sb, |
1305 | brelse(bh); | 1535 | (struct fat_boot_sector *)bh->b_data, silent, &bpb); |
1306 | goto out_invalid; | 1536 | brelse(bh); |
1307 | } | ||
1308 | if (!b->fats) { | ||
1309 | if (!silent) | ||
1310 | fat_msg(sb, KERN_ERR, "bogus number of FAT structure"); | ||
1311 | brelse(bh); | ||
1312 | goto out_invalid; | ||
1313 | } | ||
1314 | |||
1315 | /* | ||
1316 | * Earlier we checked here that b->secs_track and b->head are nonzero, | ||
1317 | * but it turns out valid FAT filesystems can have zero there. | ||
1318 | */ | ||
1319 | 1537 | ||
1320 | media = b->media; | 1538 | if (error == -EINVAL) |
1321 | if (!fat_valid_media(media)) { | ||
1322 | if (!silent) | ||
1323 | fat_msg(sb, KERN_ERR, "invalid media value (0x%02x)", | ||
1324 | media); | ||
1325 | brelse(bh); | ||
1326 | goto out_invalid; | ||
1327 | } | ||
1328 | logical_sector_size = get_unaligned_le16(&b->sector_size); | ||
1329 | if (!is_power_of_2(logical_sector_size) | ||
1330 | || (logical_sector_size < 512) | ||
1331 | || (logical_sector_size > 4096)) { | ||
1332 | if (!silent) | ||
1333 | fat_msg(sb, KERN_ERR, "bogus logical sector size %u", | ||
1334 | logical_sector_size); | ||
1335 | brelse(bh); | ||
1336 | goto out_invalid; | ||
1337 | } | ||
1338 | sbi->sec_per_clus = b->sec_per_clus; | ||
1339 | if (!is_power_of_2(sbi->sec_per_clus)) { | ||
1340 | if (!silent) | ||
1341 | fat_msg(sb, KERN_ERR, "bogus sectors per cluster %u", | ||
1342 | sbi->sec_per_clus); | ||
1343 | brelse(bh); | ||
1344 | goto out_invalid; | 1539 | goto out_invalid; |
1345 | } | 1540 | else if (error) |
1541 | goto out_fail; | ||
1542 | |||
1543 | logical_sector_size = bpb.fat_sector_size; | ||
1544 | sbi->sec_per_clus = bpb.fat_sec_per_clus; | ||
1346 | 1545 | ||
1546 | error = -EIO; | ||
1347 | if (logical_sector_size < sb->s_blocksize) { | 1547 | if (logical_sector_size < sb->s_blocksize) { |
1348 | fat_msg(sb, KERN_ERR, "logical sector size too small for device" | 1548 | fat_msg(sb, KERN_ERR, "logical sector size too small for device" |
1349 | " (logical sector size = %u)", logical_sector_size); | 1549 | " (logical sector size = %u)", logical_sector_size); |
1350 | brelse(bh); | ||
1351 | goto out_fail; | 1550 | goto out_fail; |
1352 | } | 1551 | } |
1552 | |||
1353 | if (logical_sector_size > sb->s_blocksize) { | 1553 | if (logical_sector_size > sb->s_blocksize) { |
1354 | brelse(bh); | 1554 | struct buffer_head *bh_resize; |
1355 | 1555 | ||
1356 | if (!sb_set_blocksize(sb, logical_sector_size)) { | 1556 | if (!sb_set_blocksize(sb, logical_sector_size)) { |
1357 | fat_msg(sb, KERN_ERR, "unable to set blocksize %u", | 1557 | fat_msg(sb, KERN_ERR, "unable to set blocksize %u", |
1358 | logical_sector_size); | 1558 | logical_sector_size); |
1359 | goto out_fail; | 1559 | goto out_fail; |
1360 | } | 1560 | } |
1361 | bh = sb_bread(sb, 0); | 1561 | |
1362 | if (bh == NULL) { | 1562 | /* Verify that the larger boot sector is fully readable */ |
1563 | bh_resize = sb_bread(sb, 0); | ||
1564 | if (bh_resize == NULL) { | ||
1363 | fat_msg(sb, KERN_ERR, "unable to read boot sector" | 1565 | fat_msg(sb, KERN_ERR, "unable to read boot sector" |
1364 | " (logical sector size = %lu)", | 1566 | " (logical sector size = %lu)", |
1365 | sb->s_blocksize); | 1567 | sb->s_blocksize); |
1366 | goto out_fail; | 1568 | goto out_fail; |
1367 | } | 1569 | } |
1368 | b = (struct fat_boot_sector *) bh->b_data; | 1570 | brelse(bh_resize); |
1369 | } | 1571 | } |
1370 | 1572 | ||
1371 | mutex_init(&sbi->s_lock); | 1573 | mutex_init(&sbi->s_lock); |
1372 | sbi->cluster_size = sb->s_blocksize * sbi->sec_per_clus; | 1574 | sbi->cluster_size = sb->s_blocksize * sbi->sec_per_clus; |
1373 | sbi->cluster_bits = ffs(sbi->cluster_size) - 1; | 1575 | sbi->cluster_bits = ffs(sbi->cluster_size) - 1; |
1374 | sbi->fats = b->fats; | 1576 | sbi->fats = bpb.fat_fats; |
1375 | sbi->fat_bits = 0; /* Don't know yet */ | 1577 | sbi->fat_bits = 0; /* Don't know yet */ |
1376 | sbi->fat_start = le16_to_cpu(b->reserved); | 1578 | sbi->fat_start = bpb.fat_reserved; |
1377 | sbi->fat_length = le16_to_cpu(b->fat_length); | 1579 | sbi->fat_length = bpb.fat_fat_length; |
1378 | sbi->root_cluster = 0; | 1580 | sbi->root_cluster = 0; |
1379 | sbi->free_clusters = -1; /* Don't know yet */ | 1581 | sbi->free_clusters = -1; /* Don't know yet */ |
1380 | sbi->free_clus_valid = 0; | 1582 | sbi->free_clus_valid = 0; |
1381 | sbi->prev_free = FAT_START_ENT; | 1583 | sbi->prev_free = FAT_START_ENT; |
1382 | sb->s_maxbytes = 0xffffffff; | 1584 | sb->s_maxbytes = 0xffffffff; |
1383 | 1585 | ||
1384 | if (!sbi->fat_length && b->fat32.length) { | 1586 | if (!sbi->fat_length && bpb.fat32_length) { |
1385 | struct fat_boot_fsinfo *fsinfo; | 1587 | struct fat_boot_fsinfo *fsinfo; |
1386 | struct buffer_head *fsinfo_bh; | 1588 | struct buffer_head *fsinfo_bh; |
1387 | 1589 | ||
1388 | /* Must be FAT32 */ | 1590 | /* Must be FAT32 */ |
1389 | sbi->fat_bits = 32; | 1591 | sbi->fat_bits = 32; |
1390 | sbi->fat_length = le32_to_cpu(b->fat32.length); | 1592 | sbi->fat_length = bpb.fat32_length; |
1391 | sbi->root_cluster = le32_to_cpu(b->fat32.root_cluster); | 1593 | sbi->root_cluster = bpb.fat32_root_cluster; |
1392 | 1594 | ||
1393 | /* MC - if info_sector is 0, don't multiply by 0 */ | 1595 | /* MC - if info_sector is 0, don't multiply by 0 */ |
1394 | sbi->fsinfo_sector = le16_to_cpu(b->fat32.info_sector); | 1596 | sbi->fsinfo_sector = bpb.fat32_info_sector; |
1395 | if (sbi->fsinfo_sector == 0) | 1597 | if (sbi->fsinfo_sector == 0) |
1396 | sbi->fsinfo_sector = 1; | 1598 | sbi->fsinfo_sector = 1; |
1397 | 1599 | ||
@@ -1399,7 +1601,6 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, | |||
1399 | if (fsinfo_bh == NULL) { | 1601 | if (fsinfo_bh == NULL) { |
1400 | fat_msg(sb, KERN_ERR, "bread failed, FSINFO block" | 1602 | fat_msg(sb, KERN_ERR, "bread failed, FSINFO block" |
1401 | " (sector = %lu)", sbi->fsinfo_sector); | 1603 | " (sector = %lu)", sbi->fsinfo_sector); |
1402 | brelse(bh); | ||
1403 | goto out_fail; | 1604 | goto out_fail; |
1404 | } | 1605 | } |
1405 | 1606 | ||
@@ -1422,35 +1623,28 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, | |||
1422 | 1623 | ||
1423 | /* interpret volume ID as a little endian 32 bit integer */ | 1624 | /* interpret volume ID as a little endian 32 bit integer */ |
1424 | if (sbi->fat_bits == 32) | 1625 | if (sbi->fat_bits == 32) |
1425 | sbi->vol_id = (((u32)b->fat32.vol_id[0]) | | 1626 | sbi->vol_id = bpb.fat32_vol_id; |
1426 | ((u32)b->fat32.vol_id[1] << 8) | | ||
1427 | ((u32)b->fat32.vol_id[2] << 16) | | ||
1428 | ((u32)b->fat32.vol_id[3] << 24)); | ||
1429 | else /* fat 16 or 12 */ | 1627 | else /* fat 16 or 12 */ |
1430 | sbi->vol_id = (((u32)b->fat16.vol_id[0]) | | 1628 | sbi->vol_id = bpb.fat16_vol_id; |
1431 | ((u32)b->fat16.vol_id[1] << 8) | | ||
1432 | ((u32)b->fat16.vol_id[2] << 16) | | ||
1433 | ((u32)b->fat16.vol_id[3] << 24)); | ||
1434 | 1629 | ||
1435 | sbi->dir_per_block = sb->s_blocksize / sizeof(struct msdos_dir_entry); | 1630 | sbi->dir_per_block = sb->s_blocksize / sizeof(struct msdos_dir_entry); |
1436 | sbi->dir_per_block_bits = ffs(sbi->dir_per_block) - 1; | 1631 | sbi->dir_per_block_bits = ffs(sbi->dir_per_block) - 1; |
1437 | 1632 | ||
1438 | sbi->dir_start = sbi->fat_start + sbi->fats * sbi->fat_length; | 1633 | sbi->dir_start = sbi->fat_start + sbi->fats * sbi->fat_length; |
1439 | sbi->dir_entries = get_unaligned_le16(&b->dir_entries); | 1634 | sbi->dir_entries = bpb.fat_dir_entries; |
1440 | if (sbi->dir_entries & (sbi->dir_per_block - 1)) { | 1635 | if (sbi->dir_entries & (sbi->dir_per_block - 1)) { |
1441 | if (!silent) | 1636 | if (!silent) |
1442 | fat_msg(sb, KERN_ERR, "bogus directory-entries per block" | 1637 | fat_msg(sb, KERN_ERR, "bogus directory-entries per block" |
1443 | " (%u)", sbi->dir_entries); | 1638 | " (%u)", sbi->dir_entries); |
1444 | brelse(bh); | ||
1445 | goto out_invalid; | 1639 | goto out_invalid; |
1446 | } | 1640 | } |
1447 | 1641 | ||
1448 | rootdir_sectors = sbi->dir_entries | 1642 | rootdir_sectors = sbi->dir_entries |
1449 | * sizeof(struct msdos_dir_entry) / sb->s_blocksize; | 1643 | * sizeof(struct msdos_dir_entry) / sb->s_blocksize; |
1450 | sbi->data_start = sbi->dir_start + rootdir_sectors; | 1644 | sbi->data_start = sbi->dir_start + rootdir_sectors; |
1451 | total_sectors = get_unaligned_le16(&b->sectors); | 1645 | total_sectors = bpb.fat_sectors; |
1452 | if (total_sectors == 0) | 1646 | if (total_sectors == 0) |
1453 | total_sectors = le32_to_cpu(b->total_sect); | 1647 | total_sectors = bpb.fat_total_sect; |
1454 | 1648 | ||
1455 | total_clusters = (total_sectors - sbi->data_start) / sbi->sec_per_clus; | 1649 | total_clusters = (total_sectors - sbi->data_start) / sbi->sec_per_clus; |
1456 | 1650 | ||
@@ -1459,9 +1653,9 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, | |||
1459 | 1653 | ||
1460 | /* some OSes set FAT_STATE_DIRTY and clean it on unmount. */ | 1654 | /* some OSes set FAT_STATE_DIRTY and clean it on unmount. */ |
1461 | if (sbi->fat_bits == 32) | 1655 | if (sbi->fat_bits == 32) |
1462 | sbi->dirty = b->fat32.state & FAT_STATE_DIRTY; | 1656 | sbi->dirty = bpb.fat32_state & FAT_STATE_DIRTY; |
1463 | else /* fat 16 or 12 */ | 1657 | else /* fat 16 or 12 */ |
1464 | sbi->dirty = b->fat16.state & FAT_STATE_DIRTY; | 1658 | sbi->dirty = bpb.fat16_state & FAT_STATE_DIRTY; |
1465 | 1659 | ||
1466 | /* check that FAT table does not overflow */ | 1660 | /* check that FAT table does not overflow */ |
1467 | fat_clusters = calc_fat_clusters(sb); | 1661 | fat_clusters = calc_fat_clusters(sb); |
@@ -1470,7 +1664,6 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, | |||
1470 | if (!silent) | 1664 | if (!silent) |
1471 | fat_msg(sb, KERN_ERR, "count of clusters too big (%u)", | 1665 | fat_msg(sb, KERN_ERR, "count of clusters too big (%u)", |
1472 | total_clusters); | 1666 | total_clusters); |
1473 | brelse(bh); | ||
1474 | goto out_invalid; | 1667 | goto out_invalid; |
1475 | } | 1668 | } |
1476 | 1669 | ||
@@ -1483,8 +1676,6 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, | |||
1483 | if (sbi->prev_free < FAT_START_ENT) | 1676 | if (sbi->prev_free < FAT_START_ENT) |
1484 | sbi->prev_free = FAT_START_ENT; | 1677 | sbi->prev_free = FAT_START_ENT; |
1485 | 1678 | ||
1486 | brelse(bh); | ||
1487 | |||
1488 | /* set up enough so that it can read an inode */ | 1679 | /* set up enough so that it can read an inode */ |
1489 | fat_hash_init(sb); | 1680 | fat_hash_init(sb); |
1490 | dir_hash_init(sb); | 1681 | dir_hash_init(sb); |
diff --git a/fs/file_table.c b/fs/file_table.c index a374f5033e97..40bf4660f0a3 100644 --- a/fs/file_table.c +++ b/fs/file_table.c | |||
@@ -76,14 +76,14 @@ EXPORT_SYMBOL_GPL(get_max_files); | |||
76 | * Handle nr_files sysctl | 76 | * Handle nr_files sysctl |
77 | */ | 77 | */ |
78 | #if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS) | 78 | #if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS) |
79 | int proc_nr_files(ctl_table *table, int write, | 79 | int proc_nr_files(struct ctl_table *table, int write, |
80 | void __user *buffer, size_t *lenp, loff_t *ppos) | 80 | void __user *buffer, size_t *lenp, loff_t *ppos) |
81 | { | 81 | { |
82 | files_stat.nr_files = get_nr_files(); | 82 | files_stat.nr_files = get_nr_files(); |
83 | return proc_doulongvec_minmax(table, write, buffer, lenp, ppos); | 83 | return proc_doulongvec_minmax(table, write, buffer, lenp, ppos); |
84 | } | 84 | } |
85 | #else | 85 | #else |
86 | int proc_nr_files(ctl_table *table, int write, | 86 | int proc_nr_files(struct ctl_table *table, int write, |
87 | void __user *buffer, size_t *lenp, loff_t *ppos) | 87 | void __user *buffer, size_t *lenp, loff_t *ppos) |
88 | { | 88 | { |
89 | return -ENOSYS; | 89 | return -ENOSYS; |
diff --git a/fs/fscache/main.c b/fs/fscache/main.c index acd4bf1fc277..63f868e869b9 100644 --- a/fs/fscache/main.c +++ b/fs/fscache/main.c | |||
@@ -67,7 +67,7 @@ static int fscache_max_active_sysctl(struct ctl_table *table, int write, | |||
67 | return ret; | 67 | return ret; |
68 | } | 68 | } |
69 | 69 | ||
70 | ctl_table fscache_sysctls[] = { | 70 | struct ctl_table fscache_sysctls[] = { |
71 | { | 71 | { |
72 | .procname = "object_max_active", | 72 | .procname = "object_max_active", |
73 | .data = &fscache_object_max_active, | 73 | .data = &fscache_object_max_active, |
@@ -87,7 +87,7 @@ ctl_table fscache_sysctls[] = { | |||
87 | {} | 87 | {} |
88 | }; | 88 | }; |
89 | 89 | ||
90 | ctl_table fscache_sysctls_root[] = { | 90 | struct ctl_table fscache_sysctls_root[] = { |
91 | { | 91 | { |
92 | .procname = "fscache", | 92 | .procname = "fscache", |
93 | .mode = 0555, | 93 | .mode = 0555, |
diff --git a/fs/hfsplus/attributes.c b/fs/hfsplus/attributes.c index caf89a7be0a1..e5b221de7de6 100644 --- a/fs/hfsplus/attributes.c +++ b/fs/hfsplus/attributes.c | |||
@@ -54,14 +54,11 @@ int hfsplus_attr_build_key(struct super_block *sb, hfsplus_btree_key *key, | |||
54 | memset(key, 0, sizeof(struct hfsplus_attr_key)); | 54 | memset(key, 0, sizeof(struct hfsplus_attr_key)); |
55 | key->attr.cnid = cpu_to_be32(cnid); | 55 | key->attr.cnid = cpu_to_be32(cnid); |
56 | if (name) { | 56 | if (name) { |
57 | len = strlen(name); | 57 | int res = hfsplus_asc2uni(sb, |
58 | if (len > HFSPLUS_ATTR_MAX_STRLEN) { | ||
59 | pr_err("invalid xattr name's length\n"); | ||
60 | return -EINVAL; | ||
61 | } | ||
62 | hfsplus_asc2uni(sb, | ||
63 | (struct hfsplus_unistr *)&key->attr.key_name, | 58 | (struct hfsplus_unistr *)&key->attr.key_name, |
64 | HFSPLUS_ATTR_MAX_STRLEN, name, len); | 59 | HFSPLUS_ATTR_MAX_STRLEN, name, strlen(name)); |
60 | if (res) | ||
61 | return res; | ||
65 | len = be16_to_cpu(key->attr.key_name.length); | 62 | len = be16_to_cpu(key->attr.key_name.length); |
66 | } else { | 63 | } else { |
67 | key->attr.key_name.length = 0; | 64 | key->attr.key_name.length = 0; |
@@ -82,31 +79,6 @@ int hfsplus_attr_build_key(struct super_block *sb, hfsplus_btree_key *key, | |||
82 | return 0; | 79 | return 0; |
83 | } | 80 | } |
84 | 81 | ||
85 | void hfsplus_attr_build_key_uni(hfsplus_btree_key *key, | ||
86 | u32 cnid, | ||
87 | struct hfsplus_attr_unistr *name) | ||
88 | { | ||
89 | int ustrlen; | ||
90 | |||
91 | memset(key, 0, sizeof(struct hfsplus_attr_key)); | ||
92 | ustrlen = be16_to_cpu(name->length); | ||
93 | key->attr.cnid = cpu_to_be32(cnid); | ||
94 | key->attr.key_name.length = cpu_to_be16(ustrlen); | ||
95 | ustrlen *= 2; | ||
96 | memcpy(key->attr.key_name.unicode, name->unicode, ustrlen); | ||
97 | |||
98 | /* The length of the key, as stored in key_len field, does not include | ||
99 | * the size of the key_len field itself. | ||
100 | * So, offsetof(hfsplus_attr_key, key_name) is a trick because | ||
101 | * it takes into consideration key_len field (__be16) of | ||
102 | * hfsplus_attr_key structure instead of length field (__be16) of | ||
103 | * hfsplus_attr_unistr structure. | ||
104 | */ | ||
105 | key->key_len = | ||
106 | cpu_to_be16(offsetof(struct hfsplus_attr_key, key_name) + | ||
107 | ustrlen); | ||
108 | } | ||
109 | |||
110 | hfsplus_attr_entry *hfsplus_alloc_attr_entry(void) | 82 | hfsplus_attr_entry *hfsplus_alloc_attr_entry(void) |
111 | { | 83 | { |
112 | return kmem_cache_alloc(hfsplus_attr_tree_cachep, GFP_KERNEL); | 84 | return kmem_cache_alloc(hfsplus_attr_tree_cachep, GFP_KERNEL); |
diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c index 11c860204520..759708fd9331 100644 --- a/fs/hfsplus/bnode.c +++ b/fs/hfsplus/bnode.c | |||
@@ -27,13 +27,13 @@ void hfs_bnode_read(struct hfs_bnode *node, void *buf, int off, int len) | |||
27 | pagep = node->page + (off >> PAGE_CACHE_SHIFT); | 27 | pagep = node->page + (off >> PAGE_CACHE_SHIFT); |
28 | off &= ~PAGE_CACHE_MASK; | 28 | off &= ~PAGE_CACHE_MASK; |
29 | 29 | ||
30 | l = min(len, (int)PAGE_CACHE_SIZE - off); | 30 | l = min_t(int, len, PAGE_CACHE_SIZE - off); |
31 | memcpy(buf, kmap(*pagep) + off, l); | 31 | memcpy(buf, kmap(*pagep) + off, l); |
32 | kunmap(*pagep); | 32 | kunmap(*pagep); |
33 | 33 | ||
34 | while ((len -= l) != 0) { | 34 | while ((len -= l) != 0) { |
35 | buf += l; | 35 | buf += l; |
36 | l = min(len, (int)PAGE_CACHE_SIZE); | 36 | l = min_t(int, len, PAGE_CACHE_SIZE); |
37 | memcpy(buf, kmap(*++pagep), l); | 37 | memcpy(buf, kmap(*++pagep), l); |
38 | kunmap(*pagep); | 38 | kunmap(*pagep); |
39 | } | 39 | } |
@@ -80,14 +80,14 @@ void hfs_bnode_write(struct hfs_bnode *node, void *buf, int off, int len) | |||
80 | pagep = node->page + (off >> PAGE_CACHE_SHIFT); | 80 | pagep = node->page + (off >> PAGE_CACHE_SHIFT); |
81 | off &= ~PAGE_CACHE_MASK; | 81 | off &= ~PAGE_CACHE_MASK; |
82 | 82 | ||
83 | l = min(len, (int)PAGE_CACHE_SIZE - off); | 83 | l = min_t(int, len, PAGE_CACHE_SIZE - off); |
84 | memcpy(kmap(*pagep) + off, buf, l); | 84 | memcpy(kmap(*pagep) + off, buf, l); |
85 | set_page_dirty(*pagep); | 85 | set_page_dirty(*pagep); |
86 | kunmap(*pagep); | 86 | kunmap(*pagep); |
87 | 87 | ||
88 | while ((len -= l) != 0) { | 88 | while ((len -= l) != 0) { |
89 | buf += l; | 89 | buf += l; |
90 | l = min(len, (int)PAGE_CACHE_SIZE); | 90 | l = min_t(int, len, PAGE_CACHE_SIZE); |
91 | memcpy(kmap(*++pagep), buf, l); | 91 | memcpy(kmap(*++pagep), buf, l); |
92 | set_page_dirty(*pagep); | 92 | set_page_dirty(*pagep); |
93 | kunmap(*pagep); | 93 | kunmap(*pagep); |
@@ -110,13 +110,13 @@ void hfs_bnode_clear(struct hfs_bnode *node, int off, int len) | |||
110 | pagep = node->page + (off >> PAGE_CACHE_SHIFT); | 110 | pagep = node->page + (off >> PAGE_CACHE_SHIFT); |
111 | off &= ~PAGE_CACHE_MASK; | 111 | off &= ~PAGE_CACHE_MASK; |
112 | 112 | ||
113 | l = min(len, (int)PAGE_CACHE_SIZE - off); | 113 | l = min_t(int, len, PAGE_CACHE_SIZE - off); |
114 | memset(kmap(*pagep) + off, 0, l); | 114 | memset(kmap(*pagep) + off, 0, l); |
115 | set_page_dirty(*pagep); | 115 | set_page_dirty(*pagep); |
116 | kunmap(*pagep); | 116 | kunmap(*pagep); |
117 | 117 | ||
118 | while ((len -= l) != 0) { | 118 | while ((len -= l) != 0) { |
119 | l = min(len, (int)PAGE_CACHE_SIZE); | 119 | l = min_t(int, len, PAGE_CACHE_SIZE); |
120 | memset(kmap(*++pagep), 0, l); | 120 | memset(kmap(*++pagep), 0, l); |
121 | set_page_dirty(*pagep); | 121 | set_page_dirty(*pagep); |
122 | kunmap(*pagep); | 122 | kunmap(*pagep); |
@@ -142,14 +142,14 @@ void hfs_bnode_copy(struct hfs_bnode *dst_node, int dst, | |||
142 | dst &= ~PAGE_CACHE_MASK; | 142 | dst &= ~PAGE_CACHE_MASK; |
143 | 143 | ||
144 | if (src == dst) { | 144 | if (src == dst) { |
145 | l = min(len, (int)PAGE_CACHE_SIZE - src); | 145 | l = min_t(int, len, PAGE_CACHE_SIZE - src); |
146 | memcpy(kmap(*dst_page) + src, kmap(*src_page) + src, l); | 146 | memcpy(kmap(*dst_page) + src, kmap(*src_page) + src, l); |
147 | kunmap(*src_page); | 147 | kunmap(*src_page); |
148 | set_page_dirty(*dst_page); | 148 | set_page_dirty(*dst_page); |
149 | kunmap(*dst_page); | 149 | kunmap(*dst_page); |
150 | 150 | ||
151 | while ((len -= l) != 0) { | 151 | while ((len -= l) != 0) { |
152 | l = min(len, (int)PAGE_CACHE_SIZE); | 152 | l = min_t(int, len, PAGE_CACHE_SIZE); |
153 | memcpy(kmap(*++dst_page), kmap(*++src_page), l); | 153 | memcpy(kmap(*++dst_page), kmap(*++src_page), l); |
154 | kunmap(*src_page); | 154 | kunmap(*src_page); |
155 | set_page_dirty(*dst_page); | 155 | set_page_dirty(*dst_page); |
@@ -251,7 +251,7 @@ void hfs_bnode_move(struct hfs_bnode *node, int dst, int src, int len) | |||
251 | dst &= ~PAGE_CACHE_MASK; | 251 | dst &= ~PAGE_CACHE_MASK; |
252 | 252 | ||
253 | if (src == dst) { | 253 | if (src == dst) { |
254 | l = min(len, (int)PAGE_CACHE_SIZE - src); | 254 | l = min_t(int, len, PAGE_CACHE_SIZE - src); |
255 | memmove(kmap(*dst_page) + src, | 255 | memmove(kmap(*dst_page) + src, |
256 | kmap(*src_page) + src, l); | 256 | kmap(*src_page) + src, l); |
257 | kunmap(*src_page); | 257 | kunmap(*src_page); |
@@ -259,7 +259,7 @@ void hfs_bnode_move(struct hfs_bnode *node, int dst, int src, int len) | |||
259 | kunmap(*dst_page); | 259 | kunmap(*dst_page); |
260 | 260 | ||
261 | while ((len -= l) != 0) { | 261 | while ((len -= l) != 0) { |
262 | l = min(len, (int)PAGE_CACHE_SIZE); | 262 | l = min_t(int, len, PAGE_CACHE_SIZE); |
263 | memmove(kmap(*++dst_page), | 263 | memmove(kmap(*++dst_page), |
264 | kmap(*++src_page), l); | 264 | kmap(*++src_page), l); |
265 | kunmap(*src_page); | 265 | kunmap(*src_page); |
@@ -386,9 +386,8 @@ struct hfs_bnode *hfs_bnode_findhash(struct hfs_btree *tree, u32 cnid) | |||
386 | struct hfs_bnode *node; | 386 | struct hfs_bnode *node; |
387 | 387 | ||
388 | if (cnid >= tree->node_count) { | 388 | if (cnid >= tree->node_count) { |
389 | pr_err("request for non-existent node " | 389 | pr_err("request for non-existent node %d in B*Tree\n", |
390 | "%d in B*Tree\n", | 390 | cnid); |
391 | cnid); | ||
392 | return NULL; | 391 | return NULL; |
393 | } | 392 | } |
394 | 393 | ||
@@ -409,9 +408,8 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid) | |||
409 | loff_t off; | 408 | loff_t off; |
410 | 409 | ||
411 | if (cnid >= tree->node_count) { | 410 | if (cnid >= tree->node_count) { |
412 | pr_err("request for non-existent node " | 411 | pr_err("request for non-existent node %d in B*Tree\n", |
413 | "%d in B*Tree\n", | 412 | cnid); |
414 | cnid); | ||
415 | return NULL; | 413 | return NULL; |
416 | } | 414 | } |
417 | 415 | ||
@@ -602,7 +600,7 @@ struct hfs_bnode *hfs_bnode_create(struct hfs_btree *tree, u32 num) | |||
602 | 600 | ||
603 | pagep = node->page; | 601 | pagep = node->page; |
604 | memset(kmap(*pagep) + node->page_offset, 0, | 602 | memset(kmap(*pagep) + node->page_offset, 0, |
605 | min((int)PAGE_CACHE_SIZE, (int)tree->node_size)); | 603 | min_t(int, PAGE_CACHE_SIZE, tree->node_size)); |
606 | set_page_dirty(*pagep); | 604 | set_page_dirty(*pagep); |
607 | kunmap(*pagep); | 605 | kunmap(*pagep); |
608 | for (i = 1; i < tree->pages_per_bnode; i++) { | 606 | for (i = 1; i < tree->pages_per_bnode; i++) { |
@@ -648,8 +646,8 @@ void hfs_bnode_put(struct hfs_bnode *node) | |||
648 | if (test_bit(HFS_BNODE_DELETED, &node->flags)) { | 646 | if (test_bit(HFS_BNODE_DELETED, &node->flags)) { |
649 | hfs_bnode_unhash(node); | 647 | hfs_bnode_unhash(node); |
650 | spin_unlock(&tree->hash_lock); | 648 | spin_unlock(&tree->hash_lock); |
651 | hfs_bnode_clear(node, 0, | 649 | if (hfs_bnode_need_zeroout(tree)) |
652 | PAGE_CACHE_SIZE * tree->pages_per_bnode); | 650 | hfs_bnode_clear(node, 0, tree->node_size); |
653 | hfs_bmap_free(node); | 651 | hfs_bmap_free(node); |
654 | hfs_bnode_free(node); | 652 | hfs_bnode_free(node); |
655 | return; | 653 | return; |
@@ -658,3 +656,16 @@ void hfs_bnode_put(struct hfs_bnode *node) | |||
658 | } | 656 | } |
659 | } | 657 | } |
660 | 658 | ||
659 | /* | ||
660 | * Unused nodes have to be zeroed if this is the catalog tree and | ||
661 | * a corresponding flag in the volume header is set. | ||
662 | */ | ||
663 | bool hfs_bnode_need_zeroout(struct hfs_btree *tree) | ||
664 | { | ||
665 | struct super_block *sb = tree->inode->i_sb; | ||
666 | struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); | ||
667 | const u32 volume_attr = be32_to_cpu(sbi->s_vhdr->attributes); | ||
668 | |||
669 | return tree->cnid == HFSPLUS_CAT_CNID && | ||
670 | volume_attr & HFSPLUS_VOL_UNUSED_NODE_FIX; | ||
671 | } | ||
diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c index 0fcec8b2a90b..3345c7553edc 100644 --- a/fs/hfsplus/btree.c +++ b/fs/hfsplus/btree.c | |||
@@ -358,7 +358,7 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree) | |||
358 | u32 count; | 358 | u32 count; |
359 | int res; | 359 | int res; |
360 | 360 | ||
361 | res = hfsplus_file_extend(inode); | 361 | res = hfsplus_file_extend(inode, hfs_bnode_need_zeroout(tree)); |
362 | if (res) | 362 | if (res) |
363 | return ERR_PTR(res); | 363 | return ERR_PTR(res); |
364 | hip->phys_size = inode->i_size = | 364 | hip->phys_size = inode->i_size = |
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c index bdec66522de3..610a3260bef1 100644 --- a/fs/hfsplus/dir.c +++ b/fs/hfsplus/dir.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/fs.h> | 12 | #include <linux/fs.h> |
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/random.h> | 14 | #include <linux/random.h> |
15 | #include <linux/nls.h> | ||
15 | 16 | ||
16 | #include "hfsplus_fs.h" | 17 | #include "hfsplus_fs.h" |
17 | #include "hfsplus_raw.h" | 18 | #include "hfsplus_raw.h" |
@@ -127,7 +128,7 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx) | |||
127 | struct inode *inode = file_inode(file); | 128 | struct inode *inode = file_inode(file); |
128 | struct super_block *sb = inode->i_sb; | 129 | struct super_block *sb = inode->i_sb; |
129 | int len, err; | 130 | int len, err; |
130 | char strbuf[HFSPLUS_MAX_STRLEN + 1]; | 131 | char *strbuf; |
131 | hfsplus_cat_entry entry; | 132 | hfsplus_cat_entry entry; |
132 | struct hfs_find_data fd; | 133 | struct hfs_find_data fd; |
133 | struct hfsplus_readdir_data *rd; | 134 | struct hfsplus_readdir_data *rd; |
@@ -139,6 +140,11 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx) | |||
139 | err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd); | 140 | err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd); |
140 | if (err) | 141 | if (err) |
141 | return err; | 142 | return err; |
143 | strbuf = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_MAX_STRLEN + 1, GFP_KERNEL); | ||
144 | if (!strbuf) { | ||
145 | err = -ENOMEM; | ||
146 | goto out; | ||
147 | } | ||
142 | hfsplus_cat_build_key(sb, fd.search_key, inode->i_ino, NULL); | 148 | hfsplus_cat_build_key(sb, fd.search_key, inode->i_ino, NULL); |
143 | err = hfs_brec_find(&fd, hfs_find_rec_by_key); | 149 | err = hfs_brec_find(&fd, hfs_find_rec_by_key); |
144 | if (err) | 150 | if (err) |
@@ -193,7 +199,7 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx) | |||
193 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, | 199 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, |
194 | fd.entrylength); | 200 | fd.entrylength); |
195 | type = be16_to_cpu(entry.type); | 201 | type = be16_to_cpu(entry.type); |
196 | len = HFSPLUS_MAX_STRLEN; | 202 | len = NLS_MAX_CHARSET_SIZE * HFSPLUS_MAX_STRLEN; |
197 | err = hfsplus_uni2asc(sb, &fd.key->cat.name, strbuf, &len); | 203 | err = hfsplus_uni2asc(sb, &fd.key->cat.name, strbuf, &len); |
198 | if (err) | 204 | if (err) |
199 | goto out; | 205 | goto out; |
@@ -212,13 +218,31 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx) | |||
212 | be32_to_cpu(entry.folder.id), DT_DIR)) | 218 | be32_to_cpu(entry.folder.id), DT_DIR)) |
213 | break; | 219 | break; |
214 | } else if (type == HFSPLUS_FILE) { | 220 | } else if (type == HFSPLUS_FILE) { |
221 | u16 mode; | ||
222 | unsigned type = DT_UNKNOWN; | ||
223 | |||
215 | if (fd.entrylength < sizeof(struct hfsplus_cat_file)) { | 224 | if (fd.entrylength < sizeof(struct hfsplus_cat_file)) { |
216 | pr_err("small file entry\n"); | 225 | pr_err("small file entry\n"); |
217 | err = -EIO; | 226 | err = -EIO; |
218 | goto out; | 227 | goto out; |
219 | } | 228 | } |
229 | |||
230 | mode = be16_to_cpu(entry.file.permissions.mode); | ||
231 | if (S_ISREG(mode)) | ||
232 | type = DT_REG; | ||
233 | else if (S_ISLNK(mode)) | ||
234 | type = DT_LNK; | ||
235 | else if (S_ISFIFO(mode)) | ||
236 | type = DT_FIFO; | ||
237 | else if (S_ISCHR(mode)) | ||
238 | type = DT_CHR; | ||
239 | else if (S_ISBLK(mode)) | ||
240 | type = DT_BLK; | ||
241 | else if (S_ISSOCK(mode)) | ||
242 | type = DT_SOCK; | ||
243 | |||
220 | if (!dir_emit(ctx, strbuf, len, | 244 | if (!dir_emit(ctx, strbuf, len, |
221 | be32_to_cpu(entry.file.id), DT_REG)) | 245 | be32_to_cpu(entry.file.id), type)) |
222 | break; | 246 | break; |
223 | } else { | 247 | } else { |
224 | pr_err("bad catalog entry type\n"); | 248 | pr_err("bad catalog entry type\n"); |
@@ -246,6 +270,7 @@ next: | |||
246 | } | 270 | } |
247 | memcpy(&rd->key, fd.key, sizeof(struct hfsplus_cat_key)); | 271 | memcpy(&rd->key, fd.key, sizeof(struct hfsplus_cat_key)); |
248 | out: | 272 | out: |
273 | kfree(strbuf); | ||
249 | hfs_find_exit(&fd); | 274 | hfs_find_exit(&fd); |
250 | return err; | 275 | return err; |
251 | } | 276 | } |
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c index a7aafb35b624..feca524ce2a5 100644 --- a/fs/hfsplus/extents.c +++ b/fs/hfsplus/extents.c | |||
@@ -235,7 +235,7 @@ int hfsplus_get_block(struct inode *inode, sector_t iblock, | |||
235 | if (iblock > hip->fs_blocks || !create) | 235 | if (iblock > hip->fs_blocks || !create) |
236 | return -EIO; | 236 | return -EIO; |
237 | if (ablock >= hip->alloc_blocks) { | 237 | if (ablock >= hip->alloc_blocks) { |
238 | res = hfsplus_file_extend(inode); | 238 | res = hfsplus_file_extend(inode, false); |
239 | if (res) | 239 | if (res) |
240 | return res; | 240 | return res; |
241 | } | 241 | } |
@@ -425,7 +425,7 @@ int hfsplus_free_fork(struct super_block *sb, u32 cnid, | |||
425 | return res; | 425 | return res; |
426 | } | 426 | } |
427 | 427 | ||
428 | int hfsplus_file_extend(struct inode *inode) | 428 | int hfsplus_file_extend(struct inode *inode, bool zeroout) |
429 | { | 429 | { |
430 | struct super_block *sb = inode->i_sb; | 430 | struct super_block *sb = inode->i_sb; |
431 | struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); | 431 | struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); |
@@ -436,10 +436,9 @@ int hfsplus_file_extend(struct inode *inode) | |||
436 | if (sbi->alloc_file->i_size * 8 < | 436 | if (sbi->alloc_file->i_size * 8 < |
437 | sbi->total_blocks - sbi->free_blocks + 8) { | 437 | sbi->total_blocks - sbi->free_blocks + 8) { |
438 | /* extend alloc file */ | 438 | /* extend alloc file */ |
439 | pr_err("extend alloc file! " | 439 | pr_err("extend alloc file! (%llu,%u,%u)\n", |
440 | "(%llu,%u,%u)\n", | 440 | sbi->alloc_file->i_size * 8, |
441 | sbi->alloc_file->i_size * 8, | 441 | sbi->total_blocks, sbi->free_blocks); |
442 | sbi->total_blocks, sbi->free_blocks); | ||
443 | return -ENOSPC; | 442 | return -ENOSPC; |
444 | } | 443 | } |
445 | 444 | ||
@@ -463,6 +462,12 @@ int hfsplus_file_extend(struct inode *inode) | |||
463 | } | 462 | } |
464 | } | 463 | } |
465 | 464 | ||
465 | if (zeroout) { | ||
466 | res = sb_issue_zeroout(sb, start, len, GFP_NOFS); | ||
467 | if (res) | ||
468 | goto out; | ||
469 | } | ||
470 | |||
466 | hfs_dbg(EXTENT, "extend %lu: %u,%u\n", inode->i_ino, start, len); | 471 | hfs_dbg(EXTENT, "extend %lu: %u,%u\n", inode->i_ino, start, len); |
467 | 472 | ||
468 | if (hip->alloc_blocks <= hip->first_blocks) { | 473 | if (hip->alloc_blocks <= hip->first_blocks) { |
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h index 83dc29286b10..eb5e059f481a 100644 --- a/fs/hfsplus/hfsplus_fs.h +++ b/fs/hfsplus/hfsplus_fs.h | |||
@@ -369,114 +369,119 @@ typedef int (*search_strategy_t)(struct hfs_bnode *, | |||
369 | /* attributes.c */ | 369 | /* attributes.c */ |
370 | int __init hfsplus_create_attr_tree_cache(void); | 370 | int __init hfsplus_create_attr_tree_cache(void); |
371 | void hfsplus_destroy_attr_tree_cache(void); | 371 | void hfsplus_destroy_attr_tree_cache(void); |
372 | int hfsplus_attr_bin_cmp_key(const hfsplus_btree_key *k1, | ||
373 | const hfsplus_btree_key *k2); | ||
374 | int hfsplus_attr_build_key(struct super_block *sb, hfsplus_btree_key *key, | ||
375 | u32 cnid, const char *name); | ||
372 | hfsplus_attr_entry *hfsplus_alloc_attr_entry(void); | 376 | hfsplus_attr_entry *hfsplus_alloc_attr_entry(void); |
373 | void hfsplus_destroy_attr_entry(hfsplus_attr_entry *entry_p); | 377 | void hfsplus_destroy_attr_entry(hfsplus_attr_entry *entry); |
374 | int hfsplus_attr_bin_cmp_key(const hfsplus_btree_key *, | 378 | int hfsplus_find_attr(struct super_block *sb, u32 cnid, const char *name, |
375 | const hfsplus_btree_key *); | 379 | struct hfs_find_data *fd); |
376 | int hfsplus_attr_build_key(struct super_block *, hfsplus_btree_key *, | ||
377 | u32, const char *); | ||
378 | void hfsplus_attr_build_key_uni(hfsplus_btree_key *key, | ||
379 | u32 cnid, | ||
380 | struct hfsplus_attr_unistr *name); | ||
381 | int hfsplus_find_attr(struct super_block *, u32, | ||
382 | const char *, struct hfs_find_data *); | ||
383 | int hfsplus_attr_exists(struct inode *inode, const char *name); | 380 | int hfsplus_attr_exists(struct inode *inode, const char *name); |
384 | int hfsplus_create_attr(struct inode *, const char *, const void *, size_t); | 381 | int hfsplus_create_attr(struct inode *inode, const char *name, |
385 | int hfsplus_delete_attr(struct inode *, const char *); | 382 | const void *value, size_t size); |
383 | int hfsplus_delete_attr(struct inode *inode, const char *name); | ||
386 | int hfsplus_delete_all_attrs(struct inode *dir, u32 cnid); | 384 | int hfsplus_delete_all_attrs(struct inode *dir, u32 cnid); |
387 | 385 | ||
388 | /* bitmap.c */ | 386 | /* bitmap.c */ |
389 | int hfsplus_block_allocate(struct super_block *, u32, u32, u32 *); | 387 | int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, |
390 | int hfsplus_block_free(struct super_block *, u32, u32); | 388 | u32 *max); |
389 | int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count); | ||
391 | 390 | ||
392 | /* btree.c */ | 391 | /* btree.c */ |
393 | u32 hfsplus_calc_btree_clump_size(u32, u32, u64, int); | 392 | u32 hfsplus_calc_btree_clump_size(u32 block_size, u32 node_size, u64 sectors, |
394 | struct hfs_btree *hfs_btree_open(struct super_block *, u32); | 393 | int file_id); |
395 | void hfs_btree_close(struct hfs_btree *); | 394 | struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id); |
396 | int hfs_btree_write(struct hfs_btree *); | 395 | void hfs_btree_close(struct hfs_btree *tree); |
397 | struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *); | 396 | int hfs_btree_write(struct hfs_btree *tree); |
398 | void hfs_bmap_free(struct hfs_bnode *); | 397 | struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree); |
398 | void hfs_bmap_free(struct hfs_bnode *node); | ||
399 | 399 | ||
400 | /* bnode.c */ | 400 | /* bnode.c */ |
401 | void hfs_bnode_read(struct hfs_bnode *, void *, int, int); | 401 | void hfs_bnode_read(struct hfs_bnode *node, void *buf, int off, int len); |
402 | u16 hfs_bnode_read_u16(struct hfs_bnode *, int); | 402 | u16 hfs_bnode_read_u16(struct hfs_bnode *node, int off); |
403 | u8 hfs_bnode_read_u8(struct hfs_bnode *, int); | 403 | u8 hfs_bnode_read_u8(struct hfs_bnode *node, int off); |
404 | void hfs_bnode_read_key(struct hfs_bnode *, void *, int); | 404 | void hfs_bnode_read_key(struct hfs_bnode *node, void *key, int off); |
405 | void hfs_bnode_write(struct hfs_bnode *, void *, int, int); | 405 | void hfs_bnode_write(struct hfs_bnode *node, void *buf, int off, int len); |
406 | void hfs_bnode_write_u16(struct hfs_bnode *, int, u16); | 406 | void hfs_bnode_write_u16(struct hfs_bnode *node, int off, u16 data); |
407 | void hfs_bnode_clear(struct hfs_bnode *, int, int); | 407 | void hfs_bnode_clear(struct hfs_bnode *node, int off, int len); |
408 | void hfs_bnode_copy(struct hfs_bnode *, int, | 408 | void hfs_bnode_copy(struct hfs_bnode *dst_node, int dst, |
409 | struct hfs_bnode *, int, int); | 409 | struct hfs_bnode *src_node, int src, int len); |
410 | void hfs_bnode_move(struct hfs_bnode *, int, int, int); | 410 | void hfs_bnode_move(struct hfs_bnode *node, int dst, int src, int len); |
411 | void hfs_bnode_dump(struct hfs_bnode *); | 411 | void hfs_bnode_dump(struct hfs_bnode *node); |
412 | void hfs_bnode_unlink(struct hfs_bnode *); | 412 | void hfs_bnode_unlink(struct hfs_bnode *node); |
413 | struct hfs_bnode *hfs_bnode_findhash(struct hfs_btree *, u32); | 413 | struct hfs_bnode *hfs_bnode_findhash(struct hfs_btree *tree, u32 cnid); |
414 | struct hfs_bnode *hfs_bnode_find(struct hfs_btree *, u32); | 414 | void hfs_bnode_unhash(struct hfs_bnode *node); |
415 | void hfs_bnode_unhash(struct hfs_bnode *); | 415 | struct hfs_bnode *hfs_bnode_find(struct hfs_btree *tree, u32 num); |
416 | void hfs_bnode_free(struct hfs_bnode *); | 416 | void hfs_bnode_free(struct hfs_bnode *node); |
417 | struct hfs_bnode *hfs_bnode_create(struct hfs_btree *, u32); | 417 | struct hfs_bnode *hfs_bnode_create(struct hfs_btree *tree, u32 num); |
418 | void hfs_bnode_get(struct hfs_bnode *); | 418 | void hfs_bnode_get(struct hfs_bnode *node); |
419 | void hfs_bnode_put(struct hfs_bnode *); | 419 | void hfs_bnode_put(struct hfs_bnode *node); |
420 | bool hfs_bnode_need_zeroout(struct hfs_btree *tree); | ||
420 | 421 | ||
421 | /* brec.c */ | 422 | /* brec.c */ |
422 | u16 hfs_brec_lenoff(struct hfs_bnode *, u16, u16 *); | 423 | u16 hfs_brec_lenoff(struct hfs_bnode *node, u16 rec, u16 *off); |
423 | u16 hfs_brec_keylen(struct hfs_bnode *, u16); | 424 | u16 hfs_brec_keylen(struct hfs_bnode *node, u16 rec); |
424 | int hfs_brec_insert(struct hfs_find_data *, void *, int); | 425 | int hfs_brec_insert(struct hfs_find_data *fd, void *entry, int entry_len); |
425 | int hfs_brec_remove(struct hfs_find_data *); | 426 | int hfs_brec_remove(struct hfs_find_data *fd); |
426 | 427 | ||
427 | /* bfind.c */ | 428 | /* bfind.c */ |
428 | int hfs_find_init(struct hfs_btree *, struct hfs_find_data *); | 429 | int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd); |
429 | void hfs_find_exit(struct hfs_find_data *); | 430 | void hfs_find_exit(struct hfs_find_data *fd); |
430 | int hfs_find_1st_rec_by_cnid(struct hfs_bnode *, | 431 | int hfs_find_1st_rec_by_cnid(struct hfs_bnode *bnode, struct hfs_find_data *fd, |
431 | struct hfs_find_data *, | 432 | int *begin, int *end, int *cur_rec); |
432 | int *, int *, int *); | 433 | int hfs_find_rec_by_key(struct hfs_bnode *bnode, struct hfs_find_data *fd, |
433 | int hfs_find_rec_by_key(struct hfs_bnode *, | 434 | int *begin, int *end, int *cur_rec); |
434 | struct hfs_find_data *, | 435 | int __hfs_brec_find(struct hfs_bnode *bnode, struct hfs_find_data *fd, |
435 | int *, int *, int *); | 436 | search_strategy_t rec_found); |
436 | int __hfs_brec_find(struct hfs_bnode *, struct hfs_find_data *, | 437 | int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare); |
437 | search_strategy_t); | 438 | int hfs_brec_read(struct hfs_find_data *fd, void *rec, int rec_len); |
438 | int hfs_brec_find(struct hfs_find_data *, search_strategy_t); | 439 | int hfs_brec_goto(struct hfs_find_data *fd, int cnt); |
439 | int hfs_brec_read(struct hfs_find_data *, void *, int); | ||
440 | int hfs_brec_goto(struct hfs_find_data *, int); | ||
441 | 440 | ||
442 | /* catalog.c */ | 441 | /* catalog.c */ |
443 | int hfsplus_cat_case_cmp_key(const hfsplus_btree_key *, | 442 | int hfsplus_cat_case_cmp_key(const hfsplus_btree_key *k1, |
444 | const hfsplus_btree_key *); | 443 | const hfsplus_btree_key *k2); |
445 | int hfsplus_cat_bin_cmp_key(const hfsplus_btree_key *, | 444 | int hfsplus_cat_bin_cmp_key(const hfsplus_btree_key *k1, |
446 | const hfsplus_btree_key *); | 445 | const hfsplus_btree_key *k2); |
447 | void hfsplus_cat_build_key(struct super_block *sb, | 446 | void hfsplus_cat_build_key(struct super_block *sb, hfsplus_btree_key *key, |
448 | hfsplus_btree_key *, u32, struct qstr *); | 447 | u32 parent, struct qstr *str); |
449 | int hfsplus_find_cat(struct super_block *, u32, struct hfs_find_data *); | ||
450 | int hfsplus_create_cat(u32, struct inode *, struct qstr *, struct inode *); | ||
451 | int hfsplus_delete_cat(u32, struct inode *, struct qstr *); | ||
452 | int hfsplus_rename_cat(u32, struct inode *, struct qstr *, | ||
453 | struct inode *, struct qstr *); | ||
454 | void hfsplus_cat_set_perms(struct inode *inode, struct hfsplus_perm *perms); | 448 | void hfsplus_cat_set_perms(struct inode *inode, struct hfsplus_perm *perms); |
449 | int hfsplus_find_cat(struct super_block *sb, u32 cnid, | ||
450 | struct hfs_find_data *fd); | ||
451 | int hfsplus_create_cat(u32 cnid, struct inode *dir, struct qstr *str, | ||
452 | struct inode *inode); | ||
453 | int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str); | ||
454 | int hfsplus_rename_cat(u32 cnid, struct inode *src_dir, struct qstr *src_name, | ||
455 | struct inode *dst_dir, struct qstr *dst_name); | ||
455 | 456 | ||
456 | /* dir.c */ | 457 | /* dir.c */ |
457 | extern const struct inode_operations hfsplus_dir_inode_operations; | 458 | extern const struct inode_operations hfsplus_dir_inode_operations; |
458 | extern const struct file_operations hfsplus_dir_operations; | 459 | extern const struct file_operations hfsplus_dir_operations; |
459 | 460 | ||
460 | /* extents.c */ | 461 | /* extents.c */ |
461 | int hfsplus_ext_cmp_key(const hfsplus_btree_key *, const hfsplus_btree_key *); | 462 | int hfsplus_ext_cmp_key(const hfsplus_btree_key *k1, |
462 | int hfsplus_ext_write_extent(struct inode *); | 463 | const hfsplus_btree_key *k2); |
463 | int hfsplus_get_block(struct inode *, sector_t, struct buffer_head *, int); | 464 | int hfsplus_ext_write_extent(struct inode *inode); |
464 | int hfsplus_free_fork(struct super_block *, u32, | 465 | int hfsplus_get_block(struct inode *inode, sector_t iblock, |
465 | struct hfsplus_fork_raw *, int); | 466 | struct buffer_head *bh_result, int create); |
466 | int hfsplus_file_extend(struct inode *); | 467 | int hfsplus_free_fork(struct super_block *sb, u32 cnid, |
467 | void hfsplus_file_truncate(struct inode *); | 468 | struct hfsplus_fork_raw *fork, int type); |
469 | int hfsplus_file_extend(struct inode *inode, bool zeroout); | ||
470 | void hfsplus_file_truncate(struct inode *inode); | ||
468 | 471 | ||
469 | /* inode.c */ | 472 | /* inode.c */ |
470 | extern const struct address_space_operations hfsplus_aops; | 473 | extern const struct address_space_operations hfsplus_aops; |
471 | extern const struct address_space_operations hfsplus_btree_aops; | 474 | extern const struct address_space_operations hfsplus_btree_aops; |
472 | extern const struct dentry_operations hfsplus_dentry_operations; | 475 | extern const struct dentry_operations hfsplus_dentry_operations; |
473 | 476 | ||
474 | void hfsplus_inode_read_fork(struct inode *, struct hfsplus_fork_raw *); | 477 | struct inode *hfsplus_new_inode(struct super_block *sb, umode_t mode); |
475 | void hfsplus_inode_write_fork(struct inode *, struct hfsplus_fork_raw *); | 478 | void hfsplus_delete_inode(struct inode *inode); |
476 | int hfsplus_cat_read_inode(struct inode *, struct hfs_find_data *); | 479 | void hfsplus_inode_read_fork(struct inode *inode, |
477 | int hfsplus_cat_write_inode(struct inode *); | 480 | struct hfsplus_fork_raw *fork); |
478 | struct inode *hfsplus_new_inode(struct super_block *, umode_t); | 481 | void hfsplus_inode_write_fork(struct inode *inode, |
479 | void hfsplus_delete_inode(struct inode *); | 482 | struct hfsplus_fork_raw *fork); |
483 | int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd); | ||
484 | int hfsplus_cat_write_inode(struct inode *inode); | ||
480 | int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end, | 485 | int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end, |
481 | int datasync); | 486 | int datasync); |
482 | 487 | ||
@@ -484,13 +489,17 @@ int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end, | |||
484 | long hfsplus_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); | 489 | long hfsplus_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); |
485 | 490 | ||
486 | /* options.c */ | 491 | /* options.c */ |
487 | int hfsplus_parse_options(char *, struct hfsplus_sb_info *); | 492 | void hfsplus_fill_defaults(struct hfsplus_sb_info *opts); |
488 | int hfsplus_parse_options_remount(char *input, int *force); | 493 | int hfsplus_parse_options_remount(char *input, int *force); |
489 | void hfsplus_fill_defaults(struct hfsplus_sb_info *); | 494 | int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi); |
490 | int hfsplus_show_options(struct seq_file *, struct dentry *); | 495 | int hfsplus_show_options(struct seq_file *seq, struct dentry *root); |
496 | |||
497 | /* part_tbl.c */ | ||
498 | int hfs_part_find(struct super_block *sb, sector_t *part_start, | ||
499 | sector_t *part_size); | ||
491 | 500 | ||
492 | /* super.c */ | 501 | /* super.c */ |
493 | struct inode *hfsplus_iget(struct super_block *, unsigned long); | 502 | struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino); |
494 | void hfsplus_mark_mdb_dirty(struct super_block *sb); | 503 | void hfsplus_mark_mdb_dirty(struct super_block *sb); |
495 | 504 | ||
496 | /* tables.c */ | 505 | /* tables.c */ |
@@ -499,23 +508,23 @@ extern u16 hfsplus_decompose_table[]; | |||
499 | extern u16 hfsplus_compose_table[]; | 508 | extern u16 hfsplus_compose_table[]; |
500 | 509 | ||
501 | /* unicode.c */ | 510 | /* unicode.c */ |
502 | int hfsplus_strcasecmp(const struct hfsplus_unistr *, | 511 | int hfsplus_strcasecmp(const struct hfsplus_unistr *s1, |
503 | const struct hfsplus_unistr *); | 512 | const struct hfsplus_unistr *s2); |
504 | int hfsplus_strcmp(const struct hfsplus_unistr *, | 513 | int hfsplus_strcmp(const struct hfsplus_unistr *s1, |
505 | const struct hfsplus_unistr *); | 514 | const struct hfsplus_unistr *s2); |
506 | int hfsplus_uni2asc(struct super_block *, | 515 | int hfsplus_uni2asc(struct super_block *sb, const struct hfsplus_unistr *ustr, |
507 | const struct hfsplus_unistr *, char *, int *); | 516 | char *astr, int *len_p); |
508 | int hfsplus_asc2uni(struct super_block *, | 517 | int hfsplus_asc2uni(struct super_block *sb, struct hfsplus_unistr *ustr, |
509 | struct hfsplus_unistr *, int, const char *, int); | 518 | int max_unistr_len, const char *astr, int len); |
510 | int hfsplus_hash_dentry(const struct dentry *dentry, struct qstr *str); | 519 | int hfsplus_hash_dentry(const struct dentry *dentry, struct qstr *str); |
511 | int hfsplus_compare_dentry(const struct dentry *parent, const struct dentry *dentry, | 520 | int hfsplus_compare_dentry(const struct dentry *parent, |
512 | unsigned int len, const char *str, const struct qstr *name); | 521 | const struct dentry *dentry, unsigned int len, |
522 | const char *str, const struct qstr *name); | ||
513 | 523 | ||
514 | /* wrapper.c */ | 524 | /* wrapper.c */ |
515 | int hfsplus_read_wrapper(struct super_block *); | 525 | int hfsplus_submit_bio(struct super_block *sb, sector_t sector, void *buf, |
516 | int hfs_part_find(struct super_block *, sector_t *, sector_t *); | 526 | void **data, int rw); |
517 | int hfsplus_submit_bio(struct super_block *sb, sector_t sector, | 527 | int hfsplus_read_wrapper(struct super_block *sb); |
518 | void *buf, void **data, int rw); | ||
519 | 528 | ||
520 | /* time macros */ | 529 | /* time macros */ |
521 | #define __hfsp_mt2ut(t) (be32_to_cpu(t) - 2082844800U) | 530 | #define __hfsp_mt2ut(t) (be32_to_cpu(t) - 2082844800U) |
diff --git a/fs/hfsplus/hfsplus_raw.h b/fs/hfsplus/hfsplus_raw.h index 5a126828d85e..8298d0985f81 100644 --- a/fs/hfsplus/hfsplus_raw.h +++ b/fs/hfsplus/hfsplus_raw.h | |||
@@ -144,6 +144,7 @@ struct hfsplus_vh { | |||
144 | #define HFSPLUS_VOL_NODEID_REUSED (1 << 12) | 144 | #define HFSPLUS_VOL_NODEID_REUSED (1 << 12) |
145 | #define HFSPLUS_VOL_JOURNALED (1 << 13) | 145 | #define HFSPLUS_VOL_JOURNALED (1 << 13) |
146 | #define HFSPLUS_VOL_SOFTLOCK (1 << 15) | 146 | #define HFSPLUS_VOL_SOFTLOCK (1 << 15) |
147 | #define HFSPLUS_VOL_UNUSED_NODE_FIX (1 << 31) | ||
147 | 148 | ||
148 | /* HFS+ BTree node descriptor */ | 149 | /* HFS+ BTree node descriptor */ |
149 | struct hfs_bnode_desc { | 150 | struct hfs_bnode_desc { |
diff --git a/fs/hfsplus/options.c b/fs/hfsplus/options.c index 68537e8b7a09..c90b72ee676d 100644 --- a/fs/hfsplus/options.c +++ b/fs/hfsplus/options.c | |||
@@ -173,9 +173,8 @@ int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi) | |||
173 | if (p) | 173 | if (p) |
174 | sbi->nls = load_nls(p); | 174 | sbi->nls = load_nls(p); |
175 | if (!sbi->nls) { | 175 | if (!sbi->nls) { |
176 | pr_err("unable to load " | 176 | pr_err("unable to load nls mapping \"%s\"\n", |
177 | "nls mapping \"%s\"\n", | 177 | p); |
178 | p); | ||
179 | kfree(p); | 178 | kfree(p); |
180 | return 0; | 179 | return 0; |
181 | } | 180 | } |
@@ -232,8 +231,8 @@ int hfsplus_show_options(struct seq_file *seq, struct dentry *root) | |||
232 | if (sbi->nls) | 231 | if (sbi->nls) |
233 | seq_printf(seq, ",nls=%s", sbi->nls->charset); | 232 | seq_printf(seq, ",nls=%s", sbi->nls->charset); |
234 | if (test_bit(HFSPLUS_SB_NODECOMPOSE, &sbi->flags)) | 233 | if (test_bit(HFSPLUS_SB_NODECOMPOSE, &sbi->flags)) |
235 | seq_printf(seq, ",nodecompose"); | 234 | seq_puts(seq, ",nodecompose"); |
236 | if (test_bit(HFSPLUS_SB_NOBARRIER, &sbi->flags)) | 235 | if (test_bit(HFSPLUS_SB_NOBARRIER, &sbi->flags)) |
237 | seq_printf(seq, ",nobarrier"); | 236 | seq_puts(seq, ",nobarrier"); |
238 | return 0; | 237 | return 0; |
239 | } | 238 | } |
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c index a513d2d36be9..4cf2024b87da 100644 --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c | |||
@@ -131,9 +131,10 @@ static int hfsplus_system_write_inode(struct inode *inode) | |||
131 | hfsplus_inode_write_fork(inode, fork); | 131 | hfsplus_inode_write_fork(inode, fork); |
132 | if (tree) { | 132 | if (tree) { |
133 | int err = hfs_btree_write(tree); | 133 | int err = hfs_btree_write(tree); |
134 | |||
134 | if (err) { | 135 | if (err) { |
135 | pr_err("b-tree write err: %d, ino %lu\n", | 136 | pr_err("b-tree write err: %d, ino %lu\n", |
136 | err, inode->i_ino); | 137 | err, inode->i_ino); |
137 | return err; | 138 | return err; |
138 | } | 139 | } |
139 | } | 140 | } |
diff --git a/fs/hfsplus/wrapper.c b/fs/hfsplus/wrapper.c index 3f999649587f..cc6235671437 100644 --- a/fs/hfsplus/wrapper.c +++ b/fs/hfsplus/wrapper.c | |||
@@ -24,8 +24,8 @@ struct hfsplus_wd { | |||
24 | u16 embed_count; | 24 | u16 embed_count; |
25 | }; | 25 | }; |
26 | 26 | ||
27 | /* | 27 | /** |
28 | * hfsplus_submit_bio - Perfrom block I/O | 28 | * hfsplus_submit_bio - Perform block I/O |
29 | * @sb: super block of volume for I/O | 29 | * @sb: super block of volume for I/O |
30 | * @sector: block to read or write, for blocks of HFSPLUS_SECTOR_SIZE bytes | 30 | * @sector: block to read or write, for blocks of HFSPLUS_SECTOR_SIZE bytes |
31 | * @buf: buffer for I/O | 31 | * @buf: buffer for I/O |
@@ -231,10 +231,8 @@ reread: | |||
231 | if (blocksize < HFSPLUS_SECTOR_SIZE || ((blocksize - 1) & blocksize)) | 231 | if (blocksize < HFSPLUS_SECTOR_SIZE || ((blocksize - 1) & blocksize)) |
232 | goto out_free_backup_vhdr; | 232 | goto out_free_backup_vhdr; |
233 | sbi->alloc_blksz = blocksize; | 233 | sbi->alloc_blksz = blocksize; |
234 | sbi->alloc_blksz_shift = 0; | 234 | sbi->alloc_blksz_shift = ilog2(blocksize); |
235 | while ((blocksize >>= 1) != 0) | 235 | blocksize = min_t(u32, sbi->alloc_blksz, PAGE_SIZE); |
236 | sbi->alloc_blksz_shift++; | ||
237 | blocksize = min(sbi->alloc_blksz, (u32)PAGE_SIZE); | ||
238 | 236 | ||
239 | /* | 237 | /* |
240 | * Align block size to block offset. | 238 | * Align block size to block offset. |
diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c index 4e27edc082a4..d98094a9f476 100644 --- a/fs/hfsplus/xattr.c +++ b/fs/hfsplus/xattr.c | |||
@@ -8,6 +8,7 @@ | |||
8 | 8 | ||
9 | #include "hfsplus_fs.h" | 9 | #include "hfsplus_fs.h" |
10 | #include <linux/posix_acl_xattr.h> | 10 | #include <linux/posix_acl_xattr.h> |
11 | #include <linux/nls.h> | ||
11 | #include "xattr.h" | 12 | #include "xattr.h" |
12 | #include "acl.h" | 13 | #include "acl.h" |
13 | 14 | ||
@@ -66,10 +67,10 @@ static void hfsplus_init_header_node(struct inode *attr_file, | |||
66 | char *bmp; | 67 | char *bmp; |
67 | u32 used_nodes; | 68 | u32 used_nodes; |
68 | u32 used_bmp_bytes; | 69 | u32 used_bmp_bytes; |
69 | loff_t tmp; | 70 | u64 tmp; |
70 | 71 | ||
71 | hfs_dbg(ATTR_MOD, "init_hdr_attr_file: clump %u, node_size %u\n", | 72 | hfs_dbg(ATTR_MOD, "init_hdr_attr_file: clump %u, node_size %u\n", |
72 | clump_size, node_size); | 73 | clump_size, node_size); |
73 | 74 | ||
74 | /* The end of the node contains list of record offsets */ | 75 | /* The end of the node contains list of record offsets */ |
75 | rec_offsets = (__be16 *)(buf + node_size); | 76 | rec_offsets = (__be16 *)(buf + node_size); |
@@ -195,7 +196,7 @@ check_attr_tree_state_again: | |||
195 | } | 196 | } |
196 | 197 | ||
197 | while (hip->alloc_blocks < hip->clump_blocks) { | 198 | while (hip->alloc_blocks < hip->clump_blocks) { |
198 | err = hfsplus_file_extend(attr_file); | 199 | err = hfsplus_file_extend(attr_file, false); |
199 | if (unlikely(err)) { | 200 | if (unlikely(err)) { |
200 | pr_err("failed to extend attributes file\n"); | 201 | pr_err("failed to extend attributes file\n"); |
201 | goto end_attr_file_creation; | 202 | goto end_attr_file_creation; |
@@ -645,8 +646,7 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size) | |||
645 | struct hfs_find_data fd; | 646 | struct hfs_find_data fd; |
646 | u16 key_len = 0; | 647 | u16 key_len = 0; |
647 | struct hfsplus_attr_key attr_key; | 648 | struct hfsplus_attr_key attr_key; |
648 | char strbuf[HFSPLUS_ATTR_MAX_STRLEN + | 649 | char *strbuf; |
649 | XATTR_MAC_OSX_PREFIX_LEN + 1] = {0}; | ||
650 | int xattr_name_len; | 650 | int xattr_name_len; |
651 | 651 | ||
652 | if ((!S_ISREG(inode->i_mode) && | 652 | if ((!S_ISREG(inode->i_mode) && |
@@ -666,6 +666,13 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size) | |||
666 | return err; | 666 | return err; |
667 | } | 667 | } |
668 | 668 | ||
669 | strbuf = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + | ||
670 | XATTR_MAC_OSX_PREFIX_LEN + 1, GFP_KERNEL); | ||
671 | if (!strbuf) { | ||
672 | res = -ENOMEM; | ||
673 | goto out; | ||
674 | } | ||
675 | |||
669 | err = hfsplus_find_attr(inode->i_sb, inode->i_ino, NULL, &fd); | 676 | err = hfsplus_find_attr(inode->i_sb, inode->i_ino, NULL, &fd); |
670 | if (err) { | 677 | if (err) { |
671 | if (err == -ENOENT) { | 678 | if (err == -ENOENT) { |
@@ -692,7 +699,7 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size) | |||
692 | if (be32_to_cpu(attr_key.cnid) != inode->i_ino) | 699 | if (be32_to_cpu(attr_key.cnid) != inode->i_ino) |
693 | goto end_listxattr; | 700 | goto end_listxattr; |
694 | 701 | ||
695 | xattr_name_len = HFSPLUS_ATTR_MAX_STRLEN; | 702 | xattr_name_len = NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN; |
696 | if (hfsplus_uni2asc(inode->i_sb, | 703 | if (hfsplus_uni2asc(inode->i_sb, |
697 | (const struct hfsplus_unistr *)&fd.key->attr.key_name, | 704 | (const struct hfsplus_unistr *)&fd.key->attr.key_name, |
698 | strbuf, &xattr_name_len)) { | 705 | strbuf, &xattr_name_len)) { |
@@ -718,6 +725,8 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size) | |||
718 | } | 725 | } |
719 | 726 | ||
720 | end_listxattr: | 727 | end_listxattr: |
728 | kfree(strbuf); | ||
729 | out: | ||
721 | hfs_find_exit(&fd); | 730 | hfs_find_exit(&fd); |
722 | return res; | 731 | return res; |
723 | } | 732 | } |
@@ -797,47 +806,55 @@ end_removexattr: | |||
797 | static int hfsplus_osx_getxattr(struct dentry *dentry, const char *name, | 806 | static int hfsplus_osx_getxattr(struct dentry *dentry, const char *name, |
798 | void *buffer, size_t size, int type) | 807 | void *buffer, size_t size, int type) |
799 | { | 808 | { |
800 | char xattr_name[HFSPLUS_ATTR_MAX_STRLEN + | 809 | char *xattr_name; |
801 | XATTR_MAC_OSX_PREFIX_LEN + 1] = {0}; | 810 | int res; |
802 | size_t len = strlen(name); | ||
803 | 811 | ||
804 | if (!strcmp(name, "")) | 812 | if (!strcmp(name, "")) |
805 | return -EINVAL; | 813 | return -EINVAL; |
806 | 814 | ||
807 | if (len > HFSPLUS_ATTR_MAX_STRLEN) | ||
808 | return -EOPNOTSUPP; | ||
809 | |||
810 | /* | 815 | /* |
811 | * Don't allow retrieving properly prefixed attributes | 816 | * Don't allow retrieving properly prefixed attributes |
812 | * by prepending them with "osx." | 817 | * by prepending them with "osx." |
813 | */ | 818 | */ |
814 | if (is_known_namespace(name)) | 819 | if (is_known_namespace(name)) |
815 | return -EOPNOTSUPP; | 820 | return -EOPNOTSUPP; |
821 | xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN | ||
822 | + XATTR_MAC_OSX_PREFIX_LEN + 1, GFP_KERNEL); | ||
823 | if (!xattr_name) | ||
824 | return -ENOMEM; | ||
825 | strcpy(xattr_name, XATTR_MAC_OSX_PREFIX); | ||
826 | strcpy(xattr_name + XATTR_MAC_OSX_PREFIX_LEN, name); | ||
816 | 827 | ||
817 | return hfsplus_getxattr(dentry, xattr_name, buffer, size); | 828 | res = hfsplus_getxattr(dentry, xattr_name, buffer, size); |
829 | kfree(xattr_name); | ||
830 | return res; | ||
818 | } | 831 | } |
819 | 832 | ||
820 | static int hfsplus_osx_setxattr(struct dentry *dentry, const char *name, | 833 | static int hfsplus_osx_setxattr(struct dentry *dentry, const char *name, |
821 | const void *buffer, size_t size, int flags, int type) | 834 | const void *buffer, size_t size, int flags, int type) |
822 | { | 835 | { |
823 | char xattr_name[HFSPLUS_ATTR_MAX_STRLEN + | 836 | char *xattr_name; |
824 | XATTR_MAC_OSX_PREFIX_LEN + 1] = {0}; | 837 | int res; |
825 | size_t len = strlen(name); | ||
826 | 838 | ||
827 | if (!strcmp(name, "")) | 839 | if (!strcmp(name, "")) |
828 | return -EINVAL; | 840 | return -EINVAL; |
829 | 841 | ||
830 | if (len > HFSPLUS_ATTR_MAX_STRLEN) | ||
831 | return -EOPNOTSUPP; | ||
832 | |||
833 | /* | 842 | /* |
834 | * Don't allow setting properly prefixed attributes | 843 | * Don't allow setting properly prefixed attributes |
835 | * by prepending them with "osx." | 844 | * by prepending them with "osx." |
836 | */ | 845 | */ |
837 | if (is_known_namespace(name)) | 846 | if (is_known_namespace(name)) |
838 | return -EOPNOTSUPP; | 847 | return -EOPNOTSUPP; |
848 | xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN | ||
849 | + XATTR_MAC_OSX_PREFIX_LEN + 1, GFP_KERNEL); | ||
850 | if (!xattr_name) | ||
851 | return -ENOMEM; | ||
852 | strcpy(xattr_name, XATTR_MAC_OSX_PREFIX); | ||
853 | strcpy(xattr_name + XATTR_MAC_OSX_PREFIX_LEN, name); | ||
839 | 854 | ||
840 | return hfsplus_setxattr(dentry, xattr_name, buffer, size, flags); | 855 | res = hfsplus_setxattr(dentry, xattr_name, buffer, size, flags); |
856 | kfree(xattr_name); | ||
857 | return res; | ||
841 | } | 858 | } |
842 | 859 | ||
843 | static size_t hfsplus_osx_listxattr(struct dentry *dentry, char *list, | 860 | static size_t hfsplus_osx_listxattr(struct dentry *dentry, char *list, |
diff --git a/fs/hfsplus/xattr_security.c b/fs/hfsplus/xattr_security.c index 00722765ea79..6ec5e107691f 100644 --- a/fs/hfsplus/xattr_security.c +++ b/fs/hfsplus/xattr_security.c | |||
@@ -7,6 +7,8 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/security.h> | 9 | #include <linux/security.h> |
10 | #include <linux/nls.h> | ||
11 | |||
10 | #include "hfsplus_fs.h" | 12 | #include "hfsplus_fs.h" |
11 | #include "xattr.h" | 13 | #include "xattr.h" |
12 | #include "acl.h" | 14 | #include "acl.h" |
@@ -14,37 +16,43 @@ | |||
14 | static int hfsplus_security_getxattr(struct dentry *dentry, const char *name, | 16 | static int hfsplus_security_getxattr(struct dentry *dentry, const char *name, |
15 | void *buffer, size_t size, int type) | 17 | void *buffer, size_t size, int type) |
16 | { | 18 | { |
17 | char xattr_name[HFSPLUS_ATTR_MAX_STRLEN + 1] = {0}; | 19 | char *xattr_name; |
18 | size_t len = strlen(name); | 20 | int res; |
19 | 21 | ||
20 | if (!strcmp(name, "")) | 22 | if (!strcmp(name, "")) |
21 | return -EINVAL; | 23 | return -EINVAL; |
22 | 24 | ||
23 | if (len + XATTR_SECURITY_PREFIX_LEN > HFSPLUS_ATTR_MAX_STRLEN) | 25 | xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1, |
24 | return -EOPNOTSUPP; | 26 | GFP_KERNEL); |
25 | 27 | if (!xattr_name) | |
28 | return -ENOMEM; | ||
26 | strcpy(xattr_name, XATTR_SECURITY_PREFIX); | 29 | strcpy(xattr_name, XATTR_SECURITY_PREFIX); |
27 | strcpy(xattr_name + XATTR_SECURITY_PREFIX_LEN, name); | 30 | strcpy(xattr_name + XATTR_SECURITY_PREFIX_LEN, name); |
28 | 31 | ||
29 | return hfsplus_getxattr(dentry, xattr_name, buffer, size); | 32 | res = hfsplus_getxattr(dentry, xattr_name, buffer, size); |
33 | kfree(xattr_name); | ||
34 | return res; | ||
30 | } | 35 | } |
31 | 36 | ||
32 | static int hfsplus_security_setxattr(struct dentry *dentry, const char *name, | 37 | static int hfsplus_security_setxattr(struct dentry *dentry, const char *name, |
33 | const void *buffer, size_t size, int flags, int type) | 38 | const void *buffer, size_t size, int flags, int type) |
34 | { | 39 | { |
35 | char xattr_name[HFSPLUS_ATTR_MAX_STRLEN + 1] = {0}; | 40 | char *xattr_name; |
36 | size_t len = strlen(name); | 41 | int res; |
37 | 42 | ||
38 | if (!strcmp(name, "")) | 43 | if (!strcmp(name, "")) |
39 | return -EINVAL; | 44 | return -EINVAL; |
40 | 45 | ||
41 | if (len + XATTR_SECURITY_PREFIX_LEN > HFSPLUS_ATTR_MAX_STRLEN) | 46 | xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1, |
42 | return -EOPNOTSUPP; | 47 | GFP_KERNEL); |
43 | 48 | if (!xattr_name) | |
49 | return -ENOMEM; | ||
44 | strcpy(xattr_name, XATTR_SECURITY_PREFIX); | 50 | strcpy(xattr_name, XATTR_SECURITY_PREFIX); |
45 | strcpy(xattr_name + XATTR_SECURITY_PREFIX_LEN, name); | 51 | strcpy(xattr_name + XATTR_SECURITY_PREFIX_LEN, name); |
46 | 52 | ||
47 | return hfsplus_setxattr(dentry, xattr_name, buffer, size, flags); | 53 | res = hfsplus_setxattr(dentry, xattr_name, buffer, size, flags); |
54 | kfree(xattr_name); | ||
55 | return res; | ||
48 | } | 56 | } |
49 | 57 | ||
50 | static size_t hfsplus_security_listxattr(struct dentry *dentry, char *list, | 58 | static size_t hfsplus_security_listxattr(struct dentry *dentry, char *list, |
@@ -62,31 +70,30 @@ static int hfsplus_initxattrs(struct inode *inode, | |||
62 | void *fs_info) | 70 | void *fs_info) |
63 | { | 71 | { |
64 | const struct xattr *xattr; | 72 | const struct xattr *xattr; |
65 | char xattr_name[HFSPLUS_ATTR_MAX_STRLEN + 1] = {0}; | 73 | char *xattr_name; |
66 | size_t xattr_name_len; | ||
67 | int err = 0; | 74 | int err = 0; |
68 | 75 | ||
76 | xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1, | ||
77 | GFP_KERNEL); | ||
78 | if (!xattr_name) | ||
79 | return -ENOMEM; | ||
69 | for (xattr = xattr_array; xattr->name != NULL; xattr++) { | 80 | for (xattr = xattr_array; xattr->name != NULL; xattr++) { |
70 | xattr_name_len = strlen(xattr->name); | ||
71 | 81 | ||
72 | if (xattr_name_len == 0) | 82 | if (!strcmp(xattr->name, "")) |
73 | continue; | 83 | continue; |
74 | 84 | ||
75 | if (xattr_name_len + XATTR_SECURITY_PREFIX_LEN > | ||
76 | HFSPLUS_ATTR_MAX_STRLEN) | ||
77 | return -EOPNOTSUPP; | ||
78 | |||
79 | strcpy(xattr_name, XATTR_SECURITY_PREFIX); | 85 | strcpy(xattr_name, XATTR_SECURITY_PREFIX); |
80 | strcpy(xattr_name + | 86 | strcpy(xattr_name + |
81 | XATTR_SECURITY_PREFIX_LEN, xattr->name); | 87 | XATTR_SECURITY_PREFIX_LEN, xattr->name); |
82 | memset(xattr_name + | 88 | memset(xattr_name + |
83 | XATTR_SECURITY_PREFIX_LEN + xattr_name_len, 0, 1); | 89 | XATTR_SECURITY_PREFIX_LEN + strlen(xattr->name), 0, 1); |
84 | 90 | ||
85 | err = __hfsplus_setxattr(inode, xattr_name, | 91 | err = __hfsplus_setxattr(inode, xattr_name, |
86 | xattr->value, xattr->value_len, 0); | 92 | xattr->value, xattr->value_len, 0); |
87 | if (err) | 93 | if (err) |
88 | break; | 94 | break; |
89 | } | 95 | } |
96 | kfree(xattr_name); | ||
90 | return err; | 97 | return err; |
91 | } | 98 | } |
92 | 99 | ||
diff --git a/fs/hfsplus/xattr_trusted.c b/fs/hfsplus/xattr_trusted.c index 426cee277542..3c5f27e4746a 100644 --- a/fs/hfsplus/xattr_trusted.c +++ b/fs/hfsplus/xattr_trusted.c | |||
@@ -6,43 +6,51 @@ | |||
6 | * Handler for trusted extended attributes. | 6 | * Handler for trusted extended attributes. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/nls.h> | ||
10 | |||
9 | #include "hfsplus_fs.h" | 11 | #include "hfsplus_fs.h" |
10 | #include "xattr.h" | 12 | #include "xattr.h" |
11 | 13 | ||
12 | static int hfsplus_trusted_getxattr(struct dentry *dentry, const char *name, | 14 | static int hfsplus_trusted_getxattr(struct dentry *dentry, const char *name, |
13 | void *buffer, size_t size, int type) | 15 | void *buffer, size_t size, int type) |
14 | { | 16 | { |
15 | char xattr_name[HFSPLUS_ATTR_MAX_STRLEN + 1] = {0}; | 17 | char *xattr_name; |
16 | size_t len = strlen(name); | 18 | int res; |
17 | 19 | ||
18 | if (!strcmp(name, "")) | 20 | if (!strcmp(name, "")) |
19 | return -EINVAL; | 21 | return -EINVAL; |
20 | 22 | ||
21 | if (len + XATTR_TRUSTED_PREFIX_LEN > HFSPLUS_ATTR_MAX_STRLEN) | 23 | xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1, |
22 | return -EOPNOTSUPP; | 24 | GFP_KERNEL); |
23 | 25 | if (!xattr_name) | |
26 | return -ENOMEM; | ||
24 | strcpy(xattr_name, XATTR_TRUSTED_PREFIX); | 27 | strcpy(xattr_name, XATTR_TRUSTED_PREFIX); |
25 | strcpy(xattr_name + XATTR_TRUSTED_PREFIX_LEN, name); | 28 | strcpy(xattr_name + XATTR_TRUSTED_PREFIX_LEN, name); |
26 | 29 | ||
27 | return hfsplus_getxattr(dentry, xattr_name, buffer, size); | 30 | res = hfsplus_getxattr(dentry, xattr_name, buffer, size); |
31 | kfree(xattr_name); | ||
32 | return res; | ||
28 | } | 33 | } |
29 | 34 | ||
30 | static int hfsplus_trusted_setxattr(struct dentry *dentry, const char *name, | 35 | static int hfsplus_trusted_setxattr(struct dentry *dentry, const char *name, |
31 | const void *buffer, size_t size, int flags, int type) | 36 | const void *buffer, size_t size, int flags, int type) |
32 | { | 37 | { |
33 | char xattr_name[HFSPLUS_ATTR_MAX_STRLEN + 1] = {0}; | 38 | char *xattr_name; |
34 | size_t len = strlen(name); | 39 | int res; |
35 | 40 | ||
36 | if (!strcmp(name, "")) | 41 | if (!strcmp(name, "")) |
37 | return -EINVAL; | 42 | return -EINVAL; |
38 | 43 | ||
39 | if (len + XATTR_TRUSTED_PREFIX_LEN > HFSPLUS_ATTR_MAX_STRLEN) | 44 | xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1, |
40 | return -EOPNOTSUPP; | 45 | GFP_KERNEL); |
41 | 46 | if (!xattr_name) | |
47 | return -ENOMEM; | ||
42 | strcpy(xattr_name, XATTR_TRUSTED_PREFIX); | 48 | strcpy(xattr_name, XATTR_TRUSTED_PREFIX); |
43 | strcpy(xattr_name + XATTR_TRUSTED_PREFIX_LEN, name); | 49 | strcpy(xattr_name + XATTR_TRUSTED_PREFIX_LEN, name); |
44 | 50 | ||
45 | return hfsplus_setxattr(dentry, xattr_name, buffer, size, flags); | 51 | res = hfsplus_setxattr(dentry, xattr_name, buffer, size, flags); |
52 | kfree(xattr_name); | ||
53 | return res; | ||
46 | } | 54 | } |
47 | 55 | ||
48 | static size_t hfsplus_trusted_listxattr(struct dentry *dentry, char *list, | 56 | static size_t hfsplus_trusted_listxattr(struct dentry *dentry, char *list, |
diff --git a/fs/hfsplus/xattr_user.c b/fs/hfsplus/xattr_user.c index e34016561ae0..2b625a538b64 100644 --- a/fs/hfsplus/xattr_user.c +++ b/fs/hfsplus/xattr_user.c | |||
@@ -6,43 +6,51 @@ | |||
6 | * Handler for user extended attributes. | 6 | * Handler for user extended attributes. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/nls.h> | ||
10 | |||
9 | #include "hfsplus_fs.h" | 11 | #include "hfsplus_fs.h" |
10 | #include "xattr.h" | 12 | #include "xattr.h" |
11 | 13 | ||
12 | static int hfsplus_user_getxattr(struct dentry *dentry, const char *name, | 14 | static int hfsplus_user_getxattr(struct dentry *dentry, const char *name, |
13 | void *buffer, size_t size, int type) | 15 | void *buffer, size_t size, int type) |
14 | { | 16 | { |
15 | char xattr_name[HFSPLUS_ATTR_MAX_STRLEN + 1] = {0}; | 17 | char *xattr_name; |
16 | size_t len = strlen(name); | 18 | int res; |
17 | 19 | ||
18 | if (!strcmp(name, "")) | 20 | if (!strcmp(name, "")) |
19 | return -EINVAL; | 21 | return -EINVAL; |
20 | 22 | ||
21 | if (len + XATTR_USER_PREFIX_LEN > HFSPLUS_ATTR_MAX_STRLEN) | 23 | xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1, |
22 | return -EOPNOTSUPP; | 24 | GFP_KERNEL); |
23 | 25 | if (!xattr_name) | |
26 | return -ENOMEM; | ||
24 | strcpy(xattr_name, XATTR_USER_PREFIX); | 27 | strcpy(xattr_name, XATTR_USER_PREFIX); |
25 | strcpy(xattr_name + XATTR_USER_PREFIX_LEN, name); | 28 | strcpy(xattr_name + XATTR_USER_PREFIX_LEN, name); |
26 | 29 | ||
27 | return hfsplus_getxattr(dentry, xattr_name, buffer, size); | 30 | res = hfsplus_getxattr(dentry, xattr_name, buffer, size); |
31 | kfree(xattr_name); | ||
32 | return res; | ||
28 | } | 33 | } |
29 | 34 | ||
30 | static int hfsplus_user_setxattr(struct dentry *dentry, const char *name, | 35 | static int hfsplus_user_setxattr(struct dentry *dentry, const char *name, |
31 | const void *buffer, size_t size, int flags, int type) | 36 | const void *buffer, size_t size, int flags, int type) |
32 | { | 37 | { |
33 | char xattr_name[HFSPLUS_ATTR_MAX_STRLEN + 1] = {0}; | 38 | char *xattr_name; |
34 | size_t len = strlen(name); | 39 | int res; |
35 | 40 | ||
36 | if (!strcmp(name, "")) | 41 | if (!strcmp(name, "")) |
37 | return -EINVAL; | 42 | return -EINVAL; |
38 | 43 | ||
39 | if (len + XATTR_USER_PREFIX_LEN > HFSPLUS_ATTR_MAX_STRLEN) | 44 | xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1, |
40 | return -EOPNOTSUPP; | 45 | GFP_KERNEL); |
41 | 46 | if (!xattr_name) | |
47 | return -ENOMEM; | ||
42 | strcpy(xattr_name, XATTR_USER_PREFIX); | 48 | strcpy(xattr_name, XATTR_USER_PREFIX); |
43 | strcpy(xattr_name + XATTR_USER_PREFIX_LEN, name); | 49 | strcpy(xattr_name + XATTR_USER_PREFIX_LEN, name); |
44 | 50 | ||
45 | return hfsplus_setxattr(dentry, xattr_name, buffer, size, flags); | 51 | res = hfsplus_setxattr(dentry, xattr_name, buffer, size, flags); |
52 | kfree(xattr_name); | ||
53 | return res; | ||
46 | } | 54 | } |
47 | 55 | ||
48 | static size_t hfsplus_user_listxattr(struct dentry *dentry, char *list, | 56 | static size_t hfsplus_user_listxattr(struct dentry *dentry, char *list, |
diff --git a/fs/hpfs/alloc.c b/fs/hpfs/alloc.c index 58b5106186d0..f005046e1591 100644 --- a/fs/hpfs/alloc.c +++ b/fs/hpfs/alloc.c | |||
@@ -316,7 +316,7 @@ void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) | |||
316 | struct quad_buffer_head qbh; | 316 | struct quad_buffer_head qbh; |
317 | __le32 *bmp; | 317 | __le32 *bmp; |
318 | struct hpfs_sb_info *sbi = hpfs_sb(s); | 318 | struct hpfs_sb_info *sbi = hpfs_sb(s); |
319 | /*printk("2 - ");*/ | 319 | /*pr_info("2 - ");*/ |
320 | if (!n) return; | 320 | if (!n) return; |
321 | if (sec < 0x12) { | 321 | if (sec < 0x12) { |
322 | hpfs_error(s, "Trying to free reserved sector %08x", sec); | 322 | hpfs_error(s, "Trying to free reserved sector %08x", sec); |
diff --git a/fs/hpfs/buffer.c b/fs/hpfs/buffer.c index 139ef1684d07..8057fe4e6574 100644 --- a/fs/hpfs/buffer.c +++ b/fs/hpfs/buffer.c | |||
@@ -55,7 +55,7 @@ void *hpfs_map_sector(struct super_block *s, unsigned secno, struct buffer_head | |||
55 | if (bh != NULL) | 55 | if (bh != NULL) |
56 | return bh->b_data; | 56 | return bh->b_data; |
57 | else { | 57 | else { |
58 | printk("HPFS: hpfs_map_sector: read error\n"); | 58 | pr_err("%s(): read error\n", __func__); |
59 | return NULL; | 59 | return NULL; |
60 | } | 60 | } |
61 | } | 61 | } |
@@ -76,7 +76,7 @@ void *hpfs_get_sector(struct super_block *s, unsigned secno, struct buffer_head | |||
76 | set_buffer_uptodate(bh); | 76 | set_buffer_uptodate(bh); |
77 | return bh->b_data; | 77 | return bh->b_data; |
78 | } else { | 78 | } else { |
79 | printk("HPFS: hpfs_get_sector: getblk failed\n"); | 79 | pr_err("%s(): getblk failed\n", __func__); |
80 | return NULL; | 80 | return NULL; |
81 | } | 81 | } |
82 | } | 82 | } |
@@ -93,7 +93,7 @@ void *hpfs_map_4sectors(struct super_block *s, unsigned secno, struct quad_buffe | |||
93 | cond_resched(); | 93 | cond_resched(); |
94 | 94 | ||
95 | if (secno & 3) { | 95 | if (secno & 3) { |
96 | printk("HPFS: hpfs_map_4sectors: unaligned read\n"); | 96 | pr_err("%s(): unaligned read\n", __func__); |
97 | return NULL; | 97 | return NULL; |
98 | } | 98 | } |
99 | 99 | ||
@@ -112,7 +112,7 @@ void *hpfs_map_4sectors(struct super_block *s, unsigned secno, struct quad_buffe | |||
112 | 112 | ||
113 | qbh->data = data = kmalloc(2048, GFP_NOFS); | 113 | qbh->data = data = kmalloc(2048, GFP_NOFS); |
114 | if (!data) { | 114 | if (!data) { |
115 | printk("HPFS: hpfs_map_4sectors: out of memory\n"); | 115 | pr_err("%s(): out of memory\n", __func__); |
116 | goto bail4; | 116 | goto bail4; |
117 | } | 117 | } |
118 | 118 | ||
@@ -145,7 +145,7 @@ void *hpfs_get_4sectors(struct super_block *s, unsigned secno, | |||
145 | hpfs_lock_assert(s); | 145 | hpfs_lock_assert(s); |
146 | 146 | ||
147 | if (secno & 3) { | 147 | if (secno & 3) { |
148 | printk("HPFS: hpfs_get_4sectors: unaligned read\n"); | 148 | pr_err("%s(): unaligned read\n", __func__); |
149 | return NULL; | 149 | return NULL; |
150 | } | 150 | } |
151 | 151 | ||
@@ -161,7 +161,7 @@ void *hpfs_get_4sectors(struct super_block *s, unsigned secno, | |||
161 | } | 161 | } |
162 | 162 | ||
163 | if (!(qbh->data = kmalloc(2048, GFP_NOFS))) { | 163 | if (!(qbh->data = kmalloc(2048, GFP_NOFS))) { |
164 | printk("HPFS: hpfs_get_4sectors: out of memory\n"); | 164 | pr_err("%s(): out of memory\n", __func__); |
165 | goto bail4; | 165 | goto bail4; |
166 | } | 166 | } |
167 | return qbh->data; | 167 | return qbh->data; |
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c index 292b1acb9b81..2a8e07425de0 100644 --- a/fs/hpfs/dir.c +++ b/fs/hpfs/dir.c | |||
@@ -36,7 +36,7 @@ static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence) | |||
36 | mutex_lock(&i->i_mutex); | 36 | mutex_lock(&i->i_mutex); |
37 | hpfs_lock(s); | 37 | hpfs_lock(s); |
38 | 38 | ||
39 | /*printk("dir lseek\n");*/ | 39 | /*pr_info("dir lseek\n");*/ |
40 | if (new_off == 0 || new_off == 1 || new_off == 11 || new_off == 12 || new_off == 13) goto ok; | 40 | if (new_off == 0 || new_off == 1 || new_off == 11 || new_off == 12 || new_off == 13) goto ok; |
41 | pos = ((loff_t) hpfs_de_as_down_as_possible(s, hpfs_inode->i_dno) << 4) + 1; | 41 | pos = ((loff_t) hpfs_de_as_down_as_possible(s, hpfs_inode->i_dno) << 4) + 1; |
42 | while (pos != new_off) { | 42 | while (pos != new_off) { |
@@ -51,7 +51,7 @@ ok: | |||
51 | mutex_unlock(&i->i_mutex); | 51 | mutex_unlock(&i->i_mutex); |
52 | return new_off; | 52 | return new_off; |
53 | fail: | 53 | fail: |
54 | /*printk("illegal lseek: %016llx\n", new_off);*/ | 54 | /*pr_warn("illegal lseek: %016llx\n", new_off);*/ |
55 | hpfs_unlock(s); | 55 | hpfs_unlock(s); |
56 | mutex_unlock(&i->i_mutex); | 56 | mutex_unlock(&i->i_mutex); |
57 | return -ESPIPE; | 57 | return -ESPIPE; |
@@ -127,7 +127,7 @@ static int hpfs_readdir(struct file *file, struct dir_context *ctx) | |||
127 | if (ctx->pos == 12) | 127 | if (ctx->pos == 12) |
128 | goto out; | 128 | goto out; |
129 | if (ctx->pos == 3 || ctx->pos == 4 || ctx->pos == 5) { | 129 | if (ctx->pos == 3 || ctx->pos == 4 || ctx->pos == 5) { |
130 | printk("HPFS: warning: pos==%d\n",(int)ctx->pos); | 130 | pr_err("pos==%d\n", (int)ctx->pos); |
131 | goto out; | 131 | goto out; |
132 | } | 132 | } |
133 | if (ctx->pos == 0) { | 133 | if (ctx->pos == 0) { |
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c index 4364b2a02c5d..f36fc010fccb 100644 --- a/fs/hpfs/dnode.c +++ b/fs/hpfs/dnode.c | |||
@@ -17,7 +17,7 @@ static loff_t get_pos(struct dnode *d, struct hpfs_dirent *fde) | |||
17 | if (de == fde) return ((loff_t) le32_to_cpu(d->self) << 4) | (loff_t)i; | 17 | if (de == fde) return ((loff_t) le32_to_cpu(d->self) << 4) | (loff_t)i; |
18 | i++; | 18 | i++; |
19 | } | 19 | } |
20 | printk("HPFS: get_pos: not_found\n"); | 20 | pr_info("%s(): not_found\n", __func__); |
21 | return ((loff_t)le32_to_cpu(d->self) << 4) | (loff_t)1; | 21 | return ((loff_t)le32_to_cpu(d->self) << 4) | (loff_t)1; |
22 | } | 22 | } |
23 | 23 | ||
@@ -32,7 +32,7 @@ void hpfs_add_pos(struct inode *inode, loff_t *pos) | |||
32 | if (hpfs_inode->i_rddir_off[i] == pos) return; | 32 | if (hpfs_inode->i_rddir_off[i] == pos) return; |
33 | if (!(i&0x0f)) { | 33 | if (!(i&0x0f)) { |
34 | if (!(ppos = kmalloc((i+0x11) * sizeof(loff_t*), GFP_NOFS))) { | 34 | if (!(ppos = kmalloc((i+0x11) * sizeof(loff_t*), GFP_NOFS))) { |
35 | printk("HPFS: out of memory for position list\n"); | 35 | pr_err("out of memory for position list\n"); |
36 | return; | 36 | return; |
37 | } | 37 | } |
38 | if (hpfs_inode->i_rddir_off) { | 38 | if (hpfs_inode->i_rddir_off) { |
@@ -63,7 +63,8 @@ void hpfs_del_pos(struct inode *inode, loff_t *pos) | |||
63 | } | 63 | } |
64 | return; | 64 | return; |
65 | not_f: | 65 | not_f: |
66 | /*printk("HPFS: warning: position pointer %p->%08x not found\n", pos, (int)*pos);*/ | 66 | /*pr_warn("position pointer %p->%08x not found\n", |
67 | pos, (int)*pos);*/ | ||
67 | return; | 68 | return; |
68 | } | 69 | } |
69 | 70 | ||
@@ -92,8 +93,11 @@ static void hpfs_pos_ins(loff_t *p, loff_t d, loff_t c) | |||
92 | { | 93 | { |
93 | if ((*p & ~0x3f) == (d & ~0x3f) && (*p & 0x3f) >= (d & 0x3f)) { | 94 | if ((*p & ~0x3f) == (d & ~0x3f) && (*p & 0x3f) >= (d & 0x3f)) { |
94 | int n = (*p & 0x3f) + c; | 95 | int n = (*p & 0x3f) + c; |
95 | if (n > 0x3f) printk("HPFS: hpfs_pos_ins: %08x + %d\n", (int)*p, (int)c >> 8); | 96 | if (n > 0x3f) |
96 | else *p = (*p & ~0x3f) | n; | 97 | pr_err("%s(): %08x + %d\n", |
98 | __func__, (int)*p, (int)c >> 8); | ||
99 | else | ||
100 | *p = (*p & ~0x3f) | n; | ||
97 | } | 101 | } |
98 | } | 102 | } |
99 | 103 | ||
@@ -101,8 +105,11 @@ static void hpfs_pos_del(loff_t *p, loff_t d, loff_t c) | |||
101 | { | 105 | { |
102 | if ((*p & ~0x3f) == (d & ~0x3f) && (*p & 0x3f) >= (d & 0x3f)) { | 106 | if ((*p & ~0x3f) == (d & ~0x3f) && (*p & 0x3f) >= (d & 0x3f)) { |
103 | int n = (*p & 0x3f) - c; | 107 | int n = (*p & 0x3f) - c; |
104 | if (n < 1) printk("HPFS: hpfs_pos_ins: %08x - %d\n", (int)*p, (int)c >> 8); | 108 | if (n < 1) |
105 | else *p = (*p & ~0x3f) | n; | 109 | pr_err("%s(): %08x - %d\n", |
110 | __func__, (int)*p, (int)c >> 8); | ||
111 | else | ||
112 | *p = (*p & ~0x3f) | n; | ||
106 | } | 113 | } |
107 | } | 114 | } |
108 | 115 | ||
@@ -239,12 +246,12 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
239 | struct fnode *fnode; | 246 | struct fnode *fnode; |
240 | int c1, c2 = 0; | 247 | int c1, c2 = 0; |
241 | if (!(nname = kmalloc(256, GFP_NOFS))) { | 248 | if (!(nname = kmalloc(256, GFP_NOFS))) { |
242 | printk("HPFS: out of memory, can't add to dnode\n"); | 249 | pr_err("out of memory, can't add to dnode\n"); |
243 | return 1; | 250 | return 1; |
244 | } | 251 | } |
245 | go_up: | 252 | go_up: |
246 | if (namelen >= 256) { | 253 | if (namelen >= 256) { |
247 | hpfs_error(i->i_sb, "hpfs_add_to_dnode: namelen == %d", namelen); | 254 | hpfs_error(i->i_sb, "%s(): namelen == %d", __func__, namelen); |
248 | kfree(nd); | 255 | kfree(nd); |
249 | kfree(nname); | 256 | kfree(nname); |
250 | return 1; | 257 | return 1; |
@@ -281,7 +288,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
281 | not be any error while splitting dnodes, otherwise the | 288 | not be any error while splitting dnodes, otherwise the |
282 | whole directory, not only file we're adding, would | 289 | whole directory, not only file we're adding, would |
283 | be lost. */ | 290 | be lost. */ |
284 | printk("HPFS: out of memory for dnode splitting\n"); | 291 | pr_err("out of memory for dnode splitting\n"); |
285 | hpfs_brelse4(&qbh); | 292 | hpfs_brelse4(&qbh); |
286 | kfree(nname); | 293 | kfree(nname); |
287 | return 1; | 294 | return 1; |
@@ -597,7 +604,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
597 | if (!de_next->down) goto endm; | 604 | if (!de_next->down) goto endm; |
598 | ndown = de_down_pointer(de_next); | 605 | ndown = de_down_pointer(de_next); |
599 | if (!(de_cp = kmalloc(le16_to_cpu(de->length), GFP_NOFS))) { | 606 | if (!(de_cp = kmalloc(le16_to_cpu(de->length), GFP_NOFS))) { |
600 | printk("HPFS: out of memory for dtree balancing\n"); | 607 | pr_err("out of memory for dtree balancing\n"); |
601 | goto endm; | 608 | goto endm; |
602 | } | 609 | } |
603 | memcpy(de_cp, de, le16_to_cpu(de->length)); | 610 | memcpy(de_cp, de, le16_to_cpu(de->length)); |
@@ -612,7 +619,8 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
612 | hpfs_brelse4(&qbh1); | 619 | hpfs_brelse4(&qbh1); |
613 | } | 620 | } |
614 | hpfs_add_to_dnode(i, ndown, de_cp->name, de_cp->namelen, de_cp, de_cp->down ? de_down_pointer(de_cp) : 0); | 621 | hpfs_add_to_dnode(i, ndown, de_cp->name, de_cp->namelen, de_cp, de_cp->down ? de_down_pointer(de_cp) : 0); |
615 | /*printk("UP-TO-DNODE: %08x (ndown = %08x, down = %08x, dno = %08x)\n", up, ndown, down, dno);*/ | 622 | /*pr_info("UP-TO-DNODE: %08x (ndown = %08x, down = %08x, dno = %08x)\n", |
623 | up, ndown, down, dno);*/ | ||
616 | dno = up; | 624 | dno = up; |
617 | kfree(de_cp); | 625 | kfree(de_cp); |
618 | goto try_it_again; | 626 | goto try_it_again; |
@@ -637,15 +645,15 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
637 | if (!dlp && down) { | 645 | if (!dlp && down) { |
638 | if (le32_to_cpu(d1->first_free) > 2044) { | 646 | if (le32_to_cpu(d1->first_free) > 2044) { |
639 | if (hpfs_sb(i->i_sb)->sb_chk >= 2) { | 647 | if (hpfs_sb(i->i_sb)->sb_chk >= 2) { |
640 | printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); | 648 | pr_err("unbalanced dnode tree, see hpfs.txt 4 more info\n"); |
641 | printk("HPFS: warning: terminating balancing operation\n"); | 649 | pr_err("terminating balancing operation\n"); |
642 | } | 650 | } |
643 | hpfs_brelse4(&qbh1); | 651 | hpfs_brelse4(&qbh1); |
644 | goto endm; | 652 | goto endm; |
645 | } | 653 | } |
646 | if (hpfs_sb(i->i_sb)->sb_chk >= 2) { | 654 | if (hpfs_sb(i->i_sb)->sb_chk >= 2) { |
647 | printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); | 655 | pr_err("unbalanced dnode tree, see hpfs.txt 4 more info\n"); |
648 | printk("HPFS: warning: goin'on\n"); | 656 | pr_err("goin'on\n"); |
649 | } | 657 | } |
650 | le16_add_cpu(&del->length, 4); | 658 | le16_add_cpu(&del->length, 4); |
651 | del->down = 1; | 659 | del->down = 1; |
@@ -659,7 +667,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
659 | *(__le32 *) ((void *) del + le16_to_cpu(del->length) - 4) = cpu_to_le32(down); | 667 | *(__le32 *) ((void *) del + le16_to_cpu(del->length) - 4) = cpu_to_le32(down); |
660 | } else goto endm; | 668 | } else goto endm; |
661 | if (!(de_cp = kmalloc(le16_to_cpu(de_prev->length), GFP_NOFS))) { | 669 | if (!(de_cp = kmalloc(le16_to_cpu(de_prev->length), GFP_NOFS))) { |
662 | printk("HPFS: out of memory for dtree balancing\n"); | 670 | pr_err("out of memory for dtree balancing\n"); |
663 | hpfs_brelse4(&qbh1); | 671 | hpfs_brelse4(&qbh1); |
664 | goto endm; | 672 | goto endm; |
665 | } | 673 | } |
@@ -1000,7 +1008,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno, | |||
1000 | int d1, d2 = 0; | 1008 | int d1, d2 = 0; |
1001 | name1 = f->name; | 1009 | name1 = f->name; |
1002 | if (!(name2 = kmalloc(256, GFP_NOFS))) { | 1010 | if (!(name2 = kmalloc(256, GFP_NOFS))) { |
1003 | printk("HPFS: out of memory, can't map dirent\n"); | 1011 | pr_err("out of memory, can't map dirent\n"); |
1004 | return NULL; | 1012 | return NULL; |
1005 | } | 1013 | } |
1006 | if (f->len <= 15) | 1014 | if (f->len <= 15) |
diff --git a/fs/hpfs/ea.c b/fs/hpfs/ea.c index bcaafcd2666a..ce3f98ba993a 100644 --- a/fs/hpfs/ea.c +++ b/fs/hpfs/ea.c | |||
@@ -51,7 +51,7 @@ static char *get_indirect_ea(struct super_block *s, int ano, secno a, int size) | |||
51 | { | 51 | { |
52 | char *ret; | 52 | char *ret; |
53 | if (!(ret = kmalloc(size + 1, GFP_NOFS))) { | 53 | if (!(ret = kmalloc(size + 1, GFP_NOFS))) { |
54 | printk("HPFS: out of memory for EA\n"); | 54 | pr_err("out of memory for EA\n"); |
55 | return NULL; | 55 | return NULL; |
56 | } | 56 | } |
57 | if (hpfs_ea_read(s, a, ano, 0, size, ret)) { | 57 | if (hpfs_ea_read(s, a, ano, 0, size, ret)) { |
@@ -139,7 +139,7 @@ char *hpfs_get_ea(struct super_block *s, struct fnode *fnode, char *key, int *si | |||
139 | if (ea_indirect(ea)) | 139 | if (ea_indirect(ea)) |
140 | return get_indirect_ea(s, ea_in_anode(ea), ea_sec(ea), *size = ea_len(ea)); | 140 | return get_indirect_ea(s, ea_in_anode(ea), ea_sec(ea), *size = ea_len(ea)); |
141 | if (!(ret = kmalloc((*size = ea_valuelen(ea)) + 1, GFP_NOFS))) { | 141 | if (!(ret = kmalloc((*size = ea_valuelen(ea)) + 1, GFP_NOFS))) { |
142 | printk("HPFS: out of memory for EA\n"); | 142 | pr_err("out of memory for EA\n"); |
143 | return NULL; | 143 | return NULL; |
144 | } | 144 | } |
145 | memcpy(ret, ea_data(ea), ea_valuelen(ea)); | 145 | memcpy(ret, ea_data(ea), ea_valuelen(ea)); |
@@ -165,7 +165,7 @@ char *hpfs_get_ea(struct super_block *s, struct fnode *fnode, char *key, int *si | |||
165 | if (ea_indirect(ea)) | 165 | if (ea_indirect(ea)) |
166 | return get_indirect_ea(s, ea_in_anode(ea), ea_sec(ea), *size = ea_len(ea)); | 166 | return get_indirect_ea(s, ea_in_anode(ea), ea_sec(ea), *size = ea_len(ea)); |
167 | if (!(ret = kmalloc((*size = ea_valuelen(ea)) + 1, GFP_NOFS))) { | 167 | if (!(ret = kmalloc((*size = ea_valuelen(ea)) + 1, GFP_NOFS))) { |
168 | printk("HPFS: out of memory for EA\n"); | 168 | pr_err("out of memory for EA\n"); |
169 | return NULL; | 169 | return NULL; |
170 | } | 170 | } |
171 | if (hpfs_ea_read(s, a, ano, pos + 4 + ea->namelen + 1, ea_valuelen(ea), ret)) { | 171 | if (hpfs_ea_read(s, a, ano, pos + 4 + ea->namelen + 1, ea_valuelen(ea), ret)) { |
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h index 3ba49c080e42..b63b75fa00e7 100644 --- a/fs/hpfs/hpfs_fn.h +++ b/fs/hpfs/hpfs_fn.h | |||
@@ -8,6 +8,11 @@ | |||
8 | 8 | ||
9 | //#define DBG | 9 | //#define DBG |
10 | //#define DEBUG_LOCKS | 10 | //#define DEBUG_LOCKS |
11 | #ifdef pr_fmt | ||
12 | #undef pr_fmt | ||
13 | #endif | ||
14 | |||
15 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
11 | 16 | ||
12 | #include <linux/mutex.h> | 17 | #include <linux/mutex.h> |
13 | #include <linux/pagemap.h> | 18 | #include <linux/pagemap.h> |
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c index 50a427313835..7ce4b74234a1 100644 --- a/fs/hpfs/inode.c +++ b/fs/hpfs/inode.c | |||
@@ -183,7 +183,8 @@ void hpfs_write_inode(struct inode *i) | |||
183 | struct inode *parent; | 183 | struct inode *parent; |
184 | if (i->i_ino == hpfs_sb(i->i_sb)->sb_root) return; | 184 | if (i->i_ino == hpfs_sb(i->i_sb)->sb_root) return; |
185 | if (hpfs_inode->i_rddir_off && !atomic_read(&i->i_count)) { | 185 | if (hpfs_inode->i_rddir_off && !atomic_read(&i->i_count)) { |
186 | if (*hpfs_inode->i_rddir_off) printk("HPFS: write_inode: some position still there\n"); | 186 | if (*hpfs_inode->i_rddir_off) |
187 | pr_err("write_inode: some position still there\n"); | ||
187 | kfree(hpfs_inode->i_rddir_off); | 188 | kfree(hpfs_inode->i_rddir_off); |
188 | hpfs_inode->i_rddir_off = NULL; | 189 | hpfs_inode->i_rddir_off = NULL; |
189 | } | 190 | } |
diff --git a/fs/hpfs/map.c b/fs/hpfs/map.c index 3aa66ae1031e..442770edcdc7 100644 --- a/fs/hpfs/map.c +++ b/fs/hpfs/map.c | |||
@@ -65,12 +65,13 @@ unsigned char *hpfs_load_code_page(struct super_block *s, secno cps) | |||
65 | struct code_page_directory *cp = hpfs_map_sector(s, cps, &bh, 0); | 65 | struct code_page_directory *cp = hpfs_map_sector(s, cps, &bh, 0); |
66 | if (!cp) return NULL; | 66 | if (!cp) return NULL; |
67 | if (le32_to_cpu(cp->magic) != CP_DIR_MAGIC) { | 67 | if (le32_to_cpu(cp->magic) != CP_DIR_MAGIC) { |
68 | printk("HPFS: Code page directory magic doesn't match (magic = %08x)\n", le32_to_cpu(cp->magic)); | 68 | pr_err("Code page directory magic doesn't match (magic = %08x)\n", |
69 | le32_to_cpu(cp->magic)); | ||
69 | brelse(bh); | 70 | brelse(bh); |
70 | return NULL; | 71 | return NULL; |
71 | } | 72 | } |
72 | if (!le32_to_cpu(cp->n_code_pages)) { | 73 | if (!le32_to_cpu(cp->n_code_pages)) { |
73 | printk("HPFS: n_code_pages == 0\n"); | 74 | pr_err("n_code_pages == 0\n"); |
74 | brelse(bh); | 75 | brelse(bh); |
75 | return NULL; | 76 | return NULL; |
76 | } | 77 | } |
@@ -79,19 +80,19 @@ unsigned char *hpfs_load_code_page(struct super_block *s, secno cps) | |||
79 | brelse(bh); | 80 | brelse(bh); |
80 | 81 | ||
81 | if (cpi >= 3) { | 82 | if (cpi >= 3) { |
82 | printk("HPFS: Code page index out of array\n"); | 83 | pr_err("Code page index out of array\n"); |
83 | return NULL; | 84 | return NULL; |
84 | } | 85 | } |
85 | 86 | ||
86 | if (!(cpd = hpfs_map_sector(s, cpds, &bh, 0))) return NULL; | 87 | if (!(cpd = hpfs_map_sector(s, cpds, &bh, 0))) return NULL; |
87 | if (le16_to_cpu(cpd->offs[cpi]) > 0x178) { | 88 | if (le16_to_cpu(cpd->offs[cpi]) > 0x178) { |
88 | printk("HPFS: Code page index out of sector\n"); | 89 | pr_err("Code page index out of sector\n"); |
89 | brelse(bh); | 90 | brelse(bh); |
90 | return NULL; | 91 | return NULL; |
91 | } | 92 | } |
92 | ptr = (unsigned char *)cpd + le16_to_cpu(cpd->offs[cpi]) + 6; | 93 | ptr = (unsigned char *)cpd + le16_to_cpu(cpd->offs[cpi]) + 6; |
93 | if (!(cp_table = kmalloc(256, GFP_KERNEL))) { | 94 | if (!(cp_table = kmalloc(256, GFP_KERNEL))) { |
94 | printk("HPFS: out of memory for code page table\n"); | 95 | pr_err("out of memory for code page table\n"); |
95 | brelse(bh); | 96 | brelse(bh); |
96 | return NULL; | 97 | return NULL; |
97 | } | 98 | } |
@@ -114,7 +115,7 @@ __le32 *hpfs_load_bitmap_directory(struct super_block *s, secno bmp) | |||
114 | int i; | 115 | int i; |
115 | __le32 *b; | 116 | __le32 *b; |
116 | if (!(b = kmalloc(n * 512, GFP_KERNEL))) { | 117 | if (!(b = kmalloc(n * 512, GFP_KERNEL))) { |
117 | printk("HPFS: can't allocate memory for bitmap directory\n"); | 118 | pr_err("can't allocate memory for bitmap directory\n"); |
118 | return NULL; | 119 | return NULL; |
119 | } | 120 | } |
120 | for (i=0;i<n;i++) { | 121 | for (i=0;i<n;i++) { |
@@ -281,7 +282,9 @@ struct dnode *hpfs_map_dnode(struct super_block *s, unsigned secno, | |||
281 | hpfs_error(s, "dnode %08x does not end with \\377 entry", secno); | 282 | hpfs_error(s, "dnode %08x does not end with \\377 entry", secno); |
282 | goto bail; | 283 | goto bail; |
283 | } | 284 | } |
284 | if (b == 3) printk("HPFS: warning: unbalanced dnode tree, dnode %08x; see hpfs.txt 4 more info\n", secno); | 285 | if (b == 3) |
286 | pr_err("unbalanced dnode tree, dnode %08x; see hpfs.txt 4 more info\n", | ||
287 | secno); | ||
285 | } | 288 | } |
286 | return dnode; | 289 | return dnode; |
287 | bail: | 290 | bail: |
diff --git a/fs/hpfs/name.c b/fs/hpfs/name.c index 9acdf338def0..b00d396d22c6 100644 --- a/fs/hpfs/name.c +++ b/fs/hpfs/name.c | |||
@@ -56,14 +56,15 @@ unsigned char *hpfs_translate_name(struct super_block *s, unsigned char *from, | |||
56 | unsigned char *to; | 56 | unsigned char *to; |
57 | int i; | 57 | int i; |
58 | if (hpfs_sb(s)->sb_chk >= 2) if (hpfs_is_name_long(from, len) != lng) { | 58 | if (hpfs_sb(s)->sb_chk >= 2) if (hpfs_is_name_long(from, len) != lng) { |
59 | printk("HPFS: Long name flag mismatch - name "); | 59 | pr_err("Long name flag mismatch - name "); |
60 | for (i=0; i<len; i++) printk("%c", from[i]); | 60 | for (i = 0; i < len; i++) |
61 | printk(" misidentified as %s.\n", lng ? "short" : "long"); | 61 | pr_cont("%c", from[i]); |
62 | printk("HPFS: It's nothing serious. It could happen because of bug in OS/2.\nHPFS: Set checks=normal to disable this message.\n"); | 62 | pr_cont(" misidentified as %s.\n", lng ? "short" : "long"); |
63 | pr_err("It's nothing serious. It could happen because of bug in OS/2.\nSet checks=normal to disable this message.\n"); | ||
63 | } | 64 | } |
64 | if (!lc) return from; | 65 | if (!lc) return from; |
65 | if (!(to = kmalloc(len, GFP_KERNEL))) { | 66 | if (!(to = kmalloc(len, GFP_KERNEL))) { |
66 | printk("HPFS: can't allocate memory for name conversion buffer\n"); | 67 | pr_err("can't allocate memory for name conversion buffer\n"); |
67 | return from; | 68 | return from; |
68 | } | 69 | } |
69 | for (i = 0; i < len; i++) to[i] = locase(hpfs_sb(s)->sb_cp_table,from[i]); | 70 | for (i = 0; i < len; i++) to[i] = locase(hpfs_sb(s)->sb_cp_table,from[i]); |
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c index 1b39afdd86fd..bdbc2c3080a4 100644 --- a/fs/hpfs/namei.c +++ b/fs/hpfs/namei.c | |||
@@ -404,7 +404,7 @@ again: | |||
404 | d_rehash(dentry); | 404 | d_rehash(dentry); |
405 | } else { | 405 | } else { |
406 | struct iattr newattrs; | 406 | struct iattr newattrs; |
407 | /*printk("HPFS: truncating file before delete.\n");*/ | 407 | /*pr_info("truncating file before delete.\n");*/ |
408 | newattrs.ia_size = 0; | 408 | newattrs.ia_size = 0; |
409 | newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME; | 409 | newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME; |
410 | err = notify_change(dentry, &newattrs, NULL); | 410 | err = notify_change(dentry, &newattrs, NULL); |
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c index fe3463a43236..7cd00d3a7c9b 100644 --- a/fs/hpfs/super.c +++ b/fs/hpfs/super.c | |||
@@ -62,22 +62,26 @@ void hpfs_error(struct super_block *s, const char *fmt, ...) | |||
62 | vsnprintf(err_buf, sizeof(err_buf), fmt, args); | 62 | vsnprintf(err_buf, sizeof(err_buf), fmt, args); |
63 | va_end(args); | 63 | va_end(args); |
64 | 64 | ||
65 | printk("HPFS: filesystem error: %s", err_buf); | 65 | pr_err("filesystem error: %s", err_buf); |
66 | if (!hpfs_sb(s)->sb_was_error) { | 66 | if (!hpfs_sb(s)->sb_was_error) { |
67 | if (hpfs_sb(s)->sb_err == 2) { | 67 | if (hpfs_sb(s)->sb_err == 2) { |
68 | printk("; crashing the system because you wanted it\n"); | 68 | pr_cont("; crashing the system because you wanted it\n"); |
69 | mark_dirty(s, 0); | 69 | mark_dirty(s, 0); |
70 | panic("HPFS panic"); | 70 | panic("HPFS panic"); |
71 | } else if (hpfs_sb(s)->sb_err == 1) { | 71 | } else if (hpfs_sb(s)->sb_err == 1) { |
72 | if (s->s_flags & MS_RDONLY) printk("; already mounted read-only\n"); | 72 | if (s->s_flags & MS_RDONLY) |
73 | pr_cont("; already mounted read-only\n"); | ||
73 | else { | 74 | else { |
74 | printk("; remounting read-only\n"); | 75 | pr_cont("; remounting read-only\n"); |
75 | mark_dirty(s, 0); | 76 | mark_dirty(s, 0); |
76 | s->s_flags |= MS_RDONLY; | 77 | s->s_flags |= MS_RDONLY; |
77 | } | 78 | } |
78 | } else if (s->s_flags & MS_RDONLY) printk("; going on - but anything won't be destroyed because it's read-only\n"); | 79 | } else if (s->s_flags & MS_RDONLY) |
79 | else printk("; corrupted filesystem mounted read/write - your computer will explode within 20 seconds ... but you wanted it so!\n"); | 80 | pr_cont("; going on - but anything won't be destroyed because it's read-only\n"); |
80 | } else printk("\n"); | 81 | else |
82 | pr_cont("; corrupted filesystem mounted read/write - your computer will explode within 20 seconds ... but you wanted it so!\n"); | ||
83 | } else | ||
84 | pr_cont("\n"); | ||
81 | hpfs_sb(s)->sb_was_error = 1; | 85 | hpfs_sb(s)->sb_was_error = 1; |
82 | } | 86 | } |
83 | 87 | ||
@@ -292,7 +296,7 @@ static int parse_opts(char *opts, kuid_t *uid, kgid_t *gid, umode_t *umask, | |||
292 | if (!opts) | 296 | if (!opts) |
293 | return 1; | 297 | return 1; |
294 | 298 | ||
295 | /*printk("Parsing opts: '%s'\n",opts);*/ | 299 | /*pr_info("Parsing opts: '%s'\n",opts);*/ |
296 | 300 | ||
297 | while ((p = strsep(&opts, ",")) != NULL) { | 301 | while ((p = strsep(&opts, ",")) != NULL) { |
298 | substring_t args[MAX_OPT_ARGS]; | 302 | substring_t args[MAX_OPT_ARGS]; |
@@ -387,7 +391,7 @@ static int parse_opts(char *opts, kuid_t *uid, kgid_t *gid, umode_t *umask, | |||
387 | 391 | ||
388 | static inline void hpfs_help(void) | 392 | static inline void hpfs_help(void) |
389 | { | 393 | { |
390 | printk("\n\ | 394 | pr_info("\n\ |
391 | HPFS filesystem options:\n\ | 395 | HPFS filesystem options:\n\ |
392 | help do not mount and display this text\n\ | 396 | help do not mount and display this text\n\ |
393 | uid=xxx set uid of files that don't have uid specified in eas\n\ | 397 | uid=xxx set uid of files that don't have uid specified in eas\n\ |
@@ -434,7 +438,7 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data) | |||
434 | 438 | ||
435 | if (!(o = parse_opts(data, &uid, &gid, &umask, &lowercase, | 439 | if (!(o = parse_opts(data, &uid, &gid, &umask, &lowercase, |
436 | &eas, &chk, &errs, &chkdsk, ×hift))) { | 440 | &eas, &chk, &errs, &chkdsk, ×hift))) { |
437 | printk("HPFS: bad mount options.\n"); | 441 | pr_err("bad mount options.\n"); |
438 | goto out_err; | 442 | goto out_err; |
439 | } | 443 | } |
440 | if (o == 2) { | 444 | if (o == 2) { |
@@ -442,7 +446,7 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data) | |||
442 | goto out_err; | 446 | goto out_err; |
443 | } | 447 | } |
444 | if (timeshift != sbi->sb_timeshift) { | 448 | if (timeshift != sbi->sb_timeshift) { |
445 | printk("HPFS: timeshift can't be changed using remount.\n"); | 449 | pr_err("timeshift can't be changed using remount.\n"); |
446 | goto out_err; | 450 | goto out_err; |
447 | } | 451 | } |
448 | 452 | ||
@@ -523,7 +527,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
523 | 527 | ||
524 | if (!(o = parse_opts(options, &uid, &gid, &umask, &lowercase, | 528 | if (!(o = parse_opts(options, &uid, &gid, &umask, &lowercase, |
525 | &eas, &chk, &errs, &chkdsk, ×hift))) { | 529 | &eas, &chk, &errs, &chkdsk, ×hift))) { |
526 | printk("HPFS: bad mount options.\n"); | 530 | pr_err("bad mount options.\n"); |
527 | goto bail0; | 531 | goto bail0; |
528 | } | 532 | } |
529 | if (o==2) { | 533 | if (o==2) { |
@@ -542,16 +546,17 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
542 | if (/*le16_to_cpu(bootblock->magic) != BB_MAGIC | 546 | if (/*le16_to_cpu(bootblock->magic) != BB_MAGIC |
543 | ||*/ le32_to_cpu(superblock->magic) != SB_MAGIC | 547 | ||*/ le32_to_cpu(superblock->magic) != SB_MAGIC |
544 | || le32_to_cpu(spareblock->magic) != SP_MAGIC) { | 548 | || le32_to_cpu(spareblock->magic) != SP_MAGIC) { |
545 | if (!silent) printk("HPFS: Bad magic ... probably not HPFS\n"); | 549 | if (!silent) |
550 | pr_err("Bad magic ... probably not HPFS\n"); | ||
546 | goto bail4; | 551 | goto bail4; |
547 | } | 552 | } |
548 | 553 | ||
549 | /* Check version */ | 554 | /* Check version */ |
550 | if (!(s->s_flags & MS_RDONLY) && | 555 | if (!(s->s_flags & MS_RDONLY) && |
551 | superblock->funcversion != 2 && superblock->funcversion != 3) { | 556 | superblock->funcversion != 2 && superblock->funcversion != 3) { |
552 | printk("HPFS: Bad version %d,%d. Mount readonly to go around\n", | 557 | pr_err("Bad version %d,%d. Mount readonly to go around\n", |
553 | (int)superblock->version, (int)superblock->funcversion); | 558 | (int)superblock->version, (int)superblock->funcversion); |
554 | printk("HPFS: please try recent version of HPFS driver at http://artax.karlin.mff.cuni.cz/~mikulas/vyplody/hpfs/index-e.cgi and if it still can't understand this format, contact author - mikulas@artax.karlin.mff.cuni.cz\n"); | 559 | pr_err("please try recent version of HPFS driver at http://artax.karlin.mff.cuni.cz/~mikulas/vyplody/hpfs/index-e.cgi and if it still can't understand this format, contact author - mikulas@artax.karlin.mff.cuni.cz\n"); |
555 | goto bail4; | 560 | goto bail4; |
556 | } | 561 | } |
557 | 562 | ||
@@ -597,7 +602,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
597 | /* Check for general fs errors*/ | 602 | /* Check for general fs errors*/ |
598 | if (spareblock->dirty && !spareblock->old_wrote) { | 603 | if (spareblock->dirty && !spareblock->old_wrote) { |
599 | if (errs == 2) { | 604 | if (errs == 2) { |
600 | printk("HPFS: Improperly stopped, not mounted\n"); | 605 | pr_err("Improperly stopped, not mounted\n"); |
601 | goto bail4; | 606 | goto bail4; |
602 | } | 607 | } |
603 | hpfs_error(s, "improperly stopped"); | 608 | hpfs_error(s, "improperly stopped"); |
@@ -611,22 +616,25 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
611 | 616 | ||
612 | if (spareblock->hotfixes_used || spareblock->n_spares_used) { | 617 | if (spareblock->hotfixes_used || spareblock->n_spares_used) { |
613 | if (errs >= 2) { | 618 | if (errs >= 2) { |
614 | printk("HPFS: Hotfixes not supported here, try chkdsk\n"); | 619 | pr_err("Hotfixes not supported here, try chkdsk\n"); |
615 | mark_dirty(s, 0); | 620 | mark_dirty(s, 0); |
616 | goto bail4; | 621 | goto bail4; |
617 | } | 622 | } |
618 | hpfs_error(s, "hotfixes not supported here, try chkdsk"); | 623 | hpfs_error(s, "hotfixes not supported here, try chkdsk"); |
619 | if (errs == 0) printk("HPFS: Proceeding, but your filesystem will be probably corrupted by this driver...\n"); | 624 | if (errs == 0) |
620 | else printk("HPFS: This driver may read bad files or crash when operating on disk with hotfixes.\n"); | 625 | pr_err("Proceeding, but your filesystem will be probably corrupted by this driver...\n"); |
626 | else | ||
627 | pr_err("This driver may read bad files or crash when operating on disk with hotfixes.\n"); | ||
621 | } | 628 | } |
622 | if (le32_to_cpu(spareblock->n_dnode_spares) != le32_to_cpu(spareblock->n_dnode_spares_free)) { | 629 | if (le32_to_cpu(spareblock->n_dnode_spares) != le32_to_cpu(spareblock->n_dnode_spares_free)) { |
623 | if (errs >= 2) { | 630 | if (errs >= 2) { |
624 | printk("HPFS: Spare dnodes used, try chkdsk\n"); | 631 | pr_err("Spare dnodes used, try chkdsk\n"); |
625 | mark_dirty(s, 0); | 632 | mark_dirty(s, 0); |
626 | goto bail4; | 633 | goto bail4; |
627 | } | 634 | } |
628 | hpfs_error(s, "warning: spare dnodes used, try chkdsk"); | 635 | hpfs_error(s, "warning: spare dnodes used, try chkdsk"); |
629 | if (errs == 0) printk("HPFS: Proceeding, but your filesystem could be corrupted if you delete files or directories\n"); | 636 | if (errs == 0) |
637 | pr_err("Proceeding, but your filesystem could be corrupted if you delete files or directories\n"); | ||
630 | } | 638 | } |
631 | if (chk) { | 639 | if (chk) { |
632 | unsigned a; | 640 | unsigned a; |
@@ -645,12 +653,13 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
645 | goto bail4; | 653 | goto bail4; |
646 | } | 654 | } |
647 | sbi->sb_dirband_size = a; | 655 | sbi->sb_dirband_size = a; |
648 | } else printk("HPFS: You really don't want any checks? You are crazy...\n"); | 656 | } else |
657 | pr_err("You really don't want any checks? You are crazy...\n"); | ||
649 | 658 | ||
650 | /* Load code page table */ | 659 | /* Load code page table */ |
651 | if (le32_to_cpu(spareblock->n_code_pages)) | 660 | if (le32_to_cpu(spareblock->n_code_pages)) |
652 | if (!(sbi->sb_cp_table = hpfs_load_code_page(s, le32_to_cpu(spareblock->code_page_dir)))) | 661 | if (!(sbi->sb_cp_table = hpfs_load_code_page(s, le32_to_cpu(spareblock->code_page_dir)))) |
653 | printk("HPFS: Warning: code page support is disabled\n"); | 662 | pr_err("code page support is disabled\n"); |
654 | 663 | ||
655 | brelse(bh2); | 664 | brelse(bh2); |
656 | brelse(bh1); | 665 | brelse(bh1); |
diff --git a/fs/inode.c b/fs/inode.c index f96d2a6f88cc..2feb9b69f1be 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -105,7 +105,7 @@ long get_nr_dirty_inodes(void) | |||
105 | * Handle nr_inode sysctl | 105 | * Handle nr_inode sysctl |
106 | */ | 106 | */ |
107 | #ifdef CONFIG_SYSCTL | 107 | #ifdef CONFIG_SYSCTL |
108 | int proc_nr_inodes(ctl_table *table, int write, | 108 | int proc_nr_inodes(struct ctl_table *table, int write, |
109 | void __user *buffer, size_t *lenp, loff_t *ppos) | 109 | void __user *buffer, size_t *lenp, loff_t *ppos) |
110 | { | 110 | { |
111 | inodes_stat.nr_inodes = get_nr_inodes(); | 111 | inodes_stat.nr_inodes = get_nr_inodes(); |
diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c index 2b60ce1996aa..bb9cebc9ca8a 100644 --- a/fs/jffs2/background.c +++ b/fs/jffs2/background.c | |||
@@ -75,10 +75,13 @@ void jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c) | |||
75 | static int jffs2_garbage_collect_thread(void *_c) | 75 | static int jffs2_garbage_collect_thread(void *_c) |
76 | { | 76 | { |
77 | struct jffs2_sb_info *c = _c; | 77 | struct jffs2_sb_info *c = _c; |
78 | sigset_t hupmask; | ||
78 | 79 | ||
80 | siginitset(&hupmask, sigmask(SIGHUP)); | ||
79 | allow_signal(SIGKILL); | 81 | allow_signal(SIGKILL); |
80 | allow_signal(SIGSTOP); | 82 | allow_signal(SIGSTOP); |
81 | allow_signal(SIGCONT); | 83 | allow_signal(SIGCONT); |
84 | allow_signal(SIGHUP); | ||
82 | 85 | ||
83 | c->gc_task = current; | 86 | c->gc_task = current; |
84 | complete(&c->gc_thread_start); | 87 | complete(&c->gc_thread_start); |
@@ -87,7 +90,7 @@ static int jffs2_garbage_collect_thread(void *_c) | |||
87 | 90 | ||
88 | set_freezable(); | 91 | set_freezable(); |
89 | for (;;) { | 92 | for (;;) { |
90 | allow_signal(SIGHUP); | 93 | sigprocmask(SIG_UNBLOCK, &hupmask, NULL); |
91 | again: | 94 | again: |
92 | spin_lock(&c->erase_completion_lock); | 95 | spin_lock(&c->erase_completion_lock); |
93 | if (!jffs2_thread_should_wake(c)) { | 96 | if (!jffs2_thread_should_wake(c)) { |
@@ -95,10 +98,9 @@ static int jffs2_garbage_collect_thread(void *_c) | |||
95 | spin_unlock(&c->erase_completion_lock); | 98 | spin_unlock(&c->erase_completion_lock); |
96 | jffs2_dbg(1, "%s(): sleeping...\n", __func__); | 99 | jffs2_dbg(1, "%s(): sleeping...\n", __func__); |
97 | schedule(); | 100 | schedule(); |
98 | } else | 101 | } else { |
99 | spin_unlock(&c->erase_completion_lock); | 102 | spin_unlock(&c->erase_completion_lock); |
100 | 103 | } | |
101 | |||
102 | /* Problem - immediately after bootup, the GCD spends a lot | 104 | /* Problem - immediately after bootup, the GCD spends a lot |
103 | * of time in places like jffs2_kill_fragtree(); so much so | 105 | * of time in places like jffs2_kill_fragtree(); so much so |
104 | * that userspace processes (like gdm and X) are starved | 106 | * that userspace processes (like gdm and X) are starved |
@@ -150,7 +152,7 @@ static int jffs2_garbage_collect_thread(void *_c) | |||
150 | } | 152 | } |
151 | } | 153 | } |
152 | /* We don't want SIGHUP to interrupt us. STOP and KILL are OK though. */ | 154 | /* We don't want SIGHUP to interrupt us. STOP and KILL are OK though. */ |
153 | disallow_signal(SIGHUP); | 155 | sigprocmask(SIG_BLOCK, &hupmask, NULL); |
154 | 156 | ||
155 | jffs2_dbg(1, "%s(): pass\n", __func__); | 157 | jffs2_dbg(1, "%s(): pass\n", __func__); |
156 | if (jffs2_garbage_collect_pass(c) == -ENOSPC) { | 158 | if (jffs2_garbage_collect_pass(c) == -ENOSPC) { |
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 6bf06a07f3e0..de051cb1f553 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c | |||
@@ -436,7 +436,7 @@ EXPORT_SYMBOL_GPL(lockd_down); | |||
436 | * Sysctl parameters (same as module parameters, different interface). | 436 | * Sysctl parameters (same as module parameters, different interface). |
437 | */ | 437 | */ |
438 | 438 | ||
439 | static ctl_table nlm_sysctls[] = { | 439 | static struct ctl_table nlm_sysctls[] = { |
440 | { | 440 | { |
441 | .procname = "nlm_grace_period", | 441 | .procname = "nlm_grace_period", |
442 | .data = &nlm_grace_period, | 442 | .data = &nlm_grace_period, |
@@ -490,7 +490,7 @@ static ctl_table nlm_sysctls[] = { | |||
490 | { } | 490 | { } |
491 | }; | 491 | }; |
492 | 492 | ||
493 | static ctl_table nlm_sysctl_dir[] = { | 493 | static struct ctl_table nlm_sysctl_dir[] = { |
494 | { | 494 | { |
495 | .procname = "nfs", | 495 | .procname = "nfs", |
496 | .mode = 0555, | 496 | .mode = 0555, |
@@ -499,7 +499,7 @@ static ctl_table nlm_sysctl_dir[] = { | |||
499 | { } | 499 | { } |
500 | }; | 500 | }; |
501 | 501 | ||
502 | static ctl_table nlm_sysctl_root[] = { | 502 | static struct ctl_table nlm_sysctl_root[] = { |
503 | { | 503 | { |
504 | .procname = "fs", | 504 | .procname = "fs", |
505 | .mode = 0555, | 505 | .mode = 0555, |
diff --git a/fs/nfs/nfs4sysctl.c b/fs/nfs/nfs4sysctl.c index 2628d921b7e3..b6ebe7e445f6 100644 --- a/fs/nfs/nfs4sysctl.c +++ b/fs/nfs/nfs4sysctl.c | |||
@@ -16,7 +16,7 @@ static const int nfs_set_port_min = 0; | |||
16 | static const int nfs_set_port_max = 65535; | 16 | static const int nfs_set_port_max = 65535; |
17 | static struct ctl_table_header *nfs4_callback_sysctl_table; | 17 | static struct ctl_table_header *nfs4_callback_sysctl_table; |
18 | 18 | ||
19 | static ctl_table nfs4_cb_sysctls[] = { | 19 | static struct ctl_table nfs4_cb_sysctls[] = { |
20 | { | 20 | { |
21 | .procname = "nfs_callback_tcpport", | 21 | .procname = "nfs_callback_tcpport", |
22 | .data = &nfs_callback_set_tcpport, | 22 | .data = &nfs_callback_set_tcpport, |
@@ -36,7 +36,7 @@ static ctl_table nfs4_cb_sysctls[] = { | |||
36 | { } | 36 | { } |
37 | }; | 37 | }; |
38 | 38 | ||
39 | static ctl_table nfs4_cb_sysctl_dir[] = { | 39 | static struct ctl_table nfs4_cb_sysctl_dir[] = { |
40 | { | 40 | { |
41 | .procname = "nfs", | 41 | .procname = "nfs", |
42 | .mode = 0555, | 42 | .mode = 0555, |
@@ -45,7 +45,7 @@ static ctl_table nfs4_cb_sysctl_dir[] = { | |||
45 | { } | 45 | { } |
46 | }; | 46 | }; |
47 | 47 | ||
48 | static ctl_table nfs4_cb_sysctl_root[] = { | 48 | static struct ctl_table nfs4_cb_sysctl_root[] = { |
49 | { | 49 | { |
50 | .procname = "fs", | 50 | .procname = "fs", |
51 | .mode = 0555, | 51 | .mode = 0555, |
diff --git a/fs/nfs/sysctl.c b/fs/nfs/sysctl.c index 6b3f2535a3ec..bb6ed810fa6f 100644 --- a/fs/nfs/sysctl.c +++ b/fs/nfs/sysctl.c | |||
@@ -13,7 +13,7 @@ | |||
13 | 13 | ||
14 | static struct ctl_table_header *nfs_callback_sysctl_table; | 14 | static struct ctl_table_header *nfs_callback_sysctl_table; |
15 | 15 | ||
16 | static ctl_table nfs_cb_sysctls[] = { | 16 | static struct ctl_table nfs_cb_sysctls[] = { |
17 | { | 17 | { |
18 | .procname = "nfs_mountpoint_timeout", | 18 | .procname = "nfs_mountpoint_timeout", |
19 | .data = &nfs_mountpoint_expiry_timeout, | 19 | .data = &nfs_mountpoint_expiry_timeout, |
@@ -31,7 +31,7 @@ static ctl_table nfs_cb_sysctls[] = { | |||
31 | { } | 31 | { } |
32 | }; | 32 | }; |
33 | 33 | ||
34 | static ctl_table nfs_cb_sysctl_dir[] = { | 34 | static struct ctl_table nfs_cb_sysctl_dir[] = { |
35 | { | 35 | { |
36 | .procname = "nfs", | 36 | .procname = "nfs", |
37 | .mode = 0555, | 37 | .mode = 0555, |
@@ -40,7 +40,7 @@ static ctl_table nfs_cb_sysctl_dir[] = { | |||
40 | { } | 40 | { } |
41 | }; | 41 | }; |
42 | 42 | ||
43 | static ctl_table nfs_cb_sysctl_root[] = { | 43 | static struct ctl_table nfs_cb_sysctl_root[] = { |
44 | { | 44 | { |
45 | .procname = "fs", | 45 | .procname = "fs", |
46 | .mode = 0555, | 46 | .mode = 0555, |
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 78a2ca3966c3..cc423a30a0c8 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c | |||
@@ -57,7 +57,7 @@ static struct kmem_cache *inotify_inode_mark_cachep __read_mostly; | |||
57 | 57 | ||
58 | static int zero; | 58 | static int zero; |
59 | 59 | ||
60 | ctl_table inotify_table[] = { | 60 | struct ctl_table inotify_table[] = { |
61 | { | 61 | { |
62 | .procname = "max_user_instances", | 62 | .procname = "max_user_instances", |
63 | .data = &inotify_max_user_instances, | 63 | .data = &inotify_max_user_instances, |
diff --git a/fs/ntfs/sysctl.c b/fs/ntfs/sysctl.c index 1927170a35ce..a503156ec15f 100644 --- a/fs/ntfs/sysctl.c +++ b/fs/ntfs/sysctl.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include "debug.h" | 34 | #include "debug.h" |
35 | 35 | ||
36 | /* Definition of the ntfs sysctl. */ | 36 | /* Definition of the ntfs sysctl. */ |
37 | static ctl_table ntfs_sysctls[] = { | 37 | static struct ctl_table ntfs_sysctls[] = { |
38 | { | 38 | { |
39 | .procname = "ntfs-debug", | 39 | .procname = "ntfs-debug", |
40 | .data = &debug_msgs, /* Data pointer and size. */ | 40 | .data = &debug_msgs, /* Data pointer and size. */ |
@@ -46,7 +46,7 @@ static ctl_table ntfs_sysctls[] = { | |||
46 | }; | 46 | }; |
47 | 47 | ||
48 | /* Define the parent directory /proc/sys/fs. */ | 48 | /* Define the parent directory /proc/sys/fs. */ |
49 | static ctl_table sysctls_root[] = { | 49 | static struct ctl_table sysctls_root[] = { |
50 | { | 50 | { |
51 | .procname = "fs", | 51 | .procname = "fs", |
52 | .mode = 0555, | 52 | .mode = 0555, |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 48cbe4c0b2a5..5d9da22e29b0 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -1418,10 +1418,10 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid) | |||
1418 | seq_printf(m, "%08lx %s", vma->vm_start, buffer); | 1418 | seq_printf(m, "%08lx %s", vma->vm_start, buffer); |
1419 | 1419 | ||
1420 | if (file) { | 1420 | if (file) { |
1421 | seq_printf(m, " file="); | 1421 | seq_puts(m, " file="); |
1422 | seq_path(m, &file->f_path, "\n\t= "); | 1422 | seq_path(m, &file->f_path, "\n\t= "); |
1423 | } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) { | 1423 | } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) { |
1424 | seq_printf(m, " heap"); | 1424 | seq_puts(m, " heap"); |
1425 | } else { | 1425 | } else { |
1426 | pid_t tid = vm_is_stack(task, vma, is_pid); | 1426 | pid_t tid = vm_is_stack(task, vma, is_pid); |
1427 | if (tid != 0) { | 1427 | if (tid != 0) { |
@@ -1431,14 +1431,14 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid) | |||
1431 | */ | 1431 | */ |
1432 | if (!is_pid || (vma->vm_start <= mm->start_stack && | 1432 | if (!is_pid || (vma->vm_start <= mm->start_stack && |
1433 | vma->vm_end >= mm->start_stack)) | 1433 | vma->vm_end >= mm->start_stack)) |
1434 | seq_printf(m, " stack"); | 1434 | seq_puts(m, " stack"); |
1435 | else | 1435 | else |
1436 | seq_printf(m, " stack:%d", tid); | 1436 | seq_printf(m, " stack:%d", tid); |
1437 | } | 1437 | } |
1438 | } | 1438 | } |
1439 | 1439 | ||
1440 | if (is_vm_hugetlb_page(vma)) | 1440 | if (is_vm_hugetlb_page(vma)) |
1441 | seq_printf(m, " huge"); | 1441 | seq_puts(m, " huge"); |
1442 | 1442 | ||
1443 | walk_page_range(vma->vm_start, vma->vm_end, &walk); | 1443 | walk_page_range(vma->vm_start, vma->vm_end, &walk); |
1444 | 1444 | ||
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c index 6a8e785b29da..382aa890e228 100644 --- a/fs/proc/vmcore.c +++ b/fs/proc/vmcore.c | |||
@@ -42,7 +42,7 @@ static size_t elfnotes_sz; | |||
42 | /* Total size of vmcore file. */ | 42 | /* Total size of vmcore file. */ |
43 | static u64 vmcore_size; | 43 | static u64 vmcore_size; |
44 | 44 | ||
45 | static struct proc_dir_entry *proc_vmcore = NULL; | 45 | static struct proc_dir_entry *proc_vmcore; |
46 | 46 | ||
47 | /* | 47 | /* |
48 | * Returns > 0 for RAM pages, 0 for non-RAM pages, < 0 on error | 48 | * Returns > 0 for RAM pages, 0 for non-RAM pages, < 0 on error |
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 46d269e38706..0a9b72cdfeca 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c | |||
@@ -18,6 +18,8 @@ | |||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #define pr_fmt(fmt) "pstore: " fmt | ||
22 | |||
21 | #include <linux/atomic.h> | 23 | #include <linux/atomic.h> |
22 | #include <linux/types.h> | 24 | #include <linux/types.h> |
23 | #include <linux/errno.h> | 25 | #include <linux/errno.h> |
@@ -224,14 +226,12 @@ static void allocate_buf_for_compression(void) | |||
224 | zlib_inflate_workspacesize()); | 226 | zlib_inflate_workspacesize()); |
225 | stream.workspace = kmalloc(size, GFP_KERNEL); | 227 | stream.workspace = kmalloc(size, GFP_KERNEL); |
226 | if (!stream.workspace) { | 228 | if (!stream.workspace) { |
227 | pr_err("pstore: No memory for compression workspace; " | 229 | pr_err("No memory for compression workspace; skipping compression\n"); |
228 | "skipping compression\n"); | ||
229 | kfree(big_oops_buf); | 230 | kfree(big_oops_buf); |
230 | big_oops_buf = NULL; | 231 | big_oops_buf = NULL; |
231 | } | 232 | } |
232 | } else { | 233 | } else { |
233 | pr_err("No memory for uncompressed data; " | 234 | pr_err("No memory for uncompressed data; skipping compression\n"); |
234 | "skipping compression\n"); | ||
235 | stream.workspace = NULL; | 235 | stream.workspace = NULL; |
236 | } | 236 | } |
237 | 237 | ||
@@ -455,8 +455,7 @@ int pstore_register(struct pstore_info *psi) | |||
455 | add_timer(&pstore_timer); | 455 | add_timer(&pstore_timer); |
456 | } | 456 | } |
457 | 457 | ||
458 | pr_info("pstore: Registered %s as persistent store backend\n", | 458 | pr_info("Registered %s as persistent store backend\n", psi->name); |
459 | psi->name); | ||
460 | 459 | ||
461 | return 0; | 460 | return 0; |
462 | } | 461 | } |
@@ -502,8 +501,8 @@ void pstore_get_records(int quiet) | |||
502 | size = unzipped_len; | 501 | size = unzipped_len; |
503 | compressed = false; | 502 | compressed = false; |
504 | } else { | 503 | } else { |
505 | pr_err("pstore: decompression failed;" | 504 | pr_err("decompression failed;returned %d\n", |
506 | "returned %d\n", unzipped_len); | 505 | unzipped_len); |
507 | compressed = true; | 506 | compressed = true; |
508 | } | 507 | } |
509 | } | 508 | } |
@@ -524,8 +523,8 @@ out: | |||
524 | mutex_unlock(&psi->read_mutex); | 523 | mutex_unlock(&psi->read_mutex); |
525 | 524 | ||
526 | if (failed) | 525 | if (failed) |
527 | printk(KERN_WARNING "pstore: failed to load %d record(s) from '%s'\n", | 526 | pr_warn("failed to load %d record(s) from '%s'\n", |
528 | failed, psi->name); | 527 | failed, psi->name); |
529 | } | 528 | } |
530 | 529 | ||
531 | static void pstore_dowork(struct work_struct *work) | 530 | static void pstore_dowork(struct work_struct *work) |
diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c index ff7e3d4df5a1..34a1e5aa848c 100644 --- a/fs/pstore/ram_core.c +++ b/fs/pstore/ram_core.c | |||
@@ -12,6 +12,8 @@ | |||
12 | * | 12 | * |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #define pr_fmt(fmt) "persistent_ram: " fmt | ||
16 | |||
15 | #include <linux/device.h> | 17 | #include <linux/device.h> |
16 | #include <linux/err.h> | 18 | #include <linux/err.h> |
17 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
@@ -205,12 +207,10 @@ static void persistent_ram_ecc_old(struct persistent_ram_zone *prz) | |||
205 | size = buffer->data + prz->buffer_size - block; | 207 | size = buffer->data + prz->buffer_size - block; |
206 | numerr = persistent_ram_decode_rs8(prz, block, size, par); | 208 | numerr = persistent_ram_decode_rs8(prz, block, size, par); |
207 | if (numerr > 0) { | 209 | if (numerr > 0) { |
208 | pr_devel("persistent_ram: error in block %p, %d\n", | 210 | pr_devel("error in block %p, %d\n", block, numerr); |
209 | block, numerr); | ||
210 | prz->corrected_bytes += numerr; | 211 | prz->corrected_bytes += numerr; |
211 | } else if (numerr < 0) { | 212 | } else if (numerr < 0) { |
212 | pr_devel("persistent_ram: uncorrectable error in block %p\n", | 213 | pr_devel("uncorrectable error in block %p\n", block); |
213 | block); | ||
214 | prz->bad_blocks++; | 214 | prz->bad_blocks++; |
215 | } | 215 | } |
216 | block += prz->ecc_info.block_size; | 216 | block += prz->ecc_info.block_size; |
@@ -257,7 +257,7 @@ static int persistent_ram_init_ecc(struct persistent_ram_zone *prz, | |||
257 | prz->rs_decoder = init_rs(prz->ecc_info.symsize, prz->ecc_info.poly, | 257 | prz->rs_decoder = init_rs(prz->ecc_info.symsize, prz->ecc_info.poly, |
258 | 0, 1, prz->ecc_info.ecc_size); | 258 | 0, 1, prz->ecc_info.ecc_size); |
259 | if (prz->rs_decoder == NULL) { | 259 | if (prz->rs_decoder == NULL) { |
260 | pr_info("persistent_ram: init_rs failed\n"); | 260 | pr_info("init_rs failed\n"); |
261 | return -EINVAL; | 261 | return -EINVAL; |
262 | } | 262 | } |
263 | 263 | ||
@@ -267,10 +267,10 @@ static int persistent_ram_init_ecc(struct persistent_ram_zone *prz, | |||
267 | numerr = persistent_ram_decode_rs8(prz, buffer, sizeof(*buffer), | 267 | numerr = persistent_ram_decode_rs8(prz, buffer, sizeof(*buffer), |
268 | prz->par_header); | 268 | prz->par_header); |
269 | if (numerr > 0) { | 269 | if (numerr > 0) { |
270 | pr_info("persistent_ram: error in header, %d\n", numerr); | 270 | pr_info("error in header, %d\n", numerr); |
271 | prz->corrected_bytes += numerr; | 271 | prz->corrected_bytes += numerr; |
272 | } else if (numerr < 0) { | 272 | } else if (numerr < 0) { |
273 | pr_info("persistent_ram: uncorrectable error in header\n"); | 273 | pr_info("uncorrectable error in header\n"); |
274 | prz->bad_blocks++; | 274 | prz->bad_blocks++; |
275 | } | 275 | } |
276 | 276 | ||
@@ -317,7 +317,7 @@ void persistent_ram_save_old(struct persistent_ram_zone *prz) | |||
317 | prz->old_log = kmalloc(size, GFP_KERNEL); | 317 | prz->old_log = kmalloc(size, GFP_KERNEL); |
318 | } | 318 | } |
319 | if (!prz->old_log) { | 319 | if (!prz->old_log) { |
320 | pr_err("persistent_ram: failed to allocate buffer\n"); | 320 | pr_err("failed to allocate buffer\n"); |
321 | return; | 321 | return; |
322 | } | 322 | } |
323 | 323 | ||
@@ -396,8 +396,8 @@ static void *persistent_ram_vmap(phys_addr_t start, size_t size) | |||
396 | 396 | ||
397 | pages = kmalloc(sizeof(struct page *) * page_count, GFP_KERNEL); | 397 | pages = kmalloc(sizeof(struct page *) * page_count, GFP_KERNEL); |
398 | if (!pages) { | 398 | if (!pages) { |
399 | pr_err("%s: Failed to allocate array for %u pages\n", __func__, | 399 | pr_err("%s: Failed to allocate array for %u pages\n", |
400 | page_count); | 400 | __func__, page_count); |
401 | return NULL; | 401 | return NULL; |
402 | } | 402 | } |
403 | 403 | ||
@@ -462,19 +462,17 @@ static int persistent_ram_post_init(struct persistent_ram_zone *prz, u32 sig, | |||
462 | if (prz->buffer->sig == sig) { | 462 | if (prz->buffer->sig == sig) { |
463 | if (buffer_size(prz) > prz->buffer_size || | 463 | if (buffer_size(prz) > prz->buffer_size || |
464 | buffer_start(prz) > buffer_size(prz)) | 464 | buffer_start(prz) > buffer_size(prz)) |
465 | pr_info("persistent_ram: found existing invalid buffer," | 465 | pr_info("found existing invalid buffer, size %zu, start %zu\n", |
466 | " size %zu, start %zu\n", | 466 | buffer_size(prz), buffer_start(prz)); |
467 | buffer_size(prz), buffer_start(prz)); | ||
468 | else { | 467 | else { |
469 | pr_debug("persistent_ram: found existing buffer," | 468 | pr_debug("found existing buffer, size %zu, start %zu\n", |
470 | " size %zu, start %zu\n", | 469 | buffer_size(prz), buffer_start(prz)); |
471 | buffer_size(prz), buffer_start(prz)); | ||
472 | persistent_ram_save_old(prz); | 470 | persistent_ram_save_old(prz); |
473 | return 0; | 471 | return 0; |
474 | } | 472 | } |
475 | } else { | 473 | } else { |
476 | pr_debug("persistent_ram: no valid data in buffer" | 474 | pr_debug("no valid data in buffer (sig = 0x%08x)\n", |
477 | " (sig = 0x%08x)\n", prz->buffer->sig); | 475 | prz->buffer->sig); |
478 | } | 476 | } |
479 | 477 | ||
480 | prz->buffer->sig = sig; | 478 | prz->buffer->sig = sig; |
@@ -509,7 +507,7 @@ struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size, | |||
509 | 507 | ||
510 | prz = kzalloc(sizeof(struct persistent_ram_zone), GFP_KERNEL); | 508 | prz = kzalloc(sizeof(struct persistent_ram_zone), GFP_KERNEL); |
511 | if (!prz) { | 509 | if (!prz) { |
512 | pr_err("persistent_ram: failed to allocate persistent ram zone\n"); | 510 | pr_err("failed to allocate persistent ram zone\n"); |
513 | goto err; | 511 | goto err; |
514 | } | 512 | } |
515 | 513 | ||
diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c index dc9a6829f7c6..1bcffeab713c 100644 --- a/fs/reiserfs/bitmap.c +++ b/fs/reiserfs/bitmap.c | |||
@@ -142,7 +142,6 @@ static int scan_bitmap_block(struct reiserfs_transaction_handle *th, | |||
142 | int org = *beg; | 142 | int org = *beg; |
143 | 143 | ||
144 | BUG_ON(!th->t_trans_id); | 144 | BUG_ON(!th->t_trans_id); |
145 | |||
146 | RFALSE(bmap_n >= reiserfs_bmap_count(s), "Bitmap %u is out of " | 145 | RFALSE(bmap_n >= reiserfs_bmap_count(s), "Bitmap %u is out of " |
147 | "range (0..%u)", bmap_n, reiserfs_bmap_count(s) - 1); | 146 | "range (0..%u)", bmap_n, reiserfs_bmap_count(s) - 1); |
148 | PROC_INFO_INC(s, scan_bitmap.bmap); | 147 | PROC_INFO_INC(s, scan_bitmap.bmap); |
@@ -321,7 +320,6 @@ static int scan_bitmap(struct reiserfs_transaction_handle *th, | |||
321 | unsigned int off_max = s->s_blocksize << 3; | 320 | unsigned int off_max = s->s_blocksize << 3; |
322 | 321 | ||
323 | BUG_ON(!th->t_trans_id); | 322 | BUG_ON(!th->t_trans_id); |
324 | |||
325 | PROC_INFO_INC(s, scan_bitmap.call); | 323 | PROC_INFO_INC(s, scan_bitmap.call); |
326 | if (SB_FREE_BLOCKS(s) <= 0) | 324 | if (SB_FREE_BLOCKS(s) <= 0) |
327 | return 0; // No point in looking for more free blocks | 325 | return 0; // No point in looking for more free blocks |
@@ -388,9 +386,7 @@ static void _reiserfs_free_block(struct reiserfs_transaction_handle *th, | |||
388 | unsigned int nr, offset; | 386 | unsigned int nr, offset; |
389 | 387 | ||
390 | BUG_ON(!th->t_trans_id); | 388 | BUG_ON(!th->t_trans_id); |
391 | |||
392 | PROC_INFO_INC(s, free_block); | 389 | PROC_INFO_INC(s, free_block); |
393 | |||
394 | rs = SB_DISK_SUPER_BLOCK(s); | 390 | rs = SB_DISK_SUPER_BLOCK(s); |
395 | sbh = SB_BUFFER_WITH_SB(s); | 391 | sbh = SB_BUFFER_WITH_SB(s); |
396 | apbi = SB_AP_BITMAP(s); | 392 | apbi = SB_AP_BITMAP(s); |
@@ -435,8 +431,8 @@ void reiserfs_free_block(struct reiserfs_transaction_handle *th, | |||
435 | int for_unformatted) | 431 | int for_unformatted) |
436 | { | 432 | { |
437 | struct super_block *s = th->t_super; | 433 | struct super_block *s = th->t_super; |
438 | BUG_ON(!th->t_trans_id); | ||
439 | 434 | ||
435 | BUG_ON(!th->t_trans_id); | ||
440 | RFALSE(!s, "vs-4061: trying to free block on nonexistent device"); | 436 | RFALSE(!s, "vs-4061: trying to free block on nonexistent device"); |
441 | if (!is_reusable(s, block, 1)) | 437 | if (!is_reusable(s, block, 1)) |
442 | return; | 438 | return; |
@@ -471,6 +467,7 @@ static void __discard_prealloc(struct reiserfs_transaction_handle *th, | |||
471 | unsigned long save = ei->i_prealloc_block; | 467 | unsigned long save = ei->i_prealloc_block; |
472 | int dirty = 0; | 468 | int dirty = 0; |
473 | struct inode *inode = &ei->vfs_inode; | 469 | struct inode *inode = &ei->vfs_inode; |
470 | |||
474 | BUG_ON(!th->t_trans_id); | 471 | BUG_ON(!th->t_trans_id); |
475 | #ifdef CONFIG_REISERFS_CHECK | 472 | #ifdef CONFIG_REISERFS_CHECK |
476 | if (ei->i_prealloc_count < 0) | 473 | if (ei->i_prealloc_count < 0) |
@@ -494,6 +491,7 @@ void reiserfs_discard_prealloc(struct reiserfs_transaction_handle *th, | |||
494 | struct inode *inode) | 491 | struct inode *inode) |
495 | { | 492 | { |
496 | struct reiserfs_inode_info *ei = REISERFS_I(inode); | 493 | struct reiserfs_inode_info *ei = REISERFS_I(inode); |
494 | |||
497 | BUG_ON(!th->t_trans_id); | 495 | BUG_ON(!th->t_trans_id); |
498 | if (ei->i_prealloc_count) | 496 | if (ei->i_prealloc_count) |
499 | __discard_prealloc(th, ei); | 497 | __discard_prealloc(th, ei); |
@@ -504,7 +502,6 @@ void reiserfs_discard_all_prealloc(struct reiserfs_transaction_handle *th) | |||
504 | struct list_head *plist = &SB_JOURNAL(th->t_super)->j_prealloc_list; | 502 | struct list_head *plist = &SB_JOURNAL(th->t_super)->j_prealloc_list; |
505 | 503 | ||
506 | BUG_ON(!th->t_trans_id); | 504 | BUG_ON(!th->t_trans_id); |
507 | |||
508 | while (!list_empty(plist)) { | 505 | while (!list_empty(plist)) { |
509 | struct reiserfs_inode_info *ei; | 506 | struct reiserfs_inode_info *ei; |
510 | ei = list_entry(plist->next, struct reiserfs_inode_info, | 507 | ei = list_entry(plist->next, struct reiserfs_inode_info, |
@@ -562,7 +559,7 @@ int reiserfs_parse_alloc_options(struct super_block *s, char *options) | |||
562 | if (!strcmp(this_char, "displacing_new_packing_localities")) { | 559 | if (!strcmp(this_char, "displacing_new_packing_localities")) { |
563 | SET_OPTION(displacing_new_packing_localities); | 560 | SET_OPTION(displacing_new_packing_localities); |
564 | continue; | 561 | continue; |
565 | }; | 562 | } |
566 | 563 | ||
567 | if (!strcmp(this_char, "old_hashed_relocation")) { | 564 | if (!strcmp(this_char, "old_hashed_relocation")) { |
568 | SET_OPTION(old_hashed_relocation); | 565 | SET_OPTION(old_hashed_relocation); |
@@ -729,6 +726,7 @@ void show_alloc_options(struct seq_file *seq, struct super_block *s) | |||
729 | static inline void new_hashed_relocation(reiserfs_blocknr_hint_t * hint) | 726 | static inline void new_hashed_relocation(reiserfs_blocknr_hint_t * hint) |
730 | { | 727 | { |
731 | char *hash_in; | 728 | char *hash_in; |
729 | |||
732 | if (hint->formatted_node) { | 730 | if (hint->formatted_node) { |
733 | hash_in = (char *)&hint->key.k_dir_id; | 731 | hash_in = (char *)&hint->key.k_dir_id; |
734 | } else { | 732 | } else { |
@@ -757,6 +755,7 @@ static void dirid_groups(reiserfs_blocknr_hint_t * hint) | |||
757 | __u32 dirid = 0; | 755 | __u32 dirid = 0; |
758 | int bm = 0; | 756 | int bm = 0; |
759 | struct super_block *sb = hint->th->t_super; | 757 | struct super_block *sb = hint->th->t_super; |
758 | |||
760 | if (hint->inode) | 759 | if (hint->inode) |
761 | dirid = le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id); | 760 | dirid = le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id); |
762 | else if (hint->formatted_node) | 761 | else if (hint->formatted_node) |
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c index b14706a05d52..615cd9ab7940 100644 --- a/fs/reiserfs/stree.c +++ b/fs/reiserfs/stree.c | |||
@@ -228,10 +228,10 @@ const struct reiserfs_key MIN_KEY = { 0, 0, {{0, 0},} }; | |||
228 | 228 | ||
229 | /* Maximal possible key. It is never in the tree. */ | 229 | /* Maximal possible key. It is never in the tree. */ |
230 | static const struct reiserfs_key MAX_KEY = { | 230 | static const struct reiserfs_key MAX_KEY = { |
231 | __constant_cpu_to_le32(0xffffffff), | 231 | cpu_to_le32(0xffffffff), |
232 | __constant_cpu_to_le32(0xffffffff), | 232 | cpu_to_le32(0xffffffff), |
233 | {{__constant_cpu_to_le32(0xffffffff), | 233 | {{cpu_to_le32(0xffffffff), |
234 | __constant_cpu_to_le32(0xffffffff)},} | 234 | cpu_to_le32(0xffffffff)},} |
235 | }; | 235 | }; |
236 | 236 | ||
237 | /* Get delimiting key of the buffer by looking for it in the buffers in the path, starting from the bottom | 237 | /* Get delimiting key of the buffer by looking for it in the buffers in the path, starting from the bottom |
diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index 0ab1de4b39a5..7bc20809c99e 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | #define INVBLOCK ((u64)-1L) | 25 | #define INVBLOCK ((u64)-1L) |
26 | 26 | ||
27 | static u64 ufs_add_fragments(struct inode *, u64, unsigned, unsigned, int *); | 27 | static u64 ufs_add_fragments(struct inode *, u64, unsigned, unsigned); |
28 | static u64 ufs_alloc_fragments(struct inode *, unsigned, u64, unsigned, int *); | 28 | static u64 ufs_alloc_fragments(struct inode *, unsigned, u64, unsigned, int *); |
29 | static u64 ufs_alloccg_block(struct inode *, struct ufs_cg_private_info *, u64, int *); | 29 | static u64 ufs_alloccg_block(struct inode *, struct ufs_cg_private_info *, u64, int *); |
30 | static u64 ufs_bitmap_search (struct super_block *, struct ufs_cg_private_info *, u64, unsigned); | 30 | static u64 ufs_bitmap_search (struct super_block *, struct ufs_cg_private_info *, u64, unsigned); |
@@ -52,7 +52,7 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count) | |||
52 | if (ufs_fragnum(fragment) + count > uspi->s_fpg) | 52 | if (ufs_fragnum(fragment) + count > uspi->s_fpg) |
53 | ufs_error (sb, "ufs_free_fragments", "internal error"); | 53 | ufs_error (sb, "ufs_free_fragments", "internal error"); |
54 | 54 | ||
55 | mutex_lock(&UFS_SB(sb)->s_lock); | 55 | lock_ufs(sb); |
56 | 56 | ||
57 | cgno = ufs_dtog(uspi, fragment); | 57 | cgno = ufs_dtog(uspi, fragment); |
58 | bit = ufs_dtogd(uspi, fragment); | 58 | bit = ufs_dtogd(uspi, fragment); |
@@ -116,12 +116,12 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count) | |||
116 | ubh_sync_block(UCPI_UBH(ucpi)); | 116 | ubh_sync_block(UCPI_UBH(ucpi)); |
117 | ufs_mark_sb_dirty(sb); | 117 | ufs_mark_sb_dirty(sb); |
118 | 118 | ||
119 | mutex_unlock(&UFS_SB(sb)->s_lock); | 119 | unlock_ufs(sb); |
120 | UFSD("EXIT\n"); | 120 | UFSD("EXIT\n"); |
121 | return; | 121 | return; |
122 | 122 | ||
123 | failed: | 123 | failed: |
124 | mutex_unlock(&UFS_SB(sb)->s_lock); | 124 | unlock_ufs(sb); |
125 | UFSD("EXIT (FAILED)\n"); | 125 | UFSD("EXIT (FAILED)\n"); |
126 | return; | 126 | return; |
127 | } | 127 | } |
@@ -151,7 +151,7 @@ void ufs_free_blocks(struct inode *inode, u64 fragment, unsigned count) | |||
151 | goto failed; | 151 | goto failed; |
152 | } | 152 | } |
153 | 153 | ||
154 | mutex_lock(&UFS_SB(sb)->s_lock); | 154 | lock_ufs(sb); |
155 | 155 | ||
156 | do_more: | 156 | do_more: |
157 | overflow = 0; | 157 | overflow = 0; |
@@ -211,12 +211,12 @@ do_more: | |||
211 | } | 211 | } |
212 | 212 | ||
213 | ufs_mark_sb_dirty(sb); | 213 | ufs_mark_sb_dirty(sb); |
214 | mutex_unlock(&UFS_SB(sb)->s_lock); | 214 | unlock_ufs(sb); |
215 | UFSD("EXIT\n"); | 215 | UFSD("EXIT\n"); |
216 | return; | 216 | return; |
217 | 217 | ||
218 | failed_unlock: | 218 | failed_unlock: |
219 | mutex_unlock(&UFS_SB(sb)->s_lock); | 219 | unlock_ufs(sb); |
220 | failed: | 220 | failed: |
221 | UFSD("EXIT (FAILED)\n"); | 221 | UFSD("EXIT (FAILED)\n"); |
222 | return; | 222 | return; |
@@ -357,7 +357,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, | |||
357 | usb1 = ubh_get_usb_first(uspi); | 357 | usb1 = ubh_get_usb_first(uspi); |
358 | *err = -ENOSPC; | 358 | *err = -ENOSPC; |
359 | 359 | ||
360 | mutex_lock(&UFS_SB(sb)->s_lock); | 360 | lock_ufs(sb); |
361 | tmp = ufs_data_ptr_to_cpu(sb, p); | 361 | tmp = ufs_data_ptr_to_cpu(sb, p); |
362 | 362 | ||
363 | if (count + ufs_fragnum(fragment) > uspi->s_fpb) { | 363 | if (count + ufs_fragnum(fragment) > uspi->s_fpb) { |
@@ -378,19 +378,19 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, | |||
378 | "fragment %llu, tmp %llu\n", | 378 | "fragment %llu, tmp %llu\n", |
379 | (unsigned long long)fragment, | 379 | (unsigned long long)fragment, |
380 | (unsigned long long)tmp); | 380 | (unsigned long long)tmp); |
381 | mutex_unlock(&UFS_SB(sb)->s_lock); | 381 | unlock_ufs(sb); |
382 | return INVBLOCK; | 382 | return INVBLOCK; |
383 | } | 383 | } |
384 | if (fragment < UFS_I(inode)->i_lastfrag) { | 384 | if (fragment < UFS_I(inode)->i_lastfrag) { |
385 | UFSD("EXIT (ALREADY ALLOCATED)\n"); | 385 | UFSD("EXIT (ALREADY ALLOCATED)\n"); |
386 | mutex_unlock(&UFS_SB(sb)->s_lock); | 386 | unlock_ufs(sb); |
387 | return 0; | 387 | return 0; |
388 | } | 388 | } |
389 | } | 389 | } |
390 | else { | 390 | else { |
391 | if (tmp) { | 391 | if (tmp) { |
392 | UFSD("EXIT (ALREADY ALLOCATED)\n"); | 392 | UFSD("EXIT (ALREADY ALLOCATED)\n"); |
393 | mutex_unlock(&UFS_SB(sb)->s_lock); | 393 | unlock_ufs(sb); |
394 | return 0; | 394 | return 0; |
395 | } | 395 | } |
396 | } | 396 | } |
@@ -399,7 +399,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, | |||
399 | * There is not enough space for user on the device | 399 | * There is not enough space for user on the device |
400 | */ | 400 | */ |
401 | if (!capable(CAP_SYS_RESOURCE) && ufs_freespace(uspi, UFS_MINFREE) <= 0) { | 401 | if (!capable(CAP_SYS_RESOURCE) && ufs_freespace(uspi, UFS_MINFREE) <= 0) { |
402 | mutex_unlock(&UFS_SB(sb)->s_lock); | 402 | unlock_ufs(sb); |
403 | UFSD("EXIT (FAILED)\n"); | 403 | UFSD("EXIT (FAILED)\n"); |
404 | return 0; | 404 | return 0; |
405 | } | 405 | } |
@@ -424,7 +424,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, | |||
424 | ufs_clear_frags(inode, result + oldcount, | 424 | ufs_clear_frags(inode, result + oldcount, |
425 | newcount - oldcount, locked_page != NULL); | 425 | newcount - oldcount, locked_page != NULL); |
426 | } | 426 | } |
427 | mutex_unlock(&UFS_SB(sb)->s_lock); | 427 | unlock_ufs(sb); |
428 | UFSD("EXIT, result %llu\n", (unsigned long long)result); | 428 | UFSD("EXIT, result %llu\n", (unsigned long long)result); |
429 | return result; | 429 | return result; |
430 | } | 430 | } |
@@ -432,14 +432,14 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, | |||
432 | /* | 432 | /* |
433 | * resize block | 433 | * resize block |
434 | */ | 434 | */ |
435 | result = ufs_add_fragments (inode, tmp, oldcount, newcount, err); | 435 | result = ufs_add_fragments(inode, tmp, oldcount, newcount); |
436 | if (result) { | 436 | if (result) { |
437 | *err = 0; | 437 | *err = 0; |
438 | UFS_I(inode)->i_lastfrag = max(UFS_I(inode)->i_lastfrag, | 438 | UFS_I(inode)->i_lastfrag = max(UFS_I(inode)->i_lastfrag, |
439 | fragment + count); | 439 | fragment + count); |
440 | ufs_clear_frags(inode, result + oldcount, newcount - oldcount, | 440 | ufs_clear_frags(inode, result + oldcount, newcount - oldcount, |
441 | locked_page != NULL); | 441 | locked_page != NULL); |
442 | mutex_unlock(&UFS_SB(sb)->s_lock); | 442 | unlock_ufs(sb); |
443 | UFSD("EXIT, result %llu\n", (unsigned long long)result); | 443 | UFSD("EXIT, result %llu\n", (unsigned long long)result); |
444 | return result; | 444 | return result; |
445 | } | 445 | } |
@@ -477,7 +477,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, | |||
477 | *err = 0; | 477 | *err = 0; |
478 | UFS_I(inode)->i_lastfrag = max(UFS_I(inode)->i_lastfrag, | 478 | UFS_I(inode)->i_lastfrag = max(UFS_I(inode)->i_lastfrag, |
479 | fragment + count); | 479 | fragment + count); |
480 | mutex_unlock(&UFS_SB(sb)->s_lock); | 480 | unlock_ufs(sb); |
481 | if (newcount < request) | 481 | if (newcount < request) |
482 | ufs_free_fragments (inode, result + newcount, request - newcount); | 482 | ufs_free_fragments (inode, result + newcount, request - newcount); |
483 | ufs_free_fragments (inode, tmp, oldcount); | 483 | ufs_free_fragments (inode, tmp, oldcount); |
@@ -485,13 +485,13 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, | |||
485 | return result; | 485 | return result; |
486 | } | 486 | } |
487 | 487 | ||
488 | mutex_unlock(&UFS_SB(sb)->s_lock); | 488 | unlock_ufs(sb); |
489 | UFSD("EXIT (FAILED)\n"); | 489 | UFSD("EXIT (FAILED)\n"); |
490 | return 0; | 490 | return 0; |
491 | } | 491 | } |
492 | 492 | ||
493 | static u64 ufs_add_fragments(struct inode *inode, u64 fragment, | 493 | static u64 ufs_add_fragments(struct inode *inode, u64 fragment, |
494 | unsigned oldcount, unsigned newcount, int *err) | 494 | unsigned oldcount, unsigned newcount) |
495 | { | 495 | { |
496 | struct super_block * sb; | 496 | struct super_block * sb; |
497 | struct ufs_sb_private_info * uspi; | 497 | struct ufs_sb_private_info * uspi; |
diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c index 98f7211599ff..a9cc75ffa925 100644 --- a/fs/ufs/ialloc.c +++ b/fs/ufs/ialloc.c | |||
@@ -69,11 +69,11 @@ void ufs_free_inode (struct inode * inode) | |||
69 | 69 | ||
70 | ino = inode->i_ino; | 70 | ino = inode->i_ino; |
71 | 71 | ||
72 | mutex_lock(&UFS_SB(sb)->s_lock); | 72 | lock_ufs(sb); |
73 | 73 | ||
74 | if (!((ino > 1) && (ino < (uspi->s_ncg * uspi->s_ipg )))) { | 74 | if (!((ino > 1) && (ino < (uspi->s_ncg * uspi->s_ipg )))) { |
75 | ufs_warning(sb, "ufs_free_inode", "reserved inode or nonexistent inode %u\n", ino); | 75 | ufs_warning(sb, "ufs_free_inode", "reserved inode or nonexistent inode %u\n", ino); |
76 | mutex_unlock(&UFS_SB(sb)->s_lock); | 76 | unlock_ufs(sb); |
77 | return; | 77 | return; |
78 | } | 78 | } |
79 | 79 | ||
@@ -81,7 +81,7 @@ void ufs_free_inode (struct inode * inode) | |||
81 | bit = ufs_inotocgoff (ino); | 81 | bit = ufs_inotocgoff (ino); |
82 | ucpi = ufs_load_cylinder (sb, cg); | 82 | ucpi = ufs_load_cylinder (sb, cg); |
83 | if (!ucpi) { | 83 | if (!ucpi) { |
84 | mutex_unlock(&UFS_SB(sb)->s_lock); | 84 | unlock_ufs(sb); |
85 | return; | 85 | return; |
86 | } | 86 | } |
87 | ucg = ubh_get_ucg(UCPI_UBH(ucpi)); | 87 | ucg = ubh_get_ucg(UCPI_UBH(ucpi)); |
@@ -115,7 +115,7 @@ void ufs_free_inode (struct inode * inode) | |||
115 | ubh_sync_block(UCPI_UBH(ucpi)); | 115 | ubh_sync_block(UCPI_UBH(ucpi)); |
116 | 116 | ||
117 | ufs_mark_sb_dirty(sb); | 117 | ufs_mark_sb_dirty(sb); |
118 | mutex_unlock(&UFS_SB(sb)->s_lock); | 118 | unlock_ufs(sb); |
119 | UFSD("EXIT\n"); | 119 | UFSD("EXIT\n"); |
120 | } | 120 | } |
121 | 121 | ||
@@ -193,7 +193,7 @@ struct inode *ufs_new_inode(struct inode *dir, umode_t mode) | |||
193 | sbi = UFS_SB(sb); | 193 | sbi = UFS_SB(sb); |
194 | uspi = sbi->s_uspi; | 194 | uspi = sbi->s_uspi; |
195 | 195 | ||
196 | mutex_lock(&sbi->s_lock); | 196 | lock_ufs(sb); |
197 | 197 | ||
198 | /* | 198 | /* |
199 | * Try to place the inode in its parent directory | 199 | * Try to place the inode in its parent directory |
@@ -328,21 +328,20 @@ cg_found: | |||
328 | sync_dirty_buffer(bh); | 328 | sync_dirty_buffer(bh); |
329 | brelse(bh); | 329 | brelse(bh); |
330 | } | 330 | } |
331 | 331 | unlock_ufs(sb); | |
332 | mutex_unlock(&sbi->s_lock); | ||
333 | 332 | ||
334 | UFSD("allocating inode %lu\n", inode->i_ino); | 333 | UFSD("allocating inode %lu\n", inode->i_ino); |
335 | UFSD("EXIT\n"); | 334 | UFSD("EXIT\n"); |
336 | return inode; | 335 | return inode; |
337 | 336 | ||
338 | fail_remove_inode: | 337 | fail_remove_inode: |
339 | mutex_unlock(&sbi->s_lock); | 338 | unlock_ufs(sb); |
340 | clear_nlink(inode); | 339 | clear_nlink(inode); |
341 | iput(inode); | 340 | iput(inode); |
342 | UFSD("EXIT (FAILED): err %d\n", err); | 341 | UFSD("EXIT (FAILED): err %d\n", err); |
343 | return ERR_PTR(err); | 342 | return ERR_PTR(err); |
344 | failed: | 343 | failed: |
345 | mutex_unlock(&sbi->s_lock); | 344 | unlock_ufs(sb); |
346 | make_bad_inode(inode); | 345 | make_bad_inode(inode); |
347 | iput (inode); | 346 | iput (inode); |
348 | UFSD("EXIT (FAILED): err %d\n", err); | 347 | UFSD("EXIT (FAILED): err %d\n", err); |
diff --git a/fs/ufs/super.c b/fs/ufs/super.c index c1183f9f69dc..b879f1ba3439 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c | |||
@@ -697,7 +697,6 @@ static int ufs_sync_fs(struct super_block *sb, int wait) | |||
697 | unsigned flags; | 697 | unsigned flags; |
698 | 698 | ||
699 | lock_ufs(sb); | 699 | lock_ufs(sb); |
700 | mutex_lock(&UFS_SB(sb)->s_lock); | ||
701 | 700 | ||
702 | UFSD("ENTER\n"); | 701 | UFSD("ENTER\n"); |
703 | 702 | ||
@@ -715,7 +714,6 @@ static int ufs_sync_fs(struct super_block *sb, int wait) | |||
715 | ufs_put_cstotal(sb); | 714 | ufs_put_cstotal(sb); |
716 | 715 | ||
717 | UFSD("EXIT\n"); | 716 | UFSD("EXIT\n"); |
718 | mutex_unlock(&UFS_SB(sb)->s_lock); | ||
719 | unlock_ufs(sb); | 717 | unlock_ufs(sb); |
720 | 718 | ||
721 | return 0; | 719 | return 0; |
@@ -760,6 +758,7 @@ static void ufs_put_super(struct super_block *sb) | |||
760 | 758 | ||
761 | ubh_brelse_uspi (sbi->s_uspi); | 759 | ubh_brelse_uspi (sbi->s_uspi); |
762 | kfree (sbi->s_uspi); | 760 | kfree (sbi->s_uspi); |
761 | mutex_destroy(&sbi->mutex); | ||
763 | kfree (sbi); | 762 | kfree (sbi); |
764 | sb->s_fs_info = NULL; | 763 | sb->s_fs_info = NULL; |
765 | UFSD("EXIT\n"); | 764 | UFSD("EXIT\n"); |
@@ -786,6 +785,14 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) | |||
786 | flags = 0; | 785 | flags = 0; |
787 | 786 | ||
788 | UFSD("ENTER\n"); | 787 | UFSD("ENTER\n"); |
788 | |||
789 | #ifndef CONFIG_UFS_FS_WRITE | ||
790 | if (!(sb->s_flags & MS_RDONLY)) { | ||
791 | printk("ufs was compiled with read-only support, " | ||
792 | "can't be mounted as read-write\n"); | ||
793 | return -EROFS; | ||
794 | } | ||
795 | #endif | ||
789 | 796 | ||
790 | sbi = kzalloc(sizeof(struct ufs_sb_info), GFP_KERNEL); | 797 | sbi = kzalloc(sizeof(struct ufs_sb_info), GFP_KERNEL); |
791 | if (!sbi) | 798 | if (!sbi) |
@@ -795,15 +802,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) | |||
795 | 802 | ||
796 | UFSD("flag %u\n", (int)(sb->s_flags & MS_RDONLY)); | 803 | UFSD("flag %u\n", (int)(sb->s_flags & MS_RDONLY)); |
797 | 804 | ||
798 | #ifndef CONFIG_UFS_FS_WRITE | ||
799 | if (!(sb->s_flags & MS_RDONLY)) { | ||
800 | printk("ufs was compiled with read-only support, " | ||
801 | "can't be mounted as read-write\n"); | ||
802 | goto failed; | ||
803 | } | ||
804 | #endif | ||
805 | mutex_init(&sbi->mutex); | 805 | mutex_init(&sbi->mutex); |
806 | mutex_init(&sbi->s_lock); | ||
807 | spin_lock_init(&sbi->work_lock); | 806 | spin_lock_init(&sbi->work_lock); |
808 | INIT_DELAYED_WORK(&sbi->sync_work, delayed_sync_fs); | 807 | INIT_DELAYED_WORK(&sbi->sync_work, delayed_sync_fs); |
809 | /* | 808 | /* |
@@ -1257,6 +1256,7 @@ magic_found: | |||
1257 | return 0; | 1256 | return 0; |
1258 | 1257 | ||
1259 | failed: | 1258 | failed: |
1259 | mutex_destroy(&sbi->mutex); | ||
1260 | if (ubh) | 1260 | if (ubh) |
1261 | ubh_brelse_uspi (uspi); | 1261 | ubh_brelse_uspi (uspi); |
1262 | kfree (uspi); | 1262 | kfree (uspi); |
@@ -1280,7 +1280,6 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) | |||
1280 | 1280 | ||
1281 | sync_filesystem(sb); | 1281 | sync_filesystem(sb); |
1282 | lock_ufs(sb); | 1282 | lock_ufs(sb); |
1283 | mutex_lock(&UFS_SB(sb)->s_lock); | ||
1284 | uspi = UFS_SB(sb)->s_uspi; | 1283 | uspi = UFS_SB(sb)->s_uspi; |
1285 | flags = UFS_SB(sb)->s_flags; | 1284 | flags = UFS_SB(sb)->s_flags; |
1286 | usb1 = ubh_get_usb_first(uspi); | 1285 | usb1 = ubh_get_usb_first(uspi); |
@@ -1294,7 +1293,6 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) | |||
1294 | new_mount_opt = 0; | 1293 | new_mount_opt = 0; |
1295 | ufs_set_opt (new_mount_opt, ONERROR_LOCK); | 1294 | ufs_set_opt (new_mount_opt, ONERROR_LOCK); |
1296 | if (!ufs_parse_options (data, &new_mount_opt)) { | 1295 | if (!ufs_parse_options (data, &new_mount_opt)) { |
1297 | mutex_unlock(&UFS_SB(sb)->s_lock); | ||
1298 | unlock_ufs(sb); | 1296 | unlock_ufs(sb); |
1299 | return -EINVAL; | 1297 | return -EINVAL; |
1300 | } | 1298 | } |
@@ -1302,14 +1300,12 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) | |||
1302 | new_mount_opt |= ufstype; | 1300 | new_mount_opt |= ufstype; |
1303 | } else if ((new_mount_opt & UFS_MOUNT_UFSTYPE) != ufstype) { | 1301 | } else if ((new_mount_opt & UFS_MOUNT_UFSTYPE) != ufstype) { |
1304 | printk("ufstype can't be changed during remount\n"); | 1302 | printk("ufstype can't be changed during remount\n"); |
1305 | mutex_unlock(&UFS_SB(sb)->s_lock); | ||
1306 | unlock_ufs(sb); | 1303 | unlock_ufs(sb); |
1307 | return -EINVAL; | 1304 | return -EINVAL; |
1308 | } | 1305 | } |
1309 | 1306 | ||
1310 | if ((*mount_flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) { | 1307 | if ((*mount_flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) { |
1311 | UFS_SB(sb)->s_mount_opt = new_mount_opt; | 1308 | UFS_SB(sb)->s_mount_opt = new_mount_opt; |
1312 | mutex_unlock(&UFS_SB(sb)->s_lock); | ||
1313 | unlock_ufs(sb); | 1309 | unlock_ufs(sb); |
1314 | return 0; | 1310 | return 0; |
1315 | } | 1311 | } |
@@ -1334,7 +1330,6 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) | |||
1334 | #ifndef CONFIG_UFS_FS_WRITE | 1330 | #ifndef CONFIG_UFS_FS_WRITE |
1335 | printk("ufs was compiled with read-only support, " | 1331 | printk("ufs was compiled with read-only support, " |
1336 | "can't be mounted as read-write\n"); | 1332 | "can't be mounted as read-write\n"); |
1337 | mutex_unlock(&UFS_SB(sb)->s_lock); | ||
1338 | unlock_ufs(sb); | 1333 | unlock_ufs(sb); |
1339 | return -EINVAL; | 1334 | return -EINVAL; |
1340 | #else | 1335 | #else |
@@ -1344,13 +1339,11 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) | |||
1344 | ufstype != UFS_MOUNT_UFSTYPE_SUNx86 && | 1339 | ufstype != UFS_MOUNT_UFSTYPE_SUNx86 && |
1345 | ufstype != UFS_MOUNT_UFSTYPE_UFS2) { | 1340 | ufstype != UFS_MOUNT_UFSTYPE_UFS2) { |
1346 | printk("this ufstype is read-only supported\n"); | 1341 | printk("this ufstype is read-only supported\n"); |
1347 | mutex_unlock(&UFS_SB(sb)->s_lock); | ||
1348 | unlock_ufs(sb); | 1342 | unlock_ufs(sb); |
1349 | return -EINVAL; | 1343 | return -EINVAL; |
1350 | } | 1344 | } |
1351 | if (!ufs_read_cylinder_structures(sb)) { | 1345 | if (!ufs_read_cylinder_structures(sb)) { |
1352 | printk("failed during remounting\n"); | 1346 | printk("failed during remounting\n"); |
1353 | mutex_unlock(&UFS_SB(sb)->s_lock); | ||
1354 | unlock_ufs(sb); | 1347 | unlock_ufs(sb); |
1355 | return -EPERM; | 1348 | return -EPERM; |
1356 | } | 1349 | } |
@@ -1358,7 +1351,6 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) | |||
1358 | #endif | 1351 | #endif |
1359 | } | 1352 | } |
1360 | UFS_SB(sb)->s_mount_opt = new_mount_opt; | 1353 | UFS_SB(sb)->s_mount_opt = new_mount_opt; |
1361 | mutex_unlock(&UFS_SB(sb)->s_lock); | ||
1362 | unlock_ufs(sb); | 1354 | unlock_ufs(sb); |
1363 | return 0; | 1355 | return 0; |
1364 | } | 1356 | } |
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h index ff2c15ab81aa..343e6fc571e5 100644 --- a/fs/ufs/ufs.h +++ b/fs/ufs/ufs.h | |||
@@ -24,7 +24,6 @@ struct ufs_sb_info { | |||
24 | int work_queued; /* non-zero if the delayed work is queued */ | 24 | int work_queued; /* non-zero if the delayed work is queued */ |
25 | struct delayed_work sync_work; /* FS sync delayed work */ | 25 | struct delayed_work sync_work; /* FS sync delayed work */ |
26 | spinlock_t work_lock; /* protects sync_work and work_queued */ | 26 | spinlock_t work_lock; /* protects sync_work and work_queued */ |
27 | struct mutex s_lock; | ||
28 | }; | 27 | }; |
29 | 28 | ||
30 | struct ufs_inode_info { | 29 | struct ufs_inode_info { |
diff --git a/include/asm-generic/ioctl.h b/include/asm-generic/ioctl.h index d17295b290fa..297fb0d7cd6c 100644 --- a/include/asm-generic/ioctl.h +++ b/include/asm-generic/ioctl.h | |||
@@ -3,10 +3,15 @@ | |||
3 | 3 | ||
4 | #include <uapi/asm-generic/ioctl.h> | 4 | #include <uapi/asm-generic/ioctl.h> |
5 | 5 | ||
6 | #ifdef __CHECKER__ | ||
7 | #define _IOC_TYPECHECK(t) (sizeof(t)) | ||
8 | #else | ||
6 | /* provoke compile error for invalid uses of size argument */ | 9 | /* provoke compile error for invalid uses of size argument */ |
7 | extern unsigned int __invalid_size_argument_for_IOC; | 10 | extern unsigned int __invalid_size_argument_for_IOC; |
8 | #define _IOC_TYPECHECK(t) \ | 11 | #define _IOC_TYPECHECK(t) \ |
9 | ((sizeof(t) == sizeof(t[1]) && \ | 12 | ((sizeof(t) == sizeof(t[1]) && \ |
10 | sizeof(t) < (1 << _IOC_SIZEBITS)) ? \ | 13 | sizeof(t) < (1 << _IOC_SIZEBITS)) ? \ |
11 | sizeof(t) : __invalid_size_argument_for_IOC) | 14 | sizeof(t) : __invalid_size_argument_for_IOC) |
15 | #endif | ||
16 | |||
12 | #endif /* _ASM_GENERIC_IOCTL_H */ | 17 | #endif /* _ASM_GENERIC_IOCTL_H */ |
diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 81887120395c..95978ad7fcdd 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h | |||
@@ -256,7 +256,6 @@ enum cpuhp_state { | |||
256 | }; | 256 | }; |
257 | 257 | ||
258 | void cpu_startup_entry(enum cpuhp_state state); | 258 | void cpu_startup_entry(enum cpuhp_state state); |
259 | void cpu_idle(void); | ||
260 | 259 | ||
261 | void cpu_idle_poll_ctrl(bool enable); | 260 | void cpu_idle_poll_ctrl(bool enable); |
262 | 261 | ||
diff --git a/include/linux/idr.h b/include/linux/idr.h index 6af3400b9b2f..013fd9bc4cb6 100644 --- a/include/linux/idr.h +++ b/include/linux/idr.h | |||
@@ -29,21 +29,24 @@ | |||
29 | 29 | ||
30 | struct idr_layer { | 30 | struct idr_layer { |
31 | int prefix; /* the ID prefix of this idr_layer */ | 31 | int prefix; /* the ID prefix of this idr_layer */ |
32 | DECLARE_BITMAP(bitmap, IDR_SIZE); /* A zero bit means "space here" */ | 32 | int layer; /* distance from leaf */ |
33 | struct idr_layer __rcu *ary[1<<IDR_BITS]; | 33 | struct idr_layer __rcu *ary[1<<IDR_BITS]; |
34 | int count; /* When zero, we can release it */ | 34 | int count; /* When zero, we can release it */ |
35 | int layer; /* distance from leaf */ | 35 | union { |
36 | struct rcu_head rcu_head; | 36 | /* A zero bit means "space here" */ |
37 | DECLARE_BITMAP(bitmap, IDR_SIZE); | ||
38 | struct rcu_head rcu_head; | ||
39 | }; | ||
37 | }; | 40 | }; |
38 | 41 | ||
39 | struct idr { | 42 | struct idr { |
40 | struct idr_layer __rcu *hint; /* the last layer allocated from */ | 43 | struct idr_layer __rcu *hint; /* the last layer allocated from */ |
41 | struct idr_layer __rcu *top; | 44 | struct idr_layer __rcu *top; |
42 | struct idr_layer *id_free; | ||
43 | int layers; /* only valid w/o concurrent changes */ | 45 | int layers; /* only valid w/o concurrent changes */ |
44 | int id_free_cnt; | ||
45 | int cur; /* current pos for cyclic allocation */ | 46 | int cur; /* current pos for cyclic allocation */ |
46 | spinlock_t lock; | 47 | spinlock_t lock; |
48 | int id_free_cnt; | ||
49 | struct idr_layer *id_free; | ||
47 | }; | 50 | }; |
48 | 51 | ||
49 | #define IDR_INIT(name) \ | 52 | #define IDR_INIT(name) \ |
diff --git a/include/linux/key.h b/include/linux/key.h index 80d677483e31..3ae45f09589b 100644 --- a/include/linux/key.h +++ b/include/linux/key.h | |||
@@ -332,7 +332,7 @@ do { \ | |||
332 | } while (0) | 332 | } while (0) |
333 | 333 | ||
334 | #ifdef CONFIG_SYSCTL | 334 | #ifdef CONFIG_SYSCTL |
335 | extern ctl_table key_sysctls[]; | 335 | extern struct ctl_table key_sysctls[]; |
336 | #endif | 336 | #endif |
337 | /* | 337 | /* |
338 | * the userspace interface | 338 | * the userspace interface |
diff --git a/include/linux/kmemleak.h b/include/linux/kmemleak.h index 5bb424659c04..057e95971014 100644 --- a/include/linux/kmemleak.h +++ b/include/linux/kmemleak.h | |||
@@ -30,6 +30,7 @@ extern void kmemleak_alloc_percpu(const void __percpu *ptr, size_t size) __ref; | |||
30 | extern void kmemleak_free(const void *ptr) __ref; | 30 | extern void kmemleak_free(const void *ptr) __ref; |
31 | extern void kmemleak_free_part(const void *ptr, size_t size) __ref; | 31 | extern void kmemleak_free_part(const void *ptr, size_t size) __ref; |
32 | extern void kmemleak_free_percpu(const void __percpu *ptr) __ref; | 32 | extern void kmemleak_free_percpu(const void __percpu *ptr) __ref; |
33 | extern void kmemleak_update_trace(const void *ptr) __ref; | ||
33 | extern void kmemleak_not_leak(const void *ptr) __ref; | 34 | extern void kmemleak_not_leak(const void *ptr) __ref; |
34 | extern void kmemleak_ignore(const void *ptr) __ref; | 35 | extern void kmemleak_ignore(const void *ptr) __ref; |
35 | extern void kmemleak_scan_area(const void *ptr, size_t size, gfp_t gfp) __ref; | 36 | extern void kmemleak_scan_area(const void *ptr, size_t size, gfp_t gfp) __ref; |
@@ -83,6 +84,9 @@ static inline void kmemleak_free_recursive(const void *ptr, unsigned long flags) | |||
83 | static inline void kmemleak_free_percpu(const void __percpu *ptr) | 84 | static inline void kmemleak_free_percpu(const void __percpu *ptr) |
84 | { | 85 | { |
85 | } | 86 | } |
87 | static inline void kmemleak_update_trace(const void *ptr) | ||
88 | { | ||
89 | } | ||
86 | static inline void kmemleak_not_leak(const void *ptr) | 90 | static inline void kmemleak_not_leak(const void *ptr) |
87 | { | 91 | { |
88 | } | 92 | } |
diff --git a/include/linux/mc146818rtc.h b/include/linux/mc146818rtc.h index 2f4e957af656..433e0c74d643 100644 --- a/include/linux/mc146818rtc.h +++ b/include/linux/mc146818rtc.h | |||
@@ -31,6 +31,10 @@ struct cmos_rtc_board_info { | |||
31 | void (*wake_on)(struct device *dev); | 31 | void (*wake_on)(struct device *dev); |
32 | void (*wake_off)(struct device *dev); | 32 | void (*wake_off)(struct device *dev); |
33 | 33 | ||
34 | u32 flags; | ||
35 | #define CMOS_RTC_FLAGS_NOFREQ (1 << 0) | ||
36 | int address_space; | ||
37 | |||
34 | u8 rtc_day_alarm; /* zero, or register index */ | 38 | u8 rtc_day_alarm; /* zero, or register index */ |
35 | u8 rtc_mon_alarm; /* zero, or register index */ | 39 | u8 rtc_mon_alarm; /* zero, or register index */ |
36 | u8 rtc_century; /* zero, or register index */ | 40 | u8 rtc_century; /* zero, or register index */ |
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h index 07d0df6bf768..077904c8b70d 100644 --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/sched.h> /* For struct task_struct. */ | 5 | #include <linux/sched.h> /* For struct task_struct. */ |
6 | #include <linux/err.h> /* for IS_ERR_VALUE */ | 6 | #include <linux/err.h> /* for IS_ERR_VALUE */ |
7 | #include <linux/bug.h> /* For BUG_ON. */ | 7 | #include <linux/bug.h> /* For BUG_ON. */ |
8 | #include <linux/pid_namespace.h> /* For task_active_pid_ns. */ | ||
8 | #include <uapi/linux/ptrace.h> | 9 | #include <uapi/linux/ptrace.h> |
9 | 10 | ||
10 | /* | 11 | /* |
@@ -129,6 +130,37 @@ static inline void ptrace_event(int event, unsigned long message) | |||
129 | } | 130 | } |
130 | 131 | ||
131 | /** | 132 | /** |
133 | * ptrace_event_pid - possibly stop for a ptrace event notification | ||
134 | * @event: %PTRACE_EVENT_* value to report | ||
135 | * @pid: process identifier for %PTRACE_GETEVENTMSG to return | ||
136 | * | ||
137 | * Check whether @event is enabled and, if so, report @event and @pid | ||
138 | * to the ptrace parent. @pid is reported as the pid_t seen from the | ||
139 | * the ptrace parent's pid namespace. | ||
140 | * | ||
141 | * Called without locks. | ||
142 | */ | ||
143 | static inline void ptrace_event_pid(int event, struct pid *pid) | ||
144 | { | ||
145 | /* | ||
146 | * FIXME: There's a potential race if a ptracer in a different pid | ||
147 | * namespace than parent attaches between computing message below and | ||
148 | * when we acquire tasklist_lock in ptrace_stop(). If this happens, | ||
149 | * the ptracer will get a bogus pid from PTRACE_GETEVENTMSG. | ||
150 | */ | ||
151 | unsigned long message = 0; | ||
152 | struct pid_namespace *ns; | ||
153 | |||
154 | rcu_read_lock(); | ||
155 | ns = task_active_pid_ns(rcu_dereference(current->parent)); | ||
156 | if (ns) | ||
157 | message = pid_nr_ns(pid, ns); | ||
158 | rcu_read_unlock(); | ||
159 | |||
160 | ptrace_event(event, message); | ||
161 | } | ||
162 | |||
163 | /** | ||
132 | * ptrace_init_task - initialize ptrace state for a new child | 164 | * ptrace_init_task - initialize ptrace state for a new child |
133 | * @child: new child task | 165 | * @child: new child task |
134 | * @ptrace: true if child should be ptrace'd by parent's tracer | 166 | * @ptrace: true if child should be ptrace'd by parent's tracer |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 8fcd0e6098d9..ea74596014a2 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -2414,9 +2414,6 @@ extern void flush_itimer_signals(void); | |||
2414 | 2414 | ||
2415 | extern void do_group_exit(int); | 2415 | extern void do_group_exit(int); |
2416 | 2416 | ||
2417 | extern int allow_signal(int); | ||
2418 | extern int disallow_signal(int); | ||
2419 | |||
2420 | extern int do_execve(struct filename *, | 2417 | extern int do_execve(struct filename *, |
2421 | const char __user * const __user *, | 2418 | const char __user * const __user *, |
2422 | const char __user * const __user *); | 2419 | const char __user * const __user *); |
diff --git a/include/linux/shm.h b/include/linux/shm.h index 1e2cd2e6b540..57d77709fbe2 100644 --- a/include/linux/shm.h +++ b/include/linux/shm.h | |||
@@ -3,9 +3,8 @@ | |||
3 | 3 | ||
4 | #include <asm/page.h> | 4 | #include <asm/page.h> |
5 | #include <uapi/linux/shm.h> | 5 | #include <uapi/linux/shm.h> |
6 | |||
7 | #define SHMALL (SHMMAX/PAGE_SIZE*(SHMMNI/16)) /* max shm system wide (pages) */ | ||
8 | #include <asm/shmparam.h> | 6 | #include <asm/shmparam.h> |
7 | |||
9 | struct shmid_kernel /* private to the kernel */ | 8 | struct shmid_kernel /* private to the kernel */ |
10 | { | 9 | { |
11 | struct kern_ipc_perm shm_perm; | 10 | struct kern_ipc_perm shm_perm; |
diff --git a/include/linux/signal.h b/include/linux/signal.h index 2ac423bdb676..c9e65360c49a 100644 --- a/include/linux/signal.h +++ b/include/linux/signal.h | |||
@@ -63,11 +63,6 @@ static inline int sigismember(sigset_t *set, int _sig) | |||
63 | return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW)); | 63 | return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW)); |
64 | } | 64 | } |
65 | 65 | ||
66 | static inline int sigfindinword(unsigned long word) | ||
67 | { | ||
68 | return ffz(~word); | ||
69 | } | ||
70 | |||
71 | #endif /* __HAVE_ARCH_SIG_BITOPS */ | 66 | #endif /* __HAVE_ARCH_SIG_BITOPS */ |
72 | 67 | ||
73 | static inline int sigisemptyset(sigset_t *set) | 68 | static inline int sigisemptyset(sigset_t *set) |
@@ -289,6 +284,22 @@ extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, | |||
289 | extern void signal_setup_done(int failed, struct ksignal *ksig, int stepping); | 284 | extern void signal_setup_done(int failed, struct ksignal *ksig, int stepping); |
290 | extern void signal_delivered(int sig, siginfo_t *info, struct k_sigaction *ka, struct pt_regs *regs, int stepping); | 285 | extern void signal_delivered(int sig, siginfo_t *info, struct k_sigaction *ka, struct pt_regs *regs, int stepping); |
291 | extern void exit_signals(struct task_struct *tsk); | 286 | extern void exit_signals(struct task_struct *tsk); |
287 | extern void kernel_sigaction(int, __sighandler_t); | ||
288 | |||
289 | static inline void allow_signal(int sig) | ||
290 | { | ||
291 | /* | ||
292 | * Kernel threads handle their own signals. Let the signal code | ||
293 | * know it'll be handled, so that they don't get converted to | ||
294 | * SIGKILL or just silently dropped. | ||
295 | */ | ||
296 | kernel_sigaction(sig, (__force __sighandler_t)2); | ||
297 | } | ||
298 | |||
299 | static inline void disallow_signal(int sig) | ||
300 | { | ||
301 | kernel_sigaction(sig, SIG_IGN); | ||
302 | } | ||
292 | 303 | ||
293 | /* | 304 | /* |
294 | * Eventually that'll replace get_signal_to_deliver(); macro for now, | 305 | * Eventually that'll replace get_signal_to_deliver(); macro for now, |
diff --git a/include/linux/smp.h b/include/linux/smp.h index 633f5edd7470..34347f26be9b 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h | |||
@@ -13,8 +13,6 @@ | |||
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/llist.h> | 14 | #include <linux/llist.h> |
15 | 15 | ||
16 | extern void cpu_idle(void); | ||
17 | |||
18 | typedef void (*smp_call_func_t)(void *info); | 16 | typedef void (*smp_call_func_t)(void *info); |
19 | struct call_single_data { | 17 | struct call_single_data { |
20 | struct llist_node llist; | 18 | struct llist_node llist; |
diff --git a/include/uapi/linux/shm.h b/include/uapi/linux/shm.h index 78b69413f582..1fbf24ea37fd 100644 --- a/include/uapi/linux/shm.h +++ b/include/uapi/linux/shm.h | |||
@@ -8,19 +8,20 @@ | |||
8 | #endif | 8 | #endif |
9 | 9 | ||
10 | /* | 10 | /* |
11 | * SHMMAX, SHMMNI and SHMALL are upper limits are defaults which can | 11 | * SHMMNI, SHMMAX and SHMALL are default upper limits which can be |
12 | * be increased by sysctl | 12 | * modified by sysctl. The SHMMAX and SHMALL values have been chosen to |
13 | * be as large possible without facilitating scenarios where userspace | ||
14 | * causes overflows when adjusting the limits via operations of the form | ||
15 | * "retrieve current limit; add X; update limit". It is therefore not | ||
16 | * advised to make SHMMAX and SHMALL any larger. These limits are | ||
17 | * suitable for both 32 and 64-bit systems. | ||
13 | */ | 18 | */ |
14 | |||
15 | #define SHMMAX 0x2000000 /* max shared seg size (bytes) */ | ||
16 | #define SHMMIN 1 /* min shared seg size (bytes) */ | 19 | #define SHMMIN 1 /* min shared seg size (bytes) */ |
17 | #define SHMMNI 4096 /* max num of segs system wide */ | 20 | #define SHMMNI 4096 /* max num of segs system wide */ |
18 | #ifndef __KERNEL__ | 21 | #define SHMMAX (ULONG_MAX - (1UL << 24)) /* max shared seg size (bytes) */ |
19 | #define SHMALL (SHMMAX/getpagesize()*(SHMMNI/16)) | 22 | #define SHMALL (ULONG_MAX - (1UL << 24)) /* max shm system wide (pages) */ |
20 | #endif | ||
21 | #define SHMSEG SHMMNI /* max shared segs per process */ | 23 | #define SHMSEG SHMMNI /* max shared segs per process */ |
22 | 24 | ||
23 | |||
24 | /* Obsolete, used only for backwards compatibility and libc5 compiles */ | 25 | /* Obsolete, used only for backwards compatibility and libc5 compiles */ |
25 | struct shmid_ds { | 26 | struct shmid_ds { |
26 | struct ipc_perm shm_perm; /* operation perms */ | 27 | struct ipc_perm shm_perm; /* operation perms */ |
diff --git a/ipc/compat.c b/ipc/compat.c index 45d035d4cedc..b5ef4f7946dc 100644 --- a/ipc/compat.c +++ b/ipc/compat.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <linux/ptrace.h> | 30 | #include <linux/ptrace.h> |
31 | 31 | ||
32 | #include <linux/mutex.h> | 32 | #include <linux/mutex.h> |
33 | #include <asm/uaccess.h> | 33 | #include <linux/uaccess.h> |
34 | 34 | ||
35 | #include "util.h" | 35 | #include "util.h" |
36 | 36 | ||
diff --git a/ipc/compat_mq.c b/ipc/compat_mq.c index 90d29f59cac6..ef6f91cc4490 100644 --- a/ipc/compat_mq.c +++ b/ipc/compat_mq.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include <linux/mqueue.h> | 12 | #include <linux/mqueue.h> |
13 | #include <linux/syscalls.h> | 13 | #include <linux/syscalls.h> |
14 | 14 | ||
15 | #include <asm/uaccess.h> | 15 | #include <linux/uaccess.h> |
16 | 16 | ||
17 | struct compat_mq_attr { | 17 | struct compat_mq_attr { |
18 | compat_long_t mq_flags; /* message queue flags */ | 18 | compat_long_t mq_flags; /* message queue flags */ |
diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c index 998d31b230f1..c3f0326e98db 100644 --- a/ipc/ipc_sysctl.c +++ b/ipc/ipc_sysctl.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/msg.h> | 18 | #include <linux/msg.h> |
19 | #include "util.h" | 19 | #include "util.h" |
20 | 20 | ||
21 | static void *get_ipc(ctl_table *table) | 21 | static void *get_ipc(struct ctl_table *table) |
22 | { | 22 | { |
23 | char *which = table->data; | 23 | char *which = table->data; |
24 | struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns; | 24 | struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns; |
@@ -27,7 +27,7 @@ static void *get_ipc(ctl_table *table) | |||
27 | } | 27 | } |
28 | 28 | ||
29 | #ifdef CONFIG_PROC_SYSCTL | 29 | #ifdef CONFIG_PROC_SYSCTL |
30 | static int proc_ipc_dointvec(ctl_table *table, int write, | 30 | static int proc_ipc_dointvec(struct ctl_table *table, int write, |
31 | void __user *buffer, size_t *lenp, loff_t *ppos) | 31 | void __user *buffer, size_t *lenp, loff_t *ppos) |
32 | { | 32 | { |
33 | struct ctl_table ipc_table; | 33 | struct ctl_table ipc_table; |
@@ -38,7 +38,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write, | |||
38 | return proc_dointvec(&ipc_table, write, buffer, lenp, ppos); | 38 | return proc_dointvec(&ipc_table, write, buffer, lenp, ppos); |
39 | } | 39 | } |
40 | 40 | ||
41 | static int proc_ipc_dointvec_minmax(ctl_table *table, int write, | 41 | static int proc_ipc_dointvec_minmax(struct ctl_table *table, int write, |
42 | void __user *buffer, size_t *lenp, loff_t *ppos) | 42 | void __user *buffer, size_t *lenp, loff_t *ppos) |
43 | { | 43 | { |
44 | struct ctl_table ipc_table; | 44 | struct ctl_table ipc_table; |
@@ -49,7 +49,7 @@ static int proc_ipc_dointvec_minmax(ctl_table *table, int write, | |||
49 | return proc_dointvec_minmax(&ipc_table, write, buffer, lenp, ppos); | 49 | return proc_dointvec_minmax(&ipc_table, write, buffer, lenp, ppos); |
50 | } | 50 | } |
51 | 51 | ||
52 | static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write, | 52 | static int proc_ipc_dointvec_minmax_orphans(struct ctl_table *table, int write, |
53 | void __user *buffer, size_t *lenp, loff_t *ppos) | 53 | void __user *buffer, size_t *lenp, loff_t *ppos) |
54 | { | 54 | { |
55 | struct ipc_namespace *ns = current->nsproxy->ipc_ns; | 55 | struct ipc_namespace *ns = current->nsproxy->ipc_ns; |
@@ -62,7 +62,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write, | |||
62 | return err; | 62 | return err; |
63 | } | 63 | } |
64 | 64 | ||
65 | static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write, | 65 | static int proc_ipc_callback_dointvec_minmax(struct ctl_table *table, int write, |
66 | void __user *buffer, size_t *lenp, loff_t *ppos) | 66 | void __user *buffer, size_t *lenp, loff_t *ppos) |
67 | { | 67 | { |
68 | struct ctl_table ipc_table; | 68 | struct ctl_table ipc_table; |
@@ -85,7 +85,7 @@ static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write, | |||
85 | return rc; | 85 | return rc; |
86 | } | 86 | } |
87 | 87 | ||
88 | static int proc_ipc_doulongvec_minmax(ctl_table *table, int write, | 88 | static int proc_ipc_doulongvec_minmax(struct ctl_table *table, int write, |
89 | void __user *buffer, size_t *lenp, loff_t *ppos) | 89 | void __user *buffer, size_t *lenp, loff_t *ppos) |
90 | { | 90 | { |
91 | struct ctl_table ipc_table; | 91 | struct ctl_table ipc_table; |
@@ -119,7 +119,7 @@ static void ipc_auto_callback(int val) | |||
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write, | 122 | static int proc_ipcauto_dointvec_minmax(struct ctl_table *table, int write, |
123 | void __user *buffer, size_t *lenp, loff_t *ppos) | 123 | void __user *buffer, size_t *lenp, loff_t *ppos) |
124 | { | 124 | { |
125 | struct ctl_table ipc_table; | 125 | struct ctl_table ipc_table; |
diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c index 5bb8bfe67149..68d4e953762c 100644 --- a/ipc/mq_sysctl.c +++ b/ipc/mq_sysctl.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/sysctl.h> | 14 | #include <linux/sysctl.h> |
15 | 15 | ||
16 | #ifdef CONFIG_PROC_SYSCTL | 16 | #ifdef CONFIG_PROC_SYSCTL |
17 | static void *get_mq(ctl_table *table) | 17 | static void *get_mq(struct ctl_table *table) |
18 | { | 18 | { |
19 | char *which = table->data; | 19 | char *which = table->data; |
20 | struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns; | 20 | struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns; |
@@ -22,7 +22,7 @@ static void *get_mq(ctl_table *table) | |||
22 | return which; | 22 | return which; |
23 | } | 23 | } |
24 | 24 | ||
25 | static int proc_mq_dointvec(ctl_table *table, int write, | 25 | static int proc_mq_dointvec(struct ctl_table *table, int write, |
26 | void __user *buffer, size_t *lenp, loff_t *ppos) | 26 | void __user *buffer, size_t *lenp, loff_t *ppos) |
27 | { | 27 | { |
28 | struct ctl_table mq_table; | 28 | struct ctl_table mq_table; |
@@ -32,7 +32,7 @@ static int proc_mq_dointvec(ctl_table *table, int write, | |||
32 | return proc_dointvec(&mq_table, write, buffer, lenp, ppos); | 32 | return proc_dointvec(&mq_table, write, buffer, lenp, ppos); |
33 | } | 33 | } |
34 | 34 | ||
35 | static int proc_mq_dointvec_minmax(ctl_table *table, int write, | 35 | static int proc_mq_dointvec_minmax(struct ctl_table *table, int write, |
36 | void __user *buffer, size_t *lenp, loff_t *ppos) | 36 | void __user *buffer, size_t *lenp, loff_t *ppos) |
37 | { | 37 | { |
38 | struct ctl_table mq_table; | 38 | struct ctl_table mq_table; |
@@ -53,7 +53,7 @@ static int msg_max_limit_max = HARD_MSGMAX; | |||
53 | static int msg_maxsize_limit_min = MIN_MSGSIZEMAX; | 53 | static int msg_maxsize_limit_min = MIN_MSGSIZEMAX; |
54 | static int msg_maxsize_limit_max = HARD_MSGSIZEMAX; | 54 | static int msg_maxsize_limit_max = HARD_MSGSIZEMAX; |
55 | 55 | ||
56 | static ctl_table mq_sysctls[] = { | 56 | static struct ctl_table mq_sysctls[] = { |
57 | { | 57 | { |
58 | .procname = "queues_max", | 58 | .procname = "queues_max", |
59 | .data = &init_ipc_ns.mq_queues_max, | 59 | .data = &init_ipc_ns.mq_queues_max, |
@@ -100,7 +100,7 @@ static ctl_table mq_sysctls[] = { | |||
100 | {} | 100 | {} |
101 | }; | 101 | }; |
102 | 102 | ||
103 | static ctl_table mq_sysctl_dir[] = { | 103 | static struct ctl_table mq_sysctl_dir[] = { |
104 | { | 104 | { |
105 | .procname = "mqueue", | 105 | .procname = "mqueue", |
106 | .mode = 0555, | 106 | .mode = 0555, |
@@ -109,7 +109,7 @@ static ctl_table mq_sysctl_dir[] = { | |||
109 | {} | 109 | {} |
110 | }; | 110 | }; |
111 | 111 | ||
112 | static ctl_table mq_sysctl_root[] = { | 112 | static struct ctl_table mq_sysctl_root[] = { |
113 | { | 113 | { |
114 | .procname = "fs", | 114 | .procname = "fs", |
115 | .mode = 0555, | 115 | .mode = 0555, |
@@ -39,12 +39,10 @@ | |||
39 | #include <linux/ipc_namespace.h> | 39 | #include <linux/ipc_namespace.h> |
40 | 40 | ||
41 | #include <asm/current.h> | 41 | #include <asm/current.h> |
42 | #include <asm/uaccess.h> | 42 | #include <linux/uaccess.h> |
43 | #include "util.h" | 43 | #include "util.h" |
44 | 44 | ||
45 | /* | 45 | /* one msg_receiver structure for each sleeping receiver */ |
46 | * one msg_receiver structure for each sleeping receiver: | ||
47 | */ | ||
48 | struct msg_receiver { | 46 | struct msg_receiver { |
49 | struct list_head r_list; | 47 | struct list_head r_list; |
50 | struct task_struct *r_tsk; | 48 | struct task_struct *r_tsk; |
@@ -53,6 +51,12 @@ struct msg_receiver { | |||
53 | long r_msgtype; | 51 | long r_msgtype; |
54 | long r_maxsize; | 52 | long r_maxsize; |
55 | 53 | ||
54 | /* | ||
55 | * Mark r_msg volatile so that the compiler | ||
56 | * does not try to get smart and optimize | ||
57 | * it. We rely on this for the lockless | ||
58 | * receive algorithm. | ||
59 | */ | ||
56 | struct msg_msg *volatile r_msg; | 60 | struct msg_msg *volatile r_msg; |
57 | }; | 61 | }; |
58 | 62 | ||
@@ -70,75 +74,6 @@ struct msg_sender { | |||
70 | 74 | ||
71 | #define msg_ids(ns) ((ns)->ids[IPC_MSG_IDS]) | 75 | #define msg_ids(ns) ((ns)->ids[IPC_MSG_IDS]) |
72 | 76 | ||
73 | static void freeque(struct ipc_namespace *, struct kern_ipc_perm *); | ||
74 | static int newque(struct ipc_namespace *, struct ipc_params *); | ||
75 | #ifdef CONFIG_PROC_FS | ||
76 | static int sysvipc_msg_proc_show(struct seq_file *s, void *it); | ||
77 | #endif | ||
78 | |||
79 | /* | ||
80 | * Scale msgmni with the available lowmem size: the memory dedicated to msg | ||
81 | * queues should occupy at most 1/MSG_MEM_SCALE of lowmem. | ||
82 | * Also take into account the number of nsproxies created so far. | ||
83 | * This should be done staying within the (MSGMNI , IPCMNI/nr_ipc_ns) range. | ||
84 | */ | ||
85 | void recompute_msgmni(struct ipc_namespace *ns) | ||
86 | { | ||
87 | struct sysinfo i; | ||
88 | unsigned long allowed; | ||
89 | int nb_ns; | ||
90 | |||
91 | si_meminfo(&i); | ||
92 | allowed = (((i.totalram - i.totalhigh) / MSG_MEM_SCALE) * i.mem_unit) | ||
93 | / MSGMNB; | ||
94 | nb_ns = atomic_read(&nr_ipc_ns); | ||
95 | allowed /= nb_ns; | ||
96 | |||
97 | if (allowed < MSGMNI) { | ||
98 | ns->msg_ctlmni = MSGMNI; | ||
99 | return; | ||
100 | } | ||
101 | |||
102 | if (allowed > IPCMNI / nb_ns) { | ||
103 | ns->msg_ctlmni = IPCMNI / nb_ns; | ||
104 | return; | ||
105 | } | ||
106 | |||
107 | ns->msg_ctlmni = allowed; | ||
108 | } | ||
109 | |||
110 | void msg_init_ns(struct ipc_namespace *ns) | ||
111 | { | ||
112 | ns->msg_ctlmax = MSGMAX; | ||
113 | ns->msg_ctlmnb = MSGMNB; | ||
114 | |||
115 | recompute_msgmni(ns); | ||
116 | |||
117 | atomic_set(&ns->msg_bytes, 0); | ||
118 | atomic_set(&ns->msg_hdrs, 0); | ||
119 | ipc_init_ids(&ns->ids[IPC_MSG_IDS]); | ||
120 | } | ||
121 | |||
122 | #ifdef CONFIG_IPC_NS | ||
123 | void msg_exit_ns(struct ipc_namespace *ns) | ||
124 | { | ||
125 | free_ipcs(ns, &msg_ids(ns), freeque); | ||
126 | idr_destroy(&ns->ids[IPC_MSG_IDS].ipcs_idr); | ||
127 | } | ||
128 | #endif | ||
129 | |||
130 | void __init msg_init(void) | ||
131 | { | ||
132 | msg_init_ns(&init_ipc_ns); | ||
133 | |||
134 | printk(KERN_INFO "msgmni has been set to %d\n", | ||
135 | init_ipc_ns.msg_ctlmni); | ||
136 | |||
137 | ipc_init_proc_interface("sysvipc/msg", | ||
138 | " key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n", | ||
139 | IPC_MSG_IDS, sysvipc_msg_proc_show); | ||
140 | } | ||
141 | |||
142 | static inline struct msg_queue *msq_obtain_object(struct ipc_namespace *ns, int id) | 77 | static inline struct msg_queue *msq_obtain_object(struct ipc_namespace *ns, int id) |
143 | { | 78 | { |
144 | struct kern_ipc_perm *ipcp = ipc_obtain_object(&msg_ids(ns), id); | 79 | struct kern_ipc_perm *ipcp = ipc_obtain_object(&msg_ids(ns), id); |
@@ -227,7 +162,7 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params) | |||
227 | static inline void ss_add(struct msg_queue *msq, struct msg_sender *mss) | 162 | static inline void ss_add(struct msg_queue *msq, struct msg_sender *mss) |
228 | { | 163 | { |
229 | mss->tsk = current; | 164 | mss->tsk = current; |
230 | current->state = TASK_INTERRUPTIBLE; | 165 | __set_current_state(TASK_INTERRUPTIBLE); |
231 | list_add_tail(&mss->list, &msq->q_senders); | 166 | list_add_tail(&mss->list, &msq->q_senders); |
232 | } | 167 | } |
233 | 168 | ||
@@ -306,15 +241,14 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg) | |||
306 | SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg) | 241 | SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg) |
307 | { | 242 | { |
308 | struct ipc_namespace *ns; | 243 | struct ipc_namespace *ns; |
309 | struct ipc_ops msg_ops; | 244 | static const struct ipc_ops msg_ops = { |
245 | .getnew = newque, | ||
246 | .associate = msg_security, | ||
247 | }; | ||
310 | struct ipc_params msg_params; | 248 | struct ipc_params msg_params; |
311 | 249 | ||
312 | ns = current->nsproxy->ipc_ns; | 250 | ns = current->nsproxy->ipc_ns; |
313 | 251 | ||
314 | msg_ops.getnew = newque; | ||
315 | msg_ops.associate = msg_security; | ||
316 | msg_ops.more_checks = NULL; | ||
317 | |||
318 | msg_params.key = key; | 252 | msg_params.key = key; |
319 | msg_params.flg = msgflg; | 253 | msg_params.flg = msgflg; |
320 | 254 | ||
@@ -612,23 +546,22 @@ SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, struct msqid_ds __user *, buf) | |||
612 | 546 | ||
613 | static int testmsg(struct msg_msg *msg, long type, int mode) | 547 | static int testmsg(struct msg_msg *msg, long type, int mode) |
614 | { | 548 | { |
615 | switch (mode) | 549 | switch (mode) { |
616 | { | 550 | case SEARCH_ANY: |
617 | case SEARCH_ANY: | 551 | case SEARCH_NUMBER: |
618 | case SEARCH_NUMBER: | 552 | return 1; |
553 | case SEARCH_LESSEQUAL: | ||
554 | if (msg->m_type <= type) | ||
619 | return 1; | 555 | return 1; |
620 | case SEARCH_LESSEQUAL: | 556 | break; |
621 | if (msg->m_type <= type) | 557 | case SEARCH_EQUAL: |
622 | return 1; | 558 | if (msg->m_type == type) |
623 | break; | 559 | return 1; |
624 | case SEARCH_EQUAL: | 560 | break; |
625 | if (msg->m_type == type) | 561 | case SEARCH_NOTEQUAL: |
626 | return 1; | 562 | if (msg->m_type != type) |
627 | break; | 563 | return 1; |
628 | case SEARCH_NOTEQUAL: | 564 | break; |
629 | if (msg->m_type != type) | ||
630 | return 1; | ||
631 | break; | ||
632 | } | 565 | } |
633 | return 0; | 566 | return 0; |
634 | } | 567 | } |
@@ -978,7 +911,7 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp, int msgfl | |||
978 | else | 911 | else |
979 | msr_d.r_maxsize = bufsz; | 912 | msr_d.r_maxsize = bufsz; |
980 | msr_d.r_msg = ERR_PTR(-EAGAIN); | 913 | msr_d.r_msg = ERR_PTR(-EAGAIN); |
981 | current->state = TASK_INTERRUPTIBLE; | 914 | __set_current_state(TASK_INTERRUPTIBLE); |
982 | 915 | ||
983 | ipc_unlock_object(&msq->q_perm); | 916 | ipc_unlock_object(&msq->q_perm); |
984 | rcu_read_unlock(); | 917 | rcu_read_unlock(); |
@@ -1056,6 +989,57 @@ SYSCALL_DEFINE5(msgrcv, int, msqid, struct msgbuf __user *, msgp, size_t, msgsz, | |||
1056 | return do_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg, do_msg_fill); | 989 | return do_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg, do_msg_fill); |
1057 | } | 990 | } |
1058 | 991 | ||
992 | /* | ||
993 | * Scale msgmni with the available lowmem size: the memory dedicated to msg | ||
994 | * queues should occupy at most 1/MSG_MEM_SCALE of lowmem. | ||
995 | * Also take into account the number of nsproxies created so far. | ||
996 | * This should be done staying within the (MSGMNI , IPCMNI/nr_ipc_ns) range. | ||
997 | */ | ||
998 | void recompute_msgmni(struct ipc_namespace *ns) | ||
999 | { | ||
1000 | struct sysinfo i; | ||
1001 | unsigned long allowed; | ||
1002 | int nb_ns; | ||
1003 | |||
1004 | si_meminfo(&i); | ||
1005 | allowed = (((i.totalram - i.totalhigh) / MSG_MEM_SCALE) * i.mem_unit) | ||
1006 | / MSGMNB; | ||
1007 | nb_ns = atomic_read(&nr_ipc_ns); | ||
1008 | allowed /= nb_ns; | ||
1009 | |||
1010 | if (allowed < MSGMNI) { | ||
1011 | ns->msg_ctlmni = MSGMNI; | ||
1012 | return; | ||
1013 | } | ||
1014 | |||
1015 | if (allowed > IPCMNI / nb_ns) { | ||
1016 | ns->msg_ctlmni = IPCMNI / nb_ns; | ||
1017 | return; | ||
1018 | } | ||
1019 | |||
1020 | ns->msg_ctlmni = allowed; | ||
1021 | } | ||
1022 | |||
1023 | void msg_init_ns(struct ipc_namespace *ns) | ||
1024 | { | ||
1025 | ns->msg_ctlmax = MSGMAX; | ||
1026 | ns->msg_ctlmnb = MSGMNB; | ||
1027 | |||
1028 | recompute_msgmni(ns); | ||
1029 | |||
1030 | atomic_set(&ns->msg_bytes, 0); | ||
1031 | atomic_set(&ns->msg_hdrs, 0); | ||
1032 | ipc_init_ids(&ns->ids[IPC_MSG_IDS]); | ||
1033 | } | ||
1034 | |||
1035 | #ifdef CONFIG_IPC_NS | ||
1036 | void msg_exit_ns(struct ipc_namespace *ns) | ||
1037 | { | ||
1038 | free_ipcs(ns, &msg_ids(ns), freeque); | ||
1039 | idr_destroy(&ns->ids[IPC_MSG_IDS].ipcs_idr); | ||
1040 | } | ||
1041 | #endif | ||
1042 | |||
1059 | #ifdef CONFIG_PROC_FS | 1043 | #ifdef CONFIG_PROC_FS |
1060 | static int sysvipc_msg_proc_show(struct seq_file *s, void *it) | 1044 | static int sysvipc_msg_proc_show(struct seq_file *s, void *it) |
1061 | { | 1045 | { |
@@ -1080,3 +1064,15 @@ static int sysvipc_msg_proc_show(struct seq_file *s, void *it) | |||
1080 | msq->q_ctime); | 1064 | msq->q_ctime); |
1081 | } | 1065 | } |
1082 | #endif | 1066 | #endif |
1067 | |||
1068 | void __init msg_init(void) | ||
1069 | { | ||
1070 | msg_init_ns(&init_ipc_ns); | ||
1071 | |||
1072 | printk(KERN_INFO "msgmni has been set to %d\n", | ||
1073 | init_ipc_ns.msg_ctlmni); | ||
1074 | |||
1075 | ipc_init_proc_interface("sysvipc/msg", | ||
1076 | " key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n", | ||
1077 | IPC_MSG_IDS, sysvipc_msg_proc_show); | ||
1078 | } | ||
@@ -47,8 +47,7 @@ | |||
47 | * Thus: Perfect SMP scaling between independent semaphore arrays. | 47 | * Thus: Perfect SMP scaling between independent semaphore arrays. |
48 | * If multiple semaphores in one array are used, then cache line | 48 | * If multiple semaphores in one array are used, then cache line |
49 | * trashing on the semaphore array spinlock will limit the scaling. | 49 | * trashing on the semaphore array spinlock will limit the scaling. |
50 | * - semncnt and semzcnt are calculated on demand in count_semncnt() and | 50 | * - semncnt and semzcnt are calculated on demand in count_semcnt() |
51 | * count_semzcnt() | ||
52 | * - the task that performs a successful semop() scans the list of all | 51 | * - the task that performs a successful semop() scans the list of all |
53 | * sleeping tasks and completes any pending operations that can be fulfilled. | 52 | * sleeping tasks and completes any pending operations that can be fulfilled. |
54 | * Semaphores are actively given to waiting tasks (necessary for FIFO). | 53 | * Semaphores are actively given to waiting tasks (necessary for FIFO). |
@@ -87,7 +86,7 @@ | |||
87 | #include <linux/nsproxy.h> | 86 | #include <linux/nsproxy.h> |
88 | #include <linux/ipc_namespace.h> | 87 | #include <linux/ipc_namespace.h> |
89 | 88 | ||
90 | #include <asm/uaccess.h> | 89 | #include <linux/uaccess.h> |
91 | #include "util.h" | 90 | #include "util.h" |
92 | 91 | ||
93 | /* One semaphore structure for each semaphore in the system. */ | 92 | /* One semaphore structure for each semaphore in the system. */ |
@@ -110,6 +109,7 @@ struct sem_queue { | |||
110 | int pid; /* process id of requesting process */ | 109 | int pid; /* process id of requesting process */ |
111 | int status; /* completion status of operation */ | 110 | int status; /* completion status of operation */ |
112 | struct sembuf *sops; /* array of pending operations */ | 111 | struct sembuf *sops; /* array of pending operations */ |
112 | struct sembuf *blocking; /* the operation that blocked */ | ||
113 | int nsops; /* number of operations */ | 113 | int nsops; /* number of operations */ |
114 | int alter; /* does *sops alter the array? */ | 114 | int alter; /* does *sops alter the array? */ |
115 | }; | 115 | }; |
@@ -160,7 +160,7 @@ static int sysvipc_sem_proc_show(struct seq_file *s, void *it); | |||
160 | * sem_array.pending{_alter,_cont}, | 160 | * sem_array.pending{_alter,_cont}, |
161 | * sem_array.sem_undo: global sem_lock() for read/write | 161 | * sem_array.sem_undo: global sem_lock() for read/write |
162 | * sem_undo.proc_next: only "current" is allowed to read/write that field. | 162 | * sem_undo.proc_next: only "current" is allowed to read/write that field. |
163 | * | 163 | * |
164 | * sem_array.sem_base[i].pending_{const,alter}: | 164 | * sem_array.sem_base[i].pending_{const,alter}: |
165 | * global or semaphore sem_lock() for read/write | 165 | * global or semaphore sem_lock() for read/write |
166 | */ | 166 | */ |
@@ -564,7 +564,11 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp, | |||
564 | SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg) | 564 | SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg) |
565 | { | 565 | { |
566 | struct ipc_namespace *ns; | 566 | struct ipc_namespace *ns; |
567 | struct ipc_ops sem_ops; | 567 | static const struct ipc_ops sem_ops = { |
568 | .getnew = newary, | ||
569 | .associate = sem_security, | ||
570 | .more_checks = sem_more_checks, | ||
571 | }; | ||
568 | struct ipc_params sem_params; | 572 | struct ipc_params sem_params; |
569 | 573 | ||
570 | ns = current->nsproxy->ipc_ns; | 574 | ns = current->nsproxy->ipc_ns; |
@@ -572,10 +576,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg) | |||
572 | if (nsems < 0 || nsems > ns->sc_semmsl) | 576 | if (nsems < 0 || nsems > ns->sc_semmsl) |
573 | return -EINVAL; | 577 | return -EINVAL; |
574 | 578 | ||
575 | sem_ops.getnew = newary; | ||
576 | sem_ops.associate = sem_security; | ||
577 | sem_ops.more_checks = sem_more_checks; | ||
578 | |||
579 | sem_params.key = key; | 579 | sem_params.key = key; |
580 | sem_params.flg = semflg; | 580 | sem_params.flg = semflg; |
581 | sem_params.u.nsems = nsems; | 581 | sem_params.u.nsems = nsems; |
@@ -586,21 +586,23 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg) | |||
586 | /** | 586 | /** |
587 | * perform_atomic_semop - Perform (if possible) a semaphore operation | 587 | * perform_atomic_semop - Perform (if possible) a semaphore operation |
588 | * @sma: semaphore array | 588 | * @sma: semaphore array |
589 | * @sops: array with operations that should be checked | 589 | * @q: struct sem_queue that describes the operation |
590 | * @nsops: number of operations | ||
591 | * @un: undo array | ||
592 | * @pid: pid that did the change | ||
593 | * | 590 | * |
594 | * Returns 0 if the operation was possible. | 591 | * Returns 0 if the operation was possible. |
595 | * Returns 1 if the operation is impossible, the caller must sleep. | 592 | * Returns 1 if the operation is impossible, the caller must sleep. |
596 | * Negative values are error codes. | 593 | * Negative values are error codes. |
597 | */ | 594 | */ |
598 | static int perform_atomic_semop(struct sem_array *sma, struct sembuf *sops, | 595 | static int perform_atomic_semop(struct sem_array *sma, struct sem_queue *q) |
599 | int nsops, struct sem_undo *un, int pid) | ||
600 | { | 596 | { |
601 | int result, sem_op; | 597 | int result, sem_op, nsops, pid; |
602 | struct sembuf *sop; | 598 | struct sembuf *sop; |
603 | struct sem *curr; | 599 | struct sem *curr; |
600 | struct sembuf *sops; | ||
601 | struct sem_undo *un; | ||
602 | |||
603 | sops = q->sops; | ||
604 | nsops = q->nsops; | ||
605 | un = q->undo; | ||
604 | 606 | ||
605 | for (sop = sops; sop < sops + nsops; sop++) { | 607 | for (sop = sops; sop < sops + nsops; sop++) { |
606 | curr = sma->sem_base + sop->sem_num; | 608 | curr = sma->sem_base + sop->sem_num; |
@@ -628,6 +630,7 @@ static int perform_atomic_semop(struct sem_array *sma, struct sembuf *sops, | |||
628 | } | 630 | } |
629 | 631 | ||
630 | sop--; | 632 | sop--; |
633 | pid = q->pid; | ||
631 | while (sop >= sops) { | 634 | while (sop >= sops) { |
632 | sma->sem_base[sop->sem_num].sempid = pid; | 635 | sma->sem_base[sop->sem_num].sempid = pid; |
633 | sop--; | 636 | sop--; |
@@ -640,6 +643,8 @@ out_of_range: | |||
640 | goto undo; | 643 | goto undo; |
641 | 644 | ||
642 | would_block: | 645 | would_block: |
646 | q->blocking = sop; | ||
647 | |||
643 | if (sop->sem_flg & IPC_NOWAIT) | 648 | if (sop->sem_flg & IPC_NOWAIT) |
644 | result = -EAGAIN; | 649 | result = -EAGAIN; |
645 | else | 650 | else |
@@ -780,8 +785,7 @@ static int wake_const_ops(struct sem_array *sma, int semnum, | |||
780 | q = container_of(walk, struct sem_queue, list); | 785 | q = container_of(walk, struct sem_queue, list); |
781 | walk = walk->next; | 786 | walk = walk->next; |
782 | 787 | ||
783 | error = perform_atomic_semop(sma, q->sops, q->nsops, | 788 | error = perform_atomic_semop(sma, q); |
784 | q->undo, q->pid); | ||
785 | 789 | ||
786 | if (error <= 0) { | 790 | if (error <= 0) { |
787 | /* operation completed, remove from queue & wakeup */ | 791 | /* operation completed, remove from queue & wakeup */ |
@@ -893,8 +897,7 @@ again: | |||
893 | if (semnum != -1 && sma->sem_base[semnum].semval == 0) | 897 | if (semnum != -1 && sma->sem_base[semnum].semval == 0) |
894 | break; | 898 | break; |
895 | 899 | ||
896 | error = perform_atomic_semop(sma, q->sops, q->nsops, | 900 | error = perform_atomic_semop(sma, q); |
897 | q->undo, q->pid); | ||
898 | 901 | ||
899 | /* Does q->sleeper still need to sleep? */ | 902 | /* Does q->sleeper still need to sleep? */ |
900 | if (error > 0) | 903 | if (error > 0) |
@@ -989,65 +992,74 @@ static void do_smart_update(struct sem_array *sma, struct sembuf *sops, int nsop | |||
989 | set_semotime(sma, sops); | 992 | set_semotime(sma, sops); |
990 | } | 993 | } |
991 | 994 | ||
992 | /* The following counts are associated to each semaphore: | 995 | /* |
993 | * semncnt number of tasks waiting on semval being nonzero | 996 | * check_qop: Test if a queued operation sleeps on the semaphore semnum |
994 | * semzcnt number of tasks waiting on semval being zero | ||
995 | * This model assumes that a task waits on exactly one semaphore. | ||
996 | * Since semaphore operations are to be performed atomically, tasks actually | ||
997 | * wait on a whole sequence of semaphores simultaneously. | ||
998 | * The counts we return here are a rough approximation, but still | ||
999 | * warrant that semncnt+semzcnt>0 if the task is on the pending queue. | ||
1000 | */ | 997 | */ |
1001 | static int count_semncnt(struct sem_array *sma, ushort semnum) | 998 | static int check_qop(struct sem_array *sma, int semnum, struct sem_queue *q, |
999 | bool count_zero) | ||
1002 | { | 1000 | { |
1003 | int semncnt; | 1001 | struct sembuf *sop = q->blocking; |
1004 | struct sem_queue *q; | ||
1005 | 1002 | ||
1006 | semncnt = 0; | 1003 | /* |
1007 | list_for_each_entry(q, &sma->sem_base[semnum].pending_alter, list) { | 1004 | * Linux always (since 0.99.10) reported a task as sleeping on all |
1008 | struct sembuf *sops = q->sops; | 1005 | * semaphores. This violates SUS, therefore it was changed to the |
1009 | BUG_ON(sops->sem_num != semnum); | 1006 | * standard compliant behavior. |
1010 | if ((sops->sem_op < 0) && !(sops->sem_flg & IPC_NOWAIT)) | 1007 | * Give the administrators a chance to notice that an application |
1011 | semncnt++; | 1008 | * might misbehave because it relies on the Linux behavior. |
1012 | } | 1009 | */ |
1010 | pr_info_once("semctl(GETNCNT/GETZCNT) is since 3.16 Single Unix Specification compliant.\n" | ||
1011 | "The task %s (%d) triggered the difference, watch for misbehavior.\n", | ||
1012 | current->comm, task_pid_nr(current)); | ||
1013 | 1013 | ||
1014 | list_for_each_entry(q, &sma->pending_alter, list) { | 1014 | if (sop->sem_num != semnum) |
1015 | struct sembuf *sops = q->sops; | 1015 | return 0; |
1016 | int nsops = q->nsops; | 1016 | |
1017 | int i; | 1017 | if (count_zero && sop->sem_op == 0) |
1018 | for (i = 0; i < nsops; i++) | 1018 | return 1; |
1019 | if (sops[i].sem_num == semnum | 1019 | if (!count_zero && sop->sem_op < 0) |
1020 | && (sops[i].sem_op < 0) | 1020 | return 1; |
1021 | && !(sops[i].sem_flg & IPC_NOWAIT)) | 1021 | |
1022 | semncnt++; | 1022 | return 0; |
1023 | } | ||
1024 | return semncnt; | ||
1025 | } | 1023 | } |
1026 | 1024 | ||
1027 | static int count_semzcnt(struct sem_array *sma, ushort semnum) | 1025 | /* The following counts are associated to each semaphore: |
1026 | * semncnt number of tasks waiting on semval being nonzero | ||
1027 | * semzcnt number of tasks waiting on semval being zero | ||
1028 | * | ||
1029 | * Per definition, a task waits only on the semaphore of the first semop | ||
1030 | * that cannot proceed, even if additional operation would block, too. | ||
1031 | */ | ||
1032 | static int count_semcnt(struct sem_array *sma, ushort semnum, | ||
1033 | bool count_zero) | ||
1028 | { | 1034 | { |
1029 | int semzcnt; | 1035 | struct list_head *l; |
1030 | struct sem_queue *q; | 1036 | struct sem_queue *q; |
1037 | int semcnt; | ||
1038 | |||
1039 | semcnt = 0; | ||
1040 | /* First: check the simple operations. They are easy to evaluate */ | ||
1041 | if (count_zero) | ||
1042 | l = &sma->sem_base[semnum].pending_const; | ||
1043 | else | ||
1044 | l = &sma->sem_base[semnum].pending_alter; | ||
1031 | 1045 | ||
1032 | semzcnt = 0; | 1046 | list_for_each_entry(q, l, list) { |
1033 | list_for_each_entry(q, &sma->sem_base[semnum].pending_const, list) { | 1047 | /* all task on a per-semaphore list sleep on exactly |
1034 | struct sembuf *sops = q->sops; | 1048 | * that semaphore |
1035 | BUG_ON(sops->sem_num != semnum); | 1049 | */ |
1036 | if ((sops->sem_op == 0) && !(sops->sem_flg & IPC_NOWAIT)) | 1050 | semcnt++; |
1037 | semzcnt++; | ||
1038 | } | 1051 | } |
1039 | 1052 | ||
1040 | list_for_each_entry(q, &sma->pending_const, list) { | 1053 | /* Then: check the complex operations. */ |
1041 | struct sembuf *sops = q->sops; | 1054 | list_for_each_entry(q, &sma->pending_alter, list) { |
1042 | int nsops = q->nsops; | 1055 | semcnt += check_qop(sma, semnum, q, count_zero); |
1043 | int i; | ||
1044 | for (i = 0; i < nsops; i++) | ||
1045 | if (sops[i].sem_num == semnum | ||
1046 | && (sops[i].sem_op == 0) | ||
1047 | && !(sops[i].sem_flg & IPC_NOWAIT)) | ||
1048 | semzcnt++; | ||
1049 | } | 1056 | } |
1050 | return semzcnt; | 1057 | if (count_zero) { |
1058 | list_for_each_entry(q, &sma->pending_const, list) { | ||
1059 | semcnt += check_qop(sma, semnum, q, count_zero); | ||
1060 | } | ||
1061 | } | ||
1062 | return semcnt; | ||
1051 | } | 1063 | } |
1052 | 1064 | ||
1053 | /* Free a semaphore set. freeary() is called with sem_ids.rwsem locked | 1065 | /* Free a semaphore set. freeary() is called with sem_ids.rwsem locked |
@@ -1161,7 +1173,7 @@ static int semctl_nolock(struct ipc_namespace *ns, int semid, | |||
1161 | err = security_sem_semctl(NULL, cmd); | 1173 | err = security_sem_semctl(NULL, cmd); |
1162 | if (err) | 1174 | if (err) |
1163 | return err; | 1175 | return err; |
1164 | 1176 | ||
1165 | memset(&seminfo, 0, sizeof(seminfo)); | 1177 | memset(&seminfo, 0, sizeof(seminfo)); |
1166 | seminfo.semmni = ns->sc_semmni; | 1178 | seminfo.semmni = ns->sc_semmni; |
1167 | seminfo.semmns = ns->sc_semmns; | 1179 | seminfo.semmns = ns->sc_semmns; |
@@ -1181,7 +1193,7 @@ static int semctl_nolock(struct ipc_namespace *ns, int semid, | |||
1181 | } | 1193 | } |
1182 | max_id = ipc_get_maxid(&sem_ids(ns)); | 1194 | max_id = ipc_get_maxid(&sem_ids(ns)); |
1183 | up_read(&sem_ids(ns).rwsem); | 1195 | up_read(&sem_ids(ns).rwsem); |
1184 | if (copy_to_user(p, &seminfo, sizeof(struct seminfo))) | 1196 | if (copy_to_user(p, &seminfo, sizeof(struct seminfo))) |
1185 | return -EFAULT; | 1197 | return -EFAULT; |
1186 | return (max_id < 0) ? 0 : max_id; | 1198 | return (max_id < 0) ? 0 : max_id; |
1187 | } | 1199 | } |
@@ -1449,10 +1461,10 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, | |||
1449 | err = curr->sempid; | 1461 | err = curr->sempid; |
1450 | goto out_unlock; | 1462 | goto out_unlock; |
1451 | case GETNCNT: | 1463 | case GETNCNT: |
1452 | err = count_semncnt(sma, semnum); | 1464 | err = count_semcnt(sma, semnum, 0); |
1453 | goto out_unlock; | 1465 | goto out_unlock; |
1454 | case GETZCNT: | 1466 | case GETZCNT: |
1455 | err = count_semzcnt(sma, semnum); | 1467 | err = count_semcnt(sma, semnum, 1); |
1456 | goto out_unlock; | 1468 | goto out_unlock; |
1457 | } | 1469 | } |
1458 | 1470 | ||
@@ -1866,8 +1878,13 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, | |||
1866 | if (un && un->semid == -1) | 1878 | if (un && un->semid == -1) |
1867 | goto out_unlock_free; | 1879 | goto out_unlock_free; |
1868 | 1880 | ||
1869 | error = perform_atomic_semop(sma, sops, nsops, un, | 1881 | queue.sops = sops; |
1870 | task_tgid_vnr(current)); | 1882 | queue.nsops = nsops; |
1883 | queue.undo = un; | ||
1884 | queue.pid = task_tgid_vnr(current); | ||
1885 | queue.alter = alter; | ||
1886 | |||
1887 | error = perform_atomic_semop(sma, &queue); | ||
1871 | if (error == 0) { | 1888 | if (error == 0) { |
1872 | /* If the operation was successful, then do | 1889 | /* If the operation was successful, then do |
1873 | * the required updates. | 1890 | * the required updates. |
@@ -1883,12 +1900,6 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, | |||
1883 | /* We need to sleep on this operation, so we put the current | 1900 | /* We need to sleep on this operation, so we put the current |
1884 | * task into the pending queue and go to sleep. | 1901 | * task into the pending queue and go to sleep. |
1885 | */ | 1902 | */ |
1886 | |||
1887 | queue.sops = sops; | ||
1888 | queue.nsops = nsops; | ||
1889 | queue.undo = un; | ||
1890 | queue.pid = task_tgid_vnr(current); | ||
1891 | queue.alter = alter; | ||
1892 | 1903 | ||
1893 | if (nsops == 1) { | 1904 | if (nsops == 1) { |
1894 | struct sem *curr; | 1905 | struct sem *curr; |
@@ -2016,7 +2027,7 @@ int copy_semundo(unsigned long clone_flags, struct task_struct *tsk) | |||
2016 | return error; | 2027 | return error; |
2017 | atomic_inc(&undo_list->refcnt); | 2028 | atomic_inc(&undo_list->refcnt); |
2018 | tsk->sysvsem.undo_list = undo_list; | 2029 | tsk->sysvsem.undo_list = undo_list; |
2019 | } else | 2030 | } else |
2020 | tsk->sysvsem.undo_list = NULL; | 2031 | tsk->sysvsem.undo_list = NULL; |
2021 | 2032 | ||
2022 | return 0; | 2033 | return 0; |
@@ -43,7 +43,7 @@ | |||
43 | #include <linux/mount.h> | 43 | #include <linux/mount.h> |
44 | #include <linux/ipc_namespace.h> | 44 | #include <linux/ipc_namespace.h> |
45 | 45 | ||
46 | #include <asm/uaccess.h> | 46 | #include <linux/uaccess.h> |
47 | 47 | ||
48 | #include "util.h" | 48 | #include "util.h" |
49 | 49 | ||
@@ -493,7 +493,11 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params) | |||
493 | if (size < SHMMIN || size > ns->shm_ctlmax) | 493 | if (size < SHMMIN || size > ns->shm_ctlmax) |
494 | return -EINVAL; | 494 | return -EINVAL; |
495 | 495 | ||
496 | if (ns->shm_tot + numpages > ns->shm_ctlall) | 496 | if (numpages << PAGE_SHIFT < size) |
497 | return -ENOSPC; | ||
498 | |||
499 | if (ns->shm_tot + numpages < ns->shm_tot || | ||
500 | ns->shm_tot + numpages > ns->shm_ctlall) | ||
497 | return -ENOSPC; | 501 | return -ENOSPC; |
498 | 502 | ||
499 | shp = ipc_rcu_alloc(sizeof(*shp)); | 503 | shp = ipc_rcu_alloc(sizeof(*shp)); |
@@ -609,15 +613,15 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp, | |||
609 | SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg) | 613 | SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg) |
610 | { | 614 | { |
611 | struct ipc_namespace *ns; | 615 | struct ipc_namespace *ns; |
612 | struct ipc_ops shm_ops; | 616 | static const struct ipc_ops shm_ops = { |
617 | .getnew = newseg, | ||
618 | .associate = shm_security, | ||
619 | .more_checks = shm_more_checks, | ||
620 | }; | ||
613 | struct ipc_params shm_params; | 621 | struct ipc_params shm_params; |
614 | 622 | ||
615 | ns = current->nsproxy->ipc_ns; | 623 | ns = current->nsproxy->ipc_ns; |
616 | 624 | ||
617 | shm_ops.getnew = newseg; | ||
618 | shm_ops.associate = shm_security; | ||
619 | shm_ops.more_checks = shm_more_checks; | ||
620 | |||
621 | shm_params.key = key; | 625 | shm_params.key = key; |
622 | shm_params.flg = shmflg; | 626 | shm_params.flg = shmflg; |
623 | shm_params.u.size = size; | 627 | shm_params.u.size = size; |
@@ -694,7 +698,7 @@ static inline unsigned long copy_shminfo_to_user(void __user *buf, struct shminf | |||
694 | out.shmmin = in->shmmin; | 698 | out.shmmin = in->shmmin; |
695 | out.shmmni = in->shmmni; | 699 | out.shmmni = in->shmmni; |
696 | out.shmseg = in->shmseg; | 700 | out.shmseg = in->shmseg; |
697 | out.shmall = in->shmall; | 701 | out.shmall = in->shmall; |
698 | 702 | ||
699 | return copy_to_user(buf, &out, sizeof(out)); | 703 | return copy_to_user(buf, &out, sizeof(out)); |
700 | } | 704 | } |
@@ -1160,6 +1164,9 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr, | |||
1160 | down_write(¤t->mm->mmap_sem); | 1164 | down_write(¤t->mm->mmap_sem); |
1161 | if (addr && !(shmflg & SHM_REMAP)) { | 1165 | if (addr && !(shmflg & SHM_REMAP)) { |
1162 | err = -EINVAL; | 1166 | err = -EINVAL; |
1167 | if (addr + size < addr) | ||
1168 | goto invalid; | ||
1169 | |||
1163 | if (find_vma_intersection(current->mm, addr, addr + size)) | 1170 | if (find_vma_intersection(current->mm, addr, addr + size)) |
1164 | goto invalid; | 1171 | goto invalid; |
1165 | /* | 1172 | /* |
diff --git a/ipc/util.c b/ipc/util.c index 2eb0d1eaa312..27d74e69fd57 100644 --- a/ipc/util.c +++ b/ipc/util.c | |||
@@ -183,7 +183,7 @@ void __init ipc_init_proc_interface(const char *path, const char *header, | |||
183 | * ipc_findkey - find a key in an ipc identifier set | 183 | * ipc_findkey - find a key in an ipc identifier set |
184 | * @ids: ipc identifier set | 184 | * @ids: ipc identifier set |
185 | * @key: key to find | 185 | * @key: key to find |
186 | * | 186 | * |
187 | * Returns the locked pointer to the ipc structure if found or NULL | 187 | * Returns the locked pointer to the ipc structure if found or NULL |
188 | * otherwise. If key is found ipc points to the owning ipc structure | 188 | * otherwise. If key is found ipc points to the owning ipc structure |
189 | * | 189 | * |
@@ -317,7 +317,7 @@ int ipc_addid(struct ipc_ids *ids, struct kern_ipc_perm *new, int size) | |||
317 | * when the key is IPC_PRIVATE. | 317 | * when the key is IPC_PRIVATE. |
318 | */ | 318 | */ |
319 | static int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids, | 319 | static int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids, |
320 | struct ipc_ops *ops, struct ipc_params *params) | 320 | const struct ipc_ops *ops, struct ipc_params *params) |
321 | { | 321 | { |
322 | int err; | 322 | int err; |
323 | 323 | ||
@@ -344,7 +344,7 @@ static int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids, | |||
344 | */ | 344 | */ |
345 | static int ipc_check_perms(struct ipc_namespace *ns, | 345 | static int ipc_check_perms(struct ipc_namespace *ns, |
346 | struct kern_ipc_perm *ipcp, | 346 | struct kern_ipc_perm *ipcp, |
347 | struct ipc_ops *ops, | 347 | const struct ipc_ops *ops, |
348 | struct ipc_params *params) | 348 | struct ipc_params *params) |
349 | { | 349 | { |
350 | int err; | 350 | int err; |
@@ -375,7 +375,7 @@ static int ipc_check_perms(struct ipc_namespace *ns, | |||
375 | * On success, the ipc id is returned. | 375 | * On success, the ipc id is returned. |
376 | */ | 376 | */ |
377 | static int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids, | 377 | static int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids, |
378 | struct ipc_ops *ops, struct ipc_params *params) | 378 | const struct ipc_ops *ops, struct ipc_params *params) |
379 | { | 379 | { |
380 | struct kern_ipc_perm *ipcp; | 380 | struct kern_ipc_perm *ipcp; |
381 | int flg = params->flg; | 381 | int flg = params->flg; |
@@ -538,7 +538,7 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag) | |||
538 | else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid)) | 538 | else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid)) |
539 | granted_mode >>= 3; | 539 | granted_mode >>= 3; |
540 | /* is there some bit set in requested_mode but not in granted_mode? */ | 540 | /* is there some bit set in requested_mode but not in granted_mode? */ |
541 | if ((requested_mode & ~granted_mode & 0007) && | 541 | if ((requested_mode & ~granted_mode & 0007) && |
542 | !ns_capable(ns->user_ns, CAP_IPC_OWNER)) | 542 | !ns_capable(ns->user_ns, CAP_IPC_OWNER)) |
543 | return -1; | 543 | return -1; |
544 | 544 | ||
@@ -678,7 +678,7 @@ out: | |||
678 | * Common routine called by sys_msgget(), sys_semget() and sys_shmget(). | 678 | * Common routine called by sys_msgget(), sys_semget() and sys_shmget(). |
679 | */ | 679 | */ |
680 | int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids, | 680 | int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids, |
681 | struct ipc_ops *ops, struct ipc_params *params) | 681 | const struct ipc_ops *ops, struct ipc_params *params) |
682 | { | 682 | { |
683 | if (params->key == IPC_PRIVATE) | 683 | if (params->key == IPC_PRIVATE) |
684 | return ipcget_new(ns, ids, ops, params); | 684 | return ipcget_new(ns, ids, ops, params); |
diff --git a/ipc/util.h b/ipc/util.h index 9c47d6f6c7b4..1a5a0fcd099c 100644 --- a/ipc/util.h +++ b/ipc/util.h | |||
@@ -78,9 +78,9 @@ struct ipc_params { | |||
78 | * . routine to call for an extra check if needed | 78 | * . routine to call for an extra check if needed |
79 | */ | 79 | */ |
80 | struct ipc_ops { | 80 | struct ipc_ops { |
81 | int (*getnew) (struct ipc_namespace *, struct ipc_params *); | 81 | int (*getnew)(struct ipc_namespace *, struct ipc_params *); |
82 | int (*associate) (struct kern_ipc_perm *, int); | 82 | int (*associate)(struct kern_ipc_perm *, int); |
83 | int (*more_checks) (struct kern_ipc_perm *, struct ipc_params *); | 83 | int (*more_checks)(struct kern_ipc_perm *, struct ipc_params *); |
84 | }; | 84 | }; |
85 | 85 | ||
86 | struct seq_file; | 86 | struct seq_file; |
@@ -142,7 +142,7 @@ struct kern_ipc_perm *ipcctl_pre_down_nolock(struct ipc_namespace *ns, | |||
142 | struct ipc64_perm *perm, int extra_perm); | 142 | struct ipc64_perm *perm, int extra_perm); |
143 | 143 | ||
144 | #ifndef CONFIG_ARCH_WANT_IPC_PARSE_VERSION | 144 | #ifndef CONFIG_ARCH_WANT_IPC_PARSE_VERSION |
145 | /* On IA-64, we always use the "64-bit version" of the IPC structures. */ | 145 | /* On IA-64, we always use the "64-bit version" of the IPC structures. */ |
146 | # define ipc_parse_version(cmd) IPC_64 | 146 | # define ipc_parse_version(cmd) IPC_64 |
147 | #else | 147 | #else |
148 | int ipc_parse_version(int *cmd); | 148 | int ipc_parse_version(int *cmd); |
@@ -201,7 +201,7 @@ static inline bool ipc_valid_object(struct kern_ipc_perm *perm) | |||
201 | 201 | ||
202 | struct kern_ipc_perm *ipc_obtain_object_check(struct ipc_ids *ids, int id); | 202 | struct kern_ipc_perm *ipc_obtain_object_check(struct ipc_ids *ids, int id); |
203 | int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids, | 203 | int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids, |
204 | struct ipc_ops *ops, struct ipc_params *params); | 204 | const struct ipc_ops *ops, struct ipc_params *params); |
205 | void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids, | 205 | void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids, |
206 | void (*free)(struct ipc_namespace *, struct kern_ipc_perm *)); | 206 | void (*free)(struct ipc_namespace *, struct kern_ipc_perm *)); |
207 | #endif | 207 | #endif |
diff --git a/kernel/acct.c b/kernel/acct.c index 8d6e145138bb..808a86ff229d 100644 --- a/kernel/acct.c +++ b/kernel/acct.c | |||
@@ -55,7 +55,7 @@ | |||
55 | #include <linux/times.h> | 55 | #include <linux/times.h> |
56 | #include <linux/syscalls.h> | 56 | #include <linux/syscalls.h> |
57 | #include <linux/mount.h> | 57 | #include <linux/mount.h> |
58 | #include <asm/uaccess.h> | 58 | #include <linux/uaccess.h> |
59 | #include <asm/div64.h> | 59 | #include <asm/div64.h> |
60 | #include <linux/blkdev.h> /* sector_div */ | 60 | #include <linux/blkdev.h> /* sector_div */ |
61 | #include <linux/pid_namespace.h> | 61 | #include <linux/pid_namespace.h> |
@@ -134,7 +134,7 @@ static int check_free_space(struct bsd_acct_struct *acct, struct file *file) | |||
134 | spin_lock(&acct_lock); | 134 | spin_lock(&acct_lock); |
135 | if (file != acct->file) { | 135 | if (file != acct->file) { |
136 | if (act) | 136 | if (act) |
137 | res = act>0; | 137 | res = act > 0; |
138 | goto out; | 138 | goto out; |
139 | } | 139 | } |
140 | 140 | ||
@@ -262,7 +262,7 @@ SYSCALL_DEFINE1(acct, const char __user *, name) | |||
262 | if (name) { | 262 | if (name) { |
263 | struct filename *tmp = getname(name); | 263 | struct filename *tmp = getname(name); |
264 | if (IS_ERR(tmp)) | 264 | if (IS_ERR(tmp)) |
265 | return (PTR_ERR(tmp)); | 265 | return PTR_ERR(tmp); |
266 | error = acct_on(tmp); | 266 | error = acct_on(tmp); |
267 | putname(tmp); | 267 | putname(tmp); |
268 | } else { | 268 | } else { |
diff --git a/kernel/audit.c b/kernel/audit.c index 47845c57eb19..f30106459a32 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 44 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
45 | 45 | ||
46 | #include <linux/init.h> | 46 | #include <linux/init.h> |
47 | #include <asm/types.h> | 47 | #include <linux/types.h> |
48 | #include <linux/atomic.h> | 48 | #include <linux/atomic.h> |
49 | #include <linux/mm.h> | 49 | #include <linux/mm.h> |
50 | #include <linux/export.h> | 50 | #include <linux/export.h> |
diff --git a/kernel/exit.c b/kernel/exit.c index 750c2e594617..e5c4668f1799 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -313,45 +313,6 @@ kill_orphaned_pgrp(struct task_struct *tsk, struct task_struct *parent) | |||
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | /* | ||
317 | * Let kernel threads use this to say that they allow a certain signal. | ||
318 | * Must not be used if kthread was cloned with CLONE_SIGHAND. | ||
319 | */ | ||
320 | int allow_signal(int sig) | ||
321 | { | ||
322 | if (!valid_signal(sig) || sig < 1) | ||
323 | return -EINVAL; | ||
324 | |||
325 | spin_lock_irq(¤t->sighand->siglock); | ||
326 | /* This is only needed for daemonize()'ed kthreads */ | ||
327 | sigdelset(¤t->blocked, sig); | ||
328 | /* | ||
329 | * Kernel threads handle their own signals. Let the signal code | ||
330 | * know it'll be handled, so that they don't get converted to | ||
331 | * SIGKILL or just silently dropped. | ||
332 | */ | ||
333 | current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2; | ||
334 | recalc_sigpending(); | ||
335 | spin_unlock_irq(¤t->sighand->siglock); | ||
336 | return 0; | ||
337 | } | ||
338 | |||
339 | EXPORT_SYMBOL(allow_signal); | ||
340 | |||
341 | int disallow_signal(int sig) | ||
342 | { | ||
343 | if (!valid_signal(sig) || sig < 1) | ||
344 | return -EINVAL; | ||
345 | |||
346 | spin_lock_irq(¤t->sighand->siglock); | ||
347 | current->sighand->action[(sig)-1].sa.sa_handler = SIG_IGN; | ||
348 | recalc_sigpending(); | ||
349 | spin_unlock_irq(¤t->sighand->siglock); | ||
350 | return 0; | ||
351 | } | ||
352 | |||
353 | EXPORT_SYMBOL(disallow_signal); | ||
354 | |||
355 | #ifdef CONFIG_MEMCG | 316 | #ifdef CONFIG_MEMCG |
356 | /* | 317 | /* |
357 | * A task is exiting. If it owned this mm, find a new owner for the mm. | 318 | * A task is exiting. If it owned this mm, find a new owner for the mm. |
diff --git a/kernel/fork.c b/kernel/fork.c index 0d53eb0dfb6f..d2799d1fc952 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -1606,10 +1606,12 @@ long do_fork(unsigned long clone_flags, | |||
1606 | */ | 1606 | */ |
1607 | if (!IS_ERR(p)) { | 1607 | if (!IS_ERR(p)) { |
1608 | struct completion vfork; | 1608 | struct completion vfork; |
1609 | struct pid *pid; | ||
1609 | 1610 | ||
1610 | trace_sched_process_fork(current, p); | 1611 | trace_sched_process_fork(current, p); |
1611 | 1612 | ||
1612 | nr = task_pid_vnr(p); | 1613 | pid = get_task_pid(p, PIDTYPE_PID); |
1614 | nr = pid_vnr(pid); | ||
1613 | 1615 | ||
1614 | if (clone_flags & CLONE_PARENT_SETTID) | 1616 | if (clone_flags & CLONE_PARENT_SETTID) |
1615 | put_user(nr, parent_tidptr); | 1617 | put_user(nr, parent_tidptr); |
@@ -1624,12 +1626,14 @@ long do_fork(unsigned long clone_flags, | |||
1624 | 1626 | ||
1625 | /* forking complete and child started to run, tell ptracer */ | 1627 | /* forking complete and child started to run, tell ptracer */ |
1626 | if (unlikely(trace)) | 1628 | if (unlikely(trace)) |
1627 | ptrace_event(trace, nr); | 1629 | ptrace_event_pid(trace, pid); |
1628 | 1630 | ||
1629 | if (clone_flags & CLONE_VFORK) { | 1631 | if (clone_flags & CLONE_VFORK) { |
1630 | if (!wait_for_vfork_done(p, &vfork)) | 1632 | if (!wait_for_vfork_done(p, &vfork)) |
1631 | ptrace_event(PTRACE_EVENT_VFORK_DONE, nr); | 1633 | ptrace_event_pid(PTRACE_EVENT_VFORK_DONE, pid); |
1632 | } | 1634 | } |
1635 | |||
1636 | put_pid(pid); | ||
1633 | } else { | 1637 | } else { |
1634 | nr = PTR_ERR(p); | 1638 | nr = PTR_ERR(p); |
1635 | } | 1639 | } |
diff --git a/kernel/kexec.c b/kernel/kexec.c index 28c57069ef68..6748688813d0 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c | |||
@@ -125,8 +125,8 @@ static struct page *kimage_alloc_page(struct kimage *image, | |||
125 | unsigned long dest); | 125 | unsigned long dest); |
126 | 126 | ||
127 | static int do_kimage_alloc(struct kimage **rimage, unsigned long entry, | 127 | static int do_kimage_alloc(struct kimage **rimage, unsigned long entry, |
128 | unsigned long nr_segments, | 128 | unsigned long nr_segments, |
129 | struct kexec_segment __user *segments) | 129 | struct kexec_segment __user *segments) |
130 | { | 130 | { |
131 | size_t segment_bytes; | 131 | size_t segment_bytes; |
132 | struct kimage *image; | 132 | struct kimage *image; |
@@ -257,13 +257,13 @@ static int kimage_normal_alloc(struct kimage **rimage, unsigned long entry, | |||
257 | image->control_code_page = kimage_alloc_control_pages(image, | 257 | image->control_code_page = kimage_alloc_control_pages(image, |
258 | get_order(KEXEC_CONTROL_PAGE_SIZE)); | 258 | get_order(KEXEC_CONTROL_PAGE_SIZE)); |
259 | if (!image->control_code_page) { | 259 | if (!image->control_code_page) { |
260 | printk(KERN_ERR "Could not allocate control_code_buffer\n"); | 260 | pr_err("Could not allocate control_code_buffer\n"); |
261 | goto out_free; | 261 | goto out_free; |
262 | } | 262 | } |
263 | 263 | ||
264 | image->swap_page = kimage_alloc_control_pages(image, 0); | 264 | image->swap_page = kimage_alloc_control_pages(image, 0); |
265 | if (!image->swap_page) { | 265 | if (!image->swap_page) { |
266 | printk(KERN_ERR "Could not allocate swap buffer\n"); | 266 | pr_err("Could not allocate swap buffer\n"); |
267 | goto out_free; | 267 | goto out_free; |
268 | } | 268 | } |
269 | 269 | ||
@@ -332,7 +332,7 @@ static int kimage_crash_alloc(struct kimage **rimage, unsigned long entry, | |||
332 | image->control_code_page = kimage_alloc_control_pages(image, | 332 | image->control_code_page = kimage_alloc_control_pages(image, |
333 | get_order(KEXEC_CONTROL_PAGE_SIZE)); | 333 | get_order(KEXEC_CONTROL_PAGE_SIZE)); |
334 | if (!image->control_code_page) { | 334 | if (!image->control_code_page) { |
335 | printk(KERN_ERR "Could not allocate control_code_buffer\n"); | 335 | pr_err("Could not allocate control_code_buffer\n"); |
336 | goto out_free; | 336 | goto out_free; |
337 | } | 337 | } |
338 | 338 | ||
@@ -621,8 +621,8 @@ static void kimage_terminate(struct kimage *image) | |||
621 | 621 | ||
622 | #define for_each_kimage_entry(image, ptr, entry) \ | 622 | #define for_each_kimage_entry(image, ptr, entry) \ |
623 | for (ptr = &image->head; (entry = *ptr) && !(entry & IND_DONE); \ | 623 | for (ptr = &image->head; (entry = *ptr) && !(entry & IND_DONE); \ |
624 | ptr = (entry & IND_INDIRECTION)? \ | 624 | ptr = (entry & IND_INDIRECTION) ? \ |
625 | phys_to_virt((entry & PAGE_MASK)): ptr +1) | 625 | phys_to_virt((entry & PAGE_MASK)) : ptr + 1) |
626 | 626 | ||
627 | static void kimage_free_entry(kimage_entry_t entry) | 627 | static void kimage_free_entry(kimage_entry_t entry) |
628 | { | 628 | { |
@@ -650,8 +650,7 @@ static void kimage_free(struct kimage *image) | |||
650 | * done with it. | 650 | * done with it. |
651 | */ | 651 | */ |
652 | ind = entry; | 652 | ind = entry; |
653 | } | 653 | } else if (entry & IND_SOURCE) |
654 | else if (entry & IND_SOURCE) | ||
655 | kimage_free_entry(entry); | 654 | kimage_free_entry(entry); |
656 | } | 655 | } |
657 | /* Free the final indirection page */ | 656 | /* Free the final indirection page */ |
@@ -774,8 +773,7 @@ static struct page *kimage_alloc_page(struct kimage *image, | |||
774 | addr = old_addr; | 773 | addr = old_addr; |
775 | page = old_page; | 774 | page = old_page; |
776 | break; | 775 | break; |
777 | } | 776 | } else { |
778 | else { | ||
779 | /* Place the page on the destination list I | 777 | /* Place the page on the destination list I |
780 | * will use it later. | 778 | * will use it later. |
781 | */ | 779 | */ |
@@ -1059,7 +1057,7 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry, | |||
1059 | return -EINVAL; | 1057 | return -EINVAL; |
1060 | 1058 | ||
1061 | ksegments = compat_alloc_user_space(nr_segments * sizeof(out)); | 1059 | ksegments = compat_alloc_user_space(nr_segments * sizeof(out)); |
1062 | for (i=0; i < nr_segments; i++) { | 1060 | for (i = 0; i < nr_segments; i++) { |
1063 | result = copy_from_user(&in, &segments[i], sizeof(in)); | 1061 | result = copy_from_user(&in, &segments[i], sizeof(in)); |
1064 | if (result) | 1062 | if (result) |
1065 | return -EFAULT; | 1063 | return -EFAULT; |
@@ -1214,14 +1212,14 @@ void crash_save_cpu(struct pt_regs *regs, int cpu) | |||
1214 | * squirrelled away. ELF notes happen to provide | 1212 | * squirrelled away. ELF notes happen to provide |
1215 | * all of that, so there is no need to invent something new. | 1213 | * all of that, so there is no need to invent something new. |
1216 | */ | 1214 | */ |
1217 | buf = (u32*)per_cpu_ptr(crash_notes, cpu); | 1215 | buf = (u32 *)per_cpu_ptr(crash_notes, cpu); |
1218 | if (!buf) | 1216 | if (!buf) |
1219 | return; | 1217 | return; |
1220 | memset(&prstatus, 0, sizeof(prstatus)); | 1218 | memset(&prstatus, 0, sizeof(prstatus)); |
1221 | prstatus.pr_pid = current->pid; | 1219 | prstatus.pr_pid = current->pid; |
1222 | elf_core_copy_kernel_regs(&prstatus.pr_reg, regs); | 1220 | elf_core_copy_kernel_regs(&prstatus.pr_reg, regs); |
1223 | buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_PRSTATUS, | 1221 | buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_PRSTATUS, |
1224 | &prstatus, sizeof(prstatus)); | 1222 | &prstatus, sizeof(prstatus)); |
1225 | final_note(buf); | 1223 | final_note(buf); |
1226 | } | 1224 | } |
1227 | 1225 | ||
@@ -1230,8 +1228,7 @@ static int __init crash_notes_memory_init(void) | |||
1230 | /* Allocate memory for saving cpu registers. */ | 1228 | /* Allocate memory for saving cpu registers. */ |
1231 | crash_notes = alloc_percpu(note_buf_t); | 1229 | crash_notes = alloc_percpu(note_buf_t); |
1232 | if (!crash_notes) { | 1230 | if (!crash_notes) { |
1233 | printk("Kexec: Memory allocation for saving cpu register" | 1231 | pr_warn("Kexec: Memory allocation for saving cpu register states failed\n"); |
1234 | " states failed\n"); | ||
1235 | return -ENOMEM; | 1232 | return -ENOMEM; |
1236 | } | 1233 | } |
1237 | return 0; | 1234 | return 0; |
@@ -1253,10 +1250,10 @@ subsys_initcall(crash_notes_memory_init); | |||
1253 | * | 1250 | * |
1254 | * The function returns 0 on success and -EINVAL on failure. | 1251 | * The function returns 0 on success and -EINVAL on failure. |
1255 | */ | 1252 | */ |
1256 | static int __init parse_crashkernel_mem(char *cmdline, | 1253 | static int __init parse_crashkernel_mem(char *cmdline, |
1257 | unsigned long long system_ram, | 1254 | unsigned long long system_ram, |
1258 | unsigned long long *crash_size, | 1255 | unsigned long long *crash_size, |
1259 | unsigned long long *crash_base) | 1256 | unsigned long long *crash_base) |
1260 | { | 1257 | { |
1261 | char *cur = cmdline, *tmp; | 1258 | char *cur = cmdline, *tmp; |
1262 | 1259 | ||
@@ -1267,12 +1264,12 @@ static int __init parse_crashkernel_mem(char *cmdline, | |||
1267 | /* get the start of the range */ | 1264 | /* get the start of the range */ |
1268 | start = memparse(cur, &tmp); | 1265 | start = memparse(cur, &tmp); |
1269 | if (cur == tmp) { | 1266 | if (cur == tmp) { |
1270 | pr_warning("crashkernel: Memory value expected\n"); | 1267 | pr_warn("crashkernel: Memory value expected\n"); |
1271 | return -EINVAL; | 1268 | return -EINVAL; |
1272 | } | 1269 | } |
1273 | cur = tmp; | 1270 | cur = tmp; |
1274 | if (*cur != '-') { | 1271 | if (*cur != '-') { |
1275 | pr_warning("crashkernel: '-' expected\n"); | 1272 | pr_warn("crashkernel: '-' expected\n"); |
1276 | return -EINVAL; | 1273 | return -EINVAL; |
1277 | } | 1274 | } |
1278 | cur++; | 1275 | cur++; |
@@ -1281,31 +1278,30 @@ static int __init parse_crashkernel_mem(char *cmdline, | |||
1281 | if (*cur != ':') { | 1278 | if (*cur != ':') { |
1282 | end = memparse(cur, &tmp); | 1279 | end = memparse(cur, &tmp); |
1283 | if (cur == tmp) { | 1280 | if (cur == tmp) { |
1284 | pr_warning("crashkernel: Memory " | 1281 | pr_warn("crashkernel: Memory value expected\n"); |
1285 | "value expected\n"); | ||
1286 | return -EINVAL; | 1282 | return -EINVAL; |
1287 | } | 1283 | } |
1288 | cur = tmp; | 1284 | cur = tmp; |
1289 | if (end <= start) { | 1285 | if (end <= start) { |
1290 | pr_warning("crashkernel: end <= start\n"); | 1286 | pr_warn("crashkernel: end <= start\n"); |
1291 | return -EINVAL; | 1287 | return -EINVAL; |
1292 | } | 1288 | } |
1293 | } | 1289 | } |
1294 | 1290 | ||
1295 | if (*cur != ':') { | 1291 | if (*cur != ':') { |
1296 | pr_warning("crashkernel: ':' expected\n"); | 1292 | pr_warn("crashkernel: ':' expected\n"); |
1297 | return -EINVAL; | 1293 | return -EINVAL; |
1298 | } | 1294 | } |
1299 | cur++; | 1295 | cur++; |
1300 | 1296 | ||
1301 | size = memparse(cur, &tmp); | 1297 | size = memparse(cur, &tmp); |
1302 | if (cur == tmp) { | 1298 | if (cur == tmp) { |
1303 | pr_warning("Memory value expected\n"); | 1299 | pr_warn("Memory value expected\n"); |
1304 | return -EINVAL; | 1300 | return -EINVAL; |
1305 | } | 1301 | } |
1306 | cur = tmp; | 1302 | cur = tmp; |
1307 | if (size >= system_ram) { | 1303 | if (size >= system_ram) { |
1308 | pr_warning("crashkernel: invalid size\n"); | 1304 | pr_warn("crashkernel: invalid size\n"); |
1309 | return -EINVAL; | 1305 | return -EINVAL; |
1310 | } | 1306 | } |
1311 | 1307 | ||
@@ -1323,8 +1319,7 @@ static int __init parse_crashkernel_mem(char *cmdline, | |||
1323 | cur++; | 1319 | cur++; |
1324 | *crash_base = memparse(cur, &tmp); | 1320 | *crash_base = memparse(cur, &tmp); |
1325 | if (cur == tmp) { | 1321 | if (cur == tmp) { |
1326 | pr_warning("Memory value expected " | 1322 | pr_warn("Memory value expected after '@'\n"); |
1327 | "after '@'\n"); | ||
1328 | return -EINVAL; | 1323 | return -EINVAL; |
1329 | } | 1324 | } |
1330 | } | 1325 | } |
@@ -1336,26 +1331,26 @@ static int __init parse_crashkernel_mem(char *cmdline, | |||
1336 | /* | 1331 | /* |
1337 | * That function parses "simple" (old) crashkernel command lines like | 1332 | * That function parses "simple" (old) crashkernel command lines like |
1338 | * | 1333 | * |
1339 | * crashkernel=size[@offset] | 1334 | * crashkernel=size[@offset] |
1340 | * | 1335 | * |
1341 | * It returns 0 on success and -EINVAL on failure. | 1336 | * It returns 0 on success and -EINVAL on failure. |
1342 | */ | 1337 | */ |
1343 | static int __init parse_crashkernel_simple(char *cmdline, | 1338 | static int __init parse_crashkernel_simple(char *cmdline, |
1344 | unsigned long long *crash_size, | 1339 | unsigned long long *crash_size, |
1345 | unsigned long long *crash_base) | 1340 | unsigned long long *crash_base) |
1346 | { | 1341 | { |
1347 | char *cur = cmdline; | 1342 | char *cur = cmdline; |
1348 | 1343 | ||
1349 | *crash_size = memparse(cmdline, &cur); | 1344 | *crash_size = memparse(cmdline, &cur); |
1350 | if (cmdline == cur) { | 1345 | if (cmdline == cur) { |
1351 | pr_warning("crashkernel: memory value expected\n"); | 1346 | pr_warn("crashkernel: memory value expected\n"); |
1352 | return -EINVAL; | 1347 | return -EINVAL; |
1353 | } | 1348 | } |
1354 | 1349 | ||
1355 | if (*cur == '@') | 1350 | if (*cur == '@') |
1356 | *crash_base = memparse(cur+1, &cur); | 1351 | *crash_base = memparse(cur+1, &cur); |
1357 | else if (*cur != ' ' && *cur != '\0') { | 1352 | else if (*cur != ' ' && *cur != '\0') { |
1358 | pr_warning("crashkernel: unrecognized char\n"); | 1353 | pr_warn("crashkernel: unrecognized char\n"); |
1359 | return -EINVAL; | 1354 | return -EINVAL; |
1360 | } | 1355 | } |
1361 | 1356 | ||
@@ -1691,7 +1686,7 @@ int kernel_kexec(void) | |||
1691 | * CPU hotplug again; so re-enable it here. | 1686 | * CPU hotplug again; so re-enable it here. |
1692 | */ | 1687 | */ |
1693 | cpu_hotplug_enable(); | 1688 | cpu_hotplug_enable(); |
1694 | printk(KERN_EMERG "Starting new kernel\n"); | 1689 | pr_emerg("Starting new kernel\n"); |
1695 | machine_shutdown(); | 1690 | machine_shutdown(); |
1696 | } | 1691 | } |
1697 | 1692 | ||
diff --git a/kernel/kmod.c b/kernel/kmod.c index 0ac67a5861c5..8637e041a247 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c | |||
@@ -285,10 +285,7 @@ static int wait_for_helper(void *data) | |||
285 | pid_t pid; | 285 | pid_t pid; |
286 | 286 | ||
287 | /* If SIGCLD is ignored sys_wait4 won't populate the status. */ | 287 | /* If SIGCLD is ignored sys_wait4 won't populate the status. */ |
288 | spin_lock_irq(¤t->sighand->siglock); | 288 | kernel_sigaction(SIGCHLD, SIG_DFL); |
289 | current->sighand->action[SIGCHLD-1].sa.sa_handler = SIG_DFL; | ||
290 | spin_unlock_irq(¤t->sighand->siglock); | ||
291 | |||
292 | pid = kernel_thread(____call_usermodehelper, sub_info, SIGCHLD); | 289 | pid = kernel_thread(____call_usermodehelper, sub_info, SIGCHLD); |
293 | if (pid < 0) { | 290 | if (pid < 0) { |
294 | sub_info->retval = pid; | 291 | sub_info->retval = pid; |
diff --git a/kernel/panic.c b/kernel/panic.c index d02fa9fef46a..62e16cef9cc2 100644 --- a/kernel/panic.c +++ b/kernel/panic.c | |||
@@ -32,6 +32,7 @@ static unsigned long tainted_mask; | |||
32 | static int pause_on_oops; | 32 | static int pause_on_oops; |
33 | static int pause_on_oops_flag; | 33 | static int pause_on_oops_flag; |
34 | static DEFINE_SPINLOCK(pause_on_oops_lock); | 34 | static DEFINE_SPINLOCK(pause_on_oops_lock); |
35 | static bool crash_kexec_post_notifiers; | ||
35 | 36 | ||
36 | int panic_timeout = CONFIG_PANIC_TIMEOUT; | 37 | int panic_timeout = CONFIG_PANIC_TIMEOUT; |
37 | EXPORT_SYMBOL_GPL(panic_timeout); | 38 | EXPORT_SYMBOL_GPL(panic_timeout); |
@@ -112,9 +113,11 @@ void panic(const char *fmt, ...) | |||
112 | /* | 113 | /* |
113 | * If we have crashed and we have a crash kernel loaded let it handle | 114 | * If we have crashed and we have a crash kernel loaded let it handle |
114 | * everything else. | 115 | * everything else. |
115 | * Do we want to call this before we try to display a message? | 116 | * If we want to run this after calling panic_notifiers, pass |
117 | * the "crash_kexec_post_notifiers" option to the kernel. | ||
116 | */ | 118 | */ |
117 | crash_kexec(NULL); | 119 | if (!crash_kexec_post_notifiers) |
120 | crash_kexec(NULL); | ||
118 | 121 | ||
119 | /* | 122 | /* |
120 | * Note smp_send_stop is the usual smp shutdown function, which | 123 | * Note smp_send_stop is the usual smp shutdown function, which |
@@ -131,6 +134,15 @@ void panic(const char *fmt, ...) | |||
131 | 134 | ||
132 | kmsg_dump(KMSG_DUMP_PANIC); | 135 | kmsg_dump(KMSG_DUMP_PANIC); |
133 | 136 | ||
137 | /* | ||
138 | * If you doubt kdump always works fine in any situation, | ||
139 | * "crash_kexec_post_notifiers" offers you a chance to run | ||
140 | * panic_notifiers and dumping kmsg before kdump. | ||
141 | * Note: since some panic_notifiers can make crashed kernel | ||
142 | * more unstable, it can increase risks of the kdump failure too. | ||
143 | */ | ||
144 | crash_kexec(NULL); | ||
145 | |||
134 | bust_spinlocks(0); | 146 | bust_spinlocks(0); |
135 | 147 | ||
136 | if (!panic_blink) | 148 | if (!panic_blink) |
@@ -472,6 +484,13 @@ EXPORT_SYMBOL(__stack_chk_fail); | |||
472 | core_param(panic, panic_timeout, int, 0644); | 484 | core_param(panic, panic_timeout, int, 0644); |
473 | core_param(pause_on_oops, pause_on_oops, int, 0644); | 485 | core_param(pause_on_oops, pause_on_oops, int, 0644); |
474 | 486 | ||
487 | static int __init setup_crash_kexec_post_notifiers(char *s) | ||
488 | { | ||
489 | crash_kexec_post_notifiers = true; | ||
490 | return 0; | ||
491 | } | ||
492 | early_param("crash_kexec_post_notifiers", setup_crash_kexec_post_notifiers); | ||
493 | |||
475 | static int __init oops_setup(char *s) | 494 | static int __init oops_setup(char *s) |
476 | { | 495 | { |
477 | if (!s) | 496 | if (!s) |
diff --git a/kernel/profile.c b/kernel/profile.c index cb980f0c731b..54bf5ba26420 100644 --- a/kernel/profile.c +++ b/kernel/profile.c | |||
@@ -52,9 +52,9 @@ static DEFINE_MUTEX(profile_flip_mutex); | |||
52 | 52 | ||
53 | int profile_setup(char *str) | 53 | int profile_setup(char *str) |
54 | { | 54 | { |
55 | static char schedstr[] = "schedule"; | 55 | static const char schedstr[] = "schedule"; |
56 | static char sleepstr[] = "sleep"; | 56 | static const char sleepstr[] = "sleep"; |
57 | static char kvmstr[] = "kvm"; | 57 | static const char kvmstr[] = "kvm"; |
58 | int par; | 58 | int par; |
59 | 59 | ||
60 | if (!strncmp(str, sleepstr, strlen(sleepstr))) { | 60 | if (!strncmp(str, sleepstr, strlen(sleepstr))) { |
@@ -64,12 +64,10 @@ int profile_setup(char *str) | |||
64 | str += strlen(sleepstr) + 1; | 64 | str += strlen(sleepstr) + 1; |
65 | if (get_option(&str, &par)) | 65 | if (get_option(&str, &par)) |
66 | prof_shift = par; | 66 | prof_shift = par; |
67 | printk(KERN_INFO | 67 | pr_info("kernel sleep profiling enabled (shift: %ld)\n", |
68 | "kernel sleep profiling enabled (shift: %ld)\n", | ||
69 | prof_shift); | 68 | prof_shift); |
70 | #else | 69 | #else |
71 | printk(KERN_WARNING | 70 | pr_warn("kernel sleep profiling requires CONFIG_SCHEDSTATS\n"); |
72 | "kernel sleep profiling requires CONFIG_SCHEDSTATS\n"); | ||
73 | #endif /* CONFIG_SCHEDSTATS */ | 71 | #endif /* CONFIG_SCHEDSTATS */ |
74 | } else if (!strncmp(str, schedstr, strlen(schedstr))) { | 72 | } else if (!strncmp(str, schedstr, strlen(schedstr))) { |
75 | prof_on = SCHED_PROFILING; | 73 | prof_on = SCHED_PROFILING; |
@@ -77,8 +75,7 @@ int profile_setup(char *str) | |||
77 | str += strlen(schedstr) + 1; | 75 | str += strlen(schedstr) + 1; |
78 | if (get_option(&str, &par)) | 76 | if (get_option(&str, &par)) |
79 | prof_shift = par; | 77 | prof_shift = par; |
80 | printk(KERN_INFO | 78 | pr_info("kernel schedule profiling enabled (shift: %ld)\n", |
81 | "kernel schedule profiling enabled (shift: %ld)\n", | ||
82 | prof_shift); | 79 | prof_shift); |
83 | } else if (!strncmp(str, kvmstr, strlen(kvmstr))) { | 80 | } else if (!strncmp(str, kvmstr, strlen(kvmstr))) { |
84 | prof_on = KVM_PROFILING; | 81 | prof_on = KVM_PROFILING; |
@@ -86,13 +83,12 @@ int profile_setup(char *str) | |||
86 | str += strlen(kvmstr) + 1; | 83 | str += strlen(kvmstr) + 1; |
87 | if (get_option(&str, &par)) | 84 | if (get_option(&str, &par)) |
88 | prof_shift = par; | 85 | prof_shift = par; |
89 | printk(KERN_INFO | 86 | pr_info("kernel KVM profiling enabled (shift: %ld)\n", |
90 | "kernel KVM profiling enabled (shift: %ld)\n", | ||
91 | prof_shift); | 87 | prof_shift); |
92 | } else if (get_option(&str, &par)) { | 88 | } else if (get_option(&str, &par)) { |
93 | prof_shift = par; | 89 | prof_shift = par; |
94 | prof_on = CPU_PROFILING; | 90 | prof_on = CPU_PROFILING; |
95 | printk(KERN_INFO "kernel profiling enabled (shift: %ld)\n", | 91 | pr_info("kernel profiling enabled (shift: %ld)\n", |
96 | prof_shift); | 92 | prof_shift); |
97 | } | 93 | } |
98 | return 1; | 94 | return 1; |
diff --git a/kernel/seccomp.c b/kernel/seccomp.c index b35c21503a36..f6d76bebe69f 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c | |||
@@ -39,7 +39,7 @@ | |||
39 | * is only needed for handling filters shared across tasks. | 39 | * is only needed for handling filters shared across tasks. |
40 | * @prev: points to a previously installed, or inherited, filter | 40 | * @prev: points to a previously installed, or inherited, filter |
41 | * @len: the number of instructions in the program | 41 | * @len: the number of instructions in the program |
42 | * @insns: the BPF program instructions to evaluate | 42 | * @insnsi: the BPF program instructions to evaluate |
43 | * | 43 | * |
44 | * seccomp_filter objects are organized in a tree linked via the @prev | 44 | * seccomp_filter objects are organized in a tree linked via the @prev |
45 | * pointer. For any task, it appears to be a singly-linked list starting | 45 | * pointer. For any task, it appears to be a singly-linked list starting |
@@ -220,7 +220,7 @@ static long seccomp_attach_filter(struct sock_fprog *fprog) | |||
220 | return -ENOMEM; | 220 | return -ENOMEM; |
221 | 221 | ||
222 | /* | 222 | /* |
223 | * Installing a seccomp filter requires that the task have | 223 | * Installing a seccomp filter requires that the task has |
224 | * CAP_SYS_ADMIN in its namespace or be running with no_new_privs. | 224 | * CAP_SYS_ADMIN in its namespace or be running with no_new_privs. |
225 | * This avoids scenarios where unprivileged tasks can affect the | 225 | * This avoids scenarios where unprivileged tasks can affect the |
226 | * behavior of privileged children. | 226 | * behavior of privileged children. |
diff --git a/kernel/signal.c b/kernel/signal.c index 6e600aaa2af4..a4077e90f19f 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -277,6 +277,7 @@ void task_clear_jobctl_trapping(struct task_struct *task) | |||
277 | { | 277 | { |
278 | if (unlikely(task->jobctl & JOBCTL_TRAPPING)) { | 278 | if (unlikely(task->jobctl & JOBCTL_TRAPPING)) { |
279 | task->jobctl &= ~JOBCTL_TRAPPING; | 279 | task->jobctl &= ~JOBCTL_TRAPPING; |
280 | smp_mb(); /* advised by wake_up_bit() */ | ||
280 | wake_up_bit(&task->jobctl, JOBCTL_TRAPPING_BIT); | 281 | wake_up_bit(&task->jobctl, JOBCTL_TRAPPING_BIT); |
281 | } | 282 | } |
282 | } | 283 | } |
@@ -705,11 +706,8 @@ void signal_wake_up_state(struct task_struct *t, unsigned int state) | |||
705 | * Returns 1 if any signals were found. | 706 | * Returns 1 if any signals were found. |
706 | * | 707 | * |
707 | * All callers must be holding the siglock. | 708 | * All callers must be holding the siglock. |
708 | * | ||
709 | * This version takes a sigset mask and looks at all signals, | ||
710 | * not just those in the first mask word. | ||
711 | */ | 709 | */ |
712 | static int rm_from_queue_full(sigset_t *mask, struct sigpending *s) | 710 | static int flush_sigqueue_mask(sigset_t *mask, struct sigpending *s) |
713 | { | 711 | { |
714 | struct sigqueue *q, *n; | 712 | struct sigqueue *q, *n; |
715 | sigset_t m; | 713 | sigset_t m; |
@@ -727,29 +725,6 @@ static int rm_from_queue_full(sigset_t *mask, struct sigpending *s) | |||
727 | } | 725 | } |
728 | return 1; | 726 | return 1; |
729 | } | 727 | } |
730 | /* | ||
731 | * Remove signals in mask from the pending set and queue. | ||
732 | * Returns 1 if any signals were found. | ||
733 | * | ||
734 | * All callers must be holding the siglock. | ||
735 | */ | ||
736 | static int rm_from_queue(unsigned long mask, struct sigpending *s) | ||
737 | { | ||
738 | struct sigqueue *q, *n; | ||
739 | |||
740 | if (!sigtestsetmask(&s->signal, mask)) | ||
741 | return 0; | ||
742 | |||
743 | sigdelsetmask(&s->signal, mask); | ||
744 | list_for_each_entry_safe(q, n, &s->list, list) { | ||
745 | if (q->info.si_signo < SIGRTMIN && | ||
746 | (mask & sigmask(q->info.si_signo))) { | ||
747 | list_del_init(&q->list); | ||
748 | __sigqueue_free(q); | ||
749 | } | ||
750 | } | ||
751 | return 1; | ||
752 | } | ||
753 | 728 | ||
754 | static inline int is_si_special(const struct siginfo *info) | 729 | static inline int is_si_special(const struct siginfo *info) |
755 | { | 730 | { |
@@ -861,6 +836,7 @@ static bool prepare_signal(int sig, struct task_struct *p, bool force) | |||
861 | { | 836 | { |
862 | struct signal_struct *signal = p->signal; | 837 | struct signal_struct *signal = p->signal; |
863 | struct task_struct *t; | 838 | struct task_struct *t; |
839 | sigset_t flush; | ||
864 | 840 | ||
865 | if (signal->flags & (SIGNAL_GROUP_EXIT | SIGNAL_GROUP_COREDUMP)) { | 841 | if (signal->flags & (SIGNAL_GROUP_EXIT | SIGNAL_GROUP_COREDUMP)) { |
866 | if (signal->flags & SIGNAL_GROUP_COREDUMP) | 842 | if (signal->flags & SIGNAL_GROUP_COREDUMP) |
@@ -872,26 +848,25 @@ static bool prepare_signal(int sig, struct task_struct *p, bool force) | |||
872 | /* | 848 | /* |
873 | * This is a stop signal. Remove SIGCONT from all queues. | 849 | * This is a stop signal. Remove SIGCONT from all queues. |
874 | */ | 850 | */ |
875 | rm_from_queue(sigmask(SIGCONT), &signal->shared_pending); | 851 | siginitset(&flush, sigmask(SIGCONT)); |
876 | t = p; | 852 | flush_sigqueue_mask(&flush, &signal->shared_pending); |
877 | do { | 853 | for_each_thread(p, t) |
878 | rm_from_queue(sigmask(SIGCONT), &t->pending); | 854 | flush_sigqueue_mask(&flush, &t->pending); |
879 | } while_each_thread(p, t); | ||
880 | } else if (sig == SIGCONT) { | 855 | } else if (sig == SIGCONT) { |
881 | unsigned int why; | 856 | unsigned int why; |
882 | /* | 857 | /* |
883 | * Remove all stop signals from all queues, wake all threads. | 858 | * Remove all stop signals from all queues, wake all threads. |
884 | */ | 859 | */ |
885 | rm_from_queue(SIG_KERNEL_STOP_MASK, &signal->shared_pending); | 860 | siginitset(&flush, SIG_KERNEL_STOP_MASK); |
886 | t = p; | 861 | flush_sigqueue_mask(&flush, &signal->shared_pending); |
887 | do { | 862 | for_each_thread(p, t) { |
863 | flush_sigqueue_mask(&flush, &t->pending); | ||
888 | task_clear_jobctl_pending(t, JOBCTL_STOP_PENDING); | 864 | task_clear_jobctl_pending(t, JOBCTL_STOP_PENDING); |
889 | rm_from_queue(SIG_KERNEL_STOP_MASK, &t->pending); | ||
890 | if (likely(!(t->ptrace & PT_SEIZED))) | 865 | if (likely(!(t->ptrace & PT_SEIZED))) |
891 | wake_up_state(t, __TASK_STOPPED); | 866 | wake_up_state(t, __TASK_STOPPED); |
892 | else | 867 | else |
893 | ptrace_trap_notify(t); | 868 | ptrace_trap_notify(t); |
894 | } while_each_thread(p, t); | 869 | } |
895 | 870 | ||
896 | /* | 871 | /* |
897 | * Notify the parent with CLD_CONTINUED if we were stopped. | 872 | * Notify the parent with CLD_CONTINUED if we were stopped. |
@@ -2854,7 +2829,7 @@ int do_sigtimedwait(const sigset_t *which, siginfo_t *info, | |||
2854 | 2829 | ||
2855 | spin_lock_irq(&tsk->sighand->siglock); | 2830 | spin_lock_irq(&tsk->sighand->siglock); |
2856 | __set_task_blocked(tsk, &tsk->real_blocked); | 2831 | __set_task_blocked(tsk, &tsk->real_blocked); |
2857 | siginitset(&tsk->real_blocked, 0); | 2832 | sigemptyset(&tsk->real_blocked); |
2858 | sig = dequeue_signal(tsk, &mask, info); | 2833 | sig = dequeue_signal(tsk, &mask, info); |
2859 | } | 2834 | } |
2860 | spin_unlock_irq(&tsk->sighand->siglock); | 2835 | spin_unlock_irq(&tsk->sighand->siglock); |
@@ -3091,18 +3066,39 @@ COMPAT_SYSCALL_DEFINE4(rt_tgsigqueueinfo, | |||
3091 | } | 3066 | } |
3092 | #endif | 3067 | #endif |
3093 | 3068 | ||
3069 | /* | ||
3070 | * For kthreads only, must not be used if cloned with CLONE_SIGHAND | ||
3071 | */ | ||
3072 | void kernel_sigaction(int sig, __sighandler_t action) | ||
3073 | { | ||
3074 | spin_lock_irq(¤t->sighand->siglock); | ||
3075 | current->sighand->action[sig - 1].sa.sa_handler = action; | ||
3076 | if (action == SIG_IGN) { | ||
3077 | sigset_t mask; | ||
3078 | |||
3079 | sigemptyset(&mask); | ||
3080 | sigaddset(&mask, sig); | ||
3081 | |||
3082 | flush_sigqueue_mask(&mask, ¤t->signal->shared_pending); | ||
3083 | flush_sigqueue_mask(&mask, ¤t->pending); | ||
3084 | recalc_sigpending(); | ||
3085 | } | ||
3086 | spin_unlock_irq(¤t->sighand->siglock); | ||
3087 | } | ||
3088 | EXPORT_SYMBOL(kernel_sigaction); | ||
3089 | |||
3094 | int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact) | 3090 | int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact) |
3095 | { | 3091 | { |
3096 | struct task_struct *t = current; | 3092 | struct task_struct *p = current, *t; |
3097 | struct k_sigaction *k; | 3093 | struct k_sigaction *k; |
3098 | sigset_t mask; | 3094 | sigset_t mask; |
3099 | 3095 | ||
3100 | if (!valid_signal(sig) || sig < 1 || (act && sig_kernel_only(sig))) | 3096 | if (!valid_signal(sig) || sig < 1 || (act && sig_kernel_only(sig))) |
3101 | return -EINVAL; | 3097 | return -EINVAL; |
3102 | 3098 | ||
3103 | k = &t->sighand->action[sig-1]; | 3099 | k = &p->sighand->action[sig-1]; |
3104 | 3100 | ||
3105 | spin_lock_irq(¤t->sighand->siglock); | 3101 | spin_lock_irq(&p->sighand->siglock); |
3106 | if (oact) | 3102 | if (oact) |
3107 | *oact = *k; | 3103 | *oact = *k; |
3108 | 3104 | ||
@@ -3121,21 +3117,20 @@ int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact) | |||
3121 | * (for example, SIGCHLD), shall cause the pending signal to | 3117 | * (for example, SIGCHLD), shall cause the pending signal to |
3122 | * be discarded, whether or not it is blocked" | 3118 | * be discarded, whether or not it is blocked" |
3123 | */ | 3119 | */ |
3124 | if (sig_handler_ignored(sig_handler(t, sig), sig)) { | 3120 | if (sig_handler_ignored(sig_handler(p, sig), sig)) { |
3125 | sigemptyset(&mask); | 3121 | sigemptyset(&mask); |
3126 | sigaddset(&mask, sig); | 3122 | sigaddset(&mask, sig); |
3127 | rm_from_queue_full(&mask, &t->signal->shared_pending); | 3123 | flush_sigqueue_mask(&mask, &p->signal->shared_pending); |
3128 | do { | 3124 | for_each_thread(p, t) |
3129 | rm_from_queue_full(&mask, &t->pending); | 3125 | flush_sigqueue_mask(&mask, &t->pending); |
3130 | } while_each_thread(current, t); | ||
3131 | } | 3126 | } |
3132 | } | 3127 | } |
3133 | 3128 | ||
3134 | spin_unlock_irq(¤t->sighand->siglock); | 3129 | spin_unlock_irq(&p->sighand->siglock); |
3135 | return 0; | 3130 | return 0; |
3136 | } | 3131 | } |
3137 | 3132 | ||
3138 | static int | 3133 | static int |
3139 | do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long sp) | 3134 | do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long sp) |
3140 | { | 3135 | { |
3141 | stack_t oss; | 3136 | stack_t oss; |
diff --git a/kernel/smp.c b/kernel/smp.c index 06d574e42c72..306f8180b0d5 100644 --- a/kernel/smp.c +++ b/kernel/smp.c | |||
@@ -185,14 +185,26 @@ void generic_smp_call_function_single_interrupt(void) | |||
185 | { | 185 | { |
186 | struct llist_node *entry; | 186 | struct llist_node *entry; |
187 | struct call_single_data *csd, *csd_next; | 187 | struct call_single_data *csd, *csd_next; |
188 | static bool warned; | ||
189 | |||
190 | entry = llist_del_all(&__get_cpu_var(call_single_queue)); | ||
191 | entry = llist_reverse_order(entry); | ||
188 | 192 | ||
189 | /* | 193 | /* |
190 | * Shouldn't receive this interrupt on a cpu that is not yet online. | 194 | * Shouldn't receive this interrupt on a cpu that is not yet online. |
191 | */ | 195 | */ |
192 | WARN_ON_ONCE(!cpu_online(smp_processor_id())); | 196 | if (unlikely(!cpu_online(smp_processor_id()) && !warned)) { |
197 | warned = true; | ||
198 | WARN(1, "IPI on offline CPU %d\n", smp_processor_id()); | ||
193 | 199 | ||
194 | entry = llist_del_all(&__get_cpu_var(call_single_queue)); | 200 | /* |
195 | entry = llist_reverse_order(entry); | 201 | * We don't have to use the _safe() variant here |
202 | * because we are not invoking the IPI handlers yet. | ||
203 | */ | ||
204 | llist_for_each_entry(csd, entry, llist) | ||
205 | pr_warn("IPI callback %pS sent to offline CPU\n", | ||
206 | csd->func); | ||
207 | } | ||
196 | 208 | ||
197 | llist_for_each_entry_safe(csd, csd_next, entry, llist) { | 209 | llist_for_each_entry_safe(csd, csd_next, entry, llist) { |
198 | csd->func(csd->info); | 210 | csd->func(csd->info); |
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 40ce2d983b12..db19e3e2aa4b 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -173,6 +173,13 @@ extern int no_unaligned_warning; | |||
173 | #endif | 173 | #endif |
174 | 174 | ||
175 | #ifdef CONFIG_PROC_SYSCTL | 175 | #ifdef CONFIG_PROC_SYSCTL |
176 | |||
177 | #define SYSCTL_WRITES_LEGACY -1 | ||
178 | #define SYSCTL_WRITES_WARN 0 | ||
179 | #define SYSCTL_WRITES_STRICT 1 | ||
180 | |||
181 | static int sysctl_writes_strict = SYSCTL_WRITES_WARN; | ||
182 | |||
176 | static int proc_do_cad_pid(struct ctl_table *table, int write, | 183 | static int proc_do_cad_pid(struct ctl_table *table, int write, |
177 | void __user *buffer, size_t *lenp, loff_t *ppos); | 184 | void __user *buffer, size_t *lenp, loff_t *ppos); |
178 | static int proc_taint(struct ctl_table *table, int write, | 185 | static int proc_taint(struct ctl_table *table, int write, |
@@ -195,7 +202,7 @@ static int proc_dostring_coredump(struct ctl_table *table, int write, | |||
195 | /* Note: sysrq code uses it's own private copy */ | 202 | /* Note: sysrq code uses it's own private copy */ |
196 | static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE; | 203 | static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE; |
197 | 204 | ||
198 | static int sysrq_sysctl_handler(ctl_table *table, int write, | 205 | static int sysrq_sysctl_handler(struct ctl_table *table, int write, |
199 | void __user *buffer, size_t *lenp, | 206 | void __user *buffer, size_t *lenp, |
200 | loff_t *ppos) | 207 | loff_t *ppos) |
201 | { | 208 | { |
@@ -495,6 +502,15 @@ static struct ctl_table kern_table[] = { | |||
495 | .mode = 0644, | 502 | .mode = 0644, |
496 | .proc_handler = proc_taint, | 503 | .proc_handler = proc_taint, |
497 | }, | 504 | }, |
505 | { | ||
506 | .procname = "sysctl_writes_strict", | ||
507 | .data = &sysctl_writes_strict, | ||
508 | .maxlen = sizeof(int), | ||
509 | .mode = 0644, | ||
510 | .proc_handler = proc_dointvec_minmax, | ||
511 | .extra1 = &neg_one, | ||
512 | .extra2 = &one, | ||
513 | }, | ||
498 | #endif | 514 | #endif |
499 | #ifdef CONFIG_LATENCYTOP | 515 | #ifdef CONFIG_LATENCYTOP |
500 | { | 516 | { |
@@ -1703,8 +1719,8 @@ int __init sysctl_init(void) | |||
1703 | 1719 | ||
1704 | #ifdef CONFIG_PROC_SYSCTL | 1720 | #ifdef CONFIG_PROC_SYSCTL |
1705 | 1721 | ||
1706 | static int _proc_do_string(void* data, int maxlen, int write, | 1722 | static int _proc_do_string(char *data, int maxlen, int write, |
1707 | void __user *buffer, | 1723 | char __user *buffer, |
1708 | size_t *lenp, loff_t *ppos) | 1724 | size_t *lenp, loff_t *ppos) |
1709 | { | 1725 | { |
1710 | size_t len; | 1726 | size_t len; |
@@ -1717,21 +1733,30 @@ static int _proc_do_string(void* data, int maxlen, int write, | |||
1717 | } | 1733 | } |
1718 | 1734 | ||
1719 | if (write) { | 1735 | if (write) { |
1720 | len = 0; | 1736 | if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) { |
1737 | /* Only continue writes not past the end of buffer. */ | ||
1738 | len = strlen(data); | ||
1739 | if (len > maxlen - 1) | ||
1740 | len = maxlen - 1; | ||
1741 | |||
1742 | if (*ppos > len) | ||
1743 | return 0; | ||
1744 | len = *ppos; | ||
1745 | } else { | ||
1746 | /* Start writing from beginning of buffer. */ | ||
1747 | len = 0; | ||
1748 | } | ||
1749 | |||
1750 | *ppos += *lenp; | ||
1721 | p = buffer; | 1751 | p = buffer; |
1722 | while (len < *lenp) { | 1752 | while ((p - buffer) < *lenp && len < maxlen - 1) { |
1723 | if (get_user(c, p++)) | 1753 | if (get_user(c, p++)) |
1724 | return -EFAULT; | 1754 | return -EFAULT; |
1725 | if (c == 0 || c == '\n') | 1755 | if (c == 0 || c == '\n') |
1726 | break; | 1756 | break; |
1727 | len++; | 1757 | data[len++] = c; |
1728 | } | 1758 | } |
1729 | if (len >= maxlen) | 1759 | data[len] = 0; |
1730 | len = maxlen-1; | ||
1731 | if(copy_from_user(data, buffer, len)) | ||
1732 | return -EFAULT; | ||
1733 | ((char *) data)[len] = 0; | ||
1734 | *ppos += *lenp; | ||
1735 | } else { | 1760 | } else { |
1736 | len = strlen(data); | 1761 | len = strlen(data); |
1737 | if (len > maxlen) | 1762 | if (len > maxlen) |
@@ -1748,10 +1773,10 @@ static int _proc_do_string(void* data, int maxlen, int write, | |||
1748 | if (len > *lenp) | 1773 | if (len > *lenp) |
1749 | len = *lenp; | 1774 | len = *lenp; |
1750 | if (len) | 1775 | if (len) |
1751 | if(copy_to_user(buffer, data, len)) | 1776 | if (copy_to_user(buffer, data, len)) |
1752 | return -EFAULT; | 1777 | return -EFAULT; |
1753 | if (len < *lenp) { | 1778 | if (len < *lenp) { |
1754 | if(put_user('\n', ((char __user *) buffer) + len)) | 1779 | if (put_user('\n', buffer + len)) |
1755 | return -EFAULT; | 1780 | return -EFAULT; |
1756 | len++; | 1781 | len++; |
1757 | } | 1782 | } |
@@ -1761,6 +1786,14 @@ static int _proc_do_string(void* data, int maxlen, int write, | |||
1761 | return 0; | 1786 | return 0; |
1762 | } | 1787 | } |
1763 | 1788 | ||
1789 | static void warn_sysctl_write(struct ctl_table *table) | ||
1790 | { | ||
1791 | pr_warn_once("%s wrote to %s when file position was not 0!\n" | ||
1792 | "This will not be supported in the future. To silence this\n" | ||
1793 | "warning, set kernel.sysctl_writes_strict = -1\n", | ||
1794 | current->comm, table->procname); | ||
1795 | } | ||
1796 | |||
1764 | /** | 1797 | /** |
1765 | * proc_dostring - read a string sysctl | 1798 | * proc_dostring - read a string sysctl |
1766 | * @table: the sysctl table | 1799 | * @table: the sysctl table |
@@ -1781,8 +1814,11 @@ static int _proc_do_string(void* data, int maxlen, int write, | |||
1781 | int proc_dostring(struct ctl_table *table, int write, | 1814 | int proc_dostring(struct ctl_table *table, int write, |
1782 | void __user *buffer, size_t *lenp, loff_t *ppos) | 1815 | void __user *buffer, size_t *lenp, loff_t *ppos) |
1783 | { | 1816 | { |
1784 | return _proc_do_string(table->data, table->maxlen, write, | 1817 | if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN) |
1785 | buffer, lenp, ppos); | 1818 | warn_sysctl_write(table); |
1819 | |||
1820 | return _proc_do_string((char *)(table->data), table->maxlen, write, | ||
1821 | (char __user *)buffer, lenp, ppos); | ||
1786 | } | 1822 | } |
1787 | 1823 | ||
1788 | static size_t proc_skip_spaces(char **buf) | 1824 | static size_t proc_skip_spaces(char **buf) |
@@ -1956,6 +1992,18 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, | |||
1956 | conv = do_proc_dointvec_conv; | 1992 | conv = do_proc_dointvec_conv; |
1957 | 1993 | ||
1958 | if (write) { | 1994 | if (write) { |
1995 | if (*ppos) { | ||
1996 | switch (sysctl_writes_strict) { | ||
1997 | case SYSCTL_WRITES_STRICT: | ||
1998 | goto out; | ||
1999 | case SYSCTL_WRITES_WARN: | ||
2000 | warn_sysctl_write(table); | ||
2001 | break; | ||
2002 | default: | ||
2003 | break; | ||
2004 | } | ||
2005 | } | ||
2006 | |||
1959 | if (left > PAGE_SIZE - 1) | 2007 | if (left > PAGE_SIZE - 1) |
1960 | left = PAGE_SIZE - 1; | 2008 | left = PAGE_SIZE - 1; |
1961 | page = __get_free_page(GFP_TEMPORARY); | 2009 | page = __get_free_page(GFP_TEMPORARY); |
@@ -2013,6 +2061,7 @@ free: | |||
2013 | return err ? : -EINVAL; | 2061 | return err ? : -EINVAL; |
2014 | } | 2062 | } |
2015 | *lenp -= left; | 2063 | *lenp -= left; |
2064 | out: | ||
2016 | *ppos += *lenp; | 2065 | *ppos += *lenp; |
2017 | return err; | 2066 | return err; |
2018 | } | 2067 | } |
@@ -2205,6 +2254,18 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int | |||
2205 | left = *lenp; | 2254 | left = *lenp; |
2206 | 2255 | ||
2207 | if (write) { | 2256 | if (write) { |
2257 | if (*ppos) { | ||
2258 | switch (sysctl_writes_strict) { | ||
2259 | case SYSCTL_WRITES_STRICT: | ||
2260 | goto out; | ||
2261 | case SYSCTL_WRITES_WARN: | ||
2262 | warn_sysctl_write(table); | ||
2263 | break; | ||
2264 | default: | ||
2265 | break; | ||
2266 | } | ||
2267 | } | ||
2268 | |||
2208 | if (left > PAGE_SIZE - 1) | 2269 | if (left > PAGE_SIZE - 1) |
2209 | left = PAGE_SIZE - 1; | 2270 | left = PAGE_SIZE - 1; |
2210 | page = __get_free_page(GFP_TEMPORARY); | 2271 | page = __get_free_page(GFP_TEMPORARY); |
@@ -2260,6 +2321,7 @@ free: | |||
2260 | return err ? : -EINVAL; | 2321 | return err ? : -EINVAL; |
2261 | } | 2322 | } |
2262 | *lenp -= left; | 2323 | *lenp -= left; |
2324 | out: | ||
2263 | *ppos += *lenp; | 2325 | *ppos += *lenp; |
2264 | return err; | 2326 | return err; |
2265 | } | 2327 | } |
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index bf71b4b2d632..fcc02560fd6b 100644 --- a/kernel/user_namespace.c +++ b/kernel/user_namespace.c | |||
@@ -286,7 +286,7 @@ EXPORT_SYMBOL(from_kuid_munged); | |||
286 | /** | 286 | /** |
287 | * make_kgid - Map a user-namespace gid pair into a kgid. | 287 | * make_kgid - Map a user-namespace gid pair into a kgid. |
288 | * @ns: User namespace that the gid is in | 288 | * @ns: User namespace that the gid is in |
289 | * @uid: group identifier | 289 | * @gid: group identifier |
290 | * | 290 | * |
291 | * Maps a user-namespace gid pair into a kernel internal kgid, | 291 | * Maps a user-namespace gid pair into a kernel internal kgid, |
292 | * and returns that kgid. | 292 | * and returns that kgid. |
@@ -482,7 +482,8 @@ static int projid_m_show(struct seq_file *seq, void *v) | |||
482 | return 0; | 482 | return 0; |
483 | } | 483 | } |
484 | 484 | ||
485 | static void *m_start(struct seq_file *seq, loff_t *ppos, struct uid_gid_map *map) | 485 | static void *m_start(struct seq_file *seq, loff_t *ppos, |
486 | struct uid_gid_map *map) | ||
486 | { | 487 | { |
487 | struct uid_gid_extent *extent = NULL; | 488 | struct uid_gid_extent *extent = NULL; |
488 | loff_t pos = *ppos; | 489 | loff_t pos = *ppos; |
@@ -546,7 +547,8 @@ struct seq_operations proc_projid_seq_operations = { | |||
546 | .show = projid_m_show, | 547 | .show = projid_m_show, |
547 | }; | 548 | }; |
548 | 549 | ||
549 | static bool mappings_overlap(struct uid_gid_map *new_map, struct uid_gid_extent *extent) | 550 | static bool mappings_overlap(struct uid_gid_map *new_map, |
551 | struct uid_gid_extent *extent) | ||
550 | { | 552 | { |
551 | u32 upper_first, lower_first, upper_last, lower_last; | 553 | u32 upper_first, lower_first, upper_last, lower_last; |
552 | unsigned idx; | 554 | unsigned idx; |
@@ -653,7 +655,7 @@ static ssize_t map_write(struct file *file, const char __user *buf, | |||
653 | ret = -EINVAL; | 655 | ret = -EINVAL; |
654 | pos = kbuf; | 656 | pos = kbuf; |
655 | new_map.nr_extents = 0; | 657 | new_map.nr_extents = 0; |
656 | for (;pos; pos = next_line) { | 658 | for (; pos; pos = next_line) { |
657 | extent = &new_map.extent[new_map.nr_extents]; | 659 | extent = &new_map.extent[new_map.nr_extents]; |
658 | 660 | ||
659 | /* Find the end of line and ensure I don't look past it */ | 661 | /* Find the end of line and ensure I don't look past it */ |
@@ -687,13 +689,16 @@ static ssize_t map_write(struct file *file, const char __user *buf, | |||
687 | 689 | ||
688 | /* Verify we have been given valid starting values */ | 690 | /* Verify we have been given valid starting values */ |
689 | if ((extent->first == (u32) -1) || | 691 | if ((extent->first == (u32) -1) || |
690 | (extent->lower_first == (u32) -1 )) | 692 | (extent->lower_first == (u32) -1)) |
691 | goto out; | 693 | goto out; |
692 | 694 | ||
693 | /* Verify count is not zero and does not cause the extent to wrap */ | 695 | /* Verify count is not zero and does not cause the |
696 | * extent to wrap | ||
697 | */ | ||
694 | if ((extent->first + extent->count) <= extent->first) | 698 | if ((extent->first + extent->count) <= extent->first) |
695 | goto out; | 699 | goto out; |
696 | if ((extent->lower_first + extent->count) <= extent->lower_first) | 700 | if ((extent->lower_first + extent->count) <= |
701 | extent->lower_first) | ||
697 | goto out; | 702 | goto out; |
698 | 703 | ||
699 | /* Do the ranges in extent overlap any previous extents? */ | 704 | /* Do the ranges in extent overlap any previous extents? */ |
@@ -751,7 +756,8 @@ out: | |||
751 | return ret; | 756 | return ret; |
752 | } | 757 | } |
753 | 758 | ||
754 | ssize_t proc_uid_map_write(struct file *file, const char __user *buf, size_t size, loff_t *ppos) | 759 | ssize_t proc_uid_map_write(struct file *file, const char __user *buf, |
760 | size_t size, loff_t *ppos) | ||
755 | { | 761 | { |
756 | struct seq_file *seq = file->private_data; | 762 | struct seq_file *seq = file->private_data; |
757 | struct user_namespace *ns = seq->private; | 763 | struct user_namespace *ns = seq->private; |
@@ -767,7 +773,8 @@ ssize_t proc_uid_map_write(struct file *file, const char __user *buf, size_t siz | |||
767 | &ns->uid_map, &ns->parent->uid_map); | 773 | &ns->uid_map, &ns->parent->uid_map); |
768 | } | 774 | } |
769 | 775 | ||
770 | ssize_t proc_gid_map_write(struct file *file, const char __user *buf, size_t size, loff_t *ppos) | 776 | ssize_t proc_gid_map_write(struct file *file, const char __user *buf, |
777 | size_t size, loff_t *ppos) | ||
771 | { | 778 | { |
772 | struct seq_file *seq = file->private_data; | 779 | struct seq_file *seq = file->private_data; |
773 | struct user_namespace *ns = seq->private; | 780 | struct user_namespace *ns = seq->private; |
@@ -783,7 +790,8 @@ ssize_t proc_gid_map_write(struct file *file, const char __user *buf, size_t siz | |||
783 | &ns->gid_map, &ns->parent->gid_map); | 790 | &ns->gid_map, &ns->parent->gid_map); |
784 | } | 791 | } |
785 | 792 | ||
786 | ssize_t proc_projid_map_write(struct file *file, const char __user *buf, size_t size, loff_t *ppos) | 793 | ssize_t proc_projid_map_write(struct file *file, const char __user *buf, |
794 | size_t size, loff_t *ppos) | ||
787 | { | 795 | { |
788 | struct seq_file *seq = file->private_data; | 796 | struct seq_file *seq = file->private_data; |
789 | struct user_namespace *ns = seq->private; | 797 | struct user_namespace *ns = seq->private; |
@@ -800,7 +808,7 @@ ssize_t proc_projid_map_write(struct file *file, const char __user *buf, size_t | |||
800 | &ns->projid_map, &ns->parent->projid_map); | 808 | &ns->projid_map, &ns->parent->projid_map); |
801 | } | 809 | } |
802 | 810 | ||
803 | static bool new_idmap_permitted(const struct file *file, | 811 | static bool new_idmap_permitted(const struct file *file, |
804 | struct user_namespace *ns, int cap_setid, | 812 | struct user_namespace *ns, int cap_setid, |
805 | struct uid_gid_map *new_map) | 813 | struct uid_gid_map *new_map) |
806 | { | 814 | { |
@@ -811,8 +819,7 @@ static bool new_idmap_permitted(const struct file *file, | |||
811 | kuid_t uid = make_kuid(ns->parent, id); | 819 | kuid_t uid = make_kuid(ns->parent, id); |
812 | if (uid_eq(uid, file->f_cred->fsuid)) | 820 | if (uid_eq(uid, file->f_cred->fsuid)) |
813 | return true; | 821 | return true; |
814 | } | 822 | } else if (cap_setid == CAP_SETGID) { |
815 | else if (cap_setid == CAP_SETGID) { | ||
816 | kgid_t gid = make_kgid(ns->parent, id); | 823 | kgid_t gid = make_kgid(ns->parent, id); |
817 | if (gid_eq(gid, file->f_cred->fsgid)) | 824 | if (gid_eq(gid, file->f_cred->fsgid)) |
818 | return true; | 825 | return true; |
diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c index 6fbe811c7ad1..c8eac43267e9 100644 --- a/kernel/utsname_sysctl.c +++ b/kernel/utsname_sysctl.c | |||
@@ -17,7 +17,7 @@ | |||
17 | 17 | ||
18 | #ifdef CONFIG_PROC_SYSCTL | 18 | #ifdef CONFIG_PROC_SYSCTL |
19 | 19 | ||
20 | static void *get_uts(ctl_table *table, int write) | 20 | static void *get_uts(struct ctl_table *table, int write) |
21 | { | 21 | { |
22 | char *which = table->data; | 22 | char *which = table->data; |
23 | struct uts_namespace *uts_ns; | 23 | struct uts_namespace *uts_ns; |
@@ -32,7 +32,7 @@ static void *get_uts(ctl_table *table, int write) | |||
32 | return which; | 32 | return which; |
33 | } | 33 | } |
34 | 34 | ||
35 | static void put_uts(ctl_table *table, int write, void *which) | 35 | static void put_uts(struct ctl_table *table, int write, void *which) |
36 | { | 36 | { |
37 | if (!write) | 37 | if (!write) |
38 | up_read(&uts_sem); | 38 | up_read(&uts_sem); |
@@ -44,7 +44,7 @@ static void put_uts(ctl_table *table, int write, void *which) | |||
44 | * Special case of dostring for the UTS structure. This has locks | 44 | * Special case of dostring for the UTS structure. This has locks |
45 | * to observe. Should this be in kernel/sys.c ???? | 45 | * to observe. Should this be in kernel/sys.c ???? |
46 | */ | 46 | */ |
47 | static int proc_do_uts_string(ctl_table *table, int write, | 47 | static int proc_do_uts_string(struct ctl_table *table, int write, |
48 | void __user *buffer, size_t *lenp, loff_t *ppos) | 48 | void __user *buffer, size_t *lenp, loff_t *ppos) |
49 | { | 49 | { |
50 | struct ctl_table uts_table; | 50 | struct ctl_table uts_table; |
@@ -18,12 +18,6 @@ | |||
18 | * pointer or what ever, we treat it as a (void *). You can pass this | 18 | * pointer or what ever, we treat it as a (void *). You can pass this |
19 | * id to a user for him to pass back at a later time. You then pass | 19 | * id to a user for him to pass back at a later time. You then pass |
20 | * that id to this code and it returns your pointer. | 20 | * that id to this code and it returns your pointer. |
21 | |||
22 | * You can release ids at any time. When all ids are released, most of | ||
23 | * the memory is returned (we keep MAX_IDR_FREE) in a local pool so we | ||
24 | * don't need to go to the memory "store" during an id allocate, just | ||
25 | * so you don't need to be too concerned about locking and conflicts | ||
26 | * with the slab allocator. | ||
27 | */ | 21 | */ |
28 | 22 | ||
29 | #ifndef TEST // to test in user space... | 23 | #ifndef TEST // to test in user space... |
@@ -151,7 +145,7 @@ static void idr_layer_rcu_free(struct rcu_head *head) | |||
151 | 145 | ||
152 | static inline void free_layer(struct idr *idr, struct idr_layer *p) | 146 | static inline void free_layer(struct idr *idr, struct idr_layer *p) |
153 | { | 147 | { |
154 | if (idr->hint && idr->hint == p) | 148 | if (idr->hint == p) |
155 | RCU_INIT_POINTER(idr->hint, NULL); | 149 | RCU_INIT_POINTER(idr->hint, NULL); |
156 | call_rcu(&p->rcu_head, idr_layer_rcu_free); | 150 | call_rcu(&p->rcu_head, idr_layer_rcu_free); |
157 | } | 151 | } |
@@ -249,7 +243,7 @@ static int sub_alloc(struct idr *idp, int *starting_id, struct idr_layer **pa, | |||
249 | id = (id | ((1 << (IDR_BITS * l)) - 1)) + 1; | 243 | id = (id | ((1 << (IDR_BITS * l)) - 1)) + 1; |
250 | 244 | ||
251 | /* if already at the top layer, we need to grow */ | 245 | /* if already at the top layer, we need to grow */ |
252 | if (id >= 1 << (idp->layers * IDR_BITS)) { | 246 | if (id > idr_max(idp->layers)) { |
253 | *starting_id = id; | 247 | *starting_id = id; |
254 | return -EAGAIN; | 248 | return -EAGAIN; |
255 | } | 249 | } |
@@ -562,6 +556,11 @@ void idr_remove(struct idr *idp, int id) | |||
562 | if (id < 0) | 556 | if (id < 0) |
563 | return; | 557 | return; |
564 | 558 | ||
559 | if (id > idr_max(idp->layers)) { | ||
560 | idr_remove_warning(id); | ||
561 | return; | ||
562 | } | ||
563 | |||
565 | sub_remove(idp, (idp->layers - 1) * IDR_BITS, id); | 564 | sub_remove(idp, (idp->layers - 1) * IDR_BITS, id); |
566 | if (idp->top && idp->top->count == 1 && (idp->layers > 1) && | 565 | if (idp->top && idp->top->count == 1 && (idp->layers > 1) && |
567 | idp->top->ary[0]) { | 566 | idp->top->ary[0]) { |
@@ -579,16 +578,6 @@ void idr_remove(struct idr *idp, int id) | |||
579 | bitmap_clear(to_free->bitmap, 0, IDR_SIZE); | 578 | bitmap_clear(to_free->bitmap, 0, IDR_SIZE); |
580 | free_layer(idp, to_free); | 579 | free_layer(idp, to_free); |
581 | } | 580 | } |
582 | while (idp->id_free_cnt >= MAX_IDR_FREE) { | ||
583 | p = get_from_free_list(idp); | ||
584 | /* | ||
585 | * Note: we don't call the rcu callback here, since the only | ||
586 | * layers that fall into the freelist are those that have been | ||
587 | * preallocated. | ||
588 | */ | ||
589 | kmem_cache_free(idr_layer_cache, p); | ||
590 | } | ||
591 | return; | ||
592 | } | 581 | } |
593 | EXPORT_SYMBOL(idr_remove); | 582 | EXPORT_SYMBOL(idr_remove); |
594 | 583 | ||
@@ -809,14 +798,12 @@ void *idr_replace(struct idr *idp, void *ptr, int id) | |||
809 | 798 | ||
810 | p = idp->top; | 799 | p = idp->top; |
811 | if (!p) | 800 | if (!p) |
812 | return ERR_PTR(-EINVAL); | 801 | return ERR_PTR(-ENOENT); |
813 | |||
814 | n = (p->layer+1) * IDR_BITS; | ||
815 | 802 | ||
816 | if (id >= (1 << n)) | 803 | if (id > idr_max(p->layer + 1)) |
817 | return ERR_PTR(-EINVAL); | 804 | return ERR_PTR(-ENOENT); |
818 | 805 | ||
819 | n -= IDR_BITS; | 806 | n = p->layer * IDR_BITS; |
820 | while ((n > 0) && p) { | 807 | while ((n > 0) && p) { |
821 | p = p->ary[(id >> n) & IDR_MASK]; | 808 | p = p->ary[(id >> n) & IDR_MASK]; |
822 | n -= IDR_BITS; | 809 | n -= IDR_BITS; |
@@ -1027,6 +1014,9 @@ void ida_remove(struct ida *ida, int id) | |||
1027 | int n; | 1014 | int n; |
1028 | struct ida_bitmap *bitmap; | 1015 | struct ida_bitmap *bitmap; |
1029 | 1016 | ||
1017 | if (idr_id > idr_max(ida->idr.layers)) | ||
1018 | goto err; | ||
1019 | |||
1030 | /* clear full bits while looking up the leaf idr_layer */ | 1020 | /* clear full bits while looking up the leaf idr_layer */ |
1031 | while ((shift > 0) && p) { | 1021 | while ((shift > 0) && p) { |
1032 | n = (idr_id >> shift) & IDR_MASK; | 1022 | n = (idr_id >> shift) & IDR_MASK; |
@@ -1042,7 +1032,7 @@ void ida_remove(struct ida *ida, int id) | |||
1042 | __clear_bit(n, p->bitmap); | 1032 | __clear_bit(n, p->bitmap); |
1043 | 1033 | ||
1044 | bitmap = (void *)p->ary[n]; | 1034 | bitmap = (void *)p->ary[n]; |
1045 | if (!test_bit(offset, bitmap->bitmap)) | 1035 | if (!bitmap || !test_bit(offset, bitmap->bitmap)) |
1046 | goto err; | 1036 | goto err; |
1047 | 1037 | ||
1048 | /* update bitmap and remove it if empty */ | 1038 | /* update bitmap and remove it if empty */ |
diff --git a/lib/radix-tree.c b/lib/radix-tree.c index d64815651e90..3291a8e37490 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/radix-tree.h> | 27 | #include <linux/radix-tree.h> |
28 | #include <linux/percpu.h> | 28 | #include <linux/percpu.h> |
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/kmemleak.h> | ||
30 | #include <linux/notifier.h> | 31 | #include <linux/notifier.h> |
31 | #include <linux/cpu.h> | 32 | #include <linux/cpu.h> |
32 | #include <linux/string.h> | 33 | #include <linux/string.h> |
@@ -200,6 +201,11 @@ radix_tree_node_alloc(struct radix_tree_root *root) | |||
200 | rtp->nodes[rtp->nr - 1] = NULL; | 201 | rtp->nodes[rtp->nr - 1] = NULL; |
201 | rtp->nr--; | 202 | rtp->nr--; |
202 | } | 203 | } |
204 | /* | ||
205 | * Update the allocation stack trace as this is more useful | ||
206 | * for debugging. | ||
207 | */ | ||
208 | kmemleak_update_trace(ret); | ||
203 | } | 209 | } |
204 | if (ret == NULL) | 210 | if (ret == NULL) |
205 | ret = kmem_cache_alloc(radix_tree_node_cachep, gfp_mask); | 211 | ret = kmem_cache_alloc(radix_tree_node_cachep, gfp_mask); |
diff --git a/mm/fremap.c b/mm/fremap.c index 2c5646f11f41..72b8fa361433 100644 --- a/mm/fremap.c +++ b/mm/fremap.c | |||
@@ -149,6 +149,10 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, | |||
149 | int has_write_lock = 0; | 149 | int has_write_lock = 0; |
150 | vm_flags_t vm_flags = 0; | 150 | vm_flags_t vm_flags = 0; |
151 | 151 | ||
152 | pr_warn_once("%s (%d) uses deprecated remap_file_pages() syscall. " | ||
153 | "See Documentation/vm/remap_file_pages.txt.\n", | ||
154 | current->comm, current->pid); | ||
155 | |||
152 | if (prot) | 156 | if (prot) |
153 | return err; | 157 | return err; |
154 | /* | 158 | /* |
diff --git a/mm/kmemleak-test.c b/mm/kmemleak-test.c index ff0d9779cec8..dcdcadb69533 100644 --- a/mm/kmemleak-test.c +++ b/mm/kmemleak-test.c | |||
@@ -18,6 +18,8 @@ | |||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #define pr_fmt(fmt) "kmemleak: " fmt | ||
22 | |||
21 | #include <linux/init.h> | 23 | #include <linux/init.h> |
22 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
23 | #include <linux/module.h> | 25 | #include <linux/module.h> |
@@ -50,25 +52,25 @@ static int __init kmemleak_test_init(void) | |||
50 | printk(KERN_INFO "Kmemleak testing\n"); | 52 | printk(KERN_INFO "Kmemleak testing\n"); |
51 | 53 | ||
52 | /* make some orphan objects */ | 54 | /* make some orphan objects */ |
53 | pr_info("kmemleak: kmalloc(32) = %p\n", kmalloc(32, GFP_KERNEL)); | 55 | pr_info("kmalloc(32) = %p\n", kmalloc(32, GFP_KERNEL)); |
54 | pr_info("kmemleak: kmalloc(32) = %p\n", kmalloc(32, GFP_KERNEL)); | 56 | pr_info("kmalloc(32) = %p\n", kmalloc(32, GFP_KERNEL)); |
55 | pr_info("kmemleak: kmalloc(1024) = %p\n", kmalloc(1024, GFP_KERNEL)); | 57 | pr_info("kmalloc(1024) = %p\n", kmalloc(1024, GFP_KERNEL)); |
56 | pr_info("kmemleak: kmalloc(1024) = %p\n", kmalloc(1024, GFP_KERNEL)); | 58 | pr_info("kmalloc(1024) = %p\n", kmalloc(1024, GFP_KERNEL)); |
57 | pr_info("kmemleak: kmalloc(2048) = %p\n", kmalloc(2048, GFP_KERNEL)); | 59 | pr_info("kmalloc(2048) = %p\n", kmalloc(2048, GFP_KERNEL)); |
58 | pr_info("kmemleak: kmalloc(2048) = %p\n", kmalloc(2048, GFP_KERNEL)); | 60 | pr_info("kmalloc(2048) = %p\n", kmalloc(2048, GFP_KERNEL)); |
59 | pr_info("kmemleak: kmalloc(4096) = %p\n", kmalloc(4096, GFP_KERNEL)); | 61 | pr_info("kmalloc(4096) = %p\n", kmalloc(4096, GFP_KERNEL)); |
60 | pr_info("kmemleak: kmalloc(4096) = %p\n", kmalloc(4096, GFP_KERNEL)); | 62 | pr_info("kmalloc(4096) = %p\n", kmalloc(4096, GFP_KERNEL)); |
61 | #ifndef CONFIG_MODULES | 63 | #ifndef CONFIG_MODULES |
62 | pr_info("kmemleak: kmem_cache_alloc(files_cachep) = %p\n", | 64 | pr_info("kmem_cache_alloc(files_cachep) = %p\n", |
63 | kmem_cache_alloc(files_cachep, GFP_KERNEL)); | 65 | kmem_cache_alloc(files_cachep, GFP_KERNEL)); |
64 | pr_info("kmemleak: kmem_cache_alloc(files_cachep) = %p\n", | 66 | pr_info("kmem_cache_alloc(files_cachep) = %p\n", |
65 | kmem_cache_alloc(files_cachep, GFP_KERNEL)); | 67 | kmem_cache_alloc(files_cachep, GFP_KERNEL)); |
66 | #endif | 68 | #endif |
67 | pr_info("kmemleak: vmalloc(64) = %p\n", vmalloc(64)); | 69 | pr_info("vmalloc(64) = %p\n", vmalloc(64)); |
68 | pr_info("kmemleak: vmalloc(64) = %p\n", vmalloc(64)); | 70 | pr_info("vmalloc(64) = %p\n", vmalloc(64)); |
69 | pr_info("kmemleak: vmalloc(64) = %p\n", vmalloc(64)); | 71 | pr_info("vmalloc(64) = %p\n", vmalloc(64)); |
70 | pr_info("kmemleak: vmalloc(64) = %p\n", vmalloc(64)); | 72 | pr_info("vmalloc(64) = %p\n", vmalloc(64)); |
71 | pr_info("kmemleak: vmalloc(64) = %p\n", vmalloc(64)); | 73 | pr_info("vmalloc(64) = %p\n", vmalloc(64)); |
72 | 74 | ||
73 | /* | 75 | /* |
74 | * Add elements to a list. They should only appear as orphan | 76 | * Add elements to a list. They should only appear as orphan |
@@ -76,7 +78,7 @@ static int __init kmemleak_test_init(void) | |||
76 | */ | 78 | */ |
77 | for (i = 0; i < 10; i++) { | 79 | for (i = 0; i < 10; i++) { |
78 | elem = kzalloc(sizeof(*elem), GFP_KERNEL); | 80 | elem = kzalloc(sizeof(*elem), GFP_KERNEL); |
79 | pr_info("kmemleak: kzalloc(sizeof(*elem)) = %p\n", elem); | 81 | pr_info("kzalloc(sizeof(*elem)) = %p\n", elem); |
80 | if (!elem) | 82 | if (!elem) |
81 | return -ENOMEM; | 83 | return -ENOMEM; |
82 | INIT_LIST_HEAD(&elem->list); | 84 | INIT_LIST_HEAD(&elem->list); |
@@ -85,7 +87,7 @@ static int __init kmemleak_test_init(void) | |||
85 | 87 | ||
86 | for_each_possible_cpu(i) { | 88 | for_each_possible_cpu(i) { |
87 | per_cpu(kmemleak_test_pointer, i) = kmalloc(129, GFP_KERNEL); | 89 | per_cpu(kmemleak_test_pointer, i) = kmalloc(129, GFP_KERNEL); |
88 | pr_info("kmemleak: kmalloc(129) = %p\n", | 90 | pr_info("kmalloc(129) = %p\n", |
89 | per_cpu(kmemleak_test_pointer, i)); | 91 | per_cpu(kmemleak_test_pointer, i)); |
90 | } | 92 | } |
91 | 93 | ||
diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 736ade31d1dc..3cda50c1e394 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c | |||
@@ -387,7 +387,7 @@ static void dump_object_info(struct kmemleak_object *object) | |||
387 | pr_notice(" min_count = %d\n", object->min_count); | 387 | pr_notice(" min_count = %d\n", object->min_count); |
388 | pr_notice(" count = %d\n", object->count); | 388 | pr_notice(" count = %d\n", object->count); |
389 | pr_notice(" flags = 0x%lx\n", object->flags); | 389 | pr_notice(" flags = 0x%lx\n", object->flags); |
390 | pr_notice(" checksum = %d\n", object->checksum); | 390 | pr_notice(" checksum = %u\n", object->checksum); |
391 | pr_notice(" backtrace:\n"); | 391 | pr_notice(" backtrace:\n"); |
392 | print_stack_trace(&trace, 4); | 392 | print_stack_trace(&trace, 4); |
393 | } | 393 | } |
@@ -990,6 +990,40 @@ void __ref kmemleak_free_percpu(const void __percpu *ptr) | |||
990 | EXPORT_SYMBOL_GPL(kmemleak_free_percpu); | 990 | EXPORT_SYMBOL_GPL(kmemleak_free_percpu); |
991 | 991 | ||
992 | /** | 992 | /** |
993 | * kmemleak_update_trace - update object allocation stack trace | ||
994 | * @ptr: pointer to beginning of the object | ||
995 | * | ||
996 | * Override the object allocation stack trace for cases where the actual | ||
997 | * allocation place is not always useful. | ||
998 | */ | ||
999 | void __ref kmemleak_update_trace(const void *ptr) | ||
1000 | { | ||
1001 | struct kmemleak_object *object; | ||
1002 | unsigned long flags; | ||
1003 | |||
1004 | pr_debug("%s(0x%p)\n", __func__, ptr); | ||
1005 | |||
1006 | if (!kmemleak_enabled || IS_ERR_OR_NULL(ptr)) | ||
1007 | return; | ||
1008 | |||
1009 | object = find_and_get_object((unsigned long)ptr, 1); | ||
1010 | if (!object) { | ||
1011 | #ifdef DEBUG | ||
1012 | kmemleak_warn("Updating stack trace for unknown object at %p\n", | ||
1013 | ptr); | ||
1014 | #endif | ||
1015 | return; | ||
1016 | } | ||
1017 | |||
1018 | spin_lock_irqsave(&object->lock, flags); | ||
1019 | object->trace_len = __save_stack_trace(object->trace); | ||
1020 | spin_unlock_irqrestore(&object->lock, flags); | ||
1021 | |||
1022 | put_object(object); | ||
1023 | } | ||
1024 | EXPORT_SYMBOL(kmemleak_update_trace); | ||
1025 | |||
1026 | /** | ||
993 | * kmemleak_not_leak - mark an allocated object as false positive | 1027 | * kmemleak_not_leak - mark an allocated object as false positive |
994 | * @ptr: pointer to beginning of the object | 1028 | * @ptr: pointer to beginning of the object |
995 | * | 1029 | * |
diff --git a/mm/memblock.c b/mm/memblock.c index 0aa0d2b07624..6d2f219a48b0 100644 --- a/mm/memblock.c +++ b/mm/memblock.c | |||
@@ -691,6 +691,7 @@ int __init_memblock memblock_free(phys_addr_t base, phys_addr_t size) | |||
691 | (unsigned long long)base + size - 1, | 691 | (unsigned long long)base + size - 1, |
692 | (void *)_RET_IP_); | 692 | (void *)_RET_IP_); |
693 | 693 | ||
694 | kmemleak_free_part(__va(base), size); | ||
694 | return memblock_remove_range(&memblock.reserved, base, size); | 695 | return memblock_remove_range(&memblock.reserved, base, size); |
695 | } | 696 | } |
696 | 697 | ||
@@ -1043,9 +1044,14 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, | |||
1043 | align = SMP_CACHE_BYTES; | 1044 | align = SMP_CACHE_BYTES; |
1044 | 1045 | ||
1045 | found = memblock_find_in_range_node(size, align, start, end, nid); | 1046 | found = memblock_find_in_range_node(size, align, start, end, nid); |
1046 | if (found && !memblock_reserve(found, size)) | 1047 | if (found && !memblock_reserve(found, size)) { |
1048 | /* | ||
1049 | * The min_count is set to 0 so that memblock allocations are | ||
1050 | * never reported as leaks. | ||
1051 | */ | ||
1052 | kmemleak_alloc(__va(found), size, 0, 0); | ||
1047 | return found; | 1053 | return found; |
1048 | 1054 | } | |
1049 | return 0; | 1055 | return 0; |
1050 | } | 1056 | } |
1051 | 1057 | ||
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index a500cb0594c4..a9559b91603c 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -676,9 +676,11 @@ static void disarm_static_keys(struct mem_cgroup *memcg) | |||
676 | static void drain_all_stock_async(struct mem_cgroup *memcg); | 676 | static void drain_all_stock_async(struct mem_cgroup *memcg); |
677 | 677 | ||
678 | static struct mem_cgroup_per_zone * | 678 | static struct mem_cgroup_per_zone * |
679 | mem_cgroup_zoneinfo(struct mem_cgroup *memcg, int nid, int zid) | 679 | mem_cgroup_zone_zoneinfo(struct mem_cgroup *memcg, struct zone *zone) |
680 | { | 680 | { |
681 | VM_BUG_ON((unsigned)nid >= nr_node_ids); | 681 | int nid = zone_to_nid(zone); |
682 | int zid = zone_idx(zone); | ||
683 | |||
682 | return &memcg->nodeinfo[nid]->zoneinfo[zid]; | 684 | return &memcg->nodeinfo[nid]->zoneinfo[zid]; |
683 | } | 685 | } |
684 | 686 | ||
@@ -688,12 +690,12 @@ struct cgroup_subsys_state *mem_cgroup_css(struct mem_cgroup *memcg) | |||
688 | } | 690 | } |
689 | 691 | ||
690 | static struct mem_cgroup_per_zone * | 692 | static struct mem_cgroup_per_zone * |
691 | page_cgroup_zoneinfo(struct mem_cgroup *memcg, struct page *page) | 693 | mem_cgroup_page_zoneinfo(struct mem_cgroup *memcg, struct page *page) |
692 | { | 694 | { |
693 | int nid = page_to_nid(page); | 695 | int nid = page_to_nid(page); |
694 | int zid = page_zonenum(page); | 696 | int zid = page_zonenum(page); |
695 | 697 | ||
696 | return mem_cgroup_zoneinfo(memcg, nid, zid); | 698 | return &memcg->nodeinfo[nid]->zoneinfo[zid]; |
697 | } | 699 | } |
698 | 700 | ||
699 | static struct mem_cgroup_tree_per_zone * | 701 | static struct mem_cgroup_tree_per_zone * |
@@ -711,11 +713,9 @@ soft_limit_tree_from_page(struct page *page) | |||
711 | return &soft_limit_tree.rb_tree_per_node[nid]->rb_tree_per_zone[zid]; | 713 | return &soft_limit_tree.rb_tree_per_node[nid]->rb_tree_per_zone[zid]; |
712 | } | 714 | } |
713 | 715 | ||
714 | static void | 716 | static void __mem_cgroup_insert_exceeded(struct mem_cgroup_per_zone *mz, |
715 | __mem_cgroup_insert_exceeded(struct mem_cgroup *memcg, | 717 | struct mem_cgroup_tree_per_zone *mctz, |
716 | struct mem_cgroup_per_zone *mz, | 718 | unsigned long long new_usage_in_excess) |
717 | struct mem_cgroup_tree_per_zone *mctz, | ||
718 | unsigned long long new_usage_in_excess) | ||
719 | { | 719 | { |
720 | struct rb_node **p = &mctz->rb_root.rb_node; | 720 | struct rb_node **p = &mctz->rb_root.rb_node; |
721 | struct rb_node *parent = NULL; | 721 | struct rb_node *parent = NULL; |
@@ -745,10 +745,8 @@ __mem_cgroup_insert_exceeded(struct mem_cgroup *memcg, | |||
745 | mz->on_tree = true; | 745 | mz->on_tree = true; |
746 | } | 746 | } |
747 | 747 | ||
748 | static void | 748 | static void __mem_cgroup_remove_exceeded(struct mem_cgroup_per_zone *mz, |
749 | __mem_cgroup_remove_exceeded(struct mem_cgroup *memcg, | 749 | struct mem_cgroup_tree_per_zone *mctz) |
750 | struct mem_cgroup_per_zone *mz, | ||
751 | struct mem_cgroup_tree_per_zone *mctz) | ||
752 | { | 750 | { |
753 | if (!mz->on_tree) | 751 | if (!mz->on_tree) |
754 | return; | 752 | return; |
@@ -756,13 +754,11 @@ __mem_cgroup_remove_exceeded(struct mem_cgroup *memcg, | |||
756 | mz->on_tree = false; | 754 | mz->on_tree = false; |
757 | } | 755 | } |
758 | 756 | ||
759 | static void | 757 | static void mem_cgroup_remove_exceeded(struct mem_cgroup_per_zone *mz, |
760 | mem_cgroup_remove_exceeded(struct mem_cgroup *memcg, | 758 | struct mem_cgroup_tree_per_zone *mctz) |
761 | struct mem_cgroup_per_zone *mz, | ||
762 | struct mem_cgroup_tree_per_zone *mctz) | ||
763 | { | 759 | { |
764 | spin_lock(&mctz->lock); | 760 | spin_lock(&mctz->lock); |
765 | __mem_cgroup_remove_exceeded(memcg, mz, mctz); | 761 | __mem_cgroup_remove_exceeded(mz, mctz); |
766 | spin_unlock(&mctz->lock); | 762 | spin_unlock(&mctz->lock); |
767 | } | 763 | } |
768 | 764 | ||
@@ -772,16 +768,14 @@ static void mem_cgroup_update_tree(struct mem_cgroup *memcg, struct page *page) | |||
772 | unsigned long long excess; | 768 | unsigned long long excess; |
773 | struct mem_cgroup_per_zone *mz; | 769 | struct mem_cgroup_per_zone *mz; |
774 | struct mem_cgroup_tree_per_zone *mctz; | 770 | struct mem_cgroup_tree_per_zone *mctz; |
775 | int nid = page_to_nid(page); | ||
776 | int zid = page_zonenum(page); | ||
777 | mctz = soft_limit_tree_from_page(page); | ||
778 | 771 | ||
772 | mctz = soft_limit_tree_from_page(page); | ||
779 | /* | 773 | /* |
780 | * Necessary to update all ancestors when hierarchy is used. | 774 | * Necessary to update all ancestors when hierarchy is used. |
781 | * because their event counter is not touched. | 775 | * because their event counter is not touched. |
782 | */ | 776 | */ |
783 | for (; memcg; memcg = parent_mem_cgroup(memcg)) { | 777 | for (; memcg; memcg = parent_mem_cgroup(memcg)) { |
784 | mz = mem_cgroup_zoneinfo(memcg, nid, zid); | 778 | mz = mem_cgroup_page_zoneinfo(memcg, page); |
785 | excess = res_counter_soft_limit_excess(&memcg->res); | 779 | excess = res_counter_soft_limit_excess(&memcg->res); |
786 | /* | 780 | /* |
787 | * We have to update the tree if mz is on RB-tree or | 781 | * We have to update the tree if mz is on RB-tree or |
@@ -791,12 +785,12 @@ static void mem_cgroup_update_tree(struct mem_cgroup *memcg, struct page *page) | |||
791 | spin_lock(&mctz->lock); | 785 | spin_lock(&mctz->lock); |
792 | /* if on-tree, remove it */ | 786 | /* if on-tree, remove it */ |
793 | if (mz->on_tree) | 787 | if (mz->on_tree) |
794 | __mem_cgroup_remove_exceeded(memcg, mz, mctz); | 788 | __mem_cgroup_remove_exceeded(mz, mctz); |
795 | /* | 789 | /* |
796 | * Insert again. mz->usage_in_excess will be updated. | 790 | * Insert again. mz->usage_in_excess will be updated. |
797 | * If excess is 0, no tree ops. | 791 | * If excess is 0, no tree ops. |
798 | */ | 792 | */ |
799 | __mem_cgroup_insert_exceeded(memcg, mz, mctz, excess); | 793 | __mem_cgroup_insert_exceeded(mz, mctz, excess); |
800 | spin_unlock(&mctz->lock); | 794 | spin_unlock(&mctz->lock); |
801 | } | 795 | } |
802 | } | 796 | } |
@@ -804,15 +798,15 @@ static void mem_cgroup_update_tree(struct mem_cgroup *memcg, struct page *page) | |||
804 | 798 | ||
805 | static void mem_cgroup_remove_from_trees(struct mem_cgroup *memcg) | 799 | static void mem_cgroup_remove_from_trees(struct mem_cgroup *memcg) |
806 | { | 800 | { |
807 | int node, zone; | ||
808 | struct mem_cgroup_per_zone *mz; | ||
809 | struct mem_cgroup_tree_per_zone *mctz; | 801 | struct mem_cgroup_tree_per_zone *mctz; |
802 | struct mem_cgroup_per_zone *mz; | ||
803 | int nid, zid; | ||
810 | 804 | ||
811 | for_each_node(node) { | 805 | for_each_node(nid) { |
812 | for (zone = 0; zone < MAX_NR_ZONES; zone++) { | 806 | for (zid = 0; zid < MAX_NR_ZONES; zid++) { |
813 | mz = mem_cgroup_zoneinfo(memcg, node, zone); | 807 | mz = &memcg->nodeinfo[nid]->zoneinfo[zid]; |
814 | mctz = soft_limit_tree_node_zone(node, zone); | 808 | mctz = soft_limit_tree_node_zone(nid, zid); |
815 | mem_cgroup_remove_exceeded(memcg, mz, mctz); | 809 | mem_cgroup_remove_exceeded(mz, mctz); |
816 | } | 810 | } |
817 | } | 811 | } |
818 | } | 812 | } |
@@ -835,7 +829,7 @@ retry: | |||
835 | * we will to add it back at the end of reclaim to its correct | 829 | * we will to add it back at the end of reclaim to its correct |
836 | * position in the tree. | 830 | * position in the tree. |
837 | */ | 831 | */ |
838 | __mem_cgroup_remove_exceeded(mz->memcg, mz, mctz); | 832 | __mem_cgroup_remove_exceeded(mz, mctz); |
839 | if (!res_counter_soft_limit_excess(&mz->memcg->res) || | 833 | if (!res_counter_soft_limit_excess(&mz->memcg->res) || |
840 | !css_tryget(&mz->memcg->css)) | 834 | !css_tryget(&mz->memcg->css)) |
841 | goto retry; | 835 | goto retry; |
@@ -946,8 +940,7 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *memcg, | |||
946 | __this_cpu_add(memcg->stat->nr_page_events, nr_pages); | 940 | __this_cpu_add(memcg->stat->nr_page_events, nr_pages); |
947 | } | 941 | } |
948 | 942 | ||
949 | unsigned long | 943 | unsigned long mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list lru) |
950 | mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list lru) | ||
951 | { | 944 | { |
952 | struct mem_cgroup_per_zone *mz; | 945 | struct mem_cgroup_per_zone *mz; |
953 | 946 | ||
@@ -955,46 +948,38 @@ mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list lru) | |||
955 | return mz->lru_size[lru]; | 948 | return mz->lru_size[lru]; |
956 | } | 949 | } |
957 | 950 | ||
958 | static unsigned long | 951 | static unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg, |
959 | mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg, int nid, int zid, | 952 | int nid, |
960 | unsigned int lru_mask) | 953 | unsigned int lru_mask) |
961 | { | 954 | { |
962 | struct mem_cgroup_per_zone *mz; | 955 | unsigned long nr = 0; |
963 | enum lru_list lru; | ||
964 | unsigned long ret = 0; | ||
965 | |||
966 | mz = mem_cgroup_zoneinfo(memcg, nid, zid); | ||
967 | |||
968 | for_each_lru(lru) { | ||
969 | if (BIT(lru) & lru_mask) | ||
970 | ret += mz->lru_size[lru]; | ||
971 | } | ||
972 | return ret; | ||
973 | } | ||
974 | |||
975 | static unsigned long | ||
976 | mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg, | ||
977 | int nid, unsigned int lru_mask) | ||
978 | { | ||
979 | u64 total = 0; | ||
980 | int zid; | 956 | int zid; |
981 | 957 | ||
982 | for (zid = 0; zid < MAX_NR_ZONES; zid++) | 958 | VM_BUG_ON((unsigned)nid >= nr_node_ids); |
983 | total += mem_cgroup_zone_nr_lru_pages(memcg, | ||
984 | nid, zid, lru_mask); | ||
985 | 959 | ||
986 | return total; | 960 | for (zid = 0; zid < MAX_NR_ZONES; zid++) { |
961 | struct mem_cgroup_per_zone *mz; | ||
962 | enum lru_list lru; | ||
963 | |||
964 | for_each_lru(lru) { | ||
965 | if (!(BIT(lru) & lru_mask)) | ||
966 | continue; | ||
967 | mz = &memcg->nodeinfo[nid]->zoneinfo[zid]; | ||
968 | nr += mz->lru_size[lru]; | ||
969 | } | ||
970 | } | ||
971 | return nr; | ||
987 | } | 972 | } |
988 | 973 | ||
989 | static unsigned long mem_cgroup_nr_lru_pages(struct mem_cgroup *memcg, | 974 | static unsigned long mem_cgroup_nr_lru_pages(struct mem_cgroup *memcg, |
990 | unsigned int lru_mask) | 975 | unsigned int lru_mask) |
991 | { | 976 | { |
977 | unsigned long nr = 0; | ||
992 | int nid; | 978 | int nid; |
993 | u64 total = 0; | ||
994 | 979 | ||
995 | for_each_node_state(nid, N_MEMORY) | 980 | for_each_node_state(nid, N_MEMORY) |
996 | total += mem_cgroup_node_nr_lru_pages(memcg, nid, lru_mask); | 981 | nr += mem_cgroup_node_nr_lru_pages(memcg, nid, lru_mask); |
997 | return total; | 982 | return nr; |
998 | } | 983 | } |
999 | 984 | ||
1000 | static bool mem_cgroup_event_ratelimit(struct mem_cgroup *memcg, | 985 | static bool mem_cgroup_event_ratelimit(struct mem_cgroup *memcg, |
@@ -1242,11 +1227,9 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root, | |||
1242 | int uninitialized_var(seq); | 1227 | int uninitialized_var(seq); |
1243 | 1228 | ||
1244 | if (reclaim) { | 1229 | if (reclaim) { |
1245 | int nid = zone_to_nid(reclaim->zone); | ||
1246 | int zid = zone_idx(reclaim->zone); | ||
1247 | struct mem_cgroup_per_zone *mz; | 1230 | struct mem_cgroup_per_zone *mz; |
1248 | 1231 | ||
1249 | mz = mem_cgroup_zoneinfo(root, nid, zid); | 1232 | mz = mem_cgroup_zone_zoneinfo(root, reclaim->zone); |
1250 | iter = &mz->reclaim_iter[reclaim->priority]; | 1233 | iter = &mz->reclaim_iter[reclaim->priority]; |
1251 | if (prev && reclaim->generation != iter->generation) { | 1234 | if (prev && reclaim->generation != iter->generation) { |
1252 | iter->last_visited = NULL; | 1235 | iter->last_visited = NULL; |
@@ -1353,7 +1336,7 @@ struct lruvec *mem_cgroup_zone_lruvec(struct zone *zone, | |||
1353 | goto out; | 1336 | goto out; |
1354 | } | 1337 | } |
1355 | 1338 | ||
1356 | mz = mem_cgroup_zoneinfo(memcg, zone_to_nid(zone), zone_idx(zone)); | 1339 | mz = mem_cgroup_zone_zoneinfo(memcg, zone); |
1357 | lruvec = &mz->lruvec; | 1340 | lruvec = &mz->lruvec; |
1358 | out: | 1341 | out: |
1359 | /* | 1342 | /* |
@@ -1412,7 +1395,7 @@ struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct zone *zone) | |||
1412 | if (!PageLRU(page) && !PageCgroupUsed(pc) && memcg != root_mem_cgroup) | 1395 | if (!PageLRU(page) && !PageCgroupUsed(pc) && memcg != root_mem_cgroup) |
1413 | pc->mem_cgroup = memcg = root_mem_cgroup; | 1396 | pc->mem_cgroup = memcg = root_mem_cgroup; |
1414 | 1397 | ||
1415 | mz = page_cgroup_zoneinfo(memcg, page); | 1398 | mz = mem_cgroup_page_zoneinfo(memcg, page); |
1416 | lruvec = &mz->lruvec; | 1399 | lruvec = &mz->lruvec; |
1417 | out: | 1400 | out: |
1418 | /* | 1401 | /* |
@@ -1550,7 +1533,7 @@ static unsigned long mem_cgroup_margin(struct mem_cgroup *memcg) | |||
1550 | int mem_cgroup_swappiness(struct mem_cgroup *memcg) | 1533 | int mem_cgroup_swappiness(struct mem_cgroup *memcg) |
1551 | { | 1534 | { |
1552 | /* root ? */ | 1535 | /* root ? */ |
1553 | if (!css_parent(&memcg->css)) | 1536 | if (mem_cgroup_disabled() || !css_parent(&memcg->css)) |
1554 | return vm_swappiness; | 1537 | return vm_swappiness; |
1555 | 1538 | ||
1556 | return memcg->swappiness; | 1539 | return memcg->swappiness; |
@@ -4597,7 +4580,7 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, | |||
4597 | break; | 4580 | break; |
4598 | } while (1); | 4581 | } while (1); |
4599 | } | 4582 | } |
4600 | __mem_cgroup_remove_exceeded(mz->memcg, mz, mctz); | 4583 | __mem_cgroup_remove_exceeded(mz, mctz); |
4601 | excess = res_counter_soft_limit_excess(&mz->memcg->res); | 4584 | excess = res_counter_soft_limit_excess(&mz->memcg->res); |
4602 | /* | 4585 | /* |
4603 | * One school of thought says that we should not add | 4586 | * One school of thought says that we should not add |
@@ -4608,7 +4591,7 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, | |||
4608 | * term TODO. | 4591 | * term TODO. |
4609 | */ | 4592 | */ |
4610 | /* If excess == 0, no tree ops */ | 4593 | /* If excess == 0, no tree ops */ |
4611 | __mem_cgroup_insert_exceeded(mz->memcg, mz, mctz, excess); | 4594 | __mem_cgroup_insert_exceeded(mz, mctz, excess); |
4612 | spin_unlock(&mctz->lock); | 4595 | spin_unlock(&mctz->lock); |
4613 | css_put(&mz->memcg->css); | 4596 | css_put(&mz->memcg->css); |
4614 | loop++; | 4597 | loop++; |
@@ -5305,7 +5288,7 @@ static int memcg_stat_show(struct seq_file *m, void *v) | |||
5305 | 5288 | ||
5306 | for_each_online_node(nid) | 5289 | for_each_online_node(nid) |
5307 | for (zid = 0; zid < MAX_NR_ZONES; zid++) { | 5290 | for (zid = 0; zid < MAX_NR_ZONES; zid++) { |
5308 | mz = mem_cgroup_zoneinfo(memcg, nid, zid); | 5291 | mz = &memcg->nodeinfo[nid]->zoneinfo[zid]; |
5309 | rstat = &mz->lruvec.reclaim_stat; | 5292 | rstat = &mz->lruvec.reclaim_stat; |
5310 | 5293 | ||
5311 | recent_rotated[0] += rstat->recent_rotated[0]; | 5294 | recent_rotated[0] += rstat->recent_rotated[0]; |
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 16bc9fa42998..1c16c228f35a 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
@@ -65,6 +65,8 @@ | |||
65 | kernel is not always grateful with that. | 65 | kernel is not always grateful with that. |
66 | */ | 66 | */ |
67 | 67 | ||
68 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
69 | |||
68 | #include <linux/mempolicy.h> | 70 | #include <linux/mempolicy.h> |
69 | #include <linux/mm.h> | 71 | #include <linux/mm.h> |
70 | #include <linux/highmem.h> | 72 | #include <linux/highmem.h> |
@@ -91,6 +93,7 @@ | |||
91 | #include <linux/ctype.h> | 93 | #include <linux/ctype.h> |
92 | #include <linux/mm_inline.h> | 94 | #include <linux/mm_inline.h> |
93 | #include <linux/mmu_notifier.h> | 95 | #include <linux/mmu_notifier.h> |
96 | #include <linux/printk.h> | ||
94 | 97 | ||
95 | #include <asm/tlbflush.h> | 98 | #include <asm/tlbflush.h> |
96 | #include <asm/uaccess.h> | 99 | #include <asm/uaccess.h> |
@@ -2645,7 +2648,7 @@ void __init numa_policy_init(void) | |||
2645 | node_set(prefer, interleave_nodes); | 2648 | node_set(prefer, interleave_nodes); |
2646 | 2649 | ||
2647 | if (do_set_mempolicy(MPOL_INTERLEAVE, 0, &interleave_nodes)) | 2650 | if (do_set_mempolicy(MPOL_INTERLEAVE, 0, &interleave_nodes)) |
2648 | printk("numa_policy_init: interleaving failed\n"); | 2651 | pr_err("%s: interleaving failed\n", __func__); |
2649 | 2652 | ||
2650 | check_numabalancing_enable(); | 2653 | check_numabalancing_enable(); |
2651 | } | 2654 | } |
diff --git a/mm/mempool.c b/mm/mempool.c index 455d468c3a5d..e209c98c7203 100644 --- a/mm/mempool.c +++ b/mm/mempool.c | |||
@@ -10,6 +10,7 @@ | |||
10 | 10 | ||
11 | #include <linux/mm.h> | 11 | #include <linux/mm.h> |
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <linux/kmemleak.h> | ||
13 | #include <linux/export.h> | 14 | #include <linux/export.h> |
14 | #include <linux/mempool.h> | 15 | #include <linux/mempool.h> |
15 | #include <linux/blkdev.h> | 16 | #include <linux/blkdev.h> |
@@ -222,6 +223,11 @@ repeat_alloc: | |||
222 | spin_unlock_irqrestore(&pool->lock, flags); | 223 | spin_unlock_irqrestore(&pool->lock, flags); |
223 | /* paired with rmb in mempool_free(), read comment there */ | 224 | /* paired with rmb in mempool_free(), read comment there */ |
224 | smp_wmb(); | 225 | smp_wmb(); |
226 | /* | ||
227 | * Update the allocation stack trace as this is more useful | ||
228 | * for debugging. | ||
229 | */ | ||
230 | kmemleak_update_trace(element); | ||
225 | return element; | 231 | return element; |
226 | } | 232 | } |
227 | 233 | ||
@@ -6,6 +6,8 @@ | |||
6 | * Address space accounting code <alan@lxorguk.ukuu.org.uk> | 6 | * Address space accounting code <alan@lxorguk.ukuu.org.uk> |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
10 | |||
9 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
10 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
11 | #include <linux/backing-dev.h> | 13 | #include <linux/backing-dev.h> |
@@ -37,6 +39,7 @@ | |||
37 | #include <linux/sched/sysctl.h> | 39 | #include <linux/sched/sysctl.h> |
38 | #include <linux/notifier.h> | 40 | #include <linux/notifier.h> |
39 | #include <linux/memory.h> | 41 | #include <linux/memory.h> |
42 | #include <linux/printk.h> | ||
40 | 43 | ||
41 | #include <asm/uaccess.h> | 44 | #include <asm/uaccess.h> |
42 | #include <asm/cacheflush.h> | 45 | #include <asm/cacheflush.h> |
@@ -361,20 +364,20 @@ static int browse_rb(struct rb_root *root) | |||
361 | struct vm_area_struct *vma; | 364 | struct vm_area_struct *vma; |
362 | vma = rb_entry(nd, struct vm_area_struct, vm_rb); | 365 | vma = rb_entry(nd, struct vm_area_struct, vm_rb); |
363 | if (vma->vm_start < prev) { | 366 | if (vma->vm_start < prev) { |
364 | printk("vm_start %lx prev %lx\n", vma->vm_start, prev); | 367 | pr_info("vm_start %lx prev %lx\n", vma->vm_start, prev); |
365 | bug = 1; | 368 | bug = 1; |
366 | } | 369 | } |
367 | if (vma->vm_start < pend) { | 370 | if (vma->vm_start < pend) { |
368 | printk("vm_start %lx pend %lx\n", vma->vm_start, pend); | 371 | pr_info("vm_start %lx pend %lx\n", vma->vm_start, pend); |
369 | bug = 1; | 372 | bug = 1; |
370 | } | 373 | } |
371 | if (vma->vm_start > vma->vm_end) { | 374 | if (vma->vm_start > vma->vm_end) { |
372 | printk("vm_end %lx < vm_start %lx\n", | 375 | pr_info("vm_end %lx < vm_start %lx\n", |
373 | vma->vm_end, vma->vm_start); | 376 | vma->vm_end, vma->vm_start); |
374 | bug = 1; | 377 | bug = 1; |
375 | } | 378 | } |
376 | if (vma->rb_subtree_gap != vma_compute_subtree_gap(vma)) { | 379 | if (vma->rb_subtree_gap != vma_compute_subtree_gap(vma)) { |
377 | printk("free gap %lx, correct %lx\n", | 380 | pr_info("free gap %lx, correct %lx\n", |
378 | vma->rb_subtree_gap, | 381 | vma->rb_subtree_gap, |
379 | vma_compute_subtree_gap(vma)); | 382 | vma_compute_subtree_gap(vma)); |
380 | bug = 1; | 383 | bug = 1; |
@@ -388,7 +391,7 @@ static int browse_rb(struct rb_root *root) | |||
388 | for (nd = pn; nd; nd = rb_prev(nd)) | 391 | for (nd = pn; nd; nd = rb_prev(nd)) |
389 | j++; | 392 | j++; |
390 | if (i != j) { | 393 | if (i != j) { |
391 | printk("backwards %d, forwards %d\n", j, i); | 394 | pr_info("backwards %d, forwards %d\n", j, i); |
392 | bug = 1; | 395 | bug = 1; |
393 | } | 396 | } |
394 | return bug ? -1 : i; | 397 | return bug ? -1 : i; |
@@ -423,17 +426,17 @@ static void validate_mm(struct mm_struct *mm) | |||
423 | i++; | 426 | i++; |
424 | } | 427 | } |
425 | if (i != mm->map_count) { | 428 | if (i != mm->map_count) { |
426 | printk("map_count %d vm_next %d\n", mm->map_count, i); | 429 | pr_info("map_count %d vm_next %d\n", mm->map_count, i); |
427 | bug = 1; | 430 | bug = 1; |
428 | } | 431 | } |
429 | if (highest_address != mm->highest_vm_end) { | 432 | if (highest_address != mm->highest_vm_end) { |
430 | printk("mm->highest_vm_end %lx, found %lx\n", | 433 | pr_info("mm->highest_vm_end %lx, found %lx\n", |
431 | mm->highest_vm_end, highest_address); | 434 | mm->highest_vm_end, highest_address); |
432 | bug = 1; | 435 | bug = 1; |
433 | } | 436 | } |
434 | i = browse_rb(&mm->mm_rb); | 437 | i = browse_rb(&mm->mm_rb); |
435 | if (i != mm->map_count) { | 438 | if (i != mm->map_count) { |
436 | printk("map_count %d rb %d\n", mm->map_count, i); | 439 | pr_info("map_count %d rb %d\n", mm->map_count, i); |
437 | bug = 1; | 440 | bug = 1; |
438 | } | 441 | } |
439 | BUG_ON(bug); | 442 | BUG_ON(bug); |
@@ -3280,7 +3283,7 @@ static struct notifier_block reserve_mem_nb = { | |||
3280 | static int __meminit init_reserve_notifier(void) | 3283 | static int __meminit init_reserve_notifier(void) |
3281 | { | 3284 | { |
3282 | if (register_hotmemory_notifier(&reserve_mem_nb)) | 3285 | if (register_hotmemory_notifier(&reserve_mem_nb)) |
3283 | printk("Failed registering memory add/remove notifier for admin reserve"); | 3286 | pr_err("Failed registering memory add/remove notifier for admin reserve\n"); |
3284 | 3287 | ||
3285 | return 0; | 3288 | return 0; |
3286 | } | 3289 | } |
diff --git a/mm/nobootmem.c b/mm/nobootmem.c index 04a9d94333a5..7ed58602e71b 100644 --- a/mm/nobootmem.c +++ b/mm/nobootmem.c | |||
@@ -197,7 +197,6 @@ unsigned long __init free_all_bootmem(void) | |||
197 | void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr, | 197 | void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr, |
198 | unsigned long size) | 198 | unsigned long size) |
199 | { | 199 | { |
200 | kmemleak_free_part(__va(physaddr), size); | ||
201 | memblock_free(physaddr, size); | 200 | memblock_free(physaddr, size); |
202 | } | 201 | } |
203 | 202 | ||
@@ -212,7 +211,6 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr, | |||
212 | */ | 211 | */ |
213 | void __init free_bootmem(unsigned long addr, unsigned long size) | 212 | void __init free_bootmem(unsigned long addr, unsigned long size) |
214 | { | 213 | { |
215 | kmemleak_free_part(__va(addr), size); | ||
216 | memblock_free(addr, size); | 214 | memblock_free(addr, size); |
217 | } | 215 | } |
218 | 216 | ||
diff --git a/mm/nommu.c b/mm/nommu.c index 85f8d6698d48..b78e3a8f5ee7 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -13,6 +13,8 @@ | |||
13 | * Copyright (c) 2007-2010 Paul Mundt <lethal@linux-sh.org> | 13 | * Copyright (c) 2007-2010 Paul Mundt <lethal@linux-sh.org> |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
17 | |||
16 | #include <linux/export.h> | 18 | #include <linux/export.h> |
17 | #include <linux/mm.h> | 19 | #include <linux/mm.h> |
18 | #include <linux/vmacache.h> | 20 | #include <linux/vmacache.h> |
@@ -32,6 +34,7 @@ | |||
32 | #include <linux/syscalls.h> | 34 | #include <linux/syscalls.h> |
33 | #include <linux/audit.h> | 35 | #include <linux/audit.h> |
34 | #include <linux/sched/sysctl.h> | 36 | #include <linux/sched/sysctl.h> |
37 | #include <linux/printk.h> | ||
35 | 38 | ||
36 | #include <asm/uaccess.h> | 39 | #include <asm/uaccess.h> |
37 | #include <asm/tlb.h> | 40 | #include <asm/tlb.h> |
@@ -1246,7 +1249,7 @@ error_free: | |||
1246 | return ret; | 1249 | return ret; |
1247 | 1250 | ||
1248 | enomem: | 1251 | enomem: |
1249 | printk("Allocation of length %lu from process %d (%s) failed\n", | 1252 | pr_err("Allocation of length %lu from process %d (%s) failed\n", |
1250 | len, current->pid, current->comm); | 1253 | len, current->pid, current->comm); |
1251 | show_free_areas(0); | 1254 | show_free_areas(0); |
1252 | return -ENOMEM; | 1255 | return -ENOMEM; |
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 533fa60c9ac1..7d9a4ef0a078 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
@@ -1664,7 +1664,7 @@ void throttle_vm_writeout(gfp_t gfp_mask) | |||
1664 | /* | 1664 | /* |
1665 | * sysctl handler for /proc/sys/vm/dirty_writeback_centisecs | 1665 | * sysctl handler for /proc/sys/vm/dirty_writeback_centisecs |
1666 | */ | 1666 | */ |
1667 | int dirty_writeback_centisecs_handler(ctl_table *table, int write, | 1667 | int dirty_writeback_centisecs_handler(struct ctl_table *table, int write, |
1668 | void __user *buffer, size_t *length, loff_t *ppos) | 1668 | void __user *buffer, size_t *length, loff_t *ppos) |
1669 | { | 1669 | { |
1670 | proc_dointvec(table, write, buffer, length, ppos); | 1670 | proc_dointvec(table, write, buffer, length, ppos); |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a59bdb653958..4f59fa29eda8 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -3389,7 +3389,7 @@ early_param("numa_zonelist_order", setup_numa_zonelist_order); | |||
3389 | /* | 3389 | /* |
3390 | * sysctl handler for numa_zonelist_order | 3390 | * sysctl handler for numa_zonelist_order |
3391 | */ | 3391 | */ |
3392 | int numa_zonelist_order_handler(ctl_table *table, int write, | 3392 | int numa_zonelist_order_handler(struct ctl_table *table, int write, |
3393 | void __user *buffer, size_t *length, | 3393 | void __user *buffer, size_t *length, |
3394 | loff_t *ppos) | 3394 | loff_t *ppos) |
3395 | { | 3395 | { |
@@ -5805,7 +5805,7 @@ module_init(init_per_zone_wmark_min) | |||
5805 | * that we can call two helper functions whenever min_free_kbytes | 5805 | * that we can call two helper functions whenever min_free_kbytes |
5806 | * changes. | 5806 | * changes. |
5807 | */ | 5807 | */ |
5808 | int min_free_kbytes_sysctl_handler(ctl_table *table, int write, | 5808 | int min_free_kbytes_sysctl_handler(struct ctl_table *table, int write, |
5809 | void __user *buffer, size_t *length, loff_t *ppos) | 5809 | void __user *buffer, size_t *length, loff_t *ppos) |
5810 | { | 5810 | { |
5811 | int rc; | 5811 | int rc; |
@@ -5822,7 +5822,7 @@ int min_free_kbytes_sysctl_handler(ctl_table *table, int write, | |||
5822 | } | 5822 | } |
5823 | 5823 | ||
5824 | #ifdef CONFIG_NUMA | 5824 | #ifdef CONFIG_NUMA |
5825 | int sysctl_min_unmapped_ratio_sysctl_handler(ctl_table *table, int write, | 5825 | int sysctl_min_unmapped_ratio_sysctl_handler(struct ctl_table *table, int write, |
5826 | void __user *buffer, size_t *length, loff_t *ppos) | 5826 | void __user *buffer, size_t *length, loff_t *ppos) |
5827 | { | 5827 | { |
5828 | struct zone *zone; | 5828 | struct zone *zone; |
@@ -5838,7 +5838,7 @@ int sysctl_min_unmapped_ratio_sysctl_handler(ctl_table *table, int write, | |||
5838 | return 0; | 5838 | return 0; |
5839 | } | 5839 | } |
5840 | 5840 | ||
5841 | int sysctl_min_slab_ratio_sysctl_handler(ctl_table *table, int write, | 5841 | int sysctl_min_slab_ratio_sysctl_handler(struct ctl_table *table, int write, |
5842 | void __user *buffer, size_t *length, loff_t *ppos) | 5842 | void __user *buffer, size_t *length, loff_t *ppos) |
5843 | { | 5843 | { |
5844 | struct zone *zone; | 5844 | struct zone *zone; |
@@ -5864,7 +5864,7 @@ int sysctl_min_slab_ratio_sysctl_handler(ctl_table *table, int write, | |||
5864 | * minimum watermarks. The lowmem reserve ratio can only make sense | 5864 | * minimum watermarks. The lowmem reserve ratio can only make sense |
5865 | * if in function of the boot time zone sizes. | 5865 | * if in function of the boot time zone sizes. |
5866 | */ | 5866 | */ |
5867 | int lowmem_reserve_ratio_sysctl_handler(ctl_table *table, int write, | 5867 | int lowmem_reserve_ratio_sysctl_handler(struct ctl_table *table, int write, |
5868 | void __user *buffer, size_t *length, loff_t *ppos) | 5868 | void __user *buffer, size_t *length, loff_t *ppos) |
5869 | { | 5869 | { |
5870 | proc_dointvec_minmax(table, write, buffer, length, ppos); | 5870 | proc_dointvec_minmax(table, write, buffer, length, ppos); |
@@ -5877,7 +5877,7 @@ int lowmem_reserve_ratio_sysctl_handler(ctl_table *table, int write, | |||
5877 | * cpu. It is the fraction of total pages in each zone that a hot per cpu | 5877 | * cpu. It is the fraction of total pages in each zone that a hot per cpu |
5878 | * pagelist can have before it gets flushed back to buddy allocator. | 5878 | * pagelist can have before it gets flushed back to buddy allocator. |
5879 | */ | 5879 | */ |
5880 | int percpu_pagelist_fraction_sysctl_handler(ctl_table *table, int write, | 5880 | int percpu_pagelist_fraction_sysctl_handler(struct ctl_table *table, int write, |
5881 | void __user *buffer, size_t *length, loff_t *ppos) | 5881 | void __user *buffer, size_t *length, loff_t *ppos) |
5882 | { | 5882 | { |
5883 | struct zone *zone; | 5883 | struct zone *zone; |
@@ -1726,7 +1726,7 @@ static void *get_partial(struct kmem_cache *s, gfp_t flags, int node, | |||
1726 | struct kmem_cache_cpu *c) | 1726 | struct kmem_cache_cpu *c) |
1727 | { | 1727 | { |
1728 | void *object; | 1728 | void *object; |
1729 | int searchnode = (node == NUMA_NO_NODE) ? numa_node_id() : node; | 1729 | int searchnode = (node == NUMA_NO_NODE) ? numa_mem_id() : node; |
1730 | 1730 | ||
1731 | object = get_partial_node(s, get_node(s, searchnode), c, flags); | 1731 | object = get_partial_node(s, get_node(s, searchnode), c, flags); |
1732 | if (object || node != NUMA_NO_NODE) | 1732 | if (object || node != NUMA_NO_NODE) |
diff --git a/mm/vmscan.c b/mm/vmscan.c index 9149444f947d..71f23c0c1090 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -11,6 +11,8 @@ | |||
11 | * Multiqueue VM started 5.8.00, Rik van Riel. | 11 | * Multiqueue VM started 5.8.00, Rik van Riel. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
15 | |||
14 | #include <linux/mm.h> | 16 | #include <linux/mm.h> |
15 | #include <linux/module.h> | 17 | #include <linux/module.h> |
16 | #include <linux/gfp.h> | 18 | #include <linux/gfp.h> |
@@ -43,6 +45,7 @@ | |||
43 | #include <linux/sysctl.h> | 45 | #include <linux/sysctl.h> |
44 | #include <linux/oom.h> | 46 | #include <linux/oom.h> |
45 | #include <linux/prefetch.h> | 47 | #include <linux/prefetch.h> |
48 | #include <linux/printk.h> | ||
46 | 49 | ||
47 | #include <asm/tlbflush.h> | 50 | #include <asm/tlbflush.h> |
48 | #include <asm/div64.h> | 51 | #include <asm/div64.h> |
@@ -83,6 +86,9 @@ struct scan_control { | |||
83 | /* Scan (total_size >> priority) pages at once */ | 86 | /* Scan (total_size >> priority) pages at once */ |
84 | int priority; | 87 | int priority; |
85 | 88 | ||
89 | /* anon vs. file LRUs scanning "ratio" */ | ||
90 | int swappiness; | ||
91 | |||
86 | /* | 92 | /* |
87 | * The memory cgroup that hit its limit and as a result is the | 93 | * The memory cgroup that hit its limit and as a result is the |
88 | * primary target of this reclaim invocation. | 94 | * primary target of this reclaim invocation. |
@@ -477,7 +483,7 @@ static pageout_t pageout(struct page *page, struct address_space *mapping, | |||
477 | if (page_has_private(page)) { | 483 | if (page_has_private(page)) { |
478 | if (try_to_free_buffers(page)) { | 484 | if (try_to_free_buffers(page)) { |
479 | ClearPageDirty(page); | 485 | ClearPageDirty(page); |
480 | printk("%s: orphaned page\n", __func__); | 486 | pr_info("%s: orphaned page\n", __func__); |
481 | return PAGE_CLEAN; | 487 | return PAGE_CLEAN; |
482 | } | 488 | } |
483 | } | 489 | } |
@@ -1845,13 +1851,6 @@ static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan, | |||
1845 | return shrink_inactive_list(nr_to_scan, lruvec, sc, lru); | 1851 | return shrink_inactive_list(nr_to_scan, lruvec, sc, lru); |
1846 | } | 1852 | } |
1847 | 1853 | ||
1848 | static int vmscan_swappiness(struct scan_control *sc) | ||
1849 | { | ||
1850 | if (global_reclaim(sc)) | ||
1851 | return vm_swappiness; | ||
1852 | return mem_cgroup_swappiness(sc->target_mem_cgroup); | ||
1853 | } | ||
1854 | |||
1855 | enum scan_balance { | 1854 | enum scan_balance { |
1856 | SCAN_EQUAL, | 1855 | SCAN_EQUAL, |
1857 | SCAN_FRACT, | 1856 | SCAN_FRACT, |
@@ -1912,7 +1911,7 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, | |||
1912 | * using the memory controller's swap limit feature would be | 1911 | * using the memory controller's swap limit feature would be |
1913 | * too expensive. | 1912 | * too expensive. |
1914 | */ | 1913 | */ |
1915 | if (!global_reclaim(sc) && !vmscan_swappiness(sc)) { | 1914 | if (!global_reclaim(sc) && !sc->swappiness) { |
1916 | scan_balance = SCAN_FILE; | 1915 | scan_balance = SCAN_FILE; |
1917 | goto out; | 1916 | goto out; |
1918 | } | 1917 | } |
@@ -1922,7 +1921,7 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, | |||
1922 | * system is close to OOM, scan both anon and file equally | 1921 | * system is close to OOM, scan both anon and file equally |
1923 | * (unless the swappiness setting disagrees with swapping). | 1922 | * (unless the swappiness setting disagrees with swapping). |
1924 | */ | 1923 | */ |
1925 | if (!sc->priority && vmscan_swappiness(sc)) { | 1924 | if (!sc->priority && sc->swappiness) { |
1926 | scan_balance = SCAN_EQUAL; | 1925 | scan_balance = SCAN_EQUAL; |
1927 | goto out; | 1926 | goto out; |
1928 | } | 1927 | } |
@@ -1965,7 +1964,7 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, | |||
1965 | * With swappiness at 100, anonymous and file have the same priority. | 1964 | * With swappiness at 100, anonymous and file have the same priority. |
1966 | * This scanning priority is essentially the inverse of IO cost. | 1965 | * This scanning priority is essentially the inverse of IO cost. |
1967 | */ | 1966 | */ |
1968 | anon_prio = vmscan_swappiness(sc); | 1967 | anon_prio = sc->swappiness; |
1969 | file_prio = 200 - anon_prio; | 1968 | file_prio = 200 - anon_prio; |
1970 | 1969 | ||
1971 | /* | 1970 | /* |
@@ -2265,6 +2264,7 @@ static void shrink_zone(struct zone *zone, struct scan_control *sc) | |||
2265 | 2264 | ||
2266 | lruvec = mem_cgroup_zone_lruvec(zone, memcg); | 2265 | lruvec = mem_cgroup_zone_lruvec(zone, memcg); |
2267 | 2266 | ||
2267 | sc->swappiness = mem_cgroup_swappiness(memcg); | ||
2268 | shrink_lruvec(lruvec, sc); | 2268 | shrink_lruvec(lruvec, sc); |
2269 | 2269 | ||
2270 | /* | 2270 | /* |
@@ -2731,6 +2731,7 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *memcg, | |||
2731 | .may_swap = !noswap, | 2731 | .may_swap = !noswap, |
2732 | .order = 0, | 2732 | .order = 0, |
2733 | .priority = 0, | 2733 | .priority = 0, |
2734 | .swappiness = mem_cgroup_swappiness(memcg), | ||
2734 | .target_mem_cgroup = memcg, | 2735 | .target_mem_cgroup = memcg, |
2735 | }; | 2736 | }; |
2736 | struct lruvec *lruvec = mem_cgroup_zone_lruvec(zone, memcg); | 2737 | struct lruvec *lruvec = mem_cgroup_zone_lruvec(zone, memcg); |
@@ -3372,7 +3373,10 @@ static int kswapd(void *p) | |||
3372 | } | 3373 | } |
3373 | } | 3374 | } |
3374 | 3375 | ||
3376 | tsk->flags &= ~(PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD); | ||
3375 | current->reclaim_state = NULL; | 3377 | current->reclaim_state = NULL; |
3378 | lockdep_clear_current_reclaim_state(); | ||
3379 | |||
3376 | return 0; | 3380 | return 0; |
3377 | } | 3381 | } |
3378 | 3382 | ||
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 32487ed18354..e66e710cc595 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile | |||
@@ -10,6 +10,7 @@ TARGETS += timers | |||
10 | TARGETS += vm | 10 | TARGETS += vm |
11 | TARGETS += powerpc | 11 | TARGETS += powerpc |
12 | TARGETS += user | 12 | TARGETS += user |
13 | TARGETS += sysctl | ||
13 | 14 | ||
14 | all: | 15 | all: |
15 | for TARGET in $(TARGETS); do \ | 16 | for TARGET in $(TARGETS); do \ |
diff --git a/tools/testing/selftests/sysctl/Makefile b/tools/testing/selftests/sysctl/Makefile new file mode 100644 index 000000000000..0a92adaf0865 --- /dev/null +++ b/tools/testing/selftests/sysctl/Makefile | |||
@@ -0,0 +1,19 @@ | |||
1 | # Makefile for sysctl selftests. | ||
2 | # Expects kernel.sysctl_writes_strict=1. | ||
3 | |||
4 | # No binaries, but make sure arg-less "make" doesn't trigger "run_tests". | ||
5 | all: | ||
6 | |||
7 | # Allow specific tests to be selected. | ||
8 | test_num: | ||
9 | @/bin/sh ./run_numerictests | ||
10 | |||
11 | test_string: | ||
12 | @/bin/sh ./run_stringtests | ||
13 | |||
14 | run_tests: all test_num test_string | ||
15 | |||
16 | # Nothing to clean up. | ||
17 | clean: | ||
18 | |||
19 | .PHONY: all run_tests clean test_num test_string | ||
diff --git a/tools/testing/selftests/sysctl/common_tests b/tools/testing/selftests/sysctl/common_tests new file mode 100644 index 000000000000..17d534b1b7b4 --- /dev/null +++ b/tools/testing/selftests/sysctl/common_tests | |||
@@ -0,0 +1,109 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | TEST_FILE=$(mktemp) | ||
4 | |||
5 | echo "== Testing sysctl behavior against ${TARGET} ==" | ||
6 | |||
7 | set_orig() | ||
8 | { | ||
9 | echo "${ORIG}" > "${TARGET}" | ||
10 | } | ||
11 | |||
12 | set_test() | ||
13 | { | ||
14 | echo "${TEST_STR}" > "${TARGET}" | ||
15 | } | ||
16 | |||
17 | verify() | ||
18 | { | ||
19 | local seen | ||
20 | seen=$(cat "$1") | ||
21 | if [ "${seen}" != "${TEST_STR}" ]; then | ||
22 | return 1 | ||
23 | fi | ||
24 | return 0 | ||
25 | } | ||
26 | |||
27 | trap 'set_orig; rm -f "${TEST_FILE}"' EXIT | ||
28 | |||
29 | rc=0 | ||
30 | |||
31 | echo -n "Writing test file ... " | ||
32 | echo "${TEST_STR}" > "${TEST_FILE}" | ||
33 | if ! verify "${TEST_FILE}"; then | ||
34 | echo "FAIL" >&2 | ||
35 | exit 1 | ||
36 | else | ||
37 | echo "ok" | ||
38 | fi | ||
39 | |||
40 | echo -n "Checking sysctl is not set to test value ... " | ||
41 | if verify "${TARGET}"; then | ||
42 | echo "FAIL" >&2 | ||
43 | exit 1 | ||
44 | else | ||
45 | echo "ok" | ||
46 | fi | ||
47 | |||
48 | echo -n "Writing sysctl from shell ... " | ||
49 | set_test | ||
50 | if ! verify "${TARGET}"; then | ||
51 | echo "FAIL" >&2 | ||
52 | exit 1 | ||
53 | else | ||
54 | echo "ok" | ||
55 | fi | ||
56 | |||
57 | echo -n "Resetting sysctl to original value ... " | ||
58 | set_orig | ||
59 | if verify "${TARGET}"; then | ||
60 | echo "FAIL" >&2 | ||
61 | exit 1 | ||
62 | else | ||
63 | echo "ok" | ||
64 | fi | ||
65 | |||
66 | # Now that we've validated the sanity of "set_test" and "set_orig", | ||
67 | # we can use those functions to set starting states before running | ||
68 | # specific behavioral tests. | ||
69 | |||
70 | echo -n "Writing entire sysctl in single write ... " | ||
71 | set_orig | ||
72 | dd if="${TEST_FILE}" of="${TARGET}" bs=4096 2>/dev/null | ||
73 | if ! verify "${TARGET}"; then | ||
74 | echo "FAIL" >&2 | ||
75 | rc=1 | ||
76 | else | ||
77 | echo "ok" | ||
78 | fi | ||
79 | |||
80 | echo -n "Writing middle of sysctl after synchronized seek ... " | ||
81 | set_test | ||
82 | dd if="${TEST_FILE}" of="${TARGET}" bs=1 seek=1 skip=1 2>/dev/null | ||
83 | if ! verify "${TARGET}"; then | ||
84 | echo "FAIL" >&2 | ||
85 | rc=1 | ||
86 | else | ||
87 | echo "ok" | ||
88 | fi | ||
89 | |||
90 | echo -n "Writing beyond end of sysctl ... " | ||
91 | set_orig | ||
92 | dd if="${TEST_FILE}" of="${TARGET}" bs=20 seek=2 2>/dev/null | ||
93 | if verify "${TARGET}"; then | ||
94 | echo "FAIL" >&2 | ||
95 | rc=1 | ||
96 | else | ||
97 | echo "ok" | ||
98 | fi | ||
99 | |||
100 | echo -n "Writing sysctl with multiple long writes ... " | ||
101 | set_orig | ||
102 | (perl -e 'print "A" x 50;'; echo "${TEST_STR}") | \ | ||
103 | dd of="${TARGET}" bs=50 2>/dev/null | ||
104 | if verify "${TARGET}"; then | ||
105 | echo "FAIL" >&2 | ||
106 | rc=1 | ||
107 | else | ||
108 | echo "ok" | ||
109 | fi | ||
diff --git a/tools/testing/selftests/sysctl/run_numerictests b/tools/testing/selftests/sysctl/run_numerictests new file mode 100644 index 000000000000..8510f93f2d14 --- /dev/null +++ b/tools/testing/selftests/sysctl/run_numerictests | |||
@@ -0,0 +1,10 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | SYSCTL="/proc/sys" | ||
4 | TARGET="${SYSCTL}/vm/swappiness" | ||
5 | ORIG=$(cat "${TARGET}") | ||
6 | TEST_STR=$(( $ORIG + 1 )) | ||
7 | |||
8 | . ./common_tests | ||
9 | |||
10 | exit $rc | ||
diff --git a/tools/testing/selftests/sysctl/run_stringtests b/tools/testing/selftests/sysctl/run_stringtests new file mode 100644 index 000000000000..90a9293d520c --- /dev/null +++ b/tools/testing/selftests/sysctl/run_stringtests | |||
@@ -0,0 +1,77 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | SYSCTL="/proc/sys" | ||
4 | TARGET="${SYSCTL}/kernel/domainname" | ||
5 | ORIG=$(cat "${TARGET}") | ||
6 | TEST_STR="Testing sysctl" | ||
7 | |||
8 | . ./common_tests | ||
9 | |||
10 | # Only string sysctls support seeking/appending. | ||
11 | MAXLEN=65 | ||
12 | |||
13 | echo -n "Writing entire sysctl in short writes ... " | ||
14 | set_orig | ||
15 | dd if="${TEST_FILE}" of="${TARGET}" bs=1 2>/dev/null | ||
16 | if ! verify "${TARGET}"; then | ||
17 | echo "FAIL" >&2 | ||
18 | rc=1 | ||
19 | else | ||
20 | echo "ok" | ||
21 | fi | ||
22 | |||
23 | echo -n "Writing middle of sysctl after unsynchronized seek ... " | ||
24 | set_test | ||
25 | dd if="${TEST_FILE}" of="${TARGET}" bs=1 seek=1 2>/dev/null | ||
26 | if verify "${TARGET}"; then | ||
27 | echo "FAIL" >&2 | ||
28 | rc=1 | ||
29 | else | ||
30 | echo "ok" | ||
31 | fi | ||
32 | |||
33 | echo -n "Checking sysctl maxlen is at least $MAXLEN ... " | ||
34 | set_orig | ||
35 | perl -e 'print "A" x ('"${MAXLEN}"'-2), "B";' | \ | ||
36 | dd of="${TARGET}" bs="${MAXLEN}" 2>/dev/null | ||
37 | if ! grep -q B "${TARGET}"; then | ||
38 | echo "FAIL" >&2 | ||
39 | rc=1 | ||
40 | else | ||
41 | echo "ok" | ||
42 | fi | ||
43 | |||
44 | echo -n "Checking sysctl keeps original string on overflow append ... " | ||
45 | set_orig | ||
46 | perl -e 'print "A" x ('"${MAXLEN}"'-1), "B";' | \ | ||
47 | dd of="${TARGET}" bs=$(( MAXLEN - 1 )) 2>/dev/null | ||
48 | if grep -q B "${TARGET}"; then | ||
49 | echo "FAIL" >&2 | ||
50 | rc=1 | ||
51 | else | ||
52 | echo "ok" | ||
53 | fi | ||
54 | |||
55 | echo -n "Checking sysctl stays NULL terminated on write ... " | ||
56 | set_orig | ||
57 | perl -e 'print "A" x ('"${MAXLEN}"'-1), "B";' | \ | ||
58 | dd of="${TARGET}" bs="${MAXLEN}" 2>/dev/null | ||
59 | if grep -q B "${TARGET}"; then | ||
60 | echo "FAIL" >&2 | ||
61 | rc=1 | ||
62 | else | ||
63 | echo "ok" | ||
64 | fi | ||
65 | |||
66 | echo -n "Checking sysctl stays NULL terminated on overwrite ... " | ||
67 | set_orig | ||
68 | perl -e 'print "A" x ('"${MAXLEN}"'-1), "BB";' | \ | ||
69 | dd of="${TARGET}" bs=$(( $MAXLEN + 1 )) 2>/dev/null | ||
70 | if grep -q B "${TARGET}"; then | ||
71 | echo "FAIL" >&2 | ||
72 | rc=1 | ||
73 | else | ||
74 | echo "ok" | ||
75 | fi | ||
76 | |||
77 | exit $rc | ||
diff --git a/usr/Kconfig b/usr/Kconfig index 642f503d3e9f..2d4c77eecf2e 100644 --- a/usr/Kconfig +++ b/usr/Kconfig | |||
@@ -98,80 +98,3 @@ config RD_LZ4 | |||
98 | help | 98 | help |
99 | Support loading of a LZ4 encoded initial ramdisk or cpio buffer | 99 | Support loading of a LZ4 encoded initial ramdisk or cpio buffer |
100 | If unsure, say N. | 100 | If unsure, say N. |
101 | |||
102 | choice | ||
103 | prompt "Built-in initramfs compression mode" if INITRAMFS_SOURCE!="" | ||
104 | help | ||
105 | This option decides by which algorithm the builtin initramfs | ||
106 | will be compressed. Several compression algorithms are | ||
107 | available, which differ in efficiency, compression and | ||
108 | decompression speed. Compression speed is only relevant | ||
109 | when building a kernel. Decompression speed is relevant at | ||
110 | each boot. | ||
111 | |||
112 | If you have any problems with bzip2 or LZMA compressed | ||
113 | initramfs, mail me (Alain Knaff) <alain@knaff.lu>. | ||
114 | |||
115 | High compression options are mostly useful for users who are | ||
116 | low on RAM, since it reduces the memory consumption during | ||
117 | boot. | ||
118 | |||
119 | If in doubt, select 'gzip' | ||
120 | |||
121 | config INITRAMFS_COMPRESSION_NONE | ||
122 | bool "None" | ||
123 | help | ||
124 | Do not compress the built-in initramfs at all. This may | ||
125 | sound wasteful in space, but, you should be aware that the | ||
126 | built-in initramfs will be compressed at a later stage | ||
127 | anyways along with the rest of the kernel, on those | ||
128 | architectures that support this. | ||
129 | However, not compressing the initramfs may lead to slightly | ||
130 | higher memory consumption during a short time at boot, while | ||
131 | both the cpio image and the unpacked filesystem image will | ||
132 | be present in memory simultaneously | ||
133 | |||
134 | config INITRAMFS_COMPRESSION_GZIP | ||
135 | bool "Gzip" | ||
136 | depends on RD_GZIP | ||
137 | help | ||
138 | The old and tried gzip compression. It provides a good balance | ||
139 | between compression ratio and decompression speed. | ||
140 | |||
141 | config INITRAMFS_COMPRESSION_BZIP2 | ||
142 | bool "Bzip2" | ||
143 | depends on RD_BZIP2 | ||
144 | help | ||
145 | Its compression ratio and speed is intermediate. | ||
146 | Decompression speed is slowest among the choices. The initramfs | ||
147 | size is about 10% smaller with bzip2, in comparison to gzip. | ||
148 | Bzip2 uses a large amount of memory. For modern kernels you | ||
149 | will need at least 8MB RAM or more for booting. | ||
150 | |||
151 | config INITRAMFS_COMPRESSION_LZMA | ||
152 | bool "LZMA" | ||
153 | depends on RD_LZMA | ||
154 | help | ||
155 | This algorithm's compression ratio is best. | ||
156 | Decompression speed is between the other choices. | ||
157 | Compression is slowest. The initramfs size is about 33% | ||
158 | smaller with LZMA in comparison to gzip. | ||
159 | |||
160 | config INITRAMFS_COMPRESSION_XZ | ||
161 | bool "XZ" | ||
162 | depends on RD_XZ | ||
163 | help | ||
164 | XZ uses the LZMA2 algorithm. The initramfs size is about 30% | ||
165 | smaller with XZ in comparison to gzip. Decompression speed | ||
166 | is better than that of bzip2 but worse than gzip and LZO. | ||
167 | Compression is slow. | ||
168 | |||
169 | config INITRAMFS_COMPRESSION_LZO | ||
170 | bool "LZO" | ||
171 | depends on RD_LZO | ||
172 | help | ||
173 | Its compression ratio is the poorest among the choices. The kernel | ||
174 | size is about 10% bigger than gzip; however its speed | ||
175 | (both compression and decompression) is the fastest. | ||
176 | |||
177 | endchoice | ||