aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile2
-rw-r--r--lib/int_sqrt.c2
-rw-r--r--lib/iomap_copy.c42
-rw-r--r--lib/kobject.c9
-rw-r--r--lib/kobject_uevent.c6
-rw-r--r--lib/radix-tree.c10
-rw-r--r--lib/spinlock_debug.c6
-rw-r--r--lib/ts_bm.c40
8 files changed, 92 insertions, 25 deletions
diff --git a/lib/Makefile b/lib/Makefile
index 8535f4d7d1c..648b2c1242f 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -9,7 +9,7 @@ lib-y := errno.o ctype.o string.o vsprintf.o cmdline.o \
lib-y += kobject.o kref.o kobject_uevent.o klist.o
-obj-y += sort.o parser.o halfmd4.o
+obj-y += sort.o parser.o halfmd4.o iomap_copy.o
ifeq ($(CONFIG_DEBUG_KOBJECT),y)
CFLAGS_kobject.o += -DDEBUG
diff --git a/lib/int_sqrt.c b/lib/int_sqrt.c
index a5d2cdc5684..fd355a99327 100644
--- a/lib/int_sqrt.c
+++ b/lib/int_sqrt.c
@@ -15,7 +15,7 @@ unsigned long int_sqrt(unsigned long x)
op = x;
res = 0;
- one = 1 << 30;
+ one = 1UL << (BITS_PER_LONG - 2);
while (one > op)
one >>= 2;
diff --git a/lib/iomap_copy.c b/lib/iomap_copy.c
new file mode 100644
index 00000000000..351045f4f63
--- /dev/null
+++ b/lib/iomap_copy.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2006 PathScale, Inc. All Rights Reserved.
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/io.h>
+
+/**
+ * __iowrite32_copy - copy data to MMIO space, in 32-bit units
+ * @to: destination, in MMIO space (must be 32-bit aligned)
+ * @from: source (must be 32-bit aligned)
+ * @count: number of 32-bit quantities to copy
+ *
+ * Copy data from kernel space to MMIO space, in units of 32 bits at a
+ * time. Order of access is not guaranteed, nor is a memory barrier
+ * performed afterwards.
+ */
+void __attribute__((weak)) __iowrite32_copy(void __iomem *to,
+ const void *from,
+ size_t count)
+{
+ u32 __iomem *dst = to;
+ const u32 *src = from;
+ const u32 *end = src + count;
+
+ while (src < end)
+ __raw_writel(*src++, dst++);
+}
+EXPORT_SYMBOL_GPL(__iowrite32_copy);
diff --git a/lib/kobject.c b/lib/kobject.c
index 7a0e6809490..efe67fa96a7 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -72,6 +72,8 @@ static int get_kobj_path_length(struct kobject *kobj)
* Add 1 to strlen for leading '/' of each level.
*/
do {
+ if (kobject_name(parent) == NULL)
+ return 0;
length += strlen(kobject_name(parent)) + 1;
parent = parent->parent;
} while (parent);
@@ -107,6 +109,8 @@ char *kobject_get_path(struct kobject *kobj, gfp_t gfp_mask)
int len;
len = get_kobj_path_length(kobj);
+ if (len == 0)
+ return NULL;
path = kmalloc(len, gfp_mask);
if (!path)
return NULL;
@@ -162,6 +166,11 @@ int kobject_add(struct kobject * kobj)
return -ENOENT;
if (!kobj->k_name)
kobj->k_name = kobj->name;
+ if (!kobj->k_name) {
+ pr_debug("kobject attempted to be registered with no name!\n");
+ WARN_ON(1);
+ return -EINVAL;
+ }
parent = kobject_get(kobj->parent);
pr_debug("kobject %s: registering. parent: %s, set: %s\n",
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index f56e27ae9d5..086a0c6e888 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -22,7 +22,7 @@
#include <linux/kobject.h>
#include <net/sock.h>
-#define BUFFER_SIZE 1024 /* buffer for the variables */
+#define BUFFER_SIZE 2048 /* buffer for the variables */
#define NUM_ENVP 32 /* number of env pointers */
#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
@@ -38,6 +38,10 @@ static char *action_to_string(enum kobject_action action)
return "remove";
case KOBJ_CHANGE:
return "change";
+ case KOBJ_MOUNT:
+ return "mount";
+ case KOBJ_UMOUNT:
+ return "umount";
case KOBJ_OFFLINE:
return "offline";
case KOBJ_ONLINE:
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index c0bd4a91480..1e5b17dc7e3 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -752,12 +752,14 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
*/
nr_cleared_tags = 0;
for (tag = 0; tag < RADIX_TREE_TAGS; tag++) {
+ tags[tag] = 1;
if (tag_get(pathp->node, tag, pathp->offset)) {
tag_clear(pathp->node, tag, pathp->offset);
- tags[tag] = 0;
- nr_cleared_tags++;
- } else
- tags[tag] = 1;
+ if (!any_tag_set(pathp->node, tag)) {
+ tags[tag] = 0;
+ nr_cleared_tags++;
+ }
+ }
}
for (pathp--; nr_cleared_tags && pathp->node; pathp--) {
diff --git a/lib/spinlock_debug.c b/lib/spinlock_debug.c
index c8bb8cc899d..d8b6bb419d4 100644
--- a/lib/spinlock_debug.c
+++ b/lib/spinlock_debug.c
@@ -72,9 +72,9 @@ static void __spin_lock_debug(spinlock_t *lock)
for (;;) {
for (i = 0; i < loops_per_jiffy * HZ; i++) {
- cpu_relax();
if (__raw_spin_trylock(&lock->raw_lock))
return;
+ __delay(1);
}
/* lockup suspected: */
if (print_once) {
@@ -144,9 +144,9 @@ static void __read_lock_debug(rwlock_t *lock)
for (;;) {
for (i = 0; i < loops_per_jiffy * HZ; i++) {
- cpu_relax();
if (__raw_read_trylock(&lock->raw_lock))
return;
+ __delay(1);
}
/* lockup suspected: */
if (print_once) {
@@ -217,9 +217,9 @@ static void __write_lock_debug(rwlock_t *lock)
for (;;) {
for (i = 0; i < loops_per_jiffy * HZ; i++) {
- cpu_relax();
if (__raw_write_trylock(&lock->raw_lock))
return;
+ __delay(1);
}
/* lockup suspected: */
if (print_once) {
diff --git a/lib/ts_bm.c b/lib/ts_bm.c
index 8a8b3a16133..c4c1ac5fbd1 100644
--- a/lib/ts_bm.c
+++ b/lib/ts_bm.c
@@ -94,10 +94,28 @@ next: bs = bm->bad_shift[text[shift-i]];
return UINT_MAX;
}
+static int subpattern(u8 *pattern, int i, int j, int g)
+{
+ int x = i+g-1, y = j+g-1, ret = 0;
+
+ while(pattern[x--] == pattern[y--]) {
+ if (y < 0) {
+ ret = 1;
+ break;
+ }
+ if (--g == 0) {
+ ret = pattern[i-1] != pattern[j-1];
+ break;
+ }
+ }
+
+ return ret;
+}
+
static void compute_prefix_tbl(struct ts_bm *bm, const u8 *pattern,
unsigned int len)
{
- int i, j, ended, l[ASIZE];
+ int i, j, g;
for (i = 0; i < ASIZE; i++)
bm->bad_shift[i] = len;
@@ -106,23 +124,15 @@ static void compute_prefix_tbl(struct ts_bm *bm, const u8 *pattern,
/* Compute the good shift array, used to match reocurrences
* of a subpattern */
- for (i = 1; i < bm->patlen; i++) {
- for (j = 0; j < bm->patlen && bm->pattern[bm->patlen - 1 - j]
- == bm->pattern[bm->patlen - 1 - i - j]; j++);
- l[i] = j;
- }
-
bm->good_shift[0] = 1;
for (i = 1; i < bm->patlen; i++)
bm->good_shift[i] = bm->patlen;
- for (i = bm->patlen - 1; i > 0; i--)
- bm->good_shift[l[i]] = i;
- ended = 0;
- for (i = 0; i < bm->patlen; i++) {
- if (l[i] == bm->patlen - 1 - i)
- ended = i;
- if (ended)
- bm->good_shift[i] = ended;
+ for (i = bm->patlen-1, g = 1; i > 0; g++, i--) {
+ for (j = i-1; j >= 1-g ; j--)
+ if (subpattern(bm->pattern, i, j, g)) {
+ bm->good_shift[g] = bm->patlen-j-g;
+ break;
+ }
}
}