diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/macintosh/adb.c | 30 | ||||
-rw-r--r-- | drivers/macintosh/therm_pm72.c | 31 | ||||
-rw-r--r-- | drivers/macintosh/windfarm_smu_sat.c | 10 |
3 files changed, 36 insertions, 35 deletions
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c index 20978205cd02..b8b9e44f7f4e 100644 --- a/drivers/macintosh/adb.c +++ b/drivers/macintosh/adb.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <linux/device.h> | 37 | #include <linux/device.h> |
38 | #include <linux/kthread.h> | 38 | #include <linux/kthread.h> |
39 | #include <linux/platform_device.h> | 39 | #include <linux/platform_device.h> |
40 | #include <linux/semaphore.h> | 40 | #include <linux/mutex.h> |
41 | 41 | ||
42 | #include <asm/uaccess.h> | 42 | #include <asm/uaccess.h> |
43 | #ifdef CONFIG_PPC | 43 | #ifdef CONFIG_PPC |
@@ -102,7 +102,7 @@ static struct adb_handler { | |||
102 | } adb_handler[16]; | 102 | } adb_handler[16]; |
103 | 103 | ||
104 | /* | 104 | /* |
105 | * The adb_handler_sem mutex protects all accesses to the original_address | 105 | * The adb_handler_mutex mutex protects all accesses to the original_address |
106 | * and handler_id fields of adb_handler[i] for all i, and changes to the | 106 | * and handler_id fields of adb_handler[i] for all i, and changes to the |
107 | * handler field. | 107 | * handler field. |
108 | * Accesses to the handler field are protected by the adb_handler_lock | 108 | * Accesses to the handler field are protected by the adb_handler_lock |
@@ -110,7 +110,7 @@ static struct adb_handler { | |||
110 | * time adb_unregister returns, we know that the old handler isn't being | 110 | * time adb_unregister returns, we know that the old handler isn't being |
111 | * called. | 111 | * called. |
112 | */ | 112 | */ |
113 | static DECLARE_MUTEX(adb_handler_sem); | 113 | static DEFINE_MUTEX(adb_handler_mutex); |
114 | static DEFINE_RWLOCK(adb_handler_lock); | 114 | static DEFINE_RWLOCK(adb_handler_lock); |
115 | 115 | ||
116 | #if 0 | 116 | #if 0 |
@@ -355,7 +355,7 @@ do_adb_reset_bus(void) | |||
355 | msleep(500); | 355 | msleep(500); |
356 | } | 356 | } |
357 | 357 | ||
358 | down(&adb_handler_sem); | 358 | mutex_lock(&adb_handler_mutex); |
359 | write_lock_irq(&adb_handler_lock); | 359 | write_lock_irq(&adb_handler_lock); |
360 | memset(adb_handler, 0, sizeof(adb_handler)); | 360 | memset(adb_handler, 0, sizeof(adb_handler)); |
361 | write_unlock_irq(&adb_handler_lock); | 361 | write_unlock_irq(&adb_handler_lock); |
@@ -376,7 +376,7 @@ do_adb_reset_bus(void) | |||
376 | if (adb_controller->autopoll) | 376 | if (adb_controller->autopoll) |
377 | adb_controller->autopoll(autopoll_devs); | 377 | adb_controller->autopoll(autopoll_devs); |
378 | } | 378 | } |
379 | up(&adb_handler_sem); | 379 | mutex_unlock(&adb_handler_mutex); |
380 | 380 | ||
381 | blocking_notifier_call_chain(&adb_client_list, | 381 | blocking_notifier_call_chain(&adb_client_list, |
382 | ADB_MSG_POST_RESET, NULL); | 382 | ADB_MSG_POST_RESET, NULL); |
@@ -454,7 +454,7 @@ adb_register(int default_id, int handler_id, struct adb_ids *ids, | |||
454 | { | 454 | { |
455 | int i; | 455 | int i; |
456 | 456 | ||
457 | down(&adb_handler_sem); | 457 | mutex_lock(&adb_handler_mutex); |
458 | ids->nids = 0; | 458 | ids->nids = 0; |
459 | for (i = 1; i < 16; i++) { | 459 | for (i = 1; i < 16; i++) { |
460 | if ((adb_handler[i].original_address == default_id) && | 460 | if ((adb_handler[i].original_address == default_id) && |
@@ -472,7 +472,7 @@ adb_register(int default_id, int handler_id, struct adb_ids *ids, | |||
472 | ids->id[ids->nids++] = i; | 472 | ids->id[ids->nids++] = i; |
473 | } | 473 | } |
474 | } | 474 | } |
475 | up(&adb_handler_sem); | 475 | mutex_unlock(&adb_handler_mutex); |
476 | return ids->nids; | 476 | return ids->nids; |
477 | } | 477 | } |
478 | 478 | ||
@@ -481,7 +481,7 @@ adb_unregister(int index) | |||
481 | { | 481 | { |
482 | int ret = -ENODEV; | 482 | int ret = -ENODEV; |
483 | 483 | ||
484 | down(&adb_handler_sem); | 484 | mutex_lock(&adb_handler_mutex); |
485 | write_lock_irq(&adb_handler_lock); | 485 | write_lock_irq(&adb_handler_lock); |
486 | if (adb_handler[index].handler) { | 486 | if (adb_handler[index].handler) { |
487 | while(adb_handler[index].busy) { | 487 | while(adb_handler[index].busy) { |
@@ -493,7 +493,7 @@ adb_unregister(int index) | |||
493 | adb_handler[index].handler = NULL; | 493 | adb_handler[index].handler = NULL; |
494 | } | 494 | } |
495 | write_unlock_irq(&adb_handler_lock); | 495 | write_unlock_irq(&adb_handler_lock); |
496 | up(&adb_handler_sem); | 496 | mutex_unlock(&adb_handler_mutex); |
497 | return ret; | 497 | return ret; |
498 | } | 498 | } |
499 | 499 | ||
@@ -557,19 +557,19 @@ adb_try_handler_change(int address, int new_id) | |||
557 | { | 557 | { |
558 | int ret; | 558 | int ret; |
559 | 559 | ||
560 | down(&adb_handler_sem); | 560 | mutex_lock(&adb_handler_mutex); |
561 | ret = try_handler_change(address, new_id); | 561 | ret = try_handler_change(address, new_id); |
562 | up(&adb_handler_sem); | 562 | mutex_unlock(&adb_handler_mutex); |
563 | return ret; | 563 | return ret; |
564 | } | 564 | } |
565 | 565 | ||
566 | int | 566 | int |
567 | adb_get_infos(int address, int *original_address, int *handler_id) | 567 | adb_get_infos(int address, int *original_address, int *handler_id) |
568 | { | 568 | { |
569 | down(&adb_handler_sem); | 569 | mutex_lock(&adb_handler_mutex); |
570 | *original_address = adb_handler[address].original_address; | 570 | *original_address = adb_handler[address].original_address; |
571 | *handler_id = adb_handler[address].handler_id; | 571 | *handler_id = adb_handler[address].handler_id; |
572 | up(&adb_handler_sem); | 572 | mutex_unlock(&adb_handler_mutex); |
573 | 573 | ||
574 | return (*original_address != 0); | 574 | return (*original_address != 0); |
575 | } | 575 | } |
@@ -628,10 +628,10 @@ do_adb_query(struct adb_request *req) | |||
628 | case ADB_QUERY_GETDEVINFO: | 628 | case ADB_QUERY_GETDEVINFO: |
629 | if (req->nbytes < 3) | 629 | if (req->nbytes < 3) |
630 | break; | 630 | break; |
631 | down(&adb_handler_sem); | 631 | mutex_lock(&adb_handler_mutex); |
632 | req->reply[0] = adb_handler[req->data[2]].original_address; | 632 | req->reply[0] = adb_handler[req->data[2]].original_address; |
633 | req->reply[1] = adb_handler[req->data[2]].handler_id; | 633 | req->reply[1] = adb_handler[req->data[2]].handler_id; |
634 | up(&adb_handler_sem); | 634 | mutex_unlock(&adb_handler_mutex); |
635 | req->complete = 1; | 635 | req->complete = 1; |
636 | req->reply_len = 2; | 636 | req->reply_len = 2; |
637 | adb_write_done(req); | 637 | adb_write_done(req); |
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 | } |
diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c index 797918d0e59c..7f2be4baaeda 100644 --- a/drivers/macintosh/windfarm_smu_sat.c +++ b/drivers/macintosh/windfarm_smu_sat.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/wait.h> | 14 | #include <linux/wait.h> |
15 | #include <linux/i2c.h> | 15 | #include <linux/i2c.h> |
16 | #include <linux/semaphore.h> | 16 | #include <linux/mutex.h> |
17 | #include <asm/prom.h> | 17 | #include <asm/prom.h> |
18 | #include <asm/smu.h> | 18 | #include <asm/smu.h> |
19 | #include <asm/pmac_low_i2c.h> | 19 | #include <asm/pmac_low_i2c.h> |
@@ -36,7 +36,7 @@ | |||
36 | struct wf_sat { | 36 | struct wf_sat { |
37 | int nr; | 37 | int nr; |
38 | atomic_t refcnt; | 38 | atomic_t refcnt; |
39 | struct semaphore mutex; | 39 | struct mutex mutex; |
40 | unsigned long last_read; /* jiffies when cache last updated */ | 40 | unsigned long last_read; /* jiffies when cache last updated */ |
41 | u8 cache[16]; | 41 | u8 cache[16]; |
42 | struct i2c_client i2c; | 42 | struct i2c_client i2c; |
@@ -163,7 +163,7 @@ static int wf_sat_get(struct wf_sensor *sr, s32 *value) | |||
163 | if (sat->i2c.adapter == NULL) | 163 | if (sat->i2c.adapter == NULL) |
164 | return -ENODEV; | 164 | return -ENODEV; |
165 | 165 | ||
166 | down(&sat->mutex); | 166 | mutex_lock(&sat->mutex); |
167 | if (time_after(jiffies, (sat->last_read + MAX_AGE))) { | 167 | if (time_after(jiffies, (sat->last_read + MAX_AGE))) { |
168 | err = wf_sat_read_cache(sat); | 168 | err = wf_sat_read_cache(sat); |
169 | if (err) | 169 | if (err) |
@@ -182,7 +182,7 @@ static int wf_sat_get(struct wf_sensor *sr, s32 *value) | |||
182 | err = 0; | 182 | err = 0; |
183 | 183 | ||
184 | fail: | 184 | fail: |
185 | up(&sat->mutex); | 185 | mutex_unlock(&sat->mutex); |
186 | return err; | 186 | return err; |
187 | } | 187 | } |
188 | 188 | ||
@@ -233,7 +233,7 @@ static void wf_sat_create(struct i2c_adapter *adapter, struct device_node *dev) | |||
233 | sat->nr = -1; | 233 | sat->nr = -1; |
234 | sat->node = of_node_get(dev); | 234 | sat->node = of_node_get(dev); |
235 | atomic_set(&sat->refcnt, 0); | 235 | atomic_set(&sat->refcnt, 0); |
236 | init_MUTEX(&sat->mutex); | 236 | mutex_init(&sat->mutex); |
237 | sat->i2c.addr = (addr >> 1) & 0x7f; | 237 | sat->i2c.addr = (addr >> 1) & 0x7f; |
238 | sat->i2c.adapter = adapter; | 238 | sat->i2c.adapter = adapter; |
239 | sat->i2c.driver = &wf_sat_driver; | 239 | sat->i2c.driver = &wf_sat_driver; |