From patchwork Sat Oct 22 19:23:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Hunter X-Patchwork-Id: 685439 X-Patchwork-Delegate: treding@nvidia.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3t1XXl4VQRz9t0w for ; Sun, 23 Oct 2016 06:24:07 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755318AbcJVTYH (ORCPT ); Sat, 22 Oct 2016 15:24:07 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:12826 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755185AbcJVTYG (ORCPT ); Sat, 22 Oct 2016 15:24:06 -0400 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com id ; Sat, 22 Oct 2016 12:23:45 -0700 Received: from HQMAIL107.nvidia.com ([172.20.13.39]) by hqnvupgp07.nvidia.com (PGP Universal service); Sat, 22 Oct 2016 12:16:46 -0700 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Sat, 22 Oct 2016 12:16:46 -0700 Received: from HQMAIL103.nvidia.com (172.20.187.11) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Sat, 22 Oct 2016 19:24:05 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL103.nvidia.com (172.20.187.11) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Sat, 22 Oct 2016 19:24:05 +0000 Received: from dhcp-10-21-132-102.nvidia.com (Not Verified[10.26.11.248]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7, 5, 5, 8150) id ; Sat, 22 Oct 2016 12:24:04 -0700 From: Jon Hunter To: Stephen Warren , Thierry Reding , Alexandre Courbot CC: , Jon Hunter Subject: [PATCH 2/5] soc/tegra: pmc: Simplify IO rail bit handling Date: Sat, 22 Oct 2016 20:23:53 +0100 Message-ID: <1477164236-29351-3-git-send-email-jonathanh@nvidia.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1477164236-29351-1-git-send-email-jonathanh@nvidia.com> References: <1477164236-29351-1-git-send-email-jonathanh@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org The function tegra_io_rail_prepare() converts the IO rail ID into a bit position that is used to check the status and control the IO rail in the PMC registers. However, rather than converting to a bit position it is more useful to convert to a bit-mask because this is what is actually used. By doing so the BIT() marco only needs to be used once and we can use the IO_DPD_REQ_CODE_MASK when checking for erroneous rail IDs. Signed-off-by: Jon Hunter --- drivers/soc/tegra/pmc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c index c99580aabcf6..6a6df6e8bfd6 100644 --- a/drivers/soc/tegra/pmc.c +++ b/drivers/soc/tegra/pmc.c @@ -913,13 +913,13 @@ static int tegra_io_rail_prepare(unsigned int id, unsigned long *request, { unsigned long rate, value; - *bit = id % 32; + *bit = BIT(id % 32); /* * There are two sets of 30 bits to select IO rails, but bits 30 and * 31 are control bits rather than IO rail selection bits. */ - if (id > 63 || *bit == 30 || *bit == 31) + if (id > 63 || *bit & IO_DPD_REQ_CODE_MASK) return -EINVAL; if (id < 32) { @@ -979,9 +979,9 @@ int tegra_io_rail_power_on(unsigned int id) if (err) goto error; - tegra_pmc_writel(IO_DPD_REQ_CODE_OFF | BIT(bit), request); + tegra_pmc_writel(IO_DPD_REQ_CODE_OFF | bit, request); - err = tegra_io_rail_poll(status, BIT(bit), 0, 250); + err = tegra_io_rail_poll(status, bit, 0, 250); if (err) { pr_info("tegra_io_rail_poll() failed: %d\n", err); goto error; @@ -1010,9 +1010,9 @@ int tegra_io_rail_power_off(unsigned int id) goto error; } - tegra_pmc_writel(IO_DPD_REQ_CODE_ON | BIT(bit), request); + tegra_pmc_writel(IO_DPD_REQ_CODE_ON | bit, request); - err = tegra_io_rail_poll(status, BIT(bit), BIT(bit), 250); + err = tegra_io_rail_poll(status, bit, bit, 250); if (err) goto error;