From patchwork Fri May 30 20:53:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 4274021 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DE8E89F30B for ; Fri, 30 May 2014 20:55:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1EE3F203B0 for ; Fri, 30 May 2014 20:55:52 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0AD22201BC for ; Fri, 30 May 2014 20:55:51 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WqTo7-00036y-Is; Fri, 30 May 2014 20:53:43 +0000 Received: from mail-ie0-f172.google.com ([209.85.223.172]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WqTny-0002xh-6T for linux-arm-kernel@lists.infradead.org; Fri, 30 May 2014 20:53:34 +0000 Received: by mail-ie0-f172.google.com with SMTP id tp5so2284959ieb.31 for ; Fri, 30 May 2014 13:53:12 -0700 (PDT) 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=+A03BbN2FKVhB+YjxvNqwRia6W/JSbMQ/W1TTRVXztk=; b=COCnYK5TK+Mjs7bcM8C1iNnhoHtWy197xYbM60qmOZr2uAi4YE/01o+ZRxZSYWZewi VfCcQef/Tu+o5qblgp2rzAdqpjk88r/w/IHubj2zkE2YTxigNtcCSnyCNTBncwTu2rOU b88UKe3VrRv0sDWevNjYZTM6Y8U3EFh87ebMq8zrt3C/O90gHDYMvBT7OsO7Bd13zcvS ESuDGnMN18H2ipYErEz6ysr1USx+QZc6D/rdi8rjtO+7xC7LFHVKnAdVPe2ypG1yq407 EtEw4F7jNvyXNg4qqBS63tRJbBUvvkYdGoO1eSKB3nc2DUnVBEPYZId/D/FwdAg6s7JC FqSA== X-Gm-Message-State: ALoCoQlwOt2a/TgOnQQ03JqdgdrOlaE96eL8S2OazXEq+hkLU7mGU4IrbpX9hUceNBVBm8wbMFmR X-Received: by 10.50.143.107 with SMTP id sd11mr9056958igb.39.1401483192332; Fri, 30 May 2014 13:53:12 -0700 (PDT) Received: from localhost.localdomain (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPSA id b8sm8057705igx.3.2014.05.30.13.53.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 May 2014 13:53:11 -0700 (PDT) From: Alex Elder To: mturquette@linaro.org, mporter@linaro.org, bcm@fixthebug.org Subject: [PATCH v4 1/7] clk: kona: allow nested ccu_write_enable() requests Date: Fri, 30 May 2014 15:53:02 -0500 Message-Id: <1401483188-5395-2-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1401483188-5395-1-git-send-email-elder@linaro.org> References: <1401483188-5395-1-git-send-email-elder@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140530_135334_273966_686371FE X-CRM114-Status: GOOD ( 13.51 ) X-Spam-Score: -0.7 (/) Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use a counter rather than a Boolean to track whether write access to a CCU has been enabled or not. This will allow more than one of these requests to be nested. Note that __ccu_write_enable() and __ccu_write_disable() calls all come in pairs, and they are always surrounded immediately by calls to ccu_lock() and ccu_unlock(). Signed-off-by: Alex Elder --- drivers/clk/bcm/clk-kona.c | 14 ++++---------- drivers/clk/bcm/clk-kona.h | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c index 95af2e6..ee8e988 100644 --- a/drivers/clk/bcm/clk-kona.c +++ b/drivers/clk/bcm/clk-kona.c @@ -170,13 +170,8 @@ static inline void ccu_unlock(struct ccu_data *ccu, unsigned long flags) */ static inline void __ccu_write_enable(struct ccu_data *ccu) { - if (ccu->write_enabled) { - pr_err("%s: access already enabled for %s\n", __func__, - ccu->name); - return; - } - ccu->write_enabled = true; - __ccu_write(ccu, 0, CCU_ACCESS_PASSWORD | 1); + if (!ccu->write_enabled++) + __ccu_write(ccu, 0, CCU_ACCESS_PASSWORD | 1); } static inline void __ccu_write_disable(struct ccu_data *ccu) @@ -186,9 +181,8 @@ static inline void __ccu_write_disable(struct ccu_data *ccu) ccu->name); return; } - - __ccu_write(ccu, 0, CCU_ACCESS_PASSWORD); - ccu->write_enabled = false; + if (!--ccu->write_enabled) + __ccu_write(ccu, 0, CCU_ACCESS_PASSWORD); } /* diff --git a/drivers/clk/bcm/clk-kona.h b/drivers/clk/bcm/clk-kona.h index 2537b30..e9a8466 100644 --- a/drivers/clk/bcm/clk-kona.h +++ b/drivers/clk/bcm/clk-kona.h @@ -478,7 +478,7 @@ struct ccu_policy { struct ccu_data { void __iomem *base; /* base of mapped address space */ spinlock_t lock; /* serialization lock */ - bool write_enabled; /* write access is currently enabled */ + u32 write_enabled; /* write access enable count */ struct ccu_policy policy; struct list_head links; /* for ccu_list */ struct device_node *node;