[PATCH 2/3] ALSA: core: Make snd_card_free_when_closed() return void

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



All callers from other files ignore the return value of this function.
And it can only ever return a non-zero value if the parameter card is NULL.

This cannot happen in snd_card_free() as card was dereferenced just before
snd_card_free_when_closed() is called. So the error handling can be dropped
there.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
---
 include/sound/core.h |  2 +-
 sound/core/init.c    | 12 +++++-------
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/include/sound/core.h b/include/sound/core.h
index 9a73c60b6f1e..21884c979c17 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -289,7 +289,7 @@ int snd_devm_card_new(struct device *parent, int idx, const char *xid,
 void snd_card_disconnect(struct snd_card *card);
 void snd_card_disconnect_sync(struct snd_card *card);
 int snd_card_free(struct snd_card *card);
-int snd_card_free_when_closed(struct snd_card *card);
+void snd_card_free_when_closed(struct snd_card *card);
 int snd_card_free_on_error(struct device *dev, int ret);
 void snd_card_set_id(struct snd_card *card, const char *id);
 int snd_card_register(struct snd_card *card);
diff --git a/sound/core/init.c b/sound/core/init.c
index a03eddab12fe..6bb3e2b77971 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -608,14 +608,14 @@ static int snd_card_do_free(struct snd_card *card)
  *
  * Return: zero if successful, or a negative error code
  */
-int snd_card_free_when_closed(struct snd_card *card)
+void snd_card_free_when_closed(struct snd_card *card)
 {
 	if (!card)
-		return -EINVAL;
+		return;
 
 	snd_card_disconnect(card);
 	put_device(&card->card_dev);
-	return 0;
+	return;
 }
 EXPORT_SYMBOL(snd_card_free_when_closed);
 
@@ -635,7 +635,6 @@ EXPORT_SYMBOL(snd_card_free_when_closed);
 int snd_card_free(struct snd_card *card)
 {
 	DECLARE_COMPLETION_ONSTACK(released);
-	int ret;
 
 	/* The call of snd_card_free() is allowed from various code paths;
 	 * a manual call from the driver and the call via devres_free, and
@@ -647,9 +646,8 @@ int snd_card_free(struct snd_card *card)
 		return 0;
 
 	card->release_completion = &released;
-	ret = snd_card_free_when_closed(card);
-	if (ret)
-		return ret;
+	snd_card_free_when_closed(card);
+
 	/* wait, until all devices are ready for the free operation */
 	wait_for_completion(&released);
 
-- 
2.39.0




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux