aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/staging/most/sound/sound.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/most/sound/sound.c')
-rw-r--r--drivers/staging/most/sound/sound.c58
1 files changed, 14 insertions, 44 deletions
diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c
index 1527f410af2b..8a449ab9bdce 100644
--- a/drivers/staging/most/sound/sound.c
+++ b/drivers/staging/most/sound/sound.c
@@ -50,10 +50,8 @@ struct channel {
unsigned int period_pos;
unsigned int buffer_pos;
bool is_stream_running;
-
struct task_struct *playback_task;
wait_queue_head_t playback_waitq;
-
void (*copy_fn)(void *alsa, void *most, unsigned int bytes);
};
@@ -176,7 +174,6 @@ static struct channel *get_channel(struct most_interface *iface,
if ((channel->iface == iface) && (channel->id == channel_id))
return channel;
}
-
return NULL;
}
@@ -220,7 +217,6 @@ static bool copy_data(struct channel *channel, struct mbo *mbo)
channel->period_pos -= runtime->period_size;
return true;
}
-
return false;
}
@@ -260,7 +256,6 @@ static int playback_thread(void *data)
if (period_elapsed)
snd_pcm_period_elapsed(channel->substream);
}
-
return 0;
}
@@ -278,6 +273,7 @@ static int pcm_open(struct snd_pcm_substream *substream)
struct channel *channel = substream->private_data;
struct snd_pcm_runtime *runtime = substream->runtime;
struct most_channel_config *cfg = channel->cfg;
+ int ret;
channel->substream = substream;
@@ -290,11 +286,12 @@ static int pcm_open(struct snd_pcm_substream *substream)
}
}
- if (most_start_channel(channel->iface, channel->id, &comp)) {
+ ret = most_start_channel(channel->iface, channel->id, &comp);
+ if (ret) {
pr_err("most_start_channel() failed!\n");
if (cfg->direction == MOST_CH_TX)
kthread_stop(channel->playback_task);
- return -EBUSY;
+ return ret;
}
runtime->hw = channel->pcm_hardware;
@@ -318,7 +315,6 @@ static int pcm_close(struct snd_pcm_substream *substream)
if (channel->cfg->direction == MOST_CH_TX)
kthread_stop(channel->playback_task);
most_stop_channel(channel->iface, channel->id, &comp);
-
return 0;
}
@@ -360,14 +356,10 @@ static int pcm_prepare(struct snd_pcm_substream *substream)
channel->copy_fn = most_to_alsa_copy32;
}
- if (!channel->copy_fn) {
- pr_err("unsupported format\n");
+ if (!channel->copy_fn)
return -EINVAL;
- }
-
channel->period_pos = 0;
channel->buffer_pos = 0;
-
return 0;
}
@@ -396,7 +388,6 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
return 0;
default:
- pr_info("%s(), invalid\n", __func__);
return -EINVAL;
}
return 0;
@@ -442,12 +433,11 @@ static int split_arg_list(char *buf, u16 *ch_num, char **sample_res)
*sample_res = strsep(&buf, ".\n");
if (!*sample_res)
goto err;
-
return 0;
err:
pr_err("Bad PCM format\n");
- return -EIO;
+ return -EINVAL;
}
static const struct sample_resolution_info {
@@ -472,7 +462,7 @@ static int audio_set_hw_params(struct snd_pcm_hardware *pcm_hw,
goto found;
}
pr_err("Unsupported PCM format\n");
- return -EIO;
+ return -EINVAL;
found:
if (!ch_num) {
@@ -541,9 +531,6 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id,
char *sample_res;
char arg_list_cpy[STRING_SIZE];
- if (!iface)
- return -EINVAL;
-
if (cfg->data_type != MOST_CH_SYNC) {
pr_err("Incompatible channel type\n");
return -EINVAL;
@@ -583,7 +570,7 @@ skip_adpt_alloc:
if (get_channel(iface, channel_id)) {
pr_err("channel (%s:%d) is already linked\n",
iface->description, channel_id);
- return -EINVAL;
+ return -EEXIST;
}
if (cfg->direction == MOST_CH_TX) {
@@ -620,7 +607,6 @@ skip_adpt_alloc:
strscpy(pcm->name, device_name, sizeof(pcm->name));
snd_pcm_set_ops(pcm, direction, &pcm_ops);
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
-
return 0;
err_free_adpt:
@@ -664,11 +650,8 @@ static int audio_disconnect_channel(struct most_interface *iface,
struct sound_adapter *adpt = iface->priv;
channel = get_channel(iface, channel_id);
- if (!channel) {
- pr_err("sound_disconnect_channel(), invalid channel %d\n",
- channel_id);
+ if (!channel)
return -EINVAL;
- }
list_del(&channel->list);
@@ -692,20 +675,13 @@ static int audio_rx_completion(struct mbo *mbo)
struct channel *channel = get_channel(mbo->ifp, mbo->hdm_channel_id);
bool period_elapsed = false;
- if (!channel) {
- pr_err("sound_rx_completion(), invalid channel %d\n",
- mbo->hdm_channel_id);
+ if (!channel)
return -EINVAL;
- }
-
if (channel->is_stream_running)
period_elapsed = copy_data(channel, mbo);
-
most_put_mbo(mbo);
-
if (period_elapsed)
snd_pcm_period_elapsed(channel->substream);
-
return 0;
}
@@ -724,14 +700,10 @@ static int audio_tx_completion(struct most_interface *iface, int channel_id)
{
struct channel *channel = get_channel(iface, channel_id);
- if (!channel) {
- pr_err("sound_tx_completion(), invalid channel %d\n",
- channel_id);
+ if (!channel)
return -EINVAL;
- }
wake_up_interruptible(&channel->playback_waitq);
-
return 0;
}
@@ -752,25 +724,23 @@ static int __init audio_init(void)
{
int ret;
- pr_info("init()\n");
-
INIT_LIST_HEAD(&adpt_list);
ret = most_register_component(&comp);
- if (ret)
+ if (ret) {
pr_err("Failed to register %s\n", comp.name);
+ return ret;
+ }
ret = most_register_configfs_subsys(&comp);
if (ret) {
pr_err("Failed to register %s configfs subsys\n", comp.name);
most_deregister_component(&comp);
}
-
return ret;
}
static void __exit audio_exit(void)
{
- pr_info("exit()\n");
most_deregister_configfs_subsys(&comp);
most_deregister_component(&comp);
}