mirror of https://github.com/torvalds/linux.git
ALSA: echoaudio: Use guard() for spin locks
Clean up the code using guard() for spin locks. Merely code refactoring, and no behavior change. Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20250829144342.4290-26-tiwai@suse.de
This commit is contained in:
parent
3eda594925
commit
9bd92d6673
|
|
@ -531,7 +531,7 @@ static int init_engine(struct snd_pcm_substream *substream,
|
||||||
/* Sets up che hardware. If it's already initialized, reset and
|
/* Sets up che hardware. If it's already initialized, reset and
|
||||||
* redo with the new parameters
|
* redo with the new parameters
|
||||||
*/
|
*/
|
||||||
spin_lock_irq(&chip->lock);
|
scoped_guard(spinlock_irq, &chip->lock) {
|
||||||
if (pipe->index >= 0) {
|
if (pipe->index >= 0) {
|
||||||
dev_dbg(chip->card->dev, "hwp_ie free(%d)\n", pipe->index);
|
dev_dbg(chip->card->dev, "hwp_ie free(%d)\n", pipe->index);
|
||||||
err = free_pipes(chip, pipe);
|
err = free_pipes(chip, pipe);
|
||||||
|
|
@ -541,12 +541,11 @@ static int init_engine(struct snd_pcm_substream *substream,
|
||||||
|
|
||||||
err = allocate_pipes(chip, pipe, pipe_index, interleave);
|
err = allocate_pipes(chip, pipe, pipe_index, interleave);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
dev_err(chip->card->dev, "allocate_pipes(%d) err=%d\n",
|
dev_err(chip->card->dev, "allocate_pipes(%d) err=%d\n",
|
||||||
pipe_index, err);
|
pipe_index, err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
spin_unlock_irq(&chip->lock);
|
}
|
||||||
dev_dbg(chip->card->dev, "allocate_pipes()=%d\n", pipe_index);
|
dev_dbg(chip->card->dev, "allocate_pipes()=%d\n", pipe_index);
|
||||||
|
|
||||||
dev_dbg(chip->card->dev,
|
dev_dbg(chip->card->dev,
|
||||||
|
|
@ -594,9 +593,8 @@ static int init_engine(struct snd_pcm_substream *substream,
|
||||||
smp_wmb();
|
smp_wmb();
|
||||||
chip->substream[pipe_index] = substream;
|
chip->substream[pipe_index] = substream;
|
||||||
chip->rate_set = 1;
|
chip->rate_set = 1;
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
set_sample_rate(chip, hw_params->rate_num / hw_params->rate_den);
|
set_sample_rate(chip, hw_params->rate_num / hw_params->rate_den);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -658,14 +656,13 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
|
||||||
chip = snd_pcm_substream_chip(substream);
|
chip = snd_pcm_substream_chip(substream);
|
||||||
pipe = (struct audiopipe *) substream->runtime->private_data;
|
pipe = (struct audiopipe *) substream->runtime->private_data;
|
||||||
|
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
if (pipe->index >= 0) {
|
if (pipe->index >= 0) {
|
||||||
dev_dbg(chip->card->dev, "pcm_hw_free(%d)\n", pipe->index);
|
dev_dbg(chip->card->dev, "pcm_hw_free(%d)\n", pipe->index);
|
||||||
free_pipes(chip, pipe);
|
free_pipes(chip, pipe);
|
||||||
chip->substream[pipe->index] = NULL;
|
chip->substream[pipe->index] = NULL;
|
||||||
pipe->index = -1;
|
pipe->index = -1;
|
||||||
}
|
}
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -715,15 +712,12 @@ static int pcm_prepare(struct snd_pcm_substream *substream)
|
||||||
* exclusive control
|
* exclusive control
|
||||||
*/
|
*/
|
||||||
|
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
|
|
||||||
if (snd_BUG_ON(!is_pipe_allocated(chip, pipe_index))) {
|
if (snd_BUG_ON(!is_pipe_allocated(chip, pipe_index)))
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
|
||||||
|
|
||||||
set_audio_format(chip, pipe_index, &format);
|
set_audio_format(chip, pipe_index, &format);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -747,7 +741,7 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock(&chip->lock);
|
guard(spinlock)(&chip->lock);
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case SNDRV_PCM_TRIGGER_RESUME:
|
case SNDRV_PCM_TRIGGER_RESUME:
|
||||||
case SNDRV_PCM_TRIGGER_START:
|
case SNDRV_PCM_TRIGGER_START:
|
||||||
|
|
@ -795,7 +789,6 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
||||||
default:
|
default:
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
}
|
}
|
||||||
spin_unlock(&chip->lock);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1012,7 +1005,7 @@ static int snd_echo_output_gain_put(struct snd_kcontrol *kcontrol,
|
||||||
|
|
||||||
changed = 0;
|
changed = 0;
|
||||||
chip = snd_kcontrol_chip(kcontrol);
|
chip = snd_kcontrol_chip(kcontrol);
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
for (c = 0; c < num_busses_out(chip); c++) {
|
for (c = 0; c < num_busses_out(chip); c++) {
|
||||||
gain = ucontrol->value.integer.value[c];
|
gain = ucontrol->value.integer.value[c];
|
||||||
/* Ignore out of range values */
|
/* Ignore out of range values */
|
||||||
|
|
@ -1025,7 +1018,6 @@ static int snd_echo_output_gain_put(struct snd_kcontrol *kcontrol,
|
||||||
}
|
}
|
||||||
if (changed)
|
if (changed)
|
||||||
update_output_line_level(chip);
|
update_output_line_level(chip);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1093,7 +1085,7 @@ static int snd_echo_input_gain_put(struct snd_kcontrol *kcontrol,
|
||||||
|
|
||||||
changed = 0;
|
changed = 0;
|
||||||
chip = snd_kcontrol_chip(kcontrol);
|
chip = snd_kcontrol_chip(kcontrol);
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
for (c = 0; c < num_analog_busses_in(chip); c++) {
|
for (c = 0; c < num_analog_busses_in(chip); c++) {
|
||||||
gain = ucontrol->value.integer.value[c];
|
gain = ucontrol->value.integer.value[c];
|
||||||
/* Ignore out of range values */
|
/* Ignore out of range values */
|
||||||
|
|
@ -1106,7 +1098,6 @@ static int snd_echo_input_gain_put(struct snd_kcontrol *kcontrol,
|
||||||
}
|
}
|
||||||
if (changed)
|
if (changed)
|
||||||
update_input_line_level(chip);
|
update_input_line_level(chip);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1162,7 +1153,7 @@ static int snd_echo_output_nominal_put(struct snd_kcontrol *kcontrol,
|
||||||
|
|
||||||
changed = 0;
|
changed = 0;
|
||||||
chip = snd_kcontrol_chip(kcontrol);
|
chip = snd_kcontrol_chip(kcontrol);
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
for (c = 0; c < num_analog_busses_out(chip); c++) {
|
for (c = 0; c < num_analog_busses_out(chip); c++) {
|
||||||
if (chip->nominal_level[c] != ucontrol->value.integer.value[c]) {
|
if (chip->nominal_level[c] != ucontrol->value.integer.value[c]) {
|
||||||
set_nominal_level(chip, c,
|
set_nominal_level(chip, c,
|
||||||
|
|
@ -1172,7 +1163,6 @@ static int snd_echo_output_nominal_put(struct snd_kcontrol *kcontrol,
|
||||||
}
|
}
|
||||||
if (changed)
|
if (changed)
|
||||||
update_output_line_level(chip);
|
update_output_line_level(chip);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1225,7 +1215,7 @@ static int snd_echo_input_nominal_put(struct snd_kcontrol *kcontrol,
|
||||||
|
|
||||||
changed = 0;
|
changed = 0;
|
||||||
chip = snd_kcontrol_chip(kcontrol);
|
chip = snd_kcontrol_chip(kcontrol);
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
for (c = 0; c < num_analog_busses_in(chip); c++) {
|
for (c = 0; c < num_analog_busses_in(chip); c++) {
|
||||||
if (chip->nominal_level[bx_analog_in(chip) + c] !=
|
if (chip->nominal_level[bx_analog_in(chip) + c] !=
|
||||||
ucontrol->value.integer.value[c]) {
|
ucontrol->value.integer.value[c]) {
|
||||||
|
|
@ -1238,7 +1228,6 @@ static int snd_echo_input_nominal_put(struct snd_kcontrol *kcontrol,
|
||||||
update_output_line_level(chip); /* "Output" is not a mistake
|
update_output_line_level(chip); /* "Output" is not a mistake
|
||||||
* here.
|
* here.
|
||||||
*/
|
*/
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1298,10 +1287,9 @@ static int snd_echo_mixer_put(struct snd_kcontrol *kcontrol,
|
||||||
if (gain < ECHOGAIN_MINOUT || gain > ECHOGAIN_MAXOUT)
|
if (gain < ECHOGAIN_MINOUT || gain > ECHOGAIN_MAXOUT)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (chip->monitor_gain[out][in] != gain) {
|
if (chip->monitor_gain[out][in] != gain) {
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
set_monitor_gain(chip, out, in, gain);
|
set_monitor_gain(chip, out, in, gain);
|
||||||
update_output_line_level(chip);
|
update_output_line_level(chip);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
changed = 1;
|
changed = 1;
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
|
|
@ -1361,10 +1349,9 @@ static int snd_echo_vmixer_put(struct snd_kcontrol *kcontrol,
|
||||||
if (gain < ECHOGAIN_MINOUT || gain > ECHOGAIN_MAXOUT)
|
if (gain < ECHOGAIN_MINOUT || gain > ECHOGAIN_MAXOUT)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (chip->vmixer_gain[out][vch] != ucontrol->value.integer.value[0]) {
|
if (chip->vmixer_gain[out][vch] != ucontrol->value.integer.value[0]) {
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
set_vmixer_gain(chip, out, vch, ucontrol->value.integer.value[0]);
|
set_vmixer_gain(chip, out, vch, ucontrol->value.integer.value[0]);
|
||||||
update_vmixer_level(chip);
|
update_vmixer_level(chip);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
changed = 1;
|
changed = 1;
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
|
|
@ -1500,9 +1487,8 @@ static int snd_echo_spdif_mode_put(struct snd_kcontrol *kcontrol,
|
||||||
chip = snd_kcontrol_chip(kcontrol);
|
chip = snd_kcontrol_chip(kcontrol);
|
||||||
mode = !!ucontrol->value.enumerated.item[0];
|
mode = !!ucontrol->value.enumerated.item[0];
|
||||||
if (mode != chip->professional_spdif) {
|
if (mode != chip->professional_spdif) {
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
set_professional_spdif(chip, mode);
|
set_professional_spdif(chip, mode);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1567,11 +1553,10 @@ static int snd_echo_clock_source_put(struct snd_kcontrol *kcontrol,
|
||||||
dclock = chip->clock_source_list[eclock];
|
dclock = chip->clock_source_list[eclock];
|
||||||
if (chip->input_clock != dclock) {
|
if (chip->input_clock != dclock) {
|
||||||
guard(mutex)(&chip->mode_mutex);
|
guard(mutex)(&chip->mode_mutex);
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
changed = set_input_clock(chip, dclock);
|
changed = set_input_clock(chip, dclock);
|
||||||
if (!changed)
|
if (!changed)
|
||||||
changed = 1; /* no errors */
|
changed = 1; /* no errors */
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed < 0)
|
if (changed < 0)
|
||||||
|
|
@ -1615,9 +1600,8 @@ static int snd_echo_phantom_power_put(struct snd_kcontrol *kcontrol,
|
||||||
|
|
||||||
power = !!ucontrol->value.integer.value[0];
|
power = !!ucontrol->value.integer.value[0];
|
||||||
if (chip->phantom_power != power) {
|
if (chip->phantom_power != power) {
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
changed = set_phantom_power(chip, power);
|
changed = set_phantom_power(chip, power);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
if (changed == 0)
|
if (changed == 0)
|
||||||
changed = 1; /* no errors */
|
changed = 1; /* no errors */
|
||||||
}
|
}
|
||||||
|
|
@ -1658,9 +1642,8 @@ static int snd_echo_automute_put(struct snd_kcontrol *kcontrol,
|
||||||
|
|
||||||
automute = !!ucontrol->value.integer.value[0];
|
automute = !!ucontrol->value.integer.value[0];
|
||||||
if (chip->digital_in_automute != automute) {
|
if (chip->digital_in_automute != automute) {
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
changed = set_input_auto_mute(chip, automute);
|
changed = set_input_auto_mute(chip, automute);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
if (changed == 0)
|
if (changed == 0)
|
||||||
changed = 1; /* no errors */
|
changed = 1; /* no errors */
|
||||||
}
|
}
|
||||||
|
|
@ -1688,9 +1671,8 @@ static int snd_echo_vumeters_switch_put(struct snd_kcontrol *kcontrol,
|
||||||
struct echoaudio *chip;
|
struct echoaudio *chip;
|
||||||
|
|
||||||
chip = snd_kcontrol_chip(kcontrol);
|
chip = snd_kcontrol_chip(kcontrol);
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
set_meters_on(chip, ucontrol->value.integer.value[0]);
|
set_meters_on(chip, ucontrol->value.integer.value[0]);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2135,17 +2117,13 @@ static int snd_echo_suspend(struct device *dev)
|
||||||
if (chip->midi_out)
|
if (chip->midi_out)
|
||||||
snd_echo_midi_output_trigger(chip->midi_out, 0);
|
snd_echo_midi_output_trigger(chip->midi_out, 0);
|
||||||
#endif
|
#endif
|
||||||
spin_lock_irq(&chip->lock);
|
scoped_guard(spinlock_irq, &chip->lock) {
|
||||||
if (wait_handshake(chip)) {
|
if (wait_handshake(chip))
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
|
||||||
clear_handshake(chip);
|
clear_handshake(chip);
|
||||||
if (send_vector(chip, DSP_VC_GO_COMATOSE) < 0) {
|
if (send_vector(chip, DSP_VC_GO_COMATOSE) < 0)
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
|
|
||||||
chip->dsp_code = NULL;
|
chip->dsp_code = NULL;
|
||||||
free_irq(chip->irq, chip);
|
free_irq(chip->irq, chip);
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ static int set_digital_mode(struct echoaudio *chip, u8 mode)
|
||||||
* updated by the DSP comm object. */
|
* updated by the DSP comm object. */
|
||||||
if (err >= 0 && previous_mode != mode &&
|
if (err >= 0 && previous_mode != mode &&
|
||||||
(previous_mode == DIGITAL_MODE_ADAT || mode == DIGITAL_MODE_ADAT)) {
|
(previous_mode == DIGITAL_MODE_ADAT || mode == DIGITAL_MODE_ADAT)) {
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
for (o = 0; o < num_busses_out(chip); o++)
|
for (o = 0; o < num_busses_out(chip); o++)
|
||||||
for (i = 0; i < num_busses_in(chip); i++)
|
for (i = 0; i < num_busses_in(chip); i++)
|
||||||
set_monitor_gain(chip, o, i,
|
set_monitor_gain(chip, o, i,
|
||||||
|
|
@ -134,7 +134,6 @@ static int set_digital_mode(struct echoaudio *chip, u8 mode)
|
||||||
for (o = 0; o < num_busses_out(chip); o++)
|
for (o = 0; o < num_busses_out(chip); o++)
|
||||||
set_output_gain(chip, o, chip->output_gain[o]);
|
set_output_gain(chip, o, chip->output_gain[o]);
|
||||||
update_output_line_level(chip);
|
update_output_line_level(chip);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
|
@ -396,7 +395,7 @@ static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
|
|
||||||
if (incompatible_clock) {
|
if (incompatible_clock) {
|
||||||
chip->sample_rate = 48000;
|
chip->sample_rate = 48000;
|
||||||
|
|
@ -422,7 +421,6 @@ static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = write_control_reg(chip, control_reg, get_frq_reg(chip), 1);
|
err = write_control_reg(chip, control_reg, get_frq_reg(chip), 1);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
chip->digital_mode = mode;
|
chip->digital_mode = mode;
|
||||||
|
|
|
||||||
|
|
@ -305,7 +305,7 @@ static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
|
|
||||||
if (incompatible_clock) { /* Switch to 48KHz, internal */
|
if (incompatible_clock) { /* Switch to 48KHz, internal */
|
||||||
chip->sample_rate = 48000;
|
chip->sample_rate = 48000;
|
||||||
|
|
@ -336,7 +336,6 @@ static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = write_control_reg(chip, control_reg, true);
|
err = write_control_reg(chip, control_reg, true);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
chip->digital_mode = mode;
|
chip->digital_mode = mode;
|
||||||
|
|
|
||||||
|
|
@ -358,16 +358,15 @@ static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode)
|
||||||
|
|
||||||
if (incompatible_clock) { /* Switch to 48KHz, internal */
|
if (incompatible_clock) { /* Switch to 48KHz, internal */
|
||||||
chip->sample_rate = 48000;
|
chip->sample_rate = 48000;
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
set_input_clock(chip, ECHO_CLOCK_INTERNAL);
|
set_input_clock(chip, ECHO_CLOCK_INTERNAL);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* switch_asic() can sleep */
|
/* switch_asic() can sleep */
|
||||||
if (switch_asic(chip, asic) < 0)
|
if (switch_asic(chip, asic) < 0)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
|
|
||||||
/* Tweak the control register */
|
/* Tweak the control register */
|
||||||
control_reg = le32_to_cpu(chip->comm_page->control_register);
|
control_reg = le32_to_cpu(chip->comm_page->control_register);
|
||||||
|
|
@ -387,7 +386,6 @@ static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = write_control_reg(chip, control_reg, true);
|
err = write_control_reg(chip, control_reg, true);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
chip->digital_mode = mode;
|
chip->digital_mode = mode;
|
||||||
|
|
|
||||||
|
|
@ -167,9 +167,8 @@ static void snd_echo_midi_input_trigger(struct snd_rawmidi_substream *substream,
|
||||||
struct echoaudio *chip = substream->rmidi->private_data;
|
struct echoaudio *chip = substream->rmidi->private_data;
|
||||||
|
|
||||||
if (up != chip->midi_input_enabled) {
|
if (up != chip->midi_input_enabled) {
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
enable_midi_input(chip, up);
|
enable_midi_input(chip, up);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
chip->midi_input_enabled = up;
|
chip->midi_input_enabled = up;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -201,14 +200,13 @@ static int snd_echo_midi_output_open(struct snd_rawmidi_substream *substream)
|
||||||
static void snd_echo_midi_output_write(struct timer_list *t)
|
static void snd_echo_midi_output_write(struct timer_list *t)
|
||||||
{
|
{
|
||||||
struct echoaudio *chip = timer_container_of(chip, t, timer);
|
struct echoaudio *chip = timer_container_of(chip, t, timer);
|
||||||
unsigned long flags;
|
|
||||||
int bytes, sent, time;
|
int bytes, sent, time;
|
||||||
unsigned char buf[MIDI_OUT_BUFFER_SIZE - 1];
|
unsigned char buf[MIDI_OUT_BUFFER_SIZE - 1];
|
||||||
|
|
||||||
/* No interrupts are involved: we have to check at regular intervals
|
/* No interrupts are involved: we have to check at regular intervals
|
||||||
if the card's output buffer has room for new data. */
|
if the card's output buffer has room for new data. */
|
||||||
sent = 0;
|
sent = 0;
|
||||||
spin_lock_irqsave(&chip->lock, flags);
|
guard(spinlock_irqsave)(&chip->lock);
|
||||||
chip->midi_full = 0;
|
chip->midi_full = 0;
|
||||||
if (!snd_rawmidi_transmit_empty(chip->midi_out)) {
|
if (!snd_rawmidi_transmit_empty(chip->midi_out)) {
|
||||||
bytes = snd_rawmidi_transmit_peek(chip->midi_out, buf,
|
bytes = snd_rawmidi_transmit_peek(chip->midi_out, buf,
|
||||||
|
|
@ -242,7 +240,6 @@ static void snd_echo_midi_output_write(struct timer_list *t)
|
||||||
dev_dbg(chip->card->dev,
|
dev_dbg(chip->card->dev,
|
||||||
"Timer armed(%d)\n", ((time * HZ + 999) / 1000));
|
"Timer armed(%d)\n", ((time * HZ + 999) / 1000));
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&chip->lock, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -251,9 +248,10 @@ static void snd_echo_midi_output_trigger(struct snd_rawmidi_substream *substream
|
||||||
int up)
|
int up)
|
||||||
{
|
{
|
||||||
struct echoaudio *chip = substream->rmidi->private_data;
|
struct echoaudio *chip = substream->rmidi->private_data;
|
||||||
|
bool remove_timer = false;
|
||||||
|
|
||||||
dev_dbg(chip->card->dev, "snd_echo_midi_output_trigger(%d)\n", up);
|
dev_dbg(chip->card->dev, "snd_echo_midi_output_trigger(%d)\n", up);
|
||||||
spin_lock_irq(&chip->lock);
|
scoped_guard(spinlock_irq, &chip->lock) {
|
||||||
if (up) {
|
if (up) {
|
||||||
if (!chip->tinuse) {
|
if (!chip->tinuse) {
|
||||||
timer_setup(&chip->timer, snd_echo_midi_output_write,
|
timer_setup(&chip->timer, snd_echo_midi_output_write,
|
||||||
|
|
@ -263,13 +261,16 @@ static void snd_echo_midi_output_trigger(struct snd_rawmidi_substream *substream
|
||||||
} else {
|
} else {
|
||||||
if (chip->tinuse) {
|
if (chip->tinuse) {
|
||||||
chip->tinuse = 0;
|
chip->tinuse = 0;
|
||||||
spin_unlock_irq(&chip->lock);
|
remove_timer = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remove_timer) {
|
||||||
timer_delete_sync(&chip->timer);
|
timer_delete_sync(&chip->timer);
|
||||||
dev_dbg(chip->card->dev, "Timer removed\n");
|
dev_dbg(chip->card->dev, "Timer removed\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
|
|
||||||
if (up && !chip->midi_full)
|
if (up && !chip->midi_full)
|
||||||
snd_echo_midi_output_write(&chip->timer);
|
snd_echo_midi_output_write(&chip->timer);
|
||||||
|
|
|
||||||
|
|
@ -381,7 +381,7 @@ static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_irq(&chip->lock);
|
guard(spinlock_irq)(&chip->lock);
|
||||||
|
|
||||||
if (incompatible_clock) { /* Switch to 48KHz, internal */
|
if (incompatible_clock) { /* Switch to 48KHz, internal */
|
||||||
chip->sample_rate = 48000;
|
chip->sample_rate = 48000;
|
||||||
|
|
@ -413,7 +413,6 @@ static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = write_control_reg(chip, control_reg, false);
|
err = write_control_reg(chip, control_reg, false);
|
||||||
spin_unlock_irq(&chip->lock);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
chip->digital_mode = mode;
|
chip->digital_mode = mode;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue