Skip to content

Commit

Permalink
[PATCH] sem2mutex: drivers/macintosh/windfarm_core.c
Browse files Browse the repository at this point in the history
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: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Ingo Molnar authored and Paul Mackerras committed Jan 20, 2006
1 parent 0f36b01 commit 837e959
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions drivers/macintosh/windfarm_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <linux/reboot.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/mutex.h>

#include "windfarm.h"

Expand All @@ -48,7 +49,7 @@

static LIST_HEAD(wf_controls);
static LIST_HEAD(wf_sensors);
static DECLARE_MUTEX(wf_lock);
static DEFINE_MUTEX(wf_lock);
static struct notifier_block *wf_client_list;
static int wf_client_count;
static unsigned int wf_overtemp;
Expand Down Expand Up @@ -160,12 +161,12 @@ int wf_register_control(struct wf_control *new_ct)
{
struct wf_control *ct;

down(&wf_lock);
mutex_lock(&wf_lock);
list_for_each_entry(ct, &wf_controls, link) {
if (!strcmp(ct->name, new_ct->name)) {
printk(KERN_WARNING "windfarm: trying to register"
" duplicate control %s\n", ct->name);
up(&wf_lock);
mutex_unlock(&wf_lock);
return -EEXIST;
}
}
Expand All @@ -175,17 +176,17 @@ int wf_register_control(struct wf_control *new_ct)
DBG("wf: Registered control %s\n", new_ct->name);

wf_notify(WF_EVENT_NEW_CONTROL, new_ct);
up(&wf_lock);
mutex_unlock(&wf_lock);

return 0;
}
EXPORT_SYMBOL_GPL(wf_register_control);

void wf_unregister_control(struct wf_control *ct)
{
down(&wf_lock);
mutex_lock(&wf_lock);
list_del(&ct->link);
up(&wf_lock);
mutex_unlock(&wf_lock);

DBG("wf: Unregistered control %s\n", ct->name);

Expand All @@ -197,16 +198,16 @@ struct wf_control * wf_find_control(const char *name)
{
struct wf_control *ct;

down(&wf_lock);
mutex_lock(&wf_lock);
list_for_each_entry(ct, &wf_controls, link) {
if (!strcmp(ct->name, name)) {
if (wf_get_control(ct))
ct = NULL;
up(&wf_lock);
mutex_unlock(&wf_lock);
return ct;
}
}
up(&wf_lock);
mutex_unlock(&wf_lock);
return NULL;
}
EXPORT_SYMBOL_GPL(wf_find_control);
Expand Down Expand Up @@ -250,12 +251,12 @@ int wf_register_sensor(struct wf_sensor *new_sr)
{
struct wf_sensor *sr;

down(&wf_lock);
mutex_lock(&wf_lock);
list_for_each_entry(sr, &wf_sensors, link) {
if (!strcmp(sr->name, new_sr->name)) {
printk(KERN_WARNING "windfarm: trying to register"
" duplicate sensor %s\n", sr->name);
up(&wf_lock);
mutex_unlock(&wf_lock);
return -EEXIST;
}
}
Expand All @@ -265,17 +266,17 @@ int wf_register_sensor(struct wf_sensor *new_sr)
DBG("wf: Registered sensor %s\n", new_sr->name);

wf_notify(WF_EVENT_NEW_SENSOR, new_sr);
up(&wf_lock);
mutex_unlock(&wf_lock);

return 0;
}
EXPORT_SYMBOL_GPL(wf_register_sensor);

void wf_unregister_sensor(struct wf_sensor *sr)
{
down(&wf_lock);
mutex_lock(&wf_lock);
list_del(&sr->link);
up(&wf_lock);
mutex_unlock(&wf_lock);

DBG("wf: Unregistered sensor %s\n", sr->name);

Expand All @@ -287,16 +288,16 @@ struct wf_sensor * wf_find_sensor(const char *name)
{
struct wf_sensor *sr;

down(&wf_lock);
mutex_lock(&wf_lock);
list_for_each_entry(sr, &wf_sensors, link) {
if (!strcmp(sr->name, name)) {
if (wf_get_sensor(sr))
sr = NULL;
up(&wf_lock);
mutex_unlock(&wf_lock);
return sr;
}
}
up(&wf_lock);
mutex_unlock(&wf_lock);
return NULL;
}
EXPORT_SYMBOL_GPL(wf_find_sensor);
Expand Down Expand Up @@ -329,7 +330,7 @@ int wf_register_client(struct notifier_block *nb)
struct wf_control *ct;
struct wf_sensor *sr;

down(&wf_lock);
mutex_lock(&wf_lock);
rc = notifier_chain_register(&wf_client_list, nb);
if (rc != 0)
goto bail;
Expand All @@ -341,51 +342,51 @@ int wf_register_client(struct notifier_block *nb)
if (wf_client_count == 1)
wf_start_thread();
bail:
up(&wf_lock);
mutex_unlock(&wf_lock);
return rc;
}
EXPORT_SYMBOL_GPL(wf_register_client);

int wf_unregister_client(struct notifier_block *nb)
{
down(&wf_lock);
mutex_lock(&wf_lock);
notifier_chain_unregister(&wf_client_list, nb);
wf_client_count++;
if (wf_client_count == 0)
wf_stop_thread();
up(&wf_lock);
mutex_unlock(&wf_lock);

return 0;
}
EXPORT_SYMBOL_GPL(wf_unregister_client);

void wf_set_overtemp(void)
{
down(&wf_lock);
mutex_lock(&wf_lock);
wf_overtemp++;
if (wf_overtemp == 1) {
printk(KERN_WARNING "windfarm: Overtemp condition detected !\n");
wf_overtemp_counter = 0;
wf_notify(WF_EVENT_OVERTEMP, NULL);
}
up(&wf_lock);
mutex_unlock(&wf_lock);
}
EXPORT_SYMBOL_GPL(wf_set_overtemp);

void wf_clear_overtemp(void)
{
down(&wf_lock);
mutex_lock(&wf_lock);
WARN_ON(wf_overtemp == 0);
if (wf_overtemp == 0) {
up(&wf_lock);
mutex_unlock(&wf_lock);
return;
}
wf_overtemp--;
if (wf_overtemp == 0) {
printk(KERN_WARNING "windfarm: Overtemp condition cleared !\n");
wf_notify(WF_EVENT_NORMALTEMP, NULL);
}
up(&wf_lock);
mutex_unlock(&wf_lock);
}
EXPORT_SYMBOL_GPL(wf_clear_overtemp);

Expand Down

0 comments on commit 837e959

Please sign in to comment.