From patchwork Tue Mar 21 18:33:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 9637353 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 0B805601E9 for ; Tue, 21 Mar 2017 18:43:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0068A28304 for ; Tue, 21 Mar 2017 18:43:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E92EF28405; Tue, 21 Mar 2017 18:43: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 725D828304 for ; Tue, 21 Mar 2017 18:43:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933051AbdCUSlf (ORCPT ); Tue, 21 Mar 2017 14:41:35 -0400 Received: from mail-wr0-f169.google.com ([209.85.128.169]:32842 "EHLO mail-wr0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933027AbdCUSkm (ORCPT ); Tue, 21 Mar 2017 14:40:42 -0400 Received: by mail-wr0-f169.google.com with SMTP id u48so117549011wrc.0 for ; Tue, 21 Mar 2017 11:40:41 -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=IlObeAmBs+7UX533XrwwKhwVHOqg2ROJXgP9VcG/L2E=; b=TJiMtFOLhvGMaBVUy0ufestD1suXu4kkuysnTSlQR7kIc9F3M/YT9Yt/u24z82rVQV 4zQsWoiv2QsZkfNjwC/p3YlgteVKb3Hst2+qatr1a4XPXX5FShT9VpNMqzs2DxCnKAXn 1uiIh6f0M4R67wttCZ0AQ5guKZSf+o0Gd9oPndQ15TucO85wqxcPAi6bjmyUB8BxbZi6 xzNcjBKIHeh0hxXxa3uoWWcplubL4Nx5XNwEQYUkMUfaGHMyKBh1HUye7REyOTmtReND cIYjP3m8HWtxX/3HfkdsbVFOKh7u1wicHr6Mbj+4HBYpiwKyNu32WgV86Ehns5M4Djj5 21mA== 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=IlObeAmBs+7UX533XrwwKhwVHOqg2ROJXgP9VcG/L2E=; b=eLPvMe8kotKcDZ5L8eyLrGElEOM//0Dx36M8eMPJGJIrcN8Sa0tMxTd1QIYiH1msPw rd1ovaIipc9D2afvkKd4gFZXUkePGiFg2CLwYAGGBQUKoUYiUrN4+rc2Gzpyc4Q52TqC XO3dpInqFjypxcwLKsRnUjiRBkQXU5hrLqiGaoYHnkmA8C/uwp6K0vOggxgP80JgxC0C FVUOa5bbNwbgttynmOsP+Lr7+xcqbKoa5fBpauV5i7GGYDZxvvOdFsC6bxLJXEWxhxxW TVVcn0TCvBzeIiG2yv4/ZNBgkOsgauSH2P7ZmKV7D2VNKNgBg/8BtFloFMPTREC0vi2n cQYg== X-Gm-Message-State: AFeK/H2LJzEjVsgywwyiQrVtI2bWEr8Y+AstM5lRE+xDeQ+jCD/kmDwZXz9H6LnkbtkIkeCe X-Received: by 10.223.173.76 with SMTP id p70mr30386081wrc.168.1490121219853; Tue, 21 Mar 2017 11:33:39 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id q12sm18667504wmd.8.2017.03.21.11.33.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Mar 2017 11:33:39 -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 Subject: [RFC 5/7] clk: rollback set_rate_range changes on failure Date: Tue, 21 Mar 2017 19:33:28 +0100 Message-Id: <20170321183330.26722-6-jbrunet@baylibre.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170321183330.26722-1-jbrunet@baylibre.com> References: <20170321183330.26722-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 69db8cc15063..50798ef618d1 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1759,6 +1759,7 @@ EXPORT_SYMBOL_GPL(clk_set_rate); 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; @@ -1776,9 +1777,16 @@ int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max) clk_core_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_ucount)