All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Cc: Mark Brown <broonie@kernel.org>
Subject: [PATCH 20/20] ALSA: pcm: Define snd_pcm_lib_preallocate_*() as returning void
Date: Tue,  5 Feb 2019 20:42:21 +0100	[thread overview]
Message-ID: <20190205194221.25924-21-tiwai@suse.de> (raw)
In-Reply-To: <20190205194221.25924-1-tiwai@suse.de>

Now all callers no longer check the return value from
snd_pcm_lib_preallocate_pages() and co, let's make them to return
void, so that any new code won't fall into the same pitfall.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 include/sound/pcm.h     |  8 ++++----
 sound/core/pcm_memory.c | 29 ++++++++---------------------
 2 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index ca20f80f8976..465d7d033c4c 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -1185,12 +1185,12 @@ static inline void snd_pcm_gettime(struct snd_pcm_runtime *runtime,
  *  Memory
  */
 
-int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream);
-int snd_pcm_lib_preallocate_free_for_all(struct snd_pcm *pcm);
-int snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream,
+void snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream);
+void snd_pcm_lib_preallocate_free_for_all(struct snd_pcm *pcm);
+void snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream,
 				  int type, struct device *data,
 				  size_t size, size_t max);
-int snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm,
+void snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm,
 					  int type, void *data,
 					  size_t size, size_t max);
 int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size);
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c
index 9a98bc61461f..049d65cad54a 100644
--- a/sound/core/pcm_memory.c
+++ b/sound/core/pcm_memory.c
@@ -87,13 +87,10 @@ static void snd_pcm_lib_preallocate_dma_free(struct snd_pcm_substream *substream
  * @substream: the pcm substream instance
  *
  * Releases the pre-allocated buffer of the given substream.
- *
- * Return: Zero if successful, or a negative error code on failure.
  */
-int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream)
+void snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream)
 {
 	snd_pcm_lib_preallocate_dma_free(substream);
-	return 0;
 }
 
 /**
@@ -101,10 +98,8 @@ int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream)
  * @pcm: the pcm instance
  *
  * Releases all the pre-allocated buffers on the given pcm.
- *
- * Return: Zero if successful, or a negative error code on failure.
  */
-int snd_pcm_lib_preallocate_free_for_all(struct snd_pcm *pcm)
+void snd_pcm_lib_preallocate_free_for_all(struct snd_pcm *pcm)
 {
 	struct snd_pcm_substream *substream;
 	int stream;
@@ -112,7 +107,6 @@ int snd_pcm_lib_preallocate_free_for_all(struct snd_pcm *pcm)
 	for (stream = 0; stream < 2; stream++)
 		for (substream = pcm->streams[stream].substream; substream; substream = substream->next)
 			snd_pcm_lib_preallocate_free(substream);
-	return 0;
 }
 EXPORT_SYMBOL(snd_pcm_lib_preallocate_free_for_all);
 
@@ -215,7 +209,7 @@ static inline void preallocate_info_init(struct snd_pcm_substream *substream)
 /*
  * pre-allocate the buffer and create a proc file for the substream
  */
-static int snd_pcm_lib_preallocate_pages1(struct snd_pcm_substream *substream,
+static void snd_pcm_lib_preallocate_pages1(struct snd_pcm_substream *substream,
 					  size_t size, size_t max)
 {
 
@@ -226,7 +220,6 @@ static int snd_pcm_lib_preallocate_pages1(struct snd_pcm_substream *substream,
 		substream->buffer_bytes_max = substream->dma_buffer.bytes;
 	substream->dma_max = max;
 	preallocate_info_init(substream);
-	return 0;
 }
 
 
@@ -239,16 +232,14 @@ static int snd_pcm_lib_preallocate_pages1(struct snd_pcm_substream *substream,
  * @max: the max. allowed pre-allocation size
  *
  * Do pre-allocation for the given DMA buffer type.
- *
- * Return: Zero if successful, or a negative error code on failure.
  */
-int snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream,
+void snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream,
 				  int type, struct device *data,
 				  size_t size, size_t max)
 {
 	substream->dma_buffer.dev.type = type;
 	substream->dma_buffer.dev.dev = data;
-	return snd_pcm_lib_preallocate_pages1(substream, size, max);
+	snd_pcm_lib_preallocate_pages1(substream, size, max);
 }
 EXPORT_SYMBOL(snd_pcm_lib_preallocate_pages);
 
@@ -262,21 +253,17 @@ EXPORT_SYMBOL(snd_pcm_lib_preallocate_pages);
  *
  * Do pre-allocation to all substreams of the given pcm for the
  * specified DMA type.
- *
- * Return: Zero if successful, or a negative error code on failure.
  */
-int snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm,
+void snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm,
 					  int type, void *data,
 					  size_t size, size_t max)
 {
 	struct snd_pcm_substream *substream;
-	int stream, err;
+	int stream;
 
 	for (stream = 0; stream < 2; stream++)
 		for (substream = pcm->streams[stream].substream; substream; substream = substream->next)
-			if ((err = snd_pcm_lib_preallocate_pages(substream, type, data, size, max)) < 0)
-				return err;
-	return 0;
+			snd_pcm_lib_preallocate_pages(substream, type, data, size, max);
 }
 EXPORT_SYMBOL(snd_pcm_lib_preallocate_pages_for_all);
 
-- 
2.16.4

  parent reply	other threads:[~2019-02-05 19:42 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-05 19:42 [PATCH 00/20] ALSA: Drop superfluous PCM preallocation error checks Takashi Iwai
2019-02-05 19:42 ` [PATCH 01/20] ALSA: atmel: " Takashi Iwai
2019-02-05 19:42 ` [PATCH 02/20] ALSA: parisc: " Takashi Iwai
2019-02-05 19:42 ` [PATCH 03/20] ALSA: pci: " Takashi Iwai
2019-02-05 19:42 ` [PATCH 04/20] ALSA: ppc: " Takashi Iwai
2019-02-05 19:42 ` [PATCH 05/20] ALSA: sh: " Takashi Iwai
2019-02-05 19:42 ` [PATCH 06/20] ALSA: sparc: " Takashi Iwai
2019-02-05 19:42 ` [PATCH 07/20] ALSA: spi: " Takashi Iwai
2019-02-05 19:42 ` [PATCH 08/20] ALSA: usb: " Takashi Iwai
2019-02-05 19:42 ` [PATCH 09/20] ASoC: amd: " Takashi Iwai
2019-02-05 19:42 ` [PATCH 10/20] ASoC: dwc: " Takashi Iwai
2019-02-05 19:42 ` [PATCH 11/20] ASoC: intel: " Takashi Iwai
2019-02-05 19:42 ` [PATCH 12/20] ASoC: mediatek: " Takashi Iwai
2019-02-05 19:42 ` [PATCH 13/20] ASoC: meson: " Takashi Iwai
2019-02-05 19:42 ` [PATCH 14/20] ASoC: sh: " Takashi Iwai
2019-02-06  5:51   ` Kuninori Morimoto
2019-02-05 19:42 ` [PATCH 15/20] ASoC: stm: " Takashi Iwai
2019-02-05 19:42 ` [PATCH 16/20] ASoC: txx9: " Takashi Iwai
2019-02-05 19:42 ` [PATCH 17/20] ASoC: uniphier: " Takashi Iwai
2019-02-05 19:42 ` [PATCH 18/20] ASoC: xtensa: " Takashi Iwai
2019-02-05 19:42 ` [PATCH 19/20] ASoC: dmaengine: " Takashi Iwai
2019-02-05 19:42 ` Takashi Iwai [this message]
2019-02-06  9:07 ` [PATCH 00/20] ALSA: " Jaroslav Kysela
2019-02-06  9:27   ` Takashi Iwai
2019-02-06 14:50   ` Mark Brown
2019-02-06 15:35     ` Jaroslav Kysela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190205194221.25924-21-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.