All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] staging: most: sound: clean up
@ 2020-06-23 15:07 Christian Gromm
  2020-06-23 15:07 ` [PATCH 1/5] staging: most: sound: remove noisy log messages Christian Gromm
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Christian Gromm @ 2020-06-23 15:07 UTC (permalink / raw)
  To: gregkh; +Cc: Christian Gromm, driverdev-devel

Patch set to clean up code and fix issues.

Christian Gromm (5):
  staging: most: sound: remove noisy log messages
  staging: most: sound: fix error path
  staging: most: sound: fix return values
  staging: most: sound: fix white spaces
  staging: most: sound: remove overcautious argument checking

 drivers/staging/most/sound/sound.c | 58 +++++++++-----------------------------
 1 file changed, 14 insertions(+), 44 deletions(-)

-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/5] staging: most: sound: remove noisy log messages
  2020-06-23 15:07 [PATCH 0/5] staging: most: sound: clean up Christian Gromm
@ 2020-06-23 15:07 ` Christian Gromm
  2020-06-23 15:07 ` [PATCH 2/5] staging: most: sound: fix error path Christian Gromm
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Christian Gromm @ 2020-06-23 15:07 UTC (permalink / raw)
  To: gregkh; +Cc: Christian Gromm, driverdev-devel

This patch removes unnecessary log messages to avoid noise
in the kernel log.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
---
 drivers/staging/most/sound/sound.c | 24 ++++--------------------
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c
index 1527f41..e6396d1 100644
--- a/drivers/staging/most/sound/sound.c
+++ b/drivers/staging/most/sound/sound.c
@@ -360,10 +360,8 @@ 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;
@@ -396,7 +394,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;
@@ -664,11 +661,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,11 +686,8 @@ 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);
@@ -724,14 +715,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,8 +739,6 @@ static int __init audio_init(void)
 {
 	int ret;
 
-	pr_info("init()\n");
-
 	INIT_LIST_HEAD(&adpt_list);
 
 	ret = most_register_component(&comp);
@@ -770,7 +755,6 @@ static int __init audio_init(void)
 
 static void __exit audio_exit(void)
 {
-	pr_info("exit()\n");
 	most_deregister_configfs_subsys(&comp);
 	most_deregister_component(&comp);
 }
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/5] staging: most: sound: fix error path
  2020-06-23 15:07 [PATCH 0/5] staging: most: sound: clean up Christian Gromm
  2020-06-23 15:07 ` [PATCH 1/5] staging: most: sound: remove noisy log messages Christian Gromm
@ 2020-06-23 15:07 ` Christian Gromm
  2020-06-23 15:07 ` [PATCH 3/5] staging: most: sound: fix return values Christian Gromm
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Christian Gromm @ 2020-06-23 15:07 UTC (permalink / raw)
  To: gregkh; +Cc: Christian Gromm, driverdev-devel

Return error and exit the function in case registering the component
with the core is failing.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
---
 drivers/staging/most/sound/sound.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c
index e6396d1..80a8feb 100644
--- a/drivers/staging/most/sound/sound.c
+++ b/drivers/staging/most/sound/sound.c
@@ -742,8 +742,10 @@ static int __init audio_init(void)
 	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);
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/5] staging: most: sound: fix return values
  2020-06-23 15:07 [PATCH 0/5] staging: most: sound: clean up Christian Gromm
  2020-06-23 15:07 ` [PATCH 1/5] staging: most: sound: remove noisy log messages Christian Gromm
  2020-06-23 15:07 ` [PATCH 2/5] staging: most: sound: fix error path Christian Gromm
@ 2020-06-23 15:07 ` Christian Gromm
  2020-06-23 15:07 ` [PATCH 4/5] staging: most: sound: fix white spaces Christian Gromm
  2020-06-23 15:07 ` [PATCH 5/5] staging: most: sound: remove overcautious argument checking Christian Gromm
  4 siblings, 0 replies; 6+ messages in thread
From: Christian Gromm @ 2020-06-23 15:07 UTC (permalink / raw)
  To: gregkh; +Cc: Christian Gromm, driverdev-devel

This patch returns the proper values when reporting an error
to the caller.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
---
 drivers/staging/most/sound/sound.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c
index 80a8feb..467faa1 100644
--- a/drivers/staging/most/sound/sound.c
+++ b/drivers/staging/most/sound/sound.c
@@ -278,6 +278,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 +291,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;
@@ -444,7 +446,7 @@ static int split_arg_list(char *buf, u16 *ch_num, char **sample_res)
 
 err:
 	pr_err("Bad PCM format\n");
-	return -EIO;
+	return -EINVAL;
 }
 
 static const struct sample_resolution_info {
@@ -469,7 +471,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) {
@@ -580,7 +582,7 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id,
 	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) {
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/5] staging: most: sound: fix white spaces
  2020-06-23 15:07 [PATCH 0/5] staging: most: sound: clean up Christian Gromm
                   ` (2 preceding siblings ...)
  2020-06-23 15:07 ` [PATCH 3/5] staging: most: sound: fix return values Christian Gromm
@ 2020-06-23 15:07 ` Christian Gromm
  2020-06-23 15:07 ` [PATCH 5/5] staging: most: sound: remove overcautious argument checking Christian Gromm
  4 siblings, 0 replies; 6+ messages in thread
From: Christian Gromm @ 2020-06-23 15:07 UTC (permalink / raw)
  To: gregkh; +Cc: Christian Gromm, driverdev-devel

This patch removes unnecessary empty lines.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
---
 drivers/staging/most/sound/sound.c | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c
index 467faa1..7c56cdb 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;
 }
 
@@ -320,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;
 }
 
@@ -364,10 +358,8 @@ static int pcm_prepare(struct snd_pcm_substream *substream)
 
 	if (!channel->copy_fn)
 		return -EINVAL;
-
 	channel->period_pos = 0;
 	channel->buffer_pos = 0;
-
 	return 0;
 }
 
@@ -441,7 +433,6 @@ 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:
@@ -619,7 +610,6 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id,
 	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:
@@ -690,15 +680,11 @@ static int audio_rx_completion(struct mbo *mbo)
 
 	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;
 }
 
@@ -753,7 +739,6 @@ static int __init audio_init(void)
 		pr_err("Failed to register %s configfs subsys\n", comp.name);
 		most_deregister_component(&comp);
 	}
-
 	return ret;
 }
 
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/5] staging: most: sound: remove overcautious argument checking
  2020-06-23 15:07 [PATCH 0/5] staging: most: sound: clean up Christian Gromm
                   ` (3 preceding siblings ...)
  2020-06-23 15:07 ` [PATCH 4/5] staging: most: sound: fix white spaces Christian Gromm
@ 2020-06-23 15:07 ` Christian Gromm
  4 siblings, 0 replies; 6+ messages in thread
From: Christian Gromm @ 2020-06-23 15:07 UTC (permalink / raw)
  To: gregkh; +Cc: Christian Gromm, driverdev-devel

The interface pointer passed to a component API function cannot be NULL.
This patch removes the unnecessary sanity check of this argument.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
---
 drivers/staging/most/sound/sound.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c
index 7c56cdb..8a449ab 100644
--- a/drivers/staging/most/sound/sound.c
+++ b/drivers/staging/most/sound/sound.c
@@ -531,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;
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-23 15:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-23 15:07 [PATCH 0/5] staging: most: sound: clean up Christian Gromm
2020-06-23 15:07 ` [PATCH 1/5] staging: most: sound: remove noisy log messages Christian Gromm
2020-06-23 15:07 ` [PATCH 2/5] staging: most: sound: fix error path Christian Gromm
2020-06-23 15:07 ` [PATCH 3/5] staging: most: sound: fix return values Christian Gromm
2020-06-23 15:07 ` [PATCH 4/5] staging: most: sound: fix white spaces Christian Gromm
2020-06-23 15:07 ` [PATCH 5/5] staging: most: sound: remove overcautious argument checking Christian Gromm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.