aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/files/crypto/ocf/random.c
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2013-02-02 15:31:44 +0000
committerGabor Juhos <juhosg@openwrt.org>2013-02-02 15:31:44 +0000
commitd3fe8e38ccc5ad4911691cca8690fe577011cfc0 (patch)
tree4756ec5b4d958b052aefdf10a346c37197e39712 /target/linux/generic/files/crypto/ocf/random.c
parentaad50acc534732ab43c5aa9b56f5163709993a1d (diff)
downloadmaster-187ad058-d3fe8e38ccc5ad4911691cca8690fe577011cfc0.tar.gz
master-187ad058-d3fe8e38ccc5ad4911691cca8690fe577011cfc0.tar.bz2
master-187ad058-d3fe8e38ccc5ad4911691cca8690fe577011cfc0.zip
generic: convert crypto-ocf from kernel_thread to kthread
recent kernels have finally stopped exporting kernel_thread, since a deprecation circa 2006. This patch attempts to convert to the newer kernel kthread API, particularly in random.c [juhosg: remove randomproc variable, it is not required after the patch] Signed-off-by: Russell Senior <russell@personaltelco.net> Signed-off-by: Gabor Juhos <juhosg@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35456 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic/files/crypto/ocf/random.c')
-rw-r--r--target/linux/generic/files/crypto/ocf/random.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/target/linux/generic/files/crypto/ocf/random.c b/target/linux/generic/files/crypto/ocf/random.c
index a5f2f648c7..9fc070ed42 100644
--- a/target/linux/generic/files/crypto/ocf/random.c
+++ b/target/linux/generic/files/crypto/ocf/random.c
@@ -49,6 +49,7 @@
#include <linux/unistd.h>
#include <linux/poll.h>
#include <linux/random.h>
+#include <linux/kthread.h>
#include <cryptodev.h>
#ifdef CONFIG_OCF_FIPS
@@ -79,9 +80,9 @@ struct random_op {
void *arg;
};
+static struct task_struct *random_thread;
static int random_proc(void *arg);
-static pid_t randomproc = (pid_t) -1;
static spinlock_t random_lock;
/*
@@ -141,12 +142,10 @@ crypto_rregister(
spin_lock_irqsave(&random_lock, flags);
list_add_tail(&rops->random_list, &random_ops);
if (!started) {
- randomproc = kernel_thread(random_proc, NULL, CLONE_FS|CLONE_FILES);
- if (randomproc < 0) {
- ret = randomproc;
- printk("crypto: crypto_rregister cannot start random thread; "
- "error %d", ret);
- } else
+ random_thread = kthread_run(random_proc, NULL, "ocf-random");
+ if (IS_ERR(random_thread))
+ ret = PTR_ERR(random_thread);
+ else
started = 1;
}
spin_unlock_irqrestore(&random_lock, flags);
@@ -172,7 +171,7 @@ crypto_runregister_all(u_int32_t driverid)
spin_lock_irqsave(&random_lock, flags);
if (list_empty(&random_ops) && started)
- kill_proc(randomproc, SIGKILL, 1);
+ kthread_stop(random_thread);
spin_unlock_irqrestore(&random_lock, flags);
return(0);
}
@@ -203,7 +202,6 @@ random_proc(void *arg)
sprintf(current->comm, "ocf-random");
#else
daemonize("ocf-random");
- allow_signal(SIGKILL);
#endif
(void) get_fs();
@@ -306,12 +304,11 @@ random_proc(void *arg)
#endif
}
}
-
+
kfree(buf);
bad_alloc:
spin_lock_irq(&random_lock);
- randomproc = (pid_t) -1;
started = 0;
spin_unlock_irq(&random_lock);