mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
ALSA: lx6464es: Use guard() for mutex locks
Replace the manual mutex lock/unlock pairs with guard() for code simplification. Only code refactoring, and no behavior change. Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20250829144342.4290-42-tiwai@suse.de
This commit is contained in:
@@ -207,7 +207,7 @@ static int lx_pcm_open(struct snd_pcm_substream *substream)
|
||||
int board_rate;
|
||||
|
||||
dev_dbg(chip->card->dev, "->lx_pcm_open\n");
|
||||
mutex_lock(&chip->setup_mutex);
|
||||
guard(mutex)(&chip->setup_mutex);
|
||||
|
||||
/* copy the struct snd_pcm_hardware struct */
|
||||
runtime->hw = lx_caps;
|
||||
@@ -218,7 +218,7 @@ static int lx_pcm_open(struct snd_pcm_substream *substream)
|
||||
SNDRV_PCM_HW_PARAM_PERIODS);
|
||||
if (err < 0) {
|
||||
dev_warn(chip->card->dev, "could not constrain periods\n");
|
||||
goto exit;
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -229,7 +229,7 @@ static int lx_pcm_open(struct snd_pcm_substream *substream)
|
||||
|
||||
if (err < 0) {
|
||||
dev_warn(chip->card->dev, "could not constrain periods\n");
|
||||
goto exit;
|
||||
return err;
|
||||
}
|
||||
|
||||
/* constrain period size */
|
||||
@@ -240,7 +240,7 @@ static int lx_pcm_open(struct snd_pcm_substream *substream)
|
||||
if (err < 0) {
|
||||
dev_warn(chip->card->dev,
|
||||
"could not constrain period size\n");
|
||||
goto exit;
|
||||
return err;
|
||||
}
|
||||
|
||||
snd_pcm_hw_constraint_step(runtime, 0,
|
||||
@@ -249,10 +249,8 @@ static int lx_pcm_open(struct snd_pcm_substream *substream)
|
||||
snd_pcm_set_sync(substream);
|
||||
err = 0;
|
||||
|
||||
exit:
|
||||
runtime->private_data = chip;
|
||||
|
||||
mutex_unlock(&chip->setup_mutex);
|
||||
dev_dbg(chip->card->dev, "<-lx_pcm_open, %d\n", err);
|
||||
return err;
|
||||
}
|
||||
@@ -275,9 +273,8 @@ static snd_pcm_uframes_t lx_pcm_stream_pointer(struct snd_pcm_substream
|
||||
|
||||
dev_dbg(chip->card->dev, "->lx_pcm_stream_pointer\n");
|
||||
|
||||
mutex_lock(&chip->lock);
|
||||
guard(mutex)(&chip->lock);
|
||||
pos = lx_stream->frame_pos * substream->runtime->period_size;
|
||||
mutex_unlock(&chip->lock);
|
||||
|
||||
dev_dbg(chip->card->dev, "stream_pointer at %ld\n", pos);
|
||||
return pos;
|
||||
@@ -291,21 +288,21 @@ static int lx_pcm_prepare(struct snd_pcm_substream *substream)
|
||||
|
||||
dev_dbg(chip->card->dev, "->lx_pcm_prepare\n");
|
||||
|
||||
mutex_lock(&chip->setup_mutex);
|
||||
guard(mutex)(&chip->setup_mutex);
|
||||
|
||||
if (chip->hardware_running[is_capture]) {
|
||||
err = lx_hardware_stop(chip, substream);
|
||||
if (err < 0) {
|
||||
dev_err(chip->card->dev, "failed to stop hardware. "
|
||||
"Error code %d\n", err);
|
||||
goto exit;
|
||||
return err;
|
||||
}
|
||||
|
||||
err = lx_hardware_close(chip, substream);
|
||||
if (err < 0) {
|
||||
dev_err(chip->card->dev, "failed to close hardware. "
|
||||
"Error code %d\n", err);
|
||||
goto exit;
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,14 +311,14 @@ static int lx_pcm_prepare(struct snd_pcm_substream *substream)
|
||||
if (err < 0) {
|
||||
dev_err(chip->card->dev, "failed to open hardware. "
|
||||
"Error code %d\n", err);
|
||||
goto exit;
|
||||
return err;
|
||||
}
|
||||
|
||||
err = lx_hardware_start(chip, substream);
|
||||
if (err < 0) {
|
||||
dev_err(chip->card->dev, "failed to start hardware. "
|
||||
"Error code %d\n", err);
|
||||
goto exit;
|
||||
return err;
|
||||
}
|
||||
|
||||
chip->hardware_running[is_capture] = 1;
|
||||
@@ -331,8 +328,6 @@ static int lx_pcm_prepare(struct snd_pcm_substream *substream)
|
||||
chip->board_sample_rate = substream->runtime->rate;
|
||||
}
|
||||
|
||||
exit:
|
||||
mutex_unlock(&chip->setup_mutex);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -343,14 +338,13 @@ static int lx_pcm_hw_params(struct snd_pcm_substream *substream,
|
||||
|
||||
dev_dbg(chip->card->dev, "->lx_pcm_hw_params\n");
|
||||
|
||||
mutex_lock(&chip->setup_mutex);
|
||||
guard(mutex)(&chip->setup_mutex);
|
||||
|
||||
if (is_capture)
|
||||
chip->capture_stream.stream = substream;
|
||||
else
|
||||
chip->playback_stream.stream = substream;
|
||||
|
||||
mutex_unlock(&chip->setup_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -373,21 +367,21 @@ static int lx_pcm_hw_free(struct snd_pcm_substream *substream)
|
||||
int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE);
|
||||
|
||||
dev_dbg(chip->card->dev, "->lx_pcm_hw_free\n");
|
||||
mutex_lock(&chip->setup_mutex);
|
||||
guard(mutex)(&chip->setup_mutex);
|
||||
|
||||
if (chip->hardware_running[is_capture]) {
|
||||
err = lx_hardware_stop(chip, substream);
|
||||
if (err < 0) {
|
||||
dev_err(chip->card->dev, "failed to stop hardware. "
|
||||
"Error code %d\n", err);
|
||||
goto exit;
|
||||
return err;
|
||||
}
|
||||
|
||||
err = lx_hardware_close(chip, substream);
|
||||
if (err < 0) {
|
||||
dev_err(chip->card->dev, "failed to close hardware. "
|
||||
"Error code %d\n", err);
|
||||
goto exit;
|
||||
return err;
|
||||
}
|
||||
|
||||
chip->hardware_running[is_capture] = 0;
|
||||
@@ -398,9 +392,7 @@ static int lx_pcm_hw_free(struct snd_pcm_substream *substream)
|
||||
else
|
||||
chip->playback_stream.stream = NULL;
|
||||
|
||||
exit:
|
||||
mutex_unlock(&chip->setup_mutex);
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void lx_trigger_start(struct lx6464es *chip, struct lx_stream *lx_stream)
|
||||
@@ -486,9 +478,7 @@ static void lx_trigger_dispatch_stream(struct lx6464es *chip,
|
||||
static int lx_pcm_trigger_dispatch(struct lx6464es *chip,
|
||||
struct lx_stream *lx_stream, int cmd)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
mutex_lock(&chip->lock);
|
||||
guard(mutex)(&chip->lock);
|
||||
switch (cmd) {
|
||||
case SNDRV_PCM_TRIGGER_START:
|
||||
lx_stream->status = LX_STREAM_STATUS_SCHEDULE_RUN;
|
||||
@@ -499,16 +489,13 @@ static int lx_pcm_trigger_dispatch(struct lx6464es *chip,
|
||||
break;
|
||||
|
||||
default:
|
||||
err = -EINVAL;
|
||||
goto exit;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
lx_trigger_dispatch_stream(chip, &chip->capture_stream);
|
||||
lx_trigger_dispatch_stream(chip, &chip->playback_stream);
|
||||
|
||||
exit:
|
||||
mutex_unlock(&chip->lock);
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -318,13 +318,12 @@ int lx_dsp_get_version(struct lx6464es *chip, u32 *rdsp_version)
|
||||
{
|
||||
int ret;
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
|
||||
lx_message_init(&chip->rmh, CMD_01_GET_SYS_CFG);
|
||||
ret = lx_message_send_atomic(chip, &chip->rmh);
|
||||
|
||||
*rdsp_version = chip->rmh.stat[1];
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -335,7 +334,7 @@ int lx_dsp_get_clock_frequency(struct lx6464es *chip, u32 *rfreq)
|
||||
u32 frequency = 0;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
|
||||
lx_message_init(&chip->rmh, CMD_01_GET_SYS_CFG);
|
||||
ret = lx_message_send_atomic(chip, &chip->rmh);
|
||||
@@ -353,8 +352,6 @@ int lx_dsp_get_clock_frequency(struct lx6464es *chip, u32 *rfreq)
|
||||
frequency = 48000;
|
||||
}
|
||||
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
|
||||
*rfreq = frequency * chip->freq_ratio;
|
||||
|
||||
return ret;
|
||||
@@ -381,23 +378,19 @@ int lx_dsp_get_mac(struct lx6464es *chip)
|
||||
|
||||
int lx_dsp_set_granularity(struct lx6464es *chip, u32 gran)
|
||||
{
|
||||
int ret;
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
|
||||
lx_message_init(&chip->rmh, CMD_02_SET_GRANULARITY);
|
||||
chip->rmh.cmd[0] |= gran;
|
||||
|
||||
ret = lx_message_send_atomic(chip, &chip->rmh);
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
return ret;
|
||||
return lx_message_send_atomic(chip, &chip->rmh);
|
||||
}
|
||||
|
||||
int lx_dsp_read_async_events(struct lx6464es *chip, u32 *data)
|
||||
{
|
||||
int ret;
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
|
||||
lx_message_init(&chip->rmh, CMD_04_GET_EVENT);
|
||||
chip->rmh.stat_len = 9; /* we don't necessarily need the full length */
|
||||
@@ -407,7 +400,6 @@ int lx_dsp_read_async_events(struct lx6464es *chip, u32 *data)
|
||||
if (!ret)
|
||||
memcpy(data, chip->rmh.stat, chip->rmh.stat_len * sizeof(u32));
|
||||
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -423,14 +415,13 @@ int lx_pipe_allocate(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
int err;
|
||||
u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe);
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
lx_message_init(&chip->rmh, CMD_06_ALLOCATE_PIPE);
|
||||
|
||||
chip->rmh.cmd[0] |= pipe_cmd;
|
||||
chip->rmh.cmd[0] |= channels;
|
||||
|
||||
err = lx_message_send_atomic(chip, &chip->rmh);
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
|
||||
if (err != 0)
|
||||
dev_err(chip->card->dev, "could not allocate pipe\n");
|
||||
@@ -440,18 +431,14 @@ int lx_pipe_allocate(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
|
||||
int lx_pipe_release(struct lx6464es *chip, u32 pipe, int is_capture)
|
||||
{
|
||||
int err;
|
||||
u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe);
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
lx_message_init(&chip->rmh, CMD_07_RELEASE_PIPE);
|
||||
|
||||
chip->rmh.cmd[0] |= pipe_cmd;
|
||||
|
||||
err = lx_message_send_atomic(chip, &chip->rmh);
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
|
||||
return err;
|
||||
return lx_message_send_atomic(chip, &chip->rmh);
|
||||
}
|
||||
|
||||
int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
@@ -468,7 +455,7 @@ int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
*r_needed = 0;
|
||||
*r_freed = 0;
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
lx_message_init(&chip->rmh, CMD_08_ASK_BUFFERS);
|
||||
|
||||
chip->rmh.cmd[0] |= pipe_cmd;
|
||||
@@ -501,41 +488,32 @@ int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
}
|
||||
}
|
||||
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int lx_pipe_stop(struct lx6464es *chip, u32 pipe, int is_capture)
|
||||
{
|
||||
int err;
|
||||
u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe);
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
lx_message_init(&chip->rmh, CMD_09_STOP_PIPE);
|
||||
|
||||
chip->rmh.cmd[0] |= pipe_cmd;
|
||||
|
||||
err = lx_message_send_atomic(chip, &chip->rmh);
|
||||
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
return err;
|
||||
return lx_message_send_atomic(chip, &chip->rmh);
|
||||
}
|
||||
|
||||
static int lx_pipe_toggle_state(struct lx6464es *chip, u32 pipe, int is_capture)
|
||||
{
|
||||
int err;
|
||||
u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe);
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
lx_message_init(&chip->rmh, CMD_0B_TOGGLE_PIPE_STATE);
|
||||
|
||||
chip->rmh.cmd[0] |= pipe_cmd;
|
||||
|
||||
err = lx_message_send_atomic(chip, &chip->rmh);
|
||||
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
return err;
|
||||
return lx_message_send_atomic(chip, &chip->rmh);
|
||||
}
|
||||
|
||||
|
||||
@@ -572,7 +550,7 @@ int lx_pipe_sample_count(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
int err;
|
||||
u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe);
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
lx_message_init(&chip->rmh, CMD_0A_GET_PIPE_SPL_COUNT);
|
||||
|
||||
chip->rmh.cmd[0] |= pipe_cmd;
|
||||
@@ -589,7 +567,6 @@ int lx_pipe_sample_count(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
+ chip->rmh.stat[1]; /* lo part */
|
||||
}
|
||||
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -598,7 +575,7 @@ int lx_pipe_state(struct lx6464es *chip, u32 pipe, int is_capture, u16 *rstate)
|
||||
int err;
|
||||
u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe);
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
lx_message_init(&chip->rmh, CMD_0A_GET_PIPE_SPL_COUNT);
|
||||
|
||||
chip->rmh.cmd[0] |= pipe_cmd;
|
||||
@@ -610,7 +587,6 @@ int lx_pipe_state(struct lx6464es *chip, u32 pipe, int is_capture, u16 *rstate)
|
||||
else
|
||||
*rstate = (chip->rmh.stat[0] >> PSTATE_OFFSET) & 0x0F;
|
||||
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -651,29 +627,24 @@ int lx_pipe_wait_for_idle(struct lx6464es *chip, u32 pipe, int is_capture)
|
||||
int lx_stream_set_state(struct lx6464es *chip, u32 pipe,
|
||||
int is_capture, enum stream_state_t state)
|
||||
{
|
||||
int err;
|
||||
u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe);
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
lx_message_init(&chip->rmh, CMD_13_SET_STREAM_STATE);
|
||||
|
||||
chip->rmh.cmd[0] |= pipe_cmd;
|
||||
chip->rmh.cmd[0] |= state;
|
||||
|
||||
err = lx_message_send_atomic(chip, &chip->rmh);
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
|
||||
return err;
|
||||
return lx_message_send_atomic(chip, &chip->rmh);
|
||||
}
|
||||
|
||||
int lx_stream_set_format(struct lx6464es *chip, struct snd_pcm_runtime *runtime,
|
||||
u32 pipe, int is_capture)
|
||||
{
|
||||
int err;
|
||||
u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe);
|
||||
u32 channels = runtime->channels;
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
lx_message_init(&chip->rmh, CMD_0C_DEF_STREAM);
|
||||
|
||||
chip->rmh.cmd[0] |= pipe_cmd;
|
||||
@@ -688,10 +659,7 @@ int lx_stream_set_format(struct lx6464es *chip, struct snd_pcm_runtime *runtime,
|
||||
|
||||
chip->rmh.cmd[0] |= channels-1;
|
||||
|
||||
err = lx_message_send_atomic(chip, &chip->rmh);
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
|
||||
return err;
|
||||
return lx_message_send_atomic(chip, &chip->rmh);
|
||||
}
|
||||
|
||||
int lx_stream_state(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
@@ -700,7 +668,7 @@ int lx_stream_state(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
int err;
|
||||
u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe);
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
lx_message_init(&chip->rmh, CMD_0E_GET_STREAM_SPL_COUNT);
|
||||
|
||||
chip->rmh.cmd[0] |= pipe_cmd;
|
||||
@@ -709,7 +677,6 @@ int lx_stream_state(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
|
||||
*rstate = (chip->rmh.stat[0] & SF_START) ? START_STATE : PAUSE_STATE;
|
||||
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -719,7 +686,7 @@ int lx_stream_sample_position(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
int err;
|
||||
u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe);
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
lx_message_init(&chip->rmh, CMD_0E_GET_STREAM_SPL_COUNT);
|
||||
|
||||
chip->rmh.cmd[0] |= pipe_cmd;
|
||||
@@ -730,7 +697,6 @@ int lx_stream_sample_position(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
<< 32) /* hi part */
|
||||
+ chip->rmh.stat[1]; /* lo part */
|
||||
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -742,7 +708,7 @@ int lx_buffer_give(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
int err;
|
||||
u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe);
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
lx_message_init(&chip->rmh, CMD_0F_UPDATE_BUFFER);
|
||||
|
||||
chip->rmh.cmd[0] |= pipe_cmd;
|
||||
@@ -763,7 +729,7 @@ int lx_buffer_give(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
|
||||
if (err == 0) {
|
||||
*r_buffer_index = chip->rmh.stat[0];
|
||||
goto done;
|
||||
return err;
|
||||
}
|
||||
|
||||
if (err == EB_RBUFFERS_TABLE_OVERFLOW)
|
||||
@@ -778,8 +744,6 @@ int lx_buffer_give(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
dev_err(chip->card->dev,
|
||||
"lx_buffer_give EB_CMD_REFUSED\n");
|
||||
|
||||
done:
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -789,7 +753,7 @@ int lx_buffer_free(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
int err;
|
||||
u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe);
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
lx_message_init(&chip->rmh, CMD_11_CANCEL_BUFFER);
|
||||
|
||||
chip->rmh.cmd[0] |= pipe_cmd;
|
||||
@@ -801,26 +765,21 @@ int lx_buffer_free(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
if (err == 0)
|
||||
*r_buffer_size = chip->rmh.stat[0] & MASK_DATA_SIZE;
|
||||
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
return err;
|
||||
}
|
||||
|
||||
int lx_buffer_cancel(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
u32 buffer_index)
|
||||
{
|
||||
int err;
|
||||
u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe);
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
lx_message_init(&chip->rmh, CMD_11_CANCEL_BUFFER);
|
||||
|
||||
chip->rmh.cmd[0] |= pipe_cmd;
|
||||
chip->rmh.cmd[0] |= buffer_index;
|
||||
|
||||
err = lx_message_send_atomic(chip, &chip->rmh);
|
||||
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
return err;
|
||||
return lx_message_send_atomic(chip, &chip->rmh);
|
||||
}
|
||||
|
||||
|
||||
@@ -831,11 +790,10 @@ int lx_buffer_cancel(struct lx6464es *chip, u32 pipe, int is_capture,
|
||||
* */
|
||||
int lx_level_unmute(struct lx6464es *chip, int is_capture, int unmute)
|
||||
{
|
||||
int err;
|
||||
/* bit set to 1: channel muted */
|
||||
u64 mute_mask = unmute ? 0 : 0xFFFFFFFFFFFFFFFFLLU;
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
lx_message_init(&chip->rmh, CMD_0D_SET_MUTE);
|
||||
|
||||
chip->rmh.cmd[0] |= PIPE_INFO_TO_CMD(is_capture, 0);
|
||||
@@ -847,10 +805,7 @@ int lx_level_unmute(struct lx6464es *chip, int is_capture, int unmute)
|
||||
"mute %x %x %x\n", chip->rmh.cmd[0], chip->rmh.cmd[1],
|
||||
chip->rmh.cmd[2]);
|
||||
|
||||
err = lx_message_send_atomic(chip, &chip->rmh);
|
||||
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
return err;
|
||||
return lx_message_send_atomic(chip, &chip->rmh);
|
||||
}
|
||||
|
||||
static const u32 peak_map[] = {
|
||||
@@ -878,7 +833,7 @@ int lx_level_peaks(struct lx6464es *chip, int is_capture, int channels,
|
||||
int err = 0;
|
||||
int i;
|
||||
|
||||
mutex_lock(&chip->msg_lock);
|
||||
guard(mutex)(&chip->msg_lock);
|
||||
for (i = 0; i < channels; i += 4) {
|
||||
u32 s0, s1, s2, s3;
|
||||
|
||||
@@ -903,7 +858,6 @@ int lx_level_peaks(struct lx6464es *chip, int is_capture, int channels,
|
||||
r_levels += 4;
|
||||
}
|
||||
|
||||
mutex_unlock(&chip->msg_lock);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -1033,7 +987,7 @@ static int lx_interrupt_request_new_buffer(struct lx6464es *chip,
|
||||
|
||||
dev_dbg(chip->card->dev, "->lx_interrupt_request_new_buffer\n");
|
||||
|
||||
mutex_lock(&chip->lock);
|
||||
guard(mutex)(&chip->lock);
|
||||
|
||||
err = lx_buffer_ask(chip, 0, is_capture, &needed, &freed, size_array);
|
||||
dev_dbg(chip->card->dev,
|
||||
@@ -1047,7 +1001,6 @@ static int lx_interrupt_request_new_buffer(struct lx6464es *chip,
|
||||
buffer_index, (unsigned long)buf, period_bytes);
|
||||
|
||||
lx_stream->frame_pos = next_pos;
|
||||
mutex_unlock(&chip->lock);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user