diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/atomic64.c | 2 | ||||
-rw-r--r-- | lib/atomic64_test.c | 2 | ||||
-rw-r--r-- | lib/bitmap.c | 2 | ||||
-rw-r--r-- | lib/cpumask.c | 4 | ||||
-rw-r--r-- | lib/crc32.c | 2 | ||||
-rw-r--r-- | lib/dec_and_lock.c | 2 | ||||
-rw-r--r-- | lib/devres.c | 2 | ||||
-rw-r--r-- | lib/fault-inject.c | 156 | ||||
-rw-r--r-- | lib/idr.c | 67 | ||||
-rw-r--r-- | lib/iomap.c | 4 | ||||
-rw-r--r-- | lib/kstrtox.c | 5 | ||||
-rw-r--r-- | lib/lcm.c | 1 | ||||
-rw-r--r-- | lib/radix-tree.c | 121 | ||||
-rw-r--r-- | lib/vsprintf.c | 26 | ||||
-rw-r--r-- | lib/xz/xz_private.h | 2 |
15 files changed, 247 insertions, 151 deletions
diff --git a/lib/atomic64.c b/lib/atomic64.c index a21c12bc727c..e12ae0dd08a8 100644 --- a/lib/atomic64.c +++ b/lib/atomic64.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/spinlock.h> | 14 | #include <linux/spinlock.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <asm/atomic.h> | 17 | #include <linux/atomic.h> |
18 | 18 | ||
19 | /* | 19 | /* |
20 | * We use a hashed array of spinlocks to provide exclusive access | 20 | * We use a hashed array of spinlocks to provide exclusive access |
diff --git a/lib/atomic64_test.c b/lib/atomic64_test.c index 44524cc8c32a..0c33cde2a1e6 100644 --- a/lib/atomic64_test.c +++ b/lib/atomic64_test.c | |||
@@ -10,7 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <asm/atomic.h> | 13 | #include <linux/atomic.h> |
14 | 14 | ||
15 | #define INIT(c) do { atomic64_set(&v, c); r = c; } while (0) | 15 | #define INIT(c) do { atomic64_set(&v, c); r = c; } while (0) |
16 | static __init int test_atomic64(void) | 16 | static __init int test_atomic64(void) |
diff --git a/lib/bitmap.c b/lib/bitmap.c index 3f3b68199d74..37ef4b048795 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
@@ -756,7 +756,7 @@ static int bitmap_pos_to_ord(const unsigned long *buf, int pos, int bits) | |||
756 | * | 756 | * |
757 | * The bit positions 0 through @bits are valid positions in @buf. | 757 | * The bit positions 0 through @bits are valid positions in @buf. |
758 | */ | 758 | */ |
759 | static int bitmap_ord_to_pos(const unsigned long *buf, int ord, int bits) | 759 | int bitmap_ord_to_pos(const unsigned long *buf, int ord, int bits) |
760 | { | 760 | { |
761 | int pos = 0; | 761 | int pos = 0; |
762 | 762 | ||
diff --git a/lib/cpumask.c b/lib/cpumask.c index 05d6aca7fc19..af3e5817de98 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c | |||
@@ -30,7 +30,7 @@ int __any_online_cpu(const cpumask_t *mask) | |||
30 | { | 30 | { |
31 | int cpu; | 31 | int cpu; |
32 | 32 | ||
33 | for_each_cpu_mask(cpu, *mask) { | 33 | for_each_cpu(cpu, mask) { |
34 | if (cpu_online(cpu)) | 34 | if (cpu_online(cpu)) |
35 | break; | 35 | break; |
36 | } | 36 | } |
@@ -131,7 +131,7 @@ EXPORT_SYMBOL(zalloc_cpumask_var_node); | |||
131 | */ | 131 | */ |
132 | bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags) | 132 | bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags) |
133 | { | 133 | { |
134 | return alloc_cpumask_var_node(mask, flags, numa_node_id()); | 134 | return alloc_cpumask_var_node(mask, flags, NUMA_NO_NODE); |
135 | } | 135 | } |
136 | EXPORT_SYMBOL(alloc_cpumask_var); | 136 | EXPORT_SYMBOL(alloc_cpumask_var); |
137 | 137 | ||
diff --git a/lib/crc32.c b/lib/crc32.c index 4855995fcde9..a6e633a48cea 100644 --- a/lib/crc32.c +++ b/lib/crc32.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/compiler.h> | 26 | #include <linux/compiler.h> |
27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <asm/atomic.h> | 29 | #include <linux/atomic.h> |
30 | #include "crc32defs.h" | 30 | #include "crc32defs.h" |
31 | #if CRC_LE_BITS == 8 | 31 | #if CRC_LE_BITS == 8 |
32 | # define tole(x) __constant_cpu_to_le32(x) | 32 | # define tole(x) __constant_cpu_to_le32(x) |
diff --git a/lib/dec_and_lock.c b/lib/dec_and_lock.c index e73822aa6e9a..b5257725daad 100644 --- a/lib/dec_and_lock.c +++ b/lib/dec_and_lock.c | |||
@@ -1,6 +1,6 @@ | |||
1 | #include <linux/module.h> | 1 | #include <linux/module.h> |
2 | #include <linux/spinlock.h> | 2 | #include <linux/spinlock.h> |
3 | #include <asm/atomic.h> | 3 | #include <linux/atomic.h> |
4 | 4 | ||
5 | /* | 5 | /* |
6 | * This is an implementation of the notion of "decrement a | 6 | * This is an implementation of the notion of "decrement a |
diff --git a/lib/devres.c b/lib/devres.c index 6efddf53b90c..7c0e953a7486 100644 --- a/lib/devres.c +++ b/lib/devres.c | |||
@@ -79,9 +79,9 @@ EXPORT_SYMBOL(devm_ioremap_nocache); | |||
79 | */ | 79 | */ |
80 | void devm_iounmap(struct device *dev, void __iomem *addr) | 80 | void devm_iounmap(struct device *dev, void __iomem *addr) |
81 | { | 81 | { |
82 | iounmap(addr); | ||
83 | WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match, | 82 | WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match, |
84 | (void *)addr)); | 83 | (void *)addr)); |
84 | iounmap(addr); | ||
85 | } | 85 | } |
86 | EXPORT_SYMBOL(devm_iounmap); | 86 | EXPORT_SYMBOL(devm_iounmap); |
87 | 87 | ||
diff --git a/lib/fault-inject.c b/lib/fault-inject.c index 7e65af70635e..f193b7796449 100644 --- a/lib/fault-inject.c +++ b/lib/fault-inject.c | |||
@@ -8,7 +8,6 @@ | |||
8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
9 | #include <linux/interrupt.h> | 9 | #include <linux/interrupt.h> |
10 | #include <linux/stacktrace.h> | 10 | #include <linux/stacktrace.h> |
11 | #include <linux/kallsyms.h> | ||
12 | #include <linux/fault-inject.h> | 11 | #include <linux/fault-inject.h> |
13 | 12 | ||
14 | /* | 13 | /* |
@@ -140,16 +139,6 @@ static int debugfs_ul_set(void *data, u64 val) | |||
140 | return 0; | 139 | return 0; |
141 | } | 140 | } |
142 | 141 | ||
143 | #ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER | ||
144 | static int debugfs_ul_set_MAX_STACK_TRACE_DEPTH(void *data, u64 val) | ||
145 | { | ||
146 | *(unsigned long *)data = | ||
147 | val < MAX_STACK_TRACE_DEPTH ? | ||
148 | val : MAX_STACK_TRACE_DEPTH; | ||
149 | return 0; | ||
150 | } | ||
151 | #endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ | ||
152 | |||
153 | static int debugfs_ul_get(void *data, u64 *val) | 142 | static int debugfs_ul_get(void *data, u64 *val) |
154 | { | 143 | { |
155 | *val = *(unsigned long *)data; | 144 | *val = *(unsigned long *)data; |
@@ -165,16 +154,26 @@ static struct dentry *debugfs_create_ul(const char *name, mode_t mode, | |||
165 | } | 154 | } |
166 | 155 | ||
167 | #ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER | 156 | #ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER |
168 | DEFINE_SIMPLE_ATTRIBUTE(fops_ul_MAX_STACK_TRACE_DEPTH, debugfs_ul_get, | ||
169 | debugfs_ul_set_MAX_STACK_TRACE_DEPTH, "%llu\n"); | ||
170 | 157 | ||
171 | static struct dentry *debugfs_create_ul_MAX_STACK_TRACE_DEPTH( | 158 | static int debugfs_stacktrace_depth_set(void *data, u64 val) |
159 | { | ||
160 | *(unsigned long *)data = | ||
161 | min_t(unsigned long, val, MAX_STACK_TRACE_DEPTH); | ||
162 | |||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | DEFINE_SIMPLE_ATTRIBUTE(fops_stacktrace_depth, debugfs_ul_get, | ||
167 | debugfs_stacktrace_depth_set, "%llu\n"); | ||
168 | |||
169 | static struct dentry *debugfs_create_stacktrace_depth( | ||
172 | const char *name, mode_t mode, | 170 | const char *name, mode_t mode, |
173 | struct dentry *parent, unsigned long *value) | 171 | struct dentry *parent, unsigned long *value) |
174 | { | 172 | { |
175 | return debugfs_create_file(name, mode, parent, value, | 173 | return debugfs_create_file(name, mode, parent, value, |
176 | &fops_ul_MAX_STACK_TRACE_DEPTH); | 174 | &fops_stacktrace_depth); |
177 | } | 175 | } |
176 | |||
178 | #endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ | 177 | #endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ |
179 | 178 | ||
180 | static int debugfs_atomic_t_set(void *data, u64 val) | 179 | static int debugfs_atomic_t_set(void *data, u64 val) |
@@ -198,118 +197,51 @@ static struct dentry *debugfs_create_atomic_t(const char *name, mode_t mode, | |||
198 | return debugfs_create_file(name, mode, parent, value, &fops_atomic_t); | 197 | return debugfs_create_file(name, mode, parent, value, &fops_atomic_t); |
199 | } | 198 | } |
200 | 199 | ||
201 | void cleanup_fault_attr_dentries(struct fault_attr *attr) | 200 | struct dentry *fault_create_debugfs_attr(const char *name, |
202 | { | 201 | struct dentry *parent, struct fault_attr *attr) |
203 | debugfs_remove(attr->dentries.probability_file); | ||
204 | attr->dentries.probability_file = NULL; | ||
205 | |||
206 | debugfs_remove(attr->dentries.interval_file); | ||
207 | attr->dentries.interval_file = NULL; | ||
208 | |||
209 | debugfs_remove(attr->dentries.times_file); | ||
210 | attr->dentries.times_file = NULL; | ||
211 | |||
212 | debugfs_remove(attr->dentries.space_file); | ||
213 | attr->dentries.space_file = NULL; | ||
214 | |||
215 | debugfs_remove(attr->dentries.verbose_file); | ||
216 | attr->dentries.verbose_file = NULL; | ||
217 | |||
218 | debugfs_remove(attr->dentries.task_filter_file); | ||
219 | attr->dentries.task_filter_file = NULL; | ||
220 | |||
221 | #ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER | ||
222 | |||
223 | debugfs_remove(attr->dentries.stacktrace_depth_file); | ||
224 | attr->dentries.stacktrace_depth_file = NULL; | ||
225 | |||
226 | debugfs_remove(attr->dentries.require_start_file); | ||
227 | attr->dentries.require_start_file = NULL; | ||
228 | |||
229 | debugfs_remove(attr->dentries.require_end_file); | ||
230 | attr->dentries.require_end_file = NULL; | ||
231 | |||
232 | debugfs_remove(attr->dentries.reject_start_file); | ||
233 | attr->dentries.reject_start_file = NULL; | ||
234 | |||
235 | debugfs_remove(attr->dentries.reject_end_file); | ||
236 | attr->dentries.reject_end_file = NULL; | ||
237 | |||
238 | #endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ | ||
239 | |||
240 | if (attr->dentries.dir) | ||
241 | WARN_ON(!simple_empty(attr->dentries.dir)); | ||
242 | |||
243 | debugfs_remove(attr->dentries.dir); | ||
244 | attr->dentries.dir = NULL; | ||
245 | } | ||
246 | |||
247 | int init_fault_attr_dentries(struct fault_attr *attr, const char *name) | ||
248 | { | 202 | { |
249 | mode_t mode = S_IFREG | S_IRUSR | S_IWUSR; | 203 | mode_t mode = S_IFREG | S_IRUSR | S_IWUSR; |
250 | struct dentry *dir; | 204 | struct dentry *dir; |
251 | 205 | ||
252 | memset(&attr->dentries, 0, sizeof(attr->dentries)); | 206 | dir = debugfs_create_dir(name, parent); |
253 | |||
254 | dir = debugfs_create_dir(name, NULL); | ||
255 | if (!dir) | 207 | if (!dir) |
256 | goto fail; | 208 | return ERR_PTR(-ENOMEM); |
257 | attr->dentries.dir = dir; | ||
258 | |||
259 | attr->dentries.probability_file = | ||
260 | debugfs_create_ul("probability", mode, dir, &attr->probability); | ||
261 | 209 | ||
262 | attr->dentries.interval_file = | 210 | if (!debugfs_create_ul("probability", mode, dir, &attr->probability)) |
263 | debugfs_create_ul("interval", mode, dir, &attr->interval); | 211 | goto fail; |
264 | 212 | if (!debugfs_create_ul("interval", mode, dir, &attr->interval)) | |
265 | attr->dentries.times_file = | 213 | goto fail; |
266 | debugfs_create_atomic_t("times", mode, dir, &attr->times); | 214 | if (!debugfs_create_atomic_t("times", mode, dir, &attr->times)) |
267 | 215 | goto fail; | |
268 | attr->dentries.space_file = | 216 | if (!debugfs_create_atomic_t("space", mode, dir, &attr->space)) |
269 | debugfs_create_atomic_t("space", mode, dir, &attr->space); | 217 | goto fail; |
270 | 218 | if (!debugfs_create_ul("verbose", mode, dir, &attr->verbose)) | |
271 | attr->dentries.verbose_file = | 219 | goto fail; |
272 | debugfs_create_ul("verbose", mode, dir, &attr->verbose); | 220 | if (!debugfs_create_bool("task-filter", mode, dir, &attr->task_filter)) |
273 | |||
274 | attr->dentries.task_filter_file = debugfs_create_bool("task-filter", | ||
275 | mode, dir, &attr->task_filter); | ||
276 | |||
277 | if (!attr->dentries.probability_file || !attr->dentries.interval_file || | ||
278 | !attr->dentries.times_file || !attr->dentries.space_file || | ||
279 | !attr->dentries.verbose_file || !attr->dentries.task_filter_file) | ||
280 | goto fail; | 221 | goto fail; |
281 | 222 | ||
282 | #ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER | 223 | #ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER |
283 | 224 | ||
284 | attr->dentries.stacktrace_depth_file = | 225 | if (!debugfs_create_stacktrace_depth("stacktrace-depth", mode, dir, |
285 | debugfs_create_ul_MAX_STACK_TRACE_DEPTH( | 226 | &attr->stacktrace_depth)) |
286 | "stacktrace-depth", mode, dir, &attr->stacktrace_depth); | 227 | goto fail; |
287 | 228 | if (!debugfs_create_ul("require-start", mode, dir, | |
288 | attr->dentries.require_start_file = | 229 | &attr->require_start)) |
289 | debugfs_create_ul("require-start", mode, dir, &attr->require_start); | 230 | goto fail; |
290 | 231 | if (!debugfs_create_ul("require-end", mode, dir, &attr->require_end)) | |
291 | attr->dentries.require_end_file = | 232 | goto fail; |
292 | debugfs_create_ul("require-end", mode, dir, &attr->require_end); | 233 | if (!debugfs_create_ul("reject-start", mode, dir, &attr->reject_start)) |
293 | 234 | goto fail; | |
294 | attr->dentries.reject_start_file = | 235 | if (!debugfs_create_ul("reject-end", mode, dir, &attr->reject_end)) |
295 | debugfs_create_ul("reject-start", mode, dir, &attr->reject_start); | ||
296 | |||
297 | attr->dentries.reject_end_file = | ||
298 | debugfs_create_ul("reject-end", mode, dir, &attr->reject_end); | ||
299 | |||
300 | if (!attr->dentries.stacktrace_depth_file || | ||
301 | !attr->dentries.require_start_file || | ||
302 | !attr->dentries.require_end_file || | ||
303 | !attr->dentries.reject_start_file || | ||
304 | !attr->dentries.reject_end_file) | ||
305 | goto fail; | 236 | goto fail; |
306 | 237 | ||
307 | #endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ | 238 | #endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ |
308 | 239 | ||
309 | return 0; | 240 | return dir; |
310 | fail: | 241 | fail: |
311 | cleanup_fault_attr_dentries(attr); | 242 | debugfs_remove_recursive(dir); |
312 | return -ENOMEM; | 243 | |
244 | return ERR_PTR(-ENOMEM); | ||
313 | } | 245 | } |
314 | 246 | ||
315 | #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */ | 247 | #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */ |
@@ -34,8 +34,10 @@ | |||
34 | #include <linux/err.h> | 34 | #include <linux/err.h> |
35 | #include <linux/string.h> | 35 | #include <linux/string.h> |
36 | #include <linux/idr.h> | 36 | #include <linux/idr.h> |
37 | #include <linux/spinlock.h> | ||
37 | 38 | ||
38 | static struct kmem_cache *idr_layer_cache; | 39 | static struct kmem_cache *idr_layer_cache; |
40 | static DEFINE_SPINLOCK(simple_ida_lock); | ||
39 | 41 | ||
40 | static struct idr_layer *get_from_free_list(struct idr *idp) | 42 | static struct idr_layer *get_from_free_list(struct idr *idp) |
41 | { | 43 | { |
@@ -926,6 +928,71 @@ void ida_destroy(struct ida *ida) | |||
926 | EXPORT_SYMBOL(ida_destroy); | 928 | EXPORT_SYMBOL(ida_destroy); |
927 | 929 | ||
928 | /** | 930 | /** |
931 | * ida_simple_get - get a new id. | ||
932 | * @ida: the (initialized) ida. | ||
933 | * @start: the minimum id (inclusive, < 0x8000000) | ||
934 | * @end: the maximum id (exclusive, < 0x8000000 or 0) | ||
935 | * @gfp_mask: memory allocation flags | ||
936 | * | ||
937 | * Allocates an id in the range start <= id < end, or returns -ENOSPC. | ||
938 | * On memory allocation failure, returns -ENOMEM. | ||
939 | * | ||
940 | * Use ida_simple_remove() to get rid of an id. | ||
941 | */ | ||
942 | int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end, | ||
943 | gfp_t gfp_mask) | ||
944 | { | ||
945 | int ret, id; | ||
946 | unsigned int max; | ||
947 | |||
948 | BUG_ON((int)start < 0); | ||
949 | BUG_ON((int)end < 0); | ||
950 | |||
951 | if (end == 0) | ||
952 | max = 0x80000000; | ||
953 | else { | ||
954 | BUG_ON(end < start); | ||
955 | max = end - 1; | ||
956 | } | ||
957 | |||
958 | again: | ||
959 | if (!ida_pre_get(ida, gfp_mask)) | ||
960 | return -ENOMEM; | ||
961 | |||
962 | spin_lock(&simple_ida_lock); | ||
963 | ret = ida_get_new_above(ida, start, &id); | ||
964 | if (!ret) { | ||
965 | if (id > max) { | ||
966 | ida_remove(ida, id); | ||
967 | ret = -ENOSPC; | ||
968 | } else { | ||
969 | ret = id; | ||
970 | } | ||
971 | } | ||
972 | spin_unlock(&simple_ida_lock); | ||
973 | |||
974 | if (unlikely(ret == -EAGAIN)) | ||
975 | goto again; | ||
976 | |||
977 | return ret; | ||
978 | } | ||
979 | EXPORT_SYMBOL(ida_simple_get); | ||
980 | |||
981 | /** | ||
982 | * ida_simple_remove - remove an allocated id. | ||
983 | * @ida: the (initialized) ida. | ||
984 | * @id: the id returned by ida_simple_get. | ||
985 | */ | ||
986 | void ida_simple_remove(struct ida *ida, unsigned int id) | ||
987 | { | ||
988 | BUG_ON((int)id < 0); | ||
989 | spin_lock(&simple_ida_lock); | ||
990 | ida_remove(ida, id); | ||
991 | spin_unlock(&simple_ida_lock); | ||
992 | } | ||
993 | EXPORT_SYMBOL(ida_simple_remove); | ||
994 | |||
995 | /** | ||
929 | * ida_init - initialize ida handle | 996 | * ida_init - initialize ida handle |
930 | * @ida: ida handle | 997 | * @ida: ida handle |
931 | * | 998 | * |
diff --git a/lib/iomap.c b/lib/iomap.c index d32229385151..5dbcb4b2d864 100644 --- a/lib/iomap.c +++ b/lib/iomap.c | |||
@@ -224,6 +224,7 @@ EXPORT_SYMBOL(iowrite8_rep); | |||
224 | EXPORT_SYMBOL(iowrite16_rep); | 224 | EXPORT_SYMBOL(iowrite16_rep); |
225 | EXPORT_SYMBOL(iowrite32_rep); | 225 | EXPORT_SYMBOL(iowrite32_rep); |
226 | 226 | ||
227 | #ifdef CONFIG_HAS_IOPORT | ||
227 | /* Create a virtual mapping cookie for an IO port range */ | 228 | /* Create a virtual mapping cookie for an IO port range */ |
228 | void __iomem *ioport_map(unsigned long port, unsigned int nr) | 229 | void __iomem *ioport_map(unsigned long port, unsigned int nr) |
229 | { | 230 | { |
@@ -238,7 +239,9 @@ void ioport_unmap(void __iomem *addr) | |||
238 | } | 239 | } |
239 | EXPORT_SYMBOL(ioport_map); | 240 | EXPORT_SYMBOL(ioport_map); |
240 | EXPORT_SYMBOL(ioport_unmap); | 241 | EXPORT_SYMBOL(ioport_unmap); |
242 | #endif /* CONFIG_HAS_IOPORT */ | ||
241 | 243 | ||
244 | #ifdef CONFIG_PCI | ||
242 | /** | 245 | /** |
243 | * pci_iomap - create a virtual mapping cookie for a PCI BAR | 246 | * pci_iomap - create a virtual mapping cookie for a PCI BAR |
244 | * @dev: PCI device that owns the BAR | 247 | * @dev: PCI device that owns the BAR |
@@ -280,3 +283,4 @@ void pci_iounmap(struct pci_dev *dev, void __iomem * addr) | |||
280 | } | 283 | } |
281 | EXPORT_SYMBOL(pci_iomap); | 284 | EXPORT_SYMBOL(pci_iomap); |
282 | EXPORT_SYMBOL(pci_iounmap); | 285 | EXPORT_SYMBOL(pci_iounmap); |
286 | #endif /* CONFIG_PCI */ | ||
diff --git a/lib/kstrtox.c b/lib/kstrtox.c index 2dbae88090ac..5e066759f551 100644 --- a/lib/kstrtox.c +++ b/lib/kstrtox.c | |||
@@ -19,11 +19,6 @@ | |||
19 | #include <linux/types.h> | 19 | #include <linux/types.h> |
20 | #include <asm/uaccess.h> | 20 | #include <asm/uaccess.h> |
21 | 21 | ||
22 | static inline char _tolower(const char c) | ||
23 | { | ||
24 | return c | 0x20; | ||
25 | } | ||
26 | |||
27 | static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) | 22 | static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) |
28 | { | 23 | { |
29 | unsigned long long acc; | 24 | unsigned long long acc; |
@@ -1,6 +1,7 @@ | |||
1 | #include <linux/kernel.h> | 1 | #include <linux/kernel.h> |
2 | #include <linux/gcd.h> | 2 | #include <linux/gcd.h> |
3 | #include <linux/module.h> | 3 | #include <linux/module.h> |
4 | #include <linux/lcm.h> | ||
4 | 5 | ||
5 | /* Lowest common multiple */ | 6 | /* Lowest common multiple */ |
6 | unsigned long lcm(unsigned long a, unsigned long b) | 7 | unsigned long lcm(unsigned long a, unsigned long b) |
diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 7ea2e033d715..a2f9da59c197 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c | |||
@@ -823,8 +823,8 @@ unsigned long radix_tree_prev_hole(struct radix_tree_root *root, | |||
823 | EXPORT_SYMBOL(radix_tree_prev_hole); | 823 | EXPORT_SYMBOL(radix_tree_prev_hole); |
824 | 824 | ||
825 | static unsigned int | 825 | static unsigned int |
826 | __lookup(struct radix_tree_node *slot, void ***results, unsigned long index, | 826 | __lookup(struct radix_tree_node *slot, void ***results, unsigned long *indices, |
827 | unsigned int max_items, unsigned long *next_index) | 827 | unsigned long index, unsigned int max_items, unsigned long *next_index) |
828 | { | 828 | { |
829 | unsigned int nr_found = 0; | 829 | unsigned int nr_found = 0; |
830 | unsigned int shift, height; | 830 | unsigned int shift, height; |
@@ -857,12 +857,16 @@ __lookup(struct radix_tree_node *slot, void ***results, unsigned long index, | |||
857 | 857 | ||
858 | /* Bottom level: grab some items */ | 858 | /* Bottom level: grab some items */ |
859 | for (i = index & RADIX_TREE_MAP_MASK; i < RADIX_TREE_MAP_SIZE; i++) { | 859 | for (i = index & RADIX_TREE_MAP_MASK; i < RADIX_TREE_MAP_SIZE; i++) { |
860 | index++; | ||
861 | if (slot->slots[i]) { | 860 | if (slot->slots[i]) { |
862 | results[nr_found++] = &(slot->slots[i]); | 861 | results[nr_found] = &(slot->slots[i]); |
863 | if (nr_found == max_items) | 862 | if (indices) |
863 | indices[nr_found] = index; | ||
864 | if (++nr_found == max_items) { | ||
865 | index++; | ||
864 | goto out; | 866 | goto out; |
867 | } | ||
865 | } | 868 | } |
869 | index++; | ||
866 | } | 870 | } |
867 | out: | 871 | out: |
868 | *next_index = index; | 872 | *next_index = index; |
@@ -918,8 +922,8 @@ radix_tree_gang_lookup(struct radix_tree_root *root, void **results, | |||
918 | 922 | ||
919 | if (cur_index > max_index) | 923 | if (cur_index > max_index) |
920 | break; | 924 | break; |
921 | slots_found = __lookup(node, (void ***)results + ret, cur_index, | 925 | slots_found = __lookup(node, (void ***)results + ret, NULL, |
922 | max_items - ret, &next_index); | 926 | cur_index, max_items - ret, &next_index); |
923 | nr_found = 0; | 927 | nr_found = 0; |
924 | for (i = 0; i < slots_found; i++) { | 928 | for (i = 0; i < slots_found; i++) { |
925 | struct radix_tree_node *slot; | 929 | struct radix_tree_node *slot; |
@@ -944,6 +948,7 @@ EXPORT_SYMBOL(radix_tree_gang_lookup); | |||
944 | * radix_tree_gang_lookup_slot - perform multiple slot lookup on radix tree | 948 | * radix_tree_gang_lookup_slot - perform multiple slot lookup on radix tree |
945 | * @root: radix tree root | 949 | * @root: radix tree root |
946 | * @results: where the results of the lookup are placed | 950 | * @results: where the results of the lookup are placed |
951 | * @indices: where their indices should be placed (but usually NULL) | ||
947 | * @first_index: start the lookup from this key | 952 | * @first_index: start the lookup from this key |
948 | * @max_items: place up to this many items at *results | 953 | * @max_items: place up to this many items at *results |
949 | * | 954 | * |
@@ -958,7 +963,8 @@ EXPORT_SYMBOL(radix_tree_gang_lookup); | |||
958 | * protection, radix_tree_deref_slot may fail requiring a retry. | 963 | * protection, radix_tree_deref_slot may fail requiring a retry. |
959 | */ | 964 | */ |
960 | unsigned int | 965 | unsigned int |
961 | radix_tree_gang_lookup_slot(struct radix_tree_root *root, void ***results, | 966 | radix_tree_gang_lookup_slot(struct radix_tree_root *root, |
967 | void ***results, unsigned long *indices, | ||
962 | unsigned long first_index, unsigned int max_items) | 968 | unsigned long first_index, unsigned int max_items) |
963 | { | 969 | { |
964 | unsigned long max_index; | 970 | unsigned long max_index; |
@@ -974,6 +980,8 @@ radix_tree_gang_lookup_slot(struct radix_tree_root *root, void ***results, | |||
974 | if (first_index > 0) | 980 | if (first_index > 0) |
975 | return 0; | 981 | return 0; |
976 | results[0] = (void **)&root->rnode; | 982 | results[0] = (void **)&root->rnode; |
983 | if (indices) | ||
984 | indices[0] = 0; | ||
977 | return 1; | 985 | return 1; |
978 | } | 986 | } |
979 | node = indirect_to_ptr(node); | 987 | node = indirect_to_ptr(node); |
@@ -987,8 +995,9 @@ radix_tree_gang_lookup_slot(struct radix_tree_root *root, void ***results, | |||
987 | 995 | ||
988 | if (cur_index > max_index) | 996 | if (cur_index > max_index) |
989 | break; | 997 | break; |
990 | slots_found = __lookup(node, results + ret, cur_index, | 998 | slots_found = __lookup(node, results + ret, |
991 | max_items - ret, &next_index); | 999 | indices ? indices + ret : NULL, |
1000 | cur_index, max_items - ret, &next_index); | ||
992 | ret += slots_found; | 1001 | ret += slots_found; |
993 | if (next_index == 0) | 1002 | if (next_index == 0) |
994 | break; | 1003 | break; |
@@ -1194,6 +1203,98 @@ radix_tree_gang_lookup_tag_slot(struct radix_tree_root *root, void ***results, | |||
1194 | } | 1203 | } |
1195 | EXPORT_SYMBOL(radix_tree_gang_lookup_tag_slot); | 1204 | EXPORT_SYMBOL(radix_tree_gang_lookup_tag_slot); |
1196 | 1205 | ||
1206 | #if defined(CONFIG_SHMEM) && defined(CONFIG_SWAP) | ||
1207 | #include <linux/sched.h> /* for cond_resched() */ | ||
1208 | |||
1209 | /* | ||
1210 | * This linear search is at present only useful to shmem_unuse_inode(). | ||
1211 | */ | ||
1212 | static unsigned long __locate(struct radix_tree_node *slot, void *item, | ||
1213 | unsigned long index, unsigned long *found_index) | ||
1214 | { | ||
1215 | unsigned int shift, height; | ||
1216 | unsigned long i; | ||
1217 | |||
1218 | height = slot->height; | ||
1219 | shift = (height-1) * RADIX_TREE_MAP_SHIFT; | ||
1220 | |||
1221 | for ( ; height > 1; height--) { | ||
1222 | i = (index >> shift) & RADIX_TREE_MAP_MASK; | ||
1223 | for (;;) { | ||
1224 | if (slot->slots[i] != NULL) | ||
1225 | break; | ||
1226 | index &= ~((1UL << shift) - 1); | ||
1227 | index += 1UL << shift; | ||
1228 | if (index == 0) | ||
1229 | goto out; /* 32-bit wraparound */ | ||
1230 | i++; | ||
1231 | if (i == RADIX_TREE_MAP_SIZE) | ||
1232 | goto out; | ||
1233 | } | ||
1234 | |||
1235 | shift -= RADIX_TREE_MAP_SHIFT; | ||
1236 | slot = rcu_dereference_raw(slot->slots[i]); | ||
1237 | if (slot == NULL) | ||
1238 | goto out; | ||
1239 | } | ||
1240 | |||
1241 | /* Bottom level: check items */ | ||
1242 | for (i = 0; i < RADIX_TREE_MAP_SIZE; i++) { | ||
1243 | if (slot->slots[i] == item) { | ||
1244 | *found_index = index + i; | ||
1245 | index = 0; | ||
1246 | goto out; | ||
1247 | } | ||
1248 | } | ||
1249 | index += RADIX_TREE_MAP_SIZE; | ||
1250 | out: | ||
1251 | return index; | ||
1252 | } | ||
1253 | |||
1254 | /** | ||
1255 | * radix_tree_locate_item - search through radix tree for item | ||
1256 | * @root: radix tree root | ||
1257 | * @item: item to be found | ||
1258 | * | ||
1259 | * Returns index where item was found, or -1 if not found. | ||
1260 | * Caller must hold no lock (since this time-consuming function needs | ||
1261 | * to be preemptible), and must check afterwards if item is still there. | ||
1262 | */ | ||
1263 | unsigned long radix_tree_locate_item(struct radix_tree_root *root, void *item) | ||
1264 | { | ||
1265 | struct radix_tree_node *node; | ||
1266 | unsigned long max_index; | ||
1267 | unsigned long cur_index = 0; | ||
1268 | unsigned long found_index = -1; | ||
1269 | |||
1270 | do { | ||
1271 | rcu_read_lock(); | ||
1272 | node = rcu_dereference_raw(root->rnode); | ||
1273 | if (!radix_tree_is_indirect_ptr(node)) { | ||
1274 | rcu_read_unlock(); | ||
1275 | if (node == item) | ||
1276 | found_index = 0; | ||
1277 | break; | ||
1278 | } | ||
1279 | |||
1280 | node = indirect_to_ptr(node); | ||
1281 | max_index = radix_tree_maxindex(node->height); | ||
1282 | if (cur_index > max_index) | ||
1283 | break; | ||
1284 | |||
1285 | cur_index = __locate(node, item, cur_index, &found_index); | ||
1286 | rcu_read_unlock(); | ||
1287 | cond_resched(); | ||
1288 | } while (cur_index != 0 && cur_index <= max_index); | ||
1289 | |||
1290 | return found_index; | ||
1291 | } | ||
1292 | #else | ||
1293 | unsigned long radix_tree_locate_item(struct radix_tree_root *root, void *item) | ||
1294 | { | ||
1295 | return -1; | ||
1296 | } | ||
1297 | #endif /* CONFIG_SHMEM && CONFIG_SWAP */ | ||
1197 | 1298 | ||
1198 | /** | 1299 | /** |
1199 | * radix_tree_shrink - shrink height of a radix tree to minimal | 1300 | * radix_tree_shrink - shrink height of a radix tree to minimal |
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 4365df31a1d5..d7222a9c8267 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -31,13 +31,10 @@ | |||
31 | #include <asm/div64.h> | 31 | #include <asm/div64.h> |
32 | #include <asm/sections.h> /* for dereference_function_descriptor() */ | 32 | #include <asm/sections.h> /* for dereference_function_descriptor() */ |
33 | 33 | ||
34 | /* Works only for digits and letters, but small and fast */ | ||
35 | #define TOLOWER(x) ((x) | 0x20) | ||
36 | |||
37 | static unsigned int simple_guess_base(const char *cp) | 34 | static unsigned int simple_guess_base(const char *cp) |
38 | { | 35 | { |
39 | if (cp[0] == '0') { | 36 | if (cp[0] == '0') { |
40 | if (TOLOWER(cp[1]) == 'x' && isxdigit(cp[2])) | 37 | if (_tolower(cp[1]) == 'x' && isxdigit(cp[2])) |
41 | return 16; | 38 | return 16; |
42 | else | 39 | else |
43 | return 8; | 40 | return 8; |
@@ -59,13 +56,13 @@ unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int bas | |||
59 | if (!base) | 56 | if (!base) |
60 | base = simple_guess_base(cp); | 57 | base = simple_guess_base(cp); |
61 | 58 | ||
62 | if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x') | 59 | if (base == 16 && cp[0] == '0' && _tolower(cp[1]) == 'x') |
63 | cp += 2; | 60 | cp += 2; |
64 | 61 | ||
65 | while (isxdigit(*cp)) { | 62 | while (isxdigit(*cp)) { |
66 | unsigned int value; | 63 | unsigned int value; |
67 | 64 | ||
68 | value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10; | 65 | value = isdigit(*cp) ? *cp - '0' : _tolower(*cp) - 'a' + 10; |
69 | if (value >= base) | 66 | if (value >= base) |
70 | break; | 67 | break; |
71 | result = result * base + value; | 68 | result = result * base + value; |
@@ -1036,8 +1033,8 @@ precision: | |||
1036 | qualifier: | 1033 | qualifier: |
1037 | /* get the conversion qualifier */ | 1034 | /* get the conversion qualifier */ |
1038 | spec->qualifier = -1; | 1035 | spec->qualifier = -1; |
1039 | if (*fmt == 'h' || TOLOWER(*fmt) == 'l' || | 1036 | if (*fmt == 'h' || _tolower(*fmt) == 'l' || |
1040 | TOLOWER(*fmt) == 'z' || *fmt == 't') { | 1037 | _tolower(*fmt) == 'z' || *fmt == 't') { |
1041 | spec->qualifier = *fmt++; | 1038 | spec->qualifier = *fmt++; |
1042 | if (unlikely(spec->qualifier == *fmt)) { | 1039 | if (unlikely(spec->qualifier == *fmt)) { |
1043 | if (spec->qualifier == 'l') { | 1040 | if (spec->qualifier == 'l') { |
@@ -1104,7 +1101,7 @@ qualifier: | |||
1104 | spec->type = FORMAT_TYPE_LONG; | 1101 | spec->type = FORMAT_TYPE_LONG; |
1105 | else | 1102 | else |
1106 | spec->type = FORMAT_TYPE_ULONG; | 1103 | spec->type = FORMAT_TYPE_ULONG; |
1107 | } else if (TOLOWER(spec->qualifier) == 'z') { | 1104 | } else if (_tolower(spec->qualifier) == 'z') { |
1108 | spec->type = FORMAT_TYPE_SIZE_T; | 1105 | spec->type = FORMAT_TYPE_SIZE_T; |
1109 | } else if (spec->qualifier == 't') { | 1106 | } else if (spec->qualifier == 't') { |
1110 | spec->type = FORMAT_TYPE_PTRDIFF; | 1107 | spec->type = FORMAT_TYPE_PTRDIFF; |
@@ -1149,8 +1146,7 @@ qualifier: | |||
1149 | * %pi4 print an IPv4 address with leading zeros | 1146 | * %pi4 print an IPv4 address with leading zeros |
1150 | * %pI6 print an IPv6 address with colons | 1147 | * %pI6 print an IPv6 address with colons |
1151 | * %pi6 print an IPv6 address without colons | 1148 | * %pi6 print an IPv6 address without colons |
1152 | * %pI6c print an IPv6 address as specified by | 1149 | * %pI6c print an IPv6 address as specified by RFC 5952 |
1153 | * http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-00 | ||
1154 | * %pU[bBlL] print a UUID/GUID in big or little endian using lower or upper | 1150 | * %pU[bBlL] print a UUID/GUID in big or little endian using lower or upper |
1155 | * case. | 1151 | * case. |
1156 | * %n is ignored | 1152 | * %n is ignored |
@@ -1263,7 +1259,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) | |||
1263 | if (qualifier == 'l') { | 1259 | if (qualifier == 'l') { |
1264 | long *ip = va_arg(args, long *); | 1260 | long *ip = va_arg(args, long *); |
1265 | *ip = (str - buf); | 1261 | *ip = (str - buf); |
1266 | } else if (TOLOWER(qualifier) == 'z') { | 1262 | } else if (_tolower(qualifier) == 'z') { |
1267 | size_t *ip = va_arg(args, size_t *); | 1263 | size_t *ip = va_arg(args, size_t *); |
1268 | *ip = (str - buf); | 1264 | *ip = (str - buf); |
1269 | } else { | 1265 | } else { |
@@ -1550,7 +1546,7 @@ do { \ | |||
1550 | void *skip_arg; | 1546 | void *skip_arg; |
1551 | if (qualifier == 'l') | 1547 | if (qualifier == 'l') |
1552 | skip_arg = va_arg(args, long *); | 1548 | skip_arg = va_arg(args, long *); |
1553 | else if (TOLOWER(qualifier) == 'z') | 1549 | else if (_tolower(qualifier) == 'z') |
1554 | skip_arg = va_arg(args, size_t *); | 1550 | skip_arg = va_arg(args, size_t *); |
1555 | else | 1551 | else |
1556 | skip_arg = va_arg(args, int *); | 1552 | skip_arg = va_arg(args, int *); |
@@ -1856,8 +1852,8 @@ int vsscanf(const char *buf, const char *fmt, va_list args) | |||
1856 | 1852 | ||
1857 | /* get conversion qualifier */ | 1853 | /* get conversion qualifier */ |
1858 | qualifier = -1; | 1854 | qualifier = -1; |
1859 | if (*fmt == 'h' || TOLOWER(*fmt) == 'l' || | 1855 | if (*fmt == 'h' || _tolower(*fmt) == 'l' || |
1860 | TOLOWER(*fmt) == 'z') { | 1856 | _tolower(*fmt) == 'z') { |
1861 | qualifier = *fmt++; | 1857 | qualifier = *fmt++; |
1862 | if (unlikely(qualifier == *fmt)) { | 1858 | if (unlikely(qualifier == *fmt)) { |
1863 | if (qualifier == 'h') { | 1859 | if (qualifier == 'h') { |
diff --git a/lib/xz/xz_private.h b/lib/xz/xz_private.h index a65633e06962..482b90f363fe 100644 --- a/lib/xz/xz_private.h +++ b/lib/xz/xz_private.h | |||
@@ -12,7 +12,7 @@ | |||
12 | 12 | ||
13 | #ifdef __KERNEL__ | 13 | #ifdef __KERNEL__ |
14 | # include <linux/xz.h> | 14 | # include <linux/xz.h> |
15 | # include <asm/byteorder.h> | 15 | # include <linux/kernel.h> |
16 | # include <asm/unaligned.h> | 16 | # include <asm/unaligned.h> |
17 | /* XZ_PREBOOT may be defined only via decompress_unxz.c. */ | 17 | /* XZ_PREBOOT may be defined only via decompress_unxz.c. */ |
18 | # ifndef XZ_PREBOOT | 18 | # ifndef XZ_PREBOOT |