From patchwork Mon Jun 12 19:44:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 9782679 X-Patchwork-Delegate: sboyd@codeaurora.org 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 92C3F602DA for ; Mon, 12 Jun 2017 19:44:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 849B3284EE for ; Mon, 12 Jun 2017 19:44:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 793EA286B7; Mon, 12 Jun 2017 19:44:58 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2482D284EE for ; Mon, 12 Jun 2017 19:44:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752685AbdFLTo5 (ORCPT ); Mon, 12 Jun 2017 15:44:57 -0400 Received: from mail-wr0-f178.google.com ([209.85.128.178]:36007 "EHLO mail-wr0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752534AbdFLTo5 (ORCPT ); Mon, 12 Jun 2017 15:44:57 -0400 Received: by mail-wr0-f178.google.com with SMTP id v111so110853709wrc.3 for ; Mon, 12 Jun 2017 12:44:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7LhEcd30qdqZgGMXPmCNu9yJVbVqFSv4xPbnhzqp4gA=; b=TWDygxWKD/lR4cITU6Pd2zrdepRCPgBu4gZr2xB93Vyf1J+g36SLxN5cF4KmSevUrO U+SCQ+q83btC+jcNWibL3oOHaFaGyZnLigGtvG8Php0VNJjACHUIf1gY+XKTF4aK3CxX Pl1feDYYAIMEufzVKFnIShRDd2vlDV0p2pUwzSwJuaXK1qLvhC+9VgYxauBNBF/dqsUy RqjR6PsCAi1GwCJzINvZk5h7Jr0xlAbDL/N+6r8J7ZB1dfgAuSDa1dVS64bMfT3IFs5u GZh3TwTm38MOZxezrqZ5iAxKcJHbHMKSHoQDw2ZVYOQPE0zir6DWBrTo/km2sOkQ50xV gptg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7LhEcd30qdqZgGMXPmCNu9yJVbVqFSv4xPbnhzqp4gA=; b=PvSBRRHLIzgc8vXnTva3Bo3VpA2CfCWgd+BwbRv6s8lAumCuXkeCoX2l2TKFQWiQh6 hN+BnNqrRRCTL4hqubopAyil+LOvVzgzqjM7mntryr+n6JnAiCGPWFi+IMf8eId1WWRe YE7iQFrp9c4kVt7Au4ckEDLMVixgHP5wOT26mpAvn8tK7W0TTqNye+kLXqdRQz017Bhj Qfb2Owu85UZ5/luQERhkmfUG3quxtpNv+ZtNgApF7HwGRdveUqkQEky6Swbyf0wP74xW g8Z6sXMICuWuGwFbIKRVcOl0YPr+Di3hW2EQhOQYIxWRhKJ9wX4v8dj+FTKWDyn9l5wG WhXw== X-Gm-Message-State: AKS2vOxEQlM4If3e8KPu/oGhkT1k5+Jd0tBZxHQEmfHTkZKvJjBBK/34 0ZOi2guklA3A9yOe X-Received: by 10.223.138.204 with SMTP id z12mr371970wrz.50.1497296695649; Mon, 12 Jun 2017 12:44:55 -0700 (PDT) Received: from localhost.localdomain (cag06-3-82-243-161-21.fbx.proxad.net. [82.243.161.21]) by smtp.googlemail.com with ESMTPSA id 70sm13250797wmu.28.2017.06.12.12.44.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Jun 2017 12:44:55 -0700 (PDT) From: Jerome Brunet To: Michael Turquette , Stephen Boyd , linux-clk@vger.kernel.org Cc: Jerome Brunet , Kevin Hilman , linux-amlogic@lists.infradead.org, Russell King , Linus Walleij , Boris Brezillon Subject: [PATCH v3 07/10] clk: rollback set_rate_range changes on failure Date: Mon, 12 Jun 2017 21:44:35 +0200 Message-Id: <20170612194438.12298-8-jbrunet@baylibre.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170612194438.12298-1-jbrunet@baylibre.com> References: <20170612194438.12298-1-jbrunet@baylibre.com> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Jerome Brunet --- drivers/clk/clk.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index d91236e70a04..253f1d3f0971 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1864,6 +1864,7 @@ EXPORT_SYMBOL_GPL(clk_set_rate_protect); int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max) { int ret = 0; + unsigned int old_min, old_max; if (!clk) return 0; @@ -1881,9 +1882,16 @@ int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max) clk_core_rate_unprotect(clk->core); if (min != clk->min_rate || max != clk->max_rate) { + old_min = clk->min_rate; + old_max = clk->max_rate; clk->min_rate = min; clk->max_rate = max; ret = clk_core_set_rate_nolock(clk->core, clk->core->req_rate); + if (ret) { + /* undo changes */ + clk->min_rate = old_min; + clk->max_rate = old_max; + } } if (clk->protect_count)