The patch titled saa7134-tvaudio: convert to kthread API has been removed from the -mm tree. Its filename was mm-only-saa7134-tvaudio-convert-to-kthread-api.patch This patch was dropped because an updated version will be merged ------------------------------------------------------ Subject: saa7134-tvaudio: convert to kthread API From: Eric W. Biederman <ebiederm@xxxxxxxxxxxx> It is my goal to replace all kernel code that handles signals from user space, calls kernel_thread or calls daemonize. All of which the kthread_api makes unncessary. Handling signals from user space is a maintenance problem becuase using a kernel thread is an implementation detail and if user space cares it does not allow us to change the implementation. Calling daemonize is a problem because it has to undo a continually changing set of state generated by user space, requiring the implemetation to change continually. kernel_thread is a problem because it returns a pid_t value. Numeric pids are inherently racy and in the presence of a pid namespace they are no longer global making them useless for general use in the kernel. So this patch renames the pid member of struct saa7134_thread started and changes it's type from pid_t to int. All it has ever been used for is to detect if the kernel thread is has been started so this works. allow_signal(SIGTERM) and the calls to signal_pending have been removed they are needed for the driver to operation. The startup of tvaudio_thread and tvaudio_thread_dep have been modified to use kthread_run instead of a combination of kernel_thread and daemonize. The result is code that is slightly simpler and more maintainable. Cc: Hartmut Hackmann <hartmut.hackmann@xxxxxxxxxxx> Cc: Mauro Carvalho Chehab <mchehab@xxxxxxxxxxxxx> Signed-off-by: Eric W. Biederman <ebiederm@xxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/media/video/saa7134/saa7134-tvaudio.c | 27 +++++++--------- drivers/media/video/saa7134/saa7134.h | 2 - 2 files changed, 14 insertions(+), 15 deletions(-) diff -puN drivers/media/video/saa7134/saa7134-tvaudio.c~mm-only-saa7134-tvaudio-convert-to-kthread-api drivers/media/video/saa7134/saa7134-tvaudio.c --- a/drivers/media/video/saa7134/saa7134-tvaudio.c~mm-only-saa7134-tvaudio-convert-to-kthread-api +++ a/drivers/media/video/saa7134/saa7134-tvaudio.c @@ -22,6 +22,7 @@ #include <linux/init.h> #include <linux/list.h> +#include <linux/kthread.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/kernel.h> @@ -506,11 +507,9 @@ static int tvaudio_thread(void *data) unsigned int i, audio, nscan; int max1,max2,carrier,rx,mode,lastmode,default_carrier; - daemonize("%s", dev->name); - allow_signal(SIGTERM); for (;;) { tvaudio_sleep(dev,-1); - if (dev->thread.shutdown || signal_pending(current)) + if (dev->thread.shutdown) goto done; restart: @@ -619,7 +618,7 @@ static int tvaudio_thread(void *data) for (;;) { if (tvaudio_sleep(dev,5000)) goto restart; - if (dev->thread.shutdown || signal_pending(current)) + if (dev->thread.shutdown) break; if (UNSET == dev->thread.mode) { rx = tvaudio_getstereo(dev,&tvaudio[i]); @@ -783,9 +782,6 @@ static int tvaudio_thread_ddep(void *dat struct saa7134_dev *dev = data; u32 value, norms, clock; - daemonize("%s", dev->name); - allow_signal(SIGTERM); - clock = saa7134_boards[dev->board].audio_clock; if (UNSET != audio_clock_override) clock = audio_clock_override; @@ -797,7 +793,7 @@ static int tvaudio_thread_ddep(void *dat for (;;) { tvaudio_sleep(dev,-1); - if (dev->thread.shutdown || signal_pending(current)) + if (dev->thread.shutdown) goto done; restart: @@ -987,14 +983,17 @@ int saa7134_tvaudio_init2(struct saa7134 break; } - dev->thread.pid = -1; + dev->thread.started = 0; if (my_thread) { + struct task_struct *task; /* start tvaudio thread */ init_waitqueue_head(&dev->thread.wq); init_completion(&dev->thread.exit); - dev->thread.pid = kernel_thread(my_thread,dev,0); - if (dev->thread.pid < 0) - printk(KERN_WARNING "%s: kernel_thread() failed\n", + task = kthread_run(my_thread, dev, "%s", dev->name); + if (!IS_ERR(task)) + dev->thread.started = 1; + else + printk(KERN_WARNING "%s: kthread_create() failed\n", dev->name); saa7134_tvaudio_do_scan(dev); } @@ -1006,7 +1005,7 @@ int saa7134_tvaudio_init2(struct saa7134 int saa7134_tvaudio_fini(struct saa7134_dev *dev) { /* shutdown tvaudio thread */ - if (dev->thread.pid >= 0) { + if (dev->thread.started) { dev->thread.shutdown = 1; wake_up_interruptible(&dev->thread.wq); wait_for_completion(&dev->thread.exit); @@ -1021,7 +1020,7 @@ int saa7134_tvaudio_do_scan(struct saa71 dprintk("sound IF not in use, skipping scan\n"); dev->automute = 0; saa7134_tvaudio_setmute(dev); - } else if (dev->thread.pid >= 0) { + } else if (dev->thread.started) { dev->thread.mode = UNSET; dev->thread.scan2++; wake_up_interruptible(&dev->thread.wq); diff -puN drivers/media/video/saa7134/saa7134.h~mm-only-saa7134-tvaudio-convert-to-kthread-api drivers/media/video/saa7134/saa7134.h --- a/drivers/media/video/saa7134/saa7134.h~mm-only-saa7134-tvaudio-convert-to-kthread-api +++ a/drivers/media/video/saa7134/saa7134.h @@ -324,7 +324,7 @@ struct saa7134_pgtable { /* tvaudio thread status */ struct saa7134_thread { - pid_t pid; + int started; struct completion exit; wait_queue_head_t wq; unsigned int shutdown; _ Patches currently in -mm which might be from ebiederm@xxxxxxxxxxxx are origin.patch git-arm.patch iop13xx-msi-support-rev6.patch dvb_en_50221-convert-to-kthread-api.patch mm-only-saa7134-tvaudio-convert-to-kthread-api.patch ia64-sn-xpc-convert-to-use-kthread-api.patch ia64-sn-xpc-convert-to-use-kthread-api-fix.patch ia64-sn-xpc-convert-to-use-kthread-api-fix-2.patch fix-i-oat-for-kexec.patch cpqphp-partially-convert-to-use-the-kthread-api.patch ibmphp-partially-convert-to-use-the-kthreads-api.patch cpci_hotplug-partially-convert-to-use-the-kthread-api.patch msi-fix-arm-compile.patch s390-scsi-zfcp_erp-partially-convert-to-use-the-kthread-api.patch s390-qeth-convert-to-use-the-kthread-api.patch s390-net-lcs-convert-to-the-kthread-api.patch sas_scsi_host-partially-convert-to-use-the-kthread-api.patch sparc64-powerc-convert-to-use-the-kthread-api.patch i386-irq-kill-irq-compression.patch i386-map-enough-initial-memory-to-create-lowmem-mappings-fix.patch i386-efi-fix-proc-iomem-type-for-kexec-tools.patch clone-flag-clone_parent_tidptr-leaves-invalid-results-in-memory.patch allow-access-to-proc-pid-fd-after-setuid.patch merge-sys_clone-sys_unshare-nsproxy-and-namespace.patch fix-race-between-proc_get_inode-and-remove_proc_entry.patch fix-race-between-proc_readdir-and-remove_proc_entry.patch procfs-reorder-struct-pid_dentry-to-save-space-on-64bit-archs-and-constify-them.patch tty-remove-unnecessary-export-of-proc_clear_tty.patch tty-simplify-calling-of-put_pid.patch tty-introduce-no_tty-and-use-it-in-selinux.patch remove-hardcoding-of-hard_smp_processor_id-on-up.patch use-the-apic-to-determine-the-hardware-processor-id-i386.patch use-the-apic-to-determine-the-hardware-processor-id-x86_64.patch always-ask-the-hardware-to-obtain-hardware-processor-id-ia64.patch proc-cleanup-use-seq_release_private-where-appropriate.patch smbfs-remove-unnecessary-allow_signal.patch pnpbios-conert-to-use-the-kthread-api.patch kthread-dont-depend-on-work-queues-take-2.patch change-reparent_to_init-to-reparent_to_kthreadd.patch wait_for_helper-remove-unneeded-do_sigaction.patch worker_thread-dont-play-with-sigchld-and-numa-policy.patch change-kernel-threads-to-ignore-signals-instead-of-blocking-them.patch fix-kthread_create-vs-freezer-theoretical-race.patch remvoe-kthread_bind-call-from-_cpu_down.patch nfsd-nfs4state-remove-unnecessary-daemonize-call.patch statically-initialize-struct-pid-for-swapper.patch explicitly-set-pgid-and-sid-of-init-process.patch use-struct-pid-parameter-in-copy_process.patch use-task_pgrp-task_session-in-copy_process.patch kill-unused-sesssion-and-group-values-in-rocket-driver.patch fix-some-coding-style-errors-in-autofs.patch replace-pid_t-in-autofs-with-struct-pid-reference.patch dont-init-pgrp-and-__session-in-init_signals.patch mutex-subsystem-synchro-test-module-convert-to-the-kthread-api.patch vdso-print-fatal-signals-use-ctl_unnumbered.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html