- * ata_thread -
- * @data:
- *
- * LOCKING:
- *
- * RETURNS:
- *
- */
-
-static int ata_thread (void *data)
-{
- struct ata_port *ap = data;
- long timeout;
-
- daemonize ("katad-%u", ap->id);
- allow_signal(SIGTERM);
-
- while (1) {
- cond_resched();
-
- timeout = ata_thread_iter(ap);
-
- if (signal_pending (current))
- flush_signals(current);
-
- if (current->flags & PF_FREEZE)
- refrigerator(PF_FREEZE);
-
-
- if ((timeout < 0) || (ap->time_to_die))
- break;
-
- /* note sleeping for full timeout not guaranteed (that's ok) */
- if (timeout) {
- mod_timer(&ap->thr_timer, jiffies + timeout);
- down_interruptible(&ap->thr_sem);
-
- if (signal_pending (current))
- flush_signals(current);
-
- if (ap->time_to_die)
- break;
- }
- }
-
- printk(KERN_DEBUG "ata%u: thread exiting\n", ap->id);
- ap->thr_pid = -1;
- del_timer_sync(&ap->thr_timer);
- complete_and_exit (&ap->thr_exited, 0);
-}
-
-/**
- * ata_thread_kill - kill per-port kernel thread
- * @ap: port those thread is to be killed
- *
- * LOCKING:
- *
- */
-
-static int ata_thread_kill(struct ata_port *ap)
-{
- int ret = 0;
-
- if (ap->thr_pid >= 0) {
- ap->time_to_die = 1;
- wmb();
- ret = kill_proc(ap->thr_pid, SIGTERM, 1);
- if (ret)
- printk(KERN_ERR "ata%d: unable to kill kernel thread\n",
- ap->id);
- else
- wait_for_completion(&ap->thr_exited);
- }
-
- return ret;
-}
-
-/**
- * atapi_cdb_send - Write CDB bytes to hardware
- * @ap: Port to which ATAPI device is attached.