Skip to content

Commit

Permalink
[ARM] OMAP1: N770: Convert audio_pwr_sem in a mutex
Browse files Browse the repository at this point in the history
ARM: OMAP1: N770: The semaphore audio_pwr_sem is used as a
mutex. Convert it to the mutex API

[akpm@linux-foundation.org: include mutex.h]
Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>
Cc: Tony Lindgren <tony@atomide.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Matthias Kaehlcke authored and Russell King committed Jul 3, 2008
1 parent 3c093f9 commit d41d219
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions arch/arm/mach-omap1/board-nokia770.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/input.h>
#include <linux/clk.h>
Expand Down Expand Up @@ -202,7 +203,7 @@ static struct omap_board_config_kernel nokia770_config[] __initdata = {
#define AMPLIFIER_CTRL_GPIO 58

static struct clk *dspxor_ck;
static DECLARE_MUTEX(audio_pwr_sem);
static DEFINE_MUTEX(audio_pwr_lock);
/*
* audio_pwr_state
* +--+-------------------------+---------------------------------------+
Expand All @@ -218,7 +219,7 @@ static DECLARE_MUTEX(audio_pwr_sem);
static int audio_pwr_state = -1;

/*
* audio_pwr_up / down should be called under audio_pwr_sem
* audio_pwr_up / down should be called under audio_pwr_lock
*/
static void nokia770_audio_pwr_up(void)
{
Expand All @@ -237,11 +238,11 @@ static void nokia770_audio_pwr_up(void)

static void codec_delayed_power_down(struct work_struct *work)
{
down(&audio_pwr_sem);
mutex_lock(&audio_pwr_lock);
if (audio_pwr_state == -1)
aic23_power_down();
clk_disable(dspxor_ck);
up(&audio_pwr_sem);
mutex_unlock(&audio_pwr_lock);
}

static DECLARE_DELAYED_WORK(codec_power_down_work, codec_delayed_power_down);
Expand All @@ -258,19 +259,19 @@ static void nokia770_audio_pwr_down(void)
static int
nokia770_audio_pwr_up_request(struct dsp_kfunc_device *kdev, int stage)
{
down(&audio_pwr_sem);
mutex_lock(&audio_pwr_lock);
if (audio_pwr_state == -1)
nokia770_audio_pwr_up();
/* force audio_pwr_state = 0, even if it was 1. */
audio_pwr_state = 0;
up(&audio_pwr_sem);
mutex_unlock(&audio_pwr_lock);
return 0;
}

static int
nokia770_audio_pwr_down_request(struct dsp_kfunc_device *kdev, int stage)
{
down(&audio_pwr_sem);
mutex_lock(&audio_pwr_lock);
switch (stage) {
case 1:
if (audio_pwr_state == 0)
Expand All @@ -283,7 +284,7 @@ nokia770_audio_pwr_down_request(struct dsp_kfunc_device *kdev, int stage)
}
break;
}
up(&audio_pwr_sem);
mutex_unlock(&audio_pwr_lock);
return 0;
}

Expand Down

0 comments on commit d41d219

Please sign in to comment.