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: 31227 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f197.google.com (mail-yk0-f197.google.com [209.85.160.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4EF4B20671 for ; Fri, 30 May 2014 20:54:19 +0000 (UTC) Received: by mail-yk0-f197.google.com with SMTP id 19sf6061121ykq.0 for ; Fri, 30 May 2014 13:54:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=c3dSzwsPjvFA4sMNCGj4c3J9tFgNqau2QcgvNzq65uU=; b=MK1P8BjcTGNkKqSeaiKdZ0OZ4ln9USoeu87MBbK944jb9mTC4uopko73lQNt6RM0qk XlsTidYBLwR0Rwew2RptSCr5DSLPaAMGi79g8X5s5hHxVBxsNHiTN0/aBspb/UdPYe0a Ndyy6UXygaJtldTG7lFi4hGGCnqN2IfKWptBfDBdL+hpRZ99O3qgPK3HKXMQiuRJe/Ey 8ftUzqwaL7BBfa4ULWMIEdcNEM9PHnzuNjvO4RwmpBEDHLZ20d8gIiocHxQ6p1nSzUKg KZiVrfX8vbuHnGCRGWZ2nXEEHYxs5pGVdyjusVUsQCrDWy1IJe+I3b992H3t0BY7CSiR dtQA== X-Gm-Message-State: ALoCoQmjhUSLLurAfZBQSm1fHkEoxD/yiYOeiIRLewRiXnAZaJ7PwpcUuHXtR/8TmDrtur998JHH X-Received: by 10.224.79.212 with SMTP id q20mr6786191qak.9.1401483259080; Fri, 30 May 2014 13:54:19 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.34.196 with SMTP id l62ls887781qgl.35.gmail; Fri, 30 May 2014 13:54:18 -0700 (PDT) X-Received: by 10.52.35.234 with SMTP id l10mr3812698vdj.61.1401483258916; Fri, 30 May 2014 13:54:18 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id s7si4088616vcl.50.2014.05.30.13.54.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 May 2014 13:54:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id hq11so746498vcb.39 for ; Fri, 30 May 2014 13:54:18 -0700 (PDT) X-Received: by 10.221.20.199 with SMTP id qp7mr16485250vcb.24.1401483258826; Fri, 30 May 2014 13:54:18 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp140979vcb; Fri, 30 May 2014 13:54:18 -0700 (PDT) X-Received: by 10.68.204.225 with SMTP id lb1mr21765779pbc.63.1401483258101; Fri, 30 May 2014 13:54:18 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h4si7016520pbw.231.2014.05.30.13.54.17; Fri, 30 May 2014 13:54:17 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934363AbaE3UxP (ORCPT + 28 others); Fri, 30 May 2014 16:53:15 -0400 Received: from mail-ig0-f180.google.com ([209.85.213.180]:51920 "EHLO mail-ig0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754460AbaE3UxN (ORCPT ); Fri, 30 May 2014 16:53:13 -0400 Received: by mail-ig0-f180.google.com with SMTP id c1so1331209igq.1 for ; Fri, 30 May 2014 13:53:12 -0700 (PDT) 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.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> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: elder@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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;