From patchwork Mon Sep 26 10:35:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Yushchenko X-Patchwork-Id: 9350671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 29B236077B for ; Mon, 26 Sep 2016 13:09:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B3C426224 for ; Mon, 26 Sep 2016 13:09:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FE6B28B8D; Mon, 26 Sep 2016 13:09:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 088A026224 for ; Mon, 26 Sep 2016 13:09:10 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 73D7B265598; Mon, 26 Sep 2016 15:09:09 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id A19CF265598; Mon, 26 Sep 2016 15:06:50 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id D7E2B266A5B; Mon, 26 Sep 2016 12:36:05 +0200 (CEST) Received: from mail-lf0-f43.google.com (mail-lf0-f43.google.com [209.85.215.43]) by alsa0.perex.cz (Postfix) with ESMTP id A3F5F2650FE for ; Mon, 26 Sep 2016 12:36:00 +0200 (CEST) Received: by mail-lf0-f43.google.com with SMTP id l131so137143597lfl.2 for ; Mon, 26 Sep 2016 03:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TXwNPtOH7IqxPGX8lBE5OafJd339blgKmhNWMSFifXU=; b=kBZHhrszWxJ0rueRJqPZb6fHE7suLiwq8lDPqR4UwSggEabhUFvkjM7MIshB0LYoA2 bw5/gXhBukT+WUKguDOe1rCaeRo1Fvo0cRzfgrwyWSbQop0FYk2yJTpTkZhKcf5LUWf/ 6wVo8kFwY1lhr4Uk+3hiSbd7AZ8MR9Q3+D7+/OKMJJVD9CE8PQko3tLl1/ymXyn56weZ 2VckVFVfBGSJnl5WwewEiyGleZJMfvJw4jPpUlDNq6F+jU3xYTZF5fZbcR3tXyBIknl8 UdVOPmR+pHJAtg/F10MfL/rIGG+yc54HjtraMdWMEo0d2hHdDd2S49YM7J5GS0QAyk1f /nrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TXwNPtOH7IqxPGX8lBE5OafJd339blgKmhNWMSFifXU=; b=MYNjrbweAfBgaElYiedg4Ly+G8xfpiA5lqpwntOsyBp50husJsOPerVJFjaGVogyVp veWfz2gBHjV5IHEzWGQAuRO3VfB/tW8jeuYSwjOFKKTYgVec+eY5WYyhqHGNVhDCrKQ/ CUGp8dzvp/WJs+GWNTWiszuryblDK0aZe/rNG1RALJVc7DC/D6hIA6Qh2R39MvoEmEYc dUv/wRSQphnlag++X02EgFM3TKoQv8mhnjy2/H2QgTI+9Sr85kFHAgyARIVpnTnMMQEr 7OxMILxzLai+AwdbbwLCMiAKCKiBl6X8Vgg0DDhfC5VpimzdQ839844GJoOiS3VKbCI5 wAUg== X-Gm-Message-State: AE9vXwMX3k6zpOf4R+sSJEpreUPfd4PpxPtiIjo/0KAorQb/Xbsd/7uMBuU0dgTDY3hFNA== X-Received: by 10.25.34.85 with SMTP id i82mr6424733lfi.141.1474886159849; Mon, 26 Sep 2016 03:35:59 -0700 (PDT) Received: from hugenb.home (nikaet.starlink.ru. [94.141.168.29]) by smtp.gmail.com with ESMTPSA id u78sm3731632lff.31.2016.09.26.03.35.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Sep 2016 03:35:56 -0700 (PDT) From: Nikita Yushchenko To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Helen Koike , Lars-Peter Clausen , Sebastian Reichel , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Date: Mon, 26 Sep 2016 13:35:50 +0300 Message-Id: <1474886150-16207-1-git-send-email-nikita.yoush@cogentembedded.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <20160924183110.s4lxuigycpxegamq@sirena.org.uk> References: <20160924183110.s4lxuigycpxegamq@sirena.org.uk> Cc: Nikita Yushchenko , Chris Healy Subject: [alsa-devel] [PATCH] ASoC: tpa6130a2: unmerge power enable error path from power disable path X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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; } }