summaryrefslogtreecommitdiffstats
path: root/sound/firewire/amdtp.c
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2015-09-19 04:21:49 +0200
committerTakashi Iwai <tiwai@suse.de>2015-09-29 12:35:45 +0200
commit547e631ce3886175a33b5ccf67729bdd18e9b7e0 (patch)
tree8c48fda0c7a8c5442d00a100901bd1747e349155 /sound/firewire/amdtp.c
parentALSA: firewire-lib: arrange structure for AMDTP stream (diff)
downloadlinux-547e631ce3886175a33b5ccf67729bdd18e9b7e0.tar.xz
linux-547e631ce3886175a33b5ccf67729bdd18e9b7e0.zip
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: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/amdtp.c')
-rw-r--r--sound/firewire/amdtp.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
index 2a153d260836..2bacb5173ff8 100644
--- a/sound/firewire/amdtp.c
+++ b/sound/firewire/amdtp.c
@@ -197,10 +197,10 @@ 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,
- unsigned int rate,
- unsigned int pcm_channels,
- unsigned int midi_ports)
+int amdtp_stream_set_parameters(struct amdtp_stream *s,
+ unsigned int rate,
+ unsigned int pcm_channels,
+ unsigned int midi_ports)
{
unsigned int i, sfc, midi_channels;
@@ -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 @@ sfc_found:
* (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);