From patchwork Sun May 21 21:59:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 9739467 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 5851F6034C for ; Sun, 21 May 2017 22:00:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49F46285C9 for ; Sun, 21 May 2017 22:00:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E743285DB; Sun, 21 May 2017 22:00:23 +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 DA2CA285F3 for ; Sun, 21 May 2017 22:00:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756944AbdEUWAW (ORCPT ); Sun, 21 May 2017 18:00:22 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:37159 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755502AbdEUWAV (ORCPT ); Sun, 21 May 2017 18:00:21 -0400 Received: by mail-wm0-f47.google.com with SMTP id d127so130113198wmf.0 for ; Sun, 21 May 2017 15:00:21 -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=kHUC/yXtZhspNJzHAtyfDqx+V7D3wE0yELHPSzHQdlQ=; b=bPuMDSzkN8DrRr4umtEj0n/3CGYr/BXBZ6cyxhcyLsjbp5nNHjhT58lN3xP7mxkd/B HyYGml17IiNYGtFGjBI0kYMn2cGuKnowZugVjrdyt9cFwEtXelekp283h4Dz6nCA9H4Y 7kBLWtKuT78RTYAIkqk9ohqodmUgqMPA+eQBvV5ns2EBa4wugNpexWJd5rJ9tZWUtrkl 3gYZ0Z2BwsWw+Y059nsT40wD1PPr98Tjmgn9sLEhCatEadpbgeyjPBcnxW8UoTpHbFOo m90fbptZBldzHSFE6gSefmKoxw8G/SKtTWJICDnjxeJ/WfmAdn6swVqvV0EMcO9dhc/M Ql3g== 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=kHUC/yXtZhspNJzHAtyfDqx+V7D3wE0yELHPSzHQdlQ=; b=sFsx+4Z80+m3C1/9oErt/BIKv7LcSJTz/gLKxWVl/Lnx3AKC1gqmm/dy3JUBqdnjFz /VkKH0jvcadsEWopnMbZQeW7wnN2aBebZnoZlkTaZvk/Rm13Swa4hHxfCzl2f85FAaTh F0h+6icuUJIB1kaimAL7w6rinhSCAUms1hqTUiZ8fT1+LlQwd7I7Fbf/rfp2H/n1FMD9 axDnxJE7/vfAqF7opENQhgA5YbU+S3soehfoupRHUMOo+l4+ePP0OY/5HwHKhJfUawvv bVojo49wOrd122CBAlo3XK9ok6JTRxcIgzxqpGDlBYbk6tAXAORa6U0aKc3LfARsMKH/ 8ORg== X-Gm-Message-State: AODbwcBipTBacZBNrYcyWJBNSC6B0SgnjjrjQIoSaRi8gcKtu1dmcOFU Zdmf5GuZ3HCTyqnW X-Received: by 10.28.146.2 with SMTP id u2mr12603725wmd.94.1495404020584; Sun, 21 May 2017 15:00:20 -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 a73sm12812579wrc.58.2017.05.21.15.00.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 May 2017 15:00:20 -0700 (PDT) From: Jerome Brunet To: Michael Turquette , Stephen Boyd , Kevin Hilman Cc: Jerome Brunet , linux-clk@vger.kernel.org, linux-amlogic@lists.infradead.org, Linus Walleij , Boris Brezillon Subject: [PATCH v2 07/11] clk: rollback set_rate_range changes on failure Date: Sun, 21 May 2017 23:59:54 +0200 Message-Id: <20170521215958.19743-8-jbrunet@baylibre.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170521215958.19743-1-jbrunet@baylibre.com> References: <20170521215958.19743-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 33ec990b2e97..71b0480a152b 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)