Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 547e631c authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Takashi Iwai
Browse files

ALSA: firewire-lib: return error code when amdtp_stream_set_parameters() detects error



Currently, amdtp_stream_set_parameters() returns no error even if wrong
arguments are given. This is not good for streaming layer because drivers
can continue processing ignoring capability of streaming layer.

This commit changes this function to return error code.

Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 10b2b6dc
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -197,7 +197,7 @@ EXPORT_SYMBOL(amdtp_stream_add_pcm_hw_constraints);
 * The parameters must be set before the stream is started, and must not be
 * changed while the stream is running.
 */
void amdtp_stream_set_parameters(struct amdtp_stream *s,
int amdtp_stream_set_parameters(struct amdtp_stream *s,
				unsigned int rate,
				unsigned int pcm_channels,
				unsigned int midi_ports)
@@ -209,15 +209,15 @@ void amdtp_stream_set_parameters(struct amdtp_stream *s,
	if (WARN_ON(amdtp_stream_running(s)) |
	    WARN_ON(pcm_channels > AMDTP_MAX_CHANNELS_FOR_PCM) |
	    WARN_ON(midi_channels > AMDTP_MAX_CHANNELS_FOR_MIDI))
		return;
		return -EINVAL;

	for (sfc = 0; sfc < ARRAY_SIZE(amdtp_rate_table); ++sfc)
	for (sfc = 0; sfc < ARRAY_SIZE(amdtp_rate_table); ++sfc) {
		if (amdtp_rate_table[sfc] == rate)
			goto sfc_found;
	WARN_ON(1);
	return;
			break;
	}
	if (sfc == ARRAY_SIZE(amdtp_rate_table))
		return -EINVAL;

sfc_found:
	s->pcm_channels = pcm_channels;
	s->sfc = sfc;
	s->data_block_quadlets = s->pcm_channels + midi_channels;
@@ -243,6 +243,8 @@ void amdtp_stream_set_parameters(struct amdtp_stream *s,
	 * (The value here is adjusted for midi_ratelimit_per_packet().)
	 */
	s->midi_fifo_limit = rate - MIDI_BYTES_PER_SECOND * s->syt_interval + 1;

	return 0;
}
EXPORT_SYMBOL(amdtp_stream_set_parameters);

+4 −4
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ int amdtp_stream_init(struct amdtp_stream *s, struct fw_unit *unit,
		      enum cip_flags flags);
void amdtp_stream_destroy(struct amdtp_stream *s);

void amdtp_stream_set_parameters(struct amdtp_stream *s,
int amdtp_stream_set_parameters(struct amdtp_stream *s,
				unsigned int rate,
				unsigned int pcm_channels,
				unsigned int midi_ports);
+9 −4
Original line number Diff line number Diff line
@@ -427,12 +427,17 @@ make_both_connections(struct snd_bebob *bebob, unsigned int rate)
	index = get_formation_index(rate);
	pcm_channels = bebob->tx_stream_formations[index].pcm;
	midi_channels = bebob->tx_stream_formations[index].midi;
	amdtp_stream_set_parameters(&bebob->tx_stream,
				    rate, pcm_channels, midi_channels * 8);
	err = amdtp_stream_set_parameters(&bebob->tx_stream, rate,
					  pcm_channels, midi_channels * 8);
	if (err < 0)
		goto end;

	pcm_channels = bebob->rx_stream_formations[index].pcm;
	midi_channels = bebob->rx_stream_formations[index].midi;
	amdtp_stream_set_parameters(&bebob->rx_stream,
				    rate, pcm_channels, midi_channels * 8);
	err = amdtp_stream_set_parameters(&bebob->rx_stream, rate,
					  pcm_channels, midi_channels * 8);
	if (err < 0)
		goto end;

	/* establish connections for both streams */
	err = cmp_connection_establish(&bebob->out_conn,
+4 −1
Original line number Diff line number Diff line
@@ -133,7 +133,10 @@ static int start_stream(struct snd_dice *dice, struct amdtp_stream *stream,
		stream->double_pcm_frames = false;
	}

	amdtp_stream_set_parameters(stream, rate, pcm_chs, midi_ports);
	err = amdtp_stream_set_parameters(stream, rate, pcm_chs, midi_ports);
	if (err < 0)
		goto end;

	if (mode > 1) {
		pcm_chs /= 2;

+4 −2
Original line number Diff line number Diff line
@@ -73,8 +73,10 @@ start_stream(struct snd_efw *efw, struct amdtp_stream *stream,
		midi_ports = efw->midi_in_ports;
	}

	amdtp_stream_set_parameters(stream, sampling_rate,
	err = amdtp_stream_set_parameters(stream, sampling_rate,
					  pcm_channels, midi_ports);
	if (err < 0)
		goto end;

	/*  establish connection via CMP */
	err = cmp_connection_establish(conn,
Loading