diff options
author | Christoph Hellwig <hch@lst.de> | 2006-02-14 12:45:06 -0500 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-02-27 23:55:14 -0500 |
commit | fe27381d16c6683c55e618360d0d11bd43647e43 (patch) | |
tree | 142cd1c8661480081b293fe50de9354b0b181ffd | |
parent | 38e14f895b212943995379dea824cc52b0c25991 (diff) |
[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>
-rw-r--r-- | drivers/scsi/aacraid/aacraid.h | 5 | ||||
-rw-r--r-- | drivers/scsi/aacraid/comminit.c | 1 | ||||
-rw-r--r-- | drivers/scsi/aacraid/commsup.c | 14 | ||||
-rw-r--r-- | drivers/scsi/aacraid/linit.c | 14 |
4 files changed, 13 insertions, 21 deletions
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 2d430b7e8cf4..9ce7002bd070 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h | |||
@@ -997,7 +997,7 @@ struct aac_dev | |||
997 | int maximum_num_physicals; | 997 | int maximum_num_physicals; |
998 | int maximum_num_channels; | 998 | int maximum_num_channels; |
999 | struct fsa_dev_info *fsa_dev; | 999 | struct fsa_dev_info *fsa_dev; |
1000 | pid_t thread_pid; | 1000 | struct task_struct *thread; |
1001 | int cardtype; | 1001 | int cardtype; |
1002 | 1002 | ||
1003 | /* | 1003 | /* |
@@ -1017,7 +1017,6 @@ struct aac_dev | |||
1017 | * AIF thread states | 1017 | * AIF thread states |
1018 | */ | 1018 | */ |
1019 | u32 aif_thread; | 1019 | u32 aif_thread; |
1020 | struct completion aif_completion; | ||
1021 | struct aac_adapter_info adapter_info; | 1020 | struct aac_adapter_info adapter_info; |
1022 | struct aac_supplement_adapter_info supplement_adapter_info; | 1021 | struct aac_supplement_adapter_info supplement_adapter_info; |
1023 | /* These are in adapter info but they are in the io flow so | 1022 | /* 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); | |||
1797 | unsigned int aac_response_normal(struct aac_queue * q); | 1796 | unsigned int aac_response_normal(struct aac_queue * q); |
1798 | unsigned int aac_command_normal(struct aac_queue * q); | 1797 | unsigned int aac_command_normal(struct aac_queue * q); |
1799 | unsigned int aac_intr_normal(struct aac_dev * dev, u32 Index); | 1798 | unsigned int aac_intr_normal(struct aac_dev * dev, u32 Index); |
1800 | int aac_command_thread(struct aac_dev * dev); | 1799 | int aac_command_thread(void *data); |
1801 | int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context *fibctx); | 1800 | int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context *fibctx); |
1802 | int aac_fib_adapter_complete(struct fib * fibptr, unsigned short size); | 1801 | int aac_fib_adapter_complete(struct fib * fibptr, unsigned short size); |
1803 | struct aac_driver_ident* aac_get_driver_ident(int devtype); | 1802 | struct aac_driver_ident* aac_get_driver_ident(int devtype); |
diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index 1628d094943d..19397453bae7 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c | |||
@@ -433,7 +433,6 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev) | |||
433 | } | 433 | } |
434 | 434 | ||
435 | INIT_LIST_HEAD(&dev->fib_list); | 435 | INIT_LIST_HEAD(&dev->fib_list); |
436 | init_completion(&dev->aif_completion); | ||
437 | 436 | ||
438 | return dev; | 437 | return dev; |
439 | } | 438 | } |
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 609fd19b1844..c7f80ec7abde 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/completion.h> | 39 | #include <linux/completion.h> |
40 | #include <linux/blkdev.h> | 40 | #include <linux/blkdev.h> |
41 | #include <linux/delay.h> | 41 | #include <linux/delay.h> |
42 | #include <linux/kthread.h> | ||
42 | #include <scsi/scsi_host.h> | 43 | #include <scsi/scsi_host.h> |
43 | #include <scsi/scsi_device.h> | 44 | #include <scsi/scsi_device.h> |
44 | #include <asm/semaphore.h> | 45 | #include <asm/semaphore.h> |
@@ -1045,8 +1046,9 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) | |||
1045 | * more FIBs. | 1046 | * more FIBs. |
1046 | */ | 1047 | */ |
1047 | 1048 | ||
1048 | int aac_command_thread(struct aac_dev * dev) | 1049 | int aac_command_thread(void *data) |
1049 | { | 1050 | { |
1051 | struct aac_dev *dev = data; | ||
1050 | struct hw_fib *hw_fib, *hw_newfib; | 1052 | struct hw_fib *hw_fib, *hw_newfib; |
1051 | struct fib *fib, *newfib; | 1053 | struct fib *fib, *newfib; |
1052 | struct aac_fib_context *fibctx; | 1054 | struct aac_fib_context *fibctx; |
@@ -1058,12 +1060,7 @@ int aac_command_thread(struct aac_dev * dev) | |||
1058 | */ | 1060 | */ |
1059 | if (dev->aif_thread) | 1061 | if (dev->aif_thread) |
1060 | return -EINVAL; | 1062 | return -EINVAL; |
1061 | /* | 1063 | |
1062 | * Set up the name that will appear in 'ps' | ||
1063 | * stored in task_struct.comm[16]. | ||
1064 | */ | ||
1065 | daemonize("aacraid"); | ||
1066 | allow_signal(SIGKILL); | ||
1067 | /* | 1064 | /* |
1068 | * Let the DPC know it has a place to send the AIF's to. | 1065 | * Let the DPC know it has a place to send the AIF's to. |
1069 | */ | 1066 | */ |
@@ -1266,13 +1263,12 @@ int aac_command_thread(struct aac_dev * dev) | |||
1266 | spin_unlock_irqrestore(dev->queues->queue[HostNormCmdQueue].lock, flags); | 1263 | spin_unlock_irqrestore(dev->queues->queue[HostNormCmdQueue].lock, flags); |
1267 | schedule(); | 1264 | schedule(); |
1268 | 1265 | ||
1269 | if(signal_pending(current)) | 1266 | if (kthread_should_stop()) |
1270 | break; | 1267 | break; |
1271 | set_current_state(TASK_INTERRUPTIBLE); | 1268 | set_current_state(TASK_INTERRUPTIBLE); |
1272 | } | 1269 | } |
1273 | if (dev->queues) | 1270 | if (dev->queues) |
1274 | remove_wait_queue(&dev->queues->queue[HostNormCmdQueue].cmdready, &wait); | 1271 | remove_wait_queue(&dev->queues->queue[HostNormCmdQueue].cmdready, &wait); |
1275 | dev->aif_thread = 0; | 1272 | dev->aif_thread = 0; |
1276 | complete_and_exit(&dev->aif_completion, 0); | ||
1277 | return 0; | 1273 | return 0; |
1278 | } | 1274 | } |
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 271617890562..c2596335549d 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <linux/syscalls.h> | 48 | #include <linux/syscalls.h> |
49 | #include <linux/delay.h> | 49 | #include <linux/delay.h> |
50 | #include <linux/smp_lock.h> | 50 | #include <linux/smp_lock.h> |
51 | #include <linux/kthread.h> | ||
51 | #include <asm/semaphore.h> | 52 | #include <asm/semaphore.h> |
52 | 53 | ||
53 | #include <scsi/scsi.h> | 54 | #include <scsi/scsi.h> |
@@ -850,10 +851,10 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, | |||
850 | /* | 851 | /* |
851 | * Start any kernel threads needed | 852 | * Start any kernel threads needed |
852 | */ | 853 | */ |
853 | aac->thread_pid = kernel_thread((int (*)(void *))aac_command_thread, | 854 | aac->thread = kthread_run(aac_command_thread, aac, AAC_DRIVERNAME); |
854 | aac, 0); | 855 | if (IS_ERR(aac->thread)) { |
855 | if (aac->thread_pid < 0) { | ||
856 | printk(KERN_ERR "aacraid: Unable to create command thread.\n"); | 856 | printk(KERN_ERR "aacraid: Unable to create command thread.\n"); |
857 | error = PTR_ERR(aac->thread); | ||
857 | goto out_deinit; | 858 | goto out_deinit; |
858 | } | 859 | } |
859 | 860 | ||
@@ -934,9 +935,7 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, | |||
934 | return 0; | 935 | return 0; |
935 | 936 | ||
936 | out_deinit: | 937 | out_deinit: |
937 | kill_proc(aac->thread_pid, SIGKILL, 0); | 938 | kthread_stop(aac->thread); |
938 | wait_for_completion(&aac->aif_completion); | ||
939 | |||
940 | aac_send_shutdown(aac); | 939 | aac_send_shutdown(aac); |
941 | aac_adapter_disable_int(aac); | 940 | aac_adapter_disable_int(aac); |
942 | free_irq(pdev->irq, aac); | 941 | free_irq(pdev->irq, aac); |
@@ -970,8 +969,7 @@ static void __devexit aac_remove_one(struct pci_dev *pdev) | |||
970 | 969 | ||
971 | scsi_remove_host(shost); | 970 | scsi_remove_host(shost); |
972 | 971 | ||
973 | kill_proc(aac->thread_pid, SIGKILL, 0); | 972 | kthread_stop(aac->thread); |
974 | wait_for_completion(&aac->aif_completion); | ||
975 | 973 | ||
976 | aac_send_shutdown(aac); | 974 | aac_send_shutdown(aac); |
977 | aac_adapter_disable_int(aac); | 975 | aac_adapter_disable_int(aac); |