aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/ibmphp_hpc.c
diff options
context:
space:
mode:
authorKristen Carlson Accardi <kristen.c.accardi@intel.com>2007-08-14 19:07:00 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-10-12 18:03:15 -0400
commit2d100fe8f6ebe5e4335b26f3749bb0b7f706d1f9 (patch)
treef7af5282ec0eae0569a46a7500e70ba18004b6e6 /drivers/pci/hotplug/ibmphp_hpc.c
parent229f5afded86bf3819b7b67e57c62813ca0648a7 (diff)
pci: hotplug: ibmphp: convert to kthread
Convert ibmphp to new kthread api Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/hotplug/ibmphp_hpc.c')
-rw-r--r--drivers/pci/hotplug/ibmphp_hpc.c57
1 files changed, 12 insertions, 45 deletions
diff --git a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c
index d06ccb69e411..c31e7bf34502 100644
--- a/drivers/pci/hotplug/ibmphp_hpc.c
+++ b/drivers/pci/hotplug/ibmphp_hpc.c
@@ -35,7 +35,7 @@
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <linux/sched.h> 37#include <linux/sched.h>
38 38#include <linux/kthread.h>
39#include "ibmphp.h" 39#include "ibmphp.h"
40 40
41static int to_debug = 0; 41static int to_debug = 0;
@@ -101,12 +101,11 @@ static int to_debug = 0;
101//---------------------------------------------------------------------------- 101//----------------------------------------------------------------------------
102// global variables 102// global variables
103//---------------------------------------------------------------------------- 103//----------------------------------------------------------------------------
104static int ibmphp_shutdown;
105static int tid_poll;
106static struct mutex sem_hpcaccess; // lock access to HPC 104static struct mutex sem_hpcaccess; // lock access to HPC
107static struct semaphore semOperations; // lock all operations and 105static struct semaphore semOperations; // lock all operations and
108 // access to data structures 106 // access to data structures
109static struct semaphore sem_exit; // make sure polling thread goes away 107static struct semaphore sem_exit; // make sure polling thread goes away
108static struct task_struct *ibmphp_poll_thread;
110//---------------------------------------------------------------------------- 109//----------------------------------------------------------------------------
111// local function prototypes 110// local function prototypes
112//---------------------------------------------------------------------------- 111//----------------------------------------------------------------------------
@@ -116,10 +115,9 @@ static u8 hpc_writecmdtoindex (u8, u8);
116static u8 hpc_readcmdtoindex (u8, u8); 115static u8 hpc_readcmdtoindex (u8, u8);
117static void get_hpc_access (void); 116static void get_hpc_access (void);
118static void free_hpc_access (void); 117static void free_hpc_access (void);
119static void poll_hpc (void); 118static int poll_hpc(void *data);
120static int process_changeinstatus (struct slot *, struct slot *); 119static int process_changeinstatus (struct slot *, struct slot *);
121static int process_changeinlatch (u8, u8, struct controller *); 120static int process_changeinlatch (u8, u8, struct controller *);
122static int hpc_poll_thread (void *);
123static int hpc_wait_ctlr_notworking (int, struct controller *, void __iomem *, u8 *); 121static int hpc_wait_ctlr_notworking (int, struct controller *, void __iomem *, u8 *);
124//---------------------------------------------------------------------------- 122//----------------------------------------------------------------------------
125 123
@@ -137,8 +135,6 @@ void __init ibmphp_hpc_initvars (void)
137 init_MUTEX (&semOperations); 135 init_MUTEX (&semOperations);
138 init_MUTEX_LOCKED (&sem_exit); 136 init_MUTEX_LOCKED (&sem_exit);
139 to_debug = 0; 137 to_debug = 0;
140 ibmphp_shutdown = 0;
141 tid_poll = 0;
142 138
143 debug ("%s - Exit\n", __FUNCTION__); 139 debug ("%s - Exit\n", __FUNCTION__);
144} 140}
@@ -819,7 +815,7 @@ void ibmphp_unlock_operations (void)
819#define POLL_LATCH_REGISTER 0 815#define POLL_LATCH_REGISTER 0
820#define POLL_SLOTS 1 816#define POLL_SLOTS 1
821#define POLL_SLEEP 2 817#define POLL_SLEEP 2
822static void poll_hpc (void) 818static int poll_hpc(void *data)
823{ 819{
824 struct slot myslot; 820 struct slot myslot;
825 struct slot *pslot = NULL; 821 struct slot *pslot = NULL;
@@ -833,10 +829,7 @@ static void poll_hpc (void)
833 829
834 debug ("%s - Entry\n", __FUNCTION__); 830 debug ("%s - Entry\n", __FUNCTION__);
835 831
836 while (!ibmphp_shutdown) { 832 while (!kthread_should_stop()) {
837 if (ibmphp_shutdown)
838 break;
839
840 /* try to get the lock to do some kind of hardware access */ 833 /* try to get the lock to do some kind of hardware access */
841 down (&semOperations); 834 down (&semOperations);
842 835
@@ -896,7 +889,7 @@ static void poll_hpc (void)
896 up (&semOperations); 889 up (&semOperations);
897 msleep(POLL_INTERVAL_SEC * 1000); 890 msleep(POLL_INTERVAL_SEC * 1000);
898 891
899 if (ibmphp_shutdown) 892 if (kthread_should_stop())
900 break; 893 break;
901 894
902 down (&semOperations); 895 down (&semOperations);
@@ -915,6 +908,7 @@ static void poll_hpc (void)
915 } 908 }
916 up (&sem_exit); 909 up (&sem_exit);
917 debug ("%s - Exit\n", __FUNCTION__); 910 debug ("%s - Exit\n", __FUNCTION__);
911 return 0;
918} 912}
919 913
920 914
@@ -1050,47 +1044,20 @@ static int process_changeinlatch (u8 old, u8 new, struct controller *ctrl)
1050} 1044}
1051 1045
1052/*---------------------------------------------------------------------- 1046/*----------------------------------------------------------------------
1053* Name: hpc_poll_thread
1054*
1055* Action: polling
1056*
1057* Return 0
1058* Value:
1059*---------------------------------------------------------------------*/
1060static int hpc_poll_thread (void *data)
1061{
1062 debug ("%s - Entry\n", __FUNCTION__);
1063
1064 daemonize("hpc_poll");
1065 allow_signal(SIGKILL);
1066
1067 poll_hpc ();
1068
1069 tid_poll = 0;
1070 debug ("%s - Exit\n", __FUNCTION__);
1071 return 0;
1072}
1073
1074
1075/*----------------------------------------------------------------------
1076* Name: ibmphp_hpc_start_poll_thread 1047* Name: ibmphp_hpc_start_poll_thread
1077* 1048*
1078* Action: start polling thread 1049* Action: start polling thread
1079*---------------------------------------------------------------------*/ 1050*---------------------------------------------------------------------*/
1080int __init ibmphp_hpc_start_poll_thread (void) 1051int __init ibmphp_hpc_start_poll_thread (void)
1081{ 1052{
1082 int rc = 0;
1083
1084 debug ("%s - Entry\n", __FUNCTION__); 1053 debug ("%s - Entry\n", __FUNCTION__);
1085 1054
1086 tid_poll = kernel_thread (hpc_poll_thread, NULL, 0); 1055 ibmphp_poll_thread = kthread_run(poll_hpc, NULL, "hpc_poll");
1087 if (tid_poll < 0) { 1056 if (IS_ERR(ibmphp_poll_thread)) {
1088 err ("%s - Error, thread not started\n", __FUNCTION__); 1057 err ("%s - Error, thread not started\n", __FUNCTION__);
1089 rc = -1; 1058 return PTR_ERR(ibmphp_poll_thread);
1090 } 1059 }
1091 1060 return 0;
1092 debug ("%s - Exit tid_poll[%d] rc[%d]\n", __FUNCTION__, tid_poll, rc);
1093 return rc;
1094} 1061}
1095 1062
1096/*---------------------------------------------------------------------- 1063/*----------------------------------------------------------------------
@@ -1102,7 +1069,7 @@ void __exit ibmphp_hpc_stop_poll_thread (void)
1102{ 1069{
1103 debug ("%s - Entry\n", __FUNCTION__); 1070 debug ("%s - Entry\n", __FUNCTION__);
1104 1071
1105 ibmphp_shutdown = 1; 1072 kthread_stop(ibmphp_poll_thread);
1106 debug ("before locking operations \n"); 1073 debug ("before locking operations \n");
1107 ibmphp_lock_operations (); 1074 ibmphp_lock_operations ();
1108 debug ("after locking operations \n"); 1075 debug ("after locking operations \n");