[SCSI] aacraid: use kthread_ API
Use the kthread_ API instead of opencoding lots of hairy code for kernel thread creation and teardown. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Salyzyn, Mark <mark_salyzyn@adaptec.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
This commit is contained in:
committed by
James Bottomley
parent
38e14f895b
commit
fe27381d16
@@ -997,7 +997,7 @@ struct aac_dev
|
|||||||
int maximum_num_physicals;
|
int maximum_num_physicals;
|
||||||
int maximum_num_channels;
|
int maximum_num_channels;
|
||||||
struct fsa_dev_info *fsa_dev;
|
struct fsa_dev_info *fsa_dev;
|
||||||
pid_t thread_pid;
|
struct task_struct *thread;
|
||||||
int cardtype;
|
int cardtype;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1017,7 +1017,6 @@ struct aac_dev
|
|||||||
* AIF thread states
|
* AIF thread states
|
||||||
*/
|
*/
|
||||||
u32 aif_thread;
|
u32 aif_thread;
|
||||||
struct completion aif_completion;
|
|
||||||
struct aac_adapter_info adapter_info;
|
struct aac_adapter_info adapter_info;
|
||||||
struct aac_supplement_adapter_info supplement_adapter_info;
|
struct aac_supplement_adapter_info supplement_adapter_info;
|
||||||
/* These are in adapter info but they are in the io flow so
|
/* These are in adapter info but they are in the io flow so
|
||||||
@@ -1797,7 +1796,7 @@ int aac_sa_init(struct aac_dev *dev);
|
|||||||
unsigned int aac_response_normal(struct aac_queue * q);
|
unsigned int aac_response_normal(struct aac_queue * q);
|
||||||
unsigned int aac_command_normal(struct aac_queue * q);
|
unsigned int aac_command_normal(struct aac_queue * q);
|
||||||
unsigned int aac_intr_normal(struct aac_dev * dev, u32 Index);
|
unsigned int aac_intr_normal(struct aac_dev * dev, u32 Index);
|
||||||
int aac_command_thread(struct aac_dev * dev);
|
int aac_command_thread(void *data);
|
||||||
int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context *fibctx);
|
int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context *fibctx);
|
||||||
int aac_fib_adapter_complete(struct fib * fibptr, unsigned short size);
|
int aac_fib_adapter_complete(struct fib * fibptr, unsigned short size);
|
||||||
struct aac_driver_ident* aac_get_driver_ident(int devtype);
|
struct aac_driver_ident* aac_get_driver_ident(int devtype);
|
||||||
|
@@ -433,7 +433,6 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
INIT_LIST_HEAD(&dev->fib_list);
|
INIT_LIST_HEAD(&dev->fib_list);
|
||||||
init_completion(&dev->aif_completion);
|
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
#include <linux/completion.h>
|
#include <linux/completion.h>
|
||||||
#include <linux/blkdev.h>
|
#include <linux/blkdev.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
|
#include <linux/kthread.h>
|
||||||
#include <scsi/scsi_host.h>
|
#include <scsi/scsi_host.h>
|
||||||
#include <scsi/scsi_device.h>
|
#include <scsi/scsi_device.h>
|
||||||
#include <asm/semaphore.h>
|
#include <asm/semaphore.h>
|
||||||
@@ -1045,8 +1046,9 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr)
|
|||||||
* more FIBs.
|
* more FIBs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int aac_command_thread(struct aac_dev * dev)
|
int aac_command_thread(void *data)
|
||||||
{
|
{
|
||||||
|
struct aac_dev *dev = data;
|
||||||
struct hw_fib *hw_fib, *hw_newfib;
|
struct hw_fib *hw_fib, *hw_newfib;
|
||||||
struct fib *fib, *newfib;
|
struct fib *fib, *newfib;
|
||||||
struct aac_fib_context *fibctx;
|
struct aac_fib_context *fibctx;
|
||||||
@@ -1058,12 +1060,7 @@ int aac_command_thread(struct aac_dev * dev)
|
|||||||
*/
|
*/
|
||||||
if (dev->aif_thread)
|
if (dev->aif_thread)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
/*
|
|
||||||
* Set up the name that will appear in 'ps'
|
|
||||||
* stored in task_struct.comm[16].
|
|
||||||
*/
|
|
||||||
daemonize("aacraid");
|
|
||||||
allow_signal(SIGKILL);
|
|
||||||
/*
|
/*
|
||||||
* Let the DPC know it has a place to send the AIF's to.
|
* Let the DPC know it has a place to send the AIF's to.
|
||||||
*/
|
*/
|
||||||
@@ -1266,13 +1263,12 @@ int aac_command_thread(struct aac_dev * dev)
|
|||||||
spin_unlock_irqrestore(dev->queues->queue[HostNormCmdQueue].lock, flags);
|
spin_unlock_irqrestore(dev->queues->queue[HostNormCmdQueue].lock, flags);
|
||||||
schedule();
|
schedule();
|
||||||
|
|
||||||
if(signal_pending(current))
|
if (kthread_should_stop())
|
||||||
break;
|
break;
|
||||||
set_current_state(TASK_INTERRUPTIBLE);
|
set_current_state(TASK_INTERRUPTIBLE);
|
||||||
}
|
}
|
||||||
if (dev->queues)
|
if (dev->queues)
|
||||||
remove_wait_queue(&dev->queues->queue[HostNormCmdQueue].cmdready, &wait);
|
remove_wait_queue(&dev->queues->queue[HostNormCmdQueue].cmdready, &wait);
|
||||||
dev->aif_thread = 0;
|
dev->aif_thread = 0;
|
||||||
complete_and_exit(&dev->aif_completion, 0);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -48,6 +48,7 @@
|
|||||||
#include <linux/syscalls.h>
|
#include <linux/syscalls.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/smp_lock.h>
|
#include <linux/smp_lock.h>
|
||||||
|
#include <linux/kthread.h>
|
||||||
#include <asm/semaphore.h>
|
#include <asm/semaphore.h>
|
||||||
|
|
||||||
#include <scsi/scsi.h>
|
#include <scsi/scsi.h>
|
||||||
@@ -850,10 +851,10 @@ static int __devinit aac_probe_one(struct pci_dev *pdev,
|
|||||||
/*
|
/*
|
||||||
* Start any kernel threads needed
|
* Start any kernel threads needed
|
||||||
*/
|
*/
|
||||||
aac->thread_pid = kernel_thread((int (*)(void *))aac_command_thread,
|
aac->thread = kthread_run(aac_command_thread, aac, AAC_DRIVERNAME);
|
||||||
aac, 0);
|
if (IS_ERR(aac->thread)) {
|
||||||
if (aac->thread_pid < 0) {
|
|
||||||
printk(KERN_ERR "aacraid: Unable to create command thread.\n");
|
printk(KERN_ERR "aacraid: Unable to create command thread.\n");
|
||||||
|
error = PTR_ERR(aac->thread);
|
||||||
goto out_deinit;
|
goto out_deinit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -934,9 +935,7 @@ static int __devinit aac_probe_one(struct pci_dev *pdev,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_deinit:
|
out_deinit:
|
||||||
kill_proc(aac->thread_pid, SIGKILL, 0);
|
kthread_stop(aac->thread);
|
||||||
wait_for_completion(&aac->aif_completion);
|
|
||||||
|
|
||||||
aac_send_shutdown(aac);
|
aac_send_shutdown(aac);
|
||||||
aac_adapter_disable_int(aac);
|
aac_adapter_disable_int(aac);
|
||||||
free_irq(pdev->irq, aac);
|
free_irq(pdev->irq, aac);
|
||||||
@@ -970,8 +969,7 @@ static void __devexit aac_remove_one(struct pci_dev *pdev)
|
|||||||
|
|
||||||
scsi_remove_host(shost);
|
scsi_remove_host(shost);
|
||||||
|
|
||||||
kill_proc(aac->thread_pid, SIGKILL, 0);
|
kthread_stop(aac->thread);
|
||||||
wait_for_completion(&aac->aif_completion);
|
|
||||||
|
|
||||||
aac_send_shutdown(aac);
|
aac_send_shutdown(aac);
|
||||||
aac_adapter_disable_int(aac);
|
aac_adapter_disable_int(aac);
|
||||||
|
Reference in New Issue
Block a user