diff options
author | Daniel Walker <dwalker@mvista.com> | 2008-05-02 16:34:01 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-05-05 02:47:13 -0400 |
commit | 0885cb5653ff82c8d322df1b8a95843dc5f5486b (patch) | |
tree | 3f92f533b28696e4c0f1e2e1037cbfc3005c7bc2 | |
parent | f74d505b58d36ceeef10e459094f0eb760681165 (diff) |
[POWERPC] macintosh: therm_pm72: driver_lock semaphore to mutex
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>
-rw-r--r-- | drivers/macintosh/therm_pm72.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c index 1e0a69a5e815..ddfb426a9abd 100644 --- a/drivers/macintosh/therm_pm72.c +++ b/drivers/macintosh/therm_pm72.c | |||
@@ -122,6 +122,7 @@ | |||
122 | #include <linux/kmod.h> | 122 | #include <linux/kmod.h> |
123 | #include <linux/i2c.h> | 123 | #include <linux/i2c.h> |
124 | #include <linux/kthread.h> | 124 | #include <linux/kthread.h> |
125 | #include <linux/mutex.h> | ||
125 | #include <asm/prom.h> | 126 | #include <asm/prom.h> |
126 | #include <asm/machdep.h> | 127 | #include <asm/machdep.h> |
127 | #include <asm/io.h> | 128 | #include <asm/io.h> |
@@ -169,7 +170,7 @@ static int rackmac; | |||
169 | static s32 dimm_output_clamp; | 170 | static s32 dimm_output_clamp; |
170 | static int fcu_rpm_shift; | 171 | static int fcu_rpm_shift; |
171 | static int fcu_tickle_ticks; | 172 | static int fcu_tickle_ticks; |
172 | static DECLARE_MUTEX(driver_lock); | 173 | static DEFINE_MUTEX(driver_lock); |
173 | 174 | ||
174 | /* | 175 | /* |
175 | * We have 3 types of CPU PID control. One is "split" old style control | 176 | * We have 3 types of CPU PID control. One is "split" old style control |
@@ -729,9 +730,9 @@ static void fetch_cpu_pumps_minmax(void) | |||
729 | static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \ | 730 | static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \ |
730 | { \ | 731 | { \ |
731 | ssize_t r; \ | 732 | ssize_t r; \ |
732 | down(&driver_lock); \ | 733 | mutex_lock(&driver_lock); \ |
733 | r = sprintf(buf, "%d.%03d", FIX32TOPRINT(data)); \ | 734 | r = sprintf(buf, "%d.%03d", FIX32TOPRINT(data)); \ |
734 | up(&driver_lock); \ | 735 | mutex_unlock(&driver_lock); \ |
735 | return r; \ | 736 | return r; \ |
736 | } | 737 | } |
737 | #define BUILD_SHOW_FUNC_INT(name, data) \ | 738 | #define BUILD_SHOW_FUNC_INT(name, data) \ |
@@ -1803,11 +1804,11 @@ static int main_control_loop(void *x) | |||
1803 | { | 1804 | { |
1804 | DBG("main_control_loop started\n"); | 1805 | DBG("main_control_loop started\n"); |
1805 | 1806 | ||
1806 | down(&driver_lock); | 1807 | mutex_lock(&driver_lock); |
1807 | 1808 | ||
1808 | if (start_fcu() < 0) { | 1809 | if (start_fcu() < 0) { |
1809 | printk(KERN_ERR "kfand: failed to start FCU\n"); | 1810 | printk(KERN_ERR "kfand: failed to start FCU\n"); |
1810 | up(&driver_lock); | 1811 | mutex_unlock(&driver_lock); |
1811 | goto out; | 1812 | goto out; |
1812 | } | 1813 | } |
1813 | 1814 | ||
@@ -1822,14 +1823,14 @@ static int main_control_loop(void *x) | |||
1822 | 1823 | ||
1823 | fcu_tickle_ticks = FCU_TICKLE_TICKS; | 1824 | fcu_tickle_ticks = FCU_TICKLE_TICKS; |
1824 | 1825 | ||
1825 | up(&driver_lock); | 1826 | mutex_unlock(&driver_lock); |
1826 | 1827 | ||
1827 | while (state == state_attached) { | 1828 | while (state == state_attached) { |
1828 | unsigned long elapsed, start; | 1829 | unsigned long elapsed, start; |
1829 | 1830 | ||
1830 | start = jiffies; | 1831 | start = jiffies; |
1831 | 1832 | ||
1832 | down(&driver_lock); | 1833 | mutex_lock(&driver_lock); |
1833 | 1834 | ||
1834 | /* Tickle the FCU just in case */ | 1835 | /* Tickle the FCU just in case */ |
1835 | if (--fcu_tickle_ticks < 0) { | 1836 | if (--fcu_tickle_ticks < 0) { |
@@ -1861,7 +1862,7 @@ static int main_control_loop(void *x) | |||
1861 | do_monitor_slots(&slots_state); | 1862 | do_monitor_slots(&slots_state); |
1862 | else | 1863 | else |
1863 | do_monitor_drives(&drives_state); | 1864 | do_monitor_drives(&drives_state); |
1864 | up(&driver_lock); | 1865 | mutex_unlock(&driver_lock); |
1865 | 1866 | ||
1866 | if (critical_state == 1) { | 1867 | if (critical_state == 1) { |
1867 | printk(KERN_WARNING "Temperature control detected a critical condition\n"); | 1868 | printk(KERN_WARNING "Temperature control detected a critical condition\n"); |
@@ -2019,13 +2020,13 @@ static void detach_fcu(void) | |||
2019 | */ | 2020 | */ |
2020 | static int therm_pm72_attach(struct i2c_adapter *adapter) | 2021 | static int therm_pm72_attach(struct i2c_adapter *adapter) |
2021 | { | 2022 | { |
2022 | down(&driver_lock); | 2023 | mutex_lock(&driver_lock); |
2023 | 2024 | ||
2024 | /* Check state */ | 2025 | /* Check state */ |
2025 | if (state == state_detached) | 2026 | if (state == state_detached) |
2026 | state = state_attaching; | 2027 | state = state_attaching; |
2027 | if (state != state_attaching) { | 2028 | if (state != state_attaching) { |
2028 | up(&driver_lock); | 2029 | mutex_unlock(&driver_lock); |
2029 | return 0; | 2030 | return 0; |
2030 | } | 2031 | } |
2031 | 2032 | ||
@@ -2054,7 +2055,7 @@ static int therm_pm72_attach(struct i2c_adapter *adapter) | |||
2054 | state = state_attached; | 2055 | state = state_attached; |
2055 | start_control_loops(); | 2056 | start_control_loops(); |
2056 | } | 2057 | } |
2057 | up(&driver_lock); | 2058 | mutex_unlock(&driver_lock); |
2058 | 2059 | ||
2059 | return 0; | 2060 | return 0; |
2060 | } | 2061 | } |
@@ -2065,16 +2066,16 @@ static int therm_pm72_attach(struct i2c_adapter *adapter) | |||
2065 | */ | 2066 | */ |
2066 | static int therm_pm72_detach(struct i2c_adapter *adapter) | 2067 | static int therm_pm72_detach(struct i2c_adapter *adapter) |
2067 | { | 2068 | { |
2068 | down(&driver_lock); | 2069 | mutex_lock(&driver_lock); |
2069 | 2070 | ||
2070 | if (state != state_detached) | 2071 | if (state != state_detached) |
2071 | state = state_detaching; | 2072 | state = state_detaching; |
2072 | 2073 | ||
2073 | /* Stop control loops if any */ | 2074 | /* Stop control loops if any */ |
2074 | DBG("stopping control loops\n"); | 2075 | DBG("stopping control loops\n"); |
2075 | up(&driver_lock); | 2076 | mutex_unlock(&driver_lock); |
2076 | stop_control_loops(); | 2077 | stop_control_loops(); |
2077 | down(&driver_lock); | 2078 | mutex_lock(&driver_lock); |
2078 | 2079 | ||
2079 | if (u3_0 != NULL && !strcmp(adapter->name, "u3 0")) { | 2080 | if (u3_0 != NULL && !strcmp(adapter->name, "u3 0")) { |
2080 | DBG("lost U3-0, disposing control loops\n"); | 2081 | DBG("lost U3-0, disposing control loops\n"); |
@@ -2090,7 +2091,7 @@ static int therm_pm72_detach(struct i2c_adapter *adapter) | |||
2090 | if (u3_0 == NULL && u3_1 == NULL) | 2091 | if (u3_0 == NULL && u3_1 == NULL) |
2091 | state = state_detached; | 2092 | state = state_detached; |
2092 | 2093 | ||
2093 | up(&driver_lock); | 2094 | mutex_unlock(&driver_lock); |
2094 | 2095 | ||
2095 | return 0; | 2096 | return 0; |
2096 | } | 2097 | } |