From: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
Helen Koike <helen.koike@collabora.co.uk>,
Lars-Peter Clausen <lars@metafoo.de>,
Sebastian Reichel <sre@kernel.org>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Cc: Chris Healy <cphealy@gmail.com>,
Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Subject: [PATCH] ASoC: tpa6130a2: unmerge power enable error path from power disable path
Date: Mon, 26 Sep 2016 13:35:50 +0300 [thread overview]
Message-ID: <1474886150-16207-1-git-send-email-nikita.yoush@cogentembedded.com> (raw)
In-Reply-To: <20160924183110.s4lxuigycpxegamq@sirena.org.uk>
Code undo operations in power enable errror path explicitly, instead of
reusing power disable path and playing with return values there.
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
---
I doubt that copying 7 lines into error path is better than having a tiny
logic with return values, but still here it is.
sound/soc/codecs/tpa6130a2.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c
index 3b6faed91d7e..3712db0881d0 100644
--- a/sound/soc/codecs/tpa6130a2.c
+++ b/sound/soc/codecs/tpa6130a2.c
@@ -71,7 +71,14 @@ static int tpa6130a2_power(struct tpa6130a2_data *data, bool enable)
if (ret != 0) {
dev_err(data->dev,
"Failed to sync registers: %d\n", ret);
- goto regcache_sync_failed;
+ regcache_cache_only(data->regmap, true);
+ if (data->power_gpio >= 0)
+ gpio_set_value(data->power_gpio, 0);
+ ret2 = regulator_disable(data->supply);
+ if (ret2 != 0)
+ dev_err(data->dev,
+ "Failed to disable supply: %d\n", ret2);
+ return ret;
}
} else {
/* Powered off device does not retain registers. While device
@@ -79,18 +86,17 @@ static int tpa6130a2_power(struct tpa6130a2_data *data, bool enable)
* happen in cache only.
*/
regcache_mark_dirty(data->regmap);
-regcache_sync_failed:
regcache_cache_only(data->regmap, true);
/* Power off */
if (data->power_gpio >= 0)
gpio_set_value(data->power_gpio, 0);
- ret2 = regulator_disable(data->supply);
- if (ret2 != 0) {
+ ret = regulator_disable(data->supply);
+ if (ret != 0) {
dev_err(data->dev,
- "Failed to disable supply: %d\n", ret2);
- return ret ? ret : ret2;
+ "Failed to disable supply: %d\n", ret);
+ return ret;
}
}
--
2.1.4
next prev parent reply other threads:[~2016-09-26 10:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-22 10:10 [PATCH] ASoC: tpa6130a2: fix volume setting when no stream is running Nikita Yushchenko
2016-09-24 18:31 ` Mark Brown
2016-09-26 10:35 ` Nikita Yushchenko [this message]
2016-09-26 16:08 ` [PATCH] ASoC: tpa6130a2: unmerge power enable error path from power disable path Mark Brown
2016-09-26 16:14 ` Nikita Yushchenko
2016-09-26 16:15 ` Applied "ASoC: tpa6130a2: unmerge power enable error path from power disable path" to the asoc tree Mark Brown
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=1474886150-16207-1-git-send-email-nikita.yoush@cogentembedded.com \
--to=nikita.yoush@cogentembedded.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=cphealy@gmail.com \
--cc=helen.koike@collabora.co.uk \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=sre@kernel.org \
--cc=tiwai@suse.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®