Skip to content

Commit

Permalink
[POWERPC] macintosh: therm_pm72: driver_lock semaphore to mutex
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Walker <dwalker@mvista.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Daniel Walker authored and Paul Mackerras committed May 5, 2008
1 parent f74d505 commit 0885cb5
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions drivers/macintosh/therm_pm72.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
#include <linux/kmod.h>
#include <linux/i2c.h>
#include <linux/kthread.h>
#include <linux/mutex.h>
#include <asm/prom.h>
#include <asm/machdep.h>
#include <asm/io.h>
Expand Down Expand Up @@ -169,7 +170,7 @@ static int rackmac;
static s32 dimm_output_clamp;
static int fcu_rpm_shift;
static int fcu_tickle_ticks;
static DECLARE_MUTEX(driver_lock);
static DEFINE_MUTEX(driver_lock);

/*
* We have 3 types of CPU PID control. One is "split" old style control
Expand Down Expand Up @@ -729,9 +730,9 @@ static void fetch_cpu_pumps_minmax(void)
static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
{ \
ssize_t r; \
down(&driver_lock); \
mutex_lock(&driver_lock); \
r = sprintf(buf, "%d.%03d", FIX32TOPRINT(data)); \
up(&driver_lock); \
mutex_unlock(&driver_lock); \
return r; \
}
#define BUILD_SHOW_FUNC_INT(name, data) \
Expand Down Expand Up @@ -1803,11 +1804,11 @@ static int main_control_loop(void *x)
{
DBG("main_control_loop started\n");

down(&driver_lock);
mutex_lock(&driver_lock);

if (start_fcu() < 0) {
printk(KERN_ERR "kfand: failed to start FCU\n");
up(&driver_lock);
mutex_unlock(&driver_lock);
goto out;
}

Expand All @@ -1822,14 +1823,14 @@ static int main_control_loop(void *x)

fcu_tickle_ticks = FCU_TICKLE_TICKS;

up(&driver_lock);
mutex_unlock(&driver_lock);

while (state == state_attached) {
unsigned long elapsed, start;

start = jiffies;

down(&driver_lock);
mutex_lock(&driver_lock);

/* Tickle the FCU just in case */
if (--fcu_tickle_ticks < 0) {
Expand Down Expand Up @@ -1861,7 +1862,7 @@ static int main_control_loop(void *x)
do_monitor_slots(&slots_state);
else
do_monitor_drives(&drives_state);
up(&driver_lock);
mutex_unlock(&driver_lock);

if (critical_state == 1) {
printk(KERN_WARNING "Temperature control detected a critical condition\n");
Expand Down Expand Up @@ -2019,13 +2020,13 @@ static void detach_fcu(void)
*/
static int therm_pm72_attach(struct i2c_adapter *adapter)
{
down(&driver_lock);
mutex_lock(&driver_lock);

/* Check state */
if (state == state_detached)
state = state_attaching;
if (state != state_attaching) {
up(&driver_lock);
mutex_unlock(&driver_lock);
return 0;
}

Expand Down Expand Up @@ -2054,7 +2055,7 @@ static int therm_pm72_attach(struct i2c_adapter *adapter)
state = state_attached;
start_control_loops();
}
up(&driver_lock);
mutex_unlock(&driver_lock);

return 0;
}
Expand All @@ -2065,16 +2066,16 @@ static int therm_pm72_attach(struct i2c_adapter *adapter)
*/
static int therm_pm72_detach(struct i2c_adapter *adapter)
{
down(&driver_lock);
mutex_lock(&driver_lock);

if (state != state_detached)
state = state_detaching;

/* Stop control loops if any */
DBG("stopping control loops\n");
up(&driver_lock);
mutex_unlock(&driver_lock);
stop_control_loops();
down(&driver_lock);
mutex_lock(&driver_lock);

if (u3_0 != NULL && !strcmp(adapter->name, "u3 0")) {
DBG("lost U3-0, disposing control loops\n");
Expand All @@ -2090,7 +2091,7 @@ static int therm_pm72_detach(struct i2c_adapter *adapter)
if (u3_0 == NULL && u3_1 == NULL)
state = state_detached;

up(&driver_lock);
mutex_unlock(&driver_lock);

return 0;
}
Expand Down

0 comments on commit 0885cb5

Please sign in to comment.