Commit 837e9594 authored by Ingo Molnar's avatar Ingo Molnar Committed by Paul Mackerras

[PATCH] sem2mutex: drivers/macintosh/windfarm_core.c

semaphore to mutex conversion.

the conversion was generated via scripts, and the result was validated
automatically via a script as well.

build and boot tested.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent 0f36b018
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/reboot.h> #include <linux/reboot.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/mutex.h>
#include "windfarm.h" #include "windfarm.h"
...@@ -48,7 +49,7 @@ ...@@ -48,7 +49,7 @@
static LIST_HEAD(wf_controls); static LIST_HEAD(wf_controls);
static LIST_HEAD(wf_sensors); static LIST_HEAD(wf_sensors);
static DECLARE_MUTEX(wf_lock); static DEFINE_MUTEX(wf_lock);
static struct notifier_block *wf_client_list; static struct notifier_block *wf_client_list;
static int wf_client_count; static int wf_client_count;
static unsigned int wf_overtemp; static unsigned int wf_overtemp;
...@@ -160,12 +161,12 @@ int wf_register_control(struct wf_control *new_ct) ...@@ -160,12 +161,12 @@ int wf_register_control(struct wf_control *new_ct)
{ {
struct wf_control *ct; struct wf_control *ct;
down(&wf_lock); mutex_lock(&wf_lock);
list_for_each_entry(ct, &wf_controls, link) { list_for_each_entry(ct, &wf_controls, link) {
if (!strcmp(ct->name, new_ct->name)) { if (!strcmp(ct->name, new_ct->name)) {
printk(KERN_WARNING "windfarm: trying to register" printk(KERN_WARNING "windfarm: trying to register"
" duplicate control %s\n", ct->name); " duplicate control %s\n", ct->name);
up(&wf_lock); mutex_unlock(&wf_lock);
return -EEXIST; return -EEXIST;
} }
} }
...@@ -175,7 +176,7 @@ int wf_register_control(struct wf_control *new_ct) ...@@ -175,7 +176,7 @@ int wf_register_control(struct wf_control *new_ct)
DBG("wf: Registered control %s\n", new_ct->name); DBG("wf: Registered control %s\n", new_ct->name);
wf_notify(WF_EVENT_NEW_CONTROL, new_ct); wf_notify(WF_EVENT_NEW_CONTROL, new_ct);
up(&wf_lock); mutex_unlock(&wf_lock);
return 0; return 0;
} }
...@@ -183,9 +184,9 @@ EXPORT_SYMBOL_GPL(wf_register_control); ...@@ -183,9 +184,9 @@ EXPORT_SYMBOL_GPL(wf_register_control);
void wf_unregister_control(struct wf_control *ct) void wf_unregister_control(struct wf_control *ct)
{ {
down(&wf_lock); mutex_lock(&wf_lock);
list_del(&ct->link); list_del(&ct->link);
up(&wf_lock); mutex_unlock(&wf_lock);
DBG("wf: Unregistered control %s\n", ct->name); DBG("wf: Unregistered control %s\n", ct->name);
...@@ -197,16 +198,16 @@ struct wf_control * wf_find_control(const char *name) ...@@ -197,16 +198,16 @@ struct wf_control * wf_find_control(const char *name)
{ {
struct wf_control *ct; struct wf_control *ct;
down(&wf_lock); mutex_lock(&wf_lock);
list_for_each_entry(ct, &wf_controls, link) { list_for_each_entry(ct, &wf_controls, link) {
if (!strcmp(ct->name, name)) { if (!strcmp(ct->name, name)) {
if (wf_get_control(ct)) if (wf_get_control(ct))
ct = NULL; ct = NULL;
up(&wf_lock); mutex_unlock(&wf_lock);
return ct; return ct;
} }
} }
up(&wf_lock); mutex_unlock(&wf_lock);
return NULL; return NULL;
} }
EXPORT_SYMBOL_GPL(wf_find_control); EXPORT_SYMBOL_GPL(wf_find_control);
...@@ -250,12 +251,12 @@ int wf_register_sensor(struct wf_sensor *new_sr) ...@@ -250,12 +251,12 @@ int wf_register_sensor(struct wf_sensor *new_sr)
{ {
struct wf_sensor *sr; struct wf_sensor *sr;
down(&wf_lock); mutex_lock(&wf_lock);
list_for_each_entry(sr, &wf_sensors, link) { list_for_each_entry(sr, &wf_sensors, link) {
if (!strcmp(sr->name, new_sr->name)) { if (!strcmp(sr->name, new_sr->name)) {
printk(KERN_WARNING "windfarm: trying to register" printk(KERN_WARNING "windfarm: trying to register"
" duplicate sensor %s\n", sr->name); " duplicate sensor %s\n", sr->name);
up(&wf_lock); mutex_unlock(&wf_lock);
return -EEXIST; return -EEXIST;
} }
} }
...@@ -265,7 +266,7 @@ int wf_register_sensor(struct wf_sensor *new_sr) ...@@ -265,7 +266,7 @@ int wf_register_sensor(struct wf_sensor *new_sr)
DBG("wf: Registered sensor %s\n", new_sr->name); DBG("wf: Registered sensor %s\n", new_sr->name);
wf_notify(WF_EVENT_NEW_SENSOR, new_sr); wf_notify(WF_EVENT_NEW_SENSOR, new_sr);
up(&wf_lock); mutex_unlock(&wf_lock);
return 0; return 0;
} }
...@@ -273,9 +274,9 @@ EXPORT_SYMBOL_GPL(wf_register_sensor); ...@@ -273,9 +274,9 @@ EXPORT_SYMBOL_GPL(wf_register_sensor);
void wf_unregister_sensor(struct wf_sensor *sr) void wf_unregister_sensor(struct wf_sensor *sr)
{ {
down(&wf_lock); mutex_lock(&wf_lock);
list_del(&sr->link); list_del(&sr->link);
up(&wf_lock); mutex_unlock(&wf_lock);
DBG("wf: Unregistered sensor %s\n", sr->name); DBG("wf: Unregistered sensor %s\n", sr->name);
...@@ -287,16 +288,16 @@ struct wf_sensor * wf_find_sensor(const char *name) ...@@ -287,16 +288,16 @@ struct wf_sensor * wf_find_sensor(const char *name)
{ {
struct wf_sensor *sr; struct wf_sensor *sr;
down(&wf_lock); mutex_lock(&wf_lock);
list_for_each_entry(sr, &wf_sensors, link) { list_for_each_entry(sr, &wf_sensors, link) {
if (!strcmp(sr->name, name)) { if (!strcmp(sr->name, name)) {
if (wf_get_sensor(sr)) if (wf_get_sensor(sr))
sr = NULL; sr = NULL;
up(&wf_lock); mutex_unlock(&wf_lock);
return sr; return sr;
} }
} }
up(&wf_lock); mutex_unlock(&wf_lock);
return NULL; return NULL;
} }
EXPORT_SYMBOL_GPL(wf_find_sensor); EXPORT_SYMBOL_GPL(wf_find_sensor);
...@@ -329,7 +330,7 @@ int wf_register_client(struct notifier_block *nb) ...@@ -329,7 +330,7 @@ int wf_register_client(struct notifier_block *nb)
struct wf_control *ct; struct wf_control *ct;
struct wf_sensor *sr; struct wf_sensor *sr;
down(&wf_lock); mutex_lock(&wf_lock);
rc = notifier_chain_register(&wf_client_list, nb); rc = notifier_chain_register(&wf_client_list, nb);
if (rc != 0) if (rc != 0)
goto bail; goto bail;
...@@ -341,19 +342,19 @@ int wf_register_client(struct notifier_block *nb) ...@@ -341,19 +342,19 @@ int wf_register_client(struct notifier_block *nb)
if (wf_client_count == 1) if (wf_client_count == 1)
wf_start_thread(); wf_start_thread();
bail: bail:
up(&wf_lock); mutex_unlock(&wf_lock);
return rc; return rc;
} }
EXPORT_SYMBOL_GPL(wf_register_client); EXPORT_SYMBOL_GPL(wf_register_client);
int wf_unregister_client(struct notifier_block *nb) int wf_unregister_client(struct notifier_block *nb)
{ {
down(&wf_lock); mutex_lock(&wf_lock);
notifier_chain_unregister(&wf_client_list, nb); notifier_chain_unregister(&wf_client_list, nb);
wf_client_count++; wf_client_count++;
if (wf_client_count == 0) if (wf_client_count == 0)
wf_stop_thread(); wf_stop_thread();
up(&wf_lock); mutex_unlock(&wf_lock);
return 0; return 0;
} }
...@@ -361,23 +362,23 @@ EXPORT_SYMBOL_GPL(wf_unregister_client); ...@@ -361,23 +362,23 @@ EXPORT_SYMBOL_GPL(wf_unregister_client);
void wf_set_overtemp(void) void wf_set_overtemp(void)
{ {
down(&wf_lock); mutex_lock(&wf_lock);
wf_overtemp++; wf_overtemp++;
if (wf_overtemp == 1) { if (wf_overtemp == 1) {
printk(KERN_WARNING "windfarm: Overtemp condition detected !\n"); printk(KERN_WARNING "windfarm: Overtemp condition detected !\n");
wf_overtemp_counter = 0; wf_overtemp_counter = 0;
wf_notify(WF_EVENT_OVERTEMP, NULL); wf_notify(WF_EVENT_OVERTEMP, NULL);
} }
up(&wf_lock); mutex_unlock(&wf_lock);
} }
EXPORT_SYMBOL_GPL(wf_set_overtemp); EXPORT_SYMBOL_GPL(wf_set_overtemp);
void wf_clear_overtemp(void) void wf_clear_overtemp(void)
{ {
down(&wf_lock); mutex_lock(&wf_lock);
WARN_ON(wf_overtemp == 0); WARN_ON(wf_overtemp == 0);
if (wf_overtemp == 0) { if (wf_overtemp == 0) {
up(&wf_lock); mutex_unlock(&wf_lock);
return; return;
} }
wf_overtemp--; wf_overtemp--;
...@@ -385,7 +386,7 @@ void wf_clear_overtemp(void) ...@@ -385,7 +386,7 @@ void wf_clear_overtemp(void)
printk(KERN_WARNING "windfarm: Overtemp condition cleared !\n"); printk(KERN_WARNING "windfarm: Overtemp condition cleared !\n");
wf_notify(WF_EVENT_NORMALTEMP, NULL); wf_notify(WF_EVENT_NORMALTEMP, NULL);
} }
up(&wf_lock); mutex_unlock(&wf_lock);
} }
EXPORT_SYMBOL_GPL(wf_clear_overtemp); EXPORT_SYMBOL_GPL(wf_clear_overtemp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment