From patchwork Tue Jun 21 23:43:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Rae X-Patchwork-Id: 638917 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3rZ47y4flvz9t0Y for ; Wed, 22 Jun 2016 09:44:30 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.b=Q+QVYEr8; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BA777A74FF; Wed, 22 Jun 2016 01:44:23 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Crn-ikMgEF3K; Wed, 22 Jun 2016 01:44:23 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E7C61A75C9; Wed, 22 Jun 2016 01:44:22 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1DC83A74F1 for ; Wed, 22 Jun 2016 01:44:16 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jk0rv-s04T_F for ; Wed, 22 Jun 2016 01:44:16 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com [209.85.220.53]) by theia.denx.de (Postfix) with ESMTPS id 10AE4A74E0 for ; Wed, 22 Jun 2016 01:44:12 +0200 (CEST) Received: by mail-pa0-f53.google.com with SMTP id b13so10728289pat.0 for ; Tue, 21 Jun 2016 16:44:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LEwiz0jSiejlF8ejiGroDyp6ip2yjIAOwoiq/pFQwbc=; b=Q+QVYEr8KTQ2MR+bSaY7LD1dxhhlEj1NYOFwsMw8XlPjKY3lq5QDS7YzBaKlj7Bncp 0PgPr4QD9odt8HZrSAwYZO9xDblJ2eZo8trda9Kg3e1xC8LHoZN78sFFjSfTA8CPkVUF m/3HHWBAdITiW/BtmIIIHHwjYVto+NeYuSPYc= 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=LEwiz0jSiejlF8ejiGroDyp6ip2yjIAOwoiq/pFQwbc=; b=KixNuRhtWPCTI9JECcUiIOJX6FPcrn8j6x/ucoXHxgElWjC8AIWRTn81vujPiE16V8 d8BrcvNrQSJLLJWqT2NKYGW3dtBLvKtEmdFSpwhxFkG7LVxmNaucUXkoX9KTHrEthft/ d6UmR3UDqyPPNWU441sVkB/CHY8U4kXEdgDl6gXNJU0MAQPaKLUkYW7hSDgrKATuImlH OC2eH8c0GND60ZS8aDRIUcAknULEC9hit2BMjzocFfXzTxmRGFMI22LWifCRQ+Z0H376 Qwrao2EZbKB9HIzvT1HGW/IkzJ/nquy/dYccguBQuop5O2oIf+048SGPy1s8cCNQW2yJ Flbw== X-Gm-Message-State: ALyK8tJjeLfzTIEgpH3jloyphoCme51Dk9DbtoKoe3SKj5PgdVFR3YsaQxogzIEpgiCDHt8N X-Received: by 10.66.182.194 with SMTP id eg2mr31308692pac.159.1466552650451; Tue, 21 Jun 2016 16:44:10 -0700 (PDT) Received: from VM-host64-64-A1.ric.broadcom.com ([216.31.219.19]) by smtp.gmail.com with ESMTPSA id 69sm58427246pfc.90.2016.06.21.16.44.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jun 2016 16:44:10 -0700 (PDT) From: Steve Rae To: u-boot@lists.denx.de Date: Tue, 21 Jun 2016 16:43:07 -0700 Message-Id: <1466552587-9953-5-git-send-email-srae@broadcom.com> X-Mailer: git-send-email 1.8.5 In-Reply-To: <1466552587-9953-1-git-send-email-srae@broadcom.com> References: <1466552587-9953-1-git-send-email-srae@broadcom.com> Cc: Steve Rae , Tom Rini Subject: [U-Boot] [PATCH 4/4] arm: bcm235xx: update clock framework X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The handling of the "usage counter" is incorrect, and the clock should only be disabled when transitioning from 1 to 0. Reported-by: Chris Brand Signed-off-by: Steve Rae --- arch/arm/cpu/armv7/bcm235xx/clk-core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm/cpu/armv7/bcm235xx/clk-core.c b/arch/arm/cpu/armv7/bcm235xx/clk-core.c index 2b5da6b..a326dfe 100644 --- a/arch/arm/cpu/armv7/bcm235xx/clk-core.c +++ b/arch/arm/cpu/armv7/bcm235xx/clk-core.c @@ -449,10 +449,9 @@ int clk_enable(struct clk *c) if (ret) return ret; - if (!c->use_cnt) { - c->use_cnt++; + if (!c->use_cnt) ret = c->ops->enable(c, 1); - } + c->use_cnt++; return ret; } @@ -464,9 +463,10 @@ void clk_disable(struct clk *c) if (!c->ops || !c->ops->enable) return; - if (c->use_cnt) { + if (c->use_cnt > 0) { c->use_cnt--; - c->ops->enable(c, 0); + if (c->use_cnt == 0) + c->ops->enable(c, 0); } /* disable parent */